Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
f355e1b
Make volume integral computation adaptive
DanielDoehring Jul 20, 2025
552d717
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Jul 21, 2025
3ca63fc
towards 2d
DanielDoehring Jul 21, 2025
147e896
simplify
DanielDoehring Jul 21, 2025
2eec5d8
towards 2d
DanielDoehring Jul 21, 2025
8e9949b
try
DanielDoehring Jul 21, 2025
d823ff5
non cons does not work with weak form
DanielDoehring Jul 21, 2025
7bc660a
example
DanielDoehring Jul 21, 2025
fc0347a
whiteapce
DanielDoehring Jul 21, 2025
724335a
vis
DanielDoehring Jul 22, 2025
3166699
Compute first mean, then entropy (much cheaper)
DanielDoehring Aug 10, 2025
c0b1f0b
move u mean
DanielDoehring Aug 10, 2025
9876f85
benchmark
DanielDoehring Aug 10, 2025
dde3c81
Merge branch 'VolumeIntegralAdaptive' of github.com:DanielDoehring/Tr…
DanielDoehring Aug 11, 2025
6ec9287
comment
DanielDoehring Aug 11, 2025
a96827b
work
DanielDoehring Aug 11, 2025
004adba
u_mean
DanielDoehring Aug 31, 2025
7409fdb
rm
DanielDoehring Aug 31, 2025
0bec762
fmt
DanielDoehring Aug 31, 2025
e7ae7a2
shorten
DanielDoehring Aug 31, 2025
32e4c75
work
DanielDoehring Oct 13, 2025
0a38976
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Oct 13, 2025
1375fa7
shorten
DanielDoehring Oct 13, 2025
64c123a
shorten
DanielDoehring Oct 13, 2025
0dac510
move
DanielDoehring Oct 13, 2025
58db43b
bt
DanielDoehring Oct 13, 2025
5f885d6
examples
DanielDoehring Oct 13, 2025
224b84d
restz
DanielDoehring Oct 13, 2025
eaefcc1
todo
DanielDoehring Oct 13, 2025
e27d62a
rename
DanielDoehring Oct 13, 2025
ab8cb7f
test
DanielDoehring Oct 13, 2025
a755aa6
fmt
DanielDoehring Oct 13, 2025
7535812
rm amr cap
DanielDoehring Oct 13, 2025
7533ad0
covergae
DanielDoehring Oct 13, 2025
624113c
SAVE Sol
DanielDoehring Oct 13, 2025
a618ec5
ex
DanielDoehring Oct 13, 2025
56ac3ef
test vals
DanielDoehring Oct 13, 2025
a5fb02b
Update test/test_tree_1d_euler.jl
DanielDoehring Oct 13, 2025
26dc558
Update test/test_tree_1d_euler.jl
DanielDoehring Oct 14, 2025
80d6754
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Oct 14, 2025
ebb2e21
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Oct 15, 2025
257480f
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Oct 17, 2025
2c35e7f
rm int
DanielDoehring Oct 20, 2025
6b324f7
Update src/solvers/dgsem/calc_volume_integral.jl
DanielDoehring Oct 20, 2025
80b91ca
rev
DanielDoehring Oct 20, 2025
dd741d7
rev
DanielDoehring Oct 20, 2025
48cad6b
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Nov 17, 2025
5ebe81f
better indicator
DanielDoehring Nov 17, 2025
e3b6e37
prototype
DanielDoehring Nov 17, 2025
da268d3
ft
DanielDoehring Nov 18, 2025
5df5340
fmt
DanielDoehring Nov 18, 2025
38ab686
rm
DanielDoehring Nov 18, 2025
b94c156
3d test
DanielDoehring Nov 19, 2025
2f22b19
cont
DanielDoehring Nov 19, 2025
eae242d
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Nov 26, 2025
a100e9f
rename
DanielDoehring Nov 26, 2025
cfd4a39
more examples
DanielDoehring Nov 27, 2025
e55da26
cont
DanielDoehring Nov 28, 2025
84ababa
Update src/solvers/dgsem/dgsem.jl
DanielDoehring Nov 29, 2025
68e7ac5
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Dec 1, 2025
75ca8e0
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Dec 6, 2025
ca84e57
Update src/solvers/dgsem_tree/indicators.jl
DanielDoehring Dec 7, 2025
9011796
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Dec 13, 2025
e046615
3d non std
DanielDoehring Dec 13, 2025
1b6bb01
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Dec 16, 2025
34e53ab
alive cb
DanielDoehring Dec 16, 2025
0c4d712
incr
DanielDoehring Dec 16, 2025
ecced9c
clean up
DanielDoehring Dec 16, 2025
dd82e11
shorten
DanielDoehring Dec 16, 2025
93e863e
tests
DanielDoehring Dec 16, 2025
b30f30d
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Dec 20, 2025
aa29627
WF & SC
DanielDoehring Dec 20, 2025
59ea821
ac
DanielDoehring Dec 20, 2025
cb3ba22
12.5
DanielDoehring Dec 20, 2025
22408a3
restruct
DanielDoehring Dec 20, 2025
db543c6
fix
DanielDoehring Dec 20, 2025
59665f1
test more print
DanielDoehring Dec 20, 2025
a2aafc2
Update src/solvers/dgsem_tree/indicators.jl
DanielDoehring Dec 21, 2025
c518f87
Update src/solvers/dgsem_tree/indicators.jl
DanielDoehring Dec 21, 2025
1f0a657
Update src/solvers/dgsem_tree/indicators.jl
DanielDoehring Dec 21, 2025
f84b246
safety check
DanielDoehring Dec 21, 2025
bf0da64
Update src/solvers/dgsem_tree/indicators.jl
DanielDoehring Dec 21, 2025
d3f24e4
Update src/solvers/dg.jl
DanielDoehring Dec 21, 2025
92d3e3b
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Dec 22, 2025
3014939
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Dec 23, 2025
67f60f5
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Jan 1, 2026
0dff5da
change
DanielDoehring Jan 3, 2026
6311cfa
Merge branch 'VolumeIntegralAdaptive' of github.com:DanielDoehring/Tr…
DanielDoehring Jan 3, 2026
871b1b0
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Jan 3, 2026
d2bc478
change
DanielDoehring Jan 4, 2026
1390907
jacobian
DanielDoehring Jan 5, 2026
2ffe01d
use negative matrix
DanielDoehring Jan 5, 2026
aec137b
investigate
DanielDoehring Jan 5, 2026
7ee24ba
hllc
DanielDoehring Jan 5, 2026
d7a7d71
jac business
DanielDoehring Jan 6, 2026
f8acba2
move indicator
DanielDoehring Jan 6, 2026
bc92ae8
more indicators
DanielDoehring Jan 6, 2026
67b7cf2
docstrings, test
DanielDoehring Jan 6, 2026
197deed
experiment threshold adjustment
DanielDoehring Jan 7, 2026
f63653a
try clever update of target entropy decay
DanielDoehring Jan 7, 2026
7ab06e9
rm example
DanielDoehring Jan 7, 2026
2f77491
storage-computation tradeoff
DanielDoehring Jan 7, 2026
d2b64c4
store entropy
DanielDoehring Jan 7, 2026
c6a43bc
3d sedov blast
DanielDoehring Jan 7, 2026
7270d74
all reference
DanielDoehring Jan 8, 2026
3d2bcb8
update
DanielDoehring Jan 8, 2026
e87e00d
Merge branch 'VolumeIntegralAdaptive' of github.com:DanielDoehring/Tr…
DanielDoehring Jan 8, 2026
cd82ac1
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Jan 8, 2026
f6fd807
Adaptive & RRG
DanielDoehring Jan 8, 2026
b704d88
update target decay
DanielDoehring Jan 8, 2026
9ca53ac
idea
DanielDoehring Jan 8, 2026
4b19950
try update again
DanielDoehring Jan 8, 2026
0188262
float
DanielDoehring Jan 9, 2026
04cab37
params
DanielDoehring Jan 9, 2026
0ec2c60
naca0012 NSF separation
DanielDoehring Jan 9, 2026
e103142
use sd7003 for separation example
DanielDoehring Jan 12, 2026
f863332
restart
DanielDoehring Jan 12, 2026
5c07b56
fi xorder cbs
DanielDoehring Jan 12, 2026
db0f140
rm save sol
DanielDoehring Jan 12, 2026
5e99fcb
restart
DanielDoehring Jan 14, 2026
9a53da1
add
DanielDoehring Jan 14, 2026
4c4bc81
run longer non-ref
DanielDoehring Jan 14, 2026
d3dc47b
rev
DanielDoehring Jan 14, 2026
f171029
check with AMR 3
DanielDoehring Jan 15, 2026
5d60788
remove `calc_entropy_delta`: Trade computations for storage
DanielDoehring Jan 16, 2026
5d173a2
rm update
DanielDoehring Jan 16, 2026
ab1e404
2 lvl indicator
DanielDoehring Jan 16, 2026
a83ac24
change
DanielDoehring Jan 16, 2026
c61ceb3
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Jan 16, 2026
95598b5
toml
DanielDoehring Jan 16, 2026
22e84d5
rm
DanielDoehring Jan 16, 2026
fd9e6af
conclude sd7003 sim
DanielDoehring Jan 16, 2026
3bbab7d
Merge branch 'main' into VolumeIntegralAdaptive
DanielDoehring Jan 19, 2026
a16e541
compare runtimes
DanielDoehring Jan 19, 2026
10e42f4
rename
DanielDoehring Jan 20, 2026
6801e20
reduce to entropy diffusion
DanielDoehring Jan 20, 2026
dbde5bb
linear stab
DanielDoehring Jan 20, 2026
28f3641
reference
DanielDoehring Jan 20, 2026
dd862b3
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Jan 20, 2026
17c3d71
fix
DanielDoehring Jan 20, 2026
8f7ca33
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Jan 20, 2026
b69e989
test vals
DanielDoehring Jan 20, 2026
ac8a189
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Jan 23, 2026
181ffc0
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Jan 24, 2026
45e1441
Update src/callbacks_step/analysis_dg2d.jl
DanielDoehring Jan 25, 2026
b8d8182
comments
DanielDoehring Jan 25, 2026
cb7cee1
Update src/solvers/dgsem/calc_volume_integral.jl
DanielDoehring Jan 25, 2026
66a9882
safe guarding
DanielDoehring Jan 25, 2026
d93c196
comment
DanielDoehring Jan 25, 2026
11e059c
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Jan 25, 2026
9aee330
cfl
DanielDoehring Jan 25, 2026
a5be4a5
rename
DanielDoehring Jan 25, 2026
f1d6165
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Jan 26, 2026
4ff6f21
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Jan 27, 2026
0e1575c
make more similar to Jessse PR
DanielDoehring Feb 2, 2026
adac3e4
move comment
DanielDoehring Feb 2, 2026
50e6a72
fix
DanielDoehring Feb 2, 2026
a09c446
fix
DanielDoehring Feb 2, 2026
01164f7
comments
DanielDoehring Feb 2, 2026
6a82590
adapt to jesse info
DanielDoehring Feb 3, 2026
cd36868
docstrings
DanielDoehring Feb 3, 2026
89d0784
fix
DanielDoehring Feb 3, 2026
9ea3cb2
export
DanielDoehring Feb 3, 2026
21b9f1f
rename
DanielDoehring Feb 3, 2026
f777c74
fix
DanielDoehring Feb 3, 2026
06518b7
fix
DanielDoehring Feb 3, 2026
ee9b4b1
comment
DanielDoehring Feb 3, 2026
c0c6e23
Merge branch 'main' into VolumeIntegralAdaptive_Start
JoshuaLampert Feb 4, 2026
2537158
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 4, 2026
33b3f30
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 4, 2026
f021569
Update src/solvers/dgsem/indicators.jl
DanielDoehring Feb 4, 2026
d01c58b
retrieve
DanielDoehring Feb 4, 2026
656e0bc
Merge branch 'VolumeIntegralAdaptive_Start' of github.com:DanielDoehr…
DanielDoehring Feb 4, 2026
560df63
exchange
DanielDoehring Feb 4, 2026
4565dbb
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 4, 2026
4c73871
Update src/equations/compressible_euler_2d.jl
DanielDoehring Feb 6, 2026
6d798d1
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 6, 2026
8f987dc
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 6, 2026
63f0b34
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 6, 2026
33b78fb
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 6, 2026
7809af8
Merge branch 'VolumeIntegralAdaptive_Start' of github.com:DanielDoehr…
DanielDoehring Feb 6, 2026
71ade6f
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 8, 2026
3fdc40b
ii => i
DanielDoehring Feb 8, 2026
a6ee470
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 8, 2026
fab3586
bcs
DanielDoehring Feb 9, 2026
d77d215
Merge branch 'VolumeIntegralAdaptive_Start' of github.com:DanielDoehr…
DanielDoehring Feb 9, 2026
3681cdf
mesh periodi
DanielDoehring Feb 9, 2026
d3d8ac0
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 13, 2026
62b4d29
move create cache
DanielDoehring Feb 13, 2026
6d937bf
Apply suggestions from code review
DanielDoehring Feb 13, 2026
971402c
Fix
DanielDoehring Feb 13, 2026
76679b9
rm defaults
DanielDoehring Feb 13, 2026
428f959
Merge branch 'main' into VolumeIntegralAdaptive_Start
DanielDoehring Feb 13, 2026
6616bfa
generalize comments
DanielDoehring Feb 13, 2026
61a59ac
comments
DanielDoehring Feb 13, 2026
d7704b7
format
ranocha Feb 13, 2026
85e6cc1
Update src/solvers/dg.jl
DanielDoehring Feb 13, 2026
79dd955
change
DanielDoehring Feb 13, 2026
e1c0d66
Merge branch 'VolumeIntegralAdaptive_Start' of github.com:DanielDoehr…
DanielDoehring Feb 13, 2026
d88ef7b
Update src/solvers/dg.jl
DanielDoehring Feb 13, 2026
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,77 @@
using OrdinaryDiffEqLowStorageRK
using Trixi

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

