ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
utils.F90
Go to the documentation of this file.
1 module utils
2  implicit none
3 
4 contains
5 
6  function char2str(charArray, n)
7  use constants
8  !
9  ! some gymnastics to cast a char array to string
10  !
11  implicit none
12  !
13  ! Function arguments.
14  !
15  character, dimension(maxCGNSNameLen), intent(in) :: chararray
16  integer(kind=intType), intent(in) :: n
17  !
18  ! Function type
19  !
20  character(len=n) :: char2str
21  !
22  ! Local variables.
23  !
24  integer(kind=intType) :: i
25  do i = 1, n
26  char2str(i:i) = chararray(i)
27  end do
28 
29  end function char2str
30 
31  function tsbeta(degreePolBeta, coefPolBeta, &
32  degreeFourBeta, omegaFourBeta, &
33  cosCoefFourBeta, sinCoefFourBeta, t)
34  !
35  ! TSbeta computes the angle of attack for a given Time interval
36  ! in a time spectral solution.
37  !
38  use constants
39  use inputphysics, only: equationmode
40  implicit none
41  !
42  ! Function type
43  !
44  real(kind=realtype) :: tsbeta
45  !
46  ! Function arguments.
47  !
48  integer(kind=intType), intent(in) :: degreepolbeta
49  integer(kind=intType), intent(in) :: degreefourbeta
50 
51  real(kind=realtype), intent(in) :: omegafourbeta, t
52 
53  real(kind=realtype), dimension(0:*), intent(in) :: coefpolbeta
54  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourbeta
55  real(kind=realtype), dimension(*), intent(in) :: sincoeffourbeta
56  !
57  ! Local variables.
58  !
59  integer(kind=intType) :: nn
60 
61  real(kind=realtype) :: beta, val
62 
63  ! Return immediately if this is a steady computation.
64 
65  if (equationmode == steady) then
66  tsbeta = zero
67  return
68  end if
69 
70  ! Compute the polynomial contribution. If no polynomial was
71  ! specified, the value of index 0 is set to zero automatically.
72 
73  beta = coefpolbeta(0)
74  do nn = 1, degreepolbeta
75  beta = beta + coefpolbeta(nn) * (t**nn)
76  end do
77 
78  ! Compute the fourier contribution. Again the cosine coefficient
79  ! of index 0 is defaulted to zero if not specified.
80 
81  beta = beta + coscoeffourbeta(0)
82  do nn = 1, degreefourbeta
83  val = nn * omegafourbeta * t
84  beta = beta + coscoeffourbeta(nn) * cos(val) &
85  + sincoeffourbeta(nn) * sin(val)
86  end do
87 
88  ! Set TSBeta to phi.
89 
90  tsbeta = beta
91 
92  end function tsbeta
93 
94  function tsbetadot(degreePolBeta, coefPolBeta, &
95  degreeFourBeta, omegaFourBeta, &
96  cosCoefFourBeta, sinCoefFourBeta, t)
97  !
98  ! TSbeta computes the angle of attack for a given Time interval
99  ! in a time spectral solution.
100  !
101  use constants
102  use inputphysics, only: equationmode
103  implicit none
104  !
105  ! Function type
106  !
107  real(kind=realtype) :: tsbetadot
108  !
109  ! Function arguments.
110  !
111  integer(kind=intType), intent(in) :: degreepolbeta
112  integer(kind=intType), intent(in) :: degreefourbeta
113 
114  real(kind=realtype), intent(in) :: omegafourbeta, t
115 
116  real(kind=realtype), dimension(0:*), intent(in) :: coefpolbeta
117  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourbeta
118  real(kind=realtype), dimension(*), intent(in) :: sincoeffourbeta
119  !
120  ! Local variables.
121  !
122  integer(kind=intType) :: nn
123 
124  real(kind=realtype) :: betadot, val
125 
126  ! Return immediately if this is a steady computation.
127 
128  if (equationmode == steady) then
129  tsbetadot = zero
130  return
131  end if
132 
133  ! Compute the polynomial contribution. If no polynomial was
134  ! specified, the value of index 0 is set to zero automatically.
135 
136  betadot = zero
137  do nn = 1, degreepolbeta
138  betadot = betadot + nn * coefpolbeta(nn) * (t**(nn - 1))
139  end do
140 
141  ! Compute the fourier contribution. Again the cosine coefficient
142  ! of index 0 is defaulted to zero if not specified.
143 
144  do nn = 1, degreefourbeta
145  val = nn * omegafourbeta
146  betadot = betadot - val * coscoeffourbeta(nn) * sin(val * t) &
147  + val * sincoeffourbeta(nn) * cos(val * t)
148  end do
149 
150  ! Set TSBeta to phi.
151 
152  tsbetadot = betadot
153 
154  end function tsbetadot
155 
156  function tsmach(degreePolMach, coefPolMach, &
157  degreeFourMach, omegaFourMach, &
158  cosCoefFourMach, sinCoefFourMach, t)
159  !
160  ! TSMach computes the Mach Number for a given time interval
161  ! in a time spectral solution.
162  !
163  use constants
164  use inputphysics, only: equationmode
165  implicit none
166  !
167  ! Function type
168  !
169  real(kind=realtype) :: tsmach
170  !
171  ! Function arguments.
172  !
173  integer(kind=intType), intent(in) :: degreepolmach
174  integer(kind=intType), intent(in) :: degreefourmach
175 
176  real(kind=realtype), intent(in) :: omegafourmach, t
177 
178  real(kind=realtype), dimension(0:*), intent(in) :: coefpolmach
179  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourmach
180  real(kind=realtype), dimension(*), intent(in) :: sincoeffourmach
181  !
182  ! Local variables.
183  !
184  integer(kind=intType) :: nn
185 
186  real(kind=realtype) :: intervalmach, val
187 
188  ! Return immediately if this is a steady computation.
189 
190  if (equationmode == steady) then
191  tsmach = zero
192  return
193  end if
194 
195  ! Compute the polynomial contribution. If no polynomial was
196  ! specified, the value of index 0 is set to zero automatically.
197 
198  intervalmach = coefpolmach(0)
199  do nn = 1, degreepolmach
200  intervalmach = intervalmach + coefpolmach(nn) * (t**nn)
201  end do
202 
203  ! Compute the fourier contribution. Again the cosine coefficient
204  ! of index 0 is defaulted to zero if not specified.
205 
206  intervalmach = intervalmach + coscoeffourmach(0)
207  do nn = 1, degreefourmach
208  val = nn * omegafourmach * t
209  intervalmach = intervalmach + coscoeffourmach(nn) * cos(val) &
210  + sincoeffourmach(nn) * sin(val)
211  end do
212  print *, 'inTSMach', intervalmach, nn, val, t
213  ! Set TSMach to phi.
214 
215  tsmach = intervalmach
216 
217  end function tsmach
218 
219  function tsmachdot(degreePolMach, coefPolMach, &
220  degreeFourMach, omegaFourMach, &
221  cosCoefFourMach, sinCoefFourMach, t)
222  !
223  ! TSmach computes the angle of attack for a given Time interval
224  ! in a time spectral solution.
225  !
226  use constants
227  use inputphysics, only: equationmode
228  implicit none
229  !
230  ! Function type
231  !
232  real(kind=realtype) :: tsmachdot
233  !
234  ! Function arguments.
235  !
236  integer(kind=intType), intent(in) :: degreepolmach
237  integer(kind=intType), intent(in) :: degreefourmach
238 
239  real(kind=realtype), intent(in) :: omegafourmach, t
240 
241  real(kind=realtype), dimension(0:*), intent(in) :: coefpolmach
242  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourmach
243  real(kind=realtype), dimension(*), intent(in) :: sincoeffourmach
244  !
245  ! Local variables.
246  !
247  integer(kind=intType) :: nn
248 
249  real(kind=realtype) :: machdot, val
250 
251  ! Return immediately if this is a steady computation.
252 
253  if (equationmode == steady) then
254  tsmachdot = zero
255  return
256  end if
257 
258  ! Compute the polynomial contribution. If no polynomial was
259  ! specified, the value of index 0 is set to zero automatically.
260 
261  machdot = zero
262  do nn = 1, degreepolmach
263  machdot = machdot + nn * coefpolmach(nn) * (t**(nn - 1))
264  end do
265 
266  ! Compute the fourier contribution. Again the cosine coefficient
267  ! of index 0 is defaulted to zero if not specified.
268 
269  do nn = 1, degreefourmach
270  val = nn * omegafourmach
271  machdot = machdot - val * coscoeffourmach(nn) * sin(val * t) &
272  + val * sincoeffourmach(nn) * cos(val * t)
273  end do
274 
275  ! Set TSMach to phi.
276 
277  tsmachdot = machdot
278 
279  end function tsmachdot
280 
281  function tsalpha(degreePolAlpha, coefPolAlpha, &
282  degreeFourAlpha, omegaFourAlpha, &
283  cosCoefFourAlpha, sinCoefFourAlpha, t)
284  !
285  ! TSalpha computes the angle of attack for a given Time interval
286  ! in a time spectral solution.
287  !
288  use constants
289  use inputphysics, only: equationmode
290  implicit none
291  !
292  ! Function type
293  !
294  real(kind=realtype) :: tsalpha
295  !
296  ! Function arguments.
297  !
298  integer(kind=intType), intent(in) :: degreepolalpha
299  integer(kind=intType), intent(in) :: degreefouralpha
300 
301  real(kind=realtype), intent(in) :: omegafouralpha, t
302 
303  real(kind=realtype), dimension(0:*), intent(in) :: coefpolalpha
304  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffouralpha
305  real(kind=realtype), dimension(*), intent(in) :: sincoeffouralpha
306  !
307  ! Local variables.
308  !
309  integer(kind=intType) :: nn
310 
311  real(kind=realtype) :: alpha, val
312 
313  ! Return immediately if this is a steady computation.
314 
315  if (equationmode == steady) then
316  tsalpha = zero
317  return
318  end if
319 
320  ! Compute the polynomial contribution. If no polynomial was
321  ! specified, the value of index 0 is set to zero automatically.
322  alpha = coefpolalpha(0)
323  do nn = 1, degreepolalpha
324  alpha = alpha + coefpolalpha(nn) * (t**nn)
325  end do
326 
327  ! Compute the fourier contribution. Again the cosine coefficient
328  ! of index 0 is defaulted to zero if not specified.
329 
330  alpha = alpha + coscoeffouralpha(0)
331  do nn = 1, degreefouralpha
332  val = nn * omegafouralpha * t
333  alpha = alpha + coscoeffouralpha(nn) * cos(val) &
334  + sincoeffouralpha(nn) * sin(val)
335  end do
336  !print *,'inTSalpha',alpha,nn,val,t
337  ! Set TSAlpha to phi.
338 
339  tsalpha = alpha
340 
341  end function tsalpha
342 
343  function tsalphadot(degreePolAlpha, coefPolAlpha, &
344  degreeFourAlpha, omegaFourAlpha, &
345  cosCoefFourAlpha, sinCoefFourAlpha, t)
346  !
347  ! TSalpha computes the angle of attack for a given Time interval
348  ! in a time spectral solution.
349  !
350  use constants
351  use inputphysics, only: equationmode
352  implicit none
353  !
354  ! Function type
355  !
356  real(kind=realtype) :: tsalphadot
357  !
358  ! Function arguments.
359  !
360  integer(kind=intType), intent(in) :: degreepolalpha
361  integer(kind=intType), intent(in) :: degreefouralpha
362 
363  real(kind=realtype), intent(in) :: omegafouralpha, t
364 
365  real(kind=realtype), dimension(0:*), intent(in) :: coefpolalpha
366  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffouralpha
367  real(kind=realtype), dimension(*), intent(in) :: sincoeffouralpha
368  !
369  ! Local variables.
370  !
371  integer(kind=intType) :: nn
372 
373  real(kind=realtype) :: alphadot, val
374 
375  ! Return immediately if this is a steady computation.
376 
377  if (equationmode == steady) then
378  tsalphadot = zero
379  return
380  end if
381 
382  ! Compute the polynomial contribution. If no polynomial was
383  ! specified, the value of index 0 is set to zero automatically.
384 
385  alphadot = zero
386  do nn = 1, degreepolalpha
387  alphadot = alphadot + nn * coefpolalpha(nn) * (t**(nn - 1))
388  end do
389 
390  ! Compute the fourier contribution. Again the cosine coefficient
391  ! of index 0 is defaulted to zero if not specified.
392 
393  do nn = 1, degreefouralpha
394  val = nn * omegafouralpha
395  alphadot = alphadot - val * coscoeffouralpha(nn) * sin(val * t) &
396  + val * sincoeffouralpha(nn) * cos(val * t)
397  end do
398 
399  ! Set TSAlpha to phi.
400 
401  tsalphadot = alphadot
402 
403  end function tsalphadot
404 
405  function derivativerigidrotangle(degreePolRot, &
406  coefPolRot, &
407  degreeFourRot, &
408  omegaFourRot, &
409  cosCoefFourRot, &
410  sinCoefFourRot, t)
411  !
412  ! derivativeRigidRotAngle computes the time derivative of the
413  ! rigid body rotation angle at the given time for the given
414  ! arguments. The angle is described by a combination of a
415  ! polynomial and fourier series.
416  !
417  use constants
418  use inputphysics, only: equationmode
419  use flowvarrefstate, only: timeref
420  implicit none
421  !
422  ! Function type
423  !
424  real(kind=realtype) :: derivativerigidrotangle
425  !
426  ! Function arguments.
427  !
428  integer(kind=intType), intent(in) :: degreepolrot
429  integer(kind=intType), intent(in) :: degreefourrot
430 
431  real(kind=realtype), intent(in) :: omegafourrot, t
432 
433  real(kind=realtype), dimension(0:*), intent(in) :: coefpolrot
434  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourrot
435  real(kind=realtype), dimension(*), intent(in) :: sincoeffourrot
436  !
437  ! Local variables.
438  !
439  integer(kind=intType) :: nn
440 
441  real(kind=realtype) :: dphi, val
442 
443  ! Return immediately if this is a steady computation.
444 
445  if (equationmode == steady) then
447  return
448  end if
449 
450  ! Compute the polynomial contribution.
451 
452  dphi = zero
453  do nn = 1, degreepolrot
454  dphi = dphi + nn * coefpolrot(nn) * (t**(nn - 1))
455  end do
456 
457  ! Compute the fourier contribution.
458 
459  do nn = 1, degreefourrot
460  val = nn * omegafourrot
461  dphi = dphi - val * coscoeffourrot(nn) * sin(val * t)
462  dphi = dphi + val * sincoeffourrot(nn) * cos(val * t)
463  end do
464 
465  ! Set derivativeRigidRotAngle to dPhi. Multiply by timeRef
466  ! to obtain the correct non-dimensional value.
467 
469 
470  end function derivativerigidrotangle
471 
472  function mydim(x, y)
473 
474  use constants
475 
476  real(kind=realtype) x, y
477  real(kind=realtype) :: mydim
478 
479  mydim = x - y
480  if (mydim < 0.0) then
481  mydim = 0.0
482  end if
483 
484  end function mydim
485 
486  function getcorrectfork()
487 
488  use constants
489  use flowvarrefstate, only: kpresent
491  implicit none
492 
493  logical :: getcorrectfork
494 
495  if (kpresent .and. currentlevel <= groundlevel) then
496  getcorrectfork = .true.
497  else
498  getcorrectfork = .false.
499  end if
500  end function getcorrectfork
501  subroutine terminate(routineName, errorMessage)
502  !
503  ! terminate writes an error message to standard output and
504  ! terminates the execution of the program.
505  !
506  use constants
508  implicit none
509  !
510  ! Subroutine arguments
511  !
512  character(len=*), intent(in) :: routineName
513  character(len=*), intent(in) :: errorMessage
514 #ifndef USE_TAPENADE
515 
516  !
517  ! Local parameter
518  !
519  integer, parameter :: maxCharLine = 55
520  !
521  ! Local variables
522  !
523  integer :: ierr, len, i2
524  logical :: firstTime
525 
526  character(len=len_trim(errorMessage)) :: message
527  character(len=8) :: integerString
528 
529  !
530  ! Copy the errorMessage into message. It is not possible to work
531  ! with errorMessage directly, because it is modified in this
532  ! routine. Sometimes a constant string is passed to this routine
533  ! and some compilers simply fail then.
534 
535  message = errormessage
536 
537  ! Print a nice error message. In case of a parallel executable
538  ! also the processor id is printed.
539 
540  print "(a)", "#"
541  print "(a)", "#--------------------------- !!! Error !!! &
542  &----------------------------"
543 
544  write (integerstring, "(i8)") myid
545  integerstring = adjustl(integerstring)
546 
547  print "(2a)", "#* Terminate called by processor ", &
548  trim(integerstring)
549 
550  ! Write the header of the error message.
551 
552  print "(2a)", "#* Run-time error in procedure ", &
553  trim(routinename)
554 
555  ! Loop to write the error message. If the message is too long it
556  ! is split over several lines.
557 
558  firsttime = .true.
559  do
560  ! Determine the remaining error message to be written.
561  ! If longer than the maximum number of characters allowed
562  ! on a line, it is attempted to split the message.
563 
564  message = adjustl(message)
565  len = len_trim(message)
566  i2 = min(maxcharline, len)
567 
568  if (i2 < len) i2 = index(message(:i2), " ", .true.) - 1
569  if (i2 < 0) i2 = index(message, " ") - 1
570  if (i2 < 0) i2 = len
571 
572  ! Write this part of the error message. If it is the first
573  ! line of the message some additional stuff is printed.
574 
575  if (firsttime) then
576  print "(2a)", "#* Error message: ", &
577  trim(message(:i2))
578  firsttime = .false.
579  else
580  print "(2a)", "#* ", &
581  trim(message(:i2))
582  end if
583 
584  ! Exit the loop if the entire message has been written.
585 
586  if (i2 == len) exit
587 
588  ! Adapt the string for the next part to be written.
589 
590  message = message(i2 + 1:)
591 
592  end do
593 
594  ! Write the trailing message.
595 
596  print "(a)", "#*"
597  print "(a)", "#* Now exiting"
598  print "(a)", "#------------------------------------------&
599  &----------------------------"
600  print "(a)", "#"
601 
602  ! Call abort and stop the program. This stop should be done in
603  ! abort, but just to be sure.
604 
605  call mpi_abort(adflow_comm_world, 1, ierr)
606  stop
607 
608 #endif
609 
610  end subroutine terminate
611 
612  subroutine rotmatrixrigidbody(tNew, tOld, rotationMatrix, &
613  rotationPoint)
614  !
615  ! rotMatrixRigidBody determines the rotation matrix and the
616  ! rotation point to determine the coordinates of the new time
617  ! level starting from the coordinates of the old time level.
618  !
619  use constants
620  use inputmotion
621  use flowvarrefstate, only: lref
622  implicit none
623  !
624  ! Subroutine arguments.
625  !
626  real(kind=realtype), intent(in) :: tnew, told
627 
628  real(kind=realtype), dimension(3), intent(out) :: rotationpoint
629  real(kind=realtype), dimension(3, 3), intent(out) :: rotationmatrix
630  !
631  ! Local variables.
632  !
633  integer(kind=intType) :: i, j
634 
635  real(kind=realtype) :: phi
636  real(kind=realtype) :: cosx, cosy, cosz, sinx, siny, sinz
637 
638  real(kind=realtype), dimension(3, 3) :: mnew, mold
639 
640  ! Determine the rotation angle around the x-axis for the new
641  ! time level and the corresponding values of the sine and cosine.
642 
646  sinx = sin(phi)
647  cosx = cos(phi)
648 
649  ! Idem for the y-axis.
650 
654  siny = sin(phi)
655  cosy = cos(phi)
656 
657  ! Idem for the z-axis.
658 
662  sinz = sin(phi)
663  cosz = cos(phi)
664 
665  ! Construct the transformation matrix at the new time level.
666  ! It is assumed that the sequence of rotation is first around the
667  ! x-axis then around the y-axis and finally around the z-axis.
668 
669  mnew(1, 1) = cosy * cosz
670  mnew(2, 1) = cosy * sinz
671  mnew(3, 1) = -siny
672 
673  mnew(1, 2) = sinx * siny * cosz - cosx * sinz
674  mnew(2, 2) = sinx * siny * sinz + cosx * cosz
675  mnew(3, 2) = sinx * cosy
676 
677  mnew(1, 3) = cosx * siny * cosz + sinx * sinz
678  mnew(2, 3) = cosx * siny * sinz - sinx * cosz
679  mnew(3, 3) = cosx * cosy
680 
681  ! Determine the rotation angle around the x-axis for the old
682  ! time level and the corresponding values of the sine and cosine.
683 
687  sinx = sin(phi)
688  cosx = cos(phi)
689 
690  ! Idem for the y-axis.
691 
695  siny = sin(phi)
696  cosy = cos(phi)
697 
698  ! Idem for the z-axis.
699 
703  sinz = sin(phi)
704  cosz = cos(phi)
705 
706  ! Construct the transformation matrix at the old time level.
707 
708  mold(1, 1) = cosy * cosz
709  mold(2, 1) = cosy * sinz
710  mold(3, 1) = -siny
711 
712  mold(1, 2) = sinx * siny * cosz - cosx * sinz
713  mold(2, 2) = sinx * siny * sinz + cosx * cosz
714  mold(3, 2) = sinx * cosy
715 
716  mold(1, 3) = cosx * siny * cosz + sinx * sinz
717  mold(2, 3) = cosx * siny * sinz - sinx * cosz
718  mold(3, 3) = cosx * cosy
719 
720  ! Construct the transformation matrix between the new and the
721  ! old time level. This is mNew*inverse(mOld). However the
722  ! inverse of mOld is the transpose.
723 
724  do j = 1, 3
725  do i = 1, 3
726  rotationmatrix(i, j) = mnew(i, 1) * mold(j, 1) &
727  + mnew(i, 2) * mold(j, 2) &
728  + mnew(i, 3) * mold(j, 3)
729  end do
730  end do
731 
732  ! Determine the rotation point at the old time level; it is
733  ! possible that this value changes due to translation of the grid.
734 
735  ! aInf = sqrt(gammaInf*pInf/rhoInf)
736 
737  ! rotationPoint(1) = LRef*rotPoint(1) &
738  ! + MachGrid(1)*aInf*tOld/timeRef
739  ! rotationPoint(2) = LRef*rotPoint(2) &
740  ! + MachGrid(2)*aInf*tOld/timeRef
741  ! rotationPoint(3) = LRef*rotPoint(3) &
742  ! + MachGrid(3)*aInf*tOld/timeRef
743 
744  rotationpoint(1) = lref * rotpoint(1)
745  rotationpoint(2) = lref * rotpoint(2)
746  rotationpoint(3) = lref * rotpoint(3)
747 
748  end subroutine rotmatrixrigidbody
749 
750  function secondderivativerigidrotangle(degreePolRot, &
751  coefPolRot, &
752  degreeFourRot, &
753  omegaFourRot, &
754  cosCoefFourRot, &
755  sinCoefFourRot, t)
756  !
757  ! 2ndderivativeRigidRotAngle computes the 2nd time derivative of
758  ! the rigid body rotation angle at the given time for the given
759  ! arguments. The angle is described by a combination of a
760  ! polynomial and fourier series.
761  !
762  use constants
763  use flowvarrefstate, only: timeref
764  use inputphysics, only: equationmode
765  implicit none
766  !
767  ! Function type
768  !
769  real(kind=realtype) :: secondderivativerigidrotangle
770  !
771  ! Function arguments.
772  !
773  integer(kind=intType), intent(in) :: degreepolrot
774  integer(kind=intType), intent(in) :: degreefourrot
775 
776  real(kind=realtype), intent(in) :: omegafourrot, t
777 
778  real(kind=realtype), dimension(0:*), intent(in) :: coefpolrot
779  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourrot
780  real(kind=realtype), dimension(*), intent(in) :: sincoeffourrot
781  !
782  ! Local variables.
783  !
784  integer(kind=intType) :: nn
785 
786  real(kind=realtype) :: dphi, val
787 
788  ! Return immediately if this is a steady computation.
789 
790  if (equationmode == steady) then
792  return
793  end if
794 
795  ! Compute the polynomial contribution.
796 
797  dphi = zero
798  do nn = 2, degreepolrot
799  dphi = dphi + (nn - 1) * nn * coefpolrot(nn) * (t**(nn - 2))
800  end do
801 
802  ! Compute the fourier contribution.
803 
804  do nn = 1, degreefourrot
805  val = nn * omegafourrot
806  dphi = dphi - val**2 * sincoeffourrot(nn) * sin(val * t)
807  dphi = dphi - val**2 * coscoeffourrot(nn) * cos(val * t)
808  end do
809 
810  ! Set derivativeRigidRotAngle to dPhi. Multiply by timeRef
811  ! to obtain the correct non-dimensional value.
812 
814 
815  end function secondderivativerigidrotangle
816 
817  function rigidrotangle(degreePolRot, coefPolRot, &
818  degreeFourRot, omegaFourRot, &
819  cosCoefFourRot, sinCoefFourRot, t)
820  !
821  ! rigidRotAngle computes the rigid body rotation angle at the
822  ! given time for the given arguments. The angle is described by
823  ! a combination of a polynomial and fourier series.
824  !
825  use constants
826  use inputphysics, only: equationmode
827  implicit none
828  !
829  ! Function type
830  !
831  real(kind=realtype) :: rigidrotangle
832  !
833  ! Function arguments.
834  !
835  integer(kind=intType), intent(in) :: degreepolrot
836  integer(kind=intType), intent(in) :: degreefourrot
837 
838  real(kind=realtype), intent(in) :: omegafourrot, t
839 
840  real(kind=realtype), dimension(0:*), intent(in) :: coefpolrot
841  real(kind=realtype), dimension(0:*), intent(in) :: coscoeffourrot
842  real(kind=realtype), dimension(*), intent(in) :: sincoeffourrot
843  !
844  ! Local variables.
845  !
846  integer(kind=intType) :: nn
847 
848  real(kind=realtype) :: phi, val
849 
850  ! Return immediately if this is a steady computation.
851 
852  if (equationmode == steady) then
854  return
855  end if
856 
857  ! Compute the polynomial contribution. If no polynomial was
858  ! specified, the value of index 0 is set to zero automatically.
859 
860  phi = coefpolrot(0)
861  do nn = 1, degreepolrot
862  phi = phi + coefpolrot(nn) * (t**nn)
863  end do
864 
865  ! Compute the fourier contribution. Again the cosine coefficient
866  ! of index 0 is defaulted to zero if not specified.
867 
868  phi = phi + coscoeffourrot(0)
869  do nn = 1, degreefourrot
870  val = nn * omegafourrot * t
871  phi = phi + coscoeffourrot(nn) * cos(val) &
872  + sincoeffourrot(nn) * sin(val)
873  end do
874 
875  ! Set rigidRotAngle to phi.
876 
877  rigidrotangle = phi
878 
879  end function rigidrotangle
880 
881  subroutine setbcpointers(nn, spatialPointers)
882  !
883  ! setBCPointers sets the pointers needed for the boundary
884  ! condition treatment on a general face, such that the boundary
885  ! routines are only implemented once instead of 6 times.
886  !
887  use constants
888  use blockpointers, only: w, p, rlv, rev, gamma, x, d2wall, &
889  si, sj, sk, s, globalcell, bcdata, nx, il, ie, ib, &
890  ny, jl, je, jb, nz, kl, ke, kb, bcfaceid, &
892  use bcpointers, only: ww0, ww1, ww2, ww3, pp0, pp1, pp2, pp3, &
893  rlv0, rlv1, rlv2, rlv3, rev0, rev1, rev2, rev3, &
896  use inputphysics, only: cpmodel, equations
897  implicit none
898 
899  ! Subroutine arguments.
900  integer(kind=intType), intent(in) :: nn
901  logical, intent(in) :: spatialPointers
902 
903  ! Determine the sizes of each face and point to just the range we
904  ! need on each face.
905  istart = bcdata(nn)%icBeg
906  iend = bcdata(nn)%icEnd
907  jstart = bcdata(nn)%jcBeg
908  jend = bcdata(nn)%jcEnd
909 
910  ! Set the size of the subface
911  isize = iend - istart + 1
912  jsize = jend - jstart + 1
913 
914  ! Determine the face id on which the subface is located and set
915  ! the pointers accordinly.
916 
917  select case (bcfaceid(nn))
918 
919  !---------------------------------------------------------------------------
920  case (imin)
921 
922  ww3 => w(3, 1:, 1:, :)
923  ww2 => w(2, 1:, 1:, :)
924  ww1 => w(1, 1:, 1:, :)
925  ww0 => w(0, 1:, 1:, :)
926 
927  pp3 => p(3, 1:, 1:)
928  pp2 => p(2, 1:, 1:)
929  pp1 => p(1, 1:, 1:)
930  pp0 => p(0, 1:, 1:)
931 
932  rlv3 => rlv(3, 1:, 1:)
933  rlv2 => rlv(2, 1:, 1:)
934  rlv1 => rlv(1, 1:, 1:)
935  rlv0 => rlv(0, 1:, 1:)
936 
937  rev3 => rev(3, 1:, 1:)
938  rev2 => rev(2, 1:, 1:)
939  rev1 => rev(1, 1:, 1:)
940  rev0 => rev(0, 1:, 1:)
941 
942  gamma3 => gamma(3, 1:, 1:)
943  gamma2 => gamma(2, 1:, 1:)
944  gamma1 => gamma(1, 1:, 1:)
945  gamma0 => gamma(0, 1:, 1:)
946 
947  gcp => globalcell(2, 1:, 1:)
948  !---------------------------------------------------------------------------
949 
950  case (imax)
951 
952  ww3 => w(nx, 1:, 1:, :)
953  ww2 => w(il, 1:, 1:, :)
954  ww1 => w(ie, 1:, 1:, :)
955  ww0 => w(ib, 1:, 1:, :)
956 
957  pp3 => p(nx, 1:, 1:)
958  pp2 => p(il, 1:, 1:)
959  pp1 => p(ie, 1:, 1:)
960  pp0 => p(ib, 1:, 1:)
961 
962  rlv3 => rlv(nx, 1:, 1:)
963  rlv2 => rlv(il, 1:, 1:)
964  rlv1 => rlv(ie, 1:, 1:)
965  rlv0 => rlv(ib, 1:, 1:)
966 
967  rev3 => rev(nx, 1:, 1:)
968  rev2 => rev(il, 1:, 1:)
969  rev1 => rev(ie, 1:, 1:)
970  rev0 => rev(ib, 1:, 1:)
971 
972  gamma3 => gamma(nx, 1:, 1:)
973  gamma2 => gamma(il, 1:, 1:)
974  gamma1 => gamma(ie, 1:, 1:)
975  gamma0 => gamma(ib, 1:, 1:)
976 
977  gcp => globalcell(il, 1:, 1:)
978  !---------------------------------------------------------------------------
979 
980  case (jmin)
981 
982  ww3 => w(1:, 3, 1:, :)
983  ww2 => w(1:, 2, 1:, :)
984  ww1 => w(1:, 1, 1:, :)
985  ww0 => w(1:, 0, 1:, :)
986 
987  pp3 => p(1:, 3, 1:)
988  pp2 => p(1:, 2, 1:)
989  pp1 => p(1:, 1, 1:)
990  pp0 => p(1:, 0, 1:)
991 
992  rlv3 => rlv(1:, 3, 1:)
993  rlv2 => rlv(1:, 2, 1:)
994  rlv1 => rlv(1:, 1, 1:)
995  rlv0 => rlv(1:, 0, 1:)
996 
997  rev3 => rev(1:, 3, 1:)
998  rev2 => rev(1:, 2, 1:)
999  rev1 => rev(1:, 1, 1:)
1000  rev0 => rev(1:, 0, 1:)
1001 
1002  gamma3 => gamma(1:, 3, 1:)
1003  gamma2 => gamma(1:, 2, 1:)
1004  gamma1 => gamma(1:, 1, 1:)
1005  gamma0 => gamma(1:, 0, 1:)
1006 
1007  gcp => globalcell(1:, 2, 1:)
1008  !---------------------------------------------------------------------------
1009 
1010  case (jmax)
1011 
1012  ww3 => w(1:, ny, 1:, :)
1013  ww2 => w(1:, jl, 1:, :)
1014  ww1 => w(1:, je, 1:, :)
1015  ww0 => w(1:, jb, 1:, :)
1016 
1017  pp3 => p(1:, ny, 1:)
1018  pp2 => p(1:, jl, 1:)
1019  pp1 => p(1:, je, 1:)
1020  pp0 => p(1:, jb, 1:)
1021 
1022  rlv3 => rlv(1:, ny, 1:)
1023  rlv2 => rlv(1:, jl, 1:)
1024  rlv1 => rlv(1:, je, 1:)
1025  rlv0 => rlv(1:, jb, 1:)
1026 
1027  rev3 => rev(1:, ny, 1:)
1028  rev2 => rev(1:, jl, 1:)
1029  rev1 => rev(1:, je, 1:)
1030  rev0 => rev(1:, jb, 1:)
1031 
1032  gamma3 => gamma(1:, ny, 1:)
1033  gamma2 => gamma(1:, jl, 1:)
1034  gamma1 => gamma(1:, je, 1:)
1035  gamma0 => gamma(1:, jb, 1:)
1036 
1037  gcp => globalcell(1:, jl, 1:)
1038  !---------------------------------------------------------------------------
1039 
1040  case (kmin)
1041 
1042  ww3 => w(1:, 1:, 3, :)
1043  ww2 => w(1:, 1:, 2, :)
1044  ww1 => w(1:, 1:, 1, :)
1045  ww0 => w(1:, 1:, 0, :)
1046 
1047  pp3 => p(1:, 1:, 3)
1048  pp2 => p(1:, 1:, 2)
1049  pp1 => p(1:, 1:, 1)
1050  pp0 => p(1:, 1:, 0)
1051 
1052  rlv3 => rlv(1:, 1:, 3)
1053  rlv2 => rlv(1:, 1:, 2)
1054  rlv1 => rlv(1:, 1:, 1)
1055  rlv0 => rlv(1:, 1:, 0)
1056 
1057  rev3 => rev(1:, 1:, 3)
1058  rev2 => rev(1:, 1:, 2)
1059  rev1 => rev(1:, 1:, 1)
1060  rev0 => rev(1:, 1:, 0)
1061 
1062  gamma3 => gamma(1:, 1:, 3)
1063  gamma2 => gamma(1:, 1:, 2)
1064  gamma1 => gamma(1:, 1:, 1)
1065  gamma0 => gamma(1:, 1:, 0)
1066 
1067  gcp => globalcell(1:, 1:, 2)
1068  !---------------------------------------------------------------------------
1069 
1070  case (kmax)
1071 
1072  ww3 => w(1:, 1:, nz, :)
1073  ww2 => w(1:, 1:, kl, :)
1074  ww1 => w(1:, 1:, ke, :)
1075  ww0 => w(1:, 1:, kb, :)
1076 
1077  pp3 => p(1:, 1:, nz)
1078  pp2 => p(1:, 1:, kl)
1079  pp1 => p(1:, 1:, ke)
1080  pp0 => p(1:, 1:, kb)
1081 
1082  rlv3 => rlv(1:, 1:, nz)
1083  rlv2 => rlv(1:, 1:, kl)
1084  rlv1 => rlv(1:, 1:, ke)
1085  rlv0 => rlv(1:, 1:, kb)
1086 
1087  rev3 => rev(1:, 1:, nz)
1088  rev2 => rev(1:, 1:, kl)
1089  rev1 => rev(1:, 1:, ke)
1090  rev0 => rev(1:, 1:, kb)
1091 
1092  gamma3 => gamma(1:, 1:, nz)
1093  gamma2 => gamma(1:, 1:, kl)
1094  gamma1 => gamma(1:, 1:, ke)
1095  gamma0 => gamma(1:, 1:, kb)
1096 
1097  gcp => globalcell(1:, 1:, kl)
1098  end select
1099 
1100  if (spatialpointers) then
1101  select case (bcfaceid(nn))
1102  case (imin)
1103  xx => x(1, :, :, :)
1104  ssi => si(1, :, :, :)
1105  ssj => sj(2, :, :, :)
1106  ssk => sk(2, :, :, :)
1107  ss => s(2, :, :, :)
1108  case (imax)
1109  xx => x(il, :, :, :)
1110  ssi => si(il, :, :, :)
1111  ssj => sj(il, :, :, :)
1112  ssk => sk(il, :, :, :)
1113  ss => s(il, :, :, :)
1114  case (jmin)
1115  xx => x(:, 1, :, :)
1116  ssi => sj(:, 1, :, :)
1117  ssj => si(:, 2, :, :)
1118  ssk => sk(:, 2, :, :)
1119  ss => s(:, 2, :, :)
1120  case (jmax)
1121  xx => x(:, jl, :, :)
1122  ssi => sj(:, jl, :, :)
1123  ssj => si(:, jl, :, :)
1124  ssk => sk(:, jl, :, :)
1125  ss => s(:, jl, :, :)
1126  case (kmin)
1127  xx => x(:, :, 1, :)
1128  ssi => sk(:, :, 1, :)
1129  ssj => si(:, :, 2, :)
1130  ssk => sj(:, :, 2, :)
1131  ss => s(:, :, 2, :)
1132  case (kmax)
1133  xx => x(:, :, kl, :)
1134  ssi => sk(:, :, kl, :)
1135  ssj => si(:, :, kl, :)
1136  ssk => sj(:, :, kl, :)
1137  ss => s(:, :, kl, :)
1138  end select
1139 
1140  if (addgridvelocities) then
1141  select case (bcfaceid(nn))
1142  case (imin)
1143  sface => sfacei(1, :, :)
1144  case (imax)
1145  sface => sfacei(il, :, :)
1146  case (jmin)
1147  sface => sfacej(:, 1, :)
1148  case (jmax)
1149  sface => sfacej(:, jl, :)
1150  case (kmin)
1151  sface => sfacek(:, :, 1)
1152  case (kmax)
1153  sface => sfacek(:, :, kl)
1154  end select
1155  end if
1156 
1157  if (equations == ransequations) then
1158  select case (bcfaceid(nn))
1159  case (imin)
1160  dd2wall => d2wall(2, :, :)
1161  case (imax)
1162  dd2wall => d2wall(il, :, :)
1163  case (jmin)
1164  dd2wall => d2wall(:, 2, :)
1165  case (jmax)
1166  dd2wall => d2wall(:, jl, :)
1167  case (kmin)
1168  dd2wall => d2wall(:, :, 2)
1169  case (kmax)
1170  dd2wall => d2wall(:, :, kl)
1171  end select
1172  end if
1173  end if
1174  end subroutine setbcpointers
1175 
1176  subroutine computerootbendingmoment(cf, cm, bendingMoment)
1177 
1178  ! *
1179  ! Compute a normalized bending moment coefficient from *
1180  ! the force and moment coefficient. At the moment this *
1181  ! Routine only works for a half body. Additional logic *
1182  ! would be needed for a full body. *
1183  ! *
1184 
1185  use constants
1187  implicit none
1188 
1189  !input/output variables
1190  real(kind=realtype), intent(in), dimension(3) :: cf, cm
1191  real(kind=realtype), intent(out) :: bendingmoment
1192 
1193  !Subroutine Variables
1194  real(kind=realtype) :: elasticmomentx, elasticmomenty, elasticmomentz
1195  bendingmoment = zero
1196  if (liftindex == 2) then
1197  !z out wing sum momentx,momentz
1198  elasticmomentx = cm(1) + cf(2) * (pointrefec(3) - &
1199  pointref(3)) / lengthref - cf(3) * &
1200  (pointrefec(2) - pointref(2)) / lengthref
1201  elasticmomentz = cm(3) - cf(2) * (pointrefec(1) - &
1202  pointref(1)) / lengthref + cf(1) * &
1203  (pointrefec(2) - pointref(2)) / lengthref
1204  bendingmoment = sqrt(elasticmomentx**2 + elasticmomentz**2)
1205  elseif (liftindex == 3) then
1206  !y out wing sum momentx,momenty
1207  elasticmomentx = cm(1) + cf(3) * (pointrefec(2) - &
1208  pointref(2)) / lengthref + &
1209  cf(3) * (pointrefec(3) - pointref(3)) / lengthref
1210  elasticmomenty = cm(2) + cf(3) * (pointrefec(1) - &
1211  pointref(1)) / lengthref + &
1212  cf(1) * (pointrefec(3) - pointref(3)) / lengthref
1213  bendingmoment = sqrt(elasticmomentx**2 + elasticmomenty**2)
1214  end if
1215 
1216  end subroutine computerootbendingmoment
1217 
1218  subroutine computeleastsquaresregression(y, x, npts, m, b)
1219  !
1220  ! Computes the slope of best fit for a set of x,y data of length
1221  ! npts
1222  !
1223  use constants
1224  implicit none
1225  !Subroutine arguments
1226  integer(kind=intType) :: npts
1227  real(kind=realtype), dimension(npts) :: x, y
1228  real(kind=realtype) :: m, b
1229 
1230  !local variables
1231  real(kind=realtype) :: sumx, sumy, sumx2, sumxy
1232  integer(kind=intType) :: i
1233 
1234  !begin execution
1235  sumx = 0.0
1236  sumy = 0.0
1237  sumx2 = 0.0
1238  sumxy = 0.0
1239  do i = 1, npts
1240 
1241  sumx = sumx + x(i)
1242  sumy = sumy + y(i)
1243  sumx2 = sumx2 + x(i) * x(i)
1244  sumxy = sumxy + x(i) * y(i)
1245  end do
1246 
1247  m = ((npts * sumxy) - (sumy * sumx)) / ((npts * sumx2) - (sumx)**2)
1248  b = (sumy * sumx2 - (sumx * sumxy)) / ((npts * sumx2) - (sumx)**2)
1249 
1250  end subroutine computeleastsquaresregression
1251 
1252  subroutine computetsderivatives(force, moment, coef0, dcdalpha, &
1253  dcdalphadot, dcdq, dcdqdot)
1254  !
1255  ! Computes the stability derivatives based on the time spectral
1256  ! solution of a given mesh. Takes in the force coefficients at
1257  ! all time instantces and computes the agregate parameters
1258  !
1259  use constants
1260  use communication
1261  use inputphysics
1262  use inputtimespectral
1263  use inputtsstabderiv
1264  use flowvarrefstate
1265  use monitor
1266  use section
1267  use inputmotion
1268  implicit none
1269 
1270  !
1271  ! Subroutine arguments.
1272  !
1273  real(kind=realtype), dimension(3, nTimeIntervalsSpectral) :: force, moment
1274  real(kind=realtype), dimension(8) :: dcdq, dcdqdot
1275  real(kind=realtype), dimension(8) :: dcdalpha, dcdalphadot
1276  real(kind=realtype), dimension(8) :: coef0
1277 
1278  ! Working Variables
1279  real(kind=realtype), dimension(nTimeIntervalsSpectral, 8) :: basecoef
1280  real(kind=realtype), dimension(8) :: coef0dot
1281  real(kind=realtype), dimension(nTimeIntervalsSpectral, 8) :: resbasecoef
1282  real(kind=realtype), dimension(nTimeIntervalsSpectral) :: intervalalpha, intervalalphadot
1283  real(kind=realtype), dimension(nTimeIntervalsSpectral) :: intervalmach, intervalmachdot
1284  real(kind=realtype), dimension(nSections) :: t
1285  integer(kind=intType) :: i, sps, nn
1286  !speed of sound: for normalization of q derivatives
1287  real(kind=realtype) :: a
1288  real(kind=realtype) :: fact, factmoment
1289  ! Functions
1290  real(kind=realtype), dimension(nTimeIntervalsSpectral) :: dphix, dphiy, dphiz
1291  real(kind=realtype), dimension(nTimeIntervalsSpectral) :: dphixdot, dphiydot, dphizdot
1293 
1294  fact = two / (gammainf * pinf * machcoef**2 &
1295  * surfaceref * lref**2)
1296  factmoment = fact / (lengthref * lref)
1297 
1298  if (tsqmode) then
1299 
1300  print *, 'TS Q Mode code needs to be updated in computeTSDerivatives!'
1301  stop
1302 
1303  ! !q is pitch
1304  ! do sps =1,nTimeIntervalsSpectral
1305  ! !compute the time of this intervavc
1306  ! t = timeUnsteadyRestart
1307 
1308  ! if(equationMode == timeSpectral) then
1309  ! do nn=1,nSections
1310  ! t(nn) = t(nn) + (sps-1)*sections(nn)%timePeriod &
1311  ! / (nTimeIntervalsSpectral*1.0)
1312  ! enddo
1313  ! endif
1314 
1315  ! ! Compute the time derivative of the rotation angles around the
1316  ! ! z-axis. i.e. compute q
1317 
1318  ! dphiZ(sps) = derivativeRigidRotAngle(degreePolZRot, &
1319  ! coefPolZRot, &
1320  ! degreeFourZRot, &
1321  ! omegaFourZRot, &
1322  ! cosCoefFourZRot, &
1323  ! sinCoefFourZRot, t)
1324 
1325  ! ! add in q_dot computation
1326  ! dphiZdot(sps) = secondDerivativeRigidRotAngle(degreePolZRot, &
1327  ! coefPolZRot, &
1328  ! degreeFourZRot, &
1329  ! omegaFourZRot, &
1330  ! cosCoefFourZRot, &
1331  ! sinCoefFourZRot, t)
1332  ! end do
1333 
1334  ! !now compute dCl/dq
1335  ! do i =1,8
1336  ! call computeLeastSquaresRegression(BaseCoef(:,i),dphiz,nTimeIntervalsSpectral,dcdq(i),coef0(i))
1337  ! end do
1338 
1339  ! ! now subtract off estimated cl,cmz and use remainder to compute
1340  ! ! clqdot and cmzqdot.
1341  ! do i = 1,8
1342  ! do sps = 1,nTimeIntervalsSpectral
1343  ! ResBaseCoef(sps,i) = BaseCoef(sps,i)-(dcdq(i)*dphiz(sps)+Coef0(i))
1344  ! enddo
1345  ! enddo
1346 
1347  ! !now normalize the results...
1348  ! a = sqrt(gammaInf*pInfDim/rhoInfDim)
1349  ! dcdq = dcdq*timeRef*2*(machGrid*a)/lengthRef
1350 
1351  ! !now compute dCl/dpdot
1352  ! do i = 1,8
1353  ! call computeLeastSquaresRegression(ResBaseCoef(:,i),dphizdot,nTimeIntervalsSpectral,dcdqdot(i),Coef0dot(i))
1354  ! enddo
1355 
1356  elseif (tsalphamode) then
1357 
1358  do sps = 1, ntimeintervalsspectral
1359 
1360  !compute the time of this interval
1362 
1363  if (equationmode == timespectral) then
1364  do nn = 1, nsections
1365  t(nn) = t(nn) + (sps - 1) * sections(nn)%timePeriod &
1366  / (ntimeintervalsspectral * 1.0)
1367  end do
1368  end if
1369 
1370  intervalalpha(sps) = tsalpha(degreepolalpha, coefpolalpha, &
1373 
1374  intervalalphadot(sps) = tsalphadot(degreepolalpha, coefpolalpha, &
1377 
1378  ! THIS CALL IS WRONG!!!!
1379  !call getDirAngle(velDirFreestream,liftDirection,liftIndex,alpha+intervalAlpha(sps), beta)
1380 
1381  basecoef(sps, 1) = fact * ( &
1382  force(1, sps) * liftdirection(1) + &
1383  force(2, sps) * liftdirection(2) + &
1384  force(3, sps) * liftdirection(3))
1385  basecoef(sps, 2) = fact * ( &
1386  force(1, sps) * dragdirection(1) + &
1387  force(2, sps) * dragdirection(2) + &
1388  force(3, sps) * dragdirection(3))
1389  basecoef(sps, 3) = force(1, sps) * fact
1390  basecoef(sps, 4) = force(2, sps) * fact
1391  basecoef(sps, 5) = force(3, sps) * fact
1392  basecoef(sps, 6) = moment(1, sps) * factmoment
1393  basecoef(sps, 7) = moment(2, sps) * factmoment
1394  basecoef(sps, 8) = moment(3, sps) * factmoment
1395  end do
1396 
1397  !now compute dCl/dalpha
1398  do i = 1, 8
1399  call computeleastsquaresregression(basecoef(:, i), &
1400  intervalalpha, ntimeintervalsspectral, dcdalpha(i), coef0(i))
1401  end do
1402 
1403  ! now subtract off estimated cl,cmz and use remainder to compute
1404  ! clalphadot and cmzalphadot.
1405  do i = 1, 8
1406  do sps = 1, ntimeintervalsspectral
1407  resbasecoef(sps, i) = basecoef(sps, i) - (dcdalpha(i) * intervalalpha(sps) + coef0(i))
1408  end do
1409  end do
1410 
1411  !now compute dCi/dalphadot
1412  do i = 1, 8
1413  call computeleastsquaresregression(resbasecoef(:, i), &
1414  intervalalphadot, ntimeintervalsspectral, &
1415  dcdalphadot(i), coef0dot(i))
1416  end do
1417 
1418  a = sqrt(gammainf * pinfdim / rhoinfdim)
1419  dcdalphadot = dcdalphadot * 2 * (machgrid * a) / lengthref
1420 
1421  else
1422  call terminate('computeTSDerivatives', 'Not a valid stability motion')
1423  end if
1424 
1425  end subroutine computetsderivatives
1426 
1427  subroutine getdirangle(freeStreamAxis, liftAxis, liftIndex, alpha, beta)
1428  !
1429  ! Convert the wind axes to angle of attack and side slip angle.
1430  ! The direction angles alpha and beta are computed given the
1431  ! components of the wind direction vector (freeStreamAxis), the
1432  ! lift direction vector (liftAxis) and assuming that the
1433  ! body direction (xb,yb,zb) is in the default ijk coordinate
1434  ! system. The rotations are determined by first determining
1435  ! whether the lift is primarily in the j or k direction and then
1436  ! determining the angles accordingly.
1437  ! direction vector:
1438  ! 1) Rotation about the zb or yb -axis: alpha clockwise (CW)
1439  ! (xb,yb,zb) -> (x1,y1,z1)
1440  ! 2) Rotation about the yl or z1 -axis: beta counter-clockwise
1441  ! (CCW) (x1,y1,z1) -> (xw,yw,zw)
1442  ! input arguments:
1443  ! freeStreamAxis = wind vector in body axes
1444  ! liftAxis = lift direction vector in body axis
1445  ! output arguments:
1446  ! alpha = angle of attack in radians
1447  ! beta = side slip angle in radians
1448  !
1449  use constants
1450 
1451  implicit none
1452  !
1453  ! Subroutine arguments.
1454  !
1455  ! real(kind=realType), intent(in) :: xw, yw, zw
1456  real(kind=realtype), dimension(3), intent(in) :: freestreamaxis
1457  real(kind=realtype), dimension(3), intent(in) :: liftaxis
1458  real(kind=realtype), intent(out) :: alpha, beta
1459  integer(kind=intType), intent(out) :: liftIndex
1460  !
1461  ! Local variables.
1462  !
1463  real(kind=realtype) :: rnorm
1464  integer(kind=intType) :: flowIndex, i
1465  real(kind=realtype), dimension(3) :: freestreamaxisnorm
1466  integer(kind=intType) :: temp
1467 
1468  ! Assume domoniate flow is x
1469 
1470  flowindex = 1
1471 
1472  ! Determine the dominant lift direction
1473  if (abs(liftaxis(1)) > abs(liftaxis(2)) .and. &
1474  abs(liftaxis(1)) > abs(liftaxis(3))) then
1475  temp = 1
1476  else if (abs(liftaxis(2)) > abs(liftaxis(1)) .and. &
1477  abs(liftaxis(2)) > abs(liftaxis(3))) then
1478  temp = 2
1479  else
1480  temp = 3
1481  end if
1482 
1483  liftindex = temp
1484 
1485  ! Normalize the freeStreamDirection vector.
1486  rnorm = sqrt(freestreamaxis(1)**2 + freestreamaxis(2)**2 + freestreamaxis(3)**2)
1487  do i = 1, 3
1488  freestreamaxisnorm(i) = freestreamaxis(i) / rnorm
1489  end do
1490 
1491  if (liftindex == 2) then
1492  ! different coordinate system for aerosurf
1493  ! Wing is in z- direction
1494  ! Compute angle of attack alpha.
1495 
1496  alpha = asin(freestreamaxisnorm(2))
1497 
1498  ! Compute side-slip angle beta.
1499 
1500  beta = -atan2(freestreamaxisnorm(3), freestreamaxisnorm(1))
1501 
1502  elseif (liftindex == 3) then
1503  ! Wing is in y- direction
1504 
1505  ! Compute angle of attack alpha.
1506 
1507  alpha = asin(freestreamaxisnorm(3))
1508 
1509  ! Compute side-slip angle beta.
1510 
1511  beta = atan2(freestreamaxisnorm(2), freestreamaxisnorm(1))
1512  else
1513  call terminate('getDirAngle', 'Invalid Lift Direction')
1514  end if
1515  end subroutine getdirangle
1516 
1518  !
1519  ! Runs the Time spectral stability derivative routines from the
1520  ! main program file
1521  !
1522  use precision
1523  implicit none
1524  !
1525  ! Local variables.
1526  !
1527  real(kind=realtype), dimension(8) :: dcdalpha, dcdalphadot, dcdbeta, &
1528  dcdbetadot, dcdmach, dcdmachdot
1529  real(kind=realtype), dimension(8) :: dcdp, dcdpdot, dcdq, dcdqdot, dcdr, dcdrdot
1530  real(kind=realtype), dimension(8) :: coef0, coef0dot
1531 
1532  !call computeTSDerivatives(coef0,dcdalpha,dcdalphadot,dcdq,dcdqdot)
1533 
1534  end subroutine stabilityderivativedriver
1536  !
1537  ! setCoefTimeIntegrator determines the coefficients of the
1538  ! time integration scheme in unsteady mode. Normally these are
1539  ! equal to the coefficients corresponding to the specified
1540  ! accuracy. However during the initial phase there are not
1541  ! enough states in the past and the accuracy is reduced.
1542  !
1543  use constants
1544  use inputunsteady
1545  use inputphysics
1546  use iteration
1547  use monitor
1548  implicit none
1549  !
1550  ! Local variables.
1551  !
1552  integer(kind=intType) :: nn, nLevelsSet
1553 
1554  ! Determine which time integrator must be used.
1555 
1556  ! Modified by HDN
1557  select case (timeaccuracy)
1558  case (firstorder)
1559 
1560  ! 1st order. No need to check the number of available
1561  ! states in the past. Set the two coefficients and
1562  ! nLevelsSet to 2.
1563 
1564  coeftime(0) = 1.0_realtype
1565  coeftime(1) = -1.0_realtype
1566 
1567  if (useale .and. equationmode .eq. unsteady) then
1568  coeftimeale(1) = 1.0_realtype
1569  coefmeshale(1, 1) = half
1570  coefmeshale(1, 2) = half
1571  end if
1572 
1573  nlevelsset = 2
1574 
1575  !--------------------------------------------------
1576 
1577  case (secondorder)
1578 
1579  ! Second order time integrator. Determine the amount of
1580  ! available states and set the coefficients accordingly.
1581  select case (noldsolavail)
1582 
1583  case (1_inttype)
1584  coeftime(0) = 1.0_realtype
1585  coeftime(1) = -1.0_realtype
1586 
1587  if (useale .and. equationmode .eq. unsteady) then
1588  coeftimeale(1) = half
1589  coeftimeale(2) = half
1590  coeftimeale(3) = zero
1591  coeftimeale(4) = zero
1592 
1593  coefmeshale(1, 1) = half
1594  coefmeshale(1, 2) = half
1595  coefmeshale(2, 1) = half
1596  coefmeshale(2, 2) = half
1597  end if
1598 
1599  nlevelsset = 2
1600 
1601  case default ! 2 or bigger.
1602  coeftime(0) = 1.5_realtype
1603  coeftime(1) = -2.0_realtype
1604  coeftime(2) = 0.5_realtype
1605 
1606  if (useale .and. equationmode .eq. unsteady) then
1609  coeftimeale(3) = -fourth
1610  coeftimeale(4) = -fourth
1611 
1612  coefmeshale(1, 1) = half * (1.0_realtype + 1.0_realtype / sqrtthree)
1613  coefmeshale(1, 2) = half * (1.0_realtype - 1.0_realtype / sqrtthree)
1614  coefmeshale(2, 1) = coefmeshale(1, 2)
1615  coefmeshale(2, 2) = coefmeshale(1, 1)
1616  end if
1617 
1618  nlevelsset = 3
1619 
1620  end select
1621 
1622  !--------------------------------------------------
1623 
1624  case (thirdorder)
1625 
1626  ! Third order time integrator. Determine the amount of
1627  ! available states and set the coefficients accordingly.
1628 
1629  select case (noldsolavail)
1630 
1631  case (1_inttype)
1632  coeftime(0) = 1.0_realtype
1633  coeftime(1) = -1.0_realtype
1634 
1635  if (useale .and. equationmode .eq. unsteady) then
1636  coeftimeale(1) = 1.0_realtype
1637  coefmeshale(1, 1) = half
1638  coefmeshale(1, 2) = half
1639  end if
1640 
1641  nlevelsset = 2
1642 
1643  case (2_inttype)
1644  coeftime(0) = 1.5_realtype
1645  coeftime(1) = -2.0_realtype
1646  coeftime(2) = 0.5_realtype
1647 
1648  if (useale .and. equationmode .eq. unsteady) then
1650  coeftimeale(2) = -fourth
1651  coefmeshale(1, 1) = half * (1.0_realtype + 1.0_realtype / sqrtthree)
1652  coefmeshale(1, 2) = half * (1.0_realtype - 1.0_realtype / sqrtthree)
1653  coefmeshale(2, 1) = coefmeshale(1, 2)
1654  coefmeshale(2, 2) = coefmeshale(1, 1)
1655  end if
1656 
1657  nlevelsset = 3
1658 
1659  case default ! 3 or bigger.
1660  coeftime(0) = 11.0_realtype / 6.0_realtype
1661  coeftime(1) = -3.0_realtype
1662  coeftime(2) = 1.5_realtype
1663  coeftime(3) = -1.0_realtype / 3.0_realtype
1664 
1665  ! These numbers are NOT correct
1666  ! DO NOT use 3rd order ALE for now
1667  if (useale .and. equationmode .eq. unsteady) then
1668  print *, 'Third-order ALE not implemented yet.'
1671  coeftimeale(3) = -fourth
1672  coeftimeale(4) = -fourth
1673  coefmeshale(1, 1) = half * (1.0_realtype + 1.0_realtype / sqrtthree)
1674  coefmeshale(1, 2) = half * (1.0_realtype - 1.0_realtype / sqrtthree)
1675  coefmeshale(2, 1) = coefmeshale(1, 2)
1676  coefmeshale(2, 2) = coefmeshale(1, 1)
1677  coefmeshale(3, 1) = coefmeshale(1, 2)
1678  coefmeshale(3, 2) = coefmeshale(1, 1)
1679  end if
1680 
1681  nlevelsset = 4
1682 
1683  end select
1684 
1685  end select
1686 
1687  ! Set the rest of the coefficients to 0 if not enough states
1688  ! in the past are available.
1689 
1690  do nn = nlevelsset, noldlevels
1691  coeftime(nn) = zero
1692  end do
1693 
1694  end subroutine setcoeftimeintegrator
1695 
1696  function mynorm2(x)
1697  use constants
1698  implicit none
1699  real(kind=realtype), dimension(3), intent(in) :: x
1700  real(kind=realtype) :: mynorm2
1701  mynorm2 = sqrt(x(1)**2 + x(2)**2 + x(3)**2)
1702  end function mynorm2
1703 
1704  function iswalltype(bType)
1705 
1706  use constants
1707  implicit none
1708  integer(kind=intType) :: btype
1709  logical :: iswalltype
1710 
1711  iswalltype = .false.
1712  if (btype == nswalladiabatic .or. &
1713  btype == nswallisothermal .or. &
1714  btype == eulerwall) then
1715  iswalltype = .true.
1716  end if
1717 
1718  end function iswalltype
1719 
1720  subroutine cross_prod(a, b, c)
1721 
1722  use precision
1723 
1724  ! Inputs
1725  real(kind=realtype), dimension(3), intent(in) :: a, b
1726 
1727  ! Outputs
1728  real(kind=realtype), dimension(3), intent(out) :: c
1729 
1730  c(1) = a(2) * b(3) - a(3) * b(2)
1731  c(2) = a(3) * b(1) - a(1) * b(3)
1732  c(3) = a(1) * b(2) - a(2) * b(1)
1733 
1734  end subroutine cross_prod
1735 
1736  subroutine siangle(angle, mult, trans)
1737 
1738  use constants
1739  use su_cgns, only: radian, degree
1740  implicit none
1741  !
1742  ! Subroutine arguments.
1743  !
1744  integer, intent(in) :: angle
1745  real(kind=realtype), intent(out) :: mult, trans
1746 
1747  ! Determine the situation we are having here.
1748 
1749  if (angle == radian) then
1750 
1751  ! Angle is already given in radIans. No need for a conversion.
1752 
1753  mult = one
1754  trans = zero
1755 
1756  else if (angle == degree) then
1757 
1758  ! Angle is given in degrees. A multiplication must be performed.
1759 
1760  mult = pi / 180.0_realtype
1761  trans = zero
1762 
1763  else
1764 
1765  call terminate("siAngle", &
1766  "No idea how to convert this to SI units")
1767 
1768  end if
1769 
1770  end subroutine siangle
1771 
1772  subroutine sidensity(mass, len, mult, trans)
1773  !
1774  ! siDensity computes the conversion from the given density
1775  ! unit, which can be constructed from mass and length, to the
1776  ! SI-unit kg/m^3. The conversion will look like:
1777  ! density in kg/m^3 = mult*(density in NCU) + trans.
1778  ! NCU means non-christian units, i.e. everything that is not SI.
1779  !
1780  use constants
1781  use su_cgns, only: kilogram, meter
1782  implicit none
1783  !
1784  ! Subroutine arguments.
1785  !
1786  integer, intent(in) :: mass, len
1787  real(kind=realtype), intent(out) :: mult, trans
1788 
1789  ! Determine the situation we are having here.
1790 
1791  if (mass == kilogram .and. len == meter) then
1792 
1793  ! Density is given in kg/m^3, i.e. no need for a conversion.
1794 
1795  mult = one
1796  trans = zero
1797 
1798  else
1799 
1800  call terminate("siDensity", &
1801  "No idea how to convert this to SI units")
1802 
1803  end if
1804 
1805  end subroutine sidensity
1806 
1807  subroutine silen(len, mult, trans)
1808  !
1809  ! siLen computes the conversion from the given length unit to
1810  ! the SI-unit meter. The conversion will look like:
1811  ! length in meter = mult*(length in NCU) + trans.
1812  ! NCU means non-christian units, i.e. everything that is not SI.
1813  !
1814  use constants
1815  use su_cgns, only: meter, centimeter, millimeter, foot, inch
1816  implicit none
1817  !
1818  ! Subroutine arguments.
1819  !
1820  integer, intent(in) :: len
1821  real(kind=realtype), intent(out) :: mult, trans
1822 
1823  ! Determine the situation we are having here.
1824 
1825  select case (len)
1826 
1827  case (meter)
1828  mult = one; trans = zero
1829 
1830  case (centimeter)
1831  mult = 0.01_realtype; trans = zero
1832 
1833  case (millimeter)
1834  mult = 0.001_realtype; trans = zero
1835 
1836  case (foot)
1837  mult = 0.3048_realtype; trans = zero
1838 
1839  case (inch)
1840  mult = 0.0254_realtype; trans = zero
1841 
1842  case default
1843  call terminate("siLen", &
1844  "No idea how to convert this to SI units")
1845 
1846  end select
1847 
1848  end subroutine silen
1849 
1850  subroutine sipressure(mass, len, time, mult, trans)
1851  !
1852  ! siPressure computes the conversion from the given pressure
1853  ! unit, which can be constructed from mass, length and time, to
1854  ! the SI-unit Pa. The conversion will look like:
1855  ! pressure in Pa = mult*(pressure in NCU) + trans.
1856  ! NCU means non-christian units, i.e. everything that is not SI.
1857  !
1858  use constants
1859  use su_cgns, only: kilogram, meter, second
1860  implicit none
1861  !
1862  ! Subroutine arguments.
1863  !
1864  integer, intent(in) :: mass, len, time
1865  real(kind=realtype), intent(out) :: mult, trans
1866 
1867  ! Determine the situation we are having here.
1868 
1869  if (mass == kilogram .and. len == meter .and. time == second) then
1870 
1871  ! Pressure is given in Pa, i.e. no need for a conversion.
1872 
1873  mult = one
1874  trans = zero
1875 
1876  else
1877 
1878  call terminate("siPressure", &
1879  "No idea how to convert this to SI units")
1880 
1881  end if
1882 
1883  end subroutine sipressure
1884 
1885  subroutine sitemperature(temp, mult, trans)
1886  !
1887  ! siTemperature computes the conversion from the given
1888  ! temperature unit to the SI-unit kelvin. The conversion will
1889  ! look like:
1890  ! temperature in K = mult*(temperature in NCU) + trans.
1891  ! NCU means non-christian units, i.e. everything that is not SI.
1892  !
1893  use constants
1894  use su_cgns, only: kelvin, celsius, rankine, fahrenheit
1895  implicit none
1896  !
1897  ! Subroutine arguments.
1898  !
1899  integer, intent(in) :: temp
1900  real(kind=realtype), intent(out) :: mult, trans
1901 
1902  ! Determine the situation we are having here.
1903 
1904  select case (temp)
1905 
1906  case (kelvin)
1907 
1908  ! Temperature is already given in Kelvin. No need to convert.
1909 
1910  mult = one
1911  trans = zero
1912 
1913  case (celsius) ! is it Celcius or Celsius?
1914 
1915  ! Temperature is in Celsius. Only an offset must be applied.
1916 
1917  mult = one
1918  trans = 273.16_realtype
1919 
1920  case (rankine)
1921 
1922  ! Temperature is in Rankine. Only a multiplication needs to
1923  ! be performed.
1924 
1925  mult = 5.0_realtype / 9.0_realtype
1926  trans = zero
1927 
1928  case (fahrenheit)
1929 
1930  ! Temperature is in Fahrenheit. Both a multiplication and an
1931  ! offset must be applied.
1932 
1933  mult = 5.0_realtype / 9.0_realtype
1934  trans = 255.382
1935 
1936  case default
1937 
1938  ! Unknown temperature unit.
1939 
1940  call terminate("siTemperature", &
1941  "No idea how to convert this to SI units")
1942 
1943  end select
1944 
1945  end subroutine sitemperature
1946  subroutine siturb(mass, len, time, temp, turbName, mult, trans)
1947  !
1948  ! siTurb computes the conversion from the given turbulence
1949  ! unit, which can be constructed from mass, len, time and temp,
1950  ! to the SI-unit for the given variable. The conversion will
1951  ! look like: var in SI = mult*(var in NCU) + trans.
1952  ! NCU means non-christian units, i.e. everything that is not SI.
1953  !
1954  use constants
1955  use su_cgns, only: kilogram, meter, second, kelvin
1956  implicit none
1957  !
1958  ! Subroutine arguments.
1959  !
1960  integer, intent(in) :: mass, len, time, temp
1961  character(len=*), intent(in) :: turbName
1962  real(kind=realtype), intent(out) :: mult, trans
1963 
1964  ! Determine the situation we are having here.
1965 
1966  if (mass == kilogram .and. len == meter .and. &
1967  time == second .and. temp == kelvin) then
1968 
1969  ! Everthing is already in SI units. No conversion needed.
1970 
1971  mult = one
1972  trans = zero
1973 
1974  else
1975 
1976  call terminate("siTurb", &
1977  "No idea how to convert this to SI units")
1978 
1979  end if
1980 
1981  end subroutine siturb
1982 
1983  subroutine sivelocity(length, time, mult, trans)
1984  !
1985  ! siVelocity computes the conversion from the given velocity
1986  ! unit, which can be constructed from length and time, to the
1987  ! SI-unit m/s. The conversion will look like:
1988  ! velocity in m/s = mult*(velocity in ncu) + trans.
1989  ! Ncu means non-christian units, i.e. everything that is not SI.
1990  !
1991  use constants
1992  use su_cgns, only: meter, centimeter, millimeter, foot, inch, second
1993  implicit none
1994  !
1995  ! Subroutine arguments.
1996  !
1997  integer, intent(in) :: length, time
1998  real(kind=realtype), intent(out) :: mult, trans
1999 
2000  ! Determine the situation we are having here.
2001  ! First the length.
2002 
2003  select case (length)
2004 
2005  case (meter)
2006  mult = one; trans = zero
2007 
2008  case (centimeter)
2009  mult = 0.01_realtype; trans = zero
2010 
2011  case (millimeter)
2012  mult = 0.001_realtype; trans = zero
2013 
2014  case (foot)
2015  mult = 0.3048_realtype; trans = zero
2016 
2017  case (inch)
2018  mult = 0.0254_realtype; trans = zero
2019 
2020  case default
2021  call terminate("siVelocity", &
2022  "No idea how to convert this length to SI units")
2023 
2024  end select
2025 
2026  ! And the time.
2027 
2028  select case (time)
2029 
2030  case (second)
2031  mult = mult
2032 
2033  case default
2034  call terminate("siVelocity", &
2035  "No idea how to convert this time to SI units")
2036 
2037  end select
2038 
2039  end subroutine sivelocity
2040 
2041  ! ----------------------------------------------------------------------
2042  ! |
2043  ! No Tapenade Routine below this line |
2044  ! |
2045  ! ----------------------------------------------------------------------
2046 
2047 #ifndef USE_TAPENADE
2048  subroutine setbcpointers_d(nn, spatialpointers)
2049 !
2050 ! setbcpointers sets the pointers needed for the boundary
2051 ! condition treatment on a general face, such that the boundary
2052 ! routines are only implemented once instead of 6 times.
2053 !
2054  use constants
2055  use blockpointers, only: w, wd, p, pd, rlv, rlvd, rev, revd, &
2056  & gamma, x, xd, d2wall, d2walld, si, sid, sj, sjd, sk, skd, s, sd, &
2057  & globalcell, bcdata, bcdatad, nx, il, ie, ib, ny, jl, je, jb, nz, kl,&
2060  use bcpointers_d, only: ww0, ww0d, ww1, ww1d, ww2, ww2d, ww3, ww3d,&
2061  & pp0, pp0d, pp1, pp1d, pp2, pp2d, pp3, pp3d, rlv0, rlv0d, rlv1, rlv1d&
2062  & , rlv2, rlv2d, rlv3, rlv3d, rev0, rev0d, rev1, rev1d, rev2, rev2d, &
2063  & rev3, rev3d, gamma0, gamma1, gamma2, gamma3, gcp, xx, xxd, ss, ssd, &
2064  & ssi, ssid, ssj, ssjd, ssk, sskd, dd2wall, sface, istart, iend, &
2065  & jstart, jend, isize, jsize
2066  use inputphysics, only: cpmodel, equations
2067  implicit none
2068 ! subroutine arguments.
2069  integer(kind=inttype), intent(in) :: nn
2070  logical, intent(in) :: spatialpointers
2071 ! determine the sizes of each face and point to just the range we
2072 ! need on each face.
2073  istart = bcdata(nn)%icbeg
2074  iend = bcdata(nn)%icend
2075  jstart = bcdata(nn)%jcbeg
2076  jend = bcdata(nn)%jcend
2077 ! set the size of the subface
2078  isize = iend - istart + 1
2079  jsize = jend - jstart + 1
2080 ! determine the face id on which the subface is located and set
2081 ! the pointers accordinly.
2082  select case (bcfaceid(nn))
2083  case (imin)
2084 !---------------------------------------------------------------------------
2085  ww3d => wd(3, 1:, 1:, :)
2086  ww3 => w(3, 1:, 1:, :)
2087  ww2d => wd(2, 1:, 1:, :)
2088  ww2 => w(2, 1:, 1:, :)
2089  ww1d => wd(1, 1:, 1:, :)
2090  ww1 => w(1, 1:, 1:, :)
2091  ww0d => wd(0, 1:, 1:, :)
2092  ww0 => w(0, 1:, 1:, :)
2093  pp3d => pd(3, 1:, 1:)
2094  pp3 => p(3, 1:, 1:)
2095  pp2d => pd(2, 1:, 1:)
2096  pp2 => p(2, 1:, 1:)
2097  pp1d => pd(1, 1:, 1:)
2098  pp1 => p(1, 1:, 1:)
2099  pp0d => pd(0, 1:, 1:)
2100  pp0 => p(0, 1:, 1:)
2101  rlv3d => rlvd(3, 1:, 1:)
2102  rlv3 => rlv(3, 1:, 1:)
2103  rlv2d => rlvd(2, 1:, 1:)
2104  rlv2 => rlv(2, 1:, 1:)
2105  rlv1d => rlvd(1, 1:, 1:)
2106  rlv1 => rlv(1, 1:, 1:)
2107  rlv0d => rlvd(0, 1:, 1:)
2108  rlv0 => rlv(0, 1:, 1:)
2109  rev3d => revd(3, 1:, 1:)
2110  rev3 => rev(3, 1:, 1:)
2111  rev2d => revd(2, 1:, 1:)
2112  rev2 => rev(2, 1:, 1:)
2113  rev1d => revd(1, 1:, 1:)
2114  rev1 => rev(1, 1:, 1:)
2115  rev0d => revd(0, 1:, 1:)
2116  rev0 => rev(0, 1:, 1:)
2117  gamma3 => gamma(3, 1:, 1:)
2118  gamma2 => gamma(2, 1:, 1:)
2119  gamma1 => gamma(1, 1:, 1:)
2120  gamma0 => gamma(0, 1:, 1:)
2121  gcp => globalcell(2, 1:, 1:)
2122  case (imax)
2123 !---------------------------------------------------------------------------
2124  ww3d => wd(nx, 1:, 1:, :)
2125  ww3 => w(nx, 1:, 1:, :)
2126  ww2d => wd(il, 1:, 1:, :)
2127  ww2 => w(il, 1:, 1:, :)
2128  ww1d => wd(ie, 1:, 1:, :)
2129  ww1 => w(ie, 1:, 1:, :)
2130  ww0d => wd(ib, 1:, 1:, :)
2131  ww0 => w(ib, 1:, 1:, :)
2132  pp3d => pd(nx, 1:, 1:)
2133  pp3 => p(nx, 1:, 1:)
2134  pp2d => pd(il, 1:, 1:)
2135  pp2 => p(il, 1:, 1:)
2136  pp1d => pd(ie, 1:, 1:)
2137  pp1 => p(ie, 1:, 1:)
2138  pp0d => pd(ib, 1:, 1:)
2139  pp0 => p(ib, 1:, 1:)
2140  rlv3d => rlvd(nx, 1:, 1:)
2141  rlv3 => rlv(nx, 1:, 1:)
2142  rlv2d => rlvd(il, 1:, 1:)
2143  rlv2 => rlv(il, 1:, 1:)
2144  rlv1d => rlvd(ie, 1:, 1:)
2145  rlv1 => rlv(ie, 1:, 1:)
2146  rlv0d => rlvd(ib, 1:, 1:)
2147  rlv0 => rlv(ib, 1:, 1:)
2148  rev3d => revd(nx, 1:, 1:)
2149  rev3 => rev(nx, 1:, 1:)
2150  rev2d => revd(il, 1:, 1:)
2151  rev2 => rev(il, 1:, 1:)
2152  rev1d => revd(ie, 1:, 1:)
2153  rev1 => rev(ie, 1:, 1:)
2154  rev0d => revd(ib, 1:, 1:)
2155  rev0 => rev(ib, 1:, 1:)
2156  gamma3 => gamma(nx, 1:, 1:)
2157  gamma2 => gamma(il, 1:, 1:)
2158  gamma1 => gamma(ie, 1:, 1:)
2159  gamma0 => gamma(ib, 1:, 1:)
2160  gcp => globalcell(il, 1:, 1:)
2161  case (jmin)
2162 !---------------------------------------------------------------------------
2163  ww3d => wd(1:, 3, 1:, :)
2164  ww3 => w(1:, 3, 1:, :)
2165  ww2d => wd(1:, 2, 1:, :)
2166  ww2 => w(1:, 2, 1:, :)
2167  ww1d => wd(1:, 1, 1:, :)
2168  ww1 => w(1:, 1, 1:, :)
2169  ww0d => wd(1:, 0, 1:, :)
2170  ww0 => w(1:, 0, 1:, :)
2171  pp3d => pd(1:, 3, 1:)
2172  pp3 => p(1:, 3, 1:)
2173  pp2d => pd(1:, 2, 1:)
2174  pp2 => p(1:, 2, 1:)
2175  pp1d => pd(1:, 1, 1:)
2176  pp1 => p(1:, 1, 1:)
2177  pp0d => pd(1:, 0, 1:)
2178  pp0 => p(1:, 0, 1:)
2179  rlv3d => rlvd(1:, 3, 1:)
2180  rlv3 => rlv(1:, 3, 1:)
2181  rlv2d => rlvd(1:, 2, 1:)
2182  rlv2 => rlv(1:, 2, 1:)
2183  rlv1d => rlvd(1:, 1, 1:)
2184  rlv1 => rlv(1:, 1, 1:)
2185  rlv0d => rlvd(1:, 0, 1:)
2186  rlv0 => rlv(1:, 0, 1:)
2187  rev3d => revd(1:, 3, 1:)
2188  rev3 => rev(1:, 3, 1:)
2189  rev2d => revd(1:, 2, 1:)
2190  rev2 => rev(1:, 2, 1:)
2191  rev1d => revd(1:, 1, 1:)
2192  rev1 => rev(1:, 1, 1:)
2193  rev0d => revd(1:, 0, 1:)
2194  rev0 => rev(1:, 0, 1:)
2195  gamma3 => gamma(1:, 3, 1:)
2196  gamma2 => gamma(1:, 2, 1:)
2197  gamma1 => gamma(1:, 1, 1:)
2198  gamma0 => gamma(1:, 0, 1:)
2199  gcp => globalcell(1:, 2, 1:)
2200  case (jmax)
2201 !---------------------------------------------------------------------------
2202  ww3d => wd(1:, ny, 1:, :)
2203  ww3 => w(1:, ny, 1:, :)
2204  ww2d => wd(1:, jl, 1:, :)
2205  ww2 => w(1:, jl, 1:, :)
2206  ww1d => wd(1:, je, 1:, :)
2207  ww1 => w(1:, je, 1:, :)
2208  ww0d => wd(1:, jb, 1:, :)
2209  ww0 => w(1:, jb, 1:, :)
2210  pp3d => pd(1:, ny, 1:)
2211  pp3 => p(1:, ny, 1:)
2212  pp2d => pd(1:, jl, 1:)
2213  pp2 => p(1:, jl, 1:)
2214  pp1d => pd(1:, je, 1:)
2215  pp1 => p(1:, je, 1:)
2216  pp0d => pd(1:, jb, 1:)
2217  pp0 => p(1:, jb, 1:)
2218  rlv3d => rlvd(1:, ny, 1:)
2219  rlv3 => rlv(1:, ny, 1:)
2220  rlv2d => rlvd(1:, jl, 1:)
2221  rlv2 => rlv(1:, jl, 1:)
2222  rlv1d => rlvd(1:, je, 1:)
2223  rlv1 => rlv(1:, je, 1:)
2224  rlv0d => rlvd(1:, jb, 1:)
2225  rlv0 => rlv(1:, jb, 1:)
2226  rev3d => revd(1:, ny, 1:)
2227  rev3 => rev(1:, ny, 1:)
2228  rev2d => revd(1:, jl, 1:)
2229  rev2 => rev(1:, jl, 1:)
2230  rev1d => revd(1:, je, 1:)
2231  rev1 => rev(1:, je, 1:)
2232  rev0d => revd(1:, jb, 1:)
2233  rev0 => rev(1:, jb, 1:)
2234  gamma3 => gamma(1:, ny, 1:)
2235  gamma2 => gamma(1:, jl, 1:)
2236  gamma1 => gamma(1:, je, 1:)
2237  gamma0 => gamma(1:, jb, 1:)
2238  gcp => globalcell(1:, jl, 1:)
2239  case (kmin)
2240 !---------------------------------------------------------------------------
2241  ww3d => wd(1:, 1:, 3, :)
2242  ww3 => w(1:, 1:, 3, :)
2243  ww2d => wd(1:, 1:, 2, :)
2244  ww2 => w(1:, 1:, 2, :)
2245  ww1d => wd(1:, 1:, 1, :)
2246  ww1 => w(1:, 1:, 1, :)
2247  ww0d => wd(1:, 1:, 0, :)
2248  ww0 => w(1:, 1:, 0, :)
2249  pp3d => pd(1:, 1:, 3)
2250  pp3 => p(1:, 1:, 3)
2251  pp2d => pd(1:, 1:, 2)
2252  pp2 => p(1:, 1:, 2)
2253  pp1d => pd(1:, 1:, 1)
2254  pp1 => p(1:, 1:, 1)
2255  pp0d => pd(1:, 1:, 0)
2256  pp0 => p(1:, 1:, 0)
2257  rlv3d => rlvd(1:, 1:, 3)
2258  rlv3 => rlv(1:, 1:, 3)
2259  rlv2d => rlvd(1:, 1:, 2)
2260  rlv2 => rlv(1:, 1:, 2)
2261  rlv1d => rlvd(1:, 1:, 1)
2262  rlv1 => rlv(1:, 1:, 1)
2263  rlv0d => rlvd(1:, 1:, 0)
2264  rlv0 => rlv(1:, 1:, 0)
2265  rev3d => revd(1:, 1:, 3)
2266  rev3 => rev(1:, 1:, 3)
2267  rev2d => revd(1:, 1:, 2)
2268  rev2 => rev(1:, 1:, 2)
2269  rev1d => revd(1:, 1:, 1)
2270  rev1 => rev(1:, 1:, 1)
2271  rev0d => revd(1:, 1:, 0)
2272  rev0 => rev(1:, 1:, 0)
2273  gamma3 => gamma(1:, 1:, 3)
2274  gamma2 => gamma(1:, 1:, 2)
2275  gamma1 => gamma(1:, 1:, 1)
2276  gamma0 => gamma(1:, 1:, 0)
2277  gcp => globalcell(1:, 1:, 2)
2278  case (kmax)
2279 !---------------------------------------------------------------------------
2280  ww3d => wd(1:, 1:, nz, :)
2281  ww3 => w(1:, 1:, nz, :)
2282  ww2d => wd(1:, 1:, kl, :)
2283  ww2 => w(1:, 1:, kl, :)
2284  ww1d => wd(1:, 1:, ke, :)
2285  ww1 => w(1:, 1:, ke, :)
2286  ww0d => wd(1:, 1:, kb, :)
2287  ww0 => w(1:, 1:, kb, :)
2288  pp3d => pd(1:, 1:, nz)
2289  pp3 => p(1:, 1:, nz)
2290  pp2d => pd(1:, 1:, kl)
2291  pp2 => p(1:, 1:, kl)
2292  pp1d => pd(1:, 1:, ke)
2293  pp1 => p(1:, 1:, ke)
2294  pp0d => pd(1:, 1:, kb)
2295  pp0 => p(1:, 1:, kb)
2296  rlv3d => rlvd(1:, 1:, nz)
2297  rlv3 => rlv(1:, 1:, nz)
2298  rlv2d => rlvd(1:, 1:, kl)
2299  rlv2 => rlv(1:, 1:, kl)
2300  rlv1d => rlvd(1:, 1:, ke)
2301  rlv1 => rlv(1:, 1:, ke)
2302  rlv0d => rlvd(1:, 1:, kb)
2303  rlv0 => rlv(1:, 1:, kb)
2304  rev3d => revd(1:, 1:, nz)
2305  rev3 => rev(1:, 1:, nz)
2306  rev2d => revd(1:, 1:, kl)
2307  rev2 => rev(1:, 1:, kl)
2308  rev1d => revd(1:, 1:, ke)
2309  rev1 => rev(1:, 1:, ke)
2310  rev0d => revd(1:, 1:, kb)
2311  rev0 => rev(1:, 1:, kb)
2312  gamma3 => gamma(1:, 1:, nz)
2313  gamma2 => gamma(1:, 1:, kl)
2314  gamma1 => gamma(1:, 1:, ke)
2315  gamma0 => gamma(1:, 1:, kb)
2316  gcp => globalcell(1:, 1:, kl)
2317  end select
2318  if (spatialpointers) then
2319  select case (bcfaceid(nn))
2320  case (imin)
2321  xxd => xd(1, :, :, :)
2322  xx => x(1, :, :, :)
2323  ssid => sid(1, :, :, :)
2324  ssi => si(1, :, :, :)
2325  ssjd => sjd(2, :, :, :)
2326  ssj => sj(2, :, :, :)
2327  sskd => skd(2, :, :, :)
2328  ssk => sk(2, :, :, :)
2329  ssd => sd(2, :, :, :)
2330  ss => s(2, :, :, :)
2331  case (imax)
2332  xxd => xd(il, :, :, :)
2333  xx => x(il, :, :, :)
2334  ssid => sid(il, :, :, :)
2335  ssi => si(il, :, :, :)
2336  ssjd => sjd(il, :, :, :)
2337  ssj => sj(il, :, :, :)
2338  sskd => skd(il, :, :, :)
2339  ssk => sk(il, :, :, :)
2340  ssd => sd(il, :, :, :)
2341  ss => s(il, :, :, :)
2342  case (jmin)
2343  xxd => xd(:, 1, :, :)
2344  xx => x(:, 1, :, :)
2345  ssid => sjd(:, 1, :, :)
2346  ssi => sj(:, 1, :, :)
2347  ssjd => sid(:, 2, :, :)
2348  ssj => si(:, 2, :, :)
2349  sskd => skd(:, 2, :, :)
2350  ssk => sk(:, 2, :, :)
2351  ssd => sd(:, 2, :, :)
2352  ss => s(:, 2, :, :)
2353  case (jmax)
2354  xxd => xd(:, jl, :, :)
2355  xx => x(:, jl, :, :)
2356  ssid => sjd(:, jl, :, :)
2357  ssi => sj(:, jl, :, :)
2358  ssjd => sid(:, jl, :, :)
2359  ssj => si(:, jl, :, :)
2360  sskd => skd(:, jl, :, :)
2361  ssk => sk(:, jl, :, :)
2362  ssd => sd(:, jl, :, :)
2363  ss => s(:, jl, :, :)
2364  case (kmin)
2365  xxd => xd(:, :, 1, :)
2366  xx => x(:, :, 1, :)
2367  ssid => skd(:, :, 1, :)
2368  ssi => sk(:, :, 1, :)
2369  ssjd => sid(:, :, 2, :)
2370  ssj => si(:, :, 2, :)
2371  sskd => sjd(:, :, 2, :)
2372  ssk => sj(:, :, 2, :)
2373  ssd => sd(:, :, 2, :)
2374  ss => s(:, :, 2, :)
2375  case (kmax)
2376  xxd => xd(:, :, kl, :)
2377  xx => x(:, :, kl, :)
2378  ssid => skd(:, :, kl, :)
2379  ssi => sk(:, :, kl, :)
2380  ssjd => sid(:, :, kl, :)
2381  ssj => si(:, :, kl, :)
2382  sskd => sjd(:, :, kl, :)
2383  ssk => sj(:, :, kl, :)
2384  ssd => sd(:, :, kl, :)
2385  ss => s(:, :, kl, :)
2386  end select
2387  if (addgridvelocities) then
2388  select case (bcfaceid(nn))
2389  case (imin)
2390  sface => sfacei(1, :, :)
2391  case (imax)
2392  sface => sfacei(il, :, :)
2393  case (jmin)
2394  sface => sfacej(:, 1, :)
2395  case (jmax)
2396  sface => sfacej(:, jl, :)
2397  case (kmin)
2398  sface => sfacek(:, :, 1)
2399  case (kmax)
2400  sface => sfacek(:, :, kl)
2401  end select
2402  end if
2403  if (equations .eq. ransequations) then
2404  select case (bcfaceid(nn))
2405  case (imin)
2406  dd2wall => d2wall(2, :, :)
2407  case (imax)
2408  dd2wall => d2wall(il, :, :)
2409  case (jmin)
2410  dd2wall => d2wall(:, 2, :)
2411  case (jmax)
2412  dd2wall => d2wall(:, jl, :)
2413  case (kmin)
2414  dd2wall => d2wall(:, :, 2)
2415  case (kmax)
2416  dd2wall => d2wall(:, :, kl)
2417  end select
2418  end if
2419  end if
2420  end subroutine setbcpointers_d
2421 
2422  subroutine maxeddyv(eddyvisMax)
2423  !
2424  ! maxEddyv determines the maximum value of the eddy viscosity
2425  ! ratio of the block given by the pointers in blockPointes.
2426  !
2427  use constants
2428  use blockpointers, only: il, jl, kl, rlv, rev
2429  use flowvarrefstate, only: nwf, eddymodel
2430  implicit none
2431  !
2432  ! Subroutine arguments.
2433  !
2434  real(kind=realtype), intent(out) :: eddyvismax
2435  !
2436  ! Local variables.
2437  !
2438  integer(kind=intType) :: i, j, k
2439 
2440  real(kind=realtype) :: eddyvis
2441 
2442  ! Initialize the maximum value to zero and return immediately if
2443  ! not an eddy viscosity model is used.
2444 
2445  eddyvismax = zero
2446  if (.not. eddymodel) return
2447 
2448  ! Loop over the owned cells of this block.
2449 
2450  do k = 2, kl
2451  do j = 2, jl
2452  do i = 2, il
2453 
2454  ! Compute the local viscosity ratio and take the maximum
2455  ! with the currently stored value.
2456 
2457  eddyvis = rev(i, j, k) / rlv(i, j, k)
2458  eddyvismax = max(eddyvismax, eddyvis)
2459 
2460  end do
2461  end do
2462  end do
2463 
2464  end subroutine maxeddyv
2465 
2466  subroutine maxhdiffmach(hdiffMax, MachMax)
2467  !
2468  ! maxHdiffMach determines the maximum value of the Mach number
2469  ! and total enthalpy (or better the relative total enthalpy
2470  ! difference with the freestream).
2471  !
2472  use constants
2473  use blockpointers, only: il, jl, kl, w, p, gamma
2474  use flowvarrefstate, only: pinfcorr, rhoinf, winf
2475  use monitor, only: monmachorhmax
2476  implicit none
2477  !
2478  ! Subroutine arguments.
2479  !
2480  real(kind=realtype), intent(out) :: hdiffmax, machmax
2481  !
2482  ! Local variables.
2483  !
2484  integer(kind=intType) :: i, j, k
2485 
2486  real(kind=realtype) :: hdiff, hinf, mach2
2487 
2488  ! Initialize the maximum values to zero.
2489 
2490  hdiffmax = zero
2491  machmax = zero
2492 
2493  ! In case none of the two variables needs to be monitored,
2494  ! a return is made.
2495 
2496  if (.not. monmachorhmax) return
2497 
2498  ! Set the free stream value of the total enthalpy.
2499 
2500  hinf = (winf(irhoe) + pinfcorr) / rhoinf
2501 
2502  ! Loop over the owned cells of this block.
2503 
2504  do k = 2, kl
2505  do j = 2, jl
2506  do i = 2, il
2507 
2508  ! Compute the local total enthalpy and Mach number squared.
2509 
2510  hdiff = abs((w(i, j, k, irhoe) + p(i, j, k)) / w(i, j, k, irho) - hinf)
2511  mach2 = (w(i, j, k, ivx)**2 + w(i, j, k, ivy)**2 &
2512  + w(i, j, k, ivz)**2) * w(i, j, k, irho) / (gamma(i, j, k) * p(i, j, k))
2513 
2514  ! Determine the maximum of these values and the
2515  ! currently stored maximum values.
2516 
2517  hdiffmax = max(hdiffmax, hdiff)
2518  machmax = max(machmax, mach2)
2519 
2520  end do
2521  end do
2522  end do
2523 
2524  ! Currently the maximum Mach number squared is stored in
2525  ! MachMax. Take the square root. Also create a relative
2526  ! total enthalpy difference.
2527 
2528  machmax = sqrt(machmax)
2529  hdiffmax = hdiffmax / hinf
2530 
2531  end subroutine maxhdiffmach
2532 
2533  function delta(val1, val2)
2534  !
2535  ! delta is a function used to determine the contents of the full
2536  ! transformation matrix from the shorthand form. It returns 1
2537  ! if the absolute value of the two arguments are identical.
2538  ! Otherwise it returns 0.
2539  !
2540  use constants
2541  implicit none
2542  !
2543  ! Function type.
2544  !
2545  integer(kind=intType) :: delta
2546  !
2547  ! Function arguments.
2548  !
2549  integer(kind=intType) :: val1, val2
2550 
2551  if (abs(val1) == abs(val2)) then
2552  delta = 1_inttype
2553  else
2554  delta = 0_inttype
2555  end if
2556 
2557  end function delta
2558 
2559  subroutine nullifycgnsdompointers(nn)
2560  !
2561  ! nullifyCGNSDomPointers nullifies all the pointers of the
2562  ! given CGNS block.
2563  !
2564  use constants
2565  use cgnsgrid, only: cgnsdoms
2566  implicit none
2567  !
2568  ! Subroutine arguments.
2569  !
2570  integer(kind=intType), intent(in) :: nn
2571  !
2572  nullify (cgnsdoms(nn)%procStored)
2573  nullify (cgnsdoms(nn)%conn1to1)
2574  nullify (cgnsdoms(nn)%connNonMatchAbutting)
2575  nullify (cgnsdoms(nn)%bocoInfo)
2576 
2577  end subroutine nullifycgnsdompointers
2578 
2579  subroutine nullifyflowdompointers(nn, level, sps)
2580  !
2581  ! nullifyFlowDomPointers nullifies all the pointers of the
2582  ! given block.
2583  !
2584  use constants
2585  use block, only: flowdoms
2586  implicit none
2587  !
2588  ! Subroutine arguments.
2589  !
2590  integer(kind=intType), intent(in) :: nn, level, sps
2591 
2592  nullify (flowdoms(nn, level, sps)%BCType)
2593  nullify (flowdoms(nn, level, sps)%BCFaceID)
2594  nullify (flowdoms(nn, level, sps)%cgnsSubface)
2595 
2596  nullify (flowdoms(nn, level, sps)%inBeg)
2597  nullify (flowdoms(nn, level, sps)%jnBeg)
2598  nullify (flowdoms(nn, level, sps)%knBeg)
2599  nullify (flowdoms(nn, level, sps)%inEnd)
2600  nullify (flowdoms(nn, level, sps)%jnEnd)
2601  nullify (flowdoms(nn, level, sps)%knEnd)
2602 
2603  nullify (flowdoms(nn, level, sps)%dinBeg)
2604  nullify (flowdoms(nn, level, sps)%djnBeg)
2605  nullify (flowdoms(nn, level, sps)%dknBeg)
2606  nullify (flowdoms(nn, level, sps)%dinEnd)
2607  nullify (flowdoms(nn, level, sps)%djnEnd)
2608  nullify (flowdoms(nn, level, sps)%dknEnd)
2609 
2610  nullify (flowdoms(nn, level, sps)%icBeg)
2611  nullify (flowdoms(nn, level, sps)%jcBeg)
2612  nullify (flowdoms(nn, level, sps)%kcBeg)
2613  nullify (flowdoms(nn, level, sps)%icEnd)
2614  nullify (flowdoms(nn, level, sps)%jcEnd)
2615  nullify (flowdoms(nn, level, sps)%kcEnd)
2616 
2617  nullify (flowdoms(nn, level, sps)%neighBlock)
2618  nullify (flowdoms(nn, level, sps)%neighProc)
2619  nullify (flowdoms(nn, level, sps)%l1)
2620  nullify (flowdoms(nn, level, sps)%l2)
2621  nullify (flowdoms(nn, level, sps)%l3)
2622  nullify (flowdoms(nn, level, sps)%groupNum)
2623 
2624  nullify (flowdoms(nn, level, sps)%iblank)
2625  nullify (flowdoms(nn, level, sps)%forcedRecv)
2626  nullify (flowdoms(nn, level, sps)%status)
2627  nullify (flowdoms(nn, level, sps)%fringes)
2628  nullify (flowdoms(nn, level, sps)%orphans)
2629 
2630  nullify (flowdoms(nn, level, sps)%BCData)
2631  nullify (flowdoms(nn, level, sps)%viscSubface)
2632 
2633  nullify (flowdoms(nn, level, sps)%viscIminPointer)
2634  nullify (flowdoms(nn, level, sps)%viscImaxPointer)
2635  nullify (flowdoms(nn, level, sps)%viscJminPointer)
2636  nullify (flowdoms(nn, level, sps)%viscJmaxPointer)
2637  nullify (flowdoms(nn, level, sps)%viscKminPointer)
2638  nullify (flowdoms(nn, level, sps)%viscKmaxPointer)
2639 
2640  nullify (flowdoms(nn, level, sps)%x)
2641  nullify (flowdoms(nn, level, sps)%xOld)
2642  nullify (flowdoms(nn, level, sps)%si)
2643  nullify (flowdoms(nn, level, sps)%sj)
2644  nullify (flowdoms(nn, level, sps)%sk)
2645  nullify (flowdoms(nn, level, sps)%vol)
2646  nullify (flowdoms(nn, level, sps)%volRef)
2647  nullify (flowdoms(nn, level, sps)%volOld)
2648 
2649  nullify (flowdoms(nn, level, sps)%pori)
2650  nullify (flowdoms(nn, level, sps)%porj)
2651  nullify (flowdoms(nn, level, sps)%pork)
2652 
2653  nullify (flowdoms(nn, level, sps)%indFamilyI)
2654  nullify (flowdoms(nn, level, sps)%indFamilyJ)
2655  nullify (flowdoms(nn, level, sps)%indFamilyK)
2656 
2657  nullify (flowdoms(nn, level, sps)%factFamilyI)
2658  nullify (flowdoms(nn, level, sps)%factFamilyJ)
2659  nullify (flowdoms(nn, level, sps)%factFamilyK)
2660 
2661  nullify (flowdoms(nn, level, sps)%rotMatrixI)
2662  nullify (flowdoms(nn, level, sps)%rotMatrixJ)
2663  nullify (flowdoms(nn, level, sps)%rotMatrixK)
2664 
2665  nullify (flowdoms(nn, level, sps)%sFaceI)
2666  nullify (flowdoms(nn, level, sps)%sFaceJ)
2667  nullify (flowdoms(nn, level, sps)%sFaceK)
2668 
2669  nullify (flowdoms(nn, level, sps)%w)
2670  nullify (flowdoms(nn, level, sps)%wOld)
2671  nullify (flowdoms(nn, level, sps)%p)
2672  nullify (flowdoms(nn, level, sps)%aa)
2673  nullify (flowdoms(nn, level, sps)%gamma)
2674  nullify (flowdoms(nn, level, sps)%rlv)
2675  nullify (flowdoms(nn, level, sps)%rev)
2676  nullify (flowdoms(nn, level, sps)%s)
2677 
2678  nullify (flowdoms(nn, level, sps)%ux)
2679  nullify (flowdoms(nn, level, sps)%uy)
2680  nullify (flowdoms(nn, level, sps)%uz)
2681 
2682  nullify (flowdoms(nn, level, sps)%vx)
2683  nullify (flowdoms(nn, level, sps)%vy)
2684  nullify (flowdoms(nn, level, sps)%vz)
2685 
2686  nullify (flowdoms(nn, level, sps)%wx)
2687  nullify (flowdoms(nn, level, sps)%wy)
2688  nullify (flowdoms(nn, level, sps)%wz)
2689 
2690  nullify (flowdoms(nn, level, sps)%qx)
2691  nullify (flowdoms(nn, level, sps)%qy)
2692  nullify (flowdoms(nn, level, sps)%qz)
2693 
2694  nullify (flowdoms(nn, level, sps)%dw)
2695  nullify (flowdoms(nn, level, sps)%fw)
2696  nullify (flowdoms(nn, level, sps)%scratch)
2697  nullify (flowdoms(nn, level, sps)%shockSensor)
2698 
2699  nullify (flowdoms(nn, level, sps)%dwOldRK)
2700 
2701  nullify (flowdoms(nn, level, sps)%p1)
2702  nullify (flowdoms(nn, level, sps)%w1)
2703  nullify (flowdoms(nn, level, sps)%wr)
2704 
2705  nullify (flowdoms(nn, level, sps)%mgIFine)
2706  nullify (flowdoms(nn, level, sps)%mgJFine)
2707  nullify (flowdoms(nn, level, sps)%mgKFine)
2708 
2709  nullify (flowdoms(nn, level, sps)%mgIWeight)
2710  nullify (flowdoms(nn, level, sps)%mgJWeight)
2711  nullify (flowdoms(nn, level, sps)%mgKWeight)
2712 
2713  nullify (flowdoms(nn, level, sps)%mgICoarse)
2714  nullify (flowdoms(nn, level, sps)%mgJCoarse)
2715  nullify (flowdoms(nn, level, sps)%mgKCoarse)
2716 
2717  nullify (flowdoms(nn, level, sps)%ico)
2718  nullify (flowdoms(nn, level, sps)%jco)
2719  nullify (flowdoms(nn, level, sps)%kco)
2720 
2721  nullify (flowdoms(nn, level, sps)%wn)
2722  nullify (flowdoms(nn, level, sps)%pn)
2723  nullify (flowdoms(nn, level, sps)%dtl)
2724  nullify (flowdoms(nn, level, sps)%radI)
2725  nullify (flowdoms(nn, level, sps)%radJ)
2726  nullify (flowdoms(nn, level, sps)%radK)
2727 
2728  nullify (flowdoms(nn, level, sps)%d2Wall)
2729 
2730  nullify (flowdoms(nn, level, sps)%bmti1)
2731  nullify (flowdoms(nn, level, sps)%bmti2)
2732  nullify (flowdoms(nn, level, sps)%bmtj1)
2733  nullify (flowdoms(nn, level, sps)%bmtj2)
2734  nullify (flowdoms(nn, level, sps)%bmtk1)
2735  nullify (flowdoms(nn, level, sps)%bmtk2)
2736 
2737  nullify (flowdoms(nn, level, sps)%bvti1)
2738  nullify (flowdoms(nn, level, sps)%bvti2)
2739  nullify (flowdoms(nn, level, sps)%bvtj1)
2740  nullify (flowdoms(nn, level, sps)%bvtj2)
2741  nullify (flowdoms(nn, level, sps)%bvtk1)
2742  nullify (flowdoms(nn, level, sps)%bvtk2)
2743 
2744  nullify (flowdoms(nn, level, sps)%globalCell)
2745  nullify (flowdoms(nn, level, sps)%globalNode)
2746  nullify (flowdoms(nn, level, sps)%surfNodeIndices)
2747  nullify (flowdoms(nn, level, sps)%uv)
2748  nullify (flowdoms(nn, level, sps)%wallInd)
2749  nullify (flowdoms(nn, level, sps)%xSeed)
2750 
2751  ! Added by HDN
2752  nullify (flowdoms(nn, level, sps)%xALE)
2753  nullify (flowdoms(nn, level, sps)%sIALE)
2754  nullify (flowdoms(nn, level, sps)%sJALE)
2755  nullify (flowdoms(nn, level, sps)%sKALE)
2756  nullify (flowdoms(nn, level, sps)%sFaceIALE)
2757  nullify (flowdoms(nn, level, sps)%sFaceJALE)
2758  nullify (flowdoms(nn, level, sps)%sFaceKALE)
2759  nullify (flowdoms(nn, level, sps)%dwALE)
2760  nullify (flowdoms(nn, level, sps)%fwALE)
2761 #ifndef USE_TAPENADE
2762  nullify (flowdoms(nn, level, sps)%PCMat)
2763  nullify (flowdoms(nn, level, sps)%i_D_Fact)
2764  nullify (flowdoms(nn, level, sps)%i_L_Fact)
2765  nullify (flowdoms(nn, level, sps)%i_U_Fact)
2766  nullify (flowdoms(nn, level, sps)%i_U2_Fact)
2767 
2768  nullify (flowdoms(nn, level, sps)%j_D_Fact)
2769  nullify (flowdoms(nn, level, sps)%j_L_Fact)
2770  nullify (flowdoms(nn, level, sps)%j_U_Fact)
2771  nullify (flowdoms(nn, level, sps)%j_U2_Fact)
2772 
2773  nullify (flowdoms(nn, level, sps)%k_D_Fact)
2774  nullify (flowdoms(nn, level, sps)%k_L_Fact)
2775  nullify (flowdoms(nn, level, sps)%k_U_Fact)
2776  nullify (flowdoms(nn, level, sps)%k_U2_Fact)
2777 #endif
2778 
2779  end subroutine nullifyflowdompointers
2780 
2781  subroutine reallocateinteger(intArray, newSize, oldSize, &
2782  alwaysFreeMem)
2783  !
2784  ! reallocateInteger reallocates the given integer array to the
2785  ! given new size. The old values of the array are copied. Note
2786  ! that newSize can be both smaller and larger than oldSize.
2787  !
2788  use constants
2789  implicit none
2790  !
2791  ! Subroutine arguments.
2792  !
2793  integer(kind=intType), dimension(:), pointer :: intArray
2794  integer(kind=intType), intent(in) :: newSize, oldSize
2795  logical, intent(in) :: alwaysFreeMem
2796  !
2797  ! Local variables.
2798  !
2799  integer(kind=intType), dimension(:), pointer :: tmp
2800 
2801  integer(kind=intType) :: i, nn, ll
2802 
2803  integer :: ierr
2804 
2805  ! Determine the minimum of newSize and oldSize.
2806 
2807  nn = min(newsize, oldsize)
2808 
2809  ! Set the pointer for tmp to intArray.
2810 
2811  tmp => intarray
2812 
2813  ! Allocate the memory for intArray in case newSize is larger
2814  ! than 0 or if alwaysFreeMem is .true. And copy the old data
2815  ! into it. Preserve the lower bound.
2816 
2817  if (newsize > 0 .or. alwaysfreemem) then
2818 
2819  ll = 1
2820  if (associated(intarray)) ll = lbound(intarray, 1)
2821 
2822  allocate (intarray(ll:newsize + ll - 1), stat=ierr)
2823  if (ierr /= 0) &
2824  call terminate("reallocateInteger", &
2825  "Memory allocation failure for intArray")
2826  do i = ll, ll + nn - 1
2827  intarray(i) = tmp(i)
2828  end do
2829  end if
2830 
2831  ! Release the memory for tmp in case oldSize is larger than 0 or
2832  ! if alwaysFreeMem is .true.
2833 
2834  if (oldsize > 0 .or. alwaysfreemem) then
2835  deallocate (tmp, stat=ierr)
2836  if (ierr /= 0) &
2837  call terminate("reallocateInteger", &
2838  "Deallocation error for tmp")
2839  end if
2840 
2841  end subroutine reallocateinteger
2842 
2843  !---------------------------------------------------------------------------=
2844 
2845  subroutine reallocatempioffsetkindinteger(intArray, newSize, &
2846  oldSize, alwaysFreeMem)
2847  !
2848  ! reallocateMpiOffsetKindInteger reallocates the given
2849  ! mpi_offset_kind integer array to the given new size. The old
2850  ! values of the array are copied. Note that newSize can be both
2851  ! smaller and larger than oldSize.
2852  !
2853  use constants
2854  implicit none
2855  !
2856  ! Subroutine arguments.
2857  !
2858  integer(kind=mpi_offset_kind), dimension(:), pointer :: intArray
2859  integer(kind=intType), intent(in) :: newSize, oldSize
2860  logical, intent(in) :: alwaysFreeMem
2861  !
2862  ! Local variables.
2863  !
2864  integer(kind=mpi_offset_kind), dimension(:), pointer :: tmp
2865 
2866  integer(kind=intType) :: i, nn, ll
2867 
2868  integer :: ierr
2869 
2870  ! Determine the minimum of newSize and oldSize.
2871 
2872  nn = min(newsize, oldsize)
2873 
2874  ! Set the pointer for tmp to intArray.
2875 
2876  tmp => intarray
2877 
2878  ! Allocate the memory for intArray in case newSize is larger
2879  ! than 0 or if alwaysFreeMem is .true. And copy the old data
2880  ! into it. Preserve the lower bound.
2881 
2882  if (newsize > 0 .or. alwaysfreemem) then
2883 
2884  ll = 1
2885  if (associated(intarray)) ll = lbound(intarray, 1)
2886 
2887  allocate (intarray(ll:newsize + ll - 1), stat=ierr)
2888  if (ierr /= 0) &
2889  call terminate("reallocateMpiOffsetKindInteger", &
2890  "Memory allocation failure for intArray")
2891  do i = ll, ll + nn - 1
2892  intarray(i) = tmp(i)
2893  end do
2894  end if
2895 
2896  ! Release the memory for tmp in case oldSize is larger than 0 or
2897  ! if alwaysFreeMem is .true.
2898 
2899  if (oldsize > 0 .or. alwaysfreemem) then
2900  deallocate (tmp, stat=ierr)
2901  if (ierr /= 0) &
2902  call terminate("reallocateMpiOffsetKindInteger", &
2903  "Deallocation error for tmp")
2904  end if
2905 
2906  end subroutine reallocatempioffsetkindinteger
2907 
2908  !---------------------------------------------------------------------------=
2909 
2910  subroutine reallocateinteger2(intArray, newSize1, newSize2, &
2911  oldSize1, oldSize2, &
2912  alwaysFreeMem)
2913  !
2914  ! reallocateInteger2 reallocates the given 2D integer array to
2915  ! the given new sizes. The old values of the array are copied.
2916  ! Note that the newSizes can be both smaller and larger than
2917  ! the oldSizes.
2918  !
2919  use constants
2920  implicit none
2921  !
2922  ! Subroutine arguments.
2923  !
2924  integer(kind=intType), dimension(:, :), pointer :: intArray
2925  integer(kind=intType), intent(in) :: newSize1, newSize2, &
2926  oldSize1, oldSize2
2927  logical, intent(in) :: alwaysFreeMem
2928  !
2929  ! Local variables.
2930  !
2931  integer(kind=intType), dimension(:, :), pointer :: tmp
2932 
2933  integer(kind=intType) :: newSize, oldSize
2934  integer(kind=intType) :: nn1, nn2, nn
2935 
2936  integer(kind=intType) :: i, j
2937 
2938  integer :: ierr
2939 
2940  ! Determine the total new and old size.
2941 
2942  newsize = newsize1 * newsize2
2943  oldsize = oldsize1 * oldsize2
2944 
2945  ! Determine for each of the 2 components the minimum of the new
2946  ! and the old size. Multiply these values to obtain the total
2947  ! amount of data that must be copied.
2948 
2949  nn1 = min(newsize1, oldsize1)
2950  nn2 = min(newsize2, oldsize2)
2951 
2952  nn = nn1 * nn2
2953 
2954  ! Set the pointer for tmp.
2955 
2956  tmp => intarray
2957 
2958  ! Allocate the memory for intArray in case newSize is larger
2959  ! than 0 or if alwaysFreeMem is .true. and copy the old data
2960  ! into it.
2961 
2962  if (newsize > 0 .or. alwaysfreemem) then
2963  allocate (intarray(newsize1, newsize2), stat=ierr)
2964  if (ierr /= 0) &
2965  call terminate("reallocateInteger2", &
2966  "Memory allocation failure for intArray")
2967  do j = 1, nn2
2968  do i = 1, nn1
2969  intarray(i, j) = tmp(i, j)
2970  end do
2971  end do
2972  end if
2973 
2974  ! Release the memory of tmp in case oldSize is larger than 0
2975  ! or if alwaysFreeMem is .true..
2976 
2977  if (oldsize > 0 .or. alwaysfreemem) then
2978  deallocate (tmp, stat=ierr)
2979  if (ierr /= 0) &
2980  call terminate("reallocateInteger2", &
2981  "Deallocation error for tmp")
2982  end if
2983 
2984  end subroutine reallocateinteger2
2985 
2986  subroutine reallocatereal(realArray, newSize, oldSize, &
2987  alwaysFreeMem)
2988  !
2989  ! ReallocateReal reallocates the given real array to the given
2990  ! new size. The old values of the array are copied. Note that
2991  ! newSize can be both smaller and larger than oldSize.
2992  !
2993  use constants
2994  implicit none
2995  !
2996  ! Subroutine arguments.
2997  !
2998  real(kind=realtype), dimension(:), pointer :: realarray
2999  integer(kind=intType), intent(in) :: newSize, oldSize
3000  logical, intent(in) :: alwaysFreeMem
3001  !
3002  ! Local variables.
3003  !
3004  real(kind=realtype), dimension(:), pointer :: tmp
3005 
3006  integer(kind=intType) :: i, nn
3007 
3008  integer :: ierr
3009 
3010  ! Determine the minimum of newSize and oldSize.
3011 
3012  nn = min(newsize, oldsize)
3013 
3014  ! Set the pointer for tmp to realArray.
3015 
3016  tmp => realarray
3017 
3018  ! Allocate the memory for realArray in case newSize is larger
3019  ! than 0 or if alwaysFreeMem is .True. And copy the old data
3020  ! into it.
3021 
3022  if (newsize > 0 .or. alwaysfreemem) then
3023  allocate (realarray(newsize), stat=ierr)
3024  if (ierr /= 0) &
3025  call terminate("reallocateReal", &
3026  "Memory allocation failure for realArray")
3027  do i = 1, nn
3028  realarray(i) = tmp(i)
3029  end do
3030  end if
3031 
3032  ! Release the memory for tmp in case oldSize is larger than 0 or
3033  ! if alwaysFreeMem is .True.
3034 
3035  if (oldsize > 0 .or. alwaysfreemem) then
3036  deallocate (tmp, stat=ierr)
3037  if (ierr /= 0) &
3038  call terminate("reallocateReal", &
3039  "Deallocation error for tmp")
3040  end if
3041 
3042  end subroutine reallocatereal
3043 
3044  !---------------------------------------------------------------------------=
3045 
3046  subroutine reallocatereal2(realArray, newSize1, newSize2, &
3047  oldSize1, oldSize2, &
3048  alwaysFreeMem)
3049  !
3050  ! ReallocateReal2 reallocates the given 2d integer array to
3051  ! the given new sizes. The old values of the array are copied.
3052  ! Note that the newSizes can be both smaller and larger than
3053  ! the oldSizes.
3054  !
3055  use constants
3056  implicit none
3057  !
3058  ! Subroutine arguments.
3059  !
3060  real(kind=realtype), dimension(:, :), pointer :: realarray
3061  integer(kind=intType), intent(in) :: newSize1, newSize2, &
3062  oldSize1, oldSize2
3063  logical, intent(in) :: alwaysFreeMem
3064  !
3065  ! Local variables.
3066  !
3067  real(kind=realtype), dimension(:, :), pointer :: tmp
3068 
3069  integer(kind=intType) :: newSize, oldSize
3070  integer(kind=intType) :: nn1, nn2, nn
3071 
3072  integer(kind=intType) :: i, j
3073 
3074  integer :: ierr
3075 
3076  ! Determine the total new and old size.
3077 
3078  newsize = newsize1 * newsize2
3079  oldsize = oldsize1 * oldsize2
3080 
3081  ! Determine for each of the 2 components the minimum of the new
3082  ! and the old size. Multiply these values to obtain the total
3083  ! amount of data that must be copied.
3084 
3085  nn1 = min(newsize1, oldsize1)
3086  nn2 = min(newsize2, oldsize2)
3087 
3088  nn = nn1 * nn2
3089 
3090  ! Set the pointer for tmp.
3091 
3092  tmp => realarray
3093 
3094  ! Allocate the memory for realArray in case newSize is larger
3095  ! than 0 or if alwaysFreeMem is .True. And copy the old data
3096  ! into it.
3097 
3098  if (newsize > 0 .or. alwaysfreemem) then
3099  allocate (realarray(newsize1, newsize2), stat=ierr)
3100  if (ierr /= 0) &
3101  call terminate("reallocateReal2", &
3102  "Memory allocation failure for realArray")
3103  do j = 1, nn2
3104  do i = 1, nn1
3105  realarray(i, j) = tmp(i, j)
3106  end do
3107  end do
3108  end if
3109 
3110  ! Release the memory of tmp in case oldSize is larger than 0
3111  ! or if alwaysFreeMem is .True..
3112 
3113  if (oldsize > 0 .or. alwaysfreemem) then
3114  deallocate (tmp, stat=ierr)
3115  if (ierr /= 0) &
3116  call terminate("reallocateReal2", &
3117  "Deallocation error for tmp")
3118  end if
3119 
3120  end subroutine reallocatereal2
3121 
3122  subroutine setbuffersizes(level, sps, determine1to1Buf, determineOversetBuf)
3123  !
3124  ! setBufferSizes determines the size of the send and receive
3125  ! buffers for this grid level. After that the maximum value of
3126  ! these sizes and the currently stored value is taken, such that
3127  ! for all mg levels the same buffer can be used. Normally the
3128  ! size on the finest grid should be enough, but it is just as
3129  ! safe to check on all mg levels.
3130  !
3131  use constants
3136  use flowvarrefstate, only: nw, eddymodel, viscous
3137  use inputphysics, only: cpmodel
3138  implicit none
3139  !
3140  ! Subroutine arguments.
3141  !
3142  integer(kind=intType), intent(in) :: level, sps
3143  logical, intent(in) :: determine1to1Buf
3144  logical, intent(in) :: determineOversetBuf
3145  !
3146  ! Local variables.
3147  !
3148  integer(kind=intType) :: i
3149  integer(kind=intType) :: sendSize, recvSize, nVarComm
3150 
3151  ! Determine the maximum number of variables to be communicated.
3152 
3153  nvarcomm = nw + 1
3154  if (cpmodel == cptempcurvefits) nvarcomm = nvarcomm + 1
3155  if (viscous) nvarcomm = nvarcomm + 1
3156  if (eddymodel) nvarcomm = nvarcomm + 1
3157 
3158  ! Check if the 1 to 1 communication must be considered.
3159 
3160  if (determine1to1buf) then
3161 
3162  ! Store the send and receive buffer sizes needed for the nodal
3163  ! exchange. Determine the maximum for the number of send and
3164  ! receive processors.
3165 
3166  i = commpatternnode_1st(level)%nProcSend
3167  sendsize = commpatternnode_1st(level)%nsendCum(i)
3168 
3169  i = commpatternnode_1st(level)%nProcRecv
3170  recvsize = commpatternnode_1st(level)%nrecvCum(i)
3171 
3172  ! Determine the buffer sizes for the 2nd level cell exchange and
3173  ! set the size for this processor to the maximum needed. Note
3174  ! that it is not needed to test the 1st level cell halo, because
3175  ! it is entirely incorporated in the 2nd level.
3176  ! Determine the maximum for the number of send and receive
3177  ! processors as well.
3178 
3179  i = commpatterncell_2nd(level)%nProcSend
3180  sendsize = max(sendsize, &
3181  commpatterncell_2nd(level)%nsendCum(i))
3182 
3183  i = commpatterncell_2nd(level)%nProcRecv
3184  recvsize = max(recvsize, &
3185  commpatterncell_2nd(level)%nrecvCum(i))
3186 
3187  ! Multiply sendSize and recvSize with the number of variables to
3188  ! be communicated.
3189 
3190  sendsize = sendsize * nvarcomm
3191  recvsize = recvsize * nvarcomm
3192 
3193  ! Store the maximum of the current values and the old values
3194  ! in sendBufferSize1to1 and recvBufferSize1to1.
3195 
3196  sendbuffersize_1to1 = max(sendbuffersize_1to1, sendsize)
3197  recvbuffersize_1to1 = max(recvbuffersize_1to1, recvsize)
3198 
3199  end if
3200 
3201  ! Check if the overset communication must be considered.
3202 
3203  if (determineoversetbuf) then
3204 
3205  ! Same deal for the overset communication.
3206 
3207  i = commpatternoverset(level, sps)%nProcSend
3208  sendsize = commpatternoverset(level, sps)%nsendCum(i)
3209 
3210  i = commpatternoverset(level, sps)%nProcRecv
3211  recvsize = commpatternoverset(level, sps)%nrecvCum(i)
3212 
3213  ! Multiply sendSize and recvSize with the number of variables to
3214  ! be communicated.
3215 
3216  sendsize = sendsize * nvarcomm
3217  recvsize = recvsize * nvarcomm
3218 
3219  ! Store the maximum of the current values and the old values.
3220 
3221  sendbuffersizeover = max(sendbuffersizeover, sendsize)
3222  recvbuffersizeover = max(recvbuffersizeover, recvsize)
3223 
3224  end if
3225 
3226  ! Take the maximum for of all the buffers to
3227  ! obtain the actual size to be allocated.
3228 
3233 
3234  end subroutine setbuffersizes
3235 
3236  subroutine setpointers(nn, mm, ll)
3237  !
3238  ! setPointers makes the variables in blockPointers point to
3239  ! block nn for grid level mm and spectral solution ll.
3240  !
3241  ! Make an exception to use..only. We literally need everything
3242  ! from blockPointers so use a bare use.
3243  use constants
3244  use blockpointers
3245  implicit none
3246  !
3247  ! Subroutine arguments
3248  !
3249  integer(kind=intType), intent(in) :: nn, mm, ll
3250 
3251  ! Store the info of the current block, such that inside the
3252  ! module blockPointers it is known to which block the data
3253  ! belongs.
3254 
3255  sectionid = 1 ! We currently are only ever allowed 1 section
3256  nbklocal = nn
3257  nbkglobal = flowdoms(nn, mm, ll)%cgnsBlockID
3258  mglevel = mm
3259  spectralsol = ll
3260 
3261  ! Block dimensions.
3262 
3263  nx = flowdoms(nn, mm, ll)%nx
3264  ny = flowdoms(nn, mm, ll)%ny
3265  nz = flowdoms(nn, mm, ll)%nz
3266 
3267  il = flowdoms(nn, mm, ll)%il
3268  jl = flowdoms(nn, mm, ll)%jl
3269  kl = flowdoms(nn, mm, ll)%kl
3270 
3271  ie = flowdoms(nn, mm, ll)%ie
3272  je = flowdoms(nn, mm, ll)%je
3273  ke = flowdoms(nn, mm, ll)%ke
3274 
3275  ib = flowdoms(nn, mm, ll)%ib
3276  jb = flowdoms(nn, mm, ll)%jb
3277  kb = flowdoms(nn, mm, ll)%kb
3278 
3279  imaxdim = max(ie, je)
3280  jmaxdim = max(je, ke)
3281 
3282  righthanded = flowdoms(nn, mm, ll)%righthanded
3283 
3284  ! Point range in the corresponding cgns block
3285 
3286  ibegor = flowdoms(nn, mm, ll)%iBegor
3287  iendor = flowdoms(nn, mm, ll)%iEndor
3288  jbegor = flowdoms(nn, mm, ll)%jBegor
3289  jendor = flowdoms(nn, mm, ll)%jEndor
3290  kbegor = flowdoms(nn, mm, ll)%kBegor
3291  kendor = flowdoms(nn, mm, ll)%kEndor
3292 
3293  ! Subface info. Note that the pointers point to the 1st spectral
3294  ! mode, because this is the only one allocated. The info is the
3295  ! same for all modes.
3296 
3297  nsubface = flowdoms(nn, mm, ll)%nSubface
3298  n1to1 = flowdoms(nn, mm, ll)%n1to1
3299  nbocos = flowdoms(nn, mm, ll)%nBocos
3300  nviscbocos = flowdoms(nn, mm, ll)%nViscBocos
3301 
3302  bctype => flowdoms(nn, mm, 1)%BCType
3303  bcfaceid => flowdoms(nn, mm, 1)%BCFaceID
3304  cgnssubface => flowdoms(nn, mm, 1)%cgnsSubface
3305 
3306  inbeg => flowdoms(nn, mm, 1)%inBeg
3307  jnbeg => flowdoms(nn, mm, 1)%jnBeg
3308  knbeg => flowdoms(nn, mm, 1)%knBeg
3309  inend => flowdoms(nn, mm, 1)%inEnd
3310  jnend => flowdoms(nn, mm, 1)%jnEnd
3311  knend => flowdoms(nn, mm, 1)%knEnd
3312 
3313  dinbeg => flowdoms(nn, mm, 1)%dinBeg
3314  djnbeg => flowdoms(nn, mm, 1)%djnBeg
3315  dknbeg => flowdoms(nn, mm, 1)%dknBeg
3316  dinend => flowdoms(nn, mm, 1)%dinEnd
3317  djnend => flowdoms(nn, mm, 1)%djnEnd
3318  dknend => flowdoms(nn, mm, 1)%dknEnd
3319 
3320  icbeg => flowdoms(nn, mm, 1)%icBeg
3321  jcbeg => flowdoms(nn, mm, 1)%jcBeg
3322  kcbeg => flowdoms(nn, mm, 1)%kcBeg
3323  icend => flowdoms(nn, mm, 1)%icEnd
3324  jcend => flowdoms(nn, mm, 1)%jcEnd
3325  kcend => flowdoms(nn, mm, 1)%kcEnd
3326 
3327  neighblock => flowdoms(nn, mm, 1)%neighBlock
3328  neighproc => flowdoms(nn, mm, 1)%neighProc
3329  l1 => flowdoms(nn, mm, 1)%l1
3330  l2 => flowdoms(nn, mm, 1)%l2
3331  l3 => flowdoms(nn, mm, 1)%l3
3332  groupnum => flowdoms(nn, mm, 1)%groupNum
3333 
3334  ! Overset boundary and hole info.
3335  iblank => flowdoms(nn, mm, ll)%iblank
3336  status => flowdoms(nn, mm, ll)%status
3337  forcedrecv => flowdoms(nn, mm, ll)%forcedRecv
3338 
3339  fringes => flowdoms(nn, mm, ll)%fringes
3340  fringeptr => flowdoms(nn, mm, ll)%fringePtr
3341  gind => flowdoms(nn, mm, ll)%gInd
3342  ndonors => flowdoms(nn, mm, ll)%nDonors
3343 
3344  orphans => flowdoms(nn, mm, ll)%orphans
3345  norphans = flowdoms(nn, mm, ll)%nOrphans
3346 
3347  ! The data for boundary subfaces.
3348 
3349  bcdata => flowdoms(nn, mm, ll)%BCData
3350 
3351  ! The stress tensor and heat flux vector at viscous wall faces
3352  ! as well as the face pointers to these viscous wall faces.
3353  ! The latter point to the 1st spectral mode, because they are
3354  ! the only ones allocated. The info is the same for all modes.
3355 
3356  viscsubface => flowdoms(nn, mm, ll)%viscSubface
3357 
3358  visciminpointer => flowdoms(nn, mm, 1)%viscIminPointer
3359  viscimaxpointer => flowdoms(nn, mm, 1)%viscImaxPointer
3360  viscjminpointer => flowdoms(nn, mm, 1)%viscJminPointer
3361  viscjmaxpointer => flowdoms(nn, mm, 1)%viscJmaxPointer
3362  visckminpointer => flowdoms(nn, mm, 1)%viscKminPointer
3363  visckmaxpointer => flowdoms(nn, mm, 1)%viscKmaxPointer
3364 
3365  ! Mesh related variables. The porosities point to the 1st
3366  ! spectral mode, because they are the only ones allocated.
3367  ! The info is the same for all modes.
3368  ! Note that xOld and volOld always point to the finest
3369  ! grid level.
3370 
3371  x => flowdoms(nn, mm, ll)%x
3372  xold => flowdoms(nn, 1, ll)%xOld
3373 
3374  si => flowdoms(nn, mm, ll)%si
3375  sj => flowdoms(nn, mm, ll)%sj
3376  sk => flowdoms(nn, mm, ll)%sk
3377 
3378  vol => flowdoms(nn, mm, ll)%vol
3379  volref => flowdoms(nn, mm, ll)%volRef
3380  volold => flowdoms(nn, 1, ll)%volOld
3381 
3382  skew => flowdoms(nn, mm, ll)%skew
3383 
3384  pori => flowdoms(nn, mm, 1)%porI
3385  porj => flowdoms(nn, mm, 1)%porJ
3386  pork => flowdoms(nn, mm, 1)%porK
3387 
3388  indfamilyi => flowdoms(nn, mm, 1)%indFamilyI
3389  indfamilyj => flowdoms(nn, mm, 1)%indFamilyJ
3390  indfamilyk => flowdoms(nn, mm, 1)%indFamilyK
3391 
3392  factfamilyi => flowdoms(nn, mm, 1)%factFamilyI
3393  factfamilyj => flowdoms(nn, mm, 1)%factFamilyJ
3394  factfamilyk => flowdoms(nn, mm, 1)%factFamilyK
3395 
3396  rotmatrixi => flowdoms(nn, mm, ll)%rotMatrixI
3397  rotmatrixj => flowdoms(nn, mm, ll)%rotMatrixJ
3398  rotmatrixk => flowdoms(nn, mm, ll)%rotMatrixK
3399 
3400  blockismoving = flowdoms(nn, mm, ll)%blockIsMoving
3401  addgridvelocities = flowdoms(nn, mm, ll)%addGridVelocities
3402 
3403  sfacei => flowdoms(nn, mm, ll)%sFaceI
3404  sfacej => flowdoms(nn, mm, ll)%sFaceJ
3405  sfacek => flowdoms(nn, mm, ll)%sFaceK
3406 
3407  ! Flow variables. Note that wOld, gamma and the laminar viscosity
3408  ! point to the entries on the finest mesh. The reason is that
3409  ! they are computed from the other variables. For the eddy
3410  ! viscosity this is not the case because in a decoupled solver
3411  ! its values are obtained from the fine grid level.
3412 
3413  w => flowdoms(nn, mm, ll)%w
3414  wold => flowdoms(nn, 1, ll)%wOld
3415  p => flowdoms(nn, mm, ll)%p
3416  aa => flowdoms(nn, mm, ll)%aa
3417  shocksensor => flowdoms(nn, mm, ll)%shockSensor
3418 
3419  gamma => flowdoms(nn, 1, ll)%gamma
3420  rlv => flowdoms(nn, 1, ll)%rlv
3421  rev => flowdoms(nn, mm, ll)%rev
3422  s => flowdoms(nn, mm, ll)%s
3423 
3424  ux => flowdoms(nn, mm, ll)%ux
3425  uy => flowdoms(nn, mm, ll)%uy
3426  uz => flowdoms(nn, mm, ll)%uz
3427 
3428  vx => flowdoms(nn, mm, ll)%vx
3429  vy => flowdoms(nn, mm, ll)%vy
3430  vz => flowdoms(nn, mm, ll)%vz
3431 
3432  wx => flowdoms(nn, mm, ll)%wx
3433  wy => flowdoms(nn, mm, ll)%wy
3434  wz => flowdoms(nn, mm, ll)%wz
3435 
3436  qx => flowdoms(nn, mm, ll)%qx
3437  qy => flowdoms(nn, mm, ll)%qy
3438  qz => flowdoms(nn, mm, ll)%qz
3439 
3440  ! Residual and multigrid variables. The residual point to the
3441  ! finest grid entry, the multigrid variables to their own level.
3442 
3443  dw => flowdoms(nn, 1, ll)%dw
3444  fw => flowdoms(nn, 1, ll)%fw
3445  dwoldrk => flowdoms(nn, 1, ll)%dwOldRK
3446  scratch => flowdoms(nn, 1, ll)%scratch
3447 
3448  p1 => flowdoms(nn, mm, ll)%p1
3449  w1 => flowdoms(nn, mm, ll)%w1
3450  wr => flowdoms(nn, mm, ll)%wr
3451 
3452  ! Variables, which allow a more flexible multigrid treatment.
3453  ! They are the same for all spectral modes and therefore they
3454  ! point to the 1st mode.
3455 
3456  mgifine => flowdoms(nn, mm, 1)%mgIFine
3457  mgjfine => flowdoms(nn, mm, 1)%mgJFine
3458  mgkfine => flowdoms(nn, mm, 1)%mgKFine
3459 
3460  mgiweight => flowdoms(nn, mm, 1)%mgIWeight
3461  mgjweight => flowdoms(nn, mm, 1)%mgJWeight
3462  mgkweight => flowdoms(nn, mm, 1)%mgKWeight
3463 
3464  mgicoarse => flowdoms(nn, mm, 1)%mgICoarse
3465  mgjcoarse => flowdoms(nn, mm, 1)%mgJCoarse
3466  mgkcoarse => flowdoms(nn, mm, 1)%mgKCoarse
3467 
3468  ! Time-stepping variables and spectral radIi.
3469  ! They all point to the fine mesh entry.
3470 
3471  wn => flowdoms(nn, 1, ll)%wn
3472  pn => flowdoms(nn, 1, ll)%pn
3473  dtl => flowdoms(nn, 1, ll)%dtl
3474 
3475  radi => flowdoms(nn, 1, ll)%radI
3476  radj => flowdoms(nn, 1, ll)%radJ
3477  radk => flowdoms(nn, 1, ll)%radK
3478 
3479  ! Wall distance for the turbulence models.
3480 
3481  d2wall => flowdoms(nn, mm, ll)%d2Wall
3482  filterdes => flowdoms(nn, mm, ll)%filterDES ! eran-des
3483 
3484  ! Arrays used for the implicit treatment of the turbulent wall
3485  ! boundary conditions. As these variables are only allocated for
3486  ! the 1st spectral solution of the fine mesh, the pointers point
3487  ! to those arrays.
3488 
3489  bmti1 => flowdoms(nn, 1, 1)%bmti1
3490  bmti2 => flowdoms(nn, 1, 1)%bmti2
3491  bmtj1 => flowdoms(nn, 1, 1)%bmtj1
3492  bmtj2 => flowdoms(nn, 1, 1)%bmtj2
3493  bmtk1 => flowdoms(nn, 1, 1)%bmtk1
3494  bmtk2 => flowdoms(nn, 1, 1)%bmtk2
3495 
3496  bvti1 => flowdoms(nn, 1, 1)%bvti1
3497  bvti2 => flowdoms(nn, 1, 1)%bvti2
3498  bvtj1 => flowdoms(nn, 1, 1)%bvtj1
3499  bvtj2 => flowdoms(nn, 1, 1)%bvtj2
3500  bvtk1 => flowdoms(nn, 1, 1)%bvtk1
3501  bvtk2 => flowdoms(nn, 1, 1)%bvtk2
3502 
3503  ! Pointers for globalCell/Node
3504  globalcell => flowdoms(nn, mm, ll)%globalCell
3505  globalnode => flowdoms(nn, mm, ll)%globalNode
3506 
3507  xseed => flowdoms(nn, mm, ll)%xSeed
3508  wallind => flowdoms(nn, mm, ll)%wallInd
3509 
3510  ! Added by HDN
3511  ! Kept the same dim as their counterparts
3512  xale => flowdoms(nn, mm, ll)%xALE
3513  sveloiale => flowdoms(nn, mm, ll)%sVeloIALE
3514  svelojale => flowdoms(nn, mm, ll)%sVeloJALE
3515  svelokale => flowdoms(nn, mm, ll)%sVeloKALE
3516  siale => flowdoms(nn, mm, ll)%sIALE
3517  sjale => flowdoms(nn, mm, ll)%sJALE
3518  skale => flowdoms(nn, mm, ll)%sKALE
3519  sfaceiale => flowdoms(nn, mm, ll)%sFaceIALE
3520  sfacejale => flowdoms(nn, mm, ll)%sFaceJALE
3521  sfacekale => flowdoms(nn, mm, ll)%sFaceKALE
3522  dwale => flowdoms(nn, 1, ll)%dwALE
3523  fwale => flowdoms(nn, 1, ll)%fwALE
3524 
3525  ! Pointers for PC
3526  pcmat => flowdoms(nn, mm, ll)%pcMat
3527 
3528  i_d_fact => flowdoms(nn, mm, ll)%i_D_fact
3529  i_l_fact => flowdoms(nn, mm, ll)%i_L_fact
3530  i_u_fact => flowdoms(nn, mm, ll)%i_U_fact
3531  i_u2_fact => flowdoms(nn, mm, ll)%i_U2_fact
3532 
3533  j_d_fact => flowdoms(nn, mm, ll)%j_D_fact
3534  j_l_fact => flowdoms(nn, mm, ll)%j_L_fact
3535  j_u_fact => flowdoms(nn, mm, ll)%j_U_fact
3536  j_u2_fact => flowdoms(nn, mm, ll)%j_U2_fact
3537 
3538  k_d_fact => flowdoms(nn, mm, ll)%k_D_fact
3539  k_l_fact => flowdoms(nn, mm, ll)%k_L_fact
3540  k_u_fact => flowdoms(nn, mm, ll)%k_U_fact
3541  k_u2_fact => flowdoms(nn, mm, ll)%k_U2_fact
3542 
3543  pcvec1 => flowdoms(nn, mm, ll)%PCVec1
3544  pcvec2 => flowdoms(nn, mm, ll)%PCVec2
3545 
3546  i_ipiv => flowdoms(nn, mm, ll)%i_ipiv
3547  j_ipiv => flowdoms(nn, mm, ll)%j_ipiv
3548  k_ipiv => flowdoms(nn, mm, ll)%k_ipiv
3549 
3550  end subroutine setpointers
3551 
3552  subroutine setpointers_b(nn, level, sps)
3553  use constants
3554  implicit none
3555  integer(kind=intType), intent(in) :: nn, level, sps
3556 
3557  ! Alias for setPonters_d
3558  call setpointers_d(nn, level, sps)
3559 
3560  end subroutine setpointers_b
3561 
3562  ! Set the pointers for the derivative values AND the normal pointers
3563  subroutine setpointers_d(nn, level, sps)
3564 
3565  use block, only: flowdomsd
3566  use blockpointers
3567  implicit none
3568  !
3569  ! Subroutine arguments
3570  !
3571  integer(kind=intType), intent(in) :: nn, level, sps
3572 
3573  ! Set normal pointers
3574  call setpointers(nn, level, sps)
3575 
3576  viscsubfaced => flowdomsd(nn, 1, sps)%viscSubface
3577 
3578  xd => flowdomsd(nn, 1, sps)%x
3579 
3580  sid => flowdomsd(nn, 1, sps)%si
3581  sjd => flowdomsd(nn, 1, sps)%sj
3582  skd => flowdomsd(nn, 1, sps)%sk
3583 
3584  vold => flowdomsd(nn, 1, sps)%vol
3585 
3586  rotmatrixid => flowdomsd(nn, 1, sps)%rotMatrixI
3587  rotmatrixjd => flowdomsd(nn, 1, sps)%rotMatrixJ
3588  rotmatrixkd => flowdomsd(nn, 1, sps)%rotMatrixK
3589 
3590  sfaceid => flowdomsd(nn, 1, sps)%sFaceI
3591  sfacejd => flowdomsd(nn, 1, sps)%sFaceJ
3592  sfacekd => flowdomsd(nn, 1, sps)%sFaceK
3593 
3594  ! Flow variables. Note that wOld, gamma and the laminar viscosity
3595  ! point to the entries on the finest mesh. The reason is that
3596  ! they are computed from the other variables. For the eddy
3597  ! viscosity this is not the case because in a decoupled solver
3598  ! its values are obtained from the fine grid level.
3599 
3600  wd => flowdomsd(nn, 1, sps)%w
3601  pd => flowdomsd(nn, 1, sps)%p
3602 
3603  gammad => flowdomsd(nn, 1, sps)%gamma
3604  aad => flowdomsd(nn, 1, sps)%aa
3605  rlvd => flowdomsd(nn, 1, sps)%rlv
3606  revd => flowdomsd(nn, 1, sps)%rev
3607  sd => flowdomsd(nn, 1, sps)%s
3608 
3609  uxd => flowdomsd(nn, 1, sps)%ux
3610  uyd => flowdomsd(nn, 1, sps)%uy
3611  uzd => flowdomsd(nn, 1, sps)%uz
3612 
3613  vxd => flowdomsd(nn, 1, sps)%vx
3614  vyd => flowdomsd(nn, 1, sps)%vy
3615  vzd => flowdomsd(nn, 1, sps)%vz
3616 
3617  wxd => flowdomsd(nn, 1, sps)%wx
3618  wyd => flowdomsd(nn, 1, sps)%wy
3619  wzd => flowdomsd(nn, 1, sps)%wz
3620 
3621  qxd => flowdomsd(nn, 1, sps)%qx
3622  qyd => flowdomsd(nn, 1, sps)%qy
3623  qzd => flowdomsd(nn, 1, sps)%qz
3624 
3625  ! Residual and multigrid variables. The residual point to the
3626  ! finest grid entry, the multigrid variables to their own level.
3627 
3628  dwd => flowdomsd(nn, 1, sps)%dw
3629  fwd => flowdomsd(nn, 1, sps)%fw
3630  scratchd => flowdomsd(nn, 1, sps)%scratch
3631 
3632  dtld => flowdomsd(nn, 1, sps)%dtl
3633 
3634  ! Time-stepping variables and spectral radIi.
3635  ! They asps point to the fine mesh entry.
3636 
3637  radid => flowdomsd(nn, 1, sps)%radI
3638  radjd => flowdomsd(nn, 1, sps)%radJ
3639  radkd => flowdomsd(nn, 1, sps)%radK
3640 
3641  d2walld => flowdomsd(nn, 1, sps)%d2Wall
3642 
3643  ! Arrays used for the implicit treatment of the turbulent wasps
3644  ! boundary conditions. As these variables are only aspocated for
3645  ! the 1st spectral solution of the fine mesh, the pointers point
3646  ! to those arrays.
3647 
3648  bmti1d => flowdomsd(nn, 1, 1)%bmti1
3649  bmti2d => flowdomsd(nn, 1, 1)%bmti2
3650  bmtj1d => flowdomsd(nn, 1, 1)%bmtj1
3651  bmtj2d => flowdomsd(nn, 1, 1)%bmtj2
3652  bmtk1d => flowdomsd(nn, 1, 1)%bmtk1
3653  bmtk2d => flowdomsd(nn, 1, 1)%bmtk2
3654 
3655  bvti1d => flowdomsd(nn, 1, 1)%bvti1
3656  bvti2d => flowdomsd(nn, 1, 1)%bvti2
3657  bvtj1d => flowdomsd(nn, 1, 1)%bvtj1
3658  bvtj2d => flowdomsd(nn, 1, 1)%bvtj2
3659  bvtk1d => flowdomsd(nn, 1, 1)%bvtk1
3660  bvtk2d => flowdomsd(nn, 1, 1)%bvtk2
3661 
3662  !BCData Array
3663  bcdatad => flowdomsd(nn, 1, sps)%BCdata
3664 
3665  end subroutine setpointers_d
3666 
3667  subroutine spectralinterpolcoef(nsps, t, alpScal, alpMat)
3668  !
3669  ! spectralInterpolCoef determines the scalar and matrix
3670  ! spectral interpolation coefficients for the given number of
3671  ! spectral solutions for the given t, where t is the ratio of
3672  ! the time and the periodic interval time. Note that the index
3673  ! of the spectral solutions of both alpScal and alpMat start
3674  ! at 0. In this way these coefficients are easier to determine.
3675  !
3676  use constants
3678  use section, only: nsections, sections
3679  implicit none
3680  !
3681  ! Subroutine arguments.
3682  !
3683  integer(kind=intType), intent(in) :: nsps
3684  real(kind=realtype), intent(in) :: t
3685 
3686  real(kind=realtype), dimension(0:nsps - 1), intent(out) :: alpscal
3687  real(kind=realtype), dimension(nSections, 0:nsps - 1, 3, 3), &
3688  intent(out) :: alpmat
3689  !
3690  ! Local variables.
3691  !
3692  integer(kind=intType) :: jj, nn, j, p, r, nhalfM1, m, mhalfM1
3693 
3694  real(kind=realtype) :: nspsinv, minv, tm, alp
3695 
3696  real(kind=realtype), dimension(3, 3) :: rp, tmp
3697 
3698  ! Scalar coefficients.
3699  !
3700  ! Loop over the number of spectral solutions to compute the
3701  ! coefficients. Note that the loop starts at 0.
3702 
3703  if (mod(nsps, 2) .eq. 0) then
3704  nhalfm1 = nsps / 2 - 1
3705  else
3706  nhalfm1 = (nsps - 1) / 2
3707  end if
3708 
3709  nspsinv = one / real(nsps, realtype)
3710 
3711  do j = 0, (nsps - 1)
3712  if (mod(nsps, 2) .eq. 0) then
3713  alpscal(j) = one + cos(j * pi) * cos(nsps * pi * t)
3714  else
3715  alpscal(j) = one + cos(j * pi * (nsps + 1) / nsps) * cos((nsps + 1) * pi * t)
3716  end if
3717 
3718  do r = 1, nhalfm1
3719  alpscal(j) = alpscal(j) &
3720  + two * cos(r * j * two * pi * nspsinv) * cos(r * two * pi * t) &
3721  + two * sin(r * j * two * pi * nspsinv) * sin(r * two * pi * t)
3722  end do
3723 
3724  alpscal(j) = alpscal(j) * nspsinv
3725 
3726  end do
3727  !
3728  ! Matrix coefficients. These are (can be) different for every
3729  ! section and they must therefore be determined for every
3730  ! section.
3731  !
3732  ! Loop over the number of sections in the grid.
3733 
3734  sectionloop: do nn = 1, nsections
3735 
3736  ! Compute the numbers for the entire wheel for this section.
3737  ! Note that also t must be adapted, because t is a ratio between
3738  ! the actual time and the periodic time.
3739 
3740  m = nsps * sections(nn)%nSlices
3741  if (mod(m, 2) .eq. 0) then
3742  mhalfm1 = m / 2 - 1
3743  else
3744  mhalfm1 = (m - 1) / 2
3745  end if
3746  minv = one / real(m, realtype)
3747  tm = t / real(sections(nn)%nSlices, realtype)
3748 
3749  ! Loop over the number of spectral solutions.
3750 
3751  spectralloop: do jj = 0, (nsps - 1)
3752 
3753  ! Initialize the matrix coefficients to zero and the matrix
3754  ! rp to the identity matrix. Rp is the rotation matrix of this
3755  ! section to the power p, which starts at 0, i.e. rp = i.
3756 
3757  alpmat(nn, jj, 1, 1) = zero
3758  alpmat(nn, jj, 1, 2) = zero
3759  alpmat(nn, jj, 1, 3) = zero
3760 
3761  alpmat(nn, jj, 2, 1) = zero
3762  alpmat(nn, jj, 2, 2) = zero
3763  alpmat(nn, jj, 2, 3) = zero
3764 
3765  alpmat(nn, jj, 3, 1) = zero
3766  alpmat(nn, jj, 3, 2) = zero
3767  alpmat(nn, jj, 3, 3) = zero
3768 
3769  rp(1, 1) = one
3770  rp(1, 2) = zero
3771  rp(1, 3) = zero
3772 
3773  rp(2, 1) = zero
3774  rp(2, 2) = one
3775  rp(2, 3) = zero
3776 
3777  rp(3, 1) = zero
3778  rp(3, 2) = zero
3779  rp(3, 3) = one
3780 
3781  ! Loop over the number of slices of this section. Note that
3782  ! this loop starts at zero, which simplifies the formulas.
3783 
3784  slicesloop: do p = 0, (sections(nn)%nSlices - 1)
3785 
3786  ! Determine the index j, the index of alp in the entire
3787  ! wheel.
3788 
3789  j = jj + p * nsps
3790 
3791  ! Compute the scalar coefficient alp of the index j in
3792  ! the entire wheel.
3793 
3794  if (mod(m, 2) .eq. 0) then
3795  alp = one + cos(j * pi) * cos(m * pi * tm)
3796  else
3797  alp = one + cos(j * pi * (m + 1) / m) * cos((m + 1) * pi * tm)
3798  end if
3799  do r = 1, mhalfm1
3800  alp = alp + two * cos(r * j * two * pi * minv) * cos(r * two * pi * tm) &
3801  + two * sin(r * j * two * pi * minv) * sin(r * two * pi * tm)
3802  end do
3803 
3804  alp = alp * minv
3805 
3806  ! Update the matrix coefficient.
3807 
3808  do r = 1, 3
3809  do j = 1, 3
3810  alpmat(nn, jj, r, j) = alpmat(nn, jj, r, j) + alp * rp(r, j)
3811  end do
3812  end do
3813 
3814  ! Multiply rp by the rotation matrix to obtain the correct
3815  ! matrix for the next slice. Use tmp as temporary storage.
3816 
3817  do r = 1, 3
3818  do j = 1, 3
3819  tmp(r, j) = rp(r, 1) * rotmatrixspectral(nn, 1, j) &
3820  + rp(r, 2) * rotmatrixspectral(nn, 2, j) &
3821  + rp(r, 3) * rotmatrixspectral(nn, 3, j)
3822  end do
3823  end do
3824 
3825  rp = tmp
3826 
3827  end do slicesloop
3828  end do spectralloop
3829  end do sectionloop
3830 
3831  end subroutine spectralinterpolcoef
3832 
3833  subroutine deallocatetempmemory(resNeeded)
3834  !
3835  ! deallocateTempMemory deallocates memory used in the solver,
3836  ! but which is not needed to store the actual solution. In this
3837  ! way the memory can be used differently, e.g. when writing the
3838  ! solution or computing the wall distances.
3839  !
3840  use constants
3841  use block, only: flowdoms, ndom
3842  use communication, only: sendbuffer, recvbuffer
3843  use inputiteration, only: smoother
3845  implicit none
3846  !
3847  ! Subroutine arguments.
3848  !
3849  logical, intent(in) :: resNeeded
3850  !
3851  ! Local variables.
3852  !
3853  integer :: ierr
3854 
3855  integer(kind=intType) :: nn, mm
3856 
3857  ! Deallocate the communication buffers
3858 
3859  deallocate (sendbuffer, recvbuffer, stat=ierr)
3860  if (ierr /= 0) &
3861  call terminate("deallocateTempMemory", &
3862  "Deallocation error for communication buffers")
3863 
3864  ! Loop over the spectral modes and domains. Note that only memory
3865  ! on the finest grid is released, because a) most of these
3866  ! variables are only allocated on the fine grid and b) the coarser
3867  ! grids do not contribute that much in the memory usage anyway.
3868 
3869  spectralmodes: do mm = 1, ntimeintervalsspectral
3870  domains: do nn = 1, ndom
3871 
3872  ! Check if the residual, time step, etc. Is needed.
3873 
3874  if (.not. resneeded) then
3875 
3876  ! Residual, etc. Not needed.
3877  ! Deallocate residual, the time step and the spectral radii
3878  ! of the fine level.
3879 
3880  deallocate (flowdoms(nn, 1, mm)%dw, flowdoms(nn, 1, mm)%fw, &
3881  flowdoms(nn, 1, mm)%dtl, flowdoms(nn, 1, mm)%radI, &
3882  flowdoms(nn, 1, mm)%radJ, flowdoms(nn, 1, mm)%radK, &
3883  stat=ierr)
3884  if (ierr /= 0) &
3885  call terminate("deallocateTempMemory", &
3886  "Deallocation error for dw, fw, dtl and &
3887  &spectral radii.")
3888  end if
3889 
3890  ! The memory for the zeroth Runge Kutta stage
3891  ! if a Runge Kutta scheme is used.
3892 
3893  if (smoother == rungekutta) then
3894 
3895  deallocate (flowdoms(nn, 1, mm)%wn, flowdoms(nn, 1, mm)%pn, &
3896  stat=ierr)
3897  if (ierr /= 0) &
3898  call terminate("deallocateTempMemory", &
3899  "Deallocation error for wn and pn")
3900  end if
3901 
3902  end do domains
3903  end do spectralmodes
3904 
3905  end subroutine deallocatetempmemory
3906 
3907  subroutine allocatetempmemory(resNeeded)
3908  !
3909  ! AllocateTempMemory allocates the memory again that was
3910  ! temporarily deallocted by deallocateTempMemory.
3911  !
3912  use constants
3913  use block, only: flowdoms, ndom
3915  use inputiteration, only: smoother
3917  use flowvarrefstate, only: nw, nwf
3918 
3919  implicit none
3920  !
3921  ! Subroutine arguments.
3922  !
3923  logical, intent(in) :: resNeeded
3924  !
3925  ! Local variables.
3926  !
3927  integer :: ierr
3928 
3929  integer(kind=intType) :: nn, mm
3930  integer(kind=intType) :: il, jl, kl, ie, je, ke, ib, jb, kb
3931 
3932  ! The memory for the receive buffers.
3933 
3934  allocate (sendbuffer(sendbuffersize), &
3935  recvbuffer(recvbuffersize), stat=ierr)
3936  if (ierr /= 0) &
3937  call terminate("allocateTempMemory", &
3938  "Memory allocation failure for comm buffers")
3939 
3940  ! Loop over the spectral modes and domains. Note that only memory
3941  ! on the finest mesh level needs to be reallocated, because the
3942  ! memory on the coarser levels has not been released or is not
3943  ! needed .
3944 
3945  spectralmodes: do mm = 1, ntimeintervalsspectral
3946  domains: do nn = 1, ndom
3947 
3948  ! Store some dimensions a bit easier.
3949 
3950  il = flowdoms(nn, 1, mm)%il
3951  jl = flowdoms(nn, 1, mm)%jl
3952  kl = flowdoms(nn, 1, mm)%kl
3953 
3954  ie = flowdoms(nn, 1, mm)%ie
3955  je = flowdoms(nn, 1, mm)%je
3956  ke = flowdoms(nn, 1, mm)%ke
3957 
3958  ib = flowdoms(nn, 1, mm)%ib
3959  jb = flowdoms(nn, 1, mm)%jb
3960  kb = flowdoms(nn, 1, mm)%kb
3961 
3962  ! Check if the residual, time step, etc. was deallocated.
3963 
3964  if (.not. resneeded) then
3965 
3966  ! Allocate the residual, the time step and
3967  ! the spectral radii.
3968 
3969  allocate (flowdoms(nn, 1, mm)%dw(0:ib, 0:jb, 0:kb, 1:nw), &
3970  flowdoms(nn, 1, mm)%fw(0:ib, 0:jb, 0:kb, 1:nwf), &
3971  flowdoms(nn, 1, mm)%dtl(1:ie, 1:je, 1:ke), &
3972  flowdoms(nn, 1, mm)%radI(1:ie, 1:je, 1:ke), &
3973  flowdoms(nn, 1, mm)%radJ(1:ie, 1:je, 1:ke), &
3974  flowdoms(nn, 1, mm)%radK(1:ie, 1:je, 1:ke), stat=ierr)
3975  if (ierr /= 0) &
3976  call terminate("allocateTempMemory", &
3977  "Memory allocation failure for dw, fw, &
3978  &dtl and the spectral radii.")
3979 
3980  ! Initialize dw and fw to zero to avoid possible overflows
3981  ! of the halo's.
3982 
3983  flowdoms(nn, 1, mm)%dw = zero
3984  flowdoms(nn, 1, mm)%fw = zero
3985 
3986  end if
3987 
3988  ! The memory for the zeroth runge kutta stage
3989  ! if a runge kutta scheme is used.
3990 
3991  if (smoother == rungekutta) then
3992 
3993  allocate (flowdoms(nn, 1, mm)%wn(2:il, 2:jl, 2:kl, 1:nwf), &
3994  flowdoms(nn, 1, mm)%pn(2:il, 2:jl, 2:kl), stat=ierr)
3995  if (ierr /= 0) &
3996  call terminate("allocateTempMemory", &
3997  "Memory allocation failure for wn and pn")
3998  end if
3999 
4000  end do domains
4001  end do spectralmodes
4002 
4003  end subroutine allocatetempmemory
4004 
4005  subroutine getliftdirfromsymmetry(liftDir)
4006 
4007  ! The purpose of this function is to determine what coordinate
4008  ! direction the mirror plane is in. It does NOT handle multiple mirror
4009  ! planes. It is used just to determine what the lift direction is.
4010 
4011  use constants
4012  use blockpointers, only: x, il, jl, kl, bctype, ndom, bcdata, bcfaceid, nbocos
4013  use communication, only: adflow_comm_world
4014  implicit none
4015 
4016  ! Output
4017  integer(kind=intType), intent(out) :: liftDir
4018  integer(kind=intType), dimension(3) :: sym_local, sym
4019 
4020  ! Working
4021  integer(kind=intType) :: nn, i_index(1), mm, ierr
4022  real(kind=realtype), dimension(:, :, :), pointer :: xx
4023  real(kind=realtype) :: cp(3), v1(3), v2(3)
4024  ! Loop over each block and each subFace
4025 
4026  sym_local = 0_inttype
4027  sym = 0_inttype
4028  liftdir = 0_inttype
4029  do nn = 1, ndom
4030  call setpointers(nn, 1, 1)
4031  do mm = 1, nbocos
4032  if (bctype(mm) == symm) then
4033 
4034  select case (bcfaceid(mm))
4035  case (imin)
4036  xx => x(1, :, :, :)
4037  case (imax)
4038  xx => x(il, :, :, :)
4039  case (jmin)
4040  xx => x(:, 1, :, :)
4041  case (jmax)
4042  xx => x(:, jl, :, :)
4043  case (kmin)
4044  xx => x(:, :, 1, :)
4045  case (kmax)
4046  xx => x(:, :, kl, :)
4047  end select
4048 
4049  ! Take the cross product
4050  v1(:) = xx(bcdata(mm)%inEnd, bcdata(mm)%jnEnd, :) - &
4051  xx(bcdata(mm)%inBeg, bcdata(mm)%jnBeg, :)
4052  v2(:) = xx(bcdata(mm)%inBeg, bcdata(mm)%jnEnd, :) - &
4053  xx(bcdata(mm)%inEnd, bcdata(mm)%jnBeg, :)
4054 
4055  ! Cross Product
4056  cp(1) = (v1(2) * v2(3) - v1(3) * v2(2))
4057  cp(2) = (v1(3) * v2(1) - v1(1) * v2(3))
4058  cp(3) = (v1(1) * v2(2) - v1(2) * v2(1))
4059 
4060  ! Only interesed in abs values
4061  cp = abs(cp)
4062 
4063  ! Location, ie coordiante direction of dominate direction
4064  i_index = maxloc(real(cp))
4065 
4066  sym_local(i_index(1)) = 1_inttype
4067  end if
4068  end do
4069  end do
4070 
4071  ! Now we have a bunch of sym_locals, mpi_allreduce them and SUM
4072 
4073  call mpi_allreduce(sym_local, sym, 3, adflow_integer, &
4074  mpi_sum, adflow_comm_world, ierr)
4075  call echk(ierr, __file__, __line__)
4076 
4077  ! Now we should make sure that only ONE of the values is
4078  ! non-zero. If more than one value is zero, it means we have
4079  ! multiple symmetry planes which we can't support.
4080  if (sym(1) == 0 .and. sym(2) == 0 .and. sym(3) == 0) then
4081  ! Pass - no sym, can't determine lift dir:
4082  else if (sym(1) .ne. 0 .and. sym(2) == 0 .and. sym(3) == 0) then
4083  ! Pass - x dir can't be symmetry
4084  else if (sym(1) == 0 .and. sym(2) .ne. 0 .and. sym(3) == 0) then
4085  liftdir = 3
4086  else if (sym(1) == 0 .and. sym(2) == 0 .and. sym(3) .ne. 0) then
4087  liftdir = 2
4088  else
4089  ! Multiple orientations...can't do anything
4090  end if
4091 
4092  end subroutine getliftdirfromsymmetry
4093 
4095  !
4096  ! writeIntroMessage writes a message to stdout with
4097  ! information how the executable was built, e.g. whether single
4098  ! or double precision is used for the integers and reals, etc.
4099  ! To avoid a messy output only processor 0 prints this info.
4100  !
4101  use constants
4102  use communication, only: myid, nproc
4103  implicit none
4104  !
4105  ! Local variables
4106  !
4107  character(len=7) :: integerString
4108 
4109  ! Return if this is not processor 0.
4110 
4111  if (myid > 0) return
4112 
4113  ! I'm processor 0. Write the info to stdout.
4114 
4115  print "(a)", "#"
4116  print "(a)", "# ADflow, multiblock structured flow solver"
4117  print "(a)", "#"
4118  print "(a)", "# This code solves the 3D RANS, laminar NS or &
4119  &Euler equations"
4120  print "(a)", "# on multiblock structured hexahedral grids."
4121 
4122  write (integerstring, "(i7)") nproc
4123  integerstring = adjustl(integerstring)
4124  print "(3a)", "# This is a parallel executable running on ", &
4125  trim(integerstring), " processors."
4126  print "(a)", "# It has been compiled with the &
4127  &following options:"
4128 
4129  if (debug) then
4130  print "(a)", "# - Debug mode."
4131  else
4132  print "(a)", "# - Optimized mode."
4133  end if
4134 
4135 #ifdef USE_LONG_INT
4136  print "(a)", "# - Size of standard integers: 8 bytes."
4137 #else
4138  print "(a)", "# - Size of standard integers: 4 bytes."
4139 #endif
4140 
4141 #ifdef USE_SINGLE_PRECISION
4142  print "(a)", "# - Size of standard floating point types: &
4143  &4 bytes."
4144 
4145 #elif USE_QUADRUPLE_PRECISION
4146  print "(a)", "# - Size of standard floating point types: &
4147  &16 bytes."
4148 #else
4149  print "(a)", "# - Size of standard floating point types: &
4150  &8 bytes."
4151 #endif
4152 
4153 #ifdef USE_NO_CGNS
4154  print "(a)", "# - Without cgns support"
4155 #else
4156  print "(a)", "# - With cgns support"
4157 #endif
4158 
4159 #ifdef USE_NO_SIGNALS
4160  print "(a)", "# - Without support for signals."
4161 #else
4162  print "(a)", "# - With support for signals."
4163 #endif
4164 
4165  print "(a)", "#"
4166 
4167  end subroutine writeintromessage
4168 
4169  subroutine pointreduce(pts, N, tol, uniquePts, link, nUnique)
4170 
4171  ! Given a list of N points (pts) in three space, with possible
4172  ! duplicates, (to within tol) return a list of the nUnique
4173  ! uniquePoints of points and a link array of length N, that points
4174  ! into the unique list
4175 
4176  use constants
4177  use kdtree2_module
4178  implicit none
4179 
4180  ! Input Parameters
4181  integer(kind=intType), intent(in) :: N
4182  real(kind=realtype), intent(in), dimension(3, N) :: pts
4183  real(kind=realtype), intent(in) :: tol
4184 
4185  ! Output Parametres
4186  real(kind=realtype), intent(out), dimension(3, N) :: uniquepts
4187  integer(kind=intType), intent(out), dimension(N) :: link
4188  integer(kind=intType), intent(out) :: nUnique
4189 
4190  ! Working paramters
4191  type(kdtree2), pointer :: mytree
4192  real(kind=realtype) :: tol2, timeb, timea
4193  integer(kind=intType) :: nFound, i, j, nAlloc
4194  type(kdtree2_result), allocatable, dimension(:) :: results
4195 
4196  if (n == 0) then
4197  nunique = 0
4198  return
4199  end if
4200 
4201  ! We will use the KD_tree to do most of the heavy lifting here:
4202 
4203  mytree => kdtree2_create(pts, sort=.true.)
4204 
4205  ! KD tree works with the square of the tolerance
4206  tol2 = tol**2
4207 
4208  ! Unlikely we'll have more than 20 points same, but there is a
4209  ! safetly check anwyay.
4210  nalloc = 20
4211  allocate (results(nalloc))
4212 
4213  link = 0
4214  nunique = 0
4215 
4216  ! Loop over all nodes
4217  do i = 1, n
4218  if (link(i) == 0) then
4219  call kdtree2_r_nearest(mytree, pts(:, i), tol2, nfound, nalloc, results)
4220 
4221  ! Expand if necesary and re-run
4222  if (nfound > nalloc) then
4223  deallocate (results)
4224  nalloc = nfound
4225  allocate (results(nalloc))
4226  call kdtree2_r_nearest(mytree, pts(:, i), tol2, nfound, nalloc, results)
4227  end if
4228 
4229  if (nfound == 1) then
4230  ! This one is easy, it is already a unique node
4231  nunique = nunique + 1
4232  link(i) = nunique
4233  uniquepts(:, nunique) = pts(:, i)
4234  else
4235  if (link(i) == 0) then
4236  ! This node hasn't been assigned yet:
4237  nunique = nunique + 1
4238  uniquepts(:, nunique) = pts(:, i)
4239 
4240  do j = 1, nfound
4241  link(results(j)%idx) = nunique
4242  end do
4243  end if
4244  end if
4245  end if
4246  end do
4247 
4248  ! Done with the tree and the result vector
4249  call kdtree2destroy(mytree)
4250  deallocate (results)
4251 
4252  end subroutine pointreduce
4254  !
4255  ! releaseMemoryPart1 releases all the memory on the coarser
4256  ! grids of flowDoms and the fine grid memory which is not needed
4257  ! for the possible interpolation of the spectral solution.
4258  !
4259 
4260  ! This is a free-for-all on the imports. Oh well.
4261  use block
4262  use inputiteration
4263  use inputtimespectral
4264  use inputphysics
4265  use inputunsteady
4266  use monitor
4267  use cgnsgrid
4268  use communication
4269  use iteration
4270  use cgnsgrid
4271  use section
4272  use walldistancedata
4273  use adjointvars
4274  use adjointpetsc
4275  use surfacefamilies
4276  implicit none
4277  !
4278  ! Local variables
4279  !
4280  integer :: ierr
4281 
4282  integer(kind=intType) :: sps, nLevels, level, nn, l, i, j
4283 
4284  ! Determine the number of grid levels present in flowDoms.
4285 
4286  nlevels = ubound(flowdoms, 2)
4287 
4288  ! Loop over the number of spectral solutions.
4289 
4290  spectralloop: do sps = 1, ntimeintervalsspectral
4291 
4292  ! Loop over the coarser grid levels and local blocks and
4293  ! deallocate all the memory.
4294 
4295  do level = 2, nlevels
4296  do nn = 1, ndom
4297  call deallocateblock(nn, level, sps)
4298  end do
4299  end do
4300 
4301  ! Release some memory of the fine grid, which is not needed
4302  ! anymore.
4303 
4304  do nn = 1, ndom
4305  ! Modified by HDN
4306  ! Added dwALE, fwALE
4307  deallocate ( &
4308  flowdoms(nn, 1, sps)%dw, flowdoms(nn, 1, sps)%fw, &
4309  flowdoms(nn, 1, sps)%dtl, flowdoms(nn, 1, sps)%radI, &
4310  flowdoms(nn, 1, sps)%radJ, flowdoms(nn, 1, sps)%radK, &
4311  flowdoms(nn, 1, sps)%shockSensor, &
4312  stat=ierr)
4313  if (ierr /= 0) &
4314  call terminate("releaseMemoryPart1", &
4315  "Deallocation error for dw, fw, dwALE, fwALE, dtl and &
4316  &spectral radii.")
4317 
4318  ! Extra variables for ALE
4319  if (equationmode == unsteady .and. useale) then
4320  deallocate ( &
4321  flowdoms(nn, 1, sps)%dwALE, &
4322  flowdoms(nn, 1, sps)%fwALE, &
4323  stat=ierr)
4324  if (ierr /= 0) &
4325  call terminate("releaseMemoryPart1", &
4326  "Deallocation error for dwALE, fwALE.")
4327  end if
4328 
4329  ! Nullify the pointers, such that no attempt is made to
4330  ! release the memory again.
4331 
4332  nullify (flowdoms(nn, 1, sps)%dw)
4333  nullify (flowdoms(nn, 1, sps)%fw)
4334  nullify (flowdoms(nn, 1, sps)%dwALE) ! Added by HDN
4335  nullify (flowdoms(nn, 1, sps)%fwALE) ! Added by HDN
4336  nullify (flowdoms(nn, 1, sps)%dtl)
4337  nullify (flowdoms(nn, 1, sps)%radI)
4338  nullify (flowdoms(nn, 1, sps)%radJ)
4339  nullify (flowdoms(nn, 1, sps)%radK)
4340  nullify (flowdoms(nn, 1, sps)%scratch)
4341  nullify (flowdoms(nn, 1, sps)%shockSensor)
4342  ! Check if the zeroth stage runge kutta memory has been
4343  ! allocated. If so deallocate it and nullify the pointers.
4344 
4345  if (smoother == rungekutta) then
4346 
4347  deallocate (flowdoms(nn, 1, sps)%wn, flowdoms(nn, 1, sps)%pn, &
4348  stat=ierr)
4349  if (ierr /= 0) &
4350  call terminate("releaseMemoryPart1", &
4351  "Deallocation error for wn and pn")
4352 
4353  nullify (flowdoms(nn, 1, sps)%wn)
4354  nullify (flowdoms(nn, 1, sps)%pn)
4355 
4356  end if
4357 
4358  ! Release the memory of the old residuals for the time
4359  ! accurate Runge-Kutta schemes.
4360 
4361  if (equationmode == unsteady .and. &
4362  timeintegrationscheme == explicitrk) then
4363 
4364  deallocate (flowdoms(nn, 1, sps)%dwOldRK, stat=ierr)
4365  if (ierr /= 0) &
4366  call terminate("releaseMemoryPart1", &
4367  "Deallocation error for dwOldRK,")
4368 
4369  nullify (flowdoms(nn, 1, sps)%dwOldRK)
4370  end if
4371 
4372  end do
4373 
4374  end do spectralloop
4375 
4376  ! derivative values
4377  if (derivvarsallocated) then
4378  call deallocderivativevalues(1)
4379  end if
4380 
4381  ! Bunch of extra sutff that hasn't been deallocated
4382  if (allocated(cyclestrategy)) then
4383  deallocate (cyclestrategy)
4384  end if
4385 
4386  if (allocated(monnames)) then
4387  deallocate (monnames)
4388  end if
4389 
4390  if (allocated(monloc)) then
4391  deallocate (monloc)
4392  end if
4393 
4394  if (allocated(monglob)) then
4395  deallocate (monglob)
4396  end if
4397 
4398  if (allocated(monref)) then
4399  deallocate (monref)
4400  end if
4401 
4402  if (allocated(cgnsfamilies)) then
4403  deallocate (cgnsfamilies)
4404  end if
4405 
4406  if (allocated(cgnsdomsd)) then
4407  deallocate (cgnsdomsd)
4408  end if
4409  ! deallocate(famIDsDomainInterfaces, &
4410  ! bcIDsDomainInterfaces, &
4411  ! famIDsSliding)
4412  if (allocated(sections)) then
4413  deallocate (sections)
4414  end if
4415 
4416  if (allocated(bcfamexchange)) then
4417  do j = 1, size(bcfamexchange, 2)
4418  do i = 1, size(bcfamexchange, 1)
4420  end do
4421  end do
4422  deallocate (bcfamexchange)
4423  end if
4424 
4425  if (allocated(ncellglobal)) then
4426  deallocate (ncellglobal)
4427  end if
4428 
4429  ! Now deallocate the containers and communication objects.
4430  if (allocated(commpatterncell_1st)) then
4431  do l = 1, nlevels
4433  end do
4434  deallocate (commpatterncell_1st)
4435  end if
4436  if (allocated(commpatterncell_2nd)) then
4437  do l = 1, nlevels
4439  end do
4440  deallocate (commpatterncell_2nd)
4441  end if
4442  if (allocated(commpatternnode_1st)) then
4443  do l = 1, nlevels
4445  end do
4446  deallocate (commpatternnode_1st)
4447  end if
4448  if (allocated(internalcell_1st)) then
4449  do l = 1, nlevels
4451  end do
4452  deallocate (internalcell_1st)
4453  end if
4454  if (allocated(internalcell_2nd)) then
4455  do l = 1, nlevels
4457  end do
4458  deallocate (internalcell_2nd)
4459  end if
4460  if (allocated(internalnode_1st)) then
4461  do l = 1, nlevels
4463  end do
4464  deallocate (internalnode_1st)
4465  end if
4466 
4467  ! Send/recv buffer
4468  if (allocated(sendbuffer)) then
4469  deallocate (sendbuffer)
4470  end if
4471 
4472  if (allocated(recvbuffer)) then
4473  deallocate (recvbuffer)
4474  end if
4475 
4476  ! massFlow stuff from setFamilyInfoFaces.f90
4477  if (allocated(massflowfamilyinv)) then
4478  deallocate (massflowfamilyinv)
4479  end if
4480  if (allocated(massflowfamilydiss)) then
4481  deallocate (massflowfamilydiss)
4482  end if
4483 
4484  end subroutine releasememorypart1
4485 
4486  subroutine deallocatecommtype(comm)
4487  use communication
4488  implicit none
4489  integer(kind=intType) :: ierr, i
4490 
4491  type(commtype) :: comm
4492  ! Deallocate memory in comm
4493 
4494  ! Deallocate the sendLists
4495  do i = 1, comm%nProcSend
4496  deallocate (comm%sendList(i)%block, stat=ierr)
4497  call echk(ierr, __file__, __line__)
4498 
4499  deallocate (comm%sendList(i)%indices, stat=ierr)
4500  call echk(ierr, __file__, __line__)
4501 
4502  deallocate (comm%sendList(i)%interp, stat=ierr)
4503  call echk(ierr, __file__, __line__)
4504  end do
4505 
4506  ! Deallocate the recvLists
4507  do i = 1, comm%nProcRecv
4508  deallocate (comm%recvList(i)%block, stat=ierr)
4509  call echk(ierr, __file__, __line__)
4510 
4511  deallocate (comm%recvList(i)%indices, stat=ierr)
4512  call echk(ierr, __file__, __line__)
4513  end do
4514 
4515  deallocate (comm%sendProc, stat=ierr)
4516  call echk(ierr, __file__, __line__)
4517 
4518  deallocate (comm%nsend, stat=ierr)
4519  call echk(ierr, __file__, __line__)
4520 
4521  deallocate (comm%nsendcum, stat=ierr)
4522  call echk(ierr, __file__, __line__)
4523 
4524  deallocate (comm%sendlist, stat=ierr)
4525  call echk(ierr, __file__, __line__)
4526 
4527  deallocate (comm%recvProc, stat=ierr)
4528  call echk(ierr, __file__, __line__)
4529 
4530  deallocate (comm%nrecv, stat=ierr)
4531  call echk(ierr, __file__, __line__)
4532 
4533  deallocate (comm%nrecvcum, stat=ierr)
4534  call echk(ierr, __file__, __line__)
4535 
4536  deallocate (comm%recvlist, stat=ierr)
4537  call echk(ierr, __file__, __line__)
4538 
4539  deallocate (comm%indexsendproc, stat=ierr)
4540  call echk(ierr, __file__, __line__)
4541 
4542  deallocate (comm%indexrecvproc, stat=ierr)
4543  call echk(ierr, __file__, __line__)
4544 
4545  if (comm%nPeriodic > 0) then
4546  do i = 1, comm%nPeriodic
4547  deallocate (comm%periodicData(i)%block, stat=ierr)
4548  call echk(ierr, __file__, __line__)
4549 
4550  deallocate (comm%periodicData(i)%indices)
4551  call echk(ierr, __file__, __line__)
4552  end do
4553 
4554  deallocate (comm%periodicData, stat=ierr)
4555  call echk(ierr, __file__, __line__)
4556  end if
4557 
4558  end subroutine deallocatecommtype
4559 
4561  use communication
4562  implicit none
4563  integer(kind=intType) :: ierr, i
4564 
4565  type(internalcommtype) :: comm
4566  ! Deallocate memory in comm
4567  deallocate (comm%donorBlock, stat=ierr)
4568  call echk(ierr, __file__, __line__)
4569 
4570  deallocate (comm%donorIndices, stat=ierr)
4571  call echk(ierr, __file__, __line__)
4572 
4573  deallocate (comm%donorInterp, stat=ierr)
4574  call echk(ierr, __file__, __line__)
4575 
4576  deallocate (comm%haloBlock, stat=ierr)
4577  call echk(ierr, __file__, __line__)
4578 
4579  deallocate (comm%haloIndices, stat=ierr)
4580  call echk(ierr, __file__, __line__)
4581 
4582  if (comm%nPeriodic > 0) then
4583  do i = 1, comm%nPeriodic
4584  deallocate (comm%periodicData(i)%block, stat=ierr)
4585  call echk(ierr, __file__, __line__)
4586 
4587  deallocate (comm%periodicData(i)%indices)
4588  call echk(ierr, __file__, __line__)
4589  end do
4590  deallocate (comm%periodicData, stat=ierr)
4591  call echk(ierr, __file__, __line__)
4592  end if
4593 
4594  end subroutine deallocateinternalcommtype
4595 
4596  subroutine deallocderivativevalues(level)
4597 
4598  use constants
4599  use block, only: flowdomsd, flowdoms, ndom
4601  use walldistancedata, only: xsurfvec, xsurfvecd
4602  use flowvarrefstate, only: winfd
4603  use inputphysics, only: walldistanceneeded
4604  use adjointvars, only: derivvarsallocated
4605  use bcpointers_b
4606 
4607  implicit none
4608 
4609  ! Input Parameters
4610  integer(kind=intType) :: level
4611 
4612  ! Local variables
4613  integer(kind=intType) :: nn, sps, stat, mm, ierr
4614 
4615  do nn = 1, ndom
4616  do sps = 1, ntimeintervalsspectral
4617 
4618  deallocate ( &
4619  flowdomsd(nn, level, sps)%x, &
4620  flowdomsd(nn, level, sps)%si, &
4621  flowdomsd(nn, level, sps)%sj, &
4622  flowdomsd(nn, level, sps)%sk, &
4623  flowdomsd(nn, level, sps)%vol, &
4624  flowdomsd(nn, level, sps)%rotMatrixI, &
4625  flowdomsd(nn, level, sps)%rotMatrixJ, &
4626  flowdomsd(nn, level, sps)%rotMatrixK, &
4627  flowdomsd(nn, level, sps)%s, &
4628  flowdomsd(nn, level, sps)%sFaceI, &
4629  flowdomsd(nn, level, sps)%sFaceJ, &
4630  flowdomsd(nn, level, sps)%sFaceK, &
4631  flowdomsd(nn, level, sps)%w, &
4632  flowdomsd(nn, level, sps)%dw, &
4633  flowdomsd(nn, level, sps)%fw, &
4634  flowdomsd(nn, level, sps)%scratch, &
4635  flowdomsd(nn, level, sps)%p, &
4636  flowdomsd(nn, level, sps)%gamma, &
4637  flowdomsd(nn, level, sps)%aa, &
4638  flowdomsd(nn, level, sps)%rlv, &
4639  flowdomsd(nn, level, sps)%rev, &
4640  flowdomsd(nn, level, sps)%dtl, &
4641  flowdomsd(nn, level, sps)%radI, &
4642  flowdomsd(nn, level, sps)%radJ, &
4643  flowdomsd(nn, level, sps)%radK, &
4644  flowdomsd(nn, level, sps)%ux, &
4645  flowdomsd(nn, level, sps)%uy, &
4646  flowdomsd(nn, level, sps)%uz, &
4647  flowdomsd(nn, level, sps)%vx, &
4648  flowdomsd(nn, level, sps)%vy, &
4649  flowdomsd(nn, level, sps)%vz, &
4650  flowdomsd(nn, level, sps)%wx, &
4651  flowdomsd(nn, level, sps)%wy, &
4652  flowdomsd(nn, level, sps)%wz, &
4653  flowdomsd(nn, level, sps)%qx, &
4654  flowdomsd(nn, level, sps)%qy, &
4655  flowdomsd(nn, level, sps)%qz, &
4656  flowdomsd(nn, level, sps)%bmti1, &
4657  flowdomsd(nn, level, sps)%bmti2, &
4658  flowdomsd(nn, level, sps)%bmtj1, &
4659  flowdomsd(nn, level, sps)%bmtj2, &
4660  flowdomsd(nn, level, sps)%bmtk1, &
4661  flowdomsd(nn, level, sps)%bmtk2, &
4662  flowdomsd(nn, level, sps)%bvti1, &
4663  flowdomsd(nn, level, sps)%bvti2, &
4664  flowdomsd(nn, level, sps)%bvtj1, &
4665  flowdomsd(nn, level, sps)%bvtj2, &
4666  flowdomsd(nn, level, sps)%bvtk1, &
4667  flowdomsd(nn, level, sps)%bvtk2, &
4668  flowdomsd(nn, level, sps)%d2Wall, &
4669  stat=ierr)
4670  call echk(ierr, __file__, __line__)
4671 
4672  ! Deallocate allocated boundary data
4673  do mm = 1, flowdoms(nn, level, sps)%nBocos
4674  deallocate ( &
4675  flowdomsd(nn, level, sps)%BCData(mm)%norm, &
4676  flowdomsd(nn, level, sps)%BCData(mm)%rface, &
4677  flowdomsd(nn, level, sps)%BCData(mm)%Fp, &
4678  flowdomsd(nn, level, sps)%BCData(mm)%Fv, &
4679  flowdomsd(nn, level, sps)%BCData(mm)%Tp, &
4680  flowdomsd(nn, level, sps)%BCData(mm)%Tv, &
4681  flowdomsd(nn, level, sps)%BCData(mm)%F, &
4682  flowdomsd(nn, level, sps)%BCData(mm)%T, &
4683  flowdomsd(nn, level, sps)%BCData(mm)%area, &
4684  flowdomsd(nn, level, sps)%BCData(mm)%uSlip, &
4685  flowdomsd(nn, level, sps)%BCData(mm)%TNS_Wall, &
4686  stat=ierr)
4687  call echk(ierr, __file__, __line__)
4688  end do
4689 
4690  deallocate (flowdomsd(nn, level, sps)%BCData, stat=ierr)
4691  call echk(ierr, __file__, __line__)
4692 
4693  viscbocoloop: do mm = 1, flowdoms(nn, level, sps)%nViscBocos
4694  deallocate ( &
4695  flowdomsd(nn, level, sps)%viscSubface(mm)%tau, &
4696  flowdomsd(nn, level, sps)%viscSubface(mm)%q, &
4697  stat=ierr)
4698  call echk(ierr, __file__, __line__)
4699  end do viscbocoloop
4700 
4701  deallocate (flowdomsd(nn, level, sps)%viscSubFace, stat=ierr)
4702  call echk(ierr, __file__, __line__)
4703 
4704  end do
4705  end do
4706 
4707  ! Also dealloc winfd
4708  deallocate (winfd)
4709 
4710  ! Finally deallocate flowdomsd
4711  deallocate (flowdomsd, stat=ierr)
4712  call echk(ierr, __file__, __line__)
4713 
4714  ! And the petsc vector(s)
4715  if (.not. walldistanceneeded) then
4716  do sps = 1, ntimeintervalsspectral
4717  call vecdestroy(xsurfvec(1, sps), ierr)
4718  end do
4719  end if
4720 
4721  do sps = 1, ntimeintervalsspectral
4722  call vecdestroy(xsurfvecd(sps), ierr)
4723  call echk(ierr, __file__, __line__)
4724  end do
4725  deallocate (xsurfvecd)
4726 
4727  derivvarsallocated = .false.
4728  end subroutine deallocderivativevalues
4729 
4730  ! ---------------------------------------------------------------------------
4731 
4733  !
4734  ! releaseMemoryPart2 releases all the memory of flowDoms on the
4735  ! finest grid as well as the memory allocated in the other
4736  ! modules.
4737  !
4738  use block
4739  use inputtimespectral
4741  use adjointpetsc
4742  use cgnsgrid
4743  implicit none
4744  !
4745  ! Local variables
4746  !
4747  integer :: ierr
4748 
4749  integer(kind=intType) :: nn, sps
4750 
4751  ! Release the memory of flowDoms of the finest grid and of the
4752  ! array flowDoms afterwards.
4753  if (allocated(flowdoms)) then
4754  do sps = 1, ntimeintervalsspectral
4755  do nn = 1, ndom
4756  call deallocateblock(nn, 1_inttype, sps)
4757  end do
4758  end do
4759  deallocate (flowdoms, stat=ierr)
4760  if (ierr /= 0) &
4761  call terminate("releaseMemoryPart2", &
4762  "Deallocation failure for flowDoms")
4763  end if
4764 
4765  ! Some more memory should be deallocated if this code is to
4766  ! be used in combination with adaptation.
4767 
4768  ! deallocate the cpmin_family array allocated in inputParamRoutines
4769  if (allocated(cpmin_family)) &
4770  deallocate (cpmin_family)
4771 
4772  ! deallocate the sepSenMaxFamily array allocated in inputParamRoutines
4773  if (allocated(sepsenmaxfamily)) &
4774  deallocate (sepsenmaxfamily)
4775 
4776  ! Destroy variables allocated in preprocessingAdjoint
4778  call vecdestroy(w_like1, petscierr)
4779  call echk(petscierr, __file__, __line__)
4780 
4781  call vecdestroy(w_like2, petscierr)
4782  call echk(petscierr, __file__, __line__)
4783 
4784  call vecdestroy(psi_like1, petscierr)
4785  call echk(petscierr, __file__, __line__)
4786 
4787  call vecdestroy(psi_like2, petscierr)
4788  call echk(petscierr, __file__, __line__)
4789 
4790  call vecdestroy(psi_like3, petscierr)
4791  call echk(petscierr, __file__, __line__)
4792 
4793  call vecdestroy(x_like, petscierr)
4794  call echk(petscierr, __file__, __line__)
4795  end if
4796 
4797  ! Finally delete cgnsDoms...but there is still more
4798  ! pointers that need to be deallocated...
4799  if (allocated(cgnsdoms)) then
4800  do nn = 1, cgnsndom
4801  if (associated(cgnsdoms(nn)%procStored)) &
4802  deallocate (cgnsdoms(nn)%procStored)
4803 
4804  if (associated(cgnsdoms(nn)%conn1to1)) &
4805  deallocate (cgnsdoms(nn)%conn1to1)
4806 
4807  if (associated(cgnsdoms(nn)%connNonMatchAbutting)) &
4808  deallocate (cgnsdoms(nn)%connNonMatchAbutting)
4809 
4810  if (associated(cgnsdoms(nn)%bocoInfo)) &
4811  deallocate (cgnsdoms(nn)%bocoInfo)
4812 
4813  deallocate ( &
4814  cgnsdoms(nn)%iBegOr, cgnsdoms(nn)%iEndOr, &
4815  cgnsdoms(nn)%jBegOr, cgnsdoms(nn)%jEndOr, &
4816  cgnsdoms(nn)%kBegOr, cgnsdoms(nn)%kEndOr, &
4817  cgnsdoms(nn)%localBlockID)
4818  end do
4819  end if
4820 
4821  end subroutine releasememorypart2
4822 
4823  subroutine deallocateblock(nn, level, sps)
4824  !
4825  ! deallocateBlock deallocates all the allocated memory of the
4826  ! given block.
4827  !
4828  use constants
4829  use inputunsteady
4830  use inputphysics
4831  use iteration
4832  use inputiteration, only: useskewnesscheck
4834  implicit none
4835  !
4836  ! Subroutine arguments.
4837  !
4838  integer(kind=intType), intent(in) :: nn, level, sps
4839  !
4840  ! Local variables.
4841  !
4842  integer :: ierr
4843 
4844  integer(kind=intType) :: i
4845 
4846  type(viscsubfacetype), dimension(:), pointer :: viscSubface
4847  type(bcdatatype), dimension(:), pointer :: BCData
4848 
4849  logical :: deallocationFailure
4850 
4851  ! Initialize deallocationFailure to .false.
4852 
4853  deallocationfailure = .false.
4854 
4855  ! Set the pointer for viscSubface and deallocate the memory
4856  ! stored in there. Initialize ierr to 0, such that the terminate
4857  ! routine is only called at the end if a memory deallocation
4858  ! failure occurs.
4859  ierr = 0
4860  viscsubface => flowdoms(nn, level, sps)%viscSubface
4861  do i = 1, flowdoms(nn, level, sps)%nViscBocos
4862  deallocate (viscsubface(i)%tau, viscsubface(i)%q, &
4863  viscsubface(i)%utau, stat=ierr)
4864  if (ierr /= 0) deallocationfailure = .true.
4865 
4866  nullify (viscsubface(i)%tau)
4867  nullify (viscsubface(i)%q)
4868  nullify (viscsubface(i)%utau)
4869  end do
4870 
4871  ! Set the pointer for BCData and deallocate the memory
4872  ! stored in there.
4873  bcdata => flowdoms(nn, level, sps)%BCData
4874  do i = 1, flowdoms(nn, level, sps)%nBocos
4875 
4876  if (associated(bcdata(i)%norm)) &
4877  deallocate (bcdata(i)%norm, stat=ierr)
4878  if (ierr /= 0) deallocationfailure = .true.
4879 
4880  if (associated(bcdata(i)%area)) &
4881  deallocate (bcdata(i)%area, stat=ierr)
4882  if (ierr /= 0) deallocationfailure = .true.
4883 
4884  if (associated(bcdata(i)%surfIndex)) &
4885  deallocate (bcdata(i)%surfIndex, stat=ierr)
4886  if (ierr /= 0) deallocationfailure = .true.
4887 
4888  if (associated(bcdata(i)%F)) &
4889  deallocate (bcdata(i)%F, stat=ierr)
4890  if (ierr /= 0) deallocationfailure = .true.
4891 
4892  if (associated(bcdata(i)%Fv)) &
4893  deallocate (bcdata(i)%Fv, stat=ierr)
4894  if (ierr /= 0) deallocationfailure = .true.
4895 
4896  if (associated(bcdata(i)%Fp)) &
4897  deallocate (bcdata(i)%Fp, stat=ierr)
4898  if (ierr /= 0) deallocationfailure = .true.
4899 
4900  if (associated(bcdata(i)%T)) &
4901  deallocate (bcdata(i)%T, stat=ierr)
4902  if (ierr /= 0) deallocationfailure = .true.
4903 
4904  if (associated(bcdata(i)%Tv)) &
4905  deallocate (bcdata(i)%Tv, stat=ierr)
4906  if (ierr /= 0) deallocationfailure = .true.
4907 
4908  if (associated(bcdata(i)%Tp)) &
4909  deallocate (bcdata(i)%Tp, stat=ierr)
4910  if (ierr /= 0) deallocationfailure = .true.
4911 
4912  if (associated(bcdata(i)%rface)) &
4913  deallocate (bcdata(i)%rface, stat=ierr)
4914  if (ierr /= 0) deallocationfailure = .true.
4915 
4916  if (associated(bcdata(i)%uSlip)) &
4917  deallocate (bcdata(i)%uSlip, stat=ierr)
4918  if (ierr /= 0) deallocationfailure = .true.
4919 
4920  if (associated(bcdata(i)%TNS_Wall)) &
4921  deallocate (bcdata(i)%TNS_Wall, stat=ierr)
4922  if (ierr /= 0) deallocationfailure = .true.
4923 
4924  if (associated(bcdata(i)%ptInlet)) &
4925  deallocate (bcdata(i)%ptInlet, stat=ierr)
4926  if (ierr /= 0) deallocationfailure = .true.
4927 
4928  if (associated(bcdata(i)%ttInlet)) &
4929  deallocate (bcdata(i)%ttInlet, stat=ierr)
4930  if (ierr /= 0) deallocationfailure = .true.
4931 
4932  if (associated(bcdata(i)%htInlet)) &
4933  deallocate (bcdata(i)%htInlet, stat=ierr)
4934  if (ierr /= 0) deallocationfailure = .true.
4935 
4936  if (associated(bcdata(i)%flowXdirInlet)) &
4937  deallocate (bcdata(i)%flowXdirInlet, stat=ierr)
4938  if (ierr /= 0) deallocationfailure = .true.
4939 
4940  if (associated(bcdata(i)%flowYdirInlet)) &
4941  deallocate (bcdata(i)%flowYdirInlet, stat=ierr)
4942  if (ierr /= 0) deallocationfailure = .true.
4943 
4944  if (associated(bcdata(i)%flowZdirInlet)) &
4945  deallocate (bcdata(i)%flowZdirInlet, stat=ierr)
4946  if (ierr /= 0) deallocationfailure = .true.
4947 
4948  if (associated(bcdata(i)%rho)) &
4949  deallocate (bcdata(i)%rho, stat=ierr)
4950  if (ierr /= 0) deallocationfailure = .true.
4951 
4952  if (associated(bcdata(i)%velx)) &
4953  deallocate (bcdata(i)%velx, stat=ierr)
4954  if (ierr /= 0) deallocationfailure = .true.
4955 
4956  if (associated(bcdata(i)%vely)) &
4957  deallocate (bcdata(i)%vely, stat=ierr)
4958  if (ierr /= 0) deallocationfailure = .true.
4959 
4960  if (associated(bcdata(i)%velz)) &
4961  deallocate (bcdata(i)%velz, stat=ierr)
4962  if (ierr /= 0) deallocationfailure = .true.
4963 
4964  if (associated(bcdata(i)%ps)) &
4965  deallocate (bcdata(i)%ps, stat=ierr)
4966  if (ierr /= 0) deallocationfailure = .true.
4967 
4968  if (associated(bcdata(i)%turbInlet)) &
4969  deallocate (bcdata(i)%turbInlet, stat=ierr)
4970  if (ierr /= 0) deallocationfailure = .true.
4971 
4972  if (associated(bcdata(i)%normALE)) &
4973  deallocate (bcdata(i)%normALE, stat=ierr)
4974  if (ierr /= 0) deallocationfailure = .true.
4975  if (associated(bcdata(i)%rFaceALE)) &
4976  deallocate (bcdata(i)%rFaceALE, stat=ierr)
4977  if (ierr /= 0) deallocationfailure = .true.
4978  if (associated(bcdata(i)%uSlipALE)) &
4979  deallocate (bcdata(i)%uSlipALE, stat=ierr)
4980  if (ierr /= 0) deallocationfailure = .true.
4981  if (associated(bcdata(i)%cellHeatFlux)) &
4982  deallocate (bcdata(i)%cellHeatFlux, stat=ierr)
4983  if (associated(bcdata(i)%nodeHeatFlux)) &
4984  deallocate (bcdata(i)%nodeHeatFlux, stat=ierr)
4985  if (ierr /= 0) deallocationfailure = .true.
4986 
4987  if (associated(bcdata(i)%iBlank)) &
4988  deallocate (bcdata(i)%iBlank, stat=ierr)
4989 
4990  if (ierr /= 0) deallocationfailure = .true.
4991 
4992  nullify (bcdata(i)%norm)
4993  nullify (bcdata(i)%rface)
4994  nullify (bcdata(i)%F)
4995  nullify (bcdata(i)%Fv)
4996  nullify (bcdata(i)%Fp)
4997  nullify (bcdata(i)%T)
4998  nullify (bcdata(i)%Tv)
4999  nullify (bcdata(i)%Tp)
5000 
5001  nullify (bcdata(i)%uSlip)
5002  nullify (bcdata(i)%TNS_Wall)
5003 
5004  nullify (bcdata(i)%normALE)
5005  nullify (bcdata(i)%rfaceALE)
5006  nullify (bcdata(i)%uSlipALE)
5007  nullify (bcdata(i)%cellHeatFlux)
5008  nullify (bcdata(i)%nodeHeatFlux)
5009 
5010  nullify (bcdata(i)%ptInlet)
5011  nullify (bcdata(i)%ttInlet)
5012  nullify (bcdata(i)%htInlet)
5013  nullify (bcdata(i)%flowXdirInlet)
5014  nullify (bcdata(i)%flowYdirInlet)
5015  nullify (bcdata(i)%flowZdirInlet)
5016 
5017  nullify (bcdata(i)%turbInlet)
5018 
5019  nullify (bcdata(i)%rho)
5020  nullify (bcdata(i)%velx)
5021  nullify (bcdata(i)%vely)
5022  nullify (bcdata(i)%velz)
5023  nullify (bcdata(i)%ps)
5024  nullify (bcdata(i)%iblank)
5025 
5026  end do
5027 
5028  if (associated(flowdoms(nn, level, sps)%BCType)) &
5029  deallocate (flowdoms(nn, level, sps)%BCType, stat=ierr)
5030  if (ierr /= 0) deallocationfailure = .true.
5031 
5032  if (associated(flowdoms(nn, level, sps)%BCFaceID)) &
5033  deallocate (flowdoms(nn, level, sps)%BCFaceID, stat=ierr)
5034  if (ierr /= 0) deallocationfailure = .true.
5035 
5036  if (associated(flowdoms(nn, level, sps)%cgnsSubface)) &
5037  deallocate (flowdoms(nn, level, sps)%cgnsSubface, stat=ierr)
5038  if (ierr /= 0) deallocationfailure = .true.
5039 
5040  if (associated(flowdoms(nn, level, sps)%inBeg)) &
5041  deallocate (flowdoms(nn, level, sps)%inBeg, stat=ierr)
5042  if (ierr /= 0) deallocationfailure = .true.
5043 
5044  if (associated(flowdoms(nn, level, sps)%inEnd)) &
5045  deallocate (flowdoms(nn, level, sps)%inEnd, stat=ierr)
5046  if (ierr /= 0) deallocationfailure = .true.
5047 
5048  if (associated(flowdoms(nn, level, sps)%jnBeg)) &
5049  deallocate (flowdoms(nn, level, sps)%jnBeg, stat=ierr)
5050  if (ierr /= 0) deallocationfailure = .true.
5051 
5052  if (associated(flowdoms(nn, level, sps)%jnEnd)) &
5053  deallocate (flowdoms(nn, level, sps)%jnEnd, stat=ierr)
5054  if (ierr /= 0) deallocationfailure = .true.
5055 
5056  if (associated(flowdoms(nn, level, sps)%knBeg)) &
5057  deallocate (flowdoms(nn, level, sps)%knBeg, stat=ierr)
5058  if (ierr /= 0) deallocationfailure = .true.
5059 
5060  if (associated(flowdoms(nn, level, sps)%knEnd)) &
5061  deallocate (flowdoms(nn, level, sps)%knEnd, stat=ierr)
5062  if (ierr /= 0) deallocationfailure = .true.
5063 
5064  if (associated(flowdoms(nn, level, sps)%dinBeg)) &
5065  deallocate (flowdoms(nn, level, sps)%dinBeg, stat=ierr)
5066  if (ierr /= 0) deallocationfailure = .true.
5067 
5068  if (associated(flowdoms(nn, level, sps)%dinEnd)) &
5069  deallocate (flowdoms(nn, level, sps)%dinEnd, stat=ierr)
5070  if (ierr /= 0) deallocationfailure = .true.
5071 
5072  if (associated(flowdoms(nn, level, sps)%djnBeg)) &
5073  deallocate (flowdoms(nn, level, sps)%djnBeg, stat=ierr)
5074  if (ierr /= 0) deallocationfailure = .true.
5075 
5076  if (associated(flowdoms(nn, level, sps)%djnEnd)) &
5077  deallocate (flowdoms(nn, level, sps)%djnEnd, stat=ierr)
5078  if (ierr /= 0) deallocationfailure = .true.
5079 
5080  if (associated(flowdoms(nn, level, sps)%dknBeg)) &
5081  deallocate (flowdoms(nn, level, sps)%dknBeg, stat=ierr)
5082  if (ierr /= 0) deallocationfailure = .true.
5083 
5084  if (associated(flowdoms(nn, level, sps)%dknEnd)) &
5085  deallocate (flowdoms(nn, level, sps)%dknEnd, stat=ierr)
5086  if (ierr /= 0) deallocationfailure = .true.
5087 
5088  if (associated(flowdoms(nn, level, sps)%icBeg)) &
5089  deallocate (flowdoms(nn, level, sps)%icBeg, stat=ierr)
5090  if (ierr /= 0) deallocationfailure = .true.
5091 
5092  if (associated(flowdoms(nn, level, sps)%icEnd)) &
5093  deallocate (flowdoms(nn, level, sps)%icEnd, stat=ierr)
5094  if (ierr /= 0) deallocationfailure = .true.
5095 
5096  if (associated(flowdoms(nn, level, sps)%jcBeg)) &
5097  deallocate (flowdoms(nn, level, sps)%jcBeg, stat=ierr)
5098  if (ierr /= 0) deallocationfailure = .true.
5099 
5100  if (associated(flowdoms(nn, level, sps)%jcEnd)) &
5101  deallocate (flowdoms(nn, level, sps)%jcEnd, stat=ierr)
5102  if (ierr /= 0) deallocationfailure = .true.
5103 
5104  if (associated(flowdoms(nn, level, sps)%kcBeg)) &
5105  deallocate (flowdoms(nn, level, sps)%kcBeg, stat=ierr)
5106  if (ierr /= 0) deallocationfailure = .true.
5107 
5108  if (associated(flowdoms(nn, level, sps)%kcEnd)) &
5109  deallocate (flowdoms(nn, level, sps)%kcEnd, stat=ierr)
5110  if (ierr /= 0) deallocationfailure = .true.
5111 
5112  if (associated(flowdoms(nn, level, sps)%neighBlock)) &
5113  deallocate (flowdoms(nn, level, sps)%neighBlock, stat=ierr)
5114  if (ierr /= 0) deallocationfailure = .true.
5115 
5116  if (associated(flowdoms(nn, level, sps)%neighProc)) &
5117  deallocate (flowdoms(nn, level, sps)%neighProc, stat=ierr)
5118  if (ierr /= 0) deallocationfailure = .true.
5119 
5120  if (associated(flowdoms(nn, level, sps)%l1)) &
5121  deallocate (flowdoms(nn, level, sps)%l1, stat=ierr)
5122  if (ierr /= 0) deallocationfailure = .true.
5123 
5124  if (associated(flowdoms(nn, level, sps)%l2)) &
5125  deallocate (flowdoms(nn, level, sps)%l2, stat=ierr)
5126  if (ierr /= 0) deallocationfailure = .true.
5127 
5128  if (associated(flowdoms(nn, level, sps)%l3)) &
5129  deallocate (flowdoms(nn, level, sps)%l3, stat=ierr)
5130  if (ierr /= 0) deallocationfailure = .true.
5131 
5132  if (associated(flowdoms(nn, level, sps)%groupNum)) &
5133  deallocate (flowdoms(nn, level, sps)%groupNum, stat=ierr)
5134  if (ierr /= 0) deallocationfailure = .true.
5135 
5136  if (associated(flowdoms(nn, level, sps)%iblank)) &
5137  deallocate (flowdoms(nn, level, sps)%iblank, stat=ierr)
5138  if (ierr /= 0) deallocationfailure = .true.
5139 
5140  if (associated(flowdoms(nn, level, sps)%forcedRecv)) &
5141  deallocate (flowdoms(nn, level, sps)%forcedRecv, stat=ierr)
5142  if (ierr /= 0) deallocationfailure = .true.
5143 
5144  if (associated(flowdoms(nn, level, sps)%status)) &
5145  deallocate (flowdoms(nn, level, sps)%status, stat=ierr)
5146  if (ierr /= 0) deallocationfailure = .true.
5147 
5148  if (associated(flowdoms(nn, level, sps)%BCData)) &
5149  deallocate (flowdoms(nn, level, sps)%BCData, stat=ierr)
5150  if (ierr /= 0) deallocationfailure = .true.
5151 
5152  if (associated(flowdoms(nn, level, sps)%viscSubface)) &
5153  deallocate (flowdoms(nn, level, sps)%viscSubface, stat=ierr)
5154  if (ierr /= 0) deallocationfailure = .true.
5155 
5156  if (associated(flowdoms(nn, level, sps)%viscIminPointer)) &
5157  deallocate (flowdoms(nn, level, sps)%viscIminPointer, stat=ierr)
5158  if (ierr /= 0) deallocationfailure = .true.
5159 
5160  if (associated(flowdoms(nn, level, sps)%viscImaxPointer)) &
5161  deallocate (flowdoms(nn, level, sps)%viscImaxPointer, stat=ierr)
5162  if (ierr /= 0) deallocationfailure = .true.
5163 
5164  if (associated(flowdoms(nn, level, sps)%viscJminPointer)) &
5165  deallocate (flowdoms(nn, level, sps)%viscJminPointer, stat=ierr)
5166  if (ierr /= 0) deallocationfailure = .true.
5167 
5168  if (associated(flowdoms(nn, level, sps)%viscJmaxPointer)) &
5169  deallocate (flowdoms(nn, level, sps)%viscJmaxPointer, stat=ierr)
5170  if (ierr /= 0) deallocationfailure = .true.
5171 
5172  if (associated(flowdoms(nn, level, sps)%viscKminPointer)) &
5173  deallocate (flowdoms(nn, level, sps)%viscKminPointer, stat=ierr)
5174  if (ierr /= 0) deallocationfailure = .true.
5175 
5176  if (associated(flowdoms(nn, level, sps)%viscKmaxPointer)) &
5177  deallocate (flowdoms(nn, level, sps)%viscKmaxPointer, stat=ierr)
5178  if (ierr /= 0) deallocationfailure = .true.
5179 
5180  if (associated(flowdoms(nn, level, sps)%x)) &
5181  deallocate (flowdoms(nn, level, sps)%x, stat=ierr)
5182  if (ierr /= 0) deallocationfailure = .true.
5183 
5184  if (associated(flowdoms(nn, level, sps)%xOld)) &
5185  deallocate (flowdoms(nn, level, sps)%xOld, stat=ierr)
5186  if (ierr /= 0) deallocationfailure = .true.
5187 
5188  if (associated(flowdoms(nn, level, sps)%si)) &
5189  deallocate (flowdoms(nn, level, sps)%si, stat=ierr)
5190  if (ierr /= 0) deallocationfailure = .true.
5191 
5192  if (associated(flowdoms(nn, level, sps)%sj)) &
5193  deallocate (flowdoms(nn, level, sps)%sj, stat=ierr)
5194  if (ierr /= 0) deallocationfailure = .true.
5195 
5196  if (associated(flowdoms(nn, level, sps)%sk)) &
5197  deallocate (flowdoms(nn, level, sps)%sk, stat=ierr)
5198  if (ierr /= 0) deallocationfailure = .true.
5199 
5200  if (associated(flowdoms(nn, level, sps)%vol)) &
5201  deallocate (flowdoms(nn, level, sps)%vol, stat=ierr)
5202  if (ierr /= 0) deallocationfailure = .true.
5203 
5204  if (useskewnesscheck) then
5205  if (associated(flowdoms(nn, level, sps)%skew)) &
5206  deallocate (flowdoms(nn, level, sps)%skew, stat=ierr)
5207  if (ierr /= 0) deallocationfailure = .true.
5208  end if
5209 
5210  if (associated(flowdoms(nn, level, sps)%volRef)) &
5211  deallocate (flowdoms(nn, level, sps)%volRef, stat=ierr)
5212  if (ierr /= 0) deallocationfailure = .true.
5213 
5214  if (associated(flowdoms(nn, level, sps)%volOld)) &
5215  deallocate (flowdoms(nn, level, sps)%volOld, stat=ierr)
5216  if (ierr /= 0) deallocationfailure = .true.
5217 
5218  if (associated(flowdoms(nn, level, sps)%pori)) &
5219  deallocate (flowdoms(nn, level, sps)%pori, stat=ierr)
5220  if (ierr /= 0) deallocationfailure = .true.
5221 
5222  if (associated(flowdoms(nn, level, sps)%porj)) &
5223  deallocate (flowdoms(nn, level, sps)%porj, stat=ierr)
5224  if (ierr /= 0) deallocationfailure = .true.
5225 
5226  if (associated(flowdoms(nn, level, sps)%pork)) &
5227  deallocate (flowdoms(nn, level, sps)%pork, stat=ierr)
5228  if (ierr /= 0) deallocationfailure = .true.
5229 
5230  if (associated(flowdoms(nn, level, sps)%indFamilyI)) &
5231  deallocate (flowdoms(nn, level, sps)%indFamilyI, stat=ierr)
5232  if (ierr /= 0) deallocationfailure = .true.
5233 
5234  if (associated(flowdoms(nn, level, sps)%indFamilyJ)) &
5235  deallocate (flowdoms(nn, level, sps)%indFamilyJ, stat=ierr)
5236  if (ierr /= 0) deallocationfailure = .true.
5237 
5238  if (associated(flowdoms(nn, level, sps)%indFamilyK)) &
5239  deallocate (flowdoms(nn, level, sps)%indFamilyK, stat=ierr)
5240  if (ierr /= 0) deallocationfailure = .true.
5241 
5242  if (associated(flowdoms(nn, level, sps)%factFamilyI)) &
5243  deallocate (flowdoms(nn, level, sps)%factFamilyI, stat=ierr)
5244  if (ierr /= 0) deallocationfailure = .true.
5245 
5246  if (associated(flowdoms(nn, level, sps)%factFamilyJ)) &
5247  deallocate (flowdoms(nn, level, sps)%factFamilyJ, stat=ierr)
5248  if (ierr /= 0) deallocationfailure = .true.
5249 
5250  if (associated(flowdoms(nn, level, sps)%factFamilyK)) &
5251  deallocate (flowdoms(nn, level, sps)%factFamilyK, stat=ierr)
5252  if (ierr /= 0) deallocationfailure = .true.
5253 
5254  if (associated(flowdoms(nn, level, sps)%rotMatrixI)) &
5255  deallocate (flowdoms(nn, level, sps)%rotMatrixI, stat=ierr)
5256  if (ierr /= 0) deallocationfailure = .true.
5257 
5258  if (associated(flowdoms(nn, level, sps)%rotMatrixJ)) &
5259  deallocate (flowdoms(nn, level, sps)%rotMatrixJ, stat=ierr)
5260  if (ierr /= 0) deallocationfailure = .true.
5261 
5262  if (associated(flowdoms(nn, level, sps)%rotMatrixK)) &
5263  deallocate (flowdoms(nn, level, sps)%rotMatrixK, stat=ierr)
5264  if (ierr /= 0) deallocationfailure = .true.
5265 
5266  if (associated(flowdoms(nn, level, sps)%sFaceI)) &
5267  deallocate (flowdoms(nn, level, sps)%sFaceI, stat=ierr)
5268  if (ierr /= 0) deallocationfailure = .true.
5269 
5270  if (associated(flowdoms(nn, level, sps)%sFaceJ)) &
5271  deallocate (flowdoms(nn, level, sps)%sFaceJ, stat=ierr)
5272  if (ierr /= 0) deallocationfailure = .true.
5273 
5274  if (associated(flowdoms(nn, level, sps)%sFaceK)) &
5275  deallocate (flowdoms(nn, level, sps)%sFaceK, stat=ierr)
5276  if (ierr /= 0) deallocationfailure = .true.
5277 
5278  if (associated(flowdoms(nn, level, sps)%w)) &
5279  deallocate (flowdoms(nn, level, sps)%w, stat=ierr)
5280  if (ierr /= 0) deallocationfailure = .true.
5281 
5282  if (associated(flowdoms(nn, level, sps)%wOld)) &
5283  deallocate (flowdoms(nn, level, sps)%wOld, stat=ierr)
5284  if (ierr /= 0) deallocationfailure = .true.
5285 
5286  if (associated(flowdoms(nn, level, sps)%p)) &
5287  deallocate (flowdoms(nn, level, sps)%p, stat=ierr)
5288  if (ierr /= 0) deallocationfailure = .true.
5289 
5290  if (associated(flowdoms(nn, level, sps)%aa)) &
5291  deallocate (flowdoms(nn, level, sps)%aa, stat=ierr)
5292  if (ierr /= 0) deallocationfailure = .true.
5293 
5294  if (associated(flowdoms(nn, level, sps)%gamma)) &
5295  deallocate (flowdoms(nn, level, sps)%gamma, stat=ierr)
5296  if (ierr /= 0) deallocationfailure = .true.
5297 
5298  if (associated(flowdoms(nn, level, sps)%ux)) &
5299  deallocate (flowdoms(nn, level, sps)%ux, stat=ierr)
5300  if (ierr /= 0) deallocationfailure = .true.
5301 
5302  if (associated(flowdoms(nn, level, sps)%uy)) &
5303  deallocate (flowdoms(nn, level, sps)%uy, stat=ierr)
5304  if (ierr /= 0) deallocationfailure = .true.
5305 
5306  if (associated(flowdoms(nn, level, sps)%uz)) &
5307  deallocate (flowdoms(nn, level, sps)%uz, stat=ierr)
5308  if (ierr /= 0) deallocationfailure = .true.
5309 
5310  if (associated(flowdoms(nn, level, sps)%vx)) &
5311  deallocate (flowdoms(nn, level, sps)%vx, stat=ierr)
5312  if (ierr /= 0) deallocationfailure = .true.
5313 
5314  if (associated(flowdoms(nn, level, sps)%vy)) &
5315  deallocate (flowdoms(nn, level, sps)%vy, stat=ierr)
5316  if (ierr /= 0) deallocationfailure = .true.
5317 
5318  if (associated(flowdoms(nn, level, sps)%vz)) &
5319  deallocate (flowdoms(nn, level, sps)%vz, stat=ierr)
5320  if (ierr /= 0) deallocationfailure = .true.
5321 
5322  if (associated(flowdoms(nn, level, sps)%wx)) &
5323  deallocate (flowdoms(nn, level, sps)%wx, stat=ierr)
5324  if (ierr /= 0) deallocationfailure = .true.
5325 
5326  if (associated(flowdoms(nn, level, sps)%wy)) &
5327  deallocate (flowdoms(nn, level, sps)%wy, stat=ierr)
5328  if (ierr /= 0) deallocationfailure = .true.
5329 
5330  if (associated(flowdoms(nn, level, sps)%wz)) &
5331  deallocate (flowdoms(nn, level, sps)%wz, stat=ierr)
5332  if (ierr /= 0) deallocationfailure = .true.
5333 
5334  if (associated(flowdoms(nn, level, sps)%qx)) &
5335  deallocate (flowdoms(nn, level, sps)%qx, stat=ierr)
5336  if (ierr /= 0) deallocationfailure = .true.
5337 
5338  if (associated(flowdoms(nn, level, sps)%qy)) &
5339  deallocate (flowdoms(nn, level, sps)%qy, stat=ierr)
5340  if (ierr /= 0) deallocationfailure = .true.
5341 
5342  if (associated(flowdoms(nn, level, sps)%qz)) &
5343  deallocate (flowdoms(nn, level, sps)%qz, stat=ierr)
5344  if (ierr /= 0) deallocationfailure = .true.
5345 
5346  if (associated(flowdoms(nn, level, sps)%rlv)) &
5347  deallocate (flowdoms(nn, level, sps)%rlv, stat=ierr)
5348  if (ierr /= 0) deallocationfailure = .true.
5349 
5350  if (associated(flowdoms(nn, level, sps)%rev)) &
5351  deallocate (flowdoms(nn, level, sps)%rev, stat=ierr)
5352  if (ierr /= 0) deallocationfailure = .true.
5353 
5354  if (associated(flowdoms(nn, level, sps)%s)) &
5355  deallocate (flowdoms(nn, level, sps)%s, stat=ierr)
5356  if (ierr /= 0) deallocationfailure = .true.
5357 
5358  if (associated(flowdoms(nn, level, sps)%p1)) &
5359  deallocate (flowdoms(nn, level, sps)%p1, stat=ierr)
5360  if (ierr /= 0) deallocationfailure = .true.
5361 
5362  if (associated(flowdoms(nn, level, sps)%dw)) &
5363  deallocate (flowdoms(nn, level, sps)%dw, stat=ierr)
5364  if (ierr /= 0) deallocationfailure = .true.
5365 
5366  if (associated(flowdoms(nn, level, sps)%fw)) &
5367  deallocate (flowdoms(nn, level, sps)%fw, stat=ierr)
5368  if (ierr /= 0) deallocationfailure = .true.
5369 
5370  if (associated(flowdoms(nn, level, sps)%dwOldRK)) &
5371  deallocate (flowdoms(nn, level, sps)%dwOldRK, stat=ierr)
5372  if (ierr /= 0) deallocationfailure = .true.
5373 
5374  if (associated(flowdoms(nn, level, sps)%w1)) &
5375  deallocate (flowdoms(nn, level, sps)%w1, stat=ierr)
5376  if (ierr /= 0) deallocationfailure = .true.
5377 
5378  if (associated(flowdoms(nn, level, sps)%wr)) &
5379  deallocate (flowdoms(nn, level, sps)%wr, stat=ierr)
5380  if (ierr /= 0) deallocationfailure = .true.
5381 
5382  if (associated(flowdoms(nn, level, sps)%mgIFine)) &
5383  deallocate (flowdoms(nn, level, sps)%mgIFine, stat=ierr)
5384  if (ierr /= 0) deallocationfailure = .true.
5385 
5386  if (associated(flowdoms(nn, level, sps)%mgJFine)) &
5387  deallocate (flowdoms(nn, level, sps)%mgJFine, stat=ierr)
5388  if (ierr /= 0) deallocationfailure = .true.
5389 
5390  if (associated(flowdoms(nn, level, sps)%mgKFine)) &
5391  deallocate (flowdoms(nn, level, sps)%mgKFine, stat=ierr)
5392  if (ierr /= 0) deallocationfailure = .true.
5393 
5394  if (associated(flowdoms(nn, level, sps)%mgIWeight)) &
5395  deallocate (flowdoms(nn, level, sps)%mgIWeight, stat=ierr)
5396  if (ierr /= 0) deallocationfailure = .true.
5397 
5398  if (associated(flowdoms(nn, level, sps)%mgJWeight)) &
5399  deallocate (flowdoms(nn, level, sps)%mgJWeight, stat=ierr)
5400  if (ierr /= 0) deallocationfailure = .true.
5401 
5402  if (associated(flowdoms(nn, level, sps)%mgKWeight)) &
5403  deallocate (flowdoms(nn, level, sps)%mgKWeight, stat=ierr)
5404  if (ierr /= 0) deallocationfailure = .true.
5405 
5406  if (associated(flowdoms(nn, level, sps)%mgICoarse)) &
5407  deallocate (flowdoms(nn, level, sps)%mgICoarse, stat=ierr)
5408  if (ierr /= 0) deallocationfailure = .true.
5409 
5410  if (associated(flowdoms(nn, level, sps)%mgJCoarse)) &
5411  deallocate (flowdoms(nn, level, sps)%mgJCoarse, stat=ierr)
5412  if (ierr /= 0) deallocationfailure = .true.
5413 
5414  if (associated(flowdoms(nn, level, sps)%mgKCoarse)) &
5415  deallocate (flowdoms(nn, level, sps)%mgKCoarse, stat=ierr)
5416  if (ierr /= 0) deallocationfailure = .true.
5417 
5418  if (associated(flowdoms(nn, level, sps)%iCo)) &
5419  deallocate (flowdoms(nn, level, sps)%iCo, stat=ierr)
5420  if (ierr /= 0) deallocationfailure = .true.
5421 
5422  if (associated(flowdoms(nn, level, sps)%jCo)) &
5423  deallocate (flowdoms(nn, level, sps)%jCo, stat=ierr)
5424  if (ierr /= 0) deallocationfailure = .true.
5425 
5426  if (associated(flowdoms(nn, level, sps)%kCo)) &
5427  deallocate (flowdoms(nn, level, sps)%kCo, stat=ierr)
5428  if (ierr /= 0) deallocationfailure = .true.
5429 
5430  if (associated(flowdoms(nn, level, sps)%wn)) &
5431  deallocate (flowdoms(nn, level, sps)%wn, stat=ierr)
5432  if (ierr /= 0) deallocationfailure = .true.
5433 
5434  if (associated(flowdoms(nn, level, sps)%pn)) &
5435  deallocate (flowdoms(nn, level, sps)%pn, stat=ierr)
5436  if (ierr /= 0) deallocationfailure = .true.
5437 
5438  if (associated(flowdoms(nn, level, sps)%dtl)) &
5439  deallocate (flowdoms(nn, level, sps)%dtl, stat=ierr)
5440  if (ierr /= 0) deallocationfailure = .true.
5441 
5442  if (associated(flowdoms(nn, level, sps)%radI)) &
5443  deallocate (flowdoms(nn, level, sps)%radI, stat=ierr)
5444  if (ierr /= 0) deallocationfailure = .true.
5445 
5446  if (associated(flowdoms(nn, level, sps)%radJ)) &
5447  deallocate (flowdoms(nn, level, sps)%radJ, stat=ierr)
5448  if (ierr /= 0) deallocationfailure = .true.
5449 
5450  if (associated(flowdoms(nn, level, sps)%radK)) &
5451  deallocate (flowdoms(nn, level, sps)%radK, stat=ierr)
5452  if (ierr /= 0) deallocationfailure = .true.
5453 
5454  if (associated(flowdoms(nn, level, sps)%d2Wall)) &
5455  deallocate (flowdoms(nn, level, sps)%d2Wall, stat=ierr)
5456  if (ierr /= 0) deallocationfailure = .true.
5457 
5458  if (associated(flowdoms(nn, level, sps)%bmti1)) &
5459  deallocate (flowdoms(nn, level, sps)%bmti1, stat=ierr)
5460  if (ierr /= 0) deallocationfailure = .true.
5461 
5462  if (associated(flowdoms(nn, level, sps)%bmti2)) &
5463  deallocate (flowdoms(nn, level, sps)%bmti2, stat=ierr)
5464  if (ierr /= 0) deallocationfailure = .true.
5465 
5466  if (associated(flowdoms(nn, level, sps)%bmtj1)) &
5467  deallocate (flowdoms(nn, level, sps)%bmtj1, stat=ierr)
5468  if (ierr /= 0) deallocationfailure = .true.
5469 
5470  if (associated(flowdoms(nn, level, sps)%bmtj2)) &
5471  deallocate (flowdoms(nn, level, sps)%bmtj2, stat=ierr)
5472  if (ierr /= 0) deallocationfailure = .true.
5473 
5474  if (associated(flowdoms(nn, level, sps)%bmtk1)) &
5475  deallocate (flowdoms(nn, level, sps)%bmtk1, stat=ierr)
5476  if (ierr /= 0) deallocationfailure = .true.
5477 
5478  if (associated(flowdoms(nn, level, sps)%bmtk2)) &
5479  deallocate (flowdoms(nn, level, sps)%bmtk2, stat=ierr)
5480  if (ierr /= 0) deallocationfailure = .true.
5481 
5482  if (associated(flowdoms(nn, level, sps)%bvti1)) &
5483  deallocate (flowdoms(nn, level, sps)%bvti1, stat=ierr)
5484  if (ierr /= 0) deallocationfailure = .true.
5485 
5486  if (associated(flowdoms(nn, level, sps)%bvti2)) &
5487  deallocate (flowdoms(nn, level, sps)%bvti2, stat=ierr)
5488  if (ierr /= 0) deallocationfailure = .true.
5489 
5490  if (associated(flowdoms(nn, level, sps)%bvtj1)) &
5491  deallocate (flowdoms(nn, level, sps)%bvtj1, stat=ierr)
5492  if (ierr /= 0) deallocationfailure = .true.
5493 
5494  if (associated(flowdoms(nn, level, sps)%bvtj2)) &
5495  deallocate (flowdoms(nn, level, sps)%bvtj2, stat=ierr)
5496  if (ierr /= 0) deallocationfailure = .true.
5497 
5498  if (associated(flowdoms(nn, level, sps)%bvtk1)) &
5499  deallocate (flowdoms(nn, level, sps)%bvtk1, stat=ierr)
5500  if (ierr /= 0) deallocationfailure = .true.
5501 
5502  if (associated(flowdoms(nn, level, sps)%bvtk2)) &
5503  deallocate (flowdoms(nn, level, sps)%bvtk2, stat=ierr)
5504  if (ierr /= 0) deallocationfailure = .true.
5505 
5506  if (associated(flowdoms(nn, level, sps)%globalCell)) &
5507  deallocate (flowdoms(nn, level, sps)%globalCell, stat=ierr)
5508  if (ierr /= 0) deallocationfailure = .true.
5509 
5510  if (associated(flowdoms(nn, level, sps)%globalNode)) &
5511  deallocate (flowdoms(nn, level, sps)%globalNode, stat=ierr)
5512  if (ierr /= 0) deallocationfailure = .true.
5513 
5514  if (equationmode == unsteady .and. useale) then
5515 
5516  ! Added by HDN
5517  if (associated(flowdoms(nn, level, sps)%xALE)) &
5518  deallocate (flowdoms(nn, level, sps)%xALE, stat=ierr)
5519  if (ierr /= 0) deallocationfailure = .true.
5520 
5521  if (associated(flowdoms(nn, level, sps)%sIALE)) &
5522  deallocate (flowdoms(nn, level, sps)%sIALE, stat=ierr)
5523  if (ierr /= 0) deallocationfailure = .true.
5524 
5525  if (associated(flowdoms(nn, level, sps)%sJALE)) &
5526  deallocate (flowdoms(nn, level, sps)%sJALE, stat=ierr)
5527  if (ierr /= 0) deallocationfailure = .true.
5528 
5529  if (associated(flowdoms(nn, level, sps)%sKALE)) &
5530  deallocate (flowdoms(nn, level, sps)%sKALE, stat=ierr)
5531  if (ierr /= 0) deallocationfailure = .true.
5532 
5533  if (associated(flowdoms(nn, level, sps)%sVeloIALE)) &
5534  deallocate (flowdoms(nn, level, sps)%sVeloIALE, stat=ierr)
5535  if (ierr /= 0) deallocationfailure = .true.
5536 
5537  if (associated(flowdoms(nn, level, sps)%sVeloJALE)) &
5538  deallocate (flowdoms(nn, level, sps)%sVeloJALE, stat=ierr)
5539  if (ierr /= 0) deallocationfailure = .true.
5540 
5541  if (associated(flowdoms(nn, level, sps)%sVeloKALE)) &
5542  deallocate (flowdoms(nn, level, sps)%sVeloKALE, stat=ierr)
5543  if (ierr /= 0) deallocationfailure = .true.
5544 
5545  if (associated(flowdoms(nn, level, sps)%sFaceIALE)) &
5546  deallocate (flowdoms(nn, level, sps)%sFaceIALE, stat=ierr)
5547  if (ierr /= 0) deallocationfailure = .true.
5548 
5549  if (associated(flowdoms(nn, level, sps)%sFaceJALE)) &
5550  deallocate (flowdoms(nn, level, sps)%sFaceJALE, stat=ierr)
5551  if (ierr /= 0) deallocationfailure = .true.
5552 
5553  if (associated(flowdoms(nn, level, sps)%sFaceKALE)) &
5554  deallocate (flowdoms(nn, level, sps)%sFaceKALE, stat=ierr)
5555  if (ierr /= 0) deallocationfailure = .true.
5556 
5557  ! if( associated(flowDoms(nn,level,sps)%dwALE) ) &
5558  ! deallocate(flowDoms(nn,level,sps)%dwALE, stat=ierr)
5559  ! if(ierr /= 0) deallocationFailure = .true.
5560  !
5561  ! if( associated(flowDoms(nn,level,sps)%fwALE) ) &
5562  ! deallocate(flowDoms(nn,level,sps)%fwALE, stat=ierr)
5563  ! if(ierr /= 0) deallocationFailure = .true.
5564  end if
5565 
5566  ! Check for errors in the deallocation.
5567 
5568  if (deallocationfailure) &
5569  call terminate("deallocateBlock", &
5570  "Something went wrong when deallocating memory")
5571 
5572  ! Nullify the pointers of this block.
5573  call nullifyflowdompointers(nn, level, sps)
5574 
5575  end subroutine deallocateblock
5576 
5577  integer function setcgnsrealtype()
5578  !
5579  ! setCGNSRealType sets the cgns real type, depending on the
5580  ! compiler options. Note that quadrupole precision is not
5581  ! supported by CGNS; double precision is used instead for the
5582  ! CGNS IO.
5583  !
5584  use su_cgns, only: realsingle, realdouble
5585  implicit none
5586 
5587 #ifdef USE_NO_CGNS
5588 
5589  call terminate("setCGNSRealType", &
5590  "Function should not be called if no cgns support &
5591  &is selected.")
5592 
5593 #else
5594 
5595 # ifdef USE_SINGLE_PRECISION
5596  setcgnsrealtype = realsingle
5597 # else
5598  setcgnsrealtype = realdouble
5599 # endif
5600 
5601 #endif
5602 
5603  end function setcgnsrealtype
5604 
5605  subroutine returnfail(routineName, errorMessage)
5606  !
5607  ! returnFail writes an error message to standard output and
5608  ! sets fail flags to be returned to python.
5609  !
5610  use constants
5612 #ifndef USE_TAPENADE
5614 #endif
5615  implicit none
5616  !
5617  ! Subroutine arguments
5618  !
5619  character(len=*), intent(in) :: routineName
5620  character(len=*), intent(in) :: errorMessage
5621 #ifndef USE_TAPENADE
5622 
5623  !
5624  ! Local parameter
5625  !
5626  integer, parameter :: maxCharLine = 55
5627  !
5628  ! Local variables
5629  !
5630  integer :: ierr, len, i2
5631  logical :: firstTime
5632 
5633  character(len=len_trim(errorMessage)) :: message
5634  character(len=8) :: integerString
5635 
5636  ! Copy the errorMessage into message. It is not possible to work
5637  ! with errorMessage directly, because it is modified in this
5638  ! routine. Sometimes a constant string is passed to this routine
5639  ! and some compilers simply fail then.
5640 
5641  message = errormessage
5642 
5643  ! Print a nice error message. In case of a parallel executable
5644  ! also the processor id is printed.
5645 
5646  print "(a)", "#"
5647  print "(a)", "#--------------------------- !!! Error !!! &
5648  &----------------------------"
5649 
5650  write (integerstring, "(i8)") myid
5651  integerstring = adjustl(integerstring)
5652 
5653  print "(2a)", "#* returnFail called by processor ", &
5654  trim(integerstring)
5655 
5656  ! Write the header of the error message.
5657 
5658  print "(2a)", "#* Run-time error in procedure ", &
5659  trim(routinename)
5660 
5661  ! Loop to write the error message. If the message is too long it
5662  ! is split over several lines.
5663 
5664  firsttime = .true.
5665  do
5666  ! Determine the remaining error message to be written.
5667  ! If longer than the maximum number of characters allowed
5668  ! on a line, it is attempted to split the message.
5669 
5670  message = adjustl(message)
5671  len = len_trim(message)
5672  i2 = min(maxcharline, len)
5673 
5674  if (i2 < len) i2 = index(message(:i2), " ", .true.) - 1
5675  if (i2 < 0) i2 = index(message, " ") - 1
5676  if (i2 < 0) i2 = len
5677 
5678  ! Write this part of the error message. If it is the first
5679  ! line of the message some additional stuff is printed.
5680 
5681  if (firsttime) then
5682  print "(2a)", "#* Error message: ", &
5683  trim(message(:i2))
5684  firsttime = .false.
5685  else
5686  print "(2a)", "#* ", &
5687  trim(message(:i2))
5688  end if
5689 
5690  ! Exit the loop if the entire message has been written.
5691 
5692  if (i2 == len) exit
5693 
5694  ! Adapt the string for the next part to be written.
5695 
5696  message = message(i2 + 1:)
5697 
5698  end do
5699 
5700  ! Write the trailing message.
5701 
5702  print "(a)", "#*"
5703  print "(a)", "#------------------------------------------&
5704  &----------------------------"
5705  print "(a)", "#"
5706 
5707  ! Call abort and stop the program. This stop should be done in
5708  ! abort, but just to be sure.
5709 
5710  if (frompython) then
5711  routinefailed = .true.
5712  fatalfail = .true.
5713  else
5714  call mpi_abort(adflow_comm_world, 1, ierr)
5715  stop
5716  end if
5717 #endif
5718 
5719  end subroutine returnfail
5720 
5721  subroutine echk(errorcode, file, line)
5722 
5723  ! Check if ierr that resulted from a petsc or MPI call is in fact an
5724  ! error.
5725  use constants
5727  implicit none
5728 
5729  integer(kind=intType), intent(in) :: errorcode
5730  character(len=*), intent(in) :: file
5731  integer(kind=intType), intent(in) :: line
5732  integer :: ierr
5733  character(len=maxStringLen) :: errorCodeFormat, errorLineFormat
5734 
5735  errorcodeformat = "(2(A, I2))"
5736  errorlineformat = "(A, I5, A, A)"
5737 
5738  if (errorcode == 0) then
5739  return ! No error, return immediately
5740  else
5741 #ifndef USE_TAPENADE
5742  print *, '---------------------------------------------------------------------------'
5743  print errorcodeformat, "PETSc or MPI Error. Error Code ", errorcode, ". Detected on Proc ", myid
5744  print errorlineformat, "Error at line: ", line, " in file: ", file
5745  print *, '---------------------------------------------------------------------------'
5746  call mpi_abort(adflow_comm_world, errorcode, ierr)
5747  stop ! Just in case
5748 #else
5749  stop
5750 #endif
5751  end if
5752 
5753  end subroutine echk
5754 
5755  subroutine converttolowercase(string)
5756  !
5757  ! convertToLowerCase converts the given string to lower case.
5758  !
5759  use constants
5760  implicit none
5761  !
5762  ! Subroutine arguments
5763  !
5764  character(len=*), intent(inout) :: string
5765  !
5766  ! Local variables
5767  !
5768  integer(kind=intType), parameter :: upperToLower = iachar("a") - iachar("A")
5769 
5770  integer(kind=intType) :: i, lenString
5771 
5772  ! Determine the length of the given string and convert the upper
5773  ! case characters to lower case.
5774 
5775  lenstring = len_trim(string)
5776  do i = 1, lenstring
5777  if ("A" <= string(i:i) .and. string(i:i) <= "Z") &
5778  string(i:i) = achar(iachar(string(i:i)) + uppertolower)
5779  end do
5780 
5781  end subroutine converttolowercase
5782 
5783  logical function eulerwallspresent()
5784 
5785  ! eulerWallsPresent determines whether or not inviscid walls are
5786  ! present in the whole grid. It first determines if these walls are
5787  ! present locally and performs an allReduce afterwards.
5788 
5789  use constants
5790  use block, only: ndom, flowdoms
5791  use communication, only: adflow_comm_world
5792  implicit none
5793  !
5794  ! Local variables.
5795  !
5796  integer(kind=intType) :: nn, i
5797  integer :: ierr
5798  logical :: localeulerwalls
5799 
5800  ! Initialize localEulerWalls to .false. and loop over the
5801  ! boundary subfaces of the blocks to see if Euler walls are
5802  ! present on this processor. As the info is the same for all
5803  ! spectral solutions, only the 1st needs to be considered.
5804 
5805  localeulerwalls = .false.
5806  do nn = 1, ndom
5807  do i = 1, flowdoms(nn, 1, 1)%nBocos
5808  if (flowdoms(nn, 1, 1)%BCType(i) == eulerwall) &
5809  localeulerwalls = .true.
5810  end do
5811  end do
5812 
5813  ! Set i to 1 if Euler walls are present locally and to 0
5814  ! otherwise. Determine the maximum over all processors
5815  ! and set EulerWallsPresent accordingly.
5816 
5817  i = 0
5818  if (localeulerwalls) i = 1
5819  call mpi_allreduce(i, nn, 1, adflow_integer, mpi_max, &
5820  adflow_comm_world, ierr)
5821 
5822  if (nn == 0) then
5823  eulerwallspresent = .false.
5824  else
5825  eulerwallspresent = .true.
5826  end if
5827 
5828  end function eulerwallspresent
5829  subroutine allocconvarrays(nIterTot)
5830  !
5831  ! allocConvArrays allocates the memory for the convergence
5832  ! arrays. The number of iterations allocated, nIterTot, is
5833  ! enough to store the maximum number of iterations specified
5834  ! plus possible earlier iterations read from the restart file.
5835  ! This routine MAY be called with data already inside of
5836  ! convArray and this will be saved.
5837  !
5838  use constants
5840  use inputio, only: storeconvinneriter
5842  implicit none
5843  !
5844  ! Subroutine argument.
5845  !
5846  integer(kind=intType) :: nIterTot
5847  !
5848  ! Local variables.
5849  !
5850  integer :: ierr
5851 
5852  integer(kind=intType) :: nSolverMon ! number of solver monitor variables
5853 
5854  ! Return immediately if the convergence history (of the inner
5855  ! iterations) does not need to be stored. This logical can
5856  ! only be .false. for an unsteady computation.
5857  if (.not. storeconvinneriter) return
5858 
5859  if (allocated(convarray)) then
5860  deallocate (convarray)
5861  end if
5862  if (allocated(solverdataarray)) then
5863  deallocate (solverdataarray)
5864  end if
5865  if (allocated(solvertypearray)) then
5866  deallocate (solvertypearray)
5867  end if
5868 
5869  if (showcpu) then
5870  nsolvermon = 5
5871  else
5872  nsolvermon = 4
5873  end if
5874 
5875  allocate (convarray(0:nitertot, ntimeintervalsspectral, nmon))
5876  allocate (solverdataarray(0:nitertot, ntimeintervalsspectral, nsolvermon))
5877  allocate (solvertypearray(0:nitertot, ntimeintervalsspectral))
5878 
5879  ! Zero Array:
5880  convarray = zero
5882 
5883  end subroutine allocconvarrays
5884 
5885  subroutine alloctimearrays(nTimeTot)
5886  !
5887  ! allocTimeArrays allocates the memory for the arrays to store
5888  ! the time history of the unsteady computation. The number of
5889  ! time steps specified is enought to store the total number of
5890  ! time steps of the current computation plus possible earlier
5891  ! computations.
5892  !
5893  use constants
5894  use monitor, only: timearray, timedataarray, nmon
5895  implicit none
5896  !
5897  ! Subroutine argument.
5898  !
5899  integer(kind=intType) :: nTimeTot
5900  !
5901  ! Local variables.
5902  !
5903  integer :: ierr
5904 
5905  ! Allocate the memory for both the time array as well as the
5906  ! data array.
5907 
5908  if (allocated(timearray)) then
5909  deallocate (timearray)
5910  end if
5911  if (allocated(timedataarray)) then
5912  deallocate (timedataarray)
5913  end if
5914 
5915  allocate (timearray(ntimetot), &
5916  timedataarray(ntimetot, nmon), stat=ierr)
5917  if (ierr /= 0) &
5918  call terminate("allocTimeArrays", &
5919  "Memory allocation failure for timeArray &
5920  &and timeDataArray")
5921 
5922  end subroutine alloctimearrays
5923 
5924  subroutine getmonitorvariablenames(nvar, monitor_variables)
5925  !
5926  ! copy the names in monnames to another array so that is can be
5927  ! passed back up the python level
5928  !
5929  use constants
5930  use monitor, only: nmon, monnames
5931  implicit none
5932 
5933  ! save the monitor variable names into a new array
5934  integer(kind=intType), intent(in) :: nvar
5935  character, dimension(nvar, maxCGNSNameLen), intent(out) :: monitor_variables
5936 
5937  ! working variables
5938  character(len=maxCGNSNameLen) :: var_name
5939  integer(kind=intType) :: c, idx_mon
5940 
5941  do idx_mon = 1, nvar
5942  var_name = monnames(idx_mon)
5943 
5944  do c = 1, len(monnames(idx_mon))
5945  monitor_variables(idx_mon, c) = var_name(c:c)
5946  end do
5947  end do
5948 
5949  end subroutine getmonitorvariablenames
5950 
5951  subroutine getsolvertypearray(niter, nsps, type_array)
5952  !
5953  ! copy the names in sovlerTypeArray to another array so that is can be
5954  ! passed back up the python level
5955  !
5956  use constants
5957  use monitor, only: solvertypearray
5959  use iteration, only: itertot
5960  implicit none
5961 
5962  ! save the monitor variable names into a new array
5963  integer(kind=intType), intent(in) :: niter, nsps
5964  character, dimension(0:niter, ntimeintervalsspectral, maxIterTypelen), intent(out) :: type_array
5965 
5966  ! working variables
5967  character(len=maxIterTypelen) :: type_name
5968  integer(kind=intType) :: c, idx_sps, idx_iter
5969 
5970  do idx_sps = 1, ntimeintervalsspectral
5971  do idx_iter = 0, itertot
5972  type_name = solvertypearray(idx_iter, idx_sps)
5973 
5974  do c = 1, len(solvertypearray(idx_iter, idx_sps))
5975  type_array(idx_iter, idx_sps, c) = type_name(c:c)
5976  end do
5977 
5978  end do
5979  end do
5980 
5981  end subroutine getsolvertypearray
5982 
5984  !
5985  ! convergenceHeader writes the convergence header to stdout.
5986  !
5987  use cgnsnames
5988  use inputphysics
5989  use inputunsteady
5990  use flowvarrefstate
5991  use monitor
5992  use iteration
5993  use inputiteration
5994  implicit none
5995  !
5996  ! Local variables.
5997  !
5998  integer(kind=intType) :: i, nCharWrite
5999  logical :: writeIterations
6000 
6001  ! Determine whether or not the iterations must be written.
6002 
6003  if (printiterations) then
6004  writeiterations = .true.
6005  if (equationmode == unsteady .and. &
6006  timeintegrationscheme == explicitrk) writeiterations = .false.
6007 
6008  ! Determine the number of characters to write.
6009  ! First initialize this number with the variables which are
6010  ! always written. This depends on the equation mode. For unsteady
6011  ! and spectral computations a bit more info is written.
6012 
6013  ncharwrite = 10
6014  if (writeiterations) ncharwrite = ncharwrite + 7 + 7 + 9 + 7 + 7 + 10
6015  if (equationmode == unsteady) then
6016  ncharwrite = ncharwrite + 7 + fieldwidth + 1
6017  else if (equationmode == timespectral) then
6018  ncharwrite = ncharwrite + 11
6019  end if
6020 
6021  ! Add the number of characters needed for the actual variables.
6022 
6023 #ifndef USE_COMPLEX
6024  ! for the real version this is easy
6025  ncharwrite = ncharwrite + nmon * (fieldwidthlarge + 1)
6026 #else
6027  ! for complex we need to differentiate between residuals and functionals
6028  do i = 1, nmon
6029  select case (monnames(i))
6030 
6031  case (cgnsl2resrho, cgnsl2resmomx, &
6036  cgnsl2resv2, cgnsl2resf, 'totalR')
6037 
6038  ! complex residuals need 9 more characters
6039  ncharwrite = ncharwrite + fieldwidthlarge + 1 + 9
6040 
6041  case default
6042  ! complex functionals need 25 more characters
6043  ncharwrite = ncharwrite + fieldwidthlarge + 1 + 25
6044 
6045  end select
6046  end do
6047 #endif
6048 
6049  if (showcpu) ncharwrite = ncharwrite + fieldwidth + 1
6050 
6051  ! Write the line of - signs. This line starts with a #, such
6052  ! that it is ignored by some plotting software.
6053 
6054  write (*, "(a)", advance="no") "#"
6055  do i = 2, ncharwrite
6056  write (*, "(a)", advance="no") "-"
6057  end do
6058  print "(1x)"
6059 
6060  ! Write the first line of the header. First the variables that
6061  ! will always be written. Some extra variables must be written
6062  ! for unsteady and time spectral problems.
6063  write (*, '("# ")', advance="no")
6064  write (*, "(a)", advance="no") " Grid |"
6065 
6066  if (equationmode == unsteady) then
6067  write (*, "(a)", advance="no") " Time | Time |"
6068  else if (equationmode == timespectral) then
6069  write (*, "(a)", advance="no") " Spectral |"
6070  end if
6071 
6072  if (writeiterations) write (*, "(a)", advance="no") " Iter | Iter | Iter | CFL | Step | Lin |"
6073  if (showcpu) write (*, "(a)", advance="no") " Wall |"
6074 
6075  ! Write the header for the variables to be monitored.
6076  do i = 1, nmon
6077  ! Determine the variable name and write the
6078  ! corresponding text.
6079 
6080  ! we do the real and complex versions separately
6081 #ifndef USE_COMPLEX
6082  ! real versions print the full 16 digits so these spacings are "regular" and the same for all
6083  select case (monnames(i))
6084 
6085  case ("totalR")
6086  write (*, "(a)", advance="no") " totalRes |"
6087 
6088  case (cgnsl2resrho)
6089  write (*, "(a)", advance="no") " Res rho |"
6090 
6091  case (cgnsl2resmomx)
6092  write (*, "(a)", advance="no") " Res rhou |"
6093 
6094  case (cgnsl2resmomy)
6095  write (*, "(a)", advance="no") " Res rhov |"
6096 
6097  case (cgnsl2resmomz)
6098  write (*, "(a)", advance="no") " Res rhow |"
6099 
6100  case (cgnsl2resrhoe)
6101  write (*, "(a)", advance="no") " Res rhoE |"
6102 
6103  case (cgnsl2resnu)
6104  write (*, "(a)", advance="no") " Res nuturb |"
6105 
6106  case (cgnsl2resk)
6107  write (*, "(a)", advance="no") " Res kturb |"
6108 
6109  case (cgnsl2resomega)
6110  write (*, "(a)", advance="no") " Res wturb |"
6111 
6112  case (cgnsl2restau)
6113  write (*, "(a)", advance="no") " Res tauturb |"
6114 
6115  case (cgnsl2resepsilon)
6116  write (*, "(a)", advance="no") " Res epsturb |"
6117 
6118  case (cgnsl2resv2)
6119  write (*, "(a)", advance="no") " Res v2turb |"
6120 
6121  case (cgnsl2resf)
6122  write (*, "(a)", advance="no") " Res fturb |"
6123 
6124  case (cgnscl)
6125  write (*, "(a)", advance="no") " C_lift |"
6126 
6127  case (cgnsclp)
6128  write (*, "(a)", advance="no") " C_lift_p |"
6129 
6130  case (cgnsclv)
6131  write (*, "(a)", advance="no") " C_lift_v |"
6132 
6133  case (cgnscd)
6134  write (*, "(a)", advance="no") " C_drag |"
6135 
6136  case (cgnscdp)
6137  write (*, "(a)", advance="no") " C_drag_p |"
6138 
6139  case (cgnscdv)
6140  write (*, "(a)", advance="no") " C_drag_v |"
6141 
6142  case (cgnscfx)
6143  write (*, "(a)", advance="no") " C_Fx |"
6144 
6145  case (cgnscfy)
6146  write (*, "(a)", advance="no") " C_Fy |"
6147 
6148  case (cgnscfz)
6149  write (*, "(a)", advance="no") " C_Fz |"
6150 
6151  case (cgnscmx)
6152  write (*, "(a)", advance="no") " C_Mx |"
6153 
6154  case (cgnscmy)
6155  write (*, "(a)", advance="no") " C_My |"
6156 
6157  case (cgnscmz)
6158  write (*, "(a)", advance="no") " C_Mz |"
6159 
6160  case (cgnshdiffmax)
6161  write (*, "(a)", advance="no") " |H-H_inf| |"
6162 
6163  case (cgnsmachmax)
6164  write (*, "(a)", advance="no") " Mach_max |"
6165 
6166  case (cgnsyplusmax)
6167  write (*, "(a)", advance="no") " Y+_max |"
6168 
6169  case (cgnseddymax)
6170  write (*, "(a)", advance="no") " Eddyv_max |"
6171 
6172  case (cgnssepsensor)
6173  write (*, "(a)", advance="no") " SepSensor |"
6174 
6175  case (cgnssepsensorksarea)
6176  write (*, "(a)", advance="no") " sepSensorKsArea |"
6177 
6178  case (cgnscavitation)
6179  write (*, "(a)", advance="no") " Cavitation |"
6180 
6181  case (cgnsaxismoment)
6182  write (*, "(a)", advance="no") " AxisMoment |"
6183 
6184  end select
6185 #else
6186  ! complex versions print the full 16 digits for real and complex for "functionals"
6187  ! but shorter versions only for residuals
6188  select case (monnames(i))
6189 
6190  case ("totalR")
6191  write (*, "(a)", advance="no") " totalRes |"
6192 
6193  case (cgnsl2resrho)
6194  write (*, "(a)", advance="no") " Res rho |"
6195 
6196  case (cgnsl2resmomx)
6197  write (*, "(a)", advance="no") " Res rhou |"
6198 
6199  case (cgnsl2resmomy)
6200  write (*, "(a)", advance="no") " Res rhov |"
6201 
6202  case (cgnsl2resmomz)
6203  write (*, "(a)", advance="no") " Res rhow |"
6204 
6205  case (cgnsl2resrhoe)
6206  write (*, "(a)", advance="no") " Res rhoE |"
6207 
6208  case (cgnsl2resnu)
6209  write (*, "(a)", advance="no") " Res nuturb |"
6210 
6211  case (cgnsl2resk)
6212  write (*, "(a)", advance="no") " Res kturb |"
6213 
6214  case (cgnsl2resomega)
6215  write (*, "(a)", advance="no") " Res wturb |"
6216 
6217  case (cgnsl2restau)
6218  write (*, "(a)", advance="no") " Res tauturb |"
6219 
6220  case (cgnsl2resepsilon)
6221  write (*, "(a)", advance="no") " Res epsturb |"
6222 
6223  case (cgnsl2resv2)
6224  write (*, "(a)", advance="no") " Res v2turb |"
6225 
6226  case (cgnsl2resf)
6227  write (*, "(a)", advance="no") " Res fturb |"
6228 
6229  case (cgnscl)
6230  write (*, "(a)", advance="no") " C_lift |"
6231 
6232  case (cgnsclp)
6233  write (*, "(a)", advance="no") " C_lift_p |"
6234 
6235  case (cgnsclv)
6236  write (*, "(a)", advance="no") " C_lift_v |"
6237 
6238  case (cgnscd)
6239  write (*, "(a)", advance="no") " C_drag |"
6240 
6241  case (cgnscdp)
6242  write (*, "(a)", advance="no") " C_drag_p |"
6243 
6244  case (cgnscdv)
6245  write (*, "(a)", advance="no") " C_drag_v |"
6246 
6247  case (cgnscfx)
6248  write (*, "(a)", advance="no") " C_Fx |"
6249 
6250  case (cgnscfy)
6251  write (*, "(a)", advance="no") " C_Fy |"
6252 
6253  case (cgnscfz)
6254  write (*, "(a)", advance="no") " C_Fz |"
6255 
6256  case (cgnscmx)
6257  write (*, "(a)", advance="no") " C_Mx |"
6258 
6259  case (cgnscmy)
6260  write (*, "(a)", advance="no") " C_My |"
6261 
6262  case (cgnscmz)
6263  write (*, "(a)", advance="no") " C_Mz |"
6264 
6265  case (cgnshdiffmax)
6266  write (*, "(a)", advance="no") " |H-H_inf| |"
6267 
6268  case (cgnsmachmax)
6269  write (*, "(a)", advance="no") " Mach_max |"
6270 
6271  case (cgnsyplusmax)
6272  write (*, "(a)", advance="no") " Y+_max |"
6273 
6274  case (cgnseddymax)
6275  write (*, "(a)", advance="no") " Eddyv_max |"
6276 
6277  case (cgnssepsensor)
6278  write (*, "(a)", advance="no") " SepSensor |"
6279 
6280  case (cgnssepsensorksarea)
6281  write (*, "(a)", advance="no") " sepSensorKsArea |"
6282 
6283  case (cgnscavitation)
6284  write (*, "(a)", advance="no") " Cavitation |"
6285 
6286  case (cgnsaxismoment)
6287  write (*, "(a)", advance="no") " AxisMoment |"
6288 
6289  end select
6290 #endif
6291 
6292  end do
6293 
6294  print "(1x)"
6295 
6296  ! Write the second line of the header. Most of them are empty,
6297  ! but some variables require a second line.
6298  write (*, '("# ")', advance="no")
6299 
6300  write (*, "(a)", advance="no") " level |"
6301 
6302  if (equationmode == unsteady) then
6303  write (*, "(a)", advance="no") " Step | |"
6304  else if (equationmode == timespectral) then
6305  write (*, "(a)", advance="no") " Solution |"
6306  end if
6307 
6308  if (writeiterations) write (*, "(a)", advance="no") " | Tot | Type | | | Res |"
6309  if (showcpu) write (*, "(a)", advance="no") " Clock (s) |"
6310 
6311  ! Loop over the variables to be monitored and write the
6312  ! second line.
6313 
6314  do i = 1, nmon
6315 
6316  ! Determine the variable name and write the
6317  ! corresponding text.
6318 #ifndef USE_COMPLEX
6319  ! real mode gets the same width for all variables
6320  select case (monnames(i))
6321 
6322  case (cgnshdiffmax)
6323  write (*, "(a)", advance="no") " max |"
6324 
6325  case default
6326  write (*, "(a)", advance="no") " |"
6327 
6328  end select
6329 #else
6330  ! complex mode gets shorter spacing for residuals
6331  select case (monnames(i))
6332 
6333  case (cgnshdiffmax)
6334  write (*, "(a)", advance="no") " max |"
6335 
6336  case (cgnsl2resrho, cgnsl2resmomx, &
6341  cgnsl2resv2, cgnsl2resf, 'totalR')
6342  ! residuals get a shorter line
6343  write (*, "(a)", advance="no") " |"
6344  case default
6345  ! regular functionals get the long empty line
6346  write (*, "(a)", advance="no") " |"
6347 
6348  end select
6349 #endif
6350 
6351  end do
6352  print "(1x)"
6353  end if
6354 
6355  ! Write again a line of - signs (starting with a #).
6356 
6357  write (*, "(a)", advance="no") "#"
6358  do i = 2, ncharwrite
6359  write (*, "(a)", advance="no") "-"
6360  end do
6361  print "(1x)"
6362 
6363  end subroutine convergenceheader
6364  subroutine sumresiduals(nn, mm)
6365  !
6366  ! sumResiduals adds the sum of the residuals squared at
6367  ! position nn to the array monLoc at position mm. It is assumed
6368  ! that the arrays of blockPointers already point to the correct
6369  ! block.
6370  !
6371  use blockpointers
6372  use monitor
6373  implicit none
6374  !
6375  ! Subroutine arguments.
6376  !
6377  integer(kind=intType), intent(in) :: nn, mm
6378  !
6379  ! Local variables.
6380  !
6381  integer(kind=intType) :: i, j, k
6382 
6383  ! Loop over the number of owned cells of this block and
6384  ! accumulate the residual.
6385 
6386  do k = 2, kl
6387  do j = 2, jl
6388  do i = 2, il
6389 #ifndef USE_COMPLEX
6390  monloc(mm) = monloc(mm) + (dw(i, j, k, nn) / vol(i, j, k))**2
6391 #else
6392  ! TODO squaring the complex residual when its order 1e-200 underflows and we need a better approach here
6393  ! we need to square and sum the real and complex parts separately
6394  monloc(mm) = monloc(mm) + &
6395  cmplx((real(dw(i, j, k, nn) / vol(i, j, k)))**2, &
6396  (aimag(dw(i, j, k, nn) / vol(i, j, k)))**2)
6397 #endif
6398  end do
6399  end do
6400  end do
6401 
6402  end subroutine sumresiduals
6403 
6404  subroutine sumallresiduals(mm)
6405  !
6406  ! sumAllResiduals adds the sum of the ALL residuals squared at
6407  ! to monLoc at position mm.
6408  !
6409  use blockpointers
6410  use monitor
6411  use flowvarrefstate
6412  use inputiteration
6413  implicit none
6414  !
6415  ! Subroutine arguments.
6416  !
6417  integer(kind=intType), intent(in) :: mm
6418  !
6419  ! Local variables.
6420  !
6421  integer(kind=intType) :: i, j, k, l
6422  real(kind=realtype) :: state_sum, ovv
6423 
6424  ! Loop over the number of owned cells of this block and
6425  ! accumulate the residual.
6426 
6427  do k = 2, kl
6428  do j = 2, jl
6429  do i = 2, il
6430  state_sum = 0.0
6431  ovv = one / vol(i, j, k)
6432  do l = 1, nwf
6433 #ifndef USE_COMPLEX
6434  state_sum = state_sum + (dw(i, j, k, l) * ovv)**2
6435 #else
6436  ! TODO squaring the complex residual when its order 1e-200 underflows and we need a better approach here
6437  ! we need to square and sum the real and complex parts separately
6438  state_sum = state_sum + &
6439  cmplx((real(dw(i, j, k, l) * ovv))**2, &
6440  (aimag(dw(i, j, k, l) * ovv))**2)
6441 #endif
6442  end do
6443  do l = nt1, nt2
6444  ! l-nt1+1 will index the turbResScale properly
6445 #ifndef USE_COMPLEX
6446  state_sum = state_sum + (dw(i, j, k, l) * ovv * turbresscale(l - nt1 + 1))**2
6447 #else
6448  ! we need to square and sum the real and complex parts separately
6449  state_sum = state_sum + &
6450  cmplx((real(dw(i, j, k, l) * ovv * turbresscale(l - nt1 + 1)))**2, &
6451  (aimag(dw(i, j, k, l) * ovv * turbresscale(l - nt1 + 1)))**2)
6452 #endif
6453  end do
6454  monloc(mm) = monloc(mm) + state_sum
6455  end do
6456  end do
6457  end do
6458 
6459  end subroutine sumallresiduals
6460 
6461  subroutine unsteadyheader
6462  !
6463  ! unsteadyHeader writes a header to stdout when a new time step
6464  ! is started.
6465  !
6466  use constants
6468  use commonformats, only: strings
6469  implicit none
6470  !
6471  ! Local variables
6472  !
6473  character(len=7) :: integerString
6474  character(len=12) :: realString
6475 
6476  ! Write the time step number to the integer string and the
6477  ! physical time to the real string.
6478 
6479  write (integerstring, "(i7)") timestepunsteady + ntimestepsrestart
6480  write (realstring, "(es12.5)") timeunsteady + timeunsteadyrestart
6481 
6482  integerstring = adjustl(integerstring)
6483  realstring = adjustl(realstring)
6484 
6485  ! Write the header to stdout.
6486 
6487  print "(a)", "#"
6488  print "(a)", "#**************************************************************************"
6489  print "(a)", "#"
6490  print strings, "# Unsteady time step ", trim(integerstring), ", physical time ", trim(realstring), " seconds"
6491  print "(a)", "#"
6492  print "(a)", "#**************************************************************************"
6493  print "(a)", "#"
6494 
6495  end subroutine unsteadyheader
6496 
6497  subroutine getcellcenters(level, n, xCen)
6498 
6499  use constants
6501  use blockpointers, only: ndom, il, jl, kl, x
6502 
6503  implicit none
6504 
6505  ! Input/Output
6506  integer(kind=intType), intent(in) :: level, n
6507  real(kind=realtype), dimension(3, n), intent(out) :: xcen
6508 
6509  ! Working
6510  integer(kind=intType) :: i, j, k, ii, nn, sps
6511 
6512  ii = 0
6513  do nn = 1, ndom
6514  do sps = 1, ntimeintervalsspectral
6515  call setpointers(nn, level, sps)
6516 
6517  do k = 2, kl
6518  do j = 2, jl
6519  do i = 2, il
6520  ii = ii + 1
6521 
6522  xcen(:, ii) = eighth * ( &
6523  x(i - 1, j - 1, k - 1, :) + &
6524  x(i, j - 1, k - 1, :) + &
6525  x(i - 1, j, k - 1, :) + &
6526  x(i, j, k - 1, :) + &
6527  x(i - 1, j - 1, k, :) + &
6528  x(i, j - 1, k, :) + &
6529  x(i - 1, j, k, :) + &
6530  x(i, j, k, :))
6531  end do
6532  end do
6533  end do
6534  end do
6535  end do
6536  end subroutine getcellcenters
6537 
6538  subroutine getcellcgnsblockids(level, n, cellID)
6539 
6540  use constants
6542  use blockpointers, only: ndom, il, jl, kl, nbkglobal
6543 
6544  implicit none
6545 
6546  ! Input/Output
6547  integer(kind=intType), intent(in) :: level, n
6548  real(kind=realtype), dimension(n), intent(out) :: cellid
6549 
6550  ! Working
6551  integer(kind=intType) :: i, j, k, ii, nn, sps
6552 
6553  ii = 0
6554  do nn = 1, ndom
6555  do sps = 1, ntimeintervalsspectral
6556  call setpointers(nn, level, sps)
6557 
6558  do k = 2, kl
6559  do j = 2, jl
6560  do i = 2, il
6561  ii = ii + 1
6562 
6563  cellid(ii) = nbkglobal
6564 
6565  end do
6566  end do
6567  end do
6568  end do
6569  end do
6570  end subroutine getcellcgnsblockids
6571 
6572  subroutine getncgnszones(nZones)
6573  use cgnsgrid
6574  implicit none
6575  integer(kind=inttype), intent(out) :: nZones
6576 
6577  nzones = cgnsndom
6578 
6579  end subroutine getncgnszones
6580 
6581  subroutine getcgnszonename(i, zone)
6582  use cgnsgrid
6583  implicit none
6584  character(len=maxCGNSNameLen), intent(out) :: zone
6585  integer(kind=intType), intent(in) :: i
6586 
6587  zone = cgnsdoms(i)%zoneName
6588 
6589  end subroutine getcgnszonename
6590 
6591  subroutine getrotmatrix(vec1, vec2, rotMat)
6592  !
6593  ! getRotmatrix computes and returns a rotation matrix that rotates
6594  ! the direction of vec1 to the direction of vec2. vec1 and vec2 are
6595  ! arrays of size 3, and the routine returns the dense 3 by 3 rotMat
6596  ! matrix. The vectors don't need to be normalized.
6597  !
6598  use constants
6599 
6600  implicit none
6601 
6602  real(kind=realtype), dimension(3), intent(in) :: vec1, vec2
6603  real(kind=realtype), dimension(3, 3), intent(out) :: rotmat
6604 
6605  integer(kind=intType) :: i
6606  real(kind=realtype), dimension(3) :: vec3
6607  real(kind=realtype), dimension(3, 3) :: wmat, wmat2
6608  real(kind=realtype) :: theta, dotprod, mag1, mag2, cosine
6609 
6610  ! first compute the angle between the two velocity vectors
6611  ! Compute the dot product of vec1 and vec2
6612  dotprod = zero
6613  do i = 1, 3
6614  dotprod = dotprod + vec1(i) * vec2(i)
6615  end do
6616 
6617  ! Compute the magnitude of vec1 and vec2
6618  mag1 = mynorm2(vec1)
6619  mag2 = mynorm2(vec2)
6620 
6621  ! Compute the cosine of the angle between vec1 and vec2
6622  cosine = dotprod / (mag1 * mag2)
6623 
6624  ! Compute the angle in radians
6625  theta = acos(cosine)
6626 
6627  ! then compute the normal vector of the rotation plane. This catches all changes in
6628  ! alpha and beta, and we don't need to keep track of the individual rotations and apply
6629  ! them in the same order.
6630 
6631  ! Compute the cross product of vec1 and vec2 to get vec3
6632  vec3(1) = vec1(2) * vec2(3) - vec1(3) * vec2(2)
6633  vec3(2) = vec1(3) * vec2(1) - vec1(1) * vec2(3)
6634  vec3(3) = vec1(1) * vec2(2) - vec1(2) * vec2(1)
6635  ! normalize
6636  vec3 = vec3 / sqrt(sum(vec3**2))
6637 
6638  ! compute the rotation matrix.
6639  ! for this, we use the "Rodrigues' Rotation Formula" as described here:
6640  ! https://mathworld.wolfram.com/RodriguesRotationFormula.html
6641  wmat = zero
6642  wmat2 = zero
6643  rotmat = zero
6644 
6645  ! compute Wmat and Wmat^2 first
6646  ! W is the multiplication of a 3D levi-civita tensor with vec3.
6647  ! we could do this in a loop but it takes more lines of code
6648  ! and is more difficult to understand. so just set the values
6649  wmat(1, 2) = -vec3(3)
6650  wmat(1, 3) = vec3(2)
6651  wmat(2, 1) = vec3(3)
6652  wmat(2, 3) = -vec3(1)
6653  wmat(3, 1) = -vec3(2)
6654  wmat(3, 2) = vec3(1)
6655  wmat2 = matmul(wmat, wmat)
6656 
6657  ! start with identity
6658  do i = 1, 3
6659  rotmat(i, i) = one
6660  end do
6661 
6662  ! add the W terms
6663  rotmat = rotmat + sin(theta) * wmat + (1.0 - cos(theta)) * wmat2
6664 
6665  end subroutine getrotmatrix
6666 
6667  real(kind=realtype) function norm2cplx(v)
6668  ! if input is real:
6669  ! returns the norm of the input array
6670  !
6671  ! if input is complex:
6672  ! returns a complex number where the real part represents the norm of
6673  ! all the real input parts and the complex part represents the norm of
6674  ! all the complex input parts.
6675 
6676  use constants
6677 
6678  implicit none
6679 
6680  real(kind=realtype), dimension(:), intent(in) :: v
6681 
6682 #ifdef USE_COMPLEX
6683  norm2cplx = cmplx(norm2(real(v)), norm2(aimag(v)))
6684 #else
6685  norm2cplx = norm2(v)
6686 #endif
6687 
6688  end function norm2cplx
6689 
6690 #endif
6691 end module utils
logical adjointpetscpreprocvarsallocated
logical derivvarsallocated
Definition: ADjointVars.F90:41
Definition: BCData.F90:1
real(kind=realtype), dimension(:, :), pointer rlv2
Definition: BCPointers.F90:12
real(kind=realtype), dimension(:, :), pointer gamma2
Definition: BCPointers.F90:14
real(kind=realtype), dimension(:, :), pointer rev0
Definition: BCPointers.F90:13
integer(kind=inttype), dimension(:, :), pointer gcp
Definition: BCPointers.F90:18
real(kind=realtype), dimension(:, :, :), pointer ww0
Definition: BCPointers.F90:10
real(kind=realtype), dimension(:, :), pointer dd2wall
Definition: BCPointers.F90:17
real(kind=realtype), dimension(:, :, :), pointer ssk
Definition: BCPointers.F90:15
real(kind=realtype), dimension(:, :), pointer pp3
Definition: BCPointers.F90:11
real(kind=realtype), dimension(:, :), pointer rlv0
Definition: BCPointers.F90:12
integer(kind=inttype) istart
Definition: BCPointers.F90:20
integer(kind=inttype) iend
Definition: BCPointers.F90:20
real(kind=realtype), dimension(:, :), pointer rlv1
Definition: BCPointers.F90:12
real(kind=realtype), dimension(:, :), pointer pp1
Definition: BCPointers.F90:11
real(kind=realtype), dimension(:, :), pointer pp0
Definition: BCPointers.F90:11
real(kind=realtype), dimension(:, :), pointer rev2
Definition: BCPointers.F90:13
real(kind=realtype), dimension(:, :, :), pointer ww3
Definition: BCPointers.F90:10
real(kind=realtype), dimension(:, :), pointer rev1
Definition: BCPointers.F90:13
integer(kind=inttype) jsize
Definition: BCPointers.F90:21
real(kind=realtype), dimension(:, :), pointer sface
Definition: BCPointers.F90:17
real(kind=realtype), dimension(:, :, :), pointer ssj
Definition: BCPointers.F90:15
integer(kind=inttype) jend
Definition: BCPointers.F90:21
real(kind=realtype), dimension(:, :), pointer rlv3
Definition: BCPointers.F90:12
real(kind=realtype), dimension(:, :, :), pointer ww1
Definition: BCPointers.F90:10
real(kind=realtype), dimension(:, :), pointer gamma3
Definition: BCPointers.F90:14
real(kind=realtype), dimension(:, :), pointer pp2
Definition: BCPointers.F90:11
real(kind=realtype), dimension(:, :, :), pointer xx
Definition: BCPointers.F90:16
integer(kind=inttype) jstart
Definition: BCPointers.F90:21
real(kind=realtype), dimension(:, :), pointer gamma1
Definition: BCPointers.F90:14
real(kind=realtype), dimension(:, :, :), pointer ww2
Definition: BCPointers.F90:10
integer(kind=inttype) isize
Definition: BCPointers.F90:20
real(kind=realtype), dimension(:, :, :), pointer ss
Definition: BCPointers.F90:16
real(kind=realtype), dimension(:, :), pointer gamma0
Definition: BCPointers.F90:14
real(kind=realtype), dimension(:, :), pointer rev3
Definition: BCPointers.F90:13
real(kind=realtype), dimension(:, :, :), pointer ssi
Definition: BCPointers.F90:15
Definition: block.F90:1
integer(kind=inttype) ndom
Definition: block.F90:761
type(blocktype), dimension(:, :, :), allocatable, target flowdomsd
Definition: block.F90:772
type(blocktype), dimension(:, :, :), allocatable, target flowdoms
Definition: block.F90:771
integer(kind=inttype), dimension(:), allocatable ncellglobal
Definition: block.F90:781
real(kind=realtype), dimension(:, :, :, :), pointer bmtk2
real(kind=realtype), dimension(:, :, :), pointer sfacek
real(kind=realtype), dimension(:, :, :, :, :), pointer pcmat
type(fringetype), dimension(:), pointer fringes
integer(kind=inttype), dimension(:), pointer djnbeg
real(kind=realtype), dimension(:, :, :, :, :), pointer skale
real(kind=realtype), dimension(:, :, :, :), pointer bmti1d
integer(kind=inttype), dimension(:, :), pointer viscjminpointer
integer(kind=inttype), dimension(:, :), pointer orphans
integer(kind=inttype), dimension(:), pointer dinend
real(kind=realtype), dimension(:, :, :, :), pointer w1
integer(kind=inttype), dimension(:, :), pointer mgjcoarse
real(kind=realtype), dimension(:, :, :, :), pointer i_u_fact
real(kind=realtype), dimension(:, :, :), pointer gamma
real(kind=realtype), dimension(:, :, :), pointer qz
real(kind=realtype), dimension(:, :, :, :), pointer volold
integer(kind=inttype) kendor
real(kind=realtype), dimension(:, :, :, :), pointer fwd
real(kind=realtype), dimension(:, :, :), pointer radid
real(kind=realtype), dimension(:, :, :, :), pointer sfacekale
logical addgridvelocities
integer(kind=inttype) jl
real(kind=realtype), dimension(:, :, :, :, :), pointer rotmatrixid
integer(kind=inttype) iendor
integer(kind=inttype) norphans
integer(kind=inttype), dimension(:), pointer knend
real(kind=realtype), dimension(:, :, :), pointer wzd
real(kind=realtype), dimension(:, :, :), pointer aad
real(kind=realtype), dimension(:, :, :), pointer radk
integer(kind=inttype), dimension(:), pointer inend
real(kind=realtype), dimension(:, :, :, :), pointer sfaceiale
integer(kind=portype), dimension(:, :, :), pointer pork
real(kind=realtype), dimension(:, :, :), pointer bvtk2d
integer(kind=inttype), dimension(:, :, :), pointer indfamilyj
integer(kind=inttype), dimension(:, :), pointer viscjmaxpointer
real(kind=realtype), dimension(:, :, :), pointer bvti2
integer(kind=inttype) jendor
integer(kind=inttype), dimension(:), pointer djnend
real(kind=realtype), dimension(:, :, :, :), pointer svelokale
integer(kind=inttype), dimension(:, :), pointer mgkcoarse
real(kind=realtype), dimension(:, :, :, :, :), pointer dwale
real(kind=realtype), dimension(:, :, :, :), pointer sjd
real(kind=realtype), dimension(:, :, :), pointer vxd
real(kind=realtype), dimension(:, :, :), pointer qy
real(kind=realtype), dimension(:, :, :), pointer aa
real(kind=realtype), dimension(:, :, :, :), pointer bmti1
real(kind=realtype), dimension(:, :, :), pointer uz
real(kind=realtype), dimension(:, :, :, :), pointer wd
real(kind=realtype), dimension(:, :, :), pointer uzd
integer(kind=inttype), dimension(:), pointer knbeg
real(kind=realtype), dimension(:, :, :, :), pointer bmtk2d
integer(kind=inttype) nviscbocos
integer(kind=inttype) kbegor
integer(kind=inttype), dimension(:, :, :), pointer factfamilyj
real(kind=realtype), dimension(:, :, :), pointer vold
logical blockismoving
real(kind=realtype), dimension(:, :, :), pointer bvtk1d
real(kind=realtype), dimension(:, :, :, :), pointer wr
logical righthanded
real(kind=realtype), dimension(:, :, :), pointer qxd
real(kind=realtype), dimension(:, :, :, :), pointer i_d_fact
real(kind=realtype), dimension(:, :, :, :), pointer bmtj1
integer(kind=inttype), dimension(:), pointer jnbeg
integer(kind=inttype), dimension(:, :), pointer mgifine
integer(kind=inttype), dimension(:, :, :, :), pointer i_ipiv
integer(kind=inttype) nx
real(kind=realtype), dimension(:, :, :, :), pointer bmti2
real(kind=realtype), dimension(:, :, :, :, :), pointer xold
integer(kind=inttype) spectralsol
real(kind=realtype), dimension(:, :, :), pointer p
real(kind=realtype), dimension(:, :, :), pointer radj
real(kind=realtype), dimension(:, :, :), pointer dtld
integer(kind=inttype) ny
real(kind=realtype), dimension(:, :, :, :), pointer i_u2_fact
integer(kind=inttype), dimension(:, :, :, :), pointer fringeptr
integer(kind=inttype) ie
real(kind=realtype), dimension(:, :, :, :), pointer k_d_fact
real(kind=realtype), dimension(:, :, :, :), pointer w
real(kind=realtype), dimension(:, :, :), pointer uy
integer(kind=inttype), dimension(:, :, :), pointer indfamilyk
real(kind=realtype), dimension(:, :, :, :), pointer scratch
real(kind=realtype), dimension(:, :, :), pointer sfacei
integer(kind=inttype), dimension(:, :, :, :), pointer j_ipiv
real(kind=realtype), dimension(:, :, :, :), pointer j_l_fact
type(viscsubfacetype), dimension(:), pointer viscsubface
integer(kind=inttype), dimension(:), pointer cgnssubface
integer(kind=inttype) nbklocal
integer(kind=portype), dimension(:, :, :), pointer porj
real(kind=realtype), dimension(:, :, :), pointer d2wall
integer(kind=inttype) mglevel
real(kind=realtype), dimension(:, :, :), pointer p1
integer(kind=inttype), dimension(:, :), pointer mgjfine
type(bcdatatype), dimension(:), pointer bcdatad
integer(kind=inttype), dimension(:), pointer neighblock
real(kind=realtype), dimension(:, :, :, :, :), pointer siale
real(kind=realtype), dimension(:, :, :), pointer wyd
real(kind=realtype), dimension(:, :, :), pointer revd
integer(kind=portype), dimension(:, :, :), pointer pori
real(kind=realtype), dimension(:, :, :), pointer bvtj2
integer(kind=inttype), dimension(:, :, :), pointer iblank
real(kind=realtype), dimension(:, :, :, :), pointer j_d_fact
real(kind=realtype), dimension(:, :, :, :, :), pointer sjale
real(kind=realtype), dimension(:, :, :, :, :), pointer fwale
real(kind=realtype), dimension(:, :, :), pointer wx
integer(kind=inttype), dimension(:), pointer kcend
integer(kind=inttype), dimension(:, :, :), pointer globalcell
real(kind=realtype), dimension(:, :, :, :), pointer j_u2_fact
real(kind=realtype), dimension(:, :, :, :), pointer svelojale
integer(kind=inttype), pointer ndonors
real(kind=realtype), dimension(:, :, :, :), pointer sfacejale
integer(kind=inttype), dimension(:), pointer neighproc
real(kind=realtype), dimension(:, :, :), pointer radjd
integer(kind=inttype) nbkglobal
real(kind=realtype), dimension(:, :, :, :), pointer wn
integer(kind=inttype), dimension(:, :), pointer viscimaxpointer
integer(kind=inttype), dimension(:), pointer jcend
real(kind=realtype), dimension(:, :, :), pointer bvtj1
real(kind=realtype), dimension(:, :, :, :), pointer skd
integer(kind=inttype) jb
real(kind=realtype), dimension(:, :, :), pointer bvti2d
real(kind=realtype), dimension(:, :, :, :), pointer bmtj2d
real(kind=realtype), dimension(:, :, :), pointer sfacejd
integer(kind=inttype), dimension(:, :), pointer mgicoarse
integer(kind=inttype) kb
real(kind=realtype), dimension(:, :, :), pointer rlv
integer(kind=inttype), dimension(:), pointer bcfaceid
integer(kind=inttype), dimension(:), pointer kcbeg
real(kind=realtype), dimension(:, :, :, :), pointer bmti2d
real(kind=realtype), dimension(:, :, :, :, :), pointer rotmatrixjd
real(kind=realtype), dimension(:, :, :, :, :), pointer dwoldrk
real(kind=realtype), dimension(:, :, :, :), pointer sveloiale
real(kind=realtype), dimension(:, :, :, :), pointer si
real(kind=realtype), dimension(:, :, :), pointer bvtj2d
real(kind=realtype), dimension(:, :, :), pointer bvtk2
real(kind=realtype), dimension(:, :, :, :), pointer sid
real(kind=realtype), dimension(:, :, :, :), pointer k_u2_fact
real(kind=realtype), dimension(:, :, :), pointer bvtj1d
real(kind=realtype), dimension(:, :, :), pointer radkd
integer(kind=inttype), dimension(:), pointer dknend
integer(kind=inttype), dimension(:), pointer groupnum
integer(kind=inttype) ibegor
integer(kind=inttype) nbocos
real(kind=realtype), dimension(:, :, :), pointer volref
integer(kind=inttype), dimension(:, :, :), pointer status
real(kind=realtype), dimension(:, :, :), pointer gammad
real(kind=realtype), dimension(:, :, :, :), pointer sj
integer(kind=inttype), dimension(:, :), pointer visckminpointer
integer(kind=inttype), dimension(:, :, :), pointer factfamilyi
real(kind=realtype), dimension(:, :, :), pointer uyd
integer(kind=inttype), dimension(:, :), pointer mgkfine
integer(kind=inttype) sectionid
real(kind=realtype), dimension(:, :, :, :), pointer s
real(kind=realtype), dimension(:, :, :), pointer qx
integer(kind=inttype), dimension(:, :, :), pointer factfamilyk
integer(kind=inttype) jbegor
real(kind=realtype), dimension(:, :, :, :), pointer scratchd
integer(kind=inttype), dimension(:, :, :), pointer globalnode
real(kind=realtype), dimension(:, :, :), pointer uxd
real(kind=realtype), dimension(:, :, :, :), pointer bmtj1d
real(kind=realtype), dimension(:, :, :), pointer vz
real(kind=realtype), dimension(:, :, :, :, :), pointer rotmatrixj
real(kind=realtype), dimension(:, :, :), pointer rev
real(kind=realtype), dimension(:, :, :), pointer qyd
integer(kind=inttype), dimension(:), pointer jnend
real(kind=realtype), dimension(:, :, :, :), pointer xale
real(kind=realtype), dimension(:, :, :, :), pointer bmtj2
integer(kind=inttype), dimension(:), pointer bctype
real(kind=realtype), dimension(:, :, :, :), pointer dw
real(kind=realtype), dimension(:, :, :, :), pointer sk
real(kind=realtype), dimension(:, :, :), pointer ux
real(kind=realtype), dimension(:, :, :), pointer shocksensor
integer(kind=inttype) n1to1
type(viscsubfacetype), dimension(:), pointer viscsubfaced
real(kind=realtype), dimension(:, :, :), pointer wy
integer(kind=inttype), dimension(:), pointer jcbeg
integer(kind=inttype), dimension(:), pointer l1
integer(kind=inttype) imaxdim
real(kind=realtype), dimension(:, :, :), pointer rlvd
real(kind=realtype), dimension(:), pointer mgkweight
real(kind=realtype), dimension(:, :, :), pointer wz
real(kind=realtype), dimension(:, :, :), pointer vol
real(kind=realtype), dimension(:, :, :), pointer filterdes
real(kind=realtype), dimension(:, :, :), pointer wxd
integer(kind=inttype) ib
real(kind=realtype), dimension(:), pointer mgiweight
real(kind=realtype), dimension(:, :, :), pointer dtl
real(kind=realtype), dimension(:, :, :, :), pointer xd
real(kind=realtype), dimension(:, :, :, :), pointer k_l_fact
real(kind=realtype), dimension(:, :, :), pointer sfacej
real(kind=realtype), dimension(:, :, :), pointer vy
real(kind=realtype), dimension(:, :, :, :), pointer fw
integer(kind=inttype) nz
integer(kind=inttype), dimension(:, :, :, :), pointer gind
real(kind=realtype), dimension(:, :, :), pointer vx
integer(kind=inttype), dimension(:, :, :), pointer forcedrecv
integer(kind=inttype), dimension(:, :, :), pointer wallind
integer(kind=inttype) je
integer(kind=inttype), dimension(:), pointer l3
real(kind=realtype), dimension(:, :, :), pointer radi
real(kind=realtype), dimension(:, :, :), pointer sfacekd
real(kind=realtype), dimension(:, :, :), pointer pn
real(kind=realtype), dimension(:, :, :, :), pointer pcvec1
real(kind=realtype), dimension(:, :, :, :), pointer j_u_fact
integer(kind=inttype), dimension(:), pointer dknbeg
integer(kind=inttype) ke
integer(kind=inttype), dimension(:, :, :), pointer indfamilyi
integer(kind=inttype), dimension(:), pointer dinbeg
integer(kind=inttype) nsubface
real(kind=realtype), dimension(:, :, :, :), pointer x
integer(kind=inttype), dimension(:, :), pointer visckmaxpointer
real(kind=realtype), dimension(:, :, :), pointer qzd
integer(kind=inttype) jmaxdim
real(kind=realtype), dimension(:), pointer mgjweight
real(kind=realtype), dimension(:, :, :, :), pointer i_l_fact
real(kind=realtype), dimension(:, :, :), pointer sfaceid
real(kind=realtype), dimension(:, :, :, :), pointer sd
real(kind=realtype), dimension(:, :, :, :), pointer xseed
real(kind=realtype), dimension(:, :, :), pointer d2walld
real(kind=realtype), dimension(:, :, :, :), pointer bmtk1
integer(kind=inttype), dimension(:), pointer inbeg
integer(kind=inttype), dimension(:, :), pointer visciminpointer
real(kind=realtype), dimension(:, :, :, :), pointer k_u_fact
real(kind=realtype), dimension(:, :, :), pointer vzd
real(kind=realtype), dimension(:, :, :), pointer pd
real(kind=realtype), dimension(:, :, :), pointer vyd
integer(kind=inttype), dimension(:), pointer icend
real(kind=realtype), dimension(:, :, :, :), pointer bmtk1d
real(kind=realtype), dimension(:, :, :, :, :), pointer rotmatrixkd
real(kind=realtype), dimension(:, :, :, :, :), pointer rotmatrixi
real(kind=realtype), dimension(:, :, :), pointer bvti1d
real(kind=realtype), dimension(:, :, :, :, :), pointer wold
integer(kind=inttype), dimension(:), pointer icbeg
real(kind=realtype), dimension(:, :, :, :), pointer dwd
real(kind=realtype), dimension(:, :, :), pointer bvti1
integer(kind=inttype), dimension(:, :, :, :), pointer k_ipiv
integer(kind=inttype), dimension(:), pointer l2
real(kind=realtype), dimension(:, :, :), pointer bvtk1
integer(kind=inttype) kl
real(kind=realtype), dimension(:, :, :), pointer skew
integer(kind=inttype) il
real(kind=realtype), dimension(:, :, :, :), pointer pcvec2
real(kind=realtype), dimension(:, :, :, :, :), pointer rotmatrixk
type(cgnsblockinfotype), dimension(:), allocatable cgnsdoms
Definition: cgnsGrid.F90:495
type(cgnsfamilytype), dimension(:), allocatable cgnsfamilies
Definition: cgnsGrid.F90:504
real(kind=realtype), dimension(:, :), allocatable massflowfamilydiss
Definition: cgnsGrid.F90:547
real(kind=realtype), dimension(:, :), allocatable massflowfamilyinv
Definition: cgnsGrid.F90:546
type(cgnsblockinfotype), dimension(:), allocatable cgnsdomsd
Definition: cgnsGrid.F90:496
integer(kind=inttype) cgnsndom
Definition: cgnsGrid.F90:491
character(len=maxcgnsnamelen), parameter cgnscl
Definition: cgnsNames.f90:235
character(len=maxcgnsnamelen), parameter cgnsl2resrho
Definition: cgnsNames.f90:208
character(len=maxcgnsnamelen), parameter cgnsmachmax
Definition: cgnsNames.f90:265
character(len=maxcgnsnamelen), parameter cgnsl2resmomy
Definition: cgnsNames.f90:212
character(len=maxcgnsnamelen), parameter cgnscmy
Definition: cgnsNames.f90:256
character(len=maxcgnsnamelen), parameter cgnsyplusmax
Definition: cgnsNames.f90:267
character(len=maxcgnsnamelen), parameter cgnsl2resk
Definition: cgnsNames.f90:220
character(len=maxcgnsnamelen), parameter cgnscmx
Definition: cgnsNames.f90:254
character(len=maxcgnsnamelen), parameter cgnscfy
Definition: cgnsNames.f90:250
character(len=maxcgnsnamelen), parameter cgnssepsensorksarea
Definition: cgnsNames.f90:280
character(len=maxcgnsnamelen), parameter cgnsl2resrhoe
Definition: cgnsNames.f90:216
character(len=maxcgnsnamelen), parameter cgnsaxismoment
Definition: cgnsNames.f90:282
character(len=maxcgnsnamelen), parameter cgnsl2resv2
Definition: cgnsNames.f90:228
character(len=maxcgnsnamelen), parameter cgnsl2resmomx
Definition: cgnsNames.f90:210
character(len=maxcgnsnamelen), parameter cgnsl2resmomz
Definition: cgnsNames.f90:214
character(len=maxcgnsnamelen), parameter cgnsl2resomega
Definition: cgnsNames.f90:222
character(len=maxcgnsnamelen), parameter cgnsl2restau
Definition: cgnsNames.f90:224
character(len=maxcgnsnamelen), parameter cgnsclv
Definition: cgnsNames.f90:239
character(len=maxcgnsnamelen), parameter cgnssepsensor
Definition: cgnsNames.f90:278
character(len=maxcgnsnamelen), parameter cgnsclp
Definition: cgnsNames.f90:237
character(len=maxcgnsnamelen), parameter cgnscmz
Definition: cgnsNames.f90:258
character(len=maxcgnsnamelen), parameter cgnscavitation
Definition: cgnsNames.f90:281
character(len=maxcgnsnamelen), parameter cgnseddymax
Definition: cgnsNames.f90:269
character(len=maxcgnsnamelen), parameter cgnsl2resf
Definition: cgnsNames.f90:230
character(len=maxcgnsnamelen), parameter cgnscd
Definition: cgnsNames.f90:241
character(len=maxcgnsnamelen), parameter cgnscfz
Definition: cgnsNames.f90:252
character(len=maxcgnsnamelen), parameter cgnscdp
Definition: cgnsNames.f90:243
character(len=maxcgnsnamelen), parameter cgnsl2resepsilon
Definition: cgnsNames.f90:226
character(len=maxcgnsnamelen), parameter cgnshdiffmax
Definition: cgnsNames.f90:263
character(len=maxcgnsnamelen), parameter cgnsl2resnu
Definition: cgnsNames.f90:218
character(len=maxcgnsnamelen), parameter cgnscdv
Definition: cgnsNames.f90:245
character(len=maxcgnsnamelen), parameter cgnscfx
Definition: cgnsNames.f90:248
character(len=maxstringlen) strings
integer(kind=inttype) recvbuffersizeover
integer(kind=inttype) sendbuffersize
real(kind=realtype), dimension(:), allocatable recvbuffer
real(kind=realtype), dimension(:), allocatable sendbuffer
type(internalcommtype), dimension(:), allocatable internalcell_1st
integer(kind=inttype) sendbuffersizeover
type(internalcommtype), dimension(:), allocatable internalcell_2nd
type(commtype), dimension(:, :), allocatable, target commpatternoverset
type(commtype), dimension(:), allocatable commpatterncell_1st
integer(kind=inttype) recvbuffersize
type(commtype), dimension(:), allocatable commpatterncell_2nd
type(commtype), dimension(:), allocatable commpatternnode_1st
integer(kind=inttype) sendbuffersize_1to1
type(internalcommtype), dimension(:), allocatable internalnode_1st
integer(kind=inttype) recvbuffersize_1to1
integer adflow_comm_world
integer(kind=inttype), parameter firstorder
Definition: constants.F90:142
integer(kind=inttype), parameter cptempcurvefits
Definition: constants.F90:124
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
real(kind=realtype), parameter eighth
Definition: constants.F90:84
integer, parameter irho
Definition: constants.F90:34
integer(kind=inttype), parameter nswalladiabatic
Definition: constants.F90:260
integer(kind=inttype), parameter symm
Definition: constants.F90:258
integer(kind=inttype), parameter timespectral
Definition: constants.F90:115
integer, parameter ivx
Definition: constants.F90:35
integer(kind=inttype), parameter unsteady
Definition: constants.F90:115
integer, parameter irhoe
Definition: constants.F90:38
integer(kind=inttype), parameter rungekutta
Definition: constants.F90:201
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
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(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, parameter ivy
Definition: constants.F90:36
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), dimension(:), allocatable winfd
real(kind=realtype) gammainf
integer(kind=inttype) nt1
real(kind=realtype) pinfdim
real(kind=realtype) pinfcorr
real(kind=realtype) pinf
integer(kind=inttype) nwf
real(kind=realtype), dimension(:), allocatable winf
integer(kind=inttype) nw
real(kind=realtype) lref
real(kind=realtype) rhoinf
real(kind=realtype) timeref
integer(kind=inttype) nt2
logical storeconvinneriter
Definition: inputParam.F90:166
integer(kind=inttype) smoother
Definition: inputParam.F90:264
logical useskewnesscheck
Definition: inputParam.F90:295
real(kind=realtype), dimension(4) turbresscale
Definition: inputParam.F90:293
integer(kind=inttype), dimension(:), allocatable cyclestrategy
Definition: inputParam.F90:273
logical printiterations
Definition: inputParam.F90:288
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(:), allocatable sepsenmaxfamily
Definition: inputParam.F90:609
real(kind=realtype), dimension(3) pointref
Definition: inputParam.F90:602
integer(kind=inttype) liftindex
Definition: inputParam.F90:592
logical walldistanceneeded
Definition: inputParam.F90:589
real(kind=realtype), dimension(3) dragdirection
Definition: inputParam.F90:601
real(kind=realtype), dimension(3) pointrefec
Definition: inputParam.F90:626
real(kind=realtype), dimension(:), allocatable cpmin_family
Definition: inputParam.F90:607
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
real(kind=realtype), dimension(:, :, :), allocatable rotmatrixspectral
Definition: inputParam.F90:695
integer(kind=inttype) ntimeintervalsspectral
Definition: inputParam.F90:645
logical useale
Definition: inputParam.F90:754
integer(kind=inttype) timeintegrationscheme
Definition: inputParam.F90:719
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
integer(kind=inttype) itertot
Definition: iteration.f90:31
type(kdtree2) function, pointer, public kdtree2_create(input_data, dim, sort, rearrange)
Definition: kd_tree.f90:588
subroutine, public kdtree2destroy(tp)
Definition: kd_tree.f90:979
subroutine, public kdtree2_r_nearest(tp, qv, r2, nfound, nalloc, results)
Definition: kd_tree.f90:1110
logical frompython
Definition: killSignals.f90:33
logical routinefailed
Definition: killSignals.f90:36
logical fatalfail
Definition: killSignals.f90:37
integer(kind=inttype) timestepunsteady
Definition: monitor.f90:97
integer nmon
Definition: monitor.f90:30
real(kind=cgnsrealtype), dimension(:), allocatable timearray
Definition: monitor.f90:107
real(kind=realtype), dimension(:), allocatable monloc
Definition: monitor.f90:39
logical monmachorhmax
Definition: monitor.f90:55
real(kind=realtype), dimension(:, :, :), allocatable solverdataarray
Definition: monitor.f90:77
real(kind=cgnsrealtype), dimension(:, :, :), allocatable convarray
Definition: monitor.f90:71
logical showcpu
Definition: monitor.f90:56
character(len=maxcgnsnamelen), dimension(:), allocatable monnames
Definition: monitor.f90:46
real(kind=realtype) timeunsteady
Definition: monitor.f90:98
real(kind=realtype) timeunsteadyrestart
Definition: monitor.f90:98
integer(kind=inttype) ntimestepsrestart
Definition: monitor.f90:97
integer, parameter fieldwidthlarge
Definition: monitor.f90:17
real(kind=realtype), dimension(:), allocatable monglob
Definition: monitor.f90:40
real(kind=realtype), dimension(:), allocatable monref
Definition: monitor.f90:41
real(kind=cgnsrealtype), dimension(:, :), allocatable timedataarray
Definition: monitor.f90:109
character(len=8), dimension(:, :), allocatable solvertypearray
Definition: monitor.f90:81
integer, parameter fieldwidth
Definition: monitor.f90:16
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 destroyfamilyexchange(exch)
type(familyexchange), dimension(:, :), allocatable, target bcfamexchange
Definition: utils.F90:1
subroutine silen(len, mult, trans)
Definition: utils.F90:1808
subroutine getcellcenters(level, n, xCen)
Definition: utils.F90:6498
real(kind=realtype) function tsmach(degreePolMach, coefPolMach, degreeFourMach, omegaFourMach, cosCoefFourMach, sinCoefFourMach, t)
Definition: utils.F90:159
subroutine setcoeftimeintegrator
Definition: utils.F90:1536
logical function iswalltype(bType)
Definition: utils.F90:1705
subroutine getsolvertypearray(niter, nsps, type_array)
Definition: utils.F90:5952
subroutine reallocateinteger2(intArray, newSize1, newSize2, oldSize1, oldSize2, alwaysFreeMem)
Definition: utils.F90:2913
real(kind=realtype) function tsalpha(degreePolAlpha, coefPolAlpha, degreeFourAlpha, omegaFourAlpha, cosCoefFourAlpha, sinCoefFourAlpha, t)
Definition: utils.F90:284
subroutine cross_prod(a, b, c)
Definition: utils.F90:1721
subroutine deallocateinternalcommtype(comm)
Definition: utils.F90:4561
subroutine setbcpointers(nn, spatialPointers)
Definition: utils.F90:882
subroutine reallocatereal2(realArray, newSize1, newSize2, oldSize1, oldSize2, alwaysFreeMem)
Definition: utils.F90:3049
subroutine reallocatempioffsetkindinteger(intArray, newSize, oldSize, alwaysFreeMem)
Definition: utils.F90:2847
subroutine alloctimearrays(nTimeTot)
Definition: utils.F90:5886
real(kind=realtype) function derivativerigidrotangle(degreePolRot, coefPolRot, degreeFourRot, omegaFourRot, cosCoefFourRot, sinCoefFourRot, t)
Definition: utils.F90:411
subroutine setbuffersizes(level, sps, determine1to1Buf, determineOversetBuf)
Definition: utils.F90:3123
subroutine deallocatetempmemory(resNeeded)
Definition: utils.F90:3834
subroutine sidensity(mass, len, mult, trans)
Definition: utils.F90:1773
subroutine setpointers_d(nn, level, sps)
Definition: utils.F90:3564
real(kind=realtype) function tsbeta(degreePolBeta, coefPolBeta, degreeFourBeta, omegaFourBeta, cosCoefFourBeta, sinCoefFourBeta, t)
Definition: utils.F90:34
subroutine computeleastsquaresregression(y, x, npts, m, b)
Definition: utils.F90:1219
subroutine getliftdirfromsymmetry(liftDir)
Definition: utils.F90:4006
subroutine returnfail(routineName, errorMessage)
Definition: utils.F90:5606
character(len=n) function char2str(charArray, n)
Definition: utils.F90:7
subroutine reallocatereal(realArray, newSize, oldSize, alwaysFreeMem)
Definition: utils.F90:2988
subroutine sumresiduals(nn, mm)
Definition: utils.F90:6365
subroutine maxhdiffmach(hdiffMax, MachMax)
Definition: utils.F90:2467
subroutine sumallresiduals(mm)
Definition: utils.F90:6405
subroutine stabilityderivativedriver
Definition: utils.F90:1518
real(kind=realtype) function norm2cplx(v)
Definition: utils.F90:6668
subroutine rotmatrixrigidbody(tNew, tOld, rotationMatrix, rotationPoint)
Definition: utils.F90:614
real(kind=realtype) function mynorm2(x)
Definition: utils.F90:1697
real(kind=realtype) function tsbetadot(degreePolBeta, coefPolBeta, degreeFourBeta, omegaFourBeta, cosCoefFourBeta, sinCoefFourBeta, t)
Definition: utils.F90:97
subroutine getmonitorvariablenames(nvar, monitor_variables)
Definition: utils.F90:5925
subroutine releasememorypart1
Definition: utils.F90:4254
subroutine getdirangle(freeStreamAxis, liftAxis, liftIndex, alpha, beta)
Definition: utils.F90:1428
subroutine writeintromessage
Definition: utils.F90:4095
subroutine sivelocity(length, time, mult, trans)
Definition: utils.F90:1984
subroutine computetsderivatives(force, moment, coef0, dcdalpha, dcdalphadot, dcdq, dcdqdot)
Definition: utils.F90:1254
logical function eulerwallspresent()
Definition: utils.F90:5784
subroutine releasememorypart2
Definition: utils.F90:4733
subroutine sitemperature(temp, mult, trans)
Definition: utils.F90:1886
real(kind=realtype) function rigidrotangle(degreePolRot, coefPolRot, degreeFourRot, omegaFourRot, cosCoefFourRot, sinCoefFourRot, t)
Definition: utils.F90:820
subroutine sipressure(mass, len, time, mult, trans)
Definition: utils.F90:1851
subroutine setbcpointers_d(nn, spatialpointers)
Definition: utils.F90:2049
subroutine allocatetempmemory(resNeeded)
Definition: utils.F90:3908
subroutine deallocderivativevalues(level)
Definition: utils.F90:4597
real(kind=realtype) function tsmachdot(degreePolMach, coefPolMach, degreeFourMach, omegaFourMach, cosCoefFourMach, sinCoefFourMach, t)
Definition: utils.F90:222
subroutine reallocateinteger(intArray, newSize, oldSize, alwaysFreeMem)
Definition: utils.F90:2783
subroutine getcgnszonename(i, zone)
Definition: utils.F90:6582
subroutine deallocateblock(nn, level, sps)
Definition: utils.F90:4824
subroutine getncgnszones(nZones)
Definition: utils.F90:6573
subroutine nullifyflowdompointers(nn, level, sps)
Definition: utils.F90:2580
subroutine pointreduce(pts, N, tol, uniquePts, link, nUnique)
Definition: utils.F90:4170
subroutine unsteadyheader
Definition: utils.F90:6462
subroutine echk(errorcode, file, line)
Definition: utils.F90:5722
subroutine setpointers_b(nn, level, sps)
Definition: utils.F90:3553
real(kind=realtype) function secondderivativerigidrotangle(degreePolRot, coefPolRot, degreeFourRot, omegaFourRot, cosCoefFourRot, sinCoefFourRot, t)
Definition: utils.F90:756
integer(kind=inttype) function delta(val1, val2)
Definition: utils.F90:2534
subroutine spectralinterpolcoef(nsps, t, alpScal, alpMat)
Definition: utils.F90:3668
subroutine siangle(angle, mult, trans)
Definition: utils.F90:1737
subroutine nullifycgnsdompointers(nn)
Definition: utils.F90:2560
logical function getcorrectfork()
Definition: utils.F90:487
real(kind=realtype) function tsalphadot(degreePolAlpha, coefPolAlpha, degreeFourAlpha, omegaFourAlpha, cosCoefFourAlpha, sinCoefFourAlpha, t)
Definition: utils.F90:346
subroutine siturb(mass, len, time, temp, turbName, mult, trans)
Definition: utils.F90:1947
real(kind=realtype) function mydim(x, y)
Definition: utils.F90:473
subroutine deallocatecommtype(comm)
Definition: utils.F90:4487
integer function setcgnsrealtype()
Definition: utils.F90:5578
subroutine setpointers(nn, mm, ll)
Definition: utils.F90:3237
subroutine allocconvarrays(nIterTot)
Definition: utils.F90:5830
subroutine maxeddyv(eddyvisMax)
Definition: utils.F90:2423
subroutine computerootbendingmoment(cf, cm, bendingMoment)
Definition: utils.F90:1177
subroutine convergenceheader
Definition: utils.F90:5984
subroutine getrotmatrix(vec1, vec2, rotMat)
Definition: utils.F90:6592
subroutine converttolowercase(string)
Definition: utils.F90:5756
subroutine getcellcgnsblockids(level, n, cellID)
Definition: utils.F90:6539
subroutine terminate(routineName, errorMessage)
Definition: utils.F90:502