TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Paroi_scal_hyd_base_VDF.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Modele_turbulence_scal_base.h>
17#include <Dirichlet_paroi_defilante.h>
18#include <Convection_Diffusion_std.h>
19#include <Champ_Fonc_Tabule_P0_VDF.h>
20#include <Paroi_scal_hyd_base_VDF.h>
21#include <Champ_Uniforme_Morceaux.h>
22#include <Dirichlet_paroi_fixe.h>
23#include <Champ_Fonc_Tabule.h>
24#include <Champ_Uniforme.h>
25#include <Domaine_Cl_VDF.h>
26#include <EcrFicPartage.h>
27#include <Neumann_paroi.h>
28#include <Probleme_base.h>
29#include <Fluide_base.h>
30#include <Constituant.h>
31#include <Debog.h>
32
33Implemente_base(Paroi_scal_hyd_base_VDF, "Paroi_scal_hyd_base_VDF", Turbulence_paroi_scal_base);
34
35Sortie& Paroi_scal_hyd_base_VDF::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
36
38
39void Paroi_scal_hyd_base_VDF::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
48{
49 int nb_faces_bord_reelles = le_dom_dis_->nb_faces_bord();
50 tab_.resize(nb_faces_bord_reelles, nb_fields_);
51 const Domaine_VDF& zvdf = ref_cast(Domaine_VDF, le_dom_dis_.valeur());
52
53 int nb_front = zvdf.nb_front_Cl();
54 equivalent_distance_.dimensionner(nb_front);
55
56 //loop over boundaries (number)
57 for (int n_bord = 0; n_bord < nb_front; n_bord++)
58 {
59 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
60 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
61 int n_faces = le_bord.nb_faces();
62 equivalent_distance_[n_bord].resize(n_faces);
63 //for a given boundary, loop over faces
64 for (int ind_face = 0; ind_face < n_faces; ind_face++)
65 {
66 int num_face = le_bord.num_face(ind_face);
67 if (axi)
68 equivalent_distance_[n_bord](ind_face) = zvdf.dist_norm_bord_axi(num_face);
69 else
70 equivalent_distance_[n_bord](ind_face) = zvdf.dist_norm_bord(num_face);
71 } //ind_face
72 } //n_bord
73 return 1;
74}
75
77{
78 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_dis_.valeur());
79 const IntTab& face_voisins = domaine_VDF.face_voisins();
80 int ndeb, nfin, elem;
81 const Convection_Diffusion_std& eqn = mon_modele_turb_scal->equation();
82 const Equation_base& eqn_hydr = eqn.probleme().equation(0);
83 const Fluide_base& le_fluide = ref_cast(Fluide_base, eqn_hydr.milieu());
84 const Champ_Don_base& conductivite = le_fluide.conductivite();
85 const DoubleTab& temperature = eqn.probleme().equation(1).inconnue().valeurs();
86
87 for (int n_bord = 0; n_bord < domaine_VDF.nb_front_Cl(); n_bord++)
88 {
89 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
90
91 if ((sub_type(Dirichlet_paroi_fixe, la_cl.valeur())) || (sub_type(Dirichlet_paroi_defilante, la_cl.valeur())))
92 {
93 const Domaine_Cl_VDF& domaine_Cl_VDF_th = ref_cast(Domaine_Cl_VDF, eqn.probleme().equation(1).domaine_Cl_dis());
94 const Cond_lim& la_cl_th = domaine_Cl_VDF_th.les_conditions_limites(n_bord);
95 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
96
97 //find the associated boundary
98 int boundary_index = -1;
99 if (domaine_VDF.front_VF(n_bord).le_nom() == le_bord.le_nom())
100 boundary_index = n_bord;
101 assert(boundary_index >= 0);
102
103 ndeb = le_bord.num_premiere_face();
104 nfin = ndeb + le_bord.nb_faces();
105 for (int num_face = ndeb; num_face < nfin; num_face++)
106 {
107 double dist, lambda;
108
109 if (axi)
110 dist = domaine_VDF.dist_norm_bord_axi(num_face);
111 else
112 dist = domaine_VDF.dist_norm_bord(num_face);
113 elem = face_voisins(num_face, 0);
114 if (elem == -1)
115 elem = face_voisins(num_face, 1);
116 if (sub_type(Champ_Uniforme, conductivite))
117 lambda = conductivite.valeurs()(0, 0);
118 else
119 {
120 if (conductivite.nb_comp() == 1)
121 lambda = conductivite.valeurs()(elem);
122 else
123 lambda = conductivite.valeurs()(elem, 0);
124 }
125
126 int global_face = num_face;
127 int local_face = domaine_VDF.front_VF(boundary_index).num_local_face(global_face);
128
129 tab_(num_face, 0) = equivalent_distance_[boundary_index](local_face);
130 tab_(num_face, 1) = dist / equivalent_distance_[boundary_index](local_face);
131 tab_(num_face, 2) = lambda / equivalent_distance_[boundary_index](local_face);
132 tab_(num_face, 3) = temperature(elem);
133 if (sub_type(Neumann_paroi, la_cl_th.valeur()))
134 {
135 const Neumann_paroi& la_cl_neum = ref_cast(Neumann_paroi, la_cl_th.valeur());
136 double flux = la_cl_neum.flux_impose(num_face - ndeb);
137 double tparoi = temperature(elem) + flux / lambda * equivalent_distance_[boundary_index](local_face);
138 tab_(num_face, 4) = tparoi;
139 }
140 else
141 tab_(num_face, 4) = 0;
142 tab_(num_face, 5) = 0.;
143 }
144 }
145 }
146}
147
149{
151
152 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_dis_.valeur());
153 const IntTab& face_voisins = domaine_VDF.face_voisins();
154 int ndeb, nfin, elem;
155 const Convection_Diffusion_std& eqn = mon_modele_turb_scal->equation();
156
157 EcrFicPartage Nusselt;
158 ouvrir_fichier_partage(Nusselt, "Nusselt");
159
160 for (int n_bord = 0; n_bord < domaine_VDF.nb_front_Cl(); n_bord++)
161 {
162 const Cond_lim& la_cl = le_dom_Cl_dis_->les_conditions_limites(n_bord);
163
164 if ((sub_type(Dirichlet_paroi_fixe, la_cl.valeur())) || (sub_type(Dirichlet_paroi_defilante, la_cl.valeur())))
165 {
166 const Domaine_Cl_VDF& domaine_Cl_VDF_th = ref_cast(Domaine_Cl_VDF, eqn.probleme().equation(1).domaine_Cl_dis());
167 const Cond_lim& la_cl_th = domaine_Cl_VDF_th.les_conditions_limites(n_bord);
168 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
169 if ((sub_type(Neumann_paroi, la_cl_th.valeur())))
170 {
171 if (je_suis_maitre())
172 {
173 Nusselt << finl;
174 Nusselt << "Bord " << le_bord.le_nom() << finl;
175 if (dimension == 2)
176 {
177 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
178 << finl;
179 Nusselt << "\tFace a\t\t\t\t|" << finl;
180 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
181 << finl;
182 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| Tparoi equiv.(K)" << finl;
183 Nusselt << "----------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------"
184 << finl;
185 }
186 if (dimension == 3)
187 {
188 Nusselt
189 << "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
190 << finl;
191 Nusselt << "\tFace a\t\t\t\t\t\t\t|" << finl;
192 Nusselt
193 << "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
194 << finl;
195 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| Tparoi equiv.(K)" << finl;
196 Nusselt
197 << "----------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------"
198 << finl;
199 }
200 }
201 ndeb = le_bord.num_premiere_face();
202 nfin = ndeb + le_bord.nb_faces();
203 for (int num_face = ndeb; num_face < nfin; num_face++)
204 {
205 double x = domaine_VDF.xv(num_face, 0);
206 double y = domaine_VDF.xv(num_face, 1);
207
208 elem = face_voisins(num_face, 0);
209 if (elem == -1)
210 elem = face_voisins(num_face, 1);
211
212 if (dimension == 2)
213 Nusselt << x << "\t| " << y;
214 if (dimension == 3)
215 {
216 double z = domaine_VDF.xv(num_face, 2);
217 Nusselt << x << "\t| " << y << "\t| " << z;
218 }
219
220 for (int i=0; i<nb_fields_-1; i++)
221 Nusselt << "\t| " << tab_(num_face, i);
222 Nusselt << finl;
223 }
224 }
225 else
226 {
227 if (je_suis_maitre())
228 {
229 Nusselt << finl;
230 Nusselt << "Bord " << le_bord.le_nom() << finl;
231 if (dimension == 2)
232 {
233 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------" << finl;
234 Nusselt << "\tFace a\t\t\t\t|" << finl;
235 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------" << finl;
236 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;
237 Nusselt << "----------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------" << finl;
238 }
239 if (dimension == 3)
240 {
241 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
242 << finl;
243 Nusselt << "\tFace a\t\t\t\t\t\t\t|" << finl;
244 Nusselt << "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
245 << finl;
246 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;
247 Nusselt << "----------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------|-----------------------"
248 << finl;
249 }
250 }
251
252 ndeb = le_bord.num_premiere_face();
253 nfin = ndeb + le_bord.nb_faces();
254 for (int num_face = ndeb; num_face < nfin; num_face++)
255 {
256 double x = domaine_VDF.xv(num_face, 0);
257 double y = domaine_VDF.xv(num_face, 1);
258 elem = face_voisins(num_face, 0);
259 if (elem == -1)
260 elem = face_voisins(num_face, 1);
261
262 if (dimension == 2)
263 Nusselt << x << "\t| " << y;
264 if (dimension == 3)
265 {
266 double z = domaine_VDF.xv(num_face, 2);
267 Nusselt << x << "\t| " << y << "\t| " << z;
268 }
269
270 for (int i=0; i<nb_fields_-2; i++)
271 Nusselt << "\t| " << tab_(num_face, i);
272 Nusselt << finl;
273 }
274 }
275 Nusselt.syncfile();
276 }
277 }
278 if (je_suis_maitre())
279 Nusselt << finl << finl;
280 Nusselt.syncfile();
281}
282
283DoubleVect& Paroi_scal_hyd_base_VDF::equivalent_distance_name(DoubleVect& d_eq, const Nom& nom_bord) const
284{
285 int nb_boundaries = le_dom_dis_->domaine().nb_front_Cl();
286 for (int n_bord = 0; n_bord < nb_boundaries; n_bord++)
287 {
288 const Front_VF& fr_vf = le_dom_dis_->front_VF(n_bord);
289 int nb_faces = fr_vf.nb_faces();
290 if (fr_vf.le_nom() == nom_bord)
291 {
292 d_eq.resize(fr_vf.nb_faces());
293 for (int ind_face = 0; ind_face < nb_faces; ind_face++)
294 d_eq(ind_face) = equivalent_distance(n_bord, ind_face);
295 }
296 }
297 return d_eq;
298}
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_VDF
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_VDF
Definition Domaine_VDF.h:61
double dist_norm_bord_axi(int num_face) const
Returns the normal distance for a boundary face (cylindrical coordinates).
double dist_norm_bord(int num_face) const override
Returns the normal distance for a boundary face (Cartesian coordinates).
class Domaine_VF
Definition Domaine_VF.h:44
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
const Front_VF & front_VF(int i) const
Definition Domaine_VF.h:112
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
int nb_front_Cl() const
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 num_local_face(const int) const
Definition Front_VF.h:87
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
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 compute_nusselt() const override
DoubleVect & equivalent_distance_name(DoubleVect &d_equiv, const Nom &nom_bord) const override
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void imprimer_nusselt(Sortie &) const override
virtual const Equation_base & equation(int) const =0
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
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.