Skip to content
Draft
Show file tree
Hide file tree
Changes from 121 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
bc821d7
Add idp mortar and calculation of surface integral for mortar
bennibolm Mar 7, 2025
62eb28f
Allow SimpleEuler
bennibolm Mar 7, 2025
ed465d2
Add test
bennibolm Mar 7, 2025
97b87d7
fmt
bennibolm Mar 7, 2025
9d40cc9
Merge branch 'main' into bb/idp-amr
bennibolm Mar 10, 2025
07d978a
Fix documentation
bennibolm Mar 10, 2025
53a7eab
Reformulate flux calculation
bennibolm Mar 21, 2025
ffe01ac
Use local lambdas
bennibolm Mar 21, 2025
2e0ac84
Use surface_flux
bennibolm Mar 23, 2025
38e6696
Revise implementation
bennibolm Apr 30, 2025
858507c
Merge branch 'main' into bb/idp-amr
bennibolm Apr 30, 2025
f2f5e9f
Adapt tests
bennibolm Apr 30, 2025
df08dce
Speed up by not calculating same flux twice
bennibolm Apr 30, 2025
8bf59ab
Fix test
bennibolm Apr 30, 2025
da8c3f8
Add support of blending mortar fluxes
bennibolm May 6, 2025
c0cd953
Small change
bennibolm May 9, 2025
20bea41
Small fix
bennibolm May 9, 2025
b022085
Move blending to correction stage
bennibolm May 16, 2025
e3bd327
Change orientation of limiting_factor
bennibolm May 16, 2025
b792acf
Clearify variable names
bennibolm May 20, 2025
c710d1d
Add computation of limiting factor
bennibolm May 20, 2025
777ce39
Use `get_node_vars` and `multiply_add_to_node_vars!`
bennibolm May 20, 2025
96b10d5
Disabled limiting to ensure tests are passing
bennibolm May 21, 2025
28ee0b4
Merge branch 'main' into bb/idp-amr
bennibolm May 26, 2025
d28919a
fmt
bennibolm May 26, 2025
4318c6c
Add el diablo elixir
bennibolm May 27, 2025
ceb47e3
Activate limiting
bennibolm May 27, 2025
8b9f223
Add advection elixir
bennibolm May 27, 2025
5d2152b
Adapt tests; add option to use pure low order mortars
bennibolm May 27, 2025
9475d8c
Merge branch 'main' into bb/idp-amr
bennibolm May 28, 2025
6dce7ed
Add limiting factor to solution callback
bennibolm May 28, 2025
1750fc4
Small changes
bennibolm May 28, 2025
e4527e8
Merge branch 'main' into bb/idp-amr
bennibolm Jun 2, 2025
8093689
Small fix
bennibolm Jun 5, 2025
ec6d685
Export MortarIDP
bennibolm Jun 16, 2025
31f7c41
Merge branch 'main' into bb/idp-amr
bennibolm Jun 20, 2025
6c90a4f
Implement unstable check and provisional alpha analysis
bennibolm Jun 20, 2025
b76aa13
typo
bennibolm Jun 20, 2025
ac02ccf
fmt
bennibolm Jun 20, 2025
033940d
Use real sedov blast elixir
bennibolm Jun 26, 2025
36ae714
Add blast wave elixir for testing
bennibolm Jun 26, 2025
0afdd84
Use low-order flux of high-order contains NaNs
bennibolm Jun 27, 2025
8b3a9cb
Add LimiterZhangShuLocalBounds for positivity
bennibolm Jun 27, 2025
ae4c8a3
Merge branch 'main' into bb/idp-amr
bennibolm Jul 28, 2025
cd2c51f
Fix llf use
bennibolm Jul 28, 2025
0d6a30e
Use default llf in new elixirs
bennibolm Jul 28, 2025
70e8f4a
Fix test
bennibolm Jul 28, 2025
2ef741f
Add flexibel output directory for mortar limiting factor
bennibolm Jul 31, 2025
e51da59
Move calc of limiting factor to function
bennibolm Jul 31, 2025
77da564
Fix last commit
bennibolm Aug 1, 2025
3370210
Merge branch 'main' into bb/idp-amr
bennibolm Aug 4, 2025
a8f5c8b
Make `newton_loops!` dimendion independent
bennibolm Aug 7, 2025
7b429a2
Add mortar limiting for pressure (nonlinear variables)
bennibolm Aug 7, 2025
87d6f50
Rename `first_order` to `piecewise_constant` etc
bennibolm Aug 8, 2025
c0176a5
Generalize (mortar-)limited variables
bennibolm Aug 8, 2025
4ea76d0
Fix advection test case and blast wave test results
bennibolm Aug 8, 2025
0651513
Fix test results
bennibolm Aug 8, 2025
1859bca
Include all values in computation of alpha
bennibolm Aug 8, 2025
7441481
Fix typos
bennibolm Aug 8, 2025
011fdb5
Adapt tests accordingly
bennibolm Aug 8, 2025
00bfccc
Merge branch 'main' into bb/idp-amr
bennibolm Aug 19, 2025
9130d77
Add KHI elixir
bennibolm Aug 19, 2025
e992a62
Adapt default setting of limiting
bennibolm Aug 19, 2025
9a249e2
Clean up; Remove ZhangShu with variable bounds
bennibolm Aug 22, 2025
43f7042
Decrease CFL number
bennibolm Aug 25, 2025
48dbebe
Fix test
bennibolm Aug 26, 2025
427e677
Add KHI test
bennibolm Aug 26, 2025
e2cfe5b
Include all values if `!local_factor`
bennibolm Aug 26, 2025
16a7d47
Fix last commit
bennibolm Aug 26, 2025
235af37
Fix bug
bennibolm Aug 26, 2025
7c76cae
Thread parallel computation of low order mortar flux
bennibolm Aug 26, 2025
31d162f
Remove doubled code
bennibolm Aug 26, 2025
2986083
Move high order surface_flux_values to container antidiffusive fluxes
bennibolm Aug 27, 2025
60e6567
Move code and rename functions
bennibolm Aug 27, 2025
454d19d
fmt
bennibolm Aug 27, 2025
c19b913
Add conservation tests
bennibolm Aug 27, 2025
f1bedb3
Merge branch 'main' into bb/idp-amr
bennibolm Aug 28, 2025
f99c435
Initial merge (clean version)
bennibolm Sep 1, 2025
8fdeb1b
Extend test
bennibolm Sep 2, 2025
0f1d3e0
Merge branch 'main' into idp-mortars-clean
bennibolm Sep 2, 2025
c0ab7e9
Change order in file; Add printing formats of mortar
bennibolm Sep 2, 2025
f1e015c
Fix test
bennibolm Sep 2, 2025
c806d5b
Merge branch 'main' into bb/idp-amr
bennibolm Sep 8, 2025
b5307d2
Small changes
bennibolm Sep 8, 2025
dd46ad3
Refactor mortar weights
bennibolm Sep 11, 2025
b496d02
Fix last commit
bennibolm Sep 11, 2025
903549a
Fix changes
bennibolm Sep 11, 2025
3f83aa9
Merge changes from clean branch
bennibolm Sep 11, 2025
088828c
Merge branch 'main' into idp-mortars-clean
bennibolm Sep 11, 2025
6a2b5d1
Merge branch 'main' into bb/idp-amr
bennibolm Sep 11, 2025
2b29d8f
Merge branch 'bb/idp-amr' into idp-mortars-clean
bennibolm Sep 11, 2025
8bb1c1e
Clarify comment
bennibolm Sep 11, 2025
cad1cf0
Merge branch 'main' into idp-mortars-clean
bennibolm Sep 22, 2025
5787151
Fix name of variable
bennibolm Sep 22, 2025
3da59e7
Merge branch 'main' into idp-mortars-clean
bennibolm Sep 24, 2025
9c354e7
Merge branch 'main' into idp-mortars-clean
bennibolm Sep 30, 2025
ec510cf
Merge branch 'main' into idp-mortars-clean
bennibolm Oct 8, 2025
5897092
Rename inner indices; `continue` to `break`
bennibolm Oct 9, 2025
068df38
Merge branch 'main' into idp-mortars-clean
bennibolm Oct 9, 2025
f7de47d
Add explanation to computation of local weights
bennibolm Oct 13, 2025
40b3955
typo
bennibolm Oct 13, 2025
6392064
Restructure code
bennibolm Oct 14, 2025
627bb4e
Refactor `mortar_weights`
bennibolm Oct 14, 2025
ebdfd07
Refactor `calc_bounds_twosided`
bennibolm Oct 14, 2025
2fb7bb8
Refactor `calc_mortar_flux_low_order!`
bennibolm Oct 14, 2025
ea1e116
Add equations to mortar
bennibolm Oct 15, 2025
251c177
Add comment about type instability
bennibolm Oct 15, 2025
31bad1d
Simplify computation of minimal value at mortar
bennibolm Oct 15, 2025
4822608
Refactor computation of limiting factor
bennibolm Oct 15, 2025
96920b0
Shorten code
bennibolm Oct 16, 2025
50cba3c
Update comments
bennibolm Oct 16, 2025
39e1c77
Merge branch 'main' into idp-mortars-clean
bennibolm Oct 16, 2025
b4faba2
Fix bug
bennibolm Oct 16, 2025
c32f71c
Fix error
bennibolm Oct 17, 2025
4d45dfe
Add density wave example
bennibolm Oct 17, 2025
dd25b6a
Increase allowed allocations
bennibolm Oct 18, 2025
c0a68c4
Remove KHI amr elixir
bennibolm Oct 20, 2025
5673973
Add AMR to existing KHI elixir; Apply local limiting in test
bennibolm Oct 20, 2025
01aed6b
Adapt numbers in test
bennibolm Oct 20, 2025
cf66623
Add test for output
bennibolm Oct 20, 2025
49adf96
Merge branch 'main' into idp-mortars-clean
bennibolm Oct 27, 2025
2e106fe
Implement suggestions
bennibolm Oct 28, 2025
c73b2b4
Fix bug
bennibolm Oct 28, 2025
b05e909
Simplify sum over weights
bennibolm Oct 28, 2025
329480a
Merge branch 'main' into idp-mortars-clean
bennibolm Oct 28, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Trixi

