ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
initializeFlow_fast_b.f90
Go to the documentation of this file.
1 ! generated by tapenade (inria, ecuador team)
2 ! tapenade 3.16 (develop) - 22 aug 2023 15:51
3 !
5  use constants, only : inttype, realtype, maxstringlen
6  implicit none
7  save
8 
9 contains
10  subroutine referencestate()
11 !
12 ! the original version has been nuked since the computations are
13 ! no longer necessary when calling from python
14 ! this is the most compliclated routine in all of adflow. it is
15 ! stupidly complicated. this is most likely the reason your
16 ! derivatives are wrong. you don't understand this routine
17 ! and its effects.
18 ! this routine *requries* the following as input:
19 ! mach, pinfdim, tinfdim, rhoinfdim, rgasdim (machcoef non-sa
20 ! turbulence only)
21 ! optionally, pref, rhoref and tref are used if they are
22 ! are non-negative. this only happens when you want the equations
23 ! normalized by values other than the freestream
24 ! * this routine computes as output:
25 ! * muinfdim, (unused anywhere in code)
26 ! pref, rhoref, tref, muref, timeref ('dimensional' reference)
27 ! pinf, pinfcorr, rhoinf, uinf, rgas, muinf, gammainf and winf
28 ! (non-dimensionalized values used in actual computations)
29 !
30  use constants
31  use paramturb
32  use inputphysics, only : equations, mach, machcoef, musuthdim, &
40  implicit none
41  integer(kind=inttype) :: sps, nn, mm, ierr
42  real(kind=realtype) :: gm1, ratio
43  real(kind=realtype) :: nuinf, ktmp, uinf2
44  real(kind=realtype) :: vinf, zinf, tmp1(1), tmp2(1)
45  intrinsic sqrt
46 ! compute the dimensional viscosity from sutherland's law
48 & tinfdim/tsuthdim)**1.5_realtype
49 ! set the reference values. they *could* be different from the
50 ! free-stream values for an internal flow simulation. for now,
51 ! we just use the actual free stream values.
52  pref = pinfdim
53  tref = tinfdim
55 ! compute the value of muref, such that the nondimensional
56 ! equations are identical to the dimensional ones.
57 ! note that in the non-dimensionalization of muref there is
58 ! a reference length. however this reference length is 1.0
59 ! in this code, because the coordinates are converted to
60 ! meters.
61  muref = sqrt(pref*rhoref)
62 ! compute timeref for a correct nondimensionalization of the
63 ! unsteady equations. some story as for the reference viscosity
64 ! concerning the reference length.
65  timeref = sqrt(rhoref/pref)
66  href = pref/rhoref
67  uref = sqrt(href)
68 ! compute the nondimensional pressure, density, velocity,
69 ! viscosity and gas constant.
70  pinf = pinfdim/pref
72  uinf = mach*sqrt(gammainf*pinf/rhoinf)
75  tmp1(1) = tinfdim
76  call computegamma(tmp1, tmp2, 1)
77  gammainf = tmp2(1)
78 ! ----------------------------------------
79 ! compute the final winf
80 ! ----------------------------------------
81 ! allocate the memory for winf if necessary
82 ! zero out the winf first
83  winf(:) = zero
84 ! set the reference value of the flow variables, except the total
85 ! energy. this will be computed at the end of this routine.
86  winf(irho) = rhoinf
90 ! compute the velocity squared based on machcoef. this gives a
91 ! better indication of the 'speed' of the flow so the turubulence
92 ! intensity ration is more meaningful especially for moving
93 ! geometries. (not used in sa model)
95 ! set the turbulent variables if transport variables are to be
96 ! solved. we should be checking for rans equations here,
97 ! however, this code is included in block res. the issue is
98 ! that for frozen turbulence (or ank jacobian) we call the
99 ! block_res with equationtype set to laminar even though we are
100 ! actually solving the rans equations. the issue is that, the
101 ! freestream turb variables will be changed to zero, thus
102 ! changing the solution. insteady we check if nw > nwf which
103 ! will accomplish the same thing.
104  if (nw .gt. nwf) then
105  nuinf = muinf/rhoinf
106  select case (turbmodel)
109 !=============================================================
111  winf(itu1) = 1.5_realtype*uinf2*turbintensityinf**2
112  winf(itu2) = winf(itu1)/(eddyvisinfratio*nuinf)
113 !=============================================================
114  case (ktau)
115  winf(itu1) = 1.5_realtype*uinf2*turbintensityinf**2
116  winf(itu2) = eddyvisinfratio*nuinf/winf(itu1)
117 !=============================================================
118  case (v2f)
119  winf(itu1) = 1.5_realtype*uinf2*turbintensityinf**2
120  winf(itu2) = 0.09_realtype*winf(itu1)**2/(eddyvisinfratio*nuinf)
121  winf(itu3) = 0.666666_realtype*winf(itu1)
122  winf(itu4) = 0.0_realtype
123  end select
124  end if
125 ! set the value of pinfcorr. in case a k-equation is present
126 ! add 2/3 times rho*k.
127  pinfcorr = pinf
129 ! compute the free stream total energy.
130  ktmp = zero
131  if (kpresent) ktmp = winf(itu1)
132  vinf = zero
133  zinf = zero
134  call etot(rhoinf, uinf, vinf, zinf, pinfcorr, ktmp, winf(irhoe), &
135 & kpresent)
136  end subroutine referencestate
137 ! ----------------------------------------------------------------------
138 ! |
139 ! no tapenade routine below this line |
140 ! |
141 ! ----------------------------------------------------------------------
142 
143 end module initializeflow_fast_b
144 
integer(kind=inttype), parameter spalartallmarasedwards
Definition: constants.F90:128
integer(kind=inttype), parameter spalartallmaras
Definition: constants.F90:128
real(kind=realtype), parameter zero
Definition: constants.F90:71
integer, parameter itu3
Definition: constants.F90:43
real(kind=realtype), parameter third
Definition: constants.F90:81
integer, parameter itu2
Definition: constants.F90:42
integer(kind=inttype), parameter ktau
Definition: constants.F90:128
integer, parameter itu1
Definition: constants.F90:40
integer, parameter irho
Definition: constants.F90:34
integer(kind=inttype), parameter komegawilcox
Definition: constants.F90:128
integer(kind=inttype), parameter komegamodified
Definition: constants.F90:128
integer, parameter ivx
Definition: constants.F90:35
integer, parameter irhoe
Definition: constants.F90:38
integer, parameter maxstringlen
Definition: constants.F90:16
integer, parameter ivz
Definition: constants.F90:37
real(kind=realtype), parameter two
Definition: constants.F90:73
integer, parameter itu4
Definition: constants.F90:44
integer(kind=inttype), parameter mentersst
Definition: constants.F90:128
integer, parameter ivy
Definition: constants.F90:36
integer(kind=inttype), parameter v2f
Definition: constants.F90:128
subroutine etot(rho, u, v, w, p, k, etotal, correctfork)
subroutine computegamma(t, gamma, mm)
real(kind=realtype) rhoinfdim
real(kind=realtype) muinfdim
real(kind=realtype) gammainf
real(kind=realtype) href
real(kind=realtype) uinf
real(kind=realtype) pinfdim
real(kind=realtype) pinfcorr
real(kind=realtype) pinf
real(kind=realtype) rgas
real(kind=realtype) uref
real(kind=realtype) muref
real(kind=realtype) tinfdim
real(kind=realtype) rhoref
integer(kind=inttype) nwf
real(kind=realtype), dimension(:), allocatable winf
real(kind=realtype) muinf
real(kind=realtype) tref
integer(kind=inttype) nw
real(kind=realtype) rhoinf
real(kind=realtype) pref
real(kind=realtype) timeref
real(kind=realtype) ssuthdim
Definition: inputParam.F90:604
real(kind=realtype) turbintensityinf
Definition: inputParam.F90:597
real(kind=realtype) eddyvisinfratio
Definition: inputParam.F90:597
integer(kind=inttype) equations
Definition: inputParam.F90:583
real(kind=realtype) tsuthdim
Definition: inputParam.F90:604
integer(kind=inttype) turbmodel
Definition: inputParam.F90:584
real(kind=realtype) machcoef
Definition: inputParam.F90:593
real(kind=realtype) mach
Definition: inputParam.F90:593
real(kind=realtype) rgasdim
Definition: inputParam.F90:595
real(kind=realtype), dimension(3) veldirfreestream
Definition: inputParam.F90:599
real(kind=realtype) musuthdim
Definition: inputParam.F90:604
real(kind=realtype) function sanuknowneddyratio(eddyratio, nulam)