16#include <Reordonner_faces_periodiques.h>
17#include <Partitionneur_Tranche.h>
18#include <TRUSTArray.h>
36template <
typename _SIZE_>
39 Cerr <<
"Partitionneur_Tranche_32_64<_SIZE_>::printOn invalid\n" << finl;
46template <
typename _SIZE_>
51 Cerr <<
" Error: the domain has not been associated" << finl;
60template <
typename _SIZE_>
65 if (min_array(nb_tranches_)<1)
67 Cerr <<
"Error for the cutting domain tool (Tranche) specifications : " <<finl;
68 Cerr<<
" the number of slice must be greater than 0 for each direction. " << finl;
76template <
typename _SIZE_>
79 ref_domaine_ = domaine;
80 nb_tranches_.resize(domaine.dimension);
89template <
typename _SIZE_>
94 assert(nb_tranches.
size_array() == nb_tranches_.size_array());
95 assert(min_array(nb_tranches) > 0);
97 nb_tranches_ = nb_tranches;
106template <
typename _SIZE_>
108 ArrOfInt& directions_perio)
110 Cerr <<
"Search of periodic directions of domain " << domaine.
le_nom() << finl;
112 const Noms& liste_bords_perio = domaine.bords_perio();
115 directions_perio = 0;
116 for (
auto& itr : liste_bords_perio)
119 const Nom& nom_bord = itr;
120 const int nb_bords = domaine.nb_bords();
121 while (num_bord < nb_bords)
123 if (domaine.bord(num_bord).le_nom() == nom_bord)
127 if (num_bord == nb_bords)
129 Cerr <<
"Error in Partitionneur_Tranche_32_64<_SIZE_>::chercher_direction_perio\n"
130 <<
" boundary not found : " << nom_bord << finl;
138 for (
int j = 0; j < dim; j++)
140 if (std::abs(delta[j]) > epsilon)
142 directions_perio[j]++;
143 Cerr <<
" Boundary : " << nom_bord <<
" periodic direction : " << j << finl;
149 Cerr <<
"Error in Partitionneur_Tranche_32_64<_SIZE_>::chercher_direction_perio" << finl;
150 Cerr <<
" periodic direction not found for the boundary " << nom_bord << finl;
151 Cerr <<
" Vector delta found between faces twin : " << delta << finl;
152 Cerr <<
" with a maximum error : " << erreur << finl;
153 Cerr <<
"TIP: Try to add 'declare_only' flag into declare_bord_perio block or switch to metis tool" << finl;
157 if (max_array(directions_perio) > 1)
159 Cerr <<
"Error in Partitionneur_Tranche_32_64<_SIZE_>::chercher_direction_perio" << finl;
160 Cerr <<
" several boundaries have the same periodic direction" << finl;
165template <
typename _SIZE_>
168 using DoubleTab_t = DoubleTab_T<_SIZE_>;
170 assert(ref_domaine_);
171 assert(nb_tranches_[0] > 0);
173 const Domaine_t& dom = ref_domaine_.valeur();
180 ArrOfInt directions_perio;
184 Cerr <<
"Calculation of centers of gravity of the elements" << finl;
187 assert(coord_g.dimension(0) == nb_elem);
188 assert(coord_g.dimension(1) == dim);
190 Cerr <<
"Moving of centers of gravity" << finl;
194 for (
int_t i = 0; i < nb_elem; i++)
196 double x = coord_g(i,0);
197 double y = coord_g(i,1);
198 double z = (dim == 3) ? coord_g(i,2) : 0.;
199 coord_g(i,0) = x + y*1e-6 + z*1e-12;
200 coord_g(i,1) = y + x*1e-6 + z*1e-12;
202 coord_g(i,2) = z + x*1e-6 + y*1e-12;
208 SmallArrOfTID_T<_SIZE_> nb_elem_part(1);
209 nb_elem_part= nb_elem;
218 for (
int_t i = 0; i < nb_elem; i++)
221 SmallArrOfTID_T<_SIZE_> new_nb_elem_part;
240 for (
int direction = 0; direction < dim; direction++)
243 const int nb_tranches = nb_tranches_[direction];
245 int_t index_debut_partie = 0;
247 const int nb_parts = nb_elem_part.
size_array();
249 Cerr <<
"The mesh contains " << nb_parts <<
" parts. ";
250 Cerr <<
"Splitting in the direction " << direction << finl;
254 for (
int part = 0; part < nb_parts; part++)
256 Cerr <<
" Splitting of subpart " << part << finl;
259 const int_t nb_elem_partie = nb_elem_part[part];
260 assert(index_debut_partie >= 0 && index_debut_partie + nb_elem_partie <= nb_elem);
261 index.
ref_data(listes_elem.
addr()+index_debut_partie, nb_elem_partie);
267 return ( coord_g(a,direction)<coord_g(b,direction) );
273 if (directions_perio[direction])
277 int_t j = nb_elem_partie/(nb_tranches*2);
278 for (
int i = 0; i < nb_elem_partie; i++)
280 index[j++] = copie[i];
281 if (j >= nb_elem_partie)
289 for (
int i = 0; i < nb_tranches; i++)
292 const long long new_n0 = (
long long)nb_elem_partie * (
long long)(i+1) / (
long long)nb_tranches;
293 assert(new_n0 < std::numeric_limits<_SIZE_>::max());
299 index_debut_partie += nb_elem_partie;
302 nb_elem_part = new_nb_elem_part;
306 elem_part.
resize(nb_elem);
309 const int nb_parts = nb_elem_part.
size_array();
310 int_t index_fin = 0, i = 0;
311 for (
int part = 0; part < nb_parts; part++)
313 index_fin += nb_elem_part[part];
314 for (; i < index_fin; i++)
316 const int_t elem = listes_elem[i];
317 elem_part[elem] = part;
321 if (ref_domaine_->bords_perio().size() > 0)
324 Cerr <<
"Correction elem0 on processor 0" << finl;
void calculer_centres_gravite(DoubleTab_t &xp) const
Calcule les centres de gravites des elements du domaine.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Un tableau de chaine de caracteres (VECT(Nom)).
virtual void set_param(Param &) const
static double precision_geom
virtual const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Helper class to factorize the readOn method of Objet_U classes.
void ajouter_arr_size_predefinie(const char *keyword, const ArrOfInt *value, Param::Nature nat=Param::OPTIONAL)
Register an ArrOfInt whose size has already been fixed.
Partitionneur de domaine en tranches paralleles aux directions de l'espace.
void validate_params() const override
La syntaxe est { Tranches nx ny [ nz ] }.
static void chercher_direction_perio(const Domaine_t &domaine, ArrOfInt &directions_perio)
Remplissage du tableau directions perio a partir des noms des bords periodiques.
void associer_domaine(const Domaine_t &domaine) override
Premiere etape d'initialisation du partitionneur: on associe un domaine.
Domaine_32_64< _SIZE_ > Domaine_t
void construire_partition(BigIntVect_ &elem_part, int &nb_parts_tot) const override
void initialiser(const ArrOfInt &nb_tranches)
Deuxieme etape d'initialisation: on definit le nombre de tranches.
ArrOfInt_T< _SIZE_ > ArrOfInt_t
TRUSTVect< int, _SIZE_ > BigIntVect_
Classe de base des partitionneurs de domaine (pour decouper un maillage avant un calcul parallele).
static void corriger_bords_avec_liste(const Domaine_t &dom, const int_t my_offset, BigIntVect_ &elem_part)
Calcul des graphes de connectivite elements periodiques et appel a corriger_periodique_avec_graphe.
static void corriger_elem0_sur_proc0(BigIntVect_ &elem_part)
corrige la partition pour que l'element 0 du domaine initial se trouve sur le premier sous-domaine de...
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
static int check_faces_periodiques(const Frontiere_32_64< _SIZE_ > &frontiere, ArrOfDouble &vecteur_delta, ArrOfDouble &erreur, bool verbose=false)
essaie de verifier si les faces du bord num_bord sont ordonnees suivant la convention des faces perio...
Classe de base des flux de sortie.
void append_array(_TYPE_ valeur)
_SIZE_ size_array() const
TRUSTArray & inject_array(const TRUSTArray &source, _SIZE_ nb_elements=-1, _SIZE_ first_element_dest=0, _SIZE_ first_element_source=0)
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
virtual void ref_data(_TYPE_ *ptr, _SIZE_ size)
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)