###############################################################################
# semidiscretization of the compressible Euler equations

equations = CompressibleEulerEquations2D(1.4)

initial_condition = initial_condition_density_wave

surface_flux = flux_lax_friedrichs
volume_flux = flux_ranocha
polydeg = 5
basis = LobattoLegendreBasis(polydeg)

# No limiting is needed in the volume integral
# It is still required to use `VolumeIntegralSubcellLimiting` in order to use `MortarIDP`.
limiter_idp = SubcellLimiterIDP(equations, basis;
positivity_variables_cons = [],
positivity_variables_nonlinear = [])
volume_integral = VolumeIntegralSubcellLimiting(limiter_idp;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)
mortar = MortarIDP(equations, basis;
positivity_variables_cons = ["rho"])
solver = DGSEM(basis, surface_flux, volume_integral, mortar)

coordinates_min = (-1.0, -1.0)
coordinates_max = (1.0, 1.0)
refinement_patches = ((type = "box", coordinates_min = (-0.5, -0.5),
coordinates_max = (0.0, 1.0)),
(type = "box", coordinates_min = (0.5, -1.0),
coordinates_max = (1.0, 0.5)))
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 3,
refinement_patches = refinement_patches,
n_cells_max = 10_000,
periodicity = true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 1000
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
extra_analysis_errors = (:conservation_error,))

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 1000,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim,
extra_node_variables = (:limiting_coefficient,))

