Build a rank-replicated forest over a decomposed base mesh: allgather the global node coordinates, side table, and material ids (by the decomposition's contiguous element ownership) and initialize the forest from the global tables. Collective over the mesh communicator; runs once, at controller initialization.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(QuadTreeMesh2D), | intent(out) | :: | forest | |||
| type(Mesh2D), | intent(in) | :: | mesh |
subroutine InitForestFromDecomposedMesh(forest,mesh)
!! Build a rank-replicated forest over a decomposed base mesh: allgather the global
!! node coordinates, side table, and material ids (by the decomposition's contiguous
!! element ownership) and initialize the forest from the global tables. Collective over
!! the mesh communicator; runs once, at controller initialization.
implicit none
type(QuadTreeMesh2D),intent(out) :: forest
type(Mesh2D),intent(in) :: mesh
! Local
integer :: nG,nGeo,r,s
real(prec),allocatable :: coordsG(:,:,:,:)
integer,allocatable :: siG(:,:,:),matG(:)
integer,allocatable :: nbr(:,:),nbrSide(:,:),flip(:,:),bc(:,:)
nG = mesh%decomp%nElem ! global element count
nGeo = mesh%nGeo
allocate(coordsG(1:2,1:nGeo+1,1:nGeo+1,1:nG))
allocate(siG(1:5,1:4,1:nG))
allocate(matG(1:nG))
call AllgatherPerElemReals(mesh%decomp,2*(nGeo+1)*(nGeo+1), &
mesh%nodeCoords,coordsG)
call AllgatherPerElemInts(mesh%decomp,20,mesh%sideInfo,siG)
call AllgatherPerElemInts(mesh%decomp,1,mesh%elemMaterial,matG)
! Decode the global side table (sideInfo(3) already carries global element ids).
allocate(nbr(1:4,1:nG),nbrSide(1:4,1:nG),flip(1:4,1:nG),bc(1:4,1:nG))
do r = 1,nG
do s = 1,4
nbr(s,r) = siG(3,s,r)
nbrSide(s,r) = siG(4,s,r)/10
flip(s,r) = mod(siG(4,s,r),10)
bc(s,r) = siG(5,s,r)
enddo
enddo
call forest%InitGlobal(nG,nGeo,mesh%quadrature,coordsG,nbr,nbrSide,flip,bc,matG)
deallocate(coordsG,siG,matG,nbr,nbrSide,flip,bc)
endsubroutine InitForestFromDecomposedMesh