TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Convection_Diffusion_Turbulent.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 <Convection_Diffusion_Turbulent.h>
17#include <Modele_turbulence_scal_base.h>
18#include <Operateur_Diff_base.h>
19#include <Discretisation_base.h>
20#include <Schema_Temps_base.h>
21#include <Champ_Uniforme.h>
22#include <Operateur_Diff.h>
23#include <Probleme_base.h>
24
25#include <Domaine.h>
26#include <Avanc.h>
27
29{
30 Cerr << "Reading and typing of the turbulence model : ";
31
32 Motcle typ;
33 is >> typ;
34
35 Motcle nom1("Modele_turbulence_scal_");
36 nom1 += typ;
37
38 if (typ == "sous_maille_dyn")
39 {
40 nom1 += "_";
41 Nom disc = eqn.discretisation().que_suis_je();
42 if (disc == "VEFPreP1B") disc = "VEF";
43 nom1 += disc;
44 }
45 Cerr << nom1 << finl;
46
47 le_modele_turbulence.typer(nom1);
48 le_modele_turbulence->associer_eqn(eqn);
49 le_modele_turbulence->associer(eqn.domaine_dis(), eqn.domaine_Cl_dis());
50
51 is >> le_modele_turbulence.valeur(); // On lit :-)
52
53 le_modele_turbulence->discretiser();
54
55 return is;
56}
57
59{
60 Motcle accfermee = "}";
61 Nom type = "Op_Dift_";
62
63 Motcle motbidon;
64 is >> motbidon;
65 assert(motbidon == "{");
66 is >> motbidon;
67 if (motbidon == "negligeable")
68 {
69 type += motbidon;
70 is >> motbidon;
71
72 terme_diffusif.typer(type);
73 terme_diffusif.l_op_base().associer_eqn(eqn);
74 Cerr << terme_diffusif->que_suis_je() << finl;
75 terme_diffusif->associer_diffusivite(terme_diffusif.diffusivite());
76
77 assert(motbidon == accfermee);
78 }
79 else if (motbidon == "stab")
80 {
81 Nom disc = eqn.discretisation().que_suis_je();
82 if (disc == "VEFPreP1B")
83 disc = "VEF";
84
85 Nom nb_inc;
86 nb_inc = "_";
87 if ((terme_diffusif.diffusivite().nb_comp() != 1) && ((disc == "VDF")))
88 nb_inc = "_Multi_inco_";
89
90 Nom type_inco = eqn.inconnue().que_suis_je();
91
92 type += disc;
93 type += nb_inc;
94 type += (type_inco.suffix("Champ_"));
95 if (Objet_U::axi)
96 type += "_Axi";
97 type += "_stab";
98
99 terme_diffusif.typer(type);
100 terme_diffusif.l_op_base().associer_eqn(eqn);
101 terme_diffusif->associer_diffusivite(terme_diffusif.diffusivite());
102 is >> terme_diffusif.valeur();
103 }
104 else
105 {
106 Nom disc = eqn.discretisation().que_suis_je();
107 // the C_D_Turb_T operators are common to VEF and VEFP1B discretizations
108 if (disc == "VEFPreP1B")
109 disc = "VEF";
110 type += disc;
111
112 Nom nb_inc;
113 nb_inc = "_";
114 if ((terme_diffusif.diffusivite().nb_comp() != 1) && ((disc == "VDF")))
115 nb_inc = "_Multi_inco_";
116
117 type += nb_inc;
118
119 Nom type_inco = eqn.inconnue().que_suis_je();
120 if (type_inco == "Champ_Q1_EF")
121 type += "Q1";
122 else
123 type += (type_inco.suffix("Champ_"));
124
125 if (Objet_U::axi)
126 type += "_Axi";
127
128 if (motbidon != accfermee)
129 type += Nom("_") + motbidon, is >> motbidon;
130 assert(motbidon == accfermee);
131
132 terme_diffusif.typer(type);
133 terme_diffusif.l_op_base().associer_eqn(eqn);
134 Cerr << terme_diffusif->que_suis_je() << finl;
135 terme_diffusif->associer_diffusivite(terme_diffusif.diffusivite());
136 }
137 return is;
138}
139
140/*! @brief Completes the turbulence model.
141 *
142 */
144{
145 le_modele_turbulence->completer();
146 le_modele_turbulence->loi_paroi().completer();
147}
148
150{
151 return le_modele_turbulence->initTimeStep(dt);
152}
153
154/*! @brief Prepares the computation.
155 *
156 * @return Always returns 1.
157 */
159{
160 le_modele_turbulence->preparer_calcul();
161 return 1;
162}
163
164/*! @brief for PDI IO: retrieve name, type and dimensions of the fields to save/restore
165 *
166 */
168{
169 std::vector<YAML_data> data = le_modele_turbulence->data_a_sauvegarder();
170 return data;
171}
172
173/*! @brief Simple call to Modele_turbulence_scal_base::sauvegarder(Sortie&) on the turbulence member.
174 *
175 * Saves the turbulence model to an output stream.
176 *
177 * @param os Output stream.
178 * @return Return code propagated from the turbulence model.
179 */
181{
182 return le_modele_turbulence->sauvegarder(os);
183}
184
185/*! @brief Restores from a checkpoint via an input stream.
186 *
187 * @param is Input stream.
188 * @return Always returns 1.
189 * @throws If end of file is reached during the restore.
190 */
192{
193 le_modele_turbulence->reprendre(is);
194 return 1;
195}
196
197/*! @brief Time update of the turbulence model.
198 *
199 * @param temps Current time.
200 */
202{
203 le_modele_turbulence->mettre_a_jour(temps);
204}
int preparer_calcul()
Prepares the computation.
void completer()
Completes the turbulence model.
Entree & lire_op_diff_turbulent(Entree &, const Equation_base &, Operateur_Diff &)
Entree & lire_modele(Entree &, const Equation_base &)
virtual int sauvegarder(Sortie &) const
Simple call to Modele_turbulence_scal_base::sauvegarder(Sortie&) on the turbulence member.
virtual void mettre_a_jour(double)
Time update of the turbulence model.
virtual int reprendre(Entree &)
Restores from a checkpoint via an input stream.
virtual std::vector< YAML_data > data_a_sauvegarder() const
for PDI IO: retrieve name, type and dimensions of the fields to save/restore
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....
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual const Champ_Inc_base & inconnue() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
virtual int nb_comp() const
Definition Field_base.h:56
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Nom & suffix(const char *const)
Suffix extraction: Nom x("azerty");.
Definition Nom.cpp:266
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
static int axi
Definition Objet_U.h:96
Operateur_Diff Generic class of the hierarchy of operators representing a diffusion.
const Champ_base & diffusivite() const
Returns the field representing the diffusivity.
void associer_diffusivite(const Champ_base &)
Associates the diffusivity to the operator.
void typer() override
Types the operator: types as "Op_Diff_"+discretisation() + ("_" or "_Multi_inco_") + inconnue()....
Operateur_base & l_op_base() override
Returns the underlying object upcast to Operateur_base.
void associer_eqn(const Equation_base &)
Associates an equation with the operator.
Base class for output streams.
Definition Sortie.h:52