TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Loi_Etat_Multi_GP_base.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Loi_Etat_Multi_GP_base.h>
17#include <Fluide_Dilatable_base.h>
18#include <Champ_Fonc_Tabule.h>
19#include <Champ_Uniforme.h>
20#include <Champ_Inc_base.h>
21#include <Domaine_VF.h>
22#include <Debog.h>
23
24Implemente_base(Loi_Etat_Multi_GP_base,"Loi_Etat_Multi_Gaz_Parfait_base",Loi_Etat_Melange_GP_base);
25
27{
28 os <<que_suis_je()<< finl;
29 return os;
30}
31
33{
34 return is;
35}
36
37
39{
40 const int num = liste_Y(0)->valeurs().size();
41 masse_mol_mel.resize(num,1);
44}
45
51
52/*! @brief Associates the unknown of each mass fraction equation with the state law.
53 *
54 * @param inconnue The associated unknown field.
55 */
57{
59 inco = inconnue;
60 liste_Y.add(inco);
61}
62
64{
65 Champ_Don_base& Cp = le_fluide->capacite_calorifique();
66 DoubleTab& tab_Cp = Cp.valeurs();
67 calculer_tab_Cp(tab_Cp);
69 Debog::verifier("tab_Cp",tab_Cp);
70}
71
72/*! @brief Computes the thermal conductivity.
73 *
74 */
76{
77 const Champ_Don_base& mu = le_fluide->viscosite_dynamique();
78 const DoubleTab& tab_mu = mu.valeurs();
79 Champ_Don_base& lambda = le_fluide->conductivite();
80 DoubleTab& tab_lambda = lambda.valeurs();
81 const DoubleTab& tab_Cp = le_fluide->capacite_calorifique().valeurs();
82 int i, n = tab_lambda.size();
83
84 //The conductivity is either a uniform field or computed from the dynamic viscosity and Pr
85 if (sub_type(Champ_Fonc_Tabule,lambda))
86 {
87 lambda.mettre_a_jour(temperature_->temps());
88 return;
89 }
90 if (!sub_type(Champ_Uniforme,lambda))
91 {
92 if (sub_type(Champ_Uniforme,mu))
93 {
94 double mu0 = tab_mu(0,0);
95 for (i=0 ; i<n ; i++) tab_lambda(i,0) = mu0 * Cp_ / Pr_;
96 }
97 else
98 for (i=0 ; i<n ; i++) tab_lambda(i,0) = tab_mu(i,0) * tab_Cp(i,0) / Pr_;
99 }
100 tab_lambda.echange_espace_virtuel();
101 Debog::verifier("tab_lambda",tab_lambda);
102}
103
104/*! @brief Computes the thermal diffusivity.
105 *
106 */
108{
109 const Champ_Don_base& lambda = le_fluide->conductivite();
110 const DoubleTab& tab_lambda = lambda.valeurs();
111 Champ_Don_base& alpha=le_fluide->diffusivite();
112 DoubleTab& tab_alpha = le_fluide->diffusivite().valeurs();
113 const DoubleTab& tab_rho = le_fluide->masse_volumique().valeurs();
114 const DoubleTab& tab_Cp = le_fluide->capacite_calorifique().valeurs();
115 int i, n = tab_alpha.size(), isVDF = 0;
116 if (alpha.que_suis_je()=="Champ_Fonc_P0_VDF") isVDF = 1;
117
118 if (isVDF)
119 {
120 if (sub_type(Champ_Uniforme,lambda))
121 {
122 double lambda0 = tab_lambda(0,0);
123 for (i=0 ; i<n ; i++) tab_alpha(i,0) = lambda0 / ( tab_rho(i,0) * tab_Cp(i,0) );
124 }
125 else
126 {
127 for (i=0 ; i<n ; i++) tab_alpha(i,0) = tab_lambda(i,0) / ( tab_rho(i,0) * tab_Cp(i,0) );
128 }
129 }
130 else // VEF
131 {
132 const IntTab& elem_faces=ref_cast(Domaine_VF,le_fluide->vitesse().domaine_dis_base()).elem_faces();
133 double rhoelem, Cpelem;
134 int face, nfe = elem_faces.line_size();
135
136 if (sub_type(Champ_Uniforme,lambda))
137 {
138 double lambda0 = tab_lambda(0,0);
139 for (i=0 ; i<n ; i++)
140 {
141 rhoelem = 0;
142 Cpelem = 0;
143 for (face=0; face<nfe; face++)
144 {
145 rhoelem += tab_rho(elem_faces(i,face),0);
146 Cpelem += tab_Cp(elem_faces(i,face),0);
147 }
148 rhoelem /= nfe;
149 Cpelem /= nfe;
150 tab_alpha(i,0) = lambda0 / ( rhoelem * Cpelem );
151 }
152 }
153 else
154 {
155 for (i=0 ; i<n ; i++)
156 {
157 rhoelem = 0;
158 Cpelem = 0;
159 for (face=0; face<nfe; face++)
160 {
161 rhoelem += tab_rho(elem_faces(i,face),0);
162 Cpelem += tab_Cp(elem_faces(i,face),0);
163 }
164 rhoelem /= nfe;
165 Cpelem /= nfe;
166 tab_alpha(i,0) = tab_lambda(i,0) / ( rhoelem * Cpelem );
167 }
168 }
169 }
170 tab_alpha.echange_espace_virtuel();
171 Debog::verifier("alpha",tab_alpha);
172}
173
174double Loi_Etat_Multi_GP_base::calculer_masse_volumique(double P, double T, double r) const
175{
176 if (inf_ou_egal(T,0))
177 {
178 Cerr << finl << "Warning: Temperature T must be defined in Kelvin." << finl;
179 Cerr << "Check your data file." << finl;
181 }
182 return P / ( r * T );
183}
184
186{
187 Cerr << "You should not call the method Loi_Etat_Multi_GP_base::calculer_masse_volumique(double P, double T) !" << finl;
189 return -1000.;
190}
191
192/*! @brief Computes the dynamic viscosity.
193 *
194 */
196{
197 Champ_Don_base& mu = le_fluide->viscosite_dynamique();
198 if (!sub_type(Champ_Uniforme,mu))
199 {
200 if (sub_type(Champ_Fonc_Tabule,mu)) mu.mettre_a_jour(temperature_->temps());
201 else calculer_mu_wilke();
202 }
203}
204
205void Loi_Etat_Multi_GP_base::calculer_tab_mu(const DoubleTab& mu, int size)
206{
207 // Dynamic viscosity is on elem
208 DoubleTab& tab_mu = le_fluide->viscosite_dynamique().valeurs();
209 const int nb_elem = tab_mu.size();
210 if (nb_elem==size) // VDF
211 {
212 for (int elem=0; elem < nb_elem; elem++) tab_mu(elem,0) = mu(elem);
213 }
214 else // VEF (average on elem from values on face);
215 {
216 const IntTab& elem_faces=ref_cast(Domaine_VF,le_fluide->vitesse().domaine_dis_base()).elem_faces();
217 const int nfe = elem_faces.line_size();
218 tab_mu = 0;
219 for (int elem=0; elem<nb_elem; elem++)
220 {
221 for (int face = 0; face < nfe; face++) tab_mu(elem,0) += mu(elem_faces(elem, face));
222
223 tab_mu(elem,0) /= nfe;
224 }
225 }
226 tab_mu.echange_espace_virtuel();
227 Debog::verifier("tab_mu", tab_mu);
228}
class Champ_Don_base base class of Given Fields (not calculated)
void mettre_a_jour(double temps) override
Time update.
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
Class Champ_Fonc_Tabule Derived class of Champ_Fonc_base representing.
Class Champ_Inc_base.
Champ_Uniforme Represents a field that is constant in space and time.
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
class Domaine_VF
Definition Domaine_VF.h:44
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
State law class for a mixture of ideal gases.
Base state law class for a mixture of ideal gases.
void calculer_masse_volumique() override=0
Recomputes the density (masse volumique).
virtual void calculer_mu_wilke()=0
void calculer_lambda() override
Computes the thermal conductivity.
void calculer_mu() override
Computes the dynamic viscosity.
void calculer_tab_mu(const DoubleTab &mu, int size)
void calculer_Cp() override
Computes Cp. Does nothing: Cp is constant.
void initialiser_inco_ch() override
Initialises the heat equation unknown; sets rho arrays and updates density.
virtual void associer_inconnue(const Champ_Inc_base &inconnue)
Associates the unknown of each mass fraction equation with the state law.
void calculer_alpha() override
Computes the thermal diffusivity.
virtual void calculer_tab_Cp(DoubleTab &cp) const =0
virtual void initialiser_inco_ch()
Initialises the heat equation unknown; sets rho arrays and updates density.
OBS_PTR(Fluide_Dilatable_base) le_fluide
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
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
_SIZE_ size() const
Definition TRUSTVect.tpp:45
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")