TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Paroi_std_scal_hyd_VEF.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 <Paroi_std_scal_hyd_VEF.h>
17#include <Paroi_std_hyd_VEF.h>
18#include <Probleme_base.h>
19#include <Champ_Uniforme.h>
20#include <Dirichlet_paroi_fixe.h>
21#include <Dirichlet_paroi_defilante.h>
22#include <Champ_Uniforme_Morceaux.h>
23#include <Champ_Fonc_Tabule.h>
24#include <Champ_Fonc_Tabule_P0_VEF.h>
25#include <Fluide_base.h>
26#include <Modele_turbulence_hyd_base.h>
27#include <Convection_Diffusion_Concentration.h>
28#include <Modele_turbulence_scal_base.h>
29#include <Constituant.h>
30#include <SFichier.h>
31#include <Param.h>
32#include <Paroi_decalee_Robin.h>
33
34
35Implemente_instanciable_sans_constructeur(Paroi_std_scal_hyd_VEF,"loi_standard_hydr_scalaire_VEF",Paroi_scal_hyd_base_VEF);
36Implemente_instanciable(Loi_expert_scalaire_VEF,"Loi_expert_scalaire_VEF",Paroi_std_scal_hyd_VEF);
37
38// printOn()
39/////
40
42{
43 return s << que_suis_je() << " " << le_nom();
44}
45
46//// readOn
47//
48
50{
51 return s ;
52}
53
54// printOn()
55/////
56
58{
59 return s;
60}
61
62//// readOn
63//
64
66{
67 Param param(que_suis_je());
68 param.ajouter("prdt_sur_kappa",&Prdt_sur_kappa_);
69 param.ajouter("calcul_ldp_en_flux_impose",&calcul_ldp_en_flux_impose_);
70 param.ajouter_condition("(value_of_calcul_ldp_en_flux_impose_eq_0)_or_(value_of_calcul_ldp_en_flux_impose_eq_1)","calcul_ldp_en_flux_impose must be 0 or 1");
71 param.lire_avec_accolades_depuis(s);
72 return s ;
73}
74
75/////////////////////////////////////////////////////////////////////
76//
77// Implementation des fonctions de la classe Paroi_std_hyd_VEF
78//
79/////////////////////////////////////////////////////////////////////
80
85
87{
88 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF, le_dom_dis_.valeur());
89
90 Equation_base& eqn_hydr = mon_modele_turb_scal->equation().probleme().equation(0);
91 const Fluide_base& le_fluide = ref_cast(Fluide_base,eqn_hydr.milieu());
92 const Champ_Don_base& ch_visco_cin = le_fluide.viscosite_cinematique();
93 const DoubleTab& tab_visco = ch_visco_cin.valeurs();
94 int l_unif;
95
96 double visco0=-1;
97 if (sub_type(Champ_Uniforme,ch_visco_cin))
98 {
99 l_unif = 1;
100 visco0 = std::max(tab_visco(0,0),DMINFLOAT);
101 }
102 else
103 l_unif = 0;
104
105 if ((!l_unif) && (tab_visco.local_min_vect()<DMINFLOAT))
106 // on ne doit pas changer tab_visco ici !
107 {
108 Cerr << "In Paroi_std_scal_hyd_VEF::calculer_scal : visco = " << tab_visco.local_min_vect() << " <= 0 ? " << finl;
109 throw;
110 }
111 // tab_visco+=DMINFLOAT;
112
113 const RefObjU& modele_turbulence_hydr = eqn_hydr.get_modele(TURBULENCE);
114 const Modele_turbulence_hyd_base& le_modele = ref_cast(Modele_turbulence_hyd_base,modele_turbulence_hydr.valeur());
115 const Turbulence_paroi_base& loi = le_modele.loi_paroi();
116 const DoubleVect& tab_u_star = loi.tab_u_star();
117 const Equation_base& eqn = mon_modele_turb_scal->equation();
118 // Recuperation de la diffusivite en fonction du type d'equation:
119 int schmidt = (sub_type(Convection_Diffusion_Concentration,eqn) ? 1 : 0);
120 const Champ_Don_base& champ_alpha = (schmidt==1?ref_cast(Convection_Diffusion_Concentration,eqn).constituant().diffusivite_constituant():le_fluide.diffusivite());
121 int alpha_uniforme = (sub_type(Champ_Uniforme,champ_alpha) ? 1 : 0);
122 const DoubleTab& tab_alpha = champ_alpha.valeurs();
123
124 // Verifications (l'algorithme n'est valable que si d_alpha est le meme pour chaque constituant)
125 if (schmidt)
126 {
127 if (alpha_uniforme)
128 {
129 double d_alpha = tab_alpha(0,0);
130 assert(ref_cast(Convection_Diffusion_Concentration,eqn).constituant().nb_constituants()==tab_alpha.line_size());
131 for (int nc=0; nc<tab_alpha.line_size(); nc++)
132 {
133 if (d_alpha!=tab_alpha(0,nc))
134 {
135 Cerr << "Error!" << finl;
136 Cerr << "Law of the wall are not implemented yet for constituants with different diffusion coefficients." << finl;
138 }
139 }
140 }
141 else
142 {
143 const int size = tab_alpha.dimension(0);
144 const int nb_comp = tab_alpha.line_size();
145 CDoubleTabView alpha = tab_alpha.view_ro();
146 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), size, KOKKOS_LAMBDA(const int elem)
147 {
148 double d_alpha = alpha(elem,0);
149 for (int nc=0; nc<nb_comp; nc++)
150 if (d_alpha!=alpha(elem,nc))
151 Process::Kokkos_exit("Error, Law of the wall are not implemented yet for constituants with different diffusion coefficients.");
152 });
153 end_gpu_timer(__KERNEL_NAME__);
154 }
155 }
156
157 // Boucle sur les bords:
158 for (int n_bord=0; n_bord<domaine_VEF.nb_front_Cl(); n_bord++)
159 {
160 // pour chaque condition limite on regarde son type
161 // On applique les lois de paroi uniquement
162 // aux voisinages des parois
163 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
164 if ( (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()))
165 || (sub_type(Dirichlet_paroi_defilante,la_cl.valeur()))
166 || (sub_type(Symetrie,la_cl.valeur()))
167 || (sub_type(Paroi_decalee_Robin,la_cl.valeur())) )
168 {
169 if (axi) Process::exit("Error: the axisymmetric VEF case is not yet implemented in the scalar wall-function.");
170 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
171 int size=le_bord.nb_faces();
172 DoubleVect& tab_dist_equiv = equivalent_distance_[n_bord];
173 const double delta = sub_type(Paroi_decalee_Robin,la_cl.valeur()) ? ref_cast(Paroi_decalee_Robin,la_cl.valeur()).get_delta() : -1;
174 DoubleTab& tab_alpha_t = diffusivite_turb.valeurs();
175 const double Prdt_sur_kappa = Prdt_sur_kappa_;
176 CIntTabView face_voisins = domaine_VEF.face_voisins().view_ro();
177 CDoubleArrView volumes_maille = static_cast<const ArrOfDouble&>(domaine_VEF.volumes()).view_ro();
178 CDoubleArrView surfaces_face = static_cast<const ArrOfDouble&>(domaine_VEF.face_surfaces()).view_ro();
179 CDoubleArrView u_star = static_cast<const ArrOfDouble&>(tab_u_star).view_ro();
180 CDoubleTabView alpha = tab_alpha.view_ro();
181 CDoubleTabView visco = tab_visco.view_ro();
182 CIntArrView le_bord_num_face = le_bord.num_face().view_ro();
183 CDoubleArrView alpha_t = static_cast<const ArrOfDouble&>(tab_alpha_t).view_ro();
184 DoubleArrView dist_equiv = static_cast<ArrOfDouble&>(tab_dist_equiv).view_rw();
185 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), size, KOKKOS_LAMBDA(const int ind_face)
186 {
187 const int num_face = le_bord_num_face(ind_face);
188 // We search the element touching the wall on the face "num_face".
189 int elem = face_voisins(num_face,0);
190 if (elem == -1)
191 elem = face_voisins(num_face,1);
192
193 // We calculate the distance to the wall of the center of gravity of the element.
194 // Expression de dist en fonction du volume de l element et de l aire de la face
195 const double dist = delta>0 ? delta : volumes_maille(elem)/surfaces_face(num_face);
196
197 // Alex. C. : 11/04/2003
198 const double u_star_val = u_star(num_face);
199 const double d_alpha = alpha_uniforme ? alpha(0,0) : alpha(elem,0);
200 if (u_star_val == 0 || d_alpha==0)
201 dist_equiv(ind_face) = dist;
202 else
203 {
204 // calcul de la viscosite en y+
205 const double d_visco = l_unif ? visco0 : visco(elem,0);
206 const double Pr = d_visco/d_alpha;
207 const double y_plus = dist*u_star_val/d_visco;
208 dist_equiv(ind_face) = (d_alpha + alpha_t(elem)) * T_plus(y_plus,Pr,Prdt_sur_kappa) / u_star_val;
209 }
210 });
211 end_gpu_timer(__KERNEL_NAME__);
212 tab_dist_equiv.echange_espace_virtuel();
213 }
214 }
215 return 1;
216}
217
222
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
Champ_Uniforme Represents a field that is constant in space and time.
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
Convection_Diffusion_Concentration Special case of Convection_Diffusion_std.
Dirichlet_paroi_defilante Imposes the wall velocity in an equation of type Navier_Stokes.
Dirichlet_paroi_fixe Represents a fixed wall in a Navier-Stokes type equation.
class Domaine_VEF
Definition Domaine_VEF.h:53
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
double volumes(int i) const
Definition Domaine_VF.h:113
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
int nb_front_Cl() const
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 RefObjU & get_modele(Type_modele type) const
Probleme_base & probleme()
Returns the problem associated with the equation.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
const Champ_Don_base & viscosite_cinematique() const
Definition Fluide_base.h:56
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_face(const int) const
Definition Front_VF.h:68
cette classe permet de specifier des options a la loi de paroi standard.
virtual const Champ_Don_base & diffusivite() const
Returns the diffusivity of the medium (const version).
Base class for the turbulence model hierarchy for Navier-Stokes equations.
const Turbulence_paroi_base & loi_paroi() const
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
static int axi
Definition Objet_U.h:96
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
int calculer_scal(Champ_Fonc_base &) override
virtual const Equation_base & equation(int) const =0
static KOKKOS_INLINE_FUNCTION void Kokkos_exit(const char *)
Exit routine for TRUST within a Kokkos region.
Definition Process.h:172
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
Symetrie On symmetry faces, the following properties hold:
Definition Symetrie.h:37
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
Definition TRUSTTab.h:261
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67
_TYPE_ local_min_vect(Mp_vect_options opt=VECT_REAL_ITEMS) const
Definition TRUSTVect.h:155
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
const Objet_U & valeur() const
Definition TRUST_Ref.h:134
Base class for the hierarchy of wall-law models computing turbulent quantities near walls....
const DoubleVect & tab_u_star() const
KOKKOS_INLINE_FUNCTION double T_plus(double y_plus, double Pr, double Prdt_sur_kappa)