TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_LES_base.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_base.h>
17#include <Modifier_pour_fluide_dilatable.h>
18#include <Discretisation_base.h>
19#include <Equation_base.h>
20#include <Probleme_base.h>
21#include <Milieu_base.h>
22#include <Param.h>
23#include <kokkos++.h>
24#include <TRUSTArray_kokkos.tpp>
25
26Implemente_base_sans_constructeur(Modele_turbulence_hyd_LES_base, "Modele_turbulence_hyd_LES_base", Modele_turbulence_hyd_0_eq_base);
27
28// XD form_a_nb_points objet_lecture nul NO_BRACE The structure fonction is calculated on nb points and we should add
29// XD_CONT the 2 directions (0:OX, 1:OY, 2:OZ) constituting the homegeneity planes. Example for channel flows, planes
30// XD_CONT parallel to the walls.
31// XD attr nb entier(into=[4]) nb REQ Number of points.
32// XD attr dir1 entier(max=2) dir1 REQ First direction.
33// XD attr dir2 entier(max=2) dir2 REQ Second direction.
34
35// XD mod_turb_hyd_ss_maille modele_turbulence_hyd_deriv mod_turb_hyd_ss_maille INHERITS_BRACE Class for sub-grid
36// XD_CONT turbulence model for Navier-Stokes equations.
37// XD attr formulation_a_nb_points form_a_nb_points formulation_a_nb_points OPT The structure fonction is calculated on
38// XD_CONT nb points and we should add the 2 directions (0:OX, 1:OY, 2:OZ) constituting the homegeneity planes. Example
39// XD_CONT for channel flows, planes parallel to the walls.
40
42{
43 methode_ = "volume"; // Default parameter to compute the characteristic length
44}
45
47{
49}
50
52{
54}
55
57{
59 param.ajouter("longueur_maille", &methode_); // XD_ADD_P chaine(into=["volume","volume_sans_lissage","scotti","arrete"])
60 // XD_CONT Different ways to calculate the characteristic length may be specified : NL2 volume : It is the default
61 // XD_CONT option. Characteristic length is based on the cubic root of the volume cells. A smoothing procedure is
62 // XD_CONT applied to avoid discontinuities of this quantity in VEF from a cell to another. NL2 volume_sans_lissage :
63 // XD_CONT For VEF only. Characteristic length is based on the cubic root of the volume cells (without smoothing
64 // XD_CONT procedure).NL2 scotti : Characteristic length is based on the cubic root of the volume cells and the Scotti
65 // XD_CONT correction is applied to take into account the stretching of the cell in the case of anisotropic meshes.
66 // XD_CONT NL2 arete : For VEF only. Characteristic length relies on the max edge (+ smoothing procedure) is taken
67 // XD_CONT into account.
68
69}
70
72{
74 if (methode_ != "??")
75 Cerr << "The characteristic length of the subgrid scale model is calculated with the method : " << methode_ << finl;
77 mettre_a_jour(0.);
78 return 1;
79}
80
81// E.Saikali
82// In the current version of TrioCFD and the FT part in particular, it is possible only to use LES WALE (Smagorinsky,1963,Mon.Weather Rev. 91,99)
83// For this reason, associating the wall laws of multi-phase flows is done in this method Modele_turbulence_hyd_LES_base::completer()
84// We only go inside if the user defines the wall law as loi_standard_hydr, for both discretizations VEF and VDF
85// Otherwise, in the case of negligeable, the multiphase wall law is not used
87{
88 const Milieu_base& mil = equation().milieu(); // returns Fluide_Diphasique or Fluide_Incompressible
89 const Nom& nom_mil = mil.que_suis_je();
90 const Nom& nom_loipar = loipar_->que_suis_je();
91 const Nom& nom_eq = equation().que_suis_je();
92
93 if ((nom_loipar == "loi_standard_hydr_VEF" || nom_loipar == "loi_standard_hydr_VDF") && nom_eq == "Navier_Stokes_FT_Disc" && nom_mil == "Fluide_Diphasique")
94 {
95 const Nom& discr = equation().discretisation().que_suis_je();
96 if (discr == "VEF" || discr == "VEFPreP1B")
97 {
98 loipar_.typer("loi_standard_hydr_diphasique_VEF");
99 Cerr << "Associating the two-phase hydraulic wall turbulence model : loi_standard_hydr_diphasique_VEF ..." << finl;
100 }
101 else if (discr == "VDF")
102 {
103 loipar_.typer("loi_standard_hydr_diphasique_VDF");
104 Cerr << "Associating the two-phase hydraulic wall turbulence model : loi_standard_hydr_diphasique_VDF ..." << finl;
105 }
106 else
107 {
108 Cerr << "Unknown discretization type !!!";
110 }
111 loipar_->associer_modele(*this);
112 loipar_->associer(equation().domaine_dis(), equation().domaine_Cl_dis());
113 }
114}
115
117{
118 Cerr << "Modele_turbulence_hyd_LES_base::completer()" << finl;
120}
121
123{
124 DoubleVect& k = energie_cinetique_turb_->valeurs();
125 DoubleTab& visco_turb = la_viscosite_turbulente_->valeurs();
126 double Cq = 0.094;
127
128 // PQ: 10/08/06: using the Schuman formula here: q_sm = (nu_t)^2 / (Cq.l)^2
129
130 const int nb_elem = visco_turb.size();
131 if (k.size() != nb_elem)
132 {
133 Cerr << "Size error for the array containing the values of the turbulent kinetic energy." << finl;
134 exit();
135 }
136
137 CDoubleArrView l_v = l_.view_ro();
138 CDoubleTabView visco_turb_v = visco_turb.view_ro();
139 DoubleArrView k_v = k.view_rw();
140 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_elem, KOKKOS_LAMBDA(
141 const int elem)
142 {
143 k_v(elem)=visco_turb_v(elem, 0)*visco_turb_v(elem, 0)/(Cq*Cq*l_v(elem)*l_v(elem));
144 });
145 end_gpu_timer(__KERNEL_NAME__);
146
147 double temps = mon_equation_->inconnue().temps();
148 energie_cinetique_turb_->changer_temps(temps);
149}
150
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
Base class for zero-equation (algebraic) hydraulic turbulence models.
Classe Modele_turbulence_hyd_LES_base Class representing the subgrid-scale turbulence model for the.
virtual void calculer_longueurs_caracteristiques()=0
int preparer_calcul() override
Prepares the computation.
void set_param(Param &param) const override
virtual int preparer_calcul()
Prepares the computation.
virtual void set_param(Param &param) const override
Equation_base & equation()
Returns the equation associated with the turbulence model.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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 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(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
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
Definition TRUSTTab.h:261
_SIZE_ size() const
Definition TRUSTVect.tpp:45