TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sortie_libre_pression_moyenne_imposee.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_moyenne_imposee.h>
17#include <Navier_Stokes_std.h>
18#include <Champ_Uniforme.h>
19#include <Milieu_base.h>
20#include <TRUSTTab.h>
21#include <Domaine_VF.h>
22
23Implemente_instanciable_sans_constructeur(Sortie_libre_pression_moyenne_imposee, "Frontiere_ouverte_pression_moyenne_imposee", Neumann_sortie_libre);
24// XD frontiere_ouverte_pression_moyenne_imposee neumann frontiere_ouverte_pression_moyenne_imposee NO_BRACE Class for
25// XD_CONT open boundary with pressure mean level imposed.
26// XD attr pext floattant pext REQ Mean pressure.
27
28
29Sortie_libre_pression_moyenne_imposee::Sortie_libre_pression_moyenne_imposee() : d_rho(-123.) { }
30
32
34{
35 if (app_domains.size() == 0) app_domains = { Motcle("Hydraulique"), Motcle("indetermine") };
36
37 s >> Pext_;
38 le_champ_ext.typer("Champ_front_uniforme");
39 le_champ_ext->valeurs().resize(1, dimension);
40 le_champ_front.typer("Champ_front_fonc");
41 le_champ_front->fixer_nb_comp(1);
42 return s;
43}
44
46{
47 const Milieu_base& mil = mon_dom_cl_dis->equation().milieu();
48 if (sub_type(Champ_Uniforme, mil.masse_volumique()))
49 {
50 const Champ_Uniforme& rho = ref_cast(Champ_Uniforme, mil.masse_volumique());
51 d_rho = rho.valeurs()(0, 0);
52 }
53 else
54 d_rho = -1;
55
56 int i;
57 ndeb_ = ref_cast(Front_VF,frontiere_dis()).num_premiere_face();
58 nb_faces_ = ref_cast(Front_VF,frontiere_dis()).nb_faces();
59 le_champ_front->valeurs().resize(nb_faces_, 1);
60 DoubleTab& Pimp = le_champ_front->valeurs();
61 for (i = 0; i < nb_faces_; i++)
62 Pimp(i, 0) = Pext_;
63
64 surfaces.resize(nb_faces_);
65
66 Domaine_VF& zvf = ref_cast(Domaine_VF, mon_dom_cl_dis->domaine_dis());
67 for (i = 0; i < nb_faces_; i++)
68 {
69 surfaces(i) = zvf.face_surfaces(i + ndeb_);
70 }
71
73}
74
75/*! @brief Updates the boundary conditions.
76 *
77 * @param temps current time
78 */
80{
82 const DoubleTab& tab_P = ref_cast(Navier_Stokes_std,mon_dom_cl_dis->equation()).pression().valeurs();
83
84 int face, elem, facegl;
85 DoubleTab& Pimp = le_champ_front->valeurs();
86
87 double Ptot = 0, s, S = 0;
88
89 for (face = 0; face < nb_faces_; face++)
90 {
91 facegl = face + ndeb_;
92 elem = face_voisins(facegl, 0);
93 if (elem == -1)
94 elem = face_voisins(facegl, 1);
95 s = surfaces(face);
96 S += s;
97 Ptot += s * tab_P(elem);
98 }
99 // Optimization: combine 2 mp_sum into 1 collective call
100 mp_sum_for_each(Ptot, S);
101 Ptot /= S;
102
103 Cerr << "Sortie_libre_pression_moyenne_imposee pmoy= " << Ptot << finl;
104
105 for (face = 0; face < nb_faces_; face++)
106 {
107 facegl = face + ndeb_;
108 elem = face_voisins(facegl, 0);
109 if (elem == -1)
110 elem = face_voisins(facegl, 1);
111 Pimp(face, 0) = tab_P(elem) + (Pext_ - Ptot);
112 }
113}
114
115/*! @brief Returns the value of the imposed flux on the i-th component of the field representing the flux at the boundary.
116 *
117 * The boundary field is considered constant over all elements of the boundary.
118 * The imposed flux value at the boundary equals the value of the (constant) boundary field divided by d_rho.
119 *
120 * @param i index along the first dimension of the field
121 * @return the value imposed on the specified component of the field
122 * @throws second dimension of the boundary field greater than 1
123 */
125{
126 const Milieu_base& mil = mon_dom_cl_dis->equation().milieu();
127 const Champ_base& rho = mil.masse_volumique();
128 double rho_;
129 assert(!est_egal(d_rho, -123.));
130 if (d_rho == -1)
131 rho_ = rho.valeurs()(i);
132 else
133 rho_ = d_rho;
134
135 if (le_champ_front->valeurs().size() == 1)
136 return le_champ_front->valeurs()(0, 0) / rho_;
137 else if (le_champ_front->valeurs().dimension(1) == 1)
138 return le_champ_front->valeurs()(i, 0) / rho_;
139 else
140 Cerr << "Neumann::flux_impose error" << finl;
141 exit();
142 return 0.;
143}
144
145/*! @brief Returns the value of the imposed flux on the (i,j)-th component of the field representing the flux at the boundary.
146 *
147 * The boundary field is NOT constant over all elements of the boundary.
148 *
149 * @param i index along the first dimension of the field
150 * @param j index along the second dimension of the field
151 * @return the value imposed on the specified component of the field
152 */
154{
155 const Milieu_base& mil = mon_dom_cl_dis->equation().milieu();
156 const Champ_base& rho = mil.masse_volumique();
157 double rho_;
158 assert(!est_egal(d_rho, -123.));
159 if (d_rho == -1)
160 rho_ = rho.valeurs()(i);
161 else
162 rho_ = d_rho;
163
164 if (le_champ_front->valeurs().dimension(0) == 1)
165 return le_champ_front->valeurs()(0, j) / rho_;
166 else
167 return le_champ_front->valeurs()(i, j) / rho_;
168}
169
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
virtual DoubleTab & valeurs()=0
Champ_Uniforme Represents a field that is constant in space and time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
virtual void mettre_a_jour(double temps)
Performs a time update of the boundary condition.
std::vector< Motcle > app_domains
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
class Domaine_VF
Definition Domaine_VF.h:44
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
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
virtual const Milieu_base & milieu() const =0
class Front_VF
Definition Front_VF.h:36
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).
Navier_Stokes_std This class carries the terms of the momentum equation.
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 mp_sum_for_each(T &arg1, T &arg2)
C++14 compatible mp_sum_for_each: combine multiple mp_sum calls into one collective operation Usage: ...
Definition Process.cpp:208
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Sortie_libre_pression_moyenne_imposee This class derives from Neumann_sortie_libre.
void mettre_a_jour(double) override
Updates the boundary conditions.
double flux_impose(int i) 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