15#include <Partitionneur_Ptscotch.h>
17#include <Static_Int_Lists.h>
18#include <ptscotch++.h>
20#include <Domain_Graph.h>
21#include <communications.h>
22#include <Poly_geom_base.h>
23#include <Matrix_tools.h>
24#include <Matrice_Morse.h>
25#include <Array_tools.h>
26#include <Comm_Group_MPI.h>
27#include <MD_Vector_tools.h>
30inline void not_implemented(
const Nom& chaine)
32 Cerr << chaine <<
" is not implemented yet to the Ptscotch API." << finl;
36Implemente_instanciable_sans_constructeur(
Partitionneur_Ptscotch,
"Partitionneur_Ptscotch",Partitionneur_base);
38Partitionneur_Ptscotch::Partitionneur_Ptscotch()
44 Cerr <<
"Partitionneur_Ptscotch::printOn invalid\n" << finl;
53 param.
ajouter_condition(
"(value_of_nb_parts_ge_1)_and_(value_of_nb_parts_le_100000)",
"The following condition must be satisfied : 1 <= nb_parties <= 100000");
64 ref_domaine_ = domaine;
73 Cerr <<
"Ptscotch is not compiled with this version. Use another partition tool like Tranche." << finl;
78 Cerr <<
"Error in Partitionneur_Ptscotch::construire_partition\n";
79 Cerr <<
" The domain has not been associated" << finl;
84 Cerr <<
"Error in Partitionneur_Ptscotch::construire_partition\n";
85 Cerr <<
" The parts number has not been initialized" << finl;
94 int nb_elem = ref_domaine_->nb_elem();
100 if (ref_domaine_->nb_elem() == 0)
103 Cerr <<
"Partitionneur_Ptscotch::construire_partition" << finl;
104 Cerr <<
" Construction of graph connectivity..." << finl;
105 Static_Int_Lists graph_elements_perio;
110 graph_elements_perio);
113 const int n = ref_domaine_->nb_elem();
114 SCOTCH_Num* partition =
new SCOTCH_Num[n];
116 SCOTCH_randomReset();
117 SCOTCH_Dgraph scotch_graph;
118 SCOTCH_dgraphInit(&scotch_graph, Comm_Group_MPI::get_trio_u_world());
119 SCOTCH_dgraphBuild(&scotch_graph,
132 SCOTCH_Strat scotch_strategy;
133 SCOTCH_stratInit(&scotch_strategy);
135 SCOTCH_dgraphPart(&scotch_graph,nb_parties_,&scotch_strategy,partition);
137 SCOTCH_stratExit(&scotch_strategy);
138 SCOTCH_dgraphExit(&scotch_graph);
141 for (
int i = 0; i < n; i++)
142 elem_part[i] =
static_cast<int>(partition[i]);
149 Cerr <<
"Correction of the partition for the periodicity" << finl;
153 Cerr <<
" If this number is high, we can improve the splitting with the option use_weights\n"
154 <<
" but it takes more memory)" << finl;
157 Cerr <<
"Correction elem0 on processor 0" << finl;
Build the graph of the domain that the METIS/PARMETIS/PTSCOTCH libraries need.
void construire_graph_elem_elem(const Domaine_32_64< _SIZE_ > &dom, bool use_weights, Static_Int_Lists_32_64< _SIZE_ > &graph_elements_perio)
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
virtual void set_param(Param &) const
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_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
void ajouter_condition(const char *condition, const char *message, const char *name=0)
Declare a post-read logical condition that must hold on the parameter values.
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Partition of a domain into nb_parties balanced parts using the Ptscotch library.
void associer_domaine(const Domaine &domaine) override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void construire_partition(IntVect &elem_part, int &nb_parts_tot) const override
Computes the connectivity graph, calls the partitioner and fills elem_part (for each element,...
int lire_motcle_non_standard(const Motcle &, Entree &) override
static void corriger_bords_avec_liste(const Domaine_t &dom, const int_t my_offset, BigIntVect_ &elem_part)
static void corriger_elem0_sur_proc0(BigIntVect_ &elem_part)
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
int_t get_nb_lists() const
Returns the number of stored lists.
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")