TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Neumann_sortie_libre.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 <Motcle.h>
17#include <Neumann_sortie_libre.h>
18#include <Navier_Stokes_std.h>
19#include <Equation_base.h>
20
21Implemente_instanciable(Neumann_sortie_libre, "Frontiere_ouverte", Neumann_val_ext);
22// XD frontiere_ouverte neumann frontiere_ouverte INHERITS_BRACE Boundary outlet condition on the boundary called bord
23// XD_CONT (edge) (diffusion flux zero). This condition must be associated with a boundary outlet hydraulic condition.
24// XD attr var_name chaine(into=["T_ext","C_ext","Y_ext","K_Eps_ext","K_Omega_ext","Fluctu_Temperature_ext","Flux_Chaleur_Turb_ext","V2_ext","a_ext","tau_ext","k_ext","omega_ext","H_ext","A_i_ext"]) var_name REQ Field name.
25// XD attr ch front_field_base ch REQ Boundary field type.
26
27
28Sortie& Neumann_sortie_libre::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
29
30/*! @brief Types le_champ_front as "Champ_front_uniforme".
31 *
32 * Reads the values of the external field if the boundary conditions
33 * are specified as: "T_ext","C_ext","Y_ext","K_Eps_ext","Fluctu_Temperature_ext","Flux_Chaleur_Turb_ext","V2_ext","a_ext","tau_ext","k_ext","omega_ext","H_ext"
34 * Raises an error otherwise.
35 *
36 * @param (Entree& s) input stream
37 * @return (Entree& s) the modified input stream
38 * @throws external field type not recognized;
39 * recognized types are: "T_ext","C_ext","Y_ext","K_Eps_ext","Fluctu_Temperature_ext","Flux_Chaleur_Turb_ext","V2_ext","a_ext","tau_ext","k_ext","omega_ext","H_ext", "a_i_ext"
40 */
42{
43 if (app_domains.size() == 0)
44 app_domains = {Motcle("Thermique"), Motcle("Thermique_H"),
45 Motcle("Transport_Keps"), Motcle("Transport_Keps_V2"),
46 Motcle("Transport_Keps_Bas_Re"), Motcle("Transport_Keps_Rea"),
47 Motcle("Concentration"), Motcle("Fraction_massique"),
48 Motcle("Fraction_volumique"), Motcle("Transport_V2"),
49 Motcle("Turbulence"), Motcle("Interfacial_area"),
50 Motcle("indetermine"), Motcle("Transport_Komega")
51 };
52
53 Motcle motlu;
54 Motcles les_motcles(16);
55 {
56 les_motcles[0] = "T_ext";
57 les_motcles[1] = "C_ext";
58 les_motcles[2] = "K_Eps_ext";
59 les_motcles[3] = "F_M_ext";
60 les_motcles[4] = "Fluctu_Temperature_ext";
61 les_motcles[5] = "Flux_Chaleur_Turb_ext";
62 les_motcles[6] = "V2_ext";
63 les_motcles[7] = "Y_ext";
64 les_motcles[8] = "A_ext";
65 les_motcles[9] = "k_ext";
66 les_motcles[10] = "tau_ext";
67 les_motcles[11] = "omega_ext";
68 les_motcles[12] = "k_WIT_ext";
69 les_motcles[13] = "a_i_ext";
70 les_motcles[14] = "K_Omega_ext";
71 les_motcles[15] = "H_ext"; // enthalpy
72 }
73 s >> motlu;
74 int rang = les_motcles.search(motlu);
75 if (rang >= 0)
76 s >> le_champ_ext;
77 else
78 {
79 Cerr << "Error reading boundary condition of type: " << finl;
80 Cerr << que_suis_je() << finl;
81 Cerr << "Expected " << les_motcles << " instead of " << motlu << finl;
82 exit();
83 }
84
85 le_champ_front = le_champ_ext;
86
87 return s;
88}
89
90// In the case where the boundary condition concerns pressure,
91// it must be specified explicitly; otherwise inconnue() returns
92// the velocity.
93
95{
96 if (le_champ_front)
97 {
99 const int nb_comp = le_champ_front->nb_comp();
100
101 if ((que_suis_je() == "Frontiere_ouverte") ||
102 (que_suis_je() == "Frontiere_ouverte_rayo_semi_transp") ||
103 (que_suis_je() == "Frontiere_ouverte_rayo_transp") ||
104 (que_suis_je() == "Sortie_libre_temperature_imposee_H"))
105 eq.verifie_ch_init_nb_comp_cl(eq.inconnue(), nb_comp, *this);
106 else
107 {
108 const Navier_Stokes_std& eq_ns = ref_cast(Navier_Stokes_std, eq);
109 eq.verifie_ch_init_nb_comp_cl(eq_ns.pression(), nb_comp, *this);
110 }
111 }
112}
113
114/*! @brief Returns the value of the i-th component of the field imposed on the exterior of the boundary.
115 *
116 * @param (int i) index along the first dimension of the field
117 * @return (double) the value imposed on the specified component of the field
118 * @throws second dimension of the boundary field greater than 1
119 */
121{
122 if (le_champ_ext->valeurs().size() == 1)
123 return le_champ_ext->valeurs()(0, 0);
124 else if (le_champ_ext->valeurs().dimension(1) == 1)
125 return le_champ_ext->valeurs()(i, 0);
126 else
127 {
128 Cerr << "Neumann_sortie_libre::val_ext" << finl;
129 Cerr << le_champ_ext << finl;
130 }
131 exit();
132 return 0.;
133}
134
136{
138 assert(le_champ_ext);
139 return le_champ_ext->initialiser(temps, domaine_Cl_dis().equation().inconnue());
140}
141
143{
145 assert(le_champ_ext);
146 le_champ_ext->associer_fr_dis_base(fr);
148}
149
150/*! @brief Returns the value of the (i,j)-th component of the field imposed on the exterior of the boundary.
151 *
152 * @param (int i) index along the first dimension of the field
153 * @param (int j) index along the second dimension of the field
154 * @return (double) the value imposed on the specified component of the field
155 */
156double Neumann_sortie_libre::val_ext(int i, int j) const
157{
158 if (le_champ_ext->valeurs().dimension(0) == 1)
159 return le_champ_ext->valeurs()(0, j);
160 else
161 return le_champ_ext->valeurs()(i, j);
162}
163
164const DoubleTab& Neumann_sortie_libre::val_ext() const
165{
166 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
167 int nb_faces_tot = le_bord.nb_faces_tot();
168 if (nb_faces_tot>0)
169 {
170 if (val_ext_.dimension(0) != nb_faces_tot)
171 val_ext_.resize(nb_faces_tot, le_champ_ext->valeurs().dimension(1));
172 int size = val_ext_.dimension(0);
173 int nb_comp = val_ext_.dimension(1);
174 for (int i = 0; i < size; i++)
175 for (int j = 0; j < nb_comp; j++)
176 val_ext_(i, j) = val_ext(i, j);
177 }
178 return val_ext_;
179}
180
181const DoubleTab& Neumann_sortie_libre::tab_ext() const
182{
183 return le_champ_ext->valeurs();
184}
185
187{
188 return le_champ_ext->valeurs();
189}
190
192{
194 le_champ_ext->fixer_nb_valeurs_temporelles(nb_cases);
195}
196
198{
200 le_champ_ext->mettre_a_jour(temps);
201}
202
204{
206 le_champ_ext->set_temps_defaut(temps);
207}
208
210{
212 le_champ_ext->changer_temps_futur(temps, i);
213}
214
216{
217 return Neumann::avancer(temps) && le_champ_ext->avancer(temps);
218}
219
221{
222 return Neumann::reculer(temps) && le_champ_ext->reculer(temps);
223}
virtual void changer_temps_futur(double temps, int i)
Changes the i-th future time of the BC.
virtual void mettre_a_jour(double temps)
Performs a time update of the boundary condition.
virtual void fixer_nb_valeurs_temporelles(int nb_cases)
Called by Conds_lim::completer. Calls cha_front_base::fixer_nb_valeurs_temporelles.
virtual void associer_fr_dis_base(const Frontiere_dis_base &)
Associates the boundary with the object.
virtual int avancer(double temps)
Rotates the wheel of the BC.
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
virtual int reculer(double temps)
Rotates the wheel of the BC.
std::vector< Motcle > app_domains
virtual int initialiser(double temps)
Initialization at the beginning of the calculation.
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
virtual void set_temps_defaut(double temps)
Changes the i-th future time of the BC.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Champ_Inc_base & inconnue() const =0
virtual void verifie_ch_init_nb_comp_cl(const Champ_Inc_base &ch_ref, const int nb_comp, const Cond_lim_base &cl) const
class Front_VF
Definition Front_VF.h:36
int nb_faces_tot() const
Definition Front_VF.h:58
class Frontiere_dis_base Class representing a discretized boundary.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Navier_Stokes_std This class carries the terms of the momentum equation.
Champ_Inc_base & pression()
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
int avancer(double temps) override
Rotates the wheel of the BC.
void mettre_a_jour(double temps) override
Performs a time update of the boundary condition.
const DoubleTab & val_ext() const
void changer_temps_futur(double temps, int i) override
Changes the i-th future time of the BC.
int initialiser(double temps) override
Initialization at the beginning of the calculation.
void associer_fr_dis_base(const Frontiere_dis_base &) override
Associates the boundary with the object.
const DoubleTab & tab_ext() const override
void verifie_ch_init_nb_comp() const override
Calls the verification of the field read through the equation for which the boundary condition is con...
int reculer(double temps) override
Rotates the wheel of the BC.
void set_temps_defaut(double temps) override
Changes the i-th future time of the BC.
void fixer_nb_valeurs_temporelles(int nb_cases) override
Called by Conds_lim::completer. Calls cha_front_base::fixer_nb_valeurs_temporelles.
Classe Neumann_val_ext This class is the base class of the hierarchy of.
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52