TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Saturation_base.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Saturation_base.h>
17#include <QDM_Multiphase.h>
18#include <Equation_base.h>
19#include <Pb_Multiphase.h>
20#include <TPPI_tools.h>
21#include <Discretisation_base.h>
22
23Implemente_base(Saturation_base, "Saturation_base", Interface_base);
24// XD saturation_base Interface_base saturation_base INHERITS_BRACE fluide-gas interface with phase change (used in
25// XD_CONT pb_multiphase)
26
28{
30 param.ajouter("P_ref", &P_ref_); // XD_ADD_P floattant
31 // XD_CONT not_set
32 param.ajouter("T_ref", &T_ref_); // XD_ADD_P floattant
33 // XD_CONT not_set
34}
35
36Sortie& Saturation_base::printOn(Sortie& os) const { return os; }
37
39{
40 Param param(que_suis_je());
41 set_param(param);
42 param.lire_avec_accolades_depuis(is);
43 return is;
44}
45
47{
48 DoubleTab& sigma_tab = ch_sigma_->valeurs(), &Tsat_tab = ch_Tsat_->valeurs();
49 const Pb_Multiphase& pbm = ref_cast(Pb_Multiphase, pb_.valeur());
50 const DoubleTab& press = ref_cast(QDM_Multiphase, pbm.equation_qdm()).pression().valeurs();
51
52 // for now we assume the pressure field has 1 component
53 assert(press.line_size() == 1);
54 Tsat(press.get_span_tot(), Tsat_tab.get_span_tot(), 1, 0);
55
56 // call sigma
57 sigma(Tsat_tab.get_span(), press.get_span(), sigma_tab.get_span(), 1, 0);
58 sigma_tab.echange_espace_virtuel();
59}
60
61void Saturation_base::discretiser_Tsat(const Nom& Tsat_nom, double temps)
62{
63 const Discretisation_base& dis = pb_->discretisation();
64 const Domaine_dis_base& dom_dis = pb_->domaine_dis();
65 dis.discretiser_champ("temperature", dom_dis, Tsat_nom, "C", 1, temps, ch_Tsat_);
66}
67
68void Saturation_base::Tsat(const SpanD P, SpanD res, int ncomp, int ind) const
69{
70 assert(ncomp * (int )P.size() == (int )res.size());
71 (P_ref_ > 0) ? _Tsat_(P_ref_,res,ncomp,ind) : Tsat_(P,res,ncomp,ind);
72}
73
74void Saturation_base::dP_Tsat(const SpanD P, SpanD res, int ncomp, int ind) const
75{
76 assert(ncomp * (int )P.size() == (int )res.size());
77 if (P_ref_ > 0)
78 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = 0.;
79 else dP_Tsat_(P,res,ncomp,ind);
80}
81
82void Saturation_base::Psat(const SpanD T, SpanD res, int ncomp, int ind) const
83{
84 assert((int )T.size() == (int )res.size());
85 (T_ref_ > 0) ? _Psat_(T_ref_,res,ncomp,ind) : Psat_(T,res,ncomp,ind);
86}
87
88void Saturation_base::dT_Psat(const SpanD T, SpanD res, int ncomp, int ind) const
89{
90 assert((int )T.size() == (int )res.size());
91 if (T_ref_ > 0)
92 for (int i =0; i < (int)T.size() / ncomp; i++) res[i * ncomp + ind] = 0.;
93 else dT_Psat_(T,res,ncomp,ind);
94}
95
96void Saturation_base::Lvap(const SpanD P, SpanD res, int ncomp, int ind) const
97{
98 assert(ncomp * (int )P.size() == (int )res.size());
99 (P_ref_ > 0) ? _Lvap_(P_ref_,res,ncomp,ind) : Lvap_(P,res,ncomp,ind);
100}
101
102void Saturation_base::dP_Lvap(const SpanD P, SpanD res, int ncomp, int ind) const
103{
104 assert(ncomp * (int )P.size() == (int )res.size());
105 if (P_ref_ > 0)
106 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = 0.;
107 else dP_Lvap_(P,res,ncomp,ind);
108}
109
110void Saturation_base::Hls(const SpanD P, SpanD res, int ncomp, int ind) const
111{
112 assert(ncomp * (int )P.size() == (int )res.size());
113 (P_ref_ > 0) ? _Hls_(P_ref_,res,ncomp,ind) : Hls_(P,res,ncomp,ind);
114}
115
116void Saturation_base::dP_Hls(const SpanD P, SpanD res, int ncomp, int ind) const
117{
118 assert(ncomp * (int )P.size() == (int )res.size());
119 if (P_ref_ > 0)
120 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = 0.;
121 else dP_Hls_(P,res,ncomp,ind);
122}
123
124void Saturation_base::Hvs(const SpanD P, SpanD res, int ncomp, int ind) const
125{
126 assert(ncomp * (int )P.size() == (int )res.size());
127 (P_ref_ > 0) ? _Hvs_(P_ref_,res,ncomp,ind) : Hvs_(P,res,ncomp,ind);
128}
129
130void Saturation_base::dP_Hvs(const SpanD P, SpanD res, int ncomp, int ind) const
131{
132 assert(ncomp * (int )P.size() == (int )res.size());
133 if (P_ref_ > 0)
134 for (int i =0; i < (int)P.size(); i++) res[i * ncomp + ind] = 0.;
135 else dP_Hvs_(P,res,ncomp,ind);
136}
137
138void Saturation_base::get_sigma(const SpanD T, const SpanD P, SpanD sig, int ncomp, int ind) const
139{
140 assert((int )P.size() == (int )sig.size());
141 sigma_(T, P, sig, ncomp, ind);
142}
143
144void Saturation_base::get_sigma_h(const SpanD H, const SpanD P, SpanD sig, int ncomp, int ind) const
145{
146 assert((int )P.size() == (int )sig.size());
147 sigma_h_(H, P, sig, ncomp, ind);
148}
149
150void Saturation_base::compute_all_flux_interfacial_pb_multiphase(const SpanD P, MSatSpanD sats, int ncomp, int ind) const
151{
152 assert((int )sats.size() == 7);
153
154 SpanD dPTs__ = sats.at(SAT::T_SAT_DP), Hvs__ = sats.at(SAT::HV_SAT), Hls__ = sats.at(SAT::HL_SAT),
155 dPHvs__ = sats.at(SAT::HV_SAT_DP), dPHls__ = sats.at(SAT::HL_SAT_DP),
156 Lvap__ = sats.at(SAT::LV_SAT), dPLvap__ = sats.at(SAT::LV_SAT_DP);
157
158 assert(ncomp * (int )P.size() == (int )dPTs__.size() && ncomp * (int )P.size() == (int )Hvs__.size() && ncomp * (int )P.size() == (int )Hls__.size());
159 assert(ncomp * (int )P.size() == (int )dPHvs__.size() && ncomp * (int )P.size() == (int )dPHls__.size());
160 assert(ncomp * (int )P.size() == (int )Lvap__.size() && ncomp * (int )P.size() == (int )dPLvap__.size());
161
162 dP_Tsat(P, dPTs__, ncomp, ind);
163 Hvs(P, Hvs__, ncomp, ind);
164 Hls(P, Hls__, ncomp, ind);
165 dP_Hvs(P, dPHvs__, ncomp, ind);
166 dP_Hls(P, dPHls__, ncomp, ind);
167 Lvap(P, Lvap__, ncomp, ind);
168 dP_Lvap(P, dPLvap__, ncomp, ind);
169}
class Discretisation_base This class represents a spatial discretization scheme, which
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void set_param(Param &param) const override
virtual void sigma_h_(const SpanD H, const SpanD P, SpanD res, int ncomp=1, int ind=0) const =0
virtual void sigma_(const SpanD T, const SpanD P, SpanD res, int ncomp=1, int ind=0) const =0
double sigma(const double T, const double P) const
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
Multiphase thermohydraulics problem of type "3*N equations":
virtual Equation_base & equation_qdm()
Carries the terms of the momentum equation for multiphase flow without turbulence modelling.
virtual void get_sigma(const SpanD T, const SpanD P, SpanD sig, int ncomp=1, int ind=0) const final
void discretiser_Tsat(const Nom &Tsat_nom, double temps)
void mettre_a_jour(double) override
virtual void get_sigma_h(const SpanD H, const SpanD P, SpanD sig, int ncomp=1, int ind=0) const final
void Psat(const SpanD T, SpanD res, int ncomp=1, int ind=0) const
void Tsat(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
void Hls(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
void dP_Hls(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
void dP_Hvs(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
void dT_Psat(const SpanD T, SpanD res, int ncomp=1, int ind=0) const
void set_param(Param &param) const override
void dP_Tsat(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
void dP_Lvap(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
virtual void compute_all_flux_interfacial_pb_multiphase(const SpanD P, MSatSpanD, int ncomp=1, int ind=0) const
void Lvap(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
void Hvs(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
Base class for output streams.
Definition Sortie.h:52
int line_size() const
Definition TRUSTVect.tpp:67
Span_ get_span_tot() override
Definition TRUSTVect.h:182
Span_ get_span() override
Definition TRUSTVect.h:181
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")