TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Correction_Antal_VDF.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_VDF.h>
17#include <Champ_Face_VDF.h>
18#include <Pb_Multiphase.h>
19#include <math.h>
20
21Implemente_instanciable(Correction_Antal_VDF, "Correction_Antal_VDF_Face", Source_base);
22
24{
25 return os;
26}
27
29{
30 Param param(que_suis_je());
31 param.ajouter("Cw1", &Cw1_);
32 param.ajouter("Cw2", &Cw2_);
33 param.lire_avec_accolades_depuis(is);
34
35 //identification of phases
36 Pb_Multiphase *pbm = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()) : nullptr;
37
38 if (!pbm || pbm->nb_phases() == 1) Process::exit(que_suis_je() + " : not needed for single-phase flow!");
39 for (int n = 0; n < pbm->nb_phases(); n++) //search for n_l, n_g : {liquid,gas}_continuous phase in priority
40 if (pbm->nom_phase(n).debute_par("liquide") && (n_l < 0 || pbm->nom_phase(n).finit_par("continu"))) n_l = n;
41
42 if (n_l < 0) Process::exit(que_suis_je() + " : liquid phase not found!");
43
44 pbm->creer_champ("distance_paroi_globale"); // Wall distance field required
45
46 return is;
47}
48
49void Correction_Antal_VDF::completer() // We must wait for all readOn's to be sure that the bubble dispersion and lift correlations are created
50{
51 const Pb_Multiphase& pbm = ref_cast(Pb_Multiphase, equation().probleme());
52
53 if (!pbm.has_champ("diametre_bulles")) Process::exit(que_suis_je() + " : a bubble diameter must be defined !");
54}
55
56
57void Correction_Antal_VDF::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
58{
59}
60
61void Correction_Antal_VDF::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
62{
63 const Champ_Face_VDF& ch = ref_cast(Champ_Face_VDF, equation().inconnue());
64 const DoubleTab& pvit = ch.passe(),
65 &alpha = ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe(),
66 &rho = equation().milieu().masse_volumique().passe(),
67 &d_bulles = equation().probleme().get_champ("diametre_bulles").valeurs();
68 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
69 const IntTab& f_e = domaine.face_voisins(),
70 &fcl = ch.fcl();
71 const DoubleVect& pf = equation().milieu().porosite_face(),
72 &vf = domaine.volumes_entrelaces(),
73 &fs = domaine.face_surfaces();
74 const DoubleTab& vf_dir = domaine.volumes_entrelaces_dir(),
75 &n_f = domaine.face_normales(),
76 &y_faces = domaine.y_faces(),
77 &n_y_faces = domaine.normale_paroi_faces();
78 int N = pvit.line_size() ,
79 D = dimension,
80 nf = domaine.nb_faces();
81
82 DoubleTrav dv(N, N), pvit_l(N,D), scal_u(N) ;
83 int e, f, c, k, d;
84
85 double fac, a_l, rho_l, db_l, secmem_l;
86
87 DoubleTab pvit_elem(0, N * dimension);
88 domaine.domaine().creer_tableau_elements(pvit_elem);
89 ch.get_elem_vector_field(pvit_elem, true);
90
91 for (f = 0; f < nf; f++)
92 if (fcl(f, 0) < 2)
93 {
94 // Calculation of correct velocity at the face
95 pvit_l = 0 ;
96 for (d = 0 ; d<D ; d++)
97 for (k = 0 ; k<N ; k++)
98 for (c=0 ; c<2 && (e = f_e(f, c)) >= 0; c++)
99 pvit_l(k, d) += vf_dir(f, c)/vf(f)*pvit_elem(e, N*d+k) ;
100 scal_u = 0;
101 for (k = 0 ; k<N ; k++)
102 for (d = 0 ; d<D ; d++)
103 scal_u(k) += pvit_l(k, d)*n_f(f, d)/fs(f);
104 for (k = 0 ; k<N ; k++)
105 for (d = 0 ; d<D ; d++)
106 pvit_l(k, d) += (pvit(f, k) - scal_u(k)) * n_f(f, d)/fs(f) ;
107
108 // Retract component normal to the wall
109 scal_u = 0;
110 for (k = 0 ; k<N ; k++)
111 for (d = 0 ; d<D ; d++)
112 scal_u(k) += pvit_l(k, d)*n_y_faces(f, d);
113 for (k = 0 ; k<N ; k++)
114 for (d = 0 ; d<D ; d++)
115 pvit_l(k, d) -= scal_u(k)*n_y_faces(f, d) ;
116
117 // Calculation of liuqid-gas velocity difference
118 dv = 0.;
119 for ( k = 0; k < N; k++)
120 if (k != n_l)
121 {
122 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));
123 dv(k, n_l) = std::sqrt(dv(k, n_l));
124 }
125
126 for (k = 0; k < N; k++)
127 if (k != n_l)
128 {
129 fac = 0 ;
130 for (d = 0 ; d<D ; d++) fac += n_y_faces(f, d) * n_f(f, d)/fs(f);
131
132 fac *= pf(f) * vf(f) ;
133 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);
134 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);
135 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);
136
137 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))) ;
138
139 secmem(f, k) += secmem_l;
140 secmem(f, n_l) -= secmem_l;
141 }
142
143 }
144}
class Champ_Face_VDF
virtual DoubleTab & get_elem_vector_field(DoubleTab &, bool passe=false) const
const IntTab & fcl() const
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
virtual DoubleTab & valeurs()=0
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
Correction_Antal_PolyMAC_MPFA class: Wall repulsion correction of Antal in a multiphase flow.
void completer() override
Updates internal references of the Source_base object.
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override
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()
Returns the problem associated with the equation.
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
static int dimension
Definition Objet_U.h:94
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
Multiphase thermohydraulics problem of type "3*N equations":
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)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
int line_size() const
Definition TRUSTVect.tpp:67