TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_LES_Wale_VDF.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 <Modele_turbulence_hyd_LES_Wale_VDF.h>
17#include <Schema_Temps_base.h>
18#include <Champ_Face_VDF.h>
19#include <Domaine_Cl_VDF.h>
20#include <Equation_base.h>
21#include <Domaine_VDF.h>
22#include <TRUSTTrav.h>
23#include <Param.h>
24
25Implemente_instanciable_sans_constructeur(Modele_turbulence_hyd_LES_Wale_VDF, "Modele_turbulence_hyd_sous_maille_Wale_VDF", Modele_turbulence_hyd_LES_VDF_base);
26
27// XD sous_maille_wale mod_turb_hyd_ss_maille sous_maille_wale INHERITS_BRACE This is the WALE-model. It is a new
28// XD_CONT sub-grid scale model for eddy-viscosity in LES that has the following properties : NL2 - it goes naturally to
29// XD_CONT 0 at the wall (it doesn\'t need any information on the wall position or geometry) NL2 - it has the proper
30// XD_CONT wall scaling in o(y3) in the vicinity of the wall NL2 - it reproduces correctly the laminar to turbulent
31// XD_CONT transition.
32
37
38Sortie& Modele_turbulence_hyd_LES_Wale_VDF::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
39
41
43{
45 param.ajouter("cw", &cw_); // XD_ADD_P floattant
46 // XD_CONT The unique parameter (constant) of the WALE-model (by default value 0.5).
47 param.ajouter_condition("value_of_cw_ge_0", "sous_maille_Wale_VDF model constant must be positive.");
48}
49
51{
52 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_VF_.valeur());
53 const double temps = mon_equation_->inconnue().temps();
54 DoubleTab& visco_turb = la_viscosite_turbulente_->valeurs();
55
56 if (est_egal(cw_, 0., 1.e-15))
57 visco_turb = 0.;
58 else
59 {
60 const int nb_elem = domaine_VDF.domaine().nb_elem(), nb_elem_tot = domaine_VDF.nb_elem_tot();
61
62 OP1_.resize(nb_elem_tot); // OP1 is the first spatial operator of the WALE model.
63 OP2_.resize(nb_elem_tot); // OP2 is the second spatial operator of the WALE model.
64
66
67 if (visco_turb.size() != nb_elem)
68 {
69 Cerr << "Size error for the array containing the values of the turbulent viscosity." << finl;
70 exit();
71 }
72
73 for (int elem = 0; elem < nb_elem; elem++)
74 {
75 if (OP1_[elem] != 0.) // so sd2 (and OP2 as a consequence) are nonzero
76 visco_turb[elem] = cw_ * cw_ * l_(elem) * l_(elem) * OP1_[elem] / OP2_[elem];
77 else
78 visco_turb[elem] = 0;
79 }
80 }
81
82 la_viscosite_turbulente_->changer_temps(temps);
83
84 return la_viscosite_turbulente_;
85}
86
88{
89 Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, mon_equation_->inconnue());
90 const DoubleTab& vitesse = mon_equation_->inconnue().valeurs();
91 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_VF_.valeur());
92 const Domaine_Cl_VDF& domaine_Cl_VDF = ref_cast(Domaine_Cl_VDF, le_dom_Cl_.valeur());
93 const int nb_elem = domaine_VDF.domaine().nb_elem_tot(), nb_elem_tot = domaine_VDF.nb_elem_tot();
94
95 const IntTab& face_voisins = domaine_VDF.face_voisins(), &elem_faces = domaine_VDF.elem_faces();
96
97 DoubleTrav gij2(dimension, dimension), sd(dimension, dimension);
98
99 double gkk2, sd2, Sij, Sij2;
100
101 assert(vitesse.line_size() == 1);
102 DoubleTab duidxj(nb_elem_tot, dimension, dimension, vitesse.line_size());
103
104 vit.calcul_duidxj(vitesse, duidxj, domaine_Cl_VDF);
105
106 for (int elem = 0; elem < nb_elem; elem++)
107 {
108 //Computation of the term gij2
109 for (int i = 0; i < dimension; i++)
110 for (int j = 0; j < dimension; j++)
111 {
112 gij2(i, j) = 0;
113
114 for (int k = 0; k < dimension; k++)
115 gij2(i, j) += duidxj(elem, i, k, 0) * duidxj(elem, k, j, 0);
116 }
117
118 // Computation of the term gkk2
119 gkk2 = 0;
120 for (int k = 0; k < dimension; k++)
121 gkk2 += gij2(k, k);
122
123 // Computation of sd
124 for (int i = 0; i < dimension; i++)
125 for (int j = 0; j < dimension; j++)
126 {
127 sd(i, j) = 0.5 * (gij2(i, j) + gij2(j, i));
128 if (i == j)
129 sd(i, j) -= gkk2 / 3.; // Term behind the Kronecker tensor
130 }
131
132 // Computation of sd2 and Sij2
133 sd2 = 0.;
134 Sij2 = 0.;
135
136 int face1 = 0, face2 = 0;
137 int elem1, elem2;
138
139 for (int i = 0; i < dimension; i++)
140 for (int j = 0; j < dimension; j++)
141 {
142 sd2 += sd(i, j) * sd(i, j);
143 //Shifted computation of sij
144 Sij = 0.5 * (duidxj(elem, i, j, 0) + duidxj(elem, j, i, 0));
145
146 // PQ : 24/01/07 : the stencil of Sij is by construction:
147 // - 1 cell for the diagonal terms Sii
148 // - ~2 cells for the cross terms Sij
149 //
150 // Wale relies on both sd2 (carried by Sij) and Sij2 (carried mainly by Sii)
151 // and is sensitive to this stencil difference.
152 // By extending the stencil to 3 cells for the Sii computation, we recover in HIT
153 // the correct dissipation rate as well as spectra with the correct k^-5/3 shape.
154 //
155 // To be addressed: what about a plane channel ???
156
157 if (i == j) // extend the Sii stencil
158 {
159 face1 = elem_faces(elem, i);
160 face2 = elem_faces(elem, i + dimension);
161
162 elem1 = face_voisins(face1, 0);
163 elem2 = face_voisins(face2, 1);
164
165 //if(elem1==elem) elem1=face_voisins(face1,1); // by construction this is not needed
166 //if(elem2==elem) elem2=face_voisins(face2,0); // by construction this is not needed
167
168 // if no boundary is nearby, use a 3-cell stencil
169 // otherwise keep the 1-cell stencil
170
171 if (elem1 >= 0 && elem2 >= 0)
172 Sij = ((duidxj(elem1, i, i, 0) + duidxj(elem, i, i, 0) + duidxj(elem2, i, i, 0))) / 3.;
173 }
174
175 Sij2 += Sij * Sij;
176 }
177
178 // Computation of OP1 and OP2
179 OP1_(elem) = pow(sd2, 1.5);
180 OP2_(elem) = pow(Sij2, 2.5) + pow(sd2, 1.25);
181
182 } // end of the loop over elements
183}
class Champ_Face_VDF
DoubleTab & calcul_duidxj(const DoubleTab &, DoubleTab &) const
Returns gij at elements from the element velocity (gij represents the partial derivative dui/dxj).
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
int_t nb_elem_tot() const
Definition Domaine.h:132
int_t nb_elem() const
Definition Domaine.h:131
class Domaine_Cl_VDF
class Domaine_VDF
Definition Domaine_VDF.h:61
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 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
Modele_turbulence_hyd_LES_VDF_base class.
Modele_turbulence_hyd_LES_Wale_VDF class.
virtual void set_param(Param &) const
Definition Objet_U.h:130
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter_condition(const char *condition, const char *message, const char *name=0)
Declare a post-read logical condition that must hold on the parameter values.
Definition Param.cpp:496
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
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 declare_support_masse_volumique(int ok)
The constructor of a derived class that uses the density field must call this function with the value...
_SIZE_ size() const
Definition TRUSTVect.tpp:45
int line_size() const
Definition TRUSTVect.tpp:67