TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Op_NConserv_HLL_Coloc_Vect.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 <Op_NConserv_HLL_Coloc_Vect.h>
17#include <Interface_Baer_Nunziato.h>
18#include <Conservation_Euler_base.h>
19#include <Milieu_composite_Euler.h>
20#include <Coloc_Operator_tools.h>
21#include <Sortie_supersonique.h>
22#include <Champ_Inc_P0_base.h>
23#include <Fluide_reel_base.h>
24#include <Domaine_Cl_Coloc.h>
25#include <Momentum_Euler.h>
26#include <Domaine_Coloc.h>
27#include <Dirichlet.h>
28#include <Pb_Euler.h>
29#include <array>
30
31Implemente_instanciable(Op_NConserv_HLL_Coloc_Vect, "Op_NConserv_HLL_Coloc_Vect", Op_NConserv_Coloc_base);
32
35
36void Op_NConserv_HLL_Coloc_Vect::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
37{
38 const Domaine_Coloc& domaine = ref_cast(Domaine_Coloc, le_dom_coloc_.valeur());
39 const DoubleVect& fs = domaine.face_surfaces();
40 const IntTab& f_e = domaine.face_voisins();
41 assert(secmem.line_size() / Objet_U::dimension == 2);
42
43 const int N = domaine.nb_faces();
44 DoubleTrav num_flux_left(N, Objet_U::dimension);
45 DoubleTrav num_flux_right(N, Objet_U::dimension);
46
47 Abgral_scheme(num_flux_left, num_flux_right);
48
49 for (int f = 0; f < N; f++)
50 for (int i = 0; i < 2; i++)
51 {
52 const int e = f_e(f, i);
53 if (e >= 0 && e < domaine.nb_elem())
54 {
55 double val = (i ? num_flux_right(f, 0) : num_flux_left(f, 0)) * fs(f);
56 secmem(e, 0) -= val;
57 secmem(e, 1) += val;
58 val = (i ? num_flux_right(f, 1) : num_flux_left(f, 1)) * fs(f);
59 secmem(e, 2) -= val;
60 secmem(e, 3) += val;
61 }
62 }
63}
64
65void Op_NConserv_HLL_Coloc_Vect::Abgral_scheme(DoubleTab& num_flux_left, DoubleTab& num_flux_right) const
66{
67 const Domaine_Coloc& domaine = ref_cast(Domaine_Coloc, le_dom_coloc_.valeur());
68 const IntTab& f_e = domaine.face_voisins();
69 const IntTab& fcl = ref_cast(Champ_Inc_P0_base, equation().inconnue()).fcl();
70
71 const Momentum_Euler& eq = ref_cast(Momentum_Euler, equation());
72 const DoubleTab& vit_n = eq.vitesse_normale();
73 const DoubleTab& p = eq.pression().valeurs();
74
75 const Pb_Euler& pb = ref_cast(Pb_Euler, equation().probleme());
76 const DoubleTab& alpha = pb.equation_fraction().inconnue().valeurs();
77 const DoubleTab& c = pb.equation_qdm().vitesse_son();
78
79 const Interface_Baer_Nunziato& interface = ref_cast(Interface_Baer_Nunziato, ref_cast(Milieu_composite_Euler,pb.milieu()).interface_phase());
80 const int n = interface.id_phase_vitesse_inter();
81 const int m = interface.id_phase_pression_inter();
82 const int nb_phase = pb.nb_phases();
83
84 flux_bords_.resize(domaine.nb_faces_bord(), num_flux_left.line_size());
85 flux_bords_ = 0.;
86
87 for (int f = 0; f < domaine.nb_faces(); f++)
88 {
89 const int el = f_e(f, 0), er = f_e(f, 1);
90 if (fcl(f, 0) == 0) // faces internes
91 {
92 double Sm = 0., Sp = 0., un_l = 0.;
93 compute_non_conservative_hll_left_bounds(vit_n, c, f, el, er, m, n, nb_phase, Sm, Sp, un_l);
94 for (int d = 0; d < Objet_U::dimension; d++)
95 {
96 double n_d = domaine.face_normales(f, d) / domaine.face_surfaces(f);
97 num_flux_left(f, d) = (Sp * alpha(el, 0) - Sm * alpha(er, 0)) * p(el, m) * n_d;
98 num_flux_left(f, d) /= -(Sp - Sm);
99 }
100
101 compute_non_conservative_hll_right_bounds(vit_n, c, f, el, er, m, n, nb_phase, Sm, Sp, un_l);
102
103 for (int d = 0; d < Objet_U::dimension; d++)
104 {
105 double n_d = -domaine.face_normales(f, d) / domaine.face_surfaces(f);
106 num_flux_right(f, d) = (Sp * alpha(er, 0) - Sm * alpha(el, 0)) * p(er, m) * n_d;
107 num_flux_right(f, d) /= -(Sp - Sm);
108 }
109 }
110 else // faces bords
111 {
112 //tableaux de correspondance lies aux CLs : fcl(f, .) = { type de CL, num de la CL, indice de la face dans la CL }
113 //types de CL : 0 -> pas de CL
114 // 1 -> Neumann
115 // 2 -> Navier ou symetrie
116 // 3 -> Dirichlet ou Neumann_homogene
117 // 4 -> Dirichlet_homogene
118 // 5 -> Periodique
119
120 assert(er < 0 && el >= 0 && vit_n(f, 0) != -123.123);
121 const int e = el;
122
125
126 std::array<double, 3> normal { 0., 0., 0. };
127 for (int d = 0; d < Objet_U::dimension; d++)
128 normal[d] = domaine.face_normales(f, d) / domaine.face_surfaces(f);
129
130 if (sub_type(Sortie_supersonique, cls_qdm[fcl(f, 1)].valeur()))
131 {
132 const double alpha_bord = alpha(e, 0);
133 for (int d = 0; d < Objet_U::dimension; d++)
134 {
135 num_flux_left(f, d) = -alpha_bord * p(e, m) * normal[d];
136 flux_bords_(f, d) = num_flux_left(f, d) * domaine.face_surfaces(f);
137 }
138 }
139 else if (sub_type(Dirichlet, cls_qdm[fcl(f, 1)].valeur()))
140 {
141 const double alpha_bord = ref_cast(Dirichlet, cls_alpha[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), 0);
142 for (int d = 0; d < Objet_U::dimension; d++)
143 {
144 num_flux_left(f, d) = -alpha_bord * p(e, m) * normal[d];
145 flux_bords_(f, d) = num_flux_left(f, d) * domaine.face_surfaces(f);
146 }
147 }
148 else if ( sub_type(Symetrie,cls_qdm[fcl(f, 1)].valeur()) && !sub_type(Sortie_supersonique, cls_qdm[fcl(f, 1)].valeur()))
149 {
150 //Slip wall : u_n=-u_n
151 const double alpha_bord = alpha(e, 0);
152 for (int d = 0; d < Objet_U::dimension; d++)
153 {
154 num_flux_left(f, d) = -alpha_bord * p(e, m) * normal[d];
155 flux_bords_(f, d) = num_flux_left(f, d) * domaine.face_surfaces(f);
156 }
157 }
158 else
159 {
160 Cerr << " La CL de type " << fcl(f, 0) << " pour l'equation " << eq.que_suis_je() << " n'est pas diponible .....\n";
162 }
163 }
164 }
165}
: class Champ_Inc_P0_base
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
classe Conds_lim Cette classe represente un vecteur de conditions aux limites.
Definition Conds_lim.h:32
const Champ_Inc_base & inconnue() const override
classe Dirichlet Cette classe est la classe de base de la hierarchie des conditions aux limites de ty...
Definition Dirichlet.h:31
const Cond_lim & les_conditions_limites(int) const
Renvoie la i-ieme condition aux limites.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Renvoie le domaine des conditions aux limite discretisee associee a l'equation.
const DoubleTab & vitesse_normale() const
const DoubleTab & vitesse_son() const
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
Champ_Inc_base & pression()
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
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
void Abgral_scheme(DoubleTab &num_flux_left, DoubleTab &num_flux_right) const override
DoubleTab flux_bords_
int nb_phases() const
Definition Pb_Euler.h:51
Fraction_Euler & equation_fraction()
Definition Pb_Euler.h:48
Momentum_Euler & equation_qdm()
Definition Pb_Euler.h:42
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Symetrie Sur les faces de symetrie on a les proprietes suivantes:
Definition Symetrie.h:37
int line_size() const
Definition TRUSTVect.tpp:67