TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Ch_front_Vortex.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Ch_front_Vortex.h>
17#include <Domaine.h>
18#include <LecFicDiffuse.h>
19#include <Interprete.h>
20#include <Domaine_VF.h>
21#include <time.h>
22#include <EcrFicCollecte.h>
23
24Implemente_instanciable_sans_destructeur(Ch_front_Vortex,"Champ_front_Vortex",Champ_front_var_instationnaire);
25
26
31
32/*! @brief Prints the field to an output stream.
33 *
34 * Prints the size of the field and the (constant) value on
35 * the boundary.
36 *
37 * @param (Sortie& os) an output stream
38 * @return (Sortie&) the modified output stream
39 */
41{
42 const DoubleTab& tab=valeurs();
43 os << tab.size() << " ";
44 for(int i=0; i<tab.size(); i++)
45 os << tab(0,i);
46 return os;
47}
48
49/*! @brief Reads the field from an input stream.
50 *
51 * Format:
52 * Champ_front_Vortex nb_compo vrel_1 ... [vrel_i]
53 *
54 * @param (Entree& is) an input stream
55 * @return (Entree& is) the modified input stream
56 */
58{
59 if(dimension!=3)
60 {
61 Cerr << " Vortex Boundary condition requests 3D problem " << finl;
62 exit();
63 }
64
66
67 Nom nom;
68 is >> nom >> geom >> nu >> utau;
69
70 mon_domaine = ref_cast(Domaine, Interprete::objet(nom));
71
72 return is;
73}
74
75/*! @brief Returns the object upcast to Champ_front_base&
76 *
77 * @param (Champ_front_base& ch)
78 * @return (Champ_front_base&) (*this) upcast to Champ_front_base&
79 */
84
85
87{
88 if (first_rand == 1)
89 {
90 srand((int)time (nullptr));
91 first_rand = 0;
92 }
93 return (rand ());
94}
95
97{
98 Nom fichier = "vortex.sauv";
99 if(la_frontiere_dis)
100 {
101 Cerr << "Saving vortices in " << fichier << finl;
102 EcrFicCollecte fic(fichier);
103 fic.setf(ios::scientific);
104
105 int nbvortex = xvort.size();
106
107 fic << temps << finl;
108 fic << nbvortex << finl;
109
110 for (int i=0; i<nbvortex; i++)
111 {
112 fic << xvort(i) << " " << yvort(i) << " " << zvort(i) << " " << tvort(i) << " " ;
113 fic << svort(i) << " " << fvort[i] << " " << gamma(i) << " " << sigma(i) << finl;
114 }
115 fic.close();
116 }
117}
118
120{
121 Cerr << " Ch_front_Vortex::reprendre_vortex" << finl;
122
123 Nom fichier = "vortex.sauv";
124 if (nproc()>1) fichier=fichier.nom_me(me());
125 if(la_frontiere_dis)
126 {
127 Cerr << "Resumption of vortices in " << fichier << finl;
128 EFichier fic(fichier);
129 fic.setf(ios::scientific);
130
131 if(fic.fail())
132 {
133 Cerr << "Unable to open file " << fichier << finl;
134 exit();
135 }
136
137 double tps;
138 int nbvortex;
139
140 fic >> tps;
141 fic >> nbvortex;
142
143 if(!(std::fabs(temps-tps)/(std::fabs(tps)+1.e-24)<1.e-6))
144 {
145 Cerr << " time : " << tps << " in " << fichier << " does not match the time of resumed " << temps << finl;
146 exit();
147 }
148
149 Cerr << " resumed " << nbvortex << " vortex at time " << temps << finl;
150
151 for (int i=0; i<nbvortex; i++)
152 {
153 fic >> xvort(i) >> yvort(i) >> zvort(i) >> tvort(i);
154 fic >> svort(i) >> fvort[i] >> gamma(i) >> sigma(i);
155 }
156
157 Cerr << " resumed made " << finl;
158 }
159}
160
161
162int Ch_front_Vortex::initialiser(double un_temps, const Champ_Inc_base& inco)
163{
165 return 0;
166
167 Domaine& domaine=mon_domaine.valeur();
168 const Frontiere_dis_base& fr_dis=frontiere_dis();
169 const Frontiere& frontiere=fr_dis.frontiere();
170 const int nb_faces=frontiere.nb_faces();
171 const int ndeb=frontiere.num_premiere_face();
172 const int nfin=ndeb+nb_faces;
173 const Faces& faces=frontiere.faces();
174 int nbsf=faces.nb_som_faces();
175 const Domaine_VF& zvf = ref_cast(Domaine_VF, domaine_dis());
176 const DoubleTab& xv=zvf.xv();
177
178 double x,y,z;
179 double dx,dy,dz;
180 double norme;
181
182 double C_mu = 0.09;
183
184
185 u.resize(nb_faces);
186 v.resize(nb_faces);
187 w.resize(nb_faces);
188 u_moy.resize(nb_faces);
189 dudy.resize(nb_faces);
190 k.resize(nb_faces);
191 eps.resize(nb_faces);
192 Wk.resize(nb_faces);
193
194 for(int face=ndeb; face<nfin; face++)
195 {
196 Wk(face) = 2.*drand48()-1.;
197 }
198
199
200 /////////////////////////////////////////////////////////
201 // geometric characteristics associated with the boundary
202 /////////////////////////////////////////////////////////
203
204 if(geom=="circle")
205 {
206
207 double x_xmin=1.e6;
208 double x_xmax=-1.e6;
209 double y_xmin=1.e6;
210 double y_xmax=-1.e6;
211 double z_xmin=1.e6;
212 double z_xmax=-1.e6;
213 double x_ymin=1.e6;
214 double x_ymax=-1.e6;
215 double y_ymin=1.e6;
216 double y_ymax=-1.e6;
217 double z_ymin=1.e6;
218 double z_ymax=-1.e6;
219
220
221 for(int face=ndeb; face<nfin; face++)
222 {
223 for(int kk=0; kk<nbsf; kk++)
224 {
225 x=domaine.coord(faces.sommet(face,kk),0);
226 y=domaine.coord(faces.sommet(face,kk),1);
227 z=domaine.coord(faces.sommet(face,kk),2);
228
229 if(y<y_ymin)
230 {
231 y_ymin=y;
232 x_ymin=x;
233 z_ymin=z;
234 }
235 if(y>y_ymax)
236 {
237 y_ymax=y;
238 x_ymax=x;
239 z_ymax=z;
240 }
241
242 if(x<x_xmin)
243 {
244 x_xmin=x;
245 y_xmin=y;
246 z_xmin=z;
247 }
248 if(x>x_xmax)
249 {
250 x_xmax=x;
251 y_xmax=y;
252 z_xmax=z;
253 }
254 }
255 }
256
257 if(!est_egal(y_ymin,y_ymax))
258 {
259 dx=x_ymax-x_ymin;
260 dy=y_ymax-y_ymin;
261 dz=z_ymax-z_ymin;
262
263 Ox=0.5*(x_ymax+x_ymin);
264 Oy=0.5*(y_ymax+y_ymin);
265 Oz=0.5*(z_ymax+z_ymin);
266 }
267 else
268 {
269 dx=x_xmax-x_xmin;
270 dy=y_xmax-y_xmin;
271 dz=z_xmax-z_xmin;
272
273 Ox=0.5*(x_xmax+x_xmin);
274 Oy=0.5*(y_xmax+y_xmin);
275 Oz=0.5*(z_xmax+z_xmin);
276 }
277
278 R=0.5*sqrt(dx*dx+dy*dy+dz*dz);
279
280 surf = M_PI*R*R;
281
282 Cerr << " Coordinates associated with the boundary : " << Ox << " " << Oy << " " << Oz << finl;
283 Cerr << " Radius computed : " << R << finl;
284
285 }
286 else if(geom=="channel")
287 {
288 //
289 // the channel is assumed to be oriented along x,
290 // periodic along z (and x)
291 // the inlet boundary centered at the origin
292 // with height and width: 2
293 // i.e. (x,y,z) : [0;0]x[-1;+1]x[-1;+1]
294
295 R=1.;
296
297 Ox=0.;
298 Oy=0.;
299 Oz=0.;
300
301 surf = 4.;
302 }
303
304 ///////////////////////////////////////////////////////////////
305 // local frame (t1;t2) associated with the boundary (assumed to be planar)
306 ///////////////////////////////////////////////////////////////
307 if (nb_faces==0)
308 {
309 nb_vortex=0;
310 }
311 else
312 {
313 nx=-zvf.face_normales(ndeb,0); // normals oriented towards the interior of the domain
314 ny=-zvf.face_normales(ndeb,1);
315 nz=-zvf.face_normales(ndeb,2);
316
317 norme = sqrt( nx*nx + ny*ny + nz*nz );
318
319 nx/=norme;
320 ny/=norme;
321 nz/=norme;
322
323 t1x = -ny;
324 t1y = nx;
325 t1z = 0.;
326
327 if( (est_egal(nx,0.)) && (est_egal(ny,0.)) )
328 {
329 t1x = 0.;
330 t1y = nz;
331 t1z = -ny;
332 }
333
334 norme = sqrt( t1x*t1x + t1y*t1y + t1z*t1z );
335
336 t1x/=norme;
337 t1y/=norme;
338 t1z/=norme;
339
340 t2x = ny*t1z - nz*t1y;
341 t2y = nz*t1x - nx*t1z;
342 t2z = nx*t1y - ny*t1x;
343 /*
344 Cerr << " t1x " << t1x << finl;
345 Cerr << " t1y " << t1y << finl;
346 Cerr << " t1z " << t1z << finl;
347 Cerr << " t2x " << t2x << finl;
348 Cerr << " t2y " << t2y << finl;
349 Cerr << " t2z " << t2z << finl;
350 */
351 ///////////////////////////////////////////////////////////////////
352 // initialization of the fields: velocity - k - epsilon (analytical)
353 ///////////////////////////////////////////////////////////////////
354
355 double d,dplus,Reytau;
356 double kappa = 0.41;
357 double beta = 5.1;
358 double tmp=15*15*15*15;
359 for(int face=ndeb; face<nfin; face++)
360 {
361 x=xv(face,0);
362 y=xv(face,1);
363 z=xv(face,2);
364
365 dx=x-Ox;
366 dy=y-Oy;
367 dz=z-Oz;
368
369 if(geom=="circle")
370 {
371 d = R - sqrt(dx*dx+dy*dy+dz*dz) ; // distance to the wall
372 }
373 else
374 {
375 d = R - std::fabs(y) ; // distance to the wall
376 }
377
378 if(d<=0.)
379 {
380 Cerr << " the computation of a zero or negative distance is prejudicial for the rest of the calculation" << finl;
381 Cerr << " Problem certainly related to the calculation of the size of domain or origin related to the bondary" << finl;
382 exit();
383 }
384
385 dplus = d*utau/nu;
386 Reytau = R*utau/nu;
387
388 if(dplus<11.)
389 {
390 u_moy(face) = utau*dplus ;
391 }
392 else
393 {
394 u_moy(face) = utau*((1./kappa)*log(dplus)+beta) ;
395 }
396
397 if(dplus<11.)
398 {
399 dudy(face) = utau*utau/nu ; // -> discontinuous dudy gradient at dplus = 11
400 }
401 else
402 {
403 dudy(face) = utau/(kappa*d) ; // -> generates a discontinuity on u' at this location
404 }
405
406 k(face) = utau*utau * ( 0.07*dplus*dplus*exp(-dplus/8)+4.5*(1.-exp(-dplus/20.))/(1.+4.*dplus/Reytau) ) ;
407 eps(face) = (utau*utau*utau*utau/nu) * (1./(0.41 *(pow(dplus*dplus*dplus*dplus+tmp,0.25)))) ;
408 }
409
410 u = u_moy;
411
412 //////////////////////////////////
413 // evaluation of the number of vortices
414 /////////////////////////////////
415
416 double sigma_moy = 0.;
417
418 for(int face=ndeb; face<nfin; face++)
419 {
420 double sx=zvf.face_normales(face,0);
421 double sy=zvf.face_normales(face,1);
422 double sz=zvf.face_normales(face,2);
423
424 sigma_moy += sqrt(sx*sx+sy*sy+sz*sz) * pow(k(face),1.5) / eps(face);
425
426 }
427 sigma_moy *= pow(C_mu,0.75);
428 sigma_moy /= surf;
429 // We cannot use modf (see Schema_Temps_base::limpr) because
430 // nb_vortex is used to size arrays!
431 nb_vortex = (int) ( surf / (M_PI * sigma_moy *sigma_moy) );
432 }
433 Cerr << "nb_vortex " <<nb_vortex << finl;
434
435 //nb_vortex=1;
436 //nb_vortex=nb_faces;
437
438 xvort.resize(nb_vortex);
439 yvort.resize(nb_vortex);
440 zvort.resize(nb_vortex);
441 tvort.resize(nb_vortex);
442 svort.resize(nb_vortex);
443 fvort.resize_array(nb_vortex);
444 gamma.resize(nb_vortex);
445 sigma.resize(nb_vortex);
446
447 //////////////////////////////////////////////////////
448 // Computation of the minimum lifetime of the vortices
449 //////////////////////////////////////////////////////
450
451 double dt_vortex,dt_min=1.e6;
452
453 for (int i=0; i<nb_faces; i++) // estimation of the required dt_min
454 {
455 dt_vortex=5.*C_mu*pow(k(i),3./2.)/(eps(i)*u_moy(i));
456 if(dt_vortex<dt_min) dt_min=dt_vortex;
457 }
458
459 Cerr << " DT_MIN VORTEX " << dt_min << finl;
460
461 /////////////////////////////////////////////////
462 // vortex initialisation by random drawing
463 /////////////////////////////////////////////////
464
465 /*
466 for (int i=0;i<nb_vortex;i++) // different random at each new draw
467 {
468 int face = my_rand() % nb_faces;
469 double rand1 = (my_rand() % 100)/100.;
470 double rand2 = (my_rand() % 100)/100.;
471 xvort(i)=xv(face,0);
472 yvort(i)=xv(face,1);
473 zvort(i)=xv(face,2);
474 tvort(i)=rand1*5.*C_mu*pow(k(face),3./2.)/(eps(face)*u_moy(face));
475 if (rand2<0.5) svort(i)=-1.;
476 else svort(i)=1.;
477
478 Cerr << " Vortex " << i << finl;
479 Cerr << " Face " << face << " " << xvort(i) << " " <<yvort(i) << " " <<zvort(i) << finl;
480 Cerr <<" " << tvort(i) << " " <<svort(i) << finl;
481 Cerr << " " << finl;
482
483 }
484 */
485
486 for (int i=0; i<nb_vortex; i++) // identical random sequence at each new draw
487 {
488 int face = (int)(nb_faces*drand48());
489 xvort(i)=xv(face,0);
490 yvort(i)=xv(face,1);
491 zvort(i)=xv(face,2);
492 tvort(i)=drand48()*5.*C_mu*pow(k(face),3./2.)/(eps(face)*u_moy(face));
493 if (drand48()<0.5) svort(i)=-1.;
494 else svort(i)=1.;
495 /*
496 Cerr << " Vortex " << i << finl;
497 Cerr << " Face " << face << " " << xvort(i) << " " <<yvort(i) << " " <<zvort(i) << finl;
498 Cerr <<" " << tvort(i) << " " <<svort(i) << finl;
499 Cerr << " " << finl;
500 */
501 }
502
503 mettre_a_jour(un_temps);
504
505 return 1;
506}
507
508void Ch_front_Vortex::deplacement_vortex(double dx,double dy,double dz,double asigma,double agamma,
509 double& vv,double& ww)
510{
511 double norme2 = dx*dx + dy*dy + dz*dz ;
512
513 if(norme2<(4.*asigma) && norme2>1.e-8)
514 {
515 double e1 = exp(-norme2/(2.*asigma*asigma));
516 double f = (1.-e1) * agamma * e1 / (2.* M_PI * norme2 );
517
518 double dt1 = dx*t1x + dy*t1y + dz*t1z ;
519 double dt2 = dx*t2x + dy*t2y + dz*t2z ;
520
521 vv += dt2*f;
522 ww -= dt1*f;
523 }
524}
525
527{
528 const Frontiere_dis_base& fr_dis=frontiere_dis();
529 const Frontiere& frontiere=fr_dis.frontiere();
530 const int nb_faces=frontiere.nb_faces();
531 const int ndeb=frontiere.num_premiere_face();
532 const int nfin=ndeb+nb_faces;
533 DoubleTab& les_val=valeurs();
534
535 const Domaine_VF& zvf = ref_cast(Domaine_VF, domaine_dis());
536 const DoubleTab& xv=zvf.xv();
537
538 double alpha=0;
539 double dist,dist2;
540 double x,yter,z;
541 double xp,yp,zp;
542 double xvort_mir,yvort_mir,zvort_mir;
543 double xvort_per,yvort_per,zvort_per;
544 double dx,dy,dz;
545
546 double C_mu = 0.09;
547
548 if(init)
549 {
550 init=0;
551 temps=tps;
552
553 if(temps!=0.) // this is a restart
555 }
556
557 //////////////////////////////////////////////////
558 // vortex characteristics (position-vorticity)
559 //////////////////////////////////////////////////
560 if (nb_vortex!=0)
561 alpha = 4.*sqrt(M_PI*surf/(3.*nb_vortex*(2.*log(3.)-3.*log(2.))));
562
563 for (int i=0; i<nb_vortex; i++)
564 {
565 x=xvort(i);
566 yter=yvort(i);
567 z=zvort(i);
568
569 dist=1.e6;
570 int face=-1;
571
572 for(int j=ndeb; j<nfin; j++)
573 {
574 dist2=(xv(j,0)-x)*(xv(j,0)-x)+(xv(j,1)-yter)*(xv(j,1)-yter)+(xv(j,2)-z)*(xv(j,2)-z);
575
576 if(dist2<dist)
577 {
578 dist=dist2;
579 face=j;
580 }
581 }
582 gamma(i) = alpha * sqrt(k(face)) * svort(i);
583 sigma(i) = pow(C_mu,0.75) * pow(k(face),1.5) / eps(face);
584 fvort[i] = face ;
585 }
586
587 ///////////////////////////////////////////////////////////////////////////////////
588 // computation of the velocity induced by the vortices at each face of the boundary
589 ///////////////////////////////////////////////////////////////////////////////////
590
591 for(int face=ndeb; face<nfin; face++)
592 {
593 x=xv(face,0);
594 yter=xv(face,1);
595 z=xv(face,2);
596
597 x -= Ox ; // NOTE: For practical reasons,
598 yter -= Oy ; // point coordinates are expressed
599 z -= Oz ; // relative to the boundary origin Ox,Oy,Oz
600
601 v(face) = 0.; // velocity induced by vortices at the face along t1
602 w(face) = 0.; // velocity induced by vortices at the face along t2
603
604 for (int i=0; i<nb_vortex; i++)
605 {
606 dx = (xvort(i)-Ox) - x;
607 dy = (yvort(i)-Oy) - yter;
608 dz = (zvort(i)-Oz) - z;
609
610 deplacement_vortex(dx,dy,dz,sigma(i),gamma(i),v(face),w(face));
611
612
613 ////////////////////////////////////
614 // boundary condition treatment
615 ////////////////////////////////////
616
617 //***************************************
618 // Walls: mirror vortex treatment
619 //***************************************
620
621 if(geom=="circle")
622 {
623 xp = x * R / (sqrt(x*x+yter*yter+z*z)) ;
624 yp = yter * R / (sqrt(x*x+yter*yter+z*z)) ;
625 zp = z * R / (sqrt(x*x+yter*yter+z*z)) ;
626 }
627 else //channel
628 {
629 xp = x;
630 yp = R;
631 if(yter<0) yp = -R;
632 zp = z;
633 }
634
635 xvort_mir = 2. * xp - (xvort(i)-Ox);
636 yvort_mir = 2. * yp - (yvort(i)-Oy);
637 zvort_mir = 2. * zp - (zvort(i)-Oz);
638
639 dx = xvort_mir - x;
640 dy = yvort_mir - yter;
641 dz = zvort_mir - z;
642
643 deplacement_vortex(dx,dy,dz,sigma(i),gamma(i),v(face),w(face));
644
645
646 //***************************************
647 // Periodicity: planar channel only
648 //***************************************
649
650 if(geom=="channel")
651 {
652
653 xvort_per = (xvort(i)-Ox);
654 yvort_per = (yvort(i)-Oy);
655 if( (zvort(i)-Oz) >0.) zvort_per = -2.*R + (zvort(i)-Oz) ;
656 else zvort_per = 2.*R + (zvort(i)-Oz);
657
658 dx = xvort_per - x;
659 dy = yvort_per - yter;
660 dz = zvort_per - z;
661
662 deplacement_vortex(dx,dy,dz,sigma(i),gamma(i),v(face),w(face));
663
664 }
665
666 }//loop over vortices
667
668
669 ////////////////////////////////////////////////////////////////////////////
670 // computation of the longitudinal velocity fluctuation via the Langevin equation
671 ////////////////////////////////////////////////////////////////////////////
672
673
674 // double up = u(face) - u_moy(face);
675 double up= u(face);
676 if(tps==0.) up=0.;
677 double vp;
678
679 if(geom=="channel") vp = w(face);
680 else //(geom=="circle")
681 {
682 double norme = sqrt(x*x+yter*yter+z*z);
683 double costheta = ( x*t1x + yter*t1y + z*t1z ) / norme;
684 double sintheta = ( x*t2x + yter*t2y + z*t2z ) / norme;
685 vp = costheta*v(face) + sintheta*w(face) ;
686 }
687
688 ///// Wiener process: "Gaussian" random draw satisfying <dW>=0 and <dW^2>=1 /////////
689 /////
690 ///// http://www.taygeta.com/random/gaussian.html
691
692 double x1,x2,ybis,Wkp1,dW;
693
694 do
695 {
696 x1 = 2. * drand48() - 1. ;
697 x2 = 2. * drand48() - 1. ;
698 ybis = x1 * x1 + x2 * x2;
699 }
700 while ( ybis >= 1. );
701
702 Wkp1 = x1 * sqrt( (-1.0 * log( ybis ) ) / ybis ); // Working on dW -> to ensure <dW^2>=1, the coefficient must be modified
703 dW = Wkp1 - Wk(face) ; // compared to the formulation proposed in 'taygeta'
704 Wk(face) = Wkp1 ;
705
706 /*
707 double Wkp1,dW;
708
709 Wkp1 = 2.*drand48()-1.;
710 dW = (Wkp1 - Wk(face))*sqrt(3./2.) ;
711 Wk(face) = Wkp1 ;
712
713
714 double W,Wp1,dW;
715 W = 2.*drand48()-1.;
716 Wp1 = 2.*drand48()-1.;
717 dW = (Wp1 - W)*sqrt(3./2.) ;
718 */
719
720
721 //////////////////////////////////
722
723 double C0,C1,C2;
724
725 C0=14./15.;
726 C1=1.8;
727 C2=0.6;
728
729 double T=k(face)/eps(face);
730
731 double dt = tps - temps;
732
733 if(dt!=0.) // implementation following Sergent's thesis + EDF paper (up to a factor 2/3 relative to C2)
734 {
735 up += dt*( -(C1/(2.*T))*up + (C2-1.)*dudy(face)*vp + sqrt(C0*eps(face))*dW/dt );
736
737 // up += dt*( -(C1/(2.*T))*up + ((2./3.)*C2-1.)*dudy(face)*vp + sqrt(C0*eps(face))*dW/dt );
738 }
739 /*
740 if(dt!=0.) // implementation following what is coded in Saturne
741 {
742 up += dt*(-(1.-(2./3.)*C2)*dudy(face)*vp) + 2.*sqrt((2./3.)*(C1-1.)*eps(face)*dt)*dW;
743 up /= (1.+5.*C1*dt/T);
744 }
745 */
746
747 // u(face) = u_moy(face) + up;
748 u(face) = up;
749
750
751 les_val(face,0) = u(face)*nx + v(face)*t1x + w(face)*t2x ;
752 les_val(face,1) = u(face)*ny + v(face)*t1y + w(face)*t2y ;
753 les_val(face,2) = u(face)*nz + v(face)*t1z + w(face)*t2z ;
754
755 /*
756 les_val(face,0) = gamma(face) ;
757 les_val(face,1) = sigma(face) ;
758 les_val(face,2) = fvort(face) ;
759
760 les_val(face,0) = k(face) ;
761 les_val(face,1) = eps(face) ;
762 les_val(face,2) = u_moy(face) ;
763
764 */
765 }//loop over faces
766
767
768 //////////////////////////
769 // vortex displacement
770 //////////////////////////
771
772
773 double dt = tps - temps;
774 temps=tps;
775
776
777 for (int i=0; i<nb_vortex; i++)
778 {
779 int face = fvort[i];
780
781 x = xvort(i) + dt * ( v(face)*t1x + w(face)*t2x ); // Vortex displacements only occur
782 yter = yvort(i) + dt * ( v(face)*t1y + w(face)*t2y ); // in the inlet plane, hence the u.n
783 z = zvort(i) + dt * ( v(face)*t1z + w(face)*t2z ); // components are excluded
784
785 x -= Ox ; // NOTE: For practical reasons,
786 yter -= Oy ; // point coordinates are expressed
787 z -= Oz ; // relative to the boundary origin Ox,Oy,Oz
788
789
790 if( (geom=="circle") && ((x*x+yter*yter+z*z)>=(R*R)) ) //wall
791 {
792 // wall: do nothing - leave the vortex at its current position
793 }
794 else if( (geom=="channel") && (std::fabs(yter)>R) ) //wall
795 {
796 // wall: do nothing - leave the vortex at its current position
797 }
798 else if( (geom=="channel") && (z>R) ) //periodicity
799 {
800 xvort(i) = x + Ox;
801 yvort(i) = yter + Oy;
802 zvort(i) = -2.*R + z + Oz;
803 }
804 else if( (geom=="channel") && (z<-R) ) //periodicity
805 {
806 xvort(i) = x + Ox;
807 yvort(i) = yter + Oy;
808 zvort(i) = 2.*R - z + Oz;
809 }
810 else
811 {
812 xvort(i) = x + Ox;
813 yvort(i) = yter + Oy;
814 zvort(i) = z + Oz;
815 }
816 }
817
818 ///////////////////////////////////////////////////////
819 // end of vortex lifetime - generation of new vortex
820 ///////////////////////////////////////////////////////
821
822 for (int i=0; i<nb_vortex; i++)
823 {
824 tvort(i) -= dt ;
825
826 if(tvort(i)<=0.)// end of vortex lifetime
827 {
828 /*
829 int face = my_rand() % nb_faces; // different random at each new draw
830 // double rand1 = (my_rand() % 100)/100.;
831 double rand2 = (my_rand() % 100)/100.;
832 xvort(i)=xv(face,0);
833 yvort(i)=xv(face,1);
834 zvort(i)=xv(face,2);
835 tvort(i)=5.*C_mu*pow(k(face),3./2.)/(eps(face)*u_moy(face));
836 if (rand2<0.5) svort(i)=-1.;
837 else svort(i)=1.;
838 */
839 int face = (int)(nb_faces*drand48()); // identical random sequence at each execution
840 xvort(i)=xv(face,0);
841 yvort(i)=xv(face,1);
842 zvort(i)=xv(face,2);
843 tvort(i)=5.*C_mu*pow(k(face),3./2.)/(eps(face)*u_moy(face));
844 if (drand48()<0.5) svort(i)=-1.;
845 else svort(i)=1.;
846
847 Cerr << " Time " << temps << " Vortex " << i << finl;
848 Cerr << " Face " << face << " " << xvort(i) << " " <<yvort(i) << " " <<zvort(i) << finl;
849 Cerr <<" " << tvort(i) << " " <<svort(i) << finl;
850 Cerr << " " << finl;
851 }
852 }
853}
class Ch_fr_Vortex Derived class of Champ_front_var that represents
~Ch_front_Vortex() override
void deplacement_vortex(double, double, double, double, double, double &, double &)
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of calculation.
void mettre_a_jour(double) override
DOES NOTHING, to override.
Champ_front_base & affecter_(const Champ_front_base &ch) override
Returns the object upcast to Champ_front_base&.
Class Champ_Inc_base.
virtual const Frontiere_dis_base & frontiere_dis() const
Returns the discretized boundary associated with the field.
virtual const Domaine_dis_base & domaine_dis() const
virtual DoubleTab & valeurs() override
Returns the array of field values.
class Champ_front_var_instationnaire Derived class from Champ_front_var that represents fields on
int initialiser(double temps, const Champ_Inc_base &inco) override
Initializes the current time and Gpoint.
class Domaine_VF
Definition Domaine_VF.h:44
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
File for reading. This class is to the C++ ifstream class what the Entree class is to the.
Definition EFichier.h:29
Writing to a file. This class implements the operators and virtual methods of the SFichier class as f...
void setf(IOS_FORMAT code)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
int_t sommet(int_t, int) const
Returns the number of the j-th vertex of the i-th face.
Definition Faces.h:130
int nb_som_faces() const
Returns the number of vertices per face.
Definition Faces.h:149
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
int_t num_premiere_face() const
Definition Frontiere.h:67
int_t nb_faces() const
Returns the number of faces of the boundary.
Definition Frontiere.h:59
const Faces_t & faces() const
Definition Frontiere.h:54
class Frontiere_dis_base Class representing a discretized boundary.
const Frontiere & frontiere() const
Returns the associated geometric boundary.
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Nom nom_me(int, const char *prefix=0, int without_padding=0) const
Inserts _prefix000n (n=me() or nproc()) into a file name (e.g. toto.titi) to produce toto_prefix000n....
Definition Nom.cpp:380
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
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
Definition Process.cpp:102
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
Definition Process.cpp:122
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
void setf(IOS_FORMAT code) override
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45