TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Postraitement.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 Postraitement_included
17#define Postraitement_included
18
19#include <Operateurs_Statistique_tps.h>
20#include <Champ_Gen_de_Champs_Gen.h>
21#include <Liste_Champ_Generique.h>
22#include <Postraitement_base.h>
23#include <Schema_Temps_base.h>
24#include <Format_Post_base.h>
25#include <Probleme_base.h>
26#include <Champs_Fonc.h>
27#include <Sondes_Int.h>
28#include <TRUST_List.h>
29#include <Interprete.h>
30#include <TRUST_Ref.h>
31#include <Parser_U.h>
32#include <Sondes.h>
33
34/*! @brief class Postraitement. The class holds -a list of generic fields champs_post_complet_ containing
35 *
36 * all generic fields for post-processing
37 * -a list of identifiers noms_champs_a_post_ containing the identifiers
38 * of the fields to post-process
39 *
40 * -Reading of generic fields declared in the "definition_champs" block (added to champs_post_complet_)
41 * and adding to this list the fields created by macro (triggered by old syntax in "champs" and "statistiques")
42 * Building the identifier list noms_champs_a_post_ during the reading operations
43 * -Updating generic fields, in practice updating the statistical operators for fields that carry one
44 * -post-processing performed in postraiter_champs()
45 * Iterating over identifiers
46 * The generic field corresponding to an identifier is retrieved by: get_champ_post("identifiant")
47 * For this generic field: field values to write are computed by: get_champ(espace_stockage)
48 * supplementary info is retrieved by: get_property(), get_time() ...
49 * Writing the computed values: postraiter(...)
50 *
51 *
52 * The macros used for creating generic fields are detailed in the .cpp of the class.
53 * See creer_champ_post() and creer_champ_post_stat()
54 *
55 *
56 * @sa Hierarchy of generic fields (Champ_Generique_base), Syntax to follow in the data file, Postraitement {, Sondes, {, ..., }, Definition_champs, {, //Specification of generic fields, }, Champs, {, -Creation of generic field by macro if using old syntax (e.g. vitesse elem) and adding, identifier to noms_champs_a_post_ list, -Adding to the noms_champs_a_post_ list for a field declared in the "definition_champs" block, }, Statistiques, {, t_deb val_1 t_fin_val_2, -Creation of generic field by macro if using old syntax (e.g. Moyenne vitesse elem) and adding, identifier to noms_champs_a_post_ list, }, }
57 */
59{
60 Declare_instanciable_sans_constructeur(Postraitement);
61public:
62 //
63 // Overriding methods:
64 //
65 void associer_nom_et_pb_base(const Nom&, const Probleme_base&) override;
66 void postraiter(int forcer) override;
67 void mettre_a_jour(double temps) override;
68 void finir() override;
69 std::vector<YAML_data> data_a_sauvegarder() const override;
70 int sauvegarder(Sortie& os) const override;
71 int reprendre(Entree& is) override;
72 void completer() override;
73 void completer_sondes() override;
74 void init() override;
75 void set_param(Param& param) const override;
76 int lire_motcle_non_standard(const Motcle&, Entree&) override;
77 void resetTime(double t, const std::string dirname) override;
78
79 // specifique cgns : avoid duplicated file names
80 void modify_cgns_basenames_and_reinit(const int, const int);
81
82 //
83 // Specific methods:
84 //
86
87 inline const Sondes& les_sondes() const { return les_sondes_; }
88 inline Sondes& les_sondes() { return les_sondes_; }
89 inline Probleme_base& probleme() { return mon_probleme.valeur(); }
90 inline const Probleme_base& probleme() const { return mon_probleme.valeur(); }
91
93 int traiter_sondes();
94 virtual int postraiter_champs();
95 // Called by postraiter_champs - only deal with the writing of the field values, not the geometrical parts:
96 virtual void postprocess_field_values();
97
98 int traiter_champs();
99 virtual int lire_champs_a_postraiter(Entree& is, bool expect_acco); //Optionally triggers creation of generic fields by macro
100 //and builds the noms_champs_a_post_ list of post-processed fields
101 int lire_champs_stat_a_postraiter(Entree&, bool expect_acco); //same for statistics
102 int lire_champs_operateurs(Entree& is); //Reads a generic field, named and completed
103 void complete_champ(Champ_Generique_base& champ,const Motcle& motlu);
105 int traiter_tableaux();
107 inline int lpost(double, double) const;
108 inline int lpost_champ(double) const;
109 inline int lpost_stat(double) const;
110 inline int ind_post(int nb_pas_dt) const { return (nb_pas_dt%nb_pas_dt_post_==0) ? 1 : 0; }
111 int nb_pas_dt_post() const { return nb_pas_dt_post_; }
112
113 inline double dt_post() const { return dt_post_; }
114 inline const Nom& format() const { return format_; }
115 inline Nom nom_fich() const { return nom_fich_; }
116 static inline LIST(Nom)& noms_fichiers_sondes() { return noms_fichiers_sondes_; }
120 inline int sondes_demande() { return sondes_demande_; }
121 inline int champs_demande() { return champs_demande_; }
122 inline int stat_demande() const { return stat_demande_; }
124 inline int tableaux_demande() { return tableaux_demande_; }
126 inline LIST(Nom)& noms_champs_a_post() { return noms_champs_a_post_; }
128
129 //We distinguish post-processing of an array and of a tensor
130 int postraiter(const Domaine& dom,const Noms& unites,const Noms& noms_compo,const int ncomp,
131 const double temps,
132 Nom nom_post,const Nom& localisation,const Nom& nature,const DoubleTab& valeurs,int tenseur);
133
134 int postraiter_tableau(const Domaine& dom,const Noms& unites,const Noms& noms_compo,const int ncomp,
135 const double temps,
136 Nom nom_post,const Nom& localisation,const Nom& nature,const DoubleTab& valeurs);
137
138 int postraiter_tenseur(const Domaine& dom,const Noms& unites,const Noms& noms_compo,const int ncomp,
139 const double temps,
140 Nom nom_post,const Nom& localisation,const Nom& nature,const DoubleTab& valeurs);
141
142
143 virtual const Champ_Generique_base& get_champ_post(const Motcle& nom) const;
144 virtual bool has_champ_post(const Motcle& nom) const;
145
146 Nom set_expression_champ(const Motcle& motlu1,const Motcle& motlu2,
147 const Motcle& motlu3,const Motcle& motlu4,
148 const int trouve);
149
150 //Macro methods to generate the creation of:
151 //-Champ_Generique_Interpolation
152 void creer_champ_post(const Motcle& motlu1,const Motcle& motlu2,Entree& s);
153 //-Champ_Generique_Interpolation_Statistiques
154 void creer_champ_post_stat(const Motcle& motlu1,const Motcle& motlu2,const Motcle& motlu3,const Motcle& motlu4,const double t_deb, const
155 double t_fin,Entree& s);
156 //-Champ_Generique_Morceau_Equation
157 void creer_champ_post_moreqn(const Motcle& type,const Motcle& option,const int num_eq,const int num_morceau,const int compo,Entree& s);
158
159 //Macro method for the case of med fields
160 void creer_champ_post_med(const Motcle& motlu1,const Motcle& motlu2,Entree& s);
161
162 //Method comprend_champ_post() which indicates if the identifier corresponds to the name of a Champ_Generique_base
163 //or to one of its components - sources are tested recursively
164 int comprend_champ_post(const Motcle& identifiant) const;
165
166 //temporaire a reviser
168 static Nom get_nom_localisation(const Entity& loc);
169
171 operateur_statistique) const;
172
173 inline int& compteur_champ_stat();
174 inline const double& tstat_deb() const;
175 inline const double& tstat_fin() const;
177
178 /*! Calls by postraiter_champs() and allows a derived class to write extra meshes if needed
179 * @return -1 if nothing more was written, 1 otherwise.
180 */
181 virtual int write_extra_mesh() { return -1; }
182 const OBS_PTR(Domaine)& domaine() { return le_domaine_; }
183 int DeprecatedKeepDuplicatedProbes=0; // Ancien format des sondes dans les .son qui autorise les sondes dupliquees
184
185protected:
186
188 double dt_post_; ///< output of data (fields, stats, int_array) every dt_post (a time interval)
189 int nb_pas_dt_post_; ///< output of data (fields, stats, int_array) every dt_post (a period in number of iterations)
191
192 Sondes les_sondes_; // Probes to process
193 Sondes_Int les_sondes_int_; // Probes for integer arrays
194 Operateurs_Statistique_tps les_statistiques_; // List of statistical operators to process
195
196 LIST(Nom) noms_champs_a_post_; //contains the identifiers of fields to post-process
197 Liste_Champ_Generique champs_post_complet_; //contains all generic fields dedicated to post-processing
198
199 //attributes for save-restart
200 //redundant with attributes of Champ_Generique_Statistiques
201 //The entire save-restart process should be managed by the statistical field
204
205 //Option to be managed by the statistical field
208
209 LIST(OBS_PTR(IntVect)) tableaux_a_postraiter_; // Liste de references a des tableaux a post-traiter
210 LIST(Nom) noms_tableaux_;
211
213 std::vector<std::string> locs_required_;
214 void add_locs_required_if_not(const Motcle& );
215
216 static LIST(Nom) noms_fichiers_sondes_;
220 Nom suffix_for_reset_; // Suffix appended to post base name when the method resetTime() was invoked - default to "_AFTER_RESET"
221 double temps_, dernier_temps_; // time of the previous call to postraiter()
222 OBS_PTR(Domaine) le_domaine_;
223 OBS_PTR(Domaine_dis_base) domaine_dis_pour_faces_;
224};
225
226
227inline int Postraitement::lpost(double temps_courant, double dt_post) const
228{
229 double epsilon = 1.e-8;
230 if (dt_post<=temps_courant - dernier_temps_)
231 return 1;
232 else
233 {
234 // See Schema_Temps_base::limpr for information about epsilon and modf
235 double i, j;
236 modf(temps_courant/dt_post + epsilon, &i);
237 modf(dernier_temps_/dt_post + epsilon, &j);
238 return ( i>j );
239 }
240}
241
242/*! @brief Post-processing test taking into account the time evolution of the field.
243 *
244 * Returns TRUE if the field requires post-processing, given
245 * the current time and the time step provided.
246 *
247 * @param (double temps_courant) current time
248 * @param (double dt) the time step just completed
249 * @return (int) boolean value, TRUE if the time step and current time provided indicate that post-processing is needed, FALSE otherwise.
250 */
252inline const double& Postraitement::tstat_deb() const { return tstat_deb_; }
253inline const double& Postraitement::tstat_fin() const { return tstat_fin_; }
254
255#endif /* Postraitement_included */
Base class of generic fields having other generic fields as source. The use of the class methods reli...
class Champ_Generique_base
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
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).
List_Champ_Generique Represents a list of Champ_Generique_base objects.
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
friend class Sortie
Definition Objet_U.h:70
class Operateur_Statistique_tps_base
class Operateurs_Statistique_tps
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
class Parser_U Version of the Parser class, deriving from Objet_U.
Definition Parser_U.h:32
LIST(Nom) noms_champs_a_post_
double tstat_dernier_calcul_
LIST(OBS_PTR(IntVect)) tableaux_a_postraiter_
void associer_nom_et_pb_base(const Nom &, const Probleme_base &) override
LIST(Nom) noms_tableaux_
static Nom get_nom_localisation(const Entity &loc)
Operateurs_Statistique_tps & les_statistiques()
int lpost(double, double) const
OBS_PTR(Domaine) le_domaine_
int postraiter_tableau(const Domaine &dom, const Noms &unites, const Noms &noms_compo, const int ncomp, const double temps, Nom nom_post, const Nom &localisation, const Nom &nature, const DoubleTab &valeurs)
Operateurs_Statistique_tps les_statistiques_
int est_le_premier_postraitement_pour_nom_fich_
void mettre_a_jour(double temps) override
const Sondes & les_sondes() const
const OBS_PTR(Domaine) &domaine()
int & compteur_champ_stat()
Post-processing test taking into account the time evolution of the field.
Probleme_base & probleme()
double dt_post() const
virtual int write_extra_mesh()
int comprend_champ_post(const Motcle &identifiant) const
int reprendre(Entree &is) override
Restores an Objet_U from an input stream. Virtual method to override.
OBS_PTR(Domaine_dis_base) domaine_dis_pour_faces_
int lire_champs_stat_a_postraiter(Entree &, bool expect_acco)
int stat_demande_definition_champs() const
int lire_tableaux_a_postraiter(Entree &)
void completer_sondes() override
int est_le_dernier_postraitement_pour_nom_fich_
int sauvegarder(Sortie &os) const override
Saves an Objet_U to an output stream. Virtual method to override.
OWN_PTR(Format_Post_base) format_post_
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void modify_cgns_basenames_and_reinit(const int, const int)
virtual int lire_champs_a_postraiter(Entree &is, bool expect_acco)
Lit le nom des champs a postraiter sur un flot d'entree.
Sondes_Int les_sondes_int_
int traiter_champs()
Effectue le postraitement des Champs si cela est necessaire.
int nb_pas_dt_post_
output of data (fields, stats, int_array) every dt_post (a period in number of iterations)
bool stat_demande_definition_champs_
const double & tstat_deb() const
int cherche_stat_dans_les_sources(const Champ_Gen_de_Champs_Gen &ch, Motcle nom)
On recherche les champs statistiques dans les sources du champ courant.
void postraiter(int forcer) override
const Probleme_base & probleme() const
void verifie_nom_et_sources(const Champ_Generique_base &champ)
void creer_champ_post_med(const Motcle &motlu1, const Motcle &motlu2, Entree &s)
int stat_demande() const
virtual void postprocess_field_values()
int lpost_champ(double) const
Nom nom_fich() const
virtual const Champ_Generique_base & get_champ_post(const Motcle &nom) const
std::vector< std::string > locs_required_
int DeprecatedKeepDuplicatedProbes
void add_locs_required_if_not(const Motcle &)
double dernier_temps_
LIST(Nom) &noms_champs_a_post()
void completer() override
virtual int postraiter_champs()
Effectue le postraitement des Champs de facon imperative.
int postraiter_sondes()
Effectue le postraitement lie au sondes de facon imperative.
int & est_le_dernier_postraitement_pour_nom_fich()
Sondes & les_sondes()
int lire_champs_operateurs(Entree &is)
Lit les champs a postraiter sur un flot d'entree.
int traiter_sondes()
Mets a jour (en temps) le sondes.
void init() override
Initializes the post-processing.
void creer_champ_post_moreqn(const Motcle &type, const Motcle &option, const int num_eq, const int num_morceau, const int compo, Entree &s)
void creer_champ_post_stat(const Motcle &motlu1, const Motcle &motlu2, const Motcle &motlu3, const Motcle &motlu4, const double t_deb, const double t_fin, Entree &s)
Parser_U fdt_post_
int postraiter_tenseur(const Domaine &dom, const Noms &unites, const Noms &noms_compo, const int ncomp, const double temps, Nom nom_post, const Nom &localisation, const Nom &nature, const DoubleTab &valeurs)
int champ_fonc(Motcle &nom_champ, OBS_PTR(Champ_base)&mon_champ, OBS_PTR(Operateur_Statistique_tps_base)&operateur_statistique) const
const Nom & format() const
const double & tstat_fin() const
virtual bool has_champ_post(const Motcle &nom) const
void complete_champ(Champ_Generique_base &champ, const Motcle &motlu)
void finir() override
Finalise le postraitement Ferme le fichier associe.
static LIST(Nom) noms_fichiers_sondes_
int nb_pas_dt_post() const
int ind_post(int nb_pas_dt) const
std::vector< YAML_data > data_a_sauvegarder() const override
for PDI IO: retrieve name, type and dimensions of the fields to save/restore
double dt_integr_serie_
Liste_Champ_Generique champs_post_complet_
void set_param(Param &param) const override
int lpost_stat(double) const
void creer_champ_post(const Motcle &motlu1, const Motcle &motlu2, Entree &s)
static LIST(Nom) &noms_fichiers_sondes()
Postraitement()
Default constructor.
int & est_le_premier_postraitement_pour_nom_fich()
const Liste_Champ_Generique & champs_post_complet() const
double dt_post_
output of data (fields, stats, int_array) every dt_post (a time interval)
Nom set_expression_champ(const Motcle &motlu1, const Motcle &motlu2, const Motcle &motlu3, const Motcle &motlu4, const int trouve)
void resetTime(double t, const std::string dirname) override
bool besoin_postraiter_champs()
class Probleme_base It is a Probleme_U that is not a coupling.
class Sondes_Int
Definition Sondes_Int.h:29
class Sondes
Definition Sondes.h:32