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

Assure conservation for SSP scheme #1640

Merged
merged 3 commits into from
Sep 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/time_integration/methods_SSP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ The third-order SSP Runge-Kutta method of Shu and Osher.
This is an experimental feature and may change in future releases.
"""
struct SimpleSSPRK33{StageCallbacks} <: SimpleAlgorithmSSP
a::SVector{3, Float64}
b::SVector{3, Float64}
numerator_a::SVector{3, Float64}
numerator_b::SVector{3, Float64}
denominator::SVector{3, Float64}
c::SVector{3, Float64}
stage_callbacks::StageCallbacks

function SimpleSSPRK33(; stage_callbacks = ())
a = SVector(0.0, 3 / 4, 1 / 3)
b = SVector(1.0, 1 / 4, 2 / 3)
numerator_a = SVector(0.0, 3.0, 1.0) # a = numerator_a / denominator
numerator_b = SVector(1.0, 1.0, 2.0) # b = numerator_b / denominator
denominator = SVector(1.0, 4.0, 3.0)
c = SVector(0.0, 1.0, 1 / 2)

# Butcher tableau
Expand All @@ -42,7 +44,8 @@ struct SimpleSSPRK33{StageCallbacks} <: SimpleAlgorithmSSP
# --------------------
# b | 1/6 1/6 2/3

new{typeof(stage_callbacks)}(a, b, c, stage_callbacks)
new{typeof(stage_callbacks)}(numerator_a, numerator_b, denominator, c,
stage_callbacks)
end
end

Expand Down Expand Up @@ -166,7 +169,9 @@ function solve!(integrator::SimpleIntegratorSSP)
end

# perform convex combination
@. integrator.u = alg.a[stage] * integrator.r0 + alg.b[stage] * integrator.u
@. integrator.u = (alg.numerator_a[stage] * integrator.r0 +
alg.numerator_b[stage] * integrator.u) /
alg.denominator[stage]
end

integrator.iter += 1
Expand Down