TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_pression_from_u.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
17#include <Champ_front_pression_from_u.h>
18#include <TRUSTTrav.h>
19#include <Navier_Stokes_std.h>
20#include <Domaine_VF.h>
21#include <Fluide_Incompressible.h>
22#include <Champ_Uniforme.h>
23
24Implemente_instanciable(Champ_front_pression_from_u,"Champ_front_pression_from_u",Ch_front_var_instationnaire_dep);
25// XD champ_front_pression_from_u front_field_base champ_front_pression_from_u NO_BRACE this field is used to define a
26// XD_CONT pressure field depending of a velocity field.
27// XD attr expression chaine expression REQ value depending of a velocity (like $2*u_moy^2$).
28
29
30
32{
33 return (os);
34}
35
36
38{
40 Nom expr;
41 is >> expr;
42 fonction_.setNbVar(1);
43 fonction_.addVar("u_moy");
44 fonction_.setString(expr);
45 fonction_.parseString();
46 return (is);
47}
48
49
50
51/*! @brief Updates the time.
52 *
53 */
54
56{
58 return 0;
59
60 ref_inco_=inco;
61
62
63
64 // the boundary field retrieves the mean u via div u .... we verify that rho is constant
65 int ok=0;
66 const Milieu_base& mil=inco.equation().milieu();
67 if (sub_type(Fluide_Incompressible,mil))
68 {
69 if ((sub_type(Champ_Uniforme,mil.masse_volumique())))
70 {
71
72
73
74 ok=1;
75 }
76 }
77 if (ok==0)
78 {
79 Cerr<<que_suis_je()<<" is available only for incompressible problem"<<finl;
80 exit();
81 }
82
83
84
85
86 mettre_a_jour(tps);
87
88
89 return 1;
90}
92{
93 const Champ_Inc_base& inco=ref_inco_.valeur();
94 // retrieve the boundary flux from the div operator, which is u
95 const Navier_Stokes_std& eqns=ref_cast(Navier_Stokes_std,inco.equation());
96 const Operateur_Div& opdiv=eqns.operateur_divergence();
97 const Domaine_VF& domaine_VF = ref_cast(Domaine_VF,domaine_dis());
98
99 const DoubleTab& Flux0=opdiv->flux_bords();
100 if (Flux0.size()==0)
101 {
102 Cerr<<" Div not yet ready...."<<finl;
103 return;
104 // DoubleTrav resu(eqns.div());
105 //opdiv.calculer(inco.valeurs(),resu);
106 }
107 const DoubleTab& Flux=opdiv->flux_bords();
108 const Front_VF& le_bord= ref_cast(Front_VF,frontiere_dis());
109 int premiere=le_bord.num_premiere_face();
110 double surf=0;
111 double fluxb=0;
112 for(int i=0; i<le_bord.nb_faces(); i++)
113 {
114 int face=premiere+i;
115 surf+=domaine_VF.face_surfaces(face);
116 fluxb+=Flux(face,0);
117 }
118 // Optimization: combine 2 mp_sum into 1 collective call
119 mp_sum_for_each(surf, fluxb);
120 double u_moy=fluxb/surf;
121
122
123 fonction_.setVar(0,u_moy);
124 double Pout=fonction_.eval();
125
126
127 Cout << frontiere_dis().le_nom()<<" time "<< tps <<" u_moy "<< u_moy<<" Pout "<<Pout <<finl;
128 int nb_cases=les_valeurs->nb_cases();
129
130
131 for (int t=0; t<nb_cases; t++)
132 {
133 DoubleTab& tab=les_valeurs[t].valeurs();
134 tab=Pout;
135 }
136
137 // exit();
138}
139
140
class Ch_front_var_instationnaire_dep This abstract class represents a field on a boundary,
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of calculation.
Class Champ_Inc_base.
Champ_Uniforme Represents a field that is constant in space and time.
virtual const Frontiere_dis_base & frontiere_dis() const
Returns the discretized boundary associated with the field.
virtual const Domaine_dis_base & domaine_dis() const
class Champ_front_pression_from_u
int initialiser(double temps, const Champ_Inc_base &inco) override
Updates the time.
void mettre_a_jour(double temps) override
DOES NOTHING, to override.
class Domaine_VF
Definition Domaine_VF.h:44
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
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
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
Represents an incompressible fluid and its properties:
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 Nom & le_nom() const override
Returns the name of the geometric boundary.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
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.
Operateur_Div & operateur_divergence()
Returns the divergence operator associated with the equation.
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
Operateur_Div Generic class of the hierarchy of operators computing the divergence.
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
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45