15#include <Partitionneur_Fichier_MED.h>
18#include <medcoupling++.h>
21#include <MEDLoader.hxx>
22#include <MEDCouplingField.hxx>
23#include <MEDCouplingFieldInt32.hxx>
24#pragma GCC diagnostic ignored "-Wreorder"
25#include <MEDFileField.hxx>
26#include <communications.h>
27#include <Champ_Fonc_MED.h>
37Partitionneur_Fichier_MED::Partitionneur_Fichier_MED()
43 Cerr <<
"Partitionneur_MED::printOn invalid\n" << finl;
65 ref_domaine_ = domaine;
80 Cerr <<
"Error in Partitionneur_Fichier_MED::construire_partition\n";
81 Cerr <<
" The domain has not been associated" << finl;
86 Cerr <<
"Error in Partitionneur_Fichier_MED::construire_partition\n";
87 Cerr <<
" The file name has not been initialized" << finl;
92 Cerr <<
"Error in Partitionneur_Fichier_MED::construire_partition\n";
93 Cerr <<
" The field name has not been initialized" << finl;
97 Cerr <<
"Reading of splitting file : " <<
filename_ << finl;
100 using namespace MEDCoupling;
102 MCAuto<MEDCouplingField> ffield = MEDCoupling::ReadField(
filename_.getString(),
fieldname_.getString());
103 MEDCouplingFieldInt32 * field =
dynamic_cast<MEDCouplingFieldInt32 *
>((MEDCouplingField *)ffield);
107 DataArrayInt32 *da = field->getArray();
108 const int *field_values = da->begin();
110 const mcIdType sz0 = field->getNumberOfTuplesExpected();
111 assert(sz0 < std::numeric_limits<int>::max());
112 const int sz =
static_cast<int>(sz0);
114 std::copy(field_values, field_values + sz, elem_part.
addr());
116 const int nelem = ref_domaine_->nb_elem();
119 Cerr <<
"Error in Partitionneur_Fichier_MED::construire_partition" << finl;
120 Cerr <<
" The file contains an array of " << sz <<
" values." << finl;
121 Cerr <<
" The area contains " << nelem <<
" elements" << finl;
125 MCAuto<DataArrayInt32> das = da->buildUniqueNotSorted();
126 MCAuto<DataArrayInt32> iot(DataArrayInt32::New());
128 const mcIdType max_v = das->getMaxValue(dnu);
129 iot->alloc(max_v + 1, 1);
131 if (!iot->isEqualWithoutConsideringStr(*das))
133 Cerr <<
"Error in Partitionneur_Fichier_MED::construire_partition" << finl;
134 Cerr <<
" The file contains/lacks integer values which do not cover the range [0; n_elem[." << finl;
135 Cerr <<
" Are some field values missing?" << finl;
139 Cerr <<
"Partitionneur_Fichier_MED requires TRUST compiled with MEDCoupling support!" << finl;
161 cli+= ffield->getMesh()->getName();
162 cli+=
" field partition loc elem last_time }";
165 ech >> partition_field_outer_domain;
167 int nb_elem = ref_domaine_->nb_elem();
169 ref_domaine_->calculer_centres_gravite(xp_elems);
170 IntVect elems(nb_elem);
171 partition_field_outer_domain.domaine().chercher_elements(xp_elems, elems);
172 DoubleTab double_elem_part(nb_elem);
173 double_elem_part = -1;
174 partition_field_outer_domain.valeur_aux_elems(xp_elems, elems, double_elem_part);
175 if (local_min_vect(double_elem_part)<0)
177 Cerr <<
"The domain " << ref_domaine_->le_nom() <<
" it not fully included into the domain " << ffield->getMesh()->getName() <<
" ! " << finl;
178 Cerr <<
"It is mandatory to use the partition field from " <<
filename_ << finl;
182 elem_part.
resize(nb_elem);
183 for (
int i=0; i<nb_elem; i++)
184 elem_part(i)=(int)double_elem_part(i);
185 nb_parts_tot = 1+int(local_max_vect(partition_field_outer_domain.valeurs()));
classe Champ_Fonc_MED Load a field from a MED file for a given time.
Une entree dont la source est une chaine de caracteres.
class Nom Une chaine de caractere pour nommer les objets de TRUST
virtual void set_param(Param &) const
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(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Partition d'un domaine a partir d'un fichier MED contenant un champ donnant, pour chaque element,...
void associer_domaine(const Domaine &domaine) override
void initialiser(const char *filename)
void construire_partition(IntVect &elem_part, int &nb_parts_tot) const override
Lit le contenu du fichier "filename_" et stocke le resultat dans elem_part.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Classe de base des flux de sortie.
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)