Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix positivity preserving WENO #3952

Merged
merged 7 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const ε₂ = 1e-20
# Here in the future we can easily add UpwindBiased
const BoundPreservingScheme = PositiveWENO

@inline div_Uc(i, j, k, grid, advection::BoundPreservingScheme, U, ::ZeroField) = zero(grid)

# Is this immersed-boundary safe without having to extend it in ImmersedBoundaries.jl? I think so... (velocity on immmersed boundaries is masked to 0)
@inline function div_Uc(i, j, k, grid, advection::BoundPreservingScheme, U, c)

Expand Down
4 changes: 4 additions & 0 deletions src/Advection/weno_reconstruction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ function WENO(FT::DataType=Float64;

mod(order, 2) == 0 && throw(ArgumentError("WENO reconstruction scheme is defined only for odd orders"))

if !isnothing(bounds)
@warn "Bounds preserving WENO is experimental."
end

if order < 3
# WENO(order=1) is equivalent to UpwindBiased(order=1)
return UpwindBiased(FT; order=1)
Expand Down
12 changes: 10 additions & 2 deletions test/test_immersed_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ using Oceananigans.Advection:
_biased_interpolate_yᵃᶠᵃ,
FluxFormAdvection

advection_schemes = [Centered, UpwindBiased, WENO]
linear_advection_schemes = [Centered, UpwindBiased]
advection_schemes = [linear_advection_schemes... WENO]

@inline advective_order(buffer, ::Type{Centered}) = buffer * 2
@inline advective_order(buffer, AdvectionType) = buffer * 2 - 1
Expand Down Expand Up @@ -103,12 +104,19 @@ for arch in archs
mask_immersed_field!(c)
fill_halo_regions!(c)

for adv in advection_schemes, buffer in [1, 2, 3, 4, 5]
for adv in linear_advection_schemes, buffer in [1, 2, 3, 4, 5]
scheme = adv(order = advective_order(buffer, adv))

@info " Testing immersed tracer reconstruction [$(typeof(arch)), $(summary(scheme))]"
run_tracer_interpolation_test(c, ibg, scheme)
end

for buffer in [2, 3, 4, 5], bounds in (nothing, (0, 1))
scheme = WENO(; order = advective_order(buffer, WENO), bounds)

@info " Testing immersed tracer reconstruction [$(typeof(arch)), $(summary(scheme))]"
run_tracer_interpolation_test(c, ibg, scheme)
end
end

@testset "Immersed tracer conservation" begin
Expand Down