TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_LES_1elt_VEF.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
17#include <Modele_turbulence_hyd_LES_1elt_VEF.h>
18#include <Schema_Temps_base.h>
19#include <Equation_base.h>
20#include <Domaine_VEF.h>
21#include <Debog.h>
22
23Implemente_instanciable(Modele_turbulence_hyd_LES_1elt_VEF, "Modele_turbulence_hyd_sous_maille_1elt_VEF", Modele_turbulence_hyd_LES_VEF_base);
24
25Sortie& Modele_turbulence_hyd_LES_1elt_VEF::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
26
28
30{
31 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF, le_dom_VF_.valeur());
32 double temps = mon_equation_->inconnue().temps();
33 DoubleTab& visco_turb = la_viscosite_turbulente_->valeurs();
34 const int nb_elem = domaine_VEF.nb_elem();
35 int num_elem;
36
37 F2_.resize(nb_elem);
38
40
41 if (visco_turb.size() != nb_elem)
42 {
43 Cerr << "Size error for the array containing the values of the turbulent viscosity." << finl;
45 }
46 visco_turb = 0.;
47
48 Debog::verifier("Modele_turbulence_hyd_LES_1elt_VEF::calculer_viscosite_turbulente visco_turb 0", visco_turb);
49 for (num_elem = 0; num_elem < nb_elem; num_elem++)
50 visco_turb(num_elem) = Csm1_ * l_[num_elem] * sqrt(F2_(num_elem));
51
52 Debog::verifier("Modele_turbulence_hyd_LES_1elt_VEF::calculer_viscosite_turbulente visco_turb 1", visco_turb);
53
54 la_viscosite_turbulente_->changer_temps(temps);
55 return la_viscosite_turbulente_;
56}
57
59{
60 const DoubleTab& la_vitesse = mon_equation_->inconnue().valeurs();
61 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF, le_dom_VF_.valeur());
62 const int nb_elem = domaine_VEF.nb_elem();
63 const IntTab& elem_faces = domaine_VEF.elem_faces();
64 const DoubleTab& xv = domaine_VEF.xv();
65 const DoubleTab& xp = domaine_VEF.xp();
66 const Domaine& domaine = domaine_VEF.domaine();
67 int nfac = domaine.nb_faces_elem();
68
69 int num_elem, num_face, i;
70 double vit_x_elem, vit_y_elem, vit_z_elem;
71 double dist, F2_int1, F2_int2, delta_c_val, dist1;
72 static double un_tiers = 1. / 3.;
73 double delta_c_calc;
74
75 for (num_elem = 0; num_elem < nb_elem; num_elem++)
76 {
77 delta_c_val = l_[num_elem];
78 // Vitesse au centre de gravite
79 vit_x_elem = 0.;
80 vit_y_elem = 0.;
81 vit_z_elem = 0.;
82 dist1 = 0;
83 delta_c_calc = 0.;
84 for (i = 0; i < nfac; i++)
85 {
86 num_face = elem_faces(num_elem, i);
87 vit_x_elem += la_vitesse(num_face, 0);
88 vit_y_elem += la_vitesse(num_face, 1);
89 vit_z_elem += la_vitesse(num_face, 2);
90 dist1 = (xp(num_elem, 0) - xv(num_face, 0)) * (xp(num_elem, 0) - xv(num_face, 0));
91 dist1 += (xp(num_elem, 1) - xv(num_face, 1)) * (xp(num_elem, 1) - xv(num_face, 1));
92 dist1 += (xp(num_elem, 2) - xv(num_face, 2)) * (xp(num_elem, 2) - xv(num_face, 2));
93 delta_c_calc = std::min(delta_c_calc, dist1);
94 }
95 vit_x_elem /= (nfac * 1.);
96 vit_y_elem /= (nfac * 1.);
97 vit_z_elem /= (nfac * 1.);
98
99 // fonction de structure
100 F2_int2 = 0.;
101 for (i = 0; i < nfac; i++)
102 {
103 num_face = elem_faces(num_elem, i);
104
105 dist = (xp(num_elem, 0) - xv(num_face, 0)) * (xp(num_elem, 0) - xv(num_face, 0));
106 dist += (xp(num_elem, 1) - xv(num_face, 1)) * (xp(num_elem, 1) - xv(num_face, 1));
107 dist += (xp(num_elem, 2) - xv(num_face, 2)) * (xp(num_elem, 2) - xv(num_face, 2));
108
109 dist = 1. / dist;
110 dist *= (delta_c_val * delta_c_val);
111 dist = exp(un_tiers * log(dist));
112
113 F2_int1 = (vit_x_elem - la_vitesse(num_face, 0)) * (vit_x_elem - la_vitesse(num_face, 0));
114 F2_int1 += (vit_y_elem - la_vitesse(num_face, 1)) * (vit_y_elem - la_vitesse(num_face, 1));
115 F2_int1 += (vit_z_elem - la_vitesse(num_face, 2)) * (vit_z_elem - la_vitesse(num_face, 2));
116 F2_int2 += F2_int1 * dist;
117 }
118 F2_(num_elem) = F2_int2 / nfac;
119 }
120}
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
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
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
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Class Modele_turbulence_hyd_LES_VEF_base.
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
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
_SIZE_ size() const
Definition TRUSTVect.tpp:45