-
Couldn't load subscription status.
- Fork 132
Schulz-Rinne (2D) Riemann Problem #2561
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
DanielDoehring
merged 15 commits into
trixi-framework:main
from
DanielDoehring:2D_RiemannProb_SchulzRinne
Sep 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f17f7a8
Schulz-Rinne (2D) Riemann Problem
DanielDoehring d5dd50f
work
DanielDoehring 6d303cf
p
DanielDoehring d440020
comment
DanielDoehring 55ffe26
clean up
DanielDoehring 1a3c674
clean up
DanielDoehring 1d90003
hllc comment
DanielDoehring de4e366
comment
DanielDoehring 16c1995
improve comment
DanielDoehring ad76b02
Update examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_a…
DanielDoehring 3b30c4a
cfl
DanielDoehring dd55b52
Merge branch '2D_RiemannProb_SchulzRinne' of github.com:DanielDoehrin…
DanielDoehring 5138a3a
cfl increase
DanielDoehring 38b319b
correct signature
DanielDoehring fa02b33
Merge branch 'main' into 2D_RiemannProb_SchulzRinne
DanielDoehring 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
159 changes: 159 additions & 0 deletions
159
examples/tree_2d_dgsem/elixir_euler_riemannproblem_quadrants_amr.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,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, | ||
DanielDoehring marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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); | ||
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.