Skip to content

Commit

Permalink
avoid if
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring committed Mar 22, 2024
1 parent 08bd818 commit b0d2c6e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/equations/compressible_navier_stokes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ Under `GradientVariablesEntropy`, the Navier-Stokes discretization is provably e
"""
struct GradientVariablesPrimitive end
struct GradientVariablesEntropy end

dynamic_viscosity(u, equations) = dynamic_viscosity(u, equations.mu, equations)
dynamic_viscosity(u, mu::Real, equations) = mu
dynamic_viscosity(u, mu::T, equations) where {T} = mu(u, equations)
8 changes: 1 addition & 7 deletions src/equations/compressible_navier_stokes_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,7 @@ function flux(u, gradients, orientation::Integer,
# In the simplest cases, the user passed in `mu` or `mu()`
# (which returns just a constant) but
# more complex functions like Sutherland's law are possible.
if equations.mu isa Real
mu = equations.mu
else
# The equations are equipped with a function that computes the dynamic viscosity mu
# from the current state.
mu = equations.mu(u, equations)
end
mu = dynamic_viscosity(u, equations)

# viscous flux components in the x-direction
f1 = zero(rho)
Expand Down
8 changes: 1 addition & 7 deletions src/equations/compressible_navier_stokes_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,7 @@ function flux(u, gradients, orientation::Integer,
# In the simplest cases, the user passed in `mu` or `mu()`
# (which returns just a constant) but
# more complex functions like Sutherland's law are possible.
if equations.mu isa Real
mu = equations.mu
else
# The equations are equipped with a function that computes the dynamic viscosity mu
# from the current state.
mu = equations.mu(u, equations)
end
mu = dynamic_viscosity(u, equations)

if orientation == 1
# viscous flux components in the x-direction
Expand Down
8 changes: 1 addition & 7 deletions src/equations/compressible_navier_stokes_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,7 @@ function flux(u, gradients, orientation::Integer,
# In the simplest cases, the user passed in `mu` or `mu()`
# (which returns just a constant) but
# more complex functions like Sutherland's law are possible.
if equations.mu isa Real
mu = equations.mu
else
# The equations are equipped with a function that computes the dynamic viscosity mu
# from the current state.
mu = equations.mu(u, equations)
end
mu = dynamic_viscosity(u, equations)

if orientation == 1
# viscous flux components in the x-direction
Expand Down

0 comments on commit b0d2c6e

Please sign in to comment.