Skip to content

Commit

Permalink
Type stability of self-defined functions from examples (#2122)
Browse files Browse the repository at this point in the history
Co-authored-by: Hendrik Ranocha <[email protected]>
  • Loading branch information
huiyuxie and ranocha authored Oct 22, 2024
1 parent a8967c6 commit 54237d3
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ A medium blast wave taken from
function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D)
# Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave"
# Set up polar coordinates
inicenter = SVector(0.0)
RealT = eltype(x)
inicenter = SVector(0)
x_norm = x[1] - inicenter[1]
r = abs(x_norm)
# The following code is equivalent to
Expand All @@ -28,9 +29,9 @@ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquation
cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm)

# Calculate primitive variables
rho = r > 0.5 ? 1.0 : 1.1691
v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi
p = r > 0.5 ? 1.0E-3 : 1.245
rho = r > 0.5f0 ? one(RealT) : RealT(1.1691)
v1 = r > 0.5f0 ? zero(RealT) : RealT(0.1882) * cos_phi
p = r > 0.5f0 ? RealT(1.0E-3) : RealT(1.245)

return prim2cons(SVector(rho, v1, p), equations)
end
Expand Down

0 comments on commit 54237d3

Please sign in to comment.