TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Echange_global_impose.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Echange_global_impose.h>
17#include <Champ_Uniforme.h>
18#include <Probleme_base.h>
19#include <Milieu_base.h>
20#include <Domaine_Cl_dis_base.h>
21#include <Equation_base.h>
22
23Implemente_instanciable_sans_constructeur(Echange_global_impose,"Paroi_echange_global_impose",Echange_impose_base);
24// XD paroi_echange_global_impose condlim_base paroi_echange_global_impose INHERITS_BRACE Global type exchange condition
25// XD_CONT (internal) that is to say that diffusion on the first fluid mesh is not taken into consideration.
26// XD attr h_imp chaine h_imp REQ Global exchange coefficient value. The global exchange coefficient value is expressed
27// XD_CONT in W.m-2.K-1.
28// XD attr himpc front_field_base himpc REQ Boundary field type.
29// XD attr text chaine text REQ External temperature value. The external temperature value is expressed in oC or K.
30// XD attr ch front_field_base ch REQ Boundary field type.
31
32
33Echange_global_impose::Echange_global_impose()
34{
35}
36
38{
39 return s << que_suis_je() << finl;
40}
41
42/*! @brief Simple call to Echange_impose_base::readOn(Entree&) Reads the boundary condition specifications
43 *
44 * from an input stream.
45 *
46 * @param (Entree& s) an input stream
47 * @return (Entree&) the modified output stream
48 */
50{
51
52 // TODO : optional reading of phi_ext
54 return s ;
55}
56
58{
60 if (phi_ext_lu_)
61 {
62 derivee_phi_ext_->changer_temps_futur(temps, i);
63 phi_ext_->changer_temps_futur(temps, i);
64 }
65}
66
68{
69 if (phi_ext_lu_)
70 {
71 derivee_phi_ext_->avancer(temps);
72 phi_ext_->avancer(temps);
73 }
74 return Echange_impose_base::avancer(temps);
75}
76
78{
79 if (phi_ext_lu_)
80 {
81 derivee_phi_ext_->reculer(temps);
82 phi_ext_->reculer(temps);
83 }
84 return Echange_impose_base::reculer(temps);
85}
86
88{
90 if (phi_ext_lu_)
91 {
92 derivee_phi_ext_->set_temps_defaut(temps);
93 phi_ext_->set_temps_defaut(temps);
94 }
95}
96
98{
100 if (phi_ext_lu_)
101 {
102 derivee_phi_ext_->mettre_a_jour(temps);
103 phi_ext_->mettre_a_jour(temps);
104 }
105}
106
108{
110
111 if (phi_ext_lu_)
112 {
113 derivee_phi_ext_->initialiser(temps, domaine_Cl_dis().inconnue());
114 phi_ext_->initialiser(temps, domaine_Cl_dis().inconnue());
115 DoubleTab& vals_derphi = derivee_phi_ext_->valeurs();
116 vals_derphi = 0.;
117 DoubleTab& vals_phi = phi_ext_->valeurs();
118 vals_phi = 0.;
119 }
120 return 1;
121}
122
123
124double Echange_global_impose::champ_exterieur(int i, const Champ_front_base& champ_ext) const
125{
126 if (mon_dom_cl_dis->equation().que_suis_je()!="Convection_Diffusion_Concentration")
127 {
128 const Milieu_base& mil=mon_dom_cl_dis->equation().milieu();
129 Nom nom_pb=mon_dom_cl_dis->equation().probleme().que_suis_je();
130 double d_Cp;
131 double d_rho;
132 const Champ_base& rho=mil.masse_volumique();
133 if ((nom_pb.debute_par("Probleme_Interface")|| nom_pb==Nom("Probleme_Thermo_Front_Tracking"))||!sub_type(Champ_Uniforme,rho)||nom_pb==Nom("Pb_Conduction"))
134 {
135 // For front tracking, we do not divide by Rho*Cp
136 // nor for QC
137 d_rho=1.;
138 d_Cp=1.;
139 }
140 else
141 {
142 const Champ_Don_base& Cp =mil.capacite_calorifique();
143
144 if (sub_type(Champ_Uniforme,rho))
145 d_rho= rho.valeurs()(0,0);
146 else
147 d_rho= rho.valeurs()(i);
148
149 if (sub_type(Champ_Uniforme,Cp))
150 d_Cp= Cp.valeurs()(0,0);
151 else
152 d_Cp= Cp.valeurs()(i);
153 }
154
155 if (champ_ext.valeurs().size()==1)
156 return champ_ext.valeurs()(0,0)/(d_rho*d_Cp);
157 else if (champ_ext.valeurs().dimension(1)==1)
158 return champ_ext.valeurs()(i,0)/(d_rho*d_Cp);
159 else
160 Cerr << "Echange_global_impose::flux_impose error" << finl;
161 exit();
162 return 0.;
163 }
164 else
165 {
166 if (champ_ext.valeurs().size()==1)
167 return champ_ext.valeurs()(0,0);
168 else if (champ_ext.valeurs().dimension(1)==1)
169 return champ_ext.valeurs()(i,0);
170 else
171 Cerr << "Echange_global_impose::flux_impose error" << finl;
172 exit();
173 return 0.;
174
175 }
176}
177
178double Echange_global_impose::champ_exterieur(int i,int j, const Champ_front_base& champ_ext) const
179{
180 if (mon_dom_cl_dis->equation().que_suis_je()!="Convection_Diffusion_Concentration")
181 {
182 const Milieu_base& mil=mon_dom_cl_dis->equation().milieu();
183 Nom nom_pb=mon_dom_cl_dis->equation().probleme().que_suis_je();
184 double d_Cp;
185 double d_rho;
186 const Champ_base& rho=mil.masse_volumique();
187 if ((nom_pb.debute_par("Probleme_Interface")|| nom_pb.debute_par("Probleme_FT")|| nom_pb==Nom("Probleme_Thermo_Front_Tracking"))||!sub_type(Champ_Uniforme,rho)||nom_pb==Nom("Pb_Conduction"))
188 {
189 // For front tracking, we do not divide by Rho*Cp
190 // nor for QC
191 d_rho=1.;
192 d_Cp=1.;
193 }
194 else
195 {
196 const Champ_Don_base& Cp =mil.capacite_calorifique();
197
198 if (sub_type(Champ_Uniforme,rho))
199 d_rho= rho.valeurs()(0,0);
200 else
201 d_rho= rho.valeurs()(i);
202
203 if (sub_type(Champ_Uniforme,Cp))
204 d_Cp= Cp.valeurs()(0,0);
205 else
206 d_Cp= Cp.valeurs()(i);
207 }
208 if (champ_ext.valeurs().dimension(0)==1)
209 return champ_ext.valeurs()(0,j)/(d_rho*d_Cp);
210 else
211 return champ_ext.valeurs()(i,j)/(d_rho*d_Cp);
212 }
213 else
214 {
215 if (champ_ext.valeurs().dimension(0)==1)
216 return champ_ext.valeurs()(0,j);
217 else
218 return champ_ext.valeurs()(i,j);
219 }
220}
221
223{
225 if (phi_ext_lu_)
226 {
227 derivee_phi_ext_.typer("Ch_front_var_instationnaire_dep");
228 derivee_phi_ext_->fixer_nb_comp(1);
229 derivee_phi_ext_->associer_fr_dis_base(frontiere_dis());
230 derivee_phi_ext_->fixer_nb_valeurs_temporelles(3);
231
232 phi_ext_.typer("Ch_front_var_instationnaire_dep");
233 phi_ext_->fixer_nb_comp(1);
234 phi_ext_->associer_fr_dis_base(frontiere_dis());
235 phi_ext_->fixer_nb_valeurs_temporelles(3);
236 }
237}
238
240{
241 return champ_exterieur(i,j,derivee_phi_ext());
242}
243
248
250{
251 return champ_exterieur(i,j,phi_ext());
252}
253
255{
256 return champ_exterieur(i,phi_ext());
257}
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
virtual DoubleTab & valeurs()=0
Champ_Uniforme Represents a field that is constant in space and time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual DoubleTab & valeurs() override
Returns the array of field values.
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
virtual void completer()
DOES NOTHING must be overridden in derived classes.
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
Classe Echange_global_impose This class represents the special case of the class.
virtual double flux_exterieur_impose(int i) const
void set_temps_defaut(double temps) override
Changes the i-th future time of the BC.
void mettre_a_jour(double temps) override
Performs a time update of the boundary condition.
int reculer(double temps) override
Rotates the wheel of the BC.
Champ_front_base & derivee_phi_ext()
Champ_front_base & phi_ext()
void completer() override
DOES NOTHING must be overridden in derived classes.
int avancer(double temps) override
Rotates the wheel of the BC.
int initialiser(double temps) override
Initialization at the beginning of the calculation.
virtual double derivee_flux_exterieur_imposee(int i) const
virtual double champ_exterieur(int i, int j, const Champ_front_base &champ_ext) const
void changer_temps_futur(double temps, int i) override
Changes the i-th future time of the BC.
Echange_impose_base: This boundary condition is used only for the energy equation.
int avancer(double temps) override
Rotates the wheel of the BC.
int initialiser(double temps) override
Initialization at the beginning of the calculation.
void set_temps_defaut(double temps) override
Changes the i-th future time of the BC.
int reculer(double temps) override
Rotates the wheel of the BC.
void mettre_a_jour(double) override
Performs a time update of the boundary conditions.
void changer_temps_futur(double temps, int i) override
Changes the i-th future time of the BC.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
virtual const Equation_base & equation(const std::string &nom_inc) const
virtual const Champ_Don_base & capacite_calorifique() const
Returns the heat capacity of the medium (const version).
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
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
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
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45