Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify optimal CFL calculation for PERK2 integrator and its docstring #2123

Merged
merged 9 commits into from
Oct 21, 2024
14 changes: 10 additions & 4 deletions src/time_integration/paired_explicit_runge_kutta/methods_PERK2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ function compute_PairedExplicitRK2_butcher_tableau(num_stages,
end

@doc raw"""
PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString, dt_opt,
bS = 1.0, cS = 0.5)
function PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString, dt_opt = nothing,
warisa-r marked this conversation as resolved.
Show resolved Hide resolved
bS = 1.0, cS = 0.5)
PairedExplicitRK2(num_stages, tspan, semi::AbstractSemidiscretization;
verbose = false, bS = 1.0, cS = 0.5)
PairedExplicitRK2(num_stages, tspan, eig_vals::Vector{ComplexF64};
Expand Down Expand Up @@ -135,6 +135,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
Expand All @@ -144,12 +146,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,
Expand Down Expand Up @@ -246,6 +248,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)

Expand Down
2 changes: 1 addition & 1 deletion test/test_unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading