TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Convection_Diffusion_Chaleur_QC.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_Chaleur_QC.h>
17#include <Fluide_Quasi_Compressible.h>
18#include <Op_Conv_negligeable.h>
19#include <Frontiere_dis_base.h>
20#include <Navier_Stokes_std.h>
21#include <Probleme_base.h>
22#include <Discret_Thyd.h>
23#include <Param.h>
24
25Implemente_instanciable_sans_constructeur(Convection_Diffusion_Chaleur_QC,"Convection_Diffusion_Chaleur_QC",Convection_Diffusion_Chaleur_Fluide_Dilatable_base);
26// XD convection_diffusion_chaleur_QC eqn_base convection_diffusion_chaleur_QC INHERITS_BRACE Temperature equation for a
27// XD_CONT quasi-compressible fluid.
28// XD attr mode_calcul_convection chaine(into=["ancien","divuT_moins_Tdivu","divrhouT_moins_Tdivrhou"]) mode_calcul_convection OPT Option to set the form of the convective operatorNL2 divrhouT_moins_Tdivrhou (the default since 1.6.8): rho.u.gradT = div(rho.u.T )- Tdiv(rho.u.1) NL2ancien: u.gradT = div(u.T) - T.div(u) NL2 divuT_moins_Tdivu : u.gradT = div(u.T) - Tdiv(u.1)
29// XD attr T_min double T_min OPT Specifies T_min (and T_max) to keep temperature within [T_min, T_max] and avoid
30// XD_CONT excessive excursions beyond physical limits in QC simulations. Use with caution.
31// XD attr T_max double T_max OPT Should be set when T_min set in the datafile.
32
34
36{
38}
39
41{
42 Cerr<<"Reading of data for a "<<que_suis_je()<<" equation"<<finl;
43 Param param(que_suis_je());
44 set_param(param);
45
47
48 if (std::isfinite(TMIN_) && std::isfinite(TMAX_))
49 {
50 Cerr << "TMIN and TMAX are specified in the " << que_suis_je() << " equation." << finl;
51 }
52 else if (std::isfinite(TMIN_) || std::isfinite(TMAX_))
53 {
54 Cerr << "Error: You have defined only TMIN or TMAX in your datafile (equation " << que_suis_je() << ")"<< finl;
55 Cerr << " You should specify both!!" << finl;
57 }
58
59 return is;
60}
61
62void Convection_Diffusion_Chaleur_QC ::mettre_a_jour(double temps)
63{
64
65 inconnue().mettre_a_jour(temps);
66 if (std::isfinite(TMIN_) && std::isfinite(TMAX_))
67 {
68 DoubleTab& T = inconnue().valeurs();
69 const int n = T.size_array();
70 const double eps = std::numeric_limits<double>::epsilon();
71
72 for (int i = 0; i < n; i++)
73 {
74 T(i) = std::min(std::max(TMIN_,T(i)),TMAX_);
75 if (std::abs(T(i)) < eps)
76 T(i) = 0.0;
77 }
78 }
80}
81
83{
85 param.ajouter_non_std("mode_calcul_convection",(this));
86 param.ajouter("T_min",&TMIN_);
87 param.ajouter("T_max",&TMAX_);
88}
89
91{
92 if (mot=="convection")
93 {
95
96 //the quasi-compressible heat equation contains a source term dP/dt
97 Cerr << "Source term creation of the energy equation :"<< finl;
98 Source t;
99 Source& so=les_sources.add(t);
100 Nom type_so = "Source_QC_Chaleur_";
101 Nom disc = discretisation().que_suis_je();
102 if (disc=="VEFPreP1B") disc = "VEF";
103 type_so += disc;
104 so.typer_direct(type_so);
105 so->associer_eqn(*this);
106 Cerr<<so->que_suis_je()<<finl;
107 Cerr << "Typing of the convection operator : ";
108 return 1;
109 }
110 else if (mot=="mode_calcul_convection")
111 {
112 if (terme_convectif)
113 {
114 Cerr<<" The option "<<mot<<" must be indicated before the convection operator."<<finl;
115 Cerr<<" Please modify your data set."<<finl;
116 exit();
117 }
118 Motcles modes(3);
119 modes[0]="ancien"; // Default mode before 1.6.8 (wrong in VEF)
120 modes[1]="divuT_moins_Tdivu"; // OK in VDF and VEF
121 modes[2]="divrhouT_moins_Tdivrhou"; // Default mode after 1.6.8 (better)
122 Motcle mot2;
123 is>>mot2;
124 mode_convection_=modes.search(mot2);
125 if (mode_convection_==0)
126 {
127 Cerr << "WARNING! This mode is not supported anymore." << finl;
128 }
129 if (mode_convection_==-1)
130 {
131 Cerr<<" Allowed keywords for option mode_calcul_convection are :"<<finl;
132 Cerr<<modes<<finl;
133 exit();
134 }
135 return 1;
136 }
137 else
139}
140
142{
144 else
145 {
146 const Probleme_base& pb = probleme();
147 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std,pb.equation(0));
148 return eqn_hydr.inconnue() /* u */ ;
149 }
150}
151
153{
154 // No convective operator:
155 if (sub_type(Op_Conv_negligeable,operateur(1).l_op_base()))
156 {
157 Div=0;
158 return;
159 }
160
161 if (mode_convection_!=0)
163 else
164 {
165 // Compute Div([rho]u) with Divergence operator
166 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std,probleme().equation(0));
167 const DoubleTab& pression = eqn_hydr.pression().valeurs();
168 const Champ_Inc_base& vitesse = eqn_hydr.inconnue();
169
170 // Div = Div([rho]u) located on pressure nodes:
171 DoubleTab Div_on_pressure_nodes(pression);
172 eqn_hydr.operateur_divergence().calculer(vitesse.valeurs(),Div_on_pressure_nodes);
173
174 // Test on the discretization:
175 if (vitesse.valeurs().line_size() > 1) // VEF
176 {
177 // VEF (temperature and pressure are not the same) => Div extrapolated on velocity nodes:
178 DoubleTab Div_on_temperature_nodes(inconnue().valeurs());
179 Div_on_pressure_nodes.echange_espace_virtuel();
180 ref_cast_non_const(Fluide_Quasi_Compressible,le_fluide.valeur()).divu_discvit(Div_on_pressure_nodes,Div_on_temperature_nodes);
181 const int nsom = Div_on_temperature_nodes.dimension_tot(0);
182 for (int i=0 ; i<nsom ; i++) Div(i)=Div_on_temperature_nodes(i);
183 }
184 else// VDF (temperature and pressure nodes are the same):
185 Div = Div_on_pressure_nodes;
186
187 Div *= -1;
188 }
189}
190
Class Champ_Inc_base.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
Particular case of Convection_Diffusion_std for a quasi-dilatable fluid when the transported scalar i...
int preparer_calcul() override
Everything that does not depend on other possible problems.
int remplir_cl_modifiee()
Fills the modified boundary condition domain with 1 everywhere on the boundary.
Particular case of Convection_Diffusion_Chaleur_Fluide_Dilatable_base for a quasi-compressible fluid,...
int preparer_calcul() override
Everything that does not depend on other possible problems.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
const Champ_base & vitesse_pour_transport() const override
void calculer_div_u_ou_div_rhou(DoubleTab &res) const override
void calculer_div_rho_u_impl(DoubleTab &res, const Convection_Diffusion_Fluide_Dilatable_base &eqn) const
const Operateur & operateur(int) const override
Returns the operator at the given index: returns terme_diffusif if i = 0,.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void set_param(Param &titi) const override
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
Sources les_sources
Probleme_base & probleme()
Returns the problem associated with the equation.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
Fluide_Quasi_Compressible class This class represents a quasi-compressible fluid,.
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
Navier_Stokes_std This class carries the terms of the momentum equation.
const Champ_Inc_base & inconnue() const override
Returns the velocity (unknown field of the equation) (const version).
Operateur_Div & operateur_divergence()
Returns the divergence operator associated with the equation.
Champ_Inc_base & pression()
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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
Classe Op_Conv_negligeable This class represents a negligible convection operator.
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
Initializes the array passed as parameter with the contribution of the operator.
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 Probleme_base It is a Probleme_U that is not a coupling.
virtual const Equation_base & equation(int) const =0
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 Generic class of the source term hierarchy. A Source object can.
Definition Source.h:33
void typer_direct(const Nom &)
Definition Source.cpp:41
_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")