TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Traitement_particulier_NS_canal_VDF.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 <Traitement_particulier_NS_canal_VDF.h>
17#include <Domaine_VDF.h>
18
19#include <Fluide_base.h>
20#include <Navier_Stokes_std.h>
21#include <Modele_turbulence_hyd_base.h>
22
23Implemente_instanciable(Traitement_particulier_NS_canal_VDF,"Traitement_particulier_NS_canal_VDF",Traitement_particulier_NS_canal);
24
25
26/*! @brief
27 *
28 * @param is output stream
29 * @return modified output stream
30 */
32{
33 return is;
34}
35
36
37/*! @brief
38 *
39 * @param is input stream
40 * @return modified input stream
41 */
43{
44 return is;
45}
46
51
52void Traitement_particulier_NS_canal_VDF::remplir_Y(DoubleVect& tab_Y, DoubleVect& tab_compt, int& nNy) const
53{
54 // Initialize the various member parameters of the class
55 // needed for computing the various spatial averages
56 // Initialization of: Y, compt
57
58 const Domaine_dis_base& zdisbase = mon_equation->inconnue().domaine_dis_base();
59 const Domaine_VF& domaine_VF = ref_cast(Domaine_VF, zdisbase);
60 const DoubleTab& xp = domaine_VF.xp();
61 int nb_elems = domaine_VF.domaine().nb_elem();
62 int num_elem,j,indic,trouve;
63 double y;
64
65 j=0;
66 indic = 0;
67
68 tab_Y.resize(1);
69 tab_compt.resize(1);
70 tab_Y = -100.;
71 tab_compt = 0;
72
73 //Fill the Y array
74 ////////////////////////////////////////////////////////
75
76 for (num_elem=0; num_elem<nb_elems; num_elem++)
77 {
78 y = xp(num_elem,1);
79 trouve = 0;
80
81 for (j=0; j<indic+1; j++)
82 {
83 if(est_egal(y,tab_Y[j]))
84 {
85 tab_compt[j] ++;
86 j=indic+1;
87 trouve = 1;
88 break;
89 }
90 }
91 if (trouve==0)
92 {
93 tab_Y[indic]=y;
94 tab_compt[indic] ++;
95 indic++;
96
97 tab_Y.resize(indic+1);
98 tab_Y(indic)=-100.;
99 tab_compt.resize(indic+1);
100 }
101 }
102
103 nNy = indic;
104
105 tab_Y.resize(nNy);
106 tab_compt.resize(nNy);
107}
108
109//Addition F.A 15/02/11: reorganizing operations that were repeated
110// to make full use of the memory space (loops),
111// by creating a large array (~7M per proc but not exchanged).
112// The array has the following structure: the row is the element index,
113// index of the element above, index of the element below, position in the Y vector.
114// i.e. an array of nelem x 3.
115// After remplir_Y, this function is called to perform the various calculations,
116// using this array as a function argument.
117
119{
120 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
121 const Domaine_VDF& domaine_VDF=ref_cast(Domaine_VDF, zdisbase);
122 const DoubleTab& xp = domaine_VDF.xp();
123 const IntTab& elem_faces = domaine_VDF.elem_faces();
124
125 int face; //face receiver
126 int elem_test,elem_test2; // element for testing fictitious elements
127 int nb_elem_tot = domaine_VDF.domaine().nb_elem_tot(); // total number of elements (real + fictitious)
128 int nb_elems = domaine_VDF.domaine().nb_elem();
129
130 IntTab trouve(1);// array of elements already processed
131 double y=0;
132 int i,num_elem; // counters
133 int q=1; //Cursor for the upper arrays
134 trouve[0]=0;
135
136
137 Tab_rec.resize(nb_elems,3); // Size the array.
138
139 for (num_elem=nb_elems; num_elem<nb_elem_tot; num_elem++) // loop over fictitious elements
140 {
141 face = elem_faces(num_elem,1+dimension);
142 elem_test=domaine_VDF.elem_voisin(num_elem,face,0);
143 face = elem_faces(num_elem,1);
144 elem_test2=domaine_VDF.elem_voisin(num_elem,face,1);
145
146 if ((elem_test>0) && (elem_test<nb_elems)) // if the element above is a real element
147 {
148 trouve[q-1]=elem_test;
149 q =q +1;
150 trouve.resize(q);
151
152 Tab_rec(elem_test,0)=num_elem; // assign the same value to both upper and lower slots
153 Tab_rec(elem_test,1)=num_elem; //so the function computing values sees a normal element
154
155 y=xp(elem_test,1);
156 for (i=0; i<Ny; i++)
157 {
158 if(est_egal(y,Y[i]))
159 break;
160 }
161
162 Tab_rec(elem_test,2)=i; // store i to avoid repeating the loop at each time step
163 }
164 else if ((elem_test2<nb_elems)&&(elem_test2>0)) //otherwise if the element below is a real element
165 {
166 trouve[q-1]=elem_test2;
167 q =q +1;
168 trouve.resize(q);
169
170 Tab_rec(elem_test2,0)=num_elem; // assign the same value to both upper and lower slots
171 Tab_rec(elem_test2,1)=num_elem; //so the function computing values sees a normal element
172
173 y=xp(elem_test2,1);
174 for (i=0; i<Ny; i++)
175 {
176 if(est_egal(y,Y[i]))
177 break;
178 }
179 Tab_rec(elem_test2,2)=i; // store i to avoid repeating the loop at each time step
180
181 }
182 // otherwise do nothing
183 }
184
185 Cerr << "Traitement particulier canal: there is a possible improvement to make for boundary faces!! " << finl;
186 for (num_elem=0; num_elem<nb_elems; num_elem++)
187 {
188 q=0;// reuse counter q (no longer needed) to check whether an equivalent was found
189 for(i=0; i<(trouve.size()-1); i++) // trouve is one slot too large, but instead of resizing it we use the criterion size-1
190 if(num_elem==trouve[i])
191 {
192 q = 0; // fix q so it cannot pass the next test. // correction: set q=0 because it was a false problem
193 break;
194 }
195 // in reality lambda diverges at the interface
196 if(q==0) //
197 {
198 face=elem_faces(num_elem,1); //lower face
199 elem_test=domaine_VDF.elem_voisin(num_elem,face,1);
200
201
202 if (elem_test+1)
203 {
204 Tab_rec(num_elem,1)=elem_test; // wrong if elem_test=-1, otherwise fills with the element below
205 }
206 else
207 {
208 Tab_rec(num_elem,1)=domaine_VDF.elem_voisin(num_elem,elem_faces(num_elem,1+dimension),0); // treat it as a virtual element
209 }
210
211 face= elem_faces(num_elem,1+dimension); //upper face
212 elem_test=domaine_VDF.elem_voisin(num_elem,face,0);
213
214 if (elem_test+1)
215 {
216 Tab_rec(num_elem,0)=elem_test; // wrong if elem_test=-1, otherwise fills with the element above
217 }
218 else
219 {
220 Tab_rec(num_elem,0)=domaine_VDF.elem_voisin(num_elem,elem_faces(num_elem,1),1); // treat it as a virtual element
221 }
222
223 y = xp(num_elem,1);
224 for (i=0; i<Ny; i++)
225 if(est_egal(y,Y[i])) break;
226
227 Tab_rec(num_elem,2)=i;
228
229 }
230
231 }
232}
233
235{
236 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
237 const Domaine_VDF& domaine_VDF=ref_cast(Domaine_VDF, zdisbase);
238 // const DoubleTab& xp = domaine_VDF.xp();
239 const IntTab& elem_faces = domaine_VDF.elem_faces();
240 const DoubleTab& vitesse = mon_equation->inconnue().valeurs();
241 double u,v,wl;
242 int nb_elems = domaine_VDF.domaine().nb_elem();
243 int num_elem,i;
244 int face_x_0,face_y_0,face_y_1,face_z_0;
245
246 const Fluide_base& le_fluide = ref_cast(Fluide_base,mon_equation->milieu());
247 const DoubleTab& visco_dyn = le_fluide.viscosite_dynamique().valeurs();
248 const DoubleTab& tab_rho_elem = le_fluide.masse_volumique().valeurs();
249 int taille_mu=visco_dyn.dimension(0);
250 int taille_rho=tab_rho_elem.dimension(0);
251
252 for (num_elem=0; num_elem<nb_elems; num_elem++)
253 {
254 //y=xp(num_elem,1);
255
256 face_x_0 = elem_faces(num_elem,0);
257 // face_x_1 = elem_faces(num_elem,dimension);
258 face_y_0 = elem_faces(num_elem,1);
259 face_y_1 = elem_faces(num_elem,1+dimension);
260
261 // PQ : 12/10 : to avoid averaging the velocity u and w locally,
262 // we choose to "shift" them
263 // from the face center to the element center
264 // based on the assumption that the flow is homogeneous
265 // in the xz planes.
266 // For v, the average is necessary to return to the element center.
267
268 // u = .5*(vitesse[face_x_0]+vitesse[face_x_1]);
269 u = vitesse[face_x_0];
270 v = .5*(vitesse[face_y_0]+vitesse[face_y_1]);
271
272 i= Tab_recap(num_elem,2);
273
274 val_moy(i,0) += u;
275 val_moy(i,1) += v;
276 val_moy(i,3) += u*u;
277 val_moy(i,4) += v*v;
278 val_moy(i,6) += u*v;
279
280 if(dimension==2) val_moy(i,9) += sqrt(u*u); //tangential velocity for friction computation
281
282 if(dimension==3)
283 {
284 face_z_0 = elem_faces(num_elem,2);
285 // face_z_1 = elem_faces(num_elem,2+dimension);
286
287 // w = .5*(vitesse[face_z_0]+vitesse[face_z_1]);
288 wl = vitesse[face_z_0];
289
290 val_moy(i,2) += wl;
291 val_moy(i,5) += wl*wl;
292 val_moy(i,7) += u*wl;
293 val_moy(i,8) += v*wl;
294 val_moy(i,9) += sqrt(u*u+wl*wl); //tangential velocity for friction computation
295 }
296
297 if (taille_rho==1) val_moy(i,10) += tab_rho_elem(0,0);
298 else val_moy(i,10) += tab_rho_elem[num_elem];
299
300
301 if (taille_mu==1) val_moy(i,11) += visco_dyn(0,0);
302 else val_moy(i,11) += visco_dyn[num_elem];
303 }
304}
305
307{
308 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
309 const Domaine_VDF& domaine_VDF=ref_cast(Domaine_VDF, zdisbase);
310 //const DoubleTab& xp = domaine_VDF.xp();
311 const RefObjU& modele_turbulence = mon_equation->get_modele(TURBULENCE);
312 const Modele_turbulence_hyd_base& mod_turb = ref_cast(Modele_turbulence_hyd_base,modele_turbulence.valeur());
313 const DoubleTab& nu_t = mod_turb.viscosite_turbulente().valeurs();
314
315 int nb_elems = domaine_VDF.domaine().nb_elem();
316 int num_elem,i;
317 // double y;
318
319 for (num_elem=0; num_elem<nb_elems; num_elem++)
320 {
321 //y=xp(num_elem,1);
322
323 i= Tab_recap(num_elem,2);
324
325 val_moy(i,12) += nu_t[num_elem];
326 }
327}
328
330{
331 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
332 const Domaine_VDF& domaine_VDF=ref_cast(Domaine_VDF, zdisbase);
333 //const DoubleTab& xp = domaine_VDF.xp();
334 const IntTab& elem_faces = domaine_VDF.elem_faces();
335 const DoubleTab& temperature = Temp->valeurs();
336 const DoubleTab& vitesse = mon_equation->inconnue().valeurs();
337 double u,v,wl,T;
338 int nb_elems = domaine_VDF.domaine().nb_elem();
339 int num_elem,i;
340 int face_x_0,face_x_1,face_y_0,face_y_1,face_z_0,face_z_1;
341
342 for (num_elem=0; num_elem<nb_elems; num_elem++)
343 {
344 //y=xp(num_elem,1);
345
346 T = temperature[num_elem];
347
348 face_x_0 = elem_faces(num_elem,0);
349 face_x_1 = elem_faces(num_elem,dimension);
350 face_y_0 = elem_faces(num_elem,1);
351 face_y_1 = elem_faces(num_elem,1+dimension);
352
353 u = .5*(vitesse[face_x_0]+vitesse[face_x_1]);
354 v = .5*(vitesse[face_y_0]+vitesse[face_y_1]);
355
356
357 i=Tab_recap(num_elem,2);
358 // for (i=0; i<Ny; i++) if(est_egal(y,Y[i])) break;
359
360 val_moy(i,13) += T;
361 val_moy(i,14) += T*T;
362 val_moy(i,15) += u*T;
363 val_moy(i,16) += v*T;
364
365 if(dimension==3)
366 {
367 face_z_0 = elem_faces(num_elem,2);
368 face_z_1 = elem_faces(num_elem,2+dimension);
369
370 wl = .5*(vitesse[face_z_0]+vitesse[face_z_1]);
371
372 val_moy(i,17) += wl*T;
373 }
374 }
375}
376
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
virtual DoubleTab & valeurs()=0
int_t nb_elem_tot() const
Definition Domaine.h:132
int_t nb_elem() const
Definition Domaine.h:131
class Domaine_VDF
Definition Domaine_VDF.h:61
int elem_voisin(int, int, int) const
class Domaine_VF
Definition Domaine_VF.h:44
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
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
const Champ_Don_base & viscosite_dynamique() const
Definition Fluide_base.h:58
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
Base class for the turbulence model hierarchy for Navier-Stokes equations.
const Champ_Fonc_base & viscosite_turbulente() const
friend class Entree
Definition Objet_U.h:71
static int dimension
Definition Objet_U.h:94
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
Base class for output streams.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91
const Objet_U & valeur() const
Definition TRUST_Ref.h:134
Traitement_particulier_NS_canal_VDF class.
Entree & lire(const Motcle &, Entree &)
void calculer_moyenne_spatiale_Temp(DoubleTab &) const override
void calculer_moyenne_spatiale_vitesse_rho_mu(DoubleTab &) const override
void calculer_moyenne_spatiale_nut(DoubleTab &) const override
void remplir_Y(DoubleVect &, DoubleVect &, int &) const override
Traitement_particulier_NS_canal This class performs specific post-processing treatments.