16#include <VDF_to_IJK.h>
17#include <Schema_Comm_Vecteurs.h>
18#include <Schema_Comm.h>
19#include <communications.h>
20#include <Domaine_VF.h>
23#include <Array_tools.h>
27static void pack_lists(
const VECT(ArrOfInt) & src, ArrOfInt& non_empty, Static_Int_Lists& dest)
31 const int nmax = src.size();
32 for (
int i = 0; i < nmax; i++)
33 if (src[i].size_array() > 0)
36 VECT(ArrOfInt) tmp(n);
41 for (
int i = 0; i < nmax; i++)
43 if (src[i].size_array() > 0)
59static int bsearch_double(
const ArrOfDouble& tab,
double valeur)
68 assert(j == tab.
size_array() || tab[i] <= tab[j]);
69 const int milieu = (i + j) / 2;
70 const double val = tab[milieu];
85 return domaine_vf.
xp();
91 return domaine_vf.
xv();
101 Cerr <<
"VDF_to_IJK::initialize localisation=" << (int)localisation << finl;
110 VECT(ArrOfInt) slice_offsets(3);
111 VECT(ArrOfInt) slice_size(3);
116 for (
int i = 0; i < 3; i++)
128 for (pe = 0; pe < np; pe++)
134 VECT(IntTab) all_data(np);
135 for (
int pe = 0; pe < np; pe++)
138 all_data[pe].resize(0,2);
141 int srccomponent_for_direction[3];
142 srccomponent_for_direction[direction_for_x] = 0;
143 srccomponent_for_direction[direction_for_y] = 1;
144 srccomponent_for_direction[direction_for_z] = 2;
150 const DoubleTab& coords = get_items_coords(domaine_vf, localisation, nb_items);
151 const IntVect& orientation = domaine_vf.
orientation();
155 for (
int item_index = 0; item_index < nb_items; item_index++)
157 if (localisation ==
Domaine_IJK::FACES_I && orientation[item_index] != srccomponent_for_direction[0])
159 else if (localisation ==
Domaine_IJK::FACES_J && orientation[item_index] != srccomponent_for_direction[1])
161 else if (localisation ==
Domaine_IJK::FACES_K && orientation[item_index] != srccomponent_for_direction[2])
165 coord[direction_for_x] = coords(item_index, 0) + eps;
166 coord[direction_for_y] = coords(item_index, 1) + eps;
167 coord[direction_for_z] = coords(item_index, 2) + eps;
170 ijk[0] = bsearch_double(all_coord_i, coord[0]);
171 ijk[1] = bsearch_double(all_coord_j, coord[1]);
172 ijk[2] = bsearch_double(all_coord_k, coord[2]);
176 int local_ijk_size[3];
177 int local_ijk_index[3];
178 for (
int i = 0; i < 3; i++)
183 int idx = slice_offsets[i].size_array()-1;
184 while (slice_offsets[i][idx] > ijk[i])
186 slice_index[i] = idx;
187 local_ijk_size[i] = slice_size[i][idx];
188 local_ijk_index[i] = ijk[i] - slice_offsets[i][idx];
191 int pe = mapping(slice_index[0], slice_index[1], slice_index[2]);
193 int local_index = (local_ijk_index[2] * local_ijk_size[1] + local_ijk_index[1]) * local_ijk_size[0] + local_ijk_index[0];
195 all_data[pe].append_line(local_index, item_index);
198 VECT(ArrOfInt) to_send(np);
199 for (
int pe = 0; pe < np; pe++)
201 tri_lexicographique_tableau(all_data[pe]);
202 const int n = all_data[pe].dimension(0);
204 Cerr <<
"VDF_to_IJK::initialize localisation=" << (int)localisation
205 <<
" found " << n <<
" items to send to processor " << pe << finl;
207 for (
int i = 0; i < n; i++)
209 buf << all_data[pe](i,0);
210 to_send[pe].append_array(all_data[pe](i,1));
214 VECT(ArrOfInt) to_recv(np);
215 for (
int pe = 0; pe < np; pe++)
220 for (
int pe = 0; pe < np; pe++)
230 to_recv[pe].append_array(val);
232 if (to_recv[pe].size_array() > 0)
233 Cerr <<
"VDF_to_IJK::initialize localisation=" << (int)localisation
234 <<
" found " << to_recv[pe].size_array() <<
" items to receive from processor " << pe << finl;
DoubleTab_t & les_sommets()
int_t nb_som() const
Renvoie le nombre de sommets du domaine.
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
int get_nb_elem_local(int direction) const
Returns the number of elements owned by this processor in the given direction.
void get_processor_mapping(IntTab &mapping) const
Fills an array containing the mapping of processors.
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...
const ArrOfDouble & get_node_coordinates(int direction) const
Returns an array with the coordinates of all nodes in the mesh in requested direction.
Localisation
Localisation sub class.
int nb_faces() const
renvoie le nombre global de faces.
double xv(int num_face, int k) const
virtual const IntVect & orientation() const
double xp(int num_elem, int k) const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
static double precision_geom
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static int me()
renvoie mon rang dans le groupe de communication courant.
void echange_taille_et_messages() const
Cette methode lance l'echange de donnees entre tous les processeurs.
Sortie & send_buffer(int num_PE) const
renvoie le buffer correspondant au processeur num_PE pour y entasser des donnees a envoyer.
void end_comm() const
Vide les buffers et libere les ressources: on a fini de lire les donnees recues dans les buffers.
Entree & recv_buffer(int num_PE) const
renvoie le buffer correspondant au processeur num_PE pour y lire les donnees recues.
void begin_comm() const
Reserve les buffers de comm pour une nouvelle communication.
void set_send_recv_pe_list(const ArrOfInt &send_pe_list, const ArrOfInt &recv_pe_list, const int me_to_me=0)
Definit la liste des processeurs a qui on va envoyer et de qui on va recevoir des donnees.
Classe de base des flux de sortie.
void set(const ArrsOfInt_t &src)
void append_array(_TYPE_ valeur)
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Static_Int_Lists pe_recv_data_
void initialize(const Domaine_VF &domaine_vf, const Domaine_IJK &splitting, Domaine_IJK::Localisation localisation, int direction_for_x, int direction_for_y, int direction_for_z)
Static_Int_Lists pe_send_data_