32 const VECT(IntTab) & redistribute_maps)
36 for (
int dir = 0; dir < 3; dir++)
38 if (redistribute_maps.
size() == 0)
46 Cerr <<
"Error in Redistribute_Field::initialize: you must provide a redistribute map" << finl;
52 map = redistribute_maps[dir];
56 for (
int i = 0; i < map.
dimension(0); i++)
71 int receive_size_buffer_for_me = 0;
75 for (ibloc[2] = 0; ibloc[2] < send_blocs[2].dimension(0); ibloc[2] ++)
76 for (ibloc[1] = 0; ibloc[1] < send_blocs[1].dimension(0); ibloc[1] ++)
77 for (ibloc[0] = 0; ibloc[0] < send_blocs[0].dimension(0); ibloc[0] ++)
79 const int dest_slice_i = send_blocs[0](ibloc[0], 1);
80 const int ni = send_blocs[0](ibloc[0], 2);
81 const int dest_slice_j = send_blocs[1](ibloc[1], 1);
82 const int nj = send_blocs[1](ibloc[1], 2);
83 const int dest_slice_k = send_blocs[2](ibloc[2], 1);
84 const int nk = send_blocs[2](ibloc[2], 2);
94 for (ibloc[2] = 0; ibloc[2] < recv_blocs[2].dimension(0); ibloc[2] ++)
95 for (ibloc[1] = 0; ibloc[1] < recv_blocs[1].dimension(0); ibloc[1] ++)
96 for (ibloc[0] = 0; ibloc[0] < recv_blocs[0].dimension(0); ibloc[0] ++)
98 const int src_slice_i = recv_blocs[0](ibloc[0], 1);
99 const int ni = recv_blocs[0](ibloc[0], 2);
100 const int src_slice_j = recv_blocs[1](ibloc[1], 1);
101 const int nj = recv_blocs[1](ibloc[1], 2);
102 const int src_slice_k = recv_blocs[2](ibloc[2], 1);
103 const int nk = recv_blocs[2](ibloc[2], 2);
109 receive_size_buffer_for_me += ni*nj*nk;
114 Cerr <<
"Internal error in Redistribute_Field::initialize (size_buffer_for_me)" << finl;
160 const IntTab& global_index_mapping,
164 ArrOfInt output_slice_offsets;
165 ArrOfInt output_slice_size;
174 const int n_segments = global_index_mapping.
dimension(0);
175 for (
int i_segment = 0; i_segment < n_segments; i_segment++)
177 int input_seg_start = global_index_mapping(i_segment, 0);
178 int output_seg_start = global_index_mapping(i_segment, 1);
179 int seg_length = global_index_mapping(i_segment, 2);
182 intersect(input_slice_start, input_slice_size, input_seg_start, seg_length, output_seg_start);
185 const int nb_output_slices = output_slice_offsets.
size_array();
186 for (
int oslice = 0; oslice < nb_output_slices; oslice++)
188 int input_start = input_seg_start;
189 int output_start = output_seg_start;
192 intersect(output_slice_offsets[oslice], output_slice_size[oslice], output_start, n, input_start);
195 const int input_start_local = input_start - input_slice_start;
196 send_blocs.
append_line(input_start_local, oslice, n);
203 IJK_Field_double& output_field,
206 statistics().create_custom_counter(
"Redistribute",2,
"IJK");
207 statistics().begin_count(
"Redistribute",statistics().get_last_opened_counter_level()+1);
219 ArrOfDouble buffer_for_me;
222 int index_buffer_for_me = 0;
225 for (ibloc[2] = 0; ibloc[2] < send_blocs[2].dimension(0); ibloc[2] ++)
226 for (ibloc[1] = 0; ibloc[1] < send_blocs[1].dimension(0); ibloc[1] ++)
227 for (ibloc[0] = 0; ibloc[0] < send_blocs[0].dimension(0); ibloc[0] ++)
229 const int input_i_start = send_blocs[0](ibloc[0], 0);
230 const int dest_slice_i = send_blocs[0](ibloc[0], 1);
231 const int ni = send_blocs[0](ibloc[0], 2);
232 const int input_j_start = send_blocs[1](ibloc[1], 0);
233 const int dest_slice_j = send_blocs[1](ibloc[1], 1);
234 const int nj = send_blocs[1](ibloc[1], 2);
235 const int input_k_start = send_blocs[2](ibloc[2], 0);
236 const int dest_slice_k = send_blocs[2](ibloc[2], 1);
237 const int nk = send_blocs[2](ibloc[2], 2);
241 ArrOfDouble *buf_ptr;
245 tmp.
ref_array(buffer_for_me, index_buffer_for_me , ni*nj*nk );
246 index_buffer_for_me += ni*nj*nk;
254 ArrOfDouble& buf = *buf_ptr;
256 for (
int k = 0; k < nk; k++)
258 for (
int j = 0; j < nj; j++)
260 for (
int i = 0; i < ni; i++)
262 buf[k*nj*ni + j*ni + i] = input_field(i + input_i_start, j + input_j_start, k + input_k_start);
270 index_buffer_for_me = 0;
272 for (ibloc[2] = 0; ibloc[2] < recv_blocs[2].dimension(0); ibloc[2] ++)
273 for (ibloc[1] = 0; ibloc[1] < recv_blocs[1].dimension(0); ibloc[1] ++)
274 for (ibloc[0] = 0; ibloc[0] < recv_blocs[0].dimension(0); ibloc[0] ++)
276 const int output_i_start= recv_blocs[0](ibloc[0], 0);
277 const int src_slice_i = recv_blocs[0](ibloc[0], 1);
278 const int ni = recv_blocs[0](ibloc[0], 2);
279 const int output_j_start= recv_blocs[1](ibloc[1], 0);
280 const int src_slice_j = recv_blocs[1](ibloc[1], 1);
281 const int nj = recv_blocs[1](ibloc[1], 2);
282 const int output_k_start= recv_blocs[2](ibloc[2], 0);
283 const int src_slice_k = recv_blocs[2](ibloc[2], 1);
284 const int nk = recv_blocs[2](ibloc[2], 2);
287 ArrOfDouble *buf_ptr;
291 tmp.
ref_array(buffer_for_me, index_buffer_for_me , ni*nj*nk );
292 index_buffer_for_me += ni*nj*nk;
300 ArrOfDouble& buf = *buf_ptr;
302 for (
int k = 0; k < nk; k++)
304 for (
int j = 0; j < nj; j++)
306 for (
int i = 0; i < ni; i++)
308 output_field(i + output_i_start, j + output_j_start, k + output_k_start) = buf[k*nj*ni + j*ni + i];
313 for (
int k = 0; k < nk; k++)
315 for (
int j = 0; j < nj; j++)
317 for (
int i = 0; i < ni; i++)
319 output_field(i + output_i_start, j + output_j_start, k + output_k_start) += buf[k*nj*ni + j*ni + i];
325 statistics().end_count(
"Redistribute");
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
int get_offset_local(int direction) const
Returns the local offset in requested direction.
int get_processor_by_ijk(const FixedVector< int, 3 > &slice) const
Return the global index of the processor according to its position.
int get_nb_items_local(Localisation loc, int direction) const
Returns the number of local items (on this processor) for the given localisation in the requested dir...
void get_slice_offsets(int direction, ArrOfInt &tab) const
Returns the indices of the first cell in requested direction of every slices in this direction.
int get_nb_items_global(Localisation loc, int direction) const
Returns the number of local items (on this processor) for the given localisation in the requested dir...
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...