# We repeat test case for linear stability of EC fluxes from the paper
# - Gregor J. Gassner, Magnus Svärd, Florian J. Hindenlang (2020)
# Stability issues of entropy-stable and/or split-form high-order schemes
# [DOI: 10.1007/s10915-021-01720-8](https://doi.org/10.1007/s10915-021-01720-8)
initial_condition = initial_condition_density_wave

surface_flux = flux_lax_friedrichs
volume_flux = flux_chandrashekar

polydeg = 5
basis = LobattoLegendreBasis(polydeg)

volume_integral_weakform = VolumeIntegralWeakForm()
volume_integral_fluxdiff = VolumeIntegralFluxDifferencing(volume_flux)

# This indicator compares the entropy production of the weak form to the
# true entropy evolution in that cell.
# If the weak form dissipates more entropy than the true evolution
# the indicator renders this admissible. Otherwise, the more stable
# volume integral is to be used.
indicator = IndicatorEntropyChange(maximum_entropy_increase = 0.0)

# Adaptive volume integral using the entropy change indicator to perform the
# stabilized/EC volume integral when needed and keeping the weak form if it is more diffusive.
volume_integral = VolumeIntegralAdaptive(indicator = indicator,
volume_integral_default = volume_integral_weakform,
volume_integral_stabilized = volume_integral_fluxdiff)