stepsize_callback = StepsizeCallback(cfl = 0.4)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
stepsize_callback)

###############################################################################
# run the simulation

stage_callbacks = (SubcellLimiterIDPCorrection(),)

sol = Trixi.solve(ode,
Trixi.SimpleSSPRK33(stage_callbacks = stage_callbacks);
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
callback = callbacks);
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,20 @@ function initial_condition_kelvin_helmholtz_instability(x, t,
end
initial_condition = initial_condition_kelvin_helmholtz_instability

# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# `StepsizeCallback` (CFL-Condition) and less diffusion.
surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)
surface_flux = flux_lax_friedrichs
volume_flux = flux_ranocha
polydeg = 3
basis = LobattoLegendreBasis(polydeg)

limiter_idp = SubcellLimiterIDP(equations, basis;
positivity_variables_cons = ["rho"],
positivity_variables_nonlinear = [pressure])
positivity_variables_nonlinear = [pressure],
local_twosided_variables_cons = []) # required for testing
volume_integral = VolumeIntegralSubcellLimiting(limiter_idp;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)
solver = DGSEM(basis, surface_flux, volume_integral)
mortar = MortarIDP(equations, basis; positivity_variables_cons = ["rho"])
solver = DGSEM(basis, surface_flux, volume_integral, mortar)

coordinates_min = (-1.0, -1.0)
coordinates_max = (1.0, 1.0)
Expand Down Expand Up @@ -79,12 +74,27 @@ save_solution = SaveSolutionCallback(interval = 100,
save_restart = SaveRestartCallback(interval = 1000,
save_final_restart = true)

amr_indicator = IndicatorHennemannGassner(semi,
alpha_max = 1.0,
alpha_min = 0.0001,
alpha_smooth = false,
variable = Trixi.density)
amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level = 4,
med_level = 0, med_threshold = 0.0003,
max_level = 6, max_threshold = 0.003)
amr_callback = AMRCallback(semi, amr_controller,
interval = 1,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)

stepsize_callback = StepsizeCallback(cfl = 0.7)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
stepsize_callback,
save_restart, save_solution)
amr_callback,
save_restart, save_solution,
stepsize_callback)

###############################################################################
# run the simulation
Expand All @@ -95,5 +105,4 @@ stage_callbacks = (SubcellLimiterIDPCorrection(),

sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks = stage_callbacks);
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
ode_default_options()...,
callback = callbacks);
2 changes: 1 addition & 1 deletion src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export DG,
VolumeIntegralUpwind,
SurfaceIntegralWeakForm, SurfaceIntegralStrongForm,
SurfaceIntegralUpwind,
MortarL2
MortarL2, MortarIDP

