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 optcal.f90
24!> Module for calculation options
25
26module optcal
27
28  !=============================================================================
29
30  use, intrinsic :: iso_c_binding
31
32  use paramx
33
34  implicit none
35
36  !=============================================================================
37
38  !> \defgroup optcal Module for calculation options
39
40  !> \addtogroup optcal
41  !> \{
42
43  !----------------------------------------------------------------------------
44  ! Time stepping
45  !----------------------------------------------------------------------------
46
47  !> \defgroup time_stepping Time stepping
48
49  !> \addtogroup time_stepping
50  !> \{
51
52  !> time order of time stepping
53  !>    - 2: 2nd order
54  !>    - 1: 1st order (default)
55  integer(c_int), pointer, save :: ischtp
56
57  !> time order of the mass flux scheme
58  !> The chosen value for \ref istmpf will automatically
59  !> determine the value given to the variable \ref thetfl.
60  !> - 2: theta scheme with theta > 0 (theta=0.5 means 2nd order)
61  !> the mass flow used in the momentum equations is extrapolated at
62  !> n+ \ref thetfl (= n+1/2) from the values at the two former time
63  !> steps (Adams Bashforth); the mass flow used in the equations for
64  !> turbulence and scalars is interpolated at time n+ \ref thetfl
65  !> (= n+1/2) from the values at the former time step and at the
66  !> newly calculated \f$n+1\f$ time step.
67  !> - 0: theta scheme with theta = 0 (explicit): the mass flow
68  !> calculated at the previous time step is used in the convective
69  !> terms of all the equations (momentum, turbulence and scalars)
70  !> - 1: implicit scheme (default) : the mass flow calculated
71  !> at the previous time step is used in the convective terms of the
72  !> momentum equation, and the updated mass flow is used in the
73  !> equations of turbulence and scalars. By default, \ref istmpf=2
74  !> is used in the case of a second-order time scheme (if \ref ischtp=2)
75  !> and \ref istmpf = 1 otherwise.
76  integer, save ::          istmpf
77
78  !> Time scheme option:
79  !>    - 0: staggered time scheme. On the time grids, the velocity is
80  !>         half a time step behind the density and the buoyant scalar.
81  !>         (See the thesis of \cite Pierce:2004)
82  !>    - 1: collocated time scheme. On the time grids, the velocity is
83  !>         at the same location as the density and the buoyant scalar.
84  !>         (See \cite Ma:2019)
85  integer(c_int), pointer, save :: itpcol
86
87  !> number of iterations on the velocity-pressure coupling on Navier-Stokes
88  !> (for the U/P inner iterations scheme)
89  integer(c_int), pointer, save ::          nterup
90
91  !> \ref isno2t specifies the time scheme activated for the source
92  !> terms of the momentum equation, apart from convection and
93  !> diffusion (for instance: head loss, transposed gradient, ...).
94  !> - 0: "standard" first-order: the terms which are linear
95  !> functions of the solved variable are implicit and the others
96  !> are explicit
97  !> - 1: second-order: the terms of the form \f$S_i\phi\f$ which are
98  !> linear functions of the solved variable \f$\phi\f$ are expressed
99  !> as second-order terms by interpolation (according to the formula
100  !> \f$(S_i\phi)^{n+\theta}=S_i^n[(1-\theta)\phi^n+\theta\phi^{n+1}]\f$,
101  !> \f$\theta\f$ being given by the value of \ref thetav associated
102  !> with the variable \f$\phi\f$); the other terms \f$S_e\f$ are
103  !> expressed as second-order terms by extrapolation (according to the
104  !> formula \f$(S_e)^{n+\theta}=[(1+\theta)S_e^n-\theta S_e^{n-1}]\f$,
105  !> \f$\theta\f$ being given by the value of \ref thetsn = 0.5).\n
106  !> - 2: the linear terms \f$S_i\phi\f$ are treated in the same
107  !> way as when \ref isno2t = 1; the other terms \f$S_e\f$ are
108  !> extrapolated according to the same formula as when \ref isno2t = 1,
109  !> but with \f$\theta\f$= \ref thetsn = 1. By default, \ref isno2t
110  !> is initialised to 1 (second-order) when the selected time scheme
111  !> is second-order (\ref ischtp = 2), otherwise to 0.
112  integer, save ::          isno2t
113
114  !> Time scheme for source terms of turbulence equations
115  !> (see \ref isto2t in cs_time_scheme_t).
116  integer(c_int), pointer, save :: isto2t
117
118  !> for each scalar, \ref isso2t specifies the time scheme activated
119  !> for the source terms of the equation for the scalar, apart from convection
120  !> and diffusion (for instance: variance production, user-specified terms,
121  !> ...).
122  !> - 0: "standard" first-order: the terms which are linear
123  !> functions of the solved variable are implicit and the others are explicit
124  !> - 1: second-order: the terms of the form \f$S_i\phi\f$ which are
125  !> linear functions of the solved variable \f$\phi\f$ are expressed
126  !> as second-order terms by interpolation (according to the formula
127  !> \f$(S_i\phi)^{n+\theta}=S_i^n[(1-\theta)\phi^n+\theta\phi^{n+1}]\f$,
128  !> \f$\theta\f$ being given by the value of \ref thetav associated with
129  !> the variable \f$\phi\f$);
130  !> the other terms \f$S_e\f$ are expressed as second-order terms by
131  !> extrapolation (according to the formula
132  !> \f$(S_e)^{n+\theta}=[(1+\theta)S_e^n-\theta S_e^{n-1}]\f$,
133  !> \f$\theta\f$ being given by the value of \ref thetss (iscal) = 0.5)
134  !> - 2: the linear terms \f$S_i\phi\f$ are treated in the same way as
135  !> when \ref isso2t = 1; the other terms \f$S_e\f$ are extrapolated
136  !> according to the same formula as when \ref isso2t = 1, but with
137  !> \f$\theta\f$ = \ref thetss (iscal) = 1.\n
138  !> By default, \ref isso2t (iscal) is initialised to 1 (second-order)
139  !> when the selected time scheme is second-order (\ref ischtp = 2),
140  !> otherwise to 0.
141  integer, save ::          isso2t(nscamx)
142
143  !> initvi : =1 if total viscosity read from checkpoint file
144  integer, save ::          initvi
145
146  !> initro : =1 if density read from checkpoint file
147  integer, save ::          initro
148
149  !> initcp : =1 if specific heat read from checkpoint file
150  integer, save ::          initcp
151
152  !> initvs : =1 if scalar diffusivity read from checkpoint file
153  integer, save ::          initvs(nscamx)
154
155  !> \f$ \theta_S \f$-scheme for the source terms \f$S_e\f$ in the
156  !> Navier-Stokes equations when the source term extrapolation has
157  !> been activated (see \ref isno2t), following the formula
158  !> \f$(S_e)^{n+\theta}=(1+\theta)S_e^n-\theta S_e^{n-1}\f$.\n The value
159  !> of \f$theta\f$ = \ref thetsn is deduced from the value chosen for
160  !> \ref isno2t. Generally only the value 0.5 is used.
161  !>    -  0 : second viscosity explicit
162  !>    - 1/2: second viscosity extrapolated in n+1/2
163  !>    -  1 : second viscosity extrapolated in n+1
164  double precision, save :: thetsn
165
166  !> The value of \f$theta\f$ (see \ref thetst in cs_time_scheme_t).
167  real(c_double), pointer, save :: thetst
168
169  !> \f$ \theta \f$-scheme for the extrapolation of the nonlinear
170  !> explicit source term \f$S_e\f$ of the scalar transport equation
171  !> when the source term extrapolation has been activated (see
172  !> \ref isso2t), following the formula
173  !> \f$(S_e)^{n+\theta}=(1+\theta)S_e^n-\theta S_e^{n-1}\f$.\n
174  !> The value of \f$\theta\f$ = \ref thetss is deduced from the value
175  !> chosen for \ref isso2t. Generally, only the value 0.5 is used.
176  !>    -  0 : explicit
177  !>    - 1/2: extrapolated in n+1/2
178  !>    -  1 : extrapolated in n+1
179  double precision, save :: thetss(nscamx)
180
181  !> \f$ \theta \f$-scheme for the extrapolation of the physical
182  !> property \f$\phi\f$ "total viscosity" when the extrapolation
183  !> has been activated (see \ref time_extrapolated key word), according to the
184  !> formula \f$\phi^{n+\theta}=(1+\theta)\phi^n-\theta \phi^{n-1}\f$.\n
185  !> The value of \f$\theta\f$ = \ref thetvi is deduced from the value
186  !> chosen for \ref time_extrapolated key word for the viscosity.
187  !> Generally, only the value 0.5 is used.
188  !>    -  0 : explicit
189  !>    - 1/2: extrapolated in n+1/2
190  !>    -  1 : extrapolated in n+1
191  double precision, save :: thetvi
192
193  !> \f$ \theta \f$-scheme for the extrapolation of the physical
194  !> property \f$\phi\f$ "specific heat" when the extrapolation
195  !> has been activated (see \ref time_extrapolated field key int), according to
196  !> the formula \f$\phi^{n+\theta}=(1+\theta)\phi^n-\theta \phi^{n-1}\f$.\n
197  !> The value of \f$\theta\f$ = \ref thetcp is deduced from the value chosen
198  !> for the specific heat. Generally, only the value 0.5 is used.
199  !>    -  0 : explicit
200  !>    - 1/2: extrapolated in n+1/2
201  !>    -  1 : extrapolated in n+1
202  double precision, save :: thetcp
203
204  !> \f$ \theta \f$-scheme for the extrapolation of the physical
205  !> property \f$\phi\f$ "diffusivity" when the extrapolation has
206  !> been activated (see \ref time_extrapolated key word), according to the
207  !> formula \f$\phi^{n+\theta}=(1+\theta)\phi^n-\theta \phi^{n-1}\f$.\n
208  !> The value of\f$\theta\f$ = \ref thetvs is deduced from the value
209  !> chosen for \ref time_extrapolated key word. Generally, only the value 0.5
210  !> is used.
211  !>    -  0 : explicit
212  !>    - 1/2: extrapolated in n+1/2
213  !>    -  1 : extrapolated in n+1
214  double precision, save :: thetvs(nscamx)
215
216  !> relative precision for the convergence test of the iterative process on
217  !> velocity-pressure coupling (inner iterations)
218  real(c_double), pointer, save :: epsup
219
220  !> norm  of the increment \f$ \vect{u}^{k+1} - \vect{u}^k \f$
221  !> of the iterative process on velocity-pressure coupling (inner iterations)
222  real(c_double), pointer, save :: xnrmu
223
224  !> norm of \f$ \vect{u}^0 \f$ (used by velocity-pressure inner iterations)
225  real(c_double), pointer, save :: xnrmu0
226
227  !> \}
228
229  !----------------------------------------------------------------------------
230  ! Space discretisation
231  !----------------------------------------------------------------------------
232
233  !> \defgroup space_discretisation Space discretisation
234
235  !> \addtogroup space_discretisation
236  !> \{
237
238  !> \defgroup conv_scheme Convective scheme
239  !> \addtogroup conv_scheme
240  !> \{
241
242  !> \anchor iflxmw
243  !> method to compute interior mass flux due to ALE mesh velocity
244  !>    - 1: based on cell center mesh velocity
245  !>    - 0: based on nodes displacement
246  integer(c_int), pointer, save :: iflxmw
247
248  !> \}
249
250  !> \defgroup gradient_calculation Gradient calculation
251  !> \addtogroup gradient_calculation
252  !> \{
253
254  !> type of gradient reconstruction
255  !>    - 0: iterative process
256  !>    - 1: standard least squares method
257  !>    - 2: least square method with extended neighborhood
258  !>    - 3: least square method with reduced extended neighborhood
259  !>    - 4: iterative process initialized by the least squares method
260  integer(c_int), pointer, save :: imrgra
261
262  !> \}
263
264  !> \defgroup diffusive_scheme Diffusive scheme
265  !> \addtogroup diffusive_scheme
266  !> \{
267
268  !> face viscosity field interpolation
269  !>    - 1: harmonic
270  !>    - 0: arithmetic (default)
271  integer(c_int), pointer, save :: imvisf
272
273  !> \}
274
275 !> \}
276
277  !> Indicator of a calculation restart (=1) or not (=0).
278  !> This value is set automatically by the code; depending on
279  !> whether a restart directory is present, and should not be modified by
280  !> the user
281  integer, save :: isuite
282
283  !> Indicates the reading (=1) or not (=0) of the auxiliary
284  !> calculation restart file\n
285  !> Useful only in the case of a calculation restart
286  integer(c_int), pointer, save :: ileaux
287
288  !> Indicates the writing (=1) or not (=0) of the auxiliary calculation
289  !> restart file.
290  integer(c_int), pointer, save :: iecaux
291
292  !> \anchor isuit1
293  !> For the 1D wall thermal module, activation (1) or not(0)
294  !> of the reading of the mesh and of the wall temperature
295  !> from the restart file
296  !> Useful if nfpt1d > 0
297  integer, save :: isuit1
298
299  !----------------------------------------------------------------------------
300  ! Time stepping options
301  !----------------------------------------------------------------------------
302
303  !> \defgroup time_step_options Time step options and variables
304
305  !> \addtogroup time_step_options
306  !> \{
307
308  !> Absolute time step number for previous calculation.
309  !>
310  !> In the case of a restart calculation, \ref ntpabs
311  !> is read from the restart file. Otherwise, it is
312  !> initialised to 0 \ref ntpabs is initialised
313  !> automatically by the code, its value is not to be
314  !> modified by the user.
315  integer(c_int), pointer, save :: ntpabs
316
317  !> Current absolute time step number.
318  !> In case of restart, this is equal to ntpabs + number of new iterations.
319  integer(c_int), pointer, save :: ntcabs
320
321  !> Maximum absolute time step number.
322  !>
323  !> For the restart calculations, \ref ntmabs takes into
324  !> account the number of time steps of the previous calculations.
325  !> For instance, after a first calculation of 3 time steps, a
326  !> restart file of 2 time steps is realised by setting
327  !> \ref ntmabs = 3+2 = 5
328  integer(c_int), pointer, save :: ntmabs
329
330  !> Number of time steps for initalization (for all steps between
331  !> 0 and \ref ntinit, pressure is re-set to 0 before prediction
332  !> correction).
333  integer(c_int), pointer, save :: ntinit
334
335  !> Absolute time value for previous calculation.
336  !>
337  !> In the case of a restart calculation, \ref ttpabs is read from
338  !> the restart file. Otherwise it is initialised to 0.\n
339  !> \ref ttpabs is initialised automatically by the code,
340  !> its value is not to be modified by the user.
341  real(c_double), pointer, save :: ttpabs
342
343  !> Current absolute time.
344  !>
345  !> For the restart calculations, \ref ttcabs takes
346  !> into account the physical time of the previous calculations.\n
347  !> If the time step is uniform (\ref idtvar = 0 or 1), \ref ttcabs
348  !> increases of \ref dt (value of the time step) at each iteration.
349  !> If the time step is non-uniform (\ref idtvar=2), \ref ttcabs
350  !> increases of \ref dtref at each time step.\n
351  !> \ref ttcabs} is initialised and updated automatically by the code,
352  !> its value is not to be modified by the user.
353  real(c_double), pointer, save :: ttcabs
354
355  !> Maximum absolute time.
356  real(c_double), pointer, save :: ttmabs
357
358  !> Clip the time step with respect to the buoyant effects
359  !>
360  !> When density gradients and gravity are present, a local thermal time
361  !> step can be calculated, based on the Brunt-Vaisala frequency. In
362  !> numerical simulations, it is usually wise for the time step to be
363  !> lower than this limit, otherwise numerical instabilities may appear.\n
364  !> \ref iptlro indicates whether the time step should be limited to the
365  !> local thermal time step (=1) or not (=0).\n
366  !> When \ref iptlro=1, the log shows the number of cells where the
367  !> time step has been clipped due to the thermal criterion, as well as
368  !> the maximum ratio between the time step and the maximum thermal time
369  !> step. If \ref idtvar=0, since the time step is fixed and cannot be
370  !> clipped, this ratio can be greater than 1. When \ref idtvar > 0, this
371  !> ratio will be less than 1, except if the constraint \ref dtmin has
372  !> prevented the code from reaching a sufficiently low value for \ref dt.
373  !> Useful when density gradients and gravity are present.
374  integer(c_int), pointer, save :: iptlro
375
376  !> option for a variable time step
377  !>    - -1: steady algorithm
378  !>    -  0: constant time step
379  !>    -  1: time step constant in space but variable in time
380  !>    -  2: variable time step in space and in time
381  !> If the numerical scheme is a second-order in time, only the
382  !> option 0 is allowed.
383  integer(c_int), pointer, save :: idtvar
384
385  !> Reference time step
386  !>
387  !> This is the time step value used in the case of a calculation run with a
388  !> uniform and constant time step, i.e. \ref idtvar =0 (restart calculation
389  !> or not). It is the value used to initialize the time step in the case of
390  !> an initial calculation run with a non-constant time step(\ref idtvar=1 or
391  !> 2). It is also the value used to initialise the time step in the case of
392  !> a restart calculation in which the type of time step has been changed
393  !> (for instance, \ref idtvar=1 in the new calculation and \ref idtvar = 0 or
394  !> 2 in the previous calculation).\n
395  !> See \subpage user_initialization_time_step for examples.
396  real(c_double), pointer, save :: dtref
397
398  !> maximum Courant number (when \ref idtvar is different from 0)
399  real(c_double), pointer, save :: coumax
400
401  !> maximum Courant number for the continuity equation in compressible model
402  real(c_double), pointer, save :: cflmmx
403
404  !> maximum Fourier number (when \ref idtvar is different from 0)
405  real(c_double), pointer, save :: foumax
406
407  !> maximum allowed relative increase in the calculated time step value
408  !> between two successive time steps (to ensure stability, any decrease
409  !> in the time step is immediate and without limit).\n
410  !> Useful when \ref idtvar is different from 0.
411  real(c_double), pointer, save :: varrdt
412
413  !> lower limit for the calculated time step when idtvar is different from 0.\n
414  !> Take \ref dtmin = min (ld/ud, sqrt(lt/(gdelta rho/rho)), ...)
415  real(c_double), pointer, save :: dtmin
416
417  !> upper limit for the calculated time step when idtvar is different from 0.\n
418  !> Take \ref dtmax = max (ld/ud, sqrt(lt/(gdelta rho/rho)), ...)
419  real(c_double), pointer, save :: dtmax
420
421  !> multiplicator coefficient for the time step of each variable
422  !>    - useless for u,v,w,p
423  !>    - for k,e     the same value is taken (value of k)
424  !>    - for Rij, e  the same value is taken (value of r11)\n
425  !> Hence, the time step used when solving the evolution equation for
426  !> the variable is the time step used for the dynamic equations
427  !> (velocity/pressure) multiplied by \ref cdtvar.
428  !> The size of the array \ref cdtvar is \ref dimens::nvar "nvar". For instance,
429  !> the multiplicative coefficient applied to the scalar 2 is cdtvar(isca(2))).
430  !> Yet, the value of cdtvar for the velocity components and the pressure is
431  !> not used. Also, although it is possible to change the value of \ref cdtvar
432  !> for the turbulent variables, it is highly not recommended.
433  double precision, save :: cdtvar(nvarmx)
434
435  !> relaxation coefficient for the steady algorithm
436  !> \ref relxst = 1 : no relaxation.
437  real(c_double), pointer, save :: relxst
438
439  !> \}
440
441  !----------------------------------------------------------------------------
442  ! thermal model
443  !----------------------------------------------------------------------------
444
445  !> \defgroup thermal model
446
447  !> \addtogroup thermal
448  !> \{
449
450  !> thermal model
451  !>    - 0: no thermal model
452  !>    - 1: temperature
453  !>    - 2: enthalpy
454  !>    - 3: total energy (only for compressible module)\n
455  !> When a particular physics module is activated (gas combustion,
456  !> pulverised coal, electricity or compressible), the user must not
457  !> modify \ref itherm (the choice is made automatically: the solved
458  !> variable is either the enthalpy or the total energy). The user is
459  !> also reminded that, in the case of a coupling with SYRTHES, the
460  !> solved thermal variable should be the temperature (\ref itherm = 1).
461  !> More precisely, everything is designed in the code to allow for the
462  !> running of a calculation coupled with SYRTHES with the enthalpy as
463  !> thermal variable. With the compressible model, it is possible to
464  !> carry out calculations coupled with SYRTHES, although the thermal
465  !> scalar represents the total energy and not the temperature.
466  integer(c_int), pointer, save :: itherm
467
468  !> Temperature scale
469  !> - 0: none
470  !> - 1: Kelvin
471  !> - 2: Celsius
472  !> The distinction between \ref itpscl = 1 or 2 is useful only in case of
473  !> radiation modelling. For calculations without radiation modelling,
474  !> use \ref itpscl = 1 for the temperature.\n
475  !> Useful if and only if \ref dimens::nscal "nscal" \f$\geqslant\f$ 1.
476  integer(c_int), pointer, save :: itpscl
477
478  !> Index of the thermal scalar (temperature, energy or enthalpy)
479  !>
480  !> The index of the corresponding variable is isca(iscalt)
481  !> If \ref iscalt = -1, neither the temperature nor the enthalpy is
482  !> represented by a scalar. When a specific physics module is activated
483  !> (gas combustion, pulverised coal, electricity or compressible), the user
484  !> must not modify \ref iscalt (the choice is made automatically). In the
485  !> case of the compressible module, \ref iscalt does not correspond to
486  !> the temperature nor enthalpy but to the total energy}.\n Useful if
487  !> and only if \ref dimens::nscal "nscal" \f$\geqslant\f$ 1.
488  integer(c_int), pointer, save :: iscalt
489
490  !> \}
491
492  !----------------------------------------------------------------------------
493  ! turbulence
494  !----------------------------------------------------------------------------
495
496  !> \defgroup turbulence turbulence options
497
498  !> \addtogroup turbulence
499  !> \{
500
501  !> \anchor iturb
502  !> turbulence model
503  !>    - 0: no turbulence model (laminar flow)
504  !>    - 10: mixing length model
505  !>    - 20: standard \f$ k-\varepsilon \f$ model
506  !>    - 21: \f$ k-\varepsilon \f$ model with Linear Production (LP) correction
507  !>    - 30: \f$ R_{ij}-\epsilon \f$ (LRR)
508  !>    - 31: \f$ R_{ij}-\epsilon \f$ (SSG)
509  !>    - 32: \f$ R_{ij}-\epsilon \f$ (EBRSM)
510  !>    - 40: LES (constant Smagorinsky model)
511  !>    - 41: LES ("classical" dynamic Smagorisky model)
512  !>    - 42: LES (WALE)
513  !>    - 50: v2f phi-model
514  !>    - 51: v2f \f$ BL-v^2-k \f$
515  !>    - 60: \f$ k-\omega \f$ SST
516  !>    - 70: Spalart-Allmaras model
517  integer(c_int), pointer, save :: iturb
518
519  !> Class of turbulence model (integer value iturb/10)
520  integer(c_int), pointer, save :: itytur
521
522  !> Activation of Hybrid RANS/LES model (only valid for iturb equal to 60)
523  integer(c_int), pointer, save :: hybrid_turb
524
525  !> Activation of rotation/curvature correction for eddy viscosity turbulence
526  !> models
527  !>    - 0: false
528  !>    - 1: true
529  integer(c_int), pointer, save :: irccor
530
531  !> Type of rotation/curvature correction for eddy viscosity turbulence models
532  !>    - 1 Cazalbou correction (default when irccor=1 and itytur=2 or 5)
533  !>    - 2 Spalart-Shur correction (default when irccor=1 and iturb=60 or 70)
534  integer(c_int), pointer, save :: itycor
535
536  !> Turbulent diffusion model for second moment closure
537  !>    - 0: scalar diffusivity (Shir model)
538  !>    - 1: tensorial diffusivity (Daly and Harlow model, default model)
539  integer(c_int), pointer, save :: idirsm
540
541  !>  Wall functions
542  !>  Indicates the type of wall function used for the velocity
543  !>  boundary conditions on a frictional wall.
544  !>  - 0: no wall functions
545  !>  - 1: one scale of friction velocities (power law)
546  !>  - 2: one scale of friction velocities (log law)
547  !>  - 3: two scales of friction velocities (log law)
548  !>  - 4: two scales of friction velocities (log law) (scalable wall functions)
549  !>  - 5: two scales of friction velocities (mixing length based on V. Driest
550  !>       analysis)
551  !>  - 6: wall function unifying rough and smooth friction regimes
552  !>  - 7: All \f$ y^+ \f$  for low Reynolds models\n
553  !>  \ref iwallf is initialised to 2 for \ref iturb = 10, 40, 41 or 70
554  !>  (mixing length, LES and Spalart Allmaras).\n
555  !>  \ref iwallf is initialised to 0 for \ref iturb = 0, 32, 50 or 51\n
556  !>  \ref iwallf is initialised to 3 for \ref iturb = 20, 21, 30, 31 or 60
557  !>  (\f$k-\epsilon\f$, \f$R_{ij}-\epsilon\f$ LRR, \f$R_{ij}-\epsilon\f$ SSG and
558  !> \f$ k-\omega\f$ SST models).\n
559  !>  The v2f model (\ref iturb=50) is not designed to use wall functions
560  !>  (the mesh must be low Reynolds).\n
561  !>  The value \ref iwallf = 3 is not compatible with \ref iturb=0, 10, 40
562  !>  or 41 (laminar, mixing length and LES).\n
563  !>  Concerning the \f$k-\epsilon\f$ and \f$R_{ij}-\epsilon\f$ models, the
564  !>  two-scales model is usually at least as satisfactory as the one-scale
565  !>  model.\n
566  !>  The scalable wall function allows to virtually shift the wall when
567  !>  necessary in order to be always in a logarithmic layer. It is used to make
568  !>  up for the problems related to the use of High-Reynolds models on very
569  !>  refined meshes.\n
570  !>  Useful if \ref iturb is different from 50.
571  integer(c_int), pointer, save :: iwallf
572
573  !>  Wall functions for scalar
574  !>    - 0: three layer wall function of Arpaci and Larsen
575  !>    - 1: Van Driest wall function
576  integer(c_int), pointer, save :: iwalfs
577
578  !> Indicates the clipping method used for \f$k\f$ and
579  !> \f$\varepsilon\f$, for the \f$k-\epsilon\f$ and v2f models
580  !> - 0: clipping in absolute value
581  !> - 1: coupled clipping based on physical relationships\n
582  !> Useful if and only if \ref iturb = 20, 21 or 50 (\f$k-\epsilon\f$ and
583  !> v2f models). The results obtained with the method corresponding to
584  !> \ref iclkep =1 showed in some cases a substantial sensitivity to the
585  !> values of the length scale \ref cs_turb_ref_values_t::almax "almax".\n
586  !> The option \ref iclkep = 1 is therefore not recommended, and,
587  !> if chosen, must be used cautiously.
588  integer(c_int), pointer, save :: iclkep
589
590  !> Indicates if the term \f$\frac{2}{3}\grad \rho k\f$
591  !> is taken into account in the velocity equation.
592  !> - 1: true
593  !> - 0: false in the velocity\n
594  !> Useful if and only if \ref iturb = 20, 21, 50 or 60.\n
595  !> This term may generate non-physical velocities at the wall.
596  !> When it is not explicitly taken into account, it is
597  !> implicitly included into the pressure.
598  integer(c_int), pointer, save :: igrhok
599
600  !> Indicates if the terms related to gravity are taken
601  !> into account in the equations of \f$k-\epsilon\f$.
602  !> - 1: true (default if \f$ \rho \f$ is variable)
603  !> - 0: false
604  !> Useful if and only if \ref iturb = 20, 21, 50 or 60 and
605  !> (\ref cstphy::gx "gx", \ref cstphy::gy "gy", \ref cstphy::gz "gz"})
606  !> \f$\ne\f$ (0,0,0) and the density is not uniform.
607  integer(c_int), pointer, save :: igrake
608
609  !> Indicates if the terms related to gravity are taken
610  !> into account in the equations of \f$R_{ij}-\varepsilon\f$.
611  !> - 1: true (default if \f$ \rho \f$ is variable)
612  !> - 0: false
613  !> Useful if and only if \ref iturb = 30 or 31 and (\ref cstphy::gx "gx",
614  !> \ref cstphy::gy "gy", \ref cstphy::gz "gz"}) \f$\ne\f$
615  !> (0,0,0) (\f$R_{ij}-\epsilon\f$ model with gravity) and the
616  !> density is not uniform.
617  integer(c_int), pointer, save :: igrari
618
619  !> Indicates if the coupling of the source terms of
620  !> \f$k\f$ and \f$\epsilon\f$ or \f$k\f$ and \f$\omega\f$
621  !> is taken into account or not.
622  !> - 1: true,
623  !> - 0: false\n
624  !> If \ref ikecou = 0 in \f$k-\epsilon\f$ model, the term
625  !> in \f$\epsilon\f$ in the equation of \f$k\f$ is made implicit.\n
626  !> \ref ikecou is initialised to 0 if \ref iturb = 21 or 60, and
627  !> to 1 if \ref iturb = 20.\n
628  !> \ref ikecou = 1 is forbidden when using the v2f model (\ref iturb = 50).\n
629  !> Useful if and only if \ref iturb = 20, 21 or 60 (\f$k-\epsilon\f$ and
630  !> \f$k-\omega\f$ models)
631  integer(c_int), pointer, save :: ikecou
632
633  !> Advanced re-init for EBRSM and k-omega models
634  !>    - 1: true
635  !>    - 0: false (default)
636  integer(c_int), pointer, save :: reinit_turb
637
638
639  !> Coupled solving of \f$ \tens{R} \f$
640  !>    - 1: true
641  !>    - 0: false (default)
642  integer(c_int), pointer, save :: irijco
643
644  !> pseudo eddy viscosity in the matrix of momentum equation to partially
645  !> implicit \f$ \divv \left( \rho \tens{R} \right) \f$
646  !>    - 1: true
647  !>    - 0: false (default)
648  !> The goal is to improve the stability of the calculation.
649  !> The usefulness of \ref irijnu = 1 has however not been
650  !> clearly demonstrated.\n Since the system is solved in
651  !> incremental form, this extra turbulent viscosity does
652  !> not change the final solution for steady flows. However,
653  !> for unsteady flows, the parameter \ref nswrsm should be
654  !> increased.\n Useful if and only if \ref iturb = 30 or 31
655  !> (\f$R_{ij}-\epsilon\f$ model).
656  integer(c_int), pointer, save :: irijnu
657
658  !> accurate treatment of \f$ \tens{R} \f$ at the boundary (see \ref condli)
659  !>    - 1: true
660  !>    - 0: false (default)
661  integer(c_int), pointer, save :: irijrb
662
663  !> Indicates if the wall echo terms in
664  !> \f$R_{ij}-\epsilon\f$ LRR model are taken into account:
665  !> - 1: true,
666  !> - 0: false (default)\n
667  !> Useful if and only if \ref iturb = 30 (\f$R_{ij}-\epsilon\f$
668  !> LRR).\n It is not recommended to take these terms into account:
669  !> they have an influence only near the walls, their expression is hardly
670  !> justifiable according to some authors and, in the configurations
671  !> studied with code_saturne, they did not bring any improvement in
672  !> the results.\n
673  !> In addition, their use induces an increase in the calculation time.\n
674  !> The wall echo terms imply the calculation of the distance to the wall
675  !> for every cell in the domain. See \ref icdpar for potential restrictions
676  !> due to this.
677  integer(c_int), pointer, save :: irijec
678
679  !> whole treatment of the diagonal part of the diffusion tensor of
680  !> \f$ \tens{R} \f$ and \f$ \varepsilon \f$
681  !>    - 1: true (default)
682  !>    - 0: simplified treatment
683  integer(c_int), pointer, save :: idifre
684
685  !> partial implicitation of symmetry BCs of \f$ \tens{R} \f$
686  !>    - 1: true (default)
687  !>    - 0: false
688  integer(c_int), pointer, save :: iclsyr
689
690  !> partial implicitation of wall BCs of \f$ \tens{R} \f$
691  !>    - 1: true
692  !>    - 0: false (default)
693  integer(c_int), pointer, save :: iclptr
694
695  !> Activates or the van Driest wall-damping for the
696  !> Smagorinsky constant (the Smagorinsky constant
697  !> is multiplied by the damping function
698  !> \f$1-e^{-y^+/ cdries}\f$, where \f$y^+\f$
699  !> designates the non-dimensional distance to the
700  !> nearest wall).
701  !>    - 1: true
702  !>    - 0: false
703  !> The default value is 1 for the Smagorinsky model
704  !> and 0 for the dynamic model.\n The van Driest
705  !> wall-damping requires the knowledge of the
706  !> distance to the nearest wall for each cell
707  !> in the domain. Refer to keyword \ref icdpar
708  !> for potential limitations.\n
709  !> Useful if and only if \ref iturb = 40 or 41
710  integer(c_int), pointer, save :: idries
711
712  !> Wall boundary condition on omega in k-omega SST
713  !> 0: Deprecated Neumann boundary condition
714  !> 1: Dirichlet boundary condition consistent with Menter's
715  !>    original model: w_wall = 60*nu/(beta*d**2)
716  integer, save :: ikwcln
717
718  !> Activates or not the LES balance module
719  !> - 0: false (default)
720  !> - 1: true
721  !> Useful if \ref iturb =40, 41 or 42\n
722  integer(c_int), pointer, save :: i_les_balance
723
724  !> number of variable (deprecated, used only for compatibility)
725  integer, save :: nvarcl
726
727  !> \}
728
729  !----------------------------------------------------------------------------
730  ! Stokes
731  !----------------------------------------------------------------------------
732
733  !> \defgroup stokes Stokes options
734
735  !> \addtogroup stokes
736  !> \{
737
738  !> Indicates whether the source terms in transposed gradient
739  !> and velocity divergence should be taken into account in the
740  !> momentum equation. In the compressible module, these terms
741  !> also account for the volume viscosity (cf. \ref ppincl::viscv0 "viscv0"
742  !> and \ref ppincl::iviscv "iviscv")
743  !> \f$\partial_i \left[(\kappa -2/3\,(\mu+\mu_t))\partial_k U_k  \right]
744  !> +     \partial_j \left[ (\mu+\mu_t)\partial_i U_j \right]\f$:
745  !> - 0: not taken into account,
746  !> - 1: taken into account.
747  integer(c_int), pointer, save :: ivisse
748
749  !> Reconstruction of the velocity field with the updated pressure option
750  !>    - 0: default
751  !>    - 1: from the mass flux with a RT0 like recontruction
752  integer(c_int), pointer, save ::          irevmc
753
754  !> Compute the pressure step thanks to the continuity equation
755  !>    - 1: true (default)
756  !>    - 0: false
757  integer(c_int), pointer, save ::          iprco
758
759  !> Arakawa multiplicator for the Rhie and Chow filter (1 by default)
760  real(c_double), pointer, save :: arak
761
762  !> Factor of the Rhie and Chow filter:
763  !>    - 0: dt (default)
764  !>    - 1: 1/A_u
765  integer(c_int), pointer, save :: rcfact
766
767  !> 1D staggered scheme option:
768  !>    - 0: colocated (default)
769  !>    - 1: staggered
770  integer(c_int), pointer, save :: staggered
771
772  !> indicates the algorithm for velocity-pressure coupling:
773  !> - 0: standard algorithm,
774  !> - 1: reinforced coupling in case calculation with long time steps\n
775  !> Always useful (it is seldom advised, but it can prove very useful,
776  !> for instance, in case of flows with weak convection effects and
777  !> highly variable viscosity).
778  integer(c_int), pointer, save :: ipucou
779
780  !> \anchor iccvfg
781  !> indicates whether the dynamic field should be frozen or not:
782  !>    - 1: true
783  !>    - 0: false (default)\n
784  !> In such a case, the values of velocity, pressure and the
785  !> variables related to the potential turbulence model
786  !> (\f$k\f$, \f$R_{ij}\f$, \f$\varepsilon\f$, \f$\varphi\f$,
787  !> \f$\bar{f}\f$, \f$\omega\f$, turbulent viscosity) are kept
788  !> constant over time and only the equations for the scalars
789  !> are solved.\n Also, if \ref iccvfg = 1, the physical properties
790  !> modified in \ref cs_user_physical_properties will keep being
791  !> updated. Beware of non-consistencies if these properties would
792  !> normally affect the dynamic field (modification of density for
793  !> instance).\n Useful if and only if \ref dimens::nscal "nscal"
794  !> \f$>\f$ 0 and the calculation is a restart.
795  integer(c_int), pointer, save :: iccvfg
796
797  !> Algorithm to take into account the density variation in time
798  !>    - 0: boussinesq algorithm with constant density
799  !>    - 1: dilatable steady algorithm (default)
800  !>    - 2: dilatable unsteady algorithm
801  !>    - 3: low-Mach algorithm
802  !>    - 4: algorithm for fire
803  integer(c_int), pointer, save :: idilat
804
805  !> Option to switch on massflux prediction befor momentum solving
806  !> to be fully conservative in momentum over time for variable density flows.
807  !> This option is to be removed.
808  integer, save :: ipredfl
809
810  !> parameter of diagonal pressure strengthening
811  real(c_double), pointer, save :: epsdp
812
813  !TODO doxygen
814  ! Type des conditions limites et index min et max
815  !                 des sous listes defaces de bord
816  integer, save :: idebty(ntypmx), ifinty(ntypmx)
817
818  !> accurate treatment of the wall temperature
819  !>    - 1: true
820  !>    - 0: false (default)
821  !> (see \ref condli, useful in case of coupling with syrthes)
822  integer(c_int), pointer, save :: itbrrb
823
824  !> improve static pressure algorithm
825  !>    - 1: impose the equilibrium of the static part of the pressure
826  !>         with any external force, even head losses
827  !>    - 0: no treatment (default)
828  !>        When the density effects are important, the choice of \ref iphydr = 1
829  !>        allows to improve the interpolation of the pressure and correct the
830  !>        non-physical velocities which may appear in highly stratified areas
831  !>        or near horizontal walls.\n
832  !>        The improved algorithm also allows eradicating the velocity
833  !>        oscillations which tend to appear at the frontiers of areas with
834  !>        high head losses.\n
835  !>        In the case of a stratified flow, the calculation cost is higher when
836  !>        the improved algorithm is used (about 30\% depending on the case)
837  !>        because the hydrostatic pressure must be recalculated at the outlet
838  !>        boundary conditions: see \ref icalhy.\n
839  !>        On meshes of insufficient quality, in order to
840  !>        improve the convergence, it may be useful to increase the number of
841  !>        iterations for the reconstruction of the pressure right-hand side,
842  !>        i.e. \ref cs_var_cal_opt_t::nswrsm "nswrsm".\n If head losses are
843  !>        present just along an outlet boundary, it is necessary to specify
844  !>        \ref icalhy = 0 in order to deactivate the recalculation of the
845  !>        hydrostatic pressure at the boundary, which may otherwise cause
846  !>        instabilities. Please refer to the
847  !>    <a href="../../theory.pdf#iphydr"><b>handling of the hydrostatic pressure</b></a>
848  !>      section of the theory guide for more informations.
849  integer(c_int), pointer, save :: iphydr
850
851  !> improve static pressure algorithm
852  !>    - 1: take -div(rho R) in the static pressure
853  !>      treatment IF iphydr=1
854  !>    - 0: no treatment (default)
855  integer(c_int), pointer, save :: igprij
856
857  !> improve static pressure algorithm
858  !>    - 1: take user source term in the static pressure
859  !>      treatment IF iphydr=1 (default)
860  !>    - 0: no treatment
861  integer(c_int), pointer, save :: igpust
862
863  !> indicates the presence of a Bernoulli boundary face (automatically computed)
864  !>    - 0: no face
865  !>    - 1: at least one face
866  integer(c_int), pointer, save :: iifren
867
868  !> number of the closest free standard outlet (or free inlet) face to xyzp0
869  integer, save :: ifrslb
870
871  !> max of ifrslb on all ranks, standard outlet face presence indicator
872  integer, save :: itbslb
873
874  !> compute the hydrostatic pressure in order to compute the Dirichlet
875  !> conditions on the pressure at outlets
876  !>    - 1: true
877  !>    - 0: false (default)
878  integer(c_int), pointer, save :: icalhy
879
880  !> use interpolated face diffusion coefficient instead of cell diffusion
881  !> coefficient for the mass flux reconstruction for the non-orthogonalities
882  !>    - 1: true
883  !>    - 0: false (default)
884  integer(c_int), pointer, save :: irecmf
885
886  !> Has a solid zone where dynamics must be killed?
887  !>    - false (default)
888  !>    - true
889  logical(c_bool), pointer, save :: fluid_solid
890
891  !> choice the way to compute the exchange coefficient of the
892  !> condensation source term used by the copain model
893  !>    - 1: the turbulent exchange coefficient of the flow
894  !>    - 2: the exchange coefficient of the copain correlation
895  !>    - 3: the maximal value between the two previous exchange coefficients
896  integer, save :: icophc
897
898  !> choice the way to compute the thermal exchange coefficient associated
899  !> to the heat transfer to wall due to the condensation phenomenon
900  !>    - 2: the thermal exchange coefficient of the copain correlation
901  !>    - 3: the maximal value between the current and previous thermal
902  !>         exchange coefficient evaluated by the copain correlation
903  integer, save :: icophg
904
905  !> choice the way to compute the wall temperature at the solid/fluid interface
906  !> coupled with condensation to the wall
907  !>    - 1: the wall temperature is computed with a 1-D thermal model
908  !>         with implicit numerical scheme
909  !>    - 0: the wall temperature is imposed as constant by the user (default)
910  !>         exchange coefficient evaluated by the copain correlation
911  integer, save :: itag1d
912
913  !> choice the way to compute the wall temperature at the solid/fluid interface
914  !> coupled with condensation to the metal mass structures wall
915  !>    - 1: the wall temperature is computed with a 0-D thermal model
916  !>         with explicit numerical scheme
917  !>    - 0: the wall temperature is imposed as constant by the user (default)
918  !>         and past to the copain correlation to evaluate the exchange
919  !>         coefficient
920  integer, save :: itagms
921
922
923  !> \ref iescal indicates the calculation mode for the error estimator
924  !> \ref paramx::iespre "iespre", \ref paramx::iesder "iesder",
925  !> \ref paramx::iescor "iescor" or \ref paramx::iestot "iestot"
926  !> for the Navier-Stokes equation:
927  !> - 0: estimator not calculated,
928  !> - 1: the estimator  \f$ \eta^{*}_{i,1}\f$ is calculated,
929  !> without contribution of the volume,
930  !> - 2: the estimator \f$ \eta^{*}_{i,2}\f$ is calculated,
931  !> with contribution of the volume (norm \f$L^2\f$),
932  !> except for \ref paramx::iescor "iescor", for which
933  !> \f$|\Omega_i|\ \eta^{corr}_{i,1}\ \f$
934  !> is calculated. The names of the estimators appearing
935  !> in the log and the post-processing are made up of
936  !> the default name (given before), followed by the value of
937  !> \ref iescal}. For instance, EsPre2 is the estimator
938  !> \ref paramx::iespre "iespre" calculated with \ref iescal = 2.
939  integer, save :: iescal(nestmx)
940
941  !> \ref n_buoyant_scal is the number of buoyant scalar
942  !> It will be zero if there is no buoyant scalar
943  integer(c_int), pointer, save :: n_buoyant_scal
944
945  !> \}
946
947  !----------------------------------------------------------------------------
948  ! Homogeneous mixture modelling
949  !----------------------------------------------------------------------------
950
951  !> \addtogroup homogeneous_mixture
952  !> \{
953  !> \addtogroup vof
954  !> \{
955
956  !> VoF model (sum of masks defining VoF model and submodels).
957  !> See defined masks in \ref vof_masks.
958  integer(c_int), pointer, save :: ivofmt
959
960  integer(c_int), pointer, save :: idrift
961
962  !> \addtogroup vof_masks
963  !> \{
964
965  !> Volume of Fluid model
966  integer :: VOF_ENABLED
967
968  !> Free surface model
969  integer :: VOF_FREE_SURFACE
970
971  !> Mass transfer Merkle model for vaporization / condensation (cavitation)
972  integer :: VOF_MERKLE_MASS_TRANSFER
973
974  parameter (VOF_ENABLED=1)
975  parameter (VOF_FREE_SURFACE=2)
976  parameter (VOF_MERKLE_MASS_TRANSFER=4)
977
978  !> \}
979
980  !> \}
981  !> \}
982
983  !----------------------------------------------------------------------------
984  ! Additional source terms
985  !----------------------------------------------------------------------------
986
987  !> \defgroup additional_source_terms Additional source terms
988
989  !> \addtogroup additional_source_terms
990  !> \{
991
992  !> Indicateur pertes de charge global (ie somme sur les processeurs
993  !>   de ncepdc)
994  integer, save :: ncpdct
995
996  !> Indicateur termes sources de masse global (ie somme sur les processeurs
997  !>   de ncetsm)
998  integer, save :: nctsmt
999
1000  !> Global indicator of condensation source terms (ie. sum on the processors
1001  !> of nfbpcd) cells associated to the face with condensation phenomenon
1002  integer, save :: nftcdt
1003
1004  !> \anchor iporos
1005  !> take the porosity fomulation into account
1006  !>    - 1: Taking porosity into account
1007  !>    - 0: Standard algorithm (Without porosity)
1008  integer(c_int), pointer, save :: iporos
1009
1010  !> \}
1011
1012  !----------------------------------------------------------------------------
1013  ! Numerical parameters for the wall distance calculation
1014  !----------------------------------------------------------------------------
1015
1016  !> \defgroup num_wall_distance Numerical parameters for the wall distance
1017  !> calculation
1018
1019  !> \addtogroup num_wall_distance
1020  !> \{
1021
1022  !> - 1, the wall distance must be computed,
1023  !> - 0, the wall distance computation is not necessary.
1024  integer, save :: ineedy
1025
1026  !> - 1, the wall distance is up to date,
1027  !> - 0, the wall distance has not been updated.
1028  integer, save :: imajdy
1029
1030  !> Specifies the method used to calculate the distance to the wall y
1031  !> and the non-dimensional distance \f$ y+ \f$ for all the cells of
1032  !> the calculation domain (when necessary):
1033  !> - 1: standard algorithm (based on a Poisson equation for y and
1034  !> convection equation for \f$ y+ \f$), with reading of the distance
1035  !> to the wall from the restart file if possible
1036  !> - -1: standard algorithm (based on a Poisson equation for y and
1037  !> convection equation for \f$ y+ \f$ ), with systematic recalculation
1038  !> of the distance to the wall in case of calculation restart
1039  !> - 2: former algorithm (based on geometrical considerations), with
1040  !> reading of the distance to the wall from the restart file if possible\n
1041  !> - -2: former algorithm (based on geometrical considerations) with
1042  !> systematic recalculation of the distance to the wall in case of
1043  !> calculation restart.\n\n
1044  !> In case of restart calculation, if the position of the walls haven’t
1045  !> changed, reading the distance to the wall from the restart file can save
1046  !> a fair amount of computational time.\n Useful in \f$ R_{ij}-\epsilon \f$
1047  !> model with wall echo
1048  !> (\ref iturb=30 and \ref irijec=1), in LES with van Driest damping
1049  !> (\ref iturb=40 and \ref idries=1) and in \f$ k-\omega\f$ SST
1050  !> (\ref iturb=60).
1051  !> By default, \ref icdpar is initialised to -1, in case there has been a
1052  !> change in the definition of the boundary conditions between two
1053  !> computations (change in the number or the positions of the walls).
1054  !> Yet, with the \f$k-\omega\f$
1055  !> SST model, the distance to the wall is needed to calculate the turbulent
1056  !> viscosity, which is done before the calculation of the distance to the wall.
1057  !> Hence, when this model is used (and only in that case), \ref icdpar is set
1058  !> to 1 by default, to ensure total continuity of the calculation at restart.
1059  !> As a consequence, with the \f$k-\omega\f$ SST model, if the number and
1060  !> positions of the walls are changed
1061  !> at a calculation restart, it is mandatory for the user to set \ref icdpar
1062  !> explicitly to -1, otherwise the distance to the wall used will not
1063  !> correspond to the actual position of the walls.\n The former algorithm
1064  !> is not compatible with parallelism nor periodicity. Also, whatever the
1065  !> value chosen for \ref icdpar, the calculation of the distance to the wall
1066  !> is made at the most> once for all at the beginning of the calculation; it
1067  !> is therefore not compatible with moving walls. Please contact the
1068  !> development team if you need to override this limitation.
1069  integer, save :: icdpar
1070
1071  !> \}
1072
1073  !----------------------------------------------------------------------------
1074  ! Transported scalars parameters
1075  !----------------------------------------------------------------------------
1076
1077  !> \defgroup scalar_params Transported scalars parameters
1078
1079  !> \addtogroup scalar_params
1080  !> \{
1081
1082  !> iclvfl : 0 : clip variances to zero
1083  !>          1 : clip variances to zero and to f(1-f)
1084  !>          2 : clip variances to  max(zero,scamin) and scamax
1085  !> for every scalar iscal representing the average of the square of the
1086  !> fluctuations of another scalar ii= \ref iscavr (iscal) (noted \$f\$),
1087  !> indicator of the clipping method:
1088  !> - -1: no clipping because the scalar does not represent
1089  !> the average of the square of the fluctuations of another scalar
1090  !> - 0: clipping to 0 for the lower range of values
1091  !> - 1: clipping to 0 for the lower range of values and to
1092  !> \f$(f-f_{min})(f_{max}-f)\f$ for higher values, where \f$f\f$ is
1093  !> the associated scalar, \f$f_{min}\f$ and \f$f_{max}\f$ its minimum and
1094  !> maximum values specified by the user (i.e. scamin (ii) and scamax (ii))
1095  !> - 2: clipping to max(0,scamin(iscal)) for lower values and to
1096  !>  scamax(iscal) for higher values.scamin and scamax are limits
1097  !> specified by the user.\n Useful for the scalars iscal for
1098  !> which \ref iscavr (iscal) \f$>\f$0.
1099  integer, save ::          iclvfl(nscamx)
1100
1101  !> iscasp(ii) : index of the ii^th species (0 if not a species)
1102  integer, save ::          iscasp(nscamx)
1103
1104  !> When iscavr(iscal)>0, \ref rvarfl is the coefficient \f$R_f\f$ in
1105  !> the dissipation term \f$\-\frac{\rho}{R_f}\frac{\varepsilon}{k}\f$
1106  !> of the equation concerning the scalar,
1107  !> which represents the root mean square of the fluctuations
1108  !> of the scalar.\n
1109  !> Useful if and only if there is 1\f$\leqslant\f$ iscal \f$\leqslant\f$
1110  !> \ref dimens::nscal "nscal" such as iscavr(iscal)>0
1111  double precision, save :: rvarfl(nscamx)
1112
1113  !> ctheta : coefficient des modeles de flux turbulents GGDH et AFM
1114  double precision, save :: ctheta(nscamx)
1115
1116  !> flag for computing the drift mass flux:
1117  !> (for coal classes for instance, only the first
1118  !>  scalar of a class compute the drift flux of the class
1119  !>  and the other scalars use it without recomputing it)
1120  integer :: DRIFT_SCALAR_ADD_DRIFT_FLUX
1121
1122  !> flag for activating thermophoresis for drift scalars
1123  integer :: DRIFT_SCALAR_THERMOPHORESIS
1124
1125  !> flag for activating turbophoresis for drift scalars
1126  integer :: DRIFT_SCALAR_TURBOPHORESIS
1127
1128  ! flag for activating electrophoresis for drift scalars
1129  integer :: DRIFT_SCALAR_ELECTROPHORESIS
1130
1131  !> flag for activating the centrifugal force for drift scalars
1132  integer :: DRIFT_SCALAR_CENTRIFUGALFORCE
1133
1134  !> flag for activating imposed mass flux
1135  integer :: DRIFT_SCALAR_IMPOSED_MASS_FLUX
1136
1137  !> flag for seting the mass flux to zero at all boundaries
1138  integer :: DRIFT_SCALAR_ZERO_BNDY_FLUX
1139
1140  !> flag for seting the mass flux to zero at walls only
1141  integer :: DRIFT_SCALAR_ZERO_BNDY_FLUX_AT_WALLS
1142
1143  parameter (DRIFT_SCALAR_ADD_DRIFT_FLUX=1)
1144  parameter (DRIFT_SCALAR_THERMOPHORESIS=2)
1145  parameter (DRIFT_SCALAR_TURBOPHORESIS=3)
1146  parameter (DRIFT_SCALAR_ELECTROPHORESIS=4)
1147  parameter (DRIFT_SCALAR_CENTRIFUGALFORCE=5)
1148  parameter (DRIFT_SCALAR_IMPOSED_MASS_FLUX=6)
1149  parameter (DRIFT_SCALAR_ZERO_BNDY_FLUX=7)
1150  parameter (DRIFT_SCALAR_ZERO_BNDY_FLUX_AT_WALLS=8)
1151
1152  !> flag for isotropic diffusion
1153  integer :: ISOTROPIC_DIFFUSION
1154
1155  !> flag for orthotropic diffusion
1156  integer :: ORTHOTROPIC_DIFFUSION
1157
1158  !> flag for diffusion by a left-multiplied symmetric 3x3 tensor
1159  integer :: ANISOTROPIC_LEFT_DIFFUSION
1160
1161  ! flag for diffusion by a right-multiplied symmetric 3x3 tensor
1162  integer :: ANISOTROPIC_RIGHT_DIFFUSION
1163
1164  !> flag for diffusion by a symmetric 3x3 tensor
1165  integer :: ANISOTROPIC_DIFFUSION
1166
1167  parameter (ISOTROPIC_DIFFUSION=1)
1168  parameter (ORTHOTROPIC_DIFFUSION=2)
1169  parameter (ANISOTROPIC_LEFT_DIFFUSION=4)
1170  parameter (ANISOTROPIC_RIGHT_DIFFUSION=8)
1171  parameter (ANISOTROPIC_DIFFUSION=12)
1172
1173  !> \}
1174
1175  !----------------------------------------------------------------------------
1176  ! electric model parameters
1177  !----------------------------------------------------------------------------
1178
1179  !> \defgroup electric_model parameters
1180
1181  !> \addtogroup electric_model_params
1182  !> \{
1183
1184  !> ngazge  : number of species for electric arc
1185  integer(c_int), pointer, save :: ngazge
1186
1187  !> ielcor : 0 : electric arc scaling desactivate
1188  !>          1 : electric arc scaling activate
1189  integer(c_int), pointer, save :: ielcor
1190
1191  !> pot_diff : potential between electrods
1192  real(c_double), pointer, save :: pot_diff
1193
1194  !> coejou : scaling coefficient
1195  real(c_double), pointer, save :: coejou
1196
1197  !> elcou : current
1198  real(c_double), pointer, save :: elcou
1199
1200  !> pot_diff : imposed value for current
1201  real(c_double), pointer, save :: couimp
1202
1203  !> irestrike : 0 : restrike mode off
1204  !>             1 : restrike mode on
1205  integer(c_int), pointer, save :: irestrike
1206
1207  !> restrike_point : coordinate of restrike point
1208  real(c_double), pointer, save :: restrike_point_x
1209  real(c_double), pointer, save :: restrike_point_y
1210  real(c_double), pointer, save :: restrike_point_z
1211
1212  !> ntdcla : start iteration for restrike
1213  integer(c_int), pointer, save :: ntdcla
1214
1215  !> \}
1216
1217  !> \}
1218
1219  !=============================================================================
1220
1221  interface
1222
1223    !---------------------------------------------------------------------------
1224
1225    !> \cond DOXYGEN_SHOULD_SKIP_THIS
1226
1227    !---------------------------------------------------------------------------
1228
1229    ! Interface to C function defining whether time step is variable in
1230    ! time or not
1231
1232    subroutine time_step_define_variable(is_variable)  &
1233      bind(C, name='cs_time_step_define_variable')
1234      use, intrinsic :: iso_c_binding
1235      implicit none
1236      integer(c_int), value :: is_variable
1237    end subroutine time_step_define_variable
1238
1239    ! Interface to C function defining whether time step is local in
1240    ! space or not
1241
1242    subroutine time_step_define_local(is_local)  &
1243      bind(C, name='cs_time_step_define_local')
1244      use, intrinsic :: iso_c_binding
1245      implicit none
1246      integer(c_int), value :: is_local
1247    end subroutine time_step_define_local
1248
1249    ! Interface to C function retrieving pointers to members of the
1250    ! global time step structure
1251
1252    subroutine cs_f_time_step_get_pointers(nt_prev, nt_cur, nt_max, nt_ini,  &
1253                                           dt_ref, t_prev, t_cur, t_max)     &
1254      bind(C, name='cs_f_time_step_get_pointers')
1255      use, intrinsic :: iso_c_binding
1256      implicit none
1257      type(c_ptr), intent(out) :: nt_prev, nt_cur, nt_max, nt_ini
1258      type(c_ptr), intent(out) :: dt_ref, t_prev, t_cur, t_max
1259    end subroutine cs_f_time_step_get_pointers
1260
1261    ! Interface to C function retrieving pointers to members of the
1262    ! global time step options structure
1263
1264    subroutine cs_f_time_step_options_get_pointers(iptlro, idtvar,         &
1265                                                   coumax, cflmmx,         &
1266                                                   foumax, varrdt, dtmin,  &
1267                                                   dtmax, relxst)          &
1268      bind(C, name='cs_f_time_step_options_get_pointers')
1269      use, intrinsic :: iso_c_binding
1270      implicit none
1271      type(c_ptr), intent(out) :: iptlro, idtvar, coumax, cflmmx
1272      type(c_ptr), intent(out) :: foumax, varrdt, dtmin, dtmax, relxst
1273    end subroutine cs_f_time_step_options_get_pointers
1274
1275    ! Interface to C function retrieving pointers to members of the
1276    ! global thermal model structure
1277
1278    subroutine cs_f_thermal_model_get_pointers(itherm, itpscl, iscalt) &
1279      bind(C, name='cs_f_thermal_model_get_pointers')
1280      use, intrinsic :: iso_c_binding
1281      implicit none
1282      type(c_ptr), intent(out) :: itherm, itpscl, iscalt
1283    end subroutine cs_f_thermal_model_get_pointers
1284
1285    ! Interface to C function retrieving pointers to members of the
1286    ! global turbulence model structure
1287
1288    subroutine cs_f_turb_model_get_pointers(iturb, itytur, hybrid_turb) &
1289      bind(C, name='cs_f_turb_model_get_pointers')
1290      use, intrinsic :: iso_c_binding
1291      implicit none
1292      type(c_ptr), intent(out) :: iturb, itytur, hybrid_turb
1293    end subroutine cs_f_turb_model_get_pointers
1294
1295    ! Interface to C function retrieving pointers to members of the
1296    ! global wall functions structure
1297
1298    subroutine cs_f_wall_functions_get_pointers(iwallf, iwalfs, &
1299                                                ypluli)         &
1300      bind(C, name='cs_f_wall_functions_get_pointers')
1301      use, intrinsic :: iso_c_binding
1302      implicit none
1303      type(c_ptr), intent(out) :: iwallf, iwalfs, ypluli
1304    end subroutine cs_f_wall_functions_get_pointers
1305
1306    ! Interface to C function retrieving pointers to members of the
1307    ! RANS turbulence model structure
1308
1309    subroutine cs_f_turb_rans_model_get_pointers(irccor, itycor, idirsm, &
1310                                                 iclkep, igrhok, igrake, &
1311                                                 igrari, ikecou, reinit_turb, &
1312                                                 irijco, irijnu,  &
1313                                                 irijrb, irijec, idifre, &
1314                                                 iclsyr, iclptr)         &
1315      bind(C, name='cs_f_turb_rans_model_get_pointers')
1316      use, intrinsic :: iso_c_binding
1317      implicit none
1318      type(c_ptr), intent(out) :: irccor, itycor, idirsm, iclkep, igrhok
1319      type(c_ptr), intent(out) :: igrake, igrari, ikecou, reinit_turb, irijco
1320      type(c_ptr), intent(out) :: irijnu, irijrb
1321      type(c_ptr), intent(out) :: irijec, idifre, iclsyr, iclptr
1322    end subroutine cs_f_turb_rans_model_get_pointers
1323
1324    ! Interface to C function retrieving pointers to members of the
1325    ! LES turbulence model structure
1326
1327    subroutine cs_f_turb_les_model_get_pointers(idries) &
1328      bind(C, name='cs_f_turb_les_model_get_pointers')
1329      use, intrinsic :: iso_c_binding
1330      implicit none
1331      type(c_ptr), intent(out) :: idries
1332    end subroutine cs_f_turb_les_model_get_pointers
1333
1334    ! Interface to C function retrieving pointers to members of the
1335    ! LES balance structure
1336    subroutine cs_f_les_balance_get_pointer(i_les_balance) &
1337      bind(C, name='cs_f_les_balance_get_pointer')
1338      use, intrinsic :: iso_c_binding
1339      implicit none
1340      type(c_ptr), intent(out) :: i_les_balance
1341    end subroutine cs_f_les_balance_get_pointer
1342
1343    ! Interface to C function retrieving pointers to mesh quantity options
1344
1345    subroutine cs_f_porous_model_get_pointers(iporos)  &
1346      bind(C, name='cs_f_porous_model_get_pointers')
1347      use, intrinsic :: iso_c_binding
1348      implicit none
1349      type(c_ptr), intent(out) :: iporos
1350    end subroutine cs_f_porous_model_get_pointers
1351
1352    ! Interface to C function retrieving pointers to members of the
1353    ! velocity pressure model options structure
1354
1355    subroutine cs_f_velocity_pressure_model_get_pointers  &
1356      (ivisse, idilat, fluid_solid, n_buoyant_scal)  &
1357      bind(C, name='cs_f_velocity_pressure_model_get_pointers')
1358      use, intrinsic :: iso_c_binding
1359      implicit none
1360      type(c_ptr), intent(out) :: ivisse, idilat, fluid_solid, n_buoyant_scal
1361    end subroutine cs_f_velocity_pressure_model_get_pointers
1362
1363    ! Interface to C function retrieving pointers to members of the
1364    ! velocity pressure parameters structure
1365
1366    subroutine cs_f_velocity_pressure_param_get_pointers  &
1367      (iphydr, icalhy, iprco, irevmc, iifren, irecmf,  &
1368       igprij, igpust, ipucou, itpcol, arak, rcfact, staggered, nterup, epsup, &
1369       xnrmu, xnrmu0, c_epsdp)  &
1370      bind(C, name='cs_f_velocity_pressure_param_get_pointers')
1371      use, intrinsic :: iso_c_binding
1372      implicit none
1373      type(c_ptr), intent(out) :: iphydr, icalhy, iprco, irevmc, iifren
1374      type(c_ptr), intent(out) :: irecmf, igprij, igpust, ipucou, itpcol
1375      type(c_ptr), intent(out) :: arak, rcfact, staggered, nterup, epsup
1376      type(c_ptr), intent(out) :: xnrmu, xnrmu0, c_epsdp
1377    end subroutine cs_f_velocity_pressure_param_get_pointers
1378
1379    ! Interface to C function retrieving pointers to members of the
1380    ! global spatial discretisation options structure
1381
1382    subroutine cs_f_space_disc_get_pointers(imvisf, imrgra, iflxmw, itbrrb)   &
1383      bind(C, name='cs_f_space_disc_get_pointers')
1384      use, intrinsic :: iso_c_binding
1385      implicit none
1386      type(c_ptr), intent(out) :: imvisf, imrgra, iflxmw, itbrrb
1387    end subroutine cs_f_space_disc_get_pointers
1388
1389    ! Interface to C function retrieving pointers to members of the
1390    ! global time schemeoptions structure
1391
1392    subroutine cs_f_time_scheme_get_pointers(ischtp, isto2t, thetst, iccvfg)  &
1393      bind(C, name='cs_f_time_scheme_get_pointers')
1394      use, intrinsic :: iso_c_binding
1395      implicit none
1396      type(c_ptr), intent(out) :: ischtp, isto2t, thetst, iccvfg
1397    end subroutine cs_f_time_scheme_get_pointers
1398
1399    ! Interface to C function retrieving pointers to members of the
1400    ! global restart_auxiliary options structure
1401
1402    subroutine cs_f_restart_auxiliary_get_pointers(ileaux, iecaux)          &
1403      bind(C, name='cs_f_restart_auxiliary_get_pointers')
1404      use, intrinsic :: iso_c_binding
1405      implicit none
1406      type(c_ptr), intent(out) :: ileaux, iecaux
1407    end subroutine cs_f_restart_auxiliary_get_pointers
1408
1409    ! Interface to C function retrieving pointers to members of the
1410    ! global electric model structure
1411
1412    subroutine cs_f_elec_model_get_pointers(ngazge, ielcor, pot_diff, coejou,  &
1413                                            elcou, couimp, irestrike, ntdcla,  &
1414                                            restrike_point_x,  &
1415                                            restrike_point_y,  &
1416                                            restrike_point_z)  &
1417      bind(C, name='cs_f_elec_model_get_pointers')
1418      use, intrinsic :: iso_c_binding
1419      implicit none
1420      type(c_ptr), intent(out) :: ngazge, ielcor, pot_diff, coejou, elcou
1421      type(c_ptr), intent(out) :: couimp, irestrike, ntdcla, restrike_point_x
1422      type(c_ptr), intent(out) :: restrike_point_y, restrike_point_z
1423    end subroutine cs_f_elec_model_get_pointers
1424
1425    !---------------------------------------------------------------------------
1426
1427    !> (DOXYGEN_SHOULD_SKIP_THIS) \endcond
1428
1429    !---------------------------------------------------------------------------
1430
1431  end interface
1432
1433  !=============================================================================
1434
1435contains
1436
1437  !=============================================================================
1438
1439  !> \brief If scalar iscal represents the mean of the square of a scalar
1440  !> k, return k; otherwise, return 0.
1441
1442  function iscavr(iscal) result(iscvr)
1443
1444    use field
1445    use numvar
1446
1447    implicit none
1448
1449    ! Parameters
1450
1451    integer, intent(in) :: iscal
1452    integer             :: iscvr
1453
1454    ! Local arguments
1455
1456    integer :: f_id
1457    integer :: kscavr = -1
1458    integer :: keysca = -1
1459
1460    ! Function body
1461
1462    iscvr = 0
1463
1464    if (kscavr .lt. 0) then
1465      call field_get_key_id("first_moment_id", kscavr)
1466      call field_get_key_id("scalar_id", keysca)
1467    endif
1468
1469    if (kscavr.ge.0) then
1470      call field_get_key_int(ivarfl(isca(iscal)), kscavr, f_id)
1471      if (f_id.ge.0) call field_get_key_int(f_id, keysca, iscvr)
1472    endif
1473
1474  end function iscavr
1475
1476  !> \brief If scalar iscal represents the mean of the square of a scalar
1477  !> k, return k; otherwise, return 0.
1478
1479  function visls0(iscal) result(visls_0)
1480
1481    use field
1482    use numvar
1483
1484    implicit none
1485
1486    ! Parameters
1487
1488    integer, intent(in) :: iscal
1489    double precision    :: visls_0
1490
1491    call field_get_key_double(ivarfl(isca(iscal)), kvisl0, visls_0)
1492
1493  end function visls0
1494
1495  !> \brief Initialize Fortran time step API.
1496  !> This maps Fortran pointers to global C structure members.
1497
1498  subroutine time_step_init
1499
1500    use, intrinsic :: iso_c_binding
1501    implicit none
1502
1503    ! Local variables
1504
1505    type(c_ptr) :: c_ntpabs, c_ntcabs, c_ntmabs, c_ntinit
1506    type(c_ptr) :: c_dtref, c_ttpabs, c_ttcabs, c_ttmabs
1507
1508    call cs_f_time_step_get_pointers(c_ntpabs, c_ntcabs, c_ntmabs, c_ntinit, &
1509                                     c_dtref, c_ttpabs, c_ttcabs, c_ttmabs)
1510
1511    call c_f_pointer(c_ntpabs, ntpabs)
1512    call c_f_pointer(c_ntcabs, ntcabs)
1513    call c_f_pointer(c_ntmabs, ntmabs)
1514    call c_f_pointer(c_ntinit, ntinit)
1515
1516    call c_f_pointer(c_dtref,  dtref)
1517    call c_f_pointer(c_ttpabs, ttpabs)
1518    call c_f_pointer(c_ttcabs, ttcabs)
1519    call c_f_pointer(c_ttmabs, ttmabs)
1520
1521  end subroutine time_step_init
1522
1523  !> \brief Initialize Fortran time step options API.
1524  !> This maps Fortran pointers to global C structure members.
1525
1526  subroutine time_step_options_init
1527
1528    use, intrinsic :: iso_c_binding
1529    implicit none
1530
1531    ! Local variables
1532
1533    type(c_ptr) :: c_iptlro, c_idtvar
1534    type(c_ptr) :: c_coumax, c_cflmmx
1535    type(c_ptr) :: c_foumax, c_varrdt, c_dtmin
1536    type(c_ptr) :: c_dtmax, c_relxst
1537
1538    call cs_f_time_step_options_get_pointers(c_iptlro, c_idtvar,  &
1539                                             c_coumax, c_cflmmx,  &
1540                                             c_foumax, c_varrdt, c_dtmin,  &
1541                                             c_dtmax, c_relxst)
1542
1543    call c_f_pointer(c_iptlro, iptlro)
1544    call c_f_pointer(c_idtvar, idtvar)
1545    call c_f_pointer(c_coumax, coumax)
1546    call c_f_pointer(c_cflmmx, cflmmx)
1547    call c_f_pointer(c_foumax, foumax)
1548    call c_f_pointer(c_varrdt, varrdt)
1549    call c_f_pointer(c_dtmin,  dtmin)
1550    call c_f_pointer(c_dtmax,  dtmax)
1551    call c_f_pointer(c_relxst, relxst)
1552
1553  end subroutine time_step_options_init
1554
1555  !> \brief Initialize Fortran thermal model API.
1556  !> This maps Fortran pointers to global C structure members.
1557
1558  subroutine thermal_model_init
1559
1560    use, intrinsic :: iso_c_binding
1561    implicit none
1562
1563    ! Local variables
1564
1565    type(c_ptr) :: c_itherm, c_itpscl, c_iscalt
1566
1567    call cs_f_thermal_model_get_pointers(c_itherm, c_itpscl, c_iscalt)
1568
1569    call c_f_pointer(c_itherm, itherm)
1570    call c_f_pointer(c_itpscl, itpscl)
1571    call c_f_pointer(c_iscalt, iscalt)
1572
1573  end subroutine thermal_model_init
1574
1575  !> \brief Initialize Fortran turbulence model API.
1576  !> This maps Fortran pointers to global C structure members.
1577
1578  subroutine turb_model_init
1579
1580    use, intrinsic :: iso_c_binding
1581    use cs_c_bindings
1582    use cdomod
1583    implicit none
1584
1585    ! Local variables
1586
1587    type(c_ptr) :: c_iturb, c_itytur, c_hybrid_turb
1588
1589    if (icdo.lt.2) then
1590      call cs_turb_model_init
1591    endif
1592
1593    call cs_f_turb_model_get_pointers(c_iturb, c_itytur, c_hybrid_turb)
1594
1595    call c_f_pointer(c_iturb, iturb)
1596    call c_f_pointer(c_itytur, itytur)
1597    call c_f_pointer(c_hybrid_turb, hybrid_turb)
1598
1599  end subroutine turb_model_init
1600
1601  !> \brief Initialize Fortran wall functions API.
1602  !> This maps Fortran pointers to global C structure members.
1603
1604  subroutine wall_functions_init
1605
1606    use, intrinsic :: iso_c_binding
1607    use cstphy, only: ypluli
1608    implicit none
1609
1610    ! Local variables
1611
1612    type(c_ptr) :: c_iwallf, c_iwalfs, c_ypluli
1613
1614    call cs_f_wall_functions_get_pointers(c_iwallf, c_iwalfs, &
1615                                          c_ypluli)
1616
1617    call c_f_pointer(c_iwallf, iwallf)
1618    call c_f_pointer(c_iwalfs, iwalfs)
1619    call c_f_pointer(c_ypluli, ypluli)
1620
1621  end subroutine wall_functions_init
1622
1623  !> \brief Initialize Fortran RANS turbulence model API.
1624  !> This maps Fortran pointers to global C structure members.
1625
1626  subroutine turb_rans_model_init
1627
1628    use, intrinsic :: iso_c_binding
1629    implicit none
1630
1631    ! Local variables
1632
1633    type(c_ptr) :: c_irccor, c_itycor, c_idirsm, c_iclkep, c_igrhok, c_igrake
1634    type(c_ptr) :: c_igrari, c_ikecou, c_reinit_turb, c_irijco, c_irijnu
1635    type(c_ptr) :: c_irijrb, c_irijec, c_idifre
1636    type(c_ptr) :: c_iclsyr, c_iclptr
1637
1638    call cs_f_turb_rans_model_get_pointers( c_irccor, c_itycor, c_idirsm, &
1639                                            c_iclkep, c_igrhok, c_igrake, &
1640                                            c_igrari, c_ikecou, c_reinit_turb, &
1641                                            c_irijco, c_irijnu, &
1642                                            c_irijrb, c_irijec, c_idifre, &
1643                                            c_iclsyr, c_iclptr)
1644
1645    call c_f_pointer(c_irccor, irccor)
1646    call c_f_pointer(c_itycor, itycor)
1647    call c_f_pointer(c_idirsm, idirsm)
1648    call c_f_pointer(c_iclkep, iclkep)
1649    call c_f_pointer(c_igrhok, igrhok)
1650    call c_f_pointer(c_igrake, igrake)
1651    call c_f_pointer(c_igrari, igrari)
1652    call c_f_pointer(c_ikecou, ikecou)
1653    call c_f_pointer(c_reinit_turb, reinit_turb)
1654    call c_f_pointer(c_irijco, irijco)
1655    call c_f_pointer(c_irijnu, irijnu)
1656    call c_f_pointer(c_irijrb, irijrb)
1657    call c_f_pointer(c_irijec, irijec)
1658    call c_f_pointer(c_idifre, idifre)
1659    call c_f_pointer(c_iclsyr, iclsyr)
1660    call c_f_pointer(c_iclptr, iclptr)
1661
1662  end subroutine turb_rans_model_init
1663
1664  !> \brief Initialize Fortran LES turbulence model API.
1665  !> This maps Fortran pointers to global C structure members.
1666
1667  subroutine turb_les_model_init
1668
1669    use, intrinsic :: iso_c_binding
1670    implicit none
1671
1672    ! Local variables
1673
1674    type(c_ptr) :: c_idries, c_i_les_balance
1675
1676    call cs_f_turb_les_model_get_pointers(c_idries)
1677    call cs_f_les_balance_get_pointer(c_i_les_balance)
1678
1679    call c_f_pointer(c_idries, idries)
1680    call c_f_pointer(c_i_les_balance, i_les_balance)
1681
1682  end subroutine turb_les_model_init
1683
1684  !> \brief Initialize Fortran Stokes options API.
1685  !> This maps Fortran pointers to global C structure members.
1686
1687  subroutine velocity_pressure_options_init
1688
1689    use, intrinsic :: iso_c_binding
1690    implicit none
1691
1692    ! Local variables
1693
1694    type(c_ptr) :: c_iporos, c_ivisse, c_irevmc, c_iprco, c_arak, c_rcfact, c_staggered
1695    type(c_ptr) :: c_ipucou, c_itpcol, c_idilat, c_epsdp, c_iphydr
1696    type(c_ptr) :: c_igprij, c_igpust, c_iifren, c_icalhy, c_irecmf
1697    type(c_ptr) :: c_fluid_solid
1698    type(c_ptr) :: c_nterup, c_epsup, c_xnrmu, c_xnrmu0, c_n_buoyant_scal
1699
1700    call cs_f_porous_model_get_pointers(c_iporos)
1701
1702    call c_f_pointer(c_iporos, iporos)
1703
1704    call cs_f_velocity_pressure_model_get_pointers  &
1705      (c_ivisse, c_idilat, c_fluid_solid, c_n_buoyant_scal)
1706
1707    call c_f_pointer(c_ivisse, ivisse)
1708    call c_f_pointer(c_idilat, idilat)
1709    call c_f_pointer(c_fluid_solid, fluid_solid)
1710    call c_f_pointer(c_n_buoyant_scal, n_buoyant_scal)
1711
1712    call cs_f_velocity_pressure_param_get_pointers  &
1713      (c_iphydr, c_icalhy, c_iprco, c_irevmc, c_iifren, c_irecmf,  &
1714       c_igprij, c_igpust, c_ipucou, c_itpcol, c_arak, c_rcfact,   &
1715       c_staggered, c_nterup, c_epsup, c_xnrmu, c_xnrmu0, c_epsdp)
1716
1717    call c_f_pointer(c_iphydr, iphydr)
1718    call c_f_pointer(c_icalhy, icalhy)
1719    call c_f_pointer(c_iprco , iprco )
1720    call c_f_pointer(c_irevmc, irevmc)
1721    call c_f_pointer(c_iifren, iifren)
1722    call c_f_pointer(c_irecmf, irecmf)
1723    call c_f_pointer(c_igprij, igprij)
1724    call c_f_pointer(c_igpust, igpust)
1725    call c_f_pointer(c_ipucou, ipucou)
1726    call c_f_pointer(c_itpcol, itpcol)
1727    call c_f_pointer(c_arak  , arak  )
1728    call c_f_pointer(c_rcfact, rcfact)
1729    call c_f_pointer(c_staggered, staggered)
1730    call c_f_pointer(c_nterup, nterup)
1731    call c_f_pointer(c_epsup, epsup)
1732    call c_f_pointer(c_xnrmu, xnrmu)
1733    call c_f_pointer(c_xnrmu0, xnrmu0)
1734    call c_f_pointer(c_epsdp , epsdp )
1735
1736  end subroutine velocity_pressure_options_init
1737
1738  !> \brief Initialize Fortran space discretisation options API.
1739  !> This maps Fortran pointers to global C structure members.
1740
1741  subroutine space_disc_options_init
1742
1743    use, intrinsic :: iso_c_binding
1744    implicit none
1745
1746    ! Local variables
1747
1748    type(c_ptr) :: c_imvisf, c_imrgra, c_iflxmw, c_itbrrb
1749
1750    call cs_f_space_disc_get_pointers(c_imvisf, c_imrgra, c_iflxmw, c_itbrrb)
1751
1752    call c_f_pointer(c_imvisf, imvisf)
1753    call c_f_pointer(c_imrgra, imrgra)
1754    call c_f_pointer(c_iflxmw, iflxmw)
1755    call c_f_pointer(c_itbrrb, itbrrb)
1756
1757  end subroutine space_disc_options_init
1758
1759  !> \brief Initialize Fortran time scheme options API.
1760  !> This maps Fortran pointers to global C structure members.
1761
1762  subroutine time_scheme_options_init
1763
1764    use, intrinsic :: iso_c_binding
1765    implicit none
1766
1767    ! Local variables
1768
1769    type(c_ptr) :: c_ischtp, c_isto2t, c_thetst, c_iccvfg
1770
1771    call cs_f_time_scheme_get_pointers(c_ischtp, c_isto2t, c_thetst, c_iccvfg)
1772
1773    call c_f_pointer(c_ischtp, ischtp)
1774    call c_f_pointer(c_isto2t, isto2t)
1775    call c_f_pointer(c_thetst, thetst)
1776    call c_f_pointer(c_iccvfg, iccvfg)
1777
1778  end subroutine time_scheme_options_init
1779
1780  !> \brief Initialize Fortran auxiliary options API.
1781  !> This maps Fortran pointers to global C structure members.
1782
1783  subroutine restart_auxiliary_options_init
1784
1785    use, intrinsic :: iso_c_binding
1786    implicit none
1787
1788    ! Local variables
1789
1790    type(c_ptr) :: c_ileaux, c_iecaux
1791
1792    call cs_f_restart_auxiliary_get_pointers(c_ileaux, c_iecaux)
1793
1794    call c_f_pointer(c_ileaux, ileaux)
1795    call c_f_pointer(c_iecaux, iecaux)
1796
1797  end subroutine restart_auxiliary_options_init
1798
1799  !> \brief Initialize Fortran ELEC options API.
1800  !> This maps Fortran pointers to global C structure members.
1801
1802  subroutine elec_option_init
1803
1804    use, intrinsic :: iso_c_binding
1805    implicit none
1806
1807    ! Local variables
1808
1809    type(c_ptr) :: c_ngazge, c_ielcor, c_pot_diff, c_coejou, c_couimp
1810    type(c_ptr) :: c_elcou, c_irestrike, c_ntdcla, c_restrike_point_x
1811    type(c_ptr) :: c_restrike_point_y, c_restrike_point_z
1812
1813    call cs_f_elec_model_get_pointers(c_ngazge, c_ielcor, c_pot_diff,  &
1814                                      c_coejou, c_elcou, c_couimp,  &
1815                                      c_irestrike, c_ntdcla,  &
1816                                      c_restrike_point_x, c_restrike_point_y,  &
1817                                      c_restrike_point_z)
1818
1819    call c_f_pointer(c_ngazge,           ngazge)
1820    call c_f_pointer(c_ielcor,           ielcor)
1821    call c_f_pointer(c_pot_diff,         pot_diff)
1822    call c_f_pointer(c_coejou,           coejou)
1823    call c_f_pointer(c_elcou,            elcou)
1824    call c_f_pointer(c_couimp,           couimp)
1825    call c_f_pointer(c_irestrike,        irestrike)
1826    call c_f_pointer(c_ntdcla,           ntdcla)
1827    call c_f_pointer(c_restrike_point_x, restrike_point_x)
1828    call c_f_pointer(c_restrike_point_y, restrike_point_y)
1829    call c_f_pointer(c_restrike_point_z, restrike_point_y)
1830
1831  end subroutine elec_option_init
1832
1833  !=============================================================================
1834
1835end module optcal
1836