From cc6dd3130e38243e108b12fc5a1263005cda1906 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Thu, 19 Dec 2024 15:31:31 -0500 Subject: [PATCH] Fix names, move constraint outside of BCs --- src/Operators/finitedifference.jl | 14 ++++++++------ .../finitedifference/convergence_column.jl | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Operators/finitedifference.jl b/src/Operators/finitedifference.jl index 6ee14aa8f2..a7dce22e0b 100644 --- a/src/Operators/finitedifference.jl +++ b/src/Operators/finitedifference.jl @@ -1341,8 +1341,9 @@ cases (discussed in Lin et al (1994)) include setting the 𝜙_min = 0 or 𝜙_m saturation mixing ratio for water vapor are not considered here in favour of the generalized local extrema in equation (5a, 5b). """ -struct LinVanLeerC2F{BCS} <: AdvectionOperator +struct LinVanLeerC2F{BCS, C} <: AdvectionOperator bcs::BCS + constraint::C end abstract type LimiterConstraint end struct AlgebraicMean <: LimiterConstraint end @@ -1350,7 +1351,8 @@ struct PositiveDefinite <: LimiterConstraint end struct MonotoneHarmonic <: LimiterConstraint end struct MonotoneLocalExtrema <: LimiterConstraint end -LinVanLeerC2F(; kwargs...) = LinVanLeerC2F(NamedTuple(kwargs)) +LinVanLeerC2F(; constraint, kwargs...) = + LinVanLeerC2F(NamedTuple(kwargs), constraint) return_eltype(::LinVanLeerC2F, V, A, dt) = Geometry.Contravariant3Vector{eltype(eltype(V))} @@ -1395,16 +1397,16 @@ function compute_Δ𝛼_linvanleer(a⁻, a⁰, a⁺, v, dt, ::AlgebraicMean) return ((a⁰ - a⁻) + (a⁺ - a⁰)) / 2 * (1 - sign(v) * v * dt) end -function slope_limited_product(v, a⁻, a⁻⁻, a⁺, a⁺⁺, dt, method) +function slope_limited_product(v, a⁻, a⁻⁻, a⁺, a⁺⁺, dt, constraint) # Following Lin et al. (1994) # https://doi.org/10.1175/1520-0493(1994)122<1575:ACOTVL>2.0.CO;2 if v >= 0 # Eqn (2,5a,5b,5c) - Δ𝛼 = compute_Δ𝛼_linvanleer(a⁻⁻, a⁻, a⁺, v, dt, method) + Δ𝛼 = compute_Δ𝛼_linvanleer(a⁻⁻, a⁻, a⁺, v, dt, constraint) return v ⊠ (a⁻ ⊞ RecursiveApply.rdiv(Δ𝛼, 2)) else # Eqn (2,5a,5b,5c) - Δ𝛼 = compute_Δ𝛼_linvanleer(a⁻, a⁺, a⁺⁺, v, dt, method) + Δ𝛼 = compute_Δ𝛼_linvanleer(a⁻, a⁺, a⁺⁺, v, dt, constraint) return v ⊠ (a⁺ ⊟ RecursiveApply.rdiv(Δ𝛼, 2)) end end @@ -1431,7 +1433,7 @@ Base.@propagate_inbounds function stencil_interior( Geometry.LocalGeometry(space, idx, hidx), ) return Geometry.Contravariant3Vector( - slope_limited_product(vᶠ, a⁻, a⁻⁻, a⁺, a⁺⁺, dt, op.bcs.method), + slope_limited_product(vᶠ, a⁻, a⁻⁻, a⁺, a⁺⁺, dt, op.constraint), ) end diff --git a/test/Operators/finitedifference/convergence_column.jl b/test/Operators/finitedifference/convergence_column.jl index 1dea171741..8a647bb67d 100644 --- a/test/Operators/finitedifference/convergence_column.jl +++ b/test/Operators/finitedifference/convergence_column.jl @@ -718,7 +718,7 @@ end SLMethod = Operators.LinVanLeerC2F( bottom = Operators.FirstOrderOneSided(), top = Operators.FirstOrderOneSided(), - method = Operators.Mono5(), + constraint = Operators.MonotoneLocalExtrema(), ) divf2c = Operators.DivergenceF2C() @@ -771,10 +771,10 @@ end # c = sin(z), scalar field defined at the centers c = sin.(centers) - SLMethod = Operators.LinVanLeerC2F( + SLMethod = Operators.LinVanLeerC2F(; bottom = Operators.FirstOrderOneSided(), top = Operators.FirstOrderOneSided(), - method = Operators.MonotoneHarmonic(), + constraint = Operators.MonotoneHarmonic(), ) divf2c = Operators.DivergenceF2C() @@ -830,7 +830,7 @@ end SLMethod = Operators.LinVanLeerC2F( bottom = Operators.FirstOrderOneSided(), top = Operators.FirstOrderOneSided(), - method = Operators.PosDef(), + constraint = Operators.PositiveDefinite(), ) divf2c = Operators.DivergenceF2C()