TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Sortie_libre_Gradient_Pression_libre_VEFPreP1B.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Sortie_libre_Gradient_Pression_libre_VEFPreP1B.h>
17#include <Champ_P1_isoP1Bulle.h>
18#include <Domaine_Cl_dis_base.h>
19#include <Navier_Stokes_std.h>
20#include <Champ_Uniforme.h>
21#include <distances_VEF.h>
22#include <Milieu_base.h>
23
24Implemente_instanciable(Sortie_libre_Gradient_Pression_libre_VEFPreP1B, "Frontiere_ouverte_Gradient_Pression_libre_VEFPreP1B", Neumann_sortie_libre);
25// XD frontiere_ouverte_gradient_pression_libre_vefprep1b neumann frontiere_ouverte_gradient_pression_libre_vefprep1b INHERITS_BRACE Class for outlet boundary condition in VEF P1B/P1NC like Orlansky.
26
27
29
31{
32 if (app_domains.size() == 0) app_domains = { Motcle("Hydraulique"), Motcle("indetermine") };
33 if (supp_discs.size() == 0) supp_discs = { Nom("VEFPreP1B") };
34
35 le_champ_front.typer("Champ_front_uniforme");
36 le_champ_front->valeurs().resize(1, dimension);
37 le_champ_front->fixer_nb_comp(1);
38 le_champ_ext.typer("Champ_front_uniforme");
39 le_champ_ext->valeurs().resize(1, dimension);
40 return is;
41}
42
44{
45
46 Cerr << "Sortie_libre_Gradient_Pression_libre_VEFPreP1B::completer()" << finl;
47 const Domaine_Cl_dis_base& le_dom_Cl = domaine_Cl_dis();
48 const Equation_base& eqn = le_dom_Cl.equation();
49 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std, eqn);
50
51 const Domaine_VEF& mon_dom_VEF = ref_cast(Domaine_VEF, eqn.domaine_dis());
52
53 const Champ_P1_isoP1Bulle& pression = ref_cast(Champ_P1_isoP1Bulle, eqn_hydr.pression());
54
55 const IntTab& face_voisins = mon_dom_VEF.face_voisins();
56
57 pression_interne = pression;
58
59 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
60 int nb_faces_loc = le_bord.nb_faces();
61
62 int ndeb = le_bord.num_premiere_face();
63 int nfin = ndeb + nb_faces_loc;
64 int face;
65 coeff.resize(nb_faces_loc);
66
67 if (dimension == 2)
68 for (face = ndeb; face < nfin; face++)
69 {
70 int elem = face_voisins(face, 0);
71 coeff[face - ndeb] = distance_2D(face, elem, mon_dom_VEF) * 3.;
72 }
73 if (dimension == 3)
74 for (face = ndeb; face < nfin; face++)
75 {
76 int elem = face_voisins(face, 0);
77 coeff[face - ndeb] = distance_3D(face, elem, mon_dom_VEF) * 4.;
78 }
79
80 pression_temps_moins_un.resize(nb_faces_loc);
81 pression_temps_moins_deux.resize(nb_faces_loc);
82 pression_moins_un_temps_moins_un.resize(nb_faces_loc);
83 pression_moins_un_temps_moins_deux.resize(nb_faces_loc);
84 pression_moins_deux_temps_moins_un.resize(nb_faces_loc);
85 pression_moins_un.resize(nb_faces_loc, 1);
86 pression_moins_deux.resize(nb_faces_loc, 1);
87
88 Pimp.resize(nb_faces_loc);
89
90 Cerr << "Sortie_libre_Gradient_Pression_libre_VEFPreP1B::completer() ok" << finl;
91}
92
94{
95
96 int ok = Cond_lim_base::initialiser(temps);
97
98 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
99
100 int nb_faces_loc = le_bord.nb_faces();
101 int ndeb = le_bord.num_premiere_face();
102 int nfin = ndeb + nb_faces_loc;
103
104 int face, face_loc;
105
106 for (face = ndeb; face < nfin; face++)
107 {
108 face_loc = face - ndeb;
109 Pimp[face_loc] = pression_interne->valeur_au_bord(face);
110 pression_moins_un(face_loc, 0) = Pimp[face_loc];
111 pression_moins_deux(face_loc, 0) = Pimp[face_loc];
112 }
113
119
120 return ok;
121}
122
124{
125
126 const Domaine_Cl_dis_base& le_dom_Cl = domaine_Cl_dis();
127 const Equation_base& eqn = le_dom_Cl.equation();
128 const Domaine_VEF& mon_dom_VEF = ref_cast(Domaine_VEF, eqn.domaine_dis());
129 const DoubleTab& face_normale = mon_dom_VEF.face_normales();
130 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
131
132 int nb_faces_loc = le_bord.nb_faces();
133 int ndeb = le_bord.num_premiere_face();
134 int nfin = ndeb + nb_faces_loc;
135
136 int face, face_loc, j;
137
138 const DoubleTab& xv = mon_dom_VEF.xv();
139
140 DoubleTab geom;
141 geom.resize(nb_faces_loc, dimension);
142
144
145 for (face = ndeb; face < nfin; face++)
146 {
147 face_loc = face - ndeb;
148
150 pression_temps_moins_un(face_loc) = Pimp(face_loc);
154 }
155
156 double orient;
157 for (face = ndeb; face < nfin; face++)
158 {
159 orient = 0.;
160 for (j = 0; j < dimension; j++)
161 {
162 orient += (face_normale(face, j) * face_normale(face, j));
163 }
164
165 orient = sqrt(orient);
166
167 for (j = 0; j < dimension; j++)
168 {
169 geom(face - ndeb, j) = xv(face, j);
170 geom(face - ndeb, j) -= face_normale(face, j) / orient * coeff(face - ndeb);
171 ;
172 }
173
174 }
175
176 pression_interne->valeur_aux(geom, pression_moins_un);
177
178 for (face = ndeb; face < nfin; face++)
179 {
180 orient = 0.;
181 for (j = 0; j < dimension; j++)
182 {
183 orient += (face_normale(face, j) * face_normale(face, j));
184 }
185
186 orient = sqrt(orient);
187
188 for (j = 0; j < dimension; j++)
189 {
190 geom(face - ndeb, j) = xv(face, j);
191 geom(face - ndeb, j) -= face_normale(face, j) / orient * 2. * coeff(face - ndeb);
192 }
193
194 }
195
196 pression_interne->valeur_aux(geom, pression_moins_deux);
197
198 double VPhiP;
199
200 for (face = ndeb; face < nfin; face++)
201 {
202 face_loc = face - ndeb;
203 double pre_m_un_t_m_deux = pression_moins_un_temps_moins_deux(face_loc);
204 double pre_m_deux_t_m_un = pression_moins_deux_temps_moins_un(face_loc);
205 double pre_m_un = pression_moins_un(face_loc, 0);
206
207 if (pre_m_un_t_m_deux == pre_m_un)
208 VPhiP = 0.;
209 else
210 VPhiP = (pre_m_un_t_m_deux - pre_m_un) / (pre_m_un + pre_m_un_t_m_deux - 2 * pre_m_deux_t_m_un);
211
212 if (VPhiP <= 1.e-24)
213 VPhiP = 0.0;
214 if (VPhiP > 1.)
215 VPhiP = 1.0;
216 assert(VPhiP < 1.e12);
217
218 Pimp[face_loc] = (1 - VPhiP) / (1 + VPhiP) * pression_temps_moins_un(face_loc) + (2 * VPhiP) / (1 + VPhiP) * pression_moins_un(face_loc, 0);
219
220 }
221
222}
223
225{
226 return Pimp[face];
227}
228
230{
231 return flux_impose(face);
232}
233
235{
236 const Milieu_base& mil = mon_dom_cl_dis->equation().milieu();
237 const Champ_Uniforme& rho = ref_cast(Champ_Uniforme, mil.masse_volumique());
238 double d_rho = rho.valeurs()(0, 0);
239 if (le_champ_front->valeurs().size() == 1)
240 return le_champ_front->valeurs()(0, 0) / d_rho;
241 else if (le_champ_front->valeurs().dimension(1) == 1)
242 return le_champ_front->valeurs()(face, 0) / d_rho;
243 else
244 Cerr << "Sortie_libre_Gradient_Pression_libre_VEFPreP1B::Grad_P_lib_VEFPreP1B() erreur" << finl;
245 exit();
246 return 0.;
247}
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
classe Champ_Uniforme Represente un champ constant dans l'espace et dans le temps.
std::vector< Nom > supp_discs
virtual void mettre_a_jour(double temps)
Effectue une mise a jour en temps de la condition aux limites.
Domaine_Cl_dis_base & domaine_Cl_dis()
Renvoie le domaine des conditions aux limites discretisee dont l'objet fait partie.
std::vector< Motcle > app_domains
virtual int initialiser(double temps)
Initialisation en debut de calcul.
virtual Frontiere_dis_base & frontiere_dis()
Renvoie la frontiere discretisee a laquelle les conditions aux limites s'appliquent.
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
class Domaine_VEF
Definition Domaine_VEF.h:54
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
virtual const Milieu_base & milieu() const =0
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
classe Milieu_base Cette classe est la base de la hierarchie des milieux (physiques)
Definition Milieu_base.h:50
virtual const Equation_base & equation(const std::string &nom_inc) const
virtual const Champ_base & masse_volumique() const
Renvoie la masse volumique du milieu.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
classe Navier_Stokes_std Cette classe porte les termes de l'equation de la dynamique
Champ_Inc_base & pression()
classe Neumann_sortie_libre Cette classe represente une frontiere ouverte sans vitesse imposee
static int dimension
Definition Objet_U.h:99
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
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
void mettre_a_jour(double temps) override
Effectue une mise a jour en temps de la condition aux limites.
int initialiser(double temps) override
Initialisation en debut de calcul.
void completer() override
NE FAIT RIEN A surcharger dans les classes derivees.
double flux_impose(int) const override
Renvoie la valeur du flux impose sur la i-eme composante du champ representant le flux a la frontiere...
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469