TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Milieu_composite_Euler.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 <Interface_Baer_Nunziato.h>
17#include <Milieu_composite_Euler.h>
18#include <Discretisation_base.h>
19#include <Fluide_reel_base.h>
20#include <Champ_Uniforme.h>
21#include <Momentum_Euler.h>
22#include <Pb_Euler.h>
23
24Implemente_instanciable(Milieu_composite_Euler, "Milieu_composite_Euler", Milieu_composite);
25// XD Milieu_composite_Euler Milieu_composite Milieu_composite_Euler INHERITS_BRACE Composite medium made of several sub
26// XD_CONT mediums.
27
28Sortie& Milieu_composite_Euler::printOn(Sortie& os) const { return os; }
30{
32
33 // XXX pour le moment on force ca .. a retirer apres
35 Process::exit("We dont accept at present a saturation object in Milieu_composite_Euler ... But we will soon !\n");
36
37 if (static_cast<int>(fluides_.size()) == 1 && inter_lu_)
38 {
39 Cerr << "Error while reading Milieu_composite_Euler !!" << finl;
40 Cerr << "You are simulating a Single-Phase Euler problem. No need to define an interface !" << finl;
41 Cerr << "Please remove the object " << inter_lu_->que_suis_je() << " from your data file !" << finl;
43 }
44
45 if (inter_lu_ && !sub_type(Interface_Baer_Nunziato, inter_lu_.valeur()))
46 Process::exit("We dont accept at present an interface object with a type different than Interface_Baer_Nunziato !\n");
47
48 return is;
49}
50
52{
53 Cerr << "Composite Euler medium discretization" << finl;
54 // on discretise seulement la porosite
56
57 res_en_T_ = true;
58
59 if (inter_lu_)
60 {
61 inter_lu_->assoscier_pb(pb);
62 inter_lu_->completer();
63 }
64}
65
66void Milieu_composite_Euler::init_energie_tot(DoubleTab& alpha_energie_tot_jdd) const
67{
68 const Momentum_Euler& qdm = ref_cast(Momentum_Euler, equation("alpha_rho_u"));
69 const DoubleTab& rho = ref_cast(Density_Euler,equation("alpha_rho")).densite().valeurs();
70 const DoubleTab& alpha = equation("alpha").inconnue().valeurs();
71 const DoubleTab& p = qdm.pression().valeurs();
72 const int Nb_phase = static_cast<int>(fluides_.size());
73 const int Nb_elem = qdm.domaine_dis().nb_elem();
74
75 for (int n = 0; n < Nb_phase; n++)
76 {
77 const DoubleTab& vit_phase = qdm.vitesse_phase(n).valeurs();
78 const Fluide_reel_base& phase = ref_cast(Fluide_reel_base, get_fluid(n));
79
80 for (int i = 0; i < Nb_elem; i++)
81 {
82 double nom_u2 = 0;
83 for (int d = 0; d < Objet_U::dimension; d++)
84 nom_u2 += vit_phase(i, d) * vit_phase(i, d);
85
86 alpha_energie_tot_jdd(i, n) = alpha(i, n) * phase.init_energie_tot(rho(i, n), nom_u2, p(i, n));
87 }
88 }
89
90 alpha_energie_tot_jdd.echange_espace_virtuel();
91}
92
94{
95 const Momentum_Euler& qdm = ref_cast(Momentum_Euler, equation("alpha_rho_u"));
96 const DoubleTab& rho = ref_cast(Density_Euler,equation("alpha_rho")).densite().valeurs();
97 const DoubleTab& alpha = equation("alpha").inconnue().valeurs();
98 const DoubleTab& alpha_rhoE = equation("alpha_energie_tot").inconnue().valeurs();
99
100 DoubleTrav rhoE(alpha_rhoE);
101 rhoE = alpha_rhoE; // XXX
102 tab_divide_any_shape(rhoE, alpha); // @suppress("Function cannot be resolved")
103
104 const int Nb_phase = static_cast<int>(fluides_.size());
105 const int Nb_elem = qdm.domaine_dis().nb_elem();
106
107 for (int n = 0; n < Nb_phase; n++)
108 {
109 const DoubleTab& vit_phase = qdm.vitesse_phase(n).valeurs();
110 const Fluide_reel_base& phase = ref_cast(Fluide_reel_base, get_fluid(n));
111
112 for (int e = 0; e < Nb_elem; e++)
113 {
114 double nom_u2 = 0;
115 for (int d = 0; d < Objet_U::dimension; d++)
116 nom_u2 += vit_phase(e, d) * vit_phase(e, d);
117
118 p(e, n) = phase.calculer_pression(rho(e, n), nom_u2, rhoE(e, n));
119 assert(p(e, n) > 0);
120 }
121 }
122
124}
125
127{
128 const Momentum_Euler& qdm = ref_cast(Momentum_Euler, equation("alpha_rho_u"));
129 const DoubleTab& rho = ref_cast(Density_Euler,equation("alpha_rho")).densite().valeurs();
130 const DoubleTab& p = qdm.pression().valeurs();
131
132 const int Nb_phase = static_cast<int>(fluides_.size());
133 const int Nb_elem = qdm.domaine_dis().nb_elem();
134 assert(c.dimension(0) == Nb_elem && c.line_size() == Nb_phase);
135 assert(c.dimension_tot(0) == qdm.domaine_dis().nb_elem_tot());
136
137 for (int n = 0; n < Nb_phase; n++)
138 {
139 const Fluide_reel_base& phase = ref_cast(Fluide_reel_base, get_fluid(n));
140 for (int e = 0; e < Nb_elem; e++)
141 c(e, n) = phase.calculer_vitesse_son(rho(e, n), p(e, n));
142 }
143
145}
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
classe Discretisation_base Cette classe represente un schema de discretisation en espace,...
int nb_elem_tot() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Champ_Inc_base & inconnue() const =0
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
Classe Fluide_reel_base Cette classe represente un fluide reel ainsi que.
virtual double calculer_vitesse_son(const double &rho, const double &p) const
virtual double init_energie_tot(const double &rho, const double &norm_U, const double &u) const
virtual double calculer_pression(const double &rho, const double &rhou, const double &rhoE) const
void discretiser_porosite(const Probleme_base &pb, const Discretisation_base &dis)
virtual const Equation_base & equation(const std::string &nom_inc) const
void calculer_pression(DoubleTab &pression_old) const
void calculer_vitesse_son(DoubleTab &c) const
void init_energie_tot(DoubleTab &energie_tot_jdd) const
void discretiser(const Probleme_base &pb, const Discretisation_base &dis) override
Classe Milieu_composite Cette classe represente un fluide reel ainsi que.
std::vector< OWN_PTR(Fluide_base)> fluides_
const Fluide_base & get_fluid(const int i) const
const Champ_Inc_base & vitesse_phase(const int i) const
Champ_Inc_base & pression()
static int dimension
Definition Objet_U.h:99
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
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
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
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")