Generic residual Each sweeper can define its own residual, or use this generic one Compute the integral of F
add tau if it exists subtract out the solution value
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pf_sweeper_t), | intent(in) | :: | this | |||
class(pf_level_t), | intent(inout) | :: | lev | |||
real(kind=pfdp), | intent(in) | :: | dt | |||
integer, | intent(in), | optional | :: | flags |
subroutine pf_generic_residual(this, lev, dt, flags)
class(pf_sweeper_t), intent(in) :: this
class(pf_level_t), intent(inout) :: lev
real(pfdp), intent(in) :: dt
integer, intent(in), optional :: flags
integer :: m
!> Compute the integral of F
call lev%ulevel%sweeper%integrate(lev, lev%Q, lev%F, dt, lev%I, flags)
!> add tau if it exists
if (allocated(lev%tauQ)) then
do m = 1, lev%nnodes-1
call lev%I(m)%axpy(1.0_pfdp, lev%tauQ(m), flags)
end do
end if
!> subtract out the solution value
if (present(flags)) then
do m = 1, lev%nnodes-1
if( (flags .eq. 0) .or. (flags .eq. 1) ) then
call lev%R(m)%copy(lev%I(m), 1)
call lev%R(m)%axpy(1.0_pfdp, lev%Q(1), 1)
call lev%R(m)%axpy(-1.0_pfdp, lev%Q(m+1), 1)
end if
if( (flags .eq. 0) .or. (flags .eq. 2) ) then
call lev%R(m)%copy(lev%I(m), 2)
call lev%R(m)%axpy(1.0_pfdp, lev%Q(lev%nnodes), 2)
call lev%R(m)%axpy(-1.0_pfdp, lev%Q(m), 2)
end if
end do
else
do m = 1, lev%nnodes-1
call lev%R(m)%copy(lev%I(m))
call lev%R(m)%axpy(1.0_pfdp, lev%Q(1))
call lev%R(m)%axpy(-1.0_pfdp, lev%Q(m+1))
end do
end if
end subroutine pf_generic_residual