TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Navier_Stokes_Turbulent_QC.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 <Convection_Diffusion_Chaleur_Turbulent_QC.h>
17#include <Navier_Stokes_Turbulent_QC.h>
18#include <Fluide_Quasi_Compressible.h>
19#include <Assembleur_base.h>
20#include <Probleme_base.h>
21#include <Discret_Thyd.h>
22#include <Param.h>
23
24Implemente_instanciable(Navier_Stokes_Turbulent_QC, "Navier_Stokes_Turbulent_QC", Navier_Stokes_Turbulent);
25// XD navier_stokes_turbulent_qc navier_stokes_turbulent navier_stokes_turbulent_qc INHERITS_BRACE Navier-Stokes
26// XD_CONT equations under low Mach number as well as the associated turbulence model equations.
27
29
31{
32 assert(le_fluide);
33 if (!sub_type(Fluide_Quasi_Compressible, le_fluide.valeur()))
34 {
35 Cerr << "ERROR: the equation " << this->que_suis_je() << " can be associated only to a quasi-compressible fluid." << finl;
36 exit();
37 }
39 divergence.set_description((Nom) "Mass flow rate=Integral(rho*u*ndS) [kg.s-1]");
40 return is;
41}
42
47
48/*! @brief Calls Navier_Stokes_Turbulent::mettre_a_jour and Convection_Diffusion_Chaleur_Turbulent_QC::mettre_a_jour_modele.
49 *
50 * @param temps Current time.
51 */
53{
55 // Elie Saikali
56 // for Pb_Hydraulique_Melange_Binaire_Turbulent_QC we do all in mettre_a_jour(temps) !
57 if (probleme().que_suis_je() != "Pb_Hydraulique_Melange_Binaire_Turbulent_QC")
58 ref_cast(Convection_Diffusion_Chaleur_Turbulent_QC,probleme().equation(1)).mettre_a_jour_modele(temps);
59}
60
66
72
74{
76 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
77 dis.vitesse(schema_temps(), domaine_dis(), rho_la_vitesse_);
78 rho_la_vitesse_->nommer("rho_u");
79}
80
81/*! @brief Successive calls to: Navier_Stokes_std::completer()
82 *
83 * Mod_Turb_Hyd::completer() [on the turbulence member]
84 *
85 */
87{
88 if (le_fluide->a_gravite())
89 {
90 Cerr << "Gravity=" << le_fluide->gravite() << finl;
91 //the quasi-compressible NS equation may contain a gravity source term
92 if (le_fluide->has_beta_t()) // for debugging - TO BE REMOVED LATER
93 {
94 Cerr << "Beta_t !=0 -> Boussinesq is currently used :" << finl;
95 }
96 else
97 {
98 Cerr << "Creation of the buoyancy source term for the Navier_Stokes_Turbulent_QC equation :" << finl;
99 Source t;
100 Source& so = les_sources.add(t);
101 Nom type_so = "Source_QC_Gravite_";
102 Nom disc = discretisation().que_suis_je();
103 if (disc == "VEFPreP1B")
104 disc = "VEF";
105 type_so += disc;
106 so.typer_direct(type_so);
107 so->associer_eqn(*this);
108 Cerr << so->que_suis_je() << finl;
109 }
110 }
111
113}
114
115/*! @brief See Equation_base::preparer_calcul(). Assembles the pressure solver and initializes the pressure.
116 *
117 * @return Always returns 1.
118 */
123
124bool Navier_Stokes_Turbulent_QC::has_champ(const Motcle& nom, OBS_PTR(Champ_base)& ref_champ) const
125{
126 if (nom == "rho_u")
127 {
128 ref_champ = rho_la_vitesse();
129 return true;
130 }
131
132 if (Navier_Stokes_Turbulent::has_champ(nom, ref_champ))
133 return true;
134
135 if (milieu().has_champ(nom, ref_champ))
136 return true;
137
138 return false; /* nothing found */
139}
140
142{
143 if (nom == "rho_u")
144 return true;
145
147 return true;
148
149 if (milieu().has_champ(nom))
150 return true;
151
152 return false; /* nothing found */
153}
154
156{
157 if (nom == "rho_u")
158 return rho_la_vitesse();
159
160 OBS_PTR(Champ_base) ref_champ;
161
162 if (Navier_Stokes_Turbulent::has_champ(nom, ref_champ))
163 return ref_champ;
164
165 if (milieu().has_champ(nom, ref_champ))
166 return ref_champ;
167
168 throw std::runtime_error(std::string("Field ") + nom.getString() + std::string(" not found !"));
169}
170
171/*! @brief Computes the time derivative of the velocity unknown, i.e. the acceleration dU/dt, and returns it.
172 *
173 * Calls Equation_base::derivee_en_temps_inco(DoubleTab&).
174 * Also computes the pressure.
175 *
176 * @param vpoint Array of acceleration values dU/dt.
177 * @return Array of acceleration values (velocity derivative).
178 */
183
184void Navier_Stokes_Turbulent_QC::assembler(Matrice_Morse& mat_morse, const DoubleTab& present, DoubleTab& secmem)
185{
186 return Navier_Stokes_Fluide_Dilatable_Proto::assembler_impl(mat_morse, present, secmem);
187}
188void Navier_Stokes_Turbulent_QC::assembler_avec_inertie(Matrice_Morse& mat_morse, const DoubleTab& present, DoubleTab& secmem)
189{
190 return Navier_Stokes_Fluide_Dilatable_Proto::assembler_avec_inertie_impl(*this, mat_morse, present, secmem);
191}
192
194{
195
196 DoubleTab& tab_vitesse = inconnue().valeurs();
197
198 Fluide_Quasi_Compressible& fluide_QC = ref_cast(Fluide_Quasi_Compressible, le_fluide.valeur());
199
200 const DoubleTab& tab_rho = fluide_QC.rho_discvit();
201
202 DoubleTab& rhovitesse = rho_la_vitesse_->valeurs();
203 Navier_Stokes_Fluide_Dilatable_Proto::rho_vitesse_impl(tab_rho, tab_vitesse, rhovitesse);
204
206}
class Champ_Don_base base class of Given Fields (not calculated)
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
Turbulent convection-diffusion of heat for a quasi-compressible fluid.
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 int impr(Sortie &os) const
Prints the equation operators to an output stream, unconditionally.
Sources les_sources
Probleme_base & probleme()
Returns the problem associated with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual void discretiser()
Discretizes the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
const DoubleTab & rho_discvit() const
Fluide_Quasi_Compressible class This class represents a quasi-compressible fluid,.
const Champ_Don_base & viscosite_dynamique() const
Definition Fluide_base.h:58
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
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_impl(Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem)
Navier-Stokes equation for a quasi-compressible fluid with turbulence modelling.
const Champ_Don_base & diffusivite_pour_transport() const override
void discretiser() override
Discretizes the equation.
int preparer_calcul() override
See Equation_base::preparer_calcul(). Assembles the pressure solver and initializes the pressure.
bool initTimeStep(double dt) override
Allocation and initialization of the unknown and boundary conditions until present+dt.
const Champ_Inc_base & rho_la_vitesse() const override
void assembler_avec_inertie(Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem) override
DoubleTab & derivee_en_temps_inco(DoubleTab &) override
Computes the time derivative of the velocity unknown, i.e. the acceleration dU/dt,...
void mettre_a_jour(double) override
Calls Navier_Stokes_Turbulent::mettre_a_jour and Convection_Diffusion_Chaleur_Turbulent_QC::mettre_a_...
void assembler(Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem) override
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
int impr(Sortie &) const override
Prints some information to an output stream: - maximum of div U.
void imprimer(Sortie &os) const override
Prints the equation operators if the time scheme indicates it is necessary.
void completer() override
Successive calls to: Navier_Stokes_std::completer().
const Champ_base & get_champ(const Motcle &nom) const override
Navier-Stokes equation for a viscous incompressible fluid (div U = 0) with turbulence modelling.
void mettre_a_jour(double) override
Performs a time update of the equation.
int preparer_calcul() override
Prepares the computation.
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
bool initTimeStep(double dt) override
Allocation and initialization of the unknown and boundary conditions until present+dt.
void completer() override
Successive calls to: Navier_Stokes_std::completer().
void imprimer(Sortie &) const override
Prints the equation operators if the time scheme indicates it is necessary.
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).
const Fluide_base & fluide() const
Returns the incompressible fluid (physical medium of the equation) associated with the equation.
Operateur_Div divergence
OBS_PTR(Fluide_base) le_fluide
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
Source Generic class of the source term hierarchy. A Source object can.
Definition Source.h:33
void typer_direct(const Nom &)
Definition Source.cpp:41