TrioCFD 1.9.8
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 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 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(); //actuel
50 const DoubleTab& tab_hn = le_fluide_->inco_chaleur().passe(); //passe
51 const DoubleTab& tab_rho = le_fluide_->masse_volumique().valeurs(); //actuel
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; //mesure du domaine
57 double Fn = 0; //integrale 1 a l'etape n
58 double Fnp1 = 0; //integrale 1 a l'etape n+1
59 double S = 0; //second membre
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 << "Pression thermo recalculee (impl" << k << ") = " << Pth << finl;
127 }
128 return Pth;
129}
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
class Domaine_VDF
Definition Domaine_VDF.h:64
double dim_elem(int, int) const
double volumes(int i) const
Definition Domaine_VF.h:113
int elem_faces(int i, int j) const
renvoie le numero de le ieme face de la maille num_elem la facon dont ces faces sont numerotees est
Definition Domaine_VF.h:543
int nb_front_Cl() const
classe EDO_Pression_th_VDF_Gaz_Reel Cette classe represente l'EDO sur la pression associee au schema ...
double resoudre(double) override
Resoud l'EDO.
classe EDO_Pression_th_VDF 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
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133