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-2021 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 "cs_defs.h" 32 33 /*---------------------------------------------------------------------------- 34 * Local headers 35 *----------------------------------------------------------------------------*/ 36 37 #include "cs_base.h" 38 #include "cs_zone.h" 39 40 /*----------------------------------------------------------------------------*/ 41 42 BEGIN_C_DECLS 43 44 /*============================================================================ 45 * Macro definitions 46 *============================================================================*/ 47 48 /*============================================================================ 49 * Type definitions 50 *============================================================================*/ 51 52 /*---------------------------------------------------------------------------- 53 * Type of synthetic turbulence generation 54 *----------------------------------------------------------------------------*/ 55 56 typedef enum { 57 58 CS_INFLOW_LAMINAR, /*!< Laminar fluctuations (i.e no fluctuation) */ 59 CS_INFLOW_RANDOM, /*!< Gaussian random fluctuation */ 60 CS_INFLOW_BATTEN, /*!< Fluctuations generated by the Batten method */ 61 CS_INFLOW_SEM /*!< Fluctuations generated by the 62 Synthetic Eddy Method */ 63 64 } cs_les_inflow_type_t; 65 66 /*============================================================================= 67 * Local Structure Definitions 68 *============================================================================*/ 69 70 /* Inlet definition */ 71 /*------------------*/ 72 73 typedef struct _cs_inlet_t cs_inlet_t; 74 75 typedef struct { 76 77 int n_structures; /*!< Number of coherent structures */ 78 int volume_mode; /*!< Indicator to use classic inlet SEM (0) 79 or volumic SEM over the domain */ 80 cs_real_3_t *position; /*!< Position of the structures */ 81 cs_real_3_t *energy; /*!w Anisotropic energy of the structures */ 82 83 } cs_inflow_sem_t; 84 85 /*============================================================================= 86 * Public function prototypes for Fortran API 87 *============================================================================*/ 88 89 /*---------------------------------------------------------------------------- 90 * General synthetic turbulence generation 91 *----------------------------------------------------------------------------*/ 92 93 void CS_PROCF(synthe, SYNTHE) 94 ( 95 const cs_real_t *const ttcabs, /* --> current physical time */ 96 const cs_real_t dt[], /* --> time step */ 97 cs_real_t rcodcl[] /* <-> boundary conditions array */ 98 ); 99 100 /*============================================================================= 101 * Public function prototypes 102 *============================================================================*/ 103 104 /*----------------------------------------------------------------------------*/ 105 /*! 106 * \brief Creation of structures for the LES inflows 107 */ 108 /*----------------------------------------------------------------------------*/ 109 110 void 111 cs_les_inflow_initialize(void); 112 113 /*----------------------------------------------------------------------------*/ 114 /*! 115 * \brief Finalize turbulent inflow generation API. 116 */ 117 /*----------------------------------------------------------------------------*/ 118 119 void 120 cs_les_inflow_finalize(void); 121 122 /*----------------------------------------------------------------------------*/ 123 /*! 124 * \brief Add an inlet definition for synthetic turbulence inflow generation. 125 * 126 * \remark: 127 * - eps_r is used only for CS_INFLOW_BATTEN and CS_INFLOW_SEM types. 128 * - Strictly positive values are required for k_r and eps_r. 129 * - Finer definition of the statistics of the flow at the inlet 130 * can be done later using \ref cs_user_les_inflow_advanced. 131 * 132 * \param[out] type type of inflow method at the inlet 133 * \param[out] volume_mode if true, generate turbulence over the whole domain 134 * (only if type is CS_INFLOW_SEM) 135 * \param[in] zone pointer to associated boundary zone 136 * \param[out] n_entities number of structures or modes 137 * \param[out] verbosity verbosity level 138 * \param[out] vel_r reference mean velocity 139 * \param[out] k_r reference turbulent kinetic energy 140 * \param[out] eps_r reference turbulent dissipation 141 */ 142 /*----------------------------------------------------------------------------*/ 143 144 void 145 cs_les_inflow_add_inlet(cs_les_inflow_type_t type, 146 bool volume_mode, 147 const cs_zone_t *zone, 148 int n_entities, 149 int verbosity, 150 const cs_real_t *vel_r, 151 cs_real_t k_r, 152 cs_real_t eps_r); 153 154 /*---------------------------------------------------------------------------- 155 * Read the restart file of les inflow module. 156 *----------------------------------------------------------------------------*/ 157 158 void 159 cs_les_synthetic_eddy_restart_read(void); 160 161 /*---------------------------------------------------------------------------- 162 * Write the restart file of les inflow module. 163 *----------------------------------------------------------------------------*/ 164 165 void 166 cs_les_synthetic_eddy_restart_write(void); 167 168 /*----------------------------------------------------------------------------*/ 169 /*! 170 * \brief Generation of synthetic turbulence via the Synthetic Eddy Method (SEM). 171 * 172 * \param[in] n_points local number of points where 173 * turbulence is generated 174 * \param[in] elt_ids local id of inlet elements 175 * \param[in] point_coordinates point coordinates 176 * \param[in] point_weight point weights (surface, volume or NULL) 177 * \param[in] initialize initialization indicator 178 * \param[in] verbosity verbosity level 179 * \param[in] inflow pointer to structure for Batten method 180 * \param[in] t_cur current time 181 * \param[in] vel_m_l mean velocity at each point 182 * \param[in] rij_l reynolds stresses at each point 183 * \param[in] eps_l dissipation rate at each point 184 * \param[out] fluctuations velocity fluctuations at each point 185 */ 186 /*----------------------------------------------------------------------------*/ 187 188 void 189 cs_les_synthetic_eddy_method(cs_lnum_t n_points, 190 const cs_lnum_t elt_ids[], 191 const cs_real_3_t point_coordinates[], 192 const cs_real_t *point_weight, 193 int initialize, 194 int verbosity, 195 cs_inflow_sem_t *inflow, 196 cs_real_t t_cur, 197 const cs_real_3_t vel_m_l[], 198 const cs_real_6_t rij_l[], 199 const cs_real_t eps_l[], 200 cs_real_3_t fluctuations[]); 201 202 /*----------------------------------------------------------------------------*/ 203 /*! 204 * \brief Rescale fluctuations by statistics following the Lund method. 205 * 206 * One assumes that the statistics are interlaced and ordered as follows: 207 * <u'u'> <v'v'> <w'w'> <u'v'> <v'w'> <u'w'> 208 * 209 * \param[in] n_points local number of points where 210 * turbulence is generated 211 * \param[in] statistics statistics (i.e. Reynolds stresses) 212 * \param[in, out] fluctuations velocity fluctuations generated 213 *----------------------------------------------------------------------------*/ 214 215 void 216 cs_les_rescale_fluctuations(cs_lnum_t n_points, 217 const cs_real_6_t statistics[], 218 cs_real_3_t fluctuations[]); 219 220 /*----------------------------------------------------------------------------*/ 221 /*! 222 * \brief Set number of structures used for volume SEM when 223 * restarting from another turbulence model. 224 * 225 * By default, a restart file is read if present, and a checkpoint written. 226 * If not read, synthetic fluctuations are re-initialized. 227 * 228 * \param[in] n_structures number of structures for initialization 229 */ 230 /*----------------------------------------------------------------------------*/ 231 232 void 233 cs_les_synthetic_eddy_set_n_restart_structures(int n_structures); 234 235 /*----------------------------------------------------------------------------*/ 236 /*! 237 * \brief Return number of structures used for volume SEM when 238 * restarting from another turbulence model. 239 * 240 * \return number of structures for initialization 241 */ 242 /*----------------------------------------------------------------------------*/ 243 244 int 245 cs_les_synthetic_eddy_get_n_restart_structures(void); 246 247 /*----------------------------------------------------------------------------*/ 248 /*! 249 * \brief Query behavior of the LES inflow module in case of restart. 250 * 251 * See \ref cs_les_synthetic_eddy_set_restart for details. 252 * 253 * \param[out] allow_read pointer to read flag, or NULL 254 * \param[out] allow_write pointer to write flag, or NULL 255 */ 256 /*----------------------------------------------------------------------------*/ 257 258 void 259 cs_les_inflow_get_restart(bool *allow_read, 260 bool *allow_write); 261 262 /*----------------------------------------------------------------------------*/ 263 /*! 264 * \brief Define behavior of the LES inflow module in case of restart. 265 * 266 * By default, a restart file is read if present, and a checkpoint written. 267 * If not read, synthetic fluctuations are re-initialized. 268 * 269 * \param[in] allow_read allow reading a relevant checkpoint if present 270 * \param[in] allow_write allow writing a relevant checkpoint if present 271 */ 272 /*----------------------------------------------------------------------------*/ 273 274 void 275 cs_les_inflow_set_restart(bool allow_read, 276 bool allow_write); 277 278 /*----------------------------------------------------------------------------*/ 279 /*! 280 * \brief Define parameters of synthetic turbulence at LES inflow. 281 */ 282 /*----------------------------------------------------------------------------*/ 283 284 void 285 cs_user_les_inflow_define(void); 286 287 /*----------------------------------------------------------------------------*/ 288 /*! 289 * \brief Update of the characteristics of a given synthetic turbulence inlet. 290 * 291 * \param[in] zone pointer to associated boundary zone 292 * \param[out] vel_r reference mean velocity 293 * \param[out] k_r reference turbulent kinetic energy 294 * \param[out] eps_r reference turbulent dissipation 295 */ 296 /*----------------------------------------------------------------------------*/ 297 298 void 299 cs_user_les_inflow_update(const cs_zone_t *zone, 300 cs_real_t vel_r[3], 301 cs_real_t *k_r, 302 cs_real_t *eps_r); 303 304 /*---------------------------------------------------------------------------- 305 * Definition of mean velocity, Reynolds stresses and dissipation rate 306 * for each boundary face of the given synthetic turbulence inlet. 307 *----------------------------------------------------------------------------*/ 308 309 void 310 cs_user_les_inflow_advanced(const cs_zone_t *zone, 311 cs_real_3_t vel_l[], 312 cs_real_6_t rij_l[], 313 cs_real_t eps_l[]); 314 315 /*----------------------------------------------------------------------------*/ 316 317 END_C_DECLS 318 319 #endif /* __CS_LES_INFLOW_H__ */ 320