TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Dispersion_bulles_VDF.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 <Viscosite_turbulente_base.h>
17#include <Dispersion_bulles_base.h>
18#include <Dispersion_bulles_VDF.h>
19#include <Operateur_Diff_base.h>
20#include <Milieu_composite.h>
21#include <Masse_Multiphase.h>
22#include <Champ_Face_VDF.h>
23#include <Operateur_Grad.h>
24#include <Pb_Multiphase.h>
25#include <Domaine_VF.h>
26
27Implemente_instanciable(Dispersion_bulles_VDF, "Dispersion_bulles_VDF_Face", Source_Dispersion_bulles_base);
28
29Sortie& Dispersion_bulles_VDF::printOn(Sortie& os) const { return os; }
30
32{
34 if (ref_cast(Operateur_Diff_base, equation().operateur(0).l_op_base()).is_turb()) is_turb = 1;
35 return is;
36}
37
38void Dispersion_bulles_VDF::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
39{
40 const Pb_Multiphase& pbm = ref_cast(Pb_Multiphase, equation().probleme());
41 const bool res_en_T = pbm.resolution_en_T();
42 if (!res_en_T) Process::exit("Dispersion_bulles_VDF::ajouter_blocs NOT YET PORTED TO ENTHALPY EQUATION ! TODO FIXME !!");
43
44 const Champ_Face_VDF& ch = ref_cast(Champ_Face_VDF, equation().inconnue());
45 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
46 const IntTab& f_e = domaine.face_voisins(), &fcl = ch.fcl();
47 const DoubleVect& pf = equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces();
48 const DoubleTab& vf_dir = domaine.volumes_entrelaces_dir();
49 const DoubleTab& pvit = ch.passe(),
50 &alpha = pbm.equation_masse().inconnue().passe(),
51 &press = ref_cast(QDM_Multiphase, pbm.equation_qdm()).pression().passe(),
52 &temp = pbm.equation_energie().inconnue().passe(),
53 &rho = equation().milieu().masse_volumique().passe(),
54 &mu = ref_cast(Fluide_base, equation().milieu()).viscosite_dynamique().passe();
55 const Milieu_composite& milc = ref_cast(Milieu_composite, equation().milieu());
56
57 DoubleTab const * d_bulles = (equation().probleme().has_champ("diametre_bulles")) ? &equation().probleme().get_champ("diametre_bulles").valeurs() : nullptr ;
58 DoubleTab const * k_turb = (equation().probleme().has_champ("k")) ? &equation().probleme().get_champ("k").passe() : nullptr ;
59
60 int N = pvit.line_size() , Np = press.line_size(), nf_tot = domaine.nb_faces_tot(), nf = domaine.nb_faces(), ne_tot = domaine.nb_elem_tot(), cR = (rho.dimension_tot(0) == 1), cM = (mu.dimension_tot(0) == 1), Nk = (k_turb) ? (*k_turb).dimension(1) : 1;
61 DoubleTrav nut(domaine.nb_elem_tot(), N); //viscosite turbulente
62 if (is_turb) ref_cast(Viscosite_turbulente_base, (*ref_cast(Operateur_Diff_base, equation().operateur(0).l_op_base()).correlation_viscosite_turbulente())).eddy_viscosity(nut); //remplissage par la correlation
63
64 // Input-output
65 const Dispersion_bulles_base& correlation_db = ref_cast(Dispersion_bulles_base, correlation_.valeur());
68 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.nut.resize(N), in.d_bulles.resize(N), in.nv.resize(N, N);
69 out.Ctd.resize(N, N);
70
71 /* Calcul de grad alpha aux faces */
72
73 DoubleTrav grad_f_a(nf_tot, N);
74 assert ( alpha.dimension_tot(0) == ne_tot );
75 const Masse_Multiphase& eq_alp = ref_cast(Masse_Multiphase, pbm.equation_masse());
76 const Operateur_Grad& Op_Grad_alp = eq_alp.operateur_gradient_inconnue();
77 Op_Grad_alp.calculer(alpha,grad_f_a); // compute grad(diss) at faces
78
79 // Vitesse passee aux elems
80 DoubleTab pvit_elem(0, N * dimension);
81 domaine.domaine().creer_tableau_elements(pvit_elem);
82 ch.get_elem_vector_field(pvit_elem, true);
83
84 // Et pour les methodes span de la classe Interface pour choper la tension de surface
85 const int nb_max_sat = N * (N-1) /2; // oui !! suite arithmetique !!
86 DoubleTrav Sigma_tab(ne_tot,nb_max_sat);
87
88 // remplir les tabs ...
89 for (int k = 0; k < N; k++)
90 for (int l = k + 1; l < N; l++)
91 {
92 if (milc.has_saturation(k, l))
93 {
94 Saturation_base& z_sat = milc.get_saturation(k, l);
95 const int ind_trav = (k*(N-1)-(k-1)*(k)/2) + (l-k-1); // Et oui ! matrice triang sup !
96 // recuperer sigma ...
97 const DoubleTab& sig = z_sat.get_sigma_tab();
98 // fill in the good case
99 for (int ii = 0; ii < ne_tot; ii++) Sigma_tab(ii, ind_trav) = sig(ii);
100 }
101 else if (milc.has_interface(k, l))
102 {
103 Interface_base& sat = milc.get_interface(k,l);
104 const int ind_trav = (k*(N-1)-(k-1)*(k)/2) + (l-k-1); // Et oui ! matrice triang sup !
105 for (int i = 0 ; i<ne_tot ; i++)
106 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)));
107 }
108 }
109
110 /* faces */
111 for (int f = 0; f < nf; f++)
112 if (fcl(f, 0) < 2)
113 {
114 in.alpha=0., in.T=0., in.rho=0., in.mu=0., in.sigma=0., in.k_turb=0., in.nut=0., in.d_bulles=0., in.nv=0.;
115 int e;
116 for (int c = 0; c < 2 && (e = f_e(f, c)) >= 0; c++)
117 {
118 for (int n = 0; n < N; n++)
119 {
120 in.alpha[n] += vf_dir(f, c)/vf(f) * alpha(e, n);
121 in.p[n] += vf_dir(f, c)/vf(f) * press(e, n * (Np > 1));
122 in.T[n] += vf_dir(f, c)/vf(f) * temp(e, n); // FIXME si res_en_T
123 in.rho[n] += vf_dir(f, c)/vf(f) * rho(!cR * e, n);
124 in.mu[n] += vf_dir(f, c)/vf(f) * mu(!cM * e, n);
125 in.nut[n] += is_turb ? vf_dir(f, c)/vf(f) * nut(e,n) : 0;
126 in.d_bulles[n] += (d_bulles) ? vf_dir(f, c)/vf(f) * (*d_bulles)(e,n) : 0;
127 for (int k = n+1; k < N; k++)
128 if (milc.has_interface(n,k))
129 {
130 const int ind_trav = (n*(N-1)-(n-1)*(n)/2) + (k-n-1);
131 in.sigma[ind_trav] += vf_dir(f, c) / vf(f) * Sigma_tab(e, ind_trav);
132 }
133 for (int k = 0; k < N; k++)
134 in.nv(k, n) += vf_dir(f, c)/vf(f) * ch.v_norm(pvit_elem, pvit, e, f, k, n, nullptr, nullptr);
135 }
136 for (int n = 0; n <Nk; n++) in.k_turb[n] += (k_turb) ? vf_dir(f, c)/vf(f) * (*k_turb)(e,0) : 0;
137 }
138
139 correlation_db.coefficient(in, out);
140
141 for (int k = 0; k < N; k++)
142 for (int l = 0; l < N; l++)
143 if (k != l)
144 {
145 double fac = beta_*pf(f) * vf(f);
146 secmem(f, k) += fac * ( - out.Ctd(k, l) * grad_f_a(f, k) + out.Ctd(l, k) * grad_f_a(f, l));
147 }
148 }
149}
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.
virtual DoubleTab & valeurs()=0
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
classe Dispersion_bulles_base utilitaire pour les operateurs de dispersion turbulente ou la force
virtual void coefficient(const input_t &input, output_t &output) const =0
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
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
classe Masse_Multiphase Cas particulier de Convection_Diffusion_std pour un fluide quasi conpressible
const Operateur_Grad & operateur_gradient_inconnue() 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 Operateur_Diff_base Cette classe est la base de la hierarchie des operateurs representant
Classe Operateur_Grad Classe generique de la hierarchie des operateurs calculant le gradient.
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
Initialise le tableau passe en parametre avec la contribution de l'operateur.
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()
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_Dispersion_bulles_base.
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
int line_size() const
Definition TRUSTVect.tpp:67
classe Viscosite_turbulente_base correlations de viscosite turbulente decrivant le tenseur de Reynold...