TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Frottement_interfacial_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 <Frottement_interfacial_base.h>
17#include <Frottement_interfacial_VDF.h>
18#include <Milieu_composite.h>
19#include <Champ_Face_VDF.h>
20#include <Pb_Multiphase.h>
21
22Implemente_instanciable(Frottement_interfacial_VDF, "Frottement_interfacial_VDF_Face", Source_Frottement_interfacial_base);
23
24Sortie& Frottement_interfacial_VDF::printOn(Sortie& os) const { return os; }
26
27void Frottement_interfacial_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("Frottement_interfacial_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 Matrice_Morse *mat = matrices.count(ch.le_nom().getString()) ? matrices.at(ch.le_nom().getString()) : nullptr;
35 const Domaine_VDF& domaine = ref_cast(Domaine_VDF, equation().domaine_dis());
36 const IntTab& f_e = domaine.face_voisins(), &fcl = ch.fcl();
37 const DoubleVect& pf = equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces(),
39 const DoubleTab& inco = ch.valeurs(), &pvit = ch.passe(), &vfd = domaine.volumes_entrelaces_dir(),
40 &alpha = pbm.equation_masse().inconnue().passe(),
41 &press = ref_cast(QDM_Multiphase, equation()).pression().passe(),
42 &temp = pbm.equation_energie().inconnue().passe(),
43 &rho = equation().milieu().masse_volumique().passe(),
44 &mu = ref_cast(Fluide_base, equation().milieu()).viscosite_dynamique().passe();
45
46 const Milieu_composite& milc = ref_cast(Milieu_composite, equation().milieu());
47
48 DoubleTab const *d_bulles = (equation().probleme().has_champ("diametre_bulles")) ? &equation().probleme().get_champ("diametre_bulles").valeurs() : nullptr;
49
50 int e, f, c, i, j, k, l, n, N = inco.line_size(), Np = press.line_size(), cR = (rho.dimension_tot(0) == 1), cM = (mu.dimension_tot(0) == 1);
51 DoubleTrav a_l(N), p_l(N), T_l(N), rho_l(N), mu_l(N), sigma_l(N*(N-1)/2), dv(N, N), ddv(N, N, 4), d_bulles_l(N), coeff(N, N, 2); //arguments for coeff
52 double ddv_c[4] = {0., 0., 0., 0. };
53 double dh;
54 const Frottement_interfacial_base& correlation_fi = ref_cast(Frottement_interfacial_base, correlation_.valeur());
55
56 DoubleTab pvit_elem(0, N * dimension);
57 domaine.domaine().creer_tableau_elements(pvit_elem);
58 ch.get_elem_vector_field(pvit_elem, true);
59
60 // For the span methods of the Saturation class
61 const int ne_tot = domaine.nb_elem_tot(), nb_max_sat = N * (N-1) /2; // yes!! arithmetic sequence!!
62 DoubleTrav Sigma_tab(ne_tot,nb_max_sat);
63
64 // fill the arrays ...
65 for (k = 0; k < N; k++)
66 for (l = k + 1; l < N; l++)
67 {
68 if (milc.has_saturation(k, l))
69 {
70 Saturation_base& z_sat = milc.get_saturation(k, l);
71 const int ind_trav = (k*(N-1)-(k-1)*(k)/2) + (l-k-1); // Yes! upper triangular matrix!
72 // retrieve sigma ...
73 const DoubleTab& sig = z_sat.get_sigma_tab();
74 // fill in the good case
75 for (int ii = 0; ii < ne_tot; ii++) Sigma_tab(ii, ind_trav) = sig(ii);
76 }
77 else if (milc.has_interface(k, l))
78 {
79 Interface_base& sat = milc.get_interface(k,l);
80 const int ind_trav = (k*(N-1)-(k-1)*(k)/2) + (l-k-1); // Yes! upper triangular matrix!
81 for (i = 0 ; i<ne_tot ; i++)
82 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)));
83 }
84 }
85
86 /* faces */
87 for (f = 0; f < domaine.nb_faces(); f++)
88 if (fcl(f, 0) < 2)
89 {
90 a_l = 0, p_l = 0, T_l = 0, rho_l = 0, mu_l = 0, dh = 0, sigma_l = 0, dv = dv_min, ddv = 0, d_bulles_l = 0;
91 for (c = 0; c < 2 ; c++)
92 if( (e = f_e(f, c)) >= 0 )
93 for (n = 0; n < N; n++)
94 {
95 a_l(n) += vfd(f, c) / vf(f) * alpha(e, n);
96 p_l(n) += vfd(f, c) / vf(f) * press(e, n * (Np > 1));
97 T_l(n) += vfd(f, c) / vf(f) * temp(e, n); // FIXME SI res_en_T
98 rho_l(n) += vfd(f, c) / vf(f) * rho(!cR * e, n);
99 mu_l(n) += vfd(f, c) / vf(f) * mu(!cM * e, n);
100 for (k = n+1; k < N; k++)
101 if (milc.has_interface(n, k))
102 {
103 const int ind_trav = (n*(N-1)-(n-1)*(n)/2) + (k-n-1);
104 sigma_l(ind_trav) += vfd(f, c) / vf(f) * Sigma_tab(e, ind_trav);
105 }
106 dh += vfd(f, c) / vf(f) * alpha(e, n) * dh_e(e);
107
108 for (k = 0; k < N; k++)
109 {
110 double dv_c = ch.v_norm(pvit_elem, pvit, e, f, k, n, nullptr, &ddv_c[0]);
111 if (dv_c > dv(k, n))
112 for (dv(k, n) = dv_c, i = 0; i < 4; i++)
113 ddv(k, n, i) = ddv_c[i];
114 }
115 d_bulles_l(n) += (d_bulles) ? vfd(f, c) / vf(f) * (*d_bulles)(e, n) : 0;
116 }
117
118 correlation_fi.coefficient(a_l, p_l, T_l, rho_l, mu_l, sigma_l, dh, dv, d_bulles_l, coeff);
119 for (k = 0; k < N; k++)
120 for (l = 0; l < N; l++)
121 for (j = 0; j < 2; j++)
122 coeff(k, l, j) *= 1 + (a_l(k) > 1e-8 ? std::pow(a_l(k) / a_res_, -exp_res) : 0) + (a_l(l) > 1e-8 ? std::pow(a_l(l) / a_res_, -exp_res) : 0);
123
124 /* contributions: take the max between the two sides */
125 for (k = 0; k < N; k++)
126 for (l = 0; l < N; l++)
127 if (k != l)
128 {
129 double fac = pf(f) * vf(f);
130 /* attempt to implicitize coeff without slowing convergence by performing a limited expansion around pvit (in the direction of interest only) */
131 secmem(f, k) -= fac * (coeff(k, l, 0) * (inco(f, k) - inco(f, l)) + coeff(k, l, 1) * ddv(k, l, 3) * (pvit(f, k) - pvit(f, l)) * ((inco(f, k) - inco(f, l)) - (pvit(f, k) - pvit(f, l))));
132 if (mat)
133 for (j = 0; j < 2; j++)
134 (*mat)(N * f + k, N * f + (j ? l : k)) += fac * (j ? -1 : 1) * (coeff(k, l, 0) + coeff(k, l, 1) * ddv(k, l, 3) * (pvit(f, k) - pvit(f, l)));
135 }
136
137 }
138}
class Champ_Face_VDF
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
Returns field values at instant t-i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & valeurs()=0
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
class Domaine_VDF
Definition Domaine_VDF.h:61
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()
Returns the problem associated with the equation.
const Nom & le_nom() const override
Returns the name of the field.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
Frottement_interfacial_base class: utility for interfacial friction operators taking the form.
virtual void coefficient(const DoubleTab &alpha, const DoubleTab &p, const DoubleTab &T, const DoubleTab &rho, const DoubleTab &mu, const DoubleTab &sigma, double Dh, const DoubleTab &ndv, const DoubleTab &d_bulles, DoubleTab &coeff) const =0
double sigma_h(const double h, const double P) const
DoubleTab & get_sigma_tab()
double sigma(const double T, const double P) const
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
DoubleTab & diametre_hydraulique_elem()
Definition Milieu_base.h:70
DoubleVect & porosite_face()
Definition Milieu_base.h:62
Composite medium representing a multiphase fluid and its properties:
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
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
const std::string & getString() const
Definition Nom.h:92
static int dimension
Definition Objet_U.h:94
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":
virtual bool resolution_en_T() const
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)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Carries the terms of the momentum equation for multiphase flow without turbulence modelling.
Base class for output streams.
Definition Sortie.h:52
Interfacial friction source term of the form:
int line_size() const
Definition TRUSTVect.tpp:67