TrioCFD 1.9.9_beta
TrioCFD documentation
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 //lookup arrays for boundary conditions: fcl(f, .) = { BC type, BC index, face index within BC }
89 //BC types: 0 -> no BC
90 // 1 -> Neumann
91 // 2 -> Navier or symmetry
92 // 3 -> Dirichlet or 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 << " The BC of type " << fcl(f, 0) << " for the equation " << eq.que_suis_je() << " is not available .....\n";
172 }
173
174 }
175}
: class Champ_Inc_P0_base
DoubleTab & valeurs() override
Returns the array of field values at the current time.
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
const Champ_Inc_base & inconnue() const override
const Champ_Inc_base & densite() const
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
Entree_fluide_vitesse_imposee Special case of the class 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()
Returns the discretized boundary condition domain associated with the 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
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Champ_Inc_base & pression()
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
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)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
Symetrie On symmetry faces, the following properties hold:
Definition Symetrie.h:37
int line_size() const
Definition TRUSTVect.tpp:67