TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Echange_impose_base.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_impose_base.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Equation_base.h>
19#include <Probleme_base.h>
20#include <Milieu_base.h>
21
22Implemente_base_sans_constructeur(Echange_impose_base, "Echange_impose_base", Cond_lim_base);
23
24Sortie& Echange_impose_base::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
25
27{
28 if (app_domains.size() == 0) app_domains = { Motcle("Thermique"), Motcle("Neutronique"), Motcle("fraction_massique"), Motcle("indetermine"), Motcle("concentration") };
29 if (supp_discs.size() == 0) supp_discs = { Nom("VDF"), Nom("VEFPreP1B"), Nom("PolyMAC_CDO"), Nom("PolyMAC_HFV"), Nom("PolyMAC_MPFA") };
30
31 Motcle motlu;
32 Motcles les_motcles(2);
33 {
34 les_motcles[0] = "h_imp";
35 les_motcles[1] = "T_ext";
36 }
37
38 int ind = 0;
39 while (ind < 2)
40 {
41 s >> motlu;
42 int rang = les_motcles.search(motlu);
43
44 switch(rang)
45 {
46 case 0:
47 {
48 s >> h_imp_;
49 break;
50 }
51 case 1:
52 {
53 s >> le_champ_front;
54 break;
55 }
56 default:
57 {
58 Cerr << "Error while reading BC of type Echange_impose " << finl;
59 Cerr << "we expected a keyword among: " << les_motcles << " instead of " << motlu << finl;
60 exit();
61 }
62 }
63
64 ind++;
65
66 }
67
68 return s;
69}
70
71/*! @brief Returns the value of the imposed temperature on the i-th component of the boundary field.
72 *
73 * @param (int i) the index of the boundary field component
74 * @return (double)
75 */
76double Echange_impose_base::T_ext(int i) const
77{
78 if (T_ext().valeurs().size() == 1)
79 return T_ext().valeurs()(0, 0);
80 else if (T_ext().valeurs().dimension(1) == 1)
81 return T_ext().valeurs()(i, 0);
82 else
83 {
84 Cerr << "Echange_impose_base::T_ext error" << finl;
85 assert(0);
86 }
87 exit();
88 return 0.;
89}
90
91/*! @brief Returns the value of the imposed temperature on the (i,j)-th component of the boundary field.
92 *
93 * @param (int i)
94 * @param (int j)
95 * @return (double)
96 */
97double Echange_impose_base::T_ext(int i, int j) const
98{
99 if (T_ext().valeurs().dimension(0) == 1)
100 return T_ext().valeurs()(0, j);
101 else
102 return T_ext().valeurs()(i, j);
103}
104
105/*! @brief Returns the value of the imposed heat exchange coefficient on the i-th component
106 *
107 * of the boundary field.
108 *
109 * @param (int i)
110 * @return (double)
111 */
112double Echange_impose_base::h_imp(int i) const
113{
114 assert (has_h_imp());
115 if (h_imp_->valeurs().size() == 1)
116 return h_imp_->valeurs()(0, 0);
117 else if (h_imp_->valeurs().dimension(1) == 1)
118 return h_imp_->valeurs()(i, 0);
119 else
120 Cerr << "Echange_impose_base::h_imp error" << finl;
121
122 exit();
123 return 0.;
124}
125
126/*! @brief Returns the value of the imposed heat exchange coefficient on the i-th component
127 *
128 * of the boundary field.
129 *
130 * @param (int i)
131 * @param (int j)
132 * @return (double)
133 */
134double Echange_impose_base::h_imp(int i, int j) const
135{
136 assert (has_h_imp());
137 if (h_imp_->valeurs().dimension(0) == 1)
138 return h_imp_->valeurs()(0, j);
139 else
140 return h_imp_->valeurs()(i, j);
141}
142
143/*! @brief Returns the value of the imposed emissivity on the i-th component
144 *
145 * of the boundary field.
146 *
147 * @param (int i)
148 * @return (double)
149 */
151{
152 assert (has_emissivite());
153 if (emissivite_->valeurs().size() == 1)
154 return emissivite_->valeurs()(0, 0);
155 else if (emissivite_->valeurs().dimension(1) == 1)
156 return emissivite_->valeurs()(i, 0);
157 else
158 Cerr << "Echange_impose_base::emissivite error" << finl;
159
160 exit();
161 return 0.;
162}
163
164/*! @brief Returns the value of the imposed emissivity on the i-th component
165 *
166 * of the boundary field.
167 *
168 * @param (int i)
169 * @param (int j)
170 * @return (double)
171 */
172double Echange_impose_base::emissivite(int i, int j) const
173{
174 assert (has_emissivite());
175 if (emissivite_->valeurs().dimension(0) == 1)
176 return emissivite_->valeurs()(0, j);
177 else
178 return emissivite_->valeurs()(i, j);
179}
180
181/*! @brief Performs a time update of the boundary conditions.
182 *
183 * During the first call, initializations are performed:
184 * h_imp(0,0) = (rho(0,0)*Cp(0,0))
185 *
186 * @param (double temps) the time of the update
187 */
189{
191 if (has_h_imp())
192 h_imp_->mettre_a_jour(temps);
193 if (has_emissivite())
194 emissivite_->mettre_a_jour(temps);
195}
196
198{
199 if (has_h_imp())
200 h_imp_->initialiser(temps, domaine_Cl_dis().equation().inconnue()), h_imp_->mettre_a_jour(temps);
201 if (has_emissivite())
202 emissivite_->initialiser(temps, domaine_Cl_dis().equation().inconnue()), emissivite_->mettre_a_jour(temps);
203 return Cond_lim_base::initialiser(temps);
204}
205
206// Added method to avoid operating directly on the champ_front
208{
209 if (has_h_imp())
210 h_imp_->set_temps_defaut(temps);
211 if (has_emissivite())
212 emissivite_->set_temps_defaut(temps);
214}
216{
217 if (has_h_imp())
218 h_imp_->fixer_nb_valeurs_temporelles(nb_cases);
219 if (has_emissivite())
220 emissivite_->fixer_nb_valeurs_temporelles(nb_cases);
222}
223//
225{
226 if (has_h_imp())
227 h_imp_->changer_temps_futur(temps, i);
228 if (has_emissivite())
229 emissivite_->changer_temps_futur(temps, i);
231}
233{
234 if (has_h_imp())
235 h_imp_->avancer(temps);
236 if (has_emissivite())
237 emissivite_->avancer(temps);
238 return Cond_lim_base::avancer(temps);
239}
240
242{
243 if (has_h_imp())
244 h_imp_->reculer(temps);
245 if (has_emissivite())
246 emissivite_->reculer(temps);
247 return Cond_lim_base::reculer(temps);
248}
250{
251 if (has_h_imp())
252 h_imp_->associer_fr_dis_base(fr);
253 if (has_emissivite())
254 emissivite_->associer_fr_dis_base(fr);
256}
257
258const DoubleTab& Echange_impose_base::tab_T_ext(double temps) const
259{
260 if (temps==DMAXFLOAT) temps = le_champ_front->get_temps_defaut();
261 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
262 // ToDo factorize in Champ_front_base::valeurs_face()
263 int size = le_champ_front->valeurs().dimension(0) == 1 ? le_bord.nb_faces_tot() : le_champ_front->valeurs().dimension_tot(0);
264 if (size>0)
265 {
266 bool update = le_champ_front->instationnaire();
267 if (text_.dimension(0) != size)
268 {
269 text_.resize(size, le_champ_front->valeurs().dimension(1));
270 update = true;
271 }
272 update = true; // Provisoire
273 if (update)
274 {
275 int nb_comp = text_.dimension(1);
276 for (int face = 0; face < size; face++)
277 for (int comp = 0; comp < nb_comp; comp++)
278 text_(face, comp) = T_ext(face, comp);
279 }
280 }
281 return text_;
282}
283
284const DoubleTab& Echange_impose_base::tab_h_imp(double temps) const
285{
286 if (temps==DMAXFLOAT) temps = le_champ_front->get_temps_defaut();
287 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
288 // ToDo factorize in Champ_front_base::valeurs_face()
289 int size = le_champ_front->valeurs().dimension(0) == 1 ? le_bord.nb_faces_tot() : le_champ_front->valeurs().dimension_tot(0);
290 if (size>0)
291 {
292 bool update = le_champ_front->instationnaire();
293 if (himp_.dimension(0) != size)
294 {
295 himp_.resize(size, le_champ_front->valeurs().dimension(1));
296 update = true;
297 }
298 update = true; // Provisoire
299 if (update)
300 {
301 int nb_comp = himp_.dimension(1);
302 for (int face = 0; face < size; face++)
303 for (int comp = 0; comp < nb_comp; comp++)
304 himp_(face, comp) = h_imp(face, comp);
305 }
306 }
307 return himp_;
308}
309
310const DoubleTab& Echange_impose_base::tab_emissivite(double temps) const
311{
312 if (temps==DMAXFLOAT) temps = le_champ_front->get_temps_defaut();
313 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
314 // ToDo factorize in Champ_front_base::valeurs_face()
315 int size = le_champ_front->valeurs().dimension(0) == 1 ? le_bord.nb_faces_tot() : le_champ_front->valeurs().dimension_tot(0);
316 if (size>0)
317 {
318 bool update = le_champ_front->instationnaire();
319 if (eps_.dimension(0) != size)
320 {
321 eps_.resize(size, le_champ_front->valeurs().dimension(1));
322 update = true;
323 }
324 update = true; // Provisoire
325 if (update)
326 {
327 int nb_comp = eps_.dimension(1);
328 for (int face = 0; face < size; face++)
329 for (int comp = 0; comp < nb_comp; comp++)
330 eps_(face, comp) = emissivite(face, comp);
331 }
332 }
333 return eps_;
334}
virtual DoubleTab & valeurs() override
Returns the array of field values.
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
std::vector< Nom > supp_discs
virtual void changer_temps_futur(double temps, int i)
Changes the i-th future time of the BC.
virtual void mettre_a_jour(double temps)
Performs a time update of the boundary condition.
virtual void fixer_nb_valeurs_temporelles(int nb_cases)
Called by Conds_lim::completer. Calls cha_front_base::fixer_nb_valeurs_temporelles.
virtual void associer_fr_dis_base(const Frontiere_dis_base &)
Associates the boundary with the object.
virtual int avancer(double temps)
Rotates the wheel of the BC.
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
virtual int reculer(double temps)
Rotates the wheel of the BC.
std::vector< Motcle > app_domains
virtual int initialiser(double temps)
Initialization at the beginning of the calculation.
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
virtual void set_temps_defaut(double temps)
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 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 & h_imp()
virtual Champ_front_base & T_ext()
Returns the T_ext field of temperature imposed at the boundary.
const DoubleTab & tab_h_imp(double temps=DMAXFLOAT) const
int reculer(double temps) override
Rotates the wheel of the BC.
Champ_front_base & emissivite()
const DoubleTab & tab_T_ext(double temps=DMAXFLOAT) const
void mettre_a_jour(double) override
Performs a time update of the boundary conditions.
const DoubleTab & tab_emissivite(double temps=DMAXFLOAT) const
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
class Front_VF
Definition Front_VF.h:36
int nb_faces_tot() const
Definition Front_VF.h:58
class Frontiere_dis_base Class representing a discretized boundary.
static int dimension
Definition Objet_U.h:94
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