TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sortie_libre_Gradient_Pression_libre_VEF.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_Gradient_Pression_libre_VEF.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Navier_Stokes_std.h>
19#include <Champ_Uniforme.h>
20#include <distances_VEF.h>
21#include <Champ_P0_VEF.h>
22#include <Milieu_base.h>
23#include <Domaine_VEF.h>
24
25Implemente_instanciable(Sortie_libre_Gradient_Pression_libre_VEF, "Frontiere_ouverte_Gradient_Pression_libre_VEF", Neumann_sortie_libre);
26// XD frontiere_ouverte_gradient_pression_libre_vef neumann frontiere_ouverte_gradient_pression_libre_vef INHERITS_BRACE
27// XD_CONT Class for outlet boundary condition in VEF like Orlansky. There is no reference for pressure for theses
28// XD_CONT boundary conditions so it is better to add pressure condition (with Frontiere_ouverte_pression_imposee) on
29// XD_CONT one or two cells (for symmetry in a channel) of the boundary where Orlansky conditions are imposed.
30
31
33
35{
36 if (app_domains.size() == 0) app_domains = { Motcle("Hydraulique"), Motcle("indetermine") };
37 if (supp_discs.size() == 0) supp_discs = { Nom("VEF") };
38
39 le_champ_front.typer("Champ_front_uniforme");
40 le_champ_front->valeurs().resize(1, dimension);
41 le_champ_front->fixer_nb_comp(1);
42 le_champ_ext.typer("Champ_front_uniforme");
43 le_champ_ext->valeurs().resize(1, dimension);
44 return s;
45}
46
48{
49 Cerr << "Sortie_libre_Gradient_Pression_libre_VEF::completer()" << finl;
50 const Domaine_Cl_dis_base& le_dom_Cl = domaine_Cl_dis();
51 const Equation_base& eqn = le_dom_Cl.equation();
52 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std, eqn);
53
54 // const Domaine_VEF& le_dom_VEF = ref_cast(Domaine_VEF,eqn.domaine_dis());
55
56 const Champ_P0_VEF& pression = ref_cast(Champ_P0_VEF, eqn_hydr.pression());
57
58 pression_interne = pression;
59
60 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
61 int nb_faces_loc = le_bord.nb_faces();
62
63 trace_pression_int.resize(nb_faces_loc);
64
65 Cerr << "Sortie_libre_Gradient_Pression_libre_VEF::completer() ok" << finl;
66}
67
69{
70
71 int ok = Cond_lim_base::initialiser(temps);
72
73 const Domaine_Cl_dis_base& le_dom_Cl = domaine_Cl_dis();
74 const Equation_base& eqn = le_dom_Cl.equation();
75 // const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std,eqn);
76 const Domaine_VEF& mon_dom_VEF = ref_cast(Domaine_VEF, eqn.domaine_dis());
77 const IntTab& face_voisins = mon_dom_VEF.face_voisins();
78 // const Domaine_Cl_VEF& domaine_Cl_VEF = ref_cast(Domaine_Cl_VEF,mon_dom_cl_dis.valeur());
79 // const DoubleVect& volumes_entrelaces_Cl = domaine_Cl_VEF.volumes_entrelaces_Cl();
80 // const DoubleTab& face_normale = le_dom_VEF.face_normales();
81 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
82 int nb_faces_loc = le_bord.nb_faces();
83 int ndeb = le_bord.num_premiere_face();
84 int nfin = ndeb + nb_faces_loc;
85 int face;
86 coeff.resize(nb_faces_loc);
87 if (dimension == 2)
88 for (face = ndeb; face < nfin; face++)
89 {
90 int elem = face_voisins(face, 0);
91 if (elem != -1)
92 coeff[face - ndeb] = distance_2D(face, elem, mon_dom_VEF);
93 else
94 {
95 elem = face_voisins(face, 1);
96 coeff[face - ndeb] = -distance_2D(face, elem, mon_dom_VEF);
97 }
98 }
99 if (dimension == 3)
100 for (face = ndeb; face < nfin; face++)
101 {
102 int elem = face_voisins(face, 0);
103 if (elem != -1)
104 coeff[face - ndeb] = distance_3D(face, elem, mon_dom_VEF);
105 else
106 {
107 elem = face_voisins(face, 1);
108 coeff[face - ndeb] = -distance_3D(face, elem, mon_dom_VEF);
109 }
110 }
111 return ok;
112}
113
115{
117
118 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
119 int ndeb = le_bord.num_premiere_face();
120 int nb_faces_loc = le_bord.nb_faces();
121 int nfin = ndeb + nb_faces_loc;
122
123 assert(pression_interne);
124 for (int face = ndeb; face < nfin; face++)
125 {
126 trace_pression_int[face - ndeb] = pression_interne->valeur_au_bord(face);
127 }
128
129}
130
132{
133 const Domaine_Cl_dis_base& le_dom_Cl = domaine_Cl_dis();
134 const Equation_base& eqn = le_dom_Cl.equation();
135 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std, eqn);
136 const Domaine_VEF& mon_dom_VEF = ref_cast(Domaine_VEF, eqn.domaine_dis());
137 const IntTab& face_voisins = mon_dom_VEF.face_voisins();
138 // const Domaine_Cl_VEF& domaine_Cl_VEF = ref_cast(Domaine_Cl_VEF,mon_dom_cl_dis.valeur());
139 // const Front_VF& le_bord = ref_cast(Front_VF,frontiere_dis());
140 const IntTab& elem_faces = mon_dom_VEF.elem_faces();
141 const DoubleTab& face_normales = mon_dom_VEF.face_normales();
142 const Champ_P0_VEF& pre = ref_cast(Champ_P0_VEF, eqn_hydr.pression());
143
144 double Pimp, diff, grad;
145
146 int elem1, elem2, face_adj, face_face_adj;
147
148 double a1 = trace_pression_int[face];
149 double a2 = coeff[face];
150
151 double a3 = 0.;
152
153 elem1 = face_voisins(face, 0);
154
155 for (face_adj = 0; face_adj < dimension; face_adj++)
156 {
157 face_face_adj = elem_faces(elem1, face_adj);
158
159 elem2 = face_voisins(face_face_adj, 0);
160 if (elem2 != elem1)
161 {
162 diff = pre.valeurs()(elem2) - pre.valeurs()(elem1);
163
164 for (int comp = 0; comp < dimension; comp++)
165 {
166 grad = diff * face_normales(face_face_adj, comp);
167 a3 += grad;
168 }
169 }
170 }
171
172 a3 /= double(dimension);
173 Pimp = a1 + a2 * a3;
174 return Pimp;
175
176}
177
179{
180 if (ncomp == 0) return flux_impose(face);
181
182 Cerr << "Sortie_libre_Gradient_Pression_libre_VEF::flux_impose(int , int )" << finl;
183 Cerr << "Only the normal component of the gradient can be imposed" << finl;
185 return 0.;
186}
187
189{
190 const Milieu_base& mil = mon_dom_cl_dis->equation().milieu();
191 const Champ_Uniforme& rho = ref_cast(Champ_Uniforme, mil.masse_volumique());
192 double d_rho = rho.valeurs()(0, 0);
193 if (le_champ_front->valeurs().size() == 1)
194 return le_champ_front->valeurs()(0, 0) / d_rho;
195 else if (le_champ_front->valeurs().line_size() == 1)
196 return le_champ_front->valeurs()(face, 0) / d_rho;
197 else
198 Cerr << "Sortie_libre_Gradient_Pression_libre_VEF::Grad_P_lib_VEF() error" << finl;
199 exit();
200 return 0.;
201}
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
class Champ_P0_VEF
Champ_Uniforme Represents a field that is constant in space and time.
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 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.
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VEF
Definition Domaine_VEF.h:53
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
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....
virtual const Milieu_base & milieu() const =0
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
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
virtual const Equation_base & equation(const std::string &nom_inc) const
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
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.
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
int initialiser(double temps) override
Initialization at the beginning of the calculation.
void mettre_a_jour(double temps) override
Performs a time update of the boundary condition.
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 completer() override
DOES NOTHING must be overridden in derived classes.
Base class for output streams.
Definition Sortie.h:52