TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Conduction.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 <Frontiere_dis_base.h>
17#include <Discret_Thermique.h>
18#include <Probleme_base.h>
19#include <Conduction.h>
20#include <Solide.h>
21#include <Param.h>
22
23Implemente_instanciable(Conduction,"Conduction",Equation_base);
24// XD Conduction eqn_base Conduction INHERITS_BRACE Heat equation.
25
27{
28 return s << que_suis_je() << finl;
29}
30
32{
34 terme_diffusif.set_fichier("Diffusion_chaleur");
35 terme_diffusif.set_description((Nom)"Conduction heat transfer rate=Integral(lambda*grad(T)*ndS) [W] if SI units used");
36 return is;
37}
38
39void Conduction::set_param(Param& param) const
40{
42 param.ajouter_non_std("diffusion",(this));
43 param.ajouter_condition("is_read_diffusion","The diffusion operator must be read, select negligeable type if you want to neglect it.");
44 param.ajouter_non_std("Traitement_particulier",(this));
45}
46
47// Overrides the base Conduction::lire_motcle_non_standard()!
49{
50 //Motcle motlu;
51 if (mot=="diffusion")
52 {
53 Cerr << "Reading and typing of the diffusion operator : " << finl;
54
55 terme_diffusif.associer_diffusivite(diffusivite_pour_transport());
56 is >> terme_diffusif;
57 // the dt_stab field is the same as the operator field. We always use diffusivite()
58 // as in the Conduction case
59 terme_diffusif.associer_diffusivite_pour_pas_de_temps(milieu().diffusivite());
60 solveur_masse->set_name_of_coefficient_temporel("rho_cp_comme_T");
61
62 return 1;
63 }
64 else if (mot=="Traitement_particulier")
65 {
66 Cerr << "Reading and typing of the Traitement_particulier object : " << finl;
67 Nom type="Traitement_particulier_";
68 Motcle motbidon;
69 is >> motbidon;
70 if (motbidon == "{")
71 {
72 Motcle le_cas;
73 is >> le_cas;
74 if (le_cas == "}")
75 le_cas ="";
76 else
77 {
78 type+= le_cas;
79 type+= "_";
80 }
82 if (discr == "VEFPreP1B")
83 discr = "VEF";
84 type+=discr;
85 Cerr << type << finl;
86 le_traitement_particulier.typer(type);
87 le_traitement_particulier->associer_eqn(*this);
88 le_traitement_particulier->lire(is);
89 le_traitement_particulier->preparer_calcul_particulier();
90 return 1;
91 }
92 else
93 {
94 Cerr << "Error while reading Traitement_particulier" << finl;
95 Cerr << "A { is expected." << finl;
96 exit();
97 return -1;
98 }
99 }
100 else
102}
103
104// returns the *conductivity* rather than the diffusivity as in Conduction
109
111{
112 return terme_diffusif.diffusivite();
113}
114
115/*! @brief Associates a physical medium with the equation; the medium is cast to Solide.
116 *
117 * @param le_milieu Reference to the physical medium (cast to Solide internally).
118 */
120{
121 associer_solide(ref_cast(Solide,le_milieu));
122}
123
124/*! @brief Associates the solid medium with the equation.
125 *
126 * @param un_solide The solid medium to associate with the equation.
127 */
129{
130 le_solide = un_solide;
131}
132
133/*! @brief Returns the number of operators in the equation. For the standard conduction equation this is always 1.
134 *
135 * @return Number of operators in the equation.
136 */
138{
139 return 1;
140}
141
142/*! @brief Returns the operator at the given index in the equation (const version).
143 *
144 * Returns terme_diffusif when i=0; exits when i>0.
145 *
146 * @param i Index of the operator to return.
147 * @return The operator at the given index (only terme_diffusif is available).
148 * @throws The standard conduction equation contains only one operator.
149 */
151{
152 if (i == 0)
153 return terme_diffusif;
154 else
155 {
156 Cerr << "Conduction::operateur("<<i<<") !! " << finl;
157 Cerr << "Equation Conduction has only one operator." << finl;
158 exit();
159 }
160 // Required to satisfy compilers!!
161 return terme_diffusif;
162}
163
164/*! @brief Returns the operator at the given index in the equation.
165 *
166 * Returns terme_diffusif when i=0; exits when i>0.
167 *
168 * @param i Index of the operator to return.
169 * @return The operator at the given index (only terme_diffusif is available).
170 * @throws The standard conduction equation contains only one operator.
171 */
173{
174 if (i == 0)
175 return terme_diffusif;
176 else
177 {
178 Cerr << "Conduction::operateur("<<i<<") !! " << finl;
179 Cerr << "Equation Conduction has only one operator." << finl;
180 exit();
181 }
182 // Required to satisfy compilers!!
183 return terme_diffusif;
184}
185
186/*! @brief Discretises the equation.
187 *
188 */
190{
191 const Discret_Thermique& dis=ref_cast(Discret_Thermique, discretisation());
192 Cerr << "Conduction equation discretization" << finl;
193 dis.temperature(schema_temps(), domaine_dis(), la_temperature);
194 champs_compris_.ajoute_champ(la_temperature);
196}
197
198
199/*! @brief Returns the physical medium associated with the equation (const version).
200 *
201 * Here Solide is upcast to Milieu_base.
202 *
203 * @return The physical medium associated with the equation (Solide upcast to Milieu_base).
204 */
206{
207 return solide();
208}
209
210/*! @brief Returns the physical medium associated with the equation.
211 *
212 * Here Solide is upcast to Milieu_base.
213 *
214 * @return The physical medium associated with the equation (Solide upcast to Milieu_base).
215 */
217{
218 return solide();
219}
220
221/*! @brief Returns the solid medium associated with the equation (const version).
222 *
223 * @return The solid medium associated with the equation.
224 * @throws No solid medium has been associated with the equation.
225 */
227{
228 if(!le_solide)
229 {
230 Cerr << "You forgot to associate the solid to the problem named " << probleme().le_nom() << finl;
232 }
233 return le_solide.valeur();
234}
235
237{
238 if (motlu == "temperature_paroi" || motlu == "wall_temperature")
239 {
240 if (!temperature_paroi_)
241 {
242 const Discret_Thermique& dis = ref_cast(Discret_Thermique, discretisation());
243 dis.t_paroi(domaine_dis(), domaine_Cl_dis(), la_temperature, temperature_paroi_);
244 champs_compris_.ajoute_champ(temperature_paroi_);
245 }
246 }
247
249}
250
251bool Conduction::has_champ(const Motcle& nom, OBS_PTR(Champ_base) &ref_champ) const
252{
253 if (nom == "temperature_paroi" || nom == "wall_temperature")
254 {
255 ref_champ = Conduction::get_champ(nom);
256 return true;
257 }
258
259 if (Equation_base::has_champ(nom, ref_champ))
260 return true;
261
262 if (le_traitement_particulier)
263 if (le_traitement_particulier->has_champ(nom, ref_champ))
264 return true;
265
266 return false; /* nothing found */
267}
268
269bool Conduction::has_champ(const Motcle& nom) const
270{
271 if (nom == "temperature_paroi" || nom == "wall_temperature")
272 return true;
273
275 return true;
276
277 if (le_traitement_particulier)
278 if (le_traitement_particulier->has_champ(nom))
279 return true;
280
281 return false; /* nothing found */
282}
283
285{
286 OBS_PTR(Champ_base) ref_champ;
287
288 if (nom == "temperature_paroi" || nom == "wall_temperature")
289 {
290 double temps_init = schema_temps().temps_init();
291 Champ_Fonc_base& ch_tp = ref_cast_non_const(Champ_Fonc_base, temperature_paroi_.valeur());
292 if (((ch_tp.temps() != la_temperature->temps()) || (ch_tp.temps() == temps_init)) && ((la_temperature->mon_equation_non_nul())))
293 ch_tp.mettre_a_jour(la_temperature->temps());
294 return champs_compris_.get_champ(nom);
295 }
296
297 if (Equation_base::has_champ(nom, ref_champ))
298 return ref_champ;
299
300 if (le_traitement_particulier)
301 if (le_traitement_particulier->has_champ(nom, ref_champ))
302 return ref_champ;
303
304 throw std::runtime_error(std::string("Field ") + nom.getString() + std::string(" not found !"));
305}
306
308{
310
311 Noms noms_compris = champs_compris_.liste_noms_compris();
312 noms_compris.add("TEMPERATURE_PAROI");
313 noms_compris.add("WALL_TEMPERATURE");
314
315 if (opt == DESCRIPTION)
316 Cerr << "Conduction : " << noms_compris << finl;
317 else
318 nom.add(noms_compris);
319
320 if (le_traitement_particulier)
321 le_traitement_particulier->get_noms_champs_postraitables(nom, opt);
322}
323
324/*! @brief Returns the solid medium associated with the equation.
325 *
326 * @return The solid medium associated with the equation.
327 * @throws No solid medium has been associated with the equation.
328 */
330{
331 if(!le_solide)
332 {
333 Cerr << "A solide medium has not been associated to a Conduction equation"<<finl;
334 exit();
335 }
336 return le_solide.valeur();
337}
338
339/*! @brief Prints the diffusive term to an output stream.
340 *
341 * @param os An output stream.
342 * @return Always returns 1.
343 */
345{
346 return Equation_base::impr(os);
347}
348
349/*! @brief Returns the application domain name of the equation.
350 *
351 * Here "Thermique".
352 *
353 * @return The application domain name of the equation.
354 */
356{
357 static Motcle domaine = "Thermique";
358 return domaine;
359}
360
362{
364
365 if (le_traitement_particulier)
366 le_traitement_particulier->post_traitement_particulier();
367}
class Champ_Don_base base class of Given Fields (not calculated)
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
void mettre_a_jour(double temps) override
Time update of the field.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
double temps() const
Returns the time of the field.
Class Conduction: represents the temperature evolution equation.
Definition Conduction.h:41
int nombre_d_operateurs() const override
Returns the number of operators in the equation. For the standard conduction equation this is always ...
void set_param(Param &) const override
void mettre_a_jour(double temps) override
The value of the unknown at the time step has been calculated.
void creer_champ(const Motcle &motlu) override
const Solide & solide() const
Returns the solid medium associated with the equation (const version).
void associer_solide(const Solide &)
Associates the solid medium with the equation.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
virtual const Champ_Don_base & diffusivite_pour_transport() const
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
void associer_milieu_base(const Milieu_base &) override
Associates a physical medium with the equation; the medium is cast to Solide.
int impr(Sortie &os) const override
Prints the diffusive term to an output stream.
virtual const Champ_base & diffusivite_pour_pas_de_temps() const
const Champ_base & get_champ(const Motcle &nom) const override
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
const Motcle & domaine_application() const override
Returns the application domain name of the equation.
const Operateur & operateur(int) const override
Returns the operator at the given index in the equation (const version).
void discretiser() override
Discretises the equation.
const Milieu_base & milieu() const override
Returns the physical medium associated with the equation (const version).
Class Discret_Thermique: base class representing a spatial discretisation applied to thermal problems...
void temperature(const Schema_Temps_base &, Domaine_dis_base &, OWN_PTR(Champ_Inc_base)&, int nb_comp=1) const
virtual void t_paroi(const Domaine_dis_base &z, const Domaine_Cl_dis_base &zcl, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&ch) const
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 void set_param(Param &titi) const override
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
virtual int impr(Sortie &os) const
Prints the equation operators to an output stream, unconditionally.
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void creer_champ(const Motcle &motlu) override
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual void discretiser()
Discretizes the equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
virtual const Champ_Don_base & conductivite() const
Returns the conductivity of the medium (const version).
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
An array of character strings (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:71
friend class Sortie
Definition Objet_U.h:70
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
class Operateur Generic class of the operator hierarchy.
Definition Operateur.h:39
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter_condition(const char *condition, const char *message, const char *name=0)
Declare a post-read logical condition that must hold on the parameter values.
Definition Param.cpp:496
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
double temps_init() const
Returns the initial time.
Class Solide: represents a solid medium and its physical properties.
Definition Solide.h:26
Base class for output streams.
Definition Sortie.h:52