block_obj_GetOwningCell Function

private pure function block_obj_GetOwningCell(this, p) result(cell)

Returns the coordinates of the cell that contains the position p. This subroutine ignores gost cells. As such, it will always return an internal cell of the domain. If the point is located in a ghost cell, the returned cell will be an internal boundary cell that is closest to that ghost cell.

Type Bound

block_obj

Arguments

Type IntentOptional Attributes Name
class(block_obj), intent(in) :: this

A block object

real(kind=wp), intent(in) :: p(3)

Position to locate

Return Value integer, (3)

Cell coordinates


Called by

proc~~block_obj_getowningcell~~CalledByGraph proc~block_obj_getowningcell block_obj%block_obj_GetOwningCell proc~lagrangian_obj_locate lagrangian_obj%lagrangian_obj_Locate proc~lagrangian_obj_locate->proc~block_obj_getowningcell proc~lagrangian_set_localize lagrangian_set%lagrangian_set_Localize proc~lagrangian_set_localize->proc~block_obj_getowningcell proc~cdifs_obj_advancesolutionrp cdifs_obj_AdvanceSolutionRP proc~cdifs_obj_advancesolutionrp->proc~lagrangian_set_localize proc~grans_obj_advancesolution grans_obj_AdvanceSolution proc~grans_obj_advancesolution->proc~lagrangian_set_localize proc~marker_set_readh5hut marker_set%marker_set_ReadH5HUT proc~marker_set_readh5hut->proc~lagrangian_set_localize proc~marker_set_readhdf5 marker_set%marker_set_ReadHDF5 proc~marker_set_readhdf5->proc~lagrangian_set_localize proc~respart_set_readh5hut ResPart_set%ResPart_set_ReadH5HUT proc~respart_set_readh5hut->proc~lagrangian_set_localize proc~respart_set_readhdf5 ResPart_set%ResPart_set_ReadHDF5 proc~respart_set_readhdf5->proc~lagrangian_set_localize proc~respart_set_readhdf5->proc~marker_set_readhdf5 proc~solid_set_localize solid_set%solid_set_Localize proc~solid_set_localize->proc~lagrangian_set_localize interface~grans_obj_advancesolution grans_obj%grans_obj_AdvanceSolution interface~grans_obj_advancesolution->proc~grans_obj_advancesolution proc~cdifs_obj_advancesolution cdifs_obj_AdvanceSolution proc~cdifs_obj_advancesolution->proc~cdifs_obj_advancesolutionrp proc~solid_set_readhdf5 solid_set%solid_set_ReadHDF5 proc~solid_set_readhdf5->proc~marker_set_readhdf5 interface~cdifs_obj_advancesolution cdifs_obj%cdifs_obj_AdvanceSolution interface~cdifs_obj_advancesolution->proc~cdifs_obj_advancesolution

Source Code

    pure function block_obj_GetOwningCell(this,p) result (cell)
      !> Returns the coordinates of the cell that contains
      ! the position p. This subroutine ignores gost cells.
      ! As such, it will always return an internal cell of the
      ! domain. If the point is located in a ghost cell, the
      ! returned cell will be an internal boundary cell that is
      ! closest to that ghost cell.
      implicit none
      class(block_obj), intent(in) :: this                                     !! A block object
      real(wp),         intent(in) :: p(3)                                     !! Position to locate
      integer                      :: cell(3)                                  !! Cell coordinates
      ! Work variables
      integer :: c_hi(3),c_lo(3)
      integer :: dir


      c_lo = this%lo
      c_hi = this%hi+1

      do dir =1,3
        ! Sandwich xp between x(c) and x(c+1)
        do while (c_hi(dir)-c_lo(dir).ge.2)
          ! Compute a mid-point
          cell(dir)= (c_hi(dir)+c_lo(dir))/2
          if (p(dir).ge.this%axis(dir)%x(cell(dir))) then
            c_lo(dir)=cell(dir)
          else
            c_hi(dir)=cell(dir)
          end if
        end do
        ! xm(c) lies between x(c) and x(c+1)
        cell(dir)= c_lo(dir)
      end do

      return
    end function block_obj_GetOwningCell