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_hypdiff_nonperiodic.jl
2055 views
1
using Trixi
2
3
###############################################################################
4
# semidiscretization of the hyperbolic diffusion equations
5
6
equations = HyperbolicDiffusionEquations2D()
7
8
initial_condition = initial_condition_poisson_nonperiodic
9
10
solver = DGSEM(polydeg = 6, surface_flux = flux_lax_friedrichs)
11
12
boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic,
13
x_pos = boundary_condition_poisson_nonperiodic,
14
y_neg = boundary_condition_periodic,
15
y_pos = boundary_condition_periodic)
16
17
###############################################################################
18
# Get the curved quad mesh from a mapping function
19
#
20
# Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D
21
function mapping(xi_, eta_)
22
# Transform input variables between -1 and 1 onto [0,3]
23
xi = 1.5 * xi_ + 1.5
24
eta = 1.5 * eta_ + 1.5
25
26
y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) *
27
cos(0.5 * pi * (2 * eta - 3) / 3))
28
29
x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) *
30
cos(2 * pi * (2 * y - 3) / 3))
31
32
return SVector(x, y)
33
end
34
35
# Create curved mesh with 8 x 8 elements
36
cells_per_dimension = (8, 8)
37
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = (false, true))
38
39
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
40
source_terms = source_terms_poisson_nonperiodic,
41
boundary_conditions = boundary_conditions)
42
43
###############################################################################
44
# ODE solvers, callbacks etc.
45
46
tspan = (0.0, 30.0)
47
ode = semidiscretize(semi, tspan)
48
49
summary_callback = SummaryCallback()
50
51
resid_tol = 5.0e-12
52
steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0)
53
54
analysis_interval = 4000
55
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
56
extra_analysis_integrals = (entropy, energy_total))
57
58
alive_callback = AliveCallback(analysis_interval = analysis_interval)
59
60
save_solution = SaveSolutionCallback(interval = 4000,
61
save_initial_solution = true,
62
save_final_solution = true,
63
solution_variables = cons2prim)
64
65
stepsize_callback = StepsizeCallback(cfl = 1.9)
66
67
callbacks = CallbackSet(summary_callback, steady_state_callback,
68
analysis_callback, alive_callback,
69
save_solution,
70
stepsize_callback)
71
72
###############################################################################
73
# run the simulation
74
75
sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52();
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