tem_CoordOfReal Function

public pure function tem_CoordOfReal(mesh, point, level) result(coord)

This function returns a coordinate in the given treelmesh for a physical point location on the finest possible level.

Arguments

Type IntentOptional Attributes Name
type(treelmesh_type), intent(in) :: mesh
real(kind=rk), intent(in) :: point(3)
integer, intent(in), optional :: level

coordinate on

Return Value integer, (4)


Called by

proc~~tem_coordofreal~~CalledByGraph proc~tem_coordofreal tem_CoordOfReal proc~evaluate_add_spacetime_scalarbycoordinate evaluate_add_spacetime_scalarByCoordinate proc~evaluate_add_spacetime_scalarbycoordinate->proc~tem_coordofreal proc~evaluate_add_spacetime_vectorbycoordinate evaluate_add_spacetime_vectorByCoordinate proc~evaluate_add_spacetime_vectorbycoordinate->proc~tem_coordofreal proc~evaluate_first_spacetime_scalarbycoordinate evaluate_first_spacetime_scalarByCoordinate proc~evaluate_first_spacetime_scalarbycoordinate->proc~tem_coordofreal proc~tem_cano_initsubtree tem_cano_initSubTree proc~tem_cano_initsubtree->proc~tem_coordofreal proc~setup_indices_spacetime setup_indices_spacetime proc~setup_indices_spacetime->proc~tem_coordofreal proc~tem_cano_storepntsinsubtree tem_cano_storePntsInSubTree proc~tem_cano_storepntsinsubtree->proc~tem_coordofreal proc~tem_init_surfdata tem_init_surfData proc~tem_init_surfdata->proc~tem_coordofreal proc~evaluate_first_spacetime_vectorbycoordinate evaluate_first_spacetime_vectorByCoordinate proc~evaluate_first_spacetime_vectorbycoordinate->proc~tem_coordofreal proc~tem_cano_checkneigh tem_cano_checkNeigh proc~tem_cano_checkneigh->proc~tem_coordofreal proc~append_pointdata append_pointData proc~append_pointdata->proc~tem_coordofreal proc~tem_unify_surfacedata tem_unify_surfaceData proc~tem_unify_surfacedata->proc~tem_coordofreal proc~tem_shape_subtreefromgeominters tem_shape_subTreeFromGeomInters proc~tem_shape_subtreefromgeominters->proc~tem_cano_initsubtree proc~tem_shape_subtreefromgeominters->proc~tem_cano_storepntsinsubtree proc~tem_shape_subtreefromgeominters->proc~tem_cano_checkneigh interface~append~43 append interface~append~43->proc~append_pointdata proc~tem_update_surfpos tem_update_surfPos proc~tem_update_surfpos->proc~tem_init_surfdata proc~tem_readandunify_surfdata tem_readAndUnify_surfData proc~tem_readandunify_surfdata->proc~tem_unify_surfacedata 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

Contents

Source Code


Source Code

  pure function tem_CoordOfReal(mesh, point, level) result(coord)
    ! -------------------------------------------------------------------- !
    type(treelmesh_type), intent(in) :: mesh !< Mesh to locate the point in
    real(kind=rk), intent(in) :: point(3) !< Point to look up
    integer, intent(in), optional :: level !< optional level to return the
                                           !! coordinate on
    integer :: coord(4) !< x,y,z,level
    ! -------------------------------------------------------------------- !
    real(kind=rk) :: locInCube(3)
    real(kind=rk) :: meshDensity
    integer :: dimLen
    integer :: coordlevel
    ! -------------------------------------------------------------------- !

    if (present(level)) then
      coordlevel = min(level, globalMaxLevels)
    else
      coordlevel = globalMaxLevels
    end if

    locInCube = point - mesh%global%Origin
    dimLen = 2**coordlevel
    meshDensity = real(dimLen, kind=rk) / mesh%global%BoundingCubeLength

    ! Look up the real coordinate on the finest possible resolution.
    coord(4) = coordlevel

    ! Coordinates range from 0 to dimLen-1 in each direction
    ! Do not use periodic domain here, instead use the first
    ! and last element to capture all points outside the
    ! domain to deal with numerical inaccuracies.
    ! That is all elements include their lower boundaries, except
    ! the last one in a given direction, which includes the lower
    ! as well as the upper.
    coord(1:3) = max( min( int(locInCube*meshDensity), dimLen-1 ), 0 )

  end function tem_CoordOfReal