From 436b2db6826958ea41408f0a6e4dd5526decacf7 Mon Sep 17 00:00:00 2001 From: bennibolm Date: Fri, 15 Sep 2023 17:55:28 +0200 Subject: [PATCH 1/3] Add denominator variable for SSP scheme --- src/time_integration/methods_SSP.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/time_integration/methods_SSP.jl b/src/time_integration/methods_SSP.jl index 8ecad69748b..942a2aaa6bd 100644 --- a/src/time_integration/methods_SSP.jl +++ b/src/time_integration/methods_SSP.jl @@ -26,12 +26,14 @@ The third-order SSP Runge-Kutta method of Shu and Osher. struct SimpleSSPRK33{StageCallbacks} <: SimpleAlgorithmSSP a::SVector{3, Float64} b::SVector{3, Float64} + denom::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) + a = SVector(0.0, 3.0, 1.0) # a = a / denom + b = SVector(1.0, 1.0, 2.0) # b = b / denom + denom = SVector(1.0, 4.0, 3.0) c = SVector(0.0, 1.0, 1 / 2) # Butcher tableau @@ -42,7 +44,7 @@ struct SimpleSSPRK33{StageCallbacks} <: SimpleAlgorithmSSP # -------------------- # b | 1/6 1/6 2/3 - new{typeof(stage_callbacks)}(a, b, c, stage_callbacks) + new{typeof(stage_callbacks)}(a, b, denom, c, stage_callbacks) end end @@ -166,7 +168,7 @@ function solve!(integrator::SimpleIntegratorSSP) end # perform convex combination - @. integrator.u = alg.a[stage] * integrator.r0 + alg.b[stage] * integrator.u + @. integrator.u = (alg.a[stage] * integrator.r0 + alg.b[stage] * integrator.u) / alg.denom[stage] end integrator.iter += 1 From 643e0b225d722bb9aa482289cfb2d97593c7447c Mon Sep 17 00:00:00 2001 From: bennibolm Date: Fri, 15 Sep 2023 18:12:49 +0200 Subject: [PATCH 2/3] Fix format --- src/time_integration/methods_SSP.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/time_integration/methods_SSP.jl b/src/time_integration/methods_SSP.jl index 942a2aaa6bd..a4941142ec0 100644 --- a/src/time_integration/methods_SSP.jl +++ b/src/time_integration/methods_SSP.jl @@ -168,7 +168,8 @@ function solve!(integrator::SimpleIntegratorSSP) end # perform convex combination - @. integrator.u = (alg.a[stage] * integrator.r0 + alg.b[stage] * integrator.u) / alg.denom[stage] + @. integrator.u = (alg.a[stage] * integrator.r0 + + alg.b[stage] * integrator.u) / alg.denom[stage] end integrator.iter += 1 From 044b4391a9e1fcb006a4adb75da00636439a0947 Mon Sep 17 00:00:00 2001 From: bennibolm Date: Fri, 15 Sep 2023 18:43:37 +0200 Subject: [PATCH 3/3] Implement suggestions --- src/time_integration/methods_SSP.jl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/time_integration/methods_SSP.jl b/src/time_integration/methods_SSP.jl index a4941142ec0..a0ed889968a 100644 --- a/src/time_integration/methods_SSP.jl +++ b/src/time_integration/methods_SSP.jl @@ -24,16 +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} - denom::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.0, 1.0) # a = a / denom - b = SVector(1.0, 1.0, 2.0) # b = b / denom - denom = SVector(1.0, 4.0, 3.0) + 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 @@ -44,7 +44,8 @@ struct SimpleSSPRK33{StageCallbacks} <: SimpleAlgorithmSSP # -------------------- # b | 1/6 1/6 2/3 - new{typeof(stage_callbacks)}(a, b, denom, c, stage_callbacks) + new{typeof(stage_callbacks)}(numerator_a, numerator_b, denominator, c, + stage_callbacks) end end @@ -168,8 +169,9 @@ function solve!(integrator::SimpleIntegratorSSP) end # perform convex combination - @. integrator.u = (alg.a[stage] * integrator.r0 + - alg.b[stage] * integrator.u) / alg.denom[stage] + @. integrator.u = (alg.numerator_a[stage] * integrator.r0 + + alg.numerator_b[stage] * integrator.u) / + alg.denominator[stage] end integrator.iter += 1