TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Fluide_Quasi_Compressible.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 <Fluide_Quasi_Compressible.h>
17#include <Neumann_sortie_libre.h>
18#include <Loi_Etat_Multi_GP_QC.h>
19#include <Discretisation_base.h>
20#include <Champ_Fonc_Fonction.h>
21#include <Probleme_base.h>
22#include <Param.h>
23
24Implemente_instanciable(Fluide_Quasi_Compressible,"Fluide_Quasi_Compressible",Fluide_Dilatable_base);
25// XD fluide_quasi_compressible fluide_base fluide_quasi_compressible INHERITS_BRACE Quasi-compressible flow with a low
26// XD_CONT mach number assumption; this means that the thermo-dynamic pressure (used in state law) is uniform in space.
27// XD attr sutherland bloc_sutherland sutherland OPT Sutherland law for viscosity and for conductivity.
28// XD attr pression double pression OPT Initial thermo-dynamic pressure used in the assosciated state law.
29// XD attr loi_etat loi_etat_base loi_etat OPT The state law that will be associated to the Quasi-compressible fluid.
30// XD attr traitement_pth chaine(into=["edo","constant","conservation_masse"]) traitement_pth OPT Particular treatment
31// XD_CONT for the thermodynamic pressure Pth ; there are three possibilities: NL2 1) with the keyword \'edo\' the code
32// XD_CONT computes Pth solving an O.D.E. ; in this case, the mass is not strictly conserved (it is the default case for
33// XD_CONT quasi compressible computation): NL2 2) the keyword \'conservation_masse\' forces the conservation of the
34// XD_CONT mass (closed geometry or with periodic boundaries condition) NL2 3) the keyword \'constant\' makes it
35// XD_CONT possible to have a constant Pth ; it\'s the good choice when the flow is open (e.g. with pressure boundary
36// XD_CONT conditions). NL2 It is possible to monitor the volume averaged value for temperature and density, plus Pth
37// XD_CONT evolution in the .evol_glob file.
38// XD attr traitement_rho_gravite chaine(into=["standard","moins_rho_moyen"]) traitement_rho_gravite OPT It may be :1)
39// XD_CONT \`standard\` : the gravity term is evaluted with rho*g (It is the default). 2) \`moins_rho_moyen\` : the
40// XD_CONT gravity term is evaluated with (rho-rhomoy) *g. Unknown pressure is then P*=P+rhomoy*g*z. It is useful when
41// XD_CONT you apply uniforme pressure boundary condition like P*=0.
42// XD attr temps_debut_prise_en_compte_drho_dt double temps_debut_prise_en_compte_drho_dt OPT While time<value, dRho/dt
43// XD_CONT is set to zero (Rho, volumic mass). Useful for some calculation during the first time steps with big
44// XD_CONT variation of temperature and volumic mass.
45// XD attr omega_relaxation_drho_dt double omega_relaxation_drho_dt OPT Optional option to have a relaxed algorithm to
46// XD_CONT solve the mass equation. value is used (1 per default) to specify omega.
47// XD attr lambda field_base lambda_u OPT Conductivity (W.m-1.K-1).
48// XD attr mu field_base mu OPT Dynamic viscosity (kg.m-1.s-1).
49
50// XD bloc_sutherland objet_lecture nul NO_BRACE Sutherland law for viscosity mu(T)=mu0*((T0+C)/(T+C))*(T/T0)**1.5 and
51// XD_CONT (optional) for conductivity lambda(T)=mu0*Cp/Prandtl*((T0+Slambda)/(T+Slambda))*(T/T0)**1.5
52// XD attr problem_name ref_Pb_base problem_name REQ Name of problem.
53// XD attr mu0 chaine(into=["mu0"]) mu0 REQ not_set
54// XD attr mu0_val double mu0_val REQ not_set
55// XD attr t0 chaine(into=["T0"]) t0 REQ not_set
56// XD attr t0_val double t0_val REQ not_set
57// XD attr Slambda chaine(into=["Slambda"]) Slambda OPT not_set
58// XD attr s double s OPT not_set
59// XD attr C chaine(into=["C"]) C REQ not_set
60// XD attr c_val double c_val REQ not_set
61
63
65
67{
69 param.ajouter("temps_debut_prise_en_compte_drho_dt", &temps_debut_prise_en_compte_drho_dt_);
70 param.ajouter("omega_relaxation_drho_dt", &omega_drho_dt_);
71 param.ajouter_non_std("pression", (this), Param::REQUIRED);
72 param.ajouter_non_std("Traitement_rho_gravite", (this));
73}
74
76{
77 if (mot == "pression")
78 {
79 is >> Pth_;
80 Pth_n_ = Pth_;
81 ch_rho_.typer("Champ_Uniforme");
82 DoubleTab& tab_rho = ch_rho_->valeurs();
83 tab_rho.resize(1, 1);
84 tab_rho(0, 0) = 1.;
85 return 1;
86 }
87 else if (mot == "Traitement_rho_gravite")
88 {
89 Motcle trait;
90 is >> trait;
91 Motcles les_options(2);
92 {
93 les_options[0] = "standard";
94 les_options[1] = "moins_rho_moyen";
95 }
96 traitement_rho_gravite_ = les_options.search(trait);
98 {
99 Cerr << trait << " is not understood as an option of the keyword " << mot << finl;
100 Cerr << "One of the following options was expected : " << les_options << finl;
102 }
103 return 1;
104 }
105 else
107}
108
109/*! @brief Complete le fluide avec les champs inconnus associes au probleme
110 *
111 * @param (Pb_Thermohydraulique& pb) le probleme a resoudre
112 */
114{
115 Cerr << "Fluide_Quasi_Compressible::completer Pth = " << Pth_ << finl;
116 if ((loi_etat_->que_suis_je() == "Loi_Etat_rhoT_Gaz_Parfait_QC" || loi_etat_->que_suis_je() == "Loi_Etat_Binaire_Gaz_Parfait_QC") && traitement_PTh_ == 0)
117 {
118 Cerr << "The option Traitement_PTh EDO is not allowed with the state law " << loi_etat_->que_suis_je() << finl;
119 Cerr << "Set **traitement_pth** constant or conservation_masse in the Fluide_Quasi_Compressible bloc definition." << finl;
121 }
122
124}
125
127{
128 const Domaine_dis_base& domaine_dis = pb.equation(0).domaine_dis();
129 double temps = pb.schema_temps().temps_courant();
130
131 // In *_Melange_Binaire_QC we do not even have a temperature variable ...
132 // it is the species mass fraction Y1... Although named ch_temperature
133 if (pb.que_suis_je() == "Pb_Hydraulique_Melange_Binaire_QC" || pb.que_suis_je() == "Pb_Hydraulique_Melange_Binaire_Turbulent_QC")
134 dis.discretiser_champ("temperature", domaine_dis, "fraction_massique", "neant", 1, temps, loi_etat_->temperature_);
135 else
136 dis.discretiser_champ("temperature", domaine_dis, "temperature", "K", 1, temps, loi_etat_->temperature_);
137
138 if (type_fluide() != "Gaz_Parfait")
139 loi_etat()->champs_compris().ajoute_champ(ch_temperature());
140
142}
143
144void Fluide_Quasi_Compressible::remplir_champ_pression_tot(int n, const DoubleTab& tab_PHydro, DoubleTab& tab_PTot)
145{
146 double Pth = Pth_;
147 CDoubleTabView PHydro = tab_PHydro.view_ro();
148 DoubleTabView PTot = tab_PTot.view_wo();
149 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), n, KOKKOS_LAMBDA(const int i)
150 {
151 PTot(i,0) = PHydro(i,0) + Pth;
152 });
153 end_gpu_timer(__KERNEL_NAME__);
154}
classe Discretisation_base Cette classe represente un schema de discretisation en espace,...
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 Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
classe Fluide_Dilatable_base Cette classe represente un d'un fluide dilatable,
const Champ_Don_base & ch_temperature() const
Renvoie le champ de le temperature.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
void discretiser(const Probleme_base &pb, const Discretisation_base &dis) override
void set_param(Param &param) const override
const Nom type_fluide() const
virtual void completer(const Probleme_base &)
Complete le fluide avec les champs inconnus associes au probleme.
classe Fluide_Quasi_Compressible Cette classe represente un d'un fluide quasi compressible
void completer(const Probleme_base &) override
Complete le fluide avec les champs inconnus associes au probleme.
void discretiser(const Probleme_base &pb, const Discretisation_base &dis) override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
void set_param(Param &param) const override
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
Un tableau d'objets de la classe Motcle.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:321
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
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
@ REQUIRED
Definition Param.h:115
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
const Schema_Temps_base & schema_temps() const
Renvoie le schema en temps associe au probleme.
virtual const Equation_base & equation(int) const =0
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
double temps_courant() const
Renvoie le temps courant.
Classe de base des flux de sortie.
Definition Sortie.h:52
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_wo()
Definition TRUSTTab.h:276
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
Definition TRUSTTab.h:261