TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Energy_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 <Momentum_Euler.h>
17#include <Energy_Euler.h>
18#include <Discret_Thyd.h>
19#include <Domaine_VF.h>
20#include <Pb_Euler.h>
21#include <Domaine.h>
22#include <Param.h>
23
24Implemente_instanciable(Energy_Euler, "Energy_Euler|Energie_Euler", Conservation_Euler_base);
25// XD energy_euler cons_euler energie_euler INHERITS_BRACE Internal energy conservation equation for a multi-phase Euler
26// XD_CONT problem where the unknown is the temperature
27
29
31{
34
35 terme_convectif.set_fichier("Convection_energie");
36 terme_convectif.set_description("Convective heat transfer rate=Integral(-h*u*ndS) [W] if SI units used");
37
38 terme_nconserv_.set_fichier("Non_conservative_energie");
39 terme_nconserv_.set_description("Conribution of non_conservative operator in energy equation");
40
41 return is;
42}
43
45{
47 param.ajouter_non_std("termes_non_conservatifs|non_conservative_terms", (this));
48 param.ajouter_non_std("convection", (this), Param::REQUIRED);
49}
50
52{
53 Cerr << "Energy_Euler discretization" << finl;
54 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
55 const Pb_Euler& pb = ref_cast(Pb_Euler, probleme());
56
57 const double temps = schema_temps().temps_courant();
58 const int nb_valeurs_temp = schema_temps().nb_valeurs_temporelles();
59 const int N = pb.nb_phases();
60
61 dis.discretiser_champ("temperature", domaine_dis(), "alpha_energie_tot", "J/m3", N, nb_valeurs_temp, temps, l_inco_ch_);
62 l_inco_ch_->fixer_nature_du_champ(N == 1 ? scalaire : multi_scalaire);
63
64 for (int i = 0; i < N; i++)
65 l_inco_ch_->fixer_nom_compo(i, Nom("alpha_energie_tot_") + pb.nom_phase(i));
66
67 champs_compris_.ajoute_champ(l_inco_ch_);
68
70
71 Cerr << "Energy_Euler discretization ==> ok" << finl;
72}
73
74// overridden to avoid affecting energie_tot and to read but do nothing !!
76{
77 Cerr << "Reading of initial conditions\n";
78 Nom nom;
79 Motcle motlu;
80 is >> nom;
81 motlu = nom;
82 if (motlu != Motcle("{"))
83 {
84 Cerr << "We expected a { while reading " << que_suis_je() << finl;
85 Cerr << "and not : " << nom << finl;
86 exit();
87 }
88 is >> nom;
89 motlu = nom;
90 if (motlu != Motcle(inconnue().le_nom()) && motlu != "Energie_tot")
91 {
92 Cerr << nom << " is not the name of the unknown " << inconnue().le_nom() << finl;
93 exit();
94 }
95 OWN_PTR(Champ_Don_base) ch_init;
96 is >> ch_init;
97
98 const int nb_comp = ch_init->nb_comp();
100
101 is >> nom;
102 motlu = nom;
103 if (motlu != Motcle("}"))
104 {
105 Cerr << "We expected a } while reading " << que_suis_je() << finl;
106 Cerr << "and not : " << nom << finl;
107 exit();
108 }
109 return is;
110}
111
113{
114 switch(i)
115 {
116 case 0:
117 return terme_convectif;
118 case 1:
119 return terme_nconserv_;
120 default:
121 Cerr << que_suis_je() << " : wrong operator number " << i << finl;
123 }
124 // For the compilers!!
125 return terme_convectif;
126}
127
129{
130 switch(i)
131 {
132 case 0:
133 return terme_convectif;
134 case 1:
135 return terme_nconserv_;
136 default:
137 Cerr << que_suis_je() << " : wrong operator number " << i << finl;
139 }
140 // For the compilers!!
141 return terme_convectif;
142}
class Champ_Don_base base class of Given Fields (not calculated)
const Champ_Inc_base & inconnue() const override
OWN_PTR(Champ_Inc_base) l_inco_ch_
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
void set_param(Param &param) const override
const Operateur & operateur(int) const override
Entree & lire_cond_init(Entree &is) override
Reading of initial conditions in an input stream.
void discretiser() override
Discretizes the equation.
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.
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