InitGlobal_QuadTreeMesh2D Subroutine

public subroutine InitGlobal_QuadTreeMesh2D(this, nRoots, nGeo, quadrature, rootCoords, rootNbr, rootNbrSide, rootFlip, rootBC, rootMaterial)

Initialize the forest directly from GLOBAL base-mesh tables (one root per global base element, all leaves at level 0). This is the initialization path for a rank-replicated forest over a decomposed base mesh (AMR Stage 5): every rank passes the same gathered tables and holds an identical forest. rootNbr carries global element ids (0 = physical boundary), rootNbrSide/rootFlip decode the base sideInfo(4) pairing, rootBC the base boundary-condition id per side, and rootMaterial the base material id per element.

Arguments

TypeIntentOptionalAttributesName
class(QuadTreeMesh2D), intent(out) :: this
integer, intent(in) :: nRoots
integer, intent(in) :: nGeo
integer, intent(in) :: quadrature
real(kind=prec), intent(in) :: rootCoords(1:2,1:nGeo+1,1:nGeo+1,1:nRoots)
integer, intent(in) :: rootNbr(1:4,1:nRoots)
integer, intent(in) :: rootNbrSide(1:4,1:nRoots)
integer, intent(in) :: rootFlip(1:4,1:nRoots)
integer, intent(in) :: rootBC(1:4,1:nRoots)
integer, intent(in) :: rootMaterial(1:nRoots)

Contents


Source Code

  subroutine InitGlobal_QuadTreeMesh2D(this,nRoots,nGeo,quadrature,rootCoords, &
                                       rootNbr,rootNbrSide,rootFlip,rootBC,rootMaterial)
    !! Initialize the forest directly from GLOBAL base-mesh tables (one root per global base
    !! element, all leaves at level 0). This is the initialization path for a rank-replicated
    !! forest over a decomposed base mesh (AMR Stage 5): every rank passes the same gathered
    !! tables and holds an identical forest. rootNbr carries global element ids (0 = physical
    !! boundary), rootNbrSide/rootFlip decode the base sideInfo(4) pairing, rootBC the base
    !! boundary-condition id per side, and rootMaterial the base material id per element.
    implicit none
    class(QuadTreeMesh2D),intent(out) :: this
    integer,intent(in) :: nRoots
    integer,intent(in) :: nGeo
    integer,intent(in) :: quadrature
    real(prec),intent(in) :: rootCoords(1:2,1:nGeo+1,1:nGeo+1,1:nRoots)
    integer,intent(in) :: rootNbr(1:4,1:nRoots)
    integer,intent(in) :: rootNbrSide(1:4,1:nRoots)
    integer,intent(in) :: rootFlip(1:4,1:nRoots)
    integer,intent(in) :: rootBC(1:4,1:nRoots)
    integer,intent(in) :: rootMaterial(1:nRoots)
    ! Local
    integer :: r

    this%nGeo = nGeo
    this%quadrature = quadrature
    this%nRoots = nRoots

    allocate(this%rootCoords(1:2,1:nGeo+1,1:nGeo+1,1:nRoots))
    this%rootCoords(1:2,1:nGeo+1,1:nGeo+1,1:nRoots) = &
      rootCoords(1:2,1:nGeo+1,1:nGeo+1,1:nRoots)

    allocate(this%rootNbr(1:4,1:nRoots))
    allocate(this%rootNbrSide(1:4,1:nRoots))
    allocate(this%rootFlip(1:4,1:nRoots))
    allocate(this%rootBC(1:4,1:nRoots))
    allocate(this%rootMaterial(1:nRoots))
    this%rootNbr(1:4,1:nRoots) = rootNbr(1:4,1:nRoots)
    this%rootNbrSide(1:4,1:nRoots) = rootNbrSide(1:4,1:nRoots)
    this%rootFlip(1:4,1:nRoots) = rootFlip(1:4,1:nRoots)
    this%rootBC(1:4,1:nRoots) = rootBC(1:4,1:nRoots)
    this%rootMaterial(1:nRoots) = rootMaterial(1:nRoots)

    ! Roots are the first nRoots nodes.
    this%capacity = max(4*this%nRoots,16)
    this%nNodes = this%nRoots
    allocate(this%level(1:this%capacity))
    allocate(this%parent(1:this%capacity))
    allocate(this%quadrant(1:this%capacity))
    allocate(this%rootElem(1:this%capacity))
    allocate(this%child(1:4,1:this%capacity))
    this%level = 0
    this%parent = 0
    this%quadrant = 0
    this%rootElem = 0
    this%child = 0
    do r = 1,this%nRoots
      this%rootElem(r) = r
    enddo

    call this%RebuildLeaves()

  endsubroutine InitGlobal_QuadTreeMesh2D