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