TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Correction_Antal_PolyMAC_MPFA.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 <Correction_Antal_PolyMAC_MPFA.h>
17#include <Champ_Face_PolyMAC_MPFA.h>
18#include <Pb_Multiphase.h>
19#include <math.h>
20
21Implemente_instanciable(Correction_Antal_PolyMAC_MPFA, "Correction_Antal_Face_PolyMAC_MPFA", Source_base);
22// XD Correction_Antal source_base Correction_Antal BRACE Antal correction source term for multiphase problem
23
25{
26 return os;
27}
28
30{
31 Param param(que_suis_je());
32 param.ajouter("Cw1", &Cw1_);
33 param.ajouter("Cw2", &Cw2_);
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_Antal_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
57
58void Correction_Antal_PolyMAC_MPFA::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
59{
60}
61
62void Correction_Antal_PolyMAC_MPFA::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
63{
64 const Champ_Face_PolyMAC_MPFA& ch = ref_cast(Champ_Face_PolyMAC_MPFA, equation().inconnue());
65 const DoubleTab& pvit = ch.passe(),
66 &alpha = ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe(),
67 &rho = equation().milieu().masse_volumique().passe(),
68 &d_bulles = equation().probleme().get_champ("diametre_bulles").valeurs();
69 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
70 const IntTab& f_e = domaine.face_voisins(),
71 &fcl = ch.fcl();
72 const DoubleVect& pe = equation().milieu().porosite_elem(),
73 &pf = equation().milieu().porosite_face(),
74 &ve = domaine.volumes(),
75 &vf = domaine.volumes_entrelaces(),
76 &fs = domaine.face_surfaces();
77 const DoubleTab& vf_dir = domaine.volumes_entrelaces_dir(),
78 &n_f = domaine.face_normales(),
79 &y_elem = domaine.y_elem(),
80 &y_faces = domaine.y_faces(),
81 &n_y_elem = domaine.normale_paroi_elem(),
82 &n_y_faces = domaine.normale_paroi_faces();
83 int N = pvit.line_size() ,
84 D = dimension,
85 nf_tot = domaine.nb_faces_tot(),
86 nf = domaine.nb_faces(),
87 ne_tot = domaine.nb_elem_tot();
88
89 DoubleTrav dv(N, N), pvit_l(N,D), scal_u(N) ;
90 int e, f, c, k, d, i;
91
92 double fac, a_l, rho_l, db_l, secmem_l;
93
94 for (f = 0; f < nf; f++)
95 if (fcl(f, 0) < 2)
96 {
97 // Calculation of correct velocity at the face
98 pvit_l = 0 ;
99 for (d = 0 ; d<D ; d++)
100 for (k = 0 ; k<N ; k++)
101 for (c=0 ; c<2 && (e = f_e(f, c)) >= 0; c++)
102 pvit_l(k, d) += vf_dir(f, c)/vf(f)*pvit(nf_tot+D*e+d, k) ;
103 scal_u = 0;
104 for (k = 0 ; k<N ; k++)
105 for (d = 0 ; d<D ; d++)
106 scal_u(k) += pvit_l(k, d)*n_f(f, d)/fs(f);
107 for (k = 0 ; k<N ; k++)
108 for (d = 0 ; d<D ; d++)
109 pvit_l(k, d) += (pvit(f, k) - scal_u(k)) * n_f(f, d)/fs(f) ;
110
111 // Retract component normal to the wall
112 scal_u = 0;
113 for (k = 0 ; k<N ; k++)
114 for (d = 0 ; d<D ; d++)
115 scal_u(k) += pvit_l(k, d)*n_y_faces(f, d);
116 for (k = 0 ; k<N ; k++)
117 for (d = 0 ; d<D ; d++)
118 pvit_l(k, d) -= scal_u(k)*n_y_faces(f, d) ;
119
120 // Calculation of liuqid-gas velocity difference
121 dv = 0.;
122 for ( k = 0; k < N; k++)
123 if (k != n_l)
124 {
125 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));
126 dv(k, n_l) = std::sqrt(dv(k, n_l));
127 }
128
129 for (k = 0; k < N; k++)
130 if (k != n_l)
131 {
132 fac = 0 ;
133 for (d = 0 ; d<D ; d++) fac += n_y_faces(f, d) * n_f(f, d)/fs(f);
134
135 fac *= pf(f) * vf(f) ;
136 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);
137 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);
138 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);
139
140 secmem_l = fac * 2. * a_l * rho_l * dv(k,n_l) * dv(k,n_l) / db_l * std::max(0., Cw1_ + Cw2_*db_l/(2.*y_faces(f))) ;
141
142 secmem(f, k) += secmem_l;
143 secmem(f, n_l) -= secmem_l;
144 }
145
146 }
147
148 for ( e = 0; e < ne_tot; e++)
149 {
150 pvit_l = 0;
151 // Fill velocity at the element
152 for (d = 0 ; d<D ; d++)
153 for (k = 0 ; k<N ; k++)
154 pvit_l(k, d) += pvit(nf_tot+D*e+d, k) ;
155
156 // Retract component normal to the wall
157 scal_u = 0;
158 for (k = 0 ; k<N ; k++)
159 for (d = 0 ; d<D ; d++)
160 scal_u(k) += pvit_l(k, d)*n_y_elem(e, d);
161 for (k = 0 ; k<N ; k++)
162 for (d = 0 ; d<D ; d++)
163 pvit_l(k, d) -= scal_u(k)*n_y_elem(e, d) ;
164
165 // Calculation of norm of velocity
166 dv = 0.;
167 for ( k = 0; k < N; k++)
168 if (k != n_l)
169 {
170 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));
171 dv(k, n_l) = std::sqrt(dv(k, n_l));
172 }
173
174 for (k = 0; k < N; k++)
175 if (k != n_l)
176 {
177 fac = pe(e) * ve(e) ;
178 secmem_l = fac * 2. * alpha(e,k) * rho(e,n_l) * dv(k,n_l) * dv(k,n_l) / d_bulles(e,k) * std::max(0., Cw1_ + Cw2_*d_bulles(e,k)/(2.*y_elem(e))) ;
179
180 for ( d = 0, i = nf_tot + D * e; d < D; d++, i++)
181 {
182 secmem(i , k) += secmem_l * n_y_elem(e, d);
183 secmem(i , n_l) -= secmem_l * n_y_elem(e, d);
184 }
185 }
186 }
187}
: 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_Antal_PolyMAC_MPFA Correction de repulsion en paroi d'Antal dans un ecoulement mult...
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override
void completer() override
Met a jour les references internes a l'objet Source_base.
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.
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
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