15#ifndef Coarsen_Operator_Uniform_TPP_H
16#define Coarsen_Operator_Uniform_TPP_H
18#include <Domaine_IJK.h>
19#include <Perf_counters.h>
21template<
typename _TYPE_>
24 int additional_k_layers)
26 const Domaine_IJK& src_grid_geom = fine.
get_domaine();
27 VECT(ArrOfDouble) coarse_delta(3);
30 for (
int dir = 0; dir < 3; dir++)
33 const ArrOfDouble& fine_delta = src_grid_geom.
get_delta(dir);
36 if (src_n % coarsen_factor != 0)
38 Cerr <<
"Coarsen_Operator_Uniform::initialize_grid_data: source grid has " << src_n
39 <<
" elements in direction " << dir
40 <<
" and cannot be refined by factor " << coarsen_factor << finl;
44 if (nlocal[dir] % coarsen_factor != 0)
46 Cerr <<
"Coarsen_Operator_Uniform::initialize_grid_data: local source grid processor has " << nlocal[dir]
47 <<
" elements in direction " << dir
48 <<
" and cannot be refined by factor " << coarsen_factor << finl;
51 nlocal[dir] /= coarsen_factor;
52 const int n = src_n / coarsen_factor;
53 ArrOfDouble& delta = coarse_delta[dir];
58 for (
int dest_index = 0; dest_index < n; dest_index++)
61 for (
int j = 0; j < coarsen_factor; j++)
63 d += fine_delta[src_index];
66 delta[dest_index] = d;
70 Domaine_IJK grid_geom;
81 Domaine_IJK coarse_splitting;
83 IntTab processor_mapping;
86 VECT(ArrOfInt) slice_sizes(3);
87 for (
int dir = 0; dir < 3; dir++)
90 const int n = slice_sizes[dir].size_array();
91 for (
int i = 0; i < n; i++)
94 coarse_splitting.
initialize_mapping(grid_geom, slice_sizes[0], slice_sizes[1], slice_sizes[2],
97 coarse.
initialize(coarse_splitting, ghost_domaine_size, additional_k_layers);
100template <
typename _TYPE_,
typename _TYPE_ARRAY_>
103 int compute_weighted_average)
const
106 statistics().
begin_count(
"multigrid: uniform coarsening",statistics().get_last_opened_counter_level()+1);
107 const int ni2 = coarse.
ni();
108 const int nj2 = coarse.
nj();
109 const int nk2 = coarse.
nk();
112 if (compute_weighted_average)
115 const int Kstart = 0;
116 const int Kend = nk2;
117 const int deltaK = 1;
118 for (
int K = Kstart; K != Kend; K += deltaK)
121 for (
int J = 0; J < nj2; J++)
124 for (
int I = 0; I < ni2; I++)
131 sum += fine(i + ii, j + jj, k + kk);
132 coarse(I,J,K) = sum * coef;
137 statistics().
end_count(
"multigrid: uniform coarsening");
141template <
typename _TYPE_,
typename _TYPE_ARRAY_>
144 const int kshift)
const
148 Cerr <<
"error Coarsen_Operator_Uniform: kshift=1 will not work" << finl;
153 statistics().
begin_count(
"multigrid: interpolate uniform",statistics().get_last_opened_counter_level()+1);
155 const int ni2 = coarse.
ni();
156 const int nj2 = coarse.
nj();
157 const int nk2 = coarse.
nk();
159 const int Kstart = kshift <= 0 ? 0 : nk2 - 1;
160 const int Kend = kshift <= 0 ? nk2 : -1;
161 const int deltaK = kshift <= 0 ? 1 : -1;
163 for (
int K = Kstart; K != Kend; K += deltaK)
166 for (
int J = 0; J < nj2; ++J)
169 for (
int I = 0; I < ni2; ++I)
172 const _TYPE_ val = coarse(I, J, K);
182 statistics().
end_count(
"multigrid: interpolate uniform");
bool get_periodic_flag(int direction) const
Method returns true if periodic in this direction.
void get_processor_mapping(IntTab &mapping) const
Fills an array containing the mapping of processors.
const ArrOfDouble & get_delta(int direction) const
Returns the array of mesh cell sizes in requested direction.
double get_origin(int direction) const
Returns the coordinate of the first node (global) of the mesh in the requested direction.
void initialize_mapping(Domaine_IJK &dom, const ArrOfInt &slice_size_i, const ArrOfInt &slice_size_j, const ArrOfInt &slice_size_k, const IntTab &processor_mapping)
Creates a splitting of the domain by specifying the slice sizes and the processor mapping.
void get_slice_size(int direction, Localisation loc, ArrOfInt &tab) const
Returns the number of items of given location (elements, nodes, faces...) for all slices in the reque...
void initialize_origin_deltas(double x0, double y0, double z0, const ArrOfDouble &delta_x, const ArrOfDouble &delta_y, const ArrOfDouble &delta_z, bool perio_x, bool perio_y, bool perio_z)
Initializes class elements given dataset's parameters.
const IJK_Field_template< _TYPE_, TRUSTArray< _TYPE_ > > & get_rho() const
int get_ghost_size() const
void initialize(const Domaine_IJK &, int ghost, int additional_k_layers)
const Domaine_IJK & get_domaine() const
_TYPE_ & get_in_allocated_area(int i, int j, int k)
int nb_elem_local(int dir) const
void shift_k_origin(int n)
: This class is an IJK_Field_local with parallel informations.
void begin_count(const STD_COUNTERS &std_cnt, int counter_lvl=-100000)
void end_count(const std::string &custom_count_name, int count_increment=1, long int quantity_increment=0)
End the count of a counter and update the counter values.
void create_custom_counter(std::string counter_description, int counter_level, std::string counter_family="None", bool is_comm=false, bool is_gpu=false)
Create a new counter and add it to the map of custom counters.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)