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 | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(block_obj), | intent(in) | :: | this |
A block object |
||
| real(kind=wp), | intent(in) | :: | p(3) |
Position to locate |
Cell coordinates
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