RefineNode_QuadTreeMesh2D Subroutine

public subroutine RefineNode_QuadTreeMesh2D(this, node)

Subdivide one leaf node into four children. Does nothing (with a warning) if the node is already refined. The caller is responsible for rebuilding the leaf list afterwards (or calling AdaptFromFlags, which does so).

Arguments

TypeIntentOptionalAttributesName
class(QuadTreeMesh2D), intent(inout) :: this
integer, intent(in) :: node

Contents


Source Code

  subroutine RefineNode_QuadTreeMesh2D(this,node)
    !! Subdivide one leaf node into four children. Does nothing (with a warning) if the node is
    !! already refined. The caller is responsible for rebuilding the leaf list afterwards (or
    !! calling AdaptFromFlags, which does so).
    implicit none
    class(QuadTreeMesh2D),intent(inout) :: this
    integer,intent(in) :: node
    ! Local
    integer :: c,newid

    if(this%child(1,node) /= 0) then
      print*,__FILE__,':',__LINE__,' : Warning : RefineNode called on an already-refined node.'
      return
    endif

    call this%EnsureCapacity(this%nNodes+4)
    do c = 1,4
      newid = this%nNodes+c
      this%level(newid) = this%level(node)+1
      this%parent(newid) = node
      this%quadrant(newid) = c
      this%rootElem(newid) = this%rootElem(node)
      this%child(1:4,newid) = 0
    enddo
    this%child(1,node) = this%nNodes+1
    this%child(2,node) = this%nNodes+2
    this%child(3,node) = this%nNodes+3
    this%child(4,node) = this%nNodes+4
    this%nNodes = this%nNodes+4

  endsubroutine RefineNode_QuadTreeMesh2D