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