Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/structured_2d_dgsem/elixir_euler_ec.jl
2802 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations2D(1.4)
8
9
initial_condition = initial_condition_weak_blast_wave
10
11
###############################################################################
12
# Get the DG approximation space
13
14
volume_integral = VolumeIntegralFluxDifferencing(volume_flux = flux_ranocha)
15
solver = DGSEM(polydeg = 4, surface_flux = flux_ranocha,
16
volume_integral = volume_integral)
17
18
###############################################################################
19
# Get the curved quad mesh from a mapping function
20
21
# Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D
22
function mapping(xi_, eta_)
23
# Transform input variables between -1 and 1 onto [0,3]
24
xi = 1.5 * xi_ + 1.5
25
eta = 1.5 * eta_ + 1.5
26
27
y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) *
28
cos(0.5 * pi * (2 * eta - 3) / 3))
29
30
x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) *
31
cos(2 * pi * (2 * y - 3) / 3))
32
33
return SVector(x, y)
34
end
35
36
cells_per_dimension = (16, 16)
37
38
# Create curved mesh with 16 x 16 elements
39
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)
40
41
###############################################################################
42
# create the semi discretization object
43
44
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
45
boundary_conditions = boundary_condition_periodic)
46
47
###############################################################################
48
# ODE solvers, callbacks etc.
49
50
tspan = (0.0, 2.0)
51
ode = semidiscretize(semi, tspan)
52
53
summary_callback = SummaryCallback()
54
55
analysis_interval = 100
56
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
57
58
alive_callback = AliveCallback(analysis_interval = analysis_interval)
59
60
save_solution = SaveSolutionCallback(interval = 100,
61
save_initial_solution = true,
62
save_final_solution = true)
63
64
stepsize_callback = StepsizeCallback(cfl = 1.0)
65
66
callbacks = CallbackSet(summary_callback,
67
analysis_callback,
68
alive_callback,
69
save_solution,
70
stepsize_callback)
71
72
###############################################################################
73
# run the simulation
74
75
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
76
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
77
ode_default_options()..., callback = callbacks);
78
79