TrioCFD 1.9.9_beta
TrioCFD documentation
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 Verifies that the equation has an associated concentration and constituent, then calls Convection_Diffusion_std::readOn(Entree&).
34 *
35 * @param is an input stream
36 * @return the modified input stream
37 */
39{
40 assert(la_concentration);
42 if (terme_convectif.op_non_nul())
43 {
44 Nom nom="Convection_";
45 nom+=inconnue().le_nom(); // append the unknown name to plan for passive scalar equations
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// returns the molar mass; it must have been read beforehand
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: should it be uppercased?
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: should it be uppercased?
108 is >> nom;
109 Cerr << "nom_inconnue: Renaming equation and its unknown"
110 << "\n Old name : " << inconnue().le_nom()
111 << "\n New name : " << 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 Associates a physical medium to the equation; the medium is cast to Constituant and associated with the equation.
126 *
127 * @param un_milieu the physical medium to associate
128 * @throws diffusivity of the constituent in the fluid not defined
129 */
131{
132 const Constituant& un_constituant = ref_cast(Constituant,un_milieu);
133 associer_constituant(un_constituant);
134}
135
140
141/*! @brief Discretizes the 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 Returns the physical medium of the equation.
156 *
157 * (a Constituant upcast to Milieu_base)
158 * (const version)
159 *
160 * @return the Constituant upcast to Milieu_base
161 */
166
167
168/*! @brief Returns the physical medium of the equation.
169 *
170 * (a Constituant upcast to Milieu_base)
171 *
172 * @return the Constituant upcast to Milieu_base
173 */
178
179
180/*! @brief Returns the constituent (if one has been associated).
181 *
182 * (const version)
183 *
184 * @return the constituent associated with the 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 Returns the constituent (if one has been associated).
198 *
199 * @return the constituent associated with the 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 Prints the boundary fluxes to an output stream.
227 *
228 * Calls Equation_base::impr(Sortie&)
229 *
230 * @param os an output stream
231 * @return propagated return code
232 */
237
238/*! @brief Returns 1 if the specified keyword designates an unknown field type of the equation.
239 *
240 * Returns 1 if mot = "concentration"
241 * Returns 0 otherwise.
242 * If the method returns 1, ch_ref holds a reference to the field of the specified type.
243 *
244 * @param mot the field type keyword to look up
245 * @param ch_ref reference to the field of the specified type
246 * @return 1 if the field was found, 0 otherwise
247 */
248inline int string2int(char* digit, int& result)
249{
250 result = 0;
251
252 //--- Convert each digit char and add into result.
253 while (*digit >= '0' && *digit <='9')
254 {
255 result = (result * 10) + (*digit - '0');
256 digit++;
257 }
258
259 //--- Check that there were no non-digits at end.
260 if (*digit != 0)
261 {
262 return 0;
263 }
264
265 return 1;
266}
267
268
269
270/*! @brief Returns the name of the application domain of the equation.
271 *
272 * Here "Concentration".
273 *
274 * @return the name of the application domain of the equation
275 */
277{
278 static Motcle domaine = "Concentration";
279 return domaine;
280}
281
class Champ_Don_base base class of Given Fields (not calculated)
Represents the constituent(s) of a fluid.
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
Convection_Diffusion_Concentration Special case of Convection_Diffusion_std.
const Constituant & constituant() const
Returns the constituent (if one has been associated).
void associer_constituant(const Constituant &)
Associates a constituent to the equation.
const Milieu_base & milieu() const override
Returns the physical medium of the equation.
void discretiser() override
Discretizes the equation.
int preparer_calcul() override
Everything that does not depend on other possible problems.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
const Champ_Inc_base & inconnue() const override
Returns the unknown field of the equation: the concentration.
void associer_milieu_base(const Milieu_base &) override
Associates a physical medium to the equation; the medium is cast to Constituant and associated with t...
const Motcle & domaine_application() const override
Returns the name of the application domain of the equation.
int impr(Sortie &os) const override
Prints the boundary fluxes to an output stream.
const Champ_Don_base & diffusivite_pour_transport() const override
void mettre_a_jour(double) override
The value of the unknown at the time step has been calculated.
Convection_Diffusion_std This class is the base for equations modelling the transport.
void set_param(Param &titi) const override
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
class Discret_Thyd This class is the base class representing a discretization
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
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.
virtual int preparer_calcul()
Everything that does not depend on other possible problems.
Probleme_base & probleme()
Returns the problem associated with the equation.
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.
bool diffusion_multi_scalaire_
const Nom & le_nom() const override
Returns the name of the field.
void nommer(const Nom &) override
Gives a name to the field.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
A character string (Nom) in uppercase.
Definition Motcle.h:26
friend class Entree
Definition Objet_U.h:71
static int dimension
Definition Objet_U.h:94
friend class Sortie
Definition Objet_U.h:70
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
static int bidim_axi
Definition Objet_U.h:97
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
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
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_courant() const
Returns the current time.
Base class for output streams.
Definition Sortie.h:52