From 5321c8db203939078b7a73c4c7bad007bfa893e2 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 15:26:20 -0600 Subject: [PATCH 01/14] adding DGMulti versions of fluxes --- src/equations/compressible_euler_quasi_1d.jl | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/equations/compressible_euler_quasi_1d.jl b/src/equations/compressible_euler_quasi_1d.jl index 0a543277ee4..2d12c8f0232 100644 --- a/src/equations/compressible_euler_quasi_1d.jl +++ b/src/equations/compressible_euler_quasi_1d.jl @@ -163,6 +163,10 @@ end """ @inline function flux_nonconservative_chan_etal(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquationsQuasi1D) +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction, + equations::CompressibleEulerEquationsQuasi1D) +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_ll, normal_rr, + equations::CompressibleEulerEquationsQuasi1D) Non-symmetric two-point volume flux discretizing the nonconservative (source) term that contains the gradient of the pressure [`CompressibleEulerEquationsQuasi1D`](@ref) @@ -190,6 +194,18 @@ Further details are available in the paper: return SVector(z, a_ll * p_avg, z, z) end +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, + equations::CompressibleEulerEquationsQuasi1D) + return normal_direction[1] * flux_nonconservative_chan_etal(u_ll, u_rr, 1, equations) +end + +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, + normal_ll::AbstractVector, normal_rr::AbstractVector, + equations::CompressibleEulerEquationsQuasi1D) + # normal_ll should be equal to normal_rr in 1D + return flux_nonconservative_chan_etal(u_ll, u_rr, normal_ll, equations) +end + """ @inline function flux_chan_etal(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquationsQuasi1D) @@ -230,6 +246,11 @@ Further details are available in the paper: return SVector(f1, f2, f3, zero(eltype(u_ll))) end +@inline function flux_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, + equations::CompressibleEulerEquationsQuasi1D) + return normal_direction[1] * flux_chan_etal(u_ll, u_rr, 1, equations) +end + # Calculate estimates for maximum wave speed for local Lax-Friedrichs-type dissipation as the # maximum velocity magnitude plus the maximum speed of sound @inline function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, From db89b06b766e02f0d10923da86fd3b400178f315 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 15:27:33 -0600 Subject: [PATCH 02/14] remove incorrect factor of 2 --- src/solvers/dgmulti/flux_differencing.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solvers/dgmulti/flux_differencing.jl b/src/solvers/dgmulti/flux_differencing.jl index 36aa50dff4e..f38292deb11 100644 --- a/src/solvers/dgmulti/flux_differencing.jl +++ b/src/solvers/dgmulti/flux_differencing.jl @@ -60,7 +60,7 @@ end for j in col_ids u_j = u[j] f_ij = volume_flux(u_i, u_j, orientation, equations) - du_i = du_i + 2 * A[i, j] * f_ij + du_i = du_i + A[i, j] * f_ij end du[i] = du_i end @@ -181,7 +181,7 @@ end # evaluated using both the normal and its average at interfaces. u_j = u[j] f_ij = volume_flux(u_i, u_j, normal_direction, normal_direction, equations) - du_i = du_i + 2 * A_ij * f_ij + du_i = du_i + A_ij * f_ij end du[i] = du_i end From 5e8545a9007715c64f6578e5e5ae5a6ba6e3ff47 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 15:29:55 -0600 Subject: [PATCH 03/14] add example and test --- examples/dgmulti_1d/elixir_euler_quasi_1d.jl | 50 ++++++++++++++++++++ test/test_dgmulti_1d.jl | 26 ++++++++++ 2 files changed, 76 insertions(+) create mode 100644 examples/dgmulti_1d/elixir_euler_quasi_1d.jl diff --git a/examples/dgmulti_1d/elixir_euler_quasi_1d.jl b/examples/dgmulti_1d/elixir_euler_quasi_1d.jl new file mode 100644 index 00000000000..ca418b3e654 --- /dev/null +++ b/examples/dgmulti_1d/elixir_euler_quasi_1d.jl @@ -0,0 +1,50 @@ +using OrdinaryDiffEq +using Trixi +using ForwardDiff + +############################################################################### +# Semidiscretization of the quasi 1d compressible Euler equations +# See Chan et al. https://doi.org/10.48550/arXiv.2307.12089 for details + +equations = CompressibleEulerEquationsQuasi1D(1.4) + +initial_condition = initial_condition_convergence_test + +surface_flux = (flux_chan_etal, flux_nonconservative_chan_etal) +volume_flux = surface_flux +dg = DGMulti(polydeg = 4, element_type = Line(), approximation_type = SBP(), + surface_integral = SurfaceIntegralWeakForm(surface_flux), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +cells_per_dimension = (8,) +mesh = DGMultiMesh(dg, cells_per_dimension, + coordinates_min = (-1.0,), coordinates_max = (1.0,), periodicity = true) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg; + source_terms = source_terms_convergence_test) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 2.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) +stepsize_callback = StepsizeCallback(cfl = 0.8) + +callbacks = CallbackSet(summary_callback, + analysis_callback, + alive_callback, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/test/test_dgmulti_1d.jl b/test/test_dgmulti_1d.jl index 79ad64075b4..d5bded9b6c1 100644 --- a/test/test_dgmulti_1d.jl +++ b/test/test_dgmulti_1d.jl @@ -162,6 +162,32 @@ end @test minimum(dg.basis.rst[1]) ≈ -1 @test maximum(dg.basis.rst[1])≈1 atol=0.35 end + +@trixi_testset "elixir_euler_quasi_1d.jl (SBP) " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_quasi_1d.jl"), + cells_per_dimension=(8,), + approximation_type=SBP(), + l2=[ + 1.633271343738687e-5, + 9.575385661756332e-6, + 1.2700331443128421e-5, + 0.0, + ], + linf=[ + 7.304984704381567e-5, + 5.2365944135601694e-5, + 6.469559594934893e-5, + 0.0, + ]) + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end +end end # Clean up afterwards: delete Trixi.jl output directory From 3db86804d0745b8fec0a47a189d423184dc1d646 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 15:39:23 -0600 Subject: [PATCH 04/14] formatting --- src/equations/compressible_euler_quasi_1d.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/equations/compressible_euler_quasi_1d.jl b/src/equations/compressible_euler_quasi_1d.jl index 2d12c8f0232..c8038bd12d7 100644 --- a/src/equations/compressible_euler_quasi_1d.jl +++ b/src/equations/compressible_euler_quasi_1d.jl @@ -194,13 +194,16 @@ Further details are available in the paper: return SVector(z, a_ll * p_avg, z, z) end -@inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, + normal_direction::AbstractVector, equations::CompressibleEulerEquationsQuasi1D) - return normal_direction[1] * flux_nonconservative_chan_etal(u_ll, u_rr, 1, equations) + return normal_direction[1] * + flux_nonconservative_chan_etal(u_ll, u_rr, 1, equations) end -@inline function flux_nonconservative_chan_etal(u_ll, u_rr, - normal_ll::AbstractVector, normal_rr::AbstractVector, +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, + normal_ll::AbstractVector, + normal_rr::AbstractVector, equations::CompressibleEulerEquationsQuasi1D) # normal_ll should be equal to normal_rr in 1D return flux_nonconservative_chan_etal(u_ll, u_rr, normal_ll, equations) @@ -246,7 +249,7 @@ Further details are available in the paper: return SVector(f1, f2, f3, zero(eltype(u_ll))) end -@inline function flux_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, +@inline function flux_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, equations::CompressibleEulerEquationsQuasi1D) return normal_direction[1] * flux_chan_etal(u_ll, u_rr, 1, equations) end From 2595ac32c62285b20105a2e1b5b330afab591905 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 15:44:07 -0600 Subject: [PATCH 05/14] add comment --- test/test_dgmulti_1d.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_dgmulti_1d.jl b/test/test_dgmulti_1d.jl index d5bded9b6c1..ebe4a1dec80 100644 --- a/test/test_dgmulti_1d.jl +++ b/test/test_dgmulti_1d.jl @@ -163,6 +163,7 @@ end @test maximum(dg.basis.rst[1])≈1 atol=0.35 end +# tests a non-conservative system @trixi_testset "elixir_euler_quasi_1d.jl (SBP) " begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_quasi_1d.jl"), cells_per_dimension=(8,), From 93bff5ae4b768531b19676d808494a1787cd36b2 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 17:00:25 -0600 Subject: [PATCH 06/14] revert removing factor of 2 --- src/solvers/dgmulti/flux_differencing.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solvers/dgmulti/flux_differencing.jl b/src/solvers/dgmulti/flux_differencing.jl index f38292deb11..aa5077a3f5d 100644 --- a/src/solvers/dgmulti/flux_differencing.jl +++ b/src/solvers/dgmulti/flux_differencing.jl @@ -60,7 +60,7 @@ end for j in col_ids u_j = u[j] f_ij = volume_flux(u_i, u_j, orientation, equations) - du_i = du_i + A[i, j] * f_ij + du_i = du_i + 2 * A[i, j] * f_ij end du[i] = du_i end @@ -181,7 +181,7 @@ end # evaluated using both the normal and its average at interfaces. u_j = u[j] f_ij = volume_flux(u_i, u_j, normal_direction, normal_direction, equations) - du_i = du_i + A_ij * f_ij + du_i = du_i + 2 * A_ij * f_ij end du[i] = du_i end From a28a5600dfb2d41345287917742211ba274cf584 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 17:01:05 -0600 Subject: [PATCH 07/14] formatting --- src/solvers/dgmulti/flux_differencing.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solvers/dgmulti/flux_differencing.jl b/src/solvers/dgmulti/flux_differencing.jl index aa5077a3f5d..36aa50dff4e 100644 --- a/src/solvers/dgmulti/flux_differencing.jl +++ b/src/solvers/dgmulti/flux_differencing.jl @@ -60,7 +60,7 @@ end for j in col_ids u_j = u[j] f_ij = volume_flux(u_i, u_j, orientation, equations) - du_i = du_i + 2 * A[i, j] * f_ij + du_i = du_i + 2 * A[i, j] * f_ij end du[i] = du_i end From ee5d3f2d888704a28dde1ba5f8663e96dedde44b Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 20:30:59 -0600 Subject: [PATCH 08/14] add SWE quasi-1D test d --- .../elixir_shallow_water_quasi_1d.jl | 49 +++++++++++++++++++ test/test_dgmulti_1d.jl | 28 ++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl diff --git a/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl b/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl new file mode 100644 index 00000000000..39fc593ea97 --- /dev/null +++ b/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl @@ -0,0 +1,49 @@ +using OrdinaryDiffEq +using Trixi +using ForwardDiff + +############################################################################### +# Semidiscretization of the quasi 1d shallow water equations +# See Chan et al. https://doi.org/10.48550/arXiv.2307.12089 for details + +equations = ShallowWaterEquationsQuasi1D(gravity_constant = 9.81) + +initial_condition = initial_condition_convergence_test + +volume_flux = (flux_chan_etal, flux_nonconservative_chan_etal) +surface_flux = (FluxPlusDissipation(flux_chan_etal, DissipationLocalLaxFriedrichs()), + flux_nonconservative_chan_etal) + +dg = DGMulti(polydeg = 4, element_type = Line(), approximation_type = SBP(), + surface_integral = SurfaceIntegralWeakForm(surface_flux), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +cells_per_dimension = (8,) +mesh = DGMultiMesh(dg, cells_per_dimension, + coordinates_min = (0.0,), coordinates_max = (sqrt(2),), periodicity = true) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg; + source_terms = source_terms_convergence_test) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +callbacks = CallbackSet(summary_callback, + analysis_callback, + alive_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks) +summary_callback() # print the timer summary diff --git a/test/test_dgmulti_1d.jl b/test/test_dgmulti_1d.jl index ebe4a1dec80..0363086341f 100644 --- a/test/test_dgmulti_1d.jl +++ b/test/test_dgmulti_1d.jl @@ -163,7 +163,33 @@ end @test maximum(dg.basis.rst[1])≈1 atol=0.35 end -# tests a non-conservative system +# test non-conservative systems +@trixi_testset "elixir_shallow_water_quasi_1d.jl (SBP) " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallow_water_quasi_1d.jl"), + cells_per_dimension=(8,), + approximation_type=SBP(), + l2=[ + 3.03001101100507e-6, + 1.692177335948727e-5, + 3.002634351734614e-16, + 1.1636653574178203e-15, + ], + linf=[ + 1.2043401988570679e-5, + 5.346847010329059e-5, + 9.43689570931383e-16, + 2.220446049250313e-15, + ]) + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end +end + @trixi_testset "elixir_euler_quasi_1d.jl (SBP) " begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_quasi_1d.jl"), cells_per_dimension=(8,), From 5fe4fafbc893fdc3638653dcc3737c9802a38de3 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 20:31:19 -0600 Subject: [PATCH 09/14] enable quasi1D SWE for DGMulti --- src/equations/shallow_water_quasi_1d.jl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/equations/shallow_water_quasi_1d.jl b/src/equations/shallow_water_quasi_1d.jl index d3935f0e75f..68be0fcd7d8 100644 --- a/src/equations/shallow_water_quasi_1d.jl +++ b/src/equations/shallow_water_quasi_1d.jl @@ -176,6 +176,18 @@ Further details are available in the paper: return SVector(z, equations.gravity * a_ll * h_ll * (h_rr + b_rr), z, z) end +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, + equations::ShallowWaterEquationsQuasi1D) + return normal_direction[1] * flux_nonconservative_chan_etal(u_ll, u_rr, 1, equations) +end + +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, + normal_ll::AbstractVector, normal_rr::AbstractVector, + equations::ShallowWaterEquationsQuasi1D) + # normal_ll should be equal to normal_rr + return flux_nonconservative_chan_etal(u_ll, u_rr, normal_ll, equations) +end + """ flux_chan_etal(u_ll, u_rr, orientation, equations::ShallowWaterEquationsQuasi1D) @@ -204,6 +216,11 @@ Further details are available in the paper: return SVector(f1, f2, zero(eltype(u_ll)), zero(eltype(u_ll))) end +@inline function flux_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, + equations::ShallowWaterEquationsQuasi1D) + return normal_direction[1] * flux_chan_etal(u_ll, u_rr, 1, equations) +end + # Calculate maximum wave speed for local Lax-Friedrichs-type dissipation as the # maximum velocity magnitude plus the maximum speed of sound @inline function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, From 3384553c2bf7e473bce9cebb0038c5a3d7639404 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 20:32:42 -0600 Subject: [PATCH 10/14] add docstrings --- src/equations/shallow_water_quasi_1d.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/equations/shallow_water_quasi_1d.jl b/src/equations/shallow_water_quasi_1d.jl index 68be0fcd7d8..b00dc3f2154 100644 --- a/src/equations/shallow_water_quasi_1d.jl +++ b/src/equations/shallow_water_quasi_1d.jl @@ -152,6 +152,11 @@ end """ flux_nonconservative_chan_etal(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquationsQuasi1D) + flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, + equations::ShallowWaterEquationsQuasi1D) + flux_nonconservative_chan_etal(u_ll, u_rr, + normal_ll::AbstractVector, normal_rr::AbstractVector, + equations::ShallowWaterEquationsQuasi1D) Non-symmetric two-point volume flux discretizing the nonconservative (source) term that contains the gradient of the bottom topography [`ShallowWaterEquationsQuasi1D`](@ref) From a62cca06874450ed7e2f26325729f839cdc79fa7 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 3 Jan 2024 20:36:29 -0600 Subject: [PATCH 11/14] formatting --- .../elixir_shallow_water_quasi_1d.jl | 3 ++- src/equations/shallow_water_quasi_1d.jl | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl b/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl index 39fc593ea97..a2818c099cc 100644 --- a/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl +++ b/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl @@ -20,7 +20,8 @@ dg = DGMulti(polydeg = 4, element_type = Line(), approximation_type = SBP(), cells_per_dimension = (8,) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (0.0,), coordinates_max = (sqrt(2),), periodicity = true) + coordinates_min = (0.0,), coordinates_max = (sqrt(2),), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg; source_terms = source_terms_convergence_test) diff --git a/src/equations/shallow_water_quasi_1d.jl b/src/equations/shallow_water_quasi_1d.jl index b00dc3f2154..07a19d9deed 100644 --- a/src/equations/shallow_water_quasi_1d.jl +++ b/src/equations/shallow_water_quasi_1d.jl @@ -181,16 +181,19 @@ Further details are available in the paper: return SVector(z, equations.gravity * a_ll * h_ll * (h_rr + b_rr), z, z) end -@inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, - equations::ShallowWaterEquationsQuasi1D) - return normal_direction[1] * flux_nonconservative_chan_etal(u_ll, u_rr, 1, equations) +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, + normal_direction::AbstractVector, + equations::ShallowWaterEquationsQuasi1D) + return normal_direction[1] * + flux_nonconservative_chan_etal(u_ll, u_rr, 1, equations) end -@inline function flux_nonconservative_chan_etal(u_ll, u_rr, - normal_ll::AbstractVector, normal_rr::AbstractVector, - equations::ShallowWaterEquationsQuasi1D) +@inline function flux_nonconservative_chan_etal(u_ll, u_rr, + normal_ll::AbstractVector, + normal_rr::AbstractVector, + equations::ShallowWaterEquationsQuasi1D) # normal_ll should be equal to normal_rr - return flux_nonconservative_chan_etal(u_ll, u_rr, normal_ll, equations) + return flux_nonconservative_chan_etal(u_ll, u_rr, normal_ll, equations) end """ @@ -222,7 +225,7 @@ Further details are available in the paper: end @inline function flux_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, - equations::ShallowWaterEquationsQuasi1D) + equations::ShallowWaterEquationsQuasi1D) return normal_direction[1] * flux_chan_etal(u_ll, u_rr, 1, equations) end From b3cfd96199fcfe8a02d60d94bf45c82725553be6 Mon Sep 17 00:00:00 2001 From: Jesse Chan <1156048+jlchan@users.noreply.github.com> Date: Thu, 4 Jan 2024 09:31:55 -0600 Subject: [PATCH 12/14] Update src/equations/compressible_euler_quasi_1d.jl Co-authored-by: Hendrik Ranocha --- src/equations/compressible_euler_quasi_1d.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/equations/compressible_euler_quasi_1d.jl b/src/equations/compressible_euler_quasi_1d.jl index c8038bd12d7..83af136153c 100644 --- a/src/equations/compressible_euler_quasi_1d.jl +++ b/src/equations/compressible_euler_quasi_1d.jl @@ -161,12 +161,12 @@ end end """ -@inline function flux_nonconservative_chan_etal(u_ll, u_rr, orientation::Integer, - equations::CompressibleEulerEquationsQuasi1D) -@inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction, - equations::CompressibleEulerEquationsQuasi1D) -@inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_ll, normal_rr, - equations::CompressibleEulerEquationsQuasi1D) + flux_nonconservative_chan_etal(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquationsQuasi1D) + flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction, + equations::CompressibleEulerEquationsQuasi1D) + flux_nonconservative_chan_etal(u_ll, u_rr, normal_ll, normal_rr, + equations::CompressibleEulerEquationsQuasi1D) Non-symmetric two-point volume flux discretizing the nonconservative (source) term that contains the gradient of the pressure [`CompressibleEulerEquationsQuasi1D`](@ref) From 75e7d27ca8439a001c022cb552d8201281bd14e4 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Thu, 4 Jan 2024 09:40:20 -0600 Subject: [PATCH 13/14] adding comments explaining why `normal_direction` is included in 1D --- src/equations/compressible_euler_1d.jl | 5 +++++ src/equations/compressible_euler_quasi_1d.jl | 10 ++++++++++ src/equations/shallow_water_quasi_1d.jl | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/equations/compressible_euler_1d.jl b/src/equations/compressible_euler_1d.jl index 05c38ce791d..a50c896cd1c 100644 --- a/src/equations/compressible_euler_1d.jl +++ b/src/equations/compressible_euler_1d.jl @@ -408,6 +408,11 @@ See also return SVector(f1, f2, f3) end +# While `normal_direction` isn't strictly necessary in 1D, certain solvers assume that +# the normal component is incorporated into the numerical flux. +# +# See `flux(u, normal_direction::AbstractVector, equations::AbstractEquations{1})` for a +# similar implementation. @inline function flux_ranocha(u_ll, u_rr, normal_direction::AbstractVector, equations::CompressibleEulerEquations1D) return normal_direction[1] * flux_ranocha(u_ll, u_rr, 1, equations) diff --git a/src/equations/compressible_euler_quasi_1d.jl b/src/equations/compressible_euler_quasi_1d.jl index 83af136153c..6844bf9bee5 100644 --- a/src/equations/compressible_euler_quasi_1d.jl +++ b/src/equations/compressible_euler_quasi_1d.jl @@ -194,6 +194,11 @@ Further details are available in the paper: return SVector(z, a_ll * p_avg, z, z) end +# While `normal_direction` isn't strictly necessary in 1D, certain solvers assume that +# the normal component is incorporated into the numerical flux. +# +# See `flux(u, normal_direction::AbstractVector, equations::AbstractEquations{1})` for a +# similar implementation. @inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, equations::CompressibleEulerEquationsQuasi1D) @@ -249,6 +254,11 @@ Further details are available in the paper: return SVector(f1, f2, f3, zero(eltype(u_ll))) end +# While `normal_direction` isn't strictly necessary in 1D, certain solvers assume that +# the normal component is incorporated into the numerical flux. +# +# See `flux(u, normal_direction::AbstractVector, equations::AbstractEquations{1})` for a +# similar implementation. @inline function flux_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, equations::CompressibleEulerEquationsQuasi1D) return normal_direction[1] * flux_chan_etal(u_ll, u_rr, 1, equations) diff --git a/src/equations/shallow_water_quasi_1d.jl b/src/equations/shallow_water_quasi_1d.jl index 07a19d9deed..d52fbab841d 100644 --- a/src/equations/shallow_water_quasi_1d.jl +++ b/src/equations/shallow_water_quasi_1d.jl @@ -181,6 +181,11 @@ Further details are available in the paper: return SVector(z, equations.gravity * a_ll * h_ll * (h_rr + b_rr), z, z) end +# While `normal_direction` isn't strictly necessary in 1D, certain solvers assume that +# the normal component is incorporated into the numerical flux. +# +# See `flux(u, normal_direction::AbstractVector, equations::AbstractEquations{1})` for a +# similar implementation. @inline function flux_nonconservative_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, equations::ShallowWaterEquationsQuasi1D) @@ -224,6 +229,11 @@ Further details are available in the paper: return SVector(f1, f2, zero(eltype(u_ll)), zero(eltype(u_ll))) end +# While `normal_direction` isn't strictly necessary in 1D, certain solvers assume that +# the normal component is incorporated into the numerical flux. +# +# See `flux(u, normal_direction::AbstractVector, equations::AbstractEquations{1})` for a +# similar implementation. @inline function flux_chan_etal(u_ll, u_rr, normal_direction::AbstractVector, equations::ShallowWaterEquationsQuasi1D) return normal_direction[1] * flux_chan_etal(u_ll, u_rr, 1, equations) From fdb34c4cdf4a69b87b1c7ec4f0ee3884a2e62cee Mon Sep 17 00:00:00 2001 From: Jesse Chan <1156048+jlchan@users.noreply.github.com> Date: Thu, 4 Jan 2024 11:56:46 -0600 Subject: [PATCH 14/14] Apply suggestions from code review Co-authored-by: Daniel Doehring --- examples/dgmulti_1d/elixir_euler_quasi_1d.jl | 1 - examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/dgmulti_1d/elixir_euler_quasi_1d.jl b/examples/dgmulti_1d/elixir_euler_quasi_1d.jl index ca418b3e654..19269fa925b 100644 --- a/examples/dgmulti_1d/elixir_euler_quasi_1d.jl +++ b/examples/dgmulti_1d/elixir_euler_quasi_1d.jl @@ -1,6 +1,5 @@ using OrdinaryDiffEq using Trixi -using ForwardDiff ############################################################################### # Semidiscretization of the quasi 1d compressible Euler equations diff --git a/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl b/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl index a2818c099cc..85741f9dbd3 100644 --- a/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl +++ b/examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl @@ -1,6 +1,5 @@ using OrdinaryDiffEq using Trixi -using ForwardDiff ############################################################################### # Semidiscretization of the quasi 1d shallow water equations