TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Pb_Multiphase.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
16#include <Schema_Euler_Implicite.h>
17#include <Discretisation_base.h>
18#include <Loi_Fermeture_base.h>
19#include <Milieu_composite.h>
20#include <Interprete_bloc.h>
21#include <Pb_Multiphase.h>
22#include <Domaine.h>
23#include <EChaine.h>
24#include <Debog.h>
25#include <SETS.h>
26
27Implemente_instanciable(Pb_Multiphase, "Pb_Multiphase", Pb_Fluide_base);
28// XD Pb_Multiphase Pb_base Pb_Multiphase INHERITS_BRACE A problem that allows the resolution of N-phases with 3*N
29// XD_CONT equations
30// XD attr milieu_composite bloc_lecture milieu_composite OPT The composite medium associated with the problem.
31// XD attr Milieu_MUSIG bloc_lecture Milieu_MUSIG OPT The composite medium associated with the problem.
32// XD attr correlations bloc_lecture correlations OPT List of correlations used in specific source terms (i.e.
33// XD_CONT interfacial flux, interfacial friction, ...)
34// XD attr models bloc_lecture models OPT List of models used in specific source terms (i.e. interfacial flux,
35// XD_CONT interfacial friction, ...)
36// XD attr QDM_Multiphase QDM_Multiphase QDM_Multiphase REQ Momentum conservation equation for a multi-phase problem
37// XD_CONT where the unknown is the velocity
38// XD attr Masse_Multiphase Masse_Multiphase Masse_Multiphase REQ Mass consevation equation for a multi-phase problem
39// XD_CONT where the unknown is the alpha (void fraction)
40// XD attr Energie_Multiphase Energie_Multiphase Energie_Multiphase REQ Internal energy conservation equation for a
41// XD_CONT multi-phase problem where the unknown is the temperature
42// XD attr Echelle_temporelle_turbulente Echelle_temporelle_turbulente Echelle_temporelle_turbulente OPT Turbulent
43// XD_CONT Dissipation time scale equation for a turbulent mono/multi-phase problem (available in TrioCFD)
44// XD attr Energie_cinetique_turbulente Energie_cinetique_turbulente Energie_cinetique_turbulente OPT Turbulent kinetic
45// XD_CONT Energy conservation equation for a turbulent mono/multi-phase problem (available in TrioCFD)
46// XD attr Energie_cinetique_turbulente_WIT Energie_cinetique_turbulente_WIT Energie_cinetique_turbulente_WIT OPT Bubble
47// XD_CONT Induced Turbulent kinetic Energy equation for a turbulent multi-phase problem (available in TrioCFD)
48// XD attr Taux_dissipation_turbulent Taux_dissipation_turbulent Taux_dissipation_turbulent OPT Turbulent Dissipation
49// XD_CONT frequency equation for a turbulent mono/multi-phase problem (available in TrioCFD)
50// XD attr aire_interfaciale aire_interfaciale aire_interfaciale OPT Interfacial-area transport equation for a
51// XD_CONT multi-phase problem (available in TrioCFD)
52
53// XD Energie_cinetique_turbulente eqn_base Energie_cinetique_turbulente BRACE Turbulent kinetic Energy conservation
54// XD_CONT equation for a turbulent mono/multi-phase problem (available in TrioCFD)
55// XD aire_interfaciale eqn_base aire_interfaciale BRACE Interfacial-area transport equation for a multi-phase problem
56// XD_CONT (available in TrioCFD)
57// XD Echelle_temporelle_turbulente eqn_base Echelle_temporelle_turbulente INHERITS_BRACE Turbulent Dissipation time
58// XD_CONT scale equation for a turbulent mono/multi-phase problem (available in TrioCFD)
59// XD Energie_cinetique_turbulente_WIT eqn_base Energie_cinetique_turbulente_WIT INHERITS_BRACE Bubble Induced Turbulent
60// XD_CONT kinetic Energy equation for a turbulent multi-phase problem (available in TrioCFD)
61// XD Taux_dissipation_turbulent eqn_base Taux_dissipation_turbulent INHERITS_BRACE Turbulent Dissipation frequency
62// XD_CONT equation for a turbulent mono/multi-phase problem (available in TrioCFD)
63
65{
66 return Pb_Fluide_base::printOn(os);
67}
68
70{
71 if (discretisation().is_vef())
72 {
73 Cerr << "Error: Problem of type " << que_suis_je() << " is not available for VEF discretization" << finl;
74 Cerr << "It is only available for VDF, PolyMAC_HFV and PolyMAC_MPFA discretizations." << finl;
76 }
77 return Pb_Fluide_base::readOn(is);
78}
79
81{
82 // Verify that user choosed adapted time scheme/solver
83 if (!sub_type(Schema_Euler_Implicite, le_schema_en_temps_.valeur()))
84 {
85 Cerr << "Error: for Pb_Multiphase, you can only use Scheme_euler_implicit time scheme with sets/ice solver" << finl;
87 }
88 else if (sub_type(Schema_Euler_Implicite, le_schema_en_temps_.valeur()))
89 {
90 Schema_Euler_Implicite& schm_imp = ref_cast(Schema_Euler_Implicite, le_schema_en_temps_.valeur());
91 if (!sub_type(SETS, schm_imp.solveur().valeur()))
92 {
93 Cerr << "Error: for Pb_Multiphase, you can only use Scheme_euler_implicit time scheme with sets/ice solver" << finl;
95 }
96 }
97
98 bool already_read = true;
99
100 is >> mot;
101 if (mot == "correlations" || mot == "models")
102 lire_correlations(is), already_read = false;
103
104 typer_lire_correlation_hem(); // enforce an interfacial flux correlation with constant coefficient if HEM
105
106 Cerr << "Reading of the equations" << finl;
107 for (int i = 0; i < nombre_d_equations(); i++, already_read = false)
108 {
109 if (!already_read)
110 is >> mot;
111 is >> getset_equation_by_name(mot);
112 }
113
115 return is;
116}
117
119{
120 le_milieu_.resize(1); /* One medium ... but composite! */
121 is >> le_milieu_[0]; // Start by reading the medium
122 if (!sub_type(Milieu_composite, le_milieu_[0].valeur()))
123 {
124 Cerr << "Error: Fluid of type " << le_milieu_[0]->le_type() << " is not compatible with " << que_suis_je() << " problem which accepts only Milieu_composite medium" << finl;
125 Cerr << "Check your datafile!" << finl;
127 }
128 noms_phases_ = ref_cast(Milieu_composite,le_milieu_[0].valeur()).noms_phases();
129 alpha_inf_phases_.resize(noms_phases_.size());
130 alpha_inf_phases_ = 0.0;
131 associer_milieu_base(le_milieu_[0].valeur());
132
133 // Discretize equations now
135 // propagate unknown back to the medium
136 for (int i = 0; i < nombre_d_equations(); i++)
138 // Discretize the composite medium
139 equation(0).milieu().discretiser((*this), la_discretisation_.valeur());
140}
141
142/*! @brief Returns the number of equations.
143 *
144 * Returns 3 for a multiphase problem (QDM, mass, energy)
145 * plus any optional equations.
146 *
147 * @return The number of equations.
148 */
150{
151 return 3 + eq_opt_.size();
152}
153
154/*! @brief Returns the equation at index i (const version).
155 *
156 * i=0: QDM_Multiphase, i=1: Masse_Multiphase, i=2: Energie_Multiphase,
157 * i>=3: optional equations.
158 *
159 * @param i The index of the equation to return.
160 * @return The equation corresponding to the index.
161 */
163{
164 if (i == 0)
165 return eq_qdm_;
166 else if (i == 1)
167 return eq_masse_;
168 else if (i == 2)
169 return eq_energie_;
170 else if (i < 3 + eq_opt_.size())
171 return eq_opt_[i - 3].valeur();
172 else
173 {
174 Cerr << "Pb_Multiphase::equation() : Wrong equation number" << i << "!" << finl;
176 }
177 return eq_qdm_; // unreachable; needed to satisfy the compiler
178}
179
180/*! @brief Returns the equation at index i.
181 *
182 * i=0: QDM_Multiphase, i=1: Masse_Multiphase, i=2: Energie_Multiphase,
183 * i>=3: optional equations.
184 *
185 * @param i The index of the equation to return.
186 * @return The equation corresponding to the index.
187 */
189{
190 if (i == 0)
191 return eq_qdm_;
192 else if (i == 1)
193 return eq_masse_;
194 else if (i == 2)
195 return eq_energie_;
196 else if (i < 3 + eq_opt_.size())
197 return eq_opt_[i - 3].valeur();
198 else
199 {
200 Cerr << "Pb_Multiphase::equation() : Wrong equation number" << i << "!" << finl;
202 }
203 return eq_qdm_; // unreachable; needed to satisfy the compiler
204}
205
206/*! @brief Associates the medium with the problem.
207 *
208 * The medium must be of type Milieu_composite.
209 *
210 * @param mil The physical medium to associate with the problem.
211 * @throws If the medium is of the wrong type.
212 */
214{
215 /* check the medium type here */
219}
220
221/*! @brief Checks the compatibility of the thermal and hydraulic equations.
222 *
223 * The test is performed on the discretized boundary conditions of each equation.
224 * Calls the library function:
225 * tester_compatibilite_hydr_thermique(const Domaine_Cl_dis_base&,const Domaine_Cl_dis_base&)
226 *
227 * @return Propagated return code.
228 */
230{
231 const Domaine_Cl_dis_base& domaine_Cl_hydr = equation_qdm().domaine_Cl_dis();
232 const Domaine_Cl_dis_base& domaine_Cl_th = equation_energie().domaine_Cl_dis();
233 return tester_compatibilite_hydr_thermique(domaine_Cl_hydr, domaine_Cl_th);
234}
235
237{
239 const double temps = schema_temps().temps_courant();
240 mettre_a_jour(temps);
241}
242
244{
245 if (sub_type(ICE, ref_cast(Schema_Euler_Implicite, le_schema_en_temps_.valeur()).solveur().valeur()))
247 else if (ref_cast(SETS, ref_cast(Schema_Euler_Implicite, le_schema_en_temps_.valeur()).solveur().valeur()).facsec_diffusion_for_sets() < 0.)
249
250 // Case where we calculate the time step with higher facsec for diffusion
251
252 double dt = schema_temps().pas_temps_max();
253 for (int i = 0; i < nombre_d_equations(); i++)
254 {
255 double dt_op;
256
257 int nb_op = equation(i).nombre_d_operateurs();
258 for (int j = 0; j < nb_op; j++)
259 {
261
262 const Operateur_base& op = equation(i).operateur(j).l_op_base();
263
264 if (le_schema_en_temps_->limpr())
265 {
266 if (j == 0)
267 {
268 Cout << " " << finl;
269 Cout << "Printing of the next provisional time steps for the equation: " << equation(i).que_suis_je() << finl;
270 }
271 if (sub_type(Operateur_Conv_base, op))
272 Cout << " convective";
273 else if (sub_type(Operateur_Diff_base, op))
274 Cout << " diffusive";
275 else
276 Cout << " operator ";
277 Cout << " time step : " << dt_op << finl;
278 }
279 if (sub_type(Operateur_Diff_base, op))
280 dt_op *= ref_cast(SETS, ref_cast(Schema_Euler_Implicite, le_schema_en_temps_.valeur()).solveur().valeur()).facsec_diffusion_for_sets();
281 dt = std::min(dt, dt_op);
282 }
283 }
284 return dt;
285}
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
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....
virtual void associer_milieu_equation()
virtual void associer_milieu_base(const Milieu_base &)=0
virtual const Milieu_base & milieu() const =0
virtual int nombre_d_operateurs() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
virtual const Operateur & operateur(int) const =0
ICE scheme (semi-implicit ICE, CATHARE 3D style).
Definition SETS.h:141
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
virtual void discretiser(const Probleme_base &pb, const Discretisation_base &dis)
Composite medium representing a multiphase fluid and its properties:
A character string (Nom) in uppercase.
Definition Motcle.h:26
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
Operateur_Conv_base This class is the base of the hierarchy of operators representing.
Operateur_Diff_base This class is the base of the hierarchy of operators representing.
class Operateur_base This class is the base of the hierarchy of objects representing an
virtual Operateur_base & l_op_base()=0
double calculer_pas_de_temps() const
Computes the next time step.
Pb_Fluide_base This class provides a base class for.
Multiphase thermohydraulics problem of type "3*N equations":
void preparer_calcul() override
Prepares the computation: initializes the medium parameters and prepares the computation of each equa...
double calculer_pas_de_temps() const override
Computes the value of the next time step for the problem.
QDM_Multiphase eq_qdm_
Masse_Multiphase eq_masse_
virtual Equation_base & equation_qdm()
DoubleVect alpha_inf_phases_
virtual void typer_lire_correlation_hem()
Energie_Multiphase eq_energie_
virtual Equation_base & equation_energie()
Entree & lire_equations(Entree &is, Motcle &dernier_mot) override
Reading of the equations of the problem.
int nombre_d_equations() const override
Returns the number of equations.
const Equation_base & equation(int) const override
Returns the equation at index i (const version).
void typer_lire_milieu(Entree &is) override
int verifier() override
Checks the compatibility of the thermal and hydraulic equations.
void associer_milieu_base(const Milieu_base &) override
Associates the medium with the problem.
virtual Equation_base & equation_masse()
virtual void discretiser_equations()
virtual Entree & lire_correlations(Entree &is)
Entree & read_optional_equations(Entree &is, Motcle &mot)
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.
virtual double calculer_pas_de_temps() const
Computes the value of the next time step for the problem.
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.
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...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
SETS scheme (semi-implicit + stabilisation steps, TRACE-style).
Definition SETS.h:35
double temps_courant() const
Returns the current time.
double pas_temps_max() const
Returns the maximum time step.
Base class for output streams.
Definition Sortie.h:52