tem_cano_initSubTree Subroutine

public subroutine tem_cano_initSubTree(me, inTree, countElems, map2global, shapeInverted)

Create subtree from the intersection of canonical shapes and inTree

Arguments

Type IntentOptional Attributes Name
type(tem_canonicalND_type), intent(in) :: me(:)

canonicalND objects on which to work

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

Global tree

integer, intent(inout) :: countElems(globalMaxLevels)

How many elements there will be for each level in the track

type(dyn_intarray_type), intent(inout) :: map2global

growing array for the map2global

logical, intent(in) :: shapeInverted

If true then elements not intersected are added to subTree


Calls

proc~~tem_cano_initsubtree~~CallsGraph proc~tem_cano_initsubtree tem_cano_initSubTree interface~append~29 append proc~tem_cano_initsubtree->interface~append~29 proc~tem_boxcubeoverlap tem_boxCubeOverlap proc~tem_cano_initsubtree->proc~tem_boxcubeoverlap proc~tem_converttreeidtocube tem_convertTreeIDtoCube proc~tem_cano_initsubtree->proc~tem_converttreeidtocube proc~tem_coordofreal tem_CoordOfReal proc~tem_cano_initsubtree->proc~tem_coordofreal proc~tem_idofcoord tem_IdOfCoord proc~tem_cano_initsubtree->proc~tem_idofcoord proc~tem_levelof tem_LevelOf proc~tem_cano_initsubtree->proc~tem_levelof proc~tem_linecubeoverlap tem_lineCubeOverlap proc~tem_cano_initsubtree->proc~tem_linecubeoverlap proc~tem_planecubeoverlap tem_planeCubeOverlap proc~tem_cano_initsubtree->proc~tem_planecubeoverlap proc~tem_posofid tem_PosOfId proc~tem_cano_initsubtree->proc~tem_posofid proc~append_da_label append_da_label interface~append~29->proc~append_da_label proc~append_da_veclabel append_da_veclabel interface~append~29->proc~append_da_veclabel proc~tem_boxcubeoverlap->proc~tem_planecubeoverlap proc~boxboxoverlap boxBoxOverlap proc~tem_boxcubeoverlap->proc~boxboxoverlap proc~tem_elemsize tem_ElemSize proc~tem_converttreeidtocube->proc~tem_elemsize proc~tem_endofid tem_endOfId proc~tem_converttreeidtocube->proc~tem_endofid proc~tem_originofid tem_originOfId proc~tem_converttreeidtocube->proc~tem_originofid proc~raycubeoverlap rayCubeOverlap proc~tem_linecubeoverlap->proc~raycubeoverlap proc~tem_trianglecubeoverlap tem_triangleCubeOverlap proc~tem_planecubeoverlap->proc~tem_trianglecubeoverlap proc~tem_pathcomparison tem_PathComparison proc~tem_posofid->proc~tem_pathcomparison proc~tem_pathof tem_PathOf proc~tem_posofid->proc~tem_pathof interface~expand~27 expand proc~append_da_label->interface~expand~27 interface~sortedposofval~5 sortedposofval proc~append_da_label->interface~sortedposofval~5 proc~append_da_veclabel->interface~expand~27 proc~tem_elemsize->proc~tem_levelof proc~tem_elemsizelevel tem_ElemSizeLevel proc~tem_elemsize->proc~tem_elemsizelevel proc~tem_coordofid tem_CoordOfId proc~tem_endofid->proc~tem_coordofid proc~tem_endofid->proc~tem_elemsizelevel proc~tem_originofid->proc~tem_coordofid proc~tem_originofid->proc~tem_elemsizelevel proc~triboxoverlap_loc triBoxOverlap_loc proc~tem_trianglecubeoverlap->proc~triboxoverlap_loc proc~expand_da_label expand_da_label interface~expand~27->proc~expand_da_label proc~sortposofval_label sortposofval_label interface~sortedposofval~5->proc~sortposofval_label proc~tem_coordofid->proc~tem_levelof proc~axistest Axistest proc~triboxoverlap_loc->proc~axistest proc~cross_product3d cross_product3D proc~triboxoverlap_loc->proc~cross_product3d proc~planeboxoverlap planeBoxOverlap proc~triboxoverlap_loc->proc~planeboxoverlap

Called by

