TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Perte_Charge_Singuliere_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 <Perte_Charge_Singuliere_PolyMAC_HFV_Face.h>
17#include <Op_Grad_PolyMAC_HFV_Face.h>
18#include <Champ_Face_PolyMAC_HFV.h>
19#include <Domaine_PolyMAC_MPFA.h>
20#include <Equation_base.h>
21#include <Probleme_base.h>
22#include <Matrice_Morse.h>
23#include <Pb_Multiphase.h>
24#include <Matrix_tools.h>
25#include <Array_tools.h>
26#include <Domaine.h>
27
28Implemente_instanciable(Perte_Charge_Singuliere_PolyMAC_HFV_Face, "Perte_Charge_Singuliere_Face_PolyMAC_HFV|Perte_Charge_Singuliere_Face_PolyMAC_MPFA", Perte_Charge_Singuliere_PolyMAC_CDO_Face);
29
31
33
35{
37 // eq_masse besoin de champ_conserve !
38 if (sub_type(Pb_Multiphase, mon_equation->probleme())) ref_cast(Pb_Multiphase, mon_equation->probleme()).equation_masse().init_champ_conserve();
39}
40
41void Perte_Charge_Singuliere_PolyMAC_HFV_Face::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
42{
43 const Domaine_Poly_base& domaine = ref_cast(Domaine_Poly_base, equation().domaine_dis());
44 const IntTab& f_e = domaine.face_voisins(), &fcl = ref_cast(Champ_Face_PolyMAC_HFV, equation().inconnue()).fcl();
45 const std::string& nom_inco = equation().inconnue().le_nom().getString();
46 if (!matrices.count(nom_inco) || !sub_type(Domaine_PolyMAC_MPFA, domaine)) return;
47 Matrice_Morse& mat = *matrices.at(nom_inco), mat2;
48 int i, j, e, f, n, N = equation().inconnue().valeurs().line_size(), d, D = dimension, nf_tot = domaine.nb_faces_tot();
49 //DoubleTrav aar_f(N); //alpha * alpha * rho a chaque face
50 Stencil stencil(0, 2);
51
52
53 for (i = 0; i < num_faces.size(); i++)
54 if ((f = num_faces(i)) < domaine.nb_faces() && fcl(f, 0) < 2)
55 for (j = 0; j < 2 && (e = f_e(f, j)) >= 0; j++) //elem amont / aval si PolyMAC_HFV V2
56 if (e < domaine.nb_elem())
57 for (d = 0; d < D; d++)
58 for (n = 0; n < N; n++) stencil.append_line(N * (nf_tot + D * e + d) + n, N * f + n);
59 tableau_trier_retirer_doublons(stencil);
60 Matrix_tools::allocate_morse_matrix(equation().inconnue().valeurs().size_totale(), equation().inconnue().valeurs().size_totale(), stencil, mat2);
61 mat.nb_colonnes() ? mat += mat2 : mat = mat2;
62}
63
64void Perte_Charge_Singuliere_PolyMAC_HFV_Face::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
65{
66 const Domaine_Poly_base& domaine = ref_cast(Domaine_Poly_base, equation().domaine_dis());
67 //const DoubleVect& volumes_entrelaces = domaine_PolyMAC_HFV.volumes_entrelaces();
68 const DoubleVect& pf = equation().milieu().porosite_face(), &fs = domaine.face_surfaces(), &vf = domaine.volumes_entrelaces();
69 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()) : nullptr;
70 const DoubleTab& vit = la_vitesse->valeurs(), &nf = domaine.face_normales(), &vfd = domaine.volumes_entrelaces_dir(), &xv = domaine.xv(), &xp = domaine.xp(),
71 *alpha = pbm ? &pbm->equation_masse().inconnue().passe() : nullptr, *a_r = pbm ? &pbm->equation_masse().champ_conserve().passe() : nullptr;
72 const IntTab& f_e = domaine.face_voisins(), &fcl = ref_cast(Champ_Face_PolyMAC_HFV, equation().inconnue()).fcl();
73 const std::string& nom_inco = equation().inconnue().le_nom().getString();
74 Matrice_Morse *mat = matrices.count(nom_inco) ? matrices.at(nom_inco) : nullptr;
75 int i, j, e, f, n, N = equation().inconnue().valeurs().line_size();
76 int poly_v2 = sub_type(Domaine_PolyMAC_MPFA, domaine), semi = (int)semi_impl.count(nom_inco), d, D = dimension, nf_tot = domaine.nb_faces_tot();
77 DoubleTrav aar_f(N); //alpha * alpha * rho a chaque face
78 for (i = 0; i < num_faces.size(); i++)
79 if ((f = num_faces(i)) < domaine.nb_faces())
80 {
81 double fac = (direction_perte_charge() < 0 ? fs(f) : std::fabs(nf(f,direction_perte_charge()))) * pf(f) * K();
82 if (pbm)
83 for (aar_f = 0, j = 0; j < 2 && (e = f_e(f, j)) >= 0; j++)
84 for (n = 0; n < N; n++) aar_f(n) += vfd(f, j) / vf(f) * (*a_r)(e, n) * (*alpha)(e, n);
85 else aar_f = 1;
86
87 if (!poly_v2 || fcl(f, 0) < 2) //contrib a la face : sauf si face de Dirichlet/Neumann en V2
88 {
89 for (n = 0; n < N; n++) secmem(f, n) -= 0.5 * fac * aar_f(n) * vit(f, n) * std::fabs(vit(f, n));
90 if (mat)
91 for (n = 0; n < N; n++) (*mat)(N * f + n, N * f + n) += fac * aar_f(n) * std::fabs(vit(f, n));
92 }
93 if (poly_v2)
94 for (j = 0; j < 2 && (e = f_e(f, j)) >= 0; j++)
95 if (e < domaine.nb_elem()) //elem amont / aval si PolyMAC_HFV V2
96 {
97 for (d = 0; d < D; d++)
98 for (n = 0; n < N; n++) /* second membre */
99 secmem(nf_tot + D * e + d, n) += (j ? -1 : 1) * fs(f) * (xv(f, d) - xp(e, d)) * 0.5 * fac * aar_f(n) * vit(f, n) * std::fabs(vit(f, n));
100 if (mat && !semi && fcl(f, 0) < 2)
101 for (d = 0; d < D; d++)
102 for (n = 0; n < N; n++) /* derivee (pas possible en semi-implicite) */
103 (*mat)(N * (nf_tot + D * e + d) + n, N * f + n) -= (j ? -1 : 1) * fs(f) * (xv(f, d) - xp(e, d)) * fac * aar_f(n) * std::fabs(vit(f, n));
104 }
105 }
106}
: class Champ_Face_PolyMAC_HFV
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
class Domaine_Poly_base
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
Champ_Inc_base & champ_conserve() const
virtual const Champ_Inc_base & inconnue() const =0
const Nom & le_nom() const override
Renvoie le nom du champ.
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
int nb_colonnes() const override
Return local number of columns (=size on the current proc).
static void allocate_morse_matrix(const int nb_lines, const int nb_columns, const Stencil &stencil, Matrice_Morse &matrix, const bool &attach_stencil_to_matrix=false)
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
const std::string & getString() const
Definition Nom.h:92
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
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 Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
virtual Equation_base & equation_masse()
class Perte_Charge_Singuliere_PolyMAC_CDO_Face
class Perte_Charge_Singuliere_PolyMAC_HFV_Face
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override
void completer() override
Met a jour les references internes a l'objet Source_base.
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
int direction_perte_charge() const
Renvoie la direction de perte de charge.
Classe de base des flux de sortie.
Definition Sortie.h:52
virtual void completer()
Met a jour les references internes a l'objet Source_base.
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
int line_size() const
Definition TRUSTVect.tpp:67