Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the acoustic perturbation equations
6
7
equations = AcousticPerturbationEquations2D(v_mean_global = (0.0, -0.5),
8
c_mean_global = 1.0,
9
rho_mean_global = 1.0)
10
11
# Create DG solver with polynomial degree = 4 and (local) Lax-Friedrichs/Rusanov flux
12
13
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
14
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
15
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
16
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
17
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
18
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
19
# `StepsizeCallback` (CFL-Condition) and less diffusion.
20
solver = DGSEM(polydeg = 4, surface_flux = FluxLaxFriedrichs(max_abs_speed_naive))
21
22
# Create unstructured quadrilateral mesh from a file
23
mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/3c79baad6b4d73bb26ec6420b5d16f45/raw/22aefc4ec2107cf0bffc40e81dfbc52240c625b1/mesh_five_circles_in_circle.mesh",
24
joinpath(@__DIR__, "mesh_five_circles_in_circle.mesh"))
25
26
mesh = UnstructuredMesh2D(mesh_file)
27
28
"""
29
initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D)
30
31
A Gaussian pulse, used in the `gauss_wall` example elixir in combination with
32
[`boundary_condition_wall`](@ref). Uses the global mean values from `equations`.
33
"""
34
function initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D)
35
v1_prime = 0.0
36
v2_prime = 0.0
37
p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25)
38
39
prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...)
40
41
return prim2cons(prim, equations)
42
end
43
initial_condition = initial_condition_gauss_wall
44
45
boundary_conditions = Dict(:OuterCircle => boundary_condition_slip_wall,
46
:InnerCircle1 => boundary_condition_slip_wall,
47
:InnerCircle2 => boundary_condition_slip_wall,
48
:InnerCircle3 => boundary_condition_slip_wall,
49
:InnerCircle4 => boundary_condition_slip_wall,
50
:InnerCircle5 => boundary_condition_slip_wall)
51
52
# A semidiscretization collects data structures and functions for the spatial discretization
53
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
54
boundary_conditions = boundary_conditions)
55
56
###############################################################################
57
# ODE solvers, callbacks etc.
58
59
# Create ODE problem with time span from 0.0 to 300.0
60
tspan = (0.0, 300.0)
61
ode = semidiscretize(semi, tspan)
62
63
# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
64
# and resets the timers
65
summary_callback = SummaryCallback()
66
67
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
68
analysis_callback = AnalysisCallback(semi, interval = 100)
69
70
# The SaveSolutionCallback allows to save the solution to a file in regular intervals
71
save_solution = SaveSolutionCallback(interval = 50, solution_variables = cons2state)
72
73
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
74
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution)
75
76
###############################################################################
77
# run the simulation
78
79
# use a Runge-Kutta method with automatic (error based) time step size control
80
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6,
81
ode_default_options()..., callback = callbacks);
82
83