proc~~tem_cano_initsubtree~~CalledByGraph proc~tem_cano_initsubtree tem_cano_initSubTree proc~tem_shape_subtreefromgeominters tem_shape_subTreeFromGeomInters proc~tem_shape_subtreefromgeominters->proc~tem_cano_initsubtree proc~tem_shape2subtree tem_shape2subTree proc~tem_shape2subtree->proc~tem_shape_subtreefromgeominters proc~tem_create_subtree_of tem_create_subTree_of proc~tem_create_subtree_of->proc~tem_shape2subtree proc~tem_create_subtree_of_st_funlist tem_create_subTree_of_st_funList proc~tem_create_subtree_of_st_funlist->proc~tem_create_subtree_of proc~tem_init_convergence tem_init_convergence proc~tem_init_convergence->proc~tem_create_subtree_of proc~tem_init_tracker_subtree tem_init_tracker_subTree proc~tem_init_tracker_subtree->proc~tem_create_subtree_of proc~tem_write_debugmesh tem_write_debugMesh proc~tem_write_debugmesh->proc~tem_create_subtree_of

Source Code

  subroutine tem_cano_initSubTree( me, inTree, countElems, map2global, &
    &                              shapeInverted )
    ! --------------------------------------------------------------------------
    !> canonicalND objects on which to work
    type(tem_canonicalND_type ),intent(in) :: me(:)
    !> Global tree
    type(treelmesh_type), intent(in) :: inTree
    !> How many elements there will be for each level in the track
    integer, intent( inout ) :: countElems( globalMaxLevels )
    !> growing array for the map2global
    type(dyn_intArray_type), intent(inout) :: map2global
    !> If true then elements not intersected are added to subTree
    logical, intent(in) :: shapeInverted
    ! --------------------------------------------------------------------------
    integer :: iCano, tLevel, elemPos, iElem, dPos, maxLevel
    integer(kind=long_k) :: treeID
    logical :: wasAdded, intersects, addToSubTree
    type(tem_cube_type) :: cube
    ! --------------------------------------------------------------------------

    write(logUnit(4),"(A)") 'Initializing canonical shapes'

    maxLevel = inTree%global%maxLevel

    ! Create subTree by intersecting canoND objects with the inTree
    do iCano = 1, size(me)
      ! for a point there is no need to check against all elements
      ! instead just convert the point into treeID and check for its
      ! exitence in given tree
      if (trim(me(iCano)%kind) == 'point') then
        treeID = tem_IdOfCoord( tem_CoordOfReal(inTree,                     &
          &                                     me(iCano)%point%coord(1:3), &
          &                                     maxLevel) )
        ! get position of the treeID in inTree
        elemPos = tem_PosOfId( treeID, inTree%treeID)
        found_elem: if (elemPos > 0) then
          ! append the position in inTree to the map (note that already existing
          ! ones are omitted)
          call append( me       = map2global, &
            &          pos      = dpos,       &
            &          val      = elemPos,    &
            &          wasAdded = wasAdded    )

          ! Count up if it was added
          if (wasAdded) then
            tLevel   = tem_levelOf( treeID )
            countElems( tLevel ) = countElems( tLevel ) + 1
          end if ! wasAdded
        end if found_elem
      else
        do iElem = 1, inTree%nElems
          treeID = inTree%treeID(iElem)
          call tem_convertTreeIDtoCube(cube, inTree, treeID)
          intersects = .false.
          select case ( trim(me(iCano)%kind) )
          case ('line')
            intersects = tem_lineCubeOverlap(me(iCano)%line, cube)
          case ('plane')
            intersects = tem_planeCubeOverlap(me(iCano)%plane, cube)
          case ('box')
            intersects = tem_boxCubeOverlap(me(iCano)%box, cube)
          end select

          addToSubTree = .false.
          if (.not. shapeInverted .and. intersects) then
            ! Shape intersects with current element and not inverted
            addToSubTree = .true.
          else if (shapeInverted .and. .not. intersects) then
            ! shape not intersected and is inverted shape so add this to subTree
            addToSubTree = .true.
          end if

          if (addToSubTree) then
            ! append iElem in inTree to the map (note that already existing
            ! ones are omitted)
            call append( me       = map2global, &
              &          pos      = dpos,       &
              &          val      = iElem ,     &
              &          wasAdded = wasAdded    )

            ! Count up if it was added
            if( wasAdded ) then
              tLevel   = tem_levelOf( treeID )
              countElems( tLevel ) = countElems( tLevel ) + 1
            end if ! wasAdded
          end if !intersects
        end do !iElem
      end if
    end do !iCano

  end subroutine tem_cano_initSubTree