TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Solveur_Masse_Face_proto.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 <Solveur_Masse_Face_proto.h>
17#include <Masse_ajoutee_base.h>
18#include <Pb_Multiphase.h>
19#include <Matrix_tools.h>
20#include <TRUSTTrav.h>
21#include <Domaine_VF.h>
22
24{
25 solv_mass_ = sm;
26 le_dom_ = zvf;
27}
28
30{
31 const Domaine_VF& domaine = le_dom_.valeur();
32 const IntTab& f_e = domaine.face_voisins();
33 const DoubleVect& pf = solv_mass_->equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces();
34 const DoubleTab *a_r = sub_type(QDM_Multiphase, solv_mass_->equation()) ? &ref_cast(Pb_Multiphase, solv_mass_->equation().probleme()).equation_masse().champ_conserve().passe() : nullptr,
35 &vfd = domaine.volumes_entrelaces_dir();
36 int i, e, f, n, N = solv_mass_->equation().inconnue().valeurs().line_size();
37 double fac;
38
39 //vitesses aux faces
40 for (f = 0; f < domaine.nb_faces(); f++)
41 for (n = 0; n < N; n++)
42 {
43 for (fac = 0, i = 0; i < 2; i++)
44 if ((e = f_e(f, i)) >= 0)
45 fac += vfd(f, i) / vf(f) * (a_r ? (*a_r)(e, n) : 1);
46 if (fac > 1e-10)
47 sm(f, n) /= pf(f) * vf(f) * fac; //vitesse calculee
48 else
49 sm(f, n) = 0; //cas d'une evanescence
50 }
51
53 return sm;
54}
55
56void Solveur_Masse_Face_proto::dimensionner_blocs_proto(matrices_t matrices, const tabs_t& semi_impl, const bool allocate, Stencil& sten) const
57{
58 const std::string& nom_inc = solv_mass_->equation().inconnue().le_nom().getString();
59 if (!matrices.count(nom_inc)) return; //rien a faire
60
61 Matrice_Morse& mat = *matrices.at(nom_inc), mat2;
62 const Domaine_VF& domaine = le_dom_.valeur();
63 const DoubleTab& inco = solv_mass_->equation().inconnue().valeurs();
64 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, solv_mass_->equation().probleme()) ? &ref_cast(Pb_Multiphase, solv_mass_->equation().probleme()) : nullptr;
65 const Masse_ajoutee_base *corr = pbm && pbm->has_correlation("masse_ajoutee") ? &ref_cast(Masse_ajoutee_base, pbm->get_correlation("masse_ajoutee")) : nullptr;
66 int i, f, m, n, N = inco.line_size();
67
68 for (f = 0, i = 0; f < domaine.nb_faces(); f++)
69 for (n = 0; n < N; n++, i++) //faces reelles
70 if (corr)
71 for (m = 0; m < N; m++) sten.append_line(i, N * f + m);
72 else sten.append_line(i, i);
73
74 if (allocate)
75 {
77 mat.nb_colonnes() ? mat += mat2 : mat = mat2;
78 }
79}
80
81void Solveur_Masse_Face_proto::ajouter_blocs_proto(matrices_t matrices, DoubleTab& secmem, double dt, const tabs_t& semi_impl, int resoudre_en_increments) const
82{
83 const DoubleTab& inco = solv_mass_->equation().inconnue().valeurs(), &passe = solv_mass_->equation().inconnue().passe();
84 Matrice_Morse *mat = matrices[solv_mass_->equation().inconnue().le_nom().getString()]; //facultatif
85 const Domaine_VF& domaine = le_dom_.valeur();
86 const IntTab& f_e = domaine.face_voisins();
87 const DoubleVect& pf = solv_mass_->equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces();
88 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, solv_mass_->equation().probleme()) ? &ref_cast(Pb_Multiphase, solv_mass_->equation().probleme()) : nullptr;
89 const DoubleTab& vfd = domaine.volumes_entrelaces_dir(), &rho = solv_mass_->equation().milieu().masse_volumique().passe(),
90 *alpha = pbm ? &pbm->equation_masse().inconnue().passe() : nullptr, *a_r = pbm ? &pbm->equation_masse().champ_conserve().passe() : nullptr;
91 const Masse_ajoutee_base *corr = pbm && pbm->has_correlation("masse_ajoutee") ? &ref_cast(Masse_ajoutee_base, pbm->get_correlation("masse_ajoutee")) : nullptr;
92 int i, e, f, m, n, N = inco.line_size(), cR = rho.dimension_tot(0) == 1;
93
94 /* faces : si CLs, pas de produit par alpha * rho en multiphase */
95 DoubleTrav masse(N, N), masse_e(N, N); //masse alpha * rho, contribution
96 for (f = 0; f < domaine.nb_faces(); f++) //faces reelles
97 {
98 if (!pbm)
99 for (masse = 0, n = 0; n < N; n++) masse(n, n) = vf(f); //pas Pb_Multiphase ou CL -> pas de alpha * rho
100 else for (masse = 0, i = 0; i < 2; i++)
101 if ((e = f_e(f, i)) >= 0)
102 {
103 for (masse_e = 0, n = 0; n < N; n++) masse_e(n, n) = (*a_r)(e, n); //partie diagonale
104 if (corr) corr->ajouter(&(*alpha)(e, 0), &rho(!cR * e, 0), masse_e); //partie masse ajoutee
105 for (n = 0; n < N; n++)
106 for (m = 0; m < N; m++) masse(n, m) += vfd(f, i) * masse_e(n, m); //contribution au alpha * rho de la face
107 }
108 for (n = 0; n < N; n++)
109 {
110 for (m = 0; m < N; m++) secmem(f, n) += pf(f) / dt * masse(n, m) * (passe(f, m) - resoudre_en_increments * inco(f, m));
111 if (mat)
112 for (m = 0; m < N; m++)
113 if (masse(n, m)) (*mat)(N * f + n, N * f + m) += pf(f) / dt * masse(n, m);
114 }
115 }
116}
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
class Domaine_VF
Definition Domaine_VF.h:44
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
Champ_Inc_base & champ_conserve() const
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
classe Masse_ajoutee_base masse ajoutee de la forme
virtual void ajouter(const double *alpha, const double *rho, DoubleTab &a_r) const =0
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)
const std::string & getString() const
Definition Nom.h:92
virtual const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U.cpp:319
classe Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
const Equation_base & equation(int) const override
Renvoie l'equation d'hydraulique de type Navier_Stokes_std si i=0 Renvoie l'equation de la thermique ...
virtual Equation_base & equation_masse()
int has_correlation(std::string nom_correlation) const
const Correlation_base & get_correlation(std::string nom_correlation) const
classe QDM_Multiphase Cette classe porte les termes de l'equation de la dynamique
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
DoubleTab & appliquer_impl_proto(DoubleTab &) const
classe Solveur_Masse_base Represente la matrice de masse d'une equation.
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")