TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Echange_couplage_thermique.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 <Echange_couplage_thermique.h>
17#include <Discretisation_base.h>
18#include <Domaine_Cl_dis_base.h>
19#include <Champ_Uniforme.h>
20#include <Probleme_base.h>
21#include <Equation_base.h>
22#include <Milieu_base.h>
23#include <EChaine.h>
24
25Implemente_instanciable_sans_constructeur( Echange_couplage_thermique, "Echange_couplage_thermique", Echange_global_impose ) ;
26// XD Echange_couplage_thermique paroi_echange_global_impose Echange_couplage_thermique BRACE Thermal coupling boundary
27// XD_CONT condition
28// XD attr text suppress_param text OPT suppress
29// XD attr h_imp suppress_param h_imp OPT suppress
30// XD attr himpc suppress_param himpc OPT suppress
31// XD attr ch suppress_param ch OPT suppress
32// XD attr temperature_paroi field_base temperature_paroi OPT Temperature
33// XD attr flux_paroi field_base flux_paroi OPT Wall heat flux
34
35Echange_couplage_thermique::Echange_couplage_thermique()
36{
37 phi_ext_lu_ = true;
38}
39
41
43{
44 if (app_domains.size() == 0) app_domains = { Motcle("Thermique") };
45 if (supp_discs.size() == 0) supp_discs = { Nom("VDF"), Nom("VEFPreP1B"), Nom("EF_axi"), Nom("EF") };
46
47 Cerr << "Reading of coupled boundary" << finl;
48
49 EChaine ech1("Ch_front_var_instationnaire_dep 1");
50 EChaine ech2("Ch_front_var_instationnaire_dep 1");
51
52 ech1 >> h_imp_;
53 ech2 >> le_champ_front;
54
55 LIST(Nom) noms;
56 noms.add("temperature_paroi");
57 noms.add("flux_paroi");
58 lec_champs.lire_champs(is,noms);
59 reprise_ = lec_champs.champs_lus();
60
61 return is;
62}
63
65{
67
68 coeff_ap.typer("Ch_front_var_instationnaire_dep");
69 coeff_ap->fixer_nb_comp(1);
70 coeff_ap->associer_fr_dis_base(frontiere_dis());
71 coeff_ap->fixer_nb_valeurs_temporelles(3);
72
73 coeff_sp.typer("Ch_front_var_instationnaire_dep");
74 coeff_sp->fixer_nb_comp(1);
75 coeff_sp->associer_fr_dis_base(frontiere_dis());
76 coeff_sp->fixer_nb_valeurs_temporelles(3);
77
78 coeff_heff.typer("Ch_front_var_instationnaire_dep");
79 coeff_heff->fixer_nb_comp(1);
80 coeff_heff->associer_fr_dis_base(frontiere_dis());
81 coeff_heff->fixer_nb_valeurs_temporelles(3);
82
83 type_echange_eff.typer("Ch_front_var_instationnaire_dep");
84 type_echange_eff->fixer_nb_comp(1);
85 type_echange_eff->associer_fr_dis_base(frontiere_dis());
86 type_echange_eff->fixer_nb_valeurs_temporelles(3);
87
88 temperature_Teff.typer("Ch_front_var_instationnaire_dep");
89 temperature_Teff->fixer_nb_comp(1);
90 temperature_Teff->associer_fr_dis_base(frontiere_dis());
91 temperature_Teff->fixer_nb_valeurs_temporelles(3);
92
93 rftc_paroi.typer("Ch_front_var_instationnaire_dep");
94 rftc_paroi->fixer_nb_comp(1);
95 rftc_paroi->associer_fr_dis_base(frontiere_dis());
96 rftc_paroi->fixer_nb_valeurs_temporelles(3);
97
98 flux_critique_paroi.typer("Ch_front_var_instationnaire_dep");
99 flux_critique_paroi->fixer_nb_comp(1);
100 flux_critique_paroi->associer_fr_dis_base(frontiere_dis());
101 flux_critique_paroi->fixer_nb_valeurs_temporelles(3);
102
103 Nom nom_pb=mon_dom_cl_dis->equation().probleme().que_suis_je();
104 const Champ_base& rho=mon_dom_cl_dis->equation().milieu().masse_volumique();
105 if ((nom_pb.debute_par("Probleme_Interface")|| nom_pb==Nom("Probleme_Thermo_Front_Tracking"))||!sub_type(Champ_Uniforme,rho)
106 ||nom_pb==Nom("Pb_Conduction") || nom_pb.debute_par("Pb_Conduction_Combustible")
107 ||mon_dom_cl_dis->equation().que_suis_je()=="Convection_Diffusion_Concentration")
108 {
109 // For front tracking, QC, and conduc_variable cases, we do not divide by Rho*Cp:
110 divise_par_rho_cp_=false;
111 }
112}
113
114double Echange_couplage_thermique::champ_exterieur(int i,int j, const Champ_front_base& champ_ext) const
115{
117 {
118 const Milieu_base& mil=mon_dom_cl_dis->equation().milieu();
119 const Champ_base& rho=mil.masse_volumique();
120 const Champ_Don_base& Cp=mil.capacite_calorifique();
121 double d_rho = sub_type(Champ_Uniforme,rho) ? rho.valeurs()(0,0) : rho.valeurs()(i);
122 double d_Cp = sub_type(Champ_Uniforme,Cp) ? Cp.valeurs()(0,0) : Cp.valeurs()(i);
123 if (champ_ext.valeurs().dimension(0)==1)
124 return champ_ext.valeurs()(0,j)/(d_rho*d_Cp);
125 else
126 return champ_ext.valeurs()(i,j)/(d_rho*d_Cp);
127 }
128 else
129 {
130 if (champ_ext.valeurs().dimension(0)==1)
131 return champ_ext.valeurs()(0,j);
132 else
133 return champ_ext.valeurs()(i,j);
134 }
135}
136
138{
140 coeff_ap->changer_temps_futur(temps,i);
141 coeff_sp->changer_temps_futur(temps,i);
142 coeff_heff->changer_temps_futur(temps,i);
143 type_echange_eff->changer_temps_futur(temps,i);
144 temperature_Teff->changer_temps_futur(temps,i);
145 rftc_paroi->changer_temps_futur(temps,i);
146 flux_critique_paroi->changer_temps_futur(temps,i);
147}
148
150{
151 coeff_ap->avancer(temps);
152 coeff_sp->avancer(temps);
153 coeff_heff->avancer(temps);
154 type_echange_eff->avancer(temps);
155 temperature_Teff->avancer(temps);
156 rftc_paroi->avancer(temps);
157 flux_critique_paroi->avancer(temps);
158 return Echange_global_impose::avancer(temps);
159}
160
162{
163 coeff_ap->reculer(temps);
164 coeff_sp->reculer(temps);
165 coeff_heff->reculer(temps);
166 type_echange_eff->reculer(temps);
167 temperature_Teff->reculer(temps);
168 rftc_paroi->reculer(temps);
169 flux_critique_paroi->reculer(temps);
170 return Echange_global_impose::reculer(temps);
171}
172
174{
176 coeff_ap->set_temps_defaut(temps);
177 coeff_sp->set_temps_defaut(temps);
178 coeff_heff->set_temps_defaut(temps);
179 type_echange_eff->set_temps_defaut(temps);
180 temperature_Teff->set_temps_defaut(temps);
181 rftc_paroi->set_temps_defaut(temps);
182 flux_critique_paroi->set_temps_defaut(temps);
183}
184
186{
188 coeff_ap->mettre_a_jour(temps);
189 coeff_sp->mettre_a_jour(temps);
190 coeff_heff->mettre_a_jour(temps);
191 type_echange_eff->mettre_a_jour(temps);
192 temperature_Teff->mettre_a_jour(temps);
193 rftc_paroi->mettre_a_jour(temps);
194 flux_critique_paroi->mettre_a_jour(temps);
195}
196
197static bool initialized = false;
199{
200 if (!initialized)
201 {
203 if (reprise_)
204 {
206
207 ch->affecter(lec_champs.champ_lu("temperature_paroi"));
208 DoubleTab& vals1 =le_champ_front->valeurs();
209 ch->trace(frontiere_dis(),vals1,temps,0);
210
211 ch->affecter(lec_champs.champ_lu("flux_paroi"));
212 DoubleTab& vals = phi_ext_->valeurs();
213 ch->trace(frontiere_dis(),vals,temps,0);
214 }
215 }
216 else
217 {
218 // Multi-run case where the computation is re-initialised (previous phi_ext and champ_front values are preserved)
219 phi_ext_->set_temps_defaut(temps);
220 phi_ext_->mettre_a_jour(temps);
221 phi_ext_->changer_temps_futur(temps,0);
222 le_champ_front->set_temps_defaut(temps);
223 le_champ_front->mettre_a_jour(temps);
224 le_champ_front->changer_temps_futur(temps,0);
225 reprise_ = true;
226 }
227 coeff_ap->initialiser(temps,domaine_Cl_dis().inconnue());
228 coeff_sp->initialiser(temps,domaine_Cl_dis().inconnue());
229 coeff_heff->initialiser(temps,domaine_Cl_dis().inconnue());
230 type_echange_eff->initialiser(temps,domaine_Cl_dis().inconnue());
231 temperature_Teff->initialiser(temps,domaine_Cl_dis().inconnue());
232 rftc_paroi->initialiser(temps,domaine_Cl_dis().inconnue());
233 rftc_paroi->valeurs()=1e20;
234 flux_critique_paroi->initialiser(temps,domaine_Cl_dis().inconnue());
235 flux_critique_paroi->valeurs()=1e20;
236 initialized = true;
237 return 1;
238}
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
Class Champ_Inc_base.
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
Champ_base & affecter(const Champ_base &)
Assign a field to another.
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual DoubleTab & valeurs() override
Returns the array of field values.
std::vector< Nom > supp_discs
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
std::vector< Motcle > app_domains
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
: class Echange_couplage_thermique
double champ_exterieur(int i, int j, const Champ_front_base &champ_ext) const override
void set_temps_defaut(double temps) override
Changes the i-th future time of the BC.
void completer() override
DOES NOTHING must be overridden in derived classes.
OWN_PTR(Champ_front_base) coeff_ap
int avancer(double temps) override
Rotates the wheel of the BC.
int reculer(double temps) override
Rotates the wheel of the BC.
void mettre_a_jour(double temps) override
Performs a time update of the boundary condition.
void changer_temps_futur(double temps, int i) override
Changes the i-th future time of the BC.
int initialiser(double temps) override
Initialization at the beginning of the calculation.
Classe Echange_global_impose This class represents the special case of the class.
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.
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.
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
virtual const Champ_Inc_base & inconnue() 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).
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133