Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/dgmulti_1d/elixir_burgers_gauss_shock_capturing.jl
2055 views
1
using Trixi
2
using OrdinaryDiffEqLowStorageRK
3
4
equations = InviscidBurgersEquation1D()
5
6
###############################################################################
7
# setup the GSBP DG discretization that uses the Gauss operators from
8
# Chan, Del Rey Fernandez, Carpenter (2019).
9
# [https://doi.org/10.1137/18M1209234](https://doi.org/10.1137/18M1209234)
10
11
surface_flux = flux_lax_friedrichs
12
volume_flux = flux_ec
13
14
polydeg = 3
15
basis = DGMultiBasis(Line(), polydeg, approximation_type = GaussSBP())
16
17
indicator_sc = IndicatorHennemannGassner(equations, basis,
18
alpha_max = 0.5,
19
alpha_min = 0.001,
20
alpha_smooth = true,
21
variable = first)
22
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
23
volume_flux_dg = volume_flux,
24
volume_flux_fv = surface_flux)
25
26
dg = DGMulti(basis,
27
surface_integral = SurfaceIntegralWeakForm(surface_flux),
28
volume_integral = volume_integral)
29
30
###############################################################################
31
# setup the 1D mesh
32
33
cells_per_dimension = (32,)
34
mesh = DGMultiMesh(dg, cells_per_dimension,
35
coordinates_min = (-1.0,), coordinates_max = (1.0,),
36
periodicity = true)
37
38
###############################################################################
39
# setup the semidiscretization and ODE problem
40
41
semi = SemidiscretizationHyperbolic(mesh,
42
equations,
43
initial_condition_convergence_test,
44
dg)
45
46
tspan = (0.0, 2.0)
47
ode = semidiscretize(semi, tspan)
48
49
###############################################################################
50
# setup the callbacks
51
52
# prints a summary of the simulation setup and resets the timers
53
summary_callback = SummaryCallback()
54
55
# analyse the solution in regular intervals and prints the results
56
analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg))
57
58
# SaveSolutionCallback allows to save the solution to a file in regular intervals
59
save_solution = SaveSolutionCallback(interval = 100,
60
solution_variables = cons2prim)
61
62
# handles the re-calculation of the maximum Δt after each time step
63
stepsize_callback = StepsizeCallback(cfl = 0.5)
64
65
# collect all callbacks such that they can be passed to the ODE solver
66
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,
67
stepsize_callback)
68
69
# ###############################################################################
70
# # run the simulation
71
72
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
73
dt = 1.0, ode_default_options()..., callback = callbacks);
74
75