TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Portance_interfaciale_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 <Portance_interfaciale_base.h>
17#include <Portance_interfaciale_VDF.h>
18#include <Milieu_composite.h>
19#include <Champ_Face_VDF.h>
20#include <Pb_Multiphase.h>
21
22Implemente_instanciable(Portance_interfaciale_VDF, "Portance_interfaciale_VDF_Face", Source_Portance_interfaciale_base);
23
24Sortie& Portance_interfaciale_VDF::printOn(Sortie& os) const { return os; }
26
27void Portance_interfaciale_VDF::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
28{
29 const Pb_Multiphase& pbm = ref_cast(Pb_Multiphase, equation().probleme());
30 const bool res_en_T = pbm.resolution_en_T();
31 if (!res_en_T) Process::exit("Portance_interfaciale_VDF::ajouter_blocs NOT YET PORTED TO ENTHALPY EQUATION ! TODO FIXME !!");
32
33 const Champ_Face_VDF& ch = ref_cast(Champ_Face_VDF, equation().inconnue());
34 const Domaine_VDF& domaine = ref_cast(Domaine_VDF, equation().domaine_dis());
35 const IntTab& f_e = domaine.face_voisins(), &e_f = domaine.elem_faces(), &fcl = ch.fcl();
36 const DoubleTab& n_f = domaine.face_normales(), &vf_dir = domaine.volumes_entrelaces_dir(), &xv = domaine.xv();
37 const DoubleVect& pf = equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces(), &fs = domaine.face_surfaces();
38 const DoubleTab& pvit = ch.passe(),
39 &alpha = pbm.equation_masse().inconnue().passe(),
40 &press = ref_cast(QDM_Multiphase, pbm.equation_qdm()).pression().passe(),
41 &temp = pbm.equation_energie().inconnue().passe(),
42 &rho = equation().milieu().masse_volumique().passe(),
43 &mu = ref_cast(Fluide_base, equation().milieu()).viscosite_dynamique().passe(),
44 &grad_v = equation().probleme().get_champ("gradient_vitesse").valeurs(),
45 &vort = equation().probleme().get_champ("vorticite").valeurs(),
46 * d_bulles = (equation().probleme().has_champ("diametre_bulles")) ? &equation().probleme().get_champ("diametre_bulles").valeurs() : nullptr,
47 * k_turb = (equation().probleme().has_champ("k")) ? &equation().probleme().get_champ("k").passe() : nullptr ;
48 const Milieu_composite& milc = ref_cast(Milieu_composite, equation().milieu());
49
50 int e, f, c, d, i, k, l, n, N = ch.valeurs().line_size(), Np = press.line_size(), D = dimension, Nk = (k_turb) ? (*k_turb).dimension(1) : 1 ,
51 cR = (rho.dimension_tot(0) == 1), cM = (mu.dimension_tot(0) == 1);
52 DoubleTrav vr_l(N,D), scal_ur(N), scal_u(N), pvit_l(N, D), vort_l( D==2 ? 1 :D); // Requis pour corrections vort et u_l-u-g
53 double fac_f, vl_norm;
54 const Portance_interfaciale_base& correlation_pi = ref_cast(Portance_interfaciale_base, correlation_.valeur());
55
56 // Vitesse passee aux elems
57 DoubleTab pvit_elem(0, N * dimension);
58 domaine.domaine().creer_tableau_elements(pvit_elem);
59 ch.get_elem_vector_field(pvit_elem, true);
60
61 // in/out pour correlation
64 in.alpha.resize(N), in.T.resize(N), in.p.resize(N), in.rho.resize(N), in.mu.resize(N), in.sigma.resize(N*(N-1)/2), in.k_turb.resize(N), in.d_bulles.resize(N), in.nv.resize(N, N);
65 out.Cl.resize(N, N);
66
67 // Et pour les methodes span de la classe Interface pour choper la tension de surface
68 const int nbelem_tot = domaine.nb_elem_tot(), nb_max_sat = N * (N-1) /2; // oui !! suite arithmetique !!
69 DoubleTrav Sigma_tab(nbelem_tot,nb_max_sat);
70
71 // remplir les tabs ...
72 for (k = 0; k < N; k++)
73 for (l = k + 1; l < N; l++)
74 {
75 if (milc.has_saturation(k, l))
76 {
77 Saturation_base& z_sat = milc.get_saturation(k, l);
78 const int ind_trav = (k*(N-1)-(k-1)*(k)/2) + (l-k-1); // Et oui ! matrice triang sup !
79 // recuperer sigma ...
80 const DoubleTab& sig = z_sat.get_sigma_tab();
81 // fill in the good case
82 for (int ii = 0; ii < nbelem_tot; ii++) Sigma_tab(ii, ind_trav) = sig(ii);
83 }
84 else if (milc.has_interface(k, l))
85 {
86 Interface_base& sat = milc.get_interface(k,l);
87 const int ind_trav = (k*(N-1)-(k-1)*(k)/2) + (l-k-1); // Et oui ! matrice triang sup !
88 for (i = 0 ; i<nbelem_tot ; i++)
89 Sigma_tab(i,ind_trav) = res_en_T ? sat.sigma(temp(i,k),press(i,k * (Np > 1))) : sat.sigma_h(temp(i,k),press(i,k * (Np > 1)));
90 }
91 }
92
93
94 for (f = 0 ; f<domaine.nb_faces() ; f++)
95 if (fcl(f, 0) < 2)
96 {
97 in.alpha=0., in.T=0., in.p=0., in.rho=0., in.mu=0., in.sigma=0., in.k_turb=0., in.d_bulles=0., in.nv=0.;
98 for ( c = 0; c < 2 ; c++)
99 if ((e = f_e(f, c)) >= 0 )
100 {
101 for (n = 0; n < N; n++)
102 {
103 in.alpha[n] += vf_dir(f, c)/vf(f) * alpha(e, n);
104 in.p[n] += vf_dir(f, c)/vf(f) * press(e, n * (Np > 1));
105 in.T[n] += vf_dir(f, c)/vf(f) * temp(e, n); // FIXME SI res_en_T
106 in.rho[n] += vf_dir(f, c)/vf(f) * rho(!cR * e, n);
107 in.mu[n] += vf_dir(f, c)/vf(f) * mu(!cM * e, n);
108 in.d_bulles[n] += (d_bulles) ? vf_dir(f, c)/vf(f) *(*d_bulles)(e,n) : 0 ;
109 for (k = n+1; k < N; k++)
110 if (milc.has_interface(n,k))
111 {
112 const int ind_trav = (n*(N-1)-(n-1)*(n)/2) + (k-n-1);
113 in.sigma[ind_trav] += vf_dir(f, c) / vf(f) * Sigma_tab(e, ind_trav);
114 }
115 for (k = 0; k < N; k++)
116 in.nv(k, n) += vf_dir(f, c)/vf(f) * ch.v_norm(pvit_elem, pvit, e, f, k, n, nullptr, nullptr);
117 }
118 for (n = 0; n <Nk; n++) in.k_turb[n] += (k_turb) ? vf_dir(f, c)/vf(f) * (*k_turb)(e,0) : 0;
119 }
120
121 correlation_pi.coefficient(in, out);
122
123 // Quid de n_l != 0 ?
124 vort_l = 0;
125
126 if ( (f_e(f, 0)<0) || (f_e(f,1)<0) ) vort_l(0) = f_e(f, 0)>=0 ? vort(f_e(f, 0), n_l) : vort(f_e(f, 1), n_l) ;
127 else
128 {
129 {
130 int orif = domaine.orientation(f);
131 DoubleTrav grad_loc(D);
132 for ( c = 0; c < 2 ; c++)
133 {
134 e = f_e(f, c);
135 for ( d = 0 ; d < e_f.line_size() ; d++)
136 {
137 int fb = e_f(e,d);
138 int orifb = domaine.orientation(fb);
139 if (orifb != orif) grad_loc(orifb) += .25*pvit(fb, n_l)/(xv(fb, orif)-xv(f, orif));
140 }
141 }
142 DoubleTrav grad_ll(D,D);
143 for ( c = 0; c < 2 ; c++)
144 for (int d_U=0; d_U<D; d_U++)
145 for (int d_X=0; d_X<D; d_X++)
146 grad_ll(d_U,d_X) += grad_v( e, N * ( D*d_U+d_X ) + n_l) * vf_dir(f, c)/vf(f);
147 for (int oril = 0 ; oril<D ; oril++)
148 if (oril != orif)
149 grad_ll(oril,orif) = grad_loc(oril);
150 if (D==2) vort_l(0) = grad_ll(1,0) - grad_ll(0,1);
151 else // (D==3)
152 {
153 vort_l(0) = grad_ll(2, 1) - grad_ll(1, 2); // dUz/dy - dUy/dz
154 vort_l(1) = grad_ll(0, 2) - grad_ll(2, 0); // dUx/dz - dUz/dx
155 vort_l(2) = grad_ll(1, 0) - grad_ll(0, 1); // dUy/dx - dUx/dy
156 }
157 }
158 }
159
160 // We also need to calculate relative velocity at the face
161 pvit_l = 0 ;
162 for (d = 0 ; d<D ; d++)
163 for (k = 0 ; k<N ; k++)
164 for ( c = 0; c < 2 ; c++)
165 if ((e = f_e(f, c)) >= 0 )
166 pvit_l(k, d) += vf_dir(f, c)/vf(f)*pvit_elem(e, N*d+k) ;
167 scal_u = 0;
168 for (k = 0 ; k<N ; k++)
169 for (d = 0 ; d<D ; d++)
170 scal_u(k) += pvit_l(k, d)*n_f(f, d)/fs(f);
171 for (k = 0 ; k<N ; k++)
172 for (d = 0 ; d<D ; d++)
173 pvit_l(k, d) += (pvit(f, k) - scal_u(k)) * n_f(f, d)/fs(f) ; // Corect velocity at the face
174 vl_norm = 0;
175 scal_ur = 0;
176 for (d = 0 ; d < D ; d++) vl_norm += pvit_l(n_l, d)*pvit_l(n_l, d);
177 vl_norm = std::sqrt(vl_norm);
178 if (vl_norm > 1.e-6)
179 {
180 for (k = 0; k < N; k++)
181 for (d = 0 ; d < D ; d++) scal_ur(k) += pvit_l(n_l, d)/vl_norm * (pvit_l(k, d) -pvit_l(n_l, d));
182 for (k = 0; k < N; k++)
183 for (d = 0 ; d < D ; d++) vr_l(k, d) = pvit_l(n_l, d)/vl_norm * scal_ur(k) ;
184 }
185 else for (k=0 ; k<N ; k++)
186 for (d=0 ; d<D ; d++) vr_l(k, d) = pvit_l(k, d)-pvit_l(n_l, d) ;
187
188 if (D==2)
189 {
190 // Use local vairables for the calculation of secmem
191 fac_f = beta_*pf(f) * vf(f);
192 for (k = 0; k < N; k++)
193 if (k!= n_l) // gas phase
194 {
195 secmem(f, n_l) += fac_f * n_f(f, 0)/fs(f) * out.Cl(n_l, k) * vr_l(k, 1) * vort_l(0) ;
196 secmem(f, k ) -= fac_f * n_f(f, 0)/fs(f) * out.Cl(n_l, k) * vr_l(k, 1) * vort_l(0) ;
197 secmem(f, n_l) -= fac_f * n_f(f, 1)/fs(f) * out.Cl(n_l, k) * vr_l(k, 0) * vort_l(0) ;
198 secmem(f, k ) += fac_f * n_f(f, 1)/fs(f) * out.Cl(n_l, k) * vr_l(k, 0) * vort_l(0) ;
199 } // 100% explicit
200 }
201
202 if (D==3)
203 {
204 // Use local vairables for the calculation of secmem
205 fac_f = beta_*pf(f) * vf(f);
206 for (k = 0; k < N; k++)
207 if (k!= n_l) // gas phase
208 {
209 secmem(f, n_l) += fac_f * n_f(f, 0)/fs(f) * out.Cl(n_l, k) * (vr_l(k, 1) * vort_l(2) - vr_l(k, 2) * vort_l(1)) ;
210 secmem(f, k ) -= fac_f * n_f(f, 0)/fs(f) * out.Cl(n_l, k) * (vr_l(k, 1) * vort_l(2) - vr_l(k, 2) * vort_l(1)) ;
211 secmem(f, n_l) += fac_f * n_f(f, 1)/fs(f) * out.Cl(n_l, k) * (vr_l(k, 2) * vort_l(0) - vr_l(k, 0) * vort_l(2)) ;
212 secmem(f, k ) -= fac_f * n_f(f, 1)/fs(f) * out.Cl(n_l, k) * (vr_l(k, 2) * vort_l(0) - vr_l(k, 0) * vort_l(2)) ;
213 secmem(f, n_l) += fac_f * n_f(f, 2)/fs(f) * out.Cl(n_l, k) * (vr_l(k, 0) * vort_l(1) - vr_l(k, 1) * vort_l(0)) ;
214 secmem(f, k ) -= fac_f * n_f(f, 2)/fs(f) * out.Cl(n_l, k) * (vr_l(k, 0) * vort_l(1) - vr_l(k, 1) * vort_l(0)) ;
215 } // 100% explicit
216 }
217 }
218}
class Champ_Face_VDF Cette classe sert a representer un champ vectoriel dont on ne calcule
double v_norm(const DoubleTab &val, const DoubleTab &val_f, int e, int f, int k, int l, double *v_ext, double *dnv) const
virtual DoubleTab & get_elem_vector_field(DoubleTab &, bool passe=false) const
const IntTab & fcl() const
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
virtual DoubleTab & valeurs()=0
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
class Domaine_VDF
Definition Domaine_VDF.h:64
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
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
classe Fluide_base Cette classe represente un d'un fluide incompressible ainsi que
Definition Fluide_base.h:38
double sigma_h(const double h, const double P) const
DoubleTab & get_sigma_tab()
double sigma(const double T, const double P) const
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
static int dimension
Definition Objet_U.h:99
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...
virtual bool resolution_en_T() const
virtual Equation_base & equation_qdm()
virtual Equation_base & equation_energie()
virtual Equation_base & equation_masse()
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
classe Portance_interfaciale_base utilitaire pour les operateurs de frottement interfacial prenant la...
virtual void coefficient(const input_t &input, output_t &output) const =0
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const 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 QDM_Multiphase Cette classe porte les termes de l'equation de la dynamique
Classe de base des flux de sortie.
Definition Sortie.h:52
Classe Source_Portance_interfaciale_base.
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
int line_size() const
Definition TRUSTVect.tpp:67