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
2055 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_flux = flux_ranocha
15
solver = DGSEM(polydeg = 4, surface_flux = flux_ranocha,
16
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
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)
40
41
###############################################################################
42
# create the semi discretization object
43
44
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
45
46
###############################################################################
47
# ODE solvers, callbacks etc.
48
49
tspan = (0.0, 2.0)
50
ode = semidiscretize(semi, tspan)
51
52
summary_callback = SummaryCallback()
53
54
analysis_interval = 100
55
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
56
57
alive_callback = AliveCallback(analysis_interval = analysis_interval)
58
59
save_solution = SaveSolutionCallback(interval = 100,
60
save_initial_solution = true,
61
save_final_solution = true)
62
63
stepsize_callback = StepsizeCallback(cfl = 1.0)
64
65
callbacks = CallbackSet(summary_callback,
66
analysis_callback,
67
alive_callback,
68
save_solution,
69
stepsize_callback)
70
71
###############################################################################
72
# run the simulation
73
74
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
75
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
76
ode_default_options()..., callback = callbacks);
77
78