diff --git a/src/ImmersedBoundaries/immersed_grid_metrics.jl b/src/ImmersedBoundaries/immersed_grid_metrics.jl index 48cb239768..c51e2fb374 100644 --- a/src/ImmersedBoundaries/immersed_grid_metrics.jl +++ b/src/ImmersedBoundaries/immersed_grid_metrics.jl @@ -1,7 +1,5 @@ -using Oceananigans.AbstractOperations: GridMetricOperation - import Oceananigans.Grids: coordinates -import Oceananigans.Operators: Δzᵃᵃᶠ, Δzᵃᵃᶜ, intrinsic_vector, extrinsic_vector +import Oceananigans.Operators: intrinsic_vector, extrinsic_vector # Grid metrics for ImmersedBoundaryGrid # @@ -10,28 +8,36 @@ import Oceananigans.Operators: Δzᵃᵃᶠ, Δzᵃᵃᶜ, intrinsic_vector, ext # For non "full-cell" immersed boundaries, grid metric functions # must be extended for the specific immersed boundary grid in question. -for LX in (:ᶜ, :ᶠ), LY in (:ᶜ, :ᶠ), LZ in (:ᶜ, :ᶠ) - for dir in (:x, :y, :z), operator in (:Δ, :A) +# We need to extend only the metric explicitly defined in the `spacing_and_areas_and_volumes.jl` file. +# These include all the spacings and the horizontal areas. +# All the other metrics are calculated from these. + +x_superscript(dir) = dir == :x ? (:ᶜ, :ᶠ) : (:ᶜ, :ᶠ, :ᵃ) +y_superscript(dir) = dir == :y ? (:ᶜ, :ᶠ) : (:ᶜ, :ᶠ, :ᵃ) +z_superscript(dir) = dir == :z ? (:ᶜ, :ᶠ) : (:ᶜ, :ᶠ, :ᵃ) - metric = Symbol(operator, dir, LX, LY, LZ) +for dir in (:x, :y, :z) + for LX in x_superscript(dir), LY in y_superscript(dir), LZ in z_superscript(dir) + spacing = Symbol(:Δ, dir, LX, LY, LZ) @eval begin - import Oceananigans.Operators: $metric - @inline $metric(i, j, k, ibg::IBG) = $metric(i, j, k, ibg.underlying_grid) + import Oceananigans.Operators: $spacing + $spacing(i, j, k, ibg::IBG) = $spacing(i, j, k, ibg.underlying_grid) end end +end - volume = Symbol(:V, LX, LY, LZ) - @eval begin - import Oceananigans.Operators: $volume - @inline $volume(i, j, k, ibg::IBG) = $volume(i, j, k, ibg.underlying_grid) +for L1 in (:ᶜ, :ᶠ) + for L2 in (:ᶜ, :ᶠ) + zarea2D = Symbol(:Az, L1, L2, :ᵃ) + @eval begin + import Oceananigans.Operators: $zarea2D + $zarea2D(i, j, k, ibg::IBG) = $zarea2D(i, j, k, ibg.underlying_grid) + end end end coordinates(grid::IBG) = coordinates(grid.underlying_grid) -@inline Δzᵃᵃᶠ(i, j, k, ibg::IBG) = Δzᵃᵃᶠ(i, j, k, ibg.underlying_grid) -@inline Δzᵃᵃᶜ(i, j, k, ibg::IBG) = Δzᵃᵃᶜ(i, j, k, ibg.underlying_grid) - # Extend both 2D and 3D methods @inline intrinsic_vector(i, j, k, ibg::IBG, u, v) = intrinsic_vector(i, j, k, ibg.underlying_grid, u, v) @inline extrinsic_vector(i, j, k, ibg::IBG, u, v) = extrinsic_vector(i, j, k, ibg.underlying_grid, u, v)