ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
sa_d.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 !
4 ! this module contains the source code related to the sa turbulence
5 ! model. it is slightly more modularized than the original which makes
6 ! performing reverse mode ad simplier.
7 module sa_d
8  use constants
9  implicit none
10  real(kind=realtype) :: cv13, kar2inv, cw36, cb3inv
11  real(kind=realtype), dimension(:, :, :), allocatable :: qq
12  real(kind=realtype), dimension(:, :, :), pointer :: ddw, ww, ddvt
13  real(kind=realtype), dimension(:, :), pointer :: rrlv
14  real(kind=realtype), dimension(:, :), pointer :: dd2wall
15 
16 contains
17 ! differentiation of sasource in forward (tangent) mode (with options i4 dr8 r8):
18 ! variations of useful results: *scratch
19 ! with respect to varying inputs: timeref *w *rlv *vol *d2wall
20 ! *si *sj *sk
21 ! rw status of diff variables: timeref:in *w:in *rlv:in *scratch:out
22 ! *vol:in *d2wall:in *si:in *sj:in *sk:in
23 ! plus diff mem management of: w:in rlv:in scratch:in vol:in
24 ! d2wall:in si:in sj:in sk:in
25  subroutine sasource_d()
26 !
27 ! source terms.
28 ! determine the source term and its derivative w.r.t. nutilde
29 ! for all internal cells of the block.
30 ! remember that the sa field variable nutilde = w(i,j,k,itu1)
31  use blockpointers
32  use constants
33  use paramturb
34  use section
35  use inputphysics
36  use inputdiscretization, only : approxsa
37  use flowvarrefstate
38  implicit none
39 ! local parameters
40  real(kind=realtype), parameter :: f23=two*third
41 ! local variables.
42  integer(kind=inttype) :: i, j, k, nn, ii
43  real(kind=realtype) :: fv1, fv2, ft2
44  real(kind=realtype) :: fv1d, fv2d, ft2d
45  real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3
46  real(kind=realtype) :: ssd, sstd, nud, dist2invd, chid, chi2d, chi3d
47  real(kind=realtype) :: rr, gg, gg6, termfw, fwsa, term1, term2
48  real(kind=realtype) :: rrd, ggd, gg6d, termfwd, fwsad, term1d, &
49 & term2d
50  real(kind=realtype) :: dfv1, dfv2, dft2, drr, dgg, dfw
51  real(kind=realtype) :: uux, uuy, uuz, vvx, vvy, vvz, wwx, wwy, wwz
52  real(kind=realtype) :: uuxd, uuyd, uuzd, vvxd, vvyd, vvzd, wwxd, &
53 & wwyd, wwzd
54  real(kind=realtype) :: div2, fact, sxx, syy, szz, sxy, sxz, syz
55  real(kind=realtype) :: div2d, factd, sxxd, syyd, szzd, sxyd, sxzd, &
56 & syzd
57  real(kind=realtype) :: vortx, vorty, vortz
58  real(kind=realtype) :: vortxd, vortyd, vortzd
59  real(kind=realtype) :: omegax, omegay, omegaz
60  real(kind=realtype) :: omegaxd, omegayd, omegazd
61  real(kind=realtype) :: strainmag2, strainprod, vortprod
62  real(kind=realtype) :: strainmag2d, strainprodd, vortprodd
63  real(kind=realtype), parameter :: xminn=1.e-10_realtype
64  intrinsic sqrt
65  intrinsic exp
66  intrinsic min
67  intrinsic max
68  real(kind=realtype) :: y1
69  real(kind=realtype) :: y1d
70  real(kind=realtype) :: min1
71  real(kind=realtype) :: min1d
72  real(kind=realtype) :: temp
73  real(kind=realtype) :: temp0
74  real(kind=realtype) :: temp1
75  real(kind=realtype) :: temp2
76  real(kind=realtype) :: temp3
77  real(kind=realtype) :: temp4
78  real(kind=realtype) :: temp5
79  real(kind=realtype) :: temp6
80  real(kind=realtype) :: temp7
81  real(kind=realtype) :: temp8
82  real(kind=realtype) :: temp9
83  real(kind=realtype) :: temp10
84 ! set model constants
85  cv13 = rsacv1**3
86  kar2inv = one/rsak**2
87  cw36 = rsacw3**6
88  cb3inv = one/rsacb3
89 ! determine the non-dimensional wheel speed of this block.
90  omegaxd = sections(sectionid)%rotrate(1)*timerefd
91  omegax = timeref*sections(sectionid)%rotrate(1)
92  omegayd = sections(sectionid)%rotrate(2)*timerefd
93  omegay = timeref*sections(sectionid)%rotrate(2)
94  omegazd = sections(sectionid)%rotrate(3)*timerefd
95  omegaz = timeref*sections(sectionid)%rotrate(3)
96 ! create switches to production term depending on the variable that
97 ! should be used
98  if (turbprod .eq. katolaunder) then
99  print*, 'katolaunder production term not supported for sa'
100  stop
101  else
102  if (associated(scratchd)) scratchd = 0.0_8
103  strainmag2d = 0.0_8
104  ssd = 0.0_8
105  do k=2,kl
106  do j=2,jl
107  do i=2,il
108 ! compute the gradient of u in the cell center. use is made
109 ! of the fact that the surrounding normals sum up to zero,
110 ! such that the cell i,j,k does not give a contribution.
111 ! the gradient is scaled by the factor 2*vol.
112  temp = si(i, j, k, 1)
113  temp0 = w(i+1, j, k, ivx)
114  temp1 = si(i-1, j, k, 1)
115  temp2 = w(i-1, j, k, ivx)
116  temp3 = sj(i, j, k, 1)
117  temp4 = w(i, j+1, k, ivx)
118  temp5 = sk(i, j, k, 1)
119  temp6 = w(i, j, k+1, ivx)
120  temp7 = sj(i, j-1, k, 1)
121  temp8 = w(i, j-1, k, ivx)
122  temp9 = sk(i, j, k-1, 1)
123  temp10 = w(i, j, k-1, ivx)
124  uuxd = temp*wd(i+1, j, k, ivx) + temp0*sid(i, j, k, 1) - &
125 & temp1*wd(i-1, j, k, ivx) - temp2*sid(i-1, j, k, 1) + temp3&
126 & *wd(i, j+1, k, ivx) + temp4*sjd(i, j, k, 1) + temp5*wd(i, &
127 & j, k+1, ivx) + temp6*skd(i, j, k, 1) - temp7*wd(i, j-1, k&
128 & , ivx) - temp8*sjd(i, j-1, k, 1) - temp9*wd(i, j, k-1, ivx&
129 & ) - temp10*skd(i, j, k-1, 1)
130  uux = temp0*temp - temp2*temp1 + temp4*temp3 + temp6*temp5 -&
131 & temp8*temp7 - temp10*temp9
132  temp10 = si(i, j, k, 2)
133  temp9 = w(i+1, j, k, ivx)
134  temp8 = si(i-1, j, k, 2)
135  temp7 = w(i-1, j, k, ivx)
136  temp6 = sj(i, j, k, 2)
137  temp5 = w(i, j+1, k, ivx)
138  temp4 = sk(i, j, k, 2)
139  temp3 = w(i, j, k+1, ivx)
140  temp2 = sj(i, j-1, k, 2)
141  temp1 = w(i, j-1, k, ivx)
142  temp0 = sk(i, j, k-1, 2)
143  temp = w(i, j, k-1, ivx)
144  uuyd = temp10*wd(i+1, j, k, ivx) + temp9*sid(i, j, k, 2) - &
145 & temp8*wd(i-1, j, k, ivx) - temp7*sid(i-1, j, k, 2) + temp6&
146 & *wd(i, j+1, k, ivx) + temp5*sjd(i, j, k, 2) + temp4*wd(i, &
147 & j, k+1, ivx) + temp3*skd(i, j, k, 2) - temp2*wd(i, j-1, k&
148 & , ivx) - temp1*sjd(i, j-1, k, 2) - temp0*wd(i, j, k-1, ivx&
149 & ) - temp*skd(i, j, k-1, 2)
150  uuy = temp9*temp10 - temp7*temp8 + temp5*temp6 + temp3*temp4&
151 & - temp1*temp2 - temp*temp0
152  temp10 = si(i, j, k, 3)
153  temp9 = w(i+1, j, k, ivx)
154  temp8 = si(i-1, j, k, 3)
155  temp7 = w(i-1, j, k, ivx)
156  temp6 = sj(i, j, k, 3)
157  temp5 = w(i, j+1, k, ivx)
158  temp4 = sk(i, j, k, 3)
159  temp3 = w(i, j, k+1, ivx)
160  temp2 = sj(i, j-1, k, 3)
161  temp1 = w(i, j-1, k, ivx)
162  temp0 = sk(i, j, k-1, 3)
163  temp = w(i, j, k-1, ivx)
164  uuzd = temp10*wd(i+1, j, k, ivx) + temp9*sid(i, j, k, 3) - &
165 & temp8*wd(i-1, j, k, ivx) - temp7*sid(i-1, j, k, 3) + temp6&
166 & *wd(i, j+1, k, ivx) + temp5*sjd(i, j, k, 3) + temp4*wd(i, &
167 & j, k+1, ivx) + temp3*skd(i, j, k, 3) - temp2*wd(i, j-1, k&
168 & , ivx) - temp1*sjd(i, j-1, k, 3) - temp0*wd(i, j, k-1, ivx&
169 & ) - temp*skd(i, j, k-1, 3)
170  uuz = temp9*temp10 - temp7*temp8 + temp5*temp6 + temp3*temp4&
171 & - temp1*temp2 - temp*temp0
172 ! idem for the gradient of v.
173  temp10 = si(i, j, k, 1)
174  temp9 = w(i+1, j, k, ivy)
175  temp8 = si(i-1, j, k, 1)
176  temp7 = w(i-1, j, k, ivy)
177  temp6 = sj(i, j, k, 1)
178  temp5 = w(i, j+1, k, ivy)
179  temp4 = sk(i, j, k, 1)
180  temp3 = w(i, j, k+1, ivy)
181  temp2 = sj(i, j-1, k, 1)
182  temp1 = w(i, j-1, k, ivy)
183  temp0 = sk(i, j, k-1, 1)
184  temp = w(i, j, k-1, ivy)
185  vvxd = temp10*wd(i+1, j, k, ivy) + temp9*sid(i, j, k, 1) - &
186 & temp8*wd(i-1, j, k, ivy) - temp7*sid(i-1, j, k, 1) + temp6&
187 & *wd(i, j+1, k, ivy) + temp5*sjd(i, j, k, 1) + temp4*wd(i, &
188 & j, k+1, ivy) + temp3*skd(i, j, k, 1) - temp2*wd(i, j-1, k&
189 & , ivy) - temp1*sjd(i, j-1, k, 1) - temp0*wd(i, j, k-1, ivy&
190 & ) - temp*skd(i, j, k-1, 1)
191  vvx = temp9*temp10 - temp7*temp8 + temp5*temp6 + temp3*temp4&
192 & - temp1*temp2 - temp*temp0
193  temp10 = si(i, j, k, 2)
194  temp9 = w(i+1, j, k, ivy)
195  temp8 = si(i-1, j, k, 2)
196  temp7 = w(i-1, j, k, ivy)
197  temp6 = sj(i, j, k, 2)
198  temp5 = w(i, j+1, k, ivy)
199  temp4 = sk(i, j, k, 2)
200  temp3 = w(i, j, k+1, ivy)
201  temp2 = sj(i, j-1, k, 2)
202  temp1 = w(i, j-1, k, ivy)
203  temp0 = sk(i, j, k-1, 2)
204  temp = w(i, j, k-1, ivy)
205  vvyd = temp10*wd(i+1, j, k, ivy) + temp9*sid(i, j, k, 2) - &
206 & temp8*wd(i-1, j, k, ivy) - temp7*sid(i-1, j, k, 2) + temp6&
207 & *wd(i, j+1, k, ivy) + temp5*sjd(i, j, k, 2) + temp4*wd(i, &
208 & j, k+1, ivy) + temp3*skd(i, j, k, 2) - temp2*wd(i, j-1, k&
209 & , ivy) - temp1*sjd(i, j-1, k, 2) - temp0*wd(i, j, k-1, ivy&
210 & ) - temp*skd(i, j, k-1, 2)
211  vvy = temp9*temp10 - temp7*temp8 + temp5*temp6 + temp3*temp4&
212 & - temp1*temp2 - temp*temp0
213  temp10 = si(i, j, k, 3)
214  temp9 = w(i+1, j, k, ivy)
215  temp8 = si(i-1, j, k, 3)
216  temp7 = w(i-1, j, k, ivy)
217  temp6 = sj(i, j, k, 3)
218  temp5 = w(i, j+1, k, ivy)
219  temp4 = sk(i, j, k, 3)
220  temp3 = w(i, j, k+1, ivy)
221  temp2 = sj(i, j-1, k, 3)
222  temp1 = w(i, j-1, k, ivy)
223  temp0 = sk(i, j, k-1, 3)
224  temp = w(i, j, k-1, ivy)
225  vvzd = temp10*wd(i+1, j, k, ivy) + temp9*sid(i, j, k, 3) - &
226 & temp8*wd(i-1, j, k, ivy) - temp7*sid(i-1, j, k, 3) + temp6&
227 & *wd(i, j+1, k, ivy) + temp5*sjd(i, j, k, 3) + temp4*wd(i, &
228 & j, k+1, ivy) + temp3*skd(i, j, k, 3) - temp2*wd(i, j-1, k&
229 & , ivy) - temp1*sjd(i, j-1, k, 3) - temp0*wd(i, j, k-1, ivy&
230 & ) - temp*skd(i, j, k-1, 3)
231  vvz = temp9*temp10 - temp7*temp8 + temp5*temp6 + temp3*temp4&
232 & - temp1*temp2 - temp*temp0
233 ! and for the gradient of w.
234  temp10 = si(i, j, k, 1)
235  temp9 = w(i+1, j, k, ivz)
236  temp8 = si(i-1, j, k, 1)
237  temp7 = w(i-1, j, k, ivz)
238  temp6 = sj(i, j, k, 1)
239  temp5 = w(i, j+1, k, ivz)
240  temp4 = sk(i, j, k, 1)
241  temp3 = w(i, j, k+1, ivz)
242  temp2 = sj(i, j-1, k, 1)
243  temp1 = w(i, j-1, k, ivz)
244  temp0 = sk(i, j, k-1, 1)
245  temp = w(i, j, k-1, ivz)
246  wwxd = temp10*wd(i+1, j, k, ivz) + temp9*sid(i, j, k, 1) - &
247 & temp8*wd(i-1, j, k, ivz) - temp7*sid(i-1, j, k, 1) + temp6&
248 & *wd(i, j+1, k, ivz) + temp5*sjd(i, j, k, 1) + temp4*wd(i, &
249 & j, k+1, ivz) + temp3*skd(i, j, k, 1) - temp2*wd(i, j-1, k&
250 & , ivz) - temp1*sjd(i, j-1, k, 1) - temp0*wd(i, j, k-1, ivz&
251 & ) - temp*skd(i, j, k-1, 1)
252  wwx = temp9*temp10 - temp7*temp8 + temp5*temp6 + temp3*temp4&
253 & - temp1*temp2 - temp*temp0
254  temp10 = si(i, j, k, 2)
255  temp9 = w(i+1, j, k, ivz)
256  temp8 = si(i-1, j, k, 2)
257  temp7 = w(i-1, j, k, ivz)
258  temp6 = sj(i, j, k, 2)
259  temp5 = w(i, j+1, k, ivz)
260  temp4 = sk(i, j, k, 2)
261  temp3 = w(i, j, k+1, ivz)
262  temp2 = sj(i, j-1, k, 2)
263  temp1 = w(i, j-1, k, ivz)
264  temp0 = sk(i, j, k-1, 2)
265  temp = w(i, j, k-1, ivz)
266  wwyd = temp10*wd(i+1, j, k, ivz) + temp9*sid(i, j, k, 2) - &
267 & temp8*wd(i-1, j, k, ivz) - temp7*sid(i-1, j, k, 2) + temp6&
268 & *wd(i, j+1, k, ivz) + temp5*sjd(i, j, k, 2) + temp4*wd(i, &
269 & j, k+1, ivz) + temp3*skd(i, j, k, 2) - temp2*wd(i, j-1, k&
270 & , ivz) - temp1*sjd(i, j-1, k, 2) - temp0*wd(i, j, k-1, ivz&
271 & ) - temp*skd(i, j, k-1, 2)
272  wwy = temp9*temp10 - temp7*temp8 + temp5*temp6 + temp3*temp4&
273 & - temp1*temp2 - temp*temp0
274  temp10 = si(i, j, k, 3)
275  temp9 = w(i+1, j, k, ivz)
276  temp8 = si(i-1, j, k, 3)
277  temp7 = w(i-1, j, k, ivz)
278  temp6 = sj(i, j, k, 3)
279  temp5 = w(i, j+1, k, ivz)
280  temp4 = sk(i, j, k, 3)
281  temp3 = w(i, j, k+1, ivz)
282  temp2 = sj(i, j-1, k, 3)
283  temp1 = w(i, j-1, k, ivz)
284  temp0 = sk(i, j, k-1, 3)
285  temp = w(i, j, k-1, ivz)
286  wwzd = temp10*wd(i+1, j, k, ivz) + temp9*sid(i, j, k, 3) - &
287 & temp8*wd(i-1, j, k, ivz) - temp7*sid(i-1, j, k, 3) + temp6&
288 & *wd(i, j+1, k, ivz) + temp5*sjd(i, j, k, 3) + temp4*wd(i, &
289 & j, k+1, ivz) + temp3*skd(i, j, k, 3) - temp2*wd(i, j-1, k&
290 & , ivz) - temp1*sjd(i, j-1, k, 3) - temp0*wd(i, j, k-1, ivz&
291 & ) - temp*skd(i, j, k-1, 3)
292  wwz = temp9*temp10 - temp7*temp8 + temp5*temp6 + temp3*temp4&
293 & - temp1*temp2 - temp*temp0
294 ! compute the components of the stress tensor.
295 ! the combination of the current scaling of the velocity
296 ! gradients (2*vol) and the definition of the stress tensor,
297 ! leads to the factor 1/(4*vol).
298  temp10 = fourth/vol(i, j, k)
299  factd = -(temp10*vold(i, j, k)/vol(i, j, k))
300  fact = temp10
301  if (turbprod .eq. strain) then
302  sxxd = two*(uux*factd+fact*uuxd)
303  sxx = two*fact*uux
304  syyd = two*(vvy*factd+fact*vvyd)
305  syy = two*fact*vvy
306  szzd = two*(wwz*factd+fact*wwzd)
307  szz = two*fact*wwz
308  sxyd = (uuy+vvx)*factd + fact*(uuyd+vvxd)
309  sxy = fact*(uuy+vvx)
310  sxzd = (uuz+wwx)*factd + fact*(uuzd+wwxd)
311  sxz = fact*(uuz+wwx)
312  syzd = (vvz+wwy)*factd + fact*(vvzd+wwyd)
313  syz = fact*(vvz+wwy)
314 ! compute 2/3 * divergence of velocity squared
315  div2d = f23*2*(sxx+syy+szz)*(sxxd+syyd+szzd)
316  div2 = f23*(sxx+syy+szz)**2
317 ! compute strain production term
318  strainmag2d = two*(2*sxy*sxyd+2*sxz*sxzd+2*syz*syzd) + 2*&
319 & sxx*sxxd + 2*syy*syyd + 2*szz*szzd
320  strainmag2 = two*(sxy**2+sxz**2+syz**2) + sxx**2 + syy**2 &
321 & + szz**2
322  strainprodd = two*strainmag2d - div2d
323  strainprod = two*strainmag2 - div2
324  temp10 = sqrt(strainprod)
325  if (strainprod .eq. 0.0_8) then
326  ssd = 0.0_8
327  else
328  ssd = strainprodd/(2.0*temp10)
329  end if
330  ss = temp10
331  else if (turbprod .eq. vorticity) then
332 ! compute the three components of the vorticity vector.
333 ! substract the part coming from the rotating frame.
334  vortxd = two*((wwy-vvz)*factd+fact*(wwyd-vvzd)) - two*&
335 & omegaxd
336  vortx = two*fact*(wwy-vvz) - two*omegax
337  vortyd = two*((uuz-wwx)*factd+fact*(uuzd-wwxd)) - two*&
338 & omegayd
339  vorty = two*fact*(uuz-wwx) - two*omegay
340  vortzd = two*((vvx-uuy)*factd+fact*(vvxd-uuyd)) - two*&
341 & omegazd
342  vortz = two*fact*(vvx-uuy) - two*omegaz
343 ! compute the vorticity production term
344  vortprodd = 2*vortx*vortxd + 2*vorty*vortyd + 2*vortz*&
345 & vortzd
346  vortprod = vortx**2 + vorty**2 + vortz**2
347 ! first take the square root of the production term to
348 ! obtain the correct production term for spalart-allmaras.
349 ! we do this to avoid if statements.
350  temp10 = sqrt(vortprod)
351  if (vortprod .eq. 0.0_8) then
352  ssd = 0.0_8
353  else
354  ssd = vortprodd/(2.0*temp10)
355  end if
356  ss = temp10
357  end if
358 ! compute the laminar kinematic viscosity, the inverse of
359 ! wall distance squared, the ratio chi (ratio of nutilde
360 ! and nu) and the functions fv1 and fv2. the latter corrects
361 ! the production term near a viscous wall.
362  temp10 = w(i, j, k, irho)
363  temp9 = rlv(i, j, k)/temp10
364  nud = (rlvd(i, j, k)-temp9*wd(i, j, k, irho))/temp10
365  nu = temp9
366  temp10 = one/(d2wall(i, j, k)*d2wall(i, j, k))
367  dist2invd = -(temp10*2*d2walld(i, j, k)/d2wall(i, j, k))
368  dist2inv = temp10
369  temp10 = w(i, j, k, itu1)/nu
370  chid = (wd(i, j, k, itu1)-temp10*nud)/nu
371  chi = temp10
372  chi2d = 2*chi*chid
373  chi2 = chi*chi
374  chi3d = chi2*chid + chi*chi2d
375  chi3 = chi*chi2
376  temp10 = chi3/(cv13+chi3)
377  fv1d = (1.0-temp10)*chi3d/(cv13+chi3)
378  fv1 = temp10
379  temp10 = chi/(one+chi*fv1)
380  fv2d = -((chid-temp10*(fv1*chid+chi*fv1d))/(one+chi*fv1))
381  fv2 = one - temp10
382 ! the function ft2, which is designed to keep a laminar
383 ! solution laminar. when running in fully turbulent mode
384 ! this function should be set to 0.0.
385  if (useft2sa) then
386  ft2d = -(rsact3*exp(-(rsact4*chi2))*rsact4*chi2d)
387  ft2 = rsact3*exp(-(rsact4*chi2))
388  else
389  ft2 = zero
390  ft2d = 0.0_8
391  end if
392 ! correct the production term to account for the influence
393 ! of the wall.
394  temp10 = w(i, j, k, itu1)
395  sstd = ssd + kar2inv*(fv2*dist2inv*wd(i, j, k, itu1)+temp10*&
396 & (dist2inv*fv2d+fv2*dist2invd))
397  sst = ss + kar2inv*(temp10*(fv2*dist2inv))
398 ! add rotation term (userotationsa defined in inputparams.f90)
399  if (userotationsa) then
400  temp10 = sqrt(two*strainmag2)
401  if (two*strainmag2 .eq. 0.0_8) then
402  y1d = 0.0_8
403  else
404  y1d = two*strainmag2d/(2.0*temp10)
405  end if
406  y1 = temp10
407  if (zero .gt. y1) then
408  min1d = y1d
409  min1 = y1
410  else
411  min1 = zero
412  min1d = 0.0_8
413  end if
414  sstd = sstd + rsacrot*min1d
415  sst = sst + rsacrot*min1
416  end if
417  if (sst .lt. xminn) then
418  sst = xminn
419  sstd = 0.0_8
420  else
421  sst = sst
422  end if
423 ! compute the function fw. the argument rr is cut off at 10
424 ! to avoid numerical problems. this is ok, because the
425 ! asymptotical value of fw is then already reached.
426  temp10 = dist2inv/sst
427  temp9 = w(i, j, k, itu1)
428  rrd = kar2inv*(temp10*wd(i, j, k, itu1)+temp9*(dist2invd-&
429 & temp10*sstd)/sst)
430  rr = kar2inv*(temp9*temp10)
431  if (rr .gt. 10.0_realtype) then
432  rr = 10.0_realtype
433  rrd = 0.0_8
434  else
435  rr = rr
436  end if
437  ggd = (rsacw2*(6*rr**5-1.0)+1.0)*rrd
438  gg = rr + rsacw2*(rr**6-rr)
439  gg6d = 6*gg**5*ggd
440  gg6 = gg**6
441  temp10 = (one+cw36)/(cw36+gg6)
442  if (temp10 .le. 0.0_8 .and. (sixth .eq. 0.0_8 .or. sixth &
443 & .ne. int(sixth))) then
444  termfwd = 0.0_8
445  else
446  termfwd = -(sixth*temp10**(sixth-1)*temp10*gg6d/(cw36+gg6)&
447 & )
448  end if
449  termfw = temp10**sixth
450  fwsad = termfw*ggd + gg*termfwd
451  fwsa = gg*termfw
452 ! compute the source term; some terms are saved for the
453 ! linearization. the source term is stored in dvt.
454  if (approxsa) then
455  term1 = zero
456  term1d = 0.0_8
457  else
458  term1d = rsacb1*((one-ft2)*ssd-ss*ft2d)
459  term1 = rsacb1*(one-ft2)*ss
460  end if
461  temp10 = kar2inv*rsacb1*((one-ft2)*fv2+ft2) - rsacw1*fwsa
462  term2d = temp10*dist2invd + dist2inv*(kar2inv*rsacb1*((one-&
463 & ft2)*fv2d-(fv2-1.0)*ft2d)-rsacw1*fwsad)
464  term2 = dist2inv*temp10
465  temp10 = w(i, j, k, itu1)
466  temp9 = w(i, j, k, itu1)
467  scratchd(i, j, k, idvt) = temp10*(term1d+temp9*term2d+term2*&
468 & wd(i, j, k, itu1)) + (term1+term2*temp9)*wd(i, j, k, itu1)
469  scratch(i, j, k, idvt) = (term1+term2*temp9)*temp10
470  end do
471  end do
472  end do
473  end if
474  end subroutine sasource_d
475 
476  subroutine sasource()
477 !
478 ! source terms.
479 ! determine the source term and its derivative w.r.t. nutilde
480 ! for all internal cells of the block.
481 ! remember that the sa field variable nutilde = w(i,j,k,itu1)
482  use blockpointers
483  use constants
484  use paramturb
485  use section
486  use inputphysics
487  use inputdiscretization, only : approxsa
488  use flowvarrefstate
489  implicit none
490 ! local parameters
491  real(kind=realtype), parameter :: f23=two*third
492 ! local variables.
493  integer(kind=inttype) :: i, j, k, nn, ii
494  real(kind=realtype) :: fv1, fv2, ft2
495  real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3
496  real(kind=realtype) :: rr, gg, gg6, termfw, fwsa, term1, term2
497  real(kind=realtype) :: dfv1, dfv2, dft2, drr, dgg, dfw
498  real(kind=realtype) :: uux, uuy, uuz, vvx, vvy, vvz, wwx, wwy, wwz
499  real(kind=realtype) :: div2, fact, sxx, syy, szz, sxy, sxz, syz
500  real(kind=realtype) :: vortx, vorty, vortz
501  real(kind=realtype) :: omegax, omegay, omegaz
502  real(kind=realtype) :: strainmag2, strainprod, vortprod
503  real(kind=realtype), parameter :: xminn=1.e-10_realtype
504  intrinsic sqrt
505  intrinsic exp
506  intrinsic min
507  intrinsic max
508  real(kind=realtype) :: y1
509  real(kind=realtype) :: min1
510 ! set model constants
511  cv13 = rsacv1**3
512  kar2inv = one/rsak**2
513  cw36 = rsacw3**6
514  cb3inv = one/rsacb3
515 ! determine the non-dimensional wheel speed of this block.
516  omegax = timeref*sections(sectionid)%rotrate(1)
517  omegay = timeref*sections(sectionid)%rotrate(2)
518  omegaz = timeref*sections(sectionid)%rotrate(3)
519 ! create switches to production term depending on the variable that
520 ! should be used
521  if (turbprod .eq. katolaunder) then
522  print*, 'katolaunder production term not supported for sa'
523  stop
524  else
525  do k=2,kl
526  do j=2,jl
527  do i=2,il
528 ! compute the gradient of u in the cell center. use is made
529 ! of the fact that the surrounding normals sum up to zero,
530 ! such that the cell i,j,k does not give a contribution.
531 ! the gradient is scaled by the factor 2*vol.
532  uux = w(i+1, j, k, ivx)*si(i, j, k, 1) - w(i-1, j, k, ivx)*&
533 & si(i-1, j, k, 1) + w(i, j+1, k, ivx)*sj(i, j, k, 1) - w(i&
534 & , j-1, k, ivx)*sj(i, j-1, k, 1) + w(i, j, k+1, ivx)*sk(i, &
535 & j, k, 1) - w(i, j, k-1, ivx)*sk(i, j, k-1, 1)
536  uuy = w(i+1, j, k, ivx)*si(i, j, k, 2) - w(i-1, j, k, ivx)*&
537 & si(i-1, j, k, 2) + w(i, j+1, k, ivx)*sj(i, j, k, 2) - w(i&
538 & , j-1, k, ivx)*sj(i, j-1, k, 2) + w(i, j, k+1, ivx)*sk(i, &
539 & j, k, 2) - w(i, j, k-1, ivx)*sk(i, j, k-1, 2)
540  uuz = w(i+1, j, k, ivx)*si(i, j, k, 3) - w(i-1, j, k, ivx)*&
541 & si(i-1, j, k, 3) + w(i, j+1, k, ivx)*sj(i, j, k, 3) - w(i&
542 & , j-1, k, ivx)*sj(i, j-1, k, 3) + w(i, j, k+1, ivx)*sk(i, &
543 & j, k, 3) - w(i, j, k-1, ivx)*sk(i, j, k-1, 3)
544 ! idem for the gradient of v.
545  vvx = w(i+1, j, k, ivy)*si(i, j, k, 1) - w(i-1, j, k, ivy)*&
546 & si(i-1, j, k, 1) + w(i, j+1, k, ivy)*sj(i, j, k, 1) - w(i&
547 & , j-1, k, ivy)*sj(i, j-1, k, 1) + w(i, j, k+1, ivy)*sk(i, &
548 & j, k, 1) - w(i, j, k-1, ivy)*sk(i, j, k-1, 1)
549  vvy = w(i+1, j, k, ivy)*si(i, j, k, 2) - w(i-1, j, k, ivy)*&
550 & si(i-1, j, k, 2) + w(i, j+1, k, ivy)*sj(i, j, k, 2) - w(i&
551 & , j-1, k, ivy)*sj(i, j-1, k, 2) + w(i, j, k+1, ivy)*sk(i, &
552 & j, k, 2) - w(i, j, k-1, ivy)*sk(i, j, k-1, 2)
553  vvz = w(i+1, j, k, ivy)*si(i, j, k, 3) - w(i-1, j, k, ivy)*&
554 & si(i-1, j, k, 3) + w(i, j+1, k, ivy)*sj(i, j, k, 3) - w(i&
555 & , j-1, k, ivy)*sj(i, j-1, k, 3) + w(i, j, k+1, ivy)*sk(i, &
556 & j, k, 3) - w(i, j, k-1, ivy)*sk(i, j, k-1, 3)
557 ! and for the gradient of w.
558  wwx = w(i+1, j, k, ivz)*si(i, j, k, 1) - w(i-1, j, k, ivz)*&
559 & si(i-1, j, k, 1) + w(i, j+1, k, ivz)*sj(i, j, k, 1) - w(i&
560 & , j-1, k, ivz)*sj(i, j-1, k, 1) + w(i, j, k+1, ivz)*sk(i, &
561 & j, k, 1) - w(i, j, k-1, ivz)*sk(i, j, k-1, 1)
562  wwy = w(i+1, j, k, ivz)*si(i, j, k, 2) - w(i-1, j, k, ivz)*&
563 & si(i-1, j, k, 2) + w(i, j+1, k, ivz)*sj(i, j, k, 2) - w(i&
564 & , j-1, k, ivz)*sj(i, j-1, k, 2) + w(i, j, k+1, ivz)*sk(i, &
565 & j, k, 2) - w(i, j, k-1, ivz)*sk(i, j, k-1, 2)
566  wwz = w(i+1, j, k, ivz)*si(i, j, k, 3) - w(i-1, j, k, ivz)*&
567 & si(i-1, j, k, 3) + w(i, j+1, k, ivz)*sj(i, j, k, 3) - w(i&
568 & , j-1, k, ivz)*sj(i, j-1, k, 3) + w(i, j, k+1, ivz)*sk(i, &
569 & j, k, 3) - w(i, j, k-1, ivz)*sk(i, j, k-1, 3)
570 ! compute the components of the stress tensor.
571 ! the combination of the current scaling of the velocity
572 ! gradients (2*vol) and the definition of the stress tensor,
573 ! leads to the factor 1/(4*vol).
574  fact = fourth/vol(i, j, k)
575  if (turbprod .eq. strain) then
576  sxx = two*fact*uux
577  syy = two*fact*vvy
578  szz = two*fact*wwz
579  sxy = fact*(uuy+vvx)
580  sxz = fact*(uuz+wwx)
581  syz = fact*(vvz+wwy)
582 ! compute 2/3 * divergence of velocity squared
583  div2 = f23*(sxx+syy+szz)**2
584 ! compute strain production term
585  strainmag2 = two*(sxy**2+sxz**2+syz**2) + sxx**2 + syy**2 &
586 & + szz**2
587  strainprod = two*strainmag2 - div2
588  ss = sqrt(strainprod)
589  else if (turbprod .eq. vorticity) then
590 ! compute the three components of the vorticity vector.
591 ! substract the part coming from the rotating frame.
592  vortx = two*fact*(wwy-vvz) - two*omegax
593  vorty = two*fact*(uuz-wwx) - two*omegay
594  vortz = two*fact*(vvx-uuy) - two*omegaz
595 ! compute the vorticity production term
596  vortprod = vortx**2 + vorty**2 + vortz**2
597 ! first take the square root of the production term to
598 ! obtain the correct production term for spalart-allmaras.
599 ! we do this to avoid if statements.
600  ss = sqrt(vortprod)
601  end if
602 ! compute the laminar kinematic viscosity, the inverse of
603 ! wall distance squared, the ratio chi (ratio of nutilde
604 ! and nu) and the functions fv1 and fv2. the latter corrects
605 ! the production term near a viscous wall.
606  nu = rlv(i, j, k)/w(i, j, k, irho)
607  dist2inv = one/d2wall(i, j, k)**2
608  chi = w(i, j, k, itu1)/nu
609  chi2 = chi*chi
610  chi3 = chi*chi2
611  fv1 = chi3/(chi3+cv13)
612  fv2 = one - chi/(one+chi*fv1)
613 ! the function ft2, which is designed to keep a laminar
614 ! solution laminar. when running in fully turbulent mode
615 ! this function should be set to 0.0.
616  if (useft2sa) then
617  ft2 = rsact3*exp(-(rsact4*chi2))
618  else
619  ft2 = zero
620  end if
621 ! correct the production term to account for the influence
622 ! of the wall.
623  sst = ss + w(i, j, k, itu1)*fv2*kar2inv*dist2inv
624 ! add rotation term (userotationsa defined in inputparams.f90)
625  if (userotationsa) then
626  y1 = sqrt(two*strainmag2)
627  if (zero .gt. y1) then
628  min1 = y1
629  else
630  min1 = zero
631  end if
632  sst = sst + rsacrot*min1
633  end if
634  if (sst .lt. xminn) then
635  sst = xminn
636  else
637  sst = sst
638  end if
639 ! compute the function fw. the argument rr is cut off at 10
640 ! to avoid numerical problems. this is ok, because the
641 ! asymptotical value of fw is then already reached.
642  rr = w(i, j, k, itu1)*kar2inv*dist2inv/sst
643  if (rr .gt. 10.0_realtype) then
644  rr = 10.0_realtype
645  else
646  rr = rr
647  end if
648  gg = rr + rsacw2*(rr**6-rr)
649  gg6 = gg**6
650  termfw = ((one+cw36)/(gg6+cw36))**sixth
651  fwsa = gg*termfw
652 ! compute the source term; some terms are saved for the
653 ! linearization. the source term is stored in dvt.
654  if (approxsa) then
655  term1 = zero
656  else
657  term1 = rsacb1*(one-ft2)*ss
658  end if
659  term2 = dist2inv*(kar2inv*rsacb1*((one-ft2)*fv2+ft2)-rsacw1*&
660 & fwsa)
661  scratch(i, j, k, idvt) = (term1+term2*w(i, j, k, itu1))*w(i&
662 & , j, k, itu1)
663  end do
664  end do
665  end do
666  end if
667  end subroutine sasource
668 
669 ! differentiation of saviscous in forward (tangent) mode (with options i4 dr8 r8):
670 ! variations of useful results: *scratch
671 ! with respect to varying inputs: *w *rlv *scratch *vol *si *sj
672 ! *sk
673 ! rw status of diff variables: *w:in *rlv:in *scratch:in-out
674 ! *vol:in *si:in *sj:in *sk:in
675 ! plus diff mem management of: w:in rlv:in scratch:in vol:in
676 ! si:in sj:in sk:in
677  subroutine saviscous_d()
678 !
679 ! viscous term.
680 ! determine the viscous contribution to the residual
681 ! for all internal cells of the block.
682  use blockpointers
683  use paramturb
684  implicit none
685 ! local variables.
686  integer(kind=inttype) :: i, j, k, nn, ii
687  real(kind=realtype) :: nu
688  real(kind=realtype) :: nud
689  real(kind=realtype) :: fv1, fv2, ft2
690  real(kind=realtype) :: voli, volmi, volpi, xm, ym, zm, xp, yp, zp
691  real(kind=realtype) :: volid, volmid, volpid, xmd, ymd, zmd, xpd, &
692 & ypd, zpd
693  real(kind=realtype) :: xa, ya, za, ttm, ttp, cnud, cam, cap
694  real(kind=realtype) :: xad, yad, zad, ttmd, ttpd, cnudd, camd, capd
695  real(kind=realtype) :: nutm, nutp, num, nup, cdm, cdp
696  real(kind=realtype) :: nutmd, nutpd, numd, nupd, cdmd, cdpd
697  real(kind=realtype) :: c1m, c1p, c10, b1, c1, d1, qs
698  real(kind=realtype) :: c1md, c1pd, c10d
699  intrinsic max
700  real(kind=realtype) :: temp
701  real(kind=realtype) :: temp0
702  real(kind=realtype) :: temp1
703 ! set model constants
704  cv13 = rsacv1**3
705  kar2inv = one/rsak**2
706  cw36 = rsacw3**6
707  cb3inv = one/rsacb3
708 !
709 ! viscous terms in k-direction.
710 !
711  do k=2,kl
712  do j=2,jl
713  do i=2,il
714 ! compute the metrics in zeta-direction, i.e. along the
715 ! line k = constant.
716  temp = one/vol(i, j, k)
717  volid = -(temp*vold(i, j, k)/vol(i, j, k))
718  voli = temp
719  temp = two/(vol(i, j, k)+vol(i, j, k-1))
720  volmid = -(temp*(vold(i, j, k)+vold(i, j, k-1))/(vol(i, j, k)+&
721 & vol(i, j, k-1)))
722  volmi = temp
723  temp = two/(vol(i, j, k)+vol(i, j, k+1))
724  volpid = -(temp*(vold(i, j, k)+vold(i, j, k+1))/(vol(i, j, k)+&
725 & vol(i, j, k+1)))
726  volpi = temp
727  temp = sk(i, j, k-1, 1)
728  xmd = volmi*skd(i, j, k-1, 1) + temp*volmid
729  xm = temp*volmi
730  temp = sk(i, j, k-1, 2)
731  ymd = volmi*skd(i, j, k-1, 2) + temp*volmid
732  ym = temp*volmi
733  temp = sk(i, j, k-1, 3)
734  zmd = volmi*skd(i, j, k-1, 3) + temp*volmid
735  zm = temp*volmi
736  temp = sk(i, j, k, 1)
737  xpd = volpi*skd(i, j, k, 1) + temp*volpid
738  xp = temp*volpi
739  temp = sk(i, j, k, 2)
740  ypd = volpi*skd(i, j, k, 2) + temp*volpid
741  yp = temp*volpi
742  temp = sk(i, j, k, 3)
743  zpd = volpi*skd(i, j, k, 3) + temp*volpid
744  zp = temp*volpi
745  temp = sk(i, j, k, 1) + sk(i, j, k-1, 1)
746  xad = half*(voli*(skd(i, j, k, 1)+skd(i, j, k-1, 1))+temp*&
747 & volid)
748  xa = half*(temp*voli)
749  temp = sk(i, j, k, 2) + sk(i, j, k-1, 2)
750  yad = half*(voli*(skd(i, j, k, 2)+skd(i, j, k-1, 2))+temp*&
751 & volid)
752  ya = half*(temp*voli)
753  temp = sk(i, j, k, 3) + sk(i, j, k-1, 3)
754  zad = half*(voli*(skd(i, j, k, 3)+skd(i, j, k-1, 3))+temp*&
755 & volid)
756  za = half*(temp*voli)
757  ttmd = xa*xmd + xm*xad + ya*ymd + ym*yad + za*zmd + zm*zad
758  ttm = xm*xa + ym*ya + zm*za
759  ttpd = xa*xpd + xp*xad + ya*ypd + yp*yad + za*zpd + zp*zad
760  ttp = xp*xa + yp*ya + zp*za
761 ! ttm and ttp ~ 1/deltax^2
762 ! computation of the viscous terms in zeta-direction; note
763 ! that cross-derivatives are neglected, i.e. the mesh is
764 ! assumed to be orthogonal.
765 ! furthermore, the grad(nu)**2 has been rewritten as
766 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
767 ! the second derivative in zeta-direction is constructed as
768 ! the central difference of the first order derivatives, i.e.
769 ! d^2/dzeta^2 = d/dzeta (d/dzeta k+1/2 - d/dzeta k-1/2).
770 ! in this way the metric can be taken into account.
771 ! compute the diffusion coefficients multiplying the nodes
772 ! k+1, k and k-1 in the second derivative. make sure that
773 ! these coefficients are nonnegative.
774  cnudd = -(rsacb2*cb3inv*wd(i, j, k, itu1))
775  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
776  camd = cnud*ttmd + ttm*cnudd
777  cam = ttm*cnud
778  capd = cnud*ttpd + ttp*cnudd
779  cap = ttp*cnud
780 ! compute nutilde at the faces
781  nutmd = half*(wd(i, j, k-1, itu1)+wd(i, j, k, itu1))
782  nutm = half*(w(i, j, k-1, itu1)+w(i, j, k, itu1))
783  nutpd = half*(wd(i, j, k+1, itu1)+wd(i, j, k, itu1))
784  nutp = half*(w(i, j, k+1, itu1)+w(i, j, k, itu1))
785 ! compute nu at the faces
786  temp = w(i, j, k, irho)
787  temp0 = rlv(i, j, k)/temp
788  nud = (rlvd(i, j, k)-temp0*wd(i, j, k, irho))/temp
789  nu = temp0
790  temp0 = w(i, j, k-1, irho)
791  temp = rlv(i, j, k-1)/temp0
792  numd = half*((rlvd(i, j, k-1)-temp*wd(i, j, k-1, irho))/temp0+&
793 & nud)
794  num = half*(temp+nu)
795  temp0 = w(i, j, k+1, irho)
796  temp = rlv(i, j, k+1)/temp0
797  nupd = half*((rlvd(i, j, k+1)-temp*wd(i, j, k+1, irho))/temp0+&
798 & nud)
799  nup = half*(temp+nu)
800  temp0 = num + (one+rsacb2)*nutm
801  cdmd = cb3inv*(ttm*(numd+(one+rsacb2)*nutmd)+temp0*ttmd)
802  cdm = cb3inv*(temp0*ttm)
803  temp0 = nup + (one+rsacb2)*nutp
804  cdpd = cb3inv*(ttp*(nupd+(one+rsacb2)*nutpd)+temp0*ttpd)
805  cdp = cb3inv*(temp0*ttp)
806  if (cdm + cam .lt. zero) then
807  c1m = zero
808  c1md = 0.0_8
809  else
810  c1md = cdmd + camd
811  c1m = cdm + cam
812  end if
813  if (cdp + cap .lt. zero) then
814  c1p = zero
815  c1pd = 0.0_8
816  else
817  c1pd = cdpd + capd
818  c1p = cdp + cap
819  end if
820  c10d = c1md + c1pd
821  c10 = c1m + c1p
822 ! update the residual for this cell and store the possible
823 ! coefficients for the matrix in b1, c1 and d1.
824  temp0 = w(i, j, k-1, itu1)
825  temp = w(i, j, k+1, itu1)
826  temp1 = w(i, j, k, itu1)
827  scratchd(i, j, k, idvt) = scratchd(i, j, k, idvt) + temp0*c1md&
828 & + c1m*wd(i, j, k-1, itu1) + temp*c1pd + c1p*wd(i, j, k+1, &
829 & itu1) - temp1*c10d - c10*wd(i, j, k, itu1)
830  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*temp0 + &
831 & c1p*temp - c10*temp1
832  end do
833  end do
834  end do
835 !
836 ! viscous terms in j-direction.
837 !
838  do k=2,kl
839  do j=2,jl
840  do i=2,il
841 ! compute the metrics in eta-direction, i.e. along the
842 ! line j = constant.
843  temp1 = one/vol(i, j, k)
844  volid = -(temp1*vold(i, j, k)/vol(i, j, k))
845  voli = temp1
846  temp1 = two/(vol(i, j, k)+vol(i, j-1, k))
847  volmid = -(temp1*(vold(i, j, k)+vold(i, j-1, k))/(vol(i, j, k)&
848 & +vol(i, j-1, k)))
849  volmi = temp1
850  temp1 = two/(vol(i, j, k)+vol(i, j+1, k))
851  volpid = -(temp1*(vold(i, j, k)+vold(i, j+1, k))/(vol(i, j, k)&
852 & +vol(i, j+1, k)))
853  volpi = temp1
854  temp1 = sj(i, j-1, k, 1)
855  xmd = volmi*sjd(i, j-1, k, 1) + temp1*volmid
856  xm = temp1*volmi
857  temp1 = sj(i, j-1, k, 2)
858  ymd = volmi*sjd(i, j-1, k, 2) + temp1*volmid
859  ym = temp1*volmi
860  temp1 = sj(i, j-1, k, 3)
861  zmd = volmi*sjd(i, j-1, k, 3) + temp1*volmid
862  zm = temp1*volmi
863  temp1 = sj(i, j, k, 1)
864  xpd = volpi*sjd(i, j, k, 1) + temp1*volpid
865  xp = temp1*volpi
866  temp1 = sj(i, j, k, 2)
867  ypd = volpi*sjd(i, j, k, 2) + temp1*volpid
868  yp = temp1*volpi
869  temp1 = sj(i, j, k, 3)
870  zpd = volpi*sjd(i, j, k, 3) + temp1*volpid
871  zp = temp1*volpi
872  temp1 = sj(i, j, k, 1) + sj(i, j-1, k, 1)
873  xad = half*(voli*(sjd(i, j, k, 1)+sjd(i, j-1, k, 1))+temp1*&
874 & volid)
875  xa = half*(temp1*voli)
876  temp1 = sj(i, j, k, 2) + sj(i, j-1, k, 2)
877  yad = half*(voli*(sjd(i, j, k, 2)+sjd(i, j-1, k, 2))+temp1*&
878 & volid)
879  ya = half*(temp1*voli)
880  temp1 = sj(i, j, k, 3) + sj(i, j-1, k, 3)
881  zad = half*(voli*(sjd(i, j, k, 3)+sjd(i, j-1, k, 3))+temp1*&
882 & volid)
883  za = half*(temp1*voli)
884  ttmd = xa*xmd + xm*xad + ya*ymd + ym*yad + za*zmd + zm*zad
885  ttm = xm*xa + ym*ya + zm*za
886  ttpd = xa*xpd + xp*xad + ya*ypd + yp*yad + za*zpd + zp*zad
887  ttp = xp*xa + yp*ya + zp*za
888 ! computation of the viscous terms in eta-direction; note
889 ! that cross-derivatives are neglected, i.e. the mesh is
890 ! assumed to be orthogonal.
891 ! furthermore, the grad(nu)**2 has been rewritten as
892 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
893 ! the second derivative in eta-direction is constructed as
894 ! the central difference of the first order derivatives, i.e.
895 ! d^2/deta^2 = d/deta (d/deta j+1/2 - d/deta j-1/2).
896 ! in this way the metric can be taken into account.
897 ! compute the diffusion coefficients multiplying the nodes
898 ! j+1, j and j-1 in the second derivative. make sure that
899 ! these coefficients are nonnegative.
900  cnudd = -(rsacb2*cb3inv*wd(i, j, k, itu1))
901  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
902  camd = cnud*ttmd + ttm*cnudd
903  cam = ttm*cnud
904  capd = cnud*ttpd + ttp*cnudd
905  cap = ttp*cnud
906  nutmd = half*(wd(i, j-1, k, itu1)+wd(i, j, k, itu1))
907  nutm = half*(w(i, j-1, k, itu1)+w(i, j, k, itu1))
908  nutpd = half*(wd(i, j+1, k, itu1)+wd(i, j, k, itu1))
909  nutp = half*(w(i, j+1, k, itu1)+w(i, j, k, itu1))
910  temp1 = w(i, j, k, irho)
911  temp0 = rlv(i, j, k)/temp1
912  nud = (rlvd(i, j, k)-temp0*wd(i, j, k, irho))/temp1
913  nu = temp0
914  temp1 = w(i, j-1, k, irho)
915  temp0 = rlv(i, j-1, k)/temp1
916  numd = half*((rlvd(i, j-1, k)-temp0*wd(i, j-1, k, irho))/temp1&
917 & +nud)
918  num = half*(temp0+nu)
919  temp1 = w(i, j+1, k, irho)
920  temp0 = rlv(i, j+1, k)/temp1
921  nupd = half*((rlvd(i, j+1, k)-temp0*wd(i, j+1, k, irho))/temp1&
922 & +nud)
923  nup = half*(temp0+nu)
924  temp1 = num + (one+rsacb2)*nutm
925  cdmd = cb3inv*(ttm*(numd+(one+rsacb2)*nutmd)+temp1*ttmd)
926  cdm = cb3inv*(temp1*ttm)
927  temp1 = nup + (one+rsacb2)*nutp
928  cdpd = cb3inv*(ttp*(nupd+(one+rsacb2)*nutpd)+temp1*ttpd)
929  cdp = cb3inv*(temp1*ttp)
930  if (cdm + cam .lt. zero) then
931  c1m = zero
932  c1md = 0.0_8
933  else
934  c1md = cdmd + camd
935  c1m = cdm + cam
936  end if
937  if (cdp + cap .lt. zero) then
938  c1p = zero
939  c1pd = 0.0_8
940  else
941  c1pd = cdpd + capd
942  c1p = cdp + cap
943  end if
944  c10d = c1md + c1pd
945  c10 = c1m + c1p
946 ! update the residual for this cell and store the possible
947 ! coefficients for the matrix in b1, c1 and d1.
948  temp1 = w(i, j-1, k, itu1)
949  temp0 = w(i, j+1, k, itu1)
950  temp = w(i, j, k, itu1)
951  scratchd(i, j, k, idvt) = scratchd(i, j, k, idvt) + temp1*c1md&
952 & + c1m*wd(i, j-1, k, itu1) + temp0*c1pd + c1p*wd(i, j+1, k, &
953 & itu1) - temp*c10d - c10*wd(i, j, k, itu1)
954  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*temp1 + &
955 & c1p*temp0 - c10*temp
956  end do
957  end do
958  end do
959 !
960 ! viscous terms in i-direction.
961 !
962  do k=2,kl
963  do j=2,jl
964  do i=2,il
965 ! compute the metrics in xi-direction, i.e. along the
966 ! line i = constant.
967  temp1 = one/vol(i, j, k)
968  volid = -(temp1*vold(i, j, k)/vol(i, j, k))
969  voli = temp1
970  temp1 = two/(vol(i, j, k)+vol(i-1, j, k))
971  volmid = -(temp1*(vold(i, j, k)+vold(i-1, j, k))/(vol(i, j, k)&
972 & +vol(i-1, j, k)))
973  volmi = temp1
974  temp1 = two/(vol(i, j, k)+vol(i+1, j, k))
975  volpid = -(temp1*(vold(i, j, k)+vold(i+1, j, k))/(vol(i, j, k)&
976 & +vol(i+1, j, k)))
977  volpi = temp1
978  temp1 = si(i-1, j, k, 1)
979  xmd = volmi*sid(i-1, j, k, 1) + temp1*volmid
980  xm = temp1*volmi
981  temp1 = si(i-1, j, k, 2)
982  ymd = volmi*sid(i-1, j, k, 2) + temp1*volmid
983  ym = temp1*volmi
984  temp1 = si(i-1, j, k, 3)
985  zmd = volmi*sid(i-1, j, k, 3) + temp1*volmid
986  zm = temp1*volmi
987  temp1 = si(i, j, k, 1)
988  xpd = volpi*sid(i, j, k, 1) + temp1*volpid
989  xp = temp1*volpi
990  temp1 = si(i, j, k, 2)
991  ypd = volpi*sid(i, j, k, 2) + temp1*volpid
992  yp = temp1*volpi
993  temp1 = si(i, j, k, 3)
994  zpd = volpi*sid(i, j, k, 3) + temp1*volpid
995  zp = temp1*volpi
996  temp1 = si(i, j, k, 1) + si(i-1, j, k, 1)
997  xad = half*(voli*(sid(i, j, k, 1)+sid(i-1, j, k, 1))+temp1*&
998 & volid)
999  xa = half*(temp1*voli)
1000  temp1 = si(i, j, k, 2) + si(i-1, j, k, 2)
1001  yad = half*(voli*(sid(i, j, k, 2)+sid(i-1, j, k, 2))+temp1*&
1002 & volid)
1003  ya = half*(temp1*voli)
1004  temp1 = si(i, j, k, 3) + si(i-1, j, k, 3)
1005  zad = half*(voli*(sid(i, j, k, 3)+sid(i-1, j, k, 3))+temp1*&
1006 & volid)
1007  za = half*(temp1*voli)
1008  ttmd = xa*xmd + xm*xad + ya*ymd + ym*yad + za*zmd + zm*zad
1009  ttm = xm*xa + ym*ya + zm*za
1010  ttpd = xa*xpd + xp*xad + ya*ypd + yp*yad + za*zpd + zp*zad
1011  ttp = xp*xa + yp*ya + zp*za
1012 ! computation of the viscous terms in xi-direction; note
1013 ! that cross-derivatives are neglected, i.e. the mesh is
1014 ! assumed to be orthogonal.
1015 ! furthermore, the grad(nu)**2 has been rewritten as
1016 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
1017 ! the second derivative in xi-direction is constructed as
1018 ! the central difference of the first order derivatives, i.e.
1019 ! d^2/dxi^2 = d/dxi (d/dxi i+1/2 - d/dxi i-1/2).
1020 ! in this way the metric can be taken into account.
1021 ! compute the diffusion coefficients multiplying the nodes
1022 ! i+1, i and i-1 in the second derivative. make sure that
1023 ! these coefficients are nonnegative.
1024  cnudd = -(rsacb2*cb3inv*wd(i, j, k, itu1))
1025  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
1026  camd = cnud*ttmd + ttm*cnudd
1027  cam = ttm*cnud
1028  capd = cnud*ttpd + ttp*cnudd
1029  cap = ttp*cnud
1030  nutmd = half*(wd(i-1, j, k, itu1)+wd(i, j, k, itu1))
1031  nutm = half*(w(i-1, j, k, itu1)+w(i, j, k, itu1))
1032  nutpd = half*(wd(i+1, j, k, itu1)+wd(i, j, k, itu1))
1033  nutp = half*(w(i+1, j, k, itu1)+w(i, j, k, itu1))
1034  temp1 = w(i, j, k, irho)
1035  temp0 = rlv(i, j, k)/temp1
1036  nud = (rlvd(i, j, k)-temp0*wd(i, j, k, irho))/temp1
1037  nu = temp0
1038  temp1 = w(i-1, j, k, irho)
1039  temp0 = rlv(i-1, j, k)/temp1
1040  numd = half*((rlvd(i-1, j, k)-temp0*wd(i-1, j, k, irho))/temp1&
1041 & +nud)
1042  num = half*(temp0+nu)
1043  temp1 = w(i+1, j, k, irho)
1044  temp0 = rlv(i+1, j, k)/temp1
1045  nupd = half*((rlvd(i+1, j, k)-temp0*wd(i+1, j, k, irho))/temp1&
1046 & +nud)
1047  nup = half*(temp0+nu)
1048  temp1 = num + (one+rsacb2)*nutm
1049  cdmd = cb3inv*(ttm*(numd+(one+rsacb2)*nutmd)+temp1*ttmd)
1050  cdm = cb3inv*(temp1*ttm)
1051  temp1 = nup + (one+rsacb2)*nutp
1052  cdpd = cb3inv*(ttp*(nupd+(one+rsacb2)*nutpd)+temp1*ttpd)
1053  cdp = cb3inv*(temp1*ttp)
1054  if (cdm + cam .lt. zero) then
1055  c1m = zero
1056  c1md = 0.0_8
1057  else
1058  c1md = cdmd + camd
1059  c1m = cdm + cam
1060  end if
1061  if (cdp + cap .lt. zero) then
1062  c1p = zero
1063  c1pd = 0.0_8
1064  else
1065  c1pd = cdpd + capd
1066  c1p = cdp + cap
1067  end if
1068  c10d = c1md + c1pd
1069  c10 = c1m + c1p
1070 ! update the residual for this cell and store the possible
1071 ! coefficients for the matrix in b1, c1 and d1.
1072  temp1 = w(i-1, j, k, itu1)
1073  temp0 = w(i+1, j, k, itu1)
1074  temp = w(i, j, k, itu1)
1075  scratchd(i, j, k, idvt) = scratchd(i, j, k, idvt) + temp1*c1md&
1076 & + c1m*wd(i-1, j, k, itu1) + temp0*c1pd + c1p*wd(i+1, j, k, &
1077 & itu1) - temp*c10d - c10*wd(i, j, k, itu1)
1078  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*temp1 + &
1079 & c1p*temp0 - c10*temp
1080  end do
1081  end do
1082  end do
1083  end subroutine saviscous_d
1084 
1085  subroutine saviscous()
1086 !
1087 ! viscous term.
1088 ! determine the viscous contribution to the residual
1089 ! for all internal cells of the block.
1090  use blockpointers
1091  use paramturb
1092  implicit none
1093 ! local variables.
1094  integer(kind=inttype) :: i, j, k, nn, ii
1095  real(kind=realtype) :: nu
1096  real(kind=realtype) :: fv1, fv2, ft2
1097  real(kind=realtype) :: voli, volmi, volpi, xm, ym, zm, xp, yp, zp
1098  real(kind=realtype) :: xa, ya, za, ttm, ttp, cnud, cam, cap
1099  real(kind=realtype) :: nutm, nutp, num, nup, cdm, cdp
1100  real(kind=realtype) :: c1m, c1p, c10, b1, c1, d1, qs
1101  intrinsic max
1102 ! set model constants
1103  cv13 = rsacv1**3
1104  kar2inv = one/rsak**2
1105  cw36 = rsacw3**6
1106  cb3inv = one/rsacb3
1107 !
1108 ! viscous terms in k-direction.
1109 !
1110  do k=2,kl
1111  do j=2,jl
1112  do i=2,il
1113 ! compute the metrics in zeta-direction, i.e. along the
1114 ! line k = constant.
1115  voli = one/vol(i, j, k)
1116  volmi = two/(vol(i, j, k)+vol(i, j, k-1))
1117  volpi = two/(vol(i, j, k)+vol(i, j, k+1))
1118  xm = sk(i, j, k-1, 1)*volmi
1119  ym = sk(i, j, k-1, 2)*volmi
1120  zm = sk(i, j, k-1, 3)*volmi
1121  xp = sk(i, j, k, 1)*volpi
1122  yp = sk(i, j, k, 2)*volpi
1123  zp = sk(i, j, k, 3)*volpi
1124  xa = half*(sk(i, j, k, 1)+sk(i, j, k-1, 1))*voli
1125  ya = half*(sk(i, j, k, 2)+sk(i, j, k-1, 2))*voli
1126  za = half*(sk(i, j, k, 3)+sk(i, j, k-1, 3))*voli
1127  ttm = xm*xa + ym*ya + zm*za
1128  ttp = xp*xa + yp*ya + zp*za
1129 ! ttm and ttp ~ 1/deltax^2
1130 ! computation of the viscous terms in zeta-direction; note
1131 ! that cross-derivatives are neglected, i.e. the mesh is
1132 ! assumed to be orthogonal.
1133 ! furthermore, the grad(nu)**2 has been rewritten as
1134 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
1135 ! the second derivative in zeta-direction is constructed as
1136 ! the central difference of the first order derivatives, i.e.
1137 ! d^2/dzeta^2 = d/dzeta (d/dzeta k+1/2 - d/dzeta k-1/2).
1138 ! in this way the metric can be taken into account.
1139 ! compute the diffusion coefficients multiplying the nodes
1140 ! k+1, k and k-1 in the second derivative. make sure that
1141 ! these coefficients are nonnegative.
1142  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
1143  cam = ttm*cnud
1144  cap = ttp*cnud
1145 ! compute nutilde at the faces
1146  nutm = half*(w(i, j, k-1, itu1)+w(i, j, k, itu1))
1147  nutp = half*(w(i, j, k+1, itu1)+w(i, j, k, itu1))
1148 ! compute nu at the faces
1149  nu = rlv(i, j, k)/w(i, j, k, irho)
1150  num = half*(rlv(i, j, k-1)/w(i, j, k-1, irho)+nu)
1151  nup = half*(rlv(i, j, k+1)/w(i, j, k+1, irho)+nu)
1152  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
1153  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
1154  if (cdm + cam .lt. zero) then
1155  c1m = zero
1156  else
1157  c1m = cdm + cam
1158  end if
1159  if (cdp + cap .lt. zero) then
1160  c1p = zero
1161  else
1162  c1p = cdp + cap
1163  end if
1164  c10 = c1m + c1p
1165 ! update the residual for this cell and store the possible
1166 ! coefficients for the matrix in b1, c1 and d1.
1167  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*w(i, j, &
1168 & k-1, itu1) - c10*w(i, j, k, itu1) + c1p*w(i, j, k+1, itu1)
1169  end do
1170  end do
1171  end do
1172 !
1173 ! viscous terms in j-direction.
1174 !
1175  do k=2,kl
1176  do j=2,jl
1177  do i=2,il
1178 ! compute the metrics in eta-direction, i.e. along the
1179 ! line j = constant.
1180  voli = one/vol(i, j, k)
1181  volmi = two/(vol(i, j, k)+vol(i, j-1, k))
1182  volpi = two/(vol(i, j, k)+vol(i, j+1, k))
1183  xm = sj(i, j-1, k, 1)*volmi
1184  ym = sj(i, j-1, k, 2)*volmi
1185  zm = sj(i, j-1, k, 3)*volmi
1186  xp = sj(i, j, k, 1)*volpi
1187  yp = sj(i, j, k, 2)*volpi
1188  zp = sj(i, j, k, 3)*volpi
1189  xa = half*(sj(i, j, k, 1)+sj(i, j-1, k, 1))*voli
1190  ya = half*(sj(i, j, k, 2)+sj(i, j-1, k, 2))*voli
1191  za = half*(sj(i, j, k, 3)+sj(i, j-1, k, 3))*voli
1192  ttm = xm*xa + ym*ya + zm*za
1193  ttp = xp*xa + yp*ya + zp*za
1194 ! computation of the viscous terms in eta-direction; note
1195 ! that cross-derivatives are neglected, i.e. the mesh is
1196 ! assumed to be orthogonal.
1197 ! furthermore, the grad(nu)**2 has been rewritten as
1198 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
1199 ! the second derivative in eta-direction is constructed as
1200 ! the central difference of the first order derivatives, i.e.
1201 ! d^2/deta^2 = d/deta (d/deta j+1/2 - d/deta j-1/2).
1202 ! in this way the metric can be taken into account.
1203 ! compute the diffusion coefficients multiplying the nodes
1204 ! j+1, j and j-1 in the second derivative. make sure that
1205 ! these coefficients are nonnegative.
1206  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
1207  cam = ttm*cnud
1208  cap = ttp*cnud
1209  nutm = half*(w(i, j-1, k, itu1)+w(i, j, k, itu1))
1210  nutp = half*(w(i, j+1, k, itu1)+w(i, j, k, itu1))
1211  nu = rlv(i, j, k)/w(i, j, k, irho)
1212  num = half*(rlv(i, j-1, k)/w(i, j-1, k, irho)+nu)
1213  nup = half*(rlv(i, j+1, k)/w(i, j+1, k, irho)+nu)
1214  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
1215  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
1216  if (cdm + cam .lt. zero) then
1217  c1m = zero
1218  else
1219  c1m = cdm + cam
1220  end if
1221  if (cdp + cap .lt. zero) then
1222  c1p = zero
1223  else
1224  c1p = cdp + cap
1225  end if
1226  c10 = c1m + c1p
1227 ! update the residual for this cell and store the possible
1228 ! coefficients for the matrix in b1, c1 and d1.
1229  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*w(i, j-1&
1230 & , k, itu1) - c10*w(i, j, k, itu1) + c1p*w(i, j+1, k, itu1)
1231  end do
1232  end do
1233  end do
1234 !
1235 ! viscous terms in i-direction.
1236 !
1237  do k=2,kl
1238  do j=2,jl
1239  do i=2,il
1240 ! compute the metrics in xi-direction, i.e. along the
1241 ! line i = constant.
1242  voli = one/vol(i, j, k)
1243  volmi = two/(vol(i, j, k)+vol(i-1, j, k))
1244  volpi = two/(vol(i, j, k)+vol(i+1, j, k))
1245  xm = si(i-1, j, k, 1)*volmi
1246  ym = si(i-1, j, k, 2)*volmi
1247  zm = si(i-1, j, k, 3)*volmi
1248  xp = si(i, j, k, 1)*volpi
1249  yp = si(i, j, k, 2)*volpi
1250  zp = si(i, j, k, 3)*volpi
1251  xa = half*(si(i, j, k, 1)+si(i-1, j, k, 1))*voli
1252  ya = half*(si(i, j, k, 2)+si(i-1, j, k, 2))*voli
1253  za = half*(si(i, j, k, 3)+si(i-1, j, k, 3))*voli
1254  ttm = xm*xa + ym*ya + zm*za
1255  ttp = xp*xa + yp*ya + zp*za
1256 ! computation of the viscous terms in xi-direction; note
1257 ! that cross-derivatives are neglected, i.e. the mesh is
1258 ! assumed to be orthogonal.
1259 ! furthermore, the grad(nu)**2 has been rewritten as
1260 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
1261 ! the second derivative in xi-direction is constructed as
1262 ! the central difference of the first order derivatives, i.e.
1263 ! d^2/dxi^2 = d/dxi (d/dxi i+1/2 - d/dxi i-1/2).
1264 ! in this way the metric can be taken into account.
1265 ! compute the diffusion coefficients multiplying the nodes
1266 ! i+1, i and i-1 in the second derivative. make sure that
1267 ! these coefficients are nonnegative.
1268  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
1269  cam = ttm*cnud
1270  cap = ttp*cnud
1271  nutm = half*(w(i-1, j, k, itu1)+w(i, j, k, itu1))
1272  nutp = half*(w(i+1, j, k, itu1)+w(i, j, k, itu1))
1273  nu = rlv(i, j, k)/w(i, j, k, irho)
1274  num = half*(rlv(i-1, j, k)/w(i-1, j, k, irho)+nu)
1275  nup = half*(rlv(i+1, j, k)/w(i+1, j, k, irho)+nu)
1276  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
1277  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
1278  if (cdm + cam .lt. zero) then
1279  c1m = zero
1280  else
1281  c1m = cdm + cam
1282  end if
1283  if (cdp + cap .lt. zero) then
1284  c1p = zero
1285  else
1286  c1p = cdp + cap
1287  end if
1288  c10 = c1m + c1p
1289 ! update the residual for this cell and store the possible
1290 ! coefficients for the matrix in b1, c1 and d1.
1291  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*w(i-1, j&
1292 & , k, itu1) - c10*w(i, j, k, itu1) + c1p*w(i+1, j, k, itu1)
1293  end do
1294  end do
1295  end do
1296  end subroutine saviscous
1297 
1298 ! differentiation of saresscale in forward (tangent) mode (with options i4 dr8 r8):
1299 ! variations of useful results: *dw
1300 ! with respect to varying inputs: *dw *scratch
1301 ! rw status of diff variables: *dw:in-out *scratch:in
1302 ! plus diff mem management of: dw:in scratch:in
1303  subroutine saresscale_d()
1304 !
1305 ! multiply the residual by the volume and store this in dw; this
1306 ! * is done for monitoring reasons only. the multiplication with the
1307 ! * volume is present to be consistent with the flow residuals; also
1308 ! the negative value is taken, again to be consistent with the
1309 ! * flow equations. also multiply by iblank so that no updates occur
1310 ! in holes or the overset boundary.
1311  use blockpointers
1312  implicit none
1313 ! local variables
1314  integer(kind=inttype) :: i, j, k, ii
1315  real(kind=realtype) :: rblank
1316  intrinsic real
1317  intrinsic max
1318  real(realtype) :: x1
1319  real(kind=realtype) :: temp
1320  do k=2,kl
1321  do j=2,jl
1322  do i=2,il
1323  x1 = real(iblank(i, j, k), realtype)
1324  if (x1 .lt. zero) then
1325  rblank = zero
1326  else
1327  rblank = x1
1328  end if
1329  temp = volref(i, j, k)*rblank
1330  dwd(i, j, k, itu1) = -(temp*scratchd(i, j, k, idvt))
1331  dw(i, j, k, itu1) = -(temp*scratch(i, j, k, idvt))
1332  end do
1333  end do
1334  end do
1335  end subroutine saresscale_d
1336 
1337  subroutine saresscale()
1338 !
1339 ! multiply the residual by the volume and store this in dw; this
1340 ! * is done for monitoring reasons only. the multiplication with the
1341 ! * volume is present to be consistent with the flow residuals; also
1342 ! the negative value is taken, again to be consistent with the
1343 ! * flow equations. also multiply by iblank so that no updates occur
1344 ! in holes or the overset boundary.
1345  use blockpointers
1346  implicit none
1347 ! local variables
1348  integer(kind=inttype) :: i, j, k, ii
1349  real(kind=realtype) :: rblank
1350  intrinsic real
1351  intrinsic max
1352  real(realtype) :: x1
1353  do k=2,kl
1354  do j=2,jl
1355  do i=2,il
1356  x1 = real(iblank(i, j, k), realtype)
1357  if (x1 .lt. zero) then
1358  rblank = zero
1359  else
1360  rblank = x1
1361  end if
1362  dw(i, j, k, itu1) = -(volref(i, j, k)*scratch(i, j, k, idvt)*&
1363 & rblank)
1364  end do
1365  end do
1366  end do
1367  end subroutine saresscale
1368 
1369 end module sa_d
1370 
integer(kind=inttype) jl
real(kind=realtype), dimension(:, :, :, :), pointer sjd
real(kind=realtype), dimension(:, :, :, :), pointer wd
real(kind=realtype), dimension(:, :, :), pointer vold
real(kind=realtype), dimension(:, :, :, :), pointer w
real(kind=realtype), dimension(:, :, :, :), pointer scratch
real(kind=realtype), dimension(:, :, :), pointer d2wall
integer(kind=inttype), dimension(:, :, :), pointer iblank
real(kind=realtype), dimension(:, :, :, :), pointer skd
real(kind=realtype), dimension(:, :, :), pointer rlv
real(kind=realtype), dimension(:, :, :, :), pointer si
real(kind=realtype), dimension(:, :, :, :), pointer sid
real(kind=realtype), dimension(:, :, :), pointer volref
real(kind=realtype), dimension(:, :, :, :), pointer sj
integer(kind=inttype) sectionid
real(kind=realtype), dimension(:, :, :, :), pointer scratchd
real(kind=realtype), dimension(:, :, :, :), pointer dw
real(kind=realtype), dimension(:, :, :, :), pointer sk
real(kind=realtype), dimension(:, :, :), pointer rlvd
real(kind=realtype), dimension(:, :, :), pointer vol
real(kind=realtype), dimension(:, :, :), pointer d2walld
real(kind=realtype), dimension(:, :, :, :), pointer dwd
integer(kind=inttype) kl
integer(kind=inttype) il
integer(kind=inttype), parameter strain
Definition: constants.F90:137
real(kind=realtype), parameter zero
Definition: constants.F90:71
integer, parameter idvt
Definition: constants.F90:51
real(kind=realtype), parameter third
Definition: constants.F90:81
integer, parameter itu1
Definition: constants.F90:40
integer, parameter irho
Definition: constants.F90:34
integer(kind=inttype), parameter vorticity
Definition: constants.F90:137
integer, parameter ivx
Definition: constants.F90:35
real(kind=realtype), parameter one
Definition: constants.F90:72
real(kind=realtype), parameter half
Definition: constants.F90:80
integer(kind=inttype), parameter katolaunder
Definition: constants.F90:137
integer, parameter ivz
Definition: constants.F90:37
real(kind=realtype), parameter two
Definition: constants.F90:73
real(kind=realtype), parameter fourth
Definition: constants.F90:82
integer, parameter ivy
Definition: constants.F90:36
real(kind=realtype), parameter sixth
Definition: constants.F90:83
real(kind=realtype) timeref
real(kind=realtype) timerefd
logical useft2sa
Definition: inputParam.F90:587
integer(kind=inttype) turbprod
Definition: inputParam.F90:584
logical userotationsa
Definition: inputParam.F90:587
real(kind=realtype), parameter rsacw1
Definition: paramTurb.F90:18
real(kind=realtype), parameter rsak
Definition: paramTurb.F90:13
real(kind=realtype), parameter rsact4
Definition: paramTurb.F90:25
real(kind=realtype), parameter rsacrot
Definition: paramTurb.F90:26
real(kind=realtype), parameter rsacb2
Definition: paramTurb.F90:15
real(kind=realtype), parameter rsact3
Definition: paramTurb.F90:24
real(kind=realtype), parameter rsacw3
Definition: paramTurb.F90:21
real(kind=realtype), parameter rsacw2
Definition: paramTurb.F90:20
real(kind=realtype), parameter rsacv1
Definition: paramTurb.F90:17
real(kind=realtype), parameter rsacb3
Definition: paramTurb.F90:16
real(kind=realtype), parameter rsacb1
Definition: paramTurb.F90:14
Definition: sa_d.f90:7
real(kind=realtype), dimension(:, :, :), pointer ddw
Definition: sa_d.f90:12
real(kind=realtype) cv13
Definition: sa_d.f90:10
real(kind=realtype) cb3inv
Definition: sa_d.f90:10
subroutine saresscale_d()
Definition: sa_d.f90:1304
subroutine saviscous()
Definition: sa_d.f90:1086
real(kind=realtype) cw36
Definition: sa_d.f90:10
real(kind=realtype), dimension(:, :, :), pointer ddvt
Definition: sa_d.f90:12
subroutine saresscale()
Definition: sa_d.f90:1338
real(kind=realtype) kar2inv
Definition: sa_d.f90:10
real(kind=realtype), dimension(:, :, :), allocatable qq
Definition: sa_d.f90:11
subroutine sasource_d()
Definition: sa_d.f90:26
subroutine saviscous_d()
Definition: sa_d.f90:678
subroutine sasource()
Definition: sa_d.f90:477
real(kind=realtype), dimension(:, :), pointer rrlv
Definition: sa_d.f90:13
real(kind=realtype), dimension(:, :, :), pointer ww
Definition: sa_d.f90:12
real(kind=realtype), dimension(:, :), pointer dd2wall
Definition: sa_d.f90:14
type(sectiontype), dimension(:), allocatable sections
Definition: section.f90:46
Definition: SST.F90:1