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

Maximum-principle-satisfying WENO scheme #2557

Merged
merged 21 commits into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
32 changes: 16 additions & 16 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ version = "0.1.2"

[[CUDA]]
deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CompilerSupportLibraries_jll", "ExprTools", "GPUArrays", "GPUCompiler", "LLVM", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "SpecialFunctions", "TimerOutputs"]
git-tree-sha1 = "ba75320aaa092b3e17c020a2d8b9e0a572dbfa6a"
git-tree-sha1 = "bc6de7d0852de77a036a8648823b7edaf5a82852"
uuid = "052768ef-5323-5732-b1bb-66c8b64840ba"
version = "3.9.0"
version = "3.9.1"

[[CUDAKernels]]
deps = ["Adapt", "CUDA", "Cassette", "KernelAbstractions", "SpecialFunctions", "StaticArrays"]
Expand Down Expand Up @@ -270,15 +270,15 @@ version = "0.7.2"

[[LLVM]]
deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"]
git-tree-sha1 = "d7f3db3b5f564016b5dfcc71a20506f8796f403a"
git-tree-sha1 = "c8d47589611803a0f3b4813d9e267cd4e3dbcefb"
uuid = "929cbde3-209d-540e-8aea-75f648917ca0"
version = "4.10.0"
version = "4.11.1"

[[LLVMExtra_jll]]
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg", "TOML"]
git-tree-sha1 = "00d23b26d194507028b9a1c2728a691ab9914262"
git-tree-sha1 = "771bfe376249626d3ca12bcd58ba243d3f961576"
uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
version = "0.0.15+0"
version = "0.0.16+0"

[[LazyArtifacts]]
deps = ["Artifacts", "Pkg"]
Expand Down Expand Up @@ -309,9 +309,9 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[LogExpFunctions]]
deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "76c987446e8d555677f064aaac1145c4c17662f8"
git-tree-sha1 = "09e4b894ce6a976c354a69041a04748180d43637"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.14"
version = "0.3.15"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand Down Expand Up @@ -382,19 +382,19 @@ uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[OffsetArrays]]
deps = ["Adapt"]
git-tree-sha1 = "043017e0bdeff61cfbb7afeb558ab29536bbb5ed"
git-tree-sha1 = "aee446d0b3d5764e35289762f6a18e8ea041a592"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.10.8"
version = "1.11.0"

