TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Paroi_scal_hyd_base_EF.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 <Modifier_pour_fluide_dilatable.h>
17#include <Modele_turbulence_scal_base.h>
18#include <Fluide_Quasi_Compressible.h>
19#include <Dirichlet_paroi_defilante.h>
20#include <Convection_Diffusion_std.h>
21#include <Paroi_scal_hyd_base_EF.h>
22#include <Dirichlet_paroi_fixe.h>
23#include <Paroi_decalee_Robin.h>
24#include <Champ_Uniforme.h>
25#include <EcrFicPartage.h>
26#include <Neumann_paroi.h>
27#include <Probleme_base.h>
28#include <Domaine_Cl_EF.h>
29#include <Fluide_base.h>
30#include <Domaine_EF.h>
31#include <SFichier.h>
32
33Implemente_base(Paroi_scal_hyd_base_EF, "Paroi_scal_hyd_base_EF", Turbulence_paroi_scal_base);
34
35Sortie& Paroi_scal_hyd_base_EF::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
36
38
39void Paroi_scal_hyd_base_EF::associer(const Domaine_dis_base& domaine_dis, const Domaine_Cl_dis_base& domaine_Cl_dis)
40{
41 le_dom_dis_ = ref_cast(Domaine_VF, domaine_dis);
42 le_dom_Cl_dis_ = domaine_Cl_dis;
43 // Initialize the wall law immediately
45}
46
47DoubleVect& Paroi_scal_hyd_base_EF::equivalent_distance_name(DoubleVect& d_eq, const Nom& nom_bord) const
48{
49 int nb_boundaries = le_dom_dis_->domaine().nb_front_Cl();
50 for (int n_bord = 0; n_bord < nb_boundaries; n_bord++)
51 {
52 const Front_VF& fr_vf = le_dom_dis_->front_VF(n_bord);
53 int nb_faces = fr_vf.nb_faces();
54 if (fr_vf.le_nom() == nom_bord)
55 {
56 d_eq.resize(fr_vf.nb_faces());
57 for (int ind_face = 0; ind_face < nb_faces; ind_face++)
58 d_eq(ind_face) = equivalent_distance(n_bord, ind_face);
59 }
60 }
61 return d_eq;
62}
63
65{
66 int nb_faces_bord_reelles = le_dom_dis_->nb_faces_bord();
67 tab_d_reel_.resize(nb_faces_bord_reelles);
68 tab_.resize(nb_faces_bord_reelles, nb_fields_);
69
70 // Initialize equivalent_distance_, tab_d_reel, positions_Pf, elems_plus
71 // Initialize equivalent distances with geometric distances
72 const IntTab& face_voisins = le_dom_dis_->face_voisins();
73 const DoubleVect& volumes_maille = le_dom_dis_->volumes();
74 const DoubleVect& surfaces_face = le_dom_dis_->face_surfaces();
75
76 if (axi)
77 {
78 Cerr << "Warning, nothing is done in Axi for EF" << finl;
79 exit();
80 }
81 else
82 {
83 int nb_front = le_dom_dis_->nb_front_Cl();
84 equivalent_distance_.dimensionner(nb_front);
85 for (int n_bord = 0; n_bord < nb_front; n_bord++)
86 {
87 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
88 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
89
90 int size = le_bord.nb_faces();
91 DoubleVect& dist_equiv = equivalent_distance_[n_bord];
92 // Note B.M.: we pass here twice: once during readOn (via Paroi_scal_hyd_base_EF::associer())
93 // and once via Modele_turbulence_scal_base::preparer_calcul())
94 // so check if it was already done:
95 if (!dist_equiv.get_md_vector())
96 le_bord.frontiere().creer_tableau_faces(dist_equiv, RESIZE_OPTIONS::NOCOPY_NOINIT);
97 //assert(dist_equiv.get_md_vector() == le_bord.frontiere().md_vector_faces());
98
99 for (int ind_face = 0; ind_face < size; ind_face++)
100 {
101 int num_face = le_bord.num_face(ind_face);
102 int elem;
103 elem = face_voisins(num_face, 0);
104 if (elem == -1)
105 elem = face_voisins(num_face, 1);
106
107 double distance = volumes_maille(elem) / surfaces_face(num_face);
108
109 tab_d_reel_[num_face] = distance;
110
111 dist_equiv(ind_face) = distance;
112 }
113
114 dist_equiv.echange_espace_virtuel();
115 }
116 }
117
118 return 1;
119}
120
122{
123// ToDo
124 const IntTab& face_voisins = le_dom_dis_->face_voisins();
125 int ndeb, nfin, elem;
126 const Convection_Diffusion_std& eqn = mon_modele_turb_scal->equation();
127 const Equation_base& eqn_hydr = eqn.probleme().equation(0);
128 const Fluide_base& le_fluide = ref_cast(Fluide_base, eqn_hydr.milieu());
129 const Champ_Don_base& conductivite = le_fluide.conductivite();
130 const DoubleTab& temperature = eqn.probleme().equation(1).inconnue().valeurs();
131
132 const DoubleTab& conductivite_turbulente = mon_modele_turb_scal->conductivite_turbulente().valeurs();
133
134 const IntTab& elems = le_dom_dis_->domaine().les_elems();
135 int nsom = le_dom_dis_->nb_som_face();
136 int nsom_elem = le_dom_dis_->domaine().nb_som_elem();
137 ArrOfInt nodes_face(nsom);
138 int nb_nodes_free = nsom_elem - nsom;
139
140 for (int n_bord = 0; n_bord < le_dom_dis_->nb_front_Cl(); n_bord++)
141 {
142 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
143 if ((sub_type(Dirichlet_paroi_fixe, la_cl.valeur())) || (sub_type(Dirichlet_paroi_defilante, la_cl.valeur())) || (sub_type(Paroi_decalee_Robin, la_cl.valeur())))
144 {
145 const Domaine_Cl_EF& domaine_Cl_EF_th = ref_cast(Domaine_Cl_EF, eqn.probleme().equation(1).domaine_Cl_dis());
146 const Cond_lim& la_cl_th = domaine_Cl_EF_th.les_conditions_limites(n_bord);
147 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
148
149 ndeb = le_bord.num_premiere_face();
150 nfin = ndeb + le_bord.nb_faces();
151 for (int num_face = ndeb; num_face < nfin; num_face++)
152 {
153 double lambda, lambda_t;
154 elem = face_voisins(num_face, 0);
155 if (elem == -1)
156 elem = face_voisins(num_face, 1);
157 if (sub_type(Champ_Uniforme, conductivite))
158 lambda = conductivite.valeurs()(0, 0);
159 else
160 {
161 if (conductivite.nb_comp() == 1)
162 lambda = conductivite.valeurs()(elem);
163 else
164 lambda = conductivite.valeurs()(elem, 0);
165 }
166
167 lambda_t = conductivite_turbulente(elem);
168
169 // wall temperature tparoi at BC face
170 double tparoi = 0.;
171 nodes_face = 0;
172 for (int jsom = 0; jsom < nsom; jsom++)
173 {
174 int num_som = le_dom_dis_->face_sommets(num_face, jsom);
175 nodes_face[jsom] = num_som;
176 tparoi += temperature(num_som) / nsom;
177 }
178
179 // compute Tfluide in the first cell without accounting for Tparoi
180 double tfluide = 0.;
181 for (int i = 0; i < nsom_elem; i++)
182 {
183 int node = elems(elem, i);
184 int IOK = 1;
185 for (int jsom = 0; jsom < nsom; jsom++)
186 if (nodes_face[jsom] == node)
187 IOK = 0;
188 // Le noeud contribue
189 if (IOK)
190 tfluide += temperature(node) / nb_nodes_free;
191 }
192
193 double d_equiv = equivalent_distance_[n_bord](num_face - ndeb);
194
195 tab_(num_face, 0) = d_equiv;
196 tab_(num_face, 1) = (lambda + lambda_t) / lambda * tab_d_reel_[num_face] / d_equiv;
197 tab_(num_face, 2) = (lambda + lambda_t) / d_equiv;
198 tab_(num_face, 3) = tfluide;
199 tab_(num_face, 4) = tparoi;
200 if (sub_type(Neumann_paroi, la_cl_th.valeur()))
201 {
202 // in this case, print Tfluide (first-cell average), Tface, and Tparoi recomputed with d_equiv
203 const Neumann_paroi& la_cl_neum = ref_cast(Neumann_paroi, la_cl_th.valeur());
204 double flux = la_cl_neum.flux_impose(num_face - ndeb);
205 double tparoi_equiv = tfluide + flux / (lambda + lambda_t) * d_equiv;
206 tab_(num_face, 5) = tparoi_equiv;
207 }
208 else
209 {
210 tab_(num_face, 5) = 0.;
211 }
212 }
213 }
214 }
215}
216
218{
220
221 const IntTab& face_voisins = le_dom_dis_->face_voisins();
222 int ndeb, nfin, elem;
223 const Convection_Diffusion_std& eqn = mon_modele_turb_scal->equation();
224
225 EcrFicPartage Nusselt;
226 ouvrir_fichier_partage(Nusselt, "Nusselt");
227
228 for (int n_bord = 0; n_bord < le_dom_dis_->nb_front_Cl(); n_bord++)
229 {
230 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
231 if ((sub_type(Dirichlet_paroi_fixe, la_cl.valeur())) || (sub_type(Dirichlet_paroi_defilante, la_cl.valeur())) || (sub_type(Paroi_decalee_Robin, la_cl.valeur())))
232 {
233 const Domaine_Cl_EF& domaine_Cl_EF_th = ref_cast(Domaine_Cl_EF, eqn.probleme().equation(1).domaine_Cl_dis());
234 const Cond_lim& la_cl_th = domaine_Cl_EF_th.les_conditions_limites(n_bord);
235 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
236
237 if (je_suis_maitre())
238 {
239 Nusselt << finl;
240 Nusselt << "Bord " << le_bord.le_nom() << finl;
241 if ((sub_type(Neumann_paroi, la_cl_th.valeur())))
242 {
243 if (dimension == 2)
244 {
245 Nusselt
246 << "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
247 << finl;
248 Nusselt << "\tFace a\t\t\t\t|" << finl;
249 Nusselt
250 << "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
251 << finl;
252 Nusselt << "X\t\t| Y\t\t\t| dist. carac. (m)\t| Nusselt (local)\t| h (Conv. W/m2/K)\t| Tf cote paroi (K)\t| T face de bord (K)\t| Tparoi equiv.(K) " << finl;
253 Nusselt
254 << "----------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------"
255 << finl;
256 }
257 if (dimension == 3)
258 {
259 Nusselt
260 << "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
261 << finl;
262 Nusselt << "\tFace a\t\t\t\t\t\t\t|" << finl;
263 Nusselt
264 << "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
265 << finl;
266 Nusselt << "X\t\t| Y\t\t\t| Z\t\t\t| dist. carac. (m)\t| Nusselt (local)\t| h (Conv. W/m2/K)\t| Tf cote paroi (K)\t| T face de bord (K)\t| Tparoi equiv.(K)" << finl;
267 Nusselt
268 << "----------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------"
269 << finl;
270 }
271 }
272 else
273 {
274 if (dimension == 2)
275 {
276 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
277 << finl;
278 Nusselt << "\tFace a\t\t\t\t|" << finl;
279 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
280 << finl;
281 Nusselt << "X\t\t| Y\t\t\t| dist. carac. (m)\t| Nusselt (local)\t| h (Conv. W/m2/K)\t| Tf cote paroi (K) " << finl;
282 Nusselt << "----------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------" << finl;
283 }
284 if (dimension == 3)
285 {
286 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
287 << finl;
288 Nusselt << "\tFace a\t\t\t\t\t\t\t|" << finl;
289 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
290 << finl;
291 Nusselt << "X\t\t| Y\t\t\t| Z\t\t\t| dist. carac. (m)\t| Nusselt (local)\t| h (Conv. W/m2/K)\t| Tf cote paroi (K) " << finl;
292 Nusselt << "----------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------"
293 << finl;
294 }
295 }
296 }
297 ndeb = le_bord.num_premiere_face();
298 nfin = ndeb + le_bord.nb_faces();
299 for (int num_face = ndeb; num_face < nfin; num_face++)
300 {
301 double x = le_dom_dis_->xv(num_face, 0);
302 double y = le_dom_dis_->xv(num_face, 1);
303 elem = face_voisins(num_face, 0);
304 if (elem == -1)
305 elem = face_voisins(num_face, 1);
306
307 if (dimension == 2)
308 Nusselt << x << "\t| " << y;
309 if (dimension == 3)
310 {
311 double z = le_dom_dis_->xv(num_face, 2);
312 Nusselt << x << "\t| " << y << "\t| " << z;
313 }
314
315 if (sub_type(Neumann_paroi, la_cl_th.valeur()))
316 {
317 for (int i=0; i<nb_fields_; i++)
318 Nusselt << "\t| " << tab_(num_face, i);
319 Nusselt << finl;
320 }
321 else
322 {
323 // print only Tfluide since Tface=Tparoi is normally known
324 for (int i=0; i<4; i++)
325 Nusselt << "\t| " << tab_(num_face, i);
326 Nusselt << finl;
327 }
328 }
329 Nusselt.syncfile();
330 }
331 }
332 if (je_suis_maitre())
333 Nusselt << finl << finl;
334 Nusselt.syncfile();
335}
class Champ_Don_base base class of Given Fields (not calculated)
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.
Champ_Uniforme Represents a field that is constant in space and time.
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
Convection_Diffusion_std This class is the base for equations modelling the transport.
Dirichlet_paroi_defilante Imposes the wall velocity in an equation of type Navier_Stokes.
Dirichlet_paroi_fixe Represents a fixed wall in a Navier-Stokes type equation.
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VF
Definition Domaine_VF.h:44
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Sortie & syncfile() override
Triggers writing to disk of the data accumulated on the different processors since the last call to s...
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
virtual const Champ_Inc_base & inconnue() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual int nb_comp() const
Definition Field_base.h:56
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
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
int num_face(const int) const
Definition Front_VF.h:68
virtual void creer_tableau_faces(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates an array with one "row" per face of this boundary.
const Frontiere & frontiere() const
Returns the associated geometric boundary.
const Nom & le_nom() const override
Returns the name of the geometric boundary.
virtual const Champ_Don_base & conductivite() const
Returns the conductivity of the medium (const version).
Classe Neumann_paroi This boundary condition corresponds to an imposed flux for the.
virtual double flux_impose(int i) const
Returns the value of the imposed flux on the i-th component of the field representing the flux at the...
Definition Neumann.cpp:35
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
friend class Sortie
Definition Objet_U.h:70
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 const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
static int axi
Definition Objet_U.h:96
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
DoubleVect & equivalent_distance_name(DoubleVect &d_eq, const Nom &nom_bord) const override
void imprimer_nusselt(Sortie &) const override
void compute_nusselt() const override
virtual const Equation_base & equation(int) const =0
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
Base class for output streams.
Definition Sortie.h:52
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91
virtual const MD_Vector & get_md_vector() const
Definition TRUSTVect.h:123
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
Base class for the hierarchy of scalar wall-law models computing turbulent quantities near walls....
const DoubleVects & equivalent_distance() const
void ouvrir_fichier_partage(EcrFicPartage &, const Nom &) const
Opens or creates a print file for Face, d_eq, local Nu, h.