TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Conv_Coloc_Elem_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_Elem_base.h>
17#include <Conservation_Euler_base.h>
18#include <Neumann_paroi_flux_nul.h>
19#include <Milieu_composite_Euler.h>
20#include <Sortie_supersonique.h>
21#include <Entree_supersonique.h>
22#include <Champ_Inc_P0_base.h>
23#include <Fluide_reel_base.h>
24#include <Domaine_Cl_Coloc.h>
25#include <Domaine_Coloc.h>
26#include <Pb_Euler.h>
27#include <array>
28
29Implemente_base(Op_Conv_Coloc_Elem_base,"Op_Conv_Coloc_Elem_base",Op_Conv_Coloc_base);
30
33
34void Op_Conv_Coloc_Elem_base::Riemann_solver(DoubleTab& num_flux) const
35{
36 const Domaine_Coloc& domaine = ref_cast(Domaine_Coloc, le_dom_coloc_.valeur());
37 const Pb_Euler& pb = ref_cast(Pb_Euler, equation().probleme());
38 const DoubleTab& w = le_champ_inco->valeurs();
39 const Conds_lim& cls = le_dcl_coloc_->les_conditions_limites();
40 const IntTab& f_e = domaine.face_voisins();
41 const IntTab& fcl = ref_cast(Champ_Inc_P0_base, equation().inconnue()).fcl();
42 const DoubleTab& alpha = pb.equation_fraction().inconnue().valeurs();
44 const DoubleTab& vit_n = pb.equation_qdm().vitesse_normale();
45 const DoubleTab& p = pb.equation_qdm().pression().valeurs();
46 const int nb_phases = pb.nb_phases();
47 const int nb_faces = domaine.nb_faces();
48
49 // compute left/right fluxes on internal faces
50 DoubleTrav flux_l(nb_faces, num_flux.line_size()), flux_r(nb_faces, num_flux.line_size());
51 assert(flux_l.line_size() == nb_phases);
52 assert(flux_r.line_size() == nb_phases);
53
54 if (sub_type(Fraction_Euler, equation()))
55 {
56 /* Do nothing */
57 }
58 else if (sub_type(Energy_Euler, equation()))
59 {
60 const DoubleTab& alpha_rhoE = pb.equation_energie().inconnue().valeurs();
61 for (int f = 0; f < nb_faces; f++)
62 if (fcl(f, 0) == 0)
63 {
64 const int el = f_e(f, 0), er = f_e(f, 1);
65 for (int n = 0; n < nb_phases; n++)
66 {
67 flux_l(f, n) = (alpha_rhoE(el, n) + alpha(el, n) * p(el, n)) * vit_n(f, n);
68 flux_r(f, n) = (alpha_rhoE(er, n) + alpha(er, n) * p(er, n)) * vit_n(f, n + nb_phases);
69 }
70 }
71 }
72 else if (sub_type(Density_Euler, equation()))
73 {
74 const DoubleTab& alpha_rho = pb.equation_masse().inconnue().valeurs();
75 for (int f = 0; f < nb_faces; f++)
76 if (fcl(f, 0) == 0)
77 {
78 const int el = f_e(f, 0), er = f_e(f, 1);
79
80 for (int n = 0; n < nb_phases; n++)
81 {
82 flux_l(f, n) = alpha_rho(el, n) * vit_n(f, n);
83 flux_r(f, n) = alpha_rho(er, n) * vit_n(f, n + nb_phases);
84 }
85 }
86 }
87 else
88 {
89 Cerr << "Op_NConserv_HLL_Coloc_Elem should not be used for equation " << equation().que_suis_je() << finl;
91 }
92
93 // fill num_fluxe on internal faces
94 scheme(num_flux, flux_l, flux_r);
95
96 // Boundary faces treatement
97 flux_bords_.resize(domaine.nb_faces_bord(), num_flux.line_size());
98 flux_bords_ = 0.;
99
100 for (int f = 0; f < nb_faces; f++)
101 if (fcl(f, 0) != 0)
102 {
103 assert (f_e(f, 1) < 0 && f_e(f, 0) >= 0 && vit_n(f, 0) != -123.123);
104 const int e = f_e(f, 0);
105
106 //utility arrays for boundary conditions: fcl(f, .) = (BC type, BC index, index within BC)
107 //BC types: 0 -> no BC
108 // 1 -> Echange_externe_impose
109 // 2 -> Echange_global_impose
110 // 3 -> Echange_contact_Coloc
111 // 4 -> Neumann_paroi
112 // 5 -> Neumann_val_ext or Neumann_homogene or Symetrie
113 // 6 -> Dirichlet
114 // 7 -> Dirichlet_homogene
115
116 std::array<double, 3> normal { 0., 0., 0. };
117 for (int d = 0; d < Objet_U::dimension; d++)
118 normal[d] = domaine.face_normales(f, d) / domaine.face_surfaces(f);
119
120 if (sub_type(Sortie_supersonique, cls[fcl(f, 1)].valeur())) //Neumann_val_ext : 5
121 {
122 for (int n = 0; n < nb_phases; n++)
123 {
124 num_flux(f, n) = eq.flux_bord(w(e, n), vit_n(f, n), alpha(e, n) * p(e, n));
125 flux_bords_(f, n) = num_flux(f, n) * domaine.face_surfaces(f);
126 }
127 }
128 else if (sub_type(Neumann_paroi_flux_nul, cls[fcl(f, 1)].valeur())) //Neumann_homogene : 5
129 {
130 for (int n = 0; n < nb_phases; n++)
131 num_flux(f, n) = 0.;
132 }
133 else if (sub_type(Entree_supersonique, cls[fcl(f, 1)].valeur())) // Dirichlet : 6
134 {
139
140 for (int n = 0; n < nb_phases; n++)
141 {
142 std::array<double, 3> vitesse_bord { 0., 0., 0. };
143 double vitesse_normale_bord = 0;
144 double norme_vitesse = 0;
145 const double alpha_bord = ref_cast(Dirichlet, cls_alpha[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), n);
146 const double p_bord = ref_cast(Dirichlet, cls_p[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), n);
147 const double rho_bord = ref_cast(Dirichlet, cls_rho[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), n);
148
149 for (int d = 0; d < Objet_U::dimension; d++)
150 {
151 vitesse_bord[d] = ref_cast(Dirichlet, cls_qdm[fcl(f, 1)].valeur()).val_imp(fcl(f, 2), n + nb_phases * d);
152 vitesse_normale_bord += vitesse_bord[d] * normal[d];
153 norme_vitesse += vitesse_bord[d] * vitesse_bord[d];
154 }
155 /* TODO a refaire */
156 const Fluide_reel_base& phase = ref_cast(Fluide_reel_base, ref_cast(Milieu_composite_Euler,eq.milieu()).get_fluid(n));
157 const double inco_bord = (!(sub_type(Energy_Euler, equation()))) ? alpha_bord * rho_bord : alpha_bord * phase.init_energie_tot(rho_bord, norme_vitesse, p_bord);
158 num_flux(f, n) = eq.flux_bord(inco_bord, vitesse_normale_bord, alpha_bord * p_bord);
159 flux_bords_(f, n) = num_flux(f, n) * domaine.face_surfaces(f);
160 }
161 }
162 else
163 {
164 Cerr << "The BC of type " << fcl(f, 0) << "for the equation " << eq.que_suis_je() << " is not available \n";
166 }
167 }
168}
: 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 Milieu_base & milieu() const override
virtual double flux_bord(const double inco_bord, const double vit_n_bord, const double p_bord) const
const Champ_Inc_base & inconnue() const override
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.
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.
Represents a real fluid and its physical properties:
virtual double init_energie_tot(const double &rho, const double &norm_U, const double &u) const
const DoubleTab & vitesse_normale() const
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()
Classe Neumann_paroi_flux_nul This boundary condition imposes a zero flux at the boundary.
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
Momentum_Euler & equation_qdm()
Definition Pb_Euler.h:42
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
int line_size() const
Definition TRUSTVect.tpp:67