18 integer(kind=intType),
intent(in),
dimension(:) :: zipperFamLIst
19 integer(kind=intType),
intent(in) :: level, sps
22 integer(kind=intType) :: i, j, k, nn, mm, ii, jj, kk, c, e, idx
23 integer(kind=intType) :: i1, i2, j1, j2, iBeg, iEnd, jBeg, jEnd
24 integer(kind=intType) :: i3, i4, j3, j4
25 integer(kind=intType) :: iStart, iSize, ierr, iProc, firstElem, curElem
26 integer(kind=intType) :: below, above, left, right, nNodes, nElems
27 integer(kind=intType) :: patchNodeCounter, nZipped, gc
28 integer(kind=intType),
dimension(:),
allocatable :: nElemsProc, nNodesProc
29 integer(kind=intType),
dimension(:, :),
pointer :: gcp
30 real(kind=realtype),
dimension(:, :, :),
pointer :: xx
31 real(kind=realtype),
dimension(3) :: s1, s2, s3, s4, v1, v2, v3, v4, x0
32 real(kind=realtype) :: fact, timea, minnorm
34 real(kind=realtype),
dimension(:, :, :),
allocatable :: patchnormals
35 real(kind=realtype),
dimension(:, :),
allocatable :: patchh
36 integer(kind=intType),
dimension(:),
allocatable :: epc, surfaceSeeds, inverse
37 logical,
dimension(:),
allocatable :: badString
38 type(
oversetstring),
dimension(:),
allocatable,
target :: localStrings
39 type(
oversetstring),
dimension(:),
allocatable,
target :: globalStrings
42 type(
oversetstring),
dimension(:),
allocatable,
target :: strings
43 integer(kind=intType) :: nFullStrings, nUnique, famID
44 logical :: regularOrdering
45 integer mpiStatus(MPI_STATUS_SIZE)
48 integer(kind=intType) :: ncells
49 type(
oversetwall),
dimension(:),
allocatable,
target :: walls
51 character(80) :: fileName
64 domainloop:
do nn = 1, ndom
66 call getwallsize(zipperfamlist, nnodes, nelems, .false.)
68 epc(c) = epc(c) + 2 * nnodes
79 localstrings(c)%conn(2, epc(c)), localstrings(c)%nodeData(10, 2 * epc(c)), &
80 localstrings(c)%intNodeData(3, 2 * epc(c)))
81 localstrings(c)%nodeData =
zero
82 localstrings(c)%nNodes = 0
83 localstrings(c)%nElems = 0
97 domainloop2:
do nn = 1, ndom
102 bocoloop:
do mm = 1,
nbocos
104 if (
faminlist(famid, zipperfamlist))
then
111 regularordering = .true.
116 regularordering = .false.
121 regularordering = .false.
126 regularordering = .true.
131 regularordering = .true.
136 regularordering = .false.
142 regularordering = .not. (regularordering)
151 allocate (patchnormals(3, ibeg:iend, jbeg:jend), &
152 patchh(ibeg:iend, jbeg:jend))
156 patchnodecounter = patchnodecounter + 1
157 x0 = xx(i + 1, j + 1, :)
160 v1 = xx(i + 2, j + 1, :) - x0
161 v2 = xx(i + 1, j + 2, :) - x0
162 v3 = xx(i, j + 1, :) - x0
163 v4 = xx(i + 1, j, :) - x0
175 s1 = s1 / max(minnorm,
mynorm2(s1))
176 s2 = s2 / max(minnorm,
mynorm2(s2))
177 s3 = s3 / max(minnorm,
mynorm2(s3))
178 s4 = s4 / max(minnorm,
mynorm2(s4))
182 s1 =
fourth * (s1 + s2 + s3 + s4)
183 patchnormals(:, i, j) = s1 /
mynorm2(s1) * fact
187 v1 = xx(i + 2, j + 2, :) - x0
188 v2 = xx(i, j + 2, :) - x0
189 v3 = xx(i, j, :) - x0
190 v4 = xx(i + 2, j, :) - x0
201 do i = ibeg + 1, iend
202 if (gcp(i + 1, j + 1) >= 0 .and. gcp(i + 1, j + 2) >= 0)
then
203 below = max(
bcdata(mm)%iBlank(i, j), 0)
204 above = max(
bcdata(mm)%iBlank(i, j + 1), 0)
206 if ((below == 0 .and. above == 1) .or. (below == 1 .and. above == 0))
then
207 localstrings(c)%nNodes = localstrings(c)%nNodes + 2
208 localstrings(c)%nElems = localstrings(c)%nElems + 1
209 e = localstrings(c)%nElems
229 if (regularordering)
then
230 localstrings(c)%nodeData(1:3, 2 * e - 1) = xx(i1 + 1, j1 + 1, :)
231 localstrings(c)%nodeData(1:3, 2 * e) = xx(i2 + 1, j2 + 1, :)
234 localstrings(c)%intNodeData(1, 2 * e - 1) =
bcdata(mm)%surfIndex(i1, j1)
235 localstrings(c)%intNodeData(1, 2 * e) =
bcdata(mm)%surfIndex(i2, j2)
237 localstrings(c)%nodeData(1:3, 2 * e) = xx(i1 + 1, j1 + 1, :)
238 localstrings(c)%nodeData(1:3, 2 * e - 1) = xx(i2 + 1, j2 + 1, :)
240 localstrings(c)%intNodeData(1, 2 * e) =
bcdata(mm)%surfIndex(i1, j1)
241 localstrings(c)%intNodeData(1, 2 * e - 1) =
bcdata(mm)%surfIndex(i2, j2)
244 v1 = xx(i1 + 1, j1 + 1, :) - xx(i3 + 1, j3 + 1, :)
247 v2 = xx(i2 + 1, j2 + 1, :) - xx(i4 + 1, j4 + 1, :)
251 localstrings(c)%nodeData(7:9, 2 * e - 1) = v1
252 localstrings(c)%nodeData(7:9, 2 * e) = v2
255 localstrings(c)%nodeData(4:6, 2 * e - 1) = patchnormals(:, i1, j1)
256 localstrings(c)%nodeData(4:6, 2 * e) = patchnormals(:, i2, j2)
259 localstrings(c)%nodeData(10, 2 * e - 1) = patchh(i1, j1)
260 localstrings(c)%nodeData(10, 2 * e) = patchh(i2, j2)
263 localstrings(c)%intNodeData(2, 2 * e - 1) = c
264 localstrings(c)%intNodeData(2, 2 * e) = c
267 localstrings(c)%intNodeData(3, 2 * e - 1) = famid
268 localstrings(c)%intNodeData(3, 2 * e) = famid
271 localstrings(c)%conn(:, e) = (/2 * e - 1, 2 * e/)
280 do j = jbeg + 1, jend
282 if (gcp(i + 1, j + 1) >= 0 .and. gcp(i + 2, j + 1) >= 0)
then
283 left = max(
bcdata(mm)%iBlank(i, j), 0)
284 right = max(
bcdata(mm)%iBlank(i + 1, j), 0)
286 if ((left == 0 .and. right == 1) .or. (left == 1 .and. right == 0))
then
287 localstrings(c)%nNodes = localstrings(c)%nNodes + 2
288 localstrings(c)%nElems = localstrings(c)%nElems + 1
290 e = localstrings(c)%nElems
310 if (regularordering)
then
311 localstrings(c)%nodeData(1:3, 2 * e - 1) = xx(i1 + 1, j1 + 1, :)
312 localstrings(c)%nodeData(1:3, 2 * e) = xx(i2 + 1, j2 + 1, :)
315 localstrings(c)%intNodeData(1, 2 * e - 1) =
bcdata(mm)%surfIndex(i1, j1)
316 localstrings(c)%intNodeData(1, 2 * e) =
bcdata(mm)%surfIndex(i2, j2)
319 localstrings(c)%nodeData(1:3, 2 * e) = xx(i1 + 1, j1 + 1, :)
320 localstrings(c)%nodeData(1:3, 2 * e - 1) = xx(i2 + 1, j2 + 1, :)
323 localstrings(c)%intNodeData(1, 2 * e) =
bcdata(mm)%surfIndex(i1, j1)
324 localstrings(c)%intNodeData(1, 2 * e - 1) =
bcdata(mm)%surfIndex(i2, j2)
328 v1 = xx(i1 + 1, j1 + 1, :) - xx(i3 + 1, j3 + 1, :)
331 v2 = xx(i2 + 1, j2 + 1, :) - xx(i4 + 1, j4 + 1, :)
335 localstrings(c)%nodeData(7:9, 2 * e - 1) = v1
336 localstrings(c)%nodeData(7:9, 2 * e) = v2
339 localstrings(c)%nodeData(4:6, 2 * e - 1) = patchnormals(:, i1, j1)
340 localstrings(c)%nodeData(4:6, 2 * e) = patchnormals(:, i2, j2)
343 localstrings(c)%nodeData(10, 2 * e - 1) = patchh(i1, j1)
344 localstrings(c)%nodeData(10, 2 * e) = patchh(i2, j2)
347 localstrings(c)%intNodeData(2, 2 * e - 1) = c
348 localstrings(c)%intNodeData(2, 2 * e) = c
351 localstrings(c)%intNodeData(3, 2 * e - 1) = famid
352 localstrings(c)%intNodeData(3, 2 * e) = famid
355 localstrings(c)%conn(:, e) = (/2 * e - 1, 2 * e/)
360 deallocate (patchnormals, patchh)
381 allocate (nnodesproc(0:
nproc), nelemsproc(0:
nproc))
389 call mpi_gather(localstrings(c)%nElems, 1, adflow_integer, nelemsproc(1:
nproc), 1, adflow_integer, 0, &
391 call echk(ierr, __file__, __line__)
393 call mpi_gather(localstrings(c)%nNodes, 1, adflow_integer, nnodesproc(1:
nproc), 1, adflow_integer, 0, &
395 call echk(ierr, __file__, __line__)
405 nnodesproc(i) = nnodesproc(i) + nnodesproc(i - 1)
406 nelemsproc(i) = nelemsproc(i) + nelemsproc(i - 1)
409 allocate (globalstrings(c)%nodeData(10, nnodesproc(
nproc)), &
410 globalstrings(c)%intNodeData(3, nnodesproc(
nproc)), &
411 globalstrings(c)%conn(2, nelemsproc(
nproc)))
417 do i = 1, localstrings(c)%nNodes
418 globalstrings(c)%nodeData(:, i) = localstrings(c)%nodeData(:, i)
419 globalstrings(c)%intNodeData(:, i) = localstrings(c)%intNodeData(:, i)
423 do i = 1, localstrings(c)%nElems
424 globalstrings(c)%conn(:, i) = localstrings(c)%conn(:, i)
428 globalstrings(c)%nNodes = nnodesproc(
nproc)
429 globalstrings(c)%nElems = nelemsproc(
nproc)
432 do iproc = 1,
nproc - 1
434 if ((nelemsproc(iproc + 1) - nelemsproc(iproc)) > 0)
then
435 istart = nnodesproc(iproc) + 1
436 iend = nnodesproc(iproc + 1)
437 isize = iend - istart + 1
440 call mpi_recv(globalstrings(c)%nodeData(:, istart:iend), isize * 10, &
441 adflow_real, iproc, iproc, &
443 call echk(ierr, __file__, __line__)
445 call mpi_recv(globalstrings(c)%intNodeData(:, istart:iend), isize * 3, &
446 adflow_integer, iproc, iproc, &
448 call echk(ierr, __file__, __line__)
451 istart = nelemsproc(iproc) + 1
452 iend = nelemsproc(iproc + 1)
453 isize = iend - istart + 1
454 call mpi_recv(globalstrings(c)%conn(:, istart:iend), isize * 2, adflow_integer, iproc, iproc, &
456 call echk(ierr, __file__, __line__)
460 globalstrings(c)%conn(:, i) = globalstrings(c)%conn(:, i) + nnodesproc(iproc)
466 if (localstrings(c)%nElems > 0)
then
469 call mpi_send(localstrings(c)%nodeData, 10 * localstrings(c)%nNodes, adflow_real, 0,
myid, &
471 call echk(ierr, __file__, __line__)
473 call mpi_send(localstrings(c)%intNodeData, 3 * localstrings(c)%nNodes, adflow_integer, 0,
myid, &
475 call echk(ierr, __file__, __line__)
478 call mpi_send(localstrings(c)%conn, 2 * localstrings(c)%nElems, adflow_integer, 0,
myid, &
480 call echk(ierr, __file__, __line__)
490 deallocate (localstrings)
501 call buildclusterwalls(level, sps, .false., walls, zipperfamlist,
size(zipperfamlist))
509 nnodes = nnodes + walls(i)%nNodes
510 ncells = ncells + walls(i)%nCells
513 allocate (fullwall%x(3, nnodes))
514 allocate (fullwall%conn(4, ncells))
515 allocate (fullwall%ind(nnodes))
516 allocate (fullwall%indCell(ncells))
525 do j = 1, walls(i)%nNodes
527 fullwall%x(:, nnodes) = walls(i)%x(:, j)
528 fullwall%ind(nnodes) = walls(i)%ind(j)
531 do j = 1, walls(i)%nCells
533 fullwall%conn(:, ncells) = walls(i)%conn(:, j) + ii
534 fullwall%indCell(ncells) = walls(i)%indCell(j)
538 ii = ii + walls(i)%nNodes
542 fullwall%nCells = ncells
543 fullwall%nNodes = nnodes
544 call buildserialquad(ncells, nnodes, fullwall%x, fullwall%conn, fullwall%ADT)
568 nelems = nelems + globalstrings(c)%nElems
569 nnodes = nnodes + globalstrings(c)%nNodes
573 master%nNodes = nnodes
574 master%nElems = nelems
575 allocate (master%nodeData(10, nnodes), master%conn(2, nelems), &
576 master%intNodeData(3, nnodes))
586 do i = 1, globalstrings(c)%nNodes
588 master%nodeData(:, ii) = globalstrings(c)%nodeData(:, i)
589 master%intNodeData(:, ii) = globalstrings(c)%intNodeData(:, i)
592 do i = 1, globalstrings(c)%nElems
594 master%conn(:, jj) = globalstrings(c)%conn(:, i) + nnodes
604 deallocate (globalstrings)
subroutine buildclusterwalls(level, sps, useDual, walls, famList, nFamList)
subroutine buildserialquad(nQuad, nNodes, coor, quadsConn, ADT)
integer(kind=inttype), dimension(:, :, :), pointer globalcell
integer(kind=inttype), dimension(:), pointer bcfaceid
integer(kind=inttype) nbocos
integer(kind=inttype), dimension(:, :, :), pointer globalnode
integer(kind=inttype), dimension(:), pointer bctype
real(kind=realtype), dimension(:, :, :, :), pointer x
integer adflow_comm_world
real(kind=realtype), parameter zero
integer(kind=inttype), parameter imax
integer(kind=inttype), parameter kmin
integer(kind=inttype), parameter jmax
real(kind=realtype), parameter one
integer(kind=inttype), parameter imin
real(kind=realtype), parameter fourth
integer(kind=inttype), parameter kmax
integer(kind=inttype), parameter jmin
subroutine makegapboundarystrings(zipperFamList, level, sps, master)
integer(kind=inttype) nclusters
integer(kind=inttype), dimension(:), allocatable cumdomproc
integer(kind=inttype), dimension(:), allocatable clusters
subroutine getwallsize(famList, nNodes, nCells, dualMesh)
logical function faminlist(famID, famList)
subroutine reducegapstring(string)
subroutine nullifystring(string)
subroutine deallocatestring(string)
subroutine setstringpointers(string)
subroutine cross_prod(a, b, c)
real(kind=realtype) function mynorm2(x)
subroutine echk(errorcode, file, line)
subroutine setpointers(nn, mm, ll)