Skip to content

Commit

Permalink
modified: src/Operators/finitedifference.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshay Sridhar authored and Akshay Sridhar committed Apr 5, 2024
1 parent 68e6f2d commit 9ead12b
Showing 1 changed file with 9 additions and 31 deletions.
40 changes: 9 additions & 31 deletions src/Operators/finitedifference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ struct VanLeerLimiter <: AbstractTVDLimiter end
end

@inline function compute_limiter_coeff(r, ::RHalfLimiter)
return one(eltype(r)) * 1/2
return one(eltype(r)) * 1 / 2
end

@inline function compute_limiter_coeff(r, ::RMaxLimiter)
Expand All @@ -1829,26 +1829,22 @@ end
end

@inline function compute_limiter_coeff(r, ::KorenLimiter)
return max(zero(eltype(r)), min(2r, min(1 + 2r/3, 2), 2))
return max(zero(eltype(r)), min(2r, min(1 + 2r / 3, 2), 2))
end

@inline function compute_limiter_coeff(r, ::SuperbeeLimiter)
return max(
zero(eltype(r)),
min(one(eltype(r)), r),
min(2, r)
)
return max(zero(eltype(r)), min(one(eltype(r)), r), min(2, r))
end

@inline function compute_limiter_coeff(r, ::MonotonizedCentralLimiter)
return max(zero(eltype(r)), min(2r, (1+r)/2, 2))
return max(zero(eltype(r)), min(2r, (1 + r) / 2, 2))
end

@inline function compute_limiter_coeff(r, ::VanLeerLimiter)
return (r + abs(r))/(1 + abs(r) + eps(eltype(r)))
return (r + abs(r)) / (1 + abs(r) + eps(eltype(r)))
end
# ??? Do we want to allow flux method types to be determined here?
struct TVDLimitedFlux{BCS} <: AdvectionOperator
struct TVDLimitedFlux{BCS} <: AdvectionOperator
bcs::BCS
end

Expand All @@ -1863,16 +1859,7 @@ return_space(
Φ_space::AllCenterFiniteDifferenceSpace,
) = A_space

function fct_tvd(
Aⱼ₋₁₂,
Aⱼ₊₁₂,
Aⱼ₊₃₂,
ϕⱼ₋₁,
ϕⱼ,
ϕⱼ₊₁,
ϕⱼ₊₂,
rⱼ₊₁₂
)
function fct_tvd(Aⱼ₋₁₂, Aⱼ₊₁₂, Aⱼ₊₃₂, ϕⱼ₋₁, ϕⱼ, ϕⱼ₊₁, ϕⱼ₊₂, rⱼ₊₁₂)
# 1/dt is in ϕⱼ₋₁, ϕⱼ, ϕⱼ₊₁, ϕⱼ₊₂, ϕⱼ₋₁ᵗᵈ, ϕⱼᵗᵈ, ϕⱼ₊₁ᵗᵈ, ϕⱼ₊₂ᵗᵈ
stable_zero = zero(eltype(Aⱼ₊₁₂))
stable_one = one(eltype(Aⱼ₊₁₂))
Expand Down Expand Up @@ -1916,21 +1903,12 @@ Base.@propagate_inbounds function stencil_interior(
rⱼ₊₁₂ = compute_slope_ratio(ϕⱼ, ϕⱼ₋₁, ϕⱼ₊₁)

return Geometry.Contravariant3Vector(
fct_tvd(
Aⱼ₋₁₂,
Aⱼ₊₁₂,
Aⱼ₊₃₂,
ϕⱼ₋₁,
ϕⱼ,
ϕⱼ₊₁,
ϕⱼ₊₂,
rⱼ₊₁₂
),
fct_tvd(Aⱼ₋₁₂, Aⱼ₊₁₂, Aⱼ₊₃₂, ϕⱼ₋₁, ϕⱼ, ϕⱼ₊₁, ϕⱼ₊₂, rⱼ₊₁₂),
)
end

@inline function compute_slope_ratio(ϕⱼ, ϕⱼ₋₁, ϕⱼ₊₁)
return (ϕⱼ - ϕⱼ₋₁)/(ϕⱼ₊₁ - ϕⱼ + eps(eltype(ϕⱼ)))
return (ϕⱼ - ϕⱼ₋₁) / (ϕⱼ₊₁ - ϕⱼ + eps(eltype(ϕⱼ)))
end


Expand Down

0 comments on commit 9ead12b

Please sign in to comment.