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 &)
Associates a domain to all boundaries in the list.
: This class describes a group of processors on which
class Domaine_32_64 A Domain is a mesh composed of a set of geometric elements of the same type.
int nb_som_elem() const
Returns the number of vertices of the geometric elements that make up the domain.
DoubleTab_t & les_sommets()
Raccords_t & faces_raccord()
void fixer_premieres_faces_frontiere()
void typer(const Nom &)
Sets the element type of the domain using the name passed as parameter.
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Class defining operators and methods for all reading operation in an input flow (file,...
Base class for post-processing output formats for fields (lata, med, cgns, lml, single_lata).
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)
Writing a field to the post-processing file.
virtual int initialize_by_default(const Nom &file_basename)
Initializes the file with parameters appropriate to its format (e.g. ascii format,...
virtual int ecrire_temps(const double temps)
Starts writing a time step.
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)
Writing a mesh.
virtual int preparer_post(const Nom &id_du_domaine, const int est_le_premier_post, const int reprise, const double t_init)
Base class for "interpreter" objects.
void associer_domaine(const Domaine_t &)
Associates a domain with all joints in the list.
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_
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
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
Returns the filename part if the name is in the form /toto/titi/filename.
const std::string & getString() const
An array of character strings (VECT(Nom)).
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
static int enter_group(const Comm_Group &group)
If the local processor belongs to the group, the current group for this processor becomes "group" and...
static void create_group(const ArrOfInt &liste_pe, OWN_PTR(Comm_Group) &group, int force_Comm_Group_NoParallel=0)
Creates a new processor group (can be called anywhere in the code).
static void exit_group()
Returns to the group that was active before the last successful enter_group() call (which returned 1)...
Class Polyedre: represents the Polyedre geometric element.
static void barrier()
Synchronizes all processors in the current group (waits until all processors have reached the barrier...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
void associer_domaine(const Domaine_t &)
Associates a domain with all connectors in the list.
Base class for output streams.
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