TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Energie_cinetique_turbulente.cpp
1/****************************************************************************
2* Copyright (c) 2021, 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 <Energie_cinetique_turbulente.h>
17#include <EcritureLectureSpecial.h>
18#include <Scalaire_impose_paroi.h>
19#include <Champ_Face_PolyMAC_MPFA.h>
20#include <Echange_global_impose.h>
21#include <Schema_Implicite_base.h>
22#include <Neumann_sortie_libre.h>
23#include <Op_Conv_negligeable.h>
24#include <Frontiere_dis_base.h>
25#include <Navier_Stokes_std.h>
26#include <Champ_Uniforme.h>
27#include <Matrice_Morse.h>
28#include <Neumann_paroi.h>
29#include <Probleme_base.h>
30#include <Discret_Thyd.h>
31#include <Domaine_VF.h>
32#include <TRUSTTrav.h>
33#include <EChaine.h>
34#include <Domaine.h>
35#include <Avanc.h>
36#include <Param.h>
37#include <Debog.h>
38#include <SETS.h>
39
40Implemente_instanciable(Energie_cinetique_turbulente,
41 "Energie_cinetique_turbulente",
43
45{
47}
48
50{
52 terme_convectif.set_fichier("Convection_energie_cinetique_turbulente");
53 terme_convectif.set_description((Nom)"Turbulent kinetic energy transfer rate=Integral(-rho*k*ndS) [W] if SI units used");
54 terme_diffusif.set_fichier("Diffusion_energie_cinetique_turbulente");
55 terme_diffusif.set_description((Nom)"Turbulent kinetic energy transfer rate=Integral(mu*grad(k)*ndS) [W] if SI units used");
56 return is;
57}
59{
61 param.ajouter("limit_coef", &coef_limit_); // X_D attr limit_coef flottant limit_coef 1 Coefficient of the limiter (min (K, coef * v^2)). Default value of coef is set to 0.1
62 param.ajouter_flag("limit_K", &limit_k_); // X_D attr limit_K entier limit_K 1 Flag to activate the limiter on K. Default value is 0 (deactivated)
63}
64
66{
67 return ref_cast(Fluide_base, milieu()).viscosite_cinematique();
68}
69
71{
72 return ref_cast(Fluide_base, milieu()).viscosite_cinematique();
73}
74
76{
77 const int nb_valeurs_temp = schema_temps().nb_valeurs_temporelles();
78 const double temps = schema_temps().temps_courant();
79 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
80 Cerr << "Turbulent kinetic energy discretization" << finl;
81 //On utilise temperature pour la directive car discretisation identique
82 dis.discretiser_champ("temperature", domaine_dis(), "k", "J/kg", 1,
83 nb_valeurs_temp, temps, l_inco_ch);//une seule compo, meme en multiphase
84 l_inco_ch->fixer_nature_du_champ(scalaire);
85 l_inco_ch->fixer_nom_compo(0, Nom("k"));
86 champs_compris_.ajoute_champ(l_inco_ch);
88 Cerr << "Energie_cinetique_turbulente::discretiser() ok" << finl;
89}
90
92{
93 // XXX : appel a la classe mere
95
96 const Navier_Stokes_std& eqv = ref_cast(Navier_Stokes_std, probleme().equation(0));
97
98 if (probleme().discretisation().is_PolyMAC_MPFA() && limit_k_)
99 if ( temps > schema_temps().temps_courant() && coef_limit_ > 0 )
100 {
101 Cerr << "Limiting the value of K : coeff used = " << coef_limit_ << finl;
102 const Champ_Face_PolyMAC_MPFA& ch_vit = ref_cast(Champ_Face_PolyMAC_MPFA, eqv.vitesse());
103 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, domaine_dis());
104 DoubleTab& k_val = inconnue().valeurs();
105 const int N = k_val.line_size(), D = dimension;
106
107 for (int e = 0; e < domaine.nb_elem(); e++)
108 for (int n = 0; n < N; n++)
109 {
110 double norm_v2 = 0;
111 for (int d = 0 ; d < D ; d++)
112 norm_v2 += ch_vit.passe()(e, N*d + n);
113 k_val(e, n) = std::min(k_val(e, n), coef_limit_*norm_v2);
114 }
116 inconnue().passe() = k_val;
117 }
118}
119
120void Energie_cinetique_turbulente::calculer_alpha_rho_k(const Objet_U& obj, DoubleTab& val, DoubleTab& bval, tabs_t& deriv)
121{
122 /*
123 Nota: this function used to compute alpha*rho*k but now it computes only k.
124 */
125 const Equation_base& eqn = ref_cast(Equation_base, obj);
126
127 /* const Fluide_base& fl = ref_cast(Fluide_base, eqn.milieu());
128 const Champ_base& ch_rho = fl.masse_volumique();
129 const Champ_Inc_base *ch_alpha = sub_type(Pb_Multiphase, eqn.probleme()) ? &ref_cast(Pb_Multiphase, eqn.probleme()).equation_masse().inconnue() : nullptr,
130 *pch_rho = sub_type(Champ_Inc_base, ch_rho) ? &ref_cast(Champ_Inc_base, ch_rho) : nullptr; //pas toujours un Champ_Inc
131 const DoubleTab* alpha = ch_alpha ? &ch_alpha->valeurs() : nullptr, &rho = ch_rho.valeurs(), &k = eqn.inconnue().valeurs();
132 */
133
134 /* valeurs du champ */
135 const DoubleTab& k = eqn.inconnue().valeurs();
136 const int N = val.line_size();
137 const int Nl = val.dimension_tot(0);
138 for (int i = 0; i < Nl; i++)
139 for (int n = 0; n < N; n++)
140 val(i, n) = k(i, n);
141
142 /* on ne peut utiliser valeur_aux_bords que si ch_rho a un domaine_dis_base */
143 const DoubleTab& b_k = eqn.inconnue().valeur_aux_bords();
144 const int Nb = b_k.dimension_tot(0);
145 for (int i = 0; i < Nb; i++)
146 for (int n = 0; n < N; n++) bval(i, n) = b_k(i, n);
147
148 //derivee en k : 1.
149 DoubleTab& d_k = deriv["k"];
150 d_k.resize(Nl, N);
151 for (int i = 0; i < Nl; i++)
152 for (int n = 0; n < N; n++)
153 d_k(i, n) = 1.;
154}
class Champ_Don_base base class of Given Fields (not calculated)
: class Champ_Face_PolyMAC_MPFA
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
DoubleTab valeur_aux_bords() const override
Returns the field value at the boundary faces.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
classe Convection_diffusion_turbulence_multiphase Equation de transport des quantites turbulentes (k,...
const Milieu_base & milieu() const override
Renvoie le milieu physique de l'equation.
const Champ_Inc_base & inconnue() const override
Renvoie le champ inconnue representant l'inconnue (k, omega, epsilon, tau) (version const).
class Discret_Thyd This class is the base class representing a discretization
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
classe Energie_cinetique_turbulente Equation de transport d'une energie cinetique turbulente (modeles...
const Champ_Don_base & diffusivite_pour_transport() const override
void discretiser() override
Discretizes the equation.
const Champ_base & diffusivite_pour_pas_de_temps() const override
void mettre_a_jour(double) override
The value of the unknown at the time step has been calculated.
static void calculer_alpha_rho_k(const Objet_U &obj, DoubleTab &val, DoubleTab &bval, tabs_t &deriv)
void set_param(Param &titi) const override
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual void set_param(Param &titi) const override
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual const Champ_Inc_base & inconnue() const =0
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
Probleme_base & probleme()
Returns the problem associated with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual void discretiser()
Discretizes the equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
Navier_Stokes_std This class carries the terms of the momentum equation.
virtual const Champ_Inc_base & vitesse() const
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
static int dimension
Definition Objet_U.h:94
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_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
Definition Param.cpp:474
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
double temps_courant() const
Returns the current time.
virtual int nb_valeurs_temporelles() const =0
Base class for output streams.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")