Commit e9430ad0 authored by Jannis Teunissen's avatar Jannis Teunissen

Pass both i_step and n_steps to forward_euler method

parent 47899d9a
......@@ -207,7 +207,8 @@ contains
end select
end function solution
subroutine forward_euler(tree, dt, dt_lim, time, s_deriv, s_prev, s_out, istep)
subroutine forward_euler(tree, dt, dt_lim, time, s_deriv, s_prev, s_out, &
i_step, n_steps)
type(af_t), intent(inout) :: tree
real(dp), intent(in) :: dt
real(dp), intent(in) :: time
......@@ -215,7 +216,7 @@ contains
integer, intent(in) :: s_deriv
integer, intent(in) :: s_prev
integer, intent(in) :: s_out
integer, intent(in) :: istep
integer, intent(in) :: i_step, n_steps
real(dp) :: wmax(NDIM)
call flux_generic_tree(tree, 1, [i_phi+s_deriv], [i_flux], wmax, &
......
......@@ -162,7 +162,8 @@ program KT_euler
contains
subroutine forward_euler(tree, dt, dt_lim, time, s_deriv, s_prev, s_out, istep)
subroutine forward_euler(tree, dt, dt_lim, time, s_deriv, s_prev, s_out, &
i_step, n_steps)
type(af_t), intent(inout) :: tree
real(dp), intent(in) :: dt
real(dp), intent(out) :: dt_lim
......@@ -170,7 +171,7 @@ contains
integer, intent(in) :: s_deriv
integer, intent(in) :: s_prev
integer, intent(in) :: s_out
integer, intent(in) :: istep
integer, intent(in) :: i_step, n_steps
real(dp) :: wmax(NDIM)
call flux_generic_tree(tree, n_vars, variables+s_deriv, fluxes, wmax, &
......
......@@ -19,7 +19,8 @@ module m_af_advance
integer, parameter :: req_copies(n_integrators) = af_advance_num_steps
interface
subroutine subr_feuler(tree, dt, dt_lim, time, s_deriv, s_prev, s_out, istep)
subroutine subr_feuler(tree, dt, dt_lim, time, s_deriv, s_prev, s_out, &
i_step, n_steps)
import
type(af_t), intent(inout) :: tree
real(dp), intent(in) :: dt !< Time step
......@@ -28,7 +29,8 @@ module m_af_advance
integer, intent(in) :: s_deriv !< State to compute derivatives from
integer, intent(in) :: s_prev !< Previous state
integer, intent(in) :: s_out !< Output state
integer, intent(in) :: istep !< Step of the integrator
integer, intent(in) :: i_step !< Step of the integrator
integer, intent(in) :: n_steps !< Total number of steps
end subroutine subr_feuler
end interface
......@@ -45,6 +47,7 @@ contains
integer, intent(in) :: i_cc(:) !< Index of cell-centered variables
integer, intent(in) :: time_integrator
procedure(subr_feuler) :: forward_euler
integer :: n_steps
if (time_integrator < 1 .or. time_integrator > n_integrators) &
error stop "Invalid time integrator"
......@@ -52,18 +55,20 @@ contains
if (any(tree%cc_num_copies(i_cc) < req_copies(time_integrator))) &
error stop "Not enough copies available"
n_steps = af_advance_num_steps(time_integrator)
select case (time_integrator)
case (af_forward_euler)
call forward_euler(tree, dt, dt_lim, time, 0, 0, 0, 1)
call forward_euler(tree, dt, dt_lim, time, 0, 0, 0, 1, n_steps)
time = time + dt
case (af_midpoint_method)
call forward_euler(tree, 0.5_dp * dt, dt_lim, time, 0, 0, 1, 1)
call forward_euler(tree, dt, dt_lim, time, 1, 0, 0, 2)
call forward_euler(tree, 0.5_dp * dt, dt_lim, time, 0, 0, 1, 1, n_steps)
call forward_euler(tree, dt, dt_lim, time, 1, 0, 0, 2, n_steps)
time = time + dt
case (af_heuns_method)
call forward_euler(tree, dt, dt_lim, time, 0, 0, 1, 1)
call forward_euler(tree, dt, dt_lim, time, 0, 0, 1, 1, n_steps)
time = time + dt
call forward_euler(tree, dt, dt_lim, time, 1, 1, 1, 2)
call forward_euler(tree, dt, dt_lim, time, 1, 1, 1, 2, n_steps)
call combine_substeps(tree, i_cc, 2, [0, 1], [0.5_dp, 0.5_dp], 0)
end select
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment