TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Fluide_stiffened_gas.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 <Fluide_stiffened_gas.h>
17
18Implemente_instanciable_sans_constructeur(Fluide_stiffened_gas, "StiffenedGas", Fluide_reel_base);
19// XD fluide_stiffened_gas fluide_base fluide_stiffened_gas INHERITS_BRACE Class for Stiffened Gas
20
21Fluide_stiffened_gas::Fluide_stiffened_gas() : pinf_(0.), Cv_(-1.), q_(0.), q_prim_(0.), gamma_(1.4), R_(8.31446261815324), mu__(0.), lambda__(0.) { }
22
23Sortie& Fluide_stiffened_gas::printOn(Sortie& os) const { return os; }
24
26{
28 if (Cv_ == -1.) Cv_ = R_ / (gamma_ - 1.0);
29 return is;
30}
31
33{
35 param.ajouter("gamma",&gamma_); // XD_ADD_P floattant
36 // XD_CONT Heat capacity ratio (Cp/Cv)
37 param.ajouter("pinf",&pinf_); // XD_ADD_P floattant
38 // XD_CONT Stiffened gas pressure constant (if set to zero, the state law becomes identical to that of perfect gases)
39 param.ajouter("mu",&mu__); // XD_ADD_P floattant
40 // XD_CONT Dynamic viscosity
41 param.ajouter("lambda",&lambda__); // XD_ADD_P floattant
42 // XD_CONT Thermal conductivity
43 param.ajouter("Cv",&Cv_); // XD_ADD_P floattant
44 // XD_CONT Thermal capacity at constant volume
45 param.ajouter("q",&q_); // XD_ADD_P floattant
46 // XD_CONT Reference energy
47 param.ajouter("q_prim",&q_prim_); // XD_ADD_P floattant
48 // XD_CONT Model constant
49}
50
51#define ind std::distance(res.begin(), &val)
52
53/* Lois en T */
54void Fluide_stiffened_gas::rho_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
55{
56 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
57 for (auto& val : res) val = (P[ind] + pinf_) / (gamma_ - 1.0) / (T[ind * ncomp + id] + 273.15) / Cv_;
58}
59
60void Fluide_stiffened_gas::dP_rho_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
61{
62 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
63 for (auto& val : res) val = 1.0 / (gamma_ - 1.0) / Cv_ / (T[ind * ncomp + id] + 273.15);
64}
65
66void Fluide_stiffened_gas::dT_rho_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
67{
68 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
69 for (auto& val : res) val = -(P[ind] + pinf_) / (gamma_ - 1.0) / Cv_ / (T[ind * ncomp + id] + 273.15) / (T[ind * ncomp + id] + 273.15);
70}
71
72void Fluide_stiffened_gas::h_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
73{
74 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
75 for (auto& val : res) val = gamma_ * Cv_ * (T[ind * ncomp + id] + 273.15) + q_;
76}
77
78void Fluide_stiffened_gas::dP_h_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
79{
80 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
81 for (auto& val : res) val = 0.;
82}
83
84void Fluide_stiffened_gas::dT_h_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
85{
86 return cp_(T,P,res,ncomp,id);
87}
88
89void Fluide_stiffened_gas::cp_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
90{
91 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
92 for (auto& val : res) val = gamma_ * Cv_;
93}
94
95void Fluide_stiffened_gas::beta_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
96{
97 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
98 for (auto& val : res) val = 1.0 / (T[ind * ncomp + id] + 273.15);
99}
100
101void Fluide_stiffened_gas::mu_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
102{
103 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
104 for (auto& val : res) val = mu__;
105}
106
107void Fluide_stiffened_gas::lambda_(const SpanD T, const SpanD P, SpanD res, int ncomp, int id) const
108{
109 assert((int )T.size() == ncomp * (int )P.size() && (int )T.size() == ncomp * (int )res.size());
110 for (auto& val : res) val = lambda__;
111}
112
113/* Lois en h */
114void Fluide_stiffened_gas::rho_h_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
115{
116 assert((int )H.size() == ncomp * (int )P.size() && (int )H.size() == ncomp * (int )res.size());
117 for (auto& val : res) val = gamma_ * (P[ind] + pinf_) / (gamma_ - 1.0) / H[ind * ncomp + id];
118}
119
120void Fluide_stiffened_gas::dP_rho_h_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
121{
122 assert((int )H.size() == ncomp * (int )P.size() && (int )H.size() == ncomp * (int )res.size());
123 for (auto& val : res) val = gamma_ / (gamma_ - 1.0) / H[ind * ncomp + id];
124}
125
126void Fluide_stiffened_gas::dh_rho_h_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
127{
128 assert((int )H.size() == ncomp * (int )P.size() && (int )H.size() == ncomp * (int )res.size());
129 for (auto& val : res) val = - gamma_ * (P[ind] + pinf_) / (gamma_ - 1.0) / H[ind * ncomp + id] / H[ind * ncomp + id];
130}
131
132void Fluide_stiffened_gas::T_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
133{
134 assert((int )H.size() == ncomp * (int )P.size() && (int )H.size() == ncomp * (int )res.size());
135 for (auto& val : res) val = H[ind * ncomp + id] / gamma_ / Cv_ - 273.15;
136}
137
138void Fluide_stiffened_gas::dP_T_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
139{
140 assert((int )H.size() == ncomp * (int )P.size() && (int )H.size() == ncomp * (int )res.size());
141 for (auto& val : res) val = 0.;
142}
143
144void Fluide_stiffened_gas::dh_T_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
145{
146 assert((int )H.size() == ncomp * (int )P.size() && (int )H.size() == ncomp * (int )res.size());
147 for (auto& val : res) val = 1. / gamma_ / Cv_;
148}
149
150void Fluide_stiffened_gas::cp_h_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
151{
152 cp_(H, P, res, ncomp, id);
153}
154
155void Fluide_stiffened_gas::beta_h_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
156{
157 assert((int )H.size() == ncomp * (int )P.size() && (int )H.size() == ncomp * (int )res.size());
158 for (auto& val : res) val = 1.0 / (H[ind * ncomp + id] / (gamma_ * Cv_));
159}
160
161void Fluide_stiffened_gas::mu_h_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
162{
163 mu_(H, P, res, ncomp, id);
164}
165
166void Fluide_stiffened_gas::lambda_h_(const SpanD H, const SpanD P, SpanD res, int ncomp, int id) const
167{
168 lambda_(H, P, res, ncomp, id);
169}
170
171#undef ind
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Classe Fluide_reel_base Cette classe represente un fluide reel ainsi que.
void set_param(Param &param) const override
: Classe Fluide_stiffened_gas Cette classe represente un milieu reel
void dT_rho_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void lambda_h_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void dh_rho_h_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void mu_h_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void dh_T_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void beta_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void lambda_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void dP_T_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void rho_h_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void h_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void dT_h_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void T_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void cp_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void mu_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void beta_h_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void dP_rho_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void cp_h_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void dP_rho_h_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void rho_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
void set_param(Param &param) const override
void dP_h_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int id=0) const override
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
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
Classe de base des flux de sortie.
Definition Sortie.h:52