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_1d_dgsem #2133

Merged
merged 13 commits into from
Nov 8, 2024
14 changes: 8 additions & 6 deletions examples/tree_1d_dgsem/elixir_advection_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ mesh = TreeMesh(coordinates_min, coordinates_max,
n_cells_max = 30_000, # set maximum capacity of tree data structure
periodicity = true)

function x_trans_periodic(x, domain_length = SVector(2 * pi), center = SVector(0.0))
function x_trans_periodic(x, domain_length = SVector(oftype(x, 2 * pi)),
center = SVector(oftype(x, 0)))
x_normalized = x .- center
x_shifted = x_normalized .% domain_length
x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .*
x_offset = ((x_shifted .< -0.5f0 * domain_length) -
(x_shifted .> 0.5f0 * domain_length)) .*
domain_length
return center + x_shifted + x_offset
end
Expand All @@ -37,11 +39,11 @@ function initial_condition_diffusive_convergence_test(x, t,
x_trans = x_trans_periodic(x - equation.advection_velocity * t)

nu = diffusivity()
c = 0.0
A = 1.0
c = 0
A = 1
L = 2
huiyuxie marked this conversation as resolved.
Show resolved Hide resolved
f = 1 / L
omega = 1.0
f = 1.0f0 / L
huiyuxie marked this conversation as resolved.
Show resolved Hide resolved
omega = 1
scalar = c + A * sin(omega * sum(x_trans)) * exp(-nu * omega^2 * t)
return SVector(scalar)
end
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mesh = TreeMesh(coordinate_min, coordinate_max,

# Discontinuous initial condition (Riemann Problem) leading to a rarefaction fan.
function initial_condition_rarefaction(x, t, equation::InviscidBurgersEquation1D)
scalar = x[1] < 0.5 ? 0.5 : 1.5
scalar = x[1] < 0.5f0 ? 0.5f0 : 1.5f0
huiyuxie marked this conversation as resolved.
Show resolved Hide resolved

return SVector(scalar)
end
Expand Down
Loading