[[OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"

[[OpenMPI_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"]
git-tree-sha1 = "6340586e076b2abd41f5ba1a3b9c774ec6b30fde"
git-tree-sha1 = "19ec7d0311aa5fb5fe537dc6eeaec86942b64caf"
uuid = "fe0851c0-eecd-5654-98d4-656369965a5c"
version = "4.1.2+0"
version = "4.1.3+0"

[[OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand All @@ -421,9 +421,9 @@ version = "2.3.1"

[[PencilArrays]]
deps = ["Adapt", "ArrayInterface", "JSON3", "LinearAlgebra", "MPI", "OffsetArrays", "Random", "Reexport", "Requires", "StaticArrays", "StaticPermutations", "Strided", "TimerOutputs", "VersionParsing"]
git-tree-sha1 = "690dd0accf18b2a1e26ef10820665f7192dacad3"
git-tree-sha1 = "2e1be06bf6adec16ed04bc5c9c17cb13c81f1ed1"
uuid = "0e08944d-e94e-41b1-9406-dcf66b6a9d2e"
version = "0.16.1"
version = "0.17.0"

[[PencilFFTs]]
deps = ["AbstractFFTs", "FFTW", "LinearAlgebra", "MPI", "PencilArrays", "Reexport", "TimerOutputs"]
Expand Down Expand Up @@ -556,9 +556,9 @@ version = "1.2.2"

[[StructArrays]]
deps = ["Adapt", "DataAPI", "StaticArrays", "Tables"]
git-tree-sha1 = "8f705dd141733d79aa2932143af6c6e0b6cea8df"
git-tree-sha1 = "e75d82493681dfd884a357952bbd7ab0608e1dc3"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.6.6"
version = "0.6.7"

[[StructTypes]]
deps = ["Dates", "UUIDs"]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Oceananigans"
uuid = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
authors = ["Climate Modeling Alliance and contributors"]
version = "0.76.2"
version = "0.76.3"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
1 change: 1 addition & 0 deletions src/Advection/Advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ include("topologically_conditional_interpolation.jl")

include("momentum_advection_operators.jl")
include("tracer_advection_operators.jl")
include("positivity_preserving_tracer_advection_operators.jl")

end # module
94 changes: 94 additions & 0 deletions src/Advection/positivity_preserving_tracer_advection_operators.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using Oceananigans.Grids: AbstractGrid

const ω̂₁ = 5/18
const ω̂ₙ = 5/18
const ε₂ = 1e-20

# Here in the future we can easily add UpwindBiasedFifthOrder
const BoundPreservingScheme = PositiveWENO

@inline function div_Uc(i, j, k, grid, advection::BoundPreservingScheme, U, c)

div_x = bounded_tracer_flux_divergence_x(i, j, k, grid, advection, U.u, c)
div_y = bounded_tracer_flux_divergence_y(i, j, k, grid, advection, U.v, c)
div_z = bounded_tracer_flux_divergence_z(i, j, k, grid, advection, U.w, c)

return 1/Vᶜᶜᶜ(i, j, k, grid) * (div_x + div_y + div_z)
end

# Support for Flat directions
@inline bounded_tracer_flux_divergence_x(i, j, k, ::AbstractGrid{FT, Flat, TY, TZ}, args...) where {FT, TY, TZ} = zero(FT)
@inline bounded_tracer_flux_divergence_y(i, j, k, ::AbstractGrid{FT, TX, Flat, TZ}, args...) where {FT, TX, TZ} = zero(FT)
@inline bounded_tracer_flux_divergence_z(i, j, k, ::AbstractGrid{FT, TX, TY, Flat}, args...) where {FT, TX, TY} = zero(FT)

@inline function bounded_tracer_flux_divergence_x(i, j, k, grid, advection::BoundPreservingScheme, u, c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! It seems like these three funcionts are almost identical except for u -> v -> w. Is that true?

If yes, I wonder if there is away to merge these to one, rather than having three functions that do the same thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indices, areas and interpolations differ. I can try merging it with some metaprogramming

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary. This is maybe cleaner but thought I would make the observation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer having separate functions over metaprogramming in this case.

@francispoulin the difference between x, y, z is that they depend on indices i, j, k respectively. So we also have advective_tracer_flux_x, etc.


lower_limit = advection.bounds[1]
upper_limit = advection.bounds[2]

cᵢⱼ = c[i, j, k]

c₊ᴸ = _left_biased_interpolate_xᶠᵃᵃ(i+1, j, k, grid, advection, c)
c₊ᴿ = _right_biased_interpolate_xᶠᵃᵃ(i+1, j, k, grid, advection, c)
c₋ᴸ = _left_biased_interpolate_xᶠᵃᵃ(i, j, k, grid, advection, c)
c₋ᴿ = _right_biased_interpolate_xᶠᵃᵃ(i, j, k, grid, advection, c)

p̃ = (cᵢⱼ - ω̂₁ * c₋ᴿ - ω̂ₙ * c₊ᴸ) / (1 - 2ω̂₁)
M = max(p̃, c₊ᴸ, c₋ᴿ)
m = min(p̃, c₊ᴸ, c₋ᴿ)
θ = min(abs((upper_limit - cᵢⱼ)/(M - cᵢⱼ + ε₂)), abs((lower_limit - cᵢⱼ)/(m - cᵢⱼ + ε₂)), one(grid))

c₊ᴸ = θ * (c₊ᴸ - cᵢⱼ) + cᵢⱼ
c₋ᴿ = θ * (c₋ᴿ - cᵢⱼ) + cᵢⱼ

return Axᶠᶜᶜ(i+1, j, k, grid) * upwind_biased_product(u[i+1, j, k], c₊ᴸ, c₊ᴿ) -
Axᶠᶜᶜ(i, j, k, grid) * upwind_biased_product(u[i, j, k], c₋ᴸ, c₋ᴿ)
end

@inline function bounded_tracer_flux_divergence_y(i, j, k, grid, advection::BoundPreservingScheme, v, c)

lower_limit = advection.bounds[1]
upper_limit = advection.bounds[2]

cᵢⱼ = c[i, j, k]

c₊ᴸ = _left_biased_interpolate_yᵃᶠᵃ(i, j+1, k, grid, advection, c)
c₊ᴿ = _right_biased_interpolate_yᵃᶠᵃ(i, j+1, k, grid, advection, c)
c₋ᴸ = _left_biased_interpolate_yᵃᶠᵃ(i, j, k, grid, advection, c)
c₋ᴿ = _right_biased_interpolate_yᵃᶠᵃ(i, j, k, grid, advection, c)

p̃ = (cᵢⱼ - ω̂₁ * c₋ᴿ - ω̂ₙ * c₊ᴸ) / (1 - 2ω̂₁)
M = max(p̃, c₊ᴸ, c₋ᴿ)
m = min(p̃, c₊ᴸ, c₋ᴿ)
θ = min(abs((upper_limit - cᵢⱼ)/(M - cᵢⱼ + ε₂)), abs((lower_limit - cᵢⱼ)/(m - cᵢⱼ + ε₂)), one(grid))

c₊ᴸ = θ * (c₊ᴸ - cᵢⱼ) + cᵢⱼ
c₋ᴿ = θ * (c₋ᴿ - cᵢⱼ) + cᵢⱼ

return Ayᶜᶠᶜ(i, j+1, k, grid) * upwind_biased_product(v[i, j+1, k], c₊ᴸ, c₊ᴿ) -
Ayᶜᶠᶜ(i, j, k, grid) * upwind_biased_product(v[i, j, k], c₋ᴸ, c₋ᴿ)
end

@inline function bounded_tracer_flux_divergence_z(i, j, k, grid, advection::BoundPreservingScheme, w, c)

lower_limit = advection.bounds[1]
upper_limit = advection.bounds[2]

cᵢⱼ = c[i, j, k]

c₊ᴸ = _left_biased_interpolate_zᵃᵃᶠ(i, j, k+1, grid, advection, c)
c₊ᴿ = _right_biased_interpolate_zᵃᵃᶠ(i, j, k+1, grid, advection, c)
c₋ᴸ = _left_biased_interpolate_zᵃᵃᶠ(i, j, k, grid, advection, c)
c₋ᴿ = _right_biased_interpolate_zᵃᵃᶠ(i, j, k, grid, advection, c)

p̃ = (cᵢⱼ - ω̂₁ * c₋ᴿ - ω̂ₙ * c₊ᴸ) / (1 - 2ω̂₁)
M = max(p̃, c₊ᴸ, c₋ᴿ)
m = min(p̃, c₊ᴸ, c₋ᴿ)
θ = min(abs((upper_limit - cᵢⱼ)/(M - cᵢⱼ + ε₂)), abs((lower_limit - cᵢⱼ)/(m - cᵢⱼ + ε₂)), 1.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
θ = min(abs((upper_limit - cᵢⱼ)/(M - cᵢⱼ + ε₂)), abs((lower_limit - cᵢⱼ)/(m - cᵢⱼ + ε₂)), 1.0)
θ = min(abs((upper_limit - cᵢⱼ)/(M - cᵢⱼ + ε₂)), abs((lower_limit - cᵢⱼ)/(m - cᵢⱼ + ε₂)), one(grid))


c₊ᴸ = θ * (c₊ᴸ - cᵢⱼ) + cᵢⱼ
c₋ᴿ = θ * (c₋ᴿ - cᵢⱼ) + cᵢⱼ

return Azᶜᶜᶠ(i, j, k+1, grid) * upwind_biased_product(w[i, j, k+1], c₊ᴸ, c₊ᴿ) -
Azᶜᶜᶠ(i, j, k, grid) * upwind_biased_product(w[i, j, k], c₋ᴸ, c₋ᴿ)
end
111 changes: 54 additions & 57 deletions src/Advection/weno_fifth_order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ using KernelAbstractions.Extras.LoopInfo: @unroll
using Adapt
import Base: show

const C3₀ = 3/10
const C3₁ = 3/5
const C3₂ = 1/10

const two_32 = Int32(2)

const ƞ = Int32(2) # WENO exponent
Expand All @@ -26,7 +30,7 @@ Weighted Essentially Non-Oscillatory (WENO) fifth-order advection scheme.

$(TYPEDFIELDS)
"""
struct WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF} <: AbstractUpwindBiasedAdvectionScheme{2}
struct WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP} <: AbstractUpwindBiasedAdvectionScheme{2}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the design we will want when we do #2454 ? If we can avoid digging ourselves into a deeper hole we should, but maybe it's not possible without a lot of effort...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not still completely sure how #2454 will go along, this change only modifies the div_Uc so I guess it might be easy to adapt in the future

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #2454 we will disentangle vector invariant from WENO5, so VI will go away. It might still make sense to blend WENO5 with flux-limited WENO5, however. It's just that if we have nth order WENO, we would also have to figure out how to do nth order flux limited WENO if they are entangled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the limiter will be independent on the order of the original scheme. You always want to blend your scheme into a first order upwind (when crossing bounds)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, great!


"coefficient for ENO reconstruction on x-faces"
coeff_xᶠᵃᵃ::XT
Expand Down Expand Up @@ -54,22 +58,20 @@ struct WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF} <: AbstractUpwindBiasedAdvectio
"coefficient for WENO smoothness indicators on z-centers"
smooth_zᵃᵃᶜ::ZS

"coefficient for WENO reconstruction, optimal weights"
C3₀ :: FT
C3₁ :: FT
C3₂ :: FT
"bounds for maximum-principle-satisfying WENO scheme"
bounds :: PP

function WENO5{VI, WF}(coeff_xᶠᵃᵃ::XT, coeff_xᶜᵃᵃ::XT,
coeff_yᵃᶠᵃ::YT, coeff_yᵃᶜᵃ::YT,
coeff_zᵃᵃᶠ::ZT, coeff_zᵃᵃᶜ::ZT,
smooth_xᶠᵃᵃ::XS, smooth_xᶜᵃᵃ::XS,
smooth_yᵃᶠᵃ::YS, smooth_yᵃᶜᵃ::YS,
smooth_zᵃᵃᶠ::ZS, smooth_zᵃᵃᶜ::ZS,
C3₀::FT, C3₁::FT, C3₂::FT) where {FT, XT, YT, ZT, XS, YS, ZS, VI, WF}

return new{FT, XT, YT, ZT, XS, YS, ZS, VI, WF}(coeff_xᶠᵃᵃ, coeff_xᶜᵃᵃ, coeff_yᵃᶠᵃ, coeff_yᵃᶜᵃ, coeff_zᵃᵃᶠ, coeff_zᵃᵃᶜ,
smooth_xᶠᵃᵃ, smooth_xᶜᵃᵃ, smooth_yᵃᶠᵃ, smooth_yᵃᶜᵃ, smooth_zᵃᵃᶠ, smooth_zᵃᵃᶜ,
C3₀, C3₁, C3₂)
function WENO5{FT, VI, WF}(coeff_xᶠᵃᵃ::XT, coeff_xᶜᵃᵃ::XT,
coeff_yᵃᶠᵃ::YT, coeff_yᵃᶜᵃ::YT,
coeff_zᵃᵃᶠ::ZT, coeff_zᵃᵃᶜ::ZT,
smooth_xᶠᵃᵃ::XS, smooth_xᶜᵃᵃ::XS,
smooth_yᵃᶠᵃ::YS, smooth_yᵃᶜᵃ::YS,
smooth_zᵃᵃᶠ::ZS, smooth_zᵃᵃᶜ::ZS,
bounds::PP) where {FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP}

return new{FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP}(coeff_xᶠᵃᵃ, coeff_xᶜᵃᵃ, coeff_yᵃᶠᵃ, coeff_yᵃᶜᵃ, coeff_zᵃᵃᶠ, coeff_zᵃᵃᶜ,
smooth_xᶠᵃᵃ, smooth_xᶜᵃᵃ, smooth_yᵃᶠᵃ, smooth_yᵃᶜᵃ, smooth_zᵃᵃᶠ, smooth_zᵃᵃᶜ,
bounds)
end
end

Expand Down Expand Up @@ -161,26 +163,20 @@ WENO5(grid, FT::DataType=Float64; kwargs...) = WENO5(FT; grid = grid, kwargs...)

function WENO5(FT::DataType = Float64;
grid = nothing,
coeffs = nothing,
stretched_smoothness = false,
zweno = true,
vector_invariant = nothing)
vector_invariant = nothing,
bounds = nothing)

if !(grid isa Nothing)
FT = eltype(grid)
end

weno_coefficients = compute_stretched_weno_coefficients(grid, stretched_smoothness, FT)

if coeffs isa Nothing
C3₀, C3₁, C3₂ = FT.((3/10, 3/5, 1/10))
else
C3₀, C3₁, C3₂ = FT.(coeffs)
end

VI = typeof(vector_invariant)

return WENO5{VI, zweno}(weno_coefficients..., C3₀, C3₁, C3₂)
return WENO5{FT, VI, zweno}(weno_coefficients..., bounds)
end

function compute_stretched_weno_coefficients(grid, stretched_smoothness, FT)
Expand Down Expand Up @@ -216,14 +212,15 @@ return_metrics(::LatitudeLongitudeGrid) = (:λᶠᵃᵃ, :λᶜᵃᵃ, :φᵃᶠ
return_metrics(::RectilinearGrid) = (:xᶠᵃᵃ, :xᶜᵃᵃ, :yᵃᶠᵃ, :yᵃᶜᵃ, :zᵃᵃᶠ, :zᵃᵃᶜ)

# Flavours of WENO
const ZWENO = WENO5{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, true}
const ZWENO = WENO5{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, true}
const PositiveWENO = WENO5{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Tuple}

const WENOVectorInvariantVel{FT, XT, YT, ZT, XS, YS, ZS, VI, WF} =
WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF} where {FT, XT, YT, ZT, XS, YS, ZS, VI<:VelocityStencil, WF}
const WENOVectorInvariantVort{FT, XT, YT, ZT, XS, YS, ZS, VI, WF} =
WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF} where {FT, XT, YT, ZT, XS, YS, ZS, VI<:VorticityStencil, WF}
const WENOVectorInvariantVel{FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP} =
WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP} where {FT, XT, YT, ZT, XS, YS, ZS, VI<:VelocityStencil, WF, PP}
const WENOVectorInvariantVort{FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP} =
WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP} where {FT, XT, YT, ZT, XS, YS, ZS, VI<:VorticityStencil, WF, PP}

const WENOVectorInvariant = WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF} where {FT, XT, YT, ZT, XS, YS, ZS, VI<:SmoothnessStencil, WF}
const WENOVectorInvariant = WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP} where {FT, XT, YT, ZT, XS, YS, ZS, VI<:SmoothnessStencil, WF, PP}

function Base.show(io::IO, a::WENO5{FT, RX, RY, RZ}) where {FT, RX, RY, RZ}
print(io, "WENO5 advection scheme with: \n",
Expand All @@ -232,14 +229,14 @@ function Base.show(io::IO, a::WENO5{FT, RX, RY, RZ}) where {FT, RX, RY, RZ}
" └── Z $(RZ == Nothing ? "regular" : "stretched")" )
end

Adapt.adapt_structure(to, scheme::WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF}) where {FT, XT, YT, ZT, XS, YS, ZS, VI, WF} =
WENO5{VI, WF}(Adapt.adapt(to, scheme.coeff_xᶠᵃᵃ), Adapt.adapt(to, scheme.coeff_xᶜᵃᵃ),
Adapt.adapt(to, scheme.coeff_yᵃᶠᵃ), Adapt.adapt(to, scheme.coeff_yᵃᶜᵃ),
Adapt.adapt(to, scheme.coeff_zᵃᵃᶠ), Adapt.adapt(to, scheme.coeff_zᵃᵃᶜ),
Adapt.adapt(to, scheme.smooth_xᶠᵃᵃ), Adapt.adapt(to, scheme.smooth_xᶜᵃᵃ),
Adapt.adapt(to, scheme.smooth_yᵃᶠᵃ), Adapt.adapt(to, scheme.smooth_yᵃᶜᵃ),
Adapt.adapt(to, scheme.smooth_zᵃᵃᶠ), Adapt.adapt(to, scheme.smooth_zᵃᵃᶜ),
scheme.C3₀, scheme.C3₁, scheme.C3₂)
Adapt.adapt_structure(to, scheme::WENO5{FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP}) where {FT, XT, YT, ZT, XS, YS, ZS, VI, WF, PP} =
WENO5{FT, VI, WF}(Adapt.adapt(to, scheme.coeff_xᶠᵃᵃ), Adapt.adapt(to, scheme.coeff_xᶜᵃᵃ),
Adapt.adapt(to, scheme.coeff_yᵃᶠᵃ), Adapt.adapt(to, scheme.coeff_yᵃᶜᵃ),
Adapt.adapt(to, scheme.coeff_zᵃᵃᶠ), Adapt.adapt(to, scheme.coeff_zᵃᵃᶜ),
Adapt.adapt(to, scheme.smooth_xᶠᵃᵃ), Adapt.adapt(to, scheme.smooth_xᶜᵃᵃ),
Adapt.adapt(to, scheme.smooth_yᵃᶠᵃ), Adapt.adapt(to, scheme.smooth_yᵃᶜᵃ),
Adapt.adapt(to, scheme.smooth_zᵃᵃᶠ), Adapt.adapt(to, scheme.smooth_zᵃᵃᶜ),
Adapt.adapt(to, scheme.bounds))

@inline boundary_buffer(::WENO5) = 2

Expand Down Expand Up @@ -391,13 +388,13 @@ for (side, coeffs) in zip([:left, :right], ([:C3₀, :C3₁, :C3₂], [:C3₂, :

if scheme isa ZWENO
τ₅ = abs(β₂ - β₀)
α₀ = scheme.$(coeffs[1]) * (1 + (τ₅ / (β₀ + FT(ε)))^ƞ)
α₁ = scheme.$(coeffs[2]) * (1 + (τ₅ / (β₁ + FT(ε)))^ƞ)
α₂ = scheme.$(coeffs[3]) * (1 + (τ₅ / (β₂ + FT(ε)))^ƞ)
α₀ = FT($(coeffs[1])) * (1 + (τ₅ / (β₀ + FT(ε)))^ƞ)
α₁ = FT($(coeffs[2])) * (1 + (τ₅ / (β₁ + FT(ε)))^ƞ)
α₂ = FT($(coeffs[3])) * (1 + (τ₅ / (β₂ + FT(ε)))^ƞ)
else
α₀ = scheme.$(coeffs[1]) / (β₀ + FT(ε))^ƞ
α₁ = scheme.$(coeffs[2]) / (β₁ + FT(ε))^ƞ
α₂ = scheme.$(coeffs[3]) / (β₂ + FT(ε))^ƞ
α₀ = FT($(coeffs[1])) / (β₀ + FT(ε))^ƞ
α₁ = FT($(coeffs[2])) / (β₁ + FT(ε))^ƞ
α₂ = FT($(coeffs[3])) / (β₂ + FT(ε))^ƞ
end

Σα = α₀ + α₁ + α₂
Expand Down Expand Up @@ -428,13 +425,13 @@ for (side, coeffs) in zip([:left, :right], ([:C3₀, :C3₁, :C3₂], [:C3₂, :

if scheme isa ZWENO
τ₅ = abs(β₂ - β₀)
α₀ = scheme.$(coeffs[1]) * (1 + (τ₅ / (β₀ + FT(ε)))^ƞ)
α₁ = scheme.$(coeffs[2]) * (1 + (τ₅ / (β₁ + FT(ε)))^ƞ)
α₂ = scheme.$(coeffs[3]) * (1 + (τ₅ / (β₂ + FT(ε)))^ƞ)
α₀ = FT($(coeffs[1])) * (1 + (τ₅ / (β₀ + FT(ε)))^ƞ)
α₁ = FT($(coeffs[2])) * (1 + (τ₅ / (β₁ + FT(ε)))^ƞ)
α₂ = FT($(coeffs[3])) * (1 + (τ₅ / (β₂ + FT(ε)))^ƞ)
else
α₀ = scheme.$(coeffs[1]) / (β₀ + FT(ε))^ƞ
α₁ = scheme.$(coeffs[2]) / (β₁ + FT(ε))^ƞ
α₂ = scheme.$(coeffs[3]) / (β₂ + FT(ε))^ƞ
α₀ = FT($(coeffs[1])) / (β₀ + FT(ε))^ƞ
α₁ = FT($(coeffs[2])) / (β₁ + FT(ε))^ƞ
α₂ = FT($(coeffs[3])) / (β₂ + FT(ε))^ƞ
end

Σα = α₀ + α₁ + α₂
Expand All @@ -456,13 +453,13 @@ for (side, coeffs) in zip([:left, :right], ([:C3₀, :C3₁, :C3₂], [:C3₂, :

if scheme isa ZWENO
τ₅ = abs(β₂ - β₀)
α₀ = scheme.$(coeffs[1]) * (1 + (τ₅ / (β₀ + FT(ε)))^ƞ)
α₁ = scheme.$(coeffs[2]) * (1 + (τ₅ / (β₁ + FT(ε)))^ƞ)
α₂ = scheme.$(coeffs[3]) * (1 + (τ₅ / (β₂ + FT(ε)))^ƞ)
α₀ = FT($(coeffs[1])) * (1 + (τ₅ / (β₀ + FT(ε)))^ƞ)
α₁ = FT($(coeffs[2])) * (1 + (τ₅ / (β₁ + FT(ε)))^ƞ)
α₂ = FT($(coeffs[3])) * (1 + (τ₅ / (β₂ + FT(ε)))^ƞ)
else
α₀ = scheme.$(coeffs[1]) / (β₀ + FT(ε))^ƞ
α₁ = scheme.$(coeffs[2]) / (β₁ + FT(ε))^ƞ
α₂ = scheme.$(coeffs[3]) / (β₂ + FT(ε))^ƞ
α₀ = FT($(coeffs[1])) / (β₀ + FT(ε))^ƞ
α₁ = FT($(coeffs[2])) / (β₁ + FT(ε))^ƞ
α₂ = FT($(coeffs[3])) / (β₂ + FT(ε))^ƞ
end

Σα = α₀ + α₁ + α₂
Expand Down