TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Loi_Etat_TPPI_QC_base.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 <Fluide_Dilatable_base.h>
17#include <Loi_Etat_TPPI_QC_base.h>
18#include <Champ_Uniforme.h>
19#include <Domaine_VF.h>
20
21
22Implemente_base(Loi_Etat_TPPI_QC_base, "Loi_Etat_TPPI_QC_base", Loi_Etat_TPPI_base);
23// XD loi_etat_tppi_base loi_etat_base loi_etat_tppi_base INHERITS_BRACE Basic class for thermo-physical properties
24// XD_CONT interface (TPPI) used for dilatable problems
25
26Sortie& Loi_Etat_TPPI_QC_base::printOn(Sortie& os) const { return os << que_suis_je() << finl; }
28
30{
32 if (!vec_press_filled_) init_vec_press();
33}
34
35void Loi_Etat_TPPI_QC_base::init_vec_press()
36{
37 const double Pth = le_fluide->pression_th();
38 vec_press_.resize(le_fluide->inco_chaleur().valeurs().dimension(0));
39 for (auto &itr : vec_press_) itr = Pth;
40 vec_press_filled_ = true;
41}
42
43// In order, the following steps are performed:
44//
45// calculer_Cp();
46// calculer_mu();
47// calculer_lambda();
48// calculer_nu();
49// calculer_alpha();
50// calculer_mu_sur_Sc();
51// calculer_nu_sur_Sc();
53{
54 if (!vec_press_filled_) init_vec_press();
55 const DoubleTab& tab_ICh = le_fluide->inco_chaleur().valeurs();
56 SpanD temp_span = tab_ICh.get_span(), p_span = SpanD(vec_press_);
57
58 /* Step 2 : Mu */
59 Champ_Don_base& mu = le_fluide->viscosite_dynamique();
60 DoubleTab& tab_mu = mu.valeurs();
61 TPPI_->tppi_get_mu_pT(p_span, temp_span, tab_mu.get_span());
63 mu.mettre_a_jour(temperature_->temps());
64
65 /* Step 3 : Lambda */
66 Champ_Don_base& lambda = le_fluide->conductivite();
67 DoubleTab& tab_lambda = lambda.valeurs();
68 TPPI_->tppi_get_lambda_pT(p_span, temp_span, tab_lambda.get_span());
69 tab_lambda.echange_espace_virtuel();
70
71 /* Step 4 : Alpha */
72 Champ_Don_base& alpha = le_fluide->diffusivite();
73 DoubleTab& tab_alpha = alpha.valeurs();
74 const DoubleTab& tab_rho = le_fluide->masse_volumique().valeurs();
75
76 const bool isVDF = (alpha.que_suis_je() == "Champ_Fonc_P0_VDF") ? true : false;
77
78 if (isVDF)
79 for (int i = 0; i < tab_alpha.dimension(0); i++)
80 tab_alpha(i, 0) = tab_lambda(i, 0) / (tab_rho(i, 0) * Cp_);
81 else
82 {
83 const IntTab& elem_faces = ref_cast(Domaine_VF, le_fluide->vitesse().domaine_dis_base()).elem_faces();
84 const int nfe = elem_faces.line_size();
85 for (int i = 0; i < tab_alpha.dimension(0); i++)
86 {
87 double rhoelem = 0.;
88 for (int face = 0; face < nfe; face++)
89 rhoelem += tab_rho(elem_faces(i, face), 0);
90 rhoelem /= nfe;
91 tab_alpha(i, 0) = tab_lambda(i, 0) / (rhoelem * Cp_);
92 }
93 }
94 tab_alpha.echange_espace_virtuel();
95}
96
98{
99 if (!vec_press_filled_) init_vec_press();
100 const DoubleTab& tab_ICh = le_fluide->inco_chaleur().valeurs();
101 DoubleTab& tab_rho = le_fluide->masse_volumique().valeurs();
102 SpanD temp_span = tab_ICh.get_span(), p_span = SpanD(vec_press_), rho_span = tab_rho_np1.get_span();
103 TPPI_->tppi_get_rho_pT(p_span, temp_span, rho_span);
104
105 for (int som = 0; som < tab_rho.size(); som++) tab_rho(som, 0) = 0.5 * (tab_rho_n(som) + tab_rho_np1(som));
106
107 tab_rho.echange_espace_virtuel();
108 tab_rho_np1.echange_espace_virtuel();
109 le_fluide->calculer_rho_face(tab_rho_np1);
110}
class Champ_Don_base base class of Given Fields (not calculated)
void mettre_a_jour(double temps) override
Time update.
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
class Domaine_VF
Definition Domaine_VF.h:44
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
void preparer_calcul() override
Prepares the fluid for computation by filling temperature and computing density.
void calculer_masse_volumique() override
Recomputes the density (masse volumique).
void calculer_Cp() override
Computes Cp. Does nothing: Cp is constant.
void preparer_calcul() override
Prepares the fluid for computation by filling temperature and computing density.
std::shared_ptr< TPPI > TPPI_
DoubleTab tab_rho_np1
DoubleTab tab_rho_n
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
_SIZE_ size() const
Definition TRUSTVect.tpp:45
int line_size() const
Definition TRUSTVect.tpp:67
Span_ get_span() override
Definition TRUSTVect.h:181
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")