TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Echange_contact_rayo_transp_VDF.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_contact_rayo_transp_VDF.h>
17#include <Modele_rayo_transp.h>
18#include <Champ_front_uniforme.h>
19#include <Champ_front_calc.h>
20#include <Champ_Uniforme.h>
21#include <Pb_Fluide_base.h>
22#include <Domaine_VDF.h>
23#include <Debog.h>
24
25Implemente_instanciable(Echange_contact_rayo_transp_VDF, "Echange_contact_rayo_transp_VDF", Echange_contact_VDF);
26
28
30
32{
33 assert (!le_modele_rayo_);
34
35 // Retrieve the radiation model ... but we need the correct problem!
36 // XXX not yet entered Echange_contact_VDF::initialiser ... so things must be done manually here ...
37 const Probleme_base& this_pb = domaine_Cl_dis().equation().probleme();
38 if (this_pb.milieu().is_rayo_transp()) // good, we are on the fluid side!!
39 {
40 assert (sub_type(Pb_Fluide_base, this_pb));
41 le_modele_rayo_ =ref_cast(Pb_Fluide_base, this_pb).get_mod_rayo_transp();
42 }
43 else // the other problem!
44 {
45 // const Probleme_base& other_pb = ref_cast(Champ_front_calc, T_autre_pb()).inconnue().equation().probleme(); // encore tot deso ...
46 const Probleme_base& other_pb = ref_cast(Probleme_base, Interprete::objet(nom_autre_pb_));
47 if (other_pb.milieu().is_rayo_transp()) // fluid problem found!!
48 {
49 assert (sub_type(Pb_Fluide_base, other_pb));
50 le_modele_rayo_ = ref_cast(Pb_Fluide_base, other_pb).get_mod_rayo_transp();
51 }
52 else
53 {
54 Cerr << finl << "Big issue in Echange_contact_rayo_transp_VDF::initialiser !!!" << finl;
55 Cerr << "It seems that you defined a radiation contact BC between the boundaries " << frontiere_dis().frontiere().le_nom() << " and " << nom_bord << finl;
56 Cerr << "of problems " << this_pb.le_nom() << " and " << nom_autre_pb_ << " , but neither is a fluid radiation problem !!!" << finl;
57 Process::exit("Please fix your data file and use the classical paroi_contact BC for these boundaries ... \n");
58 }
59 }
60
62}
63
65{
68
69 // Compute teta_i_ at time 0
70 const Equation_base& mon_eqn = domaine_Cl_dis().equation();
71 const DoubleTab& mon_inco = mon_eqn.inconnue().valeurs();
72 const Domaine_VDF& ma_zvdf = ref_cast(Domaine_VDF, domaine_Cl_dis().domaine_dis());
73 const Front_VF& ma_front_vf = ref_cast(Front_VF, frontiere_dis());
74 const int ndeb = ma_front_vf.num_premiere_face();
75 const int nb_faces_bord = ma_front_vf.nb_faces();
76
77 for (int numfa = 0; numfa < nb_faces_bord; numfa++)
78 {
79 const int ind_fac = numfa + ndeb;
80 int elem;
81 if (ma_zvdf.face_voisins(ind_fac, 0) != -1)
82 elem = ma_zvdf.face_voisins(ind_fac, 0);
83 else
84 elem = ma_zvdf.face_voisins(ind_fac, 1);
85
86 teta_i_(numfa) = mon_inco(elem);
87 }
88 return;
89}
90
92{
93 // Echange_contact_VDF::mettre_a_jour(temps);
95 const Milieu_base& le_milieu = ch.milieu();
96 const int nb_comp = le_milieu.conductivite().nb_comp();
97
99 {
100 Cerr << "end of construction in " << que_suis_je() << finl;
102 // determine which is the fluid problem
103 const Equation_base *eqn = nullptr;
104 const Equation_base& mon_eqn = domaine_Cl_dis().equation();
105
106 const Champ_front_calc& chcal = ref_cast(Champ_front_calc, T_autre_pb());
107 const Equation_base& autre_eqn = chcal.inconnue().equation();
108 int m = 0;
109 if (mon_eqn.probleme().milieu().is_rayo_transp())
110 {
111 // we are on the fluid side
112 eqn = &mon_eqn;
113 m++;
114 }
115
116 if (autre_eqn.probleme().milieu().is_rayo_transp())
117 {
118 eqn = &autre_eqn;
119 m++;
120 }
121
122 if (m != 1)
123 {
124 Cerr << "big problem in " << que_suis_je() << finl;
126 }
127
128 if (frontiere_dis().le_nom() != chcal.front_dis().le_nom())
129 Process::exit("The boundary name must be the same for both domains at the raccord level");
130
131 const Front_VF& frontvf = ref_cast(Front_VF, eqn->domaine_dis().frontiere_dis(frontiere_dis().le_nom()));
133 Domaine_dis_base& domaine_dis1 = domaine_Cl_dis().domaine_dis();
134 Nom nom_racc1 = frontiere_dis().frontiere().le_nom();
135 if (domaine_dis1.domaine().raccord(nom_racc1)->que_suis_je() != "Raccord_distant_homogene")
137 }
138 else
139 {
140 // Process::exit();
141 }
142
143 T_autre_pb().mettre_a_jour(temps);
144
145 assert(nb_comp == 1);
146 int is_pb_fluide = 0;
147
148 // WARNING: look at the equation to determine is_pb_fluide, which is needed for radiation
149 DoubleTab& mon_h = h_imp_->valeurs();
150 int opt = 0;
151 assert(h_paroi != 0.);
152 double invhparoi = 1. / h_paroi;
153
154 calculer_h_autre_pb(autre_h, invhparoi, opt);
155
156 calculer_h_mon_pb(mon_h, 0., opt);
157
158 calculer_Teta_paroi(T_ext().valeurs_au_temps(temps), mon_h, autre_h, is_pb_fluide, temps);
159
160 // Teta_paroi has been computed; now compute htot in himp (= mon_h)
161
162 int taille = mon_h.dimension(0);
163 for (int ii = 0; ii < taille; ii++)
164 for (int jj = 0; jj < nb_comp; jj++)
165 mon_h(ii, jj) = 1. / (1. / autre_h(ii, jj) + 1. / mon_h(ii, jj));
166
168}
169
170void Echange_contact_rayo_transp_VDF::calculer_Teta_equiv(DoubleTab& Teta_eq, const DoubleTab& mon_h, const DoubleTab& lautre_h, int i, double temps)
171{
172 Cerr << "This path should not be taken: Echange_contact_rayo_transp_VDF::calculer_Teta_equiv " << __FILE__ << finl;
174}
175
176void Echange_contact_rayo_transp_VDF::calculer_Teta_paroi(DoubleTab& Teta_equiv, const DoubleTab& mon_h, const DoubleTab& lautre_h, int i, double temps)
177{
178 // i will be used in the radiation step
179 //
180 //mon_h(monT-Tw)=autre_h*(Tw-Tautre)
181 // Tautre=Text;
182 // Tw=(autr_h*Tautre+mon_h*monT)/(autr_h+mon_h)
183 const Equation_base& mon_eqn = domaine_Cl_dis().equation();
184 const DoubleTab& mon_inco = mon_eqn.inconnue().valeurs();
185 const Domaine_VDF& ma_zvdf = ref_cast(Domaine_VDF, domaine_Cl_dis().domaine_dis());
186 const Front_VF& ma_front_vf = ref_cast(Front_VF, frontiere_dis());
187
188 //DoubleTab& mon_h=h_imp_->valeurs();
189 int ndeb = ma_front_vf.num_premiere_face();
190 //int ndeb2 = l_autre_front_vf.num_premiere_face();
191 int nb_faces_bord = ma_front_vf.nb_faces();
192 int ind_fac, elem;
193 //DoubleTab& Teta_i=T_ext().valeurs();
194 //Teta_equiv.resize(nb_faces_bord,1);
195 Modele_rayo_transp& modrayo = ref_cast(Modele_rayo_transp, le_modele_rayo_.valeur());
196 if (modrayo.relaxation() == 0)
197 alpha_ = 0;
198
199 // The radiative flux must be traced in parallel for the solid problem
201 DoubleTab& t_autre = ch.valeurs_au_temps(temps);
202 const Front_VF& autre_front_vf = ref_cast(Front_VF, ch.front_dis());
203
204 int ispbfluide = mon_eqn.probleme().milieu().is_rayo_transp();
205
206 const Front_VF& frontfluide = (ispbfluide ? ma_front_vf : autre_front_vf);
207 int nb_faces_bord_fluide = frontfluide.nb_faces();
208 DoubleVect flux_radia_fluide(nb_faces_bord_fluide);
209 int ndebfluide = frontfluide.num_premiere_face();
210 assert(ndebfluide == num_premiere_face_dans_pb_fluide_);
211 for (int nfluide = 0; nfluide < nb_faces_bord_fluide; nfluide++)
212 flux_radia_fluide(nfluide) = modrayo.flux_radiatif(nfluide + ndebfluide);
213
214 DoubleVect fluxradia;
215 Domaine_dis_base& domaine_dis1 = domaine_Cl_dis().domaine_dis();
216 Nom nom_racc1 = frontiere_dis().frontiere().le_nom();
217
218 if ((ispbfluide) || (domaine_dis1.domaine().raccord(nom_racc1)->que_suis_je() != "Raccord_distant_homogene"))
219 fluxradia = flux_radia_fluide;
220 else
221 autre_front_vf.frontiere().trace_face_distant(flux_radia_fluide, fluxradia);
222
223 for (int numfa = 0; numfa < nb_faces_bord; numfa++)
224 {
225 ind_fac = numfa + ndeb;
226 if (ma_zvdf.face_voisins(ind_fac, 0) != -1)
227 elem = ma_zvdf.face_voisins(ind_fac, 0);
228 else
229 elem = ma_zvdf.face_voisins(ind_fac, 1);
230
231 double new_Teta_i = (mon_h(numfa, 0) * mon_inco(elem) + lautre_h(numfa, 0) * t_autre(numfa, 0) - fluxradia(numfa)) / (mon_h(numfa, 0) + lautre_h(numfa, 0));
232
233 double tetisa = teta_i_(numfa);
234
235 teta_i_(numfa) = (1 - alpha_) * new_Teta_i + alpha_ * teta_i_(numfa);
236 Teta_equiv(numfa, 0) = (-mon_h(numfa, 0) * mon_inco(elem) + (lautre_h(numfa, 0) + mon_h(numfa, 0)) * teta_i(numfa)) / lautre_h(numfa, 0);
237
238 if (teta_i_(numfa) <= 0)
239 {
240 Cerr << "Teta_equiv fin " << Teta_equiv(numfa, 0) << " Teta_i_old " << tetisa << " Teta_i " << teta_i_(numfa);
241 Cerr << " Teta_equiv avt modif " << (mon_h(numfa, 0) * mon_inco(elem) + lautre_h(numfa, 0) * t_autre(numfa) - fluxradia(numfa)) / (mon_h(numfa, 0) + lautre_h(numfa, 0));
242 Cerr << " h " << mon_h(numfa, 0) << " autreh " << lautre_h(numfa, 0) << " flux radia " << fluxradia(numfa);
243 Cerr << " mon T " << mon_inco(elem) << " autre T " << t_autre(numfa) << finl;
245 }
246 }
247 Debog::verifier("Teta_equiv dans Echange_contact_rayo_transp_VDF::calculer_Teta_paroi", Teta_equiv);
248}
249
250/////////////////////////////////////////////
251
252Implemente_instanciable_sans_constructeur(Echange_contact_Rayo_transp_sans_relax_VDF, "Echange_contact_Rayo_transp_sans_relax_VDF", Echange_contact_rayo_transp_VDF);
253
255{
257}
258
260{
262}
263
264Echange_contact_Rayo_transp_sans_relax_VDF::Echange_contact_Rayo_transp_sans_relax_VDF()
265{
267 alpha_ = 0;
268}
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual void associer_fr_dis_base(const Frontiere_dis_base &)
Associates a discretized boundary with the field.
virtual void mettre_a_jour(double temps)
DOES NOTHING, to override.
class Champ_front_calc Derived class of Champ_front_var representing
const Frontiere_dis_base & front_dis() const
Returns the discretized boundary corresponding to the domain on which the trace is taken.
const Champ_Inc_base & inconnue() const
Returns the associated unknown field.
const Milieu_base & milieu() const
Returns the medium associated with the equation carrying the unknown field whose trace is taken.
DoubleTab & valeurs_au_temps(double temps) override
Returns the values at the desired time.
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
virtual double teta_i(int numfa) const
void preparer_surface(const Frontiere_dis_base &, const Domaine_Cl_dis_base &)
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
Raccord_t & raccord(int i)
Definition Domaine.h:248
Domaine_dis_base & domaine_dis()
Returns a reference to the discretized domain associated with the boundary conditions.
class Domaine_VDF
Definition Domaine_VDF.h:61
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Frontiere_dis_base & frontiere_dis(const Nom &) const
Returns the boundary of Name nom.
const Domaine & domaine() const
int initialiser(double temps) override
Initialization at the beginning of the calculation.
void completer() override
DOES NOTHING must be overridden in derived classes.
void calculer_h_autre_pb(DoubleTab &tab, double invhparoi, int opt)
virtual Champ_front_base & T_autre_pb()
void calculer_h_mon_pb(DoubleTab &, double, int)
int initialiser(double temps) override
Initialization at the beginning of the calculation.
void mettre_a_jour(double) override
Performs a time update of the boundary condition.
void calculer_Teta_paroi(DoubleTab &tab_p, const DoubleTab &mon_h, const DoubleTab &autre_h, int is_pb_fluide, double temps) override
Fills Teta_p using T_autre_pb at the time passed as parameter.
void calculer_Teta_equiv(DoubleTab &Teta_equiv, const DoubleTab &mon_h, const DoubleTab &autre_h, int is_pb_fluide, double temps) override
Fills Teta_eq using T_autre_pb at the time passed as parameter.
void mettre_a_jour(double temps) override
Performs a time update of the boundary condition.
virtual Champ_front_base & T_ext()
Returns the T_ext field of temperature imposed at the boundary.
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
Probleme_base & probleme()
Returns the problem associated with the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
virtual int nb_comp() const
Definition Field_base.h:56
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
virtual void trace_face_distant(const DoubleTab &, DoubleTab &) const
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Frontiere.h:49
const Frontiere & frontiere() const
Returns the associated geometric boundary.
const Nom & le_nom() const override
Returns the name of the geometric boundary.
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
virtual bool is_rayo_transp() const
Definition Milieu_base.h:83
virtual const Champ_Don_base & conductivite() const
Returns the conductivity of the medium (const version).
double relaxation() const
double flux_radiatif(int num_face_global) const
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
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 const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Pb_Fluide_base This class provides a base class for.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
class Probleme_base It is a Probleme_U that is not a coupling.
virtual const Milieu_base & milieu() const
Returns the physical medium associated with the problem (const version).
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