From f17f7a81b7b93aea239ffcec2719fb26eb12f215 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 9 Sep 2025 17:32:23 +0200 Subject: [PATCH 01/13] Schulz-Rinne (2D) Riemann Problem --- ...ixir_euler_riemannproblem_quadrants_amr.jl | 159 ++++++++++++++++++ test/test_tree_2d_euler.jl | 26 +++ 2 files changed, 185 insertions(+) create mode 100644 examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl new file mode 100644 index 00000000000..33f0889cd93 --- /dev/null +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -0,0 +1,159 @@ +using OrdinaryDiffEqSSPRK +using Trixi + +############################################################################### +## Semidiscretization of the compressible Euler equations + +equations = CompressibleEulerEquations2D(1.4) + +# Variant of the 4-quadrant Riemann problem considered in +# - Carsten W. Schulz-Rinne: +# Classification of the Riemann Problem for Two-Dimensional Gas Dynamics +# https://doi.org/10.1137/0524006 +# and +# - Carsten W. Schulz-Rinne, James P. Collins, and Harland M. Glaz +# Numerical Solution of the Riemann Problem for Two-Dimensional Gas Dynamics +# https://doi.org/10.1137/0914082 +function initial_condition_rp(x_, t, equations::CompressibleEulerEquations2D) + x, y = x_[1], x_[2] + + if x >= 0.5 && y >= 0.5 + rho, v1, v2, p = (0.5313, 0.0, 0.0, 0.4) + elseif x < 0.5 && y >= 0.5 + rho, v1, v2, p = (1.0, 0.7276, 0.0, 1.0) + elseif x < 0.5 && y < 0.5 + rho, v1, v2, p = (0.8, 0.0, 0.0, 1.0) + elseif x >= 0.5 && y < 0.5 + rho, v1, v2, p = (1.0, 0.0, 0.7276, 1.0) + end + + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) +end +initial_condition = initial_condition_rp + +# See Section 2.3 of the reference below for a discussion of robust +# subsonic inflow/outflow boundary conditions. +# +# - Jan-Reneé Carlson (2011) +# Inflow/Outflow Boundary Conditions with Application to FUN3D. +# [NASA TM 20110022658](https://ntrs.nasa.gov/citations/20110022658) +@inline function boundary_condition_subsonic(u_inner, orientation::Integer, + normal_direction, x, t, + surface_flux_function, + equations::CompressibleEulerEquations2D) + rho_loc, v1_loc, v2_loc, p_loc = cons2prim(u_inner, equations) + + p_loc = pressure(initial_condition_rp(x, t, equations), equations) + + prim = SVector(rho_loc, v1_loc, v2_loc, p_loc) + u_surface = prim2cons(prim, equations) + + return Trixi.flux(u_surface, orientation, equations) +end + +boundary_conditions = (x_neg = boundary_condition_subsonic, + x_pos = boundary_condition_do_nothing, + y_neg = boundary_condition_subsonic, + y_pos = boundary_condition_do_nothing) + +coordinates_min = (0.0, 0.0) +coordinates_max = (1.0, 1.0) + +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 4, + n_cells_max = 100_000, + periodicity = false) + +surface_flux = flux_hllc +volume_flux = flux_ranocha + +polydeg = 3 +basis = LobattoLegendreBasis(polydeg) +shock_indicator = IndicatorHennemannGassner(equations, basis, + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = Trixi.density) + +volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) + +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) + +# Specialized function for computing coefficients of `func`, +# here the discontinuous `initial_condition_rp`. +# +# Shift the outer (i.e., ±1 on the reference element) nodes passed to the +# `func` inwards by the smallest amount possible, i.e., [-1 + ϵ, +1 - ϵ]. +# This avoids steep gradients in elements if a discontinuity is right at a cell boundary, +# i.e., if the jump location `x_jump` is at the position of an interface which is shared by +# the nodes x_{e-1}^{(i)} = x_{e}^{(1)}. +# +# In particular, this results in the typically desired behaviour for +# initial conditions of the form +# { u_1, if x <= x_jump +# u(x, t) = { +# { u_2, if x > x_jump +function Trixi.compute_coefficients!(u, func, t, + mesh::TreeMesh{2}, equations, dg::DG, cache) + Trixi.@threaded for element in eachelement(dg, cache) + for j in eachnode(dg), i in eachnode(dg) + x_node = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, + i, j, element) + if i == 1 # left boundary node + x_node = SVector(nextfloat(x_node[1]), x_node[2]) + elseif i == nnodes(dg) # right boundary node + x_node = SVector(prevfloat(x_node[1]), x_node[2]) + end + if j == 1 # bottom boundary node + x_node = SVector(x_node[1], nextfloat(x_node[2])) + elseif j == nnodes(dg) # top boundary node + x_node = SVector(x_node[1], prevfloat(x_node[2])) + end + + u_node = func(x_node, t, equations) + set_node_vars!(u, u_node, equations, dg, i, j, element) + end + end +end + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; + boundary_conditions = boundary_conditions) + +############################################################################### +## ODE solvers, callbacks etc. + +tspan = (0.0, 0.25) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 1000 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +stepsize_callback = StepsizeCallback(cfl = 1.8) + +amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) +amr_controller = ControllerThreeLevel(semi, amr_indicator, + base_level = 3, + med_level = 5, med_threshold = 0.02, + max_level = 8, max_threshold = 0.04) +amr_callback = AMRCallback(semi, amr_controller, + interval = 10, + adapt_initial_condition = true) + +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, + amr_callback, + stepsize_callback) + +############################################################################### +## Run the simulation + +sol = solve(ode, SSPRK54(); + dt = 1.0, save_everystep = false, callback = callbacks); diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index cd4b2bd5c24..41275a39034 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -1104,6 +1104,32 @@ end @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 end end + +@trixi_testset "elixir_euler_riemannproblem_quadrants_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_riemannproblem_quadrants_amr.jl"), + tspan=(0.0, 0.05), + l2=[ + 0.1366907511304207, + 0.1411685226288184, + 0.14116852262881724, + 0.5172189926332071 + ], + linf=[ + 1.2134748489242826, + 1.6127768559232698, + 1.6127768559232791, + 6.155567493629927 + ]) + # 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 end # module From d5dd50f709c6d74caa2524e87a00b0e4a3c5218a Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 9 Sep 2025 22:11:42 +0200 Subject: [PATCH 02/13] work --- Project.toml | 1 + ...ixir_euler_riemannproblem_quadrants_amr.jl | 32 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 14cb9781453..94214a24c93 100644 --- a/Project.toml +++ b/Project.toml @@ -25,6 +25,7 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221" Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +OrdinaryDiffEqSSPRK = "669c94d9-1f4b-4b64-b377-1aa079aa2388" P4est = "7d669430-f675-4ae7-b43e-fab78ec5a902" Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index 33f0889cd93..1b9b0104ba5 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -17,13 +17,13 @@ equations = CompressibleEulerEquations2D(1.4) function initial_condition_rp(x_, t, equations::CompressibleEulerEquations2D) x, y = x_[1], x_[2] - if x >= 0.5 && y >= 0.5 + if x >= 0.5 && y >= 0.5 # 1st quadrant rho, v1, v2, p = (0.5313, 0.0, 0.0, 0.4) - elseif x < 0.5 && y >= 0.5 + elseif x < 0.5 && y >= 0.5 # 2nd quadrant rho, v1, v2, p = (1.0, 0.7276, 0.0, 1.0) - elseif x < 0.5 && y < 0.5 + elseif x < 0.5 && y < 0.5 # 3rd quadrant rho, v1, v2, p = (0.8, 0.0, 0.0, 1.0) - elseif x >= 0.5 && y < 0.5 + elseif x >= 0.5 && y < 0.5 # 4th quadrant rho, v1, v2, p = (1.0, 0.0, 0.7276, 1.0) end @@ -32,6 +32,24 @@ function initial_condition_rp(x_, t, equations::CompressibleEulerEquations2D) end initial_condition = initial_condition_rp +function initial_condition_element_discontinuous(x_, t, equations::CompressibleEulerEquations2D, + orientation, direction) + x, y = x_[1], x_[2] + + if x >= 0.5 && y >= 0.5 # 1st quadrant + rho, v1, v2, p = (0.5313, 0.0, 0.0, 0.4) + elseif x < 0.5 && y >= 0.5 # 2nd quadrant + rho, v1, v2, p = (1.0, 0.7276, 0.0, 1.0) + elseif x < 0.5 && y < 0.5 # 3rd quadrant + rho, v1, v2, p = (0.8, 0.0, 0.0, 1.0) + elseif x >= 0.5 && y < 0.5 # 4th quadrant + rho, v1, v2, p = (1.0, 0.0, 0.7276, 1.0) + end + + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) +end + # See Section 2.3 of the reference below for a discussion of robust # subsonic inflow/outflow boundary conditions. # @@ -39,11 +57,13 @@ initial_condition = initial_condition_rp # Inflow/Outflow Boundary Conditions with Application to FUN3D. # [NASA TM 20110022658](https://ntrs.nasa.gov/citations/20110022658) @inline function boundary_condition_subsonic(u_inner, orientation::Integer, - normal_direction, x, t, + direction, x, t, surface_flux_function, equations::CompressibleEulerEquations2D) rho_loc, v1_loc, v2_loc, p_loc = cons2prim(u_inner, equations) + println(typeof(direction)) + p_loc = pressure(initial_condition_rp(x, t, equations), equations) prim = SVector(rho_loc, v1_loc, v2_loc, p_loc) @@ -126,7 +146,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; ############################################################################### ## ODE solvers, callbacks etc. -tspan = (0.0, 0.25) +tspan = (0.0, 0.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() From 6d303cfa5a19f4bf4b4b61b9accdf2a02ab58a16 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 9 Sep 2025 22:58:10 +0200 Subject: [PATCH 03/13] p --- Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Project.toml b/Project.toml index 94214a24c93..14cb9781453 100644 --- a/Project.toml +++ b/Project.toml @@ -25,7 +25,6 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221" Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -OrdinaryDiffEqSSPRK = "669c94d9-1f4b-4b64-b377-1aa079aa2388" P4est = "7d669430-f675-4ae7-b43e-fab78ec5a902" Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" From d440020933bcda88ca37cb39004635bc424ee47f Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 9 Sep 2025 23:04:01 +0200 Subject: [PATCH 04/13] comment --- .../elixir_euler_riemannproblem_quadrants_amr.jl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index 1b9b0104ba5..fd41732b84f 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -32,7 +32,8 @@ function initial_condition_rp(x_, t, equations::CompressibleEulerEquations2D) end initial_condition = initial_condition_rp -function initial_condition_element_discontinuous(x_, t, equations::CompressibleEulerEquations2D, +function initial_condition_element_discontinuous(x_, t, + equations::CompressibleEulerEquations2D, orientation, direction) x, y = x_[1], x_[2] @@ -72,6 +73,17 @@ end return Trixi.flux(u_surface, orientation, equations) end +# The flow is subsonic at all boundaries. +# Due to the LGL nodes including the boundary points of the reference element ± 1 +# setting discontinuous initial conditions with the desired behaviour +# { u_1, if x <= x_jump +# u(x, t) = { +# { u_2, if x > x_jump +# is difficult. +# Since the initial condition is queried in `boundary_condition_subsonic` above +# these difficulties propagate to the boundary conditions. +# The setup below is a workaround and works for this specific example, but +# generalization to other simulations cannot be expected. boundary_conditions = (x_neg = boundary_condition_subsonic, x_pos = boundary_condition_do_nothing, y_neg = boundary_condition_subsonic, @@ -146,7 +158,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; ############################################################################### ## ODE solvers, callbacks etc. -tspan = (0.0, 0.0) +tspan = (0.0, 0.25) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() From 55ffe2609c80fdc22d66e27bacb660e3e7ea6771 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 9 Sep 2025 23:05:42 +0200 Subject: [PATCH 05/13] clean up --- ...ixir_euler_riemannproblem_quadrants_amr.jl | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index fd41732b84f..248fb448264 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -32,25 +32,6 @@ function initial_condition_rp(x_, t, equations::CompressibleEulerEquations2D) end initial_condition = initial_condition_rp -function initial_condition_element_discontinuous(x_, t, - equations::CompressibleEulerEquations2D, - orientation, direction) - x, y = x_[1], x_[2] - - if x >= 0.5 && y >= 0.5 # 1st quadrant - rho, v1, v2, p = (0.5313, 0.0, 0.0, 0.4) - elseif x < 0.5 && y >= 0.5 # 2nd quadrant - rho, v1, v2, p = (1.0, 0.7276, 0.0, 1.0) - elseif x < 0.5 && y < 0.5 # 3rd quadrant - rho, v1, v2, p = (0.8, 0.0, 0.0, 1.0) - elseif x >= 0.5 && y < 0.5 # 4th quadrant - rho, v1, v2, p = (1.0, 0.0, 0.7276, 1.0) - end - - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) -end - # See Section 2.3 of the reference below for a discussion of robust # subsonic inflow/outflow boundary conditions. # From 1a3c674e1c0529236060204d1c72cbcc4a2ada59 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 9 Sep 2025 23:07:55 +0200 Subject: [PATCH 06/13] clean up --- .../tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index 248fb448264..254eb7f0728 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -44,8 +44,7 @@ initial_condition = initial_condition_rp equations::CompressibleEulerEquations2D) rho_loc, v1_loc, v2_loc, p_loc = cons2prim(u_inner, equations) - println(typeof(direction)) - + # For subsonic boundary: Take pressure from initial condition p_loc = pressure(initial_condition_rp(x, t, equations), equations) prim = SVector(rho_loc, v1_loc, v2_loc, p_loc) From 1d90003df0adcc2bdcff58c8f3dcbf973b6b0dbd Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 9 Sep 2025 23:13:17 +0200 Subject: [PATCH 07/13] hllc comment --- .../tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index 254eb7f0728..5eb8dcbb74b 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -77,6 +77,7 @@ mesh = TreeMesh(coordinates_min, coordinates_max, n_cells_max = 100_000, periodicity = false) +# HLLC flux is strictly required for this problem surface_flux = flux_hllc volume_flux = flux_ranocha @@ -148,7 +149,7 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval) alive_callback = AliveCallback(analysis_interval = analysis_interval) -stepsize_callback = StepsizeCallback(cfl = 1.8) +stepsize_callback = StepsizeCallback(cfl = 1.0) amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, From de4e3668a9d934f19a421a83d99e4c2de1aa6c6b Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 9 Sep 2025 23:15:24 +0200 Subject: [PATCH 08/13] comment --- .../tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index 5eb8dcbb74b..a9b873553fb 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -62,7 +62,8 @@ end # is difficult. # Since the initial condition is queried in `boundary_condition_subsonic` above # these difficulties propagate to the boundary conditions. -# The setup below is a workaround and works for this specific example, but +# +# The setup below is a working configuration for this specific example, but # generalization to other simulations cannot be expected. boundary_conditions = (x_neg = boundary_condition_subsonic, x_pos = boundary_condition_do_nothing, From 16c1995ca72359bd9283a0169f2e7b975c0df89d Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 10 Sep 2025 08:55:15 +0200 Subject: [PATCH 09/13] improve comment --- .../elixir_euler_riemannproblem_quadrants_amr.jl | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index a9b873553fb..ccad890382c 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -54,17 +54,11 @@ initial_condition = initial_condition_rp end # The flow is subsonic at all boundaries. -# Due to the LGL nodes including the boundary points of the reference element ± 1 -# setting discontinuous initial conditions with the desired behaviour -# { u_1, if x <= x_jump -# u(x, t) = { -# { u_2, if x > x_jump -# is difficult. -# Since the initial condition is queried in `boundary_condition_subsonic` above -# these difficulties propagate to the boundary conditions. -# -# The setup below is a working configuration for this specific example, but -# generalization to other simulations cannot be expected. +# For small enough simulation times, the solution remains at the initial condition +# *along the boundaries* of quadrants 2, 3, and 4. +# In quadrants 2 and 4 there are non-zero velocity components (v1 in quadrant 2, v2 in quadrant 4) +# normal to the boundary, which is troublesome for the `boundary_condition_do_nothing`. +# Thus, the `boundary_condition_subsonic` are used instead. boundary_conditions = (x_neg = boundary_condition_subsonic, x_pos = boundary_condition_do_nothing, y_neg = boundary_condition_subsonic, From ad76b02eac825ae8b70e85933e7a85586c37b3d7 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Wed, 10 Sep 2025 08:57:54 +0200 Subject: [PATCH 10/13] Update examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl Co-authored-by: Arpit Babbar --- .../tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index ccad890382c..f94d8d41826 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -105,7 +105,7 @@ solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, # { u_1, if x <= x_jump # u(x, t) = { # { u_2, if x > x_jump -function Trixi.compute_coefficients!(u, func, t, +function Trixi.compute_coefficients!(u, func::typeof(initial_condition_rp), t, mesh::TreeMesh{2}, equations, dg::DG, cache) Trixi.@threaded for element in eachelement(dg, cache) for j in eachnode(dg), i in eachnode(dg) From 3b30c4ab0f3fb54b526b3ccaebcf1d533af2eb05 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 10 Sep 2025 08:58:06 +0200 Subject: [PATCH 11/13] cfl --- .../tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index ccad890382c..6ed75b67f2f 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -144,7 +144,7 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval) alive_callback = AliveCallback(analysis_interval = analysis_interval) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl = 1.8) amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, From 5138a3a3e897d515ad1379b41e8c824c45c1b8a1 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 10 Sep 2025 09:04:06 +0200 Subject: [PATCH 12/13] cfl increase --- .../elixir_euler_riemannproblem_quadrants_amr.jl | 2 +- test/test_tree_2d_euler.jl | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index aa7f43e4094..9ebe54ab8f0 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -144,7 +144,7 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval) alive_callback = AliveCallback(analysis_interval = analysis_interval) -stepsize_callback = StepsizeCallback(cfl = 1.8) +stepsize_callback = StepsizeCallback(cfl = 2.4) amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 41275a39034..f4b45b481e4 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -1110,16 +1110,16 @@ end "elixir_euler_riemannproblem_quadrants_amr.jl"), tspan=(0.0, 0.05), l2=[ - 0.1366907511304207, - 0.1411685226288184, - 0.14116852262881724, - 0.5172189926332071 + 0.1368072821004113, + 0.14118941733547452, + 0.14118941733547452, + 0.517531607013678 ], linf=[ - 1.2134748489242826, - 1.6127768559232698, - 1.6127768559232791, - 6.155567493629927 + 1.2131375710616266, + 1.5874929468585157, + 1.587492946858516, + 6.190605827791707 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) From 38b319b95a077c709e974fcc9111acfecea0cc9d Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 10 Sep 2025 11:00:04 +0200 Subject: [PATCH 13/13] correct signature --- .../elixir_euler_riemannproblem_quadrants_amr.jl | 11 ++++++----- test/test_tree_2d_euler.jl | 16 ++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl index 9ebe54ab8f0..9f56b135ab2 100644 --- a/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.jl @@ -105,7 +105,8 @@ solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, # { u_1, if x <= x_jump # u(x, t) = { # { u_2, if x > x_jump -function Trixi.compute_coefficients!(u, func::typeof(initial_condition_rp), t, +function Trixi.compute_coefficients!(backend::Nothing, u, + func::typeof(initial_condition_rp), t, mesh::TreeMesh{2}, equations, dg::DG, cache) Trixi.@threaded for element in eachelement(dg, cache) for j in eachnode(dg), i in eachnode(dg) @@ -123,7 +124,7 @@ function Trixi.compute_coefficients!(u, func::typeof(initial_condition_rp), t, end u_node = func(x_node, t, equations) - set_node_vars!(u, u_node, equations, dg, i, j, element) + Trixi.set_node_vars!(u, u_node, equations, dg, i, j, element) end end end @@ -149,10 +150,10 @@ stepsize_callback = StepsizeCallback(cfl = 2.4) amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, base_level = 3, - med_level = 5, med_threshold = 0.02, - max_level = 8, max_threshold = 0.04) + med_level = 5, med_threshold = 0.01, + max_level = 8, max_threshold = 0.02) amr_callback = AMRCallback(semi, amr_controller, - interval = 10, + interval = 5, adapt_initial_condition = true) callbacks = CallbackSet(summary_callback, diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index f4b45b481e4..bd23da5e75f 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -1110,16 +1110,16 @@ end "elixir_euler_riemannproblem_quadrants_amr.jl"), tspan=(0.0, 0.05), l2=[ - 0.1368072821004113, - 0.14118941733547452, - 0.14118941733547452, - 0.517531607013678 + 0.12802172216950314, + 0.1333199240875145, + 0.13331992408751456, + 0.48888051192644405 ], linf=[ - 1.2131375710616266, - 1.5874929468585157, - 1.587492946858516, - 6.190605827791707 + 0.853710403180942, + 0.9151148367639803, + 0.9151148367639808, + 3.4300525777582864 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities)