Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/p4est_3d_dgsem/elixir_euler_free_stream_boundaries_float32.jl
2055 views
1
# Similar to p4est_3d_dgsem/elixir_euler_free_stream_boundaries.jl
2
# but using Float32 instead of the default Float64
3
4
using OrdinaryDiffEqLowStorageRK
5
using Trixi
6
7
###############################################################################
8
# semidiscretization of the compressible Euler equations
9
10
equations = CompressibleEulerEquations3D(1.4f0)
11
12
initial_condition = initial_condition_constant
13
14
polydeg = 3
15
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
16
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
17
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
18
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
19
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
20
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
21
# `StepsizeCallback` (CFL-Condition) and less diffusion.
22
solver = DGSEM(polydeg = polydeg, surface_flux = FluxLaxFriedrichs(max_abs_speed_naive),
23
RealT = Float32)
24
25
###############################################################################
26
# Get the uncurved mesh from a file (downloads the file if not available locally)
27
28
default_mesh_file = joinpath(@__DIR__, "mesh_cube_with_boundaries.inp")
29
isfile(default_mesh_file) ||
30
Trixi.download("https://gist.githubusercontent.com/DanielDoehring/710eab379fe3042dc08af6f2d1076e49/raw/38e9803bc0dab9b32a61d9542feac5343c3e6f4b/mesh_cube_with_boundaries.inp",
31
default_mesh_file)
32
mesh_file = default_mesh_file
33
34
boundary_symbols = [:PhysicalSurface1, :PhysicalSurface2]
35
36
mesh = P4estMesh{3}(mesh_file, polydeg = polydeg, boundary_symbols = boundary_symbols,
37
RealT = Float32)
38
39
boundary_conditions = Dict(:PhysicalSurface1 => BoundaryConditionDirichlet(initial_condition),
40
:PhysicalSurface2 => BoundaryConditionDirichlet(initial_condition))
41
42
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
43
boundary_conditions = boundary_conditions)
44
45
###############################################################################
46
# ODE solvers, callbacks etc.
47
48
tspan = (0.0f0, 1.0f0)
49
ode = semidiscretize(semi, tspan)
50
51
summary_callback = SummaryCallback()
52
53
analysis_interval = 100
54
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
55
56
alive_callback = AliveCallback(analysis_interval = analysis_interval)
57
58
stepsize_callback = StepsizeCallback(cfl = 1.5f0)
59
60
callbacks = CallbackSet(summary_callback,
61
analysis_callback, alive_callback,
62
stepsize_callback)
63
64
###############################################################################
65
# run the simulation
66
67
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
68
dt = 1.0f0, # solve needs some value here but it will be overwritten by the stepsize_callback
69
ode_default_options()..., callback = callbacks);
70
71