TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Paroi_Cisaillement_Imp_VEF.cpp
1/****************************************************************************
2* Copyright (c) 2017, 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_Cisaillement_Imp_VEF.h>
17#include <Champ_P1NC.h>
18#include <Fluide_base.h>
19#include <Champ_Uniforme.h>
20#include <Dirichlet_paroi_fixe.h>
21#include <Modele_turbulence_hyd_base.h>
22
23Implemente_instanciable(Paroi_Cisaillement_Imp_VEF,"UTAU_IMP_VEF",Paroi_hyd_base_VEF);
24
25// printOn()
26/////
27
29{
30 return s << que_suis_je() << " " << le_nom();
31}
32
33//// readOn
34//
35
37{
38 return lire_donnees(s);
39}
40
41
42/////////////////////////////////////////////////////////////////////
43//
44// Implementation des fonctions de la classe Paroi_Cisaillement_Imp_VEF
45//
46/////////////////////////////////////////////////////////////////////
47
53
55{
56 calculer_hyd_commun();
57 return 1;
58} // fin de calcul_hyd (K-eps)
59
60int Paroi_Cisaillement_Imp_VEF::calculer_hyd_BiK(DoubleTab& tab_k,DoubleTab& tab_eps)
61{
62 calculer_hyd_commun();
63 return 1;
64} // fin de calcul_hyd (K-eps bicephale)
65
66int Paroi_Cisaillement_Imp_VEF::calculer_hyd(DoubleTab& tab_nu_t,DoubleTab& tab_k)
67{
68 calculer_hyd_commun();
69 return 1;
70} // fin de calcul_hyd (LES)
71
72int Paroi_Cisaillement_Imp_VEF::calculer_hyd_commun()
73{
74 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF, le_dom_dis_.valeur());
75 const IntTab& face_voisins = domaine_VEF.face_voisins();
76 const Equation_base& eqn_hydr = mon_modele_turb_hyd->equation();
77 const Fluide_base& le_fluide = ref_cast(Fluide_base, eqn_hydr.milieu());
78 const Champ_Don_base& ch_visco_cin = le_fluide.viscosite_cinematique();
79 const DoubleTab& vit = eqn_hydr.inconnue().valeurs();
80 const DoubleTab& tab_visco = ch_visco_cin.valeurs();
81 const Domaine& domaine = domaine_VEF.domaine();
82 int nfac = domaine.nb_faces_elem();
83 const DoubleTab& xv = domaine_VEF.xv(); // centre de gravite des faces
84 const DoubleTab& face_normale = domaine_VEF.face_normales();
85
86 ArrOfDouble v(dimension);
87 DoubleVect pos(dimension);
88 double visco=-1;
89 int l_unif;
90 int n_bord;
91
92 tab_u_star_.resize(le_dom_dis_->nb_faces_tot());
93 tab_d_plus_.resize(le_dom_dis_->nb_faces_tot());
94
95
96 if (sub_type(Champ_Uniforme,ch_visco_cin))
97 {
98 visco = std::max(tab_visco(0,0),DMINFLOAT);
99 l_unif = 1;
100 }
101 else
102 l_unif = 0;
103
104 if ((!l_unif) && (tab_visco.local_min_vect()<DMINFLOAT))
105 // on ne doit pas changer tab_visco ici !
106 {
107 Cerr << "In Paroi_Cisaillement_Imp_VEF::calculer_hyd_commun : visco = " << tab_visco.local_min_vect() << " <= 0 ? " << finl;
108 throw;
109 }
110 //tab_visco+=DMINFLOAT;
111
112 int ndeb,nfin;
113 double norm_v=-1;
114 double d_visco;
115
116 // Boucle sur les bords
117 int nb_bords=domaine_VEF.nb_front_Cl();
118 for (n_bord=0; n_bord<nb_bords; n_bord++)
119 {
120 // pour chaque condition limite on regarde son type
121 // On applique les lois de paroi uniquement
122 // aux voisinages des parois
123
124 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
125 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) )
126 {
127 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
128 const IntTab& elem_faces = domaine_VEF.elem_faces();
129 ndeb = le_bord.num_premiere_face();
130 nfin = ndeb + le_bord.nb_faces();
131
132 for (int num_face=ndeb; num_face<nfin; num_face++)
133 {
134 int elem = face_voisins(num_face,0);
135 if (sub_type(Champ_P1NC,eqn_hydr.inconnue())) // donc triangle ou tetraedre
136 {
137
138 // Calcul la moyenne de la vitesse et de la position aux faces (autre que bord) dans l'elem.
139 v=0.;
140 int Compte_face = 0;
141 for (int i=0; i<nfac; i++)
142 if (domaine_VEF.premiere_face_int()<=elem_faces(elem,i))
143 {
144 int face = elem_faces(elem,i);
145 for (int dim=0; dim<dimension; dim++)
146 {
147 v[dim] += vit(face,dim);
148 pos[dim] += xv(face,dim);
149 }
150 Compte_face+=1 ;
151 }
152 for (int dim=0; dim<dimension; dim++)
153 {
154 v[dim]/=Compte_face ;
155 pos[dim]/=Compte_face ;
156 }
157
158 // Projection de la vitesse dans le plan tangentiel
159 double scal=0;
160 for (int dim=0; dim<dimension; dim++)
161 scal+=v[dim]*face_normale(num_face,dim);
162 double surf=0;
163 for (int dim=0; dim<dimension; dim++)
164 surf+=carre(face_normale(num_face,dim));
165 scal/=surf;
166 for (int dim=0; dim<dimension; dim++)
167 v[dim]-=face_normale(num_face,dim)*scal;
168
169 // Calcul de la norme
170 norm_v=0;
171 for (int dim=0; dim<dimension; dim++)
172 norm_v+=carre(v[dim]);
173 norm_v=sqrt(norm_v);
174 }
175 else
176 {
177 Cerr << " On ne sait traiter que des champs P1NC dans Paroi_Cisaillement_Imp_VEF::calculer_hyd" << finl;
179 }
180
181 double dist=distance_face_elem(num_face,elem,domaine_VEF);
182 if (l_unif)
183 d_visco = visco;
184 else
185 d_visco = tab_visco[elem];
186
187 // Calcul de la contrainte tangentielle
188 double ustar = calculer_utau(pos, norm_v, d_visco);
189
190 tab_u_star_(num_face)=ustar;
191 tab_d_plus_(num_face)=dist*ustar/d_visco;
192
193 double norm_tau=ustar*ustar;
194 norm_tau/=(norm_v+DMINFLOAT);
195 for (int dim=0; dim<dimension; dim++)
196 {
197 Cisaillement_paroi_(num_face,dim) = norm_tau*v[dim];
198 }
199
200 }
201
202 } // fin de Dirichlet_paroi_fixe
203 } // fin du for bord CL
204
205 return 1;
206} // fin du calcul_hyd (nu-t)
207
208
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.
int nb_faces_elem(int=0) const
Returns the number of faces of type i of the geometric elements that make up the domain.
Definition Domaine.h:484
class Domaine_VEF
Definition Domaine_VEF.h:53
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
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
const Domaine & domaine() 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
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
Ne pas utiliser cette classe.
int calculer_hyd_BiK(DoubleTab &, DoubleTab &) override
int calculer_hyd(DoubleTab &) override
Entree & lire_donnees(Entree &s)
double calculer_utau(const DoubleVect &pos, double norm_v, double d_visco)
CLASS: Paroi_hyd_base_VEF.
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
_TYPE_ local_min_vect(Mp_vect_options opt=VECT_REAL_ITEMS) const
Definition TRUSTVect.h:155
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91