ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
utils_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 module utils_d
5  implicit none
6 
7 contains
8  function char2str(chararray, n)
9  use constants
10  implicit none
11 !
12 ! function arguments.
13 !
14  character, dimension(maxcgnsnamelen), intent(in) :: chararray
15  integer(kind=inttype), intent(in) :: n
16 !
17 ! function type
18 !
19  character(len=n) :: char2str
20 !
21 ! local variables.
22 !
23  integer(kind=inttype) :: i
24  do i=1,n
25  char2str(i:i) = chararray(i)
26  end do
27  end function char2str
28 
29  function tsbeta(degreepolbeta, coefpolbeta, degreefourbeta, &
30 & omegafourbeta, coscoeffourbeta, sincoeffourbeta, t)
31 !
32 ! tsbeta computes the angle of attack for a given time interval
33 ! in a time spectral solution.
34 !
35  use constants
36  use inputphysics, only : equationmode
37  implicit none
38 !
39 ! function type
40 !
41  real(kind=realtype) :: tsbeta
42 !
43 ! function arguments.
44 !
45  integer(kind=inttype), intent(in) :: degreepolbeta
46  integer(kind=inttype), intent(in) :: degreefourbeta
47  real(kind=realtype), intent(in) :: omegafourbeta, t
48  real(kind=realtype), dimension(0:*), intent(in) :: coefpolbeta
49  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourbeta
50  real(kind=realtype), dimension(*), intent(in) :: sincoeffourbeta
51 !
52 ! local variables.
53 !
54  integer(kind=inttype) :: nn
55  real(kind=realtype) :: beta, val
56  intrinsic cos
57  intrinsic sin
58 ! return immediately if this is a steady computation.
59  if (equationmode .eq. steady) then
60  tsbeta = zero
61  return
62  else
63 ! compute the polynomial contribution. if no polynomial was
64 ! specified, the value of index 0 is set to zero automatically.
65  beta = coefpolbeta(0)
66  do nn=1,degreepolbeta
67  beta = beta + coefpolbeta(nn)*t**nn
68  end do
69 ! compute the fourier contribution. again the cosine coefficient
70 ! of index 0 is defaulted to zero if not specified.
71  beta = beta + coscoeffourbeta(0)
72  do nn=1,degreefourbeta
73  val = nn*omegafourbeta*t
74  beta = beta + coscoeffourbeta(nn)*cos(val) + sincoeffourbeta(nn)&
75 & *sin(val)
76  end do
77 ! set tsbeta to phi.
78  tsbeta = beta
79  end if
80  end function tsbeta
81 
82  function tsbetadot(degreepolbeta, coefpolbeta, degreefourbeta, &
83 & omegafourbeta, coscoeffourbeta, sincoeffourbeta, t)
84 !
85 ! tsbeta computes the angle of attack for a given time interval
86 ! in a time spectral solution.
87 !
88  use constants
89  use inputphysics, only : equationmode
90  implicit none
91 !
92 ! function type
93 !
94  real(kind=realtype) :: tsbetadot
95 !
96 ! function arguments.
97 !
98  integer(kind=inttype), intent(in) :: degreepolbeta
99  integer(kind=inttype), intent(in) :: degreefourbeta
100  real(kind=realtype), intent(in) :: omegafourbeta, t
101  real(kind=realtype), dimension(0:*), intent(in) :: coefpolbeta
102  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourbeta
103  real(kind=realtype), dimension(*), intent(in) :: sincoeffourbeta
104 !
105 ! local variables.
106 !
107  integer(kind=inttype) :: nn
108  real(kind=realtype) :: betadot, val
109  intrinsic sin
110  intrinsic cos
111 ! return immediately if this is a steady computation.
112  if (equationmode .eq. steady) then
113  tsbetadot = zero
114  return
115  else
116 ! compute the polynomial contribution. if no polynomial was
117 ! specified, the value of index 0 is set to zero automatically.
118  betadot = zero
119  do nn=1,degreepolbeta
120  betadot = betadot + nn*coefpolbeta(nn)*t**(nn-1)
121  end do
122 ! compute the fourier contribution. again the cosine coefficient
123 ! of index 0 is defaulted to zero if not specified.
124  do nn=1,degreefourbeta
125  val = nn*omegafourbeta
126  betadot = betadot - val*coscoeffourbeta(nn)*sin(val*t) + val*&
127 & sincoeffourbeta(nn)*cos(val*t)
128  end do
129 ! set tsbeta to phi.
130  tsbetadot = betadot
131  end if
132  end function tsbetadot
133 
134  function tsmach(degreepolmach, coefpolmach, degreefourmach, &
135 & omegafourmach, coscoeffourmach, sincoeffourmach, t)
136 !
137 ! tsmach computes the mach number for a given time interval
138 ! in a time spectral solution.
139 !
140  use constants
141  use inputphysics, only : equationmode
142  implicit none
143 !
144 ! function type
145 !
146  real(kind=realtype) :: tsmach
147 !
148 ! function arguments.
149 !
150  integer(kind=inttype), intent(in) :: degreepolmach
151  integer(kind=inttype), intent(in) :: degreefourmach
152  real(kind=realtype), intent(in) :: omegafourmach, t
153  real(kind=realtype), dimension(0:*), intent(in) :: coefpolmach
154  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourmach
155  real(kind=realtype), dimension(*), intent(in) :: sincoeffourmach
156 !
157 ! local variables.
158 !
159  integer(kind=inttype) :: nn
160  real(kind=realtype) :: intervalmach, val
161  intrinsic cos
162  intrinsic sin
163 ! return immediately if this is a steady computation.
164  if (equationmode .eq. steady) then
165  tsmach = zero
166  return
167  else
168 ! compute the polynomial contribution. if no polynomial was
169 ! specified, the value of index 0 is set to zero automatically.
170  intervalmach = coefpolmach(0)
171  do nn=1,degreepolmach
172  intervalmach = intervalmach + coefpolmach(nn)*t**nn
173  end do
174 ! compute the fourier contribution. again the cosine coefficient
175 ! of index 0 is defaulted to zero if not specified.
176  intervalmach = intervalmach + coscoeffourmach(0)
177  do nn=1,degreefourmach
178  val = nn*omegafourmach*t
179  intervalmach = intervalmach + coscoeffourmach(nn)*cos(val) + &
180 & sincoeffourmach(nn)*sin(val)
181  end do
182  print*, 'intsmach', intervalmach, nn, val, t
183 ! set tsmach to phi.
184  tsmach = intervalmach
185  end if
186  end function tsmach
187 
188  function tsmachdot(degreepolmach, coefpolmach, degreefourmach, &
189 & omegafourmach, coscoeffourmach, sincoeffourmach, t)
190 !
191 ! tsmach computes the angle of attack for a given time interval
192 ! in a time spectral solution.
193 !
194  use constants
195  use inputphysics, only : equationmode
196  implicit none
197 !
198 ! function type
199 !
200  real(kind=realtype) :: tsmachdot
201 !
202 ! function arguments.
203 !
204  integer(kind=inttype), intent(in) :: degreepolmach
205  integer(kind=inttype), intent(in) :: degreefourmach
206  real(kind=realtype), intent(in) :: omegafourmach, t
207  real(kind=realtype), dimension(0:*), intent(in) :: coefpolmach
208  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourmach
209  real(kind=realtype), dimension(*), intent(in) :: sincoeffourmach
210 !
211 ! local variables.
212 !
213  integer(kind=inttype) :: nn
214  real(kind=realtype) :: machdot, val
215  intrinsic sin
216  intrinsic cos
217 ! return immediately if this is a steady computation.
218  if (equationmode .eq. steady) then
219  tsmachdot = zero
220  return
221  else
222 ! compute the polynomial contribution. if no polynomial was
223 ! specified, the value of index 0 is set to zero automatically.
224  machdot = zero
225  do nn=1,degreepolmach
226  machdot = machdot + nn*coefpolmach(nn)*t**(nn-1)
227  end do
228 ! compute the fourier contribution. again the cosine coefficient
229 ! of index 0 is defaulted to zero if not specified.
230  do nn=1,degreefourmach
231  val = nn*omegafourmach
232  machdot = machdot - val*coscoeffourmach(nn)*sin(val*t) + val*&
233 & sincoeffourmach(nn)*cos(val*t)
234  end do
235 ! set tsmach to phi.
236  tsmachdot = machdot
237  end if
238  end function tsmachdot
239 
240  function tsalpha(degreepolalpha, coefpolalpha, degreefouralpha, &
241 & omegafouralpha, coscoeffouralpha, sincoeffouralpha, t)
242 !
243 ! tsalpha computes the angle of attack for a given time interval
244 ! in a time spectral solution.
245 !
246  use constants
247  use inputphysics, only : equationmode
248  implicit none
249 !
250 ! function type
251 !
252  real(kind=realtype) :: tsalpha
253 !
254 ! function arguments.
255 !
256  integer(kind=inttype), intent(in) :: degreepolalpha
257  integer(kind=inttype), intent(in) :: degreefouralpha
258  real(kind=realtype), intent(in) :: omegafouralpha, t
259  real(kind=realtype), dimension(0:*), intent(in) :: coefpolalpha
260  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffouralpha
261  real(kind=realtype), dimension(*), intent(in) :: sincoeffouralpha
262 !
263 ! local variables.
264 !
265  integer(kind=inttype) :: nn
266  real(kind=realtype) :: alpha, val
267  intrinsic cos
268  intrinsic sin
269 ! return immediately if this is a steady computation.
270  if (equationmode .eq. steady) then
271  tsalpha = zero
272  return
273  else
274 ! compute the polynomial contribution. if no polynomial was
275 ! specified, the value of index 0 is set to zero automatically.
276  alpha = coefpolalpha(0)
277  do nn=1,degreepolalpha
278  alpha = alpha + coefpolalpha(nn)*t**nn
279  end do
280 ! compute the fourier contribution. again the cosine coefficient
281 ! of index 0 is defaulted to zero if not specified.
282  alpha = alpha + coscoeffouralpha(0)
283  do nn=1,degreefouralpha
284  val = nn*omegafouralpha*t
285  alpha = alpha + coscoeffouralpha(nn)*cos(val) + sincoeffouralpha&
286 & (nn)*sin(val)
287  end do
288 !print *,'intsalpha',alpha,nn,val,t
289 ! set tsalpha to phi.
290  tsalpha = alpha
291  end if
292  end function tsalpha
293 
294  function tsalphadot(degreepolalpha, coefpolalpha, degreefouralpha, &
295 & omegafouralpha, coscoeffouralpha, sincoeffouralpha, t)
296 !
297 ! tsalpha computes the angle of attack for a given time interval
298 ! in a time spectral solution.
299 !
300  use constants
301  use inputphysics, only : equationmode
302  implicit none
303 !
304 ! function type
305 !
306  real(kind=realtype) :: tsalphadot
307 !
308 ! function arguments.
309 !
310  integer(kind=inttype), intent(in) :: degreepolalpha
311  integer(kind=inttype), intent(in) :: degreefouralpha
312  real(kind=realtype), intent(in) :: omegafouralpha, t
313  real(kind=realtype), dimension(0:*), intent(in) :: coefpolalpha
314  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffouralpha
315  real(kind=realtype), dimension(*), intent(in) :: sincoeffouralpha
316 !
317 ! local variables.
318 !
319  integer(kind=inttype) :: nn
320  real(kind=realtype) :: alphadot, val
321  intrinsic sin
322  intrinsic cos
323 ! return immediately if this is a steady computation.
324  if (equationmode .eq. steady) then
325  tsalphadot = zero
326  return
327  else
328 ! compute the polynomial contribution. if no polynomial was
329 ! specified, the value of index 0 is set to zero automatically.
330  alphadot = zero
331  do nn=1,degreepolalpha
332  alphadot = alphadot + nn*coefpolalpha(nn)*t**(nn-1)
333  end do
334 ! compute the fourier contribution. again the cosine coefficient
335 ! of index 0 is defaulted to zero if not specified.
336  do nn=1,degreefouralpha
337  val = nn*omegafouralpha
338  alphadot = alphadot - val*coscoeffouralpha(nn)*sin(val*t) + val*&
339 & sincoeffouralpha(nn)*cos(val*t)
340  end do
341 ! set tsalpha to phi.
342  tsalphadot = alphadot
343  end if
344  end function tsalphadot
345 
346 ! differentiation of derivativerigidrotangle in forward (tangent) mode (with options i4 dr8 r8):
347 ! variations of useful results: derivativerigidrotangle
348 ! with respect to varying inputs: timeref
349  real(kind=realtype) function derivativerigidrotangle_d(degreepolrot, &
350 & coefpolrot, degreefourrot, omegafourrot, coscoeffourrot, &
351 & sincoeffourrot, t, derivativerigidrotangle)
352 !
353 ! derivativerigidrotangle computes the time derivative of the
354 ! rigid body rotation angle at the given time for the given
355 ! arguments. the angle is described by a combination of a
356 ! polynomial and fourier series.
357 !
358  use constants
359  use inputphysics, only : equationmode
360  use flowvarrefstate, only : timeref, timerefd
361  implicit none
362 !
363 ! function type
364 !
365  real(kind=realtype) :: derivativerigidrotangle
366 !
367 ! function arguments.
368 !
369  integer(kind=inttype), intent(in) :: degreepolrot
370  integer(kind=inttype), intent(in) :: degreefourrot
371  real(kind=realtype), intent(in) :: omegafourrot, t
372  real(kind=realtype), dimension(0:*), intent(in) :: coefpolrot
373  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourrot
374  real(kind=realtype), dimension(*), intent(in) :: sincoeffourrot
375 !
376 ! local variables.
377 !
378  integer(kind=inttype) :: nn
379  real(kind=realtype) :: dphi, val
380  intrinsic sin
381  intrinsic cos
382 ! return immediately if this is a steady computation.
383  if (equationmode .eq. steady) then
386  return
387  else
388 ! compute the polynomial contribution.
389  dphi = zero
390  do nn=1,degreepolrot
391  dphi = dphi + nn*coefpolrot(nn)*t**(nn-1)
392  end do
393 ! compute the fourier contribution.
394  do nn=1,degreefourrot
395  val = nn*omegafourrot
396  dphi = dphi - val*coscoeffourrot(nn)*sin(val*t)
397  dphi = dphi + val*sincoeffourrot(nn)*cos(val*t)
398  end do
399 ! set derivativerigidrotangle to dphi. multiply by timeref
400 ! to obtain the correct non-dimensional value.
403  end if
404  end function derivativerigidrotangle_d
405 
406  function derivativerigidrotangle(degreepolrot, coefpolrot, &
407 & degreefourrot, omegafourrot, coscoeffourrot, sincoeffourrot, t)
408 !
409 ! derivativerigidrotangle computes the time derivative of the
410 ! rigid body rotation angle at the given time for the given
411 ! arguments. the angle is described by a combination of a
412 ! polynomial and fourier series.
413 !
414  use constants
415  use inputphysics, only : equationmode
416  use flowvarrefstate, only : timeref
417  implicit none
418 !
419 ! function type
420 !
421  real(kind=realtype) :: derivativerigidrotangle
422 !
423 ! function arguments.
424 !
425  integer(kind=inttype), intent(in) :: degreepolrot
426  integer(kind=inttype), intent(in) :: degreefourrot
427  real(kind=realtype), intent(in) :: omegafourrot, t
428  real(kind=realtype), dimension(0:*), intent(in) :: coefpolrot
429  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourrot
430  real(kind=realtype), dimension(*), intent(in) :: sincoeffourrot
431 !
432 ! local variables.
433 !
434  integer(kind=inttype) :: nn
435  real(kind=realtype) :: dphi, val
436  intrinsic sin
437  intrinsic cos
438 ! return immediately if this is a steady computation.
439  if (equationmode .eq. steady) then
441  return
442  else
443 ! compute the polynomial contribution.
444  dphi = zero
445  do nn=1,degreepolrot
446  dphi = dphi + nn*coefpolrot(nn)*t**(nn-1)
447  end do
448 ! compute the fourier contribution.
449  do nn=1,degreefourrot
450  val = nn*omegafourrot
451  dphi = dphi - val*coscoeffourrot(nn)*sin(val*t)
452  dphi = dphi + val*sincoeffourrot(nn)*cos(val*t)
453  end do
454 ! set derivativerigidrotangle to dphi. multiply by timeref
455 ! to obtain the correct non-dimensional value.
457  end if
458  end function derivativerigidrotangle
459 
460 ! differentiation of mydim in forward (tangent) mode (with options i4 dr8 r8):
461 ! variations of useful results: mydim
462 ! with respect to varying inputs: x y
463  real(kind=realtype) function mydim_d(x, xd, y, yd, mydim)
464  use constants
465  implicit none
466  real(kind=realtype) :: x, y
467  real(kind=realtype) :: xd, yd
468  real(kind=realtype) :: mydim
469  mydim_d = xd - yd
470  mydim = x - y
471  if (mydim .lt. 0.0) then
472  mydim = 0.0
473  mydim_d = 0.0_8
474  end if
475  end function mydim_d
476 
477  function mydim(x, y)
478  use constants
479  implicit none
480  real(kind=realtype) :: x, y
481  real(kind=realtype) :: mydim
482  mydim = x - y
483  if (mydim .lt. 0.0) mydim = 0.0
484  end function mydim
485 
486  function getcorrectfork()
487  use constants
488  use flowvarrefstate, only : kpresent
489  use iteration, only : currentlevel, groundlevel
490  implicit none
491  logical :: getcorrectfork
492  if (kpresent .and. currentlevel .le. groundlevel) then
493  getcorrectfork = .true.
494  else
495  getcorrectfork = .false.
496  end if
497  end function getcorrectfork
498 
499  subroutine terminate(routinename, errormessage)
500 !
501 ! terminate writes an error message to standard output and
502 ! terminates the execution of the program.
503 !
504  use constants
506  implicit none
507 !
508 ! subroutine arguments
509 !
510  character(len=*), intent(in) :: routinename
511  character(len=*), intent(in) :: errormessage
512  end subroutine terminate
513 
514  subroutine rotmatrixrigidbody(tnew, told, rotationmatrix, &
515 & rotationpoint)
516 !
517 ! rotmatrixrigidbody determines the rotation matrix and the
518 ! rotation point to determine the coordinates of the new time
519 ! level starting from the coordinates of the old time level.
520 !
521  use constants
522  use inputmotion
523  use flowvarrefstate, only : lref
524  implicit none
525 !
526 ! subroutine arguments.
527 !
528  real(kind=realtype), intent(in) :: tnew, told
529  real(kind=realtype), dimension(3), intent(out) :: rotationpoint
530  real(kind=realtype), dimension(3, 3), intent(out) :: rotationmatrix
531 !
532 ! local variables.
533 !
534  integer(kind=inttype) :: i, j
535  real(kind=realtype) :: phi
536  real(kind=realtype) :: cosx, cosy, cosz, sinx, siny, sinz
537  real(kind=realtype), dimension(3, 3) :: mnew, mold
538  intrinsic sin
539  intrinsic cos
540 ! determine the rotation angle around the x-axis for the new
541 ! time level and the corresponding values of the sine and cosine.
544  sinx = sin(phi)
545  cosx = cos(phi)
546 ! idem for the y-axis.
549  siny = sin(phi)
550  cosy = cos(phi)
551 ! idem for the z-axis.
554  sinz = sin(phi)
555  cosz = cos(phi)
556 ! construct the transformation matrix at the new time level.
557 ! it is assumed that the sequence of rotation is first around the
558 ! x-axis then around the y-axis and finally around the z-axis.
559  mnew(1, 1) = cosy*cosz
560  mnew(2, 1) = cosy*sinz
561  mnew(3, 1) = -siny
562  mnew(1, 2) = sinx*siny*cosz - cosx*sinz
563  mnew(2, 2) = sinx*siny*sinz + cosx*cosz
564  mnew(3, 2) = sinx*cosy
565  mnew(1, 3) = cosx*siny*cosz + sinx*sinz
566  mnew(2, 3) = cosx*siny*sinz - sinx*cosz
567  mnew(3, 3) = cosx*cosy
568 ! determine the rotation angle around the x-axis for the old
569 ! time level and the corresponding values of the sine and cosine.
572  sinx = sin(phi)
573  cosx = cos(phi)
574 ! idem for the y-axis.
577  siny = sin(phi)
578  cosy = cos(phi)
579 ! idem for the z-axis.
582  sinz = sin(phi)
583  cosz = cos(phi)
584 ! construct the transformation matrix at the old time level.
585  mold(1, 1) = cosy*cosz
586  mold(2, 1) = cosy*sinz
587  mold(3, 1) = -siny
588  mold(1, 2) = sinx*siny*cosz - cosx*sinz
589  mold(2, 2) = sinx*siny*sinz + cosx*cosz
590  mold(3, 2) = sinx*cosy
591  mold(1, 3) = cosx*siny*cosz + sinx*sinz
592  mold(2, 3) = cosx*siny*sinz - sinx*cosz
593  mold(3, 3) = cosx*cosy
594 ! construct the transformation matrix between the new and the
595 ! old time level. this is mnew*inverse(mold). however the
596 ! inverse of mold is the transpose.
597  do j=1,3
598  do i=1,3
599  rotationmatrix(i, j) = mnew(i, 1)*mold(j, 1) + mnew(i, 2)*mold(j&
600 & , 2) + mnew(i, 3)*mold(j, 3)
601  end do
602  end do
603 ! determine the rotation point at the old time level; it is
604 ! possible that this value changes due to translation of the grid.
605 ! ainf = sqrt(gammainf*pinf/rhoinf)
606 ! rotationpoint(1) = lref*rotpoint(1) &
607 ! + machgrid(1)*ainf*told/timeref
608 ! rotationpoint(2) = lref*rotpoint(2) &
609 ! + machgrid(2)*ainf*told/timeref
610 ! rotationpoint(3) = lref*rotpoint(3) &
611 ! + machgrid(3)*ainf*told/timeref
612  rotationpoint(1) = lref*rotpoint(1)
613  rotationpoint(2) = lref*rotpoint(2)
614  rotationpoint(3) = lref*rotpoint(3)
615  end subroutine rotmatrixrigidbody
616 
617  function secondderivativerigidrotangle(degreepolrot, coefpolrot, &
618 & degreefourrot, omegafourrot, coscoeffourrot, sincoeffourrot, t)
619 !
620 ! 2ndderivativerigidrotangle computes the 2nd time derivative of
621 ! the rigid body rotation angle at the given time for the given
622 ! arguments. the angle is described by a combination of a
623 ! polynomial and fourier series.
624 !
625  use constants
626  use flowvarrefstate, only : timeref
627  use inputphysics, only : equationmode
628  implicit none
629 !
630 ! function type
631 !
632  real(kind=realtype) :: secondderivativerigidrotangle
633 !
634 ! function arguments.
635 !
636  integer(kind=inttype), intent(in) :: degreepolrot
637  integer(kind=inttype), intent(in) :: degreefourrot
638  real(kind=realtype), intent(in) :: omegafourrot, t
639  real(kind=realtype), dimension(0:*), intent(in) :: coefpolrot
640  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourrot
641  real(kind=realtype), dimension(*), intent(in) :: sincoeffourrot
642 !
643 ! local variables.
644 !
645  integer(kind=inttype) :: nn
646  real(kind=realtype) :: dphi, val
647  intrinsic sin
648  intrinsic cos
649 ! return immediately if this is a steady computation.
650  if (equationmode .eq. steady) then
652  return
653  else
654 ! compute the polynomial contribution.
655  dphi = zero
656  do nn=2,degreepolrot
657  dphi = dphi + (nn-1)*nn*coefpolrot(nn)*t**(nn-2)
658  end do
659 ! compute the fourier contribution.
660  do nn=1,degreefourrot
661  val = nn*omegafourrot
662  dphi = dphi - val**2*sincoeffourrot(nn)*sin(val*t)
663  dphi = dphi - val**2*coscoeffourrot(nn)*cos(val*t)
664  end do
665 ! set derivativerigidrotangle to dphi. multiply by timeref
666 ! to obtain the correct non-dimensional value.
668  end if
669  end function secondderivativerigidrotangle
670 
671  function rigidrotangle(degreepolrot, coefpolrot, degreefourrot, &
672 & omegafourrot, coscoeffourrot, sincoeffourrot, t)
673 !
674 ! rigidrotangle computes the rigid body rotation angle at the
675 ! given time for the given arguments. the angle is described by
676 ! a combination of a polynomial and fourier series.
677 !
678  use constants
679  use inputphysics, only : equationmode
680  implicit none
681 !
682 ! function type
683 !
684  real(kind=realtype) :: rigidrotangle
685 !
686 ! function arguments.
687 !
688  integer(kind=inttype), intent(in) :: degreepolrot
689  integer(kind=inttype), intent(in) :: degreefourrot
690  real(kind=realtype), intent(in) :: omegafourrot, t
691  real(kind=realtype), dimension(0:*), intent(in) :: coefpolrot
692  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourrot
693  real(kind=realtype), dimension(*), intent(in) :: sincoeffourrot
694 !
695 ! local variables.
696 !
697  integer(kind=inttype) :: nn
698  real(kind=realtype) :: phi, val
699  intrinsic cos
700  intrinsic sin
701 ! return immediately if this is a steady computation.
702  if (equationmode .eq. steady) then
704  return
705  else
706 ! compute the polynomial contribution. if no polynomial was
707 ! specified, the value of index 0 is set to zero automatically.
708  phi = coefpolrot(0)
709  do nn=1,degreepolrot
710  phi = phi + coefpolrot(nn)*t**nn
711  end do
712 ! compute the fourier contribution. again the cosine coefficient
713 ! of index 0 is defaulted to zero if not specified.
714  phi = phi + coscoeffourrot(0)
715  do nn=1,degreefourrot
716  val = nn*omegafourrot*t
717  phi = phi + coscoeffourrot(nn)*cos(val) + sincoeffourrot(nn)*sin&
718 & (val)
719  end do
720 ! set rigidrotangle to phi.
721  rigidrotangle = phi
722  end if
723  end function rigidrotangle
724 
725  subroutine setbcpointers(nn, spatialpointers)
726 !
727 ! setbcpointers sets the pointers needed for the boundary
728 ! condition treatment on a general face, such that the boundary
729 ! routines are only implemented once instead of 6 times.
730 !
731  use constants
732  use blockpointers, only : w, p, rlv, rev, gamma, x, d2wall, si, sj&
733 & , sk, s, globalcell, bcdata, nx, il, ie, ib, ny, jl, je, jb, nz, kl,&
736  use bcpointers_d, only : ww0, ww1, ww2, ww3, pp0, pp1, pp2, pp3, &
737 & rlv0, rlv1, rlv2, rlv3, rev0, rev1, rev2, rev3, gamma0, gamma1, &
738 & gamma2, gamma3, gcp, xx, ss, ssi, ssj, ssk, dd2wall, sface, istart, &
739 & iend, jstart, jend, isize, jsize
740  use inputphysics, only : cpmodel, equations
741  implicit none
742 ! subroutine arguments.
743  integer(kind=inttype), intent(in) :: nn
744  logical, intent(in) :: spatialpointers
745 ! determine the sizes of each face and point to just the range we
746 ! need on each face.
747  istart = bcdata(nn)%icbeg
748  iend = bcdata(nn)%icend
749  jstart = bcdata(nn)%jcbeg
750  jend = bcdata(nn)%jcend
751 ! set the size of the subface
752  isize = iend - istart + 1
753  jsize = jend - jstart + 1
754 ! determine the face id on which the subface is located and set
755 ! the pointers accordinly.
756  select case (bcfaceid(nn))
757  case (imin)
758 !---------------------------------------------------------------------------
759  ww3 => w(3, 1:, 1:, :)
760  ww2 => w(2, 1:, 1:, :)
761  ww1 => w(1, 1:, 1:, :)
762  ww0 => w(0, 1:, 1:, :)
763  pp3 => p(3, 1:, 1:)
764  pp2 => p(2, 1:, 1:)
765  pp1 => p(1, 1:, 1:)
766  pp0 => p(0, 1:, 1:)
767  rlv3 => rlv(3, 1:, 1:)
768  rlv2 => rlv(2, 1:, 1:)
769  rlv1 => rlv(1, 1:, 1:)
770  rlv0 => rlv(0, 1:, 1:)
771  rev3 => rev(3, 1:, 1:)
772  rev2 => rev(2, 1:, 1:)
773  rev1 => rev(1, 1:, 1:)
774  rev0 => rev(0, 1:, 1:)
775  gamma3 => gamma(3, 1:, 1:)
776  gamma2 => gamma(2, 1:, 1:)
777  gamma1 => gamma(1, 1:, 1:)
778  gamma0 => gamma(0, 1:, 1:)
779  gcp => globalcell(2, 1:, 1:)
780 !---------------------------------------------------------------------------
781  case (imax)
782  ww3 => w(nx, 1:, 1:, :)
783  ww2 => w(il, 1:, 1:, :)
784  ww1 => w(ie, 1:, 1:, :)
785  ww0 => w(ib, 1:, 1:, :)
786  pp3 => p(nx, 1:, 1:)
787  pp2 => p(il, 1:, 1:)
788  pp1 => p(ie, 1:, 1:)
789  pp0 => p(ib, 1:, 1:)
790  rlv3 => rlv(nx, 1:, 1:)
791  rlv2 => rlv(il, 1:, 1:)
792  rlv1 => rlv(ie, 1:, 1:)
793  rlv0 => rlv(ib, 1:, 1:)
794  rev3 => rev(nx, 1:, 1:)
795  rev2 => rev(il, 1:, 1:)
796  rev1 => rev(ie, 1:, 1:)
797  rev0 => rev(ib, 1:, 1:)
798  gamma3 => gamma(nx, 1:, 1:)
799  gamma2 => gamma(il, 1:, 1:)
800  gamma1 => gamma(ie, 1:, 1:)
801  gamma0 => gamma(ib, 1:, 1:)
802  gcp => globalcell(il, 1:, 1:)
803 !---------------------------------------------------------------------------
804  case (jmin)
805  ww3 => w(1:, 3, 1:, :)
806  ww2 => w(1:, 2, 1:, :)
807  ww1 => w(1:, 1, 1:, :)
808  ww0 => w(1:, 0, 1:, :)
809  pp3 => p(1:, 3, 1:)
810  pp2 => p(1:, 2, 1:)
811  pp1 => p(1:, 1, 1:)
812  pp0 => p(1:, 0, 1:)
813  rlv3 => rlv(1:, 3, 1:)
814  rlv2 => rlv(1:, 2, 1:)
815  rlv1 => rlv(1:, 1, 1:)
816  rlv0 => rlv(1:, 0, 1:)
817  rev3 => rev(1:, 3, 1:)
818  rev2 => rev(1:, 2, 1:)
819  rev1 => rev(1:, 1, 1:)
820  rev0 => rev(1:, 0, 1:)
821  gamma3 => gamma(1:, 3, 1:)
822  gamma2 => gamma(1:, 2, 1:)
823  gamma1 => gamma(1:, 1, 1:)
824  gamma0 => gamma(1:, 0, 1:)
825  gcp => globalcell(1:, 2, 1:)
826 !---------------------------------------------------------------------------
827  case (jmax)
828  ww3 => w(1:, ny, 1:, :)
829  ww2 => w(1:, jl, 1:, :)
830  ww1 => w(1:, je, 1:, :)
831  ww0 => w(1:, jb, 1:, :)
832  pp3 => p(1:, ny, 1:)
833  pp2 => p(1:, jl, 1:)
834  pp1 => p(1:, je, 1:)
835  pp0 => p(1:, jb, 1:)
836  rlv3 => rlv(1:, ny, 1:)
837  rlv2 => rlv(1:, jl, 1:)
838  rlv1 => rlv(1:, je, 1:)
839  rlv0 => rlv(1:, jb, 1:)
840  rev3 => rev(1:, ny, 1:)
841  rev2 => rev(1:, jl, 1:)
842  rev1 => rev(1:, je, 1:)
843  rev0 => rev(1:, jb, 1:)
844  gamma3 => gamma(1:, ny, 1:)
845  gamma2 => gamma(1:, jl, 1:)
846  gamma1 => gamma(1:, je, 1:)
847  gamma0 => gamma(1:, jb, 1:)
848  gcp => globalcell(1:, jl, 1:)
849 !---------------------------------------------------------------------------
850  case (kmin)
851  ww3 => w(1:, 1:, 3, :)
852  ww2 => w(1:, 1:, 2, :)
853  ww1 => w(1:, 1:, 1, :)
854  ww0 => w(1:, 1:, 0, :)
855  pp3 => p(1:, 1:, 3)
856  pp2 => p(1:, 1:, 2)
857  pp1 => p(1:, 1:, 1)
858  pp0 => p(1:, 1:, 0)
859  rlv3 => rlv(1:, 1:, 3)
860  rlv2 => rlv(1:, 1:, 2)
861  rlv1 => rlv(1:, 1:, 1)
862  rlv0 => rlv(1:, 1:, 0)
863  rev3 => rev(1:, 1:, 3)
864  rev2 => rev(1:, 1:, 2)
865  rev1 => rev(1:, 1:, 1)
866  rev0 => rev(1:, 1:, 0)
867  gamma3 => gamma(1:, 1:, 3)
868  gamma2 => gamma(1:, 1:, 2)
869  gamma1 => gamma(1:, 1:, 1)
870  gamma0 => gamma(1:, 1:, 0)
871  gcp => globalcell(1:, 1:, 2)
872 !---------------------------------------------------------------------------
873  case (kmax)
874  ww3 => w(1:, 1:, nz, :)
875  ww2 => w(1:, 1:, kl, :)
876  ww1 => w(1:, 1:, ke, :)
877  ww0 => w(1:, 1:, kb, :)
878  pp3 => p(1:, 1:, nz)
879  pp2 => p(1:, 1:, kl)
880  pp1 => p(1:, 1:, ke)
881  pp0 => p(1:, 1:, kb)
882  rlv3 => rlv(1:, 1:, nz)
883  rlv2 => rlv(1:, 1:, kl)
884  rlv1 => rlv(1:, 1:, ke)
885  rlv0 => rlv(1:, 1:, kb)
886  rev3 => rev(1:, 1:, nz)
887  rev2 => rev(1:, 1:, kl)
888  rev1 => rev(1:, 1:, ke)
889  rev0 => rev(1:, 1:, kb)
890  gamma3 => gamma(1:, 1:, nz)
891  gamma2 => gamma(1:, 1:, kl)
892  gamma1 => gamma(1:, 1:, ke)
893  gamma0 => gamma(1:, 1:, kb)
894  gcp => globalcell(1:, 1:, kl)
895  end select
896  if (spatialpointers) then
897  select case (bcfaceid(nn))
898  case (imin)
899  xx => x(1, :, :, :)
900  ssi => si(1, :, :, :)
901  ssj => sj(2, :, :, :)
902  ssk => sk(2, :, :, :)
903  ss => s(2, :, :, :)
904  case (imax)
905  xx => x(il, :, :, :)
906  ssi => si(il, :, :, :)
907  ssj => sj(il, :, :, :)
908  ssk => sk(il, :, :, :)
909  ss => s(il, :, :, :)
910  case (jmin)
911  xx => x(:, 1, :, :)
912  ssi => sj(:, 1, :, :)
913  ssj => si(:, 2, :, :)
914  ssk => sk(:, 2, :, :)
915  ss => s(:, 2, :, :)
916  case (jmax)
917  xx => x(:, jl, :, :)
918  ssi => sj(:, jl, :, :)
919  ssj => si(:, jl, :, :)
920  ssk => sk(:, jl, :, :)
921  ss => s(:, jl, :, :)
922  case (kmin)
923  xx => x(:, :, 1, :)
924  ssi => sk(:, :, 1, :)
925  ssj => si(:, :, 2, :)
926  ssk => sj(:, :, 2, :)
927  ss => s(:, :, 2, :)
928  case (kmax)
929  xx => x(:, :, kl, :)
930  ssi => sk(:, :, kl, :)
931  ssj => si(:, :, kl, :)
932  ssk => sj(:, :, kl, :)
933  ss => s(:, :, kl, :)
934  end select
935  if (addgridvelocities) then
936  select case (bcfaceid(nn))
937  case (imin)
938  sface => sfacei(1, :, :)
939  case (imax)
940  sface => sfacei(il, :, :)
941  case (jmin)
942  sface => sfacej(:, 1, :)
943  case (jmax)
944  sface => sfacej(:, jl, :)
945  case (kmin)
946  sface => sfacek(:, :, 1)
947  case (kmax)
948  sface => sfacek(:, :, kl)
949  end select
950  end if
951  if (equations .eq. ransequations) then
952  select case (bcfaceid(nn))
953  case (imin)
954  dd2wall => d2wall(2, :, :)
955  case (imax)
956  dd2wall => d2wall(il, :, :)
957  case (jmin)
958  dd2wall => d2wall(:, 2, :)
959  case (jmax)
960  dd2wall => d2wall(:, jl, :)
961  case (kmin)
962  dd2wall => d2wall(:, :, 2)
963  case (kmax)
964  dd2wall => d2wall(:, :, kl)
965  end select
966  end if
967  end if
968  end subroutine setbcpointers
969 
970  subroutine computerootbendingmoment(cf, cm, bendingmoment)
971 ! *
972 ! compute a normalized bending moment coefficient from *
973 ! the force and moment coefficient. at the moment this *
974 ! routine only works for a half body. additional logic *
975 ! would be needed for a full body. *
976 ! *
977  use constants
978  use inputphysics, only : lengthref, pointref, pointrefec, &
979 & liftindex
980  implicit none
981 !input/output variables
982  real(kind=realtype), dimension(3), intent(in) :: cf, cm
983  real(kind=realtype), intent(out) :: bendingmoment
984 !subroutine variables
985  real(kind=realtype) :: elasticmomentx, elasticmomenty, &
986 & elasticmomentz
987  intrinsic sqrt
988  real(kind=realtype) :: arg1
989  bendingmoment = zero
990  if (liftindex .eq. 2) then
991 !z out wing sum momentx,momentz
992  elasticmomentx = cm(1) + cf(2)*(pointrefec(3)-pointref(3))/&
993 & lengthref - cf(3)*(pointrefec(2)-pointref(2))/lengthref
994  elasticmomentz = cm(3) - cf(2)*(pointrefec(1)-pointref(1))/&
995 & lengthref + cf(1)*(pointrefec(2)-pointref(2))/lengthref
996  arg1 = elasticmomentx**2 + elasticmomentz**2
997  bendingmoment = sqrt(arg1)
998  else if (liftindex .eq. 3) then
999 !y out wing sum momentx,momenty
1000  elasticmomentx = cm(1) + cf(3)*(pointrefec(2)-pointref(2))/&
1001 & lengthref + cf(3)*(pointrefec(3)-pointref(3))/lengthref
1002  elasticmomenty = cm(2) + cf(3)*(pointrefec(1)-pointref(1))/&
1003 & lengthref + cf(1)*(pointrefec(3)-pointref(3))/lengthref
1004  arg1 = elasticmomentx**2 + elasticmomenty**2
1005  bendingmoment = sqrt(arg1)
1006  end if
1007  end subroutine computerootbendingmoment
1008 
1009  subroutine computeleastsquaresregression(y, x, npts, m, b)
1010 !
1011 ! computes the slope of best fit for a set of x,y data of length
1012 ! npts
1013 !
1014  use constants
1015  implicit none
1016 !subroutine arguments
1017  integer(kind=inttype) :: npts
1018  real(kind=realtype), dimension(npts) :: x, y
1019  real(kind=realtype) :: m, b
1020 !local variables
1021  real(kind=realtype) :: sumx, sumy, sumx2, sumxy
1022  integer(kind=inttype) :: i
1023 !begin execution
1024  sumx = 0.0
1025  sumy = 0.0
1026  sumx2 = 0.0
1027  sumxy = 0.0
1028  do i=1,npts
1029  sumx = sumx + x(i)
1030  sumy = sumy + y(i)
1031  sumx2 = sumx2 + x(i)*x(i)
1032  sumxy = sumxy + x(i)*y(i)
1033  end do
1034  m = (npts*sumxy-sumy*sumx)/(npts*sumx2-sumx**2)
1035  b = (sumy*sumx2-sumx*sumxy)/(npts*sumx2-sumx**2)
1036  end subroutine computeleastsquaresregression
1037 
1038  subroutine computetsderivatives(force, moment, coef0, dcdalpha, &
1039 & dcdalphadot, dcdq, dcdqdot)
1040 !
1041 ! computes the stability derivatives based on the time spectral
1042 ! solution of a given mesh. takes in the force coefficients at
1043 ! all time instantces and computes the agregate parameters
1044 !
1045  use constants
1046  use communication
1047  use inputphysics
1048  use inputtimespectral
1049  use inputtsstabderiv
1050  use flowvarrefstate
1051  use monitor
1052  use section
1053  use inputmotion
1054  implicit none
1055 !
1056 ! subroutine arguments.
1057 !
1058  real(kind=realtype), dimension(3, ntimeintervalsspectral) :: force, &
1059 & moment
1060  real(kind=realtype), dimension(8) :: dcdq, dcdqdot
1061  real(kind=realtype), dimension(8) :: dcdalpha, dcdalphadot
1062  real(kind=realtype), dimension(8) :: coef0
1063 ! working variables
1064  real(kind=realtype), dimension(ntimeintervalsspectral, 8) :: &
1065 & basecoef
1066  real(kind=realtype), dimension(8) :: coef0dot
1067  real(kind=realtype), dimension(ntimeintervalsspectral, 8) :: &
1068 & resbasecoef
1069  real(kind=realtype), dimension(ntimeintervalsspectral) :: &
1070 & intervalalpha, intervalalphadot
1071  real(kind=realtype), dimension(ntimeintervalsspectral) :: &
1072 & intervalmach, intervalmachdot
1073  real(kind=realtype), dimension(nsections) :: t
1074  integer(kind=inttype) :: i, sps, nn
1075 !speed of sound: for normalization of q derivatives
1076  real(kind=realtype) :: a
1077  real(kind=realtype) :: fact, factmoment
1078 ! functions
1079  real(kind=realtype), dimension(ntimeintervalsspectral) :: dphix, &
1080 & dphiy, dphiz
1081  real(kind=realtype), dimension(ntimeintervalsspectral) :: dphixdot, &
1082 & dphiydot, dphizdot
1083  real(kind=realtype) :: derivativerigidrotangle, &
1085  intrinsic sqrt
1086  real(kind=realtype) :: arg1
1087  fact = two/(gammainf*pinf*machcoef**2*surfaceref*lref**2)
1088  factmoment = fact/(lengthref*lref)
1089  if (tsqmode) then
1090  print*, &
1091 & 'ts q mode code needs to be updated in computetsderivatives!'
1092  stop
1093 ! !q is pitch
1094 ! do sps =1,ntimeintervalsspectral
1095 ! !compute the time of this intervavc
1096 ! t = timeunsteadyrestart
1097 ! if(equationmode == timespectral) then
1098 ! do nn=1,nsections
1099 ! t(nn) = t(nn) + (sps-1)*sections(nn)%timeperiod &
1100 ! / (ntimeintervalsspectral*1.0)
1101 ! enddo
1102 ! endif
1103 ! ! compute the time derivative of the rotation angles around the
1104 ! ! z-axis. i.e. compute q
1105 ! dphiz(sps) = derivativerigidrotangle(degreepolzrot, &
1106 ! coefpolzrot, &
1107 ! degreefourzrot, &
1108 ! omegafourzrot, &
1109 ! coscoeffourzrot, &
1110 ! sincoeffourzrot, t)
1111 ! ! add in q_dot computation
1112 ! dphizdot(sps) = secondderivativerigidrotangle(degreepolzrot, &
1113 ! coefpolzrot, &
1114 ! degreefourzrot, &
1115 ! omegafourzrot, &
1116 ! coscoeffourzrot, &
1117 ! sincoeffourzrot, t)
1118 ! end do
1119 ! !now compute dcl/dq
1120 ! do i =1,8
1121 ! call computeleastsquaresregression(basecoef(:,i),dphiz,ntimeintervalsspectral,dcdq(i),coef0(i))
1122 ! end do
1123 ! ! now subtract off estimated cl,cmz and use remainder to compute
1124 ! ! clqdot and cmzqdot.
1125 ! do i = 1,8
1126 ! do sps = 1,ntimeintervalsspectral
1127 ! resbasecoef(sps,i) = basecoef(sps,i)-(dcdq(i)*dphiz(sps)+coef0(i))
1128 ! enddo
1129 ! enddo
1130 ! !now normalize the results...
1131 ! a = sqrt(gammainf*pinfdim/rhoinfdim)
1132 ! dcdq = dcdq*timeref*2*(machgrid*a)/lengthref
1133 ! !now compute dcl/dpdot
1134 ! do i = 1,8
1135 ! call computeleastsquaresregression(resbasecoef(:,i),dphizdot,ntimeintervalsspectral,dcdqdot(i),coef0dot(i))
1136 ! enddo
1137  else if (tsalphamode) then
1138  do sps=1,ntimeintervalsspectral
1139 !compute the time of this interval
1141  if (equationmode .eq. timespectral) then
1142  do nn=1,nsections
1143  t(nn) = t(nn) + (sps-1)*sections(nn)%timeperiod/(&
1145  end do
1146  end if
1147  intervalalpha(sps) = tsalpha(degreepolalpha, coefpolalpha, &
1149 & sincoeffouralpha, t(1))
1150  intervalalphadot(sps) = tsalphadot(degreepolalpha, coefpolalpha&
1152 & sincoeffouralpha, t(1))
1153 ! this call is wrong!!!!
1154 !call getdirangle(veldirfreestream,liftdirection,liftindex,alpha+intervalalpha(sps), beta)
1155  basecoef(sps, 1) = fact*(force(1, sps)*liftdirection(1)+force(2&
1156 & , sps)*liftdirection(2)+force(3, sps)*liftdirection(3))
1157  basecoef(sps, 2) = fact*(force(1, sps)*dragdirection(1)+force(2&
1158 & , sps)*dragdirection(2)+force(3, sps)*dragdirection(3))
1159  basecoef(sps, 3) = force(1, sps)*fact
1160  basecoef(sps, 4) = force(2, sps)*fact
1161  basecoef(sps, 5) = force(3, sps)*fact
1162  basecoef(sps, 6) = moment(1, sps)*factmoment
1163  basecoef(sps, 7) = moment(2, sps)*factmoment
1164  basecoef(sps, 8) = moment(3, sps)*factmoment
1165  end do
1166 !now compute dcl/dalpha
1167  do i=1,8
1168  call computeleastsquaresregression(basecoef(:, i), intervalalpha&
1169 & , ntimeintervalsspectral, dcdalpha(&
1170 & i), coef0(i))
1171  end do
1172 ! now subtract off estimated cl,cmz and use remainder to compute
1173 ! clalphadot and cmzalphadot.
1174  do i=1,8
1175  do sps=1,ntimeintervalsspectral
1176  resbasecoef(sps, i) = basecoef(sps, i) - (dcdalpha(i)*&
1177 & intervalalpha(sps)+coef0(i))
1178  end do
1179  end do
1180 !now compute dci/dalphadot
1181  do i=1,8
1182  call computeleastsquaresregression(resbasecoef(:, i), &
1183 & intervalalphadot, &
1184 & ntimeintervalsspectral, dcdalphadot&
1185 & (i), coef0dot(i))
1186  end do
1187  arg1 = gammainf*pinfdim/rhoinfdim
1188  a = sqrt(arg1)
1189  dcdalphadot = dcdalphadot*2*(machgrid*a)/lengthref
1190  else
1191  call terminate('computetsderivatives', &
1192 & 'not a valid stability motion')
1193  end if
1194  end subroutine computetsderivatives
1195 
1196  subroutine getdirangle(freestreamaxis, liftaxis, liftindex, alpha, &
1197 & beta)
1198 !
1199 ! convert the wind axes to angle of attack and side slip angle.
1200 ! the direction angles alpha and beta are computed given the
1201 ! components of the wind direction vector (freestreamaxis), the
1202 ! lift direction vector (liftaxis) and assuming that the
1203 ! body direction (xb,yb,zb) is in the default ijk coordinate
1204 ! system. the rotations are determined by first determining
1205 ! whether the lift is primarily in the j or k direction and then
1206 ! determining the angles accordingly.
1207 ! direction vector:
1208 ! 1) rotation about the zb or yb -axis: alpha clockwise (cw)
1209 ! (xb,yb,zb) -> (x1,y1,z1)
1210 ! 2) rotation about the yl or z1 -axis: beta counter-clockwise
1211 ! (ccw) (x1,y1,z1) -> (xw,yw,zw)
1212 ! input arguments:
1213 ! freestreamaxis = wind vector in body axes
1214 ! liftaxis = lift direction vector in body axis
1215 ! output arguments:
1216 ! alpha = angle of attack in radians
1217 ! beta = side slip angle in radians
1218 !
1219  use constants
1220  implicit none
1221 !
1222 ! subroutine arguments.
1223 !
1224 ! real(kind=realtype), intent(in) :: xw, yw, zw
1225  real(kind=realtype), dimension(3), intent(in) :: freestreamaxis
1226  real(kind=realtype), dimension(3), intent(in) :: liftaxis
1227  real(kind=realtype), intent(out) :: alpha, beta
1228  integer(kind=inttype), intent(out) :: liftindex
1229 !
1230 ! local variables.
1231 !
1232  real(kind=realtype) :: rnorm
1233  integer(kind=inttype) :: flowindex, i
1234  real(kind=realtype), dimension(3) :: freestreamaxisnorm
1235  integer(kind=inttype) :: temp
1236  intrinsic abs
1237  intrinsic sqrt
1238  intrinsic asin
1239  intrinsic atan2
1240  real(kind=realtype) :: abs0
1241  real(kind=realtype) :: abs1
1242  real(kind=realtype) :: abs2
1243  real(kind=realtype) :: abs3
1244  real(kind=realtype) :: abs4
1245  real(kind=realtype) :: abs5
1246  real(kind=realtype) :: abs6
1247  real(kind=realtype) :: abs7
1248  real(kind=realtype) :: arg1
1249 ! assume domoniate flow is x
1250  flowindex = 1
1251  if (liftaxis(1) .ge. 0.) then
1252  abs0 = liftaxis(1)
1253  else
1254  abs0 = -liftaxis(1)
1255  end if
1256  if (liftaxis(2) .ge. 0.) then
1257  abs2 = liftaxis(2)
1258  else
1259  abs2 = -liftaxis(2)
1260  end if
1261  if (liftaxis(1) .ge. 0.) then
1262  abs4 = liftaxis(1)
1263  else
1264  abs4 = -liftaxis(1)
1265  end if
1266  if (liftaxis(3) .ge. 0.) then
1267  abs6 = liftaxis(3)
1268  else
1269  abs6 = -liftaxis(3)
1270  end if
1271 ! determine the dominant lift direction
1272  if (abs0 .gt. abs2 .and. abs4 .gt. abs6) then
1273  temp = 1
1274  else
1275  if (liftaxis(2) .ge. 0.) then
1276  abs1 = liftaxis(2)
1277  else
1278  abs1 = -liftaxis(2)
1279  end if
1280  if (liftaxis(1) .ge. 0.) then
1281  abs3 = liftaxis(1)
1282  else
1283  abs3 = -liftaxis(1)
1284  end if
1285  if (liftaxis(2) .ge. 0.) then
1286  abs5 = liftaxis(2)
1287  else
1288  abs5 = -liftaxis(2)
1289  end if
1290  if (liftaxis(3) .ge. 0.) then
1291  abs7 = liftaxis(3)
1292  else
1293  abs7 = -liftaxis(3)
1294  end if
1295  if (abs1 .gt. abs3 .and. abs5 .gt. abs7) then
1296  temp = 2
1297  else
1298  temp = 3
1299  end if
1300  end if
1301  liftindex = temp
1302 ! normalize the freestreamdirection vector.
1303  arg1 = freestreamaxis(1)**2 + freestreamaxis(2)**2 + freestreamaxis(&
1304 & 3)**2
1305  rnorm = sqrt(arg1)
1306  do i=1,3
1307  freestreamaxisnorm(i) = freestreamaxis(i)/rnorm
1308  end do
1309  if (liftindex .eq. 2) then
1310 ! different coordinate system for aerosurf
1311 ! wing is in z- direction
1312 ! compute angle of attack alpha.
1313  alpha = asin(freestreamaxisnorm(2))
1314 ! compute side-slip angle beta.
1315  beta = -atan2(freestreamaxisnorm(3), freestreamaxisnorm(1))
1316  else if (liftindex .eq. 3) then
1317 ! wing is in y- direction
1318 ! compute angle of attack alpha.
1319  alpha = asin(freestreamaxisnorm(3))
1320 ! compute side-slip angle beta.
1321  beta = atan2(freestreamaxisnorm(2), freestreamaxisnorm(1))
1322  else
1323  call terminate('getdirangle', 'invalid lift direction')
1324  end if
1325  end subroutine getdirangle
1326 
1328 !
1329 ! runs the time spectral stability derivative routines from the
1330 ! main program file
1331 !
1332  use precision
1333  implicit none
1334 !
1335 ! local variables.
1336 !
1337  real(kind=realtype), dimension(8) :: dcdalpha, dcdalphadot, dcdbeta&
1338 & , dcdbetadot, dcdmach, dcdmachdot
1339  real(kind=realtype), dimension(8) :: dcdp, dcdpdot, dcdq, dcdqdot, &
1340 & dcdr, dcdrdot
1341  real(kind=realtype), dimension(8) :: coef0, coef0dot
1342 !call computetsderivatives(coef0,dcdalpha,dcdalphadot,dcdq,dcdqdot)
1343  end subroutine stabilityderivativedriver
1344 
1346 !
1347 ! setcoeftimeintegrator determines the coefficients of the
1348 ! time integration scheme in unsteady mode. normally these are
1349 ! equal to the coefficients corresponding to the specified
1350 ! accuracy. however during the initial phase there are not
1351 ! enough states in the past and the accuracy is reduced.
1352 !
1353  use constants
1354  use inputunsteady
1355  use inputphysics
1356  use iteration
1357  use monitor
1358  implicit none
1359 !
1360 ! local variables.
1361 !
1362  integer(kind=inttype) :: nn, nlevelsset
1363 ! determine which time integrator must be used.
1364 ! modified by hdn
1365  select case (timeaccuracy)
1366  case (firstorder)
1367 ! 1st order. no need to check the number of available
1368 ! states in the past. set the two coefficients and
1369 ! nlevelsset to 2.
1370  coeftime(0) = 1.0_realtype
1371  coeftime(1) = -1.0_realtype
1372  if (useale .and. equationmode .eq. unsteady) then
1373  coeftimeale(1) = 1.0_realtype
1374  coefmeshale(1, 1) = half
1375  coefmeshale(1, 2) = half
1376  end if
1377  nlevelsset = 2
1378 !--------------------------------------------------
1379  case (secondorder)
1380 ! second order time integrator. determine the amount of
1381 ! available states and set the coefficients accordingly.
1382  select case (noldsolavail)
1383  case (1_inttype)
1384  coeftime(0) = 1.0_realtype
1385  coeftime(1) = -1.0_realtype
1386  if (useale .and. equationmode .eq. unsteady) then
1387  coeftimeale(1) = half
1388  coeftimeale(2) = half
1389  coeftimeale(3) = zero
1390  coeftimeale(4) = zero
1391  coefmeshale(1, 1) = half
1392  coefmeshale(1, 2) = half
1393  coefmeshale(2, 1) = half
1394  coefmeshale(2, 2) = half
1395  end if
1396  nlevelsset = 2
1397  case default
1398 ! 2 or bigger.
1399  coeftime(0) = 1.5_realtype
1400  coeftime(1) = -2.0_realtype
1401  coeftime(2) = 0.5_realtype
1402  if (useale .and. equationmode .eq. unsteady) then
1405  coeftimeale(3) = -fourth
1406  coeftimeale(4) = -fourth
1407  coefmeshale(1, 1) = half*(1.0_realtype+1.0_realtype/sqrtthree)
1408  coefmeshale(1, 2) = half*(1.0_realtype-1.0_realtype/sqrtthree)
1409  coefmeshale(2, 1) = coefmeshale(1, 2)
1410  coefmeshale(2, 2) = coefmeshale(1, 1)
1411  end if
1412  nlevelsset = 3
1413  end select
1414 !--------------------------------------------------
1415  case (thirdorder)
1416 ! third order time integrator. determine the amount of
1417 ! available states and set the coefficients accordingly.
1418  select case (noldsolavail)
1419  case (1_inttype)
1420  coeftime(0) = 1.0_realtype
1421  coeftime(1) = -1.0_realtype
1422  if (useale .and. equationmode .eq. unsteady) then
1423  coeftimeale(1) = 1.0_realtype
1424  coefmeshale(1, 1) = half
1425  coefmeshale(1, 2) = half
1426  end if
1427  nlevelsset = 2
1428  case (2_inttype)
1429  coeftime(0) = 1.5_realtype
1430  coeftime(1) = -2.0_realtype
1431  coeftime(2) = 0.5_realtype
1432  if (useale .and. equationmode .eq. unsteady) then
1434  coeftimeale(2) = -fourth
1435  coefmeshale(1, 1) = half*(1.0_realtype+1.0_realtype/sqrtthree)
1436  coefmeshale(1, 2) = half*(1.0_realtype-1.0_realtype/sqrtthree)
1437  coefmeshale(2, 1) = coefmeshale(1, 2)
1438  coefmeshale(2, 2) = coefmeshale(1, 1)
1439  end if
1440  nlevelsset = 3
1441  case default
1442 ! 3 or bigger.
1443  coeftime(0) = 11.0_realtype/6.0_realtype
1444  coeftime(1) = -3.0_realtype
1445  coeftime(2) = 1.5_realtype
1446  coeftime(3) = -(1.0_realtype/3.0_realtype)
1447 ! these numbers are not correct
1448 ! do not use 3rd order ale for now
1449  if (useale .and. equationmode .eq. unsteady) then
1450  print*, 'third-order ale not implemented yet.'
1453  coeftimeale(3) = -fourth
1454  coeftimeale(4) = -fourth
1455  coefmeshale(1, 1) = half*(1.0_realtype+1.0_realtype/sqrtthree)
1456  coefmeshale(1, 2) = half*(1.0_realtype-1.0_realtype/sqrtthree)
1457  coefmeshale(2, 1) = coefmeshale(1, 2)
1458  coefmeshale(2, 2) = coefmeshale(1, 1)
1459  coefmeshale(3, 1) = coefmeshale(1, 2)
1460  coefmeshale(3, 2) = coefmeshale(1, 1)
1461  end if
1462  nlevelsset = 4
1463  end select
1464  end select
1465 ! set the rest of the coefficients to 0 if not enough states
1466 ! in the past are available.
1467  do nn=nlevelsset,noldlevels
1468  coeftime(nn) = zero
1469  end do
1470  end subroutine setcoeftimeintegrator
1471 
1472 ! differentiation of mynorm2 in forward (tangent) mode (with options i4 dr8 r8):
1473 ! variations of useful results: mynorm2
1474 ! with respect to varying inputs: x
1475  real(kind=realtype) function mynorm2_d(x, xd, mynorm2)
1476  use constants
1477  implicit none
1478  real(kind=realtype), dimension(3), intent(in) :: x
1479  real(kind=realtype), dimension(3), intent(in) :: xd
1480  real(kind=realtype) :: mynorm2
1481  intrinsic sqrt
1482  real(kind=realtype) :: arg1
1483  real(kind=realtype) :: arg1d
1484  real(kind=realtype) :: temp
1485  arg1d = 2*x(1)*xd(1) + 2*x(2)*xd(2) + 2*x(3)*xd(3)
1486  arg1 = x(1)**2 + x(2)**2 + x(3)**2
1487  temp = sqrt(arg1)
1488  if (arg1 .eq. 0.0_8) then
1489  mynorm2_d = 0.0_8
1490  else
1491  mynorm2_d = arg1d/(2.0*temp)
1492  end if
1493  mynorm2 = temp
1494  end function mynorm2_d
1495 
1496  function mynorm2(x)
1497  use constants
1498  implicit none
1499  real(kind=realtype), dimension(3), intent(in) :: x
1500  real(kind=realtype) :: mynorm2
1501  intrinsic sqrt
1502  real(kind=realtype) :: arg1
1503  arg1 = x(1)**2 + x(2)**2 + x(3)**2
1504  mynorm2 = sqrt(arg1)
1505  end function mynorm2
1506 
1507  function iswalltype(btype)
1508  use constants
1509  implicit none
1510  integer(kind=inttype) :: btype
1511  logical :: iswalltype
1512  iswalltype = .false.
1513  if ((btype .eq. nswalladiabatic .or. btype .eq. nswallisothermal) &
1514 & .or. btype .eq. eulerwall) iswalltype = .true.
1515  end function iswalltype
1516 
1517 ! differentiation of cross_prod in forward (tangent) mode (with options i4 dr8 r8):
1518 ! variations of useful results: c
1519 ! with respect to varying inputs: a b c
1520  subroutine cross_prod_d(a, ad, b, bd, c, cd)
1521  use precision
1522  implicit none
1523 ! inputs
1524  real(kind=realtype), dimension(3), intent(in) :: a, b
1525  real(kind=realtype), dimension(3), intent(in) :: ad, bd
1526 ! outputs
1527  real(kind=realtype), dimension(3), intent(out) :: c
1528  real(kind=realtype), dimension(3), intent(out) :: cd
1529  cd(1) = b(3)*ad(2) + a(2)*bd(3) - b(2)*ad(3) - a(3)*bd(2)
1530  c(1) = a(2)*b(3) - a(3)*b(2)
1531  cd(2) = b(1)*ad(3) + a(3)*bd(1) - b(3)*ad(1) - a(1)*bd(3)
1532  c(2) = a(3)*b(1) - a(1)*b(3)
1533  cd(3) = b(2)*ad(1) + a(1)*bd(2) - b(1)*ad(2) - a(2)*bd(1)
1534  c(3) = a(1)*b(2) - a(2)*b(1)
1535  end subroutine cross_prod_d
1536 
1537  subroutine cross_prod(a, b, c)
1538  use precision
1539  implicit none
1540 ! inputs
1541  real(kind=realtype), dimension(3), intent(in) :: a, b
1542 ! outputs
1543  real(kind=realtype), dimension(3), intent(out) :: c
1544  c(1) = a(2)*b(3) - a(3)*b(2)
1545  c(2) = a(3)*b(1) - a(1)*b(3)
1546  c(3) = a(1)*b(2) - a(2)*b(1)
1547  end subroutine cross_prod
1548 
1549  subroutine siangle(angle, mult, trans)
1550  use constants
1551  use su_cgns, only : radian, degree
1552  implicit none
1553 !
1554 ! subroutine arguments.
1555 !
1556  integer, intent(in) :: angle
1557  real(kind=realtype), intent(out) :: mult, trans
1558 ! determine the situation we are having here.
1559  if (angle .eq. radian) then
1560 ! angle is already given in radians. no need for a conversion.
1561  mult = one
1562  trans = zero
1563  else if (angle .eq. degree) then
1564 ! angle is given in degrees. a multiplication must be performed.
1565  mult = pi/180.0_realtype
1566  trans = zero
1567  else
1568  call terminate('siangle', &
1569 & 'no idea how to convert this to si units')
1570  end if
1571  end subroutine siangle
1572 
1573  subroutine sidensity(mass, len, mult, trans)
1574 !
1575 ! sidensity computes the conversion from the given density
1576 ! unit, which can be constructed from mass and length, to the
1577 ! si-unit kg/m^3. the conversion will look like:
1578 ! density in kg/m^3 = mult*(density in ncu) + trans.
1579 ! ncu means non-christian units, i.e. everything that is not si.
1580 !
1581  use constants
1582  use su_cgns, only : kilogram, meter
1583  implicit none
1584 !
1585 ! subroutine arguments.
1586 !
1587  integer, intent(in) :: mass, len
1588  real(kind=realtype), intent(out) :: mult, trans
1589 ! determine the situation we are having here.
1590  if (mass .eq. kilogram .and. len .eq. meter) then
1591 ! density is given in kg/m^3, i.e. no need for a conversion.
1592  mult = one
1593  trans = zero
1594  else
1595  call terminate('sidensity', &
1596 & 'no idea how to convert this to si units')
1597  end if
1598  end subroutine sidensity
1599 
1600  subroutine silen(len, mult, trans)
1601 !
1602 ! silen computes the conversion from the given length unit to
1603 ! the si-unit meter. the conversion will look like:
1604 ! length in meter = mult*(length in ncu) + trans.
1605 ! ncu means non-christian units, i.e. everything that is not si.
1606 !
1607  use constants
1608  use su_cgns, only : meter, centimeter, millimeter, foot, inch
1609  implicit none
1610 !
1611 ! subroutine arguments.
1612 !
1613  integer, intent(in) :: len
1614  real(kind=realtype), intent(out) :: mult, trans
1615 ! determine the situation we are having here.
1616  select case (len)
1617  case (meter)
1618  mult = one
1619  trans = zero
1620  case (centimeter)
1621  mult = 0.01_realtype
1622  trans = zero
1623  case (millimeter)
1624  mult = 0.001_realtype
1625  trans = zero
1626  case (foot)
1627  mult = 0.3048_realtype
1628  trans = zero
1629  case (inch)
1630  mult = 0.0254_realtype
1631  trans = zero
1632  case default
1633  call terminate('silen', 'no idea how to convert this to si units')
1634  end select
1635  end subroutine silen
1636 
1637  subroutine sipressure(mass, len, time, mult, trans)
1638 !
1639 ! sipressure computes the conversion from the given pressure
1640 ! unit, which can be constructed from mass, length and time, to
1641 ! the si-unit pa. the conversion will look like:
1642 ! pressure in pa = mult*(pressure in ncu) + trans.
1643 ! ncu means non-christian units, i.e. everything that is not si.
1644 !
1645  use constants
1646  use su_cgns, only : kilogram, meter, second
1647  implicit none
1648 !
1649 ! subroutine arguments.
1650 !
1651  integer, intent(in) :: mass, len, time
1652  real(kind=realtype), intent(out) :: mult, trans
1653 ! determine the situation we are having here.
1654  if (mass .eq. kilogram .and. len .eq. meter .and. time .eq. second) &
1655 & then
1656 ! pressure is given in pa, i.e. no need for a conversion.
1657  mult = one
1658  trans = zero
1659  else
1660  call terminate('sipressure', &
1661 & 'no idea how to convert this to si units')
1662  end if
1663  end subroutine sipressure
1664 
1665  subroutine sitemperature(temp, mult, trans)
1666 !
1667 ! sitemperature computes the conversion from the given
1668 ! temperature unit to the si-unit kelvin. the conversion will
1669 ! look like:
1670 ! temperature in k = mult*(temperature in ncu) + trans.
1671 ! ncu means non-christian units, i.e. everything that is not si.
1672 !
1673  use constants
1674  use su_cgns, only : kelvin, celsius, rankine, fahrenheit
1675  implicit none
1676 !
1677 ! subroutine arguments.
1678 !
1679  integer, intent(in) :: temp
1680  real(kind=realtype), intent(out) :: mult, trans
1681 ! determine the situation we are having here.
1682  select case (temp)
1683  case (kelvin)
1684 ! temperature is already given in kelvin. no need to convert.
1685  mult = one
1686  trans = zero
1687  case (celsius)
1688 ! is it celcius or celsius?
1689 ! temperature is in celsius. only an offset must be applied.
1690  mult = one
1691  trans = 273.16_realtype
1692  case (rankine)
1693 ! temperature is in rankine. only a multiplication needs to
1694 ! be performed.
1695  mult = 5.0_realtype/9.0_realtype
1696  trans = zero
1697  case (fahrenheit)
1698 ! temperature is in fahrenheit. both a multiplication and an
1699 ! offset must be applied.
1700  mult = 5.0_realtype/9.0_realtype
1701  trans = 255.382
1702  case default
1703 ! unknown temperature unit.
1704  call terminate('sitemperature', &
1705 & 'no idea how to convert this to si units')
1706  end select
1707  end subroutine sitemperature
1708 
1709  subroutine siturb(mass, len, time, temp, turbname, mult, trans)
1710 !
1711 ! siturb computes the conversion from the given turbulence
1712 ! unit, which can be constructed from mass, len, time and temp,
1713 ! to the si-unit for the given variable. the conversion will
1714 ! look like: var in si = mult*(var in ncu) + trans.
1715 ! ncu means non-christian units, i.e. everything that is not si.
1716 !
1717  use constants
1718  use su_cgns, only : kilogram, meter, second, kelvin
1719  implicit none
1720 !
1721 ! subroutine arguments.
1722 !
1723  integer, intent(in) :: mass, len, time, temp
1724  character(len=*), intent(in) :: turbname
1725  real(kind=realtype), intent(out) :: mult, trans
1726 ! determine the situation we are having here.
1727  if (mass .eq. kilogram .and. len .eq. meter .and. time .eq. second &
1728 & .and. temp .eq. kelvin) then
1729 ! everthing is already in si units. no conversion needed.
1730  mult = one
1731  trans = zero
1732  else
1733  call terminate('siturb', 'no idea how to convert this to si units'&
1734 & )
1735  end if
1736  end subroutine siturb
1737 
1738  subroutine sivelocity(length, time, mult, trans)
1739 !
1740 ! sivelocity computes the conversion from the given velocity
1741 ! unit, which can be constructed from length and time, to the
1742 ! si-unit m/s. the conversion will look like:
1743 ! velocity in m/s = mult*(velocity in ncu) + trans.
1744 ! ncu means non-christian units, i.e. everything that is not si.
1745 !
1746  use constants
1747  use su_cgns, only : meter, centimeter, millimeter, foot, inch, &
1748 & second
1749  implicit none
1750 !
1751 ! subroutine arguments.
1752 !
1753  integer, intent(in) :: length, time
1754  real(kind=realtype), intent(out) :: mult, trans
1755 ! determine the situation we are having here.
1756 ! first the length.
1757  select case (length)
1758  case (meter)
1759  mult = one
1760  trans = zero
1761  case (centimeter)
1762  mult = 0.01_realtype
1763  trans = zero
1764  case (millimeter)
1765  mult = 0.001_realtype
1766  trans = zero
1767  case (foot)
1768  mult = 0.3048_realtype
1769  trans = zero
1770  case (inch)
1771  mult = 0.0254_realtype
1772  trans = zero
1773  case default
1774  call terminate('sivelocity', &
1775 & 'no idea how to convert this length to si units')
1776  end select
1777 ! and the time.
1778  select case (time)
1779  case (second)
1780  mult = mult
1781  case default
1782  call terminate('sivelocity', &
1783 & 'no idea how to convert this time to si units')
1784  end select
1785  end subroutine sivelocity
1786 ! ----------------------------------------------------------------------
1787 ! |
1788 ! no tapenade routine below this line |
1789 ! |
1790 ! ----------------------------------------------------------------------
1791 
1792 end module utils_d
1793 
Definition: BCData.F90:1
real(kind=realtype), dimension(:, :, :), pointer sfacek
real(kind=realtype), dimension(:, :, :), pointer gamma
logical addgridvelocities
integer(kind=inttype) jl
integer(kind=inttype) nx
real(kind=realtype), dimension(:, :, :), pointer p
integer(kind=inttype) ny
integer(kind=inttype) ie
real(kind=realtype), dimension(:, :, :, :), pointer w
real(kind=realtype), dimension(:, :, :), pointer sfacei
real(kind=realtype), dimension(:, :, :), pointer d2wall
integer(kind=inttype), dimension(:, :, :), pointer globalcell
integer(kind=inttype) jb
integer(kind=inttype) kb
real(kind=realtype), dimension(:, :, :), pointer rlv
integer(kind=inttype), dimension(:), pointer bcfaceid
real(kind=realtype), dimension(:, :, :, :), pointer si
real(kind=realtype), dimension(:, :, :, :), pointer sj
real(kind=realtype), dimension(:, :, :, :), pointer s
real(kind=realtype), dimension(:, :, :), pointer rev
real(kind=realtype), dimension(:, :, :, :), pointer sk
integer(kind=inttype) ib
real(kind=realtype), dimension(:, :, :), pointer sfacej
integer(kind=inttype) nz
integer(kind=inttype) je
integer(kind=inttype) ke
real(kind=realtype), dimension(:, :, :, :), pointer x
integer(kind=inttype) kl
integer(kind=inttype) il
integer adflow_comm_world
integer(kind=inttype), parameter firstorder
Definition: constants.F90:142
integer(kind=inttype), parameter eulerwall
Definition: constants.F90:262
real(kind=realtype), parameter zero
Definition: constants.F90:71
integer(kind=inttype), parameter imax
Definition: constants.F90:293
real(kind=realtype), parameter threefourth
Definition: constants.F90:85
integer(kind=inttype), parameter kmin
Definition: constants.F90:296
real(kind=realtype), parameter pi
Definition: constants.F90:22
integer(kind=inttype), parameter jmax
Definition: constants.F90:295
integer(kind=inttype), parameter nswalladiabatic
Definition: constants.F90:260
integer(kind=inttype), parameter timespectral
Definition: constants.F90:115
integer(kind=inttype), parameter unsteady
Definition: constants.F90:115
real(kind=realtype), parameter one
Definition: constants.F90:72
real(kind=realtype), parameter half
Definition: constants.F90:80
integer(kind=inttype), parameter imin
Definition: constants.F90:292
integer(kind=inttype), parameter steady
Definition: constants.F90:115
real(kind=realtype), parameter two
Definition: constants.F90:73
real(kind=realtype), parameter fourth
Definition: constants.F90:82
integer(kind=inttype), parameter nswallisothermal
Definition: constants.F90:261
real(kind=realtype), parameter sqrtthree
Definition: constants.F90:86
integer(kind=inttype), parameter thirdorder
Definition: constants.F90:142
integer(kind=inttype), parameter secondorder
Definition: constants.F90:142
integer(kind=inttype), parameter kmax
Definition: constants.F90:297
integer(kind=inttype), parameter ransequations
Definition: constants.F90:110
integer(kind=inttype), parameter jmin
Definition: constants.F90:294
real(kind=realtype) rhoinfdim
real(kind=realtype) gammainf
real(kind=realtype) pinfdim
real(kind=realtype) pinf
real(kind=realtype) lref
real(kind=realtype) timeref
real(kind=realtype) timerefd
integer(kind=inttype) degreefouryrot
Definition: inputParam.F90:354
real(kind=realtype) omegafouralpha
Definition: inputParam.F90:404
integer(kind=inttype) degreefourxrot
Definition: inputParam.F90:353
integer(kind=inttype) degreepolxrot
Definition: inputParam.F90:337
real(kind=realtype) omegafouryrot
Definition: inputParam.F90:363
integer(kind=inttype) degreepolyrot
Definition: inputParam.F90:338
real(kind=realtype), dimension(:), allocatable coefpolxrot
Definition: inputParam.F90:345
real(kind=realtype) omegafourzrot
Definition: inputParam.F90:364
real(kind=realtype) omegafourxrot
Definition: inputParam.F90:362
real(kind=realtype), dimension(:), allocatable sincoeffouryrot
Definition: inputParam.F90:385
real(kind=realtype), dimension(:), allocatable coscoeffourxrot
Definition: inputParam.F90:373
real(kind=realtype), dimension(:), allocatable sincoeffourzrot
Definition: inputParam.F90:386
real(kind=realtype), dimension(:), allocatable sincoeffouralpha
Definition: inputParam.F90:415
integer(kind=inttype) degreepolzrot
Definition: inputParam.F90:339
real(kind=realtype), dimension(:), allocatable coefpolalpha
Definition: inputParam.F90:394
real(kind=realtype), dimension(:), allocatable coscoeffouryrot
Definition: inputParam.F90:374
real(kind=realtype), dimension(:), allocatable coscoeffouralpha
Definition: inputParam.F90:409
integer(kind=inttype) degreefourzrot
Definition: inputParam.F90:355
real(kind=realtype), dimension(:), allocatable coefpolzrot
Definition: inputParam.F90:347
real(kind=realtype), dimension(:), allocatable coefpolyrot
Definition: inputParam.F90:346
real(kind=realtype), dimension(3) rotpoint
Definition: inputParam.F90:330
integer(kind=inttype) degreepolalpha
Definition: inputParam.F90:390
integer(kind=inttype) degreefouralpha
Definition: inputParam.F90:399
real(kind=realtype), dimension(:), allocatable coscoeffourzrot
Definition: inputParam.F90:375
real(kind=realtype), dimension(:), allocatable sincoeffourxrot
Definition: inputParam.F90:384
integer(kind=inttype) equations
Definition: inputParam.F90:583
integer(kind=inttype) equationmode
Definition: inputParam.F90:583
real(kind=realtype), dimension(3) pointref
Definition: inputParam.F90:602
integer(kind=inttype) liftindex
Definition: inputParam.F90:592
real(kind=realtype), dimension(3) dragdirection
Definition: inputParam.F90:601
real(kind=realtype), dimension(3) pointrefec
Definition: inputParam.F90:626
real(kind=realtype) lengthref
Definition: inputParam.F90:598
real(kind=realtype) machgrid
Definition: inputParam.F90:593
real(kind=realtype) machcoef
Definition: inputParam.F90:593
real(kind=realtype), dimension(3) liftdirection
Definition: inputParam.F90:600
real(kind=realtype) surfaceref
Definition: inputParam.F90:598
integer(kind=inttype) cpmodel
Definition: inputParam.F90:584
integer(kind=inttype) ntimeintervalsspectral
Definition: inputParam.F90:645
logical useale
Definition: inputParam.F90:754
integer(kind=inttype) timeaccuracy
Definition: inputParam.F90:730
integer(kind=inttype) noldlevels
Definition: iteration.f90:79
real(kind=realtype), dimension(:, :), allocatable coefmeshale
Definition: iteration.f90:109
integer(kind=inttype) currentlevel
Definition: iteration.f90:18
integer(kind=inttype) groundlevel
Definition: iteration.f90:18
real(kind=realtype), dimension(:), allocatable coeftime
Definition: iteration.f90:80
real(kind=realtype), dimension(:), allocatable coeftimeale
Definition: iteration.f90:108
integer(kind=inttype) noldsolavail
Definition: iteration.f90:79
real(kind=realtype) timeunsteadyrestart
Definition: monitor.f90:98
integer, parameter realtype
Definition: precision.F90:112
integer(kind=inttype) nsections
Definition: section.f90:44
type(sectiontype), dimension(:), allocatable sections
Definition: section.f90:46
subroutine sivelocity(length, time, mult, trans)
Definition: utils_d.f90:1739
subroutine computetsderivatives(force, moment, coef0, dcdalpha, dcdalphadot, dcdq, dcdqdot)
Definition: utils_d.f90:1040
real(kind=realtype) function mydim_d(x, xd, y, yd, mydim)
Definition: utils_d.f90:464
subroutine cross_prod(a, b, c)
Definition: utils_d.f90:1538
real(kind=realtype) function secondderivativerigidrotangle(degreepolrot, coefpolrot, degreefourrot, omegafourrot, coscoeffourrot, sincoeffourrot, t)
Definition: utils_d.f90:619
logical function iswalltype(btype)
Definition: utils_d.f90:1508
subroutine sitemperature(temp, mult, trans)
Definition: utils_d.f90:1666
real(kind=realtype) function tsbetadot(degreepolbeta, coefpolbeta, degreefourbeta, omegafourbeta, coscoeffourbeta, sincoeffourbeta, t)
Definition: utils_d.f90:84
subroutine setcoeftimeintegrator()
Definition: utils_d.f90:1346
subroutine getdirangle(freestreamaxis, liftaxis, liftindex, alpha, beta)
Definition: utils_d.f90:1198
subroutine siturb(mass, len, time, temp, turbname, mult, trans)
Definition: utils_d.f90:1710
subroutine silen(len, mult, trans)
Definition: utils_d.f90:1601
subroutine computerootbendingmoment(cf, cm, bendingmoment)
Definition: utils_d.f90:971
real(kind=realtype) function derivativerigidrotangle(degreepolrot, coefpolrot, degreefourrot, omegafourrot, coscoeffourrot, sincoeffourrot, t)
Definition: utils_d.f90:408
real(kind=realtype) function mynorm2(x)
Definition: utils_d.f90:1497
real(kind=realtype) function mynorm2_d(x, xd, mynorm2)
Definition: utils_d.f90:1476
real(kind=realtype) function mydim(x, y)
Definition: utils_d.f90:478
subroutine rotmatrixrigidbody(tnew, told, rotationmatrix, rotationpoint)
Definition: utils_d.f90:516
real(kind=realtype) function derivativerigidrotangle_d(degreepolrot, coefpolrot, degreefourrot, omegafourrot, coscoeffourrot, sincoeffourrot, t, derivativerigidrotangle)
Definition: utils_d.f90:352
character(len=n) function char2str(chararray, n)
Definition: utils_d.f90:9
logical function getcorrectfork()
Definition: utils_d.f90:487
real(kind=realtype) function rigidrotangle(degreepolrot, coefpolrot, degreefourrot, omegafourrot, coscoeffourrot, sincoeffourrot, t)
Definition: utils_d.f90:673
real(kind=realtype) function tsbeta(degreepolbeta, coefpolbeta, degreefourbeta, omegafourbeta, coscoeffourbeta, sincoeffourbeta, t)
Definition: utils_d.f90:31
subroutine siangle(angle, mult, trans)
Definition: utils_d.f90:1550
real(kind=realtype) function tsalphadot(degreepolalpha, coefpolalpha, degreefouralpha, omegafouralpha, coscoeffouralpha, sincoeffouralpha, t)
Definition: utils_d.f90:296
subroutine computeleastsquaresregression(y, x, npts, m, b)
Definition: utils_d.f90:1010
subroutine cross_prod_d(a, ad, b, bd, c, cd)
Definition: utils_d.f90:1521
subroutine sidensity(mass, len, mult, trans)
Definition: utils_d.f90:1574
real(kind=realtype) function tsalpha(degreepolalpha, coefpolalpha, degreefouralpha, omegafouralpha, coscoeffouralpha, sincoeffouralpha, t)
Definition: utils_d.f90:242
subroutine sipressure(mass, len, time, mult, trans)
Definition: utils_d.f90:1638
subroutine setbcpointers(nn, spatialpointers)
Definition: utils_d.f90:726
real(kind=realtype) function tsmachdot(degreepolmach, coefpolmach, degreefourmach, omegafourmach, coscoeffourmach, sincoeffourmach, t)
Definition: utils_d.f90:190
real(kind=realtype) function tsmach(degreepolmach, coefpolmach, degreefourmach, omegafourmach, coscoeffourmach, sincoeffourmach, t)
Definition: utils_d.f90:136
subroutine terminate(routinename, errormessage)
Definition: utils_d.f90:500
subroutine stabilityderivativedriver()
Definition: utils_d.f90:1328