16#include <Format_Post_base.h>
17#include <Lata_2_Other.h>
18#include <EFichierBin.h>
19#include <LataFilter.h>
43 Cerr << __FILE__ << (int) __LINE__ <<
" not coded" << finl;
49 Cerr << __FILE__ << (int) __LINE__ <<
" not coded" << finl;
56void convert_domain_to_Domaine(
const Domain& dom, Domaine& dom_trio)
58 Nom type_elem = dom.lata_element_name(dom.elt_type_);
59 if (type_elem ==
"PRISM6")
62 Cerr <<
"Reading from Lata_DB an ELEM of type " << type_elem <<
" ... Typing the TRUST Domaine !" << finl;
63 dom_trio.
typer(type_elem);
64 dom_trio.type_elem()->associer_domaine(dom_trio);
66 bool poly_generique =
false;
67 if (dom.get_domain_type() == Domain::UNSTRUCTURED)
69 const DomainUnstructured& geom = dom.cast_DomainUnstructured();
70 if (geom.elem_faces_.dimension(0) > 0 && geom.faces_.dimension(0) > 0)
71 poly_generique =
true;
77 if (type_elem ==
"POLYEDRE" && poly_generique)
81 dom_trio_poubelle.
typer(type_elem);
83 if (dom.get_domain_type() == Domain::UNSTRUCTURED)
85 const DomainUnstructured& geom = dom.cast_DomainUnstructured();
86 const auto& elems = geom.elements_;
87 const auto& faces = geom.faces_;
88 const auto& ef = geom.elem_faces_;
89 const auto& nod = geom.nodes_;
91 trustIdType dim1_tmp = nod.dimension(0);
93 if (dim1_tmp >= std::numeric_limits<int>::max())
94 Process::exit(
"LATA file is too big and does not fit into 32bits!!");
96 const trustIdType nb_elems = elems.dimension(0);
98 std::vector<trustIdType> conn, connIndex;
100 connIndex.push_back(idx);
101 for (trustIdType i = 0; i < nb_elems; i++)
106 for (
int j = 0; j < ef.dimension(1); j++)
108 trustIdType fac = ef(i, j);
113 bool is_not_last =
true;
115 if (j+1 < ef.dimension(1) && ef(i, j+1) < 0)
118 for (
int jj = 0; jj < faces.dimension(1); jj++)
120 const trustIdType ff = faces(fac, jj);
125 conn.push_back(faces(fac, jj));
129 if (j < ef.dimension(1) - 1 && is_not_last)
135 connIndex.push_back(idx);
138 trustIdType marker = 0;
139 trustIdType conn_size =
static_cast<trustIdType
>(conn.size());
141 for (trustIdType i = 0; i < conn_size; i++)
145 trustIdType num_nodes = conn_size - nb_elems - marker;
146 trustIdType nfaces = nb_elems + marker;
148 ArrOfInt_T<trustIdType> nodes(num_nodes), facesIndex(nfaces + 1), polyhedronIndex(nb_elems + 1);
150 IntTab_T<trustIdType> les_elems;
151 trustIdType face = 0, node = 0;
153 for (trustIdType i = 0; i < nb_elems; i++)
155 polyhedronIndex[i] = face;
157 trustIdType index = connIndex[i] + 1;
158 int nb_som =
static_cast<int>(connIndex[i + 1] - index);
159 for (
int j = 0; j < nb_som; j++)
161 if (j == 0 || conn[index + j] < 0)
162 facesIndex[face++] = node;
163 if (conn[index + j] >= 0)
164 nodes[node++] = conn[index + j];
167 facesIndex[nfaces] = node;
168 polyhedronIndex[nb_elems] = face;
172 auto& poly = ref_cast(Polyedre, dom_trio.type_elem().valeur());
174 poly_poubelle.affecte_connectivite_numero_global(nodes, facesIndex, polyhedronIndex, les_elems);
177 poly.set_nb_som_face_max(poly_poubelle.get_nb_som_elem_max());
181 polyhedronIndex.from_tid_to_int(tmp);
182 poly.getsetPolyhedronIndex() = tmp;
192 poly.getsetFacesIndex() = tmp2;
196 const auto& nd = poly_poubelle.getNodes();
197 tmp3.
resize((
int) nd.size_array());
198 for (
auto i = 0; i < nd.size_array(); i++)
199 tmp3[i] =
static_cast<int>(nd[i]);
200 poly.getsetNodes() = tmp3;
204 int dim1 = (int) dim1_tmp;
207 for (
int i1 = 0; i1 < dim1; i1++)
208 for (
int i2 = 0; i2 < dim2; i2++)
209 som(i1, i2) = geom.nodes_(i1, i2);
218 int nx = 1, ny = 1, nz = 1;
219 if (dom.get_domain_type() == Domain::UNSTRUCTURED)
221 const DomainUnstructured& geom = dom.cast_DomainUnstructured();
222 trustIdType dim1_tmp = geom.nodes_.dimension(0);
224 if (dim1_tmp >= std::numeric_limits<int>::max())
225 Process::exit(
"LATA file is too big and does not fit into 32bits!!");
226 int dim1 = (int) dim1_tmp;
227 int dim2 = geom.nodes_.dimension_int(1);
229 for (
int i1 = 0; i1 < dim1; i1++)
230 for (
int i2 = 0; i2 < dim2; i2++)
231 som(i1, i2) = geom.nodes_(i1, i2);
235 assert(dom.get_domain_type() == Domain::IJK);
236 const DomainIJK& geom = dom.cast_DomainIJK();
237 const int dim = geom.coord_.size();
239 nx = geom.coord_[0].size_array();
240 ny = geom.coord_[1].size_array();
243 nz = geom.coord_[2].size_array();
245 som.
resize(nx * ny * nz, dim);
247 for (
int i = 0; i < nx; i++)
248 for (
int j = 0; j < ny; j++)
249 for (
int k = 0; k < nz; k++)
251 int nn = i * ny * nz + j * nz + k;
252 som(nn, 0) = geom.coord_[0][i];
253 som(nn, 1) = geom.coord_[1][j];
255 som(nn, 2) = geom.coord_[2][k];
259 if (dom.get_domain_type() == Domain::UNSTRUCTURED)
261 const DomainUnstructured& geom = dom.cast_DomainUnstructured();
274 for (
int i = 0; i < nx - 1; i++)
275 for (
int j = 0; j < ny - 1; j++)
276 for (
int k = 0; k < nz - 1; k++)
278 int nn = i * (ny - 1) * (nz - 1) + j * (nz - 1) + k;
279 nn = i + j * (nx - 1) + k * ((nx - 1) * (ny - 1));
280 elems(nn, 0) = i * ny * nz + j * nz + k;
281 elems(nn, 1) = (i + 1) * ny * nz + j * nz + k;
282 elems(nn, 2) = (i) * ny * nz + (j + 1) * nz + k;
283 elems(nn, 3) = (i + 1) * ny * nz + (j + 1) * nz + k;
284 if (elems.dimension(1) > 4)
285 for (
int ii = 0; ii < 4; ii++)
286 elems(nn, 4 + ii) = elems(nn, ii) + 1;
296 if (dom.id_.timestep_ != 0)
302 Noms geoms = filter.get_exportable_geometry_names();
303 for (
int i = 0; i < geoms.size(); i++)
305 Field_UNames fields = filter.get_exportable_field_unames(geoms[i]);
306 for (
int j = 0; j < fields.size(); j++)
308 Field_Id fieldid(fields[j], 1, -1);
311 const FieldFloat& field = filter.get_float_field(fieldid);
313 if (field.localisation_ == LataField_base::ELEM)
315 else if (field.localisation_ == LataField_base::SOM)
321 filter.release_field(field);
325 Cerr << fieldid.uname_.get_field_name() <<
" is not a FloatField !!!" << finl;
335 Cerr <<
"syntax Lata_to_Other::interpreter format_post_supp [nom_lata||NOM_DU_CAS] [nom_fichier_sortie||NOM_DU_CAS] " << finl;
336 Nom nom_lata, nom_fic;
337 Nom format_post_supp;
338 is >> format_post_supp >> nom_lata >> nom_fic;
340 std::set<std::string> formats( {
"LML",
"LATA",
"LATA_V2",
"MED",
"CGNS" });
341 Nom tmp = format_post_supp;
342 if (formats.count(tmp.majuscule().getString()) == 0)
344 Cerr <<
"Error, format " << format_post_supp <<
" is not supported!" << finl;
349 ArrOfInt liste_pe(1);
358 if (nom_lata ==
"NOM_DU_CAS")
360 if (nom_fic ==
"NOM_DU_CAS")
362 Nom filename(nom_lata);
366 set_Journal_level(0);
368 LataOptions::extract_path_basename(filename, opt.path_prefix, opt.
basename);
369 opt.dual_mesh =
true;
370 opt.faces_mesh =
false;
373 opt.regularize_tolerance = 1e-7f;
374 read_any_format_options(filename, opt);
376 read_any_format(filename, opt.path_prefix, lata_db);
378 filter.initialize(opt, lata_db);
382 Noms geom_names = filter.get_exportable_geometry_names();
383 int elt_type = filter.get_geometry(Domain_Id(geom_names[0], 1, -1)).elt_type_;
384 Cerr << elt_type << finl;
385 if (elt_type == Domain::polyedre || elt_type == Domain::polygone)
387 opt.dual_mesh =
false;
388 filter.initialize(opt, lata_db);
391 Nom nom_pdb(nom_fic);
392 Nom format_post_(format_post_supp);
393 if (format_post_ ==
"lata_v2")
394 format_post_ =
"lata";
398 Nom type(
"Format_Post_");
399 type += format_post_;
401 post_typer.typer(type.
getChar());
404 Nom format_post_bis(format_post_);
406 format_post_bis =
"lata";
408 suffix += format_post_bis;
411 if (
Motcle(format_post_supp) ==
"CGNS")
419 int format_binaire_ = 0;
420 if (format_post_bis !=
"lata")
423 post.
initialize(nom_2, format_binaire_,
"SIMPLE");
428 Noms geoms = filter.get_exportable_geometry_names();
430 for (
int i = 0; i < geoms.size(); i++)
432 Domain_Id id(geoms[i], 1, -1);
433 const Domain& dom = filter.get_geometry(
id);
436 dom_trio.
nommer(geoms[i]);
437 convert_domain_to_Domaine(dom, dom_trio);
438 int est_le_premier_post = (i == 0);
440 if (
Motcle(format_post_supp) !=
"CGNS" || (
Motcle(format_post_supp) ==
"CGNS" && i == 0))
448 filter.release_geometry(dom);
452 const char *suffix_vector_names[] = {
"X",
"Y",
"Z" };
454 for (
int t = 1; t < lata_db.nb_timesteps(); t++)
458 Noms geoms = filter.get_exportable_geometry_names();
459 double time = filter.get_timestep(t);
461 for (
int i = 0; i < geoms.size(); i++)
463 Domain_Id id(geoms[i], timestate, -1);
464 const Domain& dom = filter.get_geometry(
id);
467 dom_trio.
nommer(geoms[i]);
468 convert_domain_to_Domaine(dom, dom_trio);
469 Field_UNames fields = filter.get_exportable_field_unames(geoms[i]);
470 for (
int j = 0; j < fields.size(); j++)
476 int est_le_premie_post = (i == 0);
478 Field_Id fieldid(fields[j], timestate, -1);
483 const FieldFloat& field = filter.get_float_field(fieldid);
485 const BigFloatTab& values_lata = field.data_;
486 assert(values_lata.
size_array() < std::numeric_limits<int>::max());
487 int dim1 = (int)values_lata.
dimension(0);
489 values.
resize(dim1, dim2);
490 for (
int i1 = 0; i1 < dim1; i1++)
491 for (
int i2 = 0; i2 < dim2; i2++)
492 values(i1, i2) = values_lata(i1, i2);
496 if (field.localisation_ == LataField_base::ELEM)
498 else if (field.localisation_ == LataField_base::SOM)
502 Cerr << nom_type <<
" not coded ...... " << finl;
503 Cerr << __FILE__ <<
":" << (int) __LINE__ << finl;
510 Cerr <<
"Extraction " << time <<
" " << geoms[i] <<
" " << fields[j].get_field_name() << finl;
513 nom_post = fields[j].get_field_name();
516 nom_post +=
"_Centre";
521 for (
int ii = 0; ii < values.
dimension(1); ii++)
523 noms_post[ii] = nom_post;
525 noms_post[ii] += suffix_vector_names[ii];
527 noms_post[ii] +=
Nom(ii);
528 noms_post[ii] += ajout;
534 post.
ecrire_champ(dom_trio, unites, noms_post, -1, time, nom_post, geoms[i], nom_type,
"iii", values);
535 filter.release_field(field);
539 Cerr << fieldid.uname_.get_field_name() <<
" is not a FloatField !!!" << finl;
543 filter.release_geometry(dom);
void associer_domaine(const Domaine_t &)
Associe un domaine a tous les bords de la liste.
: Cette classe decrit un groupe de processeurs sur lesquels
classe Domaine_32_64 un Domaine est un maillage compose d'un ensemble d'elements geometriques de meme...
int nb_som_elem() const
Renvoie le nombre de sommets des elements geometriques constituants le domaine.
DoubleTab_t & les_sommets()
Raccords_t & faces_raccord()
void fixer_premieres_faces_frontiere()
void typer(const Nom &)
Type les elements du domaine avec le nom passe en parametre.
void nommer(const Nom &nom) override
Donne un nom a l'Objet_U Methode virtuelle a surcharger.
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Class defining operators and methods for all reading operation in an input flow (file,...
Classe de base des formats de postraitements pour les champs (lata, med, cgns, lml,...
virtual int initialize(const Nom &file_basename, const int format, const Nom &option_para)
virtual int finir(const int est_le_dernier_post)
virtual void set_loc_vector(const std::vector< std::string > &)
virtual int init_ecriture(double temps_courant, double temps_post, int est_le_premier_postraitement_pour_nom_fich_, const Domaine &domaine)
virtual int ecrire_champ(const Domaine &domaine, const Noms &unite_, const Noms &noms_compo, int ncomp, double temps_, const Nom &id_du_champ, const Nom &id_du_domaine, const Nom &localisation, const Nom &nature, const DoubleTab &data)
Ecriture d'un champ dans le fichier de postraitement.
virtual int initialize_by_default(const Nom &file_basename)
Initialise le fichier avec des parametres appropries pour son format (exemple: format ascii,...
virtual int ecrire_temps(const double temps)
Commence l'ecriture d'un pas de temps.
virtual int ecrire_entete(const double temps_courant, const int reprise, const int est_le_premier_post)
virtual int ecrire_domaine(const Domaine &domaine, const int est_le_premier_post)
Ecriture d'un maillage.
virtual int preparer_post(const Nom &id_du_domaine, const int est_le_premier_post, const int reprise, const double t_init)
Classe de base des objets "interprete".
void associer_domaine(const Domaine_t &)
Associe un domaine a tous les joints de la liste.
Classe Lata_2_Other Converts lata file to med or lml Can only be used with small lata files (fitting ...
Entree & interpreter(Entree &is) override
void get_fill_infos_loc(const LataDB &lata_db, LataFilter &filter, Format_Post_base &post)
std::vector< std::string > locs_required_
Une chaine de caractere (Nom) en majuscules.
class Nom Une chaine de caractere pour nommer les objets de TRUST
const char * getChar() const
virtual int finit_par(const char *const n) const
virtual int debute_par(const char *const n) const
Nom & prefix(const char *const)
Nom basename() const
Retourne fichier si le nom est sous la forme /toto/titi/fichier.
const std::string & getString() const
Un tableau de chaine de caracteres (VECT(Nom)).
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
static const Nom & nom_du_cas()
Renvoie une reference constante vers le nom du cas.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
static int enter_group(const Comm_Group &group)
Si le processeur local appartient au groupe, le groupe courant pour ce processeur devient "group" et ...
static void create_group(const ArrOfInt &liste_pe, OWN_PTR(Comm_Group) &group, int force_Comm_Group_NoParallel=0)
Creation d'un nouveau groupe de processeurs (utilisation possible n'importe ou dans le code).
static void exit_group()
Retourne dans le groupe ou l'on etait avant le dernier enter_group() reussi (dont le resultat a ete 1...
Classe Polyedre Cette represente l'element geometrique Polyedre.
static void barrier()
Synchronise tous les processeurs du groupe courant (attend que tous les processeurs soient arrives a ...
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
void associer_domaine(const Domaine_t &)
Associe un domaine a tous les raccords de la liste.
Classe de base des flux de sortie.
void from_tid_to_int(TRUSTArray< int, int > &out) const
_SIZE_ size_array() const
void resize(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
int dimension_int(int d) const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void from_tid_to_int(TRUSTTab< int, int > &out) const
_SIZE_ dimension(int d) const