Skip to content

Commit

Permalink
Implement optimal CFL calculation for PERK2 integrator and add necess…
Browse files Browse the repository at this point in the history
…ary packages
  • Loading branch information
warisa-r committed Oct 20, 2024
1 parent 480aea9 commit 9056d50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
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 @@ -149,7 +151,7 @@ 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 @@ -1671,7 +1671,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

0 comments on commit 9056d50

Please sign in to comment.