From 0c09c1fd588b2894d56f23a74dca267934b75b7e Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Fri, 18 Oct 2024 15:56:57 +0200 Subject: [PATCH 01/11] allow vector invariant form --- ...t_scalar_biharmonic_diffusivity_closure.jl | 39 +++++++++++-------- .../scalar_biharmonic_diffusivity.jl | 13 ++++--- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl index 357970226a..8791721888 100644 --- a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl +++ b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl @@ -5,12 +5,14 @@ using Oceananigans.Grids: peripheral_node Abstract type for closures with scalar biharmonic diffusivities. """ -abstract type AbstractScalarBiharmonicDiffusivity{F, N} <: AbstractTurbulenceClosure{ExplicitTimeDiscretization, N} end +abstract type AbstractScalarBiharmonicDiffusivity{F, N, V} <: AbstractTurbulenceClosure{ExplicitTimeDiscretization, N} end @inline formulation(::AbstractScalarBiharmonicDiffusivity{F}) where {F} = F() const ASBD = AbstractScalarBiharmonicDiffusivity +const VectorInvariantASBD = AbstractScalarBiharmonicDiffusivity{<:HorizontalFormulation, <:Nothing, <:VectorInvariantForm} + ##### ##### Coefficient extractors ##### @@ -71,27 +73,30 @@ const AVBD = AbstractScalarBiharmonicDiffusivity{<:VerticalFormulation} ##### Biharmonic-specific viscous operators ##### -# See https://mitgcm.readthedocs.io/en/latest/algorithm/algorithm.html#horizontal-dissipation -@inline function δ★ᶜᶜᶜ(i, j, k, grid, u, v) +@inline ∇²_vector_invariantᶠᶜᶜ(i, j, k, grid, u, v) = δxᶠᶜᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) - δyᶠᶜᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) +@inline ∇²_vector_invariantᶜᶠᶜ(i, j, k, grid, u, v) = δxᶜᶠᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) - δyᶜᶠᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) - # These closures seem to be needed to help the compiler infer types - # (either of u and v or of the function arguments) - @inline Δy_∇²u(i, j, k, grid, u) = Δy_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²hᶠᶜᶜ, u) - @inline Δx_∇²v(i, j, k, grid, v) = Δx_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²hᶜᶠᶜ, v) +# These closures seem to be needed to help the compiler infer types +# (either of u and v or of the function arguments) +@inline Δy_∇²u(i, j, k, grid, closure, u, v) = Δy_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²hᶠᶜᶜ, u) +@inline Δx_∇²v(i, j, k, grid, closure, u, v) = Δx_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²hᶜᶠᶜ, v) - return 1 / Azᶜᶜᶜ(i, j, k, grid) * (δxᶜᵃᵃ(i, j, k, grid, Δy_∇²u, u) + - δyᵃᶜᵃ(i, j, k, grid, Δx_∇²v, v)) -end +# These closures seem to be needed to help the compiler infer types +# (either of u and v or of the function arguments) +@inline Δy_∇²u(i, j, k, grid, ::VectorInvariantASBD, u, v) = Δy_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²_vector_invariantᶠᶜᶜ, u, v) +@inline Δx_∇²v(i, j, k, grid, ::VectorInvariantASBD, u, v) = Δx_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²_vector_invariantᶜᶠᶜ, u, v) -@inline function ζ★ᶠᶠᶜ(i, j, k, grid, u, v) +# See https://mitgcm.readthedocs.io/en/latest/algorithm/algorithm.html#horizontal-dissipation +@inline function δ★ᶜᶜᶜ(i, j, k, grid, closure, u, v) + + return 1 / Azᶜᶜᶜ(i, j, k, grid) * (δxᶜᵃᵃ(i, j, k, grid, Δy_∇²u, closure, u, v) + + δyᵃᶜᵃ(i, j, k, grid, Δx_∇²v, closure, u, v)) +end - # These closures seem to be needed to help the compiler infer types - # (either of u and v or of the function arguments) - @inline Δy_∇²v(i, j, k, grid, v) = Δy_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²hᶜᶠᶜ, v) - @inline Δx_∇²u(i, j, k, grid, u) = Δx_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²hᶠᶜᶜ, u) +@inline function ζ★ᶠᶠᶜ(i, j, k, grid, closure, u, v) - return 1 / Azᶠᶠᶜ(i, j, k, grid) * (δxᶠᵃᵃ(i, j, k, grid, Δy_∇²v, v) - - δyᵃᶠᵃ(i, j, k, grid, Δx_∇²u, u)) + return 1 / Azᶠᶠᶜ(i, j, k, grid) * (δxᶠᵃᵃ(i, j, k, grid, Δy_∇²v, closure, u, v) - + δyᵃᶠᵃ(i, j, k, grid, Δx_∇²u, closure, u, v)) end ##### diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 003fabbeea..5760c58134 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -6,10 +6,10 @@ using Oceananigans.Utils: prettysummary Holds viscosity and diffusivities for models with prescribed isotropic diffusivities. """ -struct ScalarBiharmonicDiffusivity{F, N, V, K} <: AbstractScalarBiharmonicDiffusivity{F, N} +struct ScalarBiharmonicDiffusivity{F, N, VI, V, K} <: AbstractScalarBiharmonicDiffusivity{F, N, VI} ν :: V κ :: K - ScalarBiharmonicDiffusivity{F, N}(ν::V, κ::K) where {F, V, K, N} = new{F, N, V, K}(ν, κ) + ScalarBiharmonicDiffusivity{F, N, VI}(ν::V, κ::K) where {F, V, K, N} = new{F, N, V, K}(ν, κ) end # Aliases that allow specify the floating type, assuming that the discretization is Explicit in time @@ -76,21 +76,24 @@ function ScalarBiharmonicDiffusivity(formulation = ThreeDimensionalFormulation() ν = 0, κ = 0, discrete_form = false, + vector_invariant_form = true, loc = (nothing, nothing, nothing), parameters = nothing, required_halo_size::Int = 2) ν = convert_diffusivity(FT, ν; discrete_form, loc, parameters) κ = convert_diffusivity(FT, κ; discrete_form, loc, parameters) - + + VI = vector_invariant_form ? VectorInvariantForm : nothing + # Force a type-stable constructor if ν and κ are numbers # This particular short-circuiting of the required_halo_size kwargs is necessary to perform parameter # estimation of the diffusivity coefficients using autodiff. if ν isa Number && κ isa Number - return ScalarBiharmonicDiffusivity{typeof(formulation), 2}(ν, κ) + return ScalarBiharmonicDiffusivity{typeof(formulation), 2, VI}(ν, κ) end - return ScalarBiharmonicDiffusivity{typeof(formulation), required_halo_size}(ν, κ) + return ScalarBiharmonicDiffusivity{typeof(formulation), required_halo_size, VI}(ν, κ) end function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, V, K}) where {F, N, V, K} From 1a726588705e6825c2c90b6c06d303bc116b1f73 Mon Sep 17 00:00:00 2001 From: Sid Date: Fri, 18 Oct 2024 16:49:35 -0400 Subject: [PATCH 02/11] =?UTF-8?q?Rename=20Laplacian=20operators=20and=20co?= =?UTF-8?q?rrect=20=E2=88=87=C2=B2v=20formula?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstract_scalar_biharmonic_diffusivity_closure.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl index 8791721888..c37907c032 100644 --- a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl +++ b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl @@ -73,8 +73,8 @@ const AVBD = AbstractScalarBiharmonicDiffusivity{<:VerticalFormulation} ##### Biharmonic-specific viscous operators ##### -@inline ∇²_vector_invariantᶠᶜᶜ(i, j, k, grid, u, v) = δxᶠᶜᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) - δyᶠᶜᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) -@inline ∇²_vector_invariantᶜᶠᶜ(i, j, k, grid, u, v) = δxᶜᶠᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) - δyᶜᶠᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) +@inline ∇²u_vector_invariantᶠᶜᶜ(i, j, k, grid, u, v) = δxᶠᶜᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) - δyᶠᶜᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) +@inline ∇²v_vector_invariantᶜᶠᶜ(i, j, k, grid, u, v) = δxᶜᶠᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) + δyᶜᶠᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) # These closures seem to be needed to help the compiler infer types # (either of u and v or of the function arguments) @@ -83,8 +83,8 @@ const AVBD = AbstractScalarBiharmonicDiffusivity{<:VerticalFormulation} # These closures seem to be needed to help the compiler infer types # (either of u and v or of the function arguments) -@inline Δy_∇²u(i, j, k, grid, ::VectorInvariantASBD, u, v) = Δy_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²_vector_invariantᶠᶜᶜ, u, v) -@inline Δx_∇²v(i, j, k, grid, ::VectorInvariantASBD, u, v) = Δx_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²_vector_invariantᶜᶠᶜ, u, v) +@inline Δy_∇²u(i, j, k, grid, ::VectorInvariantASBD, u, v) = Δy_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²u_vector_invariantᶠᶜᶜ, u, v) +@inline Δx_∇²v(i, j, k, grid, ::VectorInvariantASBD, u, v) = Δx_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²v_vector_invariantᶜᶠᶜ, u, v) # See https://mitgcm.readthedocs.io/en/latest/algorithm/algorithm.html#horizontal-dissipation @inline function δ★ᶜᶜᶜ(i, j, k, grid, closure, u, v) From 116aed21c35fa422a0c3fbd68f74f929629726a5 Mon Sep 17 00:00:00 2001 From: Sid Date: Fri, 18 Oct 2024 17:29:45 -0400 Subject: [PATCH 03/11] =?UTF-8?q?Define=20vector-invariant=20=CE=B6?= =?UTF-8?q?=E2=98=85=E1=B6=A0=E1=B6=A0=E1=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstract_scalar_biharmonic_diffusivity_closure.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl index c37907c032..3fbbd8f598 100644 --- a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl +++ b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl @@ -88,17 +88,21 @@ const AVBD = AbstractScalarBiharmonicDiffusivity{<:VerticalFormulation} # See https://mitgcm.readthedocs.io/en/latest/algorithm/algorithm.html#horizontal-dissipation @inline function δ★ᶜᶜᶜ(i, j, k, grid, closure, u, v) - return 1 / Azᶜᶜᶜ(i, j, k, grid) * (δxᶜᵃᵃ(i, j, k, grid, Δy_∇²u, closure, u, v) + δyᵃᶜᵃ(i, j, k, grid, Δx_∇²v, closure, u, v)) end @inline function ζ★ᶠᶠᶜ(i, j, k, grid, closure, u, v) - return 1 / Azᶠᶠᶜ(i, j, k, grid) * (δxᶠᵃᵃ(i, j, k, grid, Δy_∇²v, closure, u, v) - δyᵃᶠᵃ(i, j, k, grid, Δx_∇²u, closure, u, v)) end +@inline function ζ★ᶠᶠᶜ(i, j, k, grid, ::VectorInvariantASBD, u, v) + ∇²u = ∇²u_vector_invariantᶠᶜᶜ(i, j, k, grid, u, v) + ∇²v = ∇²v_vector_invariantᶜᶠᶜ(i, j, k, grid, u, v) + return ζ₃ᶠᶠᶜ(i, j, k, grid, ∇²u, ∇²v) +end + ##### ##### Biharmonic-specific diffusion operators ##### From 8a1f70ed478cfb56119abbcf0794a6a6b490d5ef Mon Sep 17 00:00:00 2001 From: Sid Date: Fri, 18 Oct 2024 19:33:51 -0400 Subject: [PATCH 04/11] Define VectorInvariantForm struct and fix bugs --- .../abstract_scalar_biharmonic_diffusivity_closure.jl | 2 +- .../abstract_scalar_diffusivity_closure.jl | 7 +++++++ .../scalar_biharmonic_diffusivity.jl | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl index 3fbbd8f598..8e97e0bbfb 100644 --- a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl +++ b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl @@ -5,7 +5,7 @@ using Oceananigans.Grids: peripheral_node Abstract type for closures with scalar biharmonic diffusivities. """ -abstract type AbstractScalarBiharmonicDiffusivity{F, N, V} <: AbstractTurbulenceClosure{ExplicitTimeDiscretization, N} end +abstract type AbstractScalarBiharmonicDiffusivity{F, N, VI} <: AbstractTurbulenceClosure{ExplicitTimeDiscretization, N} end @inline formulation(::AbstractScalarBiharmonicDiffusivity{F}) where {F} = F() diff --git a/src/TurbulenceClosures/abstract_scalar_diffusivity_closure.jl b/src/TurbulenceClosures/abstract_scalar_diffusivity_closure.jl index 01e322645d..20b7e66679 100644 --- a/src/TurbulenceClosures/abstract_scalar_diffusivity_closure.jl +++ b/src/TurbulenceClosures/abstract_scalar_diffusivity_closure.jl @@ -27,6 +27,13 @@ Specifies a horizontally-isotropic, `VectorInvariant`, `ScalarDiffusivity`. """ struct HorizontalFormulation <: AbstractDiffusivityFormulation end +""" + struct VectorInvariantForm end + +Specifies a `VectorInvariant` `ScalarDiffusivity`. +""" +struct VectorInvariantForm <: AbstractDiffusivityFormulation end + """ struct HorizontalDivergenceFormulation end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 5760c58134..3fdd1bee50 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -9,7 +9,7 @@ Holds viscosity and diffusivities for models with prescribed isotropic diffusivi struct ScalarBiharmonicDiffusivity{F, N, VI, V, K} <: AbstractScalarBiharmonicDiffusivity{F, N, VI} ν :: V κ :: K - ScalarBiharmonicDiffusivity{F, N, VI}(ν::V, κ::K) where {F, V, K, N} = new{F, N, V, K}(ν, κ) + ScalarBiharmonicDiffusivity{F, N, VI}(ν::V, κ::K) where {F, N, VI, V, K} = new{F, N, VI, V, K}(ν, κ) end # Aliases that allow specify the floating type, assuming that the discretization is Explicit in time @@ -96,7 +96,7 @@ function ScalarBiharmonicDiffusivity(formulation = ThreeDimensionalFormulation() return ScalarBiharmonicDiffusivity{typeof(formulation), required_halo_size, VI}(ν, κ) end -function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, V, K}) where {F, N, V, K} +function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, VI, V, K}) where {F, N, VI, V, K} κ = tracer_diffusivities(tracers, closure.κ) return ScalarBiharmonicDiffusivity{F, N}(closure.ν, κ) end From 5cf8017b467e96103a67c97f206bd5080d1b63fc Mon Sep 17 00:00:00 2001 From: Sid Date: Fri, 18 Oct 2024 22:01:19 -0400 Subject: [PATCH 05/11] Remove spurious parameters Co-authored-by: Gregory L. Wagner --- .../scalar_biharmonic_diffusivity.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 3fdd1bee50..188b0f8bd1 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -96,9 +96,9 @@ function ScalarBiharmonicDiffusivity(formulation = ThreeDimensionalFormulation() return ScalarBiharmonicDiffusivity{typeof(formulation), required_halo_size, VI}(ν, κ) end -function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, VI, V, K}) where {F, N, VI, V, K} +function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, VI}) where {F, N, VI} κ = tracer_diffusivities(tracers, closure.κ) - return ScalarBiharmonicDiffusivity{F, N}(closure.ν, κ) + return ScalarBiharmonicDiffusivity{F, N, VI}(closure.ν, κ) end @inline viscosity(closure::ScalarBiharmonicDiffusivity, K) = closure.ν From 12117f4a18eedf2b2603aea241a166de0d76dd92 Mon Sep 17 00:00:00 2001 From: Sid Date: Tue, 22 Oct 2024 16:54:17 -0400 Subject: [PATCH 06/11] =?UTF-8?q?Define=20=CE=94y=5F=E2=88=87=C2=B2v=20and?= =?UTF-8?q?=20=CE=94x=5F=E2=88=87=C2=B2u,=20and=20fix=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...t_scalar_biharmonic_diffusivity_closure.jl | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl index 8e97e0bbfb..98816d539f 100644 --- a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl +++ b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl @@ -10,7 +10,6 @@ abstract type AbstractScalarBiharmonicDiffusivity{F, N, VI} <: AbstractTurbulenc @inline formulation(::AbstractScalarBiharmonicDiffusivity{F}) where {F} = F() const ASBD = AbstractScalarBiharmonicDiffusivity - const VectorInvariantASBD = AbstractScalarBiharmonicDiffusivity{<:HorizontalFormulation, <:Nothing, <:VectorInvariantForm} ##### @@ -36,27 +35,31 @@ const AHBD = AbstractScalarBiharmonicDiffusivity{<:HorizontalFormulation} const ADBD = AbstractScalarBiharmonicDiffusivity{<:HorizontalDivergenceFormulation} const AVBD = AbstractScalarBiharmonicDiffusivity{<:VerticalFormulation} -@inline viscous_flux_ux(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂xᶜᶜᶜ, biharmonic_mask_x, ∇²ᶠᶜᶜ, fields.u) -@inline viscous_flux_vx(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶠᶜ, ∇²ᶜᶠᶜ, fields.v) -@inline viscous_flux_wx(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶜᶠ, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_uy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶠᶠᶜ, ∇²ᶠᶜᶜ, fields.u) -@inline viscous_flux_vy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂yᶜᶜᶜ, biharmonic_mask_y, ∇²ᶜᶠᶜ, fields.v) -@inline viscous_flux_wy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶜᶠᶠ, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_uz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶠᶜᶠ, ∇²ᶠᶜᶜ, fields.u) -@inline viscous_flux_vz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶜᶠᶠ, ∇²ᶜᶠᶜ, fields.v) -@inline viscous_flux_wz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂zᶜᶜᶜ, biharmonic_mask_z, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_ux(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) -@inline viscous_flux_vx(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, ζ★ᶠᶠᶜ, fields.u, fields.v) -@inline viscous_flux_wx(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶜᶠ, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_uy(i, j, k, grid, closure::AHBD, K, clk, fields, b) = - ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, ζ★ᶠᶠᶜ, fields.u, fields.v) -@inline viscous_flux_vy(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) -@inline viscous_flux_wy(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶜᶠᶠ, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_uz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶠᶜᶠ, ∂²zᶠᶜᶜ, fields.u) -@inline viscous_flux_vz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶜᶠᶠ, ∂²zᶜᶠᶜ, fields.v) -@inline viscous_flux_wz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂zᶜᶜᶜ, biharmonic_mask_z, ∂²zᶜᶜᶠ, fields.w) - -@inline viscous_flux_ux(i, j, k, grid, closure::ADBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) -@inline viscous_flux_vy(i, j, k, grid, closure::ADBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) +@inline ν_σᶜᶜᶜ(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clock, fields, σᶜᶜᶜ, args...) = νᶜᶜᶜ(i, j, k, grid, closure, K, clock, fields) * σᶜᶜᶜ(i, j, k, grid, closure, args...) +@inline ν_σᶠᶠᶜ(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clock, fields, σᶠᶠᶜ, args...) = νᶠᶠᶜ(i, j, k, grid, closure, K, clock, fields) * σᶠᶠᶜ(i, j, k, grid, closure, args...) +@inline ν_σᶠᶜᶠ(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clock, fields, σᶠᶜᶠ, args...) = νᶠᶜᶠ(i, j, k, grid, closure, K, clock, fields) * σᶠᶜᶠ(i, j, k, grid, closure, args...) +@inline ν_σᶜᶠᶠ(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clock, fields, σᶜᶠᶠ, args...) = νᶜᶠᶠ(i, j, k, grid, closure, K, clock, fields) * σᶜᶠᶠ(i, j, k, grid, closure, args...) + +@inline viscous_flux_ux(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂xᶜᶜᶜ, biharmonic_mask_x, ∇²ᶠᶜᶜ, fields.u) +@inline viscous_flux_vx(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶠᶜ, ∇²ᶜᶠᶜ, fields.v) +@inline viscous_flux_wx(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶜᶠ, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_uy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶠᶠᶜ, ∇²ᶠᶜᶜ, fields.u) +@inline viscous_flux_vy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂yᶜᶜᶜ, biharmonic_mask_y, ∇²ᶜᶠᶜ, fields.v) +@inline viscous_flux_wy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶜᶠᶠ, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_uz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶠᶜᶠ, ∇²ᶠᶜᶜ, fields.u) +@inline viscous_flux_vz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶜᶠᶠ, ∇²ᶜᶠᶜ, fields.v) +@inline viscous_flux_wz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂zᶜᶜᶜ, biharmonic_mask_z, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_ux(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) +@inline viscous_flux_vx(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, ζ★ᶠᶠᶜ, fields.u, fields.v) +@inline viscous_flux_wx(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶜᶠ, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_uy(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = - ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, ζ★ᶠᶠᶜ, fields.u, fields.v) +@inline viscous_flux_vy(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) +@inline viscous_flux_wy(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶜᶠᶠ, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_uz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶠᶜᶠ, ∂²zᶠᶜᶜ, fields.u) +@inline viscous_flux_vz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶜᶠᶠ, ∂²zᶜᶠᶜ, fields.v) +@inline viscous_flux_wz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂zᶜᶜᶜ, biharmonic_mask_z, ∂²zᶜᶜᶠ, fields.w) +@inline viscous_flux_ux(i, j, k, grid, closure::ADBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) +@inline viscous_flux_vy(i, j, k, grid, closure::ADBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) ##### ##### Diffusive fluxes @@ -73,16 +76,17 @@ const AVBD = AbstractScalarBiharmonicDiffusivity{<:VerticalFormulation} ##### Biharmonic-specific viscous operators ##### -@inline ∇²u_vector_invariantᶠᶜᶜ(i, j, k, grid, u, v) = δxᶠᶜᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) - δyᶠᶜᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) -@inline ∇²v_vector_invariantᶜᶠᶜ(i, j, k, grid, u, v) = δxᶜᶠᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) + δyᶜᶠᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) +@inline ∇²u_vector_invariantᶠᶜᶜ(i, j, k, grid, u, v) = δxᶠᶜᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) - δyᶠᶜᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) +@inline ∇²v_vector_invariantᶜᶠᶜ(i, j, k, grid, u, v) = δxᶜᶠᶜ(i, j, k, grid, ζ₃ᶠᶠᶜ, u, v) + δyᶜᶠᶜ(i, j, k, grid, div_xyᶜᶜᶜ, u, v) # These closures seem to be needed to help the compiler infer types # (either of u and v or of the function arguments) @inline Δy_∇²u(i, j, k, grid, closure, u, v) = Δy_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²hᶠᶜᶜ, u) @inline Δx_∇²v(i, j, k, grid, closure, u, v) = Δx_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²hᶜᶠᶜ, v) -# These closures seem to be needed to help the compiler infer types -# (either of u and v or of the function arguments) +@inline Δy_∇²v(i, j, k, grid, closure, u, v) = Δy_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²hᶜᶠᶜ, v) +@inline Δx_∇²u(i, j, k, grid, closure, u, v) = Δx_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²hᶠᶜᶜ, u) + @inline Δy_∇²u(i, j, k, grid, ::VectorInvariantASBD, u, v) = Δy_qᶠᶜᶜ(i, j, k, grid, biharmonic_mask_x, ∇²u_vector_invariantᶠᶜᶜ, u, v) @inline Δx_∇²v(i, j, k, grid, ::VectorInvariantASBD, u, v) = Δx_qᶜᶠᶜ(i, j, k, grid, biharmonic_mask_y, ∇²v_vector_invariantᶜᶠᶜ, u, v) From eac550c11d6cb7239d7f398683cc2d10cb9cbead Mon Sep 17 00:00:00 2001 From: Sid Date: Tue, 22 Oct 2024 18:40:39 -0400 Subject: [PATCH 07/11] Union{AHBD, VectorInvariantASBD} --> AHBD --- ...t_scalar_biharmonic_diffusivity_closure.jl | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl index 98816d539f..a41752adba 100644 --- a/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl +++ b/src/TurbulenceClosures/abstract_scalar_biharmonic_diffusivity_closure.jl @@ -35,31 +35,31 @@ const AHBD = AbstractScalarBiharmonicDiffusivity{<:HorizontalFormulation} const ADBD = AbstractScalarBiharmonicDiffusivity{<:HorizontalDivergenceFormulation} const AVBD = AbstractScalarBiharmonicDiffusivity{<:VerticalFormulation} -@inline ν_σᶜᶜᶜ(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clock, fields, σᶜᶜᶜ, args...) = νᶜᶜᶜ(i, j, k, grid, closure, K, clock, fields) * σᶜᶜᶜ(i, j, k, grid, closure, args...) -@inline ν_σᶠᶠᶜ(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clock, fields, σᶠᶠᶜ, args...) = νᶠᶠᶜ(i, j, k, grid, closure, K, clock, fields) * σᶠᶠᶜ(i, j, k, grid, closure, args...) -@inline ν_σᶠᶜᶠ(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clock, fields, σᶠᶜᶠ, args...) = νᶠᶜᶠ(i, j, k, grid, closure, K, clock, fields) * σᶠᶜᶠ(i, j, k, grid, closure, args...) -@inline ν_σᶜᶠᶠ(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clock, fields, σᶜᶠᶠ, args...) = νᶜᶠᶠ(i, j, k, grid, closure, K, clock, fields) * σᶜᶠᶠ(i, j, k, grid, closure, args...) - -@inline viscous_flux_ux(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂xᶜᶜᶜ, biharmonic_mask_x, ∇²ᶠᶜᶜ, fields.u) -@inline viscous_flux_vx(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶠᶜ, ∇²ᶜᶠᶜ, fields.v) -@inline viscous_flux_wx(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶜᶠ, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_uy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶠᶠᶜ, ∇²ᶠᶜᶜ, fields.u) -@inline viscous_flux_vy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂yᶜᶜᶜ, biharmonic_mask_y, ∇²ᶜᶠᶜ, fields.v) -@inline viscous_flux_wy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶜᶠᶠ, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_uz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶠᶜᶠ, ∇²ᶠᶜᶜ, fields.u) -@inline viscous_flux_vz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶜᶠᶠ, ∇²ᶜᶠᶜ, fields.v) -@inline viscous_flux_wz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂zᶜᶜᶜ, biharmonic_mask_z, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_ux(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) -@inline viscous_flux_vx(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, ζ★ᶠᶠᶜ, fields.u, fields.v) -@inline viscous_flux_wx(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶜᶠ, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_uy(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = - ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, ζ★ᶠᶠᶜ, fields.u, fields.v) -@inline viscous_flux_vy(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) -@inline viscous_flux_wy(i, j, k, grid, closure::Union{AHBD, VectorInvariantASBD}, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶜᶠᶠ, ∇²ᶜᶜᶠ, fields.w) -@inline viscous_flux_uz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶠᶜᶠ, ∂²zᶠᶜᶜ, fields.u) -@inline viscous_flux_vz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶜᶠᶠ, ∂²zᶜᶠᶜ, fields.v) -@inline viscous_flux_wz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂zᶜᶜᶜ, biharmonic_mask_z, ∂²zᶜᶜᶠ, fields.w) -@inline viscous_flux_ux(i, j, k, grid, closure::ADBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) -@inline viscous_flux_vy(i, j, k, grid, closure::ADBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) +@inline ν_σᶜᶜᶜ(i, j, k, grid, closure::AHBD, K, clock, fields, σᶜᶜᶜ, args...) = νᶜᶜᶜ(i, j, k, grid, closure, K, clock, fields) * σᶜᶜᶜ(i, j, k, grid, closure, args...) +@inline ν_σᶠᶠᶜ(i, j, k, grid, closure::AHBD, K, clock, fields, σᶠᶠᶜ, args...) = νᶠᶠᶜ(i, j, k, grid, closure, K, clock, fields) * σᶠᶠᶜ(i, j, k, grid, closure, args...) +@inline ν_σᶠᶜᶠ(i, j, k, grid, closure::AHBD, K, clock, fields, σᶠᶜᶠ, args...) = νᶠᶜᶠ(i, j, k, grid, closure, K, clock, fields) * σᶠᶜᶠ(i, j, k, grid, closure, args...) +@inline ν_σᶜᶠᶠ(i, j, k, grid, closure::AHBD, K, clock, fields, σᶜᶠᶠ, args...) = νᶜᶠᶠ(i, j, k, grid, closure, K, clock, fields) * σᶜᶠᶠ(i, j, k, grid, closure, args...) + +@inline viscous_flux_ux(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂xᶜᶜᶜ, biharmonic_mask_x, ∇²ᶠᶜᶜ, fields.u) +@inline viscous_flux_vx(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶠᶜ, ∇²ᶜᶠᶜ, fields.v) +@inline viscous_flux_wx(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶜᶠ, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_uy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶠᶠᶜ, ∇²ᶠᶜᶜ, fields.u) +@inline viscous_flux_vy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂yᶜᶜᶜ, biharmonic_mask_y, ∇²ᶜᶠᶜ, fields.v) +@inline viscous_flux_wy(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶜᶠᶠ, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_uz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶠᶜᶠ, ∇²ᶠᶜᶜ, fields.u) +@inline viscous_flux_vz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶜᶠᶠ, ∇²ᶜᶠᶜ, fields.v) +@inline viscous_flux_wz(i, j, k, grid, closure::AIBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂zᶜᶜᶜ, biharmonic_mask_z, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_ux(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) +@inline viscous_flux_vx(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, ζ★ᶠᶠᶜ, fields.u, fields.v) +@inline viscous_flux_wx(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_x, ∂xᶠᶜᶠ, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_uy(i, j, k, grid, closure::AHBD, K, clk, fields, b) = - ν_σᶠᶠᶜ(i, j, k, grid, closure, K, clk, fields, ζ★ᶠᶠᶜ, fields.u, fields.v) +@inline viscous_flux_vy(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) +@inline viscous_flux_wy(i, j, k, grid, closure::AHBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_y, ∂yᶜᶠᶠ, ∇²ᶜᶜᶠ, fields.w) +@inline viscous_flux_uz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶠᶜᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶠᶜᶠ, ∂²zᶠᶜᶜ, fields.u) +@inline viscous_flux_vz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶜᶠᶠ(i, j, k, grid, closure, K, clk, fields, biharmonic_mask_z, ∂zᶜᶠᶠ, ∂²zᶜᶠᶜ, fields.v) +@inline viscous_flux_wz(i, j, k, grid, closure::AVBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, ∂zᶜᶜᶜ, biharmonic_mask_z, ∂²zᶜᶜᶠ, fields.w) +@inline viscous_flux_ux(i, j, k, grid, closure::ADBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) +@inline viscous_flux_vy(i, j, k, grid, closure::ADBD, K, clk, fields, b) = + ν_σᶜᶜᶜ(i, j, k, grid, closure, K, clk, fields, δ★ᶜᶜᶜ, fields.u, fields.v) ##### ##### Diffusive fluxes From 81388198cae571df40b303cfee8f02a954244eba Mon Sep 17 00:00:00 2001 From: Sid Date: Tue, 22 Oct 2024 20:06:39 -0400 Subject: [PATCH 08/11] =?UTF-8?q?Fix=20adapt=5Fstructure=20and=20on=5Farch?= =?UTF-8?q?itecture=20for=20=CE=BDhb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scalar_biharmonic_diffusivity.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 188b0f8bd1..46d441df09 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -2,7 +2,7 @@ import Oceananigans.Grids: required_halo_size_x, required_halo_size_y, required_ using Oceananigans.Utils: prettysummary """ - struct ScalarBiharmonicDiffusivity{F, N, K} <: AbstractScalarBiharmonicDiffusivity{F} + struct ScalarBiharmonicDiffusivity{F, N, VI, V, K} <: AbstractScalarBiharmonicDiffusivity{F} Holds viscosity and diffusivities for models with prescribed isotropic diffusivities. """ @@ -120,14 +120,14 @@ end Base.show(io::IO, closure::ScalarBiharmonicDiffusivity) = print(io, summary(closure)) -function Adapt.adapt_structure(to, closure::ScalarBiharmonicDiffusivity{F, <:Any, <:Any, N}) where {F, N} +function Adapt.adapt_structure(to, closure::ScalarBiharmonicDiffusivity{F, N, VI, V, K}) where {F, N, VI, V, K} ν = Adapt.adapt(to, closure.ν) κ = Adapt.adapt(to, closure.κ) - return ScalarBiharmonicDiffusivity{F, N}(ν, κ) + return ScalarBiharmonicDiffusivity{F, N, VI, typeof(ν), typeof(κ)}(ν, κ) end -function on_architecture(to, closure::ScalarBiharmonicDiffusivity{F, <:Any, <:Any, N}) where {F, N} +function on_architecture(to, closure::ScalarBiharmonicDiffusivity{F, N, VI, V, K}) where {F, N, VI, V, K} ν = on_architecture(to, closure.ν) κ = on_architecture(to, closure.κ) - return ScalarBiharmonicDiffusivity{F, N}(ν, κ) + return ScalarBiharmonicDiffusivity{F, N, VI, typeof(ν), typeof(κ)}(ν, κ) end \ No newline at end of file From 31cb273d693019ee186018ec6448b6c5874d81ad Mon Sep 17 00:00:00 2001 From: Sid Date: Tue, 22 Oct 2024 21:42:05 -0400 Subject: [PATCH 09/11] Fix bug --- .../scalar_biharmonic_diffusivity.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 46d441df09..7e9b81b7a0 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -96,7 +96,7 @@ function ScalarBiharmonicDiffusivity(formulation = ThreeDimensionalFormulation() return ScalarBiharmonicDiffusivity{typeof(formulation), required_halo_size, VI}(ν, κ) end -function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, VI}) where {F, N, VI} +function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, VI, <:Any, <:Any}) where {F, N, VI} κ = tracer_diffusivities(tracers, closure.κ) return ScalarBiharmonicDiffusivity{F, N, VI}(closure.ν, κ) end @@ -120,14 +120,14 @@ end Base.show(io::IO, closure::ScalarBiharmonicDiffusivity) = print(io, summary(closure)) -function Adapt.adapt_structure(to, closure::ScalarBiharmonicDiffusivity{F, N, VI, V, K}) where {F, N, VI, V, K} +function Adapt.adapt_structure(to, closure::ScalarBiharmonicDiffusivity{F, N, VI, <:Any, <:Any}) where {F, N, VI} ν = Adapt.adapt(to, closure.ν) κ = Adapt.adapt(to, closure.κ) - return ScalarBiharmonicDiffusivity{F, N, VI, typeof(ν), typeof(κ)}(ν, κ) + return ScalarBiharmonicDiffusivity{F, N, VI}(ν, κ) end -function on_architecture(to, closure::ScalarBiharmonicDiffusivity{F, N, VI, V, K}) where {F, N, VI, V, K} +function on_architecture(to, closure::ScalarBiharmonicDiffusivity{F, N, VI, <:Any, <:Any}) where {F, N, VI} ν = on_architecture(to, closure.ν) κ = on_architecture(to, closure.κ) - return ScalarBiharmonicDiffusivity{F, N, VI, typeof(ν), typeof(κ)}(ν, κ) + return ScalarBiharmonicDiffusivity{F, N, VI}(ν, κ) end \ No newline at end of file From 1c04419bf275493b0818df0fb71be7d1f4994136 Mon Sep 17 00:00:00 2001 From: Sid Date: Wed, 30 Oct 2024 11:45:08 -0400 Subject: [PATCH 10/11] Update src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl Co-authored-by: Simone Silvestri --- .../scalar_biharmonic_diffusivity.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 7e9b81b7a0..79d7531672 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -96,7 +96,7 @@ function ScalarBiharmonicDiffusivity(formulation = ThreeDimensionalFormulation() return ScalarBiharmonicDiffusivity{typeof(formulation), required_halo_size, VI}(ν, κ) end -function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, VI, <:Any, <:Any}) where {F, N, VI} +function with_tracers(tracers, closure::ScalarBiharmonicDiffusivity{F, N, VI}) where {F, N, VI} κ = tracer_diffusivities(tracers, closure.κ) return ScalarBiharmonicDiffusivity{F, N, VI}(closure.ν, κ) end From cc0773ddfb9e1172f204d845f7454a599db4c9b7 Mon Sep 17 00:00:00 2001 From: Sid Date: Wed, 30 Oct 2024 11:45:16 -0400 Subject: [PATCH 11/11] Update src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl Co-authored-by: Simone Silvestri --- .../scalar_biharmonic_diffusivity.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 79d7531672..0169e9217b 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -126,7 +126,7 @@ function Adapt.adapt_structure(to, closure::ScalarBiharmonicDiffusivity{F, N, VI return ScalarBiharmonicDiffusivity{F, N, VI}(ν, κ) end -function on_architecture(to, closure::ScalarBiharmonicDiffusivity{F, N, VI, <:Any, <:Any}) where {F, N, VI} +function on_architecture(to, closure::ScalarBiharmonicDiffusivity{F, N, VI}) where {F, N, VI} ν = on_architecture(to, closure.ν) κ = on_architecture(to, closure.κ) return ScalarBiharmonicDiffusivity{F, N, VI}(ν, κ)