From 88c92e210771fa9b7b9331558f4c08b3426800bb Mon Sep 17 00:00:00 2001 From: Warisa Date: Mon, 8 Jul 2024 17:49:04 +0200 Subject: [PATCH] fixed step size should work with save solution now --- .../paired_explicit_runge_kutta/methods_PERK3.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/time_integration/paired_explicit_runge_kutta/methods_PERK3.jl b/src/time_integration/paired_explicit_runge_kutta/methods_PERK3.jl index 1c36f5e3700..ca549e744ab 100644 --- a/src/time_integration/paired_explicit_runge_kutta/methods_PERK3.jl +++ b/src/time_integration/paired_explicit_runge_kutta/methods_PERK3.jl @@ -221,8 +221,9 @@ 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 @@ -230,6 +231,8 @@ mutable struct PairedExplicitRK3Integrator{RealT <: Real, uType, Params, Sol, 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 @@ -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 @@ -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)