1 #ifndef __CS_FIELD_POINTER_H__ 2 #define __CS_FIELD_POINTER_H__ 3 4 /*============================================================================ 5 * Field pointers and ids for standard and model fields 6 *============================================================================*/ 7 8 /* 9 This file is part of Code_Saturne, a general-purpose CFD tool. 10 11 Copyright (C) 1998-2021 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 30 /*---------------------------------------------------------------------------- 31 * Local headers 32 *----------------------------------------------------------------------------*/ 33 34 #include "cs_defs.h" 35 #include "cs_field.h" 36 37 /*----------------------------------------------------------------------------*/ 38 39 BEGIN_C_DECLS 40 41 /*============================================================================= 42 * Macro definitions 43 *============================================================================*/ 44 45 /* Macro used for scoping of field pointer enums */ 46 47 #define CS_ENUMF_(e) CS_FIELD_POINTER_ ## e 48 49 /* Macro used to return a field pointer by its enumerated value */ 50 51 #define CS_F_(e) cs_glob_field_pointers[CS_FIELD_POINTER_ ## e].f 52 53 #define CS_FI_(e, i) cs_glob_field_pointers[CS_FIELD_POINTER_ ## e].p[i] 54 55 /*============================================================================ 56 * Type definitions 57 *============================================================================*/ 58 59 /*! Suffixes of enumerated field pointer ids, arguments of the macro CS_F_(). */ 60 61 typedef enum { 62 63 /* Base variables and properties */ 64 65 CS_ENUMF_(dt), /*!< local time step */ 66 67 CS_ENUMF_(p), /*!< pressure */ 68 CS_ENUMF_(vel), /*!< velocity */ 69 70 CS_ENUMF_(k), /*!< turbulent kinetic energy \f$ k \f$ */ 71 CS_ENUMF_(eps), /*!< turbulent dissipation \f$ \varepsilon \f$ */ 72 73 CS_ENUMF_(rij), /*!< Reynolds stress tensor \f$ R_{ij} \f$ */ 74 75 CS_ENUMF_(phi), /*!< \f$ \phi \f$ for \f$ \phi-f_b \f$ model */ 76 CS_ENUMF_(f_bar), /*!< \f$ f_b \f$ for \f$ \phi-f_b \f$ model */ 77 CS_ENUMF_(alp_bl), /*!< \f$ \alpha \f$ for \f$ Bl-v^2-k \f$ 78 or EBRSM model */ 79 80 CS_ENUMF_(omg), /*!< \f$ \omega \f$ for \f$ k-\omega \f$ SST model */ 81 CS_ENUMF_(nusa), /*!< \f$ \widetilde{\nu}_T \f$ for Spalart- 82 Allmaras */ 83 84 CS_ENUMF_(hybrid_blend), /*!< Blending factor for DDES*/ 85 86 CS_ENUMF_(mesh_u), /*!< mesh velocity */ 87 88 CS_ENUMF_(void_f), /*!< void fraction */ 89 CS_ENUMF_(vol_f), /*!< volume fraction */ 90 91 CS_ENUMF_(h), /*!< enthalpy */ 92 CS_ENUMF_(t), /*!< temperature*/ 93 CS_ENUMF_(t_b), /*!< temperature (at boundary faces)*/ 94 CS_ENUMF_(e_tot), /*!< total energy */ 95 CS_ENUMF_(h_tot), /*!< total enthalpy */ 96 97 CS_ENUMF_(rho), /*!< density (at cells) */ 98 CS_ENUMF_(rho_b), /*!< density (at boundary faces) */ 99 100 CS_ENUMF_(cp), /*!< isobaric specific heat */ 101 CS_ENUMF_(cv), /*!< isochoric specific heat */ 102 103 CS_ENUMF_(mu), /*!< molecular viscosity */ 104 CS_ENUMF_(mu_t), /*!< turbulent dynamic viscosity */ 105 106 CS_ENUMF_(lambda), /*!< Thermal conductivity */ 107 CS_ENUMF_(th_diff), /*!< Thermal diffusivity */ 108 109 CS_ENUMF_(poro), /*!< porosity */ 110 CS_ENUMF_(if_poro), /*!< internal faces porosity */ 111 CS_ENUMF_(t_poro), /*!< tensorial porosity */ 112 113 /* Specific physics variables and properties */ 114 115 CS_ENUMF_(t_kelvin), /*!< temperature, in Kelvin */ 116 117 CS_ENUMF_(vism), /*!< mesh viscosity */ 118 119 CS_ENUMF_(volume_f), /*!< homogeneous model volume fraction */ 120 CS_ENUMF_(mass_f), /*!< homogeneous model mass fraction */ 121 CS_ENUMF_(energy_f), /*!< homogeneous model energy fraction */ 122 123 CS_ENUMF_(pot_t), /*!< potential temperature */ 124 CS_ENUMF_(totwt), /*!< total water content */ 125 CS_ENUMF_(ntdrp), /*!< total number of droplets */ 126 CS_ENUMF_(chemistry), /*!< chemistry species (indexed) */ 127 128 CS_ENUMF_(fm), /*!< mixture fraction */ 129 CS_ENUMF_(fp2m), /*!< mixture fraction variance */ 130 131 CS_ENUMF_(fsm), /*!< soot mass fraction */ 132 CS_ENUMF_(npm), /*!< soot precursor number */ 133 CS_ENUMF_(ygfm), /*!< fresh gas fraction */ 134 135 CS_ENUMF_(yfm), /*!< mass fraction */ 136 CS_ENUMF_(yfp2m), /*!< mass fraction variance */ 137 CS_ENUMF_(coyfp), /*!< mass fraction covariance */ 138 139 CS_ENUMF_(np), /*!< particles per kg for coal class */ 140 CS_ENUMF_(xch), /*!< reactive coal mass fraction for coal class */ 141 CS_ENUMF_(xck), /*!< coke mass fraction for coal class */ 142 CS_ENUMF_(xwt), /*!< water mass fraction for coal class */ 143 CS_ENUMF_(h2), /*!< mass enthalpy for coal class (permeatic case) */ 144 CS_ENUMF_(f1m), /*!< mean value light volatiles for coal class */ 145 CS_ENUMF_(f2m), /*!< mean value heavy volatiles for coal class */ 146 CS_ENUMF_(f4m), /*!< oxydant 2 mass fraction */ 147 CS_ENUMF_(f5m), /*!< oxydant 3 mass fraction */ 148 CS_ENUMF_(f6m), /*!< water from coal drying mass fraction */ 149 CS_ENUMF_(f7m), /*!< carbon from coal oxidyzed by O2 mass fraction */ 150 CS_ENUMF_(f8m), /*!< carbon from coal gasified by CO2 mass fraction */ 151 CS_ENUMF_(f9m), /*!< carbon from coal gasified by H2O mass fraction */ 152 CS_ENUMF_(fvp2m), /*!< f1f2 variance */ 153 CS_ENUMF_(yco2), /*!< CO2 fraction */ 154 CS_ENUMF_(yhcn), /*!< HCN fraction */ 155 CS_ENUMF_(yno), /*!< NO fraction */ 156 CS_ENUMF_(ynh3), /*!< NH3 enthalpy */ 157 CS_ENUMF_(hox), /*!< Ox enthalpy */ 158 159 CS_ENUMF_(potr), /*!< Electric potential, real part */ 160 CS_ENUMF_(poti), /*!< Electric potential, imaginary part */ 161 CS_ENUMF_(potva), /*!< Vector potential */ 162 CS_ENUMF_(ycoel), /*!< Constituent mass fraction */ 163 CS_ENUMF_(joulp), /*!< Joule power */ 164 CS_ENUMF_(radsc), /*!< radiation source */ 165 CS_ENUMF_(elech), /*!< electric charge */ 166 CS_ENUMF_(curre), /*!< current real */ 167 CS_ENUMF_(curim), /*!< current imaginary */ 168 CS_ENUMF_(laplf), /*!< laplace forces */ 169 CS_ENUMF_(magfl), /*!< magnetic field */ 170 CS_ENUMF_(elefl), /*!< electric field */ 171 172 CS_ENUMF_(rad_lumin), /*!< Radiative luminance */ 173 CS_ENUMF_(rad_q), /*!< Radiative flux */ 174 175 CS_ENUMF_(rad_est), /*!< Radiative flux explicit source term */ 176 CS_ENUMF_(rad_ist), /*!< Radiative flux implicit source term */ 177 CS_ENUMF_(rad_abs), /*!< Radiative absorption */ 178 CS_ENUMF_(rad_emi), /*!< Radiative emission */ 179 CS_ENUMF_(rad_cak), /*!< Radiative absorption coefficient */ 180 181 CS_ENUMF_(qinci), /*!< Radiative incident radiative flux density */ 182 CS_ENUMF_(qinsp), /*!< Spectral radiative incident flux */ 183 CS_ENUMF_(xlam), /*!< Wall thermal conductivity */ 184 CS_ENUMF_(epa), /*!< Wall thickness */ 185 CS_ENUMF_(emissivity), /*!< Wall emissivity */ 186 CS_ENUMF_(fnet), /*!< Boundary radiative flux */ 187 CS_ENUMF_(fconv), /*!< Boundary radiative convective flux */ 188 CS_ENUMF_(hconv), /*!< radiative exchange coefficient */ 189 CS_ENUMF_(fup), /*!< Spectral upward radiative flux */ 190 CS_ENUMF_(fdown), /*!< Spectral downward radiative flux */ 191 CS_ENUMF_(rad_ck_up), /*!< Spectral upward Radiative absorption coefficient */ 192 CS_ENUMF_(rad_ck_down), /*!< Spectral downward Radiative absorption coefficient */ 193 194 CS_ENUMF_(mol_mass), /*!< gas mix molar max */ 195 196 CS_ENUMF_(head), /*!< hydraulic head */ 197 198 /* Cooling tower fields */ 199 CS_ENUMF_(humid), /*!< Humidity */ 200 CS_ENUMF_(ym_w), /*!< Mass fraction of dry air in humid air */ 201 CS_ENUMF_(t_l), /*!< Injected liquid water temperature */ 202 CS_ENUMF_(h_l), /*!< Injected liquid water enthalpy */ 203 CS_ENUMF_(y_l_pack), /*!< Mass of liquid per unit volume of cell */ 204 CS_ENUMF_(thermal_diff_h), /*!< Humid air thermal diffusivity */ 205 CS_ENUMF_(thermal_diff_l), /*!< Injected liquid water thermal diffusivity */ 206 CS_ENUMF_(pack_zone_id), /*!< Id of the packing zone */ 207 208 /* NCFD fields */ 209 CS_ENUMF_(yf_ncond), /*!< non-condensable mass fraction */ 210 CS_ENUMF_(qp), /*!< Turbulent Kinetic Energy q2 */ 211 CS_ENUMF_(qfp), /*!< Covariance q12 */ 212 CS_ENUMF_(qfpxx), /*!< XX component of qfp */ 213 CS_ENUMF_(qfpxy), /*!< XY component of qfp */ 214 CS_ENUMF_(qfpxz), /*!< XZ component of qfp */ 215 CS_ENUMF_(qfpyx), /*!< YX component of qfp */ 216 CS_ENUMF_(qfpyy), /*!< YY component of qfp */ 217 CS_ENUMF_(qfpyz), /*!< YZ component of qfp */ 218 CS_ENUMF_(qfpzx), /*!< ZX component of qfp */ 219 CS_ENUMF_(qfpzy), /*!< ZY component of qfp */ 220 CS_ENUMF_(qfpzz), /*!< ZZ component of qfp */ 221 CS_ENUMF_(gamma), /*!< Interfacial mass transfer */ 222 CS_ENUMF_(ia), /*!< Interfacial area */ 223 CS_ENUMF_(x2), /*!< x2 for droplets */ 224 CS_ENUMF_(d32), /*!< Sauter diameter */ 225 CS_ENUMF_(drag), /*!< Phases drag */ 226 CS_ENUMF_(ad_mass), /*!< Added mass */ 227 CS_ENUMF_(wlubr), /*!< Wall lubrication */ 228 CS_ENUMF_(th_diff_t), /*!< Turbulent thermal diffusivity */ 229 CS_ENUMF_(drho_dp), /*!< drho over dp */ 230 CS_ENUMF_(drho_dh), /*!< drho over dh */ 231 CS_ENUMF_(tau12_t), /*!< turbulent tau12 */ 232 CS_ENUMF_(lift), /*!< Lift coefficient */ 233 CS_ENUMF_(disp_t), /*!< Turbulent dispersion */ 234 CS_ENUMF_(surf_tens), /*!< Surface tension */ 235 CS_ENUMF_(drift_vel), /*!< Particles drift velocity */ 236 CS_ENUMF_(yplus), /*!< Wall distance: y+ */ 237 CS_ENUMF_(vel_mean), /*!< Mean velocity (for dispersed phases) */ 238 CS_ENUMF_(vel_rel), /*!< Relative velocity (for dispersed phases) */ 239 CS_ENUMF_(dt_dp), /*!< dtemp/dpress derivative */ 240 CS_ENUMF_(kindiff), /*!< Particles kinetic diffusivity */ 241 CS_ENUMF_(coldiff), /*!< Particles collisional diffusivity */ 242 CS_ENUMF_(elast), /*!< Particles restitution coefficient */ 243 CS_ENUMF_(c_alpha), /*!< Ponderation coefficient for GEMMA model */ 244 245 /* Added variables (scalars) */ 246 CS_ENUMF_(add_var), /*!< User added variables */ 247 248 /* User-defined arrays */ 249 CS_ENUMF_(user), 250 251 /* End of attributes */ 252 253 CS_FIELD_N_POINTERS 254 255 } cs_field_pointer_id_t; 256 257 /*! Field pointer array type */ 258 259 struct cs_field_pointer_array_t { 260 cs_field_t *f; /*!< pointer to single (first) field */ 261 cs_field_t **p; /*!< array of field pointers */ 262 }; 263 264 /*============================================================================ 265 * Global variables 266 *============================================================================*/ 267 268 /* Pointers */ 269 270 extern struct cs_field_pointer_array_t *cs_glob_field_pointers; 271 272 /*============================================================================= 273 * Public function prototypes 274 *============================================================================*/ 275 276 /*---------------------------------------------------------------------------- 277 * Ensure field pointer array is initialized. 278 *----------------------------------------------------------------------------*/ 279 280 void 281 cs_field_pointer_ensure_init(void); 282 283 /*---------------------------------------------------------------------------- 284 * Free all field pointer data. 285 *----------------------------------------------------------------------------*/ 286 287 void 288 cs_field_pointer_destroy_all(void); 289 290 /*---------------------------------------------------------------------------- 291 * Map a simple field to an enumerated pointer. 292 * 293 * The associated field pointer may then be retreived using \ref CS_F_(e). 294 * 295 * parameters: 296 * e <-- field enumerator value 297 * f <-- pointer to field structure 298 *----------------------------------------------------------------------------*/ 299 300 void 301 cs_field_pointer_map(cs_field_pointer_id_t e, 302 cs_field_t *f); 303 304 /*---------------------------------------------------------------------------- 305 * Map a field to an (enumerated pointer, index) couple. 306 * 307 * This sort of mapping may be used for sets of fields whose size 308 * is not known in advance. 309 * 310 * The associated field pointer may then be retreived using \ref CS_F_(e, i). 311 * 312 * parameters: 313 * e <-- field enumerator value 314 * index <-- field enumerator index 315 * f <-- pointer to field structure 316 *----------------------------------------------------------------------------*/ 317 318 void 319 cs_field_pointer_map_indexed(cs_field_pointer_id_t e, 320 int index, 321 cs_field_t *f); 322 323 /*---------------------------------------------------------------------------- 324 * Map base fields to enumerated pointers. 325 *----------------------------------------------------------------------------*/ 326 327 void 328 cs_field_pointer_map_base(void); 329 330 /*---------------------------------------------------------------------------- 331 * Map some boundary fields to enumerated pointers. 332 *----------------------------------------------------------------------------*/ 333 334 void 335 cs_field_pointer_map_boundary(void); 336 337 /*---------------------------------------------------------------------------- 338 * Map base fields to enumerated pointers for atmospheric models 339 * 340 * parameters: 341 * n_chem_species <-- number of chemical species 342 * species_f_if <-- field id for each chemical species 343 *----------------------------------------------------------------------------*/ 344 345 void 346 cs_field_pointer_map_atmospheric(int n_chem_species, 347 const int species_f_id[]); 348 349 /*---------------------------------------------------------------------------- 350 * Map base fields to enumerated pointers for atmospheric models 351 * 352 * parameters: 353 * n_coals <-- number of coals 354 * n_classes <-- number of coal classes 355 *----------------------------------------------------------------------------*/ 356 357 void 358 cs_field_pointer_map_coal_combustion(int n_coals, 359 int n_classes); 360 361 /*----------------------------------------------------------------------------* 362 * Map base fields to enumerated pointers for compressible model 363 *----------------------------------------------------------------------------*/ 364 365 void 366 cs_field_pointer_map_compressible(void); 367 368 /*----------------------------------------------------------------------------* 369 * Map base fields to enumerated pointers for gas mix model 370 *----------------------------------------------------------------------------*/ 371 372 void 373 cs_field_pointer_map_gas_mix(void); 374 375 /*---------------------------------------------------------------------------- 376 * Map base fields to enumerated pointers for gas combustion. 377 *----------------------------------------------------------------------------*/ 378 379 void 380 cs_field_pointer_map_gas_combustion(void); 381 382 /*----------------------------------------------------------------------------*/ 383 /* 384 * Map base fields to enumerated pointers for groundwater flows 385 *----------------------------------------------------------------------------*/ 386 387 void 388 cs_field_pointer_map_groundwater(void); 389 390 /*----------------------------------------------------------------------------*/ 391 392 END_C_DECLS 393 394 #endif /* __CS_FIELD_POINTER_H__ */ 395