Skip to content

Commit

Permalink
Added max_abs_speed_naive and max_abs_speed_naive for PolytropicEuler…
Browse files Browse the repository at this point in the history
…Equations2D.
  • Loading branch information
SimonCan committed Jan 31, 2024
1 parent 185b4fc commit 2ff14f5
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/equations/polytropic_euler_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,46 @@ end
return abs(v1) + c, abs(v2) + c
end

# Calculate maximum wave speed for local Lax-Friedrichs-type dissipation as the
# maximum velocity magnitude plus the maximum speed of sound
@inline function max_abs_speed_naive(u_ll, u_rr, orientation::Integer,
equations::PolytropicEulerEquations2D)
rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations)
rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations)

# Get the velocity value in the appropriate direction
if orientation == 1
v_ll = v1_ll
v_rr = v1_rr
else # orientation == 2
v_ll = v2_ll
v_rr = v2_rr
end
# Calculate sound speeds (we have p = kappa * rho^gamma)
c_ll = sqrt(equations.gamma * equations.kappa * rho_ll^(equations.gamma - 1))
c_rr = sqrt(equations.gamma * equations.kappa * rho_rr^(equations.gamma - 1))

λ_max = max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr)
end

@inline function max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector,
equations::PolytropicEulerEquations2D)
rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations)
rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations)

# Calculate normal velocities and sound speed (we have p = kappa * rho^gamma)
# left
v_ll = v1_ll * normal_direction[1] +
v2_ll * normal_direction[2]
c_ll = sqrt(equations.gamma * equations.kappa * rho_ll^(equations.gamma - 1))
# right
v_rr = v1_rr * normal_direction[1] +
v2_rr * normal_direction[2]
c_rr = sqrt(equations.gamma * equations.kappa * rho_rr^(equations.gamma - 1))

return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction)
end

# Convert conservative variables to primitive
@inline function cons2prim(u, equations::PolytropicEulerEquations2D)
rho, rho_v1, rho_v2 = u
Expand Down

0 comments on commit 2ff14f5

Please sign in to comment.