TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Convection_Diffusion_Concentration.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 <Convection_Diffusion_Concentration.h>
17#include <Frontiere_dis_base.h>
18#include <Navier_Stokes_std.h>
19#include <Probleme_base.h>
20#include <Discret_Thyd.h>
21#include <Constituant.h>
22#include <EChaine.h>
23#include <Param.h>
24
25Implemente_instanciable_sans_constructeur(Convection_Diffusion_Concentration,"Convection_Diffusion_Concentration",Convection_Diffusion_std);
26// XD convection_diffusion_concentration eqn_base convection_diffusion_concentration INHERITS_BRACE Constituent
27// XD_CONT transport vectorial equation (concentration diffusion convection).
28
30
32
33/*! @brief Verifie si l'equation a une concentration et un constituant associe et appelle Convection_Diffusion_std::readOn(Entree&).
34 *
35 * @param (Entree& is) un flot d'entree
36 * @return (Entree& is) le flot d'entree modifie
37 */
39{
40 assert(la_concentration);
42 if (terme_convectif.op_non_nul())
43 {
44 Nom nom="Convection_";
45 nom+=inconnue().le_nom(); // On ajoute le nom de l'inconnue pour prevoir une equation de scalaires passifs
46 terme_convectif.set_fichier(nom);
47 terme_convectif.set_description((Nom)"Convective mass transfer rate=Integral(-C*u*ndS)[m"+(Nom)(dimension+bidim_axi)+".Mol.s-1]");
48 }
49 else
50 {
51 EChaine ech("{ negligeable }");
52 ech >> terme_convectif;
53 }
54 if (terme_diffusif.op_non_nul())
55 {
56 Nom nom="Diffusion_";
57 nom+=inconnue().le_nom();
58 terme_diffusif.set_fichier(nom);
59 terme_diffusif.set_description((Nom)"Diffusion mass transfer rate=Integral(alpha*grad(C)*ndS) [m"+(Nom)(dimension+bidim_axi)+".Mol.s-1]");
60 }
61 else
62 {
63 EChaine ech("{ negligeable }");
64 ech >> terme_diffusif;
65 }
66 return is;
67}
68
69// renvoit la masse_molaire, celle ci doit avoir ete lue avant
71{
72 assert(masse_molaire_>0);
73 return masse_molaire_;
74}
75
77{
79 param.ajouter_non_std("nom_inconnue",(this)); // XD_ADD_P chaine
80 // XD_CONT Keyword Nom_inconnue will rename the unknown of this equation with the given name. In the postprocessing
81 // XD_CONT part, the concentration field will be accessible with this name. This is usefull if you want to track more
82 // XD_CONT than one concentration (otherwise, only the concentration field in the first concentration equation can be
83 // XD_CONT accessed).
84 param.ajouter_non_std("alias",(this)); // XD_ADD_P chaine
85 // XD_CONT not_set
86 param.ajouter("masse_molaire",&masse_molaire_); // XD_ADD_P floattant
87 // XD_CONT not_set
88 param.ajouter_non_std("is_multi_scalar|is_multi_scalar_diffusion", (this)); // XD_ADD_P rien
89 // XD_CONT Flag to activate the multi_scalar diffusion operator
90}
91
93{
94 if (mot=="nom_inconnue")
95 {
96 Motcle nom; // Question: veut-on le mettre en majuscules ?
97 is >> nom;
98 Cerr << "The unknow of a Convection_Diffusion_Concentration equation is renamed"
99 << "\n Old name : " << inconnue().le_nom()
100 << "\n New name : " << nom << finl;
101 inconnue().nommer(nom);
102 champs_compris_.ajoute_champ(la_concentration);
103 return 1;
104 }
105 else if (mot=="alias")
106 {
107 Motcle nom; // Question: veut-on le mettre en majuscules ?
108 is >> nom;
109 Cerr << "nom_inconnue: On renomme l'equation et son inconnue"
110 << "\n Ancien nom : " << inconnue().le_nom()
111 << "\n Nouveau nom : " << nom << finl;
112 inconnue().nommer(nom);
113 champs_compris_.ajoute_champ(la_concentration);
114 return 1;
115 }
116 else if (mot=="is_multi_scalar" || mot=="is_multi_scalar_diffusion")
117 {
119 return 1;
120 }
121 else
123}
124
125/*! @brief Associe un milieu physique a l'equation, le milieu est en fait caste en Constituant et associe a l'equation.
126 *
127 * @param (Milieu_base& un_milieu)
128 * @throws diffusivite du constituant dans le fluide non definie
129 */
131{
132 const Constituant& un_constituant = ref_cast(Constituant,un_milieu);
133 associer_constituant(un_constituant);
134}
135
140
141/*! @brief Discretise l'equation.
142 *
143 */
145{
146 assert(le_constituant);
147 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
148 Cerr << "Transport concentration(s) equation discretization " << finl;
150 dis.concentration(schema_temps(), domaine_dis(), la_concentration, nb_constituants_);
151 champs_compris_.ajoute_champ(la_concentration);
153}
154
155/*! @brief Renvoie le milieu physique de l'equation.
156 *
157 * (un Constituant upcaste en Milieu_base)
158 * (version const)
159 *
160 * @return (Milieu_base&) le Constituant upcaste en Milieu_base
161 */
166
167
168/*! @brief Renvoie le milieu physique de l'equation.
169 *
170 * (un Constituant upcaste en Milieu_base)
171 *
172 * @return (Milieu_base&) le Constituant upcaste en Milieu_base
173 */
178
179
180/*! @brief Renvoie le constituant (si il a ete associe).
181 *
182 * (version const)
183 *
184 * @return (Constituant&) le constituant associe a l'equation
185 */
187{
188 if(!le_constituant)
189 {
190 Cerr << "You forgot to associate the constituent to the problem named " << probleme().le_nom() << finl;
192 }
193 return le_constituant.valeur();
194}
195
196
197/*! @brief Renvoie le constituant (si il a ete associe).
198 *
199 * @return (Constituant&) le constituant associe a l'equation
200 */
202{
203 if(!le_constituant)
204 {
205 Cerr << "No constituant has been associated "
206 << "with a Convection_Diffusion_Concentration equation." << finl;
207 exit();
208 }
209 return le_constituant.valeur();
210}
211
219
225
226/*! @brief Impression des flux sur les bords sur un flot de sortie.
227 *
228 * Appelle Equation_base::impr(Sortie&)
229 *
230 * @param (Sortie& os) un flot de sortie
231 * @return (int) code de retour propage
232 */
237
238/*! @brief Renvoie 1 si le mot clef specifie designe un type de champ inconnue de l'equation.
239 *
240 * Renvoie 1 si mot = "concentration"
241 * Renvoie 0 sinon
242 * Si la methode renvoie 1 ch_ref fait reference au champ, dont
243 * le type a ete specifie.
244 *
245 * @param (Motcle& mot) le type du champ dont on veut recuperer la reference
246 * @param (OBS_PTR(Champ_base)& ch_ref) la reference sur le champ du type specifie
247 * @return (int) renvoie 1 si le champ a ete trouve, 0 sinon
248 */
249inline int string2int(char* digit, int& result)
250{
251 result = 0;
252
253 //--- Convert each digit char and add into result.
254 while (*digit >= '0' && *digit <='9')
255 {
256 result = (result * 10) + (*digit - '0');
257 digit++;
258 }
259
260 //--- Check that there were no non-digits at end.
261 if (*digit != 0)
262 {
263 return 0;
264 }
265
266 return 1;
267}
268
269
270
271/*! @brief Renvoie le nom du domaine d'application de l'equation.
272 *
273 * Ici "Concentration".
274 *
275 * @return (Motcle&) le nom du domaine d'application de l'equation
276 */
278{
279 static Motcle domaine = "Concentration";
280 return domaine;
281}
282
classe Champ_Don_base classe de base des Champs donnes (non calcules)
classe Constituant Cette classe represente le(s) constituant(s) d'un fluide.
Definition Constituant.h:30
int nb_constituants() const
Definition Constituant.h:57
const Champ_Don_base & diffusivite_constituant() const
Definition Constituant.h:36
void mettre_a_jour(double temps) override
Definition Constituant.h:42
int initialiser(const double temps) override
Definition Constituant.h:51
classe Convection_Diffusion_Concentration Cas particulier de Convection_Diffusion_std
const Constituant & constituant() const
Renvoie le constituant (si il a ete associe).
void associer_constituant(const Constituant &)
Associe un constituant a l'equation.
const Milieu_base & milieu() const override
Renvoie le milieu physique de l'equation.
void discretiser() override
Discretise l'equation.
int preparer_calcul() override
Tout ce qui ne depend pas des autres problemes eventuels.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
const Champ_Inc_base & inconnue() const override
Renvoie le champ inconnue de l'equation: la concentration.
void associer_milieu_base(const Milieu_base &) override
Associe un milieu physique a l'equation, le milieu est en fait caste en Constituant et associe a l'eq...
const Motcle & domaine_application() const override
Renvoie le nom du domaine d'application de l'equation.
int impr(Sortie &os) const override
Impression des flux sur les bords sur un flot de sortie.
const Champ_Don_base & diffusivite_pour_transport() const override
void mettre_a_jour(double) override
La valeur de l'inconnue sur le pas de temps a ete calculee.
classe Convection_Diffusion_std Cette classe est la base des equations modelisant le transport
void set_param(Param &titi) const override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
classe Discret_Thyd Cette classe est la classe de base representant une discretisation
void concentration(const Schema_Temps_base &, Domaine_dis_base &, OWN_PTR(Champ_Inc_base)&, int=1, const Nom nom_champ="concentration") const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Discretisation_base & discretisation() const
Renvoie la discretisation associee a l'equation.
virtual void mettre_a_jour(double temps)
La valeur de l'inconnue sur le pas de temps a ete calculee.
virtual int impr(Sortie &os) const
Imprime les operateurs de l'equation sur un flot de sortie, de facon inconditionnelle.
virtual int preparer_calcul()
Tout ce qui ne depend pas des autres problemes eventuels.
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
Schema_Temps_base & schema_temps()
Renvoie le schema en temps associe a l'equation.
virtual void discretiser()
Discretise l'equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
bool diffusion_multi_scalaire_
const Nom & le_nom() const override
Renvoie le nom du champ.
void nommer(const Nom &) override
Donne un nom au champ.
classe Milieu_base Cette classe est la base de la hierarchie des milieux (physiques)
Definition Milieu_base.h:50
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
friend class Entree
Definition Objet_U.h:76
static int dimension
Definition Objet_U.h:99
friend class Sortie
Definition Objet_U.h:75
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
static int bidim_axi
Definition Objet_U.h:102
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
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
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Probleme_U.h:109
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
double temps_courant() const
Renvoie le temps courant.
Classe de base des flux de sortie.
Definition Sortie.h:52