9.2
general documentation
cs_cdo_turbulence.h
Go to the documentation of this file.
1#ifndef CS_CDO_TURBULENCE_H
2#define CS_CDO_TURBULENCE_H
3
4/*============================================================================
5 * Functions to handle the resolution of the turbulence modelling
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------
29 * Local headers
30 *----------------------------------------------------------------------------*/
31
32#include "base/cs_field.h"
33#include "base/cs_param_types.h"
34#include "base/cs_reducers.h"
35#include "base/cs_time_step.h"
36#include "cdo/cs_cdo_connect.h"
38#include "cdo/cs_equation.h"
39#include "cdo/cs_property.h"
40#include "mesh/cs_mesh.h"
42
43/*============================================================================
44 * Macro definitions
45 *============================================================================*/
46
47#define CS_NAVSTO_TOTAL_VISCOSITY "total_viscosity"
48#define CS_NAVSTO_LAM_VISCOSITY "laminar_viscosity"
49#define CS_NAVSTO_TURB_VISCOSITY "turbulent_viscosity"
50
51/*============================================================================
52 * Type definitions
53 *============================================================================*/
54
62typedef struct {
63
70
78
86
92
98
100
107typedef struct _cs_turbulence_t cs_turbulence_t;
108
109/*============================================================================
110 * Function pointer definition
111 *============================================================================*/
112
113/*----------------------------------------------------------------------------*/
122/*----------------------------------------------------------------------------*/
123
124typedef void *
126
127/*----------------------------------------------------------------------------*/
135/*----------------------------------------------------------------------------*/
136
137typedef void *
138(cs_turb_free_context_t)(void *turb_context);
139
140/*----------------------------------------------------------------------------*/
152/*----------------------------------------------------------------------------*/
153
154typedef void
156 const cs_cdo_connect_t *connect,
157 const cs_cdo_quantities_t *quant,
158 const cs_time_step_t *time_step,
159 cs_turbulence_t *tbs);
160
161/*----------------------------------------------------------------------------*/
171/*----------------------------------------------------------------------------*/
172
173typedef void
175 const cs_cdo_connect_t *connect,
176 const cs_cdo_quantities_t *quant,
177 const cs_time_step_t *time_step,
178 const cs_turbulence_t *tbs);
179
187
199
204
216
222
228
234
239
246 /* \var mu_t_field
247 * Field related to the turbulent viscosity
248 */
249
251
257
274 void *context;
275
281
287
293
300
307
308 /*----------------------------------------------------------------------------*/
316 /*----------------------------------------------------------------------------*/
317
318 void
320
321 /*----------------------------------------------------------------------------*/
334 /*----------------------------------------------------------------------------*/
335
336 void
338 const cs_time_step_t *ts,
339 const cs_param_psteady_t &psp,
340 cs_cdo_navsto_psteady_cvg_t &ps_cvg) const;
341};
342
343/*============================================================================
344 * Public function prototypes
345 *============================================================================*/
346
347/*----------------------------------------------------------------------------*/
348/*
349 * \brief Allocate the structure storing the set of parameters for the
350 * turbulence modelling
351 *
352 * \return a pointer to a new allocated cs_turbulence_param_t structure
353 */
354/*----------------------------------------------------------------------------*/
355
358
359/*----------------------------------------------------------------------------*/
360/*
361 * \brief Allocate the structure managing the turbulence modelling
362 *
363 * \param[in] tbp pointer to a \ref cs_turbulence_param_t structure
364 *
365 * \return a pointer to a new allocated cs_turbulence_t structure
366 */
367/*----------------------------------------------------------------------------*/
368
371
372/*----------------------------------------------------------------------------*/
373/*
374 * \brief Free the structure managing the turbulence modelling
375 *
376 * \param[in, out] p_turb_struct pointer to the structure to free
377 */
378/*----------------------------------------------------------------------------*/
379
380void
381cs_turbulence_free(cs_turbulence_t **p_turb_struct);
382
383/*----------------------------------------------------------------------------*/
384/*
385 * \brief Initialize the structure managing the turbulence modelling
386 *
387 * \param[in, out] tbs pointer to the structure to initialize
388 * \param[in] mom_eq pointer to the structure mom_eq
389 */
390/*----------------------------------------------------------------------------*/
391
392void
394 cs_equation_t *mom_eq);
395
396/*----------------------------------------------------------------------------*/
397/*
398 * \brief Finalize the setup of the turbulence modelling and especially the
399 * equations/properties and other related quantities
400 *
401 * \param[in] mesh pointer to a \ref cs_mesh_t structure
402 * \param[in] connect pointer to a cs_cdo_connect_t structure
403 * \param[in] quant pointer to a cs_cdo_quantities_t structure
404 * \param[in] time_step pointer to a cs_time_step_t structure
405 * \param[in, out] tbs pointer to the turbulence main structure
406 */
407/*----------------------------------------------------------------------------*/
408
409void
411 const cs_cdo_connect_t *connect,
412 const cs_cdo_quantities_t *quant,
413 const cs_time_step_t *time_step,
414 cs_turbulence_t *tbs);
415
416/*----------------------------------------------------------------------------*/
417/*
418 * \brief Indicate whether use Legacy solved turbulent viscosity
419 * \param[in, out] tbs pointer to the turbulence main structure
420 * \param[in] is_shared boolean parameter to set
421 */
422/*----------------------------------------------------------------------------*/
423
424void
426
427/*----------------------------------------------------------------------------*/
428/*
429 * \brief Initialize the values of quantities related to a turbulence model.
430 *
431 * \param[in] mesh pointer to a \ref cs_mesh_t structure
432 * \param[in] connect pointer to a cs_cdo_connect_t structure
433 * \param[in] quant pointer to a cs_cdo_quantities_t structure
434 * \param[in] time_step pointer to a cs_time_step_t structure
435 * \param[in, out] tbs pointer to the turbulence main structure
436 */
437/*----------------------------------------------------------------------------*/
438
439void
441 const cs_cdo_connect_t *connect,
442 const cs_cdo_quantities_t *quant,
443 const cs_time_step_t *time_step,
444 cs_turbulence_t *tbs);
445
446/*----------------------------------------------------------------------------*/
447/*
448 * \brief Allocate and initialize the context structure related to the
449 * k-epsilon turbulence model
450 *
451 * \param[in] tbm structure which defines the turbulence model
452 *
453 * \return a pointer to a new allocated context structure
454 */
455/*----------------------------------------------------------------------------*/
456
457void *
459
460/*----------------------------------------------------------------------------*/
461/*
462 * \brief Free the context structure related to the k-epsilon turbulence model
463 *
464 * \param[in, out] tbc pointer to a structure context cast on-the-fly
465 *
466 * \return a null pointer
467 */
468/*----------------------------------------------------------------------------*/
469
470void *
472
473/*----------------------------------------------------------------------------*/
474/*
475 * \brief Compute for the current time step the new state for the turbulence
476 * model. This means that all related equations are built and then
477 * solved.
478 *
479 * \param[in] mesh pointer to a \ref cs_mesh_t structure
480 * \param[in] connect pointer to a cs_cdo_connect_t structure
481 * \param[in] quant pointer to a cs_cdo_quantities_t structure
482 * \param[in] time_step structure managing the time stepping
483 * \param[in, out] tbs pointer to turbulence structure
484 */
485/*----------------------------------------------------------------------------*/
486
487void
489 const cs_cdo_connect_t *connect,
490 const cs_cdo_quantities_t *quant,
491 const cs_time_step_t *time_step,
492 cs_turbulence_t *tbs);
493
494
495/*----------------------------------------------------------------------------*/
496/*
497 * \brief Update for the current time step the new state for the turbulence
498 * model. This is used to update the turbulent viscosity.
499 *
500 * \param[in] mesh pointer to a \ref cs_mesh_t structure
501 * \param[in] connect pointer to a cs_cdo_connect_t structure
502 * \param[in] quant pointer to a cs_cdo_quantities_t structure
503 * \param[in] time_step structure managing the time stepping
504 * \param[in] tbs pointer to a \ref cs_turbulence_t structure
505 */
506/*----------------------------------------------------------------------------*/
507
508void
510 const cs_cdo_connect_t *connect,
511 const cs_cdo_quantities_t *quant,
512 const cs_time_step_t *time_step,
513 const cs_turbulence_t *tbs);
514
515/*----------------------------------------------------------------------------*/
516/*
517 * \brief Update for the current time step the new state for the turbulence
518 * model. directly update the turbulent viscosity from Legacy.
519 *
520 * \param[in] mesh pointer to a \ref cs_mesh_t structure
521 * \param[in] connect pointer to a cs_cdo_connect_t structure
522 * \param[in] quant pointer to a cs_cdo_quantities_t structure
523 * \param[in] time_step structure managing the time stepping
524 * \param[in] tbs pointer to a \ref cs_turbulence_t structure
525 */
526/*----------------------------------------------------------------------------*/
527
528void
530 const cs_cdo_connect_t *connect,
531 const cs_cdo_quantities_t *quant,
532 const cs_time_step_t *time_step,
533 const cs_turbulence_t *tbs);
534
535/*----------------------------------------------------------------------------*/
549/*----------------------------------------------------------------------------*/
550
551void
553 const double nu,
554 const double k,
555 const double hfc,
556 const double uct,
557 const double uft,
558 cs_real_t *ht,
559 cs_real_t *f_w);
560
561/*----------------------------------------------------------------------------*/
562/*
563 * \brief Return true if a wall function is used for turbulence.
564 *
565 * \param[in] turbulence pointer to a cs_turbulence_param_t
566 *
567 *\return true or false
568 */
569/*----------------------------------------------------------------------------*/
570
571bool
573
574#endif /* CS_CDO_TURBULENCE_H */
Field descriptor.
Definition: cs_field.h:275
time step descriptor
Definition: cs_time_step.h:60
void cs_turbulence_finalize_setup(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, cs_turbulence_t *tbs)
Finalize the setup of the turbulence modelling and especially the equations/properties and other rela...
Definition: cs_cdo_turbulence.cpp:631
void cs_turbulence_set_shared_from_fv(cs_turbulence_t *tbs, bool is_shared)
Indicate whether use Legacy solved turbulent viscosity.
Definition: cs_cdo_turbulence.cpp:749
void cs_turbulence_init_setup(cs_turbulence_t *tbs, cs_equation_t *mom_eq)
Initialize the structure managing the turbulence modelling.
Definition: cs_cdo_turbulence.cpp:511
void * cs_turb_free_k_eps_context(void *tbc)
Free the context structure related to the k-epsilon turbulence model.
Definition: cs_cdo_turbulence.cpp:899
void *() cs_turb_free_context_t(void *turb_context)
Free the context structure related to a given turbulence modelling.
Definition: cs_cdo_turbulence.h:138
void * cs_turb_init_k_eps_context(const cs_turb_model_t *tbm)
Allocate and initialize the context structure related to the k-epsilon turbulence model.
Definition: cs_cdo_turbulence.cpp:801
bool cs_turb_wall_functions_is_activated(const cs_turbulence_param_t *turbulence)
Return true if a wall function is used for turbulence.
Definition: cs_cdo_turbulence.cpp:1196
void cs_turb_compute_wall_bc_coeffs(const cs_equation_param_t *eqp, const double nu, const double k, const double hfc, const double uct, const double uft, cs_real_t *ht, cs_real_t *f_w)
Function used to define the exchange coefficients for tangential and normal components.
Definition: cs_cdo_turbulence.cpp:1139
void cs_turbulence_free(cs_turbulence_t **p_turb_struct)
Free the structure managing the turbulence modelling.
Definition: cs_cdo_turbulence.cpp:483
void() cs_turb_compute_t(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, cs_turbulence_t *tbs)
Compute for the current time step the new state for the turbulence model. This means that all related...
Definition: cs_cdo_turbulence.h:155
void cs_turb_update_shared_legacy(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, const cs_turbulence_t *tbs)
Update for the current time step the new state for the turbulence model. directly update the turbulen...
Definition: cs_cdo_turbulence.cpp:998
cs_turbulence_t * cs_turbulence_create(cs_turbulence_param_t *tbp)
Allocate the structure managing the turbulence modelling.
Definition: cs_cdo_turbulence.cpp:432
void *() cs_turb_init_context_t(const cs_turb_model_t *tbm)
Allocate and initialize the context structure related to a given turbulence modelling.
Definition: cs_cdo_turbulence.h:125
void cs_turbulence_init_values(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, cs_turbulence_t *tbs)
Initialize the values of quantities related to a turbulence model.
Definition: cs_cdo_turbulence.cpp:768
void() cs_turb_update_t(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, const cs_turbulence_t *tbs)
Update properties, arrays related to the turbulent variables.
Definition: cs_cdo_turbulence.h:174
cs_turbulence_param_t * cs_turbulence_param_create(void)
Allocate the structure storing the set of parameters for the turbulence modelling.
Definition: cs_cdo_turbulence.cpp:398
void cs_turb_compute_k_eps(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, cs_turbulence_t *tbs)
Compute for the current time step the new state for the turbulence model. This means that all related...
Definition: cs_cdo_turbulence.cpp:1048
void cs_turb_update_k_eps(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, const cs_turbulence_t *tbs)
Update for the current time step the new state for the turbulence model. This is used to update the t...
Definition: cs_cdo_turbulence.cpp:925
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
@ k
Definition: cs_field_pointer.h:68
char * boundary_stress
Definition: function_defaults.h:186
Definition: mesh.f90:26
Definition: cs_cdo_turbulence.h:186
void check_convergence(const cs_cdo_quantities_t *quant, const cs_time_step_t *ts, const cs_param_psteady_t &psp, cs_cdo_navsto_psteady_cvg_t &ps_cvg) const
Check the convergence of the pseudo-steady algorithm when the unsteady Navier-Stokes system with a CD...
Definition: cs_cdo_turbulence.cpp:1307
cs_property_t * mu_l
Definition: cs_cdo_turbulence.h:227
cs_turb_update_t * update
Definition: cs_cdo_turbulence.h:306
void * context
Definition: cs_cdo_turbulence.h:274
cs_turb_compute_t * compute_steady
Definition: cs_cdo_turbulence.h:299
cs_turbulence_param_t * param
Definition: cs_cdo_turbulence.h:198
cs_turb_free_context_t * free_context
Definition: cs_cdo_turbulence.h:286
cs_equation_t * mom_eq
Definition: cs_cdo_turbulence.h:203
cs_property_t * mu_t
Definition: cs_cdo_turbulence.h:233
cs_turb_init_context_t * init_context
Definition: cs_cdo_turbulence.h:280
cs_turb_compute_t * compute
Definition: cs_cdo_turbulence.h:292
cs_field_t * mu_t_field
Definition: cs_cdo_turbulence.h:250
cs_property_t * rho
Definition: cs_cdo_turbulence.h:215
cs_field_t * rij
Definition: cs_cdo_turbulence.h:256
cs_real_t * mu_tot_array
Definition: cs_cdo_turbulence.h:238
void add_boundary_stress(const cs_mesh_t *m, cs_field_t *boundary_stress) const
Compute and add the turbulent part of the boundray stress.
Definition: cs_cdo_turbulence.cpp:1223
cs_property_t * mu_tot
Definition: cs_cdo_turbulence.h:221
Definition: cs_cdo_connect.h:57
Definition: cs_param_types.h:660
Definition: cs_cdo_quantities.h:142
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:190
Main structure to handle the discretization and the resolution of an equation.
Definition: cs_mesh.h:85
Set of parameters to check the convergence of the pseudo-steady algo.
Definition: cs_param_types.h:631
Structure associated to the definition of a property relying on the cs_xdef_t structure.
LES turbulence model descriptor.
Definition: cs_turbulence_model.h:287
Turbulence model general options descriptor.
Definition: cs_turbulence_model.h:126
RANS turbulence model descriptor.
Definition: cs_turbulence_model.h:210
Definition: cs_turbulence_model.h:199
Structure storing the parameters related to the resolution of the turbulence modelling....
Definition: cs_cdo_turbulence.h:62
cs_turb_les_model_t * les_param
Definition: cs_cdo_turbulence.h:85
cs_turb_ref_values_t * reference_values
Definition: cs_cdo_turbulence.h:91
cs_turb_model_t * model
Definition: cs_cdo_turbulence.h:69
cs_turb_rans_model_t * rans_param
Definition: cs_cdo_turbulence.h:77
bool shared_from_legacy
Definition: cs_cdo_turbulence.h:97
Structure storing the parameters related to the resolution of the turbulence modelling....