TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
EDO_Pression_th_VDF_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_VDF_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_VDF.h>
22#include <Domaine_VDF.h>
23#include <TRUSTTrav.h>
24
25Implemente_instanciable(EDO_Pression_th_VDF_Gaz_Reel, "EDO_Pression_th_VDF_Gaz_Reel", EDO_Pression_th_VDF);
26
27Sortie& EDO_Pression_th_VDF_Gaz_Reel::printOn(Sortie& os) const { return os << que_suis_je() << finl; }
28
30
31/*! @brief Solves the ODE for the thermodynamic pressure.
32 *
33 * @param Pth_n pressure at the previous time step
34 * @return new value of the thermodynamic pressure
35 */
37{
38 const Domaine_VDF& dom = ref_cast(Domaine_VDF, le_dom.valeur());
39 int n_bord;
40 for (n_bord = 0; n_bord < dom.nb_front_Cl(); n_bord++)
41 {
42 const Cond_lim& la_cl = le_dom_Cl->les_conditions_limites(n_bord);
43 if (sub_type(Neumann_sortie_libre, la_cl.valeur()))
44 return Pth_n;
45 }
46
47 double Pth;
48 const DoubleTab& tab_vit = ref_cast(Navier_Stokes_std,le_fluide_->vitesse().equation()).vitesse().valeurs();
49 const DoubleTab& tab_hnp1 = le_fluide_->inco_chaleur().valeurs(); //current
50 const DoubleTab& tab_hn = le_fluide_->inco_chaleur().passe(); //previous
51 const DoubleTab& tab_rho = le_fluide_->masse_volumique().valeurs(); //current
52 const OWN_PTR(Loi_Etat_base)& loi_ = le_fluide_->loi_etat();
53 //const DoubleVect& tab_rhon = loi_->rho_n(); //passe
54
55 int elem, nb_elem = dom.nb_elem(), i;
56 double V = 0; //domain measure
57 double Fn = 0; //integral 1 at time step n
58 double Fnp1 = 0; //integral 1 at time step n+1
59 double S = 0; //right-hand side
60
61 double dt = le_fluide_->vitesse().equation().schema_temps().pas_de_temps();
62 double v, al, b, bnp1, hn, hnp1, divu;
63
64 const IntTab& elem_faces = dom.elem_faces();
65 DoubleTrav divU(tab_vit.dimension(0), 1);
66 ref_cast(Navier_Stokes_std,le_fluide_->vitesse().equation()).operateur_divergence().calculer(tab_vit, divU);
67 DoubleTrav gradh(tab_vit.dimension(0));
68 DoubleTrav Hstar(tab_vit.dimension(0));
69 for (elem = 0; elem < nb_elem; elem++)
70 {
71 Hstar(elem) = .5 * (tab_hn(elem) + tab_hnp1(elem));
72 }
73 calculer_grad(Hstar, gradh);
74 DoubleTab u_gradh(nb_elem);
75 int f1, f2;
76 for (elem = 0; elem < nb_elem; elem++)
77 {
78 u_gradh(elem) = 0;
79 for (i = 0; i < dimension; i++)
80 {
81 f1 = elem_faces(elem, i);
82 f2 = elem_faces(elem, i + dimension);
83 u_gradh(elem) += .25 * (gradh(f1) + gradh(f2)) * (tab_vit(f1) + tab_vit(f2));
84 }
85 }
86
87 for (elem = 0; elem < nb_elem; elem++)
88 {
89 v = dom.volumes(elem);
90 V += v;
91 hn = tab_hn(elem);
92 hnp1 = tab_hnp1(elem);
93 al = loi_->Drho_DT(Pth_n, hn) / loi_->Drho_DP(Pth_n, hn);
94 b = tab_rho(elem) / loi_->Drho_DP(Pth_n, hn);
95 bnp1 = tab_rho(elem) / loi_->Drho_DP(Pth_n, hnp1);
96 //S += al.dh/dt
97 S -= v * al * ((hnp1 - hn) / dt);
98 divu = divU(elem);
99 //S -= al.u.gradT*
100 S -= v * al * u_gradh(elem);
101 //F += b.div(U)
102 Fn += v * b * divu;
103 Fnp1 += v * bnp1 * divu;
104 }
105
106 Pth = Pth_n + dt / V * (S - Fn);
107 Pth = Pth_n + dt / V * (S - .5 * (Fn + Fnp1));
108 double tmp = 0, r;
109 int k = 0;
110 while (std::fabs(tmp - Pth) / Pth > 1e-9 && k++ < 20)
111 {
112 tmp = Pth;
113 Fnp1 = 0;
114 for (elem = 0; elem < nb_elem; elem++)
115 {
116 v = dom.volumes(elem);
117 hnp1 = tab_hnp1(elem);
118 r = loi_->calculer_masse_volumique(Pth, hnp1);
119 bnp1 = r / loi_->Drho_DP(Pth, hnp1);
120 for (i = 0; i < dimension; i++)
121 {
122 Fnp1 += v * bnp1 * (tab_vit(elem_faces(elem, i + dimension)) - tab_vit(elem_faces(elem, i))) / dom.dim_elem(elem, i);
123 }
124 }
125 Pth = Pth_n + dt / V * (S - .5 * (Fn + Fnp1));
126 Cerr << "Recomputed thermodynamic pressure (iter " << k << ") = " << Pth << finl;
127 }
128 return Pth;
129}
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
class Domaine_VDF
Definition Domaine_VDF.h:61
double dim_elem(int, int) const
double volumes(int i) const
Definition Domaine_VF.h:113
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
int nb_front_Cl() const
class EDO_Pression_th_VDF_Gaz_Reel
double resoudre(double) override
Solves the ODE for the thermodynamic pressure.
class EDO_Pression_th_VDF This class represents the ODE for pressure associated with the
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
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133