TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Injection_QDM_nulle_VDF.cpp
1/****************************************************************************
2* Copyright (c) 2021, 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 <Injection_QDM_nulle_VDF.h>
17#include <Source_Flux_interfacial_base.h>
18#include <Masse_ajoutee_base.h>
19#include <Milieu_composite.h>
20#include <Neumann_val_ext.h>
21#include <Saturation_base.h>
22#include <Champ_Face_VDF.h>
23#include <Neumann_paroi.h>
24#include <Pb_Multiphase.h>
25#include <Champ_P0_VDF.h>
26#include <Matrix_tools.h>
27#include <Array_tools.h>
28#include <Domaine_VF.h>
29#include <Conds_lim.h>
30#include <cfloat>
31#include <math.h>
32
33Implemente_instanciable(Injection_QDM_nulle_VDF, "Injection_QDM_nulle_VDF_Face", Source_injection_QDM_base);
34
35
36Sortie& Injection_QDM_nulle_VDF::printOn(Sortie& os) const { return os; }
37
39
40void Injection_QDM_nulle_VDF::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
41{
42 const Champ_Face_VDF& ch = ref_cast(Champ_Face_VDF, equation().inconnue());
43 const Champ_P0_VDF& cha= ref_cast(Champ_P0_VDF, equation().probleme().equation(1).inconnue()); // volume fraction
44 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
46 const Milieu_composite& milc = ref_cast(Milieu_composite, equation().milieu());
47
48 const IntTab& fcl = ch.fcl(),
49 &fcla = cha.fcl(),
50 &f_e = domaine.face_voisins(),
51 &e_f = domaine.elem_faces();
52 const DoubleVect& vf = domaine.volumes_entrelaces(),
53 &fs = domaine.face_surfaces();
54 const DoubleTab& vf_dir = domaine.volumes_entrelaces_dir();
55
56 const DoubleTab& vit = ch.valeurs(),
57 &rho = equation().milieu().masse_volumique().passe(), // passe car qdm
58 &alpha = cha.passe();
59
60 Matrice_Morse *mat = matrices.count(ch.le_nom().getString()) ? matrices.at(ch.le_nom().getString()) : nullptr; // Derivee locale/QDM
61
62 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()) : nullptr;
63 const Masse_ajoutee_base *corr = pbm && pbm->has_correlation("masse_ajoutee") ? &ref_cast(Masse_ajoutee_base, pbm->get_correlation("masse_ajoutee")) : nullptr;
64
65 int N = vit.line_size(), nf_tot = domaine.nb_faces_tot(), nf = domaine.nb_faces(), ne_tot = domaine.nb_elem_tot();
66
67 // Cas adiabatique : injection de bulles a la paroi (manip de Gabillet et al.)
68 for (int f = 0 ; f< nf_tot ; f ++)
69 if (fcla(f, 0) == 4) // Neumann_paroi
70 {
71 int e = f_e(f, 0)>-1 ? f_e(f, 0) : f_e(f, 1) ;
72 if (e>=0)
73 {
74 DoubleTrav f_a_masse(N, N) ;
75 DoubleTrav f_a(1, N);
76 for (int n = 0 ; n<N ; n++)
77 {
78 f_a_masse(n, n) = ref_cast(Neumann_paroi, clsa[fcla(f, 1)].valeur()).flux_impose(fcla(f, 2), n) * rho(e, n) ; // Pas de porosite ; unite : kg/m3 m/s
79 f_a(0, n) = ref_cast(Neumann_paroi, clsa[fcla(f, 1)].valeur()).flux_impose(fcla(f, 2), n) ; // Pas de porosite ; unite : m/s
80 }
81 corr->ajouter_inj( &f_a(0,0) , &alpha(e, 0), &rho(e, 0) , f_a_masse );
82
83 for (int i=0 ; i < e_f.line_size() ; i++)
84 {
85 int f2 = e_f(e, i);
86 if ( (f2 >= 0) && (f2<nf) && (fcl(f2, 0) < 2) ) // Si pas face de bord
87 {
88 int c = ( e == f_e(f2, 0) ) ? 0 : 1 ;
89 for (int n = 0 ; n<N ; n++)
90 for (int m = 0 ; m<N ; m++)
91 {
92 secmem(f2, n) -= fs(f) * f_a_masse(n, m) * vf_dir(f2, c) / vf(f2) * vit( f2, m) * beta_;
93 if (mat)
94 (*mat)( N * f2 + n , N * f2 + m ) += fs(f) * f_a_masse(n, m) * vf_dir(f2, c) / vf(f2) * beta_;
95 }
96 }
97 }
98 }
99 }
100
101 // Cas bouillant : on passe par qpi
102 if ( (pbm) && pbm->has_correlation("flux_parietal") )
103 {
104 const DoubleTab& qpi = ref_cast(Source_Flux_interfacial_base, pbm->equation_energie().sources().dernier().valeur()).qpi(),
105 &press = ref_cast(QDM_Multiphase, pbm->equation_qdm()).pression().passe();
106 int nb_max_sat = N*(N-1)/2;
107
108 /* limiteur de changement de phase : pas mis dans la V0 de cette force */
109
110 // On a besoin juste de l'enthalpie de changement d'etat
111 DoubleTrav Lvap_tab(ne_tot,nb_max_sat);
112 DoubleTrav f_a_masse(N, N) ;
113 DoubleTrav f_a(1, N);
114
115 for (int k = 0; k < N; k++)
116 for (int l = k + 1; l < N; l++)
117 if (milc.has_saturation(k, l))
118 {
119 Saturation_base& z_sat = milc.get_saturation(k, l);
120 const int ind_trav = (k*(N-1)-(k-1)*(k)/2) + (l-k-1); // Et oui ! matrice triang sup !
121 assert (press.line_size() == 1);
122
123 z_sat.Lvap(press.get_span_tot(), Lvap_tab.get_span_tot(), nb_max_sat, ind_trav);
124 }
125
126 for (int f = 0 ; f< nf_tot ; f ++)
127 if ( (f_e(f, 0)<= 0) || (f_e(f, 1)<= 0)) // Si face de bord
128 if ( fs(f) > DBL_MIN ) // Si pas dans le milieu d'un bidim_axi
129 {
130 int e = f_e(f, 0)>-1 ? f_e(f, 0) : f_e(f, 1) ;
131 f_a_masse = 0;
132 f_a = 0;
133 double G=0;
134
135 for (int k = 0; k < N; k++)
136 for (int l = k + 1; l < N; l++)
137 if (milc.has_saturation(k, l)) //flux phase k <-> phase l si saturation
138 {
139 const int i_sat = (k*(N-1)-(k-1)*(k)/2) + (l-k-1); // Et oui ! matrice triang sup !
140
141 G = qpi(e, k, l) / Lvap_tab(e, i_sat) ; // Flux de matiere de la phase k vers l ; attention : qpi est en W, donc G en kgs-1 : il n'est pas volumique !
142
143 f_a(0, k) -= G/(fs(f)*rho(e, k)) ;
144 f_a_masse(k, k) -= G/fs(f) ;
145 f_a(0, l) += G/(fs(f)*rho(e, l)) ;
146 f_a_masse(l, l) += G/fs(f) ;
147
148 }
149
150 corr->ajouter_inj( &f_a(0,0) , &alpha(e, 0), &rho(e, 0) , f_a_masse );
151
152 for (int i=0 ; i < e_f.line_size() ; i++)
153 {
154 int f2 = e_f(e, i);
155 if ( (f2 >= 0) && (f2<nf) && (fcl(f2, 0) < 2) ) // Si pas face de bord
156 {
157 int c = ( e == f_e(f2, 0) ) ? 0 : 1 ;
158 for (int n = 0 ; n<N ; n++)
159 for (int m = 0 ; m<N ; m++)
160 {
161 secmem(f2, n) -= fs(f) * f_a_masse(n, m) * vf_dir(f2, c) / vf(f2) * vit( f2, m) * beta_ ;
162 if (mat)
163 (*mat)( N * f2 + n , N * f2 + m ) += fs(f) * f_a_masse(n, m) * vf_dir(f2, c) / vf(f2) * beta_ ;
164 }
165 }
166 }
167 }
168 }
169}
class Champ_Face_VDF
const IntTab & fcl() const
const IntTab & fcl() const
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
const Domaine_Cl_dis_base & domaine_Cl_dis() const
DoubleTab & valeurs() override
Returns the array of field values at the current time.
class Champ_P0_VDF Class representing a P0 discrete field per element associated with a discretized d...
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
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
Sources & sources()
Returns the source terms associated with the equation.
const Nom & le_nom() const override
Returns the name of the field.
classe Injection_QDM_nulle_VDF Correction de la QDM d'un fluide de l'écoulement quand on en injecte
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
Added-mass correlation of the form: alpha_k rho_k Dv_k / Dt -> alpha_k rho_k Dv_k / Dt + sum_l ma(k,...
virtual void ajouter_inj(const double *flux_alpha, const double *alpha, const double *rho, DoubleTab &f_a_r) const =0
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).
Composite medium representing a multiphase fluid and its properties:
bool has_saturation(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
Classe Neumann_paroi This boundary condition corresponds to an imposed flux for the.
const std::string & getString() const
Definition Nom.h:92
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 Equation_base & equation_qdm()
virtual Equation_base & equation_energie()
int has_correlation(std::string nom_correlation) const
const Correlation_base & get_correlation(std::string nom_correlation) const
Carries the terms of the momentum equation for multiphase flow without turbulence modelling.
void Lvap(const SpanD P, SpanD res, int ncomp=1, int ind=0) const
Base class for output streams.
Definition Sortie.h:52
Interfacial flux source term (implemented in PolyMAC_HFV) of the form:
classe Injection_QDM_nulle_VDF Correction de la QDM d'un fluide de l'écoulement quand on en injecte
int line_size() const
Definition TRUSTVect.tpp:67