Evaluates whether two scalar fields are equal within a tolerance,
specified by set_tol
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(uniform_gradient_field), | intent(in) | :: | this | |||
class(scalar_field), | intent(in) | :: | rhs |
logical function uniform_gradient_is_equal(this,rhs) result(iseq)
!* Author: Chris MacMackin
! Date: July 2017
!
! Evaluates whether two scalar fields are equal within a tolerance,
! specified by `set_tol`.
!
class(uniform_gradient_field), intent(in) :: this
class(scalar_field), intent(in) :: rhs
real(r8) :: normalization
integer :: i
call this%guard_temp(); call rhs%guard_temp()
iseq = .true.
select type(rhs)
class is(uniform_gradient_field)
iseq = (this%uniform_scalar_field == rhs%uniform_scalar_field)
do i = 1, size(this%grad)
if (.not. iseq) return
normalization = abs(this%grad(i))
if (normalization < get_tol()) normalization = 1.0_r8
iseq = iseq .and.( ((this%grad(i)-rhs%grad(i))/normalization < &
get_tol()) .or. (is_nan(this%grad(i)).and. &
is_nan(rhs%grad(i))) )
end do
class default
iseq = (rhs == this)
end select
call this%clean_temp(); call rhs%clean_temp()
end function uniform_gradient_is_equal