Skip to content
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

WIB: Subcell limiting with IDP and MCL approach #1502

Draft
wants to merge 558 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
558 commits
Select commit Hold shift + click to select a range
2827f71
Rename antidiffusive correction stage callback
bennibolm Jul 6, 2023
aa0204c
Rename file of antidiffusive correction stage callback
bennibolm Jul 6, 2023
787ecc7
Relocate subcell limiting code
bennibolm Jul 7, 2023
98d8d67
Move create_cache routine to specific file
bennibolm Jul 10, 2023
c32d490
Fix format
bennibolm Jul 10, 2023
71964b2
Merge branch 'main' into subcell-limiting
bennibolm Jul 10, 2023
84b72e4
Implement suggestions
bennibolm Aug 9, 2023
d01353b
Remove outdated code
bennibolm Aug 9, 2023
43b5a3e
Merge branch 'main' into subcell-limiting
bennibolm Aug 9, 2023
d4eeea4
Merge branch 'main' into subcell-limiting
bennibolm Aug 10, 2023
438e5db
Merge branch 'main' into subcell-limiting
bennibolm Aug 21, 2023
c55c33d
Reduce time of tests
bennibolm Aug 21, 2023
010e188
Fix typo
bennibolm Aug 21, 2023
ef4c2f2
Fix tests
bennibolm Aug 21, 2023
1a2eb00
Add two-sided limiting for conservative variables
bennibolm Sep 26, 2023
ab9e5d9
Fix visualization routines
bennibolm Sep 26, 2023
534f148
Add bounds calculation for BoundaryConditionDirichlet
bennibolm Sep 26, 2023
9b0eee9
Reduce cfl in elixir
bennibolm Sep 26, 2023
3e6f7f8
Fix test
bennibolm Sep 26, 2023
6c095a8
Fix bounds check routine
bennibolm Sep 27, 2023
73da539
Merge branch 'main' into subcell-limiting
bennibolm Sep 28, 2023
3bf461f
Update tests after fixing conservation in main
bennibolm Sep 28, 2023
e161548
Fix copy error
bennibolm Sep 28, 2023
2e25185
Implement variable_bounds as Dict with Symbols
bennibolm Sep 28, 2023
6948a21
Merge pull request #114 from bennibolm/subcell-limiting-dictionary
bennibolm Oct 2, 2023
99c1782
Added first (ugly) implementation of subcell limiting for non-conserv…
amrueda Oct 5, 2023
67e379f
Modified non-conservative fluxes to revert src/solvers/dgsem_tree/dg_…
amrueda Oct 6, 2023
12c6c1d
Subcell limiting: Added the possibility to use multiple nonconservati…
amrueda Oct 10, 2023
7017914
Added some comments and improved formatting
amrueda Oct 10, 2023
5119d97
Added expected results for MHD subcell limiting test
amrueda Oct 10, 2023
ad6177e
Restored old Powell source term and created a new function name for t…
amrueda Oct 10, 2023
9158093
Fixed bug
amrueda Oct 10, 2023
3dcccc4
Fixed bug
amrueda Oct 10, 2023
adb930e
Moved new multiple-dispatch structs for to equations.jl
amrueda Oct 11, 2023
b0e3aad
Improved allocations
amrueda Oct 11, 2023
e0a3fdf
Avoid double computation of local part of non-conservative flux
amrueda Oct 11, 2023
86884e8
Improved subcell volume integral in y direction and formatting
amrueda Oct 11, 2023
0d61cfd
Apply suggestions from code review
amrueda Oct 12, 2023
b0caf8e
Added timers and corrected docstrings
amrueda Oct 12, 2023
6dae80a
Improved formatting
amrueda Oct 12, 2023
0c2e24e
Reduced testing time
amrueda Oct 12, 2023
ac792bb
Merge branch 'subcell_limiting_noncons' into subcell_positivity_nonco…
amrueda Oct 12, 2023
9c73f4c
Deactivate bar states for subcell positivity MHD test
amrueda Oct 12, 2023
4e6681c
The pressure positivity limiter works for MHD
amrueda Oct 12, 2023
a4a1fe8
Allow arbitrary nonlinear positivity limiting
bennibolm Oct 12, 2023
2eac4cf
Implement changes for limiting of entropys
bennibolm Oct 12, 2023
651b716
Relocate checks and goal functions
bennibolm Oct 12, 2023
d7dcb75
Merge branch 'main' into subcell-limiting-minmax
bennibolm Oct 12, 2023
70b4fd8
Rename functions
bennibolm Oct 12, 2023
82c9a2f
MCL works again FOR CONSERVATIVE SYSTEMS
amrueda Oct 12, 2023
14f0093
Merge branch 'main' into subcell-limiting
bennibolm Oct 12, 2023
2be3ba8
Merge branch 'subcell-limiting' into subcell-limiting-general-nonline…
bennibolm Oct 13, 2023
463de3a
Add @inline
bennibolm Oct 13, 2023
e4d3a9d
Add @inline to checks and goal functions; Update test required
bennibolm Oct 13, 2023
d04afad
Update tests
bennibolm Oct 13, 2023
de23b58
Add comment about subcell limiting with non-conforming meshes
bennibolm Oct 13, 2023
834b481
Merge branch 'subcell-limiting' into subcell_positivity_nonconservative
amrueda Oct 13, 2023
48bd943
Subcell limiting is working with StructuredMesh again
amrueda Oct 13, 2023
20abe7b
Renamed variables for consistency
amrueda Oct 16, 2023
96be070
Remove subcell visualization
bennibolm Oct 16, 2023
fb4d876
Fix last commit
bennibolm Oct 16, 2023
2d8b49d
Remove @unpack
bennibolm Oct 16, 2023
64cf39c
Add comment to `News.md`
bennibolm Oct 16, 2023
505cbbb
Merge branch 'main' into subcell_limiting_noncons
amrueda Oct 16, 2023
2d7ce45
Fix source for sedov blast setup; Formatting
bennibolm Oct 16, 2023
cf05403
Removed some unnecessary operations in the Powell/GLM non-conservativ…
amrueda Oct 16, 2023
c2ec8c1
Added two elixirs to compare performance
amrueda Oct 17, 2023
74cd7cc
Merge branch 'subcell_limiting_noncons' into subcell_positivity_nonco…
amrueda Oct 17, 2023
13280b7
Merge pull request #115 from bennibolm/subcell-limiting-general-nonli…
bennibolm Oct 17, 2023
2c17adb
Merge branch 'subcell-limiting' into subcell_positivity_nonconservative
amrueda Oct 17, 2023
6f9d3d1
Reduce allocations
bennibolm Oct 18, 2023
781e839
avoid repeated memory writing/reading
ranocha Oct 20, 2023
c3377ec
format
ranocha Oct 20, 2023
a1131d9
Merge branch 'main' into subcell_limiting_noncons
ranocha Oct 20, 2023
39b39b6
Replace construction of Symbols
bennibolm Oct 20, 2023
9b8398c
Merge branch 'main' into subcell-limiting-minmax
bennibolm Oct 20, 2023
a90745c
Apply suggestions from code review
amrueda Oct 20, 2023
aae5ad2
Merge branch 'main' into subcell-limiting
bennibolm Oct 20, 2023
a06333d
Fix 2 bugs + formatting
bennibolm Oct 20, 2023
c5145d6
Remove `interval` from parameters
bennibolm Oct 20, 2023
3848564
Fix bug
bennibolm Oct 20, 2023
603d0f0
Add revised BoundsCheck for IDP Limiting
bennibolm Oct 22, 2023
999b856
Fix bug
bennibolm Oct 22, 2023
535f520
Add bounds check for local limiting
bennibolm Oct 22, 2023
4729149
Merge branch 'main' into subcell_limiting_noncons
amrueda Oct 23, 2023
51887eb
Merge branch 'subcell-limiting' into subcell_positivity_nonconservative
amrueda Oct 23, 2023
38231a8
format
amrueda Oct 23, 2023
842399d
Replaced scalar-vector product with scalar-scalar product
amrueda Oct 23, 2023
4fa45bc
Removed timers that are not compatible with multi-threading
amrueda Oct 23, 2023
e40f0ea
Added bounds check for GLM-MHD subcell positivity example
amrueda Oct 23, 2023
9053e17
Removed unneeded elixirs
amrueda Oct 23, 2023
6605c41
format
amrueda Oct 23, 2023
2b21e6a
Cherry-picked changes done in PR (https://github.com/bennibolm/Trixi.…
amrueda Oct 20, 2023
baeaf02
Renamed function dpdu
amrueda Oct 23, 2023
10cb3b2
Merge branch 'main' into subcell_limiting_noncons
sloede Oct 23, 2023
342bf60
Unified pressure derivative functions for the 2D Euler equations
amrueda Oct 23, 2023
41dc2a1
Apply suggestions from code review
amrueda Oct 23, 2023
f00ac01
Removed timers from MCL routines (not compatible with multi-threading)
amrueda Oct 23, 2023
c8888f3
Merge branch 'main' into subcell-limiting
bennibolm Oct 24, 2023
50be874
Renamed flux_nonconservative_powell2 to flux_nonconservative_powell_l…
amrueda Oct 24, 2023
e7d1b08
Merge branch 'main' into subcell_limiting_noncons
amrueda Oct 24, 2023
7f03d00
Add allocation tests to subcell simulation tests (only `TreeMesh`)
bennibolm Oct 24, 2023
ffbda68
Fix allocations in `SemiDiscEntropyLimiter`
bennibolm Oct 24, 2023
c7c3ca0
Increased maximum allowed allocation bound for subcell limiting simul…
amrueda Oct 24, 2023
120f9ba
Added explanatory comments about different non-conservative fluxes an…
amrueda Oct 24, 2023
81d40e2
Changed variable name noncons_term to nonconservative_term
amrueda Oct 24, 2023
c7dd7f5
Update docstrin of flux_nonconservative_powell_local_symmetric
amrueda Oct 24, 2023
5b2b888
Implement suggestions
bennibolm Oct 24, 2023
b7bed59
Fix format
bennibolm Oct 24, 2023
7910993
Renamed function nnoncons as n_nonconservative_terms
amrueda Oct 24, 2023
3f9f0fe
format
amrueda Oct 24, 2023
b6646ad
Apply suggestions from code review
amrueda Oct 24, 2023
0eee721
Non-conservative subcell limiting cache only allocated for non-conser…
amrueda Oct 24, 2023
df12f03
Merge branch 'main' into subcell_limiting_noncons
amrueda Oct 24, 2023
394c486
Merge branch 'main' into subcell-limiting-minmax
sloede Oct 25, 2023
cb1d5ec
Merge branch 'main' into subcell-limiting
bennibolm Oct 25, 2023
a23b6b1
Merge branch 'subcell-limiting' into subcell_positivity_nonconservative
amrueda Oct 25, 2023
ee21f0a
Merge branch 'subcell_limiting_noncons' into subcell_positivity_nonco…
amrueda Oct 25, 2023
f3399b6
Add allocation tests for `StructuredMesh`
bennibolm Oct 25, 2023
6f43419
Merge branch 'subcell-limiting' into subcell_positivity_nonconservative
amrueda Oct 25, 2023
3e81bbb
Merge branch 'main' into subcell_positivity_nonconservative
amrueda Oct 31, 2023
113ce70
format
amrueda Oct 31, 2023
400afb7
Updated the reference solution of some subcell limiting tests
amrueda Oct 31, 2023
30b33fd
Add memory allocation test
amrueda Oct 31, 2023
09cbdae
Merge branch 'main' into subcell-limiting-minmax
bennibolm Nov 2, 2023
6d01643
Add subcell allocation tests; Add changes to minmax limiter
bennibolm Nov 2, 2023
306fb19
Undo changes in elixirs
bennibolm Nov 2, 2023
bd781ec
Merge pull request #116 from amrueda/subcell_positivity_nonconservative
bennibolm Nov 2, 2023
9897ead
Merge branch 'main' into subcell-limiting
bennibolm Nov 2, 2023
5adf14c
Implement suggestions
bennibolm Nov 2, 2023
29ed6ce
Skip positivity limiting if local limiting is more restrictive
bennibolm Nov 3, 2023
ea226d5
Reduce allocations
bennibolm Nov 3, 2023
1c845f6
Add unintentionally removed lines
bennibolm Nov 3, 2023
953926a
Merge branch 'main' into subcell-limiting-minmax
bennibolm Nov 6, 2023
cb899fe
Revise bounds check for MCL (#118)
bennibolm Nov 6, 2023
94d8a3e
Remove doubled tests
bennibolm Nov 6, 2023
7604822
Merge branch 'main' into subcell-limiting
bennibolm Nov 6, 2023
f6836b0
Pass variable as strings instead of indices
bennibolm Nov 7, 2023
3f53816
Update test to new passing structure
bennibolm Nov 7, 2023
3afa4c1
Pass variables as strings instead of ints
bennibolm Nov 7, 2023
de20a89
Add `_nonperiodic` to elixir name
bennibolm Nov 7, 2023
50e7bc2
Merge branch 'main' into subcell-limiting-minmax
bennibolm Nov 7, 2023
5b1378c
Format
bennibolm Nov 7, 2023
ebedaba
Fix unit test
bennibolm Nov 7, 2023
fd3d531
Fix unit test
bennibolm Nov 7, 2023
5e81530
Implement suggestions
bennibolm Nov 8, 2023
310832c
Merge changes from branch 'subcell-limiting-minmax'
bennibolm Nov 8, 2023
f9ec72c
Clean up
bennibolm Nov 8, 2023
0a51a49
Add missing comma in bounds check exportation
bennibolm Nov 9, 2023
7e22f25
Reduce allocations in `calc_variable_bounds!` for IDP
bennibolm Nov 9, 2023
ba2c20b
Use thread parallelization for reset of alphas
bennibolm Nov 13, 2023
d854c50
Reduce weird allocation when using thread parallelization
bennibolm Nov 13, 2023
bc5d5e4
Merge branch 'main' into subcell-limiting
bennibolm Nov 13, 2023
fca5614
Clean up branch with main
bennibolm Nov 14, 2023
e44272d
Remove deleted tests
bennibolm Nov 14, 2023
f1b2768
Change order of test as in main
bennibolm Nov 14, 2023
062568c
Add positivity limiting of non-linear variables
bennibolm Nov 14, 2023
aa0e9e3
Rename MCL parameters (#119)
bennibolm Nov 14, 2023
849b09e
Revise derivative function call; Add default derivative version
bennibolm Nov 16, 2023
2c75e38
Adapt test to actually test pos limiter for nonlinear variables
bennibolm Nov 16, 2023
bf69564
Add unit test to test default implementation of variable_derivative
bennibolm Nov 16, 2023
e50b5a8
Clean up some stuff
bennibolm Nov 16, 2023
d44fb82
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Nov 17, 2023
0c9b36f
Merge changes from `subcell-limiting-positivty-cons-structured`
bennibolm Nov 17, 2023
5af578f
Add comments
bennibolm Nov 17, 2023
e09ed28
Extract inner code of entropy limiters due to dispatching
bennibolm Nov 20, 2023
3a20622
Fix blast wave test
bennibolm Nov 20, 2023
1aa2eaf
Format
bennibolm Nov 20, 2023
5d14a6b
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Nov 20, 2023
4830bbb
Fix entropy limiter for StructuredMesh
bennibolm Nov 20, 2023
af19dbf
Fix typo
bennibolm Nov 20, 2023
ad64cd7
Merge branch 'main' into subcell-limiting
bennibolm Nov 20, 2023
36b2481
Clean up comments and code
bennibolm Nov 20, 2023
dbc79a7
Add approved changes from P4estMesh PR
bennibolm Nov 22, 2023
b72ed16
Merge branch 'main' into subcell-limiting
bennibolm Nov 22, 2023
9c0a288
Clean up routine `get_boundary_outer_state`
bennibolm Nov 22, 2023
1d94582
Format
bennibolm Nov 22, 2023
4e7f685
Fix test
bennibolm Nov 23, 2023
73e26c4
Speed up bar states bounds calculation of entropies (#120)
bennibolm Nov 23, 2023
2beb8e5
Merge branch 'main' into subcell-limiting
bennibolm Nov 27, 2023
f50d018
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Nov 27, 2023
bcfc1e9
Fix normalization for Charactersitics and slip wall
bennibolm Nov 28, 2023
60a0fbf
Fix elixirs and tests
bennibolm Nov 28, 2023
7d9e867
Merge branch 'main' into subcell-limiting
bennibolm Dec 3, 2023
66476eb
Add verified changes from P4estMesh PR
bennibolm Dec 3, 2023
a53b431
Merge branch 'main' into subcell-limiting
bennibolm Dec 4, 2023
8ebce9d
Fix bug
bennibolm Dec 4, 2023
15abed3
Adapt tests to reduce compilation time
bennibolm Dec 4, 2023
647ead5
Format
bennibolm Dec 4, 2023
1a09eaa
Add support for P4estMesh to `subcell-limiting` (#121)
bennibolm Dec 5, 2023
8803e4d
Add entropy limiting to elixir
bennibolm Dec 6, 2023
aeb5025
Add elixirs and tests for MCL on P4estMesh
bennibolm Dec 6, 2023
1431449
Fix test
bennibolm Dec 6, 2023
6c07f01
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Dec 6, 2023
975fead
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Dec 7, 2023
2702bb8
Rename Newton-bisection variables
bennibolm Dec 7, 2023
5ec5ade
Implement suggestions
bennibolm Dec 13, 2023
2c9b0fa
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Dec 13, 2023
e436f31
Merge branch 'main' into subcell-limiting-positivity-nonlinear
sloede Dec 15, 2023
ecd798e
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Dec 18, 2023
a886ea3
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Dec 19, 2023
dd8d916
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Dec 20, 2023
fa19163
Merge branch 'main' into subcell-limiting-positivity-nonlinear
bennibolm Dec 21, 2023
535eeef
Merge branch 'main' into subcell-limiting
bennibolm Dec 21, 2023
944ec3c
fmt
bennibolm Dec 21, 2023
e5b0b63
Merge changes from branch 'subcell-limiting-positivity-nonlinear'
bennibolm Dec 21, 2023
bcd1c99
Fix variable_derivative routines for entropies
bennibolm Dec 22, 2023
ccdc34e
Relocate functions
bennibolm Dec 22, 2023
91e5239
Add entropy limiters
bennibolm Dec 22, 2023
927d783
Update test errors after adding entropy limiting
bennibolm Dec 22, 2023
40b8d93
Use `calc_onesided_boundary` from `subcell-limiting-entropies`
bennibolm Dec 22, 2023
8a516a3
Adapt elixir
bennibolm Dec 22, 2023
5187ee5
Fix estimated errors; Bug found in `subcell-limiting-entropies`
bennibolm Dec 26, 2023
a26f2a6
Merge branch 'main' into subcell-limiting
bennibolm Jan 2, 2024
896c0a7
Fix allocations with multithreaded
bennibolm Jan 30, 2024
485f447
Split mcl_bounds_delta into global and local
bennibolm Jan 30, 2024
41587cc
Add comment
bennibolm Jan 30, 2024
2c61390
Outsource code for saving bounds errors (#122)
bennibolm Jan 31, 2024
1cdb8a8
Merge branch 'main' into subcell-limiting
bennibolm Jan 31, 2024
e51644e
Cancel some `for` loops for clarity and better parallelization capabi…
bennibolm Feb 2, 2024
be7bcb9
Merge branch 'main'
bennibolm Feb 5, 2024
e5f9d69
Merge branch 'main' into subcell-limiting
bennibolm Feb 5, 2024
6464f4d
Clean up testing
bennibolm Feb 5, 2024
dc72678
Fix bug
bennibolm Feb 5, 2024
913d6f3
Merge branch 'main' into subcell-limiting
bennibolm Mar 1, 2024
bf47a2b
Remove doubled foreach_enumerate
bennibolm Mar 20, 2024
d91ccb7
Merge branch 'main' into subcell-limiting
bennibolm Mar 21, 2024
0085033
Merge branch 'main' into subcell-limiting
bennibolm Mar 25, 2024
2507794
Use @batch reduction for bounds check (#126)
bennibolm Mar 27, 2024
5899d84
Merge branch 'main' into subcell-limiting
bennibolm Mar 27, 2024
c2b197a
Merge main (#127)
bennibolm May 12, 2024
43dad26
Merge branch 'main' into subcell-limiting
bennibolm May 12, 2024
9ceaaa8
Merge branch 'main' into subcell-limiting
bennibolm May 14, 2024
aed2c65
Fix tests
bennibolm May 14, 2024
ec1e8b8
Fix and adapt tests for saving deviations with MCL
bennibolm May 14, 2024
628209e
Merge branch 'main' into subcell-limiting
bennibolm May 16, 2024
c518683
Merge branch 'main' into subcell-limiting
bennibolm May 23, 2024
8562942
Merge main: Remove dispatching for mesh types (#128)
bennibolm May 24, 2024
10580fc
Move `save_bounds_check_errors` to `subcell_bounds_check.jl`
bennibolm May 24, 2024
c030593
Fix newton loop with `continue`
bennibolm May 24, 2024
734d639
Merge branch 'main' into subcell-limiting
bennibolm May 24, 2024
53881b7
Fix boundary condition mixed for structured mesh (not used lines of c…
bennibolm Jul 25, 2024
91b5db9
Merge branch 'main' into subcell-limiting
bennibolm Jul 29, 2024
0ac57af
Merge branch from subcell limiting p4est PR (#129)
bennibolm Jul 29, 2024
6c3b009
Merge branch 'main' into subcell-limiting
bennibolm Aug 28, 2024
6ddc04c
Merge branch 'main' into subcell-limiting
bennibolm Aug 30, 2024
0ded2e3
Merge main (#131)
bennibolm Sep 20, 2024
efeaca8
Merge branch 'main' into subcell-limiting
bennibolm Sep 20, 2024
5895118
Add tests for alpha analysis (#132)
bennibolm Oct 22, 2024
c7263f7
Merge branch 'main' into subcell-limiting
bennibolm Oct 22, 2024
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
3 changes: 2 additions & 1 deletion docs/literate/src/files/subcell_shock_capturing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ volume_flux = flux_ranocha
# Here, the simulation should contain local limiting for the density using lower and upper bounds.
basis = LobattoLegendreBasis(3)
limiter_idp = SubcellLimiterIDP(equations, basis;
local_twosided_variables_cons = ["rho"])
local_twosided_variables_cons = ["rho"],
bar_states = false)

# The initialized limiter is passed to `VolumeIntegralSubcellLimiting` in addition to the volume
# fluxes of the low-order and high-order scheme.
Expand Down
168 changes: 168 additions & 0 deletions examples/p4est_2d_dgsem/elixir_euler_double_mach.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the compressible Euler equations
gamma = 1.4
equations = CompressibleEulerEquations2D(gamma)

"""
initial_condition_double_mach_reflection(x, t, equations::CompressibleEulerEquations2D)

Compressible Euler setup for a double Mach reflection problem.
Involves strong shock interactions as well as steady / unsteady flow structures.
Also exercises special boundary conditions along the bottom of the domain that is a mixture of
Dirichlet and slip wall.
See Section IV c on the paper below for details.

- Paul Woodward and Phillip Colella (1984)
The Numerical Simulation of Two-Dimensional Fluid Flows with Strong Shocks.
[DOI: 10.1016/0021-9991(84)90142-6](https://doi.org/10.1016/0021-9991(84)90142-6)
"""
@inline function initial_condition_double_mach_reflection(x, t,
equations::CompressibleEulerEquations2D)
if x[1] < 1 / 6 + (x[2] + 20 * t) / sqrt(3)
phi = pi / 6
sin_phi, cos_phi = sincos(phi)

rho = 8.0
v1 = 8.25 * cos_phi
v2 = -8.25 * sin_phi
p = 116.5
else
rho = 1.4
v1 = 0.0
v2 = 0.0
p = 1.0
end

prim = SVector(rho, v1, v2, p)
return prim2cons(prim, equations)
end

initial_condition = initial_condition_double_mach_reflection

boundary_condition_inflow_outflow = BoundaryConditionCharacteristic(initial_condition)

# Special mixed boundary condition type for the :y_neg of the domain.
# It is charachteristic-based when x < 1/6 and a slip wall when x >= 1/6
# Note: Only for P4estMesh
@inline function boundary_condition_mixed_characteristic_wall(u_inner,
normal_direction::AbstractVector,
x, t, surface_flux_function,
equations::CompressibleEulerEquations2D)
if x[1] < 1 / 6
# From the BoundaryConditionCharacteristic
# get the external state of the solution
u_boundary = Trixi.characteristic_boundary_value_function(initial_condition_double_mach_reflection,
u_inner,
normal_direction,
x, t,
equations)
# Calculate boundary flux
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)
else # x[1] >= 1 / 6
# Use the free slip wall BC otherwise
flux = boundary_condition_slip_wall(u_inner, normal_direction, x, t,
surface_flux_function, equations)
end

return flux
end

# Note: Only for P4estMesh
@inline function Trixi.get_boundary_outer_state(u_inner, cache, t,
boundary_condition::typeof(boundary_condition_mixed_characteristic_wall),
normal_direction::AbstractVector, direction,
mesh::P4estMesh{2},
equations::CompressibleEulerEquations2D,
dg, indices...)
x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, indices...)
if x[1] < 1 / 6 # BoundaryConditionCharacteristic
u_outer = Trixi.characteristic_boundary_value_function(initial_condition_double_mach_reflection,
u_inner,
normal_direction,
x, t, equations)

else # if x[1] >= 1 / 6 # boundary_condition_slip_wall
factor = (normal_direction[1] * u_inner[2] + normal_direction[2] * u_inner[3])
u_normal = (factor / sum(normal_direction .^ 2)) * normal_direction

u_outer = SVector(u_inner[1],
u_inner[2] - 2.0 * u_normal[1],
u_inner[3] - 2.0 * u_normal[2],
u_inner[4])
end
return u_outer
end

boundary_conditions = Dict(:y_neg => boundary_condition_mixed_characteristic_wall,
:y_pos => boundary_condition_inflow_outflow,
:x_pos => boundary_condition_inflow_outflow,
:x_neg => boundary_condition_inflow_outflow)

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

limiter_idp = SubcellLimiterIDP(equations, basis;
local_twosided_variables_cons = ["rho"],
local_onesided_variables_nonlinear = [(Trixi.entropy_guermond_etal,
min)],
positivity_correction_factor = 0.1,
max_iterations_newton = 100,
bar_states = true)
volume_integral = VolumeIntegralSubcellLimiting(limiter_idp;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)
solver = DGSEM(basis, surface_flux, volume_integral)

initial_refinement_level = 4
trees_per_dimension = (4 * 2^initial_refinement_level, 2^initial_refinement_level)
coordinates_min = (0.0, 0.0)
coordinates_max = (4.0, 1.0)
mesh = P4estMesh(trees_per_dimension, polydeg = polydeg,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 0,
periodicity = false)

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

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

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

summary_callback = SummaryCallback()

analysis_interval = 500
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
extra_analysis_integrals = (entropy,))

alive_callback = AliveCallback(analysis_interval = analysis_interval)

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

stepsize_callback = StepsizeCallback(cfl = 0.9)

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

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

stage_callbacks = (SubcellLimiterIDPCorrection(), BoundsCheckCallback(save_errors = false))

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);
summary_callback() # print the timer summary
170 changes: 170 additions & 0 deletions examples/p4est_2d_dgsem/elixir_euler_double_mach_MCL.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the compressible Euler equations
gamma = 1.4
equations = CompressibleEulerEquations2D(gamma)

"""
initial_condition_double_mach_reflection(x, t, equations::CompressibleEulerEquations2D)

Compressible Euler setup for a double Mach reflection problem.
Involves strong shock interactions as well as steady / unsteady flow structures.
Also exercises special boundary conditions along the bottom of the domain that is a mixture of
Dirichlet and slip wall.
See Section IV c on the paper below for details.

- Paul Woodward and Phillip Colella (1984)
The Numerical Simulation of Two-Dimensional Fluid Flows with Strong Shocks.
[DOI: 10.1016/0021-9991(84)90142-6](https://doi.org/10.1016/0021-9991(84)90142-6)
"""
@inline function initial_condition_double_mach_reflection(x, t,
equations::CompressibleEulerEquations2D)
if x[1] < 1 / 6 + (x[2] + 20 * t) / sqrt(3)
phi = pi / 6
sin_phi, cos_phi = sincos(phi)

rho = 8.0
v1 = 8.25 * cos_phi
v2 = -8.25 * sin_phi
p = 116.5
else
rho = 1.4
v1 = 0.0
v2 = 0.0
p = 1.0
end

prim = SVector(rho, v1, v2, p)
return prim2cons(prim, equations)
end

initial_condition = initial_condition_double_mach_reflection

boundary_condition_inflow_outflow = BoundaryConditionCharacteristic(initial_condition)

# Special mixed boundary condition type for the :y_neg of the domain.
# It is charachteristic-based when x < 1/6 and a slip wall when x >= 1/6
# Note: Only for P4estMesh
@inline function boundary_condition_mixed_characteristic_wall(u_inner,
normal_direction::AbstractVector,
x, t, surface_flux_function,
equations::CompressibleEulerEquations2D)
if x[1] < 1 / 6
# From the BoundaryConditionCharacteristic
# get the external state of the solution
u_boundary = Trixi.characteristic_boundary_value_function(initial_condition_double_mach_reflection,
u_inner,
normal_direction,
x, t,
equations)
# Calculate boundary flux
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)
else # x[1] >= 1 / 6
# Use the free slip wall BC otherwise
flux = boundary_condition_slip_wall(u_inner, normal_direction, x, t,
surface_flux_function, equations)
end

return flux
end

# Note: Only for P4estMesh
@inline function Trixi.get_boundary_outer_state(u_inner, cache, t,
boundary_condition::typeof(boundary_condition_mixed_characteristic_wall),
normal_direction::AbstractVector, direction,
mesh::P4estMesh{2},
equations::CompressibleEulerEquations2D,
dg, indices...)
x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, indices...)
if x[1] < 1 / 6 # BoundaryConditionCharacteristic
u_outer = Trixi.characteristic_boundary_value_function(initial_condition_double_mach_reflection,
u_inner,
normal_direction,
x, t, equations)

else # if x[1] >= 1 / 6 # boundary_condition_slip_wall
factor = (normal_direction[1] * u_inner[2] + normal_direction[2] * u_inner[3])
u_normal = (factor / sum(normal_direction .^ 2)) * normal_direction

u_outer = SVector(u_inner[1],
u_inner[2] - 2.0 * u_normal[1],
u_inner[3] - 2.0 * u_normal[2],
u_inner[4])
end
return u_outer
end

boundary_conditions = Dict(:y_neg => boundary_condition_mixed_characteristic_wall,
:y_pos => boundary_condition_inflow_outflow,
:x_pos => boundary_condition_inflow_outflow,
:x_neg => boundary_condition_inflow_outflow)

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

limiter_mcl = SubcellLimiterMCL(equations, basis;
density_limiter = true,
density_coefficient_for_all = false,
sequential_limiter = true,
conservative_limiter = false,
positivity_limiter_density = false,
positivity_limiter_pressure = false,
entropy_limiter_semidiscrete = false,
Plotting = true)
volume_integral = VolumeIntegralSubcellLimiting(limiter_mcl;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)
solver = DGSEM(basis, surface_flux, volume_integral)

initial_refinement_level = 4
trees_per_dimension = (4 * 2^initial_refinement_level, 2^initial_refinement_level)
coordinates_min = (0.0, 0.0)
coordinates_max = (4.0, 1.0)
mesh = P4estMesh(trees_per_dimension, polydeg = polydeg,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 0,
periodicity = false)

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

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

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

summary_callback = SummaryCallback()

analysis_interval = 500
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
extra_analysis_integrals = (entropy,))

alive_callback = AliveCallback(analysis_interval = analysis_interval)

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

stepsize_callback = StepsizeCallback(cfl = 0.9)

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

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

stage_callbacks = (BoundsCheckCallback(save_errors = false),)

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);
summary_callback() # print the timer summary
Loading
Loading