Integrate integrand by means of the given scheme.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | scheme | Selected scheme. |
||
class(integrand_tester_object), | intent(in) | :: | integrand_0 | Initial conditions. |
||
real(kind=R_P), | intent(in) | :: | Dt | Time step. |
||
real(kind=R_P), | intent(in) | :: | final_time | Final integration time. |
||
integer(kind=I_P), | intent(in) | :: | iterations | Number of fixed point iterations. |
||
integer(kind=I_P), | intent(in) | :: | stages | Number of stages. |
||
logical, | intent(in) | :: | is_fast | Activate fast mode integration. |
||
logical, | intent(in) | :: | save_results | Save results. |
||
character(len=*), | intent(in) | :: | output_base_name | Base name of output results file. |
||
integer(kind=I_P), | intent(in) | :: | save_frequency | Save frequency. |
||
real(kind=R_P), | intent(out) | :: | error(:) | Error of integrand integration. |
subroutine integrate(scheme, integrand_0, Dt, final_time, iterations, stages, is_fast, save_results, output_base_name, &
save_frequency, error)
!< Integrate integrand by means of the given scheme.
character(*), intent(in) :: scheme !< Selected scheme.
class(integrand_tester_object), intent(in) :: integrand_0 !< Initial conditions.
real(R_P), intent(in) :: Dt !< Time step.
real(R_P), intent(in) :: final_time !< Final integration time.
integer(I_P), intent(in) :: iterations !< Number of fixed point iterations.
integer(I_P), intent(in) :: stages !< Number of stages.
logical, intent(in) :: is_fast !< Activate fast mode integration.
logical, intent(in) :: save_results !< Save results.
character(*), intent(in) :: output_base_name !< Base name of output results file.
integer(I_P), intent(in) :: save_frequency !< Save frequency.
real(R_P), intent(out) :: error(:) !< Error of integrand integration.
real(R_P), allocatable :: error_(:) !< Error of integrand integration.
class(integrand_tester_object) , allocatable :: integrand !< Integrand.
class(integrator_object), allocatable :: integrator !< The integrator.
real(R_P) :: time !< Time.
integer(I_P) :: step !< Time steps counter.
allocate(integrand, mold=integrand_0) ; integrand = integrand_0
call foodie_integrator_factory(scheme=scheme, integrator=integrator, stages=stages, &
tolerance=1e2_R_P, iterations=iterations, autoupdate=.true., U=integrand_0)
if (is_fast) call check_scheme_has_fast_mode(scheme=trim(adjustl(scheme)), integrator=integrator)
step = 0
time = 0._R_P
if (save_results) call integrand%export_tecplot(file_name=output_base_name// &
integrand%description(prefix='-')// &
integrator%description(prefix='-')// &
'-steps_'//trim(strz(int(final_time/Dt), 10))//'.dat', &
t=time, &
scheme=scheme, &
with_exact_solution=.true., &
U0=integrand_0)
select type(integrator)
class is(integrator_multistage_object)
do
step = step + 1
if (is_fast) then
call integrator%integrate_fast(U=integrand, Dt=Dt, t=time)
else
call integrator%integrate(U=integrand, Dt=Dt, t=time)
endif
time = time + Dt
if ((time >= final_time)) exit
call integrand_export_tecplot
enddo
class is(integrator_multistep_object)
do
step = step + 1
if (integrator%steps_number() >= step) then
time = time + Dt
integrator%Dt(step) = Dt
integrator%t(step) = time
integrator%previous(step) = integrand%exact_solution(t=time, U0=integrand_0)
integrand = integrator%previous(step)
else
if (is_fast) then
call integrator%integrate_fast(U=integrand, Dt=Dt, t=time)
else
call integrator%integrate(U=integrand, Dt=Dt, t=time)
endif
time = time + Dt
endif
if ((time >= final_time)) exit
call integrand_export_tecplot
enddo
class is(integrator_multistage_multistep_object)
do
step = step + 1
if (integrator%steps_number() >= step) then
time = time + Dt
integrator%Dt(step) = Dt
integrator%t(step) = time
integrator%previous(step) = integrand%exact_solution(t=time, U0=integrand_0)
integrand = integrator%previous(step)
else
if (is_fast) then
call integrator%integrate_fast(U=integrand, Dt=Dt,t=time)
else
call integrator%integrate(U=integrand, Dt=Dt, t=time)
endif
time = time + Dt
endif
if ((time >= final_time)) exit
call integrand_export_tecplot
enddo
endselect
call integrand_close_tecplot
error_ = integrand%error(t=time, U0=integrand_0)
error(:) = error_(:)
contains
subroutine integrand_close_tecplot
!< Close current integrand tecplot file.
select type(integrand)
type is(integrand_ladvection)
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time, scheme=scheme)
type is(integrand_oscillation)
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time)
endselect
if (save_results) call integrand%export_tecplot(close_file=.true.)
endsubroutine integrand_close_tecplot
subroutine integrand_export_tecplot
!< Export current integrand solution to tecplot file.
select type(integrand)
type is(integrand_lcce)
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time, with_exact_solution=.true.)
type is(integrand_ladvection)
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time, scheme=scheme)
type is(integrand_oscillation)
if (save_results .and. mod(step, save_frequency)==0) call integrand%export_tecplot(t=time, with_exact_solution=.true.)
endselect
endsubroutine integrand_export_tecplot
endsubroutine integrate