TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_combinaison.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 <Modele_turbulence_hyd_combinaison.h>
17#include <Modifier_pour_fluide_dilatable.h>
18#include <Champ_Inc_P0_base.h>
19#include <Champ_Inc_P1_base.h>
20#include <Champ_Inc_Q1_base.h>
21#include <Equation_base.h>
22#include <Probleme_base.h>
23#include <Perf_counters.h>
24#include <Domaine_VEF.h>
25#include <Champ_P1NC.h>
26#include <Champ_Q1NC.h>
27#include <Domaine_EF.h>
28#include <Domaine_VF.h>
29#include <TRUSTTabs.h>
30#include <Param.h>
31
32
33Implemente_instanciable_sans_constructeur(Modele_turbulence_hyd_combinaison, "Modele_turbulence_hyd_combinaison", Modele_turbulence_hyd_0_eq_base);
34// XD Modele_turbulence_hyd_combinaison Modele_turbulence_hyd_0_eq_base Modele_turbulence_hyd_combinaison BRACE
35// XD_CONT Turbulence model constructed using several fields.
36
41
43{
45}
46
48{
50}
51
53{
55 param.ajouter("nb_var", &les_var); // XD_ADD_P int
56 // XD_CONT Number of fields used in the model expression (default = 0)
57 param.ajouter("fonction", &la_fct_, Param::REQUIRED); // XD_ADD_P chaine
58 // XD_CONT User function in the form f(x, y, z, t, source_field_name)
59}
60
62{
63 nb_var_ = les_var.size();
64 fxyz_.dimensionner(1);
65 fxyz_[0].setNbVar(4 + nb_var_);
66 fxyz_[0].setString(la_fct_);
67 fxyz_[0].addVar("x");
68 fxyz_[0].addVar("y");
69 fxyz_[0].addVar("z");
70 fxyz_[0].addVar("t");
71 for (int i = 0; i < nb_var_; i++)
72 fxyz_[0].addVar(les_var[i]);
73
74 fxyz_[0].parseString();
75}
76
83
85{
86 statistics().begin_count(STD_COUNTERS::turbulent_viscosity, statistics().get_last_opened_counter_level()+1);
88 loipar_->calculer_hyd(la_viscosite_turbulente_, energie_cinetique_turbulente());
90
91 if (equation().probleme().is_dilatable())
92 correction_nut_et_cisaillement_paroi_si_qc(*this);
93
94 la_viscosite_turbulente_->valeurs().echange_espace_virtuel();
95 statistics().end_count(STD_COUNTERS::turbulent_viscosity);
96}
97
99{
100 const Domaine_VF& domaine_VF = ref_cast(Domaine_VF, equation().domaine_dis());
101 const DoubleTab& xp = domaine_VF.xp();
102 DoubleTab& viscosite_valeurs = la_viscosite_turbulente_->valeurs();
103 const Probleme_base& mon_pb = equation().probleme();
104 double temps = equation().inconnue().temps();
105 const int nb_ddl = domaine_VF.nb_elem();
106 DoubleTabs sources_val(nb_var_);
107
108 IntTab conv_to_elem(nb_var_); // conv_to_elem() = 0 <=> champ P0, = 1 <=> champ P1 ou Q1, = 2 <=> champ P1NC ou Q1NC
109 int go_conv = 0; // go_conv = 1 <=> domaine EF, go_conv = 2 <=> domaine VEF
110 IntTab nb_dim_so(nb_var_);
111 IntTab dim_2_so(nb_var_);
112
113 for (int so = 0; so < nb_var_; so++)
114 {
115 OBS_PTR(Champ_base) ch_ref;
116 ch_ref = mon_pb.get_champ(les_var[so]);
117 const DoubleTab& source_so_val = ch_ref->valeurs();
118 sources_val[so] = source_so_val;
119
120 // type de champ ? doit on convertir en champ par element ?
121 if (sub_type(Champ_Inc_P0_base, mon_pb.get_champ(les_var[so])))
122 {
123 conv_to_elem(so) = 0; // on ne fait rien
124 }
125 else if ( sub_type(Champ_Inc_P1_base,mon_pb.get_champ(les_var[so])) || sub_type(Champ_Inc_Q1_base, mon_pb.get_champ(les_var[so])))
126 {
127 conv_to_elem(so) = 1; // champ nodal a convertir en champ element
128 go_conv = 1;
129 }
130 else if ( sub_type(Champ_P1NC,mon_pb.get_champ(les_var[so])) || sub_type(Champ_Q1NC, mon_pb.get_champ(les_var[so])))
131 {
132 conv_to_elem(so) = 2; // champ face a convertir en champ element
133 go_conv = 2;
134 }
135 else
136 {
137 Cerr << "Modele_turbulence_hyd_combinaison::calculer_viscosite_turbulente : error " << les_var[so] << " not Champ_P0_XX" << finl;
139 }
140
141 if (conv_to_elem(so) != 0)
142 Cerr << "Modele_turbulence_hyd_combinaison::calculer_viscosite_turbulente : " << les_var[so] << " Conversion " << " => Champ_P0_XX" << finl;
143
144 // champ scalaire ? si non, dim seconde dimension ?
145 nb_dim_so(so) = source_so_val.nb_dim();
146 if (nb_dim_so(so) < 1 || nb_dim_so(so) > 2) // nb_dim in [1; 2] only
147 {
148 Cerr << "Modele_turbulence_hyd_combinaison::calculer_viscosite_turbulente : " << les_var[so] << " nb dimension = " << source_so_val.nb_dim() << " != 1 or 2 " << finl;
150 }
151 dim_2_so(so) = 0;
152 if (nb_dim_so(so) != 1)
153 {
154 dim_2_so(so) = source_so_val.dimension(1);
155 Cerr << "Modele_turbulence_hyd_combinaison::calculer_viscosite_turbulente : " << les_var[so] << " nb dimension = " << nb_dim_so(so) << " and second dimension = " << " " << dim_2_so(so)
156 << finl;
157 }
158
159 }
160
161 int nb_loop_contr = 0;
162 IntTab *elem_contr = nullptr;
163 if (go_conv == 1) // Specialization domaine EF
164 {
165 nb_loop_contr = ref_cast(Domaine_EF, equation().domaine_dis()).domaine().nb_som_elem();
166 elem_contr = &ref_cast(Domaine_EF, equation().domaine_dis()).domaine().les_elems();
167 }
168 else if (go_conv == 2) // Specialization domaine VEF
169 {
170 nb_loop_contr = ref_cast(Domaine_VEF, equation().domaine_dis()).domaine().nb_faces_elem();
171 elem_contr = &ref_cast(Domaine_VEF, equation().domaine_dis()).elem_faces();
172 }
173
174 for (int i = 0; i < nb_ddl; i++) // boucle sur les elements
175 {
176 const double x = xp(i, 0);
177 const double y = xp(i, 1);
178 const double z = dimension > 2 ? xp(i, 2) : 0;
179
180 fxyz_[0].setVar("x", x);
181 fxyz_[0].setVar("y", y);
182 fxyz_[0].setVar("z", z);
183 fxyz_[0].setVar("t", temps);
184
185 for (int so = 0; so < nb_var_; so++)
186 {
187 const Nom nom_source = les_var[so];
188 const DoubleTab& source_so_val = sources_val[so];
189
190 if (conv_to_elem(so) == 0) // champ elem
191 {
192 if (nb_dim_so(so) == 1 || dim_2_so(so) == 1)
193 fxyz_[0].setVar(nom_source, source_so_val(i));
194 else
195 {
196 double vale2 = 0.;
197 for (int i2 = 0; i2 < (dim_2_so(so) - 1); i2++)
198 vale2 += source_so_val(i, i2) * source_so_val(i, i2);
199 fxyz_[0].setVar(nom_source, sqrt(vale2));
200 }
201 }
202 else // not champ elem
203 {
204 double vale = 0.;
205 for (int icontrl = 0; icontrl < nb_loop_contr; icontrl++)
206 {
207 const int contrl = (elem_contr != nullptr ? (*elem_contr)(i, icontrl) : 0);
208 if (nb_dim_so(so) == 1 || dim_2_so(so) == 1)
209 vale += source_so_val(contrl) / nb_loop_contr;
210 else
211 {
212 double vale2 = 0.;
213 for (int i2 = 0; i2 < (dim_2_so(so) - 1); i2++)
214 vale2 += source_so_val(contrl, i2) * source_so_val(contrl, i2);
215 vale += sqrt(vale2) / nb_loop_contr;
216 }
217 }
218 fxyz_[0].setVar(nom_source, vale);
219 }
220 }
221 viscosite_valeurs(i) = fxyz_[0].eval();
222 }
223 la_viscosite_turbulente_->changer_temps(temps);
224
225 return la_viscosite_turbulente_;
226}
classe Champ_Fonc_base Classe de base des champs qui sont fonction d'une grandeur calculee
: class Champ_Inc_P0_base
virtual DoubleTab & valeurs()=0
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
double temps() const
Renvoie le temps du champ.
class Domaine_EF
Definition Domaine_EF.h:59
class Domaine_VEF
Definition Domaine_VEF.h:54
class Domaine_VF
Definition Domaine_VF.h:44
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
Classe Modele_turbulence_hyd_0_eq_base Classe de base des modeles a 0 equation.
virtual Champ_Fonc_base & energie_cinetique_turbulente()
OBS_PTR(Domaine_VF) le_dom_VF_
virtual int preparer_calcul()
Prepare le calcul.
virtual void set_param(Param &param) const override
Equation_base & equation()
Renvoie l'equation associee au modele de turbulence.
Classe Modele_turbulence_hyd_combinaison Classe representant un modele de turbulence exprime a partir...
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int dimension
Definition Objet_U.h:99
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
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
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
const Champ_base & get_champ(const Motcle &nom) const override
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133