TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Transport_K_Omega.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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 <Transport_K_Omega.h>
17#include <Modele_turbulence_hyd_RANS_K_Omega_base.h>
18#include <Transport_2eq_base.h>
19#include <Modele_turbulence_hyd_K_Omega.h>
20#include <Fluide_Quasi_Compressible.h>
21#include <Discretisation_base.h>
22#include <Transport_K_Omega.h>
23#include <Probleme_base.h>
24#include <Equation_base.h>
25#include <Les_Pb_Turb.h>
26#include <TRUSTTrav.h>
27#include <EChaine.h>
28#include <Param.h>
29#include <Debog.h>
30#include <Nom.h>
31
32Implemente_instanciable(Transport_K_Omega, "Transport_K_Omega", Transport_K_Omega_base);
33// XD transport_k_omega transport_equation_deriv transport_k_omega INHERITS_BRACE The (k-omega) transport equation.
34// XD attr exit_on_negative_k_omega rien exit_on_negative_k_omega OPT Flag to exit (with postprocessing of fields) if a
35// XD_CONT negative value is found for k or omega
36// XD attr exit_on_big_omega rien exit_on_big_omega OPT Flag to exit (with postprocessing of fields) if an excessively
37// XD_CONT big values of omega are found
38
39/*! @brief Imprime le type de l'equation sur un flot de sortie.
40 *
41 * @param (Sortie& s) un flot de sortie
42 * @return (Sortie&) le flot de sortie modifie
43 */
44Sortie& Transport_K_Omega::printOn(Sortie& s) const { return s << que_suis_je() << "\n"; }
45
47{
49 param.ajouter("with_nu", &with_nu_); // XD_ADD_P chaine(into=["yes","no"])
50 // XD_CONT yes/no (default no)
51 param.dictionnaire("no", 0);
52 param.dictionnaire("yes", 1);
53}
54
55/*! @brief Lit les specifications d'une equation de transport K-Omega a partir d'un flot d'entree.
56 *
57 * Controle dynamique du type du terme source.
58 *
59 * @param (Entree& s) un flot d'entree
60 * @return (Entree&) le flot d'entree modifie
61 */
63{
64 with_nu_= 0 ;
65 // Lecture des attributs de l'equation
67
68 // Ajout automatique du terme source si pas instancie dans le jeu de donnees
69 if (les_sources.est_vide())
70 {
71 Source t;
72 Source& so = les_sources.add(t);
73 const Probleme_base& pb = probleme();
74 Cerr << "Construction and typing for the source term of the Transport_K_Omega equation." << finl;
75
76 if (sub_type(Pb_Thermohydraulique_Turbulent, pb)
77 || sub_type(Pb_Hydraulique_Turbulent, pb)
78 || milieu().que_suis_je() == "Fluide_Quasi_Compressible"
79 || pb.que_suis_je().contient("ALE"))
80 {
81 Nom typ = "Source_Transport_K_Omega";
82 Cerr << "TYPAGE DES SOURCES : this " << *this << finl;
83 so.typer(typ, *this);
84 }
85 so->associer_eqn(*this);
86 so->discretiser();
87 }
88 return s;
89}
90
92{
93 if (mot == "diffusion")
94 {
95 Cerr << "Reading and typing of the diffusion operator : " << finl;
96
97 if (with_nu_ == 0)
98 {
99 Cerr << "Paramètre with_nu_ nul. Association d'un champ uniforme nul pour la diffusion."
100 << finl;
101 EChaine tt("Champ_Uniforme 1 0");
102 tt >> Champ_don_nul_;
103 terme_diffusif.associer_diffusivite(Champ_don_nul_);
104 }
105 else
106 {
107 const Fluide_base& fluide_inc = ref_cast(Fluide_base, le_fluide.valeur());
108 if (sub_type(Fluide_Quasi_Compressible, fluide_inc))
109 terme_diffusif.associer_diffusivite(fluide_inc.viscosite_dynamique());
110 else
111 terme_diffusif.associer_diffusivite(fluide_inc.viscosite_cinematique());
112 }
114 return 1;
115 }
116 else if (mot == "convection")
117 {
118 Cerr << "Reading and typing of the convection operator : " << finl;
119 const Champ_Inc_base& vitesse_transportante = probleme().equation(0).inconnue();
120 associer_vitesse(vitesse_transportante);
121 terme_convectif.associer_vitesse(vitesse_transportante);
122 is >> terme_convectif;
123 return 1;
124 }
125 else if (mot == "ecrire_fichier_xyz_valeur")
126 {
127 Cerr << mot << " is not understood by " << que_suis_je() << finl;
128 Cerr << "Use this keyword in the Navier Stokes equation, not in turbulence equation, please." << finl;
130 }
131 else
133 return 1;
134}
135
136/*! @brief Associe un modele de turbulence K-Omega a l'equation.
137 *
138 * @param (Modele_turbulence_hyd_K_Omega& modele) le modele de turbulence K-Omega a asoocier a l'equation
139 */
141{
142 const Equation_base& eqn_hydr = modele.equation();
143 associer(eqn_hydr);
144 associer_milieu_base(eqn_hydr.milieu());
145 associer_vitesse(eqn_hydr.inconnue());
146 mon_modele = ref_cast(Modele_turbulence_hyd_K_Omega, modele);
147 RefObjU le_modele;
148 le_modele = mon_modele.valeur();
149 liste_modeles_.add_if_not(le_modele);
150}
151
152/*! @brief Methode to associate the gradient operator.
153 *
154 * @param None
155 */
157{
159
160 // Initialisation of the gradient operator
161 Op_Grad_komega.associer_eqn(*this);
162 Op_Grad_komega.typer();
163 Op_Grad_komega.l_op_base().associer_eqn(*this);
165}
166
167/*! @brief Renvoie le nombre d'operateurs de l'equation.
168 *
169 * Ici 2.
170 *
171 * @return (int) le nombre d'operateurs de l'equation
172 */
174{
175 return 2;
176}
177
178/*! @brief Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0
179 *
180 * renvoie terme_convectif si i = 1
181 * exit si i>1
182 * (version const)
183 *
184 * @param (int i) l'index de l'operateur a renvoyer
185 * @return (Operateur&) l'operateur specifie
186 * @throws l'equation n'a pas plus de 2 operateurs
187 */
189{
190 switch(i)
191 {
192 case 0:
193 return terme_diffusif;
194 case 1:
195 return terme_convectif;
196 default :
197 Cerr << "Error for Transport_K_Omega::operateur("<<i<<") !! " << finl;
198 Cerr << "Transport_K_Omega has " << nombre_d_operateurs() <<" operators "<<finl;
199 Cerr << "and you are trying to access the " << i <<" th one."<< finl;
201 }
202 return terme_diffusif; // Needed for the compiler
203}
204
205/*! @brief Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0
206 *
207 * renvoie terme_convectif si i = 1
208 * exit si i>1
209 *
210 * @param (int i) l'index de l'operateur a renvoyer
211 * @return (Operateur&) l'operateur specifie
212 * @throws l'equation n'a pas plus de 2 operateurs
213 */
215{
216 switch(i)
217 {
218 case 0:
219 return terme_diffusif;
220 case 1:
221 return terme_convectif;
222 default :
223 Cerr << "Error for Transport_K_Omega::operateur("<<i<<") !! " << finl;
224 Cerr << "Transport_K_Omega has " << nombre_d_operateurs() <<" operators "<<finl;
225 Cerr << "and you are trying to access the " << i <<" th one."<< finl;
227 }
228 // Pour les compilos!!
229 return terme_diffusif;
230}
231
232
233/*! @brief Renvoie le nom du domaine d'application de l'equation.
234 *
235 * Ici "Transport_Komega".
236 *
237 * @return (Motcle&) le nom du domaine d'application de l'equation
238 */
240{
241 static Motcle domaine = "Transport_Komega";
242 return domaine;
243}
244
Class Champ_Inc_base.
An input stream whose source is a character string.
Definition EChaine.h:31
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 const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
virtual void completer()
Completes the construction (initialization) of objects associated with the equation.
Sources les_sources
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.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
virtual DoubleTab & corriger_derivee_impl(DoubleTab &)
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
Fluide_Quasi_Compressible class This class represents a quasi-compressible fluid,.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
const Champ_Don_base & viscosite_dynamique() const
Definition Fluide_base.h:58
const Champ_Don_base & viscosite_cinematique() const
Definition Fluide_base.h:56
Classe Modele_turbulence_hyd_2_eq_base Classe de base des modeles de type RANS a deux equations.
Classe Modele_turbulence_hyd_K_Omega Cette classe represente le modele de turbulence (k,...
const Turbulence_paroi_base & loi_paroi() const
Equation_base & equation()
Returns the equation associated with the turbulence model.
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
bool contient(const Nom &nom) const
Definition Nom.h:86
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
class Operateur Generic class of the operator hierarchy.
Definition Operateur.h:39
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void dictionnaire(const char *option_name, int value)
Add an (option name, integer value) entry to the dictionary attached to a previously registered integ...
Definition Param.cpp:293
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
Turbulent hydraulics problem.
Turbulent thermohydraulics problem.
class Probleme_base It is a Probleme_U that is not a coupling.
virtual const Equation_base & equation(int) const =0
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(const Nom &, const Equation_base &)
Types the source by computing the required type name from the provided parameters.
Definition Source.cpp:52
const Objet_U & valeur() const
Definition TRUST_Ref.h:134
Operateur_Conv terme_convectif
void associer_vitesse(const Champ_base &)
Milieu_base & milieu() override
Renvoie le milieu (fluide) associe a l'equation.
const Modele_turbulence_hyd_2_eq_base & modele_turbulence() const
Renvoie le modele de turbulence associe a l'equation.
Operateur_Diff terme_diffusif
void associer(const Equation_base &)
void associer_milieu_base(const Milieu_base &) override
Associe un milieu physique a l'equation.
Entree & lire_op_diff_turbulent(Entree &is)
Classe Transport_K_Omega_base Classe de base pour les equations.
const Champ_Inc_base & inconnue() const override
Renvoie le champ inconnue de l'equation.
virtual void set_param(Param &) const override
classe Transport_K_Omega Cette classe represente l'equation de transport de l'energie cinetique
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
const Motcle & domaine_application() const override
Renvoie le nom du domaine d'application de l'equation.
int nombre_d_operateurs() const override
Renvoie le nombre d'operateurs de l'equation.
void associer_modele_turbulence(const Modele_turbulence_hyd_2_eq_base &) override
Associe un modele de turbulence K-Omega a l'equation.
Operateur_Grad Op_Grad_komega
DoubleTab & corriger_derivee_impl(DoubleTab &d) override
void set_param(Param &param) const override
const Operateur & operateur(int) const override
Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0.
void completer() override
Methode to associate the gradient operator.
Base class for the hierarchy of wall-law models computing turbulent quantities near walls....
virtual DoubleTab & corriger_derivee_impl(DoubleTab &d) const