TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Viscosite_turbulente_WALE.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 <Viscosite_turbulente_WALE.h>
17#include <Discretisation_base.h>
18#include <Champ_Face_base.h>
19#include <Pb_Multiphase.h>
20#include <Domaine_VF.h>
21#include <Param.h>
22
23Implemente_instanciable(Viscosite_turbulente_WALE, "Viscosite_turbulente_WALE", Viscosite_turbulente_LES_base);
24// XD type_diffusion_turbulente_multiphase_wale type_diffusion_turbulente_multiphase_deriv wale BRACE LES WALE type.
25
26Sortie& Viscosite_turbulente_WALE::printOn(Sortie& os) const { return os; }
27
29{
30 mod_const_ = 0.5; // par default
31 Param param(que_suis_je());
32 param.ajouter("cw", &mod_const_); // XD_ADD_P floattant
33 // XD_CONT WALE's model constant. By default it is se to 0.5.
34 param.lire_avec_accolades_depuis(is);
35
36 if (mod_const_ < 0.) Process::exit("The WALE's constant must be positive !");
37 else Cerr << "LES WALE model used with constant CW = " << mod_const_ << finl;
38
40}
41
42/*
43 * (Sij_d * Sij_d)^1.5
44 * visc_SGS = (Cw * delta)^2 * ---------------------------------------------------,
45 * (Sij_bar * Sij_bar)^2.5 + (Sij_d * Sij_d)^1.25
46 *
47 * avec
48 *
49 * Sij_d = 0.5 * (gij_bar^2 + gji_bar^2) -1/3 gkk_bar^2,
50 * gij_bar = du_i / dx_j,
51 * gij_bar^2 = gik_bar * gkj_bar,
52 * Sij_bar = 0.5 * (du_i / dx_j + du_j / dx_i)
53 */
55{
56 if (est_egal(mod_const_, 0., 1.e-15)) nu_t = 0.;
57 else
58 {
59 const Domaine_VF& domaine_VF = ref_cast(Domaine_VF, pb_->domaine_dis());
60 const Champ_Face_base& vit = ref_cast(Champ_Face_base, pb_->equation(0).inconnue());
61
62 // Nota bene : en PolyMAC_MPFA, grad_u__ contient (nf.grad)u_i aux faces, puis (d_j u_i) aux elements
63 const DoubleTab& grad_u__ = pb_->get_champ("gradient_vitesse").valeurs();
64
65 const IntTab& face_voisins = domaine_VF.face_voisins(), &elem_faces = domaine_VF.elem_faces();
66 const int nb_elem_tot = domaine_VF.nb_elem_tot(), dim = Objet_U::dimension, N = vit.valeurs().line_size();
67 const bool is_poly = pb_->discretisation().is_poly_family();
68 const int nb_faces_tot = is_poly ? domaine_VF.nb_faces_tot() : 0;
69 assert (N == nu_t.dimension(1));
70
71 DoubleTrav num_sur_denom(nb_elem_tot, nu_t.dimension(1));
72 num_sur_denom = 0.;
73
74 DoubleTrav grad_u(nb_elem_tot, dim, dim, N), gij_bar2(dim, dim, N), Sij_d(dim, dim, N);
75 grad_u = 0., gij_bar2 = 0., Sij_d = 0.;
76
77 // remplir grad_u en 4 dimension
78 // XXX : attention faut remplir grad_u ici pas plus tard !!!
79 for (int elem = 0; elem < nb_elem_tot; elem++)
80 for (int i = 0; i < dim; i++) // variable : du, dv, dw
81 for (int j = 0; j < dim; j++) // par rappor a : dx, dy, dz
82 for (int n = 0; n < N; n++) // phase
83 grad_u(elem, i, j, n) = is_poly ? grad_u__(nb_faces_tot + elem * dim + j, n * dim + i) : grad_u__(nb_faces_tot + elem, N * (dim * i + j) + n);
84
85 // Arrays utiles
86 ArrOfDouble gkk_bar2(N), Sij_d2(N), Sij_bar(N), Sij_bar2(N);;
87
88 for (int elem = 0; elem < nb_elem_tot; elem++)
89 {
90 //Calcul du terme Sij_d
91 for (int i = 0; i < dim; i++)
92 for (int j = 0; j < dim; j++)
93 for (int n = 0; n < N; n++)
94 {
95 gij_bar2(i, j, n) = 0.;
96 for (int k = 0; k < dim; k++)
97 gij_bar2(i, j, n) += grad_u(elem, i, k, n) * grad_u(elem, k, j, n);
98 }
99
100 gkk_bar2 = 0.;
101 for (int k = 0; k < dim; k++)
102 for (int n = 0; n < N; n++)
103 gkk_bar2(n) += gij_bar2(k, k, n);
104
105 for (int i = 0; i < dim; i++)
106 for (int j = 0; j < dim; j++)
107 for (int n = 0; n < N; n++)
108 {
109 Sij_d(i, j, n) = 0.5 * (gij_bar2(i, j, n) + gij_bar2(j, i, n));
110 if (i == j)
111 Sij_d(i, j, n) -= gkk_bar2(n) / 3.; // Terme derriere le tenseur de Kronecker
112 }
113
114 // Calcul de Sij_d2 et Sij_bar2
115 Sij_d2 = 0., Sij_bar = 0., Sij_bar2 = 0.;
116
117 for (int i = 0; i < dim; i++)
118 for (int j = 0; j < dim; j++)
119 for (int n = 0; n < N; n++)
120 {
121 Sij_d2(n) += Sij_d(i, j, n) * Sij_d(i, j, n);
122
123 // Sij_bar et Sij_bar2
124 Sij_bar(n) = 0.5 * (grad_u(elem, i, j, n) + grad_u(elem, j, i, n));
125 if (i == j)
126 {
127 const int face1 = elem_faces(elem, i), face2 = elem_faces(elem, i + dim), elem1 = face_voisins(face1, 0), elem2 = face_voisins(face2, 1);
128
129 if (elem1 >= 0 && elem2 >= 0)
130 Sij_bar(n) = ((grad_u(elem1, i, i, 0) + grad_u(elem, i, i, 0) + grad_u(elem2, i, i, 0))) / 3.;
131 }
132 Sij_bar2(n) += Sij_bar(n) * Sij_bar(n);
133 }
134
135 for (int n = 0; n < N; n++)
136 {
137 const double num = pow(Sij_d2(n), 1.5), denom = pow(Sij_bar2(n), 2.5) + pow(Sij_d2(n), 1.25);
138 num_sur_denom(elem, n) = num != 0. ? (num / denom) : 0.;
139 }
140 }
141
142 for (int i = 0; i < nu_t.dimension(0); i++)
143 for (int n = 0; n < nu_t.dimension(1); n++)
144 nu_t(i, n) = mod_const_ * mod_const_ * l_(i) * l_(i) * num_sur_denom(i, n);
145
147 }
148}
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
class Domaine_VF
Definition Domaine_VF.h:44
int nb_faces_tot() const
renvoie le nombre total de faces.
Definition Domaine_VF.h:481
int elem_faces(int i, int j) const
renvoie le numero de le ieme face de la maille num_elem la facon dont ces faces sont numerotees est
Definition Domaine_VF.h:543
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
int nb_elem_tot() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Champ_Inc_base & inconnue() const =0
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
classe Viscosite_turbulente_WALE
void eddy_viscosity(DoubleTab &nu_t) const override