TrioCFD 1.9.9_beta
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// overridden to affect rho, not the unknown !!
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}
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Returns the array of field values at the current time.
Champ_base & affecter(const Champ_base &)
Assign a field to another.
const Champ_Inc_base & inconnue() const override
const Operateur & operateur(int) const override
const Champ_Inc_base & densite() const
void discretiser() override
Discretizes the 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
Reading of initial conditions in an input stream.
void set_param(Param &param) const override
class Discret_Thyd This class is the base class representing a discretization
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
Returns the name of the equation.
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual void mettre_a_jour_champs_conserves(double temps, int reset=0)
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual void verifie_ch_init_nb_comp(const Champ_Inc_base &ch_ref, const int nb_comp) const
Verification of the number of components read for the specification of a field.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual void discretiser()
Discretizes the equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
const Nom & le_nom() const override
Returns the name of the field.
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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
class Operateur Generic class of the operator hierarchy.
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)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
double temps_courant() const
Returns the current time.
virtual int nb_valeurs_temporelles() const =0
Base class for output streams.
Definition Sortie.h:52