16#include <Partitionneur_Sous_Domaines.h>
17#include <Synonyme_info.h>
19#include <Sous_Domaines.h>
21#include <Interprete.h>
32Partitionneur_Sous_Domaines::Partitionneur_Sous_Domaines()
39 Cerr <<
"Partitionneur_Sous_Domaines::printOn invalid\n" << finl;
56 Cerr <<
" Error: the domain has not been associated" << finl;
59 param.
ajouter(
"sous_zones",&noms_sous_domaines_);
61 param.
ajouter(
"domaines",&noms_domaines_);
70 ref_domaine_ = domaine;
81 noms_sous_domaines_ = noms_sous_domaines;
99 const Domaine& dom = ref_domaine_.valeur();
101 elem_part.
resize(nb_elem);
103 if (noms_domaines_.size()!=0 && noms_sous_domaines_.size())
105 Cerr <<
"Can't mix sous_domaines and domaines yet in sous_domaines partitionner." << finl;
111 if (noms_domaines_.size()!=0)
113 for (
int i=0; i<noms_domaines_.size(); i++)
115 const Nom& nom_domaine = noms_domaines_[i];
116 if (!
interprete().objet_existant(nom_domaine) || !sub_type(Domaine,
interprete().objet(nom_domaine)))
119 Cerr <<
"Domain " << nom_domaine <<
" is not existing." << finl;
123 const Domaine& domaine = ref_cast(Domaine,
interprete().objet(nom_domaine));
124 DoubleTab domaine_xp;
125 domaine.calculer_centres_gravite(domaine_xp);
126 IntVect dom_cells_containing_domaine_cells;
128 Cerr <<
" Allocation of elements of the domain " << domaine.
le_nom() <<
" to the processor " << pe << finl;
129 for (
int cell = 0; cell < dom_cells_containing_domaine_cells.
size(); cell++)
131 int elem = dom_cells_containing_domaine_cells[cell];
132 if (elem_part[elem] < 0)
135 elem_part[elem] = pe;
138 Cerr <<
" Number of elements attributed to the processor " << pe <<
" : " << count << finl;
144 Noms noms_sous_domaines(noms_sous_domaines_);
149 noms_sous_domaines.dimensionner_force(liste.size());
150 for (
int i=0; i<liste.size(); i++) noms_sous_domaines[i]=liste[i].
le_nom();
153 const int toutes_sous_domaines = (noms_sous_domaines.size() == 0);
154 if (toutes_sous_domaines)
155 Cerr <<
" No subarea specified, we use all existing subareas." << finl;
156 for (
int i_sous_domaine = 0; i_sous_domaine < nb_sous_domaines; i_sous_domaine++)
158 const Sous_Domaine& sous_domaine = dom.
ss_domaine(i_sous_domaine);
160 bool sous_domaine_trouvee = noms_sous_domaines.
contient_(nom);
161 if (!toutes_sous_domaines && !sous_domaine_trouvee)
165 const int nb_elem_ssz = sous_domaine.
nb_elem_tot();
166 for (
int i = 0; i < nb_elem_ssz; i++)
168 const int elem = sous_domaine[i];
169 if (elem_part[elem] < 0)
172 elem_part[elem] = pe;
175 Cerr <<
" Allocation of " << count <<
" elements from the subarea " << nom <<
" to the processor " << pe << finl;
180 for (
int elem = 0; elem < nb_elem; elem++)
182 if (elem_part[elem] < 0)
185 elem_part[elem] = pe;
188 if (count>0) Cerr <<
" Allocation of the remaining " << count <<
" elements to the processor " << pe << finl;
196 if (ref_domaine_->bords_perio().size() > 0)
const Sous_Domaine_t & ss_domaine(int i) const
int_t nb_elem_tot() const
SmallArrOfTID_t & chercher_elements(const DoubleTab &pos, SmallArrOfTID_t &elem, int reel=0) const
Searches for the elements containing the points whose coordinates are specified.
int nb_ss_domaines() const
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
class Nom: a character string for naming TRUST objects.
An array of character strings (VECT(Nom)).
int contient_(const char *const ch) const
virtual void set_param(Param &) const
const Interprete & interprete() const
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Helper class to factorize the readOn method of Objet_U classes.
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Domain partitioner based on sub-domains of the domain. See construire_partition().
void associer_domaine(const Domaine &domaine) override
First initialisation step of the partitioner: associate a domain.
void initialiser(const Noms &noms_sous_domaines)
Second initialisation step: define the sub-domains to use.
void construire_partition(IntVect &elem_part, int &nb_parts_tot) const override
Each sub-domain in noms_sous_domaines_ defines the elements assigned to a processor.
static void corriger_bords_avec_liste(const Domaine_t &dom, const int_t my_offset, BigIntVect_ &elem_part)
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
int_t nb_elem_tot() const
A vector of Sous_Domaine (VECT(Sous_Domaine)).
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)