diff --git a/src/time_integration/paired_explicit_runge_kutta/methods_PERK2.jl b/src/time_integration/paired_explicit_runge_kutta/methods_PERK2.jl index ad385e6df2..bad40c6156 100644 --- a/src/time_integration/paired_explicit_runge_kutta/methods_PERK2.jl +++ b/src/time_integration/paired_explicit_runge_kutta/methods_PERK2.jl @@ -106,7 +106,7 @@ function compute_PairedExplicitRK2_butcher_tableau(num_stages, end @doc raw""" - PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString, dt_opt, + PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString, dt_opt = nothing, bS = 1.0, cS = 0.5) PairedExplicitRK2(num_stages, tspan, semi::AbstractSemidiscretization; verbose = false, bS = 1.0, cS = 0.5) @@ -117,7 +117,8 @@ end - `base_path_monomial_coeffs` (`AbstractString`): Path to a file containing monomial coefficients of the stability polynomial of PERK method. The coefficients should be stored in a text file at `joinpath(base_path_monomial_coeffs, "gamma_$(num_stages).txt")` and separated by line breaks. - - `dt_opt` (`Float64`): Optimal time step size for the simulation setup. + - `dt_opt` (`Float64`, optional): Optimal time step size for the simulation setup. Can be `nothing` if it is unknown. + In this case the optimal CFL number cannot be computed and the [`StepsizeCallback`](@ref) cannot be used. - `tspan`: Time span of the simulation. - `semi` (`AbstractSemidiscretization`): Semidiscretization setup. - `eig_vals` (`Vector{ComplexF64}`): Eigenvalues of the Jacobian of the right-hand side (rhs) of the ODEProblem after the @@ -135,6 +136,8 @@ optimized for a certain simulation setup (PDE, IC & BC, Riemann Solver, DG Solve - Brian Vermeire (2019). Paired explicit Runge-Kutta schemes for stiff systems of equations [DOI: 10.1016/j.jcp.2019.05.014](https://doi.org/10.1016/j.jcp.2019.05.014) + +Note: To use this integrator, the user must import the `Convex` and `ECOS` packages. """ mutable struct PairedExplicitRK2 <: AbstractPairedExplicitRKSingle const num_stages::Int @@ -144,12 +147,12 @@ mutable struct PairedExplicitRK2 <: AbstractPairedExplicitRKSingle b1::Float64 bS::Float64 cS::Float64 - dt_opt::Float64 + dt_opt::Union{Float64, Nothing} end # struct PairedExplicitRK2 # Constructor that reads the coefficients from a file function PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString, - dt_opt, + dt_opt = nothing, bS = 1.0, cS = 0.5) # If the user has the monomial coefficients, they also must have the optimal time step a_matrix, c = compute_PairedExplicitRK2_butcher_tableau(num_stages, @@ -246,6 +249,10 @@ function calculate_cfl(ode_algorithm::AbstractPairedExplicitRKSingle, ode) semi = ode.p dt_opt = ode_algorithm.dt_opt + if isnothing(dt_opt) + error("The optimal time step `dt_opt` must be provided.") + end + mesh, equations, solver, cache = mesh_equations_solver_cache(semi) u = wrap_array(u_ode, mesh, equations, solver, cache) diff --git a/test/test_unit.jl b/test/test_unit.jl index 4e8945eab8..523ce7061e 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -1681,7 +1681,7 @@ end Trixi.download("https://gist.githubusercontent.com/DanielDoehring/8db0808b6f80e59420c8632c0d8e2901/raw/39aacf3c737cd642636dd78592dbdfe4cb9499af/MonCoeffsS6p2.txt", joinpath(path_coeff_file, "gamma_6.txt")) - ode_algorithm = Trixi.PairedExplicitRK2(6, path_coeff_file, 42) # dummy optimal time step (dt_opt plays no role in determining `a_matrix`) + ode_algorithm = Trixi.PairedExplicitRK2(6, path_coeff_file) @test isapprox(ode_algorithm.a_matrix, [0.12405417889682908 0.07594582110317093