Skip to content

Commit

Permalink
modified: examples/column/tvd_fct_advection.jl
Browse files Browse the repository at this point in the history
	modified:   src/Operators/finitedifference.jl
  • Loading branch information
akshaysridhar committed Apr 8, 2024
1 parent 656b9a0 commit 8f5ac73
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions examples/column/tvd_fct_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ function tendency!(yₜ, y, parameters, t)
bottom = Operators.ThirdOrderOneSided(),
top = Operators.ThirdOrderOneSided(),
)
TVDLimitedFlux = Operators.TVDLimitedFlux(
TVDSlopeLimitedFlux = Operators.TVDSlopeLimitedFlux(
bottom = Operators.FirstOrderOneSided(),
top = Operators.FirstOrderOneSided(),
)
@. yₜ.q =
-divf2c(
upwind1(w, y.q) + TVDLimitedFlux(
upwind1(w, y.q) + TVDSlopeLimitedFlux(
upwind3(w, y.q) - upwind1(w, y.q),
y.q,
),
Expand Down Expand Up @@ -116,17 +116,17 @@ for (i, stretch_fn) in enumerate(stretch_fns)
err = norm(q_final .- q_analytic)
rel_mass_err = norm((sum(q_final) - sum(q_init)) / sum(q_init))

@test err 0.25
@test rel_mass_err 10eps()

plot(q_final)
Plots.png(
Plots.plot!(q_analytic, title = "TVD Limited Flux"),
Plots.plot!(q_analytic, title = "TVD Slope-Limited Flux"),
joinpath(
path,
"exact_and_computed_advected_square_wave_TVDLimitedFlux_" *
"exact_and_computed_advected_square_wave_TVDSlopeLimitedFlux_" *
plot_string[i] *
".png",
),
)
@test err 0.25
@test rel_mass_err 10eps()
end
38 changes: 19 additions & 19 deletions src/Operators/finitedifference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1797,7 +1797,7 @@ end

######Limited Flux Methods######
"""
U = TVDLimitedFlux(;boundaries)
U = TVDSlopeLimitedFlux(;boundaries)
U.(𝒜, Φ)
𝒜, following the notation of Durran (Numerical Methods for Fluid
Dynamics, 2ⁿᵈ ed.) is the antidiffusive flux given by
Expand All @@ -1824,15 +1824,15 @@ Supported limiter types are
"""
### Here we define abstract types and specific implementations
### TVD limiters (see, for instance, Durran's notes)
abstract type AbstractTVDLimiter end
struct RZeroLimiter <: AbstractTVDLimiter end
struct RHalfLimiter <: AbstractTVDLimiter end
struct RMaxLimiter <: AbstractTVDLimiter end
struct MinModLimiter <: AbstractTVDLimiter end
struct KorenLimiter <: AbstractTVDLimiter end
struct SuperbeeLimiter <: AbstractTVDLimiter end
struct MonotonizedCentralLimiter <: AbstractTVDLimiter end
struct VanLeerLimiter <: AbstractTVDLimiter end
abstract type AbstractTVDSlopeLimiter end
struct RZeroLimiter <: AbstractTVDSlopeLimiter end
struct RHalfLimiter <: AbstractTVDSlopeLimiter end
struct RMaxLimiter <: AbstractTVDSlopeLimiter end
struct MinModLimiter <: AbstractTVDSlopeLimiter end
struct KorenLimiter <: AbstractTVDSlopeLimiter end
struct SuperbeeLimiter <: AbstractTVDSlopeLimiter end
struct MonotonizedCentralLimiter <: AbstractTVDSlopeLimiter end
struct VanLeerLimiter <: AbstractTVDSlopeLimiter end

@inline function compute_limiter_coeff(r, ::RZeroLimiter)
return zero(eltype(r))
Expand Down Expand Up @@ -1866,17 +1866,17 @@ end
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 TVDSlopeLimitedFlux{BCS} <: AdvectionOperator
bcs::BCS
end

TVDLimitedFlux(; kwargs...) = TVDLimitedFlux(NamedTuple(kwargs))
TVDSlopeLimitedFlux(; kwargs...) = TVDSlopeLimitedFlux(NamedTuple(kwargs))

return_eltype(::TVDLimitedFlux, A, Φ) =
return_eltype(::TVDSlopeLimitedFlux, A, Φ) =
Geometry.Contravariant3Vector{eltype(eltype(A))}

return_space(
::TVDLimitedFlux,
::TVDSlopeLimitedFlux,
A_space::AllFaceFiniteDifferenceSpace,
Φ_space::AllCenterFiniteDifferenceSpace,
) = A_space
Expand All @@ -1891,11 +1891,11 @@ function fct_tvd(Aⱼ₋₁₂, Aⱼ₊₁₂, Aⱼ₊₃₂, ϕⱼ₋₁, ϕⱼ
return Cⱼ₊₁₂ * Aⱼ₊₁₂
end

stencil_interior_width(::TVDLimitedFlux, A_space, Φ_space) =
stencil_interior_width(::TVDSlopeLimitedFlux, A_space, Φ_space) =
((-1, 1), (-half - 1, half + 1))

Base.@propagate_inbounds function stencil_interior(
::TVDLimitedFlux,
::TVDSlopeLimitedFlux,
loc,
space,
idx,
Expand Down Expand Up @@ -1934,10 +1934,10 @@ end
end


boundary_width(::TVDLimitedFlux, ::AbstractBoundaryCondition) = 2
boundary_width(::TVDSlopeLimitedFlux, ::AbstractBoundaryCondition) = 2

Base.@propagate_inbounds function stencil_left_boundary(
::TVDLimitedFlux,
::TVDSlopeLimitedFlux,
bc::FirstOrderOneSided,
loc,
space,
Expand All @@ -1952,7 +1952,7 @@ Base.@propagate_inbounds function stencil_left_boundary(
end

Base.@propagate_inbounds function stencil_right_boundary(
::TVDLimitedFlux,
::TVDSlopeLimitedFlux,
bc::FirstOrderOneSided,
loc,
space,
Expand Down

0 comments on commit 8f5ac73

Please sign in to comment.