Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_1d_dgsem/elixir_maxwell_convergence.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the linear advection equation
6
7
equations = MaxwellEquations1D()
8
9
solver = DGSEM(polydeg = 3, surface_flux = flux_hll)
10
11
coordinates_min = 0.0
12
coordinates_max = 1.0
13
14
# Create a uniformly refined mesh with periodic boundaries
15
mesh = TreeMesh(coordinates_min, coordinates_max,
16
initial_refinement_level = 4,
17
n_cells_max = 30_000) # set maximum capacity of tree data structure
18
19
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
20
solver)
21
22
###############################################################################
23
# ODE solvers, callbacks etc.
24
25
# As the wave speed is equal to the speed of light which is on the order of 3 * 10^8
26
# we consider only a small time horizon.
27
ode = semidiscretize(semi, (0.0, 1e-8))
28
29
summary_callback = SummaryCallback()
30
31
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
32
analysis_callback = AnalysisCallback(semi, interval = 100)
33
34
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
35
stepsize_callback = StepsizeCallback(cfl = 1.6)
36
37
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
38
callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback)
39
40
###############################################################################
41
# run the simulation
42
43
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
44
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
45
ode_default_options()..., callback = callbacks);
46
47