TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Format_Post_Lata.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Format_Post_Lata_included
17#define Format_Post_Lata_included
18
19#include <TRUSTTabs_forward.h>
20#include <Format_Post_base.h>
21
22class Fichier_Lata;
23class SFichier;
24
25/*! @brief : Post-processing class for Eulerian fields in LATA format.
26 *
27 */
28
29//To create a valid file, the following steps are needed:
30// (initialization) initialize("base_nom_fichier", ASCII, SINGLE_FILE);
31// ecrire_entete(temps_courant,reprise,est_le_premier_post)
32// ecrire_domaine(domaine,est_le_premier_post)
33
34// (for each dt) ecrire_temps(temps_courant)
35// ecrire_champ(const Domaine& domaine, const Noms& unite_, const Noms& noms_compo,
36// int ncomp,double temps_,double temps_courant
37// const Nom & id_du_champ,
38// const Nom & id_du_domaine,
39// const Nom & localisation,
40// const DoubleTab & data)
41// [... ]
42
43// If option_para = MULTIPLE_FILES:
44// one post-processing file is written per processor
45// Otherwise:
46// a single file is written containing all the data.
47// The methods must then be called simultaneously on all
48// processors.
49// The LATA format specifications are described in the file
50// Specifications_lata_v2.pdf
51
53{
54 Declare_instanciable_sans_constructeur(Format_Post_Lata);
55public:
56 //
57 // Methods declared in the base class (common interface for all
58 // field post-processing formats):
59 //
60 void set_param(Param& param) const override;
61 int lire_motcle_non_standard(const Motcle&, Entree&) override;
62
63 void reset() override;
64 void resetTime(double t, const std::string dirname) override;
65
66 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,
67 const Nom& le_nom_champ_post) override;
68 int preparer_post(const Nom& id_du_domaine, const int est_le_premier_post, const int reprise, const double t_init) override;
69
70 int initialize_by_default(const Nom& file_basename) override;
71 int initialize(const Nom& file_basename, const int format, const Nom& option_para) override;
72
73 int modify_file_basename(const Nom file_basename, bool for_restart, const double tinit) override;
74
75 int ecrire_entete(const double temps_courant, const int reprise, const int est_le_premier_post) override;
76 int ecrire_domaine(const Domaine& domaine, const int est_le_premier_post) override;
77 int ecrire_temps(const double temps) override;
78 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,
79 const Nom& localisation, const Nom& nature, const DoubleTab& data) override;
80 int ecrire_item_int(const Nom& id_item, const Nom& id_du_domaine, const Nom& id_domaine, const Nom& localisation, const Nom& reference,
81 const IntVect& data, const int reference_size) override;
82
83 int finir(const int est_le_dernier_post) override;
84
85 //
86 // Other methods
87 //
88 virtual int reconstruct(const Nom file_basename, const Nom, const double tinit);
89 virtual int finir_sans_reprise(const Nom file_basename);
90
91 void ecrire_domaine_low_level(const Nom& id_dom, const DoubleTab& sommets, const IntTab& elements, const Motcle& type_elem);
92
93 // When writing joints, we need to write trustIdType (=big) values - only for LATA (?):
94 int ecrire_item_tid(const Nom& id_item, const Nom& id_du_domaine, const Nom& id_domaine, const Nom& localisation,
95 const Nom& reference, const TIDVect& data, const int reference_size);
96
97 //
98 // Methods specific to this format:
99 //
103
105 virtual int initialize_lata(const Nom& file_basename, const Format format = ASCII, const Options_Para options_para = SINGLE_FILE);
106
107 static int ecrire_entete_lata(const Nom& base_name, const Options_Para& option, const Format& format, const int est_le_premier_post);
108 static int ecrire_temps_lata(const double temps, double& temps_format, const Nom& base_name, Status& stat, const Options_Para& option);
109
110 void set_single_lata_option(const bool sing_lata) override { un_seul_fichier_lata_ = sing_lata; }
111
112 static const char * extension_lata();
113 static const char * remove_path(const char * filename);
114
115protected:
116 static trustIdType write_doubletab(Fichier_Lata& fichier, const DoubleTab& tab, int& nb_colonnes, const Options_Para& option);
117 static trustIdType write_inttab(Fichier_Lata& fichier, bool decal_fort, trustIdType decalage_partiel, const IntTab& tab, int& nb_colonnes, const Options_Para& option);
118
123
124 bool restart_already_moved_; // Whether the postprocess file was already renamed/move after a restart
125
126 double temps_courant_; // The time being written
127 double tinit_;
129 long int offset_elem_ = -1, offset_som_ = -1; // offset used if single_lata
130
131private:
132 template<typename TYP>
133 int ecrire_item_integral_T(const Nom& id_item, const Nom& id_du_domaine, const Nom& id_domaine, const Nom& localisation,
134 const Nom& reference, const TRUSTVect<TYP, int>& val, const int reference_size);
135 void ecrire_offset(SFichier& sfichier, long int offset);
136};
137
138#endif /* Format_Post_Lata_included */
void reset() override
Resets the object to the state obtained by the default constructor.
int ecrire_entete(const double temps_courant, const int reprise, const int est_le_premier_post) override
Opens the master file in ERASE mode and writes the lata file header (on the master processor only).
static const char * remove_path(const char *filename)
Returns the file name without its path: strips all characters before the last /.
bool un_seul_fichier_lata_
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.
virtual int initialize_lata(const Nom &file_basename, const Format format=ASCII, const Options_Para options_para=SINGLE_FILE)
Initializes the class, opens the file and writes the header.
int modify_file_basename(const Nom file_basename, bool for_restart, const double tinit) override
Modifying name of the post file, plus some clever management of previously saved data in case of rest...
double temps_courant_
Options_Para options_para_
int preparer_post(const Nom &id_du_domaine, const int est_le_premier_post, const int reprise, const double t_init) override
static trustIdType write_doubletab(Fichier_Lata &fichier, const DoubleTab &tab, int &nb_colonnes, const Options_Para &option)
fichier is a lata data file (not the master file). The array tab is written as-is (in binary or ASCII...
long int offset_som_
int ecrire_item_tid(const Nom &id_item, const Nom &id_du_domaine, const Nom &id_domaine, const Nom &localisation, const Nom &reference, const TIDVect &data, const int reference_size)
long int offset_elem_
Format format_
virtual int finir_sans_reprise(const Nom file_basename)
double tinit_
static int ecrire_entete_lata(const Nom &base_name, const Options_Para &option, const Format &format, const int est_le_premier_post)
Format
@ BINAIRE
@ ASCII
virtual int reconstruct(const Nom file_basename, const Nom, const double tinit)
Nom lata_basename_
Options_Para
@ SINGLE_FILE_MPIIO
@ SINGLE_FILE
@ MULTIPLE_FILES
int ecrire_domaine(const Domaine &domaine, const int est_le_premier_post) override
See Format_Post_base::ecrire_domaine. Writing a domain within a time step is accepted,...
Format_Post_Lata()
Default constructor: format_ ASCII and options_para_ = SINGLE_FILE.
void set_single_lata_option(const bool sing_lata) override
Status
@ WRITING_TIME
@ RESET
@ INITIALIZED
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
bool restart_already_moved_
void set_param(Param &param) const override
int ecrire_temps(const double temps) override
Starts writing a new time step. For the LATA format specifically:
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
voir Format_Post_base::ecrire_champ
static trustIdType write_inttab(Fichier_Lata &fichier, bool decal_fort, trustIdType decalage_partiel, const IntTab &tab, int &nb_colonnes, const Options_Para &option)
Writing an integer array to the given file.
Status status
void ecrire_domaine_low_level(const Nom &id_dom, const DoubleTab &sommets, const IntTab &elements, const Motcle &type_elem)
Low level routine to write a mesh into a LATA file.
int initialize_by_default(const Nom &file_basename) override
Initializes the class with default parameters (ASCII format, SINGLE_FILE).
int finir(const int est_le_dernier_post) override
int initialize(const Nom &file_basename, const int format, const Nom &option_para) override
static int ecrire_temps_lata(const double temps, double &temps_format, const Nom &base_name, Status &stat, const Options_Para &option)
static const char * extension_lata()
Returns the conventional extension for lata files: ".lata".
void resetTime(double t, const std::string dirname) override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
Base class for post-processing output formats for fields (lata, med, cgns, lml, single_lata).
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:71
static int axi
Definition Objet_U.h:96
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29