#volume_integral = volume_integral_weakform # Stable, but unphysical entropy increase!
#volume_integral = volume_integral_fluxdiff # Crashes!

solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
volume_integral = volume_integral)

coordinates_min = (-1.0, -1.0)
coordinates_max = (1.0, 1.0)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 2, # 4 x 4 elements
n_cells_max = 30_000,
periodicity = true)

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

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

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

summary_callback = SummaryCallback()

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

alive_callback = AliveCallback(analysis_interval = analysis_interval)

# In the paper, CFL = 0.05 is used. Same observations recovered for CFL = 0.9, though.
stepsize_callback = StepsizeCallback(cfl = 0.9)

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

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

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
dt = 1.0, ode_default_options()..., callback = callbacks);
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using OrdinaryDiffEqLowStorageRK
using Trixi

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

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

A version of the classical Kelvin-Helmholtz instability based on
- Andrés M. Rueda-Ramírez, Gregor J. Gassner (2021)
A Subcell Finite Volume Positivity-Preserving Limiter for DGSEM Discretizations
of the Euler Equations
[arXiv: 2102.06017](https://arxiv.org/abs/2102.06017)
"""
function initial_condition_kelvin_helmholtz_instability(x, t,
equations::CompressibleEulerEquations2D)
# change discontinuity to tanh
# typical resolution 128^2, 256^2
# domain size is [-1,+1]^2
RealT = eltype(x)
slope = 15
B = tanh(slope * x[2] + 7.5f0) - tanh(slope * x[2] - 7.5f0)
rho = 0.5f0 + 0.75f0 * B
v1 = 0.5f0 * (B - 1)
v2 = convert(RealT, 0.1) * sinpi(2 * x[1])
p = 1
return prim2cons(SVector(rho, v1, v2, p), equations)
end
initial_condition = initial_condition_kelvin_helmholtz_instability

surface_flux = flux_hllc
volume_flux = flux_ranocha
polydeg = 3
basis = LobattoLegendreBasis(polydeg)

volume_integral_weakform = VolumeIntegralWeakForm()
volume_integral_fluxdiff = VolumeIntegralFluxDifferencing(volume_flux)

# This indicator compares the entropy production of the weak form to the
# true entropy evolution in that cell.
# If the weak form dissipates more entropy than the true evolution
# the indicator renders this admissible. Otherwise, the more stable
# volume integral is to be used.
indicator = IndicatorEntropyChange(maximum_entropy_increase = 0.0)

# Adaptive volume integral using the entropy change indicator to perform the
# stabilized/EC volume integral when needed and keeping the weak form if it is more diffusive.
volume_integral = VolumeIntegralAdaptive(indicator = indicator,
volume_integral_default = volume_integral_weakform,
volume_integral_stabilized = volume_integral_fluxdiff)

#volume_integral = volume_integral_weakform # Crashes
#volume_integral = volume_integral_fluxdiff # Crashes as well!

solver = DGSEM(basis, surface_flux, volume_integral)

coordinates_min = (-1.0, -1.0)
coordinates_max = (1.0, 1.0)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 6,
n_cells_max = 100_000,
periodicity = true)

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

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

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

summary_callback = SummaryCallback()

analysis_interval = 1000
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
analysis_errors = Symbol[],
extra_analysis_integrals = (entropy,),
save_analysis = true)

alive_callback = AliveCallback(alive_interval = 200)

stepsize_callback = StepsizeCallback(cfl = 1.8)

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

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

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you decide to use CFL-based step size control everywhere instead of, say, an error-based one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I find the CFL-based timesteppers easier to parametrize in the sense that increase of CFL results always in fewer timesteps - whereas the effect of the adaptive timestep control is not as clear.

For this simulation, the CFL based timestepper is also way more efficient, needing only ~2000 timesteps with 5 stages vs. ~4300 vs 9 stages (for RDPK3SpFSAL49).

Nevertheless, the other two methods crash also with adaptive timestepping.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, does switching/adapting volume integrals result in an increased number of adaptive time-steps? We noticed this in some other simulations that adaptive time-stepping tended to pick up on non-differentiable changes in rhs! like this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes sense! I will test this for a given tolerance.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I tested this with SSPRK43 which gives good results also in the adaptive case. Maybe RDPK3SpFSAL49 is just not a good choice for this example.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to switch to SSPRK43 here from your point of view?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I find the adaptive integrators a bit annoying for CI, and as Carpenter Kenndedy is quite efficient here, I would like to keep it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

dt = 5e-3, ode_default_options()..., callback = callbacks);
2 changes: 2 additions & 0 deletions src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export density, pressure, density_pressure, velocity, temperature,
equilibrium_distribution,
waterheight, waterheight_pressure
export entropy, entropy_thermodynamic, entropy_math, entropy_guermond_etal,
entropy_potential,
energy_total, energy_kinetic, energy_internal, energy_internal_specific,
energy_magnetic, cross_helicity, magnetic_field, divergence_cleaning_field,
enstrophy, vorticity
Expand All @@ -268,6 +269,7 @@ export DG,
VolumeIntegralFluxDifferencing,
VolumeIntegralPureLGLFiniteVolume, VolumeIntegralPureLGLFiniteVolumeO2,
VolumeIntegralShockCapturingHG, VolumeIntegralShockCapturingRRG,
VolumeIntegralAdaptive, IndicatorEntropyChange,
IndicatorHennemannGassner,
VolumeIntegralUpwind,
SurfaceIntegralWeakForm, SurfaceIntegralStrongForm,
Expand Down
66 changes: 64 additions & 2 deletions src/callbacks_step/analysis_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,68 @@ function calc_error_norms(func, u, t, analyzer,
return l2_error, linf_error
end

# Use quadrature to numerically integrate a single element.
# We do not multiply by the Jacobian to stay in reference space.
# This avoids the need to divide the RHS of the DG scheme by the Jacobian when computing
# the time derivative of entropy, see `entropy_change_reference_element`.
function integrate_reference_element(func::Func, u, element,
mesh::AbstractMesh{2}, equations, dg::DGSEM, cache,
args...) where {Func}
@unpack weights = dg.basis

# Initialize integral with zeros of the right shape
element_integral = zero(func(u, 1, 1, element, equations, dg, args...))

for j in eachnode(dg), i in eachnode(dg)
element_integral += weights[i] * weights[j] *
func(u, i, j, element, equations, dg, args...)
end

return element_integral
end

# Calculate ∫_e (∂S/∂u ⋅ ∂u/∂t) dΩ_e where the result on element 'e' is kept in reference space
# Note that ∂S/∂u = w(u) with entropy variables w
function entropy_change_reference_element(du::AbstractArray{<:Any, 4}, u,
element,
mesh::AbstractMesh{2},
equations, dg::DGSEM, cache, args...)
return integrate_reference_element(u, element, mesh, equations, dg, cache,
du) do u, i, j, element, equations, dg, du
u_node = get_node_vars(u, equations, dg, i, j, element)
du_node = get_node_vars(du, equations, dg, i, j, element)

dot(cons2entropy(u_node, equations), du_node)
end
end

# calculate surface integral of func(u, equations) * normal on the reference element.
function surface_integral(func::Func, u, element,
mesh::TreeMesh{2}, equations, dg::DGSEM, cache,
args...) where {Func}
@unpack weights = dg.basis

u_tmp = get_node_vars(u, equations, dg, 1, 1, element)
surface_integral = zero(func(u_tmp, 1, equations))
for i in eachnode(dg)
# integrate along x direction, normal in y (2) direction
u_bottom = get_node_vars(u, equations, dg, i, 1, element)
u_top = get_node_vars(u, equations, dg, i, nnodes(dg), element)

surface_integral += weights[i] *
(func(u_top, 2, equations) - func(u_bottom, 2, equations))

# integrate along y direction, normal in x (1) direction
u_left = get_node_vars(u, equations, dg, 1, i, element)
u_right = get_node_vars(u, equations, dg, nnodes(dg), i, element)

surface_integral += weights[i] *
(func(u_right, 1, equations) - func(u_left, 1, equations))
end

return surface_integral
end

function integrate_via_indices(func::Func, u,
mesh::TreeMesh{2}, equations, dg::DGSEM, cache,
args...; normalize = true) where {Func}
Expand Down Expand Up @@ -214,8 +276,8 @@ function integrate_via_indices(func::Func, u,
mesh::Union{StructuredMesh{2}, StructuredMeshView{2},
UnstructuredMesh2D, P4estMesh{2},
T8codeMesh{2}},
equations,
dg::DGSEM, cache, args...; normalize = true) where {Func}
equations, dg::DGSEM, cache,
args...; normalize = true) where {Func}
@unpack weights = dg.basis

# Initialize integral with zeros of the right shape
Expand Down
22 changes: 22 additions & 0 deletions src/equations/compressible_euler_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,28 @@ end
return energy_total(cons, equations) - energy_kinetic(cons, equations)
end

@doc raw"""
entropy_potential(u, orientation::Int,
equations::AbstractCompressibleEulerEquations)

Calculate the entropy potential, which for the compressible Euler equations is simply
the momentum for the choice of mathematical [`entropy`](@ref) ``S(u) = \frac{\rho s}{\gamma - 1}``
with thermodynamic entropy ``s = \ln(p) - \gamma \ln(\rho)``.

## References
- Eitan Tadmor (2003)
Entropy stability theory for difference approximations of nonlinear conservation laws and related time-dependent problems
[DOI: 10.1017/S0962492902000156](https://doi.org/10.1017/S0962492902000156)
"""
@inline function entropy_potential(u, orientation::Int,
equations::CompressibleEulerEquations2D)
if orientation == 1
return u[2]
else # if orientation == 2
return u[3]
end
end

# State validation for Newton-bisection method of subcell IDP limiting
@inline function Base.isvalid(u, equations::CompressibleEulerEquations2D)
if u[1] <= 0 || pressure(u, equations) <= 0
Expand Down
74 changes: 74 additions & 0 deletions src/solvers/dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,80 @@ function Base.show(io::IO, mime::MIME"text/plain",
end
end

"""
VolumeIntegralAdaptive(;
indicator = IndicatorEntropyChange(),
volume_integral_default,
volume_integral_stabilized)

!!! warning "Experimental code"
This code is experimental and may change in any future release.

The `indicator` is currently limited to [`IndicatorEntropyChange`](@ref).
"""
struct VolumeIntegralAdaptive{Indicator,
VolumeIntegralDefault, VolumeIntegralStabilized} <:
AbstractVolumeIntegral
indicator::Indicator # A-posteriori indicator called after computation of `volume_integral_default`
volume_integral_default::VolumeIntegralDefault # Cheap(er) default volume integral to be used in non-critical regions
volume_integral_stabilized::VolumeIntegralStabilized # More expensive volume integral with stabilizing effect
end

function VolumeIntegralAdaptive(;
indicator = IndicatorEntropyChange(),
volume_integral_default,
volume_integral_stabilized)
if !(indicator isa IndicatorEntropyChange)
throw(ArgumentError("`indicator` must be of type `IndicatorEntropyChange`."))
end

return VolumeIntegralAdaptive{typeof(indicator),
typeof(volume_integral_default),
typeof(volume_integral_stabilized)}(indicator,
volume_integral_default,
volume_integral_stabilized)
end

function Base.show(io::IO, mime::MIME"text/plain",
integral::VolumeIntegralAdaptive)
@nospecialize integral # reduce precompilation time
@unpack volume_integral_default, volume_integral_stabilized, indicator = integral

if get(io, :compact, false)
show(io, integral)
else
summary_header(io, "VolumeIntegralAdaptive")

summary_line(io, "volume integral default",
volume_integral_default |> typeof |> nameof)
if !(volume_integral_default isa VolumeIntegralWeakForm)
show(increment_indent(io), mime, volume_integral_default)
end

summary_line(io, "volume integral stabilized",
volume_integral_stabilized |> typeof |> nameof)
show(increment_indent(io), mime, volume_integral_stabilized)

summary_line(io, "indicator", indicator |> typeof |> nameof)
show(increment_indent(io), mime, indicator)

summary_footer(io)
end
end

function create_cache(mesh, equations,
volume_integral::VolumeIntegralAdaptive,
dg, cache_containers, uEltype)
cache_default = create_cache(mesh, equations,
volume_integral.volume_integral_default,
dg, cache_containers, uEltype)
cache_stabilized = create_cache(mesh, equations,
volume_integral.volume_integral_stabilized,
dg, cache_containers, uEltype)

return (; cache_default..., cache_stabilized...)
end

# Abstract supertype for first-order `VolumeIntegralPureLGLFiniteVolume` and
# second-order `VolumeIntegralPureLGLFiniteVolumeO2` subcell-based finite volume
# volume integrals.
Expand Down
Loading
Loading