29 integer(kind=intType) :: i, j, k, nn, mm, ii, jj, kk
30 integer(kind=intType) :: nViscBocos
32 integer(kind=intType),
dimension(0:nProc - 1) :: nBlockPerProc
34 integer(kind=intType),
dimension(:),
allocatable :: oldSubfaceID
72 nblockperproc(
part(i)) = nblockperproc(
part(i)) + 1
143 if (
cgnsdoms(k)%rotatingFrameSpecified) &
144 flowdoms(nn, 1, 1:mm)%blockIsMoving = .true.
153 flowdoms(nn, 1, 1:mm)%blockIsMoving = .true.
158 flowdoms(nn, 1, 1:mm)%addGridVelocities = &
170 allocate (
flowdoms(nn, 1, 1)%BCType(j), &
172 flowdoms(nn, 1, 1)%cgnsSubface(j), &
195 "Memory allocation failure for subface info")
201 allocate (oldsubfaceid(
blocks(i)%nBocos), stat=ierr)
204 "Memory allocation failure for oldSubfaceID")
217 do j = 1,
blocks(i)%nSubface
224 if (j <=
blocks(i)%nBocos) k = oldsubfaceid(j)
246 flowdoms(nn, 1, 1)%neighProc(j) = -1
247 flowdoms(nn, 1, 1)%neighBlock(j) = 0
260 nviscbocos = nviscbocos + 1
263 flowdoms(nn, 1, 1:mm)%nViscBocos = nviscbocos
272 flowdoms(nn, 1, 1)%neighBlock(j) = &
278 deallocate (oldsubfaceid, stat=ierr)
281 "Deallocation error for oldSubfaceID")
300 "Deallocation error for boundary info")
311 allocate (subblocksofcgns(
nblocks), stat=ierr)
314 "Memory allocation failure for subblocksOfCGNS")
319 subblocksofcgns(nn)%cgnsBlockID =
blocks(nn)%cgnsBlockID
320 subblocksofcgns(nn)%procID =
part(nn)
321 subblocksofcgns(nn)%blockID =
blocks(nn)%blockID
323 subblocksofcgns(nn)%iBegOr =
blocks(nn)%iBegOr
324 subblocksofcgns(nn)%iEndOr =
blocks(nn)%iEndOr
325 subblocksofcgns(nn)%jBegOr =
blocks(nn)%jBegOr
326 subblocksofcgns(nn)%jEndOr =
blocks(nn)%jEndOr
327 subblocksofcgns(nn)%kBegOr =
blocks(nn)%kBegOr
328 subblocksofcgns(nn)%kEndOr =
blocks(nn)%kEndOr
349 if (subblocksofcgns(jj + 1)%cgnsBlockID > nn)
exit
357 cgnsdoms(nn)%nSubBlocks = jj - ii + 1
363 cgnsdoms(nn)%localBlockID(k), stat=ierr)
366 "Memory allocation failure for procStored, &
367 &localBlockID, iBegOr, iEndOr, etc.")
374 cgnsdoms(nn)%procStored(i) = subblocksofcgns(j)%procID
375 cgnsdoms(nn)%localBlockID(i) = subblocksofcgns(j)%blockID
377 cgnsdoms(nn)%iBegOr(i) = subblocksofcgns(j)%iBegOr
378 cgnsdoms(nn)%iEndOr(i) = subblocksofcgns(j)%iEndOr
379 cgnsdoms(nn)%jBegOr(i) = subblocksofcgns(j)%jBegOr
380 cgnsdoms(nn)%jEndOr(i) = subblocksofcgns(j)%jEndOr
381 cgnsdoms(nn)%kBegOr(i) = subblocksofcgns(j)%kBegOr
382 cgnsdoms(nn)%kEndOr(i) = subblocksofcgns(j)%kEndOr
393 deallocate (
blocks,
part, subblocksofcgns, stat=ierr)
396 "Deallocation error for blocks, part and &
429 integer(kind=intType) :: nn, nx, ny, nz
430 integer(kind=intType) :: nCellsTot, nCellsEven, nCellsUpper
431 integer(kind=intType) :: nCellsPerProcMax
432 integer(kind=intType) :: iter, iterMax
434 logical :: cellsBalanced, facesBalanced
435 logical :: emptyPartitions, commNeglected
439 character(len=maxStringLen) :: loadFormat
452 "Number of processors is larger than number &
453 &of blocks, but it is not allowed to split &
468 splitinfo(nn)%nSubBlocks = 1
470 allocate (splitinfo(nn)%ranges(1, 3, 2), stat=ierr)
473 "Memory allocation failure for ranges")
475 splitinfo(nn)%ranges(1, 1, 1) = 1
476 splitinfo(nn)%ranges(1, 2, 1) = 1
477 splitinfo(nn)%ranges(1, 3, 1) = 1
479 splitinfo(nn)%ranges(1, 1, 2) =
cgnsdoms(nn)%il
480 splitinfo(nn)%ranges(1, 2, 2) =
cgnsdoms(nn)%jl
481 splitinfo(nn)%ranges(1, 3, 2) =
cgnsdoms(nn)%kl
487 ncellstot = ncellstot + nx * ny * nz
495 ncellseven = ncellstot /
nproc
497 ncellsperprocmax = ncellsupper
502 initsplitloop:
do iter = 1, 2
521 ncellsperprocmax = ncellseven
534 distributionloop:
do iter = 1, itermax
548 if (emptypartitions)
then
549 cellsbalanced = .false.
550 facesbalanced = .false.
558 if (cellsbalanced .or. facesbalanced .or. &
559 iter == itermax)
exit
566 end do distributionloop
571 deallocate (splitinfo(nn)%ranges, stat=ierr)
574 "Deallocation failure for ranges")
580 if (emptypartitions)
then
583 "Empty partitions present")
590 if (commneglected .and.
myid == 0)
then
592 print
"(a)",
"# Warning"
593 print
"(a)",
"# Communication costs neglected to obtain a valid partitioning."
599 loadformat =
"(*(A, F6.3))"
602 if (.not. (cellsbalanced .and. facesbalanced))
then
604 print
"(a)",
"# Warning"
605 print loadformat,
"# Specified load imbalance tolerance", real(
loadimbalance),
" not achieved."
606 print loadformat,
"# Continuing with", real(
ubvec(1)), &
607 " load imbalance for the cells and", real(
ubvec(2)),
" for the faces"
611 print loadformat,
"# Specified load imbalance tolerance", real(
loadimbalance),
" achieved."
612 print loadformat,
"# Continuing with", real(
ubvec(1)), &
613 " load imbalance for the cells and", real(
ubvec(2)),
" for the faces"
635 integer(kind=intType),
intent(in) :: cgnsid
639 integer(kind=intType) :: i, nx, ny, nz, ncells
647 do i = 1, splitinfo(cgnsid)%nSubBlocks
651 nx = splitinfo(cgnsid)%ranges(i, 1, 2) &
652 - splitinfo(cgnsid)%ranges(i, 1, 1)
653 ny = splitinfo(cgnsid)%ranges(i, 2, 2) &
654 - splitinfo(cgnsid)%ranges(i, 2, 1)
655 nz = splitinfo(cgnsid)%ranges(i, 3, 2) &
656 - splitinfo(cgnsid)%ranges(i, 3, 1)
660 ncells = nx * ny * nz
666 if (ncells > ncellsperprocmax)
then
686 integer(kind=intType),
intent(in) :: cgnsID
692 integer(kind=intType) :: nn, mm
693 integer(kind=intType) :: nx, ny, nz, nCells, nSub
695 integer(kind=intType),
dimension(:, :, :),
allocatable :: tmpRange
702 call terminate(
"splitBlockInitialization", &
703 "Block must be split for load balance, &
704 &but I am not allowed to do so")
711 ncells = nx * ny * nz
718 tmpblock%nx = nx; tmpblock%il = nx + 1
719 tmpblock%ny = ny; tmpblock%jl = ny + 1
720 tmpblock%nz = nz; tmpblock%kl = nz + 1
722 tmpblock%nCell = ncells
723 tmpblock%nface = (nx + 1) * ny * nz + (ny + 1) * nx * nz &
726 tmpblock%cgnsBlockID = cgnsid
728 tmpblock%iBegor = 1; tmpblock%iEndor = tmpblock%il
729 tmpblock%jBegor = 1; tmpblock%jEndor = tmpblock%jl
730 tmpblock%kBegor = 1; tmpblock%kEndor = tmpblock%kl
732 tmpblock%nBocos =
cgnsdoms(cgnsid)%nBocos
733 tmpblock%n1to1 =
cgnsdoms(cgnsid)%n1to1
734 tmpblock%nSubface = tmpblock%nBocos + tmpblock%n1to1
739 nsub = tmpblock%nSubface
741 allocate (tmpblock%BCType(nsub), tmpblock%BCFaceID(nsub), &
742 tmpblock%inBeg(nsub), tmpblock%inEnd(nsub), &
743 tmpblock%jnBeg(nsub), tmpblock%jnEnd(nsub), &
744 tmpblock%knBeg(nsub), tmpblock%knEnd(nsub), &
747 call terminate(
"splitBlockInitialization", &
748 "Deallocation failure for the subface &
751 nullify (tmpblock%cgnsSubface, tmpblock%neighBlock, &
752 tmpblock%dinBeg, tmpblock%dinEnd, &
753 tmpblock%djnBeg, tmpblock%djnEnd, &
754 tmpblock%dknBeg, tmpblock%dknEnd, &
755 tmpblock%l1, tmpblock%l2, &
756 tmpblock%l3, tmpblock%groupNum)
763 tmpblock%inBeg(nn) =
cgnsdoms(cgnsid)%bocoInfo(nn)%iBeg
764 tmpblock%jnBeg(nn) =
cgnsdoms(cgnsid)%bocoInfo(nn)%jBeg
765 tmpblock%knBeg(nn) =
cgnsdoms(cgnsid)%bocoInfo(nn)%kBeg
767 tmpblock%inEnd(nn) =
cgnsdoms(cgnsid)%bocoInfo(nn)%iEnd
768 tmpblock%jnEnd(nn) =
cgnsdoms(cgnsid)%bocoInfo(nn)%jEnd
769 tmpblock%knEnd(nn) =
cgnsdoms(cgnsid)%bocoInfo(nn)%kEnd
771 tmpblock%BCType(nn) =
cgnsdoms(cgnsid)%bocoInfo(nn)%BCType
780 tmpblock%inBeg(nn) =
cgnsdoms(cgnsid)%conn1to1(mm)%iBeg
781 tmpblock%jnBeg(nn) =
cgnsdoms(cgnsid)%conn1to1(mm)%jBeg
782 tmpblock%knBeg(nn) =
cgnsdoms(cgnsid)%conn1to1(mm)%kBeg
784 tmpblock%inEnd(nn) =
cgnsdoms(cgnsid)%conn1to1(mm)%iEnd
785 tmpblock%jnEnd(nn) =
cgnsdoms(cgnsid)%conn1to1(mm)%jEnd
786 tmpblock%knEnd(nn) =
cgnsdoms(cgnsid)%conn1to1(mm)%kEnd
795 do nn = 1, tmpblock%nSubface
796 if (tmpblock%inBeg(nn) == tmpblock%inEnd(nn))
then
797 tmpblock%BCFaceID(nn) =
imax
798 if (tmpblock%inBeg(nn) == 1) tmpblock%BCFaceID(nn) =
imin
799 else if (tmpblock%jnBeg(nn) == tmpblock%jnEnd(nn))
then
800 tmpblock%BCFaceID(nn) =
jmax
801 if (tmpblock%jnBeg(nn) == 1) tmpblock%BCFaceID(nn) =
jmin
803 tmpblock%BCFaceID(nn) =
kmax
804 if (tmpblock%knBeg(nn) == 1) tmpblock%BCFaceID(nn) =
kmin
811 nsub = nint(real(ncells, realtype) / real(ncellseven, realtype))
812 nsub = max(nsub, 2_inttype)
817 deallocate (splitinfo(cgnsid)%ranges, stat=ierr)
819 call terminate(
"splitBlockInitialization", &
820 "Deallocation failure for ranges")
822 allocate (tmprange(nsub, 3, 2), stat=ierr)
824 call terminate(
"splitBlockInitialization", &
825 "Memory allocation failure for tmpRange")
831 call splitblock(tmpblock, nsub, ncellseven, tmprange)
835 allocate (splitinfo(cgnsid)%ranges(nsub, 3, 2), stat=ierr)
837 call terminate(
"splitBlockInitialization", &
838 "Memory allocation failure for ranges")
848 splitinfo(cgnsid)%nSubBlocks = nsub
851 splitinfo(cgnsid)%ranges(nn, 1, 1) = tmprange(nn, 1, 1)
852 splitinfo(cgnsid)%ranges(nn, 2, 1) = tmprange(nn, 2, 1)
853 splitinfo(cgnsid)%ranges(nn, 3, 1) = tmprange(nn, 3, 1)
855 splitinfo(cgnsid)%ranges(nn, 1, 2) = tmprange(nn, 1, 2)
856 splitinfo(cgnsid)%ranges(nn, 2, 2) = tmprange(nn, 2, 2)
857 splitinfo(cgnsid)%ranges(nn, 3, 2) = tmprange(nn, 3, 2)
862 deallocate (tmpblock%BCType, tmpblock%BCFaceID, &
863 tmpblock%inBeg, tmpblock%inEnd, &
864 tmpblock%jnBeg, tmpblock%jnEnd, &
865 tmpblock%knBeg, tmpblock%knEnd, &
868 call terminate(
"splitBlockInitialization", &
869 "Deallocation failure for tmpBlock &
892 integer(kind=intType) :: i, j, k, kk, jj
893 integer(kind=intType) :: nCellDiff, proc, nSub, cgnsID
894 integer(kind=intType) :: ncgnsSort
896 integer(kind=intType),
dimension(0:cgnsNDom) :: nSubBlocks
897 integer(kind=intType),
dimension(cgnsNDom) :: cgnsSort
899 integer(kind=intType),
dimension(nProc) :: nCell, nCellOr
900 integer(kind=intType),
dimension(nProc) :: tmp, procNCell
901 integer(kind=intType),
dimension(0:nProc) :: nBlockProc
902 integer(kind=intType),
dimension(0:nProc) :: multNCell
903 integer(kind=intType),
dimension(nBlocks) :: blockProc
905 integer(kind=intType),
dimension(:, :, :),
allocatable :: tmpRange
906 integer(kind=intType),
dimension(:, :, :),
pointer :: oldRanges
908 logical,
dimension(cgnsNDom) :: cgnsBlockFlagged
917 nsubblocks(i) = nsubblocks(i - 1) + splitinfo(i)%nSubBlocks
918 cgnsblockflagged(i) = .false.
929 ncell(j) = ncell(j) +
blocks(i)%nCell
930 nblockproc(j) = nblockproc(j) + 1
938 tmp(i) = nblockproc(i - 1)
939 nblockproc(i) = nblockproc(i) + tmp(i)
948 blockproc(tmp(j)) = i
965 if (ncell(i) == ncell(ncelldiff))
then
966 multncell(ncelldiff) = multncell(ncelldiff) + 1
968 ncelldiff = ncelldiff + 1
969 multncell(ncelldiff) = multncell(ncelldiff - 1) + 1
970 ncell(ncelldiff) = ncell(i)
978 tmp(i) = multncell(i - 1)
987 procncell(tmp(j)) = i - 1
1001 if (ncell(i) <= ncellsupper)
exit
1005 processorloop:
do j = (multncell(i - 1) + 1), multncell(i)
1015 k = nblockproc(proc) + 1
1018 do k = (nblockproc(proc) + 2), nblockproc(proc + 1)
1026 cgnsid =
blocks(jj)%cgnsBlockID
1027 kk = jj - nsubblocks(cgnsid - 1)
1033 ncelldiff = ncell(i) - ncellseven
1041 if (ncelldiff >=
blocks(jj)%nCell) cycle
1048 if (ncelldiff <= (ncellsupper - ncell(1)))
then
1061 ncelldiff =
blocks(jj)%nCell - ncelldiff
1065 nsub = nint(real(
blocks(jj)%nCell, realtype) &
1066 / real(ncelldiff, realtype))
1067 nsub = max(nsub, 2_inttype)
1074 allocate (tmprange(nsub, 3, 2), stat=ierr)
1076 call terminate(
"splitBlocksLoadBalance", &
1077 "Memory allocation failure for tmpRange")
1089 jj = splitinfo(cgnsid)%nSubBlocks
1090 oldranges => splitinfo(cgnsid)%ranges
1092 splitinfo(cgnsid)%nSubBlocks = jj + nsub - 1
1094 k = splitinfo(cgnsid)%nSubBlocks
1095 allocate (splitinfo(cgnsid)%ranges(k, 3, 2), stat=ierr)
1097 call terminate(
"splitBlocksLoadBalance", &
1098 "Memory allocation failure for ranges")
1109 splitinfo(cgnsid)%ranges(k, 1, 1) = oldranges(k, 1, 1)
1110 splitinfo(cgnsid)%ranges(k, 2, 1) = oldranges(k, 2, 1)
1111 splitinfo(cgnsid)%ranges(k, 3, 1) = oldranges(k, 3, 1)
1113 splitinfo(cgnsid)%ranges(k, 1, 2) = oldranges(k, 1, 2)
1114 splitinfo(cgnsid)%ranges(k, 2, 2) = oldranges(k, 2, 2)
1115 splitinfo(cgnsid)%ranges(k, 3, 2) = oldranges(k, 3, 2)
1121 splitinfo(cgnsid)%ranges(kk, 1, 1) = tmprange(1, 1, 1)
1122 splitinfo(cgnsid)%ranges(kk, 2, 1) = tmprange(1, 2, 1)
1123 splitinfo(cgnsid)%ranges(kk, 3, 1) = tmprange(1, 3, 1)
1125 splitinfo(cgnsid)%ranges(kk, 1, 2) = tmprange(1, 1, 2)
1126 splitinfo(cgnsid)%ranges(kk, 2, 2) = tmprange(1, 2, 2)
1127 splitinfo(cgnsid)%ranges(kk, 3, 2) = tmprange(1, 3, 2)
1134 splitinfo(cgnsid)%ranges(jj, 1, 1) = tmprange(k, 1, 1)
1135 splitinfo(cgnsid)%ranges(jj, 2, 1) = tmprange(k, 2, 1)
1136 splitinfo(cgnsid)%ranges(jj, 3, 1) = tmprange(k, 3, 1)
1138 splitinfo(cgnsid)%ranges(jj, 1, 2) = tmprange(k, 1, 2)
1139 splitinfo(cgnsid)%ranges(jj, 2, 2) = tmprange(k, 2, 2)
1140 splitinfo(cgnsid)%ranges(jj, 3, 2) = tmprange(k, 3, 2)
1145 deallocate (oldranges, tmprange, stat=ierr)
1147 call terminate(
"splitBlocksLoadBalance", &
1148 "Deallocation failure for oldRanges and &
1155 if (.not. cgnsblockflagged(cgnsid))
then
1156 cgnsblockflagged(cgnsid) = .true.
1157 ncgnssort = ncgnssort + 1
1158 cgnssort(ncgnssort) = cgnsid
1161 end do processorloop
1197 integer(kind=intType) :: i, j, k, nn
1207 "Memory allocation failure for flowDoms")
1234 integer(kind=intType),
dimension(*),
intent(out) :: oldSubfaceID
1239 integer(kind=intType) :: i, ii, nDiff
1241 integer(kind=intType),
dimension(blockID%nBocos) :: bcPrior
1242 integer(kind=intType),
dimension(blockID%nBocos) :: bcPriorSort
1244 integer(kind=intType),
dimension(0:blockID%nBocos) :: mult
1249 do i = 1, blockid%nBocos
1251 select case (blockid%BCType(i))
1321 bcpriorsort(i) = bcprior(i)
1335 ndiff = min(1_inttype, blockid%nBocos)
1339 do i = 2, blockid%nBocos
1340 if (bcpriorsort(i) == bcpriorsort(ndiff))
then
1341 mult(ndiff) = mult(ndiff) + 1
1344 mult(ndiff) = mult(ndiff - 1) + 1
1345 bcpriorsort(ndiff) = bcpriorsort(i)
1352 do i = 1, blockid%nBocos
1359 mult(ii - 1) = mult(ii - 1) + 1
1364 oldsubfaceid(ii) = i
1384 type(
splitcgnstype),
dimension(cgnsNDom),
intent(in) :: splitInfo
1390 integer(kind=intType) :: i, ii, jj, mm
1391 integer(kind=intType) :: nx, ny, nz, nAlloc
1393 integer(kind=intType),
dimension(0:cgnsNDom) :: nSubPerCGNS
1400 nsubpercgns(i) = nsubpercgns(i - 1) + splitinfo(i)%nSubblocks
1405 if (
allocated(
blocks))
then
1423 call terminate(
"determineComputeBlocks", &
1424 "Deallocation error for subface info")
1429 deallocate (
blocks, stat=ierr)
1431 call terminate(
"determineComputeBlocks", &
1432 "Deallocation error for blocks")
1439 call terminate(
"determineComputeBlocks", &
1440 "Memory allocation failure for blocks")
1450 subblockloop:
do mm = 1, splitinfo(i)%nSubblocks
1456 nx = splitinfo(i)%ranges(mm, 1, 2) &
1457 - splitinfo(i)%ranges(mm, 1, 1)
1458 ny = splitinfo(i)%ranges(mm, 2, 2) &
1459 - splitinfo(i)%ranges(mm, 2, 1)
1460 nz = splitinfo(i)%ranges(mm, 3, 2) &
1461 - splitinfo(i)%ranges(mm, 3, 1)
1469 blocks(ii)%ncell = nx * ny * nz
1470 blocks(ii)%nface = (nx + 1) * ny * nz + (ny + 1) * nx * nz &
1471 + (nz + 1) * nx * ny
1473 blocks(ii)%cgnsBlockID = i
1475 blocks(ii)%iBegor = splitinfo(i)%ranges(mm, 1, 1)
1476 blocks(ii)%jBegor = splitinfo(i)%ranges(mm, 2, 1)
1477 blocks(ii)%kBegor = splitinfo(i)%ranges(mm, 3, 1)
1479 blocks(ii)%iEndor = splitinfo(i)%ranges(mm, 1, 2)
1480 blocks(ii)%jEndor = splitinfo(i)%ranges(mm, 2, 2)
1481 blocks(ii)%kEndor = splitinfo(i)%ranges(mm, 3, 2)
1492 allocate (
blocks(ii)%BCType(nalloc), &
1493 blocks(ii)%BCFaceID(nalloc), &
1494 blocks(ii)%cgnsSubface(nalloc), &
1495 blocks(ii)%inBeg(nalloc), &
1496 blocks(ii)%jnBeg(nalloc), &
1497 blocks(ii)%knBeg(nalloc), &
1498 blocks(ii)%inEnd(nalloc), &
1499 blocks(ii)%jnEnd(nalloc), &
1500 blocks(ii)%knEnd(nalloc), &
1501 blocks(ii)%dinBeg(nalloc), &
1502 blocks(ii)%djnBeg(nalloc), &
1503 blocks(ii)%dknBeg(nalloc), &
1504 blocks(ii)%dinEnd(nalloc), &
1505 blocks(ii)%djnEnd(nalloc), &
1506 blocks(ii)%dknEnd(nalloc), &
1507 blocks(ii)%neighBlock(nalloc), &
1511 blocks(ii)%groupNum(nalloc), &
1514 call terminate(
"determineComputeBlocks", &
1515 "Memory allocation failure for &
1533 nalloc, splitinfo(i))
1560 integer(kind=intType),
intent(in) :: cgnsID, ii
1561 integer(kind=intType),
intent(inout) :: jj
1567 integer(kind=intType) :: j, mm
1568 integer(kind=intType) :: iBeg, iEnd, jBeg, jEnd, kBeg, kEnd
1570 character(len=maxCGNSNameLen) :: zoneName, subName
1571 character(len=2*maxStringLen) :: errorMessage
1575 bocoloop:
do j = 1,
cgnsdoms(cgnsid)%nBocos
1580 if (.not.
cgnsdoms(cgnsid)%bocoInfo(j)%actualFace) cycle
1585 ibeg = min(
cgnsdoms(cgnsid)%bocoInfo(j)%iBeg, &
1587 iend = max(
cgnsdoms(cgnsid)%bocoInfo(j)%iBeg, &
1590 jbeg = min(
cgnsdoms(cgnsid)%bocoInfo(j)%jBeg, &
1592 jend = max(
cgnsdoms(cgnsid)%bocoInfo(j)%jBeg, &
1595 kbeg = min(
cgnsdoms(cgnsid)%bocoInfo(j)%kBeg, &
1597 kend = max(
cgnsdoms(cgnsid)%bocoInfo(j)%kBeg, &
1603 overlap:
if (ibeg <=
blocks(ii)%iEndor .and. &
1604 iend >=
blocks(ii)%iBegor .and. &
1605 jbeg <=
blocks(ii)%jEndor .and. &
1606 jend >=
blocks(ii)%jBegor .and. &
1607 kbeg <=
blocks(ii)%kEndor .and. &
1608 kend >=
blocks(ii)%kBegor)
then
1613 ibeg = max(
blocks(ii)%iBegor, ibeg)
1614 iend = min(
blocks(ii)%iEndor, iend)
1616 jbeg = max(
blocks(ii)%jBegor, jbeg)
1617 jend = min(
blocks(ii)%jEndor, jend)
1619 kbeg = max(
blocks(ii)%kBegor, kbeg)
1620 kend = min(
blocks(ii)%kEndor, kend)
1625 if (ibeg == iend) mm = mm + 1
1626 if (jbeg == jend) mm = mm + 1
1627 if (kbeg == kend) mm = mm + 1
1635 zonename =
cgnsdoms(cgnsid)%zoneName
1636 subname =
cgnsdoms(cgnsid)%bocoInfo(j)%bocoName
1637 write (errormessage,
strings)
"Zone ", trim(zonename),
", boundary subface ", trim(subname), &
1638 ": No constant index found for subface"
1639 call terminate(
"BCFacesSubblock", errormessage)
1668 if (ibeg == iend)
then
1670 blocks(ii)%BCFaceID(jj) = imax
1671 if (ibeg ==
blocks(ii)%iBegor)
blocks(ii)%BCFaceID(jj) = imin
1673 else if (jbeg == jend)
then
1675 blocks(ii)%BCFaceID(jj) = jmax
1676 if (jbeg ==
blocks(ii)%jBegor)
blocks(ii)%BCFaceID(jj) = jmin
1680 blocks(ii)%BCFaceID(jj) = kmax
1681 if (kbeg ==
blocks(ii)%kBegor)
blocks(ii)%BCFaceID(jj) = kmin
1692 blocks(ii)%neighBlock(jj) = 0
1703 blocks(ii)%cgnsSubface(jj) = j
1708 if (
blocks(ii)%BCType(jj) == bcnotvalid)
then
1715 zonename =
cgnsdoms(cgnsid)%zoneName
1716 subname =
cgnsdoms(cgnsid)%bocoInfo(j)%bocoName
1723 write (errormessage,
strings)
"Zone ", trim(zonename), &
1724 ", boundary subface ", trim(subname), &
1725 ": Not a valid boundary condition for internal flow"
1727 write (errormessage,
strings)
"Zone ", trim(zonename), &
1728 ", boundary subface ", trim(subname), &
1729 ": Not a valid boundary condition for external flow"
1732 call terminate(
"BCFacesSubblock", errormessage)
1740 mm =
cgnsdoms(cgnsid)%bocoInfo(j)%familyID
1748 select case (
blocks(ii)%BCType(jj))
1749 case (slidinginterface)
1750 blocks(ii)%groupNum(jj) = &
1751 cgnsdoms(cgnsid)%bocoInfo(j)%slidingID
1753 case (massbleedinflow, massbleedoutflow)
1757 blocks(ii)%groupNum(jj) = mm
1788 integer(kind=intType),
intent(in) :: cgnsID, ii
1789 integer(kind=intType),
intent(inout) :: jj, nAlloc
1791 integer(kind=intType),
dimension(0:cgnsNDom),
intent(in) :: &
1793 type(
splitcgnstype),
dimension(cgnsNDom),
intent(in) :: splitInfo
1799 integer(kind=intType) :: j, k, kk, mm
1800 integer(kind=intType) :: l1, L2, l3
1801 integer(kind=intType) :: iBeg, iEnd, jBeg, jEnd, kBeg, kEnd
1802 integer(kind=intType) :: diBeg, diEnd, djBeg, djEnd
1803 integer(kind=intType) :: dkBeg, dkEnd
1805 integer(kind=intType),
dimension(3, 3) :: trMat
1807 integer(kind=intType),
dimension(:, :, :),
pointer :: ranges
1809 character(len=maxCGNSNameLen) :: zoneName, subName
1810 character(len=2*maxStringLen) :: errorMessage
1812 logical :: diSwap, djSwap, dkSwap
1816 n1to1loop:
do j = 1,
cgnsdoms(cgnsid)%n1to1
1821 ibeg = min(
cgnsdoms(cgnsid)%conn1to1(j)%iBeg, &
1823 iend = max(
cgnsdoms(cgnsid)%conn1to1(j)%iBeg, &
1826 jbeg = min(
cgnsdoms(cgnsid)%conn1to1(j)%jBeg, &
1828 jend = max(
cgnsdoms(cgnsid)%conn1to1(j)%jBeg, &
1831 kbeg = min(
cgnsdoms(cgnsid)%conn1to1(j)%kBeg, &
1833 kend = max(
cgnsdoms(cgnsid)%conn1to1(j)%kBeg, &
1839 overlap:
if (ibeg <=
blocks(ii)%iEndor .and. &
1840 iend >=
blocks(ii)%iBegor .and. &
1841 jbeg <=
blocks(ii)%jEndor .and. &
1842 jend >=
blocks(ii)%jBegor .and. &
1843 kbeg <=
blocks(ii)%kEndor .and. &
1844 kend >=
blocks(ii)%kBegor)
then
1849 ibeg = max(
blocks(ii)%iBegor, ibeg)
1850 iend = min(
blocks(ii)%iEndor, iend)
1852 jbeg = max(
blocks(ii)%jBegor, jbeg)
1853 jend = min(
blocks(ii)%jEndor, jend)
1855 kbeg = max(
blocks(ii)%kBegor, kbeg)
1856 kend = min(
blocks(ii)%kEndor, kend)
1861 if (ibeg == iend) kk = kk + 1
1862 if (jbeg == jend) kk = kk + 1
1863 if (kbeg == kend) kk = kk + 1
1871 zonename =
cgnsdoms(cgnsid)%zoneName
1872 subname =
cgnsdoms(cgnsid)%bocoInfo(j)%bocoName
1873 write (errormessage,
strings)
"Zone ", trim(zonename), &
1874 ", 1 to 1 block connectivity ", trim(subname), &
1875 ": No constant index found for subface"
1876 call terminate(
"externalFacesSubblock", errormessage)
1890 if (
cgnsdoms(cgnsid)%conn1to1(j)%iEnd < &
1891 cgnsdoms(cgnsid)%conn1to1(j)%iBeg)
then
1897 if (
cgnsdoms(cgnsid)%conn1to1(j)%jEnd < &
1898 cgnsdoms(cgnsid)%conn1to1(j)%jBeg)
then
1904 if (
cgnsdoms(cgnsid)%conn1to1(j)%kEnd < &
1905 cgnsdoms(cgnsid)%conn1to1(j)%kBeg)
then
1914 l1 =
cgnsdoms(cgnsid)%conn1to1(j)%l1
1915 l2 =
cgnsdoms(cgnsid)%conn1to1(j)%l2
1916 l3 =
cgnsdoms(cgnsid)%conn1to1(j)%l3
1918 trmat(1, 1) = sign(1_inttype, l1) *
delta(l1, 1_inttype)
1919 trmat(2, 1) = sign(1_inttype, l1) *
delta(l1, 2_inttype)
1920 trmat(3, 1) = sign(1_inttype, l1) *
delta(l1, 3_inttype)
1922 trmat(1, 2) = sign(1_inttype, l2) *
delta(l2, 1_inttype)
1923 trmat(2, 2) = sign(1_inttype, l2) *
delta(l2, 2_inttype)
1924 trmat(3, 2) = sign(1_inttype, l2) *
delta(l2, 3_inttype)
1926 trmat(1, 3) = sign(1_inttype, l3) *
delta(l3, 1_inttype)
1927 trmat(2, 3) = sign(1_inttype, l3) *
delta(l3, 2_inttype)
1928 trmat(3, 3) = sign(1_inttype, l3) *
delta(l3, 3_inttype)
1933 l1 = ibeg -
cgnsdoms(cgnsid)%conn1to1(j)%iBeg
1934 l2 = jbeg -
cgnsdoms(cgnsid)%conn1to1(j)%jBeg
1935 l3 = kbeg -
cgnsdoms(cgnsid)%conn1to1(j)%kBeg
1937 dibeg =
cgnsdoms(cgnsid)%conn1to1(j)%diBeg &
1938 + trmat(1, 1) * l1 + trmat(1, 2) * l2 + trmat(1, 3) * l3
1939 djbeg =
cgnsdoms(cgnsid)%conn1to1(j)%djBeg &
1940 + trmat(2, 1) * l1 + trmat(2, 2) * l2 + trmat(2, 3) * l3
1941 dkbeg =
cgnsdoms(cgnsid)%conn1to1(j)%dkBeg &
1942 + trmat(3, 1) * l1 + trmat(3, 2) * l2 + trmat(3, 3) * l3
1944 l1 = iend -
cgnsdoms(cgnsid)%conn1to1(j)%iBeg
1945 l2 = jend -
cgnsdoms(cgnsid)%conn1to1(j)%jBeg
1946 l3 = kend -
cgnsdoms(cgnsid)%conn1to1(j)%kBeg
1948 diend =
cgnsdoms(cgnsid)%conn1to1(j)%diBeg &
1949 + trmat(1, 1) * l1 + trmat(1, 2) * l2 + trmat(1, 3) * l3
1950 djend =
cgnsdoms(cgnsid)%conn1to1(j)%djBeg &
1951 + trmat(2, 1) * l1 + trmat(2, 2) * l2 + trmat(2, 3) * l3
1952 dkend =
cgnsdoms(cgnsid)%conn1to1(j)%dkBeg &
1953 + trmat(3, 1) * l1 + trmat(3, 2) * l2 + trmat(3, 3) * l3
1960 if (dibeg > diend)
then
1961 mm = dibeg; dibeg = diend; diend = mm; diswap = .true.
1965 if (djbeg > djend)
then
1966 mm = djbeg; djbeg = djend; djend = mm; djswap = .true.
1970 if (dkbeg > dkend)
then
1971 mm = dkbeg; dkbeg = dkend; dkend = mm; dkswap = .true.
1977 mm =
cgnsdoms(cgnsid)%conn1to1(j)%donorBlock
1978 ranges => splitinfo(mm)%ranges
1980 donorloop:
do k = 1, splitinfo(mm)%nSubblocks
1985 donoroverlap:
if (dibeg <= ranges(k, 1, 2) .and. &
1986 diend >= ranges(k, 1, 1) .and. &
1987 djbeg <= ranges(k, 2, 2) .and. &
1988 djend >= ranges(k, 2, 1) .and. &
1989 dkbeg <= ranges(k, 3, 2) .and. &
1990 dkend >= ranges(k, 3, 1))
then
1995 ibeg = max(dibeg, ranges(k, 1, 1))
1996 iend = min(diend, ranges(k, 1, 2))
1998 jbeg = max(djbeg, ranges(k, 2, 1))
1999 jend = min(djend, ranges(k, 2, 2))
2001 kbeg = max(dkbeg, ranges(k, 3, 1))
2002 kend = min(dkend, ranges(k, 3, 2))
2008 if (ibeg == iend) kk = kk + 1
2009 if (jbeg == jend) kk = kk + 1
2010 if (kbeg == kend) kk = kk + 1
2023 blocks(ii)%BCType(jj) = b2bmatch
2024 blocks(ii)%cgnsSubface(jj) = j
2025 blocks(ii)%groupNum(jj) = 0
2033 blocks(ii)%neighBlock(jj) = nsubpercgns(mm - 1) + k
2039 kk = ibeg; ibeg = iend; iend = kk
2043 kk = jbeg; jbeg = jend; jend = kk
2047 kk = kbeg; kbeg = kend; kend = kk
2053 blocks(ii)%dinBeg(jj) = ibeg - ranges(k, 1, 1) + 1
2054 blocks(ii)%djnBeg(jj) = jbeg - ranges(k, 2, 1) + 1
2055 blocks(ii)%dknBeg(jj) = kbeg - ranges(k, 3, 1) + 1
2057 blocks(ii)%dinEnd(jj) = iend - ranges(k, 1, 1) + 1
2058 blocks(ii)%djnEnd(jj) = jend - ranges(k, 2, 1) + 1
2059 blocks(ii)%dknEnd(jj) = kend - ranges(k, 3, 1) + 1
2066 l1 = ibeg -
cgnsdoms(cgnsid)%conn1to1(j)%diBeg
2067 l2 = jbeg -
cgnsdoms(cgnsid)%conn1to1(j)%djBeg
2068 l3 = kbeg -
cgnsdoms(cgnsid)%conn1to1(j)%dkBeg
2070 ibeg =
cgnsdoms(cgnsid)%conn1to1(j)%iBeg &
2071 + trmat(1, 1) * l1 + trmat(2, 1) * l2 + trmat(3, 1) * l3
2072 jbeg =
cgnsdoms(cgnsid)%conn1to1(j)%jBeg &
2073 + trmat(1, 2) * l1 + trmat(2, 2) * l2 + trmat(3, 2) * l3
2074 kbeg =
cgnsdoms(cgnsid)%conn1to1(j)%kBeg &
2075 + trmat(1, 3) * l1 + trmat(2, 3) * l2 + trmat(3, 3) * l3
2077 l1 = iend -
cgnsdoms(cgnsid)%conn1to1(j)%diBeg
2078 l2 = jend -
cgnsdoms(cgnsid)%conn1to1(j)%djBeg
2079 l3 = kend -
cgnsdoms(cgnsid)%conn1to1(j)%dkBeg
2081 iend =
cgnsdoms(cgnsid)%conn1to1(j)%iBeg &
2082 + trmat(1, 1) * l1 + trmat(2, 1) * l2 + trmat(3, 1) * l3
2083 jend =
cgnsdoms(cgnsid)%conn1to1(j)%jBeg &
2084 + trmat(1, 2) * l1 + trmat(2, 2) * l2 + trmat(3, 2) * l3
2085 kend =
cgnsdoms(cgnsid)%conn1to1(j)%kBeg &
2086 + trmat(1, 3) * l1 + trmat(2, 3) * l2 + trmat(3, 3) * l3
2102 if (ibeg == iend)
then
2104 blocks(ii)%BCFaceID(jj) = imax
2105 if (ibeg ==
blocks(ii)%iBegor) &
2106 blocks(ii)%BCFaceID(jj) = imin
2108 else if (jbeg == jend)
then
2110 blocks(ii)%BCFaceID(jj) = jmax
2111 if (jbeg ==
blocks(ii)%jBegor) &
2112 blocks(ii)%BCFaceID(jj) = jmin
2116 blocks(ii)%BCFaceID(jj) = kmax
2117 if (kbeg ==
blocks(ii)%kBegor) &
2118 blocks(ii)%BCFaceID(jj) = kmin
2148 integer(kind=intType),
intent(in) :: cgnsID, ii
2149 integer(kind=intType),
intent(inout) :: jj, nAlloc
2151 integer(kind=intType),
dimension(0:cgnsNDom),
intent(in) :: &
2157 integer(kind=intType) :: indFace, jBeg, jEnd, kBeg, kEnd
2158 integer(kind=intType) :: i, i2, j, k, faceID
2162 if (
blocks(ii)%iBegor > 1)
then
2167 indface =
blocks(ii)%iBegor
2174 i2 = 2; faceid = imin
2190 indface =
blocks(ii)%iEndor
2197 i2 = 1; faceid = imax
2208 if (
blocks(ii)%jBegor > 1)
then
2213 indface =
blocks(ii)%jBegor
2220 i2 = 2; faceid = jmin
2236 indface =
blocks(ii)%jEndor
2243 i2 = 1; faceid = jmax
2254 if (
blocks(ii)%kBegor > 1)
then
2259 indface =
blocks(ii)%kBegor
2266 i2 = 2; faceid = kmin
2282 indface =
blocks(ii)%kEndor
2289 i2 = 1; faceid = kmax
2315 integer(kind=intType) :: mm, jnBeg, jnEnd, knBeg, knEnd
2317 integer(kind=intType),
dimension(3, 2) :: subRange
2319 integer(kind=intType),
dimension(:, :, :),
pointer :: ranges
2323 ranges => splitinfo%ranges
2328 do mm = 1, splitinfo%nSubblocks
2333 if (ranges(mm, i, i2) == indface)
then
2337 if (jbeg <= ranges(mm, j, 2) .and. &
2338 jend >= ranges(mm, j, 1) .and. &
2339 kbeg <= ranges(mm, k, 2) .and. &
2340 kend >= ranges(mm, k, 1))
then
2345 jnbeg = max(jbeg, ranges(mm, j, 1))
2346 jnend = min(jend, ranges(mm, j, 2))
2348 knbeg = max(kbeg, ranges(mm, k, 1))
2349 knend = min(kend, ranges(mm, k, 2))
2353 if (jnend > jnbeg .and. knend > knbeg)
then
2367 blocks(ii)%BCType(jj) = b2bmatch
2368 blocks(ii)%BCFaceID(jj) = faceid
2369 blocks(ii)%cgnsSubface(jj) = 0
2370 blocks(ii)%groupNum(jj) = 0
2375 subrange(i, 1) = indface; subrange(i, 2) = indface
2376 subrange(j, 1) = jnbeg; subrange(j, 2) = jnend
2377 subrange(k, 1) = knbeg; subrange(k, 2) = knend
2381 blocks(ii)%inBeg(jj) = subrange(1, 1) &
2383 blocks(ii)%inEnd(jj) = subrange(1, 2) &
2386 blocks(ii)%jnBeg(jj) = subrange(2, 1) &
2388 blocks(ii)%jnEnd(jj) = subrange(2, 2) &
2391 blocks(ii)%knBeg(jj) = subrange(3, 1) &
2393 blocks(ii)%knEnd(jj) = subrange(3, 2) &
2398 blocks(ii)%dinBeg(jj) = subrange(1, 1) &
2399 - ranges(mm, 1, 1) + 1
2400 blocks(ii)%dinEnd(jj) = subrange(1, 2) &
2401 - ranges(mm, 1, 1) + 1
2403 blocks(ii)%djnBeg(jj) = subrange(2, 1) &
2404 - ranges(mm, 2, 1) + 1
2405 blocks(ii)%djnEnd(jj) = subrange(2, 2) &
2406 - ranges(mm, 2, 1) + 1
2408 blocks(ii)%dknBeg(jj) = subrange(3, 1) &
2409 - ranges(mm, 3, 1) + 1
2410 blocks(ii)%dknEnd(jj) = subrange(3, 2) &
2411 - ranges(mm, 3, 1) + 1
2419 blocks(ii)%neighBlock(jj) = mm + nsubpercgns(cgnsid - 1)
2449 logical,
intent(out) :: emptyPartitions, commNeglected
2482 integer :: nVertex, nCon, wgtflag, numflag, nParts, edgecut
2483 integer,
dimension(5) :: options
2485 integer(kind=intType),
dimension(:),
allocatable :: xadj, adjncy
2486 integer(kind=intType),
dimension(:),
allocatable :: adjwgt
2487 integer(kind=intType),
dimension(:, :),
allocatable :: vwgt
2493 integer(kind=intType) :: i, j
2494 integer(kind=intType) :: nEdges, nEdgesMax, ii, jj, kk
2496 integer(kind=intType),
dimension(0:nProc - 1) :: nBlockPerProc
2498 integer(kind=intType),
dimension(:),
allocatable :: tmp
2500 integer(kind=8) :: nCellsTotal
2501 integer(kind=8) :: nFacesTotal
2503 real(kind=4) :: ubvec_temp(2)
2508 if (
allocated(
part))
then
2509 deallocate (
part, stat=ierr)
2512 "Deallocation failure for part")
2522 nedges = nedges + ii
2523 nedgesmax = max(nedgesmax, ii)
2539 allocate (xadj(0:nvertex), vwgt(ncon, nvertex), adjncy(nedges), &
2540 adjwgt(nedges),
part(nvertex), tmp(nedgesmax), stat=ierr)
2543 "Memory allocation failure for graph variables")
2554 graphvertex:
do i = 1,
nblocks
2558 vwgt(1, i) =
blocks(i)%nCell
2559 vwgt(2, i) =
blocks(i)%nFace
2567 do j = 1,
blocks(i)%n1to1
2568 ii =
blocks(i)%nBocos + j
2569 if (
blocks(i)%neighBlock(ii) /= i)
then
2571 tmp(nedges) =
blocks(i)%neighBlock(ii)
2580 ii = min(nedges, 1_inttype)
2582 if (tmp(j) /= tmp(ii))
then
2591 xadj(i) = xadj(i - 1) + nedges
2596 edges1to1:
do j = 1,
blocks(i)%n1to1
2598 ii =
blocks(i)%nBocos + j
2599 if (
blocks(i)%neighBlock(ii) /= i)
then
2608 adjncy(jj) =
blocks(i)%neighBlock(ii) - 1
2616 adjwgt(jj) = adjwgt(jj) + 2 * &
2617 (max(abs(
blocks(i)%inEnd(ii) -
blocks(i)%inBeg(ii)), kk) &
2618 * max(abs(
blocks(i)%jnEnd(ii) -
blocks(i)%jnBeg(ii)), kk) &
2619 * max(abs(
blocks(i)%knEnd(ii) -
blocks(i)%knBeg(ii)), kk))
2635 ncellstotal = ncellstotal + vwgt(1, i)
2636 nfacestotal = nfacestotal + vwgt(2, i)
2639 if (ncellstotal > 2147483647 .or. nfacestotal > 2147483647)
then
2640 ncellstotal = ncellstotal / 2147483647 + 1
2641 nfacestotal = nfacestotal / 2147483647 + 1
2644 vwgt(1, i) = vwgt(1, i) / ncellstotal
2645 vwgt(2, i) = vwgt(2, i) / nfacestotal
2658 commneglected = .false.
2659 attemptloop:
do ii = 1, 2
2663 ubvec_temp(1) = real(
ubvec(1))
2664 ubvec_temp(2) = real(
ubvec(2))
2667 adjwgt, wgtflag, numflag, nparts, &
2668 ubvec_temp, options, edgecut,
part)
2673 nblockperproc(
part(i)) = nblockperproc(
part(i)) + 1
2678 emptypartitions = .false.
2680 if (nblockperproc(i) == 0) emptypartitions = .true.
2686 if (ii == 2 .or. (.not. emptypartitions))
exit attemptloop
2692 commneglected = .true.
2699 deallocate (xadj, vwgt, adjncy, adjwgt, tmp, stat=ierr)
2702 "Deallocation failure for graph variables")
2718 logical,
intent(out) :: cellsBalanced, facesBalanced
2722 integer(kind=intType) :: i, j
2723 integer(kind=intType) :: nCellMax, nCellTol
2724 integer(kind=intType) :: nFaceMax, nFaceTol
2726 integer(kind=intType),
dimension(nProc) :: nCell, nFace
2728 integer(kind=8) :: nCellsEven, nFacesEven
2743 ncell(j) = ncell(j) +
blocks(i)%nCell
2744 nface(j) = nface(j) +
blocks(i)%nFace
2749 ncellseven = ncell(1)
2750 nfaceseven = nface(1)
2753 ncellseven = ncellseven + ncell(i)
2754 nfaceseven = nfaceseven + nface(i)
2757 ncellseven = ncellseven /
nproc
2758 nfaceseven = nfaceseven /
nproc
2763 ncellmax = abs(maxval(ncell) - ncellseven)
2764 nfacemax = abs(maxval(nface) - nfaceseven)
2768 ncelltol = (
ubvec(1) -
one) * ncellseven
2769 nfacetol = (
ubvec(2) -
one) * nfaceseven
2774 cellsbalanced = .true.
2775 facesbalanced = .true.
2777 if (ncellmax > ncelltol) cellsbalanced = .false.
2778 if (nfacemax > nfacetol) facesbalanced = .false.
2783 ubvec(1) = real(ncellmax, realtype) &
2784 / real(ncellseven, realtype)
2785 ubvec(2) = real(nfacemax, realtype) &
2786 / real(nfaceseven, realtype)
2812 integer(kind=intType),
intent(in) :: nCells
2813 integer(kind=intType),
intent(inout) :: nSub
2815 integer(kind=intType),
dimension(nSub, 3, 2),
intent(out) :: ranges
2819 integer(kind=intType) :: nLevels, level, nn, mm, nTarget
2820 integer(kind=intType) :: nSplit, nSplitNew
2822 integer(kind=intType),
dimension(nSub) :: nSubblocks
2824 logical,
dimension(3) :: viscousDir
2828 viscousdir = .false.
2829 do nn = 1, compblock%nBocos
2837 select case (compblock%BCFaceID(nn))
2839 viscousdir(1) = .true.
2842 viscousdir(2) = .true.
2845 viscousdir(3) = .true.
2856 nlevels = log(real(nsub, realtype)) / log(
two)
2857 if (2**nlevels < nsub) nlevels = nlevels + 1
2862 ranges(1, 1, 1) = 1; ranges(1, 1, 2) = compblock%il
2863 ranges(1, 2, 1) = 1; ranges(1, 2, 2) = compblock%jl
2864 ranges(1, 3, 1) = 1; ranges(1, 3, 2) = compblock%kl
2870 nsubblocks(1) = nsub
2874 levelloop:
do level = 1, nlevels
2884 blocksplitloop:
do nn = 1, nsplit
2888 select case (nsubblocks(nn))
2890 case (2_inttype, 3_inttype)
2900 nsplitnew = nsplitnew + 1
2901 nsubblocks(nsplitnew) = 1
2902 nsubblocks(nn) = nsubblocks(nn) - 1
2907 call split2block(nsub, nn, nsplitnew, ncells, ranges, &
2921 nsplitnew = nsplitnew + 1
2922 nsubblocks(nsplitnew) = nsubblocks(nn) / 2
2923 nsubblocks(nn) = nsubblocks(nn) &
2924 - nsubblocks(nsplitnew)
2929 ntarget = (ranges(nn, 1, 2) - ranges(nn, 1, 1)) &
2930 * (ranges(nn, 2, 2) - ranges(nn, 2, 1)) &
2931 * (ranges(nn, 3, 2) - ranges(nn, 3, 1))
2932 ntarget = ntarget * (real(nsubblocks(nsplitnew), realtype) &
2933 / real(mm, realtype))
2938 call split2block(nsub, nn, nsplitnew, ntarget, ranges, &
2943 end do blocksplitloop
2961 if (ranges(nn, 1, 2) > ranges(nn, 1, 1) .and. &
2962 ranges(nn, 2, 2) > ranges(nn, 2, 1) .and. &
2963 ranges(nn, 3, 2) > ranges(nn, 3, 1))
then
2970 ranges(nsub, 1, 1) = ranges(nn, 1, 1) + compblock%iBegor - 1
2971 ranges(nsub, 2, 1) = ranges(nn, 2, 1) + compblock%jBegor - 1
2972 ranges(nsub, 3, 1) = ranges(nn, 3, 1) + compblock%kBegor - 1
2974 ranges(nsub, 1, 2) = ranges(nn, 1, 2) + compblock%iBegor - 1
2975 ranges(nsub, 2, 2) = ranges(nn, 2, 2) + compblock%jBegor - 1
2976 ranges(nsub, 3, 2) = ranges(nn, 3, 2) + compblock%kBegor - 1
2998 integer(kind=intType),
intent(in) :: nSub, n1, n2, nTarget
3000 integer(kind=intType),
dimension(nSub, 3, 2),
intent(inout) :: ranges
3002 logical,
dimension(3),
intent(in) :: viscousDir
3006 integer(kind=intType) :: nMG, mm, ii, jj, i, iiOpt, iOpt
3007 integer(kind=intType) :: nCellOpt
3009 integer(kind=intType),
dimension(3) :: nc, mc, c, nf, prefDir
3018 nc(1) = ranges(n1, 1, 2) - ranges(n1, 1, 1)
3019 nc(2) = ranges(n1, 2, 2) - ranges(n1, 2, 1)
3020 nc(3) = ranges(n1, 3, 2) - ranges(n1, 3, 1)
3024 loopdir:
do mm = 1, 3
3041 if (nf(mm) == nmg)
exit
3042 if (mod(nc(mm), ii) /= 0)
exit
3057 c(mm) = 2 * nc(mm) / ii
3058 mc(mm) = nc(mm) / c(mm)
3065 if (nmg > 1 .and. max(c(1), c(2), c(3)) == 1)
then
3066 c(1) = c(1) * 2; c(2) = c(2) * 2; c(3) = c(3) * 2
3067 mc(1) = mc(1) / 2; mc(2) = mc(2) / 2; mc(3) = mc(3) / 2
3073 nf(1) = nc(2) * nc(3)
3074 nf(2) = nc(1) * nc(3)
3075 nf(3) = nc(1) * nc(2)
3082 if (nf(1) < nf(2))
then
3083 if (nf(1) < nf(3))
then
3085 if (nf(2) < nf(3))
then
3097 else if (nf(2) < nf(3))
then
3099 if (nf(1) < nf(3))
then
3119 if (viscousdir(prefdir(1)))
then
3120 if (.not. viscousdir(prefdir(2)))
then
3122 prefdir(1) = prefdir(2)
3124 else if (.not. viscousdir(prefdir(3)))
then
3126 prefdir(1) = prefdir(3)
3134 if (viscousdir(prefdir(2)) .and. &
3135 .not. viscousdir(prefdir(3)))
then
3137 prefdir(2) = prefdir(3)
3144 ncellopt = 10 * nc(1) * nc(2) * nc(3)
3155 i = nint(real(ntarget, realtype) &
3156 / real(mc(ii) * nf(ii), realtype), inttype)
3157 i = max(i, 1_inttype)
3163 jj = i * mc(ii) * nf(ii)
3164 if (abs(jj - ntarget) < abs(ncellopt - ntarget))
then
3174 ranges(n2, 1, 1) = ranges(n1, 1, 1); ranges(n2, 1, 2) = ranges(n1, 1, 2)
3175 ranges(n2, 2, 1) = ranges(n1, 2, 1); ranges(n2, 2, 2) = ranges(n1, 2, 2)
3176 ranges(n2, 3, 1) = ranges(n1, 3, 1); ranges(n2, 3, 2) = ranges(n1, 3, 2)
3180 jj = iopt * mc(iiopt) + ranges(n1, iiopt, 1)
3187 ranges(n2, iiopt, 2) = jj
3188 ranges(n1, iiopt, 1) = jj
3206 integer(kind=intType),
intent(in) :: ii
3207 integer(kind=intType),
intent(inout) :: nAlloc
3211 integer(kind=intType) :: nOld, nNew
subroutine splitblocksloadbalance
subroutine searchinternalneighbors
logical function splittingisokay(cgnsID)
subroutine splitblockinitialization(cgnsID)
void metisinterface(int *n, int *ncon, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, float *ubvec, int *options, int *edgecut, idxtype *part)
integer(kind=inttype) ndom
type(blocktype), dimension(:, :, :), allocatable, target flowdoms
type(cgnsblockinfotype), dimension(:), allocatable cgnsdoms
type(cgnsfamilytype), dimension(:), allocatable cgnsfamilies
integer(kind=inttype) cgnsndom
integer adflow_comm_world
integer(kind=inttype), parameter domaininterfacep
integer(kind=inttype), parameter slidinginterface
integer(kind=inttype), parameter eulerwall
integer(kind=inttype), parameter farfield
integer(kind=inttype), parameter oversetouterbound
integer(kind=inttype), parameter massbleedoutflow
integer(kind=inttype), parameter domaininterfacerhouvw
integer(kind=inttype), parameter domaininterfacerho
integer(kind=inttype), parameter imax
integer(kind=inttype), parameter supersonicinflow
integer(kind=inttype), parameter kmin
integer(kind=inttype), parameter massbleedinflow
integer(kind=inttype), parameter jmax
integer(kind=inttype), parameter supersonicoutflow
integer(kind=inttype), parameter mdot
integer(kind=inttype), parameter b2bmatch
integer(kind=inttype), parameter nswalladiabatic
integer(kind=inttype), parameter symm
integer(kind=inttype), parameter timespectral
integer(kind=inttype), parameter unsteady
integer(kind=inttype), parameter symmpolar
integer(kind=inttype), parameter subsonicoutflow
integer(kind=inttype), parameter rungekutta
real(kind=realtype), parameter one
integer(kind=inttype), parameter imin
integer(kind=inttype), parameter domaininterfacetotal
real(kind=realtype), parameter two
integer(kind=inttype), parameter bcthrust
integer(kind=inttype), parameter nswallisothermal
integer(kind=inttype), parameter domaininterfaceall
integer(kind=inttype), parameter subsonicinflow
integer(kind=inttype), parameter kmax
integer(kind=inttype), parameter jmin
integer(kind=inttype), parameter extrap
subroutine checkloadbalance(cellsBalanced, facesBalanced)
subroutine graphpartitioning(emptyPartitions, commNeglected)
subroutine splitblock(compBlock, nSub, nCells, ranges)
subroutine loadbalancegrid
subroutine blockdistribution
subroutine externalfacessubblock(cgnsID, ii, jj, nSubPerCGNS, nAlloc, splitInfo)
subroutine bcfacessubblock(cgnsID, ii, jj)
subroutine reallocsubfacememory(ii, nAlloc)
subroutine determinecomputeblocks(splitInfo)
subroutine sortsubfaces(oldSubfaceID, blockID)
subroutine internalfacessubblock(cgnsID, ii, jj, nSubPerCGNS, nAlloc, splitInfo)
subroutine split2block(nSub, n1, n2, nTarget, ranges, viscousDir)
subroutine sortrangessplitinfo(splitInfo)
subroutine qsortsubblocksofcgnstype(arr, nn)
integer(kind=inttype), dimension(:), allocatable part
integer(kind=inttype) nblocks
type(distributionblocktype), dimension(:), allocatable blocks
subroutine qsortintegers(arr, nn)
integer(kind=inttype) function bsearchintegers(key, base)
subroutine reallocateinteger(intArray, newSize, oldSize, alwaysFreeMem)
subroutine nullifyflowdompointers(nn, level, sps)
integer(kind=inttype) function delta(val1, val2)
subroutine terminate(routineName, errorMessage)