-
Notifications
You must be signed in to change notification settings - Fork 159
Add 3d subcell limiting example with nonconservative terms #2688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bennibolm
merged 9 commits into
trixi-framework:main
from
bennibolm:3d-subcell-nonconservative-terms
Jan 7, 2026
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8c63d6e
Add example with nonconservative terms of type `NonConservativeSymmet…
bennibolm 5b5ddca
Decrease outer pressure to actually use positivity limiting for pressure
bennibolm 111d6ed
Merge branch 'main' into 3d-subcell-nonconservative-terms
bennibolm 8b23d1a
Apply suggestions from code review
bennibolm 74e301f
Merge branch 'main' into 3d-subcell-nonconservative-terms
bennibolm eecc61b
Remove `fhat` resets in new function
bennibolm 4f36ae5
Merge branch 'main' into 3d-subcell-nonconservative-terms
DanielDoehring 891e22b
Apply suggestions from code review
bennibolm 08e2ef5
Merge branch 'main' into 3d-subcell-nonconservative-terms
bennibolm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_subcell.jl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| using Trixi | ||
|
|
||
| ############################################################################### | ||
| # semidiscretization of the compressible ideal GLM-MHD equations | ||
|
|
||
| equations = IdealGlmMhdEquations3D(1.4) | ||
|
|
||
| """ | ||
| initial_condition_blast_wave(x, t, equations::IdealGlmMhdEquations3D) | ||
|
|
||
| Weak magnetic blast wave setup taken from Section 6.1 of the paper: | ||
| - A. M. Rueda-Ramírez, S. Hennemann, F. J. Hindenlang, A. R. Winters, G. J. Gassner (2021) | ||
| An entropy stable nodal discontinuous Galerkin method for the resistive MHD | ||
| equations. Part II: Subcell finite volume shock capturing | ||
| [doi: 10.1016/j.jcp.2021.110580](https://doi.org/10.1016/j.jcp.2021.110580) | ||
| """ | ||
| function initial_condition_blast_wave(x, t, equations::IdealGlmMhdEquations3D) | ||
| # Center of the blast wave is selected for the domain [0, 3]^3 | ||
| inicenter = (1.5, 1.5, 1.5) | ||
| x_norm = x[1] - inicenter[1] | ||
| y_norm = x[2] - inicenter[2] | ||
| z_norm = x[3] - inicenter[3] | ||
| r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) | ||
|
|
||
| delta_0 = 0.1 | ||
| r_0 = 0.3 | ||
| lambda = exp(5.0 / delta_0 * (r - r_0)) | ||
|
|
||
| p_inner = 0.9 | ||
| p_outer = 5e-2 | ||
| prim_inner = SVector(1.2, 0.1, 0.0, 0.1, p_inner, 1.0, 1.0, 1.0, 0.0) | ||
| prim_outer = SVector(1.2, 0.2, -0.4, 0.2, p_outer, 1.0, 1.0, 1.0, 0.0) | ||
| prim_vars = (prim_inner + lambda * prim_outer) / (1.0 + lambda) | ||
|
|
||
| return prim2cons(prim_vars, equations) | ||
| end | ||
| initial_condition = initial_condition_blast_wave | ||
|
|
||
| surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell_local_symmetric) | ||
| volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell_local_symmetric) | ||
| polydeg = 3 | ||
| basis = LobattoLegendreBasis(polydeg) | ||
| limiter_idp = SubcellLimiterIDP(equations, basis; | ||
| positivity_variables_cons = ["rho"], | ||
| positivity_variables_nonlinear = [pressure]) | ||
| volume_integral = VolumeIntegralSubcellLimiting(limiter_idp; | ||
| volume_flux_dg = volume_flux, | ||
| volume_flux_fv = surface_flux) | ||
| solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
|
||
| # Mapping as described in https://arxiv.org/abs/2012.12040 but with slightly less warping. | ||
| # The mapping will be interpolated at tree level, and then refined without changing | ||
| # the geometry interpolant. | ||
| function mapping(xi_, eta_, zeta_) | ||
| # Transform input variables between -1 and 1 onto [0,3] | ||
| xi = 1.5 * xi_ + 1.5 | ||
| eta = 1.5 * eta_ + 1.5 | ||
| zeta = 1.5 * zeta_ + 1.5 | ||
|
|
||
| y = eta + | ||
| 3 / 11 * (cos(1.5 * pi * (2 * xi - 3) / 3) * | ||
| cos(0.5 * pi * (2 * eta - 3) / 3) * | ||
| cos(0.5 * pi * (2 * zeta - 3) / 3)) | ||
|
|
||
| x = xi + | ||
| 3 / 11 * (cos(0.5 * pi * (2 * xi - 3) / 3) * | ||
| cos(2 * pi * (2 * y - 3) / 3) * | ||
| cos(0.5 * pi * (2 * zeta - 3) / 3)) | ||
|
|
||
| z = zeta + | ||
| 3 / 11 * (cos(0.5 * pi * (2 * x - 3) / 3) * | ||
| cos(pi * (2 * y - 3) / 3) * | ||
| cos(0.5 * pi * (2 * zeta - 3) / 3)) | ||
|
|
||
| return SVector(x, y, z) | ||
| end | ||
|
|
||
| trees_per_dimension = (2, 2, 2) | ||
| mesh = P4estMesh(trees_per_dimension, | ||
| polydeg = 3, | ||
| mapping = mapping, | ||
| initial_refinement_level = 2, | ||
| periodicity = true) | ||
|
|
||
| semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
|
||
| ############################################################################### | ||
| # ODE solvers, callbacks etc. | ||
|
|
||
| tspan = (0.0, 0.5) | ||
| ode = semidiscretize(semi, tspan) | ||
|
|
||
| summary_callback = SummaryCallback() | ||
|
|
||
| analysis_interval = 100 | ||
| analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
|
||
| alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
|
||
| save_solution = SaveSolutionCallback(interval = 100, | ||
| save_initial_solution = true, | ||
| save_final_solution = true, | ||
| solution_variables = cons2prim, | ||
| extra_node_variables = (:limiting_coefficient,)) | ||
|
|
||
| cfl = 0.9 | ||
| stepsize_callback = StepsizeCallback(cfl = cfl) | ||
|
|
||
| glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) | ||
|
|
||
| callbacks = CallbackSet(summary_callback, | ||
| analysis_callback, | ||
| alive_callback, | ||
| save_solution, | ||
| stepsize_callback, | ||
| glm_speed_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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.