TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Probleme_FT_Disc_gen.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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#include <Convection_Diffusion_Temperature_FT_Disc.h>
17#include <Convection_Diffusion_Concentration.h>
18#include <Transport_Interfaces_FT_Disc.h>
19#include <Triple_Line_Model_FT_Disc.h>
20#include <Dirichlet_paroi_defilante.h>
21#include <Probleme_FT_Disc_gen.h>
22#include <Dirichlet_paroi_fixe.h>
23#include <Constituant.h>
24#include <TRUST_List.h>
25#include <Chimie.h>
26
27Implemente_instanciable(Probleme_FT_Disc_gen, "Probleme_FT_Disc_gen|Pb_FrontTracking_Disc", Pb_Fluide_base);
28
29// XD listdeuxmots_acc listobj nul BRACE deuxmots 0 List of groups of two words (with curly brackets).
30
31// XD Pb_FrontTracking_Disc problem_read_generic probleme_ft_disc_gen INHERITS_BRACE The generic Front-Tracking problem
32// XD_CONT in the discontinuous version. It differs from the rest of the TRUST code : The problem does not state the
33// XD_CONT number of equations that are enclosed in the problem. Two equations are compulsory : a momentum balance
34// XD_CONT equation (alias Navier-Stokes equation) and an interface tracking equation. The list of equations to be
35// XD_CONT solved is declared in the beginning of the data file. Another difference with more classical TRUST data file,
36// XD_CONT lies in the fluids definition. The two-phase fluid (Fluide_Diphasique) is made with two usual single-phase
37// XD_CONT fluids (Fluide_Incompressible). As the list of equations to be solved in the generic Front-Tracking problem
38// XD_CONT is declared in the data file and not pre-defined in the structure of the problem, each equation has to be
39// XD_CONT distinctively associated with the problem with the Associer keyword.
40// XD attr solved_equations listdeuxmots_acc solved_equations REQ List of sovled equations in the form 'equation_type'
41// XD_CONT 'equation_alias'
42// XD attr fluide_incompressible fluide_incompressible fluide_incompressible OPT The fluid medium associated with the
43// XD_CONT problem.
44// XD attr fluide_diphasique fluide_diphasique fluide_diphasique OPT The diphasic fluid medium associated with the
45// XD_CONT problem.
46// XD attr constituant constituant constituant OPT Constituent.
47// XD attr Triple_Line_Model_FT_Disc Triple_Line_Model_FT_Disc Triple_Line_Model_FT_Disc OPT not_set
48
49Sortie& Probleme_FT_Disc_gen::printOn(Sortie& os) const { return os; }
51
53{
54 if (sub_type(Chimie, ob))
55 {
56 la_chimie_ = ref_cast(Chimie, ob);
57 return 1;
58 }
59 else
61}
62
64{
65 /* Step 1 : special FT : read the list of equations to solve ... */
66 // Here are all possible equations !!!
67 Noms noms_eq, noms_eq_maj;
68 Type_info::les_sous_types(Nom("Equation_base"), noms_eq);
69 for (auto &itr : noms_eq) noms_eq_maj.add(Motcle(itr)); //ha ha ha
70
71 Motcle read_mc;
72 Nom nom_eq;
73
74 is >> read_mc;
75
76 if (read_mc != "SOLVED_EQUATIONS")
77 {
78 Cerr << "Error in Probleme_FT_Disc_gen::lire_solved_equations !!! We expected reading the SOLVED_EQUATIONS bloc instead of " << read_mc << " !!!" << finl;
79 Cerr << "Fix your data file !!!" << finl;
81 }
82
83 is >> read_mc;
84 if (read_mc != "{")
85 {
86 Cerr << "Error in Probleme_FT_Disc_gen::lire_solved_equations !!! We expected { instead of " << read_mc << " !!!" << finl;
87 Cerr << "Fix your data file !!!" << finl;
89 }
90
91 std::vector<Nom> eq_types, eq_name;
92
93 for (is >> read_mc; read_mc != "}"; is >> read_mc)
94 {
95 if (noms_eq_maj.rang(read_mc) == -1 || (!read_mc.contient("_FT") && !read_mc.debute_par("CONVECTION_DIFFUSION_CONCENTRATION") && !read_mc.debute_par("CONVECTION_DIFFUSION_TEMPERATURE")))
96 {
97 Cerr << "Error in Probleme_FT_Disc_gen::lire_solved_equations !!! The equation " << read_mc << " could not be used with a problem of type " << que_suis_je() << " !!!" << finl;
98 Cerr << "You can only use the following equations :" << finl;
99 for (auto &itr : noms_eq_maj)
100 if (itr.contient("_FT") || itr.debute_par("CONVECTION_DIFFUSION_CONCENTRATION") || itr.debute_par("CONVECTION_DIFFUSION_TEMPERATURE"))
101 Cerr << " - " << itr << finl;
103 }
104
105 eq_types.push_back(read_mc);
106 is >> nom_eq;
107 eq_name.push_back(nom_eq);
108 }
109
110 if (eq_types.size() != eq_name.size())
111 {
112 Cerr << "Error in Probleme_FT_Disc_gen::lire_solved_equations !!! The number of strings read in the bloc SOLVED_EQUATIONS is not correct !!!" << finl;
113 Cerr << "Fix your data file !!!" << finl;
115 }
116
117 /* Step 2 : add equations to the list ... */
118 /* Add NAVIER_STOKES_FT_DISC at first */
119 for (int i = 0; i < static_cast<int>(eq_types.size()); i++)
120 if (eq_types[i] == "NAVIER_STOKES_FT_DISC")
121 add_FT_equation(eq_name[i], eq_types[i]);
122
123 /* Add Transport_Interfaces at second */
124 for (int i = 0; i < static_cast<int>(eq_types.size()); i++)
125 if (eq_types[i].debute_par("TRANSPORT_INTERFACES"))
126 add_FT_equation(eq_name[i], eq_types[i]);
127
128 /* Add the remaining */
129 for (int i = 0; i < static_cast<int>(eq_types.size()); i++)
130 if (eq_types[i] != "NAVIER_STOKES_FT_DISC" && !eq_types[i].debute_par("TRANSPORT_INTERFACES"))
131 add_FT_equation(eq_name[i], eq_types[i]);
132}
139
141{
142 for (int i = 0; i < nombre_d_equations(); i++)
143 {
144 // on force la MaJ des eqs de transport pour que NS travaille avec les bonnes distances, indicatrice, ...
145 Nom name =equation(i).que_suis_je(); // une copie pour pouvoir la passer en majuscule
146 if (name.majuscule().debute_par("TRANSPORT_INTERFACES"))
147 {
149 // TODO : preparer_calcul de l'equation est anticipe ici pour permettre le calcul des proprietes physiques dans NS avec un bon maillage
150 // une bonne interface, ... On fait donc appel a : preparer_calcul_anticipated
151 // Pourquoi celui-ci est different du mettre_a_jour (hors deplacement)
152 if (1)
154 else
155 {
157 // On ne peut pas faire appel a mettre_a_jour de l'equation facilement, car celui-ci commencerait par deplacer le maillage, et remailler!!
158 // Ici, on veut juste faire l'injection suppression si necessaire, puis mettre a jour (hors deplacement, remaillagen, ...)
159 eq_trans.injecter_supprimer_interfaces(temps);
160 eq_trans.mettre_a_jour_hors_deplacement(temps, false /* do not update stationary criterion because dt=0 */ );
161 }
162 }
163 }
164}
165
167{
168 bool needs_constituant = false;
169
170 auto& list_stl = equations_.get_stl_list();
171 for (auto& itr : list_stl)
172 if (Motcle(itr->que_suis_je()).contient("CONCENTRATION"))
173 {
174 needs_constituant = true; // pb contient concentration !
175 break;
176 }
177
178 const int nb_milieu = needs_constituant ? 2 : 1;
179 le_milieu_.resize(nb_milieu);
180
181 for (int i = 0; i < nb_milieu; i++)
182 {
183 is >> le_milieu_[i]; // On commence par la lecture du milieu
184 associer_milieu_base(le_milieu_[i].valeur()); // On l'associe a chaque equations (methode virtuelle pour chaque pb ...)
185 }
186
187 // Milieu(x) lu(s) ... Lets go ! On discretise les equations
189
190 // remontee de l'inconnue vers le milieu
191 for (int i = 0; i < nombre_d_equations(); i++)
193
194 /* On discretise le milieu de l'eq 1 (NS) */
195 equations_(0)->milieu().discretiser((*this), la_discretisation_.valeur());
196
197 if (needs_constituant) // Et l'eq de concentration !
198 for (auto& itr : equations_.get_stl_list())
199 if (sub_type(Convection_Diffusion_Concentration, itr.valeur()))
200 {
201 itr->milieu().discretiser((*this), la_discretisation_.valeur());
202 break;
203 }
204}
205
207{
208 Pb_Fluide_base::lire_equations(is, dernier_mot);
209
210 if (dernier_mot == "TRIPLE_LINE_MODEL_FT_DISC")
211 {
212 is >> tcl_; // on lit
213 tcl_.associer_pb(*this);
214 tcl_.initialize(); // on initialise !!
215 is >> dernier_mot; // et on lit le dernier mot
216 }
217 return is;
218}
219
220void Probleme_FT_Disc_gen::add_FT_equation(const Nom& eq_name, const Nom& eq_type)
221{
222 equations_.add(OWN_PTR(Equation_base)());
223 equations_.dernier().typer(eq_type);
224 Equation_base& eq = equations_.dernier().valeur();
225 eq.associer_pb_base(*this);
226 eq.associer_sch_tps_base(le_schema_en_temps_);
227 eq.nommer(Nom(eq_name));
228 Cerr << "Equation " << eq_type << " added to the list and renamed to : " << eq_name << " ..." << finl;
229}
230
231/*! @brief Verifie que le milieu est de type Fluide_Diphasique et associe le milieu aux equations.
232 *
233 * Precondition: Toutes les equations doivent avoir ete associees.
234 */
236{
237 // Le milieu est associe aux equations en fonction de son type :
238 // Si le milieu est un "Constituant", on l'associe uniquement aux equations de convection_diffusion_concentration,
239 // Sinon, on associe le milieu a toutes les autres equations.
240 const int n = nombre_d_equations();
241 const int is_constituant = sub_type(Constituant, un_milieu);
242 for (int i = 0; i < n; i++)
243 {
244 Equation_base& eq = equation(i);
245 int is_conv_diff = sub_type(Convection_Diffusion_Concentration, eq);
246 if ((is_conv_diff && is_constituant) || (!is_conv_diff && !is_constituant))
247 eq.associer_milieu_base(un_milieu);
248 }
249}
250
252{
253 const int n = nombre_d_equations();
254 const Equation_base *eq = 0;
255 int i;
256 for (i = 0; i < n; i++)
257 {
258 eq = &equation(i);
259 if (eq->le_nom() == un_nom)
260 break;
261 }
262 if (i == n)
263 {
264 Cerr << "Erreur dans Probleme_FT_Disc_gen::get_equation_by_name : " << un_nom << " n'est pas le nom d'une equation !!" << finl;
265 Cerr << "Les equations du problemes sont les suivantes :" << finl;
266 for (i = 0; i < n; i++)
267 Cerr << equation(i).le_nom() << finl;
269 }
270 return *eq;
271}
272
274{
275 const int n = nombre_d_equations();
276 Equation_base *eq = 0;
277 int i;
278 for (i = 0; i < n; i++)
279 {
280 eq = &equation(i);
281 if (Motcle(eq->le_nom()) == un_nom)
282 break;
283 }
284 if (i == n)
285 {
286 Cerr << "Erreur dans Probleme_FT_Disc_gen::getset_equation_by_name : " << un_nom << " n'est pas le nom d'une equation !!" << finl;
287 Cerr << "Les equations du problemes sont les suivantes :" << finl;
288 for (i = 0; i < n; i++)
289 Cerr << equation(i).le_nom() << finl;
291 }
292 return *eq;
293}
294
296{
297 const int n = nombre_d_equations();
298 const Transport_Interfaces_FT_Disc *eq_ptr = 0;
299 for (int i = 0; i < n; i++)
300 {
301 const Equation_base& eq = equation(i);
302 if (un_nom == eq.le_nom() && sub_type(Transport_Interfaces_FT_Disc, eq))
303 {
304 eq_ptr = &ref_cast(Transport_Interfaces_FT_Disc, eq);
305 break;
306 }
307 }
308 if (eq_ptr == 0)
309 {
311 {
312 Cerr << "Erreur dans Probleme_FT_Disc_gen::equation_interfaces : Le probleme ne contient pas d'equation Transport_Interfaces_FT_Disc de nom " << un_nom << finl;
313 Cerr << "Liste des equations du probleme:" << finl;
314 for (int i = 0; i < n; i++)
315 {
316 const Equation_base& eq = equation(i);
317 Cerr << eq.que_suis_je() << " --> " << eq.le_nom() << finl;
318 }
319 }
321 }
322 return *eq_ptr;
323}
324
326{
327 const int n = nombre_d_equations();
328 const Navier_Stokes_FT_Disc *eq_ptr = 0;
329 for (int i = 0; i < n; i++)
330 {
331 const Equation_base& eq = equation(i);
332 if (un_nom == eq.le_nom() && sub_type(Navier_Stokes_FT_Disc, eq))
333 {
334 eq_ptr = &ref_cast(Navier_Stokes_FT_Disc, eq);
335 break;
336 }
337 }
338 if (eq_ptr == 0)
339 {
341 {
342 Cerr << "Erreur dans Probleme_FT_Disc_gen::equation_hydraulique : Le probleme ne contient pas d'equation Navier_Stokes_FT_Disc de nom " << un_nom << finl;
343 Cerr << "Liste des equations du probleme:" << finl;
344 for (int i = 0; i < n; i++)
345 {
346 const Equation_base& eq = equation(i);
347 Cerr << eq.que_suis_je() << " --> " << eq.le_nom() << finl;
348 }
349 }
351 }
352 return *eq_ptr;
353}
354
356{
357 // prend le min des pas de temps de chaque equation
359
360 if (la_chimie_)
361 {
362 dt = std::min(dt, la_chimie_->calculer_pas_de_temps());
363 dt = mp_min(dt);
364 }
365 return dt;
366}
367
369{
370 if (schema_temps().que_suis_je() == "RK3_FT")
371 {
372 int nb_eqn = nombre_d_equations();
373 for (int i = 2; i < nb_eqn; i++)
374 equation(i).mettre_a_jour(temps);
375
376 les_postraitements_.mettre_a_jour(temps);
377 }
378 else
379 {
381 }
382 if (la_chimie_)
383 la_chimie_->mettre_a_jour(temps);
384
386}
387
389{
390 /*
391 equation(0).mettre_a_jour_secmem2(); // Les conditions sont-elles remplies pour qu'on calcul secmem2?
392 bool compute_secmem2 = true;
393 const int i_NS = 0;
394 for (int i = 0; i < nombre_d_equations(); i++)
395 {
396 // on force la MaJ des eqs de transport pour que NS travaille avec les bonnes distances, indicatrice, ...
397 Nom name =equation(i).que_suis_je(); // une copie pour pouvoir la passer en majuscule
398 if (name.majuscule().debute_par("TRANSPORT_INTERFACES"))
399 equation(i).mettre_a_jour(temps);
400 }
401 */
402}
403
405{
407
408 if (la_chimie_)
409 {
410 la_chimie_->discretiser(*this); /* XXX : Elie Saikali : j'ai retarde ca et mis ici ... */
411 la_chimie_->completer(*this);
412 }
413
414 // the Rc_injection_ [initilisation in completer()] is needed to used the the re_injection for liquid-solid coupling problem.
415 if (tcl_.is_activated() || tcl_.reinjection_tcl()) tcl_.completer();
416
417}
418
420{
421 // add: fill the lists of TCL model if actived, Which will be used for updated the BCs
422 if (tcl().is_activated())
425}
Represents the constituent(s) of a fluid.
Definition Constituant.h:30
Convection_Diffusion_Concentration Special case of Convection_Diffusion_std.
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....
const Nom & le_nom() const override
Returns the name of the equation.
virtual void associer_milieu_equation()
virtual void associer_milieu_base(const Milieu_base &)=0
void nommer(const Nom &nom) override
Method called when the object instance is created in the data file (Interprete::ajouter).
virtual void associer_pb_base(const Probleme_base &)
Associates with the Problem passed as parameter.
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
virtual void associer_sch_tps_base(const Schema_Temps_base &)
Associates the time scheme with the equation.
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
int debute_par(const char *const n) const override
Definition Motcle.cpp:307
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
bool contient(const Nom &nom) const
Definition Nom.h:86
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
Nom & majuscule()
Converts the name to uppercase. Only letters 'a'-'z' are modified.
Definition Nom.cpp:176
An array of character strings (VECT(Nom)).
Definition Noms.h:26
int rang(const char *const ch) const
Definition Noms.cpp:65
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
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
Pb_Fluide_base This class provides a base class for.
void completer() override
Completes the equations associated with the problem.
OWN_PTR(Modele_rayo_transp) mod_rayo_transp_
virtual const Transport_Interfaces_FT_Disc & equation_interfaces(const Motcle &nom) const
virtual bool updateGivenFields() override
WARNING:
void mettre_a_jour(double temps) override
Performs a time update of the problem.
Equation_base & getset_equation_by_name(const Nom &le_nom) override
(B. Math): Virtual method added for problems having several equations of the same type (Probleme_FT_D...
int nombre_d_equations() const override
void update_geometrical_quantities(double temps)
virtual const Navier_Stokes_FT_Disc & equation_hydraulique(const Motcle &nom) const
void preparer_calcul() override
Prepares the computation: initializes the medium parameters and prepares the computation of each equa...
void lire_solved_equations(Entree &is) override
void typer_lire_milieu(Entree &is) override
void associer_milieu_base(const Milieu_base &milieu) override
Verifie que le milieu est de type Fluide_Diphasique et associe le milieu aux equations.
double calculer_pas_de_temps() const override
Computes the value of the next time step for the problem.
Entree & lire_equations(Entree &is, Motcle &dernier_mot) override
Reading of the equations of the problem.
void update_composite_variables(double temps)
void add_FT_equation(const Nom &, const Nom &)
const Equation_base & equation(int i) const override
const Equation_base & get_equation_by_name(const Nom &le_nom) const override
(B. Math): Virtual method added for problems having several equations of the same type (Probleme_FT_D...
int associer_(Objet_U &ob) override
override Objet_U::associer_(Objet_U& ob) Associates different objects with the problem by checking
void completer() override
Completes the equations associated with the problem.
const Triple_Line_Model_FT_Disc & tcl() const
virtual Entree & lire_equations(Entree &is, Motcle &dernier_mot)
Reading of the equations of the problem.
virtual void discretiser_equations()
int associer_(Objet_U &) override
override Objet_U::associer_(Objet_U& ob) Associates different objects with the problem by checking
bool updateGivenFields() override
WARNING:
virtual void preparer_calcul()
Prepares the computation: initializes the medium parameters and prepares the computation of each equa...
virtual double calculer_pas_de_temps() const
Computes the value of the next time step for the problem.
Postraitements les_postraitements_
virtual void mettre_a_jour(double temps)
Performs a time update of the problem.
std::vector< OWN_PTR(Milieu_base)> le_milieu_
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
static double mp_min(double)
Definition Process.cpp:391
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
double temps_courant() const
Returns the current time.
Base class for output streams.
Definition Sortie.h:52
void mettre_a_jour_hors_deplacement(double temps, const bool update_statio=true, const bool update_indic=true)
static int les_sous_types(const Nom &, Noms &sous_types)
Returns the names of the subtypes for a parent type identified by name.