TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Source_Force_Tchen_base.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 <Source_Force_Tchen_base.h>
17#include <Champ_Face_base.h>
18#include <Pb_Multiphase.h>
19#include <Matrix_tools.h>
20#include <Array_tools.h>
21#include <math.h>
22
23Implemente_base(Source_Force_Tchen_base, "Source_Force_Tchen_base", Sources_Multiphase_base);
24
25Sortie& Source_Force_Tchen_base::printOn(Sortie& os) const { return os; }
26
28{
29 //identification des phases
30 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, equation().probleme()) ? &ref_cast(Pb_Multiphase, equation().probleme()) : nullptr;
31
32 if (!pbm || pbm->nb_phases() == 1) Process::exit(que_suis_je() + " : not needed for single-phase flow!");
33 for (int n = 0; n < pbm->nb_phases(); n++) //recherche de n_l, n_g : phase {liquide,gaz}_continu en priorite
34 if (pbm->nom_phase(n).debute_par("liquide") && (n_l < 0 || pbm->nom_phase(n).finit_par("continu"))) n_l = n;
35
36 if (n_l < 0) Process::exit(que_suis_je() + " : liquid phase not found!");
37
38 return is;
39}
40
41void Source_Force_Tchen_base::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
42{
43 const Champ_Face_base& ch = ref_cast(Champ_Face_base, equation().inconnue());
44 if (!matrices.count(ch.le_nom().getString())) return; //rien a faire
45
46 Matrice_Morse& mat = *matrices.at(ch.le_nom().getString()), mat2;
47 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
48 const DoubleTab& inco = ch.valeurs();
49 const IntTab& fcl = ch.fcl();
50
51 /* stencil : diagonal par bloc pour les vitesses aux faces, puis chaque composante des vitesses aux elems */
52 Stencil stencil(0, 2);
53
54 int N = inco.line_size(), nf = domaine.nb_faces();
55
56 /* faces */
57 for (int f = 0; f < nf; f++)
58 if (fcl(f, 0) < 2)
59 for (int k = 0 ; k<N ; k++)
60 if (k != n_l) //phase gazeuse
61 stencil.append_line( N * f + k , N * f + n_l) ;
62
63 /* elements si aux */
65
66 tableau_trier_retirer_doublons(stencil);
67 Matrix_tools::allocate_morse_matrix(inco.size_totale(), inco.size_totale(), stencil, mat2);
68 mat.nb_colonnes() ? mat += mat2 : mat = mat2;
69}
70
71void Source_Force_Tchen_base::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
72{
73 const Champ_Face_base& ch = ref_cast(Champ_Face_base, equation().inconnue());
74 Matrice_Morse *mat = matrices.count(ch.le_nom().getString()) ? matrices.at(ch.le_nom().getString()) : nullptr;
75 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
76 const IntTab& f_e = domaine.face_voisins(), &fcl = ch.fcl();
77 const DoubleVect& pf = equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces();
78 const DoubleTab& inco = ch.valeurs(), &pvit = ch.passe(), &alpha = ref_cast(Pb_Multiphase, equation().probleme()).equation_masse().inconnue().passe(),
79 &rho = equation().milieu().masse_volumique().passe(), &vf_dir = domaine.volumes_entrelaces_dir();
80
81 double pas_tps = equation().probleme().schema_temps().pas_de_temps();
82 int N = inco.line_size(), nf = domaine.nb_faces();
83
84 /* elements si aux */
85 ajouter_blocs_aux(matrices, secmem);
86
87 /* faces */
88 for (int f = 0; f < nf; f++)
89 if (fcl(f, 0) < 2)
90 for (int k = 0 ; k<N ; k++)
91 if (k != n_l) //phase gazeuse
92 {
93 double alpha_loc = f_e(f, 1)>=0 ? alpha(f_e(f, 0), k) * vf_dir(f, 0)/vf(f) + alpha(f_e(f, 1), k) * vf_dir(f, 1)/vf(f) : alpha(f_e(f, 0), k) ;
94 double rho_loc = f_e(f, 1)>=0 ? rho(f_e(f, 0), n_l) * vf_dir(f, 0)/vf(f) + rho(f_e(f, 1), n_l) * vf_dir(f, 1)/vf(f) : rho(f_e(f, 0), n_l) ;
95 double fac = pf(f) * vf(f) * alpha_loc * rho_loc ;
96
97 secmem(f, k ) += fac * (inco(f, n_l)-pvit(f, n_l))/pas_tps;
98 secmem(f,n_l) -= fac * (inco(f, n_l)-pvit(f, n_l))/pas_tps;
99 if (mat)
100 {
101 (*mat)( N * f + k , N * f + n_l) -= fac/pas_tps ;
102 (*mat)( N * f + n_l, N * f + n_l) += fac/pas_tps ;
103 }
104 }
105}
const IntTab & fcl() const
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.
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
class Domaine_VF
Definition Domaine_VF.h:44
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
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
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)
virtual const Champ_base & masse_volumique() const
Renvoie la masse volumique du milieu.
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
virtual int debute_par(const char *const n) const
Definition Nom.cpp:319
const std::string & getString() const
Definition Nom.h:92
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...
const Nom & nom_phase(int i) const
int nb_phases() const
const Schema_Temps_base & schema_temps() const
Renvoie le schema en temps associe au probleme.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
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 Force_Tchen Force de Tchen dans un ecoulement multiphase
virtual void dimensionner_blocs_aux(Stencil &) const =0
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
virtual void ajouter_blocs_aux(matrices_t, DoubleTab &) const =0
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
int line_size() const
Definition TRUSTVect.tpp:67