Skip to content

Commit

Permalink
fixed step size should work with save solution now
Browse files Browse the repository at this point in the history
  • Loading branch information
warisa-r committed Jul 8, 2024
1 parent 532f483 commit 88c92e2
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,18 @@ mutable struct PairedExplicitRK3Integrator{RealT <: Real, uType, Params, Sol, F,
du::uType
u_tmp::uType
t::RealT
tdir::RealT
dt::RealT # current time step
dtcache::RealT # ignored
dtcache::RealT # manually set time step
iter::Int # current number of time steps (iteration)
p::Params # will be the semidiscretization from Trixi
sol::Sol # faked
f::F
alg::Alg # This is our own class written above; Abbreviation for ALGorithm
opts::PairedExplicitRKOptions
finalstep::Bool # added for convenience
dtchangeable::Bool
force_stepfail::Bool
# PairedExplicitRK stages:
k1::uType
k_higher::uType
Expand All @@ -246,15 +249,16 @@ function init(ode::ODEProblem, alg::PairedExplicitRK3;
k_higher = zero(u0)

t0 = first(ode.tspan)
tdir = sign(ode.tspan[end] - ode.tspan[1])
iter = 0

integrator = PairedExplicitRK3Integrator(u0, du, u_tmp, t0, dt, zero(dt), iter,
integrator = PairedExplicitRK3Integrator(u0, du, u_tmp, t0, tdir, dt, dt, iter,
ode.p,
(prob = ode,), ode.f, alg,
PairedExplicitRKOptions(callback,
ode.tspan;
kwargs...),
false,
false, true, false,
k1, k_higher)

# initialize callbacks
Expand Down Expand Up @@ -306,6 +310,8 @@ function step!(integrator::PairedExplicitRK3Integrator)
error("time step size `dt` is NaN")
end

modify_dt_for_tstops!(integrator)

# if the next iteration would push the simulation beyond the end time, set dt accordingly
if integrator.t + integrator.dt > t_end ||
isapprox(integrator.t + integrator.dt, t_end)
Expand Down

0 comments on commit 88c92e2

Please sign in to comment.