TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
VDF_discretisation.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 <VDF_discretisation.h>
17#include <Rotationnel_Champ_Face.h>
18#include <grad_U_Champ_Face.h>
19#include <Correlation_Vec_Sca_VDF.h>
20#include <Champ_Fonc_Tabule.h>
21#include <Champ_Fonc_Tabule_P0_VDF.h>
22#include <Critere_Q_Champ_Face.h>
23#include <Fluide_Ostwald.h>
24#include <Champ_Ostwald_VDF.h>
25#include <Champ_Uniforme.h>
26#include <Y_plus_Champ_Face.h>
27#include <Reynolds_maille_Champ_Face.h>
28#include <Courant_maille_Champ_Face.h>
29#include <Taux_cisaillement_P0_VDF.h>
30#include <Postraitement_base.h>
31#include <Schema_Temps_base.h>
32#include <Domaine_Cl_VDF.h>
33#include <Navier_Stokes_std.h>
34#include <Domaine_VDF.h>
35#include <Probleme_base.h>
36#include <Champ_P0_VDF.h>
37#include <T_paroi_Champ_P0_VDF.h>
38
39Implemente_instanciable(VDF_discretisation, "VDF", Discret_Thyd);
40// XD vdf discretisation_base vdf INHERITS_BRACE Finite difference volume discretization.
41
43{
44 return Discret_Thyd::readOn(s);
45}
46
47Sortie& VDF_discretisation::printOn(Sortie& s) const { return s; }
48
49/*! @brief Discretizes a OWN_PTR(Champ_Inc_base) for VDF based on a discretization directive.
50 *
51 * The directive is a Motcle such as "vitesse", "pression",
52 * "temperature", "champ_elem" (creates a P0-type field ...), ...
53 * This method determines the type of field to create based on the element type
54 * and the discretization directive. It then determines the number of dofs
55 * and sets all field parameters (type, nb_compo, nb_ddl, nb_pas_dt,
56 * name(s), unit(s), nature of the field and assigns a time) and associates the Domaine_dis with the field.
57 * See the code for the correspondence between directives and
58 * the type of field created.
59 *
60 */
61void VDF_discretisation::discretiser_champ(const Motcle& directive, const Domaine_dis_base& z, Nature_du_champ nature, const Noms& noms, const Noms& unites, int nb_comp, int nb_pas_dt, double temps,
62 OWN_PTR(Champ_Inc_base) &champ, const Nom& sous_type) const
63{
64 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
65
66 Motcles motcles(7);
67 motcles[0] = "vitesse"; // Standard choice for velocity
68 motcles[1] = "pression"; // Standard choice for pressure
69 motcles[2] = "temperature"; // Standard choice for temperature
70 motcles[3] = "divergence_vitesse"; // Field type obtained by computing div v
71 motcles[4] = "gradient_pression"; // Field type obtained by computing grad P
72 motcles[5] = "champ_face"; // Create a face field
73 motcles[6] = "champ_elem"; // Create an element field (P0 type)
74
75 Nom type;
76 int default_nb_comp = -1;
77 int rang = motcles.search(directive);
78 switch(rang)
79 {
80 case 0:
81 type = "Champ_Face_VDF";
82 default_nb_comp = dimension;
83 break;
84 case 1:
85 type = "Champ_P0_VDF";
86 default_nb_comp = 1;
87 break;
88 case 2:
89 type = "Champ_P0_VDF";
90 default_nb_comp = 1;
91 break;
92 case 3:
93 type = "Champ_P0_VDF";
94 default_nb_comp = 1;
95 break;
96 case 4:
97 type = "Champ_Face_VDF";
98 default_nb_comp = dimension;
99 break;
100 case 5:
101 type = "Champ_Face_VDF";
102 default_nb_comp = 1;
103 break;
104 case 6:
105 type = "Champ_P0_VDF";
106 default_nb_comp = 1;
107 break;
108 default:
109 assert(rang < 0);
110 break;
111 }
112
113 if (directive == DEMANDE_DESCRIPTION)
114 Cerr << "VDF_discretisation : " << motcles;
115
116 if (sous_type != NOM_VIDE)
117 rang = verifie_sous_type(type, sous_type, directive);
118
119 // If the directive was not understood (or if it is a demande_description),
120 // call the ancestor:
121 if (rang < 0)
122 {
123 Discret_Thyd::discretiser_champ(directive, z, nature, noms, unites, nb_comp, nb_pas_dt, temps, champ);
124 return;
125 }
126
127 // Compute the number of dofs
128 int nb_ddl = 0;
129 if (type.debute_par("Champ_P0_VDF"))
130 nb_ddl = z.nb_elem();
131 else if (type.debute_par("Champ_Face"))
132 nb_ddl = domaine_vdf.nb_faces();
133 else
134 assert(0);
135
136 if (nb_comp < 0)
137 nb_comp = default_nb_comp;
138 assert(nb_comp > 0);
139 creer_champ(champ, z, type, noms[0], unites[0], nb_comp, nb_ddl, nb_pas_dt, temps, directive, que_suis_je());
140
141 if (nature == multi_scalaire)
142 {
143 champ->fixer_nature_du_champ(nature);
144 champ->fixer_unites(unites);
145 champ->fixer_noms_compo(noms);
146 }
147
148}
149
150/*! @brief Same as VDF_discretisation::discretiser_champ(.
151 *
152 * .. , Champ_Inc) for a Champ_Fonc.
153 *
154 */
155void VDF_discretisation::discretiser_champ(const Motcle& directive, const Domaine_dis_base& z, Nature_du_champ nature, const Noms& noms, const Noms& unites, int nb_comp, double temps,
156 OWN_PTR(Champ_Fonc_base) &champ) const
157{
158 discretiser_champ_fonc_don(directive, z, nature, noms, unites, nb_comp, temps, champ);
159}
160
161/*! @brief Same as VDF_discretisation::discretiser_champ(.
162 *
163 * .. , Champ_Inc) for a Champ_Don.
164 *
165 */
166void VDF_discretisation::discretiser_champ(const Motcle& directive, const Domaine_dis_base& z, Nature_du_champ nature, const Noms& noms, const Noms& unites, int nb_comp, double temps,
167 OWN_PTR(Champ_Don_base)& champ) const
168{
169 discretiser_champ_fonc_don(directive, z, nature, noms, unites, nb_comp, temps, champ);
170}
171
172/*! @brief Same as VEF_discretisation::discretiser_champ(.
173 *
174 * .. , Champ_Inc). Common treatment for champ_fonc and champ_don.
175 * This method is private (passing an Objet_U is not clean from
176 * an external viewpoint ...)
177 *
178 */
179void VDF_discretisation::discretiser_champ_fonc_don(const Motcle& directive, const Domaine_dis_base& z, Nature_du_champ nature, const Noms& noms, const Noms& unites, int nb_comp, double temps,
180 Objet_U& champ) const
181{
182 // Two pointers to access the champ_don or champ_fonc easily, depending on the type of the champ object.
183 OWN_PTR(Champ_Fonc_base) *champ_fonc = dynamic_cast<OWN_PTR(Champ_Fonc_base)*>(&champ);
184 OWN_PTR(Champ_Don_base) *champ_don = dynamic_cast<OWN_PTR(Champ_Don_base)*>(&champ);
185
186 Motcles motcles(8);
187 motcles[0] = "pression";
188 motcles[1] = "temperature";
189 motcles[2] = "divergence_vitesse"; // Field type obtained by computing div v
190 motcles[3] = "champ_elem"; // Create an element field (P0 type)
191 motcles[4] = "vitesse"; // Create a field like velocity
192 motcles[5] = "gradient_pression"; // Field type obtained by computing grad P
193 motcles[6] = "champ_face"; // Create a face field
194 motcles[7] = "champ_sommets"; // Create a vertex field
195
196 Nom type;
197 int rang = motcles.search(directive);
198 int default_nb_comp = 1;
199 switch(rang)
200 {
201 case 0:
202 type = "Champ_Fonc_P0_VDF";
203 break;
204 case 1:
205 type = "Champ_Fonc_P0_VDF";
206 break;
207 case 2:
208 type = "Champ_Fonc_P0_VDF";
209 break;
210 case 3:
211 type = "Champ_Fonc_P0_VDF";
212 break;
213 case 4:
214 type = "Champ_Fonc_Face_VDF";
215 default_nb_comp = dimension;
216 break;
217 case 5:
218 type = "Champ_Fonc_Face_VDF";
219 default_nb_comp = dimension;
220 break;
221 case 6:
222 type = "Champ_Fonc_Face_VDF";
223 default_nb_comp = 1;
224 break;
225 case 7:
226 type = "Champ_Fonc_Q1_VDF";
227 default_nb_comp = 1;
228 break;
229
230 default:
231 assert(rang < 0);
232 break;
233 }
234
235 if (directive == DEMANDE_DESCRIPTION)
236 Cerr << "VDF_discretisation : " << motcles;
237
238 // If the directive was not understood (or if it is a demande_description),
239 // call the ancestor:
240 if (rang < 0)
241 {
242 if (champ_fonc)
243 Discret_Thyd::discretiser_champ(directive, z, nature, noms, unites, nb_comp, temps, *champ_fonc);
244 else
245 Discret_Thyd::discretiser_champ(directive, z, nature, noms, unites, nb_comp, temps, *champ_don);
246 return;
247 }
248
249 // Compute the number of dofs
250 int nb_ddl = 0;
251 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
252 if (type == "Champ_Fonc_P0_VDF")
253 nb_ddl = z.nb_elem();
254 else if (type == "Champ_Fonc_Face_VDF")
255 nb_ddl = domaine_vdf.nb_faces();
256 else if (type == "Champ_Fonc_Q1_VDF")
257 nb_ddl = domaine_vdf.nb_som();
258 else
259 assert(0);
260
261 if (nb_comp < 0)
262 nb_comp = default_nb_comp; // Default number of components
263 if (champ_fonc)
264 creer_champ(*champ_fonc, z, type, noms[0], unites[0], nb_comp, nb_ddl, temps, directive, que_suis_je());
265 else
266 creer_champ(*champ_don, z, type, noms[0], unites[0], nb_comp, nb_ddl, temps, directive, que_suis_je());
267
268 if ((nature == multi_scalaire) && (champ_fonc))
269 {
270 champ_fonc->valeur().fixer_nature_du_champ(nature);
271 champ_fonc->valeur().fixer_unites(unites);
272 champ_fonc->valeur().fixer_noms_compo(noms);
273 }
274 else if ((nature == multi_scalaire) && (champ_don))
275 {
276 Cerr << "There is no field of type OWN_PTR(Champ_Don_base) with a multi_scalaire nature." << finl;
277 exit();
278 }
279}
280
282 OWN_PTR(Champ_Fonc_base) &ch) const
283{
284 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
285 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
286 ch.typer("Rotationnel_Champ_Face");
287 Rotationnel_Champ_Face& ch_W = ref_cast(Rotationnel_Champ_Face, ch.valeur());
288 ch_W.associer_domaine_dis_base(domaine_vdf);
289 ch_W.associer_champ(vit);
290 ch_W.nommer("vorticite");
291 if (dimension == 2)
292 ch_W.fixer_nb_comp(1);
293 else
294 {
296 ch_W.fixer_nom_compo(0, "vorticiteX");
297 ch_W.fixer_nom_compo(1, "vorticiteY");
298 ch_W.fixer_nom_compo(2, "vorticiteZ");
299 }
300 ch_W.fixer_nb_valeurs_nodales(domaine_vdf.nb_elem());
301 ch_W.fixer_unite("s-1");
302 ch_W.changer_temps(ch_vitesse.temps());
303}
304
305void VDF_discretisation::critere_Q(const Domaine_dis_base& z, const Domaine_Cl_dis_base& zcl, const Champ_Inc_base& ch_vitesse, OWN_PTR(Champ_Fonc_base) &ch) const
306{
307 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
308 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
309 const Domaine_Cl_VDF& domaine_cl_vdf = ref_cast(Domaine_Cl_VDF, zcl);
310 ch.typer("Critere_Q_Champ_Face");
311 Critere_Q_Champ_Face& ch_Criter_Q = ref_cast(Critere_Q_Champ_Face, ch.valeur());
312 ch_Criter_Q.associer_domaine_dis_base(domaine_vdf);
313 ch_Criter_Q.associer_domaine_Cl_dis_base(domaine_cl_vdf);
314 ch_Criter_Q.associer_champ(vit);
315 ch_Criter_Q.nommer("Critere_Q");
316 ch_Criter_Q.fixer_nb_comp(1);
317 ch_Criter_Q.fixer_nb_valeurs_nodales(domaine_vdf.nb_elem());
318 ch_Criter_Q.fixer_unite("s-2");
319 ch_Criter_Q.changer_temps(ch_vitesse.temps());
320}
321
322void VDF_discretisation::grad_u(const Domaine_dis_base& z, const Domaine_Cl_dis_base& zcl, const Champ_Inc_base& ch_vitesse, OWN_PTR(Champ_Fonc_base) &ch) const
323{
324 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
325 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
326 const Domaine_Cl_VDF& domaine_cl_vdf = ref_cast(Domaine_Cl_VDF, zcl);
327 const int N = ch_vitesse.valeurs().line_size();
328 ch.typer("grad_U_Champ_Face");
329 grad_U_Champ_Face& ch_grad_u = ref_cast(grad_U_Champ_Face, ch.valeur());
330 ch_grad_u.associer_domaine_dis_base(domaine_vdf);
331 ch_grad_u.associer_domaine_Cl_dis_base(domaine_cl_vdf);
332 ch_grad_u.associer_champ(vit);
333 ch_grad_u.nommer("gradient_vitesse");
334 ch_grad_u.fixer_nb_comp(dimension * dimension * N);
335
336 for (int n = 0; n < N; n++)
337 if (dimension == 2)
338 {
339 ch_grad_u.fixer_nom_compo(N * 0 + n, "dUdX"); // du/dx
340 ch_grad_u.fixer_nom_compo(N * 1 + n, "dUdY"); // du/dy
341 ch_grad_u.fixer_nom_compo(N * 2 + n, "dVdX"); // dv/dx
342 ch_grad_u.fixer_nom_compo(N * 3 + n, "dVdY"); // dv/dy
343 }
344 else
345 {
346 ch_grad_u.fixer_nom_compo(N * 0 + n, "dUdX"); // du/dx
347 ch_grad_u.fixer_nom_compo(N * 1 + n, "dUdY"); // du/dy
348 ch_grad_u.fixer_nom_compo(N * 2 + n, "dUdZ"); // du/dz
349 ch_grad_u.fixer_nom_compo(N * 3 + n, "dVdX"); // dv/dx
350 ch_grad_u.fixer_nom_compo(N * 4 + n, "dVdY"); // dv/dy
351 ch_grad_u.fixer_nom_compo(N * 5 + n, "dVdZ"); // dv/dz
352 ch_grad_u.fixer_nom_compo(N * 6 + n, "dWdX"); // dw/dx
353 ch_grad_u.fixer_nom_compo(N * 7 + n, "dWdY"); // dw/dy
354 ch_grad_u.fixer_nom_compo(N * 8 + n, "dWdZ"); // dw/dz
355 }
356 ch_grad_u.fixer_nature_du_champ(vectoriel);
357 ch_grad_u.fixer_nb_valeurs_nodales(domaine_vdf.nb_elem());
358 ch_grad_u.fixer_unite("s-1");
359 ch_grad_u.changer_temps(ch_vitesse.temps());
360}
361
362void VDF_discretisation::reynolds_maille(const Domaine_dis_base& z, const Fluide_base& le_fluide, const Champ_Inc_base& ch_vitesse, OWN_PTR(Champ_Fonc_base) &champ) const
363{
364 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
365 champ.typer("Reynolds_maille_Champ_Face");
366 Reynolds_maille_Champ_Face& ch = ref_cast(Reynolds_maille_Champ_Face, champ.valeur());
367 ch.associer_domaine_dis_base(domaine_vdf);
368 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
369 const Champ_Don_base& nu = le_fluide.viscosite_cinematique();
370 ch.associer_champ(vit, nu);
371 ch.nommer("Reynolds_maille");
373 ch.fixer_nom_compo(0, "Reynolds_maille_X");
374 ch.fixer_nom_compo(1, "Reynolds_maille_Y");
375 if (dimension == 3)
376 ch.fixer_nom_compo(2, "Reynolds_maille_Z");
377 ch.fixer_nb_valeurs_nodales(domaine_vdf.nb_faces());
378 ch.fixer_unite("adimensionnel");
379 ch.changer_temps(ch_vitesse.temps());
380}
381
382void VDF_discretisation::courant_maille(const Domaine_dis_base& z, const Schema_Temps_base& sch, const Champ_Inc_base& ch_vitesse, OWN_PTR(Champ_Fonc_base) &champ) const
383{
384 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
385 champ.typer("Courant_maille_Champ_Face");
386 Courant_maille_Champ_Face& ch = ref_cast(Courant_maille_Champ_Face, champ.valeur());
387 ch.associer_domaine_dis_base(domaine_vdf);
388 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
389 ch.associer_champ(vit, sch);
390 ch.nommer("Courant_maille");
392 ch.fixer_nom_compo(0, "Courant_maille_X");
393 ch.fixer_nom_compo(1, "Courant_maille_Y");
394 if (dimension == 3)
395 ch.fixer_nom_compo(2, "Courant_maille_Z");
396 ch.fixer_nb_valeurs_nodales(domaine_vdf.nb_faces());
397 ch.fixer_unite("adimensionnel");
398 ch.changer_temps(ch_vitesse.temps());
399}
400
401void VDF_discretisation::taux_cisaillement(const Domaine_dis_base& z, const Domaine_Cl_dis_base& zcl, const Champ_Inc_base& ch_vitesse, OWN_PTR(Champ_Fonc_base) &champ) const
402{
403 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
404 const Domaine_Cl_VDF& domaine_cl_vdf = ref_cast(Domaine_Cl_VDF, zcl);
405 champ.typer("Taux_cisaillement_P0_VDF");
406 Taux_cisaillement_P0_VDF& ch = ref_cast(Taux_cisaillement_P0_VDF, champ.valeur());
407 ch.associer_domaine_dis_base(domaine_vdf);
408 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
409 ch.associer_champ(vit, domaine_cl_vdf);
410 ch.nommer("Taux_cisaillement");
411 int N = vit.valeurs().line_size();
412 ch.fixer_nb_comp(N);
413 for (int n = 0; n < N; n++)
414 {
415 Nom phase = Nom(n);
416 ch.fixer_nom_compo(n, Nom("Taux_cisaillement_") + phase);
417 }
418 ch.fixer_nb_valeurs_nodales(domaine_vdf.nb_elem());
419 ch.fixer_unite("s-1");
420 ch.changer_temps(ch_vitesse.temps());
421}
422
423void VDF_discretisation::y_plus(const Domaine_dis_base& z, const Domaine_Cl_dis_base& zcl, const Champ_Inc_base& ch_vitesse, OWN_PTR(Champ_Fonc_base) &ch) const
424{
425 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
426 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
427 const Domaine_Cl_VDF& domaine_cl_vdf = ref_cast(Domaine_Cl_VDF, zcl);
428 if (domaine_cl_vdf.equation().probleme().que_suis_je().debute_par("Pb_Multiphase"))
429 {
430 Cerr << "Discretization of y plus" << finl; // Used as a global wall distance model
431 Noms noms(1), unites(1);
432 noms[0] = Nom("Y_plus");
433 unites[0] = Nom("adimensionnel");
434 discretiser_champ(Motcle("champ_elem"), z, scalaire, noms, unites, 1, 0, ch);
435 DoubleTab& tab_y_p = ch->valeurs();
436 for (int i = 0; i < tab_y_p.dimension_tot(0); i++)
437 for (int n = 0; n < tab_y_p.dimension_tot(1); n++)
438 tab_y_p(i, n) = -1.;
439 }
440 else
441 {
442 ch.typer("Y_plus_Champ_Face");
443 Y_plus_Champ_Face& ch_y_plus = ref_cast(Y_plus_Champ_Face, ch.valeur());
444 ch_y_plus.associer_domaine_dis_base(domaine_vdf);
445 ch_y_plus.associer_domaine_Cl_dis_base(domaine_cl_vdf);
446 ch_y_plus.associer_champ(vit);
447 ch_y_plus.nommer("Y_plus");
448 ch_y_plus.fixer_nb_comp(1);
449 ch_y_plus.fixer_nb_valeurs_nodales(domaine_vdf.nb_elem());
450 ch_y_plus.fixer_unite("adimensionnel");
451 ch_y_plus.changer_temps(ch_vitesse.temps());
452 }
453}
454
455void VDF_discretisation::t_paroi(const Domaine_dis_base& z,const Domaine_Cl_dis_base& zcl, const Champ_Inc_base& ch_temp, OWN_PTR(Champ_Fonc_base)& ch) const
456{
457 Cerr << "Discretization of temperature_paroi" << finl;
458 const Champ_P0_VDF& temp = ref_cast(Champ_P0_VDF, ch_temp);
459 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
460 const Domaine_Cl_VDF& domaine_cl_vdf = ref_cast(Domaine_Cl_VDF, zcl);
461 ch.typer("T_paroi_Champ_P0_VDF");
462 T_paroi_Champ_P0_VDF& ch_tp = ref_cast(T_paroi_Champ_P0_VDF, ch.valeur());
463 ch_tp.associer_domaine_dis_base(domaine_vdf);
464 ch_tp.associer_domaine_Cl_dis_base(domaine_cl_vdf);
465 ch_tp.associer_champ(temp);
466 ch_tp.nommer("temperature_paroi");
467 ch_tp.add_synonymous("wall_temperature");
468 ch_tp.fixer_nb_comp(ch_temp.valeurs().line_size()); // for multiphase ...
469 ch_tp.fixer_nb_valeurs_nodales(domaine_vdf.nb_elem());
470 ch_tp.fixer_unite("K-C");
471 ch_tp.changer_temps(ch_temp.temps());
472}
473
474void VDF_discretisation::modifier_champ_tabule(const Domaine_dis_base& domaine_dis, Champ_Fonc_Tabule& le_champ_tabule, const VECT(OBS_PTR(Champ_base)) &ch_inc) const
475{
476 le_champ_tabule.typer_champ_tabule_discretise("Champ_Fonc_Tabule_P0_VDF");
477 Champ_Fonc_Tabule_P0_VDF& le_champ_tabule_dis = ref_cast(Champ_Fonc_Tabule_P0_VDF, le_champ_tabule.le_champ_tabule_discretise());
478 le_champ_tabule_dis.associer_domaine_dis_base(domaine_dis);
479 le_champ_tabule_dis.associer_param(ch_inc, le_champ_tabule.table());
480 le_champ_tabule_dis.nommer(le_champ_tabule.le_nom()); // We give a name to this field, help for debug
481 le_champ_tabule_dis.fixer_nb_comp(le_champ_tabule.nb_comp());
482 le_champ_tabule_dis.fixer_nb_valeurs_nodales(domaine_dis.nb_elem());
483 le_champ_tabule_dis.changer_temps(ch_inc[0]->temps());
484}
485
486/*! @brief Discretizes the incompressible fluid in VDF, including K, e, N.
487 *
488 * @param z domain to discretize
489 * @param le_fluide fluid to discretize
490 * @param eqn_hydr Navier-Stokes equation (used to access velocity)
491 */
493{
494 Cerr << "Discretization of fluide_Ostwald" << finl;
495 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
496 const Champ_Inc_base& ch_vitesse = eqn_hydr.inconnue();
497 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
498
499 Champ_Don_base& mu = le_fluide.viscosite_dynamique();
500 // mu is always a champ_Ostwald_VDF, so the following must always be done
501 Champ_Ostwald_VDF& ch_mu = ref_cast(Champ_Ostwald_VDF, mu);
502 Cerr << "associating domainedisbase" << finl;
503 ch_mu.associer_domaine_dis_base(domaine_vdf);
504 ch_mu.associer_fluide(le_fluide);
505 ch_mu.associer_champ(vit);
506 Cerr << "associations done" << finl;
507 ch_mu.fixer_nb_comp(1);
508
509 Cerr << "calling fixer_nb_valeurs_nodales" << finl;
510 Cerr << "nb_valeurs_nodales = " << domaine_vdf.nb_elem() << finl;
511 ch_mu.fixer_nb_valeurs_nodales(domaine_vdf.nb_elem());
512
513 Cerr << "calling changer_temps" << finl;
514 ch_mu.changer_temps(vit.temps());
515
516 Cerr << "mu is discretized " << finl;
517}
518
520 OWN_PTR(Champ_Fonc_base) &ch) const
521{
522 if (sub_type(Champ_Face_VDF, ch_vitesse))
523 {
524 const Champ_Face_VDF& vit = ref_cast(Champ_Face_VDF, ch_vitesse);
525 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, vit.domaine_dis_base());
526 int N = ch_vitesse.valeurs().line_size();
527 ch.typer("Rotationnel_Champ_Face");
528 Rotationnel_Champ_Face& ch_W = ref_cast(Rotationnel_Champ_Face, ch.valeur());
529 ch_W.associer_domaine_dis_base(domaine_VDF);
530 ch_W.associer_champ(vit);
531 ch_W.nommer("vorticite");
532 if (dimension == 2)
533 ch_W.fixer_nb_comp(N);
534 else
535 for (int n = 0; n < N; n++)
536 {
537 ch_W.fixer_nb_comp(dimension * N);
538 ch_W.fixer_nom_compo(N * 0 + n, "vorticiteX");
539 ch_W.fixer_nom_compo(N * 1 + n, "vorticiteY");
540 ch_W.fixer_nom_compo(N * 2 + n, "vorticiteZ");
541 }
542 ch_W.fixer_nb_valeurs_nodales(domaine_VDF.nb_elem());
543 ch_W.fixer_unite("s-1");
544 ch_W.changer_temps(sch.temps_courant());
545 }
546}
547
548void VDF_discretisation::residu(const Domaine_dis_base& z, const Champ_Inc_base& ch_inco, OWN_PTR(Champ_Fonc_base) &champ) const
549{
550 Nom ch_name(ch_inco.le_nom());
551 ch_name += "_residu";
552 Cerr << "Discretization of " << ch_name << finl;
553
554 const Domaine_VDF& domaine_vdf = ref_cast(Domaine_VDF, z);
555
556 Motcle loc;
557 int nb_comp;
558 Nom type_ch = ch_inco.que_suis_je();
559 if (type_ch.debute_par("Champ_Face"))
560 {
561 loc = "champ_face";
562 nb_comp = dimension * ch_inco.valeurs().line_size();
563 }
564 else
565 {
566 loc = "champ_elem";
567 nb_comp = ch_inco.valeurs().line_size();
568 }
569
570 Discretisation_base::discretiser_champ(loc, domaine_vdf, ch_name, "units_not_defined", nb_comp, ch_inco.temps(), champ);
571 Champ_Fonc_base& ch_fonc = ref_cast(Champ_Fonc_base, champ.valeur());
572 DoubleTab& tab = ch_fonc.valeurs();
573 tab = -10000.0;
574 Cerr << "[Information] Discretisation_base::residu : the residue is set to -10000.0 at initial time" << finl;
575}
576
578{
579 Cerr << "Discretization of global wall distance" << finl;
580 Noms noms(1), unites(1);
581 noms[0] = Nom("distance_paroi_globale");
582 unites[0] = Nom("m");
583 discretiser_champ(Motcle("champ_elem"), z, scalaire, noms, unites, 1, 0, ch);
584}
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
class Champ_Face_VDF
int fixer_nb_valeurs_nodales(int) override
Sets the number of degrees of freedom per component.
int fixer_nb_valeurs_nodales(int n) override
Sets the number of degrees of freedom per component.
void associer_param(const VECT(OBS_PTR(Champ_base))&, const Table &)
Class Champ_Fonc_Tabule Derived class of Champ_Fonc_base representing.
const Table & table() const
void typer_champ_tabule_discretise(const Nom &typ)
const Champ_Fonc_base & le_champ_tabule_discretise() const
Returns the computed tabulated field.
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
void associer_domaine_dis_base(const Domaine_dis_base &) override
Class Champ_Inc_base.
const Domaine_dis_base & domaine_dis_base() const override
DoubleTab & valeurs() override
Returns the array of field values at the current time.
class Champ_Ostwald_VDF
void associer_champ(const Champ_Face_VDF &un_champ)
void associer_fluide(const Fluide_Ostwald &le_fluide)
int fixer_nb_valeurs_nodales(int nb_noeuds) override
Sets the number of degrees of freedom per component.
class Champ_P0_VDF Class representing a P0 discrete field per element associated with a discretized d...
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
virtual double changer_temps(const double t)
Sets the time at which the field is defined.
double temps() const
Returns the time of the field.
void associer_champ(const Champ_Face_VDF &, const Schema_Temps_base &)
class Critere_Q_Champ_Face
void associer_domaine_Cl_dis_base(const Domaine_Cl_dis_base &le_dom_Cl_dis_base)
void associer_champ(const Champ_Face_VDF &)
class Discret_Thyd This class is the base class representing a discretization
static void creer_champ(OWN_PTR(Champ_Inc_base)&ch, const Domaine_dis_base &z, const Nom &type, const Nom &nom, const Nom &unite, int nb_comp, int nb_ddl, int nb_pas_dt, double temps, const Nom &directive=NOM_VIDE, const Nom &nom_discretisation=NOM_VIDE)
Static method that creates an OWN_PTR(Champ_Inc_base) of the specified type.
static const Nom NOM_VIDE
static const Motcle DEMANDE_DESCRIPTION
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
int verifie_sous_type(Nom &type, const Nom &sous_type, const Motcle &directive) const
class Domaine_Cl_VDF
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VDF
Definition Domaine_VDF.h:61
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
const Nom & le_nom() const override
Returns the name of the field.
void nommer(const Nom &) override
Gives a name to the field.
virtual const Nom & fixer_unite(const Nom &)
Specifies the unit of a scalar field or whose all components have the same unit.
virtual Nature_du_champ fixer_nature_du_champ(Nature_du_champ nat)
Sets the nature of a field: scalar, multiscalar, vectorial.
virtual int nb_comp() const
Definition Field_base.h:56
virtual void add_synonymous(const Nom &nom)
Definition Field_base.h:53
virtual const Nom & fixer_nom_compo(int, const Nom &)
Sets the name of the i-th component of the field.
class Fluide_Ostwald
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
const Champ_Don_base & viscosite_dynamique() const
Definition Fluide_base.h:58
const Champ_Don_base & viscosite_cinematique() const
Definition Fluide_base.h:56
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
Navier_Stokes_std This class carries the terms of the momentum equation.
const Champ_Inc_base & inconnue() const override
Returns the velocity (unknown field of the equation) (const version).
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
An array of character strings (VECT(Nom)).
Definition Noms.h:26
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
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
void associer_champ(const Champ_Face_VDF &, const Champ_Don_base &)
class Rotationnel_Champ_Face
void associer_champ(const Champ_Face_VDF &)
class Schema_Temps_base
double temps_courant() const
Returns the current time.
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67
void associer_champ(const Champ_P0_VDF &)
void associer_domaine_Cl_dis_base(const Domaine_Cl_dis_base &le_dom_Cl_dis_base)
class Taux_cisaillement_P0_VDF
void associer_champ(const Champ_Face_VDF &, const Domaine_Cl_dis_base &)
void vorticite(Domaine_dis_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, Nature_du_champ nature, const Noms &nom, const Noms &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base) &champ, const Nom &sous_type=NOM_VIDE) const override
Discretizes a OWN_PTR(Champ_Inc_base) for VDF based on a discretization directive.
void residu(const Domaine_dis_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const override
void grad_u(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const override
void t_paroi(const Domaine_dis_base &z, const Domaine_Cl_dis_base &zcl, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&ch) const override
void taux_cisaillement(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const override
void proprietes_physiques_fluide_Ostwald(const Domaine_dis_base &, Fluide_Ostwald &, const Navier_Stokes_std &, const Champ_Inc_base &) const override
Discretizes the incompressible fluid in VDF, including K, e, N.
void y_plus(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const override
void distance_paroi_globale(const Schema_Temps_base &, Domaine_dis_base &, OWN_PTR(Champ_Fonc_base)&) const override
void reynolds_maille(const Domaine_dis_base &, const Fluide_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const override
void critere_Q(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const override
void courant_maille(const Domaine_dis_base &, const Schema_Temps_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const override
void creer_champ_vorticite(const Schema_Temps_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const override
class Y_plus_Champ_Face
void associer_domaine_Cl_dis_base(const Domaine_Cl_dis_base &le_dom_Cl_dis_base)
void associer_champ(const Champ_Face_VDF &)
class grad_U_Champ_Face
void associer_domaine_Cl_dis_base(const Domaine_Cl_dis_base &le_dom_Cl_dis_base)
void associer_champ(const Champ_Face_VDF &)