TRUST 1.9.8
HPC thermohydraulic platform
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 Resoud l'EDO
32 *
33 * @param (double Pth_n) La pression a l'etape precedente
34 * @return (double) La nouvelle valeur de la pression
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(); //actuel
48 const DoubleTab& tab_hn = le_fluide_->inco_chaleur().passe(); //passe
49 const DoubleTab& tab_rho = le_fluide_->masse_volumique().valeurs(); //actuel
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; //mesure du domaine
55 double Fn = 0; //integrale 1 a l'etape n
56 double Fnp1 = 0; //integrale 1 a l'etape n+1
57 double S = 0; //second membre
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 //calcul T* aux 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 //calcul gradT*
81 calculer_grad(HstarP0, gradh);
82 //calcul 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 //calcul divU en P0 et 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 << "Pression thermo recalculee (impl" << k << ") = " << Pth << finl;
148 }
149 return Pth;
150}
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
classe EDO_Pression_th_VEF_Gaz_Reel Cette classe represente l'EDO sur la pression associee au schema ...
double resoudre(double) override
Resoud l'EDO.
classe EDO_Pression_th_VEF Cette classe represente l'EDO sur la pression associee au schema de
void calculer_grad(const DoubleTab &, DoubleTab &)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Loi_Etat_base Cette classe est la base de la hierarchie des lois d'etat.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
classe Navier_Stokes_std Cette classe porte les termes de l'equation de la dynamique
virtual const Champ_Inc_base & vitesse() const
classe Neumann_sortie_libre Cette classe represente une frontiere ouverte sans vitesse imposee
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
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
Classe de base des flux de sortie.
Definition Sortie.h:52