9.2
general documentation
cs_les_inflow.h
Go to the documentation of this file.
1
2#ifndef CS_LES_INFLOW_H
3#define CS_LES_INFLOW_H
4
5/*============================================================================
6 * Turbulent inflow generation
7 *============================================================================*/
8
9/*
10 This file is part of code_saturne, a general-purpose CFD tool.
11
12 Copyright (C) 1998-2026 EDF S.A.
13
14 This program is free software; you can redistribute it and/or modify it under
15 the terms of the GNU General Public License as published by the Free Software
16 Foundation; either version 2 of the License, or (at your option) any later
17 version.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 details.
23
24 You should have received a copy of the GNU General Public License along with
25 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26 Street, Fifth Floor, Boston, MA 02110-1301, USA.
27*/
28
29/*----------------------------------------------------------------------------*/
30
31#include "base/cs_defs.h"
32
33/*----------------------------------------------------------------------------
34 * Local headers
35 *----------------------------------------------------------------------------*/
36
37#include "base/cs_base.h"
38#include "base/cs_zone.h"
39
40/*============================================================================
41 * Macro definitions
42 *============================================================================*/
43
44/*============================================================================
45 * Type definitions
46 *============================================================================*/
47
48/*----------------------------------------------------------------------------
49 * Type of synthetic turbulence generation
50 *----------------------------------------------------------------------------*/
51
52typedef enum {
53
61
62/*=============================================================================
63 * Local Structure Definitions
64 *============================================================================*/
65
66/* Inlet definition */
67/*------------------*/
68
69typedef struct _cs_inlet_t cs_inlet_t;
70
71typedef struct {
72
78
79/*=============================================================================
80 * Public function prototypes
81 *============================================================================*/
82
83/*----------------------------------------------------------------------------*/
87/*----------------------------------------------------------------------------*/
88
89extern "C" void
91
92/*----------------------------------------------------------------------------*/
96/*----------------------------------------------------------------------------*/
97
98extern "C" void
100
101/*----------------------------------------------------------------------------*/
121/*----------------------------------------------------------------------------*/
122
123extern "C" void
125 bool volume_mode,
126 const cs_zone_t *zone,
127 int n_entities,
128 int verbosity,
129 const cs_real_t *vel_r,
130 cs_real_t k_r,
131 cs_real_t eps_r);
132
133/*----------------------------------------------------------------------------*/
137/*----------------------------------------------------------------------------*/
138
139extern "C" void
141
142/*----------------------------------------------------------------------------*/
143/*
144 * \brief General synthetic turbulence generation
145 */
146/*----------------------------------------------------------------------------*/
147
148extern "C" void
150
151/*----------------------------------------------------------------------------
152 * Read the restart file of les inflow module.
153 *----------------------------------------------------------------------------*/
154
155extern "C" void
157
158/*----------------------------------------------------------------------------
159 * Write the restart file of les inflow module.
160 *----------------------------------------------------------------------------*/
161
162extern "C" void
164
165/*----------------------------------------------------------------------------*/
166/*
167 * \brief Generation of synthetic turbulence via the Synthetic Eddy Method (SEM).
168 *
169 * \param[in] n_elts local number of points where
170 * turbulence is generated
171 * \param[in] elt_ids local id of inlet elements
172 * \param[in] point_coordinates point coordinates
173 * \param[in] point_weight point weights (surface, volume or NULL)
174 * \param[in] initialize initialization indicator
175 * \param[in] volume_mode volume_mode indicator
176 * \param[in] verbosity verbosity level
177 * \param[in] inflow pointer to structure for Batten method
178 * \param[in] t_cur current time
179 * \param[in] vel_m_l mean velocity at each point
180 * \param[in] rij_l reynolds stresses at each point
181 * \param[in] eps_l dissipation rate at each point
182 * \param[out] fluctuations velocity fluctuations at each point
183 */
184/*----------------------------------------------------------------------------*/
185
186extern "C" void
188 const cs_lnum_t elt_ids[],
189 const cs_real_3_t point_coordinates[],
190 const cs_real_t *point_weight,
191 int initialize,
192 int volume_mode,
193 int verbosity,
194 cs_inflow_sem_t *inflow,
195 cs_real_t t_cur,
196 const cs_real_3_t vel_m_l[],
197 const cs_real_6_t rij_l[],
198 const cs_real_t eps_l[],
199 cs_real_3_t fluctuations[]);
200
201/*----------------------------------------------------------------------------*/
202/*
203 * \brief Rescale fluctuations by statistics following the Lund method.
204 *
205 * One assumes that the statistics are interlaced and ordered as follows:
206 * <u'u'> <v'v'> <w'w'> <u'v'> <v'w'> <u'w'>
207 *
208 * \param[in] n_points local number of points where
209 * turbulence is generated
210 * \param[in] statistics statistics (i.e. Reynolds stresses)
211 * \param[in, out] fluctuations velocity fluctuations generated
212 *----------------------------------------------------------------------------*/
213
214extern "C" void
216 const cs_real_6_t statistics[],
217 cs_real_3_t fluctuations[]);
218
219/*----------------------------------------------------------------------------*/
220/*
221 * \brief Set number of structures used for volume SEM when
222 * restarting from another turbulence model.
223 *
224 * By default, a restart file is read if present, and a checkpoint written.
225 * If not read, synthetic fluctuations are re-initialized.
226 *
227 * \param[in] n_structures number of structures for initialization
228 */
229/*----------------------------------------------------------------------------*/
230
231extern "C" void
233
234/*----------------------------------------------------------------------------*/
235/*
236 * \brief Return number of structures used for volume SEM when
237 * restarting from another turbulence model.
238 *
239 * \return number of structures for initialization
240 */
241/*----------------------------------------------------------------------------*/
242
243extern "C" int
245
246/*----------------------------------------------------------------------------*/
247/*
248 * \brief Query behavior of the LES inflow module in case of restart.
249 *
250 * See \ref cs_les_synthetic_eddy_set_restart for details.
251 *
252 * \param[out] allow_read pointer to read flag, or NULL
253 * \param[out] allow_write pointer to write flag, or NULL
254 */
255/*----------------------------------------------------------------------------*/
256
257extern "C" void
258cs_les_inflow_get_restart(bool *allow_read,
259 bool *allow_write);
260
261/*----------------------------------------------------------------------------*/
262/*
263 * \brief Define behavior of the LES inflow module in case of restart.
264 *
265 * By default, a restart file is read if present, and a checkpoint written.
266 * If not read, synthetic fluctuations are re-initialized.
267 *
268 * \param[in] allow_read allow reading a relevant checkpoint if present
269 * \param[in] allow_write allow writing a relevant checkpoint if present
270 */
271/*----------------------------------------------------------------------------*/
272
273extern "C" void
274cs_les_inflow_set_restart(bool allow_read,
275 bool allow_write);
276
277/*----------------------------------------------------------------------------*/
278/*
279 * \file cs_user_les_inflow.cpp
280 *
281 * \brief Generation of synthetic turbulence at LES inlets initialization.
282 *
283 * See \ref les_inflow for examples.
284 */
285/*----------------------------------------------------------------------------*/
286
287/*----------------------------------------------------------------------------*/
288/*
289 * \brief Define parameters of synthetic turbulence at LES inflow.
290 */
291/*----------------------------------------------------------------------------*/
292
293extern "C" void
295
296/*----------------------------------------------------------------------------*/
297/*
298 * \brief Update of the characteristics of a given synthetic turbulence inlet.
299 *
300 * \param[in] zone pointer to associated boundary zone
301 * \param[out] vel_r reference mean velocity
302 * \param[out] k_r reference turbulent kinetic energy
303 * \param[out] eps_r reference turbulent dissipation
304 */
305/*----------------------------------------------------------------------------*/
306
307extern "C" void
309 cs_real_t vel_r[3],
310 cs_real_t *k_r,
311 cs_real_t *eps_r);
312
313/*----------------------------------------------------------------------------*/
314/*
315 * \brief Definition of mean velocity, Reynolds stresses and dissipation rate
316 * for each boundary face of the given synthetic turbulence inlet.
317 *
318 * Accurate definition of mean velocity, Reynolds stresses and dissipation
319 * rate for each boundary face of the given synthetic turbulence inlet
320 *
321 * Rij components are ordered as usual: XX, YY, ZZ, XY, YZ, XZ
322 *
323 * Arrays are pre-initialized before this function is called
324 * (see \ref cs_user_les_inflow_define).
325 *
326 * vel_l[face_id][coo_id] = vel_r[coo_id]
327 *
328 * rij_l[face_id][0] = 2./3. * k_l
329 * rij_l[face_id][1] = 2./3. * k_l
330 * rij_l[face_id][2] = 2./3. * k_l
331 * rij_l[face_id][3] = 0
332 * rij_l[face_id][4] = 0
333 * rij_l[face_id][5] = 0
334 *
335 * eps_l[face_id] = eps_r
336 *
337 * \param[in] zone pointer to associated boundary zone
338 * \param[in, out] vel_l velocity a zone faces
339 * \param[in, out] rij_l reynods stresses at zone faces
340 * \param[in, out] eps_l reference turbulent dissipation
341 */
342/*----------------------------------------------------------------------------*/
343
344extern "C" void
346 cs_real_3_t vel_l[],
347 cs_real_6_t rij_l[],
348 cs_real_t eps_l[]);
349
350/*----------------------------------------------------------------------------*/
351
352#endif /* CS_LES_INFLOW_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:351
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
cs_les_inflow_type_t
Definition: cs_les_inflow.h:52
@ CS_INFLOW_BATTEN
Definition: cs_les_inflow.h:56
@ CS_INFLOW_LAMINAR
Definition: cs_les_inflow.h:54
@ CS_INFLOW_SEM
Definition: cs_les_inflow.h:57
@ CS_INFLOW_RANDOM
Definition: cs_les_inflow.h:55
void cs_les_inflow_set_restart(bool allow_read, bool allow_write)
Define behavior of the LES inflow module in case of restart.
Definition: cs_les_inflow.cpp:2268
void cs_les_volume_initialize(void)
General synthetic turbulence volume generation.
Definition: cs_les_inflow.cpp:782
void cs_les_synthetic_eddy_restart_read(void)
Definition: cs_les_inflow.cpp:1145
void cs_user_les_inflow_update(const cs_zone_t *zone, cs_real_t vel_r[3], cs_real_t *k_r, cs_real_t *eps_r)
Definition: cs_user_les_inflow.cpp:83
void cs_les_synthetic_eddy_restart_write(void)
Definition: cs_les_inflow.cpp:1494
void cs_les_inflow_add_inlet(cs_les_inflow_type_t type, bool volume_mode, const cs_zone_t *zone, int n_entities, int verbosity, const cs_real_t *vel_r, cs_real_t k_r, cs_real_t eps_r)
Add an inlet definition for synthetic turbulence inflow generation.
Definition: cs_les_inflow.cpp:643
int cs_les_synthetic_eddy_get_n_restart_structures(void)
Return number of structures used for volume SEM when restarting from another turbulence model.
Definition: cs_les_inflow.cpp:2227
struct _cs_inlet_t cs_inlet_t
Definition: cs_les_inflow.h:69
void cs_les_inflow_get_restart(bool *allow_read, bool *allow_write)
Query behavior of the LES inflow module in case of restart.
Definition: cs_les_inflow.cpp:2244
void cs_les_rescale_fluctuations(cs_lnum_t n_points, const cs_real_6_t statistics[], cs_real_3_t fluctuations[])
Rescale fluctuations by statistics following the Lund method.
Definition: cs_les_inflow.cpp:2155
void cs_les_inflow_initialize(void)
Creation of structures for the LES inflows.
Definition: cs_les_inflow.cpp:481
void cs_les_inflow_finalize(void)
Finalize turbulent inflow generation API.
Definition: cs_les_inflow.cpp:501
void cs_user_les_inflow_define(void)
Definition: cs_user_les_inflow.cpp:65
void cs_les_synthetic_eddy_method(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_3_t point_coordinates[], const cs_real_t *point_weight, int initialize, int volume_mode, int verbosity, cs_inflow_sem_t *inflow, cs_real_t t_cur, const cs_real_3_t vel_m_l[], const cs_real_6_t rij_l[], const cs_real_t eps_l[], cs_real_3_t fluctuations[])
Generation of synthetic turbulence via the Synthetic Eddy Method (SEM).
Definition: cs_les_inflow.cpp:1708
void cs_les_synthetic_eddy_set_n_restart_structures(int n_structures)
Set number of structures used for volume SEM when restarting from another turbulence model.
Definition: cs_les_inflow.cpp:2212
void cs_user_les_inflow_advanced(const cs_zone_t *zone, cs_real_3_t vel_l[], cs_real_6_t rij_l[], cs_real_t eps_l[])
Definition: cs_user_les_inflow.cpp:111
void cs_les_inflow_compute(void)
General synthetic turbulence generation.
Definition: cs_les_inflow.cpp:970
Definition: cs_les_inflow.h:71
int n_structures
Definition: cs_les_inflow.h:73
cs_real_3_t * energy
Definition: cs_les_inflow.h:75
cs_real_3_t * position
Definition: cs_les_inflow.h:74
Definition: cs_zone.h:51