TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Perte_Charge_Reguliere_VEF_P1NC.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Perte_Charge_Reguliere_VEF_P1NC.h>
17#include <Domaine_VEF.h>
18#include <Sous_Domaine.h>
19#include <Fluide_Incompressible.h>
20#include <Equation_base.h>
21#include <Probleme_base.h>
22#include <Domaine.h>
23#include <Champ_Uniforme.h>
24#include <Matrice_Morse.h>
25
26Implemente_instanciable(Perte_Charge_Reguliere_VEF_P1NC,"Perte_Charge_Reguliere_VEF_P1NC",Perte_Charge_VEF_Face);
27
28
29
30//// printOn
31//
32
34{
35 return s << que_suis_je() ;
36}
37
38
39//// readOn
40//
41
43{
44 Cerr << " Perte_Charge_Reguliere_VEF_P1NC::readOn " << finl ;
46 //Nom nom_sous_domaine;
48
49 return s ;
50}
51
52
53/////////////////////////////////////////////////////////////////////
54//
55// Implementation of functions
56//
57// of class Perte_Charge_Reguliere_VEF_P1NC
58//
59////////////////////////////////////////////////////////////////////
60
62{
63 Cerr << " Perte_Charge_Reguliere_VEF_P1NC::remplir_num_faces " << finl;
64 const Domaine& le_domaine = equation().probleme().domaine();
65 const Domaine_VEF& domaine_VEF = le_dom_VEF.valeur();
66
67 const IntTab& elem_faces = domaine_VEF.elem_faces();
68 const IntTab& face_voisins = domaine_VEF.face_voisins();
69 const DoubleVect& volumes = domaine_VEF.volumes();
70 const Sous_Domaine& le_sous_domaine = le_domaine.ss_domaine(un_nom_sous_domaine);
71 int nb_poly_ss_domaine = le_sous_domaine.nb_elem_tot();
72
73 int nfe=domaine_VEF.domaine().nb_faces_elem();
74 int nfac;
75 int num_poly;
76
77 num_faces.resize(nb_poly_ss_domaine*4);
78 corr_front_ss.resize(nb_poly_ss_domaine*4);
79
80 corr_front_ss = 1. ;
81 nfac = 0;
82
83 IntVect num_loc(domaine_VEF.nb_elem_tot());
84 IntVect fait(domaine_VEF.nb_faces_tot());
85 fait = -1;
86 num_loc = -1;
87
88 int num_poly_vois;
89 int num_elem,num_face, face_loc;
90
91 for (num_elem=0; num_elem<nb_poly_ss_domaine; num_elem++)
92 {
93 num_loc[le_sous_domaine(num_elem)] = num_elem;
94 }
95
96 for (num_elem=0; num_elem<nb_poly_ss_domaine; num_elem++)
97 {
98 num_poly = le_sous_domaine(num_elem);
99 for (face_loc = 0; face_loc < nfe ; face_loc++)
100 {
101 num_face = elem_faces(num_poly,face_loc);
102 if (fait(num_face) ==-1)
103 {
104 fait(num_face) = 1 ;
105 num_faces[nfac++] = num_face;
106 for (int i=0; i<2; i++ )
107 {
108 num_poly_vois = face_voisins(num_face,i);
109 if (num_poly_vois != -1)
110 if (num_loc[num_poly_vois] == -1) // the neighbouring poly is not in the sub-domain
111 {
112 corr_front_ss[nfac-1] = volumes(num_poly)/(volumes(num_poly)+volumes(num_poly_vois)) ;
113 }
114 }
115 }
116 }
117 }
118 num_faces.resize(nfac);
119 corr_front_ss.resize(nfac);
120}
121
122DoubleTab& Perte_Charge_Reguliere_VEF_P1NC::ajouter(DoubleTab& resu) const
123{
124 //Cerr << " Perte_Charge_Reguliere_VEF_P1NC::ajouter " << finl;
125 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF,equation().domaine_dis());
126 const DoubleVect& volumes_entrelaces = domaine_VEF.volumes_entrelaces();
127 const DoubleVect& porosite_face = equation().milieu().porosite_face();
128 const DoubleTab& vit = la_vitesse->valeurs();
129 const IntTab& face_voisins = domaine_VEF.face_voisins();
130
131 double U_abs;
132 double Cf,CK,Reynolds;
133 int numfa,n0,n1;
134
135 const Champ_Don_base& nu = le_fluide->viscosite_cinematique();
136 const DoubleTab& visco = nu.valeurs();
137 double d_visco=-1;
138 int l_visco_unif=0;
139
140 if (sub_type(Champ_Uniforme,nu))
141 {
142 const Champ_Uniforme& ch_nu = ref_cast(Champ_Uniforme,nu);
143 d_visco = ch_nu.valeurs()(0,0);
144 l_visco_unif = 1;
145 }
146
147
148 if (couronne_tube == 1)
149 {
150 Cerr << " PQ : 17/06/08: This option has been removed from Perte_Charge_Reguliere_VEF_P1NC" << finl;
151 Cerr << " It is possible to recover the same functionality using the keyword: " << finl;
152 Cerr << " Perte_charge_anisotrope (see doc) " << finl;
153 exit();
154 }
155
156 int premiere_face_int=domaine_VEF.premiere_face_int();
157 int direction = direction_perte_charge();
158 int nb_faces = num_faces.size();
159 for (int i=0; i<nb_faces; i++)
160 {
161 numfa = num_faces[i];
162
163 if (!l_visco_unif)
164 {
165 n0 = face_voisins(numfa,0);
166 n1 = face_voisins(numfa,1);
167 if (numfa < premiere_face_int)
168 {
169 if (n0 != -1)
170 d_visco = visco[n0];
171 else
172 d_visco = visco[n1];
173 }
174 else
175 d_visco = 0.5*(visco[n0]+visco[n1]);
176 }
177 // GF The velocity for computing Re does not depend on porosity
178 // and we use the norm
179 U_abs=0;
180 for (int j =0; j<dimension; j++ )
181 U_abs += vit(numfa,j)*vit(numfa,j);
182
183
184 U_abs = sqrt(U_abs) ;
185
186
187 Reynolds = U_abs*D()/d_visco;
188
189 if (!Cf_utilisateur)
190 Cf = calculer_Cf_blasius(Reynolds);
191 else
192 Cf = CF();
193
194 CK = -0.5*Cf/D();
195
196 resu(numfa,direction) += CK*U_abs*vit(numfa,direction)*volumes_entrelaces(numfa)*porosite_face(numfa)*corr_front_ss(i);
197
198 }
199
200 return resu;
201}
202
204{
205 //Cerr << " Perte_Charge_Reguliere_VEF_P1NC::ajouter " << finl;
206 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF,equation().domaine_dis());
207 const DoubleVect& volumes_entrelaces = domaine_VEF.volumes_entrelaces();
208 const DoubleVect& porosite_face = equation().milieu().porosite_face();
209 const DoubleTab& vit = la_vitesse->valeurs();
210 const IntTab& face_voisins = domaine_VEF.face_voisins();
211
212 double U_abs;
213 double Cf,CK,Reynolds;
214 int numfa,n0,n1;
215
216 const Champ_Don_base& nu = le_fluide->viscosite_cinematique();
217 const DoubleTab& visco = nu.valeurs();
218 double d_visco=-1;
219 int l_visco_unif=0;
220
221 if (sub_type(Champ_Uniforme,nu))
222 {
223 const Champ_Uniforme& ch_nu = ref_cast(Champ_Uniforme,nu);
224 d_visco = ch_nu.valeurs()(0,0);
225 l_visco_unif = 1;
226 }
227
228
229 if (couronne_tube == 1)
230 {
231 Cerr << " PQ : 17/06/08: This option has been removed from Perte_Charge_Reguliere_VEF_P1NC" << finl;
232 Cerr << " It is possible to recover the same functionality using the keyword: " << finl;
233 Cerr << " Perte_charge_anisotrope (see doc) " << finl;
234 exit();
235 }
236
237 int premiere_face_int=domaine_VEF.premiere_face_int();
238 int direction = direction_perte_charge();
239 int nb_faces = num_faces.size();
240 for (int i=0; i<nb_faces; i++)
241 {
242 numfa = num_faces[i];
243
244 if (!l_visco_unif)
245 {
246 n0 = face_voisins(numfa,0);
247 n1 = face_voisins(numfa,1);
248 if (numfa < premiere_face_int)
249 {
250 if (n0 != -1)
251 d_visco = visco[n0];
252 else
253 d_visco = visco[n1];
254 }
255 else
256 d_visco = 0.5*(visco[n0]+visco[n1]);
257 }
258 // GF The velocity for computing Re does not depend on porosity
259 // and we use the norm
260 U_abs=0;
261 for (int j =0; j<dimension; j++ )
262 U_abs += vit(numfa,j)*vit(numfa,j);
263
264
265 U_abs = sqrt(U_abs) ;
266
267
268 Reynolds = U_abs*D()/d_visco;
269
270 if (!Cf_utilisateur)
271 Cf = calculer_Cf_blasius(Reynolds);
272 else
273 Cf = CF();
274
275 CK = -0.5*Cf/D();
276
277 // resu(numfa,dir) += CK*U_abs*vit(numfa,dir)*volumes_entrelaces(numfa)*porosite_face(numfa)*corr_front_ss(i);
278 int n0bis=numfa*dimension+direction;
279 matrice.coef(n0bis,n0bis)-=CK*U_abs*volumes_entrelaces(numfa)*porosite_face(numfa)*corr_front_ss(i);
280
281 }
282
283
284}
285
292
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
Champ_Uniforme Represents a field that is constant in space and time.
const Sous_Domaine_t & ss_domaine(int i) const
Definition Domaine.h:290
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
DoubleVect & volumes_entrelaces()
Definition Domaine_VF.h:99
int nb_faces_tot() const
Returns the total number of faces.
Definition Domaine_VF.h:481
double volumes(int i) const
Definition Domaine_VF.h:113
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_elem_tot() const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
double coef(int i, int j) const
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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 Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
class Perte_Charge_Reguliere_VEF_P1NC
void completer() override
Updates internal references of the Source_base object.
void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const override
contribution to the implicit matrix of source terms, by default no contribution
DoubleTab & ajouter(DoubleTab &) const override
double calculer_Cf_blasius(double) const
Entree & lire_donnees(Entree &)
Reads the specifications of a regular pressure drop from an input stream.
class Perte_Charge_VEF_Face
int direction_perte_charge() const
Returns the pressure drop direction.
const Domaine & domaine() const
Returns the domain associated with the problem.
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
virtual void completer()
Updates internal references of the Source_base object.
int_t nb_elem_tot() const