44 integer(kind=intType) :: sps, nn, mm, ierr
45 real(kind=realtype) :: gm1, ratio
46 real(kind=realtype) :: nuinf, ktmp, uinf2
47 real(kind=realtype) :: vinf, zinf, tmp1(1), tmp2(1)
96 if (
allocated(
winf))
deallocate (
winf)
97 allocate (
winf(
nw), stat=ierr)
207 real(kind=realtype),
intent(in),
dimension(nwf) :: oldwinf
208 real(kind=realtype),
intent(in) :: correctiontol
209 character*(*),
intent(in) :: correctionType
210 integer(kind=intType) :: sps, nn, i, j, k, l
211 real(kind=realtype) :: deltawinf(
nwf)
214 real(kind=realtype),
dimension(3) :: vec1, vec2, vcell
215 real(kind=realtype),
dimension(3, 3) :: rotmat
216 real(kind=realtype) :: mag1, mag2
226 if (
mynorm2(deltawinf) < correctiontol)
then
236 if (correctiontype .eq.
"offset")
then
246 w(i, j, k, l) =
w(i, j, k, l) + deltawinf(l)
255 else if (correctiontype .eq.
"rotate")
then
280 w(i, j, k,
ivx:
ivz) = matmul(rotmat, vcell)
362 integer(kind=intType) :: sps, level, nLevels
389 do level = 2, nlevels
422 integer(kind=intType),
intent(in) :: sps, level
428 integer(kind=intType) :: nn
429 integer(kind=intType) :: il, jl, kl, ie, je, ke, ib, jb, kb
433 domains:
do nn = 1,
ndom
456 allocate (
flowdoms(nn, level, sps)%w(0:ib, 0:jb, 0:kb, 1:
nw), &
459 allocate (
flowdoms(nn, level, sps)%w(0:ib, 0:jb, 0:kb, 1:
nwf), &
464 "Memory allocation failure for w")
467 allocate (
flowdoms(nn, level, sps)%ux(il, jl, kl), stat=ierr)
468 allocate (
flowdoms(nn, level, sps)%uy(il, jl, kl), stat=ierr)
469 allocate (
flowdoms(nn, level, sps)%uz(il, jl, kl), stat=ierr)
471 allocate (
flowdoms(nn, level, sps)%vx(il, jl, kl), stat=ierr)
472 allocate (
flowdoms(nn, level, sps)%vy(il, jl, kl), stat=ierr)
473 allocate (
flowdoms(nn, level, sps)%vz(il, jl, kl), stat=ierr)
475 allocate (
flowdoms(nn, level, sps)%wx(il, jl, kl), stat=ierr)
476 allocate (
flowdoms(nn, level, sps)%wy(il, jl, kl), stat=ierr)
477 allocate (
flowdoms(nn, level, sps)%wz(il, jl, kl), stat=ierr)
479 allocate (
flowdoms(nn, level, sps)%qx(il, jl, kl), stat=ierr)
480 allocate (
flowdoms(nn, level, sps)%qy(il, jl, kl), stat=ierr)
481 allocate (
flowdoms(nn, level, sps)%qz(il, jl, kl), stat=ierr)
484 allocate (
flowdoms(nn, level, sps)%p(0:ib, 0:jb, 0:kb), stat=ierr)
487 "Memory allocation failure for p")
490 allocate (
flowdoms(nn, level, sps)%aa(0:ib, 0:jb, 0:kb), stat=ierr)
493 "Memory allocation failure for p")
502 allocate (
flowdoms(nn, level, sps)%rev(0:ib, 0:jb, 0:kb), &
507 "Memory allocation failure for rev")
512 fineleveltest:
if (level == 1)
then
517 allocate (
flowdoms(nn, level, sps)%gamma(0:ib, 0:jb, 0:kb), &
521 "Memory allocation failure for gamma.")
528 allocate (
flowdoms(nn, level, sps)%rlv(0:ib, 0:jb, 0:kb), &
532 "Memory allocation failure for rlv")
544 "Memory allocation failure for wOld")
559 "Memory allocation failure for wOld")
571 sps1ranstest:
if (sps == 1)
then
587 "Memory allocation failure for bmti1, etc")
624 integer(kind=intType),
intent(in) :: sps, level
630 integer(kind=intType) :: nn, mm
631 integer(kind=intType) :: il, jl, kl, ie, je, ke, ib, jb, kb
635 domains:
do nn = 1,
ndom
654 allocate (
flowdoms(nn, level, sps)%s(ie, je, ke, 3), &
655 flowdoms(nn, level, sps)%sFaceI(0:ie, je, ke), &
656 flowdoms(nn, level, sps)%sFaceJ(ie, 0:je, ke), &
657 flowdoms(nn, level, sps)%sFaceK(ie, je, 0:ke), stat=ierr)
660 "Memory allocation failure for s, &
661 &sFaceI, sFaceJ and sFaceK.")
666 flowdoms(nn, level, sps)%sVeloIALE(0:ie, je, ke, 3), &
667 flowdoms(nn, level, sps)%sVeloJALE(ie, 0:je, ke, 3), &
668 flowdoms(nn, level, sps)%sVeloKALE(ie, je, 0:ke, 3), &
674 "Memory allocation failure for &
675 &sVeloIALE, sVeloJALE and sVeloKALE; &
676 &sFaceIALE, sFaceJALE and sFaceKALE.")
681 fineleveltest:
if (level == 1)
then
686 flowdoms(nn, level, sps)%dw(0:ib, 0:jb, 0:kb, 1:
nw), &
687 flowdoms(nn, level, sps)%fw(0:ib, 0:jb, 0:kb, 1:
nwf), &
688 flowdoms(nn, level, sps)%dtl(1:ie, 1:je, 1:ke), &
689 flowdoms(nn, level, sps)%radI(1:ie, 1:je, 1:ke), &
690 flowdoms(nn, level, sps)%radJ(1:ie, 1:je, 1:ke), &
691 flowdoms(nn, level, sps)%radK(1:ie, 1:je, 1:ke), &
692 flowdoms(nn, level, sps)%scratch(0:ib, 0:jb, 0:kb, 10), &
693 flowdoms(nn, level, sps)%shockSensor(0:ib, 0:jb, 0:kb), &
697 "Memory allocation failure for dw, fw, dwOld, fwOld, &
698 &gamma, dtl and the spectral radii.")
713 "Memory allocation failure for dwALE, fwALE.")
720 allocate (
flowdoms(nn, level, sps)%wn(2:il, 2:jl, 2:kl, 1:
nwf), &
721 flowdoms(nn, level, sps)%pn(2:il, 2:jl, 2:kl), stat=ierr)
724 "Memory allocation failure for wn and pn")
733 allocate (
flowdoms(nn, level, sps)%dwOldRK(mm, il, jl, kl,
nw), &
737 "Memory allocation failure for dwOldRK.")
745 allocate (
flowdoms(nn, level, sps)%p1(1:ie, 1:je, 1:ke), &
746 flowdoms(nn, level, sps)%w1(1:ie, 1:je, 1:ke, 1:
nwf), &
747 flowdoms(nn, level, sps)%wr(2:il, 2:jl, 2:kl, 1:
nwf), &
751 "Memory allocation failure for p1, w1 &
780 integer(kind=intType) :: nFiles
793 "Memory allocation failure for restartFiles")
820 integer(kind=intType) :: sps, spsm1, mm, nn, i, j, k, l
822 real(kind=realtype) :: dt, tnew, told, tmp
823 real(kind=realtype) :: theta, costheta, sintheta
825 real(kind=realtype),
dimension(3) :: rotpoint, uu
826 real(kind=realtype),
dimension(3) :: xt, yt, zt
827 real(kind=realtype),
dimension(3, 3) :: rotmat
829 real(kind=realtype),
dimension(nSections, 3, 3) :: rotmatsec
838 testrotating:
if (
sections(nn)%rotating)
then
844 theta =
two *
pi / real(i, realtype)
845 costheta = cos(theta)
846 sintheta = sin(theta)
858 if (abs(xt(2)) < 0.707107_realtype)
then
870 tmp = xt(1) * yt(1) + xt(2) * yt(2) + xt(3) * yt(3)
871 yt(1) = yt(1) - tmp * xt(1)
872 yt(2) = yt(2) - tmp * xt(2)
873 yt(3) = yt(3) - tmp * xt(3)
877 tmp =
one / sqrt(yt(1)**2 + yt(2)**2 + yt(3)**2)
884 zt(1) = xt(2) * yt(3) - xt(3) * yt(2)
885 zt(2) = xt(3) * yt(1) - xt(1) * yt(3)
886 zt(3) = xt(1) * yt(2) - xt(2) * yt(1)
900 rotmatsec(nn, 1, 1) = xt(1) * xt(1) &
901 + costheta * (yt(1) * yt(1) + zt(1) * zt(1))
902 rotmatsec(nn, 1, 2) = xt(1) * xt(2) &
903 + costheta * (yt(1) * yt(2) + zt(1) * zt(2)) &
904 - sintheta * (yt(1) * zt(2) - yt(2) * zt(1))
905 rotmatsec(nn, 1, 3) = xt(1) * xt(3) &
906 + costheta * (yt(1) * yt(3) + zt(1) * zt(3)) &
907 - sintheta * (yt(1) * zt(3) - yt(3) * zt(1))
909 rotmatsec(nn, 2, 1) = xt(1) * xt(2) &
910 + costheta * (yt(1) * yt(2) + zt(1) * zt(2)) &
911 + sintheta * (yt(1) * zt(2) - yt(2) * zt(1))
912 rotmatsec(nn, 2, 2) = xt(2) * xt(2) &
913 + costheta * (yt(2) * yt(2) + zt(2) * zt(2))
914 rotmatsec(nn, 2, 3) = xt(2) * xt(3) &
915 + costheta * (yt(2) * yt(3) + zt(2) * zt(3)) &
916 - sintheta * (yt(2) * zt(3) - yt(3) * zt(2))
918 rotmatsec(nn, 3, 1) = xt(1) * xt(3) &
919 + costheta * (yt(1) * yt(3) + zt(1) * zt(3)) &
920 + sintheta * (yt(1) * zt(3) - yt(3) * zt(1))
921 rotmatsec(nn, 3, 2) = xt(2) * xt(3) &
922 + costheta * (yt(2) * yt(3) + zt(2) * zt(3)) &
923 + sintheta * (yt(2) * zt(3) - yt(3) * zt(2))
924 rotmatsec(nn, 3, 3) = xt(3) * xt(3) &
925 + costheta * (yt(3) * yt(3) + zt(3) * zt(3))
932 rotmatsec(nn, 1, 1) =
one
933 rotmatsec(nn, 1, 2) =
zero
934 rotmatsec(nn, 1, 3) =
zero
936 rotmatsec(nn, 2, 1) =
zero
937 rotmatsec(nn, 2, 2) =
one
938 rotmatsec(nn, 2, 3) =
zero
940 rotmatsec(nn, 3, 1) =
zero
941 rotmatsec(nn, 3, 2) =
zero
942 rotmatsec(nn, 3, 3) =
one
981 domains:
do nn = 1,
ndom
999 iovar(nn, sps)%w(i, j, k, l) =
iovar(nn, spsm1)%w(i, j, k, l)
1005 uu(1) = rotmat(1, 1) *
iovar(nn, sps)%w(i, j, k,
ivx) &
1006 + rotmat(1, 2) *
iovar(nn, sps)%w(i, j, k,
ivy) &
1007 + rotmat(1, 3) *
iovar(nn, sps)%w(i, j, k,
ivz)
1009 uu(2) = rotmat(2, 1) *
iovar(nn, sps)%w(i, j, k,
ivx) &
1010 + rotmat(2, 2) *
iovar(nn, sps)%w(i, j, k,
ivy) &
1011 + rotmat(2, 3) *
iovar(nn, sps)%w(i, j, k,
ivz)
1013 uu(3) = rotmat(3, 1) *
iovar(nn, sps)%w(i, j, k,
ivx) &
1014 + rotmat(3, 2) *
iovar(nn, sps)%w(i, j, k,
ivy) &
1015 + rotmat(3, 3) *
iovar(nn, sps)%w(i, j, k,
ivz)
1020 iovar(nn, sps)%w(i, j, k,
ivx) = rotmatsec(mm, 1, 1) * uu(1) &
1021 + rotmatsec(mm, 1, 2) * uu(2) &
1022 + rotmatsec(mm, 1, 3) * uu(3)
1024 iovar(nn, sps)%w(i, j, k,
ivy) = rotmatsec(mm, 2, 1) * uu(1) &
1025 + rotmatsec(mm, 2, 2) * uu(2) &
1026 + rotmatsec(mm, 2, 3) * uu(3)
1028 iovar(nn, sps)%w(i, j, k,
ivz) = rotmatsec(mm, 3, 1) * uu(1) &
1029 + rotmatsec(mm, 3, 2) * uu(2) &
1030 + rotmatsec(mm, 3, 3) * uu(3)
1070 integer(kind=intType) :: ii, nn
1072 character(len=7) :: integerString
1073 character(len=maxStringLen) :: tmpName
1095 call terminate(
"determineSolFileNames", &
1096 "Memory allocation failure for solFiles")
1122 print
"(a)",
"# Warning"
1123 print
"(a)",
"# Not enough data found for a consistent &
1124 &time accurate restart."
1125 print
"(a)",
"# Order is reduced in the first time steps &
1126 &until enough data is available again."
1179 integer(kind=intType) :: nn
1187 call terminate(
"determineSolFileNames", &
1188 "Memory allocation failure for solFiles")
1212 character(len=maxStringLen) :: errorMessage
1213 integer(kind=intType) :: nn
1216 open (unit=21, file=
solfiles(nn), status=
"old", iostat=ierr)
1218 write (errormessage, *)
"Restart file ", trim(
solfiles(nn)), &
1219 " could not be opened for reading"
1220 call terminate(
"checkSolFileNames", errormessage)
1263 logical,
intent(in) :: halosRead
1267 integer(kind=intType) :: nn, mm
1268 real(kind=realtype) :: relaxbleedsor
1270 real(kind=realtype),
dimension(nSections) :: t
1272 logical :: initBleeds
1279 initbleeds = .false.
1301 t(nn) = t(nn) + (mm - 1) *
sections(nn)%timePeriod &
1408 integer(kind=intType) :: ierr
1438 "Deallocation failure for solFiles and IOVar")
1474 integer(kind=intType) :: nn
1523 logical,
intent(in) :: halosRead
1527 integer(kind=intType) :: nn, mm, i, j, k, l
1528 integer(kind=intType) :: jj, kk
1533 domains:
do nn = 1, ndom
1541 testhalosread:
if (halosread)
then
1549 kk = max(1_inttype, min(k,
ke))
1551 jj = max(1_inttype, min(j,
je))
1554 w(0, j, k, l) =
w(1, jj, kk, l)
1555 w(
ib, j, k, l) =
w(
ie, jj, kk, l)
1558 p(0, j, k) =
p(1, jj, kk)
1559 p(
ib, j, k) =
p(
ie, jj, kk)
1568 kk = max(1_inttype, min(k,
ke))
1572 w(i, 0, k, l) =
w(i, 1, kk, l)
1573 w(i,
jb, k, l) =
w(i,
je, kk, l)
1576 p(i, 0, k) =
p(i, 1, kk)
1577 p(i,
jb, k) =
p(i,
je, kk)
1589 w(i, j, 0, l) =
w(i, j, 1, l)
1590 w(i, j,
kb, l) =
w(i, j,
ke, l)
1593 p(i, j, 0) =
p(i, j, 1)
1594 p(i, j,
kb) =
p(i, j,
ke)
1607 kk = max(2_inttype, min(k,
kl))
1609 jj = max(2_inttype, min(j,
jl))
1612 w(0, j, k, l) =
w(2, jj, kk, l)
1613 w(1, j, k, l) =
w(2, jj, kk, l)
1614 w(
ie, j, k, l) =
w(
il, jj, kk, l)
1615 w(
ib, j, k, l) =
w(
il, jj, kk, l)
1618 p(0, j, k) =
p(2, jj, kk)
1619 p(1, j, k) =
p(2, jj, kk)
1620 p(
ie, j, k) =
p(
il, jj, kk)
1621 p(
ib, j, k) =
p(
il, jj, kk)
1630 kk = max(2_inttype, min(k,
kl))
1634 w(i, 0, k, l) =
w(i, 2, kk, l)
1635 w(i, 1, k, l) =
w(i, 2, kk, l)
1636 w(i,
je, k, l) =
w(i,
jl, kk, l)
1637 w(i,
jb, k, l) =
w(i,
jl, kk, l)
1640 p(i, 0, k) =
p(i, 2, kk)
1641 p(i, 1, k) =
p(i, 2, kk)
1642 p(i,
je, k) =
p(i,
jl, kk)
1643 p(i,
jb, k) =
p(i,
jl, kk)
1655 w(i, j, 0, l) =
w(i, j, 2, l)
1656 w(i, j, 1, l) =
w(i, j, 2, l)
1657 w(i, j,
ke, l) =
w(i, j,
kl, l)
1658 w(i, j,
kb, l) =
w(i, j,
kl, l)
1661 p(i, j, 0) =
p(i, j, 2)
1662 p(i, j, 1) =
p(i, j, 2)
1663 p(i, j,
ke) =
p(i, j,
kl)
1664 p(i, j,
kb) =
p(i, j,
kl)
1669 end if testhalosread
1705 integer(kind=intType) :: jj, nn, ll, sps, i, j, k, l
1707 real(kind=realtype) :: t
1709 real(kind=realtype),
dimension(nSolsRead) :: alpscal
1710 real(kind=realtype),
dimension(nSections, nSolsRead, 3, 3) :: alpmat
1729 domains:
do nn = 1, ndom
1737 varloop:
do l = 1,
nw
1741 veltest:
if (l ==
ivx .or. l ==
ivy .or. l ==
ivz)
then
1768 w(i, j, k, l) =
zero
1770 w(i, j, k, l) =
w(i, j, k, l) &
1796 w(i, j, k, l) =
zero
1798 w(i, j, k, l) =
w(i, j, k, l) &
1799 + alpscal(jj) *
iovar(nn, jj)%w(i, j, k, l)
1818 deallocate (
iovar(nn, sps)%w, stat=ierr)
1820 call terminate(
"interpolateSpectralSolution", &
1821 "Deallocation failure for w.")
1844 integer(kind=intType) :: mm, nn, sps, level, nLevels, ii
1848 nlevels = ubound(flowdoms, 2)
1853 levelloop:
do level = 1, nlevels
1855 domainsloop:
do nn = 1, ndom
1864 bocoloop:
do mm = 1,
nbocos
1868 inflowtype:
select case(
bctype(mm))
1879 flowdoms(nn, 1, sps)%BCData(mm)%subsonicInletTreatment
1894 "Deallocation failure for rho, &
1895 &velx, vely and velz")
1898 nullify (
bcdata(mm)%velx)
1899 nullify (
bcdata(mm)%vely)
1900 nullify (
bcdata(mm)%velz)
1910 deallocate (
bcdata(mm)%ptInlet, &
1913 bcdata(mm)%flowXdirInlet, &
1914 bcdata(mm)%flowYdirInlet, &
1915 bcdata(mm)%flowZdirInlet, stat=ierr)
1918 "Deallocation failure for the &
1919 &total conditions.")
1921 nullify (
bcdata(mm)%ptInlet)
1922 nullify (
bcdata(mm)%ttInlet)
1923 nullify (
bcdata(mm)%htInlet)
1924 nullify (
bcdata(mm)%flowXdirInlet)
1925 nullify (
bcdata(mm)%flowYdirInlet)
1926 nullify (
bcdata(mm)%flowZdirInlet)
1930 end select inflowtype
1961 integer(kind=intType) :: nn, mm, il, jl, kl
1968 "Memory allocation failure for solRead")
1982 iovar(nn, 1)%pointerOffset = 0
1997 iovar(nn, 1)%pointerOffset = 0
2001 iovar(nn, mm)%pointerOffset = -1
2002 iovar(nn, mm)%w =>
flowdoms(nn, 1, 1)%wOld(mm - 1, 2:, 2:, 2:, :)
2028 iovar(nn, mm)%pointerOffset = 0
2030 allocate (
iovar(nn, mm)%w(2:il, 2:jl, 2:kl,
nw), stat=ierr)
2033 "Memory allocation failure for w")
2038 else testallocsolread
2046 iovar(nn, mm)%pointerOffset = 0
2051 end if testallocsolread
2075 logical,
intent(in) :: halosRead
2079 integer(kind=intType) :: sps, nn, nHalo
2080 integer(kind=intType) :: i, j, k
2081 integer(kind=intType) :: iBeg, iEnd, jBeg, jEnd, kBeg, kEnd
2087 if (halosread) nhalo = 1
2104 ibeg = 2 - nhalo; jbeg = 2 - nhalo; kbeg = 2 - nhalo
2105 iend =
il + nhalo; jend =
jl + nhalo; kend =
kl + nhalo
2112 p(i, j, k) =
w(i, j, k,
irhoe)
2135 character(len=*),
intent(inout) :: fileName
2136 integer(kind=intType) :: i
2163 integer(kind=intType) :: nn, mm, i, j, k, l
2165 real(kind=realtype) :: tmp
2167 real(kind=realtype),
dimension(3) :: dirloc, dirglob
2171 domains:
do nn = 1, ndom
2182 w(i, j, k, l) =
winf(l)
2232 domainloop1:
do nn = 1, ndom
2250 call mpi_allreduce(dirloc, dirglob, 3, adflow_real, mpi_sum, &
2253 tmp =
one / max(
eps, sqrt(dirglob(1)**2 &
2256 dirglob(1) = tmp * dirglob(1)
2257 dirglob(2) = tmp * dirglob(2)
2258 dirglob(3) = tmp * dirglob(3)
2263 domainsloop2:
do nn = 1, ndom
2272 tmp = sqrt(
w(i, j, k,
ivx)**2 &
2273 +
w(i, j, k,
ivy)**2 &
2274 +
w(i, j, k,
ivz)**2)
2275 w(i, j, k,
ivx) = tmp * dirglob(1)
2276 w(i, j, k,
ivy) = tmp * dirglob(2)
2277 w(i, j, k,
ivz) = tmp * dirglob(3)
2283 end do spectralloopcorr
2285 end if testcorrection
2303 integer(kind=intType),
intent(in) :: mm
2305 real(kind=realtype),
intent(out) :: vmag
2306 real(kind=realtype),
dimension(3),
intent(inout) :: dir
2312 integer(kind=intType) :: i, j
2313 real(kind=realtype) :: vel
2321 if (
associated(
bcdata(mm)%velx) .and. &
2322 associated(
bcdata(mm)%vely) .and. &
2323 associated(
bcdata(mm)%velz))
then
2334 vel = sqrt(
bcdata(mm)%velx(i, j)**2 &
2335 +
bcdata(mm)%vely(i, j)**2 &
2336 +
bcdata(mm)%velz(i, j)**2)
2337 vmag = max(vmag, vel)
2341 vel =
one / max(
eps, vel)
2342 dir(1) = dir(1) + vel *
bcdata(mm)%velx(i, j)
2343 dir(2) = dir(2) + vel *
bcdata(mm)%vely(i, j)
2344 dir(3) = dir(3) + vel *
bcdata(mm)%velz(i, j)
2352 if (
associated(
bcdata(mm)%flowXdirInlet) .and. &
2353 associated(
bcdata(mm)%flowYdirInlet) .and. &
2354 associated(
bcdata(mm)%flowZdirInlet))
then
2363 dir(1) = dir(1) +
bcdata(mm)%flowXdirInlet(i, j)
2364 dir(2) = dir(2) +
bcdata(mm)%flowYdirInlet(i, j)
2365 dir(3) = dir(3) +
bcdata(mm)%flowZdirInlet(i, j)
2374 diagMatCoefSpectral)
2392 real(kind=realtype), &
2393 dimension(nSections, nTimeIntervalsSpectral - 1), &
2394 intent(out) :: coefspectral
2395 real(kind=realtype), &
2396 dimension(nSections, nTimeIntervalsSpectral - 1, 3, 3), &
2397 intent(out) :: matrixcoefspectral
2398 real(kind=realtype),
dimension(nSections, 3, 3), &
2399 intent(out) :: diagmatcoefspectral
2403 integer(kind=intType) :: pp, nn, mm, ii, i, j, ntot
2404 real(kind=realtype) :: coef, dangle, angle, fact, slicesfact
2406 real(kind=realtype),
dimension(3, 3) :: rotmat, tmp
2430 coefspectral(mm, nn) = coef / sin(angle)
2433 coefspectral(mm, nn) = coefspectral(mm, nn) * cos(angle)
2446 dangle =
pi / real(ntot, realtype)
2450 rotmat(1, 1) =
one; rotmat(1, 2) =
zero; rotmat(1, 3) =
zero
2451 rotmat(2, 1) =
zero; rotmat(2, 2) =
one; rotmat(2, 3) =
zero
2452 rotmat(3, 1) =
zero; rotmat(3, 2) =
zero; rotmat(3, 3) =
one
2460 slicesfact =
one / real(
sections(mm)%nSlices, realtype)
2470 coef =
one / sin(angle)
2472 if (mod(ntot, 2_inttype) == 0) &
2473 coef = coef * cos(angle)
2475 coef = coef * fact * slicesfact
2481 matrixcoefspectral(mm, nn, 1, 1) = coef
2482 matrixcoefspectral(mm, nn, 1, 2) =
zero
2483 matrixcoefspectral(mm, nn, 1, 3) =
zero
2485 matrixcoefspectral(mm, nn, 2, 1) =
zero
2486 matrixcoefspectral(mm, nn, 2, 2) = coef
2487 matrixcoefspectral(mm, nn, 2, 3) =
zero
2489 matrixcoefspectral(mm, nn, 3, 1) =
zero
2490 matrixcoefspectral(mm, nn, 3, 2) =
zero
2491 matrixcoefspectral(mm, nn, 3, 3) = coef
2504 diagmatcoefspectral(mm, i, j) =
zero
2513 slicesloop:
do pp = 1, (
sections(mm)%nSlices - 1)
2529 slicesfact =
one / real(
sections(mm)%nSlices, realtype)
2540 slicesfact = fact * slicesfact
2550 angle = (nn + ii) * dangle
2551 coef =
one / sin(angle)
2553 if (mod(ntot, 2_inttype) == 0) &
2554 coef = coef * cos(angle)
2556 coef = coef * fact * slicesfact
2562 matrixcoefspectral(mm, nn, i, j) = &
2563 matrixcoefspectral(mm, nn, i, j) + coef * rotmat(i, j)
2575 coef =
one / sin(angle)
2577 if (mod(ntot, 2_inttype) == 0) &
2578 coef = coef * cos(angle)
2580 coef = coef * slicesfact
2584 diagmatcoefspectral(mm, i, j) = &
2585 diagmatcoefspectral(mm, i, j) - coef * rotmat(i, j)
2598 diagmatcoefspectral(mm, i, j) = &
2599 coef * diagmatcoefspectral(mm, i, j)
2607 matrixcoefspectral(mm, nn, i, j) = &
2608 coef * matrixcoefspectral(mm, nn, i, j)
2640 integer(kind=intType) :: nn, mm, ll, kk, ii
2641 integer(kind=intType) :: i, j
2643 real(kind=realtype),
dimension(3, 3) :: tmpmat
2645 real(kind=realtype),
dimension(:, :),
allocatable :: coefspectral
2646 real(kind=realtype),
dimension(:, :, :, :),
allocatable :: &
2648 real(kind=realtype),
dimension(:, :, :),
allocatable :: &
2670 matrixcoefspectral(
nsections, kk, 3, 3), &
2671 diagmatcoefspectral(
nsections, 3, 3), stat=ierr)
2673 call terminate(
"timeSpectralMatrices", &
2674 "Memory allocation failure for the matrices of &
2675 &the spectral time derivatives.")
2681 diagmatcoefspectral)
2712 dscalar(ii, nn, ll) = coefspectral(ii, mm)
2731 dvector(ii, kk + i, kk + j) = diagmatcoefspectral(ii, i, j)
2755 tmpmat(i, j) = matrixcoefspectral(ii, mm, i, 1) &
2757 + matrixcoefspectral(ii, mm, i, 2) &
2759 + matrixcoefspectral(ii, mm, i, 3) &
2771 tmpmat(i, j) = matrixcoefspectral(ii, mm, i, j)
2783 dvector(ii, kk + i, ll + j) = tmpmat(i, j)
2794 deallocate (coefspectral, matrixcoefspectral, &
2795 diagmatcoefspectral, stat=ierr)
2797 call terminate(
"timeSpectralMatrices", &
2798 "Deallocation failure for the help variables.")
2829 integer :: nzones, celldim, physdim, ierr, nsols
2831 integer(cgsize_t),
dimension(9) :: sizes
2832 integer,
dimension(9) :: rindsizes
2833 integer,
dimension(nSolsRead) :: fileids
2835 integer(kind=intType) :: ii, jj, nn
2836 integer(kind=intType) :: ntypemismatch
2837 integer(kind=intType) :: nhimin, nhjmin, nhkmin
2838 integer(kind=intType) :: nhimax, nhjmax, nhkmax
2840 character(len=7) :: integerstring
2841 character(len=maxCGNSNameLen) :: cgnsname
2842 character(len=2*maxStringLen) :: errormessage
2861 if (ierr /= all_ok)
then
2863 " could not be opened for reading"
2864 call terminate(
"readRestartFile", errormessage)
2873 if (ierr /= all_ok) &
2875 "Something wrong when calling cg_nbases_f")
2878 write (errormessage, *)
"CGNS file ", trim(
solfiles(
solid)), &
2879 " does not contain a base"
2880 call terminate(
"readRestartFile", errormessage)
2893 if (ierr /= all_ok) &
2895 "Something wrong when calling cg_base_read_f")
2900 if (celldim /= 3 .or. physdim /= 3)
then
2901 write (errormessage,
stringint1)
"Both the number of cell and physical dimensions should be 3, not ", &
2902 celldim,
" and ", physdim
2903 call terminate(
"readRestartFile", errormessage)
2935 if (ierr /= all_ok) &
2937 "Something wrong when calling cg_nzones_f")
2941 "Number of blocks in grid file and restart &
2951 domains:
do nn = 1, ndom
2969 write (errormessage, *)
"Zone name ", trim(cgnsname), &
2970 " not found in restart file ", &
2972 call terminate(
"readRestartFile", errormessage)
2983 cgnsname, sizes, ierr)
2984 if (ierr /= all_ok) &
2986 "Something wrong when calling &
2993 "Corresponding zones in restart file and &
2994 &grid file have different dimensions")
3000 if (ierr /= all_ok) &
3002 "Something wrong when calling cg_nsols_f")
3006 "No solution present in restart file")
3012 if ((nsols > 1) .or. nsols > 2) &
3014 "Multiple solutions present in restart file")
3023 if (ierr /= all_ok) &
3025 "Something wrong when calling &
3028 if (trim(cgnsname) /=
"Nodal Blanks")
exit
3035 if (ierr /= all_ok) &
3037 "Something wrong when calling cg_goto_f")
3039 call cg_rind_read_f(rindsizes, ierr)
3040 if (ierr /= all_ok) &
3042 "Something wrong when calling &
3050 if (rindsizes(1) == 0 .or. rindsizes(2) == 0 .or. rindsizes(3) == 0 .or. &
3051 rindsizes(4) == 0 .or. rindsizes(5) == 0 .or. rindsizes(6) == 0) &
3057 nhimin = 0; nhjmin = 0; nhkmin = 0
3058 nhimax = 0; nhjmax = 0; nhkmax = 0
3084 if (rindsizes(1) > 0) nhimin = 1;
if (rindsizes(2) > 0) nhimax = 1
3085 if (rindsizes(3) > 0) nhjmin = 1;
if (rindsizes(4) > 0) nhjmax = 1
3086 if (rindsizes(5) > 0) nhkmin = 1;
if (rindsizes(6) > 0) nhkmax = 1
3117 "Only CellCenter or Vertex data allowed in &
3125 allocate (
buffer(2 - nhimin:
il + nhimax, &
3126 2 - nhjmin:
jl + nhjmax, &
3127 2 - nhkmin:
kl + nhkmax), stat=ierr)
3130 "Memory allocation failure for buffer")
3136 "Memory allocation failure for bufferVertex")
3178 "Deallocation error for buffer, varNames &
3187 "Deallocation error for bufferVertex")
3197 "Deallocation failure for zoneNames &
3202 call cg_close_f(
cgnsind, ierr)
3203 if (ierr /= all_ok) &
3205 "Something wrong when calling cg_close_f")
3214 call mpi_reduce(ntypemismatch, ii, 1, adflow_integer, &
3216 if (
myid == 0 .and. ii > 0)
then
3218 write (integerstring,
"(i6)") ii
3219 integerstring = adjustl(integerstring)
3222 print
"(a)",
"# Warning"
3223 print
strings,
"# ", trim(integerstring),
" type mismatches occured when reading the solution of the blocks"
3252 integer :: zone, zonetype, ncoords, pathlength
3255 integer(kind=cgsize_t),
dimension(9) :: sizesblock
3257 integer(kind=intType) :: nn, ii
3259 character(len=maxStringLen) :: errormessage, linkpath
3260 character(len=maxCGNSNameLen),
dimension(cgnsNdom) :: tmpnames
3262 logical :: namefound
3264 character(len=7) :: int1string, int2string
3270 call terminate(
"getSortedZoneNumbers", &
3271 "Memory allocation failure for zoneNames &
3286 if (ierr /= all_ok) &
3287 call terminate(
"getSortedZoneNumbers", &
3288 "Something wrong when calling cg_zone_type_f")
3290 if (zonetype /= structured)
then
3292 write (int1string,
"(i7)")
cgnsbase
3293 int1string = adjustl(int1string)
3294 write (int2string,
"(i7)") zone
3295 int2string = adjustl(int2string)
3297 write (errormessage,
strings)
"Base ", trim(int1string),
": Zone ", trim(int2string), &
3298 " of the cgns restart file is not structured"
3299 call terminate(
"getSortedZoneNumbers", errormessage)
3306 if (ierr /= all_ok) &
3307 call terminate(
"getSortedZoneNumbers", &
3308 "Something wrong when calling cg_ncoords_f")
3313 if (ncoords == 3)
then
3318 "GridCoordinates_t", 1,
"end")
3319 if (ierr /= all_ok) &
3320 call terminate(
"getSortedZoneNumbers", &
3321 "Something wrong when calling cg_goto_f")
3325 call cg_is_link_f(pathlength, ierr)
3326 if (ierr /= all_ok) &
3327 call terminate(
"getSortedZoneNumbers", &
3328 "Something wrong when calling cg_is_link_f")
3330 if (pathlength > 0)
then
3334 call cg_link_read_f(errormessage, linkpath, ierr)
3335 if (ierr /= all_ok) &
3336 call terminate(
"getSortedZoneNumbers", &
3337 "Something wrong when calling &
3343 pos = index(linkpath,
"/", .true.)
3345 linkpath = linkpath(:pos - 1)
3350 pos = index(linkpath,
"/", .true.)
3351 if (pos > 0) linkpath = linkpath(pos + 1:)
3356 linkpath = adjustl(linkpath)
3366 if (.not. namefound)
then
3369 if (ierr /= all_ok) &
3370 call terminate(
"getSortedZoneNumbers", &
3371 "Something wrong when calling &
3404 call terminate(
"getSortedZoneNumbers", &
3405 "Error occurs only when two identical zone &
3406 &names are present")
3435 integer,
dimension(:),
allocatable :: tmptypes
3437 integer(kind=intType) :: nn, ii
3439 integer(kind=intType),
dimension(:),
allocatable :: varnumbers
3441 character(len=maxCGNSNameLen),
allocatable,
dimension(:) :: &
3448 if (ierr /= all_ok) &
3450 "Something wrong when calling cg_nfield_f")
3458 "Memory allocation failure for varNames, etc.")
3468 "Something wrong when calling cg_field_info_f")
3474 allocate (tmptypes(
nvar), tmpnames(
nvar), stat=ierr)
3477 "Memory allocation failure for tmp variables")
3505 if (varnumbers(ii) /= -1) &
3507 "Error occurs only when two identical &
3508 &variable names are present")
3518 deallocate (varnumbers, tmptypes, tmpnames, stat=ierr)
3521 "Deallocation error for tmp variables")
subroutine setbcdatacoarsegrid
subroutine setbcdatafinegrid(initializationPart)
subroutine applyallbc_block(secondHalo)
subroutine applyallbc(secondHalo)
integer(kind=inttype) ndom
type(blocktype), dimension(:, :, :), allocatable, target flowdoms
integer(kind=inttype) kbegor
real(kind=realtype), dimension(:, :, :), pointer p
real(kind=realtype), dimension(:, :, :, :), pointer w
real(kind=realtype), dimension(:, :, :), pointer d2wall
integer(kind=inttype) nbkglobal
real(kind=realtype), dimension(:, :, :), pointer rlv
integer(kind=inttype) ibegor
integer(kind=inttype) nbocos
integer(kind=inttype) sectionid
integer(kind=inttype) jbegor
real(kind=realtype), dimension(:, :, :), pointer rev
integer(kind=inttype), dimension(:), pointer bctype
real(kind=realtype), dimension(:, :, :, :), pointer dw
real(kind=realtype), dimension(:, :, :, :), pointer fw
type(cgnsblockinfotype), dimension(:), allocatable cgnsdoms
integer(kind=inttype) cgnsndom
integer adflow_comm_world
integer(kind=inttype), parameter spalartallmarasedwards
integer(kind=inttype), parameter spalartallmaras
real(kind=realtype), parameter zero
integer(kind=inttype), parameter coupled
real(kind=realtype), parameter third
real(kind=realtype), parameter pi
real(kind=realtype), parameter eps
integer(kind=inttype), parameter ktau
integer(kind=inttype), parameter md
integer(kind=inttype), parameter komegawilcox
integer(kind=inttype), parameter timespectral
integer(kind=inttype), parameter komegamodified
integer(kind=inttype), parameter unsteady
integer(kind=inttype), parameter bdf
integer(kind=inttype), parameter totalconditions
real(kind=realtype), parameter one
integer, parameter maxstringlen
integer(kind=inttype), parameter steady
real(kind=realtype), parameter two
integer(kind=inttype), parameter explicitrk
integer(kind=inttype), parameter massflow
integer(kind=inttype), parameter mentersst
integer(kind=inttype), parameter subsonicinflow
integer(kind=inttype), parameter ransequations
integer(kind=inttype), parameter internalflow
integer(kind=inttype), parameter v2f
subroutine computelamviscosity(includeHalos)
subroutine adjustinflowangle()
subroutine computeetotblock(iStart, iEnd, jStart, jEnd, kStart, kEnd, correctForK)
subroutine computegamma(T, gamma, mm)
subroutine etot(rho, u, v, w, p, k, etotal, correctForK)
real(kind=realtype) rhoinfdim
real(kind=realtype) muinfdim
real(kind=realtype) gammainf
integer(kind=inttype) nt1
real(kind=realtype) pinfdim
real(kind=realtype) pinfcorr
real(kind=realtype) muref
real(kind=realtype) tinfdim
real(kind=realtype) rhoref
integer(kind=inttype) nwf
real(kind=realtype), dimension(:), allocatable winf
real(kind=realtype) muinf
real(kind=realtype) rhoinf
real(kind=realtype) timeref
integer(kind=inttype) nt2
subroutine whalo2(level, start, end, commPressure, commGamma, commViscous)
subroutine allocmemflovarpart2(sps, level)
subroutine infchangecorrection(oldWinf, correctionTol, correctionType)
subroutine getsortedvarnumbers
subroutine updatebcdataalllevels
subroutine setpressureandcomputeenergy(halosRead)
subroutine allocmemflovarpart1(sps, level)
subroutine determinesolfilenames
subroutine velmagnanddirectionsubface(vmag, dir, BCData, mm)
subroutine setrestartfiles(fileName, i)
subroutine initdepvarandhalos(halosRead)
subroutine setsolfilenames
subroutine interpolatespectralsolution
subroutine copyspectralsolution
subroutine setuniformflow
subroutine checksolfilenames
subroutine getsortedzonenumbers
subroutine timespectralcoef(coefSpectral, matrixCoefSpectral, diagMatCoefSpectral)
subroutine initializehalos(halosRead)
subroutine timespectralmatrices
subroutine referencestate
subroutine releaseextramembcs
subroutine initflowrestart
subroutine allocrestartfiles(nFiles)
subroutine readrestartfile()
type(iotype), dimension(:, :), allocatable iovar
integer(kind=inttype) noldlevels
integer(kind=inttype) currentlevel
integer(kind=inttype) groundlevel
integer(kind=inttype) nalesteps
logical, dimension(:), allocatable oldsolwritten
integer(kind=inttype) noldsolavail
real(kind=realtype) timeunsteadyrestart
integer(kind=inttype) ntimestepsrestart
integer(kind=inttype) nsections
type(sectiontype), dimension(:), allocatable sections
subroutine gridvelocitiescoarselevels(sps)
subroutine slipvelocitiesfinelevel(useOldCoor, t, sps)
subroutine slipvelocitiescoarselevels(sps)
subroutine normalvelocitiesalllevels(sps)
subroutine gridvelocitiesfinelevel(useOldCoor, t, sps)
integer(kind=inttype) function bsearchstrings(key, base)
subroutine qsortstrings(arr, nn)
subroutine bcturbtreatment
subroutine applyallturbbc(secondHalo)
subroutine applyallturbbcthisblock(secondHalo)
real(kind=realtype) function sanuknowneddyratio(eddyRatio, nuLam)
subroutine computeeddyviscosity(includeHalos)
subroutine alloctimearrays(nTimeTot)
subroutine rotmatrixrigidbody(tNew, tOld, rotationMatrix, rotationPoint)
real(kind=realtype) function mynorm2(x)
subroutine spectralinterpolcoef(nsps, t, alpScal, alpMat)
subroutine setpointers(nn, mm, ll)
subroutine allocconvarrays(nIterTot)
subroutine getrotmatrix(vec1, vec2, rotMat)
subroutine terminate(routineName, errorMessage)
real(kind=cgnsrealtype), dimension(:, :, :), allocatable buffer
subroutine readymomentum(nTypeMismatch)
integer(kind=inttype) nsolsread
subroutine readyvelocity(nTypeMismatch)
integer(kind=inttype) solid
subroutine readturbvar(nTypeMismatch)
integer, dimension(:), allocatable vartypes
subroutine readzvelocity(nTypeMismatch)
integer(kind=inttype), dimension(:), allocatable zonenumbers
real(kind=cgnsrealtype), dimension(:, :, :), allocatable buffervertex
subroutine readdensity(nTypeMismatch)
subroutine readzmomentum(nTypeMismatch)
character(len=maxstringlen), dimension(:), allocatable solfiles
subroutine readxvelocity(nTypeMismatch)
subroutine readpressure(nTypeMismatch)
subroutine readenergy(nTypeMismatch)
character(len=maxcgnsnamelen), dimension(:), allocatable zonenames
subroutine readxmomentum(nTypeMismatch)
integer(kind=cgsize_t), dimension(3) rangemax
character(len=maxcgnsnamelen), dimension(:), allocatable varnames
integer(kind=cgsize_t), dimension(3) rangemin
subroutine scalefactors(fileIDs)