export reconstruction_O2_inner, reconstruction_O2_full,
reconstruction_constant,
Expand Down
13 changes: 13 additions & 0 deletions src/callbacks_stage/subcell_limiter_idp_correction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ function (limiter!::SubcellLimiterIDPCorrection)(u_ode, semi, t, dt,

perform_idp_correction!(u, dt, mesh, equations, solver, cache)

if solver.mortar isa Trixi.LobattoLegendreMortarIDP
@trixi_timeit timer() "mortar blending factors" calc_mortar_limiting_factor!(u,
semi,
t,
dt)

@trixi_timeit timer() "mortar correction" perform_idp_mortar_correction(u, dt,
mesh,
equations,
solver,
cache)
end

return nothing
end

Expand Down
108 changes: 108 additions & 0 deletions src/callbacks_stage/subcell_limiter_idp_correction_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,112 @@ function perform_idp_correction!(u, dt,

return nothing
end

function perform_idp_mortar_correction(u, dt, mesh::TreeMesh{2}, equations, dg, cache)
(; orientations, limiting_factor) = cache.mortars

(; surface_flux_values) = cache.elements
(; surface_flux_values_high_order) = cache.antidiffusive_fluxes
(; boundary_interpolation) = dg.basis

for mortar in eachmortar(dg, cache)
if isapprox(limiting_factor[mortar], one(eltype(limiting_factor)))
continue
end

if cache.mortars.large_sides[mortar] == 1 # -> small elements on right side
if orientations[mortar] == 1
direction_small = 1
direction_large = 2
else
direction_small = 3
direction_large = 4
end
# In `apply_jacobian`, `du` is multiplied with inverse jacobian and a negative sign.
# This sign switch is directly applied to the boundary interpolation factors here.
factor_small = boundary_interpolation[1, 1]
factor_large = -boundary_interpolation[nnodes(dg), 2]
else # large_sides[mortar] == 2 -> small elements on left side
if orientations[mortar] == 1
direction_small = 2
direction_large = 1
else
direction_small = 4
direction_large = 3
end
# In `apply_jacobian`, `du` is multiplied with inverse jacobian and a negative sign.
# This sign switch is directly applied to the boundary interpolation factors here.
factor_large = boundary_interpolation[1, 1]
factor_small = -boundary_interpolation[nnodes(dg), 2]
end

for i in eachnode(dg)
if cache.mortars.large_sides[mortar] == 1 # -> small elements on right side
if orientations[mortar] == 1
# L2 mortars in x-direction
indices_small = (1, i)
indices_large = (nnodes(dg), i)
else
# L2 mortars in y-direction
indices_small = (i, 1)
indices_large = (i, nnodes(dg))
end
else # large_sides[mortar] == 2 -> small elements on left side
if orientations[mortar] == 1
# L2 mortars in x-direction
indices_small = (nnodes(dg), i)
indices_large = (1, i)
else
# L2 mortars in y-direction
indices_small = (i, nnodes(dg))
indices_large = (i, 1)
end
end

# small elements
for small_element_index in 1:2
small_element = cache.mortars.neighbor_ids[small_element_index, mortar]
inverse_jacobian_small = get_inverse_jacobian(cache.elements.inverse_jacobian,
mesh, indices_small...,
small_element)

flux_small_high_order = get_node_vars(surface_flux_values_high_order,
equations, dg,
i, direction_small, small_element)
flux_small_low_order = get_node_vars(surface_flux_values, equations, dg,
i, direction_small, small_element)
flux_difference_small = factor_small *
(flux_small_high_order .- flux_small_low_order)

multiply_add_to_node_vars!(u,
dt * inverse_jacobian_small *
(1 - limiting_factor[mortar]),
flux_difference_small, equations, dg,
indices_small..., small_element)
end

# large element
large_element = cache.mortars.neighbor_ids[3, mortar]
inverse_jacobian_large = get_inverse_jacobian(cache.elements.inverse_jacobian,
mesh, indices_large...,
large_element)

flux_large_high_order = get_node_vars(surface_flux_values_high_order,
equations, dg, i, direction_large,
large_element)
flux_large_low_order = get_node_vars(surface_flux_values, equations, dg, i,
direction_large, large_element)
flux_difference_large = factor_large *
(flux_large_high_order .- flux_large_low_order)

multiply_add_to_node_vars!(u,
dt * inverse_jacobian_large *
(1 - limiting_factor[mortar]),
flux_difference_large, equations, dg,
indices_large..., large_element)
end
end

return nothing
end
end # @muladd
Loading
Loading