TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Transport_K_Eps.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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_Eps.h>
17#include <Modele_turbulence_hyd_K_Eps.h>
18#include <Les_Pb_Turb.h>
19#include <Param.h>
20#include <EChaine.h>
21#include <Fluide_Quasi_Compressible.h>
22#include <TRUSTTrav.h>
23#include <Debog.h>
24#include <Discretisation_base.h>
25#include <Probleme_base.h>
26#include <Equation_base.h>
27#include <Nom.h>
28
29// XD transport_k_epsilon transport_equation_deriv transport_k_epsilon INHERITS_BRACE The (k-eps) transport equation. To
30// XD_CONT resume from a previous mixing length calculation, an external MED-format file containing reconstructed K and
31// XD_CONT Epsilon quantities can be read (see fichier_ecriture_k_eps) thanks to the Champ_fonc_MED keyword. NL2
32// XD_CONT Warning, When used with the Quasi-compressible model, k and eps should be viewed as rho k and rho epsilon
33// XD_CONT when defining initial and boundary conditions or when visualizing values for k and eps. This bug will be
34// XD_CONT fixed in a future version.
35// XD attr disable_equation_residual entier disable_equation_residual OPT The equation residual will not be used for the
36// XD_CONT problem residual used when checking time convergence or computing dynamic time-step
37// XD attr convection bloc_convection convection OPT Keyword to alter the convection scheme.
38// XD attr diffusion bloc_diffusion diffusion OPT Keyword to specify the diffusion operator.
39// XD attr conditions_limites|boundary_conditions condlims conditions_limites OPT Boundary conditions.
40// XD attr conditions_initiales|initial_conditions condinits conditions_initiales OPT Initial conditions.
41// XD attr sources sources sources OPT To introduce a source term into an equation (in case of several source terms into
42// XD_CONT the same equation, the blocks corresponding to the various terms need to be separated by a comma)
43// XD attr ecrire_fichier_xyz_valeur ecrire_fichier_xyz_valeur ecrire_fichier_xyz_valeur OPT This keyword is used to
44// XD_CONT write the values of a field only for some boundaries in a text file
45// XD attr parametre_equation parametre_equation_base parametre_equation OPT Keyword used to specify additional
46// XD_CONT parameters for the equation
47// XD attr equation_non_resolue chaine equation_non_resolue OPT The equation will not be solved while condition(t) is
48// XD_CONT verified if equation_non_resolue keyword is used. Exemple: The Navier-Stokes equations are not solved between
49// XD_CONT time t0 and t1. NL2 Navier_Sokes_Standard NL2 { equation_non_resolue (t>t0)*(t<t1) }
50// XD attr renommer_equation chaine rename_equation OPT Rename the equation with a specific name.
51// XD attr exit_on_negative_k_eps rien exit_on_negative_k_eps OPT Flag to exit (with postprocessing of fields) if a
52// XD_CONT negative value is found for k or epsilon
53// XD attr exit_on_big_eps rien exit_on_big_eps OPT Flag to exit (with postprocessing of fields) if an excessively big
54// XD_CONT values of epsilon is found
55// XD attr disable_VEF_mean_value_corrections rien disable_VEF_mean_value_corrections OPT not_set
56Implemente_instanciable(Transport_K_Eps,"Transport_K_Epsilon",Transport_K_Eps_base);
57
58/*! @brief Imprime le type de l'equation sur un flot de sortie.
59 *
60 * @param (Sortie& s) un flot de sortie
61 * @return (Sortie&) le flot de sortie modifie
62 */
64{
65 return s << que_suis_je() << "\n";
66}
67
69{
71 param.ajouter("with_nu", &with_nu_); // XD_ADD_P chaine(into=["yes","no"])
72 // XD_CONT yes/no
73 param.dictionnaire("no", 0);
74 param.dictionnaire("yes", 1);
75}
76
77/*! @brief Lit les specifications d'une equation de transport K-epsilon a partir d'un flot d'entree.
78 *
79 * Controle dynamique du type du terme source.
80 *
81 * @param (Entree& s) un flot d'entree
82 * @return (Entree&) le flot d'entree modifie
83 */
85{
86 with_nu_ = 0;
87 // Lecture des attributs de l'equation
89
90 // Ajout automatique du terme source si pas instancie dans le jeu de donnees
91 if (les_sources.est_vide())
92 {
93 Source t;
94 Source& so=les_sources.add(t);
95 const Probleme_base& pb = probleme();
96 Cerr << "Construction and typing for the source term of the Transport_K_Eps equation." << finl;
97 const Nom pbb = probleme().que_suis_je();
98 if (sub_type(Pb_Hydraulique_Turbulent, pb)
99 || milieu().que_suis_je()=="Fluide_Quasi_Compressible"
100 || pbb.contient("ALE"))
101 {
102 Nom typ = "Source_Transport_K_Eps";
103 Cerr << "TYPAGE DES SOURCES : this " << *this << finl;
104 so.typer(typ, *this);
105 }
106 else if (sub_type(Pb_Thermohydraulique_Turbulent, pb))
107 {
108 Nom typ = "Source_Transport_K_Eps_anisotherme";
109 so.typer(typ, *this);
110 }
111 else if (sub_type(Pb_Hydraulique_Concentration_Turbulent, pb))
112 {
113 Nom typ = "Source_Transport_K_Eps_aniso_concen";
114 so.typer(typ, *this);
115 }
116 else if ((sub_type(Pb_Thermohydraulique_Concentration_Turbulent, pb)))
117 {
118 Nom typ = "Source_Transport_K_Eps_aniso_therm_concen";
119 so.typer(typ, *this);
120 }
121 so->associer_eqn(*this);
122 so->discretiser();
123 }
124 return s;
125}
126
127
129{
130 if (mot == "diffusion")
131 {
132 Cerr << "Reading and typing of the diffusion operator : " << finl;
133
134 if (with_nu_ == 0)
135 {
136 Cerr << " On associe le champ de diffusion nul afin de faire comme avant !!!!!! " << finl;
137 EChaine tt("Champ_Uniforme 1 0");
138 tt >> Champ_don_nul_;
139 terme_diffusif.associer_diffusivite(Champ_don_nul_);
140 }
141 else
142 {
143 const Fluide_base& fluide_inc = ref_cast(Fluide_base, le_fluide.valeur());
144 if (sub_type(Fluide_Quasi_Compressible, fluide_inc))
145 terme_diffusif.associer_diffusivite(fluide_inc.viscosite_dynamique());
146 else
147 terme_diffusif.associer_diffusivite(fluide_inc.viscosite_cinematique());
148 }
150 return 1;
151 }
152 else if (mot == "convection")
153 {
154 Cerr << "Reading and typing of the convection operator : " << finl;
155 const Champ_Inc_base& vitesse_transportante = probleme().equation(0).inconnue();
156 associer_vitesse(vitesse_transportante);
157 terme_convectif.associer_vitesse(vitesse_transportante);
158 is >> terme_convectif;
159 return 1;
160 }
161 else if (mot == "ecrire_fichier_xyz_valeur")
162 {
163 Cerr << mot << " is not understood by " << que_suis_je() << finl;
164 Cerr << "Use this keyword in the Navier Stokes equation, not in KEps equation, please." << finl;
166 }
167 else
169
170 return 1;
171}
172
173/*! @brief Associe un modele de turbulence K-epsilon a l'equation.
174 *
175 * @param (Modele_turbulence_hyd_K_Eps& modele) le modele de turbulence K-epsilon a asoocier a l'equation
176 */
178{
179 const Equation_base& eqn_hydr = modele.equation();
180 associer(eqn_hydr);
181 associer_milieu_base(eqn_hydr.milieu());
182 associer_vitesse(eqn_hydr.inconnue());
183 mon_modele = ref_cast(Modele_turbulence_hyd_K_Eps, modele);
184 RefObjU le_modele;
185 le_modele = mon_modele.valeur();
186 liste_modeles_.add_if_not(le_modele);
187 discretiser();
188}
189
190/*! @brief Renvoie le nombre d'operateurs de l'equation.
191 *
192 * Ici 2.
193 *
194 * @return (int) le nombre d'operateurs de l'equation
195 */
197{
198 return 2;
199}
200
201/*! @brief Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0
202 *
203 * renvoie terme_convectif si i = 1
204 * exit si i>1
205 * (version const)
206 *
207 * @param (int i) l'index de l'operateur a renvoyer
208 * @return (Operateur&) l'operateur specifie
209 * @throws l'equation n'a pas plus de 2 operateurs
210 */
212{
213 switch(i)
214 {
215 case 0:
216 return terme_diffusif;
217 case 1:
218 return terme_convectif;
219 default :
220 Cerr << "Error for Transport_K_Eps::operateur(" << i << ") !! " << finl;
221 Cerr << "Transport_K_Eps has " << nombre_d_operateurs() <<" operators "<<finl;
222 Cerr << "and you are trying to access the " << i <<" th one."<< finl;
224 }
225 // Pour les compilos!!
226 return terme_diffusif;
227}
228
229/*! @brief Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0
230 *
231 * renvoie terme_convectif si i = 1
232 * exit si i>1
233 *
234 * @param (int i) l'index de l'operateur a renvoyer
235 * @return (Operateur&) l'operateur specifie
236 * @throws l'equation n'a pas plus de 2 operateurs
237 */
239{
240 switch(i)
241 {
242 case 0:
243 return terme_diffusif;
244 case 1:
245 return terme_convectif;
246 default :
247 Cerr << "Error for Transport_K_Eps::operateur(" << i << ") !! " << finl;
248 Cerr << "Transport_K_Eps has " << nombre_d_operateurs() <<" operators "<<finl;
249 Cerr << "and you are trying to access the " << i <<" th one."<< finl;
251 }
252 // Pour les compilos!!
253 return terme_diffusif;
254}
255
256
257/*! @brief Renvoie le nom du domaine d'application de l'equation.
258 *
259 * Ici "Transport_Keps".
260 *
261 * @return (Motcle&) le nom du domaine d'application de l'equation
262 */
264{
265 static Motcle domaine = "Transport_Keps";
266 return domaine;
267}
268
270{
272 loi_paroi.corriger_derivee_impl(d);
274}
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
Sources les_sources
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 &)
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_Eps 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.
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_Eps_base Classe de base pour les equations.
void discretiser() override
Discretizes the equation.
virtual void set_param(Param &) const override
classe Transport_K_Eps Cette classe represente l'equation de transport de l'energie cinetique
const Motcle & domaine_application() const override
Renvoie le nom du domaine d'application de l'equation.
void associer_modele_turbulence(const Modele_turbulence_hyd_2_eq_base &) override
Associe un modele de turbulence K-epsilon a l'equation.
const Operateur & operateur(int) const override
Renvoie l'operateur specifie par son index: renvoie terme_diffusif si i = 0.
int nombre_d_operateurs() const override
Renvoie le nombre d'operateurs de l'equation.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void set_param(Param &param) const override
DoubleTab & corriger_derivee_impl(DoubleTab &d) override
Base class for the hierarchy of wall-law models computing turbulent quantities near walls....
virtual DoubleTab & corriger_derivee_impl(DoubleTab &d) const