TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Paroi_UTAU_IMP_VDF.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
17#include <Paroi_UTAU_IMP_VDF.h>
18#include <Champ_Uniforme.h>
19#include <Domaine_Cl_VDF.h>
20#include <Dirichlet_paroi_fixe.h>
21#include <Dirichlet_paroi_defilante.h>
22#include <Fluide_Dilatable_base.h>
23#include <Equation_base.h>
24#include <Modele_turbulence_hyd_base.h>
25
26Implemente_instanciable(Paroi_UTAU_IMP_VDF,"UTAU_IMP_VDF",Paroi_hyd_base_VDF);
27
28// printOn()
29/////
30
32{
33 return s << que_suis_je() << " " << le_nom();
34}
35
36//// readOn
37//
38
40{
41 return lire_donnees(s);
42}
43
44
45/////////////////////////////////////////////////////////////////////
46//
47// Implementation des fonctions de la classe Paroi_UTAU_IMP_VDF
48//
49/////////////////////////////////////////////////////////////////////
50
51
53{
55
56 return 1;
57}
58
59
60int Paroi_UTAU_IMP_VDF::calculer_hyd_BiK(DoubleTab& tab_k,DoubleTab& tab_eps)
61{
62// keps
63 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_dis_.valeur());
64 const IntVect& orientation = domaine_VDF.orientation();
65 const IntTab& face_voisins = domaine_VDF.face_voisins();
66 const Equation_base& eqn_hydr = mon_modele_turb_hyd->equation();
67 const DoubleVect& vit = eqn_hydr.inconnue().valeurs();
68 const DoubleTab& xv=domaine_VDF.xv() ; // centres de gravite des faces
69 DoubleVect pos(dimension);
70 const Fluide_base& le_fluide = ref_cast(Fluide_base, eqn_hydr.milieu());
71 const Champ_Don_base& ch_visco_cin = le_fluide.viscosite_cinematique();
72
73 const DoubleTab& tab_visco = ch_visco_cin.valeurs();
74 int l_unif;
75 double visco=-1;
76 if (sub_type(Champ_Uniforme,ch_visco_cin))
77 {
78 l_unif = 1;
79 visco = std::max(tab_visco(0,0),DMINFLOAT);
80 }
81 else
82 l_unif = 0;
83
84 if ((!l_unif) && (tab_visco.local_min_vect()<DMINFLOAT))
85 // on ne doit pas changer tab_visco ici !
86 {
87 Cerr << "In Paroi_UTAU_IMP_VDF::calculer_hyd_BiK : visco = " << tab_visco.local_min_vect() << " <= 0 ? " << finl;
88 throw;
89 }
90 // tab_visco+=DMINFLOAT;
91
92
93
94 int ndeb,nfin;
95 int elem,ori;
96 double signe;
97 double norm_v;
98 double d_visco;
99
100 // Boucle sur les bords
101
102 for (int n_bord=0; n_bord<domaine_VDF.nb_front_Cl(); n_bord++)
103 {
104
105 // pour chaque condition limite on regarde son type
106 // On applique les lois de paroi uniquement
107 // aux voisinages des parois
108
109 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
110 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
111 ndeb = le_bord.num_premiere_face();
112 nfin = ndeb + le_bord.nb_faces();
113
114 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) || sub_type(Dirichlet_paroi_defilante,la_cl.valeur() ))
115 {
116 int isdiri=0;
117 DoubleTab vitesse_imposee_face_bord(le_bord.nb_faces(),dimension);
118 if (sub_type(Dirichlet_paroi_defilante,la_cl.valeur()) )
119 {
120 isdiri=1;
121 const Dirichlet_paroi_defilante& cl_diri = ref_cast(Dirichlet_paroi_defilante,la_cl.valeur());
122 for (int face=ndeb; face<nfin; face++)
123 for (int k=0; k<dimension; k++)
124 vitesse_imposee_face_bord(face-ndeb,k) = cl_diri.val_imp(face-ndeb,k);
125 }
126 ArrOfDouble vit_paroi(dimension);
127 ArrOfDouble val(dimension-1);
128
129 for (int num_face=ndeb; num_face<nfin; num_face++)
130 {
131 if (isdiri)
132 {
133 int rang = num_face-ndeb;
134 for (int k=0; k<dimension; k++)
135 vit_paroi[k]=vitesse_imposee_face_bord(rang,k);
136 }
137 ori = orientation(num_face);
138 if ( (elem =face_voisins(num_face,0)) != -1)
139 {
140 norm_v=norm_vit(vit,elem,ori,domaine_VDF,vit_paroi,val);
141 signe = -1.;
142 }
143 else
144 {
145 elem = face_voisins(num_face,1);
146 //norm_v=norm_2D_vit(vit,elem,ori,domaine_VDF,val);
147 norm_v=norm_vit(vit,elem,ori,domaine_VDF,vit_paroi,val);
148 signe = 1.;
149 }
150
151 if (l_unif)
152 d_visco = visco;
153 else
154 d_visco = tab_visco[elem];
155
156 // Calcul de la position
157 for (int i=0; i<dimension; i++)
158 pos[i]=xv(num_face,i);
159
160
161 // Calcul de la contrainte tangentielle
162
163 //double ustar = u_star->valeur_a_compo(pos,0);
164 double ustar = calculer_utau(pos, norm_v, d_visco);
165 double vit_frot = ustar*ustar;
166
167 if (ori == 0)
168 {
169 Cisaillement_paroi_(num_face,1) = vit_frot*val[0]*signe;
170 if (dimension==3)
171 Cisaillement_paroi_(num_face,2) = vit_frot*val[1]*signe;
172 Cisaillement_paroi_(num_face,0) = 0.;
173 }
174 else if (ori == 1)
175 {
176 Cisaillement_paroi_(num_face,0) = vit_frot*val[0]*signe;
177 if (dimension==3)
178 Cisaillement_paroi_(num_face,2) = vit_frot*val[1]*signe;
179 Cisaillement_paroi_(num_face,1) = 0.;
180 }
181 else
182 {
183 Cisaillement_paroi_(num_face,0) = vit_frot*val[0]*signe;
184 Cisaillement_paroi_(num_face,1) = vit_frot*val[1]*signe;
185 Cisaillement_paroi_(num_face,2) = 0.;
186 }
187 }
188
189
190 }
191 }
192 Cisaillement_paroi_.echange_espace_virtuel();
194 tab_eps.echange_espace_virtuel();
195 return 1;
196}
197
198int Paroi_UTAU_IMP_VDF::calculer_hyd(DoubleTab& tab_k_eps)
199{
200 DoubleTab bidon(0);
201 // bidon ne servira pas
202 return calculer_hyd(tab_k_eps,1,bidon);
203}
204int Paroi_UTAU_IMP_VDF::calculer_hyd(DoubleTab& tab_nu_t,DoubleTab& tab_k)
205{
206 return calculer_hyd(tab_nu_t,0,tab_k);
207}
208
209
210int Paroi_UTAU_IMP_VDF::calculer_hyd(DoubleTab& tab1,int isKeps,DoubleTab& tab2)
211{
212 // si isKeps =1 tab1=tab_keps
213 // tab2 bidon
214 // si isKeps=0 tab1=tab_nu_t
215 // tab2=tab_k
216 // Cerr<<" Paroi_UTAU_IMP_VDF::calculer_hyd"<<finl;
217 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_dis_.valeur());
218 const IntVect& orientation = domaine_VDF.orientation();
219 const IntTab& face_voisins = domaine_VDF.face_voisins();
220 const Equation_base& eqn_hydr = mon_modele_turb_hyd->equation();
221 const DoubleVect& vit = eqn_hydr.inconnue().valeurs();
222 const DoubleTab& xv=domaine_VDF.xv() ; // centres de gravite des faces
223 DoubleVect pos(dimension);
224 const Fluide_base& le_fluide = ref_cast(Fluide_base, eqn_hydr.milieu());
225 const Champ_Don_base& ch_visco_cin = le_fluide.viscosite_cinematique();
226
227 const DoubleTab& tab_visco = ch_visco_cin.valeurs();
228 int l_unif;
229 double visco=-1;
230 if (sub_type(Champ_Uniforme,ch_visco_cin))
231 {
232 l_unif = 1;
233 visco = std::max(tab_visco(0,0),DMINFLOAT);
234 }
235 else
236 l_unif = 0;
237
238 if ((!l_unif) && (tab_visco.local_min_vect()<DMINFLOAT))
239 // on ne doit pas changer tab_visco ici !
240 {
241 Cerr << "In Paroi_UTAU_IMP_VDF::calculer_hyd : visco = " << tab_visco.local_min_vect() << " <= 0 ? " << finl;
242 throw;
243 }
244 // tab_visco+=DMINFLOAT;
245
246
247
248 int ndeb,nfin;
249 int elem,ori;
250 double signe;
251 double norm_v;
252 double d_visco;
253
254 // Boucle sur les bords
255
256 for (int n_bord=0; n_bord<domaine_VDF.nb_front_Cl(); n_bord++)
257 {
258
259 // pour chaque condition limite on regarde son type
260 // On applique les lois de paroi uniquement
261 // aux voisinages des parois
262
263 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
264 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
265 ndeb = le_bord.num_premiere_face();
266 nfin = ndeb + le_bord.nb_faces();
267
268 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) || sub_type(Dirichlet_paroi_defilante,la_cl.valeur() ))
269 {
270 int isdiri=0;
271 DoubleTab vitesse_imposee_face_bord(le_bord.nb_faces(),dimension);
272 if (sub_type(Dirichlet_paroi_defilante,la_cl.valeur()) )
273 {
274 isdiri=1;
275 const Dirichlet_paroi_defilante& cl_diri = ref_cast(Dirichlet_paroi_defilante,la_cl.valeur());
276 for (int face=ndeb; face<nfin; face++)
277 for (int k=0; k<dimension; k++)
278 vitesse_imposee_face_bord(face-ndeb,k) = cl_diri.val_imp(face-ndeb,k);
279 }
280 ArrOfDouble vit_paroi(dimension);
281 ArrOfDouble val(dimension-1);
282
283 for (int num_face=ndeb; num_face<nfin; num_face++)
284 {
285 if (isdiri)
286 {
287 int rang = num_face-ndeb;
288 for (int k=0; k<dimension; k++)
289 vit_paroi[k]=vitesse_imposee_face_bord(rang,k);
290 }
291 ori = orientation(num_face);
292 if ( (elem =face_voisins(num_face,0)) != -1)
293 {
294 norm_v=norm_vit(vit,elem,ori,domaine_VDF,vit_paroi,val);
295 signe = -1.;
296 }
297 else
298 {
299 elem = face_voisins(num_face,1);
300 //norm_v=norm_2D_vit(vit,elem,ori,domaine_VDF,val);
301 norm_v=norm_vit(vit,elem,ori,domaine_VDF,vit_paroi,val);
302 signe = 1.;
303 }
304
305 if (l_unif)
306 d_visco = visco;
307 else
308 d_visco = tab_visco[elem];
309
310 // Calcul de la position
311 for (int i=0; i<dimension; i++)
312 pos[i]=xv(num_face,i);
313
314
315 // Calcul de la contrainte tangentielle
316
317 //double ustar = u_star->valeur_a_compo(pos,0);
318 double ustar = calculer_utau(pos, norm_v, d_visco);
319 double vit_frot = ustar*ustar;
320
321 if (ori == 0)
322 {
323 Cisaillement_paroi_(num_face,1) = vit_frot*val[0]*signe;
324 if (dimension==3)
325 Cisaillement_paroi_(num_face,2) = vit_frot*val[1]*signe;
326 Cisaillement_paroi_(num_face,0) = 0.;
327 }
328 else if (ori == 1)
329 {
330 Cisaillement_paroi_(num_face,0) = vit_frot*val[0]*signe;
331 if (dimension==3)
332 Cisaillement_paroi_(num_face,2) = vit_frot*val[1]*signe;
333 Cisaillement_paroi_(num_face,1) = 0.;
334 }
335 else
336 {
337 Cisaillement_paroi_(num_face,0) = vit_frot*val[0]*signe;
338 Cisaillement_paroi_(num_face,1) = vit_frot*val[1]*signe;
339 Cisaillement_paroi_(num_face,2) = 0.;
340 }
341 }
342
343
344 }
345 }
346 Cisaillement_paroi_.echange_espace_virtuel();
348 if (! isKeps) tab2.echange_espace_virtuel();
349 return 1;
350}
351
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
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
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.
virtual double val_imp(int i) const
Returns the imposed value on the i-th component of the field at the boundary at the default time of c...
Definition Dirichlet.cpp:35
class Domaine_VDF
Definition Domaine_VDF.h:61
int orientation(int) const override
inline DoubleVect& Domaine_VDF::porosite_face() {
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
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 Champ_Inc_base & inconnue() const =0
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_premiere_face() const
Definition Front_VF.h:63
static int dimension
Definition Objet_U.h:94
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
Entree & lire_donnees(Entree &s)
double calculer_utau(const DoubleVect &pos, double norm_v, double d_visco)
CLASS: Paroi_UTAU_IMP_VDF.
int init_lois_paroi() override
int calculer_hyd(DoubleTab &) override
int calculer_hyd_BiK(DoubleTab &, DoubleTab &) override
Base class for output streams.
Definition Sortie.h:52
_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")