TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Convection_Diffusion_std.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_std.h>
17#include <Probleme_base.h>
18#include <Milieu_base.h>
19#include <Param.h>
20
21Implemente_base(Convection_Diffusion_std,"Convection_Diffusion_standard",Equation_base);
22
23/*! @brief Simple call to Equation_base::printOn(Sortie&)
24 *
25 * @param (Sortie& is) output stream
26 * @return (Sortie&) the modified output stream
27 */
29{
30 return Equation_base::printOn(is);
31}
32
33
34/*! @brief cf Equation_base::readOn(Entree&)
35 *
36 * @param (Entree& is) input stream
37 * @return (Entree&) the modified input stream
38 * @throws diffusive term not specified
39 * @throws convective term not specified
40 */
42{
45 terme_convectif->set_transporting_velocity_phase_index(idx_phase_transportante_);
46 return is;
47}
48
50{
52 param.ajouter_non_std("diffusion",(this));
53 param.ajouter_non_std("convection",(this));
54 param.ajouter("phase_transportante", &idx_phase_transportante_);
55}
56
57
59{
60 if (mot=="diffusion")
61 {
62 Cerr << "Reading and typing of the diffusion operator : " << finl;
63 terme_diffusif.associer_diffusivite(diffusivite_pour_transport());
64 is >> terme_diffusif;
65 terme_diffusif.associer_diffusivite_pour_pas_de_temps(diffusivite_pour_pas_de_temps());
66 return 1;
67 }
68 else if (mot=="convection")
69 {
70 Cerr << "Reading and typing of the convection operator : " << finl;
71 const Champ_base& ch_vitesse_transportante = vitesse_pour_transport();
72 associer_vitesse(ch_vitesse_transportante);
73 terme_convectif.associer_vitesse(ch_vitesse_transportante);
74 is >> terme_convectif;
75 return 1;
76 }
77 else
79}
80/*! @brief Returns the number of operators in the equation: 2 for a diffusion equation.
81 *
82 * @return (int) the number of operators in the equation
83 */
85{
86 return 2;
87}
88
89/*! @brief Returns the operator at the given index: returns terme_diffusif if i = 0,
90 *
91 * returns terme_convectif if i = 1,
92 * exits if i > 1.
93 * (const version)
94 *
95 * @param (int i) the index of the operator to return
96 * @return (Operateur&) the specified operator
97 * @throws the equation has no more than 2 operators
98 */
100{
101 switch(i)
102 {
103 case 0:
104 return terme_diffusif;
105 case 1:
106 return terme_convectif;
107 default :
108 Cerr << "Error for Convection_Diffusion_std::operateur(int i)" << finl;
109 Cerr << "Convection_Diffusion_std has " << nombre_d_operateurs() <<" operators "<<finl;
110 Cerr << "and you are trying to access the " << i <<" th one."<< finl;
111 exit();
112 }
113 // For compilers!
114 return terme_diffusif;
115}
116
117/*! @brief Returns the operator at the given index: returns terme_diffusif if i = 0,
118 *
119 * returns terme_convectif if i = 1,
120 * exits if i > 1.
121 *
122 * @param (int i) the index of the operator to return
123 * @return (Operateur&) the specified operator
124 * @throws the equation has no more than 2 operators
125 */
127{
128 switch(i)
129 {
130 case 0:
131 return terme_diffusif;
132 case 1:
133 return terme_convectif;
134 default :
135 Cerr << "Error for Convection_Diffusion_std::operateur(int i)" << finl;
136 Cerr << "Convection_Diffusion_std has " << nombre_d_operateurs() <<" operators "<<finl;
137 Cerr << "and you are trying to access the " << i <<" th one."<< finl;
138 exit();
139 }
140 // For compilers!
141 return terme_diffusif;
142}
143
148
153
155{
156 return probleme().get_champ("vitesse");
157}
158
159// E. Saikali: useful methods for virtual inheritance (diamond inheritance)
168
173
class Champ_Don_base base class of Given Fields (not calculated)
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
Convection_Diffusion_std This class is the base for equations modelling the transport.
std::vector< YAML_data > data_a_sauvegarder_base() const
void associer_vitesse(const Champ_base &)
Associates the transporting velocity with the equation.
virtual const Champ_Don_base & diffusivite_pour_transport() const
virtual const Champ_base & diffusivite_pour_pas_de_temps() const
const Operateur & operateur(int) const override
Returns the operator at the given index: returns terme_diffusif if i = 0,.
void set_param(Param &titi) const override
int nombre_d_operateurs() const override
Returns the number of operators in the equation: 2 for a diffusion equation.
virtual const Champ_base & vitesse_pour_transport() const
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
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
int reprendre(Entree &) override
We resume the unknown from an input stream.
virtual const Milieu_base & milieu() const =0
virtual std::vector< YAML_data > data_a_sauvegarder() const
for PDI IO: retrieve name, type and dimensions of the data to save/restore. This has to be overrode f...
int sauvegarder(Sortie &) const override
We save the unknown, then the source terms to an output stream.
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.
virtual const Champ_Don_base & diffusivite() const
Returns the diffusivity of the medium (const version).
A character string (Nom) in uppercase.
Definition Motcle.h:26
friend class Entree
Definition Objet_U.h:71
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
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(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 Champ_base & get_champ(const Motcle &nom) const override
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