TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Op_Conv_Coloc_Vect_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 <Op_Conv_Coloc_Vect_base.h>
17#include <Conservation_Euler_base.h>
18#include <Milieu_composite_Euler.h>
19#include <Sortie_supersonique.h>
20#include <Entree_supersonique.h>
21#include <Champ_Inc_P0_base.h>
22#include <Domaine_Cl_Coloc.h>
23#include <Fluide_reel_base.h>
24#include <Momentum_Euler.h>
25#include <Domaine_Coloc.h>
26#include <Pb_Euler.h>
27#include <array>
28
29Implemente_base(Op_Conv_Coloc_Vect_base,"Op_Conv_Coloc_Vect_base",Op_Conv_Coloc_base);
30
33
34void Op_Conv_Coloc_Vect_base::Riemann_solver(DoubleTab& num_flux) const
35{
36 const Domaine_Coloc& domaine = ref_cast(Domaine_Coloc, le_dom_coloc_.valeur());
37 const IntTab& f_e = domaine.face_voisins();
38 const IntTab& fcl = ref_cast(Champ_Inc_P0_base, equation().inconnue()).fcl();
39 const Conds_lim& cls = le_dcl_coloc_->les_conditions_limites();
40 const Momentum_Euler& eq = ref_cast(Momentum_Euler, equation());
41 const DoubleTab& vit_n = eq.vitesse_normale();
42 const DoubleTab& vit = eq.vitesse().valeurs();
43 const DoubleTab& p = eq.pression().valeurs();
44 const Pb_Euler& pb = ref_cast(Pb_Euler, equation().probleme());
45 const DoubleTab& rho = pb.equation_masse().densite().valeurs();
46 const DoubleTab& alpha = pb.equation_fraction().inconnue().valeurs();
47 const DoubleTab& alpha_rhoU = eq.inconnue().valeurs();
48 const int nb_phase = pb.nb_phases();
49 const int nb_faces = domaine.nb_faces();
50
51 // compute left/right fluxes on internal faces
52 DoubleTrav flux_l(nb_faces, num_flux.line_size()), flux_r(nb_faces, num_flux.line_size());
53 assert(flux_l.line_size() == alpha_rhoU.line_size());
54 assert(flux_r.line_size() == alpha_rhoU.line_size());
55 assert(Objet_U::dimension == 2);
56
57 for (int f = 0; f < nb_faces; f++)
58 if (fcl(f, 0) == 0)
59 {
60 const int el = f_e(f, 0), er = f_e(f, 1);
61 const double nx = domaine.face_normales(f, 0) / domaine.face_surfaces(f);
62 const double ny = domaine.face_normales(f, 1) / domaine.face_surfaces(f);
63
64 for (int n = 0; n < nb_phase; n++)
65 {
66 // left
67 double alpha_p = alpha(el, n) * p(el, n);
68 flux_l(f, n) = nx * alpha_p + alpha_rhoU(el, n) * vit_n(f, n);
69 flux_l(f, n + nb_phase) = ny * alpha_p + alpha_rhoU(el, n + nb_phase) * vit_n(f, n);
70
71 // right
72 alpha_p = alpha(er, n) * p(er, n);
73 flux_r(f, n) = nx * alpha_p + alpha_rhoU(er, n) * vit_n(f, n + nb_phase);
74 flux_r(f, n + nb_phase) = ny * alpha_p + alpha_rhoU(er, n + nb_phase) * vit_n(f, n + nb_phase);
75 }
76 }
77
78 // fill num_fluxe on internal faces
79 scheme(num_flux, flux_l, flux_r);
80
81 // Boundary faces treatement
82 flux_bords_.resize(domaine.nb_faces_bord(), num_flux.line_size());
83 flux_bords_ = 0.;
84
85 for (int f = 0; f < nb_faces; f++)
86 if (fcl(f, 0) != 0)
87 {
88 //tableaux de correspondance lies aux CLs : fcl(f, .) = { type de CL, num de la CL, indice de la face dans la CL }
89 //types de CL : 0 -> pas de CL
90 // 1 -> Neumann
91 // 2 -> Navier ou symetrie
92 // 3 -> Dirichlet ou Neumann_homogene
93 // 4 -> Dirichlet_homogene
94 // 5 -> Periodique
95
96 assert (f_e(f, 1) < 0 && f_e(f, 0) >= 0 && vit_n(f, 0) != -123.123);
97 const int e = f_e(f, 0);
98
99 std::array<double, 3> normal { 0., 0., 0. };
100 for (int d = 0; d < Objet_U::dimension; d++)
101 normal[d] = domaine.face_normales(f, d) / domaine.face_surfaces(f);
102
103 if (sub_type(Sortie_supersonique, cls[fcl(f, 1)].valeur())) // 1 -> Neumann
104 {
105 for (int n = 0; n < nb_phase; n++)
106 {
107 const double p_bord = p(e, n);
108 const double rho_bord = rho(e, n);
109 const double alpha_bord = alpha(e, n);
110
111 for (int d = 0; d < Objet_U::dimension; d++)
112 {
113 num_flux(f, n + nb_phase * d) = normal[d] * p_bord + vit(e, n + nb_phase * d) * rho_bord * vit_n(f, n);
114 num_flux(f, n + nb_phase * d) *= alpha_bord;
115 flux_bords_(f, n + nb_phase * d) = num_flux(f, n + nb_phase * d) * domaine.face_surfaces(f);
116 }
117 }
118 }
119 else if (sub_type(Entree_fluide_vitesse_imposee, cls[fcl(f, 1)].valeur())) // 3 -> Dirichlet
120 {
124
125 for (int n = 0; n < nb_phase; n++)
126 {
127 std::array<double, 3> vitesse_bord { 0., 0., 0. };
128 double vitesse_normale_bord = 0;
129
130 const double rho_bord = ref_cast(Dirichlet, cls_rho[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), n);
131 const double p_bord = ref_cast(Dirichlet, cls_p[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), n);
132 const double alpha_bord = ref_cast(Dirichlet, cls_alpha[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), n);
133
134 for (int d = 0; d < Objet_U::dimension; d++)
135 {
136 vitesse_bord[d] = ref_cast(Dirichlet, cls[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), n + nb_phase * d);
137 vitesse_normale_bord += vitesse_bord[d] * normal[d];
138 }
139
140 for (int d = 0; d < Objet_U::dimension; d++)
141 {
142 num_flux(f, n + nb_phase * d) = normal[d] * p_bord + vitesse_bord[d] * rho_bord * vitesse_normale_bord;
143 num_flux(f, n + nb_phase * d) *= alpha_bord;
144 flux_bords_(f, n + nb_phase * d) = num_flux(f, n + nb_phase * d) * domaine.face_surfaces(f);
145 }
146 }
147 }
148 else if ( sub_type(Symetrie,cls[fcl(f, 1)].valeur()) && !sub_type(Sortie_supersonique, cls[fcl(f, 1)].valeur()))
149 {
150 //Slip wall : u_n=0
151 for (int n = 0; n < nb_phase; n++)
152 {
153 std::array<double, 3> vitesse_bord { 0., 0., 0. };
154
155 const double p_bord = p(e, n);
156 const double rho_bord = rho(e, n);
157 const double alpha_bord = alpha(e, n);
158 double vitesse_normale_bord = 0;
159
160 for (int d = 0; d < Objet_U::dimension; d++)
161 {
162 num_flux(f, n + nb_phase * d) = normal[d] * p_bord + vitesse_bord[d] * rho_bord * vitesse_normale_bord;
163 num_flux(f, n + nb_phase * d) *= alpha_bord;
164 flux_bords_(f, n + nb_phase * d) = num_flux(f, n + nb_phase * d) * domaine.face_surfaces(f);
165 }
166 }
167 }
168 else
169 {
170 Cerr << " La CL de type " << fcl(f, 0) << " pour l'equation " << eq.que_suis_je() << " n est pas diponible .....\n";
172 }
173
174 }
175}
: 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
const Champ_Inc_base & densite() const
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.
classe Entree_fluide_vitesse_imposee Cas particulier de la classe Dirichlet_entree_fluide
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 Champ_Inc_base & vitesse() const override
const Champ_Inc_base & inconnue() const override
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 Riemann_solver(DoubleTab &num_flux) const override
virtual void scheme(DoubleTab &, const DoubleTab &flux_l, const DoubleTab &flux_r) const =0
DoubleTab flux_bords_
int nb_phases() const
Definition Pb_Euler.h:51
Energy_Euler & equation_energie()
Definition Pb_Euler.h:46
Fraction_Euler & equation_fraction()
Definition Pb_Euler.h:48
Density_Euler & equation_masse()
Definition Pb_Euler.h:44
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