TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
EDO_Pression_th_VEF_Gaz_Reel.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 <EDO_Pression_th_VEF_Gaz_Reel.h>
17#include <Fluide_Quasi_Compressible.h>
18#include <Neumann_sortie_libre.h>
19#include <Navier_Stokes_std.h>
20#include <Schema_Temps_base.h>
21#include <Domaine_Cl_VEF.h>
22#include <Domaine_VEF.h>
23#include <TRUSTTrav.h>
24
25Implemente_instanciable(EDO_Pression_th_VEF_Gaz_Reel, "EDO_Pression_th_VEF_Gaz_Reel_non", EDO_Pression_th_VEF);
26
27Sortie& EDO_Pression_th_VEF_Gaz_Reel::printOn(Sortie& os) const { return os << que_suis_je() << finl; }
28
30
31/*! @brief Solves the ODE.
32 *
33 * @param (double Pth_n) The pressure at the previous time step
34 * @return (double) The new pressure value
35 */
37{
38 int n_bord;
39 for (n_bord = 0; n_bord < le_dom->nb_front_Cl(); n_bord++)
40 {
41 const Cond_lim& la_cl = le_dom_Cl->les_conditions_limites(n_bord);
42 if (sub_type(Neumann_sortie_libre, la_cl.valeur()))
43 return Pth_n;
44 }
45 double Pth;
46 const DoubleTab& tab_vit = ref_cast(Navier_Stokes_std,le_fluide_->vitesse().equation()).vitesse().valeurs();
47 const DoubleTab& tab_hnp1 = le_fluide_->inco_chaleur().valeurs(); //current
48 const DoubleTab& tab_hn = le_fluide_->inco_chaleur().passe(); //previous
49 const DoubleTab& tab_rho = le_fluide_->masse_volumique().valeurs(); //current
50 const OWN_PTR(Loi_Etat_base)& loi_ = le_fluide_->loi_etat();
51 // const DoubleVect& tab_rhon = loi_->rho_n(); //passe
52
53 int elem, nb_elem = le_dom->nb_elem();
54 double V = 0; // domain measure
55 double Fn = 0; // integral 1 at time step n
56 double Fnp1 = 0; // integral 1 at time step n+1
57 double S = 0; // right-hand side
58
59 double dt = le_fluide_->vitesse().equation().schema_temps().pas_de_temps();
60 double v, al, bn, bnp1, hn, hnp1, divu;
61
62 int i, face, nb_faces = le_dom->nb_faces();
63 // compute T* at elements
64 DoubleTab HstarP0(nb_elem);
65 DoubleTab gradh(nb_faces, dimension);
66 DoubleTab u_gradh(nb_faces);
67 int nfe = le_dom->domaine().nb_faces_elem();
68 const IntTab& elem_faces = le_dom->elem_faces();
69 for (elem = 0; elem < nb_elem; elem++)
70 {
71 HstarP0(elem) = 0;
72 for (face = 0; face < nfe; face++)
73 {
74 hn = tab_hn(elem_faces(elem, face));
75 hnp1 = tab_hnp1(elem_faces(elem, face));
76 HstarP0(elem) += .5 * (hn + hnp1);
77 }
78 HstarP0(elem) /= nfe;
79 }
80 // compute gradT*
81 calculer_grad(HstarP0, gradh);
82 // compute u.gradT*
83 for (face = 0; face < nb_faces; face++)
84 {
85 u_gradh(face) = 0;
86 for (i = 0; i < dimension; i++)
87 {
88 u_gradh(face) += gradh(face, i) * tab_vit(face, i);
89 }
90 }
91 // compute divU in P0 and P1
92 DoubleTrav divUP0(nb_elem);
93 ref_cast(Navier_Stokes_std,le_fluide_->vitesse().equation()).operateur_divergence().calculer(tab_vit, divUP0);
94 DoubleTrav divU(nb_faces);
95 int e0, e1;
96 for (face = 0; face < nb_faces; face++)
97 {
98 e0 = le_dom->face_voisins(face, 0);
99 e1 = le_dom->face_voisins(face, 1);
100 if (e0 != -1 && e1 != -1)
101 {
102 divU(face) = .5 * (divUP0(e0) + divUP0(e1));
103 }
104 else if (e0 != -1)
105 {
106 divU(face) = divUP0(e0);
107 }
108 else
109 {
110 divU(face) = divUP0(e1);
111 }
112 }
113
114 for (face = 0; face < nb_faces; face++)
115 {
116 v = le_dom->volumes_entrelaces(face);
117 V += v;
118 hn = tab_hn(face);
119 hnp1 = tab_hnp1(face);
120 al = loi_->Drho_DT(Pth_n, hn) / loi_->Drho_DP(Pth_n, hn);
121 bn = tab_rho(face) / loi_->Drho_DP(Pth_n, hn);
122 bnp1 = loi_->calculer_masse_volumique(Pth_n, hnp1) / loi_->Drho_DP(Pth_n, hnp1);
123 divu = divU(face);
124
125 S -= v * al * ((hnp1 - hn) / dt + u_gradh(face));
126 Fn += v * bn * divu;
127 Fnp1 += v * bnp1 * divu;
128 }
129
130 Pth = Pth_n + dt / V * (S - Fn);
131 Pth = Pth_n + dt / V * (S - .5 * (Fn + Fnp1));
132 double tmp = 0, r;
133 int k = 0;
134 while (std::fabs(tmp - Pth) / Pth > 1e-9 && k++ < 20)
135 {
136 tmp = Pth;
137 Fnp1 = 0;
138 for (face = 0; face < nb_faces; face++)
139 {
140 v = le_dom->volumes_entrelaces(face);
141 hnp1 = tab_hnp1(face);
142 r = loi_->calculer_masse_volumique(Pth, hnp1);
143 bnp1 = r / loi_->Drho_DP(Pth, hnp1);
144 Fnp1 += v * bnp1 * divU(face);
145 }
146 Pth = Pth_n + dt / V * (S - .5 * (Fn + Fnp1));
147 Cerr << "Thermodynamic pressure recomputed (impl" << k << ") = " << Pth << finl;
148 }
149 return Pth;
150}
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
class EDO_Pression_th_VEF_Gaz_Reel
double resoudre(double) override
Solves the ODE.
class EDO_Pression_th_VEF This class represents the ODE on the pressure associated with the computati...
void calculer_grad(const DoubleTab &, DoubleTab &)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Base class for the state law hierarchy defining a dilatable fluid.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Navier_Stokes_std This class carries the terms of the momentum equation.
virtual const Champ_Inc_base & vitesse() const
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
static int dimension
Definition Objet_U.h:94
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
Base class for output streams.
Definition Sortie.h:52