Path: blob/main/examples/p4est_3d_dgsem/elixir_euler_free_stream_boundaries_float32.jl
2055 views
# Similar to p4est_3d_dgsem/elixir_euler_free_stream_boundaries.jl1# but using Float32 instead of the default Float6423using OrdinaryDiffEqLowStorageRK4using Trixi56###############################################################################7# semidiscretization of the compressible Euler equations89equations = CompressibleEulerEquations3D(1.4f0)1011initial_condition = initial_condition_constant1213polydeg = 314# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of15# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.16# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.17# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.18# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.19# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the20# `StepsizeCallback` (CFL-Condition) and less diffusion.21solver = DGSEM(polydeg = polydeg, surface_flux = FluxLaxFriedrichs(max_abs_speed_naive),22RealT = Float32)2324###############################################################################25# Get the uncurved mesh from a file (downloads the file if not available locally)2627default_mesh_file = joinpath(@__DIR__, "mesh_cube_with_boundaries.inp")28isfile(default_mesh_file) ||29Trixi.download("https://gist.githubusercontent.com/DanielDoehring/710eab379fe3042dc08af6f2d1076e49/raw/38e9803bc0dab9b32a61d9542feac5343c3e6f4b/mesh_cube_with_boundaries.inp",30default_mesh_file)31mesh_file = default_mesh_file3233boundary_symbols = [:PhysicalSurface1, :PhysicalSurface2]3435mesh = P4estMesh{3}(mesh_file, polydeg = polydeg, boundary_symbols = boundary_symbols,36RealT = Float32)3738boundary_conditions = Dict(:PhysicalSurface1 => BoundaryConditionDirichlet(initial_condition),39:PhysicalSurface2 => BoundaryConditionDirichlet(initial_condition))4041semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,42boundary_conditions = boundary_conditions)4344###############################################################################45# ODE solvers, callbacks etc.4647tspan = (0.0f0, 1.0f0)48ode = semidiscretize(semi, tspan)4950summary_callback = SummaryCallback()5152analysis_interval = 10053analysis_callback = AnalysisCallback(semi, interval = analysis_interval)5455alive_callback = AliveCallback(analysis_interval = analysis_interval)5657stepsize_callback = StepsizeCallback(cfl = 1.5f0)5859callbacks = CallbackSet(summary_callback,60analysis_callback, alive_callback,61stepsize_callback)6263###############################################################################64# run the simulation6566sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);67dt = 1.0f0, # solve needs some value here but it will be overwritten by the stepsize_callback68ode_default_options()..., callback = callbacks);697071