TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sortie_libre_Pression_imposee_Orlansky.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 <Sortie_libre_Pression_imposee_Orlansky.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Navier_Stokes_std.h>
19#include <Champ_Face_VDF.h>
20#include <Champ_P0_VDF.h>
21#include <Domaine_VDF.h>
22#include <Debog.h>
23
24Implemente_instanciable(Sortie_libre_Pression_imposee_Orlansky, "Frontiere_ouverte_Pression_imposee_Orlansky", Neumann_sortie_libre);
25// XD frontiere_ouverte_pression_imposee_orlansky neumann frontiere_ouverte_pression_imposee_orlansky INHERITS_BRACE
26// XD_CONT This boundary condition may only be used with VDF discretization. There is no reference for pressure for this
27// XD_CONT boundary condition so it is better to add pressure condition (with Frontiere_ouverte_pression_imposee) on one
28// XD_CONT or two cells (for symetry in a channel) of the boundary where Orlansky conditions are imposed.
29
30
32
34{
35 if (app_domains.size() == 0) app_domains = { Motcle("Hydraulique"), Motcle("indetermine") };
36 if (supp_discs.size() == 0) supp_discs = { Nom("VDF") };
37
38 le_champ_ext.typer("Champ_front_uniforme");
39 le_champ_ext->valeurs().resize(1, dimension);
40 le_champ_front.typer("Champ_front_uniforme");
41 le_champ_front->valeurs().resize(1, dimension);
42 le_champ_front->fixer_nb_comp(1);
43 return s;
44}
45
47{
48 Cerr << "Sortie_libre_Pression_imposee_Orlansky::completer()" << finl;
49 const Domaine_Cl_dis_base& le_dom_Cl = domaine_Cl_dis();
50 const Equation_base& eqn = le_dom_Cl.equation();
51 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std, eqn);
52 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, eqn.domaine_dis());
53 const Champ_P0_VDF& pression = ref_cast(Champ_P0_VDF, eqn_hydr.pression());
54 const Champ_Face_VDF& vitesse = ref_cast(Champ_Face_VDF, eqn_hydr.inconnue());
55 // const IntTab& face_voisins = domaine_vdf.face_voisins();
56 // const DoubleVect& volumes_entrelaces = domaine_vdf.volumes_entrelaces();
57 // const DoubleVect& face_surfaces = domaine_vdf.face_surfaces();
58
59 le_dom_VDF = domaine_vdf;
60 pression_interne = pression;
61 vitesse_interne = vitesse;
62
63 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
64 int nb_faces_loc = le_bord.nb_faces();
65 // int ndeb = le_bord.num_premiere_face();
66
67 le_champ_front->valeurs().resize(nb_faces_loc);
68 le_champ_ext->valeurs().resize(nb_faces_loc, dimension);
69 VPhiP.resize(nb_faces_loc);
70 VPhiV.resize(nb_faces_loc, dimension);
71 pression_temps_moins_un.resize(nb_faces_loc);
72 pression_temps_moins_deux.resize(nb_faces_loc);
73 pression_moins_un_temps_moins_un.resize(nb_faces_loc);
74 pression_moins_un_temps_moins_deux.resize(nb_faces_loc);
75 pression_moins_deux_temps_moins_un.resize(nb_faces_loc);
76 pression_moins_un.resize(nb_faces_loc);
77 pression_moins_deux.resize(nb_faces_loc);
78
79 vitesse_temps_moins_un.resize(nb_faces_loc, dimension);
80 vitesse_temps_moins_deux.resize(nb_faces_loc, dimension);
81 vitesse_moins_un_temps_moins_un.resize(nb_faces_loc, dimension);
82 vitesse_moins_un_temps_moins_deux.resize(nb_faces_loc, dimension);
83 vitesse_moins_deux_temps_moins_un.resize(nb_faces_loc, dimension);
84 vitesse_moins_un.resize(nb_faces_loc, dimension);
85 vitesse_moins_deux.resize(nb_faces_loc, dimension);
86
87 Cerr << "Sortie_libre_Pression_imposee_Orlansky::completer() ok" << finl;
88}
89
91{
92 //Cerr << "Sortie_libre_Pression_imposee_Orlansky::mettre_a_jour("
93 // <<temps<<")"<<finl;
94
96
97 assert(pression_interne);
98 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
99 int ndeb = le_bord.num_premiere_face();
100 int nb_faces_loc = le_bord.nb_faces();
101
102 DoubleTab& pre_bord = le_champ_front->valeurs();
103 DoubleTab& vit_ext = le_champ_ext->valeurs();
104 const Domaine_VDF& zvdf = ref_cast(Domaine_VDF, pression_interne->domaine_dis_base());
105 const DoubleTab& pre = pression_interne->valeurs();
106 const DoubleTab& vitesse = vitesse_interne->valeurs();
107
108 int face, compo;
109
110 for (face = ndeb; face < ndeb + nb_faces_loc; face++)
111 {
112 int i = face - ndeb;
113
114 int ori = zvdf.orientation(face);
115
117 pression_temps_moins_un(i) = pre_bord(i);
121
122 int elem_un = zvdf.face_voisins(face, 0);
123 if (elem_un < 0)
124 elem_un = zvdf.face_voisins(face, 1);
125 int face_moins_un = zvdf.elem_faces(elem_un, ori);
126 if (face_moins_un == face)
127 face_moins_un = zvdf.elem_faces(elem_un, ori + dimension);
128 pression_moins_un[i] = pre[elem_un];
129
130 int elem_deux = zvdf.face_voisins(face_moins_un, 0);
131 if (elem_deux == elem_un)
132 elem_deux = zvdf.face_voisins(face_moins_un, 1);
133 pression_moins_deux[i] = pre[elem_deux];
134
135 double pre_m_un_t_m_deux = pression_moins_un_temps_moins_deux(i);
136 double pre_m_deux_t_m_un = pression_moins_deux_temps_moins_un(i);
137 double pre_m_un = pression_moins_un(i);
138
139 if (pre_m_un_t_m_deux == pre_m_un)
140 VPhiP(i) = 0;
141 else
142 VPhiP(i) = (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);
143 if (VPhiP(i) <= 1.e-24)
144 VPhiP(i) = 0.0;
145 if (VPhiP(i) > 1.)
146 VPhiP(i) = 1.0;
147 assert(VPhiP(i) < 1.e12);
148
149 pre_bord[i] = (1 - VPhiP(i)) / (1 + VPhiP(i)) * pression_temps_moins_un(i) + (2 * VPhiP(i) / (1 + VPhiP(i))) * pression_moins_un(i);
150
151 }
152 Debog::verifier_bord("Orlansky::mettre_a_jour() : pre bord : ", pre_bord, ndeb);
153 //Debog::verifier_bord("Orlansky::mettre_a_jour() : VPhiP : " , VPhiP, ndeb );
154 //Debog::verifier_bord("Orlansky::mettre_a_jour() : VPhiV avant : " , VPhiV ,ndeb);
155
156 //Debog::verifier_bord("Orlansky::mettre_a_jour() : vitesse_moins_un_temps_moins_un : " , vitesse_moins_un_temps_moins_un, ndeb);
157 //Debog::verifier_bord("Orlansky::mettre_a_jour() : vitesse_moins_deux : " , vitesse_moins_deux, ndeb);
158 //Debog::verifier_bord("Orlansky::mettre_a_jour() : vitesse_moins_un : " , vitesse_moins_un, ndeb);
159
160 for (compo = 0; compo < dimension; compo++)
161 for (face = ndeb; face < ndeb + nb_faces_loc; face++)
162 {
163 int i = face - ndeb;
164
165 int ori = zvdf.orientation(face);
166
168 vitesse_temps_moins_un(i, compo) = vit_ext(i, compo);
170
173
174 int elem_un = zvdf.face_voisins(face, 0);
175 if (elem_un < 0)
176 elem_un = zvdf.face_voisins(face, 1);
177 int face_moins_un = zvdf.elem_faces(elem_un, ori);
178 if (face_moins_un == face)
179 face_moins_un = zvdf.elem_faces(elem_un, ori + dimension);
180 double vit = 0.5 * (vitesse(zvdf.elem_faces(elem_un, compo)) + vitesse(zvdf.elem_faces(elem_un, compo + dimension)));
181
182 vitesse_moins_un(i, compo) = vit;
183
184 int elem_deux = zvdf.face_voisins(face_moins_un, 0);
185 if (elem_deux == elem_un)
186 elem_deux = zvdf.face_voisins(face_moins_un, 1);
187 vit = 0.5 * (vitesse(zvdf.elem_faces(elem_deux, compo)) + vitesse(zvdf.elem_faces(elem_deux, compo + dimension)));
188 vitesse_moins_deux(i, compo) = vit;
189
190 double pre_m_un_t_m_deux = vitesse_moins_un_temps_moins_deux(i, compo);
191 double pre_m_deux_t_m_un = vitesse_moins_deux_temps_moins_un(i, compo);
192 double pre_m_un = vitesse_moins_un(i, compo);
193
194 if (pre_m_un_t_m_deux == pre_m_un)
195 VPhiV(i, compo) = 0;
196 else
197 VPhiV(i, compo) = (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);
198 if (VPhiV(i, compo) <= 1.e-24)
199 VPhiV(i, compo) = 0.0;
200 if (VPhiV(i, compo) > 1.)
201 VPhiV(i, compo) = 1.0;
202 assert(VPhiV(i, compo) < 1.e12);
203
204 vit_ext(i, compo) = (1 - VPhiV(i, compo)) / (1 + VPhiV(i, compo)) * vitesse_temps_moins_un(i, compo) + (2 * VPhiV(i, compo) / (1 + VPhiV(i, compo))) * vitesse_moins_un(i, compo);
205
206 }
207 Debog::verifier_bord("Orlansky::mettre_a_jour() : vit_ext : ", vit_ext, ndeb);
208 Debog::verifier_bord("Orlansky::mettre_a_jour() : VPhiV : ", VPhiV, ndeb);
209}
210
212{
213 return le_champ_front->valeurs()(face);
214}
215
217{
218 if (ncomp == 0) return flux_impose(face);
219
220 Cerr << "Sortie_libre_Pression_imposee_Orlansky::flux_impose(int , int ). Pressure is a scalar." << finl;
222 return 0.;
223}
class Champ_Face_VDF
class Champ_P0_VDF Class representing a P0 discrete field per element associated with a discretized d...
std::vector< Nom > supp_discs
virtual void mettre_a_jour(double temps)
Performs a time update of the boundary condition.
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
std::vector< Motcle > app_domains
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
static void verifier_bord(const char *const msg, const DoubleVect &arr, int num_deb)
Definition Debog.cpp:33
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VDF
Definition Domaine_VDF.h:61
int orientation(int) const override
inline DoubleVect& Domaine_VDF::porosite_face() {
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in 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
class Equation_base The role of an equation is the calculation of one or more fields....
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the 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
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.
const Champ_Inc_base & inconnue() const override
Returns the velocity (unknown field of the equation) (const version).
Champ_Inc_base & pression()
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
static int dimension
Definition Objet_U.h:94
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
class Sortie_libre_Pression_imposee_Orlansky
void completer() override
DOES NOTHING must be overridden in derived classes.
double flux_impose(int) const override
Returns the value of the imposed flux on the i-th component of the field representing the flux at the...
void mettre_a_jour(double) override
Performs a time update of the boundary condition.
Base class for output streams.
Definition Sortie.h:52