1!------------------------------------------------------------------------------- 2 3! This file is part of Code_Saturne, a general-purpose CFD tool. 4! 5! Copyright (C) 1998-2021 EDF S.A. 6! 7! This program is free software; you can redistribute it and/or modify it under 8! the terms of the GNU General Public License as published by the Free Software 9! Foundation; either version 2 of the License, or (at your option) any later 10! version. 11! 12! This program is distributed in the hope that it will be useful, but WITHOUT 13! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14! FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15! details. 16! 17! You should have received a copy of the GNU General Public License along with 18! this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 19! Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 21!------------------------------------------------------------------------------- 22 23!> \file numvar.f90 24!> \brief Module for variable numbering 25 26module numvar 27 28 !============================================================================= 29 30 use, intrinsic :: iso_c_binding 31 32 use paramx 33 34 implicit none 35 36 !============================================================================= 37 38 !> \defgroup numvar Module for variable numbering 39 40 !> \addtogroup numvar 41 !> \{ 42 43 !---------------------------------------------------------------------------- 44 ! Main variables 45 !---------------------------------------------------------------------------- 46 47 !> \defgroup main_variables Main variables 48 !> \brief Main variable field indices (previously stored in rtp, rtpa). 49 50 !> \addtogroup main_variables 51 !> \{ 52 53 !> \anchor ipr 54 !> pressure 55 integer, save :: ipr 56 57 !> \anchor iu 58 !> velocity component \f$ u_x \f$ 59 integer, save :: iu 60 61 !> \anchor iv 62 !> velocity component \f$ u_y \f$ 63 integer, save :: iv 64 65 !> \anchor iw 66 !> velocity component \f$ u_z \f$ 67 integer, save :: iw 68 69 !> \anchor ivolf2 70 !> void fraction for VOF method 71 integer, save :: ivolf2 72 73 !> \anchor ik 74 !> turbulent kinetic energy \f$ k \f$ 75 integer, save :: ik 76 77 !> \anchor iep 78 !> turbulent dissipation \f$ \varepsilon \f$ 79 integer, save :: iep 80 81 !> \anchor ir11 82 !> Reynolds stress component \f$ R_{xx} \f$ 83 integer, save :: ir11 84 85 !> \anchor ir22 86 !> Reynolds stress component \f$ R_{yy} \f$ 87 integer, save :: ir22 88 89 !> \anchor ir33 90 !> Reynolds stress component \f$ R_{zz} \f$ 91 integer, save :: ir33 92 93 !> \anchor ir12 94 !> Reynolds stress component \f$ R_{xy} \f$ 95 integer, save :: ir12 96 97 !> \anchor ir23 98 !> Reynolds stress component \f$ R_{yz} \f$ 99 integer, save :: ir23 100 101 !> \anchor ir13 102 !> Reynolds stress component \f$ R_{zz} \f$ 103 integer, save :: ir13 104 105 !> \anchor irij 106 !> Reynolds stress tenso \f$ R_{ij} \f$ 107 integer, save :: irij 108 109 !> \anchor iphi 110 !> variable \f$ \phi \f$ of the \f$ \phi-f_b \f$ model 111 integer, save :: iphi 112 113 !> \anchor ifb 114 !> variable \f$ f_b \f$ of the \f$ \phi-f_b \f$ model 115 integer, save :: ifb 116 117 !> \anchor ial 118 !> variable \f$ \alpha \f$ of the \f$ Bl-v^2-k \f$ model 119 integer, save :: ial 120 121 !> \anchor iomg 122 !> variable \f$ \omega \f$ of the \f$ k-\omega \f$ SST 123 integer, save :: iomg 124 125 !> \anchor inusa 126 !> variable \f$ \widetilde{\nu}_T \f$ of the Spalart Allmaras 127 integer, save :: inusa 128 129 !> \anchor isca 130 !> isca(i) is the index of the scalar i 131 integer, save :: isca(nscamx) 132 133 !> \anchor iscapp 134 !> iscapp(i) is the index of the specific physics scalar i 135 integer, save :: iscapp(nscamx) 136 137 !> \anchor nscaus 138 !> number of user scalars solutions of an advection equation 139 integer, save :: nscaus 140 141 !> \anchor nscapp 142 !> number of specific physics scalars 143 integer, save :: nscapp 144 145 !> \anchor nscasp 146 !> number of species scalars 147 integer(c_int), pointer, save :: nscasp 148 149 !> \anchor iuma 150 !> mesh velocity component \f$ w_x \f$ 151 integer, save :: iuma 152 153 !> \anchor ivma 154 !> mesh velocity component \f$ w_y \f$ 155 integer, save :: ivma 156 157 !> \anchor iwma 158 !> mesh velocity component \f$ w_z \f$ 159 integer, save :: iwma 160 161 !> \} 162 163 !---------------------------------------------------------------------------- 164 ! Physical properties 165 !---------------------------------------------------------------------------- 166 167 !> \defgroup physical_prop Physical properties 168 !> \brief Physical properties are using the field API. 169 !> See \ref cs_user_boundary_conditions for some examples. 170 171 !> \addtogroup physical_prop 172 !> \{ 173 174 !> Density at the current time step (equal to icrom, kept for compatibility) 175 integer, save :: irom 176 177 !> dynamic molecular viscosity (in kg/(m.s)) 178 integer, save :: iviscl 179 180 !> dynamic turbulent viscosity 181 integer, save :: ivisct 182 183 !> error estimator for Navier-Stokes 184 integer, save :: iestim(nestmx) 185 186 !> interior and boundary convective mass flux key ids of the variables 187 integer, save :: kimasf, kbmasf 188 189 !> constant diffusivity field id key for scalars 190 integer, save :: kvisl0 191 192 !> variable diffusivity field id key for scalars 193 integer, save :: kivisl 194 195 !> do scalars behave as a temperature (regarding multiplication by Cp) ? 196 integer, save :: kscacp 197 198 !> variable density field id key for scalars 199 integer, save :: kromsl 200 201 !> source terms at previous time step for 2nd order 202 integer, save :: kstprv 203 204 !> source terms at the current time step (used for limiters) 205 integer, save :: kst 206 207 !> turbulent schmidt key for scalars 208 integer, save :: ksigmas 209 210 !> convective mass flux of the variables at the previous time-step 211 integer, save :: ifluaa(nvarmx) 212 213 !> cell density field ids of the variables 214 integer, save :: icrom 215 216 !> boundary density field ids of the variables 217 integer, save :: ibrom 218 219 !> field ids of the cell porosity 220 integer, save :: ipori, iporf 221 222 !> dynamic constant of Smagorinsky 223 integer, save :: ismago 224 225 !> field ids of the anisotropic viscosity 226 !> \remark turbulent or Darcy module anisotropic diffusion 227 integer, save :: ivsten, ivstes 228 229 !> Courant number 230 integer, save :: icour 231 232 !> Fourier number 233 integer, save :: ifour 234 235 !> Total pressure at cell centers 236 !> \f$ P_{tot} = P^\star +\rho \vect{g} \cdot (\vect{x}-\vect{x}_0) \f$ 237 integer, save :: iprtot 238 239 !> Mesh velocity viscosity for the ALE module 240 !> \remark might be orthotropic 241 integer, save :: ivisma 242 243 !> pointer for dilatation source terms 244 integer, save :: iustdy(nscamx) 245 246 !> pointer for global dilatation source terms 247 integer, save :: itsrho 248 249 !> pointer for thermal expansion coefficient 250 integer, save :: ibeta 251 252 !> pointer for deduced mass fraction in case of gas mix 253 integer, save :: iddgas 254 255 !> pointer for gas mix molar mass 256 integer, save :: igmxml 257 258 !> field id of the stresses at boundary (if post-processed) 259 integer, save :: iforbr 260 261 !> field id of \f$y^+\f$ at boundary (if post-processed) 262 integer, save :: iyplbr 263 264 !> field id of temperature at boundary 265 integer, save :: itempb 266 267 !> field id of the square of the norm of the deviatoric 268 !> part of the deformation rate tensor (\f$S^2=2S_{ij}^D S_{ij}^D\f$). 269 !> Field defined only with the \f$k-\omega\f$ (SST) turbulence model 270 integer, save :: is2kw 271 272 !> field id of the divergence of the velocity. More precisely, 273 !> it is the trace of the velocity gradient (and not a finite volume 274 !> divergence term). In the cell \c iel, \f$div(\vect{u})\f$ is given 275 !> by \c divukw(iel1). This array is defined only with the \f$k-\omega\f$ SST 276 !> turbulence model (because in this case it may be calculated at the same 277 !> time as \f$S^2\f$) 278 integer, save :: idivukw 279 280 !> field id of the strain rate tensor at the previous time step 281 integer, save :: istraio 282 283 !> \} 284 !---------------------------------------------------------------------------- 285 ! Numerical properties 286 !---------------------------------------------------------------------------- 287 288 !> \defgroup numerical_prop Numerical properties 289 290 !> \addtogroup numerical_prop 291 !> \{ 292 293 !> Weighting for gradient calculation on variables 294 integer, save :: kwgrec 295 296 !> \} 297 !---------------------------------------------------------------------------- 298 ! Mapping to field structures 299 !---------------------------------------------------------------------------- 300 301 !> \defgroup field_map Mapping to field structures 302 303 !> \addtogroup field_map 304 !> \{ 305 306 !> Field id for variable i 307 integer, save :: ivarfl(nvarmx) 308 309 !> Field id for the dttens tensor 310 integer, save :: idtten 311 312 !> \} 313 314 !============================================================================= 315 316 interface 317 318 !--------------------------------------------------------------------------- 319 320 !> \cond DOXYGEN_SHOULD_SKIP_THIS 321 322 !--------------------------------------------------------------------------- 323 324 ! Interface to C function retrieving the number of species in the gas mix 325 ! if gas mix model is enabled (igmix) 326 327 subroutine cs_f_gas_mix_get_pointers(nscasp) & 328 bind(C, name='cs_f_gas_mix_get_pointers') 329 use, intrinsic :: iso_c_binding 330 implicit none 331 type(c_ptr), intent(out) :: nscasp 332 end subroutine cs_f_gas_mix_get_pointers 333 334 !--------------------------------------------------------------------------- 335 336 !> (DOXYGEN_SHOULD_SKIP_THIS) \endcond 337 338 !--------------------------------------------------------------------------- 339 340 end interface 341 342 !============================================================================= 343 344contains 345 346 !============================================================================= 347 348 !> \addtogroup field_map 349 !> \{ 350 351 !> \anchor iprpfl 352 !> Identity function for compatibility with deprecated iprpfl array 353 354 elemental pure function iprpfl(f_id) result(r_f_id) 355 356 implicit none 357 358 ! Parameters 359 360 integer, intent(in) :: f_id 361 integer :: r_f_id 362 363 ! Function body 364 365 r_f_id = f_id 366 367 end function iprpfl 368 369 !> \} 370 371 !> \brief Initialize Fortran gas mix API. 372 !> This maps Fortran pointers to global C variables. 373 374 subroutine gas_mix_options_init 375 376 use, intrinsic :: iso_c_binding 377 implicit none 378 379 ! Local variables 380 381 type(c_ptr) :: c_nscasp 382 383 call cs_f_gas_mix_get_pointers(c_nscasp) 384 385 call c_f_pointer(c_nscasp, nscasp) 386 387 end subroutine gas_mix_options_init 388 389 !============================================================================= 390 391 !> \} 392 393end module numvar 394