15#include <Format_Post_Lml.h>
16#include <communications.h>
52 Cerr <<
"Format_Post_Lml::printOn : error" << finl;
118 const Nature_du_champ& nature,
const int nb_compo,
const Noms& noms_compo,
119 const Motcle& loc_post,
const Nom& le_nom_champ_post)
174 int ncomp,
double temps_,
176 const Nom& id_du_domaine,
177 const Nom& localisation,
179 const DoubleTab& valeurs)
189 ecrire_champ_lml(domaine,unite_,noms_compo,ncomp,temps_,id_champ,id_du_domaine,localisation,valeurs,nom_fich);
198 const Nom& id_du_domaine,
199 const Nom& id_domaine,
200 const Nom& localisation,
201 const Nom& reference,
202 const IntVect& valeurs,
203 const int reference_size)
210 Nom id_domaine_dom(id_domaine);
212 id_domaine_dom+=id_du_domaine;
220 if (est_le_premier_post)
228 s <<
"TRUST" <<
" " <<
"Version " << TRUST_VERSION << finl;
230 s <<
"TRUST" << finl;
244 s.
ouvrir(nom_fich,ios::app);
246 if (est_le_dernier_post)
275 s.
ouvrir(nom_fich,ios::app);
276 Nom nom_grille(
"Grille_");
277 nom_grille+= domaine.
le_nom();
280 s <<
"GRILLE" << finl;
283 trustIdType nb_elem_tot0 =
static_cast<int>(
Process::mp_sum(domaine.nb_elem()));
284 if (nb_som_tot0 >= std::numeric_limits<int>::max() || nb_elem_tot0 >= std::numeric_limits<int>::max())
286 Cerr <<
"Too many items in the domain to be written in LML (exceeds the 32b limit) - the support for this is not implemented." << finl;
287 Cerr <<
"Please contact TRUST support!" << finl;
290 int nb_som_tot =
static_cast<int>(nb_som_tot0);
291 int nb_elem_tot =
static_cast<int>(nb_elem_tot0);
292 int dim = domaine.les_sommets().dimension(1);
306 s << nom_grille <<
" " <<
"3 " << nb_som_tot <<
"" << finl;
309 for (
int nsom=0; nsom<domaine.nb_som(); nsom++)
311 s << domaine.coord(nsom,0)*cos(domaine.coord(nsom,1)) <<
" "
312 << domaine.coord(nsom,0)*sin(domaine.coord(nsom,1)) <<
" "
313 << domaine.coord(nsom,2) <<
"" << finl;
322 s << nom_grille <<
" " <<
"3 " << 2*nb_som_tot <<
"" << finl;
327 for (nsom=0; nsom<domaine.nb_som(); nsom++)
329 s << domaine.coord(nsom,0)*cos(domaine.coord(nsom,1)) <<
" "
330 << domaine.coord(nsom,0)*sin(domaine.coord(nsom,1)) <<
" "
333 for (nsom=0; nsom<domaine.nb_som(); nsom++)
335 s << domaine.coord(nsom,0)*cos(domaine.coord(nsom,1)) <<
" "
336 << domaine.coord(nsom,0)*sin(domaine.coord(nsom,1)) <<
" "
350 s << nom_grille <<
" " <<
"3 " << nb_som_tot <<
"" << finl;
353 for (
int nsom=0; nsom<domaine.nb_som(); nsom++)
355 for (
int j=0; j<3; j++)
356 s << domaine.coord(nsom, j) <<
" " ;
366 s << nom_grille <<
" " <<
"3 " << 2*nb_som_tot <<
"" << finl;
371 for (nsom=0; nsom<domaine.nb_som(); nsom++)
373 s << domaine.coord(nsom,0) <<
" "
374 << domaine.coord(nsom,1) <<
" "
377 for (nsom=0; nsom<domaine.nb_som(); nsom++)
379 s << domaine.coord(nsom,0) <<
" "
380 << domaine.coord(nsom,1) <<
" "
394 int nsom = domaine.nb_som();
395 Nom nom_top(
"Topologie_");
396 nom_top+= domaine.
le_nom();
398 nom_top+=domaine.
le_nom();
399 Nom type_maille=domaine.type_elem()->nom_lml();
403 int nb_elem = domaine.nb_elem() ;
404 int nb_som_elem = domaine.nb_som_elem();
405 const IntTab& sommet_elem = domaine.les_elems();
409 s <<
"TOPOLOGIE" << finl;
410 s << nom_top <<
" " << nom_grille <<
"" << finl;
411 s <<
"MAILLE" << finl;
412 s << nb_elem_tot <<
"" << finl;
420 for (
int nelem=0; nelem<nb_elem; nelem++)
422 s << type_maille <<
" ";
423 for (j=0; j<nb_som_elem; j++)
424 s << sommet_elem(nelem,j)+1+nb_som_PE <<
" " ;
433 for (
int nelem=0; nelem<nb_elem; nelem++)
435 s << type_maille <<
" ";
437 for (j=0; j<nb_som_elem && (sommet_elem( nelem,j) > -1); j++)
438 s << sommet_elem( nelem,j)+1+2*nb_som_PE <<
" ", count++;
439 for (j=0; j<nb_som_elem && (sommet_elem( nelem,j) > -1); j++)
440 s << sommet_elem( nelem,j)+1+2*nb_som_PE+nsom <<
" ", count++;
441 for (
int k = count; k < 2 * nb_som_elem; k++) s << (
int)0 <<
" ";
450 s <<
"FACE" << finl ;
451 s << (int)0 <<
"" << finl;
467 s.
ouvrir(nom_fich,ios::app);
469 s <<
"TEMPS " << temps << finl;
477 int ncomp,
double temps_,
478 const Nom& id_du_champ,
479 const Nom& id_du_domaine,
480 const Nom& localisation,
481 const DoubleTab& data,
Nom& nom_fich)
485 os.
ouvrir(nom_fich,ios::app);
486 Nom nom_top(
"Topologie_");
487 nom_top+= domaine.
le_nom();
489 nom_top+=domaine.
le_nom();
490 int dim = domaine.les_sommets().
dimension(1);
491 Nom nom_post = id_du_champ;
497 if(localisation==
"SOM")
499 int nb_som = domaine.nb_som();
507 int nb_compo_dv = (nb_compo_==2 ? 3 : nb_compo_);
511 os <<
"CHAMPPOINT " << nom_post <<
" " << nom_top <<
" " << temps_ << finl;
512 os << nom_post <<
" " << nb_compo_dv <<
" " << unite_[0] <<
" "
513 <<
"type0" <<
" " << nb_som_tot << finl;
516 for (
int i=0; i<4-dim; i++)
517 for (
int j = 0; j < nb_som; j++)
519 os << i * nb_som + j + 1 + nb_som_PE <<
" ";
520 for (
int comp = 0; comp < nb_compo_; comp++)
521 os << data(j, comp) <<
" ";
522 if (nb_compo_ == 2) os <<
"0.";
528 else if(localisation==
"ELEM")
530 int nb_elem=domaine.nb_elem();
533 for (
int comp=0; comp<nb_compo_; comp++)
537 os <<
"CHAMPMAILLE ";
538 os << (nb_compo_ == 1 ? nom_post : noms_compo[comp]) <<
" " << nom_top <<
" " << temps_ << finl;
539 os << (nb_compo_ == 1 ? nom_post : noms_compo[comp]) <<
" " << (
int)1 <<
" " << unite_[comp] <<
" " ;
540 os <<
"type0" <<
" " << nb_elem_tot << finl;
543 for (
int j=0; j<nb_elem; j++)
544 os << j+1+nb_elem_PE <<
" " << data(j,comp) << finl;
551 Cerr <<
"We do not know to postprocess " << id_du_champ
552 <<
" with the keyword " << localisation << finl;
558 if(localisation==
"SOM")
560 int nb_som=domaine.nb_som();
571 os << nom_post <<
" " << nom_top <<
" " << temps_ << finl;
572 os << nom_post <<
" " << (int)1 <<
" " << unite_[ncomp] <<
" "
573 <<
"type0" <<
" " << nb_som_tot << finl;
576 for (
int i=0; i<4-dim; i++)
577 for (
int j=0; j<nb_som; j++)
578 os << i*nb_som+j+1+nb_som_PE <<
" " << data(j) << finl;
582 else if(localisation==
"ELEM")
584 int nb_elem=domaine.nb_elem();
589 os <<
"CHAMPMAILLE ";
590 os << nom_post <<
" " << nom_top <<
" " << temps_ << finl;
591 os << nom_post <<
" " << (int)1 <<
" " << unite_[ncomp] <<
" " ;
592 os <<
"type0" <<
" " << nb_elem_tot << finl;
595 for (
int j=0; j<nb_elem; j++)
596 os << j+1+nb_elem_PE <<
" " << data(j) << finl;
602 Cerr <<
"We do not know to postprocess " << id_du_champ
603 <<
" with the keyword " << localisation << finl;
612 const Nom& id_domaine,
617 os.
ouvrir(nom_fic,ios::app);
619 Nom nom_vect(id_item);
620 nom_vect +=
"_elem_dom";
622 Nom nom_topologie(
"Topologie_");
623 nom_topologie+= id_domaine;
628 const IntTab* intT =
dynamic_cast<const IntTab*
>(&vect);
631 const IntTab& tab = *intT;
639 for (
int i=0; i<tab_dimension0_opt; i++)
644 for (
int j2=0; j2<tab_dimension1_opt; j2++)
645 os << i+1 <<
" " << tab(i,j2) <<
" ";
657 os << nom_vect <<
" 1" <<
" 1 " <<
" type0 " << vect.
size() << finl;
658 for (
int i=0; i<vect.
size(); i++)
659 os << i+1 <<
" " << vect(i) << finl;
Sortie & unlockfile() override
Releases the critical resource for the next process.
Sortie & lockfile() override
Allows the calling process to block waiting for the common resource shared by all processes,...
Sortie & flush() override
int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out) override
Opens the file with the given mode and prot parameters. These parameters are the parameters of the st...
Sortie & syncfile() override
Triggers writing to disk of the data accumulated on the different processors since the last call to s...
Class defining operators and methods for all reading operation in an input flow (file,...
: Post-processing class for Eulerian fields in LML format.
static int ecrire_champ_lml(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 DoubleTab &data, Nom &nom_fic)
void reset() override
Resets the object to the state obtained by the default constructor.
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) override
see Format_Post_base::ecrire_champ
static int ecrire_domaine_lml(const Domaine &domaine, Nom &nom_fic)
static int finir_lml(Nom &nom_fic, const int est_le_dernier_post)
int preparer_post(const Nom &id_du_domaine, const int est_le_premier_post, const int reprise, const double t_init) override
int finir(const int est_le_dernier_post) override
int initialize(const Nom &file_basename, const int format, const Nom &option_para) override
void set_param(Param ¶m) const override
int initialize_by_default(const Nom &file_basename) override
Initializes the class with default parameters.
static int ecrire_entete_lml(Nom &nom_fic, const int est_le_premier_post)
int ecrire_entete(const double temps_courant, const int reprise, const int est_le_premier_post) override
static int ecrire_item_int_lml(const Nom &id_item, const Nom &id_domaine, const IntVect &data, const Nom &nom_fic)
int ecrire_domaine(const Domaine &domaine, const int est_le_premie_post) override
see Format_Post_base::ecrire_domaine
Format_Post_Lml()
Default constructor: specify in comments what is set by default.
int ecrire_item_int(const Nom &id_item, const Nom &id_du_domaine, const Nom &id_domaine, const Nom &localisation, const Nom &reference, const IntVect &data, const int reference_size) override
Writing an integer array to the post-processing file.
int ecrire_temps(const double temps) override
Starts writing a new time step. For the LML format specifically:
static int completer_post_lml()
static int ecrire_temps_lml(const double temps, Nom &nom_fic)
static int preparer_post_lml()
int completer_post(const Domaine &dom, const int axi, const Nature_du_champ &nature, const int nb_compo, const Noms &noms_compo, const Motcle &loc_post, const Nom &le_nom_champ_post) override
Base class for post-processing output formats for fields (lata, med, cgns, lml, single_lata).
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
const Nom & le_nom() const override
Returns *this.
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.
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.
static trustIdType mppartial_sum(trustIdType i)
Computes the partial sum of x over processors 0 to me()-1 (returns 0 on processor 0).
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Base class for output streams.
_SIZE_ dimension(int d) const