-
Notifications
You must be signed in to change notification settings - Fork 151
VolumeIntegralAdaptive with IndicatorEntropyChange
#2754
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
Changes from all commits
f355e1b
552d717
3ca63fc
147e896
2eec5d8
8e9949b
d823ff5
7bc660a
fc0347a
724335a
3166699
c0b1f0b
9876f85
dde3c81
6ec9287
a96827b
004adba
7409fdb
0bec762
e7ae7a2
32e4c75
0a38976
1375fa7
64c123a
0dac510
58db43b
5f885d6
224b84d
eaefcc1
e27d62a
ab8cb7f
a755aa6
7535812
7533ad0
624113c
a618ec5
56ac3ef
a5fb02b
26dc558
80d6754
ebb2e21
257480f
2c35e7f
6b324f7
80b91ca
dd741d7
48cad6b
5ebe81f
e3b6e37
da268d3
5df5340
38ab686
b94c156
2f22b19
eae242d
a100e9f
cfd4a39
e55da26
84ababa
68e7ac5
75ca8e0
ca84e57
9011796
e046615
1b6bb01
34e53ab
0c4d712
ecced9c
dd82e11
93e863e
b30f30d
aa29627
59ea821
cb3ba22
22408a3
db543c6
59665f1
a2aafc2
c518f87
1f0a657
f84b246
bf0da64
d3f24e4
92d3e3b
3014939
67f60f5
0dff5da
6311cfa
871b1b0
d2bc478
1390907
2ffe01d
aec137b
7ee24ba
d7a7d71
f8acba2
bc92ae8
67b7cf2
197deed
f63653a
7ab06e9
2f77491
d2b64c4
c6a43bc
7270d74
3d2bcb8
e87e00d
cd82ac1
f6fd807
b704d88
9ca53ac
4b19950
0188262
04cab37
0ec2c60
e103142
f863332
5c07b56
db0f140
5e99fcb
9a53da1
4c4bc81
d3dc47b
f171029
5d60788
5d173a2
ab1e404
a83ac24
c61ceb3
95598b5
22e84d5
fd9e6af
3bbab7d
a16e541
10e42f4
6801e20
dbde5bb
28f3641
dd862b3
17c3d71
8f7ca33
b69e989
ac8a189
181ffc0
45e1441
b8d8182
cb7cee1
66a9882
d93c196
11e059c
9aee330
a5be4a5
f1d6165
4ff6f21
0e1575c
adac3e4
50e6a72
a09c446
01164f7
6a82590
cd36868
89d0784
9ea3cb2
21b9f1f
f777c74
06518b7
ee9b4b1
c0c6e23
2537158
33b3f30
f021569
d01c58b
656e0bc
560df63
4565dbb
4c73871
6d798d1
8f987dc
63f0b34
33b78fb
7809af8
71ade6f
3fdc40b
a6ee470
fab3586
d77d215
3681cdf
d3d8ac0
62b4d29
6d937bf
971402c
76679b9
428f959
6616bfa
61a59ac
d7704b7
85e6cc1
79dd955
e1c0d66
d88ef7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
ranocha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Nevertheless, the other two methods crash also with adaptive timestepping.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah that makes sense! I will test this for a given tolerance.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I tested this with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to switch to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
| dt = 5e-3, ode_default_options()..., callback = callbacks); | ||
Uh oh!
There was an error while loading. Please reload this page.