TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Dift_Multiphase_VDF_Elem.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 <Op_Dift_Multiphase_VDF_Elem.h>
17#include <Op_Dift_Multiphase_VDF_Face.h>
18#include <Pb_Multiphase.h>
19
20Implemente_instanciable_sans_constructeur(Op_Dift_Multiphase_VDF_Elem,"Op_Diff_VDFTURBULENTE_P0_VDF|Op_Diff_VDFTURBULENT_P0_VDF",Op_Dift_VDF_Elem_base);
21
24{
25 //reading the turbulent diffusivity correlation
26 Correlation_base::typer_lire_correlation(corr_, equation().probleme(), "transport_turbulent", is);
30 return is;
31}
32
38
44
53
55{
57
58 const Operateur_base& op_qdm = equation().probleme().equation(0).operateur(0).l_op_base();
59 if (!sub_type(Op_Dift_Multiphase_VDF_Face, op_qdm))
60 {
61 Cerr << "Error in " << que_suis_je() << ": no turbulent momentum diffusion found!" << finl;
63 }
64
65 const Correlation_base& corr_visc_qdm = ref_cast(Op_Dift_Multiphase_VDF_Face, op_qdm).correlation();
66 if (!sub_type(Viscosite_turbulente_base, corr_visc_qdm))
67 {
68 Cerr << "Error in " << que_suis_je() << ": no turbulent viscosity correlation found!" << finl;
70 }
71
72 // compute d_t_
73 nu_ou_lambda_turb_ = 0.; // XXX : to exclude the laminar part
77}
78
80{
81 double dt_stab, coef = -1.e10;
82 const Domaine_VDF& domaine_VDF = iter_->domaine();
83 const IntTab& elem_faces = domaine_VDF.elem_faces();
84 const DoubleTab& lambda = alpha_() /* comme mu */, &diffu = diffusivite_pour_pas_de_temps().valeurs() /* comme nu */;
85 const DoubleTab* alp = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe() : nullptr;
86 const DoubleTab& rho = equation().milieu().masse_volumique().passe();
87 const int cL = (lambda.dimension(0) == 1), cD = (diffu.dimension(0) == 1), cR = (rho.dimension(0) == 1), dim = Objet_U::dimension;
88
89 double mu_turbulent, mu_physique, nu_physique, alfa;
90
91 ArrOfInt numfa(2 * dim);
92 for (int elem = 0; elem < domaine_VDF.nb_elem(); elem++)
93 {
94 double diflo = 0.;
95 double deltax = 0.;
96 for (int i = 0; i < 2 * dim; i++)
97 numfa[i] = elem_faces(elem, i);
98
99 for (int d = 0; d < dim; d++)
100 {
101 const double hd = domaine_VDF.dist_face(numfa[d], numfa[dim + d], d);
102 deltax += 1. / (hd * hd);
103 }
104
105 // nu_ou_lambda_turb = alpha * nut * sigma
106 for (int ncomp = 0; ncomp < nu_ou_lambda_turb_.line_size(); ncomp++)
107 {
108 //if (elem==0) cout << "ncomp "<< ncomp << " nu_ou_lambda_turb = alpha * nut * sigma "<< nu_ou_lambda_turb_(elem, ncomp) << endl;
109 alfa = (alp ? (*alp)(elem, ncomp) : 1.0);
110 mu_turbulent = rho(!cR * elem, ncomp) * nu_ou_lambda_turb_(elem, ncomp);
111 //if (elem==0) cout << "ncomp "<< ncomp << " mu_turbulent with alpha "<< mu_turbulent << endl;
112 if (alfa != 0.0 ) mu_turbulent = mu_turbulent/alfa;
113 //if (elem==0) cout << "ncomp "<< ncomp << " mu_turbulent sans alpha "<< mu_turbulent << endl;
114 mu_physique = rho(!cR * elem, ncomp) * lambda(!cL * elem, ncomp);
115 nu_physique = diffu(!cD * elem, ncomp);
116 //if (elem==0) cout << "ncomp "<< ncomp << " mu_physique "<< mu_physique << endl;
117 //if (elem==0) cout << "ncomp "<< ncomp << " nu_physique "<< nu_physique << endl;
118
119 // the stability time step is alpha(nu+nu_t); compute a(mu+mu_t)*(nu/mu)=a(mu+mu_t)/rho=a(nu+nu_t) (advantage over dividing by rho: also works for alpha and lambda and in VEF)
120 diflo = deltax * (mu_physique + mu_turbulent) * (nu_physique / mu_physique);
121 //if (elem==0) cout << "ncomp "<< ncomp << " dt "<< 0.5 / (diflo + DMINFLOAT) << endl;
122 coef = std::max(coef, diflo);
123 }
124 }
125
126 coef = Process::mp_max(coef);
127 dt_stab = 0.5 / (coef + DMINFLOAT);
128 //cout << "dt_stab "<< dt_stab << endl;
129
130 return dt_stab;
131}
132
virtual DoubleTab & valeurs()=0
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
virtual void creer_champ(const Motcle &motlu)=0
virtual void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const =0
Convection_Diffusion_std This class is the base for equations modelling the transport.
static void typer_lire_correlation(OWN_PTR(Correlation_base)&, const Probleme_base &, const Nom &, Entree &)
class Domaine_VDF
Definition Domaine_VDF.h:61
double dist_face(int, int, int k) const
Returns the distance between two face centers in direction k (Cartesian only).
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
const Domaine & domaine() const
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
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual const Operateur & operateur(int) const =0
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of character strings (VECT(Nom)).
Definition Noms.h:26
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 Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
std::enable_if_t< _TYPE_==Type_Operateur::Op_DIFT_MULTIPHASE_FACE, void > set_nut_impl(const DoubleTab &nut)
std::enable_if_t< _TYPE_==Type_Operateur::Op_DIFT_MULTIPHASE_FACE||_TYPE_==Type_Operateur::Op_DIFT_MULTIPHASE_ELEM, void > associer_corr_impl(const Correlation_base &corr)
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
void completer() override
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
double calculer_dt_stab() const override
Computes dt_stab.
void creer_champ(const Motcle &motlu) override
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.
void associer_proto(const Probleme_base &, Champs_compris &)
void mettre_a_jour_proto_elem(const double temps)
void creer_champ_proto_elem(const Motcle &motlu)
void completer_proto_elem(const Operateur_Diff_base &op)
void get_noms_champs_postraitables_proto(const Nom &, Noms &nom, Option opt) const
void call_compute_diff_turb(const Convection_Diffusion_std &eq, const Viscosite_turbulente_base &visc_turb)
void completer_Op_Dift_VDF_base()
virtual const Champ_base & diffusivite_pour_pas_de_temps() const
Returns the field corresponding to the true diffusivity of the medium used for the time step computat...
class Operateur_base This class is the base of the hierarchy of objects representing an
Champs_compris champs_compris_
virtual void mettre_a_jour(double temps)
DOES NOTHING - to override in derived classes.
virtual Operateur_base & l_op_base()=0
Multiphase thermohydraulics problem of type "3*N equations":
virtual const Equation_base & equation(int) const =0
static double mp_max(double)
Definition Process.cpp:379
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_ dimension(int d) const
Definition TRUSTTab.tpp:133
Turbulent viscosity correlations describing the Reynolds stress tensor R_{ij} = - <u'_i u'_j>.