TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Navier_Stokes_Fluide_Dilatable_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
16#include <Navier_Stokes_Fluide_Dilatable_base.h>
17#include <Fluide_Dilatable_base.h>
18#include <Loi_Etat_Multi_GP_WC.h>
19#include <Schema_Temps_base.h>
20#include <Probleme_base.h>
21#include <Discret_Thyd.h>
22
23Implemente_base(Navier_Stokes_Fluide_Dilatable_base,"Navier_Stokes_Fluide_Dilatable_base",Navier_Stokes_std);
24
26{
28}
29
31{
33 divergence.set_description((Nom)"Mass flow rate=Integral(rho*u*ndS) [kg.s-1]");
34 return is;
35}
36
42
44{
46 param.ajouter_non_std("mass_source",(this));
47}
48
50{
51 if (mot == "mass_source")
52 {
54 if (typ == "VEFPreP1B") typ = "VEF";
55
56 typ = Nom("Source_Masse_Fluide_Dilatable_") + typ;
57 Cerr << "Typing the mass source: " << typ << finl;
58 source_masse_.typer(typ);
59 Cerr << "Reading the mass source ... " << finl;
60 is >> source_masse_.valeur();
61 source_masse_->associer_domaine_cl(domaine_Cl_dis());
62 }
63 else
65
66 return 1;
67}
68
69/*! @brief @brief Calls Equation_base::preparer_calcul(), assembles the pressure solver and initialises the pressure.
70 *
71 * @return Always returns 1.
72 */
77
78/*! @brief @brief Completes the base equation: associates the pressure, completes the divergence, gradient and pressure solver.
79 *
80 * Adds two source terms: one representing the centrifugal force in the axisymmetric case, the other involved in the 2D axisymmetric resolution.
81 *
82 */
84{
85 Cerr << "Navier_Stokes_Fluide_Dilatable_base::completer" << finl;
86 if (has_source_masse())
87 {
88 // Never use QC
89 if (probleme().que_suis_je().finit_par("_QC"))
90 {
91 Cerr << "Error in Navier_Stokes_Fluide_Dilatable_base::completer() !! " << finl;
92 Cerr << "Switch to a WC problem if you want to use the mass source term ! This source term is not available for a QC problem !" << finl;
94 }
95
96 source_masse_->completer();
97
98 // Some verifications : in order to help the user to do what he wants, and in order to avoid any wrong use of the source term
99 // the line_size of the term source should be identical to the number of species
100 const int ncomp = source_masse_->nb_comp();
101
102 if (probleme().que_suis_je() == "Pb_Hydraulique_Melange_Binaire_WC" && ncomp != 2)
103 {
104 Cerr << "Error in Navier_Stokes_Fluide_Dilatable_base::completer() !! " << finl;
105 Cerr << "You can not define a mass source with " << ncomp << " components while using a problem of type " << probleme().que_suis_je() << finl;
106 Cerr << "Please define a mass source with 2 components !" << finl;
108 }
109
110 if (probleme().que_suis_je() == "Pb_Thermohydraulique_Especes_WC")
111 {
112 const Fluide_Dilatable_base& fd = ref_cast(Fluide_Dilatable_base, le_fluide.valeur());
113 assert(fd.loi_etat()->que_suis_je() == "Loi_Etat_Multi_Gaz_Parfait_WC");
114 const Loi_Etat_Multi_GP_WC& loi_etat = ref_cast(Loi_Etat_Multi_GP_WC, fd.loi_etat().valeur());
115 const int nb_esp = loi_etat.masse_molaire_especes().valeurs().line_size();
116 if (nb_esp != ncomp)
117 {
118 Cerr << "Error in Navier_Stokes_Fluide_Dilatable_base::completer() !! " << finl;
119 Cerr << "You should define " << nb_esp << " components for your mass source and not " << ncomp << " (because you have " << nb_esp << " species) !!!" << finl;
121 }
122 }
123 }
124
125 Cerr << "Navier_Stokes_std::completer" << finl;
127 Cerr << "Unknown field type : " << inconnue().que_suis_je() << finl;
128 Cerr << "Unknown field name : " << inconnue().le_nom() << finl;
129 Cerr << "Equation type : " << inconnue().equation().que_suis_je() << finl;
130}
131
133{
134 return le_fluide->viscosite_dynamique();
135}
136
138{
139 return le_fluide->viscosite_cinematique();
140}
141
143{
144 return la_vitesse;
145}
146
148{
149 if (nom == "rho_u")
150 {
151 ref_champ = rho_la_vitesse();
152 return true;
153 }
154
155 if (Navier_Stokes_std::has_champ(nom, ref_champ))
156 return true;
157
158 if (milieu().has_champ(nom, ref_champ))
159 return true;
160
161 return false; /* nothing found */
162}
163
165{
166 if (nom == "rho_u")
167 return true;
168
170 return true;
171
172 if (milieu().has_champ(nom))
173 return true;
174
175 return false; /* nothing found */
176}
177
179{
180 if (nom == "rho_u")
181 return rho_la_vitesse();
182
183 OBS_PTR(Champ_base) ref_champ;
184
185 if (Navier_Stokes_std::has_champ(nom, ref_champ))
186 return ref_champ;
187
188 if (milieu().has_champ(nom, ref_champ))
189 return ref_champ;
190
191 throw std::runtime_error(std::string("Field ") + nom.getString() + std::string(" not found !"));
192}
193
195{
196 DoubleTab& tab_vitesse = inconnue().valeurs();
197 Fluide_Dilatable_base& fluide_dil = ref_cast(Fluide_Dilatable_base, le_fluide.valeur());
198 const DoubleTab& tab_rho = fluide_dil.rho_discvit();
199 DoubleTab& rhovitesse = rho_la_vitesse_->valeurs(); // will be filled
200 rho_vitesse_impl(tab_rho, tab_vitesse, rhovitesse);
201
202 if (has_source_masse())
203 {
204 const Schema_Temps_base& sch = schema_temps();
205 // XXX: we need the current time...
206 source_masse_->changer_temps_futur(sch.temps_courant(), 0);
207 // For each future time level
208 for (int i = 1; i <= sch.nb_valeurs_futures(); i++)
209 {
210 double tps = sch.temps_futur(i);
211 source_masse_->changer_temps_futur(tps, i);
212 }
213
214 // Update the default time of the mass source term
215 source_masse_->set_temps_defaut(sch.temps_defaut());
216 }
217
219}
220
222{
224 const Discret_Thyd& dis=ref_cast(Discret_Thyd, discretisation());
225 dis.vitesse(schema_temps(), domaine_dis(), rho_la_vitesse_);
226 rho_la_vitesse_->nommer("rho_u");
227}
228
233
234void Navier_Stokes_Fluide_Dilatable_base::assembler( Matrice_Morse& mat_morse, const DoubleTab& present, DoubleTab& secmem)
235{
237}
238
239void Navier_Stokes_Fluide_Dilatable_base::assembler_avec_inertie( Matrice_Morse& mat_morse, const DoubleTab& present, DoubleTab& secmem)
240{
242}
243
244void Navier_Stokes_Fluide_Dilatable_base::assembler_blocs_avec_inertie(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl)
245{
247}
248
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Discret_Thyd This class is the base class representing a discretization
void vitesse(const Schema_Temps_base &, Domaine_dis_base &, OWN_PTR(Champ_Inc_base)&, int nb_comp=1) const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
const Nom & le_nom() const override
Returns the name of the field.
Base class for a dilatable fluid, inheriting from Fluide_base.
const DoubleTab & rho_discvit() const
State law class for a mixture of ideal gases in the weakly compressible (WC) framework.
const Champ_Don_base & masse_molaire_especes() const
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
A character string (Nom) in uppercase.
Definition Motcle.h:26
void assembler_avec_inertie_impl(const Navier_Stokes_std &eqn, Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem)
DoubleTab & rho_vitesse_impl(const DoubleTab &tab_rho, const DoubleTab &vit, DoubleTab &rhovitesse) const
int impr_impl(const Navier_Stokes_std &eqn, Sortie &os) const
DoubleTab & derivee_en_temps_inco_impl(Navier_Stokes_std &, DoubleTab &res)
Computes the time derivative of the velocity unknown, i.e. the acceleration dU/dt,...
void assembler_blocs_avec_inertie(const Navier_Stokes_std &eqn, matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl)
void assembler_impl(Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem)
Base class carrying the terms of the momentum equation for a fluid without turbulence modelling under...
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
void assembler_avec_inertie(Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem) override
const Champ_Inc_base & rho_la_vitesse() const override
DoubleTab & derivee_en_temps_inco(DoubleTab &) override
Returns the time derivative of the unknown I of the equation: dI/dt = M-1*(sum(operators(I) + sources...
int lire_motcle_non_standard(const Motcle &mot, Entree &is) override
Reads non-simple-type parameters of an Objet_U from an input stream.
const Champ_base & diffusivite_pour_pas_de_temps() const override
void completer() override
Completes the base equation: associates the pressure, completes the divergence, gradient and pressure...
void discretiser() override
Discretizes the equation.
const Champ_Don_base & diffusivite_pour_transport() const override
const Champ_base & vitesse_pour_transport() const override
void assembler(Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem) override
int preparer_calcul() override
Calls Equation_base::preparer_calcul(), assembles the pressure solver and initialises the pressure.
const Champ_base & get_champ(const Motcle &nom) const override
int impr(Sortie &os) const override
Prints the equation operators to an output stream, unconditionally.
void assembler_blocs_avec_inertie(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl) override
bool initTimeStep(double dt) override
Allocation and initialization of the unknown and boundary conditions until present+dt.
Navier_Stokes_std This class carries the terms of the momentum equation.
const Milieu_base & milieu() const override
Returns the physical medium of the equation (Fluide_base upcast to Milieu_base).
const Champ_Inc_base & inconnue() const override
Returns the velocity (unknown field of the equation) (const version).
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void completer() override
Completes the base equation, associates the pressure with the equation,.
bool initTimeStep(double dt) override
Allocation and initialization of the unknown and boundary conditions until present+dt.
int impr(Sortie &os) const override
Prints some information to an output stream: - maximum of div U.
Operateur_Div divergence
void set_param(Param &titi) const override
void discretiser() override
Discretizes the equation.
int preparer_calcul() override
cf Equation_base::preparer_calcul() Assembly of the pressure solver and
OBS_PTR(Fluide_base) le_fluide
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
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
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
class Schema_Temps_base
double temps_courant() const
Returns the current time.
virtual double temps_futur(int i) const =0
virtual int nb_valeurs_futures() const =0
virtual double temps_defaut() const =0
Base class for output streams.
Definition Sortie.h:52
int line_size() const
Definition TRUSTVect.tpp:67