InitForestFromDecomposedMesh Subroutine

public 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.

Arguments

TypeIntentOptionalAttributesName
type(OctreeMesh3D), intent(out) :: forest
type(Mesh3D), intent(in) :: mesh

Calls

proc~~initforestfromdecomposedmesh~2~~CallsGraph proc~initforestfromdecomposedmesh~2 InitForestFromDecomposedMesh proc~allgatherperelemreals~2 AllgatherPerElemReals proc~initforestfromdecomposedmesh~2->proc~allgatherperelemreals~2 proc~allgatherperelemints~2 AllgatherPerElemInts proc~initforestfromdecomposedmesh~2->proc~allgatherperelemints~2 mpi_allgatherv mpi_allgatherv proc~allgatherperelemreals~2->mpi_allgatherv proc~allgatherperelemints~2->mpi_allgatherv

Called by

proc~~initforestfromdecomposedmesh~2~~CalledByGraph proc~initforestfromdecomposedmesh~2 InitForestFromDecomposedMesh proc~init_amrcontroller3d Init_AMRController3D proc~init_amrcontroller3d->proc~initforestfromdecomposedmesh~2

Contents


Source Code

  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(OctreeMesh3D),intent(out) :: forest
    type(Mesh3D),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:3,1:nGeo+1,1:nGeo+1,1:nGeo+1,1:nG))
    allocate(siG(1:5,1:6,1:nG))
    allocate(matG(1:nG))
    call AllgatherPerElemReals(mesh%decomp,3*(nGeo+1)*(nGeo+1)*(nGeo+1), &
                               mesh%nodeCoords,coordsG)
    call AllgatherPerElemInts(mesh%decomp,30,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:6,1:nG),nbrSide(1:6,1:nG),flip(1:6,1:nG),bc(1:6,1:nG))
    do r = 1,nG
      do s = 1,6
        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