tem_BaryOfCoord Function

public pure function tem_BaryOfCoord(coord, nPoints, origin, dx) result(bary)

This function provides the coordinates of the element barycenters for a set of given element coordinates on the same refinement level.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: coord(nPoints,3)
integer, intent(in) :: nPoints
real(kind=rk), intent(in) :: origin(3)

spatial index triple for a given ID

real(kind=rk), intent(in) :: dx

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


Source Code

  pure function tem_BaryOfCoord(coord, nPoints, origin, dx) result(bary)
    ! -------------------------------------------------------------------- !
    integer, intent(in) :: nPoints !< Number of points to evaluate
    integer, intent(in) :: coord(nPoints,3)
    !> spatial index triple for a given ID
    real(kind=rk), intent(in) :: origin(3) !< origin of the universe cube
    real(kind=rk), intent(in) :: dx !< size of the elements
    real(kind=rk) :: bary(nPoints,3) !< barycenter to return
    ! -------------------------------------------------------------------- !
    integer :: ii
    real(kind=rk) :: c(3)
    ! -------------------------------------------------------------------- !

    ! bary = origin + ( coord + 0.5 ) * dx
    !      = origin + coord * dx + 0.5dx
    !      = c      + coord * dx
    c(:) = origin(:) + 0.5_rk * dx
    do ii = 1, nPoints
      bary(ii,1) = c(1) + real(coord(ii,1), kind=rk) * dx
      bary(ii,2) = c(2) + real(coord(ii,2), kind=rk) * dx
      bary(ii,3) = c(3) + real(coord(ii,3), kind=rk) * dx
    end do

  end function tem_BaryOfCoord