TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Echange_interne_impose.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_interne_impose.h>
17#include <Equation_base.h>
18#include <Champ_front_calc_interne.h>
19#include <Probleme_base.h>
20#include <Frontiere_dis_base.h>
21#include <Domaine_Cl_dis_base.h>
22#include <Domaine_VDF.h>
23#include <Front_VF.h>
24#include <Milieu_base.h>
25#include <Champ_front_uniforme.h>
26#include <EChaine.h>
27
28Implemente_instanciable(Echange_interne_impose,"Paroi_echange_interne_impose",Echange_externe_impose);
29// XD Echange_interne_impose condlim_base Paroi_echange_interne_impose INHERITS_BRACE Internal heat exchange boundary
30// XD_CONT condition with exchange coefficient.
31// XD attr h_imp chaine h_imp REQ Exchange coefficient value expressed in W.m-2.K-1.
32// XD attr ch front_field_base ch REQ Boundary field type.
33
34Sortie& Echange_interne_impose::printOn(Sortie& s ) const { return s << que_suis_je() << finl; }
35
36/*! @brief Simple call to Echange_impose_base::readOn(Entree&). Reads the boundary condition specifications
37 *
38 * from an input stream.
39 *
40 * @param s input stream
41 * @return modified output stream
42 */
44{
45 if (app_domains.size() == 0) app_domains = { Motcle("Thermique"), Motcle("Neutronique"), Motcle("fraction_massique"), Motcle("indetermine") };
46
47 Motcle motlu;
48 Motcle motcle("h_gap");
49
50 s >> motlu;
51 if (motlu ==motcle)
52 s >> h_gap_;
53 else
54 {
55 Cerr << "Error when reading boundary condition with type Echange_interne_impose " << finl;
56 Cerr << "We expected " << motcle << " instead of " << motlu << finl;
57 exit();
58 }
59
60 init();
61
62 return s;
63}
64
66{
67 le_champ_front.typer("Champ_front_calc_interne"); // preparation of T_ext
68 EChaine e("Champ_front_fonc_xyz 1 1e-10");
69 e >> h_imp_; // won't be used anyway, just make sure we have a big enough array to store future values of h
70}
71
72
73// Override to skip verification - we know we will always be dealing with temperature, and we define ourselves the T_ext with
74// a Champ_front_calc_interne.
78
80{
81 if (h_gap_)
82 h_gap_->set_temps_defaut(temps);
84}
86{
87 if (h_gap_)
88 h_gap_->fixer_nb_valeurs_temporelles(nb_cases);
90}
91//
93{
94 if (h_gap_)
95 h_gap_->changer_temps_futur(temps,i);
97}
99{
100 if (h_gap_)
101 h_gap_->avancer(temps);
103}
104
106{
107 if (h_gap_)
108 h_gap_->reculer(temps);
110}
112{
113 if (h_gap_)
114 h_gap_->associer_fr_dis_base(fr);
116}
117
118// Finish building the champ_front_calc_interne
120{
121 Nom nom_pb(domaine_Cl_dis().equation().probleme().le_nom());
122 Nom nom_bord(frontiere_dis().le_nom());
123
124 lambda_ref_ = domaine_Cl_dis().equation().probleme().milieu().conductivite();
125
127 t_ext.creer(nom_pb, nom_bord, "temperature");
128
129 const Front_VF& fvf = ref_cast(Front_VF, frontiere_dis());
130 inv_lambda_.resize(fvf.nb_faces());
131
133}
134
135double Echange_interne_impose::calcul_h_imp(const double h_gap, const double invLambda) const
136{
137 return 1./(1./h_gap + invLambda); // harmonic mean
138}
139
140// Compute e/lambda - this will be used:
141// - in calcul_h_imp to adjust for the half cell in VDF
142// - in Echange_interne_vargap for the computation of the h_gap correlation.
144{
145 bool isVDF = sub_type(Domaine_VDF, frontiere_dis().domaine_dis());
146 const Front_VF& fvf = ref_cast(Front_VF, frontiere_dis());
147
148 inv_lambda_ = 0.0;
149
150 if (isVDF)
151 {
152 DoubleTab& lambdas = lambda_ref_->valeurs();
153
154 const Domaine_VDF& zon = ref_cast(Domaine_VDF, frontiere_dis().domaine_dis());
155 for (int numf=0; numf < fvf.nb_faces(); numf++)
156 {
157 int facei = fvf.num_face(numf);
158 int vois0 = zon.face_voisins(facei, 0);
159 int elem = (vois0 != -1) ? vois0 : zon.face_voisins(facei, 1);
160 inv_lambda_(numf) = zon.dist_norm_bord(facei)/lambdas(elem, 0);
161 }
162 }
163}
164
166{
168 h_gap_->mettre_a_jour(tps);
169
171
172 bool isVDF = sub_type(Domaine_VDF, frontiere_dis().domaine_dis());
173
174 DoubleTab& h_impose = h_imp_->valeurs();
175 DoubleTab& h_gap = h_gap_->valeurs();
176
177 // If VDF, fix h_imp to take into account half cell on the other side of the wall:
178 if (isVDF)
179 {
180 const Champ_front_calc_interne& t_ext = ref_cast(Champ_front_calc_interne, T_ext());
181 const IntVect& face_map = t_ext.face_map();
182 const Front_VF& fvf = ref_cast(Front_VF, frontiere_dis());
183
184 for (int numf=0; numf < fvf.nb_faces(); numf++)
185 {
186 int opp_face = face_map(numf); // opposite face
187 if (sub_type(Champ_front_uniforme, h_gap_.valeur()))
188 h_impose(numf,0) = calcul_h_imp(h_gap(0,0), inv_lambda_(opp_face)); // inv lambda from the **opposite** side
189 else
190 h_impose(numf,0) = calcul_h_imp(h_gap(numf,0), inv_lambda_(opp_face));
191 }
192 }
193 else
194 {
195 if (sub_type(Champ_front_uniforme, h_gap_.valeur()))
196 h_impose = h_gap(0,0);
197 else
198 h_impose = h_gap;
199 }
200}
201
203{
206 return ret;
207}
class Champ_front_calc_interne Derived class of Champ_front_calc representing
const IntVect & face_map() const
void creer(const Nom &, const Nom &, const Motcle &)
Create the Champ_front_calc object representing the trace of an unknown field on a boundary from name...
class Champ_front_uniforme Derived class of Champ_front_base representing
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.
std::vector< Motcle > app_domains
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
class Domaine_VDF
Definition Domaine_VDF.h:61
double dist_norm_bord(int num_face) const override
Returns the normal distance for a boundary face (Cartesian coordinates).
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
An input stream whose source is a character string.
Definition EChaine.h:31
Classe Echange_externe_impose: This class represents the special case of the class.
int avancer(double temps) override
Rotates the wheel of the BC.
int initialiser(double temps) override
Initialization at the beginning of the calculation.
void fixer_nb_valeurs_temporelles(int nb_cases) override
Called by Conds_lim::completer. Calls cha_front_base::fixer_nb_valeurs_temporelles.
void set_temps_defaut(double temps) override
Changes the i-th future time of the BC.
void associer_fr_dis_base(const Frontiere_dis_base &) override
Associates the boundary with the object.
virtual Champ_front_base & T_ext()
Returns the T_ext field of temperature imposed at the boundary.
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 Echange_interne_impose
void fixer_nb_valeurs_temporelles(int nb_cases) override
Called by Conds_lim::completer. Calls cha_front_base::fixer_nb_valeurs_temporelles.
void mettre_a_jour(double tps) override
Performs a time update of the boundary conditions.
int avancer(double temps) override
Rotates the wheel of the BC.
int reculer(double temps) override
Rotates the wheel of the BC.
int initialiser(double temps) override
Initialization at the beginning of the calculation.
void associer_fr_dis_base(const Frontiere_dis_base &fr) override
Associates the boundary with the object.
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.
void changer_temps_futur(double temps, int i) override
Changes the i-th future time of the BC.
virtual double calcul_h_imp(const double h_gap, const double invLambda) const
void verifie_ch_init_nb_comp() const override
Calls the verification of the field read through the equation for which the boundary condition is con...
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Probleme_base & probleme()
Returns the problem associated with the equation.
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_face(const int) const
Definition Front_VF.h:68
class Frontiere_dis_base Class representing a discretized boundary.
virtual const Champ_Don_base & conductivite() const
Returns the conductivity 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
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
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