TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Probleme_base.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 Probleme_base_included
17#define Probleme_base_included
18
19#include <Probleme_base_interface_proto.h>
20#include <Champs_compris_interface.h>
21#include <Champ_front_Parametrique.h>
22#include <Champ_Parametrique.h>
23#include <Correlation_base.h>
24#include <Probleme_Couple.h>
25#include <Postraitements.h>
26#include <Equation_base.h>
27#include <Save_Restart.h>
28#include <Milieu_base.h>
29#include <TRUST_List.h>
30#include <Probleme_U.h>
31
35class Postraitement;
36class Field_base;
37
38/*! @brief class Probleme_base It is a Probleme_U that is not a coupling.
39 *
40 * The role of a Probleme_base is the resolution on a domain of
41 * the equations that compose it.
42 * Its members are the attributes and the common methods
43 * to all classes that represent problems.
44 * A certain number of objects are associated with the problem to
45 * constitute it:
46 * - 1 or more equations: Equation object
47 * - 1 discretized domain: Domaine_Dis object
48 * - a post-processing: Postraitement object
49 * - A discretization: Discretization object
50 * - a time scheme: Schema_temp object
51 *
52 * @sa Probleme, Abstract class from which all problems must derive., Abstract methods:, int nombre_d_equations() const, const Equation_base& equation(int) const, Equation_base& equation(int)
53 */
55{
56 Declare_base_sans_destructeur(Probleme_base);
57public:
59 virtual void associer();
60 virtual Entree& lire_equations(Entree& is, Motcle& dernier_mot);
61 virtual void completer();
62 virtual int verifier();
63 virtual int nombre_d_equations() const =0;
64 virtual const Equation_base& equation(int) const =0;
65 virtual Equation_base& equation(int) =0;
66
67 // B.Mathieu: I would have liked to make these two methods virtual, but
68 // then we have to override them in all problems (function ... hidden by ...)
69 // Workaround: I create a virtual method with another name.
70 // WEC : to remove equation(Nom), we would have to modify approximately 40 classes...
71 const Equation_base& equation(const Nom&) const;
72 Equation_base& equation(const Nom&);
73 int sauvegarder(Sortie& ) const override;
74 int reprendre(Entree& ) override;
75 inline int is_sauvegarde_simple() const { return save_restart_.is_sauvegarde_simple(); }
76 inline const Nom& restart_filename() const { return save_restart_.restart_filename(); }
77 inline const Nom& checkpoint_filename() const { return save_restart_.checkpoint_filename(); }
78 inline const Nom& checkpoint_format() const { return save_restart_.checkpoint_format(); }
79 inline const Nom& yaml_filename() const { return save_restart_.yaml_filename(); }
80
81 virtual const Equation_base& get_equation_by_name(const Nom&) const;
83 virtual const Milieu_base& milieu() const;
84 virtual Milieu_base& milieu();
85 virtual double calculer_pas_de_temps() const;
86 virtual void mettre_a_jour(double temps) ;
87 virtual void preparer_calcul() ;
88 virtual void imprimer(Sortie& os) const; // Calls print on each equation
89
90 // Methods for accessing private members.
91 int associer_(Objet_U&) override;
92 virtual void associer_sch_tps_base(const Schema_Temps_base&);
93 virtual void associer_domaine(const Domaine&);
94 virtual void associer_milieu_base(const Milieu_base&);
95 virtual void discretiser(Discretisation_base&);
96 virtual void discretiser_equations();
97 virtual void finir();
98
99 inline std::vector<OWN_PTR(Milieu_base)>& milieu_vect() { return le_milieu_; }
100 inline const std::vector<OWN_PTR(Milieu_base)>& milieu_vect() const { return le_milieu_; }
101
102 const Schema_Temps_base& schema_temps() const;
104 const Domaine& domaine() const;
105 Domaine& domaine();
106 bool has_domaine_dis() const { return bool(le_domaine_dis_); }
107 const Domaine_dis_base& domaine_dis() const;
109 bool is_dilatable() const;
110
111 inline const Discretisation_base& discretisation() const;
113 inline const Postraitements& postraitements() const { return les_postraitements_; }
114 void init_postraitements();
115 virtual int expression_predefini(const Motcle& motlu, Nom& expression);
116
117 inline const char* reprise_format_temps() const { return save_restart_.reprise_format_temps(); }
118 inline bool& reprise_effectuee() { return save_restart_.reprise_effectuee(); }
119 inline bool reprise_effectuee() const { return save_restart_.reprise_effectuee(); }
120
121 //Methods of the post-processable fields interface
122 /////////////////////////////////////////////////////
123 void creer_champ(const Motcle& motlu) override;
124 const Champ_base& get_champ(const Motcle& nom) const override;
125 void get_noms_champs_postraitables(Noms& nom,Option opt=NONE) const override;
126 bool has_champ(const Motcle& nom, OBS_PTR(Champ_base) &ref_champ) const override;
127 bool has_champ(const Motcle& nom) const override;
128 /////////////////////////////////////////////////////
129
130 //To access a field from the list held by the post-processing.
131 virtual const Champ_Generique_base& get_champ_post(const Motcle& nom) const;
132 virtual bool has_champ_post(const Motcle& nom) const;
133 virtual int comprend_champ_post(const Motcle& nom) const;
134
135 // Search functions for IntTab for post-processing
136 virtual int a_pour_IntVect(const Motcle&, OBS_PTR(IntVect)& ) const;
137 virtual void lire_postraitement_interfaces(Entree& is);
138 virtual void postraiter_interfaces(const Nom& nom_fich, Sortie& s, const Nom& format, double temps);
139
140 virtual void addInputField(Field_base& f) { addInputField_impl(*this, f); }
141
142 bool is_coupled() const { return bool(pbc_); }
143 virtual inline bool has_mod_rayo_transp() const { return false; }
144
145 int postraiter(int force = 1) override;
146 int limpr() const override;
147 int lsauv() const override;
148 void sauver() const override;
149 virtual void allocation() const final;
150
151 //////////////////////////////////////////////////
152 // //
153 // Implementation of the Probleme_U interface //
154 // //
155 //////////////////////////////////////////////////
156
157 // interface Problem
158 void initialize() override { initialize_impl(*this); }
160 void terminate() override { terminate_impl(*this); }
161
162 // interface UnsteadyProblem
163 double presentTime() const override { return presentTime_impl(*this); }
164 double computeTimeStep(bool& stop) const override { return computeTimeStep_impl(*this, stop); }
165 bool initTimeStep(double dt) override { return initTimeStep_impl(*this, dt); }
166 bool solveTimeStep() override { return solveTimeStep_impl(*this); }
168 bool isStationary() const override { return isStationary_impl(*this); }
169 std::string newCompute() override;
170 void validateTimeStep() override { validateTimeStep_impl(*this); }
171 void setStationary(bool flag) override { schema_temps().set_stationnaires_atteints(flag); }
172 void abortTimeStep() override { abortTimeStep_impl(*this); }
173 void resetTime(double time) override;
174
175 void getOutputPointValues(const Nom& name,
176 const std::vector<double>& x,
177 const std::vector<double>& y,
178 const std::vector<double>& z,
179 std::vector<double>& vals, int compo) override;
180
181 // interface IterativeUnsteadyProblem
182 bool iterateTimeStep(bool& converged) override { return iterateTimeStep_impl(*this, converged); }
183
184 // interface FieldIO
185 void getInputFieldsNames(Noms& noms) const override { getInputFieldsNames_impl(*this, noms); }
186 void getOutputFieldsNames(Noms& noms) const override { getOutputFieldsNames_impl(*this, noms); }
187
188 // interface Probleme_U
189 bool updateGivenFields() override { return updateGivenFields_impl(*this); }
190 double futureTime() const override { return futureTime_impl(*this); }
191
192 OBS_PTR(Field_base) findInputField(const Nom& name) const override { return findInputField_impl(*this, name); }
193 OBS_PTR(Champ_Generique_base) findOutputField(const Nom& name) const override { return findOutputField_impl(*this, name); }
194
195 void associer_pb_couple(const Probleme_Couple& pbc) { pbc_ = pbc; }
196 const Probleme_Couple& get_pb_couple() const { return pbc_; }
197 Probleme_Couple& get_pb_couple() { return pbc_; }
198 LIST(OBS_PTR(SFichier))& get_set_out_files() const { return out_files_ ; }
199
200 const Correlation_base& get_correlation(std::string nom_correlation) const
201 {
202 Motcle mot(nom_correlation);
203 return correlations_.at(mot.getString());
204 }
205
206 int has_correlation(std::string nom_correlation) const
207 {
208 Motcle mot(nom_correlation);
209 return (int)correlations_.count(mot.getString());
210 }
211
212protected :
213
214 virtual void typer_lire_milieu(Entree& is) ;
215 virtual void lire_solved_equations(Entree& is) { /* Do nothing */ }
217 virtual Entree& lire_correlations(Entree& is);
218 virtual Entree& lire_radiation_models(Entree& is, Motcle& mot);
219
221 std::vector<OWN_PTR(Milieu_base)> le_milieu_;
222 OBS_PTR(Domaine_dis_base) le_domaine_dis_; // Discretized domain. Just a REF since Domaine_dis_cache is the real owner.
224 OBS_PTR(Domaine) le_domaine_;
225 OBS_PTR(Schema_Temps_base) le_schema_en_temps_;
226 OBS_PTR(Discretisation_base) la_discretisation_;
228 mutable LIST(OBS_PTR(SFichier)) out_files_; // List of SFichier to close (.out)
229 std::map<std::string, OWN_PTR(Correlation_base)> correlations_;
230
231 LIST(OBS_PTR(Loi_Fermeture_base)) liste_loi_fermeture_; // list of closure laws associated with the problem
232 LIST(OBS_PTR(Champ_Parametrique)) Champs_Parametriques_; //Parametric fields to update when the current computation is done
233 LIST(OWN_PTR(Equation_base)) eq_opt_; //other equations (turbulence, interfacial area...)
234};
235
236/*! @brief Returns the discretization associated with the problem.
237 *
238 * @return (Discretisation_base&) discretization associated with the problem
239 * @throws if the discretization has not been built
240 */
242{
243 if(!la_discretisation_)
244 {
245 Cerr << que_suis_je() << " has not been discretized!" << finl;
246 exit();
247 }
248 return la_discretisation_.valeur();
249}
250
251#endif /* Probleme_base_included */
class Champ_Generique_base
: class Champ_Parametrique
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Champs_compris_interface This class contains an interface of methods intended to manage
class Discretisation_base This class represents a spatial discretization scheme, which
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Writing to a shared file. This class derives from Ecr_Fic_Par, using binary output.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
: Base class of closure laws.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
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
friend class Sortie
Definition Objet_U.h:70
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
class Postraitement. The class holds -a list of generic fields champs_post_complet_ containing
Probleme_Couple This is the historical coupling class of TRUST.
Probleme_U.
Definition Probleme_U.h:46
virtual bool solveTimeStep()
For possible re-implementation and unified call from python.
void getInputFieldsNames_impl(const Probleme_base &pb, Noms &noms) const
void getOutputFieldsNames_impl(const Probleme_base &pb, Noms &noms) const
bool initTimeStep_impl(Probleme_base &pb, double dt)
bool iterateTimeStep_impl(Probleme_base &pb, bool &converged)
double futureTime_impl(const Probleme_base &pb) const
double presentTime_impl(const Probleme_base &pb) const
bool isStationary_impl(const Probleme_base &pb) const
double computeTimeStep_impl(const Probleme_base &pb, bool &stop) const
void addInputField_impl(Probleme_base &pb, Field_base &f)
class Probleme_base It is a Probleme_U that is not a coupling.
int sauvegarder(Sortie &) const override
Writing of the problem to file for restart.
int limpr() const override
Asks the time scheme if a print is needed.
const bool & is_probleme_base_initialized() const
virtual void associer_milieu_base(const Milieu_base &)
Associates a physical medium with the problem equations.
bool has_domaine_dis() const
virtual Entree & lire_equations(Entree &is, Motcle &dernier_mot)
Reading of the equations of the problem.
void setStationary(bool flag) override
Tells to the Problem that stationary is reached or not.
virtual void typer_lire_milieu(Entree &is)
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
Probleme_Couple & get_pb_couple()
void getOutputPointValues(const Nom &name, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, std::vector< double > &vals, int compo) override
virtual void discretiser(Discretisation_base &)
Assigns a discretization to the problem Discretizes the Domain associated with the problem with the d...
double presentTime() const override
Returns the present time.
LIST(OBS_PTR(SFichier)) &get_set_out_files() const
OBS_PTR(Champ_Generique_base) findOutputField(const Nom &name) const override
std::string newCompute() override
Searches for parametric fields and for each, moves to the next parameter.
virtual void lire_postraitement_interfaces(Entree &is)
bool iterateTimeStep(bool &converged) override
In the case solveTimeStep uses an iterative process, this method executes a single iteration.
const Nom & checkpoint_filename() const
virtual void associer_domaine(const Domaine &)
Associates a domain with the problem.
virtual void discretiser_equations()
void initialize() override
This method is called once at the beginning, before any other one of the interface Problem.
double futureTime() const override
Returns the future time (end of current computing interval) This value is valid between initTimeStep ...
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
int postraiter(int force=1) override
If force=1, performs post-processing regardless of the post-processing frequencies.
void associer_pb_couple(const Probleme_Couple &pbc)
virtual void addInputField(Field_base &f)
virtual void postraiter_interfaces(const Nom &nom_fich, Sortie &s, const Nom &format, double temps)
LIST(OBS_PTR(Champ_Parametrique)) Champs_Parametriques_
bool is_dilatable() const
bool reprise_effectuee() const
void creer_champ(const Motcle &motlu) override
LIST(OBS_PTR(SFichier)) out_files_
void getOutputFieldsNames(Noms &noms) const override
int associer_(Objet_U &) override
override Objet_U::associer_(Objet_U& ob) Associates different objects with the problem by checking
const Nom & checkpoint_format() const
virtual Entree & lire_correlations(Entree &is)
void sauver() const override
Writes to file for restart (backup).
const Domaine & domaine() const
Returns the domain associated with the problem.
const Champ_base & get_champ(const Motcle &nom) const override
Entree & read_optional_equations(Entree &is, Motcle &mot)
bool solveTimeStep() override
For possible re-implementation and unified call from python.
bool updateGivenFields() override
WARNING:
const Nom & yaml_filename() const
virtual bool has_champ_post(const Motcle &nom) const
virtual void preparer_calcul()
Prepares the computation: initializes the medium parameters and prepares the computation of each equa...
const Discretisation_base & discretisation() const
Returns the discretization associated with the problem.
void init_postraitements()
Flags the first and last post-processing for each file And initializes the post-processing.
const Probleme_Couple & get_pb_couple() const
void abortTimeStep() override
Aborts the resolution of the current time step.
Postraitements & postraitements()
virtual double calculer_pas_de_temps() const
Computes the value of the next time step for the problem.
Postraitements les_postraitements_
virtual int a_pour_IntVect(const Motcle &, OBS_PTR(IntVect)&) const
const std::vector< OWN_PTR(Milieu_base)> & milieu_vect() const
virtual int comprend_champ_post(const Motcle &nom) const
virtual void mettre_a_jour(double temps)
Performs a time update of the problem.
Save_Restart save_restart_
void resetTime(double time) override
Reset the current time of the Problem to a given value.
int lsauv() const override
Asks the time scheme if a backup is needed.
OBS_PTR(Schema_Temps_base) le_schema_en_temps_
int has_correlation(std::string nom_correlation) const
virtual void allocation() const final
Verifies that the necessary disk space exists.
OBS_PTR(Domaine) le_domaine_
virtual void associer_sch_tps_base(const Schema_Temps_base &)
Associates a time scheme with the problem.
bool is_coupled() const
virtual void finir()
Finalizes post-processing and saves the problem to a file.
LIST(OBS_PTR(Loi_Fermeture_base)) liste_loi_fermeture_
OBS_PTR(Probleme_Couple) pbc_
virtual bool has_mod_rayo_transp() const
int is_sauvegarde_simple() const
const Correlation_base & get_correlation(std::string nom_correlation) const
virtual const Champ_Generique_base & get_champ_post(const Motcle &nom) const
bool & reprise_effectuee()
std::vector< OWN_PTR(Milieu_base)> le_milieu_
virtual const Milieu_base & milieu() const
Returns the physical medium associated with the problem (const version).
virtual Equation_base & equation(int)=0
std::map< std::string, OWN_PTR(Correlation_base)> correlations_
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
const Postraitements & postraitements() const
LIST(OWN_PTR(Equation_base)) eq_opt_
void terminate() override
This method is called once at the end, after any other one.
virtual int nombre_d_equations() const =0
OBS_PTR(Domaine_dis_base) le_domaine_dis_
OBS_PTR(Field_base) findInputField(const Nom &name) const override
virtual Entree & lire_radiation_models(Entree &is, Motcle &mot)
virtual const Equation_base & equation(int) const =0
virtual void imprimer(Sortie &os) const
Prints the equations associated with the problem if the associated time scheme indicates that it is n...
virtual int verifier()
Verifies that the object is complete, coherent, .
virtual void completer()
Completes the equations associated with the problem.
bool initTimeStep(double dt) override
This method allocates and initializes the unknown and given fields for the future time step.
OBS_PTR(Discretisation_base) la_discretisation_
void getInputFieldsNames(Noms &noms) const override
This method is used to find the names of input fields understood by the Problem.
virtual int expression_predefini(const Motcle &motlu, Nom &expression)
bool isStationary() const override
Tells if the Problem unknowns have changed during the last time step.
virtual void lire_solved_equations(Entree &is)
const Domaine_dis_base & domaine_dis() const
Returns the discretized domain associated with the problem (const version).
const char * reprise_format_temps() const
virtual const Equation_base & get_equation_by_name(const Nom &) const
(B. Math): Virtual method added for problems having several equations of the same type (Probleme_FT_D...
int reprendre(Entree &) override
Reading of an input stream (file) for restart after a backup with Probleme_base::sauvegarder(Sortie& ...
double computeTimeStep(bool &stop) const override
Compute the value the Problem would like for the next time step.
bool solveTimeStep_pbU()
virtual void associer()
Associates the problem with all its equations.
virtual Equation_base & getset_equation_by_name(const Nom &)
(B. Math): Virtual method added for problems having several equations of the same type (Probleme_FT_D...
void validateTimeStep() override
Validates the calculated unknown by moving the present time at the end of the time step.
const Nom & restart_filename() const
std::vector< OWN_PTR(Milieu_base)> & milieu_vect()
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
class Schema_Temps_base
void set_stationnaires_atteints(bool flag)
Base class for output streams.
Definition Sortie.h:52