TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Terme_Boussinesq_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 <Convection_Diffusion_std.h>
17#include <Terme_Boussinesq_base.h>
18#include <Fluide_base.h>
19#include <Motcle.h>
20#include <algorithm>
21#include <Param.h>
22#include <Pb_Multiphase.h>
23
24Implemente_base(Terme_Boussinesq_base,"Terme_Boussinesq_base",Source_base);
25// XD boussinesq_temperature source_base boussinesq_temperature INHERITS_BRACE Class to describe a source term that
26// XD_CONT couples the movement quantity equation and energy equation with the Boussinesq hypothesis.
27// XD attr t0 chaine t0 REQ Reference temperature value (oC or K). It can also be a time dependant function since the
28// XD_CONT 1.6.6 version.
29// XD attr verif_boussinesq entier verif_boussinesq OPT Keyword to check (1) or not (0) the reference value in
30// XD_CONT comparison with the mean value in the domain. It is set to 1 by default.
31// XD boussinesq_concentration source_base boussinesq_concentration INHERITS_BRACE Class to describe a source term that
32// XD_CONT couples the movement quantity equation and constituent transport equation with the Boussinesq hypothesis.
33// XD attr c0 list c0 REQ Reference concentration field type. The only field type currently available is Champ_Uniforme
34// XD_CONT (Uniform field).
35
36Sortie& Terme_Boussinesq_base::printOn(Sortie& s ) const { return s << que_suis_je() ; }
37
38/*! @brief Lit les parametres du terme source a partir d'un flot d'entree.
39 *
40 */
42{
43 Param param(que_suis_je());
44 Cerr << "Reading Boussinesq source term parameters." << finl;
45 set_param(param);
46 param.lire_avec_accolades_depuis(is);
47 return is;
48}
49
51{
52 param.ajouter_non_std("T0",(this));
53 param.ajouter_non_std("C0",(this));
54 param.ajouter("verif_boussinesq",&verif_);
55}
56
57// Cherche dans le probleme l'equation scalaire
59{
60 int ok=0;
61 if (sub_type(Pb_Multiphase, pb))
62 {
63 Cerr << "Error: The boussinesq source term can't be defined for a problem of kind " << pb.que_suis_je() << finl;
64 Cerr << " Use source_qdm if you want to add this source term!" << finl;
66 }
67 int n_eq=pb.nombre_d_equations();
68 for (int eq=0; eq<n_eq; eq++)
69 {
70 const Equation_base& eqn=pb.equation(eq);
71 if (eqn.inconnue().le_nom()==NomScalaire_)
72 {
73 ok=1;
74 equation_scalaire_ = ref_cast(Convection_Diffusion_std,eqn);
75 }
76 }
77 if (ok==0)
78 {
79 Cerr << "Error. The Boussinesq source term can't be defined on a problem of kind " << pb.que_suis_je() << finl;
81 }
82
83 const Fluide_base& fluide = ref_cast(Fluide_base, equation().milieu());
84 la_gravite_ = fluide.gravite();
85
86 //this variable indicates if the beta field is valid or not
87 int valid_beta_field = 0; // by default it is invalid
88 Nom beta_field_name="??"; // only used for the error message
89
90 if (NomScalaire_=="temperature")
91 {
92 valid_beta_field = fluide.has_beta_t();
93 beta_field_name = "thermal expansion value (beta_th)";
94 beta_=fluide.beta_t();
95 }
96 else if (NomScalaire_=="concentration")
97 {
98 valid_beta_field = fluide.has_beta_c();
99 beta_field_name = "volume expansion coefficient values in concentration (beta_co)";
100 beta_=fluide.beta_c();
101 }
102
103 if( ! valid_beta_field )
104 {
105 Cerr << "Error. Boussinesq source term is not able to access to the "<<beta_field_name<<" associated to the fluid."<<finl;
106 Cerr << "Please check your data file. " << finl;
107 Cerr << "Aborting..."<<finl;
109 }
110}
111
112// Fonction de lecture d'un Parser_U
113void read(Entree& is, Parser_U& fct_Scalaire0_)
114{
115 Nom expression;
116 is >> expression;
117 std::string ss(expression.getString());
118 std::transform(ss.begin(), ss.end(), ss.begin(), ::toupper);
119 fct_Scalaire0_.setNbVar(1);
120 fct_Scalaire0_.setString(ss);
121 fct_Scalaire0_.addVar("t");
122 fct_Scalaire0_.parseString();
123}
124
126{
127 int retval = 1;
128
129 if (mot=="T0")
130 {
131 // Temperature
132 NomScalaire_="temperature";
133 fct_Scalaire0_.dimensionner(1);
134 Scalaire0_.resize(1);
135 read(is, fct_Scalaire0_[0]);
136 }
137 else if (mot=="C0")
138 {
139 // Concentration
140 NomScalaire_="concentration";
141 int dim;
142 is >> dim;
143 fct_Scalaire0_.dimensionner(dim);
144 Scalaire0_.resize(dim);
145 for (int i=0; i<dim; i++) read(is, fct_Scalaire0_[i]);
146 }
147 else retval = -1;
148
149 return retval;
150}
classe Convection_Diffusion_std Cette classe est la base des equations modelisant le transport
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
virtual const Champ_Inc_base & inconnue() const =0
const Nom & le_nom() const override
Renvoie le nom du champ.
classe Fluide_base Cette classe represente un d'un fluide incompressible ainsi que
Definition Fluide_base.h:38
bool has_beta_c() const
Definition Fluide_base.h:67
const Champ_Don_base & beta_c() const
Definition Fluide_base.h:65
virtual const Champ_Don_base & beta_t() const
Renvoie beta_t du milieu.
bool has_beta_t() const
virtual const Champ_Don_base & gravite() const
Renvoie la gravite du milieu si elle a ete associe provoque une erreur sinon.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
friend class Entree
Definition Objet_U.h:76
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
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 Parser_U Version de la classe Parser, derivant de Objet_U.
Definition Parser_U.h:32
void setString(const std::string &s)
Definition Parser_U.h:194
void setNbVar(int nvar)
Definition Parser_U.h:174
void parseString()
Definition Parser_U.h:116
void addVar(const char *v)
Definition Parser_U.h:183
classe Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
static void abort()
Routine de sortie de Trio-U sur une erreur abort().
Definition Process.cpp:570
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
classe Source_base Un objet Source_base est un terme apparaissant au second membre d'une
Definition Source_base.h:42
Classe Terme_Boussinesq_base Cette classe represente le terme de gravite qui figure dans l'equation.
void set_param(Param &param) const override
void associer_pb(const Probleme_base &pb) 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.