TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Fraction_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 <Fraction_Euler.h>
17#include <Discret_Thyd.h>
18#include <Domaine_VF.h>
19#include <Pb_Euler.h>
20#include <Domaine.h>
21#include <Param.h>
22
23Implemente_instanciable(Fraction_Euler, "Fraction_Euler", Conservation_Euler_base);
24// XD fraction_euler cons_euler fraction_euler INHERITS_BRACE Void fraction conservation equation for a multi-phase
25// XD_CONT Euler problem where the unknown is the temperature
26
28
30{
33 verifier_somme_alpha();
34
35 terme_nconserv_.set_fichier("Non_conservative_fraction");
36 terme_nconserv_.set_description("Conribution of non_conservative operator in fraction equation");
37
38 return is;
39}
40
42{
44 param.ajouter_non_std("termes_non_conservatifs|non_conservative_terms", (this));
45}
46
48{
49 Cerr << "Fraction_Euler discretization" << finl;
50 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
51 const Pb_Euler& pb = ref_cast(Pb_Euler, probleme());
52
53 const double temps = schema_temps().temps_courant();
54 const int nb_valeurs_temp = schema_temps().nb_valeurs_temporelles();
55 const int N = pb.nb_phases();
56
57 dis.discretiser_champ("temperature", domaine_dis(), "alpha", "sans_dimension", N, nb_valeurs_temp, temps, l_inco_ch_);
58 l_inco_ch_->fixer_nature_du_champ(N == 1 ? scalaire : multi_scalaire);
59
60 for (int i = 0; i < N; i++)
61 l_inco_ch_->fixer_nom_compo(i, Nom("alpha_") + pb.nom_phase(i));
62
63 champs_compris_.ajoute_champ(l_inco_ch_);
64
66 Cerr << "Fraction_Euler discretization ==> ok" << finl;
67}
68
70{
71 if (i)
72 {
73 Cerr << que_suis_je() << " : wrong operator number " << i << finl;
75 }
76 return terme_nconserv_;
77}
78
80{
81 if (i)
82 {
83 Cerr << que_suis_je() << " : wrong operator number " << i << finl;
85 }
86 return terme_nconserv_;
87}
88
90{
92#ifndef NDEBUG
93 verifier_somme_alpha();
94#endif
95}
96
97void Fraction_Euler::verifier_somme_alpha()
98{
99 Cerr << "Fraction_Euler::verifier_somme_alpha() ..." ;
100 const DoubleTab& vals = l_inco_ch_->valeurs();
101 const int ne = vals.dimension(0), nl = vals.line_size();
102 DoubleVect vals_somme(ne);
103 vals_somme = 0.;
104
105 for (int i = 0; i < ne; i++)
106 for (int j = 0; j < nl; j++)
107 vals_somme(i) += vals(i, j);
108
109 const double min_a = mp_min_vect(vals_somme), max_a = mp_max_vect(vals_somme);
110
111 if (min_a < 1. - 1.e-12 || max_a > 1. + 1.e-12)
112 {
113 Cerr << " KO !!! " << finl;
114 Cerr << "WHAT ?? The sum of the void fraction (per cell) is not 1 !!!! You should do something !" << finl;
116 }
117 else
118 Cerr << " OK ! " << finl;
119}
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 Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
Probleme_base & probleme()
Returns the problem associated with the equation.
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.
void discretiser() override
Discretizes the equation.
void mettre_a_jour(double temps) override
The value of the unknown at the time step has been calculated.
const Operateur & operateur(int) const override
void set_param(Param &param) const override
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
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
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67