TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Density_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 <EcritureLectureSpecial.h>
17#include <Momentum_Euler.h>
18#include <Density_Euler.h>
19#include <Discret_Thyd.h>
20#include <Domaine_VF.h>
21#include <Pb_Euler.h>
22#include <Domaine.h>
23#include <Param.h>
24
25Implemente_instanciable(Density_Euler, "Masse_Euler|Density_Euler", Conservation_Euler_base);
26// XD masse_euler cons_euler density_euler INHERITS_BRACE Mass consevation equation for a multi-phase Euler problem
27// XD_CONT where the unknown is the alpha (void fraction)
28
30
32{
33 assert(densite_);
35
36 terme_convectif.set_fichier("Debit");
37 terme_convectif.set_description("Mass flow rate=Integral(-rho*u*ndS) [kg/s] if SI units used");
38
39 return is;
40}
41
43{
45 param.ajouter_non_std("convection", (this), Param::REQUIRED);
46}
47
49{
50 Cerr << "Density_Euler discretization" << finl;
51 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
52 const Pb_Euler& pb = ref_cast(Pb_Euler, probleme());
53
54 const double temps = schema_temps().temps_courant();
55 const int nb_valeurs_temp = schema_temps().nb_valeurs_temporelles();
56 const int N = pb.nb_phases();
57
58 dis.discretiser_champ("temperature", domaine_dis(), "alpha_rho", "kg/m3", N, nb_valeurs_temp, temps, l_inco_ch_);
59 l_inco_ch_->fixer_nature_du_champ(N == 1 ? scalaire : multi_scalaire);
60
61 for (int i = 0; i < N; i++)
62 l_inco_ch_->fixer_nom_compo(i, Nom("alpha_rho_") + pb.nom_phase(i));
63
64 champs_compris_.ajoute_champ(l_inco_ch_);
65
66 dis.discretiser_champ("temperature", domaine_dis(), "densite", "kg/m3", N, nb_valeurs_temp, temps, densite_);
67 densite_->fixer_nature_du_champ(N == 1 ? scalaire : multi_scalaire);
68
69 for (int i = 0; i < N; i++)
70 densite_->fixer_nom_compo(i, Nom("densite_") + pb.nom_phase(i));
71
72 champs_compris_.ajoute_champ(densite_);
73
75 Cerr << "Density_Euler discretization ==> ok" << finl;
76}
77
78// on surcharge pour effecter rho pas inconnue !!
80{
81 Cerr << "Reading of initial conditions\n";
82 Nom nom;
83 Motcle motlu;
84 is >> nom;
85 motlu = nom;
86 if (motlu != Motcle("{"))
87 {
88 Cerr << "We expected a { while reading " << que_suis_je() << finl;
89 Cerr << "and not : " << nom << finl;
90 exit();
91 }
92 is >> nom;
93 motlu = nom;
94 if (motlu != Motcle(densite().le_nom()))
95 {
96 Cerr << que_suis_je() << " : expected " << densite().le_nom() << " instead of " << nom << finl;
97 exit();
98 }
99 OWN_PTR(Champ_Don_base) ch_init;
100 is >> ch_init;
101 const int nb_comp = ch_init->nb_comp();
103
104 densite().affecter(ch_init.valeur());
105 is >> nom;
106 motlu = nom;
107 if (motlu != Motcle("}"))
108 {
109 Cerr << "We expected a } while reading " << que_suis_je() << finl;
110 Cerr << "and not : " << nom << finl;
111 exit();
112 }
113 return is;
114}
115
117{
118 const DoubleTab& alpha = ref_cast(Pb_Euler,probleme()).equation_fraction().inconnue().valeurs();
119 const DoubleTab& rho = densite().valeurs();
120 DoubleTab& alpha_rho = inconnue().valeurs();
121 alpha_rho = rho;
122 tab_multiply_any_shape(alpha_rho, alpha);
123}
124
126{
128 const DoubleTab& alpha = ref_cast(Pb_Euler,probleme()).equation_fraction().inconnue().valeurs();
129 const DoubleTab& alpha_rho = inconnue().valeurs();
130 DoubleTab& rho = densite().valeurs();
131 rho = alpha_rho;
132 tab_divide_any_shape(rho, alpha);
133}
134
136{
137 if (i)
138 {
139 Cerr << que_suis_je() << " : wrong operator number " << i << finl;
141 }
142 return terme_convectif;
143}
144
146{
147 if (i)
148 {
149 Cerr << que_suis_je() << " : wrong operator number " << i << finl;
151 }
152 return terme_convectif;
153}
classe Champ_Don_base classe de base des Champs donnes (non calcules)
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
Champ_base & affecter(const Champ_base &)
Affecter un champ dans un autre.
const Champ_Inc_base & inconnue() const override
const Operateur & operateur(int) const override
const Champ_Inc_base & densite() const
void discretiser() override
Discretise l'equation.
OWN_PTR(Champ_Inc_base) densite_
void mettre_a_jour_champs_conserves(double temps, int reset) override
Entree & lire_cond_init(Entree &is) override
Lecture des conditions initiales dans un flot d'entree.
void set_param(Param &param) const override
classe Discret_Thyd Cette classe est la classe de base representant une discretisation
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void set_param(Param &titi) const override
const Nom & le_nom() const override
Renvoie le nom de l'equation.
const Discretisation_base & discretisation() const
Renvoie la discretisation associee a l'equation.
virtual void mettre_a_jour_champs_conserves(double temps, int reset=0)
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
virtual void verifie_ch_init_nb_comp(const Champ_Inc_base &ch_ref, const int nb_comp) const
Verification du nombre de composantes lues pour la specification d un champ.
Schema_Temps_base & schema_temps()
Renvoie le schema en temps associe a l'equation.
virtual void discretiser()
Discretise l'equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
const Nom & le_nom() const override
Renvoie le nom du champ.
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
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
classe Operateur Classe generique de la hierarchie des operateurs.
Definition Operateur.h:39
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
@ REQUIRED
Definition Param.h:115
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
const Nom & nom_phase(int i) const
Definition Pb_Euler.h:52
int nb_phases() const
Definition Pb_Euler.h:51
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
double temps_courant() const
Renvoie le temps courant.
virtual int nb_valeurs_temporelles() const =0
Classe de base des flux de sortie.
Definition Sortie.h:52