subroutine Free_QuadTreeMesh2D(this)
implicit none
class(QuadTreeMesh2D),intent(inout) :: this
if(allocated(this%rootCoords)) deallocate(this%rootCoords)
if(allocated(this%rootNbr)) deallocate(this%rootNbr)
if(allocated(this%rootNbrSide)) deallocate(this%rootNbrSide)
if(allocated(this%rootFlip)) deallocate(this%rootFlip)
if(allocated(this%rootBC)) deallocate(this%rootBC)
if(allocated(this%rootMaterial)) deallocate(this%rootMaterial)
if(allocated(this%level)) deallocate(this%level)
if(allocated(this%parent)) deallocate(this%parent)
if(allocated(this%quadrant)) deallocate(this%quadrant)
if(allocated(this%rootElem)) deallocate(this%rootElem)
if(allocated(this%child)) deallocate(this%child)
if(allocated(this%leaf)) deallocate(this%leaf)
this%nGeo = 0
this%nRoots = 0
this%nNodes = 0
this%capacity = 0
this%nLeaves = 0
endsubroutine Free_QuadTreeMesh2D