From 6fc27e2dab0532d44c931e57f2ba2fa6fb56f36b Mon Sep 17 00:00:00 2001 From: Patrick Ersing <114223904+patrickersing@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:45:02 +0200 Subject: [PATCH] Apply suggestions from code review remove implicit multiplication; fix comment Co-authored-by: Andrew Winters --- ...lixir_shallowwater_multilayer_dam_break.jl | 3 +- src/equations/shallow_water_multilayer_2d.jl | 158 +++++++++--------- 2 files changed, 80 insertions(+), 81 deletions(-) diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_multilayer_dam_break.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_multilayer_dam_break.jl index 4f1f1bb..5fb3f91 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_multilayer_dam_break.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_multilayer_dam_break.jl @@ -85,8 +85,7 @@ function initial_condition_discontinuous_dam_break(x, t, element_id, IDs = [1, 2, 5, 6, 9, 10, 13, 14] if element_id in IDs H = SVector(1.0, 0.8, 0.6) - # Right side of discontinuity - else + else # Right side of discontinuity H = SVector(0.9, 0.7, 0.5) b += 0.1 end diff --git a/src/equations/shallow_water_multilayer_2d.jl b/src/equations/shallow_water_multilayer_2d.jl index 16dd026..ab3009c 100644 --- a/src/equations/shallow_water_multilayer_2d.jl +++ b/src/equations/shallow_water_multilayer_2d.jl @@ -168,85 +168,85 @@ in non-periodic domains). # this manufactured solution velocity is taken to be constant ω = 2 * pi * sqrt(2.0) - du1 = -0.1cos(t + x[2] * ω) - 0.1sin(t + x[1] * ω) - 0.1sin(t + x[2] * ω) - - 0.1cos(t + x[1] * ω) - 0.1cos(t + x[2] * ω) * ω + - 0.8(-0.1sin(t + x[1] * ω) * ω - 0.1cos(t + x[1] * ω) * ω) - - 0.1sin(t + x[2] * ω) * ω - - du2 = 0.1cos(t + x[2] * ω) + 0.1sin(t + x[1] * ω) + 0.1sin(t + x[2] * ω) + - 0.1cos(t + x[1] * ω) + 0.1cos(t + x[2] * ω) * ω + - 0.8(0.1sin(t + x[1] * ω) * ω + 0.1cos(t + x[1] * ω) * ω) + - 0.1sin(t + x[2] * ω) * ω - - du3 = -0.1sin(t + x[1] * ω) - 0.1sin(t + x[2] * ω) + 0.1sin(x[2] * ω) * ω + - 0.8(0.1sin(x[1] * ω) * ω - 0.1sin(t + x[1] * ω) * ω) - - 0.1sin(t + x[2] * ω) * ω - - du4 = 0.8(-0.1cos(t + x[2] * ω) - 0.1sin(t + x[1] * ω) - 0.1sin(t + x[2] * ω) - - 0.1cos(t + x[1] * ω)) + - 0.8(-0.1cos(t + x[2] * ω) * ω - 0.1sin(t + x[2] * ω) * ω) + - 0.8^2 * (-0.1sin(t + x[1] * ω) * ω - 0.1cos(t + x[1] * ω) * ω) + - 10.0(2.0 + 0.1cos(t + x[2] * ω) - 0.1sin(t + x[1] * ω) - - 0.1sin(t + x[2] * ω) + 0.1cos(t + x[1] * ω)) * - (-0.1sin(t + x[1] * ω) * ω - 0.1cos(t + x[1] * ω) * ω) + - (2.0 + 0.1cos(t + x[2] * ω) - 0.1sin(t + x[1] * ω) - 0.1sin(t + x[2] * ω) + - 0.1cos(t + x[1] * ω)) * cos(t + x[1] * ω) * ω - - du5 = 0.8(0.1cos(t + x[2] * ω) + 0.1sin(t + x[1] * ω) + 0.1sin(t + x[2] * ω) + - 0.1cos(t + x[1] * ω)) + - 0.8(0.1cos(t + x[2] * ω) * ω + 0.1sin(t + x[2] * ω) * ω) + - 0.8^2 * (0.1sin(t + x[1] * ω) * ω + 0.1cos(t + x[1] * ω) * ω) + - 10.0(0.5 - 0.1cos(t + x[2] * ω) + 0.1sin(t + x[1] * ω) + - 0.1sin(t + x[2] * ω) - 0.1cos(t + x[1] * ω)) * - (0.1sin(t + x[1] * ω) * ω + 0.1cos(t + x[1] * ω) * ω) + - 10.0(0.5 - 0.1cos(t + x[2] * ω) + 0.1sin(t + x[1] * ω) + - 0.1sin(t + x[2] * ω) - 0.1cos(t + x[1] * ω)) * - (-0.1sin(t + x[1] * ω) * ω + - 0.9(-0.1sin(t + x[1] * ω) * ω - 0.1cos(t + x[1] * ω) * ω)) - - du6 = 0.8(-0.1sin(t + x[1] * ω) - 0.1sin(t + x[2] * ω)) + - 0.8(0.1sin(x[2] * ω) * ω - 0.1sin(t + x[2] * ω) * ω) + - 0.8^2 * (0.1sin(x[1] * ω) * ω - 0.1sin(t + x[1] * ω) * ω) + - 10.0(0.5 - 0.1cos(x[1] * ω) + 0.1cos(t + x[2] * ω) - 0.1cos(x[2] * ω) + - 0.1cos(t + x[1] * ω)) * - (0.1sin(x[1] * ω) * ω - 0.1sin(t + x[1] * ω) * ω) + - 10.0(0.5 - 0.1cos(x[1] * ω) + 0.1cos(t + x[2] * ω) - 0.1cos(x[2] * ω) + - 0.1cos(t + x[1] * ω)) * (-0.1sin(x[1] * ω) * ω + - 0.9 / 1.1 * (-0.1sin(t + x[1] * ω) * ω - 0.1cos(t + x[1] * ω) * ω) + - 1.0 / 1.1 * (0.1sin(t + x[1] * ω) * ω + 0.1cos(t + x[1] * ω) * ω)) - - du7 = -0.1cos(t + x[2] * ω) - 0.1sin(t + x[1] * ω) - 0.1sin(t + x[2] * ω) - - 0.1cos(t + x[1] * ω) - 0.1cos(t + x[2] * ω) * ω + - 0.8(-0.1sin(t + x[1] * ω) * ω - 0.1cos(t + x[1] * ω) * ω) - - 0.1sin(t + x[2] * ω) * ω + - 10.0(2.0 + 0.1cos(t + x[2] * ω) - 0.1sin(t + x[1] * ω) - - 0.1sin(t + x[2] * ω) + 0.1cos(t + x[1] * ω)) * - (-0.1cos(t + x[2] * ω) * ω - 0.1sin(t + x[2] * ω) * ω) + - (2.0 + 0.1cos(t + x[2] * ω) - 0.1sin(t + x[1] * ω) - 0.1sin(t + x[2] * ω) + - 0.1cos(t + x[1] * ω)) * cos(t + x[2] * ω) * ω - - du8 = 0.1cos(t + x[2] * ω) + 0.1sin(t + x[1] * ω) + 0.1sin(t + x[2] * ω) + - 0.1cos(t + x[1] * ω) + 0.1cos(t + x[2] * ω) * ω + - 0.8(0.1sin(t + x[1] * ω) * ω + 0.1cos(t + x[1] * ω) * ω) + - 0.1sin(t + x[2] * ω) * ω + - 10.0(0.5 - 0.1cos(t + x[2] * ω) + 0.1sin(t + x[1] * ω) + - 0.1sin(t + x[2] * ω) - 0.1cos(t + x[1] * ω)) * - (0.9(-0.1cos(t + x[2] * ω) * ω - 0.1sin(t + x[2] * ω) * ω) - - 0.1sin(t + x[2] * ω) * ω) + - 10.0(0.5 - 0.1cos(t + x[2] * ω) + 0.1sin(t + x[1] * ω) + - 0.1sin(t + x[2] * ω) - 0.1cos(t + x[1] * ω)) * - (0.1cos(t + x[2] * ω) * ω + 0.1sin(t + x[2] * ω) * ω) - - du9 = -0.1sin(t + x[1] * ω) - 0.1sin(t + x[2] * ω) + 0.1sin(x[2] * ω) * ω + - 0.8(0.1sin(x[1] * ω) * ω - 0.1sin(t + x[1] * ω) * ω) - - 0.1sin(t + x[2] * ω) * ω + - 10.0(0.5 - 0.1cos(x[1] * ω) + 0.1cos(t + x[2] * ω) - 0.1cos(x[2] * ω) + - 0.1cos(t + x[1] * ω)) * - (0.9 / 1.1 * (-0.1cos(t + x[2] * ω) * ω - 0.1sin(t + x[2] * ω) * ω) + - 1.0 / 1.1 * (0.1cos(t + x[2] * ω) * ω + 0.1sin(t + x[2] * ω) * ω) - - 0.1sin(x[2] * ω) * ω) + - 10.0(0.5 - 0.1cos(x[1] * ω) + 0.1cos(t + x[2] * ω) - 0.1cos(x[2] * ω) + - 0.1cos(t + x[1] * ω)) * (0.1sin(x[2] * ω) * ω - 0.1sin(t + x[2] * ω) * ω) + du1 = (-0.1 * cos(t + x[2] * ω) - 0.1 * sin(t + x[1] * ω) - 0.1 * sin(t + x[2] * ω) - + 0.1 * cos(t + x[1] * ω) - 0.1 * cos(t + x[2] * ω) * ω + + 0.8 * (-0.1 * sin(t + x[1] * ω) * ω - 0.1 * cos(t + x[1] * ω) * ω) - + 0.1 * sin(t + x[2] * ω) * ω) + + du2 = (0.1 * cos(t + x[2] * ω) + 0.1 * sin(t + x[1] * ω) + 0.1 * sin(t + x[2] * ω) + + 0.1 * cos(t + x[1] * ω) + 0.1 * cos(t + x[2] * ω) * ω + + 0.8 * (0.1 * sin(t + x[1] * ω) * ω + 0.1 * cos(t + x[1] * ω) * ω) + + 0.1 * sin(t + x[2] * ω) * ω) + + du3 = (-0.1 * sin(t + x[1] * ω) - 0.1 * sin(t + x[2] * ω) + 0.1 * sin(x[2] * ω) * ω + + 0.8 * (0.1 * sin(x[1] * ω) * ω - 0.1 * sin(t + x[1] * ω) * ω) - + 0.1 * sin(t + x[2] * ω) * ω) + + du4 = (0.8 * (-0.1 * cos(t + x[2] * ω) - 0.1 * sin(t + x[1] * ω) - 0.1 * sin(t + x[2] * ω) - + 0.1 * cos(t + x[1] * ω)) + + 0.8 * (-0.1 * cos(t + x[2] * ω) * ω - 0.1 * sin(t + x[2] * ω) * ω) + + 0.8^2 * (-0.1 * sin(t + x[1] * ω) * ω - 0.1 * cos(t + x[1] * ω) * ω) + + 10.0 * (2.0 + 0.1 * cos(t + x[2] * ω) - 0.1 * sin(t + x[1] * ω) - + 0.1 * sin(t + x[2] * ω) + 0.1 * cos(t + x[1] * ω)) * + (-0.1 * sin(t + x[1] * ω) * ω - 0.1 * cos(t + x[1] * ω) * ω) + + (2.0 + 0.1 * cos(t + x[2] * ω) - 0.1 * sin(t + x[1] * ω) - 0.1 * sin(t + x[2] * ω) + + 0.1 * cos(t + x[1] * ω)) * cos(t + x[1] * ω) * ω) + + du5 = (0.8 * (0.1 * cos(t + x[2] * ω) + 0.1 * sin(t + x[1] * ω) + 0.1 * sin(t + x[2] * ω) + + 0.1 * cos(t + x[1] * ω)) + + 0.8 * (0.1 * cos(t + x[2] * ω) * ω + 0.1 * sin(t + x[2] * ω) * ω) + + 0.8^2 * (0.1 * sin(t + x[1] * ω) * ω + 0.1 * cos(t + x[1] * ω) * ω) + + 10.0 * (0.5 - 0.1 * cos(t + x[2] * ω) + 0.1 * sin(t + x[1] * ω) + + 0.1 * sin(t + x[2] * ω) - 0.1 * cos(t + x[1] * ω)) * + (0.1 * sin(t + x[1] * ω) * ω + 0.1 * cos(t + x[1] * ω) * ω) + + 10.0 * (0.5 - 0.1 * cos(t + x[2] * ω) + 0.1 * sin(t + x[1] * ω) + + 0.1 * sin(t + x[2] * ω) - 0.1 * cos(t + x[1] * ω)) * + (-0.1 * sin(t + x[1] * ω) * ω + + 0.9 * (-0.1 * sin(t + x[1] * ω) * ω - 0.1 * cos(t + x[1] * ω) * ω))) + + du6 = (0.8 * (-0.1 * sin(t + x[1] * ω) - 0.1 * sin(t + x[2] * ω)) + + 0.8 * (0.1 * sin(x[2] * ω) * ω - 0.1 * sin(t + x[2] * ω) * ω) + + 0.8^2 * (0.1 * sin(x[1] * ω) * ω - 0.1 * sin(t + x[1] * ω) * ω) + + 10.0 * (0.5 - 0.1 * cos(x[1] * ω) + 0.1 * cos(t + x[2] * ω) - 0.1 * cos(x[2] * ω) + + 0.1 * cos(t + x[1] * ω)) * + (0.1 * sin(x[1] * ω) * ω - 0.1 * sin(t + x[1] * ω) * ω) + + 10.0 * (0.5 - 0.1 * cos(x[1] * ω) + 0.1 * cos(t + x[2] * ω) - 0.1 * cos(x[2] * ω) + + 0.1 * cos(t + x[1] * ω)) * (-0.1 * sin(x[1] * ω) * ω + + 0.9 / 1.1 * (-0.1 * sin(t + x[1] * ω) * ω - 0.1 * cos(t + x[1] * ω) * ω) + + 1.0 / 1.1 * (0.1 * sin(t + x[1] * ω) * ω + 0.1 * cos(t + x[1] * ω) * ω))) + + du7 = (-0.1 * cos(t + x[2] * ω) - 0.1 * sin(t + x[1] * ω) - 0.1 * sin(t + x[2] * ω) - + 0.1 * cos(t + x[1] * ω) - 0.1 * cos(t + x[2] * ω) * ω + + 0.8 * (-0.1 * sin(t + x[1] * ω) * ω - 0.1 * cos(t + x[1] * ω) * ω) - + 0.1 * sin(t + x[2] * ω) * ω + + 10.0 * (2.0 + 0.1 * cos(t + x[2] * ω) - 0.1 * sin(t + x[1] * ω) - + 0.1 * sin(t + x[2] * ω) + 0.1 * cos(t + x[1] * ω)) * + (-0.1 * cos(t + x[2] * ω) * ω - 0.1 * sin(t + x[2] * ω) * ω) + + (2.0 + 0.1 * cos(t + x[2] * ω) - 0.1 * sin(t + x[1] * ω) - 0.1 * sin(t + x[2] * ω) + + 0.1 * cos(t + x[1] * ω)) * cos(t + x[2] * ω) * ω) + + du8 = (0.1 * cos(t + x[2] * ω) + 0.1 * sin(t + x[1] * ω) + 0.1 * sin(t + x[2] * ω) + + 0.1 * cos(t + x[1] * ω) + 0.1 * cos(t + x[2] * ω) * ω + + 0.8 * (0.1 * sin(t + x[1] * ω) * ω + 0.1 * cos(t + x[1] * ω) * ω) + + 0.1 * sin(t + x[2] * ω) * ω + + 10.0 * (0.5 - 0.1 * cos(t + x[2] * ω) + 0.1 * sin(t + x[1] * ω) + + 0.1 * sin(t + x[2] * ω) - 0.1 * cos(t + x[1] * ω)) * + (0.9 * (-0.1 * cos(t + x[2] * ω) * ω - 0.1 * sin(t + x[2] * ω) * ω) - + 0.1 * sin(t + x[2] * ω) * ω) + + 10.0 * (0.5 - 0.1 * cos(t + x[2] * ω) + 0.1 * sin(t + x[1] * ω) + + 0.1 * sin(t + x[2] * ω) - 0.1 * cos(t + x[1] * ω)) * + (0.1 * cos(t + x[2] * ω) * ω + 0.1 * sin(t + x[2] * ω) * ω)) + + du9 = (-0.1 * sin(t + x[1] * ω) - 0.1 * sin(t + x[2] * ω) + 0.1 * sin(x[2] * ω) * ω + + 0.8 * (0.1 * sin(x[1] * ω) * ω - 0.1 * sin(t + x[1] * ω) * ω) - + 0.1 * sin(t + x[2] * ω) * ω + + 10.0 * (0.5 - 0.1 * cos(x[1] * ω) + 0.1 * cos(t + x[2] * ω) - 0.1 * cos(x[2] * ω) + + 0.1 * cos(t + x[1] * ω)) * + (0.9 / 1.1 * (-0.1 * cos(t + x[2] * ω) * ω - 0.1 * sin(t + x[2] * ω) * ω) + + 1.0 / 1.1 * (0.1 * cos(t + x[2] * ω) * ω + 0.1 * sin(t + x[2] * ω) * ω) - + 0.1 * sin(x[2] * ω) * ω) + + 10.0 * (0.5 - 0.1 * cos(x[1] * ω) + 0.1 * cos(t + x[2] * ω) - 0.1 * cos(x[2] * ω) + + 0.1 * cos(t + x[1] * ω)) * (0.1 * sin(x[2] * ω) * ω - 0.1 * sin(t + x[2] * ω) * ω)) return SVector(du1, du2, du3, du4, du5, du6, du7, du8, du9, zero(eltype(u))) end