tem_GetLocalBoundingCube_fromSubTree Function

private function tem_GetLocalBoundingCube_fromSubTree(subTree, globalTree) result(BoundingCube)

Run through all the elements, check the vertices and return the fluid bounding cube

Arguments

Type IntentOptional Attributes Name
type(tem_subTree_type), intent(in) :: subTree

subTree to locate point in

type(treelmesh_type), intent(in) :: globalTree

corresponding global tree

Return Value real(kind=rk), (3,2)

xyz coordinate for min and max of bounding cube


Source Code

  function tem_GetLocalBoundingCube_fromSubTree( subTree, globalTree ) &
    &        result(BoundingCube)
    ! -------------------------------------------------------------------- !
    !> subTree to locate point in
    type(tem_subTree_type), intent(in) :: subTree
    !> corresponding global tree
    type(treelmesh_type), intent(in) :: globalTree
    !> xyz coordinate for min and max of bounding cube
    real(kind=rk) :: BoundingCube(3,2)
    ! -------------------------------------------------------------------- !
    real(kind=rk) :: vrtxCoord(3,8) ! coordinates for all eight vertices
    real(kind=rk) :: minX(3) ! xyz coordinate for min of bounding cube
    real(kind=rk) :: maxX(3) ! xyz coordinate for max of bounding cube
    integer(kind=long_k) :: tTreeID
    integer :: iElem, iVert
    ! -------------------------------------------------------------------- !

    ! if the subTree equals to the global shape
    if( subTree%useGlobalMesh ) then
      ! ... the effective bounding cube equals to the one of the tree
      BoundingCube = globalTree%global%effboundingCube(3,2)
    else ! if this is not the case
      minX =  huge( minX )
      maxX = -huge( maxX )

      ! loop over all elements
      do iElem = 1, subTree%nElems
        ! ... and distinguish between local shapes and other shapes
        if( subTree%useLocalMesh ) then
          ! ... copy the treeIDs directly
          tTreeID = subTree%treeID( iElem )
        else
          ! ... the treeIDs from the globalTree via the positions in map2global
          tTreeID = globalTree%treeID( subTree%map2global( iElem ))
        end if
        ! Calculate coordinates of vertices
        vrtxCoord(:,:) = tem_vrtxCoordOfId( globalTree, tTreeID )
        do iVert = 1, 8
          ! Compare with min max
          minX(:) = min( minX(:), vrtxCoord(:, iVert ))
          maxX(:) = max( maxX(:), vrtxCoord(:, iVert ))
        enddo
      enddo
      BoundingCube(:,1) = minX(:)
      BoundingCube(:,2) = maxX(:)
    end if ! useGlobalShape

  end function tem_GetLocalBoundingCube_fromSubTree