TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Variation_rho_PolyMAC_MPFA.cpp
1/****************************************************************************
2* Copyright (c) 2021, 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 <Variation_rho_PolyMAC_MPFA.h>
17#include <Domaine_PolyMAC_MPFA.h>
18#include <Pb_Multiphase.h>
19#include <Champ_Elem_PolyMAC_MPFA.h>
20#include <Matrix_tools.h>
21#include <Array_tools.h>
22#include <math.h>
23
24Implemente_instanciable(Variation_rho, "Variation_rho_Elem_PolyMAC_MPFA", Source_base);
25
27{
28 return os;
29}
30
32{
33 return is;
34}
35
36void Variation_rho::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
37{
38 const Champ_base& ch_rho = equation().milieu().masse_volumique();
39 const Champ_Inc_base *pch_rho = sub_type(Champ_Inc_base, ch_rho) ? &ref_cast(Champ_Inc_base, ch_rho) : nullptr;
40
41 if (!(pch_rho))
42 return; // Nothing to do if the term is null
43
44 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, equation().domaine_dis());
45 const int ne = domaine.nb_elem(), ne_tot = domaine.nb_elem_tot(), N = equation().inconnue().valeurs().line_size();
46
47 for (auto &&n_m : matrices)
48 if (n_m.first == "interfacial_area" || n_m.first == "temperature" || n_m.first == "pression")
49 {
50 Matrice_Morse& mat = *n_m.second, mat2;
51 const DoubleTab& dep = equation().probleme().get_champ(n_m.first.c_str()).valeurs();
52 const int nc = dep.dimension_tot(0);
53 const int M = dep.line_size();
54 Stencil sten(0, 2);
55 if (n_m.first == "interfacial_area" || n_m.first == "temperature") // N <= M
56 for (int e = 0; e < ne; e++)
57 for (int n = 0; n < N; n++)
58 sten.append_line(N * e + n, M * e + n);
59
60 if (n_m.first == "pression" )
61 for (int e = 0; e < ne; e++)
62 for (int n = 0, m = 0; n < N; n++, m+=(M>1))
63 sten.append_line(N * e + n, M * e + m);
64
65 Matrix_tools::allocate_morse_matrix(N * ne_tot, M * nc, sten, mat2);
66 mat.nb_colonnes() ? mat += mat2 : mat = mat2;
67 }
68}
69
70void Variation_rho::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
71{
72 const Champ_base& ch_rho = equation().milieu().masse_volumique();
73 const Champ_Inc_base *pch_rho = sub_type(Champ_Inc_base, ch_rho) ? &ref_cast(Champ_Inc_base, ch_rho) : nullptr;
74
75 if (!(pch_rho))
76 return; // Nothing to do if the term is null
77
78 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, equation().domaine_dis());
79 const DoubleVect& pe = equation().milieu().porosite_elem(), &ve = domaine.volumes();
80
81 const DoubleTab& inco = equation().inconnue().valeurs();
82 const DoubleTab& rho = (*pch_rho).valeurs();
83 const DoubleTab& rho_p = (*pch_rho).passe();
84 const DoubleTab& dP_rho = pch_rho->derivees().at("pression");
85 const DoubleTab& dT_rho = pch_rho->derivees().at("temperature");
86
87 const double pas_tps = equation().probleme().schema_temps().pas_de_temps();
88 const int N = ref_cast(Pb_Multiphase, equation().probleme()).nb_phases();
89
90 Matrice_Morse *Mp = matrices.count("pression") ? matrices.at("pression") : nullptr,
91 *Mt = matrices.count("temperature") ? matrices.at("temperature") : nullptr,
92 *Mai = matrices.count("interfacial_area") ? matrices.at("interfacial_area") : nullptr;
93
94 /* elements */
95 const int n_l = 0 ; // phase porteuse
96 for (int e = 0; e < domaine.nb_elem(); e++)
97 for (int k = 0; k < N; k++)
98 if (k != n_l) //phase gazeuse
99 {
100 const double fac = 2./3.*1/pas_tps * pe(e) * ve(e) ;
101 secmem(e , k) += fac * inco(e, k) * (1 - rho_p(e, k)/rho(e, k));
102 if (Mp) (*Mp)(N * e + k , e) -= fac * inco(e, k) * rho_p(e, k) * -dP_rho(e, k)/(rho(e, k)*rho(e, k));
103 if (Mt) (*Mt)(N * e + k , N * e + k) -= fac * inco(e, k) * rho_p(e, k) * -dT_rho(e, k)/(rho(e, k)*rho(e, k));
104 if (Mai)(*Mai)(N * e + k, N * e + k) -= fac * ( 1 - rho_p(e, k)/rho(e, k));
105 }
106}
Classe Champ_Inc_base.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
const tabs_t & derivees() const
virtual DoubleTab & valeurs()=0
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
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
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
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_elem()
Definition Milieu_base.h:58
virtual const Champ_base & masse_volumique() const
Renvoie la masse volumique du milieu.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
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...
const Champ_base & get_champ(const Motcle &nom) const override
const Schema_Temps_base & schema_temps() const
Renvoie le schema en temps associe au probleme.
double pas_de_temps() const
Renvoie le pas de temps (delta_t) courant.
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Source_base Un objet Source_base est un terme apparaissant au second membre d'une
Definition Source_base.h:42
_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
classe Variation_rho
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override