TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_BIF_PolyMAC_MPFA.cpp
1/****************************************************************************
2* Copyright (c) 2022, 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 <Source_BIF_PolyMAC_MPFA.h>
17
18#include <Domaine_PolyMAC_MPFA.h>
19#include <Champ_Elem_PolyMAC_MPFA.h>
20#include <Matrix_tools.h>
21#include <Probleme_base.h>
22#include <grad_Champ_Face_PolyMAC_MPFA.h>
23#include <Champ_Uniforme.h>
24#include <Flux_interfacial_base.h>
25#include <Milieu_composite.h>
26#include <Operateur_Diff.h>
27#include <Op_Diff_Turbulent_PolyMAC_MPFA_Face.h>
28#include <Navier_Stokes_std.h>
29#include <Viscosite_turbulente_base.h>
30#include <Viscosite_turbulente_multiple.h>
31#include <TRUSTTab_parts.h>
32
33
34Implemente_instanciable(Source_BIF_PolyMAC_MPFA,"Source_BIF_Face_PolyMAC_MPFA", Source_base);
35// XD Source_BIF source_base Source_BIF BRACE Additional fluctuations induced by the movement of bubbles, only available
36// XD_CONT in PolyMAC_MPFA
37
39{
40 return os;
41}
42
44{
45 if (!sub_type(Viscosite_turbulente_multiple, ref_cast(Op_Diff_Turbulent_PolyMAC_MPFA_Face, ref_cast(Navier_Stokes_std, equation().probleme().equation(0)).operateur(0).l_op_base()).correlation()))
46 Process::exit(que_suis_je() + " : the turbulence correlation must be multiple");
47
48 Param param(que_suis_je());
49 param.lire_avec_accolades_depuis(is);
50
51 return is;
52}
53
54void Source_BIF_PolyMAC_MPFA::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
55{
56// empty : no derivative to add in the blocks
57}
58
59void Source_BIF_PolyMAC_MPFA::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
60{
61 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, equation().domaine_dis());
62 const Probleme_base& pb = ref_cast(Probleme_base, equation().probleme());
63 const Navier_Stokes_std& eq_qdm = ref_cast(Navier_Stokes_std, pb.equation(0));
65 const DoubleTab& tab_rho = equation().probleme().get_champ("masse_volumique").passe();
66 const DoubleTab& tab_alp = equation().probleme().get_champ("alpha").passe();
67
68 const DoubleTab& vf_dir = domaine.volumes_entrelaces_dir();
69 const DoubleTab& xp = domaine.xp();
70 const DoubleTab& xv = domaine.xv();
71 const DoubleVect& pe = equation().milieu().porosite_elem();
72 const DoubleVect& ve = domaine.volumes();
73 const DoubleVect& fs = domaine.face_surfaces();
74 const DoubleTab& normales_f = domaine.face_normales();
75 const IntTab& voisins_f = domaine.face_voisins();
76 const IntTab& e_f = domaine.elem_faces();
77 const IntTab& f_e = domaine.face_voisins();
78
79 const Viscosite_turbulente_multiple& visc_turb = ref_cast(Viscosite_turbulente_multiple, Op_diff.correlation());
80
81 const int N = pb.get_champ("vitesse").valeurs().dimension(1);
82 const int D = dimension;
83 const int nf_tot = domaine.nb_faces_tot();
84 const int nf = domaine.nb_faces();
85 const int ne_tot = domaine.nb_elem_tot() ;
86
87 // On recupere les tensions de reynolds des termes de BIF
88 DoubleTrav Rij(0, N, D, D);
89 MD_Vector_tools::creer_tableau_distribue(eq_qdm.pression().valeurs().get_md_vector(), Rij); //Necessary to compare size in reynolds_stress()
90 visc_turb.reynolds_stress_BIF(Rij);
91
92 DoubleTrav grad_Rij(0, N, D, D);
93 MD_Vector_tools::creer_tableau_distribue(eq_qdm.vitesse().valeurs().get_md_vector(), grad_Rij); //Necessary to exchange virtual elements after calculation of the gradient at the faces()
94
95 const Champ_Elem_PolyMAC_MPFA& ch_alpha = ref_cast(Champ_Elem_PolyMAC_MPFA, equation().probleme().get_champ("alpha")); // Champ alpha qui servira à obtenir les coeffs du gradient ; normalement toujours des CAL de Neumann ; terme source qui n'apparait qu'en multiphase
96 ch_alpha.init_grad(0); // Initialisation des tables fgrad_d, fgrad_e, fgrad_w qui dependent de la discretisation et du type de conditions aux limites --> pas de mises a jour necessaires
97
98 const IntTab& fg_d = ch_alpha.fgrad_d;
99 const IntTab& fg_e = ch_alpha.fgrad_e; // Tables utilisees dans domaine_PolyMAC_MPFA::fgrad pour le calcul du gradient
100 const DoubleTab& fg_w = ch_alpha.fgrad_w;
101
102 // On calcule le gradient de Rij aux faces
103 for (int n = 0; n < N; n++)
104 for (int f = 0; f < nf_tot; f++)
105 for (int d_i = 0; d_i <D ; d_i++)
106 for (int d_j = 0; d_j <D ; d_j++)
107 {
108 grad_Rij(f, n, d_i, d_j) = 0;
109 // grad_Rij(face, phase, x-coord, y-coord) or
110 // grad_Rij(nb_face_tot + dimension*element*gradient_component, phase, x-coord, y-coord)
111 for (int j = fg_d(f); j < fg_d(f+1) ; j++)
112 {
113 const int e = fg_e(j);
114 int f_bord {0};
115 if ( (f_bord = e - ne_tot) < 0) //contribution d'un element
116 grad_Rij(f, n, d_i, d_j) += fg_w(j) * Rij(e, n, d_i, d_j);
117 else if ( (ch_alpha.fcl()(f_bord, 0) == 1) || (ch_alpha.fcl()(f_bord, 0) == 2)
118 || (ch_alpha.fcl()(f_bord, 0) == 3) || (ch_alpha.fcl()(f_bord, 0) == 6))
119 {
120 Process::exit("You must have a neumann limit condition on alpha for RIJ_BIF to work !");
121 }
122 }
123 }
124
125 // On interpole le gradient de Rij aux elements
126 for (int n = 0; n < N; n++)
127 for (int e = 0; e < ne_tot; e++)
128 for (int d_d = 0 ; d_d < D ; d_d++) // on derive / d_d
129 for (int d_i = 0; d_i < D ; d_i++)
130 for (int d_j = 0; d_j < D ; d_j++)
131 {
132 grad_Rij(nf_tot + D *e + d_d, n, d_i, d_j) = 0;
133 for (int j = 0, f; j < e_f.dimension(1) && (f = e_f(e, j)) >= 0; j++)
134 grad_Rij(nf_tot + D *e + d_d, n, d_i, d_j) += (e == f_e(f, 0) ? 1 : -1) * fs(f) * (xv(f, d_d) - xp(e, d_d)) / ve(e) * grad_Rij(f, n, d_i, d_j);
135 }
136
137 // On calcule le second membre aux elements
138
139 for (int e = 0 ; e < ne_tot ; e++)
140 for (int n = 0; n<N ; n++)
141 for (int d_i = 0; d_i < D; d_i++)
142 {
143 double secmem_en = 0;
144 for (int d_j = 0; d_j < D; d_j++)
145 secmem_en += grad_Rij(nf_tot + D *e + d_j, n, d_i, d_j) ;
146 secmem_en *= (-1) * pe(e) * ve(e) * tab_alp(e, n) * tab_rho(e, n) ; // For us, Rij = < u_i u_j >, therefore *(-1)
147 secmem(nf_tot + e*D + d_i, n) += secmem_en;
148 }
149
150 // On calcule le second membre aux faces
151
152 int e {0};
153
154 for (int f = 0 ; f < nf ; f++)
155 for (int n = 0; n<N ; n++)
156 for (int i = 0; i < 2 && (e = voisins_f(f, i)) >= 0; i++)
157 {
158 DoubleTrav secmem_en(D); // Contains the vector of the divergence of R_ij at the face
159 secmem_en = 0;
160 for (int d_i = 0; d_i < D; d_i++)
161 for (int d_j = 0; d_j < D; d_j++)
162 secmem_en(d_i) += grad_Rij(nf_tot + D *e + d_j, n, d_i, d_j) ;
163 for (int d_i = 0; d_i < D; d_i++)
164 secmem_en(d_i) *= (-1) * pe(e) * vf_dir(f, i) * tab_alp(e, n) * tab_rho(e, n);// For us, Rij = < u_i u_j >, therefore *(-1)
165 double flux_face = domaine.dot(&normales_f(f, 0), &secmem_en(0));
166 secmem(f, n) += flux_face;
167 }
168
169}
: class Champ_Elem_PolyMAC_MPFA
void init_grad(int full_stencil) const
const IntTab & fcl() const
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 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.
static void creer_tableau_distribue(const MD_Vector &, Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Transforms v into a parallel array having the structure md.
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Navier_Stokes_std This class carries the terms of the momentum equation.
virtual const Champ_Inc_base & vitesse() const
const Operateur & operateur(int) const override
Returns the i-th operator of the equation: - terme_diffusif if i = 0.
Champ_Inc_base & pression()
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
: class Op_Diff_Turbulent_PolyMAC_MPFA_Face
const Correlation_base & correlation() const
virtual Operateur_base & l_op_base()=0
class Probleme_base It is a Probleme_U that is not a coupling.
const Champ_base & get_champ(const Motcle &nom) const override
virtual const Equation_base & equation(int) const =0
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
Classe Source_BIF_PolyMAC_MPFA Cette classe implemente dans PolyMAC_MPFA un terme source qui ajoute l...
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
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
const Champ_base & get_champ(const Motcle &nom) const override
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
virtual const MD_Vector & get_md_vector() const
Definition TRUSTVect.h:123
Composite turbulent viscosity class that can hold multiple turbulent viscosity models for single-phas...
void reynolds_stress_BIF(DoubleTab &R_ij) const