TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sortie_libre_Gradient_Pression_impose.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_impose.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Navier_Stokes_std.h>
19#include <Champ_Uniforme.h>
20#include <Milieu_base.h>
21#include <Champ_P0_VDF.h>
22#include <Domaine_VDF.h>
23
24Implemente_instanciable(Sortie_libre_Gradient_Pression_impose, "Frontiere_ouverte_Gradient_Pression_impose", Neumann_sortie_libre);
25// XD frontiere_ouverte_gradient_pression_impose neumann frontiere_ouverte_gradient_pression_impose INHERITS_BRACE
26// XD_CONT Normal imposed pressure gradient condition on the open boundary called bord (edge). This boundary condition
27// XD_CONT may be only used in VDF discretization. The imposed $\partial P/\partial n$ value is expressed in Pa.m-1.
28// XD attr ch front_field_base ch REQ Boundary field type.
29
31
33{
34 if (app_domains.size() == 0) app_domains = { Motcle("Hydraulique"), Motcle("indetermine") };
35 if (supp_discs.size() == 0) supp_discs = { Nom("VDF") };
36
37 s >> le_champ_front;
38 le_champ_ext.typer("Champ_front_uniforme");
39 le_champ_ext->valeurs().resize(1, dimension);
40 return s;
41}
42
44{
45 Cerr << "Sortie_libre_Gradient_Pression_impose::completer()" << finl;
46 const Domaine_Cl_dis_base& le_dom_Cl = domaine_Cl_dis();
47 const Equation_base& eqn = le_dom_Cl.equation();
48 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std, eqn);
49 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, eqn.domaine_dis());
50 const Champ_P0_VDF& pression = ref_cast(Champ_P0_VDF, eqn_hydr.pression());
51 const IntTab& face_voisins = domaine_vdf.face_voisins();
52 const DoubleVect& volumes_entrelaces = domaine_vdf.volumes_entrelaces();
53 const DoubleVect& face_surfaces = domaine_vdf.face_surfaces();
54
55 le_dom_VDF = domaine_vdf;
56 pression_interne = pression;
57
58 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
59 int nb_faces_loc = le_bord.nb_faces();
60 int ndeb = le_bord.num_premiere_face();
61 int face;
62
63 coeff.resize(nb_faces_loc);
64 trace_pression_int.resize(nb_faces_loc);
65
66 for (face = ndeb; face < ndeb + nb_faces_loc; face++)
67 if (face_voisins(face, 0) != -1)
68 coeff[face - ndeb] = volumes_entrelaces[face] / face_surfaces[face];
69 else
70 coeff[face - ndeb] = -volumes_entrelaces[face] / face_surfaces[face];
71
72 Cerr << "Sortie_libre_Gradient_Pression_impose::completer() ok" << finl;
73}
74
76{
77 //Cerr<<"Sortie_libre_Gradient_Pression_impose::mettre_a_jour"<<finl;
79
80 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
81 int ndeb = le_bord.num_premiere_face();
82 int nb_faces_loc = le_bord.nb_faces();
83
84 assert(pression_interne);
85 for (int face = ndeb; face < ndeb + nb_faces_loc; face++)
86 trace_pression_int[face - ndeb] = pression_interne->valeur_au_bord(face);
87}
88
90{
91 if (le_champ_front->valeurs().size() == 1)
92 return (trace_pression_int[face] + coeff[face] * le_champ_front->valeurs()(0, 0));
93 else if (le_champ_front->valeurs().line_size() == 1)
94 return (trace_pression_int[face] + coeff[face] * le_champ_front->valeurs()(face, 0));
95 else
96 Cerr << "Sortie_libre_Gradient_Pression_impose::flux_impose error" << finl;
97 exit();
98 return 0.;
99}
100
102{
103 if (ncomp == 0) return flux_impose(face);
104
105 Cerr << "Sortie_libre_Gradient_Pression_impose::flux_impose(int , int )" << finl;
106 Cerr << "Only the normal component of the gradient can be imposed" << finl;
108 return 0.;
109}
110
112{
113 const Milieu_base& mil = mon_dom_cl_dis->equation().milieu();
114 if (sub_type(Champ_Uniforme, mil.masse_volumique()))
115 {
116 const Champ_Uniforme& rho = ref_cast(Champ_Uniforme, mil.masse_volumique());
117 double d_rho = rho.valeurs()(0, 0);
118 if (le_champ_front->valeurs().size() == 1)
119 return le_champ_front->valeurs()(0, 0) / d_rho;
120 else if (le_champ_front->valeurs().line_size() == 1)
121 return le_champ_front->valeurs()(face, 0) / d_rho;
122 else
123 Cerr << "Sortie_libre_Gradient_Pression_impose::grad_P_imp() error" << finl;
124 }
125 else
126 {
127 //quasi-compressible
128 const DoubleTab& tab_rho = mil.masse_volumique().valeurs();
129 int elem = le_dom_VDF->face_voisins(face, 0);
130 if (elem == -1)
131 elem = le_dom_VDF->face_voisins(face, 1);
132 double d_rho = tab_rho(elem);
133 if (le_champ_front->valeurs().size() == 1)
134 return le_champ_front->valeurs()(0, 0) / d_rho;
135 else if (le_champ_front->valeurs().line_size() == 1)
136 return le_champ_front->valeurs()(face, 0) / d_rho;
137 else
138 Cerr << "Sortie_libre_Gradient_Pression_impose::grad_P_imp() error" << finl;
139 }
140 exit();
141 return 0.;
142}
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
class Champ_P0_VDF Class representing a P0 discrete field per element associated with a discretized d...
virtual DoubleTab & valeurs()=0
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 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_VDF
Definition Domaine_VDF.h:61
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
DoubleVect & volumes_entrelaces()
Definition Domaine_VF.h:99
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
class Sortie_libre_Gradient_Pression_impose
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