TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Solveur_Masse_Elem_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_Elem_proto.h>
17#include <Op_Diff_negligeable.h>
18#include <Domaine_Cl_dis_base.h>
19#include <Champ_Inc_P0_base.h>
20#include <Equation_base.h>
21#include <Probleme_base.h>
22#include <Neumann_paroi.h>
23#include <Matrix_tools.h>
24#include <Milieu_base.h>
25#include <Operateur.h>
26#include <Domaine_VF.h>
27
29{
30 solv_mass_ = sm;
31 le_dom_ = zvf;
32}
33
35{
36 solv_mass_->equation().init_champ_conserve();
37}
38
40{
41 const Domaine_VF& domaine = le_dom_.valeur();
42 const DoubleVect& ve = domaine.volumes(), &pe = solv_mass_->equation().milieu().porosite_elem();
43 const DoubleTab& der = solv_mass_->equation().champ_conserve().derivees().at(solv_mass_->equation().inconnue().le_nom().getString());
44
45 int e, ne_tot = domaine.nb_elem_tot(), n, N = sm.line_size();
46 assert(sm.dimension_tot(0) >= ne_tot && N == der.line_size());
47
48 /* partie elem */
49 for (e = 0; e < ne_tot; e++)
50 for (n = 0; n < N; n++)
51 if (std::abs(der(e, n)) > 1e-10)
52 sm(e, n) /= pe(e) * ve(e) * der(e, n);
53 else
54 sm(e, n) = 0; //cas d'une evanescence
55
56 return sm;
57}
58
59void Solveur_Masse_Elem_proto::dimensionner_blocs_proto(matrices_t matrices, const tabs_t& semi_impl) const
60{
61 solv_mass_->equation().init_champ_conserve();
62 /* une diagonale par derivee de champ_conserve_ presente dans matrices */
63 const Domaine_VF& domaine = le_dom_.valeur();
64 const Champ_Inc_base& cc = solv_mass_->equation().champ_conserve();
65 int e, ne = domaine.nb_elem(), n, N = cc.valeurs().line_size();
66
67 for (auto &&i_m : matrices)
68 if (cc.derivees().count(i_m.first))
69 {
70 /* nombre de composantes de la variable : autant que le champ par defaut, mais peut etre different pour la pression */
71 const DoubleTab& col = solv_mass_->equation().probleme().get_champ(i_m.first.c_str()).valeurs(); //tableau de l'inconnue par rapport a laquelle on derive
72 int m, M = col.line_size();
73
74 Stencil stencil(0, 2);
75
76
77 for (e = 0; e < ne; e++)
78 for (n = 0, m = 0; n < N; n++, m += (M > 1)) stencil.append_line(N * e + n, M * e + m);
79 Matrice_Morse mat;
80 Matrix_tools::allocate_morse_matrix(N * solv_mass_->equation().inconnue().valeurs().dimension_tot(0), M * col.dimension_tot(0), stencil, mat);
81 i_m.second->nb_colonnes() ? *i_m.second += mat : *i_m.second = mat;
82 }
83}
84
85void Solveur_Masse_Elem_proto::ajouter_blocs_proto(matrices_t matrices, DoubleTab& secmem, double dt, const tabs_t& semi_impl, int resoudre_en_increments) const
86{
87 const Domaine_VF& domaine = le_dom_.valeur();
88 const Champ_Inc_base& cc = solv_mass_->equation().champ_conserve();
89 const Conds_lim& cls = solv_mass_->equation().domaine_Cl_dis().les_conditions_limites();
90 const IntTab& fcl = ref_cast(Champ_Inc_P0_base, solv_mass_->equation().inconnue()).fcl(), &f_e = domaine.face_voisins();
91 const DoubleTab& present = cc.valeurs(), &passe = cc.passe();
92 const DoubleVect& ve = domaine.volumes(), &pe = solv_mass_->equation().milieu().porosite_elem(), &fs = domaine.face_surfaces();
93 int e, f, n, N = cc.valeurs().line_size(), ne = domaine.nb_elem();
94
95 /* second membre : avec ou sans resolution en increments*/
96 for (e = 0; e < ne; e++)
97 {
98 const double fac_ale = domaine.domaine().deformable() ? domaine.domaine().old_volumes()(e) / ve(e) : 1.0;
99 for (n = 0; n < N; n++)
100 secmem(e, n) += pe(e) * ve(e) * (passe(e, n) * fac_ale - resoudre_en_increments * present(e, n)) / dt;
101 }
102
103 /* si on n'a pas d'operateur de diffusion (operateur(0) negligeable ou operateur(0) convectif pour Masse_Multiphase), alors ajout des flux aux faces de Neumann */
104 if ( (sub_type(Op_Diff_negligeable, solv_mass_->equation().operateur(0).l_op_base())) || (!sub_type(Operateur_Diff_base, solv_mass_->equation().operateur(0).l_op_base())) )
105 for (f = 0; f < domaine.premiere_face_int(); f++)
106 if (fcl(f, 0) == 4)
107 for (e = f_e(f, f_e(f, 0) == -1), n = 0; n < N; n++)
108 secmem(e, n) += fs(f) * ref_cast(Neumann_paroi, cls[fcl(f, 1)].valeur()).flux_impose(fcl(f, 2), n);
109
110 /* matrices */
111 for (auto &&i_m : matrices)
112 if (cc.derivees().count(i_m.first))
113 {
114 int m, M = solv_mass_->equation().probleme().get_champ(i_m.first.c_str()).valeurs().line_size();
115 const DoubleTab& der = cc.derivees().at(i_m.first);
116 for (e = 0; e < ne; e++)
117 for (n = 0, m = 0; n < N; n++, m += (M > 1))
118 (*i_m.second)(N * e + n, M * e + m) += pe(e) * ve(e) * der(e, n) / dt;
119 }
120}
: class Champ_Inc_P0_base
Classe Champ_Inc_base.
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.
const tabs_t & derivees() const
classe Conds_lim Cette classe represente un vecteur de conditions aux limites.
Definition Conds_lim.h:32
class Domaine_VF
Definition Domaine_VF.h:44
double volumes(int i) const
Definition Domaine_VF.h:113
Champ_Inc_base & champ_conserve() const
virtual const Champ_Inc_base & inconnue() const =0
virtual const Operateur & operateur(int) const =0
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
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 Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
Classe Neumann_paroi Cette condition limite correspond a un flux impose pour l'equation de.
Classe Op_Diff_negligeable Cette classe represente un operateur de diffusion negligeable.
classe Operateur_Diff_base Cette classe est la base de la hierarchie des operateurs representant
virtual Operateur_base & l_op_base()=0
void associer_masse_proto(const Solveur_Masse_base &, const Domaine_VF &)
void dimensionner_blocs_proto(matrices_t, const tabs_t &semi_impl={}) const
void ajouter_blocs_proto(matrices_t, DoubleTab &, double, const tabs_t &, int) const
DoubleTab & appliquer_impl_proto(DoubleTab &) const
classe Solveur_Masse_base Represente la matrice de masse d'une equation.
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
int line_size() const
Definition TRUSTVect.tpp:67