Return exact solution.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integrand_ladvection), | intent(in) | :: | self | Integrand. |
||
real(kind=R_P), | intent(in) | :: | t | Time. |
||
real(kind=R_P), | intent(in), | optional | :: | t0 | Initial time. |
|
class(integrand_object), | intent(in), | optional | :: | U0 | Initial conditions. |
Exact solution.
pure function exact_solution(self, t, t0, U0) result(exact)
!< Return exact solution.
class(integrand_ladvection), intent(in) :: self !< Integrand.
real(R_P), intent(in) :: t !< Time.
real(R_P), intent(in), optional :: t0 !< Initial time.
class(integrand_object), intent(in), optional :: U0 !< Initial conditions.
real(R_P), allocatable :: exact(:) !< Exact solution.
integer(I_P) :: offset !< Cells offset.
integer(I_P) :: i !< Counter.
allocate(exact(1:self%Ni))
if (present(U0)) then
select type(U0)
type is(integrand_ladvection)
offset = nint(mod(self%a * t, self%length) / self%Dx)
do i=1, self%Ni - offset
exact(i + offset) = U0%u(i)
enddo
do i=self%Ni - offset + 1, self%Ni
exact(i - self%Ni + offset) = U0%u(i)
enddo
endselect
else
exact = self%u(1:self%Ni) * 0._R_P
endif
endfunction exact_solution