Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(uniform_gradient_field), | intent(in) | :: | this | |||
integer, | intent(in) | :: | dir | Direction in which to differentiate |
||
integer, | intent(in), | optional | :: | order | Order of the derivative, default = 1 |
function uniform_gradient_d_dx(this, dir, order) result(res)
!* Author: Chris MacMackin
! Date: July 2017
!
! \(\frac{\partial^{\rm order}}{\partial x_{\rm dir}^{\rm order}}{\rm field}\)
!
class(uniform_gradient_field), intent(in) :: this
integer, intent(in) :: dir !! Direction in which to differentiate
integer, optional, intent(in) :: order !! Order of the derivative, default = 1
class(scalar_field), pointer :: res
integer :: ord
call this%guard_temp()
call this%allocate_scalar_field(res)
if (present(order)) then
ord = order
else
ord = 1
end if
select type(res)
class is(uniform_scalar_field)
if (ord == 1) then
if (dir > 0 .and. dir <= size(this%grad)) then
res = uniform_scalar_field(this%grad(dir))
else
res = uniform_scalar_field(0.0_r8)
end if
else
res = uniform_scalar_field(0.0_r8)
end if
class default
error stop ('Non-uniform_gradient_field type allocated by '//&
'`allocate_scalar_field` routine.')
end select
call res%set_temp() ! Shouldn't need to call this, but for some
! rason being set as non-temporary when
! assignment subroutine returns.
call this%clean_temp()
end function uniform_gradient_d_dx