TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Milieu_MUSIG.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 <Milieu_MUSIG.h>
17
18Implemente_instanciable( Milieu_MUSIG, "Milieu_MUSIG", Milieu_composite ) ;
19// XD Milieu_MUSIG listobj Milieu_MUSIG INHERITS_BRACE milieu_base NO_COMMA MUSIG medium made of several sub mediums.
20
21Sortie& Milieu_MUSIG::printOn(Sortie& os) const { return Objet_U::printOn(os); }
22
24{
25 int i = 0;
26 std::vector<std::pair<std::string, int>> especes; // string for phase_nom. int : 0 for liquid and 1 for gas
27 Nom mot;
28 is >> mot;
29 if (mot != "{")
30 {
31 Cerr << "Milieu_MUSIG : { expected instead of " << mot << finl;
33 }
34
35 for (is >> mot; mot != "}"; is >> mot)
36 {
37 if (Motcle(mot) == "POROSITES_CHAMP") is >> ch_porosites_;
38 else if (Motcle(mot) == "DIAMETRE_HYD_CHAMP") is >> ch_diametre_hyd_;
39 else if (Motcle(mot) == "POROSITES")
40 {
41 Cerr << "You should use porosites_champ and not porosites ! Call the 911 !" << finl;
43 }
44 else if (Motcle(mot) == "GRAVITE")
45 {
46 Cerr << que_suis_je() << " : gravity should not be defined in Pb_Multiphase ! Use source_qdm if you want gravity in QDM equation !" << finl;
48 }
49 else if (!mot.debute_par("saturation") && !mot.debute_par("interface")) // add phases
50 {
51 Nom nomPhase(mot);
52
53 Cerr << "Milieu_MUSIG : ajout la phase " << mot << " ... " << finl;
54 OWN_PTR(Fluide_base) fluide;
55 fluide.typer_lire_simple(is, "Typing the fluid medium ...");
56
57 if(fluide->que_suis_je() == "Fluide_MUSIG")
58 {
59 Fluide_MUSIG& fluide_cast = ref_cast(Fluide_MUSIG,fluide.valeur());
60 for(int k =0; k<fluide_cast.get_NbSubPhase(); k++)
61 {
62 OWN_PTR(Fluide_base) subFluide(fluide_cast.get_Fluide());
63
64 if (subFluide->has_porosites())
65 {
66 Cerr << que_suis_je() + " : porosity should be defined only once in the milieu_composite block, not in " + subFluide->que_suis_je() << finl;
68 }
69 if (subFluide->a_gravite())
70 {
71 Cerr << que_suis_je() + " : gravity should be defined only once in the milieu_composite block, not in " + subFluide->que_suis_je() << finl;
73 }
74 if (subFluide->has_hydr_diam())
75 {
76 Cerr << que_suis_je() + " : diametre_hyd_champ should be defined only once in the milieu_composite block, not in " + subFluide->que_suis_je() << finl;
78 }
79 if (!sub_type(Fluide_base,subFluide.valeur()))
80 {
81 Cerr << que_suis_je() + " : only real fluids should be read and not a fluid of type " + subFluide->que_suis_je() << finl;
83 }
84 noms_phases_.add(nomPhase+"_"+std::to_string(k));
85 subFluide->set_id_composite(i++);
86 subFluide->nommer(nomPhase);
87 fluides_.push_back(subFluide);
88 std::array<int,3> lineIndex;
89 lineIndex[0]=(int)fluides_.size()-1;
90 lineIndex[1]=(int)fluidesMUSIG_.size();
91 lineIndex[2]=k;
92 indexMilieuToIndexFluide_.push_back(lineIndex);
93 especes.push_back(check_fluid_name(subFluide->le_nom()));
94
95 }
96 fluidesMUSIG_.push_back(fluide_cast);
97 }
98 else
99 {
100 if (fluide->has_porosites())
101 {
102 Cerr << que_suis_je() + " : porosity should be defined only once in the milieu_composite block, not in " + fluide->que_suis_je() << finl;
104 }
105 if (fluide->a_gravite())
106 {
107 Cerr << que_suis_je() + " : gravity should be defined only once in the milieu_composite block, not in " + fluide->que_suis_je() << finl;
109 }
110 if (fluide->has_hydr_diam())
111 {
112 Cerr << que_suis_je() + " : diametre_hyd_champ should be defined only once in the milieu_composite block, not in " + fluide->que_suis_je() << finl;
114 }
115 if (!sub_type(Fluide_base,fluide.valeur()))
116 {
117 Cerr << que_suis_je() + " : only real fluids should be read and not a fluid of type " + fluide->que_suis_je() << finl;
119 }
120
121 noms_phases_.add(nomPhase);
122 fluide->set_id_composite(i++);
123 fluide->nommer(nomPhase); // XXX
124 fluides_.push_back(fluide);
125 std::array<int,3> lineIndex;
126 lineIndex[0]=(int)fluides_.size()-1;
127 lineIndex[1]=-1;
128 lineIndex[2]=-1;
129 indexMilieuToIndexFluide_.push_back(lineIndex);
130 especes.push_back(check_fluid_name(fluide->le_nom()));
131 }
132
133 }
134 else if (mot.debute_par("saturation")) // add saturation
135 {
136 has_saturation_ = true;
137 Cerr << "Milieu_composite : ajout la saturation " << mot << " ... " << finl;
138 sat_lu_.typer_lire_simple(is, "Typing the saturation ...");
139 }
140 else // on ajout l'interface
141 {
142 has_interface_ = true;
143 Cerr << "Milieu_composite : ajout l'interface " << mot << " ... " << finl;
144 inter_lu_.typer_lire_simple(is, "Typing the interface ...");
145 }
146 }
147
148 if (has_saturation() && has_interface())
149 {
150 Cerr << "You define both interface and saturation in Milieu_composite ???" << finl;
152 }
153
154 // Interface treatment
155 const int N = (int)fluides_.size();
156 for (int n = 0; n < N; n++)
157 {
158 std::vector<Interface_base *> inter;
159 for (int m = 0; m < N; m++)
160 {
161 const std::string espn = especes[n].first, espm = especes[m].first;
162 const int pn = especes[n].second, pm = especes[m].second;
163
164 if (pn != pm && (has_interface() || (espn == espm && has_saturation())))
165 {
166 Cerr << "Interface between fluid " << n << " : " << fluides_[n]->le_nom() << " and " << m << " : " << fluides_[m]->le_nom() << finl;
167 inter.push_back(&ref_cast(Interface_base, has_saturation_ ? sat_lu_.valeur() : inter_lu_.valeur()));
168 const Saturation_base *sat = sub_type(Saturation_base, *inter.back()) ? &ref_cast(Saturation_base, *inter.back()) : nullptr;
169 if (sat && sat->get_Pref() > 0) // for an EOS of the type: e = e0 + cp * (T - T0)
170 {
171 const double hn = pn ? sat->Hvs(sat->get_Pref()) : sat->Hls(sat->get_Pref()),
172 hm = pm ? sat->Hvs(sat->get_Pref()) : sat->Hls(sat->get_Pref()),
173 T0 = sat->Tsat(sat->get_Pref());
174 fluides_[n]->set_h0_T0(hn, T0), fluides_[m]->set_h0_T0(hm, T0);
175 }
176 }
177 else inter.push_back(nullptr);
178 }
179 tab_interface_.push_back(inter);
180 }
181
182 return is;
183}
184
185double Milieu_MUSIG::get_Diameter_Inf(int iPhaseMilieu) const
186{
187 std::array<int,3> index = indexMilieuToIndexFluide_[iPhaseMilieu];
188 double diametre = -1;
189 if(index[2] < 0)
190 {
191 Cerr << que_suis_je() + " : the function get_Diameter is only available with FluideMusig" << finl;
193 }
194
195 Fluide_MUSIG fluideMUSIG = fluidesMUSIG_[index[1]];
196
197 if(fluideMUSIG.get_Diametres().size()<1)
198 {
199 Cerr << que_suis_je() + " : you need to define diameters for this fluideMusig" << finl;
201 }
202 diametre = fluideMUSIG.get_Diametres()[index[2]];
203
204 // A decommenter si verification du tableau indexMilieuToIndexFluide_
205 // std::vector<int> indexPhase;
206 // const int N = (int)fluides_.size();
207 // for (int n = 0; n < N; n++)
208 // {
209 // indexPhase = indexMilieuToIndexFluide_[n];
210 // cout << "Phase N° "<< indexPhase[0] << " Nom Phase " << noms_phases_[n]<< endl;
211 // cout << " Fluide N° "<< indexPhase[1] << " Nom Fluide " << fluides_[n].le_nom()<< endl;
212 // cout << " Index Fluide Musig N° "<< indexPhase[2] << endl;
213 // cout << endl;
214 // }
215
216 // A decommenter si necessaire
217 //const int N = (int)fluides_.size();
218 // for (int k = 0; k < N; k++)
219 // {
220 // int phase = fluides_[k].le_nom().debute_par("gaz_dispersee");
221 // Nom espece = phase ? fluides_[k].le_nom().getSuffix("gaz_") : fluides_[k].le_nom().getSuffix("liquide_");
222 // cout << "nom " << espece << endl;
223 // }
224
225 return diametre;
226}
227
228double Milieu_MUSIG::get_Diameter_Sup(int iPhaseMilieu) const
229{
230 std::array<int,3> index = indexMilieuToIndexFluide_[iPhaseMilieu];
231 double diametre = -1;
232 if(index[2] < 0)
233 {
234 Cerr << que_suis_je() + " : the function get_Diameter is only available with FluideMusig" << finl;
236 }
237
238 Fluide_MUSIG fluideMUSIG = fluidesMUSIG_[index[1]];
239
240 if(fluideMUSIG.get_Diametres().size()<1)
241 {
242 Cerr << que_suis_je() + " : you need to define diameters for this fluideMusig" << finl;
244 }
245 diametre = fluideMUSIG.get_Diametres()[index[2]+1];
246
247 return diametre;
248}
249
250double Milieu_MUSIG::get_Diameter_Sauter(int iPhaseMilieu) const
251{
252 double diametre = -1;
253
254 double dInf = get_Diameter_Inf(iPhaseMilieu);
255 double dSup = get_Diameter_Sup(iPhaseMilieu);
256
257 diametre = dInf;
258 if (dSup != dInf) diametre = (dSup-dInf)/log(dSup/dInf);
259
260 // test
261 // if (iPhaseMilieu == 1) diametre = get_Diameter_Inf(1);
262 // if (iPhaseMilieu == 2) diametre = get_Diameter_Inf(1);
263 // if (iPhaseMilieu == 3) diametre = get_Diameter_Sup(3);
264
265 if ((diametre < dInf) || (diametre > dSup))
266 {
267 Cerr << que_suis_je() + " : Diam Sauter < dInf or Diam Sauter > dSup of phase =" << iPhaseMilieu << finl;
269 }
270
271 return diametre;
272}
273
275{
276 bool dispersedGas = false;
277 if (fluides_[k]->le_nom().debute_par("gaz_dispersee")) dispersedGas = true;
278 return dispersedGas;
279}
280
282{
283 bool dispersedLiquid = false;
284 if (fluides_[k]->le_nom().debute_par("liquide_dispersee")) dispersedLiquid = true;
285 return dispersedLiquid;
286}
287
289{
290 bool carrierLiquid = false;
291 if (fluides_[k]->le_nom().debute_par("liquide_continu")) carrierLiquid = true;
292 return carrierLiquid;
293}
294
296{
297 bool carrierGas = false;
298 if (fluides_[k]->le_nom().debute_par("gaz_continu")) carrierGas = true;
299 return carrierGas;
300}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Classe Fluide_MUSIG.
const DoubleTab & get_Diametres() const
const int & get_NbSubPhase() const
double get_Diameter_Sup(int iPhaseMilieu) const
bool has_dispersed_gas(int k) const
double get_Diameter_Inf(int iPhaseMilieu) const
bool has_dispersed_liquid(int k) const
bool has_carrier_gas(int k) const
bool has_carrier_liquid(int k) const
double get_Diameter_Sauter(int iPhaseMilieu) const
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Classe Milieu_composite Cette classe represente un fluide reel ainsi que.
OWN_PTR(Champ_Don_base) rho_m_
std::vector< OWN_PTR(Fluide_base)> fluides_
std::vector< std::vector< Interface_base * > > tab_interface_
bool has_interface() const
bool has_saturation() const
std::pair< std::string, int > check_fluid_name(const Nom &name)
virtual int debute_par(const char *const n) const
Definition Nom.cpp:319
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
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
double get_Pref() 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 Hvs(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45