TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sortie_libre_pression_imposee.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_pression_imposee.h>
17#include <Fluide_Incompressible.h>
18#include <Navier_Stokes_std.h>
19#include <Champ_Uniforme.h>
20#include <Equation_base.h>
21
22Implemente_instanciable_sans_constructeur(Sortie_libre_pression_imposee, "Frontiere_ouverte_pression_imposee", Neumann_sortie_libre);
23// XD frontiere_ouverte_pression_imposee neumann frontiere_ouverte_pression_imposee INHERITS_BRACE Imposed pressure
24// XD_CONT condition at the open boundary called bord (edge). The imposed pressure field is expressed in Pa.
25// XD attr ch front_field_base ch REQ Boundary field type.
26
27
28Sortie_libre_pression_imposee::Sortie_libre_pression_imposee() : d_rho(-123.) { }
29
30Sortie& Sortie_libre_pression_imposee::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
31
33{
34 if (app_domains.size() == 0) app_domains = { Motcle("Hydraulique"), Motcle("indetermine") };
35
36 s >> le_champ_front;
37 le_champ_ext.typer("Champ_front_uniforme");
38 le_champ_ext->valeurs().resize(1, dimension);
39 return s;
40}
41
42/*! @brief Completes the boundary conditions.
43 *
44 * Sets the constant density of the physical medium
45 * of the equation to d_rho.
46 *
47 */
49{
50 const Milieu_base& mil = mon_dom_cl_dis->equation().milieu();
51 if (sub_type(Fluide_Incompressible,mil) && mon_dom_cl_dis->equation().que_suis_je() != "QDM_Multiphase")
52 {
53 if (sub_type(Champ_Uniforme, mil.masse_volumique()))
54 {
55 const Champ_Uniforme& rho = ref_cast(Champ_Uniforme, mil.masse_volumique());
56 d_rho = rho.valeurs()(0, 0);
57 }
58 else
59 {
60 d_rho = -1;
61
62 // GF: in non-constant rho cases (QC, FT) we must not divide by rho, so d_rho=1
63 d_rho = 1;
64 }
65 }
66 else
67 d_rho = 1;
68}
69
70/*! @brief Returns the value of the imposed flux on the i-th component of the field representing the flux at the boundary.
71 *
72 * The boundary field is considered constant over all elements of the boundary.
73 * The imposed flux value at the boundary equals the value of the (constant) boundary field divided by d_rho.
74 *
75 * @param (int i) index along the first dimension of the field
76 * @return (double) the value imposed on the specified component of the field
77 * @throws second dimension of the boundary field greater than 1
78 */
80{
81 return flux_impose(i,0);
82}
83
84/*! @brief Returns the value of the imposed flux on the (i,j)-th component of the field representing the flux at the boundary.
85 *
86 * The boundary field is NOT constant over all elements
87 * of the boundary.
88 *
89 * @param (int i) index along the first dimension of the field
90 * @param (int j) index along the second dimension of the field
91 * @return (double) the value imposed on the specified component of the field
92 */
94{
95 const Milieu_base& mil = mon_dom_cl_dis->equation().milieu();
96 double rho_;
97 assert(!est_egal(d_rho, -123.));
98 if (d_rho == -1)
99 {
100 const Champ_base& rho = mil.masse_volumique();
101 rho_ = rho.valeurs()(i);
102 }
103 else
104 rho_ = d_rho;
105
106 if (le_champ_front->valeurs().dimension(0) == 1)
107 return le_champ_front->valeurs()(0, j) / rho_;
108 else if (j < le_champ_front->valeurs().dimension(1))
109 return le_champ_front->valeurs()(i, j) / rho_;
110 else
111 Cerr << "Sortie_libre_pression_imposee::flux_impose error" << finl;
113 return 0.;
114}
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
std::vector< Motcle > app_domains
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
Represents an incompressible fluid and its properties:
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).
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
Sortie_libre_pression_imposee This class derives from Neumann_sortie_libre.
void completer() override
Completes 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...
Base class for output streams.
Definition Sortie.h:52