TrioCFD 1.9.9_beta
TrioCFD documentation
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 //lookup arrays for boundary conditions: fcl(f, .) = { BC type, BC index, face index within BC }
113 //BC types: 0 -> no BC
114 // 1 -> Neumann
115 // 2 -> Navier or symmetry
116 // 3 -> Dirichlet or 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 << " The BC of type " << fcl(f, 0) << " for the equation " << eq.que_suis_je() << " is not available .....\n";
162 }
163 }
164 }
165}
: 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
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.
const DoubleTab & vitesse_normale() const
const DoubleTab & vitesse_son() 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()
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 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)
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