Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type stability of functions from examples tree_2d_dgsem #2145

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ A Gaussian pulse, used in the `gauss_wall` example elixir in combination with
[`boundary_condition_wall`](@ref). Uses the global mean values from `equations`.
"""
function initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D)
v1_prime = 0.0
v2_prime = 0.0
p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25)
RealT = eltype(x)
v1_prime = 0
v2_prime = 0
p_prime = exp(-log(convert(RealT, 2)) * (x[1]^2 + (x[2] - 25)^2) / 25)

prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...)

Expand Down
15 changes: 8 additions & 7 deletions examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ using Trixi

# Oscillating Gaussian-shaped source terms
function source_terms_gauss(u, x, t, equations::AcousticPerturbationEquations2D)
r = 0.1
A = 1.0
f = 2.0
RealT = eltype(u)
r = convert(RealT, 0.1)
A = 1
f = 2

# Velocity sources
s1 = 0.0
s2 = 0.0
s1 = 0
s2 = 0
# Pressure source
s3 = exp(-(x[1]^2 + x[2]^2) / (2 * r^2)) * A * sin(2 * pi * f * t)
s3 = exp(-(x[1]^2 + x[2]^2) / (2 * r^2)) * A * sinpi(2 * f * t)

# Mean sources
s4 = s5 = s6 = s7 = 0.0
s4 = s5 = s6 = s7 = 0

return SVector(s1, s2, s3, s4, s5, s6, s7)
end
Expand Down
22 changes: 12 additions & 10 deletions examples/tree_2d_dgsem/elixir_acoustics_monopole.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ Initial condition for the monopole in a boundary layer setup, used in combinatio
[`boundary_condition_monopole`](@ref).
"""
function initial_condition_monopole(x, t, equations::AcousticPerturbationEquations2D)
m = 0.3 # Mach number
RealT = eltype(x)
m = convert(RealT, 0.3) # Mach number

v1_prime = 0.0
v2_prime = 0.0
p_prime = 0.0
v1_prime = 0
v2_prime = 0
p_prime = 0

v1_mean = x[2] > 1 ? m : m * (2 * x[2] - 2 * x[2]^2 + x[2]^4)
v2_mean = 0.0
c_mean = 1.0
rho_mean = 1.0
v2_mean = 0
c_mean = 1
rho_mean = 1

prim = SVector(v1_prime, v2_prime, p_prime, v1_mean, v2_mean, c_mean, rho_mean)

Expand All @@ -48,6 +49,7 @@ with [`initial_condition_monopole`](@ref).
function boundary_condition_monopole(u_inner, orientation, direction, x, t,
surface_flux_function,
equations::AcousticPerturbationEquations2D)
RealT = eltype(u_inner)
if direction != 3
error("expected direction = 3, got $direction instead")
end
Expand All @@ -56,9 +58,9 @@ function boundary_condition_monopole(u_inner, orientation, direction, x, t,
# we use a sinusoidal boundary state for the perturbed variables. For the rest of the -y boundary
# we set the boundary state to the inner state and multiply the perturbed velocity in the
# y-direction by -1.
if -0.05 <= x[1] <= 0.05 # Monopole
v1_prime = 0.0
v2_prime = p_prime = sin(2 * pi * t)
if RealT(-0.05) <= x[1] <= RealT(0.05) # Monopole
v1_prime = 0
v2_prime = p_prime = sinpi(2 * t)

prim_boundary = SVector(v1_prime, v2_prime, p_prime, u_inner[4], u_inner[5],
u_inner[6], u_inner[7])
Expand Down
Loading