TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Correction_Tomiyama_PolyMAC_MPFA.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Correction_Tomiyama_PolyMAC_MPFA.h>
17#include <Champ_Face_PolyMAC_MPFA.h>
18#include <Milieu_composite.h>
19#include <Pb_Multiphase.h>
20#include <math.h>
21
22Implemente_instanciable(Correction_Tomiyama_PolyMAC_MPFA, "Correction_Tomiyama_Face_PolyMAC_MPFA", Source_base);
23// XD Correction_Tomiyama source_base Correction_Tomiyama BRACE Tomiyama correction source term for multiphase problem
24
26{
27 return os;
28}
29
31{
32 Param param(que_suis_je());
33 param.ajouter("secu_diam", &secu_diam_);
34 param.lire_avec_accolades_depuis(is);
35
36 //identification des phases
37 Pb_Multiphase *pbm = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()) : nullptr;
38
39 if (!pbm || pbm->nb_phases() == 1) Process::exit(que_suis_je() + " : not needed for single-phase flow!");
40 for (int n = 0; n < pbm->nb_phases(); n++) //recherche de n_l, n_g : phase {liquide,gaz}_continu en priorite
41 if (pbm->nom_phase(n).debute_par("liquide") && (n_l < 0 || pbm->nom_phase(n).finit_par("continu"))) n_l = n;
42
43 if (n_l < 0) Process::exit(que_suis_je() + " : liquid phase not found!");
44
45 pbm->creer_champ("distance_paroi_globale"); // Besoin de distance a la paroi
46
47 return is;
48}
49
50void Correction_Tomiyama_PolyMAC_MPFA::completer() // We must wait for all readOn's to be sure that the bubble dispersion and lift correlations are created
51{
52 const Pb_Multiphase& pbm = ref_cast(Pb_Multiphase, equation().probleme());
53
54 if (!pbm.has_champ("diametre_bulles")) Process::exit("Correction_Lubchenko_PolyMAC_MPFA::completer() : a bubble diameter must be defined !");
55}
56
57void Correction_Tomiyama_PolyMAC_MPFA::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
58{
59 const Champ_Face_PolyMAC_MPFA& ch = ref_cast(Champ_Face_PolyMAC_MPFA, equation().inconnue());
60 const Milieu_composite& milc = ref_cast(Milieu_composite, equation().milieu());
61 const DoubleTab& pvit = ch.passe(),
62 &alpha = ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe(),
63 &rho = equation().milieu().masse_volumique().passe(),
64 &d_bulles = equation().probleme().get_champ("diametre_bulles").valeurs();
65 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
66 const IntTab& f_e = domaine.face_voisins(),
67 &fcl = ch.fcl();
68 const DoubleVect& pe = equation().milieu().porosite_elem(),
69 &pf = equation().milieu().porosite_face(),
70 &ve = domaine.volumes(),
71 &vf = domaine.volumes_entrelaces(),
72 &fs = domaine.face_surfaces();
73 const DoubleTab& vf_dir = domaine.volumes_entrelaces_dir(),
74 &n_f = domaine.face_normales(),
75 &y_elem = domaine.y_elem(),
76 &y_faces = domaine.y_faces(),
77 &n_y_elem = domaine.normale_paroi_elem(),
78 &n_y_faces = domaine.normale_paroi_faces();
79 int N = pvit.line_size() ,
80 D = dimension,
81 nf_tot = domaine.nb_faces_tot(),
82 nf = domaine.nb_faces(),
83 ne_tot = domaine.nb_elem_tot();
84
85 DoubleTrav dv(N, N), pvit_l(N,D), scal_u(N), sigma_l(N,ne_tot) ;
86 int e, f, c, k, d, i;
87
88 double fac, a_l, rho_l, rho_k, db_l, secmem_l, Eo, Cw, dist, correction, sig_face;
89
90 // Et pour les methodes span de la classe Saturation
91 for (k = 0; k < N; k++)
92 {
93 if (milc.has_saturation(k, n_l))
94 {
95 const Saturation_base& z_sat = milc.get_saturation(k, n_l);
96 const DoubleTab& sig = z_sat.get_sigma_tab();
97 for (int ii = 0; ii < ne_tot; ii++) sigma_l(k,ii) = sig(ii);
98 }
99 else if (milc.has_interface(k, n_l))
100 {
101 Interface_base& sat = milc.get_interface(k,n_l);
102 const DoubleTab& sig = sat.get_sigma_tab();
103 for (int ii = 0; ii < ne_tot; ii++) sigma_l(k,ii) = sig(ii);
104 }
105 }
106
107 for (f = 0; f < nf; f++)
108 if (fcl(f, 0) < 2)
109 {
110 // Calculation of correct velocity at the face
111 pvit_l = 0 ;
112 for (d = 0 ; d<D ; d++)
113 for (k = 0 ; k<N ; k++)
114 for (c=0 ; c<2 && (e = f_e(f, c)) >= 0; c++)
115 pvit_l(k, d) += vf_dir(f, c)/vf(f)*pvit(nf_tot+D*e+d, k) ;
116 scal_u = 0;
117 for (k = 0 ; k<N ; k++)
118 for (d = 0 ; d<D ; d++)
119 scal_u(k) += pvit_l(k, d)*n_f(f, d)/fs(f);
120 for (k = 0 ; k<N ; k++)
121 for (d = 0 ; d<D ; d++)
122 pvit_l(k, d) += (pvit(f, k) - scal_u(k)) * n_f(f, d)/fs(f) ;
123
124 // Retract component normal to the wall
125 scal_u = 0;
126 for (k = 0 ; k<N ; k++)
127 for (d = 0 ; d<D ; d++)
128 scal_u(k) += pvit_l(k, d)*n_y_faces(f, d);
129 for (k = 0 ; k<N ; k++)
130 for (d = 0 ; d<D ; d++)
131 pvit_l(k, d) -= scal_u(k)*n_y_faces(f, d) ;
132
133 // Calculation of liquid-gas velocity difference
134 dv = 0.;
135 for ( k = 0; k < N; k++)
136 if (k != n_l)
137 {
138 for (d = 0 ; d<D ; d++) dv(k, n_l) += (pvit_l(k, d)-pvit_l(n_l, d)) * (pvit_l(k, d)-pvit_l(n_l, d));
139 dv(k, n_l) = std::sqrt(dv(k, n_l));
140 }
141
142 for (k = 0; k < N; k++)
143 if (k != n_l)
144 {
145 fac = 0 ;
146 for (d = 0 ; d<D ; d++) fac += n_y_faces(f, d) * n_f(f, d)/fs(f);
147
148 fac *= pf(f) * vf(f) ;
149 a_l = ( alpha(f_e(f, 0), k)*vf_dir(f,0) + ((e = f_e(f, 1))>0 ? alpha(e, k)*vf_dir(f,1) : 0) ) / vf(f);
150 rho_l=( rho(f_e(f, 0), n_l)*vf_dir(f,0) + ((e = f_e(f, 1))>0 ? rho(e, n_l)*vf_dir(f,1) : 0) ) / vf(f);
151 rho_k=( rho(f_e(f, 0), k)*vf_dir(f,0) + ((e = f_e(f, 1))>0 ? rho(e, k)*vf_dir(f,1) : 0) ) / vf(f);
152 db_l= ( d_bulles(f_e(f, 0), k)*vf_dir(f,0) + ((e = f_e(f, 1))>0 ? d_bulles(e, k)*vf_dir(f,1):0) ) / vf(f);
153 sig_face = (sigma_l(k,f_e(f, 0)) * vf_dir(f,0) + ((e = f_e(f, 1))>0 ? sigma_l(k,e)*vf_dir(f,1) : 0) ) / vf(f) ;
154
155 Eo = ( rho_l - rho_k ) * g_ * 2. * db_l / sig_face ;
156
157 dist = std::max(y_faces(f), secu_diam_ * db_l);
158 correction = std::max(1.- y_faces(f)/db_l, 0.) ;
159
160 if (Eo < 1.) {Cw = 0.74 ;}
161 else if (Eo < 5.) {Cw = exp(-0.933 * Eo + 0.179) ;}
162 else if (Eo < 33.) {Cw = 0.00599 * Eo -0.187 ;}
163 else {Cw = 0.179 ;}
164
165 secmem_l = fac * a_l * rho_l * dv(k,n_l) * dv(k,n_l) * db_l / 2. * Cw / dist / dist * correction ;
166
167 secmem(f, k) += secmem_l;
168 secmem(f, n_l) -= secmem_l;
169 }
170
171 }
172
173 for ( e = 0; e < ne_tot; e++)
174 {
175 pvit_l = 0;
176 // Fill velocity at the element
177 for (d = 0 ; d<D ; d++)
178 for (k = 0 ; k<N ; k++)
179 pvit_l(k, d) += pvit(nf_tot+D*e+d, k) ;
180
181 // Retract component normal to the wall
182 scal_u = 0;
183 for (k = 0 ; k<N ; k++)
184 for (d = 0 ; d<D ; d++)
185 scal_u(k) += pvit_l(k, d)*n_y_elem(e, d);
186 for (k = 0 ; k<N ; k++)
187 for (d = 0 ; d<D ; d++)
188 pvit_l(k, d) -= scal_u(k)*n_y_elem(e, d) ;
189
190 // Calculation of norm of velocity
191 dv = 0.;
192 for ( k = 0; k < N; k++)
193 if (k != n_l)
194 {
195 for (d = 0 ; d<D ; d++) dv(k, n_l) += (pvit_l(k, d)-pvit_l(n_l, d)) * (pvit_l(k, d)-pvit_l(n_l, d));
196 dv(k, n_l) = std::sqrt(dv(k, n_l));
197 }
198
199 for (k = 0; k < N; k++)
200 if (k != n_l)
201 {
202 fac = pe(e) * ve(e) ;
203 Eo = ( rho(e, n_l) - rho(e, k) ) * g_ * 2. * d_bulles(e, k) / sigma_l(k,e) ;
204
205
206 dist = std::max(y_elem(e), secu_diam_ * d_bulles(e, k)); // securite numerique
207 correction = std::max(1.- y_elem(e)/d_bulles(e, k), 0.) ;
208
209 if (Eo < 1.) {Cw = 0.74 ;}
210 else if (Eo < 5.) {Cw = exp(-0.933 * Eo + 0.179) ;}
211 else if (Eo < 33.) {Cw = 0.00599 * Eo -0.187 ;}
212 else {Cw = 0.179 ;}
213
214 secmem_l = fac * alpha(e,k) * rho(e,n_l) * dv(k,n_l) * dv(k,n_l) * d_bulles(e, k) / 2. * Cw / dist / dist * correction ;
215
216 for ( d = 0, i = nf_tot + D * e; d < D; d++, i++)
217 {
218 secmem(i , k) += secmem_l * n_y_elem(e, d);
219 secmem(i , n_l) -= secmem_l * n_y_elem(e, d);
220 }
221 }
222 }
223}
: class Champ_Face_PolyMAC_MPFA
const IntTab & fcl() const
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
virtual DoubleTab & valeurs()=0
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
classe Correction_Tomiyama_PolyMAC_MPFA Correction de repulsion en paroi d'Tomiyama dans un ecoulemen...
void completer() override
Met a jour les references internes a l'objet Source_base.
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
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
virtual const Milieu_base & milieu() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
DoubleTab & get_sigma_tab()
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
virtual const Champ_base & masse_volumique() const
Renvoie la masse volumique du milieu.
DoubleVect & porosite_face()
Definition Milieu_base.h:62
Classe Milieu_composite Cette classe represente un fluide reel ainsi que.
bool has_interface(int k, int l) const
bool has_saturation(int k, int l) const
Interface_base & get_interface(int k, int l) const
Saturation_base & get_saturation(int k, int l) const
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
virtual int debute_par(const char *const n) const
Definition Nom.cpp:319
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 Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
const Nom & nom_phase(int i) const
int nb_phases() const
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
void creer_champ(const Motcle &motlu) override
const Champ_base & get_champ(const Motcle &nom) const override
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Source_base Un objet Source_base est un terme apparaissant au second membre d'une
Definition Source_base.h:42
int line_size() const
Definition TRUSTVect.tpp:67