TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Masse_PolyMAC_HFV_Face.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Linear_algebra_tools_impl.h>
17#include <Op_Grad_PolyMAC_HFV_Face.h>
18#include <Masse_ajoutee_base.h>
19#include <Masse_PolyMAC_HFV_Face.h>
20#include <Dirichlet_homogene.h>
21#include <Champ_Face_PolyMAC_HFV.h>
22#include <Schema_Temps_base.h>
23#include <Domaine_Cl_PolyMAC_family.h>
24#include <Champ_Uniforme.h>
25#include <Equation_base.h>
26#include <Pb_Multiphase.h>
27#include <Domaine_PolyMAC_HFV.h>
28#include <Matrix_tools.h>
29#include <Array_tools.h>
30#include <Matrice33.h>
31#include <Dirichlet.h>
32#include <Symetrie.h>
33#include <Vecteur3.h>
34#include <Debog.h>
35#include <Piso.h>
36
37Implemente_instanciable(Masse_PolyMAC_HFV_Face, "Masse_PolyMAC_HFV_Face", Masse_PolyMAC_HFV_base);
38
39Sortie& Masse_PolyMAC_HFV_Face::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
40
42
44{
45 Solveur_Masse_Face_proto::associer_masse_proto(*this,le_dom_PolyMAC_CDO.valeur());
46}
47
48// XXX : to check if Solveur_Masse_Face_proto::appliquer_impl_proto can be used here ...
49DoubleTab& Masse_PolyMAC_HFV_Face::appliquer_impl(DoubleTab& sm) const
50{
51 const Domaine_PolyMAC_CDO& domaine = le_dom_PolyMAC_CDO.valeur();
52 const IntTab& f_e = domaine.face_voisins();
53 const DoubleVect& pf = equation().milieu().porosite_face();
54 int i, e, f, n, N = equation().inconnue().valeurs().line_size();
55 const DoubleTab *a_r = sub_type(QDM_Multiphase, equation()) ? &ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().champ_conserve().passe() : nullptr,
56 &vfd = domaine.volumes_entrelaces_dir();
57 double fac;
58
59 //velocities at faces
60 for (f = 0; f < domaine.nb_faces(); f++)
61 for (n = 0; n < N; n++)
62 {
63 for (fac = 0, i = 0; i < 2 && (e = f_e(f, i)) >= 0; i++) fac += vfd(f, i) * (a_r ? (*a_r)(e, n) : 1);
64 sm(f, n) /= pf(f) * fac; //computed velocity
65 }
66
68 return sm;
69}
70
71void Masse_PolyMAC_HFV_Face::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
72{
73 Stencil sten(0, 2);
74
75 Solveur_Masse_Face_proto::dimensionner_blocs_proto(matrices, semi_impl, true /* allocate too */, sten);
76}
77
78void Masse_PolyMAC_HFV_Face::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, double dt, const tabs_t& semi_impl, int resoudre_en_increments) const
79{
80 Solveur_Masse_Face_proto::ajouter_blocs_proto( matrices, secmem, dt,semi_impl, resoudre_en_increments);
81}
82
83//used to impose Dirichlet BCs in multiphase (where the variation of P_bord can only correct v_melange)
84DoubleTab& Masse_PolyMAC_HFV_Face::corriger_solution(DoubleTab& x, const DoubleTab& y, int incr) const
85{
86 const Domaine_PolyMAC_CDO& domaine = le_dom_PolyMAC_CDO.valeur();
87 const Conds_lim& cls = le_dom_Cl_PolyMAC_CDO->les_conditions_limites();
88 const IntTab& fcl = ref_cast(Champ_Face_PolyMAC_HFV, equation().inconnue()).fcl();
89 const DoubleTab& nf = domaine.face_normales(), &vit = equation().inconnue().valeurs();
90 const DoubleVect& fs = domaine.face_surfaces();
91 int f, n, N = x.line_size(), d, D = dimension;
92
93 for (f = 0; f < domaine.nb_faces_tot(); f++)
94 if (fcl(f, 0) == 2 || fcl(f, 0) == 4)
95 for (n = 0; n < N; n++) x(f, n) = incr ? -vit(f, n) : 0; //homogeneous Dirichlet / Symmetry: reset to 0
96 else if (fcl(f, 0) == 3)
97 for (n = 0; n < N; n++)
98 for (x(f, n) = incr ? -vit(f, n) : 0, d = 0; d < D; d++) //Dirichlet: BC value
99 x(f, n) += nf(f, d) / fs(f) * ref_cast(Dirichlet, cls[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), N * d + n);
100
101 return x;
102}
: class Champ_Face_PolyMAC_HFV
DoubleTab & valeurs() override
Returns the array of field values at the current time.
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
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
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, double dt, const tabs_t &semi_impl, int resoudre_en_increments) const override
DoubleTab & appliquer_impl(DoubleTab &) const override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl) const override
virtual DoubleTab & corriger_solution(DoubleTab &x, const DoubleTab &y, int incr=0) const override
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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 const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
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":
Carries the terms of the momentum equation for multiphase flow without turbulence modelling.
void associer_masse_proto(const Solveur_Masse_base &, const Domaine_VF &)
void ajouter_blocs_proto(matrices_t matrices, DoubleTab &secmem, double dt, const tabs_t &semi_impl, int resoudre_en_increments) const
void dimensionner_blocs_proto(matrices_t matrices, const tabs_t &semi_impl, const bool allocate, Stencil &) const
Base class for output streams.
Definition Sortie.h:52
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")