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
33// this one will soon be in trust, revert the commit when this happen
34// XD Modele_turbulence_hyd_0_eq_base modele_turbulence_hyd_deriv Modele_turbulence_hyd_0_eq_base BRACE Turbulence model
35// XD_CONT constructed using several fields.
36
37Implemente_instanciable_sans_constructeur(Modele_turbulence_hyd_combinaison, "Modele_turbulence_hyd_combinaison", Modele_turbulence_hyd_0_eq_base);
38// XD Modele_turbulence_hyd_combinaison Modele_turbulence_hyd_0_eq_base Modele_turbulence_hyd_combinaison BRACE
39// XD_CONT Turbulence model constructed using several fields.
40
45
47{
49}
50
52{
54}
55
57{
59 param.ajouter("nb_var", &les_var); // XD_ADD_P int
60 // XD_CONT Number of fields used in the model expression (default = 0)
61 param.ajouter("fonction", &la_fct_, Param::REQUIRED); // XD_ADD_P chaine
62 // XD_CONT User function in the form f(x, y, z, t, source_field_name)
63}
64
66{
67 nb_var_ = les_var.size();
68 fxyz_.dimensionner(1);
69 fxyz_[0].setNbVar(4 + nb_var_);
70 fxyz_[0].setString(la_fct_);
71 fxyz_[0].addVar("x");
72 fxyz_[0].addVar("y");
73 fxyz_[0].addVar("z");
74 fxyz_[0].addVar("t");
75 for (int i = 0; i < nb_var_; i++)
76 fxyz_[0].addVar(les_var[i]);
77
78 fxyz_[0].parseString();
79}
80
87
89{
90 statistics().begin_count(STD_COUNTERS::turbulent_viscosity, statistics().get_last_opened_counter_level()+1);
92 loipar_->calculer_hyd(la_viscosite_turbulente_, energie_cinetique_turbulente());
94
95 if (equation().probleme().is_dilatable())
96 correction_nut_et_cisaillement_paroi_si_qc(*this);
97
98 la_viscosite_turbulente_->valeurs().echange_espace_virtuel();
99 statistics().end_count(STD_COUNTERS::turbulent_viscosity);
100}
101
103{
104 const Domaine_VF& domaine_VF = ref_cast(Domaine_VF, equation().domaine_dis());
105 const DoubleTab& xp = domaine_VF.xp();
106 DoubleTab& viscosite_valeurs = la_viscosite_turbulente_->valeurs();
107 const Probleme_base& mon_pb = equation().probleme();
108 double temps = equation().inconnue().temps();
109 const int nb_ddl = domaine_VF.nb_elem();
110 DoubleTabs sources_val(nb_var_);
111
112 IntTab conv_to_elem(nb_var_); // conv_to_elem() = 0 <=> champ P0, = 1 <=> champ P1 ou Q1, = 2 <=> champ P1NC ou Q1NC
113 int go_conv = 0; // go_conv = 1 <=> domaine EF, go_conv = 2 <=> domaine VEF
114 IntTab nb_dim_so(nb_var_);
115 IntTab dim_2_so(nb_var_);
116
117 for (int so = 0; so < nb_var_; so++)
118 {
119 OBS_PTR(Champ_base) ch_ref;
120 ch_ref = mon_pb.get_champ(les_var[so]);
121 const DoubleTab& source_so_val = ch_ref->valeurs();
122 sources_val[so] = source_so_val;
123
124 // type de champ ? doit on convertir en champ par element ?
125 if (sub_type(Champ_Inc_P0_base, mon_pb.get_champ(les_var[so])))
126 {
127 conv_to_elem(so) = 0; // on ne fait rien
128 }
129 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])))
130 {
131 conv_to_elem(so) = 1; // champ nodal a convertir en champ element
132 go_conv = 1;
133 }
134 else if ( sub_type(Champ_P1NC,mon_pb.get_champ(les_var[so])) || sub_type(Champ_Q1NC, mon_pb.get_champ(les_var[so])))
135 {
136 conv_to_elem(so) = 2; // champ face a convertir en champ element
137 go_conv = 2;
138 }
139 else
140 {
141 Cerr << "Modele_turbulence_hyd_combinaison::calculer_viscosite_turbulente : error " << les_var[so] << " not Champ_P0_XX" << finl;
143 }
144
145 if (conv_to_elem(so) != 0)
146 Cerr << "Modele_turbulence_hyd_combinaison::calculer_viscosite_turbulente : " << les_var[so] << " Conversion " << " => Champ_P0_XX" << finl;
147
148 // champ scalaire ? si non, dim seconde dimension ?
149 nb_dim_so(so) = source_so_val.nb_dim();
150 if (nb_dim_so(so) < 1 || nb_dim_so(so) > 2) // nb_dim in [1; 2] only
151 {
152 Cerr << "Modele_turbulence_hyd_combinaison::calculer_viscosite_turbulente : " << les_var[so] << " nb dimension = " << source_so_val.nb_dim() << " != 1 or 2 " << finl;
154 }
155 dim_2_so(so) = 0;
156 if (nb_dim_so(so) != 1)
157 {
158 dim_2_so(so) = source_so_val.dimension(1);
159 Cerr << "Modele_turbulence_hyd_combinaison::calculer_viscosite_turbulente : " << les_var[so] << " nb dimension = " << nb_dim_so(so) << " and second dimension = " << " " << dim_2_so(so)
160 << finl;
161 }
162
163 }
164
165 int nb_loop_contr = 0;
166 IntTab *elem_contr = nullptr;
167 if (go_conv == 1) // Specialization domaine EF
168 {
169 nb_loop_contr = ref_cast(Domaine_EF, equation().domaine_dis()).domaine().nb_som_elem();
170 elem_contr = &ref_cast(Domaine_EF, equation().domaine_dis()).domaine().les_elems();
171 }
172 else if (go_conv == 2) // Specialization domaine VEF
173 {
174 nb_loop_contr = ref_cast(Domaine_VEF, equation().domaine_dis()).domaine().nb_faces_elem();
175 elem_contr = &ref_cast(Domaine_VEF, equation().domaine_dis()).elem_faces();
176 }
177
178 for (int i = 0; i < nb_ddl; i++) // boucle sur les elements
179 {
180 const double x = xp(i, 0);
181 const double y = xp(i, 1);
182 const double z = dimension > 2 ? xp(i, 2) : 0;
183
184 fxyz_[0].setVar("x", x);
185 fxyz_[0].setVar("y", y);
186 fxyz_[0].setVar("z", z);
187 fxyz_[0].setVar("t", temps);
188
189 for (int so = 0; so < nb_var_; so++)
190 {
191 const Nom nom_source = les_var[so];
192 const DoubleTab& source_so_val = sources_val[so];
193
194 if (conv_to_elem(so) == 0) // champ elem
195 {
196 if (nb_dim_so(so) == 1 || dim_2_so(so) == 1)
197 fxyz_[0].setVar(nom_source, source_so_val(i));
198 else
199 {
200 double vale2 = 0.;
201 for (int i2 = 0; i2 < (dim_2_so(so) - 1); i2++)
202 vale2 += source_so_val(i, i2) * source_so_val(i, i2);
203 fxyz_[0].setVar(nom_source, sqrt(vale2));
204 }
205 }
206 else // not champ elem
207 {
208 double vale = 0.;
209 for (int icontrl = 0; icontrl < nb_loop_contr; icontrl++)
210 {
211 const int contrl = (elem_contr != nullptr ? (*elem_contr)(i, icontrl) : 0);
212 if (nb_dim_so(so) == 1 || dim_2_so(so) == 1)
213 vale += source_so_val(contrl) / nb_loop_contr;
214 else
215 {
216 double vale2 = 0.;
217 for (int i2 = 0; i2 < (dim_2_so(so) - 1); i2++)
218 vale2 += source_so_val(contrl, i2) * source_so_val(contrl, i2);
219 vale += sqrt(vale2) / nb_loop_contr;
220 }
221 }
222 fxyz_[0].setVar(nom_source, vale);
223 }
224 }
225 viscosite_valeurs(i) = fxyz_[0].eval();
226 }
227 la_viscosite_turbulente_->changer_temps(temps);
228
229 return la_viscosite_turbulente_;
230}
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