Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# setup the equations
6
7
advection_velocity = 1.0
8
equations = LinearScalarAdvectionEquation1D(advection_velocity)
9
10
###############################################################################
11
# setup the GSBP DG discretization that uses the Gauss operators from Chan et al.
12
13
surface_flux = FluxLaxFriedrichs()
14
dg = DGMulti(polydeg = 3,
15
element_type = Line(),
16
approximation_type = GaussSBP(),
17
surface_integral = SurfaceIntegralWeakForm(surface_flux),
18
volume_integral = VolumeIntegralWeakForm())
19
20
###############################################################################
21
# setup the 1D mesh
22
23
cells_per_dimension = (8,)
24
mesh = DGMultiMesh(dg, cells_per_dimension,
25
coordinates_min = (-1.0,), coordinates_max = (1.0,),
26
periodicity = true)
27
28
###############################################################################
29
# setup the test problem (no source term needed for linear advection)
30
31
initial_condition = initial_condition_convergence_test
32
33
###############################################################################
34
# setup the semidiscretization and ODE problem
35
36
semi = SemidiscretizationHyperbolic(mesh,
37
equations,
38
initial_condition,
39
dg)
40
41
tspan = (0.0, 1.5)
42
ode = semidiscretize(semi, tspan)
43
44
###############################################################################
45
# setup the callbacks
46
47
# prints a summary of the simulation setup and resets the timers
48
summary_callback = SummaryCallback()
49
50
# analyse the solution in regular intervals and prints the results
51
analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg))
52
53
# The SaveSolutionCallback allows to save the solution to a file in regular intervals
54
save_solution = SaveSolutionCallback(interval = 100,
55
solution_variables = cons2prim)
56
57
# handles the re-calculation of the maximum Δt after each time step
58
stepsize_callback = StepsizeCallback(cfl = 0.75)
59
60
# collect all callbacks such that they can be passed to the ODE solver
61
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,
62
stepsize_callback)
63
64
###############################################################################
65
# run the simulation
66
67
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
68
dt = 1.0, ode_default_options()..., callback = callbacks);
69
70