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(QuadTreeMesh2D), intent(out) :: forest
type(Mesh2D), intent(in) :: mesh

Calls

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

Called by

proc~~initforestfromdecomposedmesh~~CalledByGraph proc~initforestfromdecomposedmesh InitForestFromDecomposedMesh proc~init_amrcontroller2d Init_AMRController2D proc~init_amrcontroller2d->proc~initforestfromdecomposedmesh

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(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