TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Format_Post_base.cpp
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#include <Format_Post_base.h>
16#include <Domaine_VF.h>
17#include <Param.h>
18
19Implemente_base(Format_Post_base,"Format_Post_base",Objet_U);
20
21/*! @brief erreur => exit
22 *
23 */
25{
26 Cerr << "Format_Post_base::printOn : error" << finl;
27 exit();
28 return os;
29}
30
32{
33 Cerr<<"Reading of data for a "<<que_suis_je()<<" post-processing format object"<<finl;
34 Param param(que_suis_je());
35 set_param(param);
36 param.lire_avec_accolades_depuis(is);
37 return is;
38}
39
40void Format_Post_base::resetTime(double t, const std::string dirname)
41{
42 if (dirname.empty())
43 {
44 Cerr << "Format '" << que_suis_je() << " does not support resetTime()!!" << finl;
45 Process::exit(-1);
46 // but LATA does :-)
47 }
48}
49
51{
52 return -1;
53}
54
55/*! @brief Initializes the file with parameters appropriate to its format (e.g. ascii format, deletes the existing file, a
56 *
57 * single file for all processors, etc.)
58 * Method to override in derived classes.
59 * Return value: 1 if the operation succeeded, 0 otherwise.
60 *
61 */
63{
64 Cerr << "Format_Post_base::initialize_by_default(" << file_basename
65 << ")\n method not coded for " << que_suis_je() << finl;
66 return 0;
67}
68
69int Format_Post_base::initialize(const Nom& file_basename, const int format, const Nom& option_para)
70{
71 Cerr << "Format_Post_base::initialize(" << file_basename
72 << ")\n method not coded for " << que_suis_je() << finl;
73 return 0;
74}
75
76/*! @brief Modification of the post processing file name.
77 * For save/restart this might also move and rename files around to avoid overriding existing files.
78 */
79int Format_Post_base::modify_file_basename(const Nom file_basename, bool for_restart, const double tinit)
80{
81 return 0;
82}
83
84int Format_Post_base::ecrire_entete(const double temps_courant,const int reprise,const int est_le_premier_post)
85{
86 Cerr << "Format_Post_base::ecrire_entete method not coded for " << que_suis_je() << finl;
87 return 0;
88}
89
90int Format_Post_base::finir(const int est_le_dernier_post)
91{
92 Cerr << "Format_Post_base::finir method not coded for " << que_suis_je() << finl;
93 return 0;
94}
95
96int Format_Post_base::init_ecriture(double temps_courant,double temps_post,
97 int est_le_premier_postraitement_pour_nom_fich_,const Domaine& domaine)
98{
99 return 1;
100}
101
102int Format_Post_base::finir_ecriture(double temps_courant)
103{
104 return 1;
105}
106
107
108
109int Format_Post_base::completer_post(const Domaine& dom,const int is_axi,
110 const Nature_du_champ& nature,const int nb_compo,const Noms& noms_compo,
111 const Motcle& loc_post,const Nom& le_nom_champ_post)
112{
113
114 Cerr << "Format_Post_base::preparer_post_champ(...)\n"
115 << " method not coded for " << que_suis_je() << finl;
116 return 0;
117
118}
119
120int Format_Post_base::preparer_post(const Nom& id_du_domaine,const int est_le_premier_post,
121 const int reprise,
122 const double t_init)
123{
124
125 Cerr << "Format_Post_base::preparer_post(...)\n"
126 << " method not coded for " << que_suis_je() << finl;
127 return 0;
128
129}
130
131
132/*! @brief Writing a mesh.
133 *
134 * The domain is written either at the beginning, before the first call to ecrire_temps, or later (dynamic mesh),
135 * but this is not necessarily supported by all post-processing formats.
136 *
137 *
138 * @param (id_domaine) the name assigned to the domain in the lata file.
139 * @param (type_elem) the type of geometric element (a type supported by the derived class; in general at least "TETRAEDRE", "HEXAEDRE", "TRIANGLE" and "RECTANGLE" are understood)
140 * @param (dimension) the dimension of the domain (number of vertex coordinates). A 3D domain may contain triangle elements (post-processing of an interface or of the boundary of a volumetric domain).
141 * @param (sommets) Vertex coordinates. If non-empty, dimension(1) must equal dimension.
142 * @param (elements) Indices of vertices for each element. dimension(1) must match the element type (3 for a triangle, 4 for a rectangle or tetrahedron, etc.)
143 */
144
145int Format_Post_base::ecrire_domaine(const Domaine& domaine,const int est_le_premier_post)
146{
147 Cerr << "Format_Post_base::ecrire_domaine(...)\n"
148 << " method not coded for " << que_suis_je() << finl;
149 return 0;
150}
151
152void Format_Post_base::ecrire_domaine_dual(const Domaine& domaine,const int est_le_premier_post)
153{
154 Cerr << "ERROR: Format_Post_base::ecrire_domaine_dual(...) method not coded for " << que_suis_je() << finl;
156}
157
158int Format_Post_base::ecrire_domaine_dis(const Domaine& domaine,const OBS_PTR(Domaine_dis_base)& domaine_dis_base,const int est_le_premier_post)
159{
160 domaine_dis_ = domaine_dis_base;
161 return ecrire_domaine(domaine, est_le_premier_post);
162}
163
164/*! @brief Starts writing a time step.
165 *
166 * The derived class must accept receiving multiple consecutive calls to this method with the same time.
167 *
168 */
169
170int Format_Post_base::ecrire_temps(const double temps)
171{
172 Cerr << "Format_Post_base::ecrire_temps(const double temps)\n"
173 << " method not coded for " << que_suis_je() << finl;
174 return 0;
175}
176
177/*! @brief Writing a field to the post-processing file.
178 *
179 * @param (id_du_champ) field identifier (allows identifying a unique field when combined with a time step number)
180 * @param (id_du_domaine) identifier of the domain on which the field is defined. This domain must have been written before by "ecrire_domaine".
181 * @param (localisation) location of field values (SOMMETS, ELEMENTS, or any other id of an already written array) (not everything is necessarily supported by all post-processing formats)
182 * @param (data) array of values to post-process. The number of rows must equal the number of rows of the "localisation" array (number of vertices, elements, faces, etc.). Return value: 1 if the operation succeeded, 0 otherwise (e.g., preconditions not met or feature not supported by the format).
183 */
184
185int Format_Post_base::ecrire_champ(const Domaine& domaine,const Noms& unite_,const Noms& noms_compo,
186 int ncomp, double temps_,
187 const Nom& id_du_champ,
188 const Nom& id_du_domaine,
189 const Nom& localisation,
190 const Nom& nature,
191 const DoubleTab& data)
192{
193 Cerr << "Format_Post_base::ecrire_champ(...)\n"
194 << " method not coded for " << que_suis_je() << finl;
195 return 0;
196}
197
198/*! @brief Writing an integer array to the post-processing file.
199 *
200 * @sa ecrire_champ
201 *
202 * @param (reference) Name of another array already written. data[i] is an index into that array (e.g., the FACES_VOISINS array can be written with localisation=FACES, reference=ELEMENTS because the array is indexed by face number and contains element indices). Writing a domain automatically creates a SOMMETS array and an ELEMENTS array.
203 * @param (reference_size) the (local) size of the referenced array (dimension(0) of the array). This dimension is used to renumber the contents of the data array to create a global numbering when all processors write to a single file.
204 */
206 const Nom& id_du_domaine,
207 const Nom& id_domaine,
208 const Nom& localisation,
209 const Nom& reference,
210 const IntVect& data,
211 const int reference_size)
212{
213 Cerr << "Format_Post_base::ecrire_champ_int(...)\n"
214 << " method not coded for " << que_suis_je() << finl;
215 return 0;
216}
217
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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 int modify_file_basename(const Nom file_basename, bool for_restart, const double tinit)
Modification of the post processing file name. For save/restart this might also move and rename files...
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
virtual void ecrire_domaine_dual(const Domaine &domaine, const int est_le_premier_post)
virtual 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)
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_dis(const Domaine &domaine, const OBS_PTR(Domaine_dis_base)&domaine_dis_base, const int est_le_premier_post)
virtual int ecrire_domaine(const Domaine &domaine, const int est_le_premier_post)
Writing a mesh.
virtual 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)
Writing an integer array to the post-processing file.
virtual int preparer_post(const Nom &id_du_domaine, const int est_le_premier_post, const int reprise, const double t_init)
OBS_PTR(Domaine_dis_base) domaine_dis_
Reference to the discretized domain - used for face fields.
virtual void set_param(Param &param) const override=0
virtual void resetTime(double t, const std::string dirname)
virtual int finir_ecriture(double temps_courant)
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
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
friend class Entree
Definition Objet_U.h:71
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52