-
Notifications
You must be signed in to change notification settings - Fork 158
Convergence Test MHD 3D (Non-Alfwen Wave) #2875
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
ranocha
merged 7 commits into
trixi-framework:main
from
DanielDoehring:Convergence_MHD_3D
Mar 23, 2026
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7107447
start
DanielDoehring f6b39e7
fmt
DanielDoehring 85b9727
Update examples/tree_3d_dgsem/elixir_mhd_convergence.jl
DanielDoehring d241e57
Apply suggestions from code review
DanielDoehring 3cc4dc5
Update examples/tree_3d_dgsem/elixir_mhd_convergence.jl
DanielDoehring 757a77f
Update examples/tree_3d_dgsem/elixir_mhd_convergence.jl
DanielDoehring 7fe0286
Merge branch 'main' into Convergence_MHD_3D
ranocha 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
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,118 @@ | ||
| using Trixi | ||
| using OrdinaryDiffEqLowStorageRK | ||
|
|
||
| ############################################################################### | ||
| # semidiscretization of the compressible ideal GLM-MHD equations | ||
|
|
||
| gamma() = 2.0 | ||
| equations = IdealGlmMhdEquations3D(gamma()) | ||
|
|
||
| """ | ||
| initial_condition_convergence(x, t, equations::IdealGlmMhdEquations3D) | ||
|
|
||
| Manufactured solution for the 3D(only!) compressible ideal GLM-MHD equations. | ||
| Proposed in | ||
| - Marvin Bohm, Andrew R Winters, Gregor J Gassner, Dominik Derigs, Florian Hindenlang, Joachim Saur (2020): | ||
| An entropy stable nodal discontinuous Galerkin method for the resistive MHD equations. | ||
| Part I: Theory and numerical verification | ||
| [10.1016/j.jcp.2018.06.027](https://doi.org/10.1016/j.jcp.2018.06.027) | ||
| """ | ||
| @inline function initial_condition_convergence(x, t, equations::IdealGlmMhdEquations3D) | ||
| h = 0.5f0 * sinpi(2 * (x[1] + x[2] + x[3] - t)) + 2 | ||
|
|
||
| u_1 = h | ||
| u_2 = h | ||
| u_3 = h | ||
| u_4 = 0 | ||
| u_5 = 2 * h^2 + h | ||
|
|
||
| u_6 = h | ||
| u_7 = -h | ||
| u_8 = 0 | ||
| u_9 = 0 | ||
|
|
||
| return SVector(u_1, u_2, u_3, u_4, u_5, u_6, u_7, u_8, u_9) | ||
| end | ||
|
|
||
| """ | ||
| source_terms_convergence(x, t, equations::IdealGlmMhdEquations3D) | ||
|
|
||
| Manufactured solution for the 3D(only!) compressible ideal GLM-MHD equations. | ||
| Proposed in | ||
| - Marvin Bohm, Andrew R Winters, Gregor J Gassner, Dominik Derigs, Florian Hindenlang, Joachim Saur (2020): | ||
| An entropy stable nodal discontinuous Galerkin method for the resistive MHD equations. | ||
| Part I: Theory and numerical verification | ||
| [10.1016/j.jcp.2018.06.027](https://doi.org/10.1016/j.jcp.2018.06.027) | ||
|
|
||
| For the version without parabolic terms see the implementation in FLUXO: | ||
| https://github.com/project-fluxo/fluxo/blob/c7e0cc9b7fd4569dcab67bbb6e5a25c0a84859f1/src/equation/mhd/equation.f90#L1539-L1554 | ||
| """ | ||
| function source_terms_convergence(u, x, t, equations::IdealGlmMhdEquations3D) | ||
| h = 0.5f0 * sinpi(2 * (x[1] + x[2] + x[3] - t)) + 2 | ||
| h_x = pi * cospi(2 * (x[1] + x[2] + x[3] - t)) | ||
|
|
||
| s_1 = h_x | ||
| s_2 = h_x + 4 * h * h_x | ||
| s_3 = h_x + 4 * h * h_x | ||
| s_4 = 4 * h * h_x | ||
| s_5 = h_x + 12 * h * h_x | ||
| s_6 = h_x | ||
| s_7 = -h_x | ||
| s_8 = 0 | ||
| s_9 = 0 | ||
|
|
||
| return SVector(s_1, s_2, s_3, s_4, s_5, s_6, s_7, s_8, s_9) | ||
| end | ||
|
|
||
| surface_flux = (flux_hll, flux_nonconservative_powell) | ||
| volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) | ||
|
|
||
| polydeg = 3 | ||
| basis = LobattoLegendreBasis(polydeg) | ||
|
|
||
| volume_integral = VolumeIntegralFluxDifferencing(volume_flux) | ||
| solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
|
||
| coordinates_min = (0.0, 0.0, 0.0) | ||
| coordinates_max = (1.0, 1.0, 1.0) | ||
|
|
||
| mesh = TreeMesh(coordinates_min, coordinates_max, | ||
| initial_refinement_level = 2, | ||
| periodicity = true, | ||
| n_cells_max = 100_000) | ||
|
|
||
| semi = SemidiscretizationHyperbolic(mesh, equations, | ||
| initial_condition_convergence, solver; | ||
| source_terms = source_terms_convergence, | ||
| boundary_conditions = boundary_condition_periodic) | ||
|
|
||
| ############################################################################### | ||
| # ODE solvers, callbacks etc. | ||
|
|
||
| tspan = (0.0, 1.0) | ||
| ode = semidiscretize(semi, tspan) | ||
|
|
||
| summary_callback = SummaryCallback() | ||
|
|
||
| analysis_interval = 50 | ||
| analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
|
||
| alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
|
||
| cfl = 1.8 | ||
| stepsize_callback = StepsizeCallback(cfl = cfl) | ||
|
|
||
| glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) | ||
|
|
||
| callbacks = CallbackSet(summary_callback, | ||
| analysis_callback, | ||
| alive_callback, | ||
| stepsize_callback, | ||
| glm_speed_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 | ||
| ode_default_options()..., 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
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.