TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_0_eq_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 <Modele_turbulence_hyd_0_eq_base.h>
17#include <Modifier_pour_fluide_dilatable.h>
18#include <Domaine_Cl_dis_base.h>
19#include <Discretisation_base.h>
20#include <Schema_Temps_base.h>
21#include <Equation_base.h>
22#include <Probleme_base.h>
23#include <Ecrire_MED.h>
24#include <Domaine.h>
25#include <Motcle.h>
26#include <Param.h>
27#include <Perf_counters.h>
28
29// XD Modele_turbulence_hyd_0_eq_base modele_turbulence_hyd_deriv Modele_turbulence_hyd_0_eq_base BRACE Turbulence model
30// XD_CONT constructed using several fields.
31
32Implemente_base(Modele_turbulence_hyd_0_eq_base, "Modele_turbulence_hyd_0_eq_base", Modele_turbulence_hyd_base);
33
35
37
39{
41 param.ajouter("fichier_ecriture_K_eps", &fichier_K_eps_sortie_);
42}
43
45{
47 discretiser_K(mon_equation_->schema_temps(), mon_equation_->domaine_dis(), energie_cinetique_turb_);
48 champs_compris_.ajoute_champ(energie_cinetique_turb_);
49}
50
52{
53 le_dom_VF_ = ref_cast(Domaine_VF, domaine_dis);
54 le_dom_Cl_ = ref_cast(Domaine_Cl_dis_base, domaine_Cl_dis);
55}
56
58 OBS_PTR(Champ_base) &ch_ref) const
59{
60 Motcles les_motcles(3);
61 {
62 les_motcles[0] = "viscosite_turbulente";
63 les_motcles[1] = "k";
64 les_motcles[2] = "distance_paroi";
65 }
66 int rang = les_motcles.search(mot);
67 switch(rang)
68 {
69 case 0:
70 {
71 ch_ref = la_viscosite_turbulente_.valeur();
72 return 1;
73 }
74 case 1:
75 {
76 Cerr << "The kinetic energy cannot be post-processed for the mixing length model." << finl;
77 //A coder
78 return 0;
79 }
80 case 2:
81 {
82 exit();
83 return 0;
84 }
85 default:
86 return 0;
87 }
88}
90{
91 return comprend_champ(mot);
92}
93
95{
96 Motcles les_motcles(3);
97 {
98 les_motcles[0] = "k";
99 les_motcles[1] = "viscosite_turbulente";
100 les_motcles[2] = "distance_paroi";
101 }
102
103 int rang = les_motcles.search(mot);
104
105 if (rang == 0)
106 {
107 Cerr << "The kinetic energy is not known for the mixing length model." << finl;
108 //A coder
109 return 0;
110 }
111 else if (rang == 1)
112 return 1;
113 else if (rang == 2)
114 {
115
116 exit();
117 return 0;
118 }
119 else
120 return 0;
121}
122
124{
125 // creation of K_eps_sortie and the med file if ecrire_K_eps was requested
126 if (fichier_K_eps_sortie_ != Nom())
127 {
128 // 1) create the med file and post-process the domain
129 const Domaine& dom = mon_equation_->domaine_dis().domaine();
130 Ecrire_MED ecr_med(fichier_K_eps_sortie_.nom_me(me()), dom);
131 ecr_med.ecrire_domaine(false);
132 //2 on discretise le champ K_eps_pour_la_sortie
133 const Discretisation_base& dis = mon_equation_->discretisation();
134 Noms noms(2);
135 Noms unit(2);
136 noms[0] = "K";
137 noms[1] = "eps";
138 unit[0] = "m2/s2";
139 unit[1] = "m2/s3";
140 int nb_case_tempo = 1;
141 double temps = mon_equation_->schema_temps().temps_courant();
142 dis.discretiser_champ("CHAMP_ELEM", mon_equation_->domaine_dis(), scalaire, noms, unit, 2, nb_case_tempo, temps, K_eps_sortie_);
143 K_eps_sortie_->nommer("K_eps_from_nut");
144 K_eps_sortie_->fixer_unites(unit);
145 K_eps_sortie_->fixer_noms_compo(noms);
146 }
147}
148
150{
151 statistics().begin_count(STD_COUNTERS::turbulent_viscosity,statistics().get_last_opened_counter_level()+1);
154 loipar_->calculer_hyd(la_viscosite_turbulente_, energie_cinetique_turbulente());
156 if (mon_equation_->probleme().is_dilatable())
157 correction_nut_et_cisaillement_paroi_si_qc(*this);
158 energie_cinetique_turb_->valeurs().echange_espace_virtuel();
159 la_viscosite_turbulente_->valeurs().echange_espace_virtuel();
160 statistics().end_count(STD_COUNTERS::turbulent_viscosity);
161}
162
164{
165 const Schema_Temps_base& sch = mon_equation_->schema_temps();
166 double temps_courant = sch.temps_courant();
167 double dt = sch.pas_de_temps();
168 if (limpr_ustar(temps_courant, sch.temps_precedent(), dt, dt_impr_ustar_) || limpr_ustar(temps_courant, sch.temps_precedent(), dt, dt_impr_ustar_mean_only_))
169 if (K_eps_sortie_)
170 {
171 double temps = mon_equation_->schema_temps().temps_courant();
172 K_eps_sortie_->mettre_a_jour(temps);
173
174 // compute K_eps
175
176 DoubleTab& K_Eps = K_eps_sortie_->valeurs();
177 const DoubleTab& visco_turb = la_viscosite_turbulente_->valeurs();
178 const DoubleTab& wall_length = wall_length_->valeurs();
179 const int nb_elem = K_Eps.dimension(0);
180
181 const double Kappa = 0.415;
182 double Cmu = CMU;
183 // PQ: 27/06/07: expressions for k and eps based on:
184 //
185 // nu_t = C_mu.K.L.k^(1/2) and nu_t = C_mu.k^2/eps
186
187 for (int elem = 0; elem < nb_elem; elem++)
188 {
189 K_Eps(elem, 0) = pow(visco_turb(elem) / (Cmu * Kappa * wall_length(elem)), 2);
190
191 if (visco_turb(elem) == 0.)
192 K_Eps(elem, 1) = 0.;
193 else
194 K_Eps(elem, 1) = Cmu * K_Eps(elem, 0) * K_Eps(elem, 0) / visco_turb(elem);
195 }
196
197 // PQ: recalibration of k and eps based on results
198 // for a plane channel at Re = 100 000 and Re = 1 000 000
199 for (int elem = 0; elem < nb_elem; elem++)
200 {
201 K_Eps(elem, 0) /= 47.;
202 K_Eps(elem, 1) /= 1000.;
203 //Cerr<<elem <<" "<< K_Eps(elem,0)<<" "<<K_Eps(elem,1)<<" ";
204 //Cerr<<visco_turb(elem)<<" "<<wall_length(elem)<<finl;
205 }
206
207 // finally write the field at elements (already there)
208 const Domaine& dom = mon_equation_->domaine_dis().domaine();
209 Nom fic = fichier_K_eps_sortie_.nom_me(me());
210
211 const Nom& nom_post = K_eps_sortie_->le_nom();
212 const Nom& type_elem = dom.type_elem()->que_suis_je();
213 assert(K_eps_sortie_->valeurs().dimension(0) == dom.nb_elem());
214 Ecrire_MED ecr_med(fic, dom);
215 ecr_med.ecrire_champ("CHAMPMAILLE", nom_post, K_eps_sortie_->valeurs(), K_eps_sortie_->unites(), K_eps_sortie_->noms_compo(), type_elem, temps);
216 }
218}
219
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Discretisation_base This class represents a spatial discretization scheme, which
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
int_t nb_elem() const
Definition Domaine.h:131
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VF
Definition Domaine_VF.h:44
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
void ecrire_champ(const Nom &type, const Nom &nom_cha1, const DoubleTab &val, const Noms &unite, const Noms &noms_compo, const Nom &type_elem, double time)
void ecrire_domaine(bool append=true)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Base class for zero-equation (algebraic) hydraulic turbulence models.
void set_param(Param &param) const override
virtual Champ_Fonc_base & energie_cinetique_turbulente()
OBS_PTR(Domaine_VF) le_dom_VF_
virtual Champ_Fonc_base & calculer_viscosite_turbulente()=0
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void discretiser() override
Discretizes the turbulence model.
int a_pour_Champ_Fonc(const Motcle &mot, OBS_PTR(Champ_base) &ch_ref) const
virtual void calculer_energie_cinetique_turb()=0
void imprimer(Sortie &) const override
Performs printing if necessary.
Base class for the turbulence model hierarchy for Navier-Stokes equations.
int limpr_ustar(double, double, double, double) const
virtual void set_param(Param &param) const override
void discretiser_K(const Schema_Temps_base &, Domaine_dis_base &, OWN_PTR(Champ_Fonc_base)&) const
virtual void discretiser()
Discretizes the turbulence model.
virtual void imprimer(Sortie &) const
Performs printing if necessary.
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const Nom & le_nom() const override
Returns *this.
Definition Nom.cpp:555
An array of character strings (VECT(Nom)).
Definition Noms.h:26
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(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
Definition Process.cpp:122
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.
double pas_de_temps() const
Returns the current time step (delta_t).
double temps_precedent() const
Returns the previous time.
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133