TrioCFD 1.9.9_beta
TrioCFD documentation
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 Reads the source term parameters from an input stream.
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// Searches the problem for the scalar equation
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// Function to read a 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}
Convection_Diffusion_std This class is the base for equations modelling the transport.
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 const Champ_Inc_base & inconnue() const =0
const Nom & le_nom() const override
Returns the name of the field.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
bool has_beta_c() const
Definition Fluide_base.h:65
const Champ_Don_base & beta_c() const
Definition Fluide_base.h:63
virtual const Champ_Don_base & beta_t() const
Returns beta_t of the medium (const version).
bool has_beta_t() const
virtual const Champ_Don_base & gravite() const
Returns the gravity of the medium if it has been associated, raises an error otherwise (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
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
friend class Entree
Definition Objet_U.h:71
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
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
class Parser_U Version of the Parser class, deriving from 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
Multiphase thermohydraulics problem of type "3*N equations":
class Probleme_base It is a Probleme_U that is not a coupling.
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
static void abort()
Abort routine for TRUST on a fatal error.
Definition Process.cpp:573
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
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
Classe Terme_Boussinesq_base This class represents the gravity term appearing in the momentum equatio...
void set_param(Param &param) const override
void associer_pb(const Probleme_base &pb) override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.