TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_K_Eps_Realisable.cpp
1/****************************************************************************
2* Copyright (c) 2019, 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 <Modele_turbulence_hyd_K_Eps_Realisable.h>
17#include <Modele_turbulence_scal_base.h>
18#include <Modele_Shih_Zhu_Lumley_VEF.h>
19#include <Navier_Stokes_Turbulent.h>
20#include <Fluide_Incompressible.h>
21#include <Champ_Inc_P0_base.h>
22#include <Schema_Temps_base.h>
23#include <Champ_Uniforme.h>
24#include <communications.h>
25#include <Probleme_base.h>
26#include <Perf_counters.h>
27#include <TRUSTTrav.h>
28#include <Param.h>
29#include <Debog.h>
30
31Implemente_instanciable(Modele_turbulence_hyd_K_Eps_Realisable, "Modele_turbulence_hyd_K_Epsilon_Realisable", Modele_turbulence_hyd_RANS_K_Eps_base);
32
33// XD K_Eps_Realisable mod_turb_hyd_rans K_Epsilon_Realisable INHERITS_BRACE Realizable K-Epsilon Turbulence Model.
34
36{
37 return s << que_suis_je() << " " << le_nom();
38}
39
41{
43}
44
46{
48 param.ajouter_non_std("Modele_Fonc_Realisable", (this), Param::REQUIRED); // XD_ADD_P Modele_Fonc_Realisable_base
49 // XD_CONT This keyword is used to set the model used
50 param.ajouter("PRANDTL_K|Sigma_K", &Sigma_K_, Param::REQUIRED); // XD_ADD_P double
51 // XD_CONT Keyword to change the Prk|Sigma_K value (default 1.0). See https://turbmodels.larc.nasa.gov/ke-chien.html
52 param.ajouter("PRANDTL_EPS|Sigma_Eps", &Sigma_Eps_, Param::REQUIRED); // XD_ADD_P double
53 // XD_CONT Keyword to change the Pre|Sigma_Eps value (default 1.3)
54}
55
57{
58 if (mot == "Modele_Fonc_Realisable")
59 {
61 get_modele_fonction()->discretiser();
62 Cerr << "Realizable K_Epsilon model type " << get_modele_fonction().que_suis_je() << finl;
63 return 1;
64 }
65 else
67}
68
70{
71 const Champ_base& chK_Eps = get_unknown();
72 const Nom& type = chK_Eps.que_suis_je();
73 const DoubleTab& tab_K_Eps = chK_Eps.valeurs();
74 Debog::verifier("Modele_turbulence_hyd_K_Eps_Realisable::calculer_viscosite_turbulente K_Eps", tab_K_Eps);
75 DoubleTab& visco_turb = la_viscosite_turbulente_->valeurs();
76
77 int n = tab_K_Eps.dimension(0);
78
79 // dans le cas d'un domaine nul on doit effectuer le dimensionnement
80 double non_prepare = 1;
81 if (visco_turb.size() == n)
82 non_prepare = 0.;
83 non_prepare = mp_max(non_prepare);
84
85 if (non_prepare == 1)
86 {
87 OWN_PTR(Champ_Inc_base) visco_turb_au_format_K_eps_Rea;
88 visco_turb_au_format_K_eps_Rea.typer(type);
89 DoubleTab& visco_turb_K_eps_Rea = complete_viscosity_field(n, get_eq_transport().domaine_dis(), visco_turb_au_format_K_eps_Rea);
90
91 if (visco_turb_K_eps_Rea.size() != n)
92 {
93 Cerr << "visco_turb_K_eps_Rea size is " << visco_turb_K_eps_Rea.size() << " instead of " << n << finl;
95 }
96
97 fill_turbulent_viscosity_tab(n, tab_K_Eps, visco_turb_K_eps_Rea);
98 la_viscosite_turbulente_->affecter(visco_turb_au_format_K_eps_Rea.valeur());
99 }
100 else
101 fill_turbulent_viscosity_tab(n, tab_K_Eps, visco_turb);
102
103 la_viscosite_turbulente_->changer_temps(temps);
104 return la_viscosite_turbulente_;
105}
106
107void Modele_turbulence_hyd_K_Eps_Realisable::fill_turbulent_viscosity_tab(const int n, const DoubleTab& tab_K_Eps, DoubleTab& turbulent_viscosity)
108{
109 const DoubleTab& Cmu = get_modele_fonction()->get_Cmu(); // attention : il faut qu'il soit deja calcule!
110 Debog::verifier("Modele_turbulence_hyd_K_Eps_Realisable::calculer_viscosite_turbulente Cmu", Cmu);
111
112 for (int i = 0; i < n; i++)
113 {
114 if (tab_K_Eps(i, 1) <= EPS_MIN_)
115 turbulent_viscosity[i] = 0.;
116 else
117 turbulent_viscosity[i] = Cmu(i) * tab_K_Eps(i, 0) * tab_K_Eps(i, 0) / tab_K_Eps(i, 1);
118 }
119}
120
128
130{
133 if (!get_eq_transport().equation_non_resolue())
136
137 statistics().begin_count(STD_COUNTERS::turbulent_viscosity, statistics().get_last_opened_counter_level()+1);
138 Debog::verifier("Modele_turbulence_hyd_K_Eps_Realisable::mettre_a_jour la_viscosite_turbulente before", la_viscosite_turbulente_->valeurs());
140 Debog::verifier("Modele_turbulence_hyd_K_Eps_Realisable::mettre_a_jour apres calculer_viscosite_turbulente la_viscosite_turbulente", la_viscosite_turbulente_->valeurs());
141 statistics().end_count(STD_COUNTERS::turbulent_viscosity);
142}
143
148
149
150bool Modele_turbulence_hyd_K_Eps_Realisable::has_champ(const Motcle& nom, OBS_PTR(Champ_base)& ref_champ) const
151{
153 return true;
154
155 if (mon_modele_fonc_)
156 if (mon_modele_fonc_->has_champ(nom, ref_champ))
157 return true;
158
159 return false; /* rien trouve */
160}
161
163{
165 return true;
166
167 if (mon_modele_fonc_)
168 if (mon_modele_fonc_->has_champ(nom))
169 return true;
170
171 return false; /* rien trouve */
172}
173
175{
176 OBS_PTR(Champ_base) ref_champ;
177
179 return ref_champ;
180
181 if (mon_modele_fonc_)
182 if (mon_modele_fonc_->has_champ(nom, ref_champ))
183 return ref_champ;
184
185 throw std::runtime_error(std::string("Field ") + nom.getString() + std::string(" not found !"));
186}
187
189{
191 if (mon_modele_fonc_)
192 mon_modele_fonc_->get_noms_champs_postraitables(nom, opt);
193}
194
196{
197 Nom lp = loipar_->que_suis_je();
198 if (lp == "negligeable_VEF" || lp == "negligeable_VDF")
199 if (!associe_modele_fonction())
200 {
201 Cerr << "The turbulence model of type " << que_suis_je() << finl;
202 Cerr << "must not be used with a wall law of type negligeable or with a modele_function." << finl;
203 Cerr << "Another wall law must be selected with this kind of turbulence model." << finl;
204 }
205}
206
208{
209 Transport_K_Eps_Realisable& eq_transport = ref_cast(Transport_K_Eps_Realisable, ptr_eq_transport_.valeur());
210 return eq_transport;
211}
212
214{
215 const Transport_K_Eps_Realisable& eq_transport = ref_cast(Transport_K_Eps_Realisable, ptr_eq_transport_.valeur());
216 return eq_transport;
217}
218
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
Class Champ_Inc_base.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
virtual void mettre_a_jour(double temps)
Performs a time update of all boundary conditions.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
virtual int preparer_calcul()
Everything that does not depend on other possible problems.
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual bool initTimeStep(double dt)
Allocation and initialization of the unknown and boundary conditions until present+dt.
static void typer_lire_Modele_Fonc_Realisable(OWN_PTR(Modele_Fonc_Realisable_base)&, const Equation_base &, Entree &is)
class Modele_turbulence_hyd_K_Eps_Realisable
Transport_K_Eps_Realisable & get_set_eq_transport() override
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
const Transport_K_Eps_Realisable & get_eq_transport() const override
virtual Champ_Fonc_base & calculer_viscosite_turbulente(double temps)
OWN_PTR(Modele_Fonc_Realisable_base) &associe_modele_fonction()
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
const Champ_base & get_champ(const Motcle &nom) const override
DoubleTab & complete_viscosity_field(const int, const Domaine_dis_base &, Champ_Inc_base &)
std::enable_if_t<(M_TYPE==MODELE_TYPE::K_EPS||M_TYPE==MODELE_TYPE::K_EPS_REALISABLE||M_TYPE==MODELE_TYPE::K_OMEGA), void > calculate_limit_viscosity(Champ_Inc_base &, double)
Classe Modele_turbulence_hyd_RANS_K_Eps_base Classe de base des modeles de type RANS_keps.
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
OBS_PTR(Equation_base) mon_equation_
virtual int preparer_calcul()
Prepares the computation.
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
An array of character strings (VECT(Nom)).
Definition Noms.h:26
virtual int lire_motcle_non_standard(const Motcle &motlu, Entree &is)
Reads non-simple-type parameters of an Objet_U from an input stream.
Definition Objet_U.cpp:115
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 const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
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(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
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 double mp_max(double)
Definition Process.cpp:379
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
class Schema_Temps_base
virtual int faire_un_pas_de_temps_eqn_base(Equation_base &)=0
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45
int controler_K_Eps()
Controle le champ inconnue K-epsilon en forcant a zero les valeurs du champ.