Skip to content

Commit

Permalink
Trying to define the complete set without duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ramadhan committed Nov 11, 2024
1 parent 3a29990 commit 735a16f
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/Operators/spacings_and_areas_and_volumes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,8 @@ The operators in this file fall into three categories:
#####
#####

@inline Δxᶠᵃᵃ(i, j, k, grid) = nothing
@inline Δxᶜᵃᵃ(i, j, k, grid) = nothing
@inline Δyᵃᶠᵃ(i, j, k, grid) = nothing
@inline Δyᵃᶜᵃ(i, j, k, grid) = nothing

const ZRG = Union{LLGZ, RGZ}

@inline Δzᵃᵃᶠ(i, j, k, grid) = @inbounds grid.Δzᵃᵃᶠ[k]
@inline Δzᵃᵃᶜ(i, j, k, grid) = @inbounds grid.Δzᵃᵃᶜ[k]

@inline Δzᵃᵃᶠ(i, j, k, grid::ZRG) = grid.Δzᵃᵃᶠ
@inline Δzᵃᵃᶜ(i, j, k, grid::ZRG) = grid.Δzᵃᵃᶜ

Expand All @@ -72,8 +64,8 @@ const ZRG = Union{LLGZ, RGZ}
@inline Δzᵃᵃᶜ(i, j, k, grid::OSSGZ) = grid.Δzᵃᵃᶜ
@inline Δzᵃᵃᶠ(i, j, k, grid::OSSGZ) = grid.Δzᵃᵃᶠ

# Convenience Functions for all grids
for LX in (:ᶜ, :ᶠ), LY in (:ᶜ, :ᶠ)
# 2D horizontal spacings
for LX in (:ᶜ, :ᶠ, :ᵃ), LY in (:ᶜ, :ᶠ, :ᵃ)

x_spacing_1D = Symbol(:Δx, LX, :ᵃ, :ᵃ)
x_spacing_2D = Symbol(:Δx, LX, LY, :ᵃ)
Expand All @@ -85,19 +77,24 @@ for LX in (:ᶜ, :ᶠ), LY in (:ᶜ, :ᶠ)
@inline $x_spacing_2D(i, j, k, grid) = $x_spacing_1D(i, j, k, grid)
@inline $y_spacing_2D(i, j, k, grid) = $y_spacing_1D(i, j, k, grid)
end
end

for LZ in (:ᶜ, :ᶠ)
x_spacing_3D = Symbol(:Δx, LX, LY, LZ)
y_spacing_3D = Symbol(:Δy, LX, LY, LZ)
# 3D spacings
for LX in (:ᶜ, :ᶠ, :ᵃ), LY in (:ᶜ, :ᶠ, :ᵃ), LZ in (:ᶜ, :ᶠ)

z_spacing_1D = Symbol(:Δz, :ᵃ, :ᵃ, LZ)
z_spacing_3D = Symbol(:Δz, LX, LY, LZ)
x_spacing_2D = Symbol(:Δx, LX, LY, :ᵃ)
y_spacing_2D = Symbol(:Δy, LX, LY, :ᵃ)

@eval begin
@inline $x_spacing_3D(i, j, k, grid) = $x_spacing_2D(i, j, k, grid)
@inline $y_spacing_3D(i, j, k, grid) = $y_spacing_2D(i, j, k, grid)
@inline $z_spacing_3D(i, j, k, grid) = $z_spacing_1D(i, j, k, grid)
end
x_spacing_3D = Symbol(:Δx, LX, LY, LZ)
y_spacing_3D = Symbol(:Δy, LX, LY, LZ)

z_spacing_1D = Symbol(:Δz, :ᵃ, :ᵃ, LZ)
z_spacing_3D = Symbol(:Δz, LX, LY, LZ)

@eval begin
@inline $x_spacing_3D(i, j, k, grid) = $x_spacing_2D(i, j, k, grid)
@inline $y_spacing_3D(i, j, k, grid) = $y_spacing_2D(i, j, k, grid)
@inline $z_spacing_3D(i, j, k, grid) = $z_spacing_1D(i, j, k, grid)
end
end

Expand Down Expand Up @@ -197,15 +194,17 @@ end
#####
#####

for LX in (:ᶜ, :ᶠ), LY in (:ᶜ, :ᶠ)
for LX in (:ᶜ, :ᶠ, :ᵃ), LY in (:ᶜ, :ᶠ, :ᵃ)

x_spacing_2D = Symbol(:Δx, LX, LY, :ᵃ)
y_spacing_2D = Symbol(:Δy, LX, LY, :ᵃ)
z_area_2D = Symbol(:Az, LX, LY, :ᵃ)

@eval $z_area_2D(i, j, k, grid) = $x_spacing_2D(i, j, k, grid) * $y_spacing_2D(i, j, k, grid)
@eval begin
@inline $z_area_2D(i, j, k, grid) = $x_spacing_2D(i, j, k, grid) * $y_spacing_2D(i, j, k, grid)
end

for LZ in (:ᶜ, :ᶠ)
for LZ in (:ᶜ, :ᶠ, :ᵃ) # Added :ᵃ here
x_spacing_3D = Symbol(:Δx, LX, LY, LZ)
y_spacing_3D = Symbol(:Δy, LX, LY, LZ)
z_spacing_3D = Symbol(:Δz, LX, LY, LZ)
Expand All @@ -222,7 +221,6 @@ for LX in (:ᶜ, :ᶠ), LY in (:ᶜ, :ᶠ)
end
end


####
#### Special 2D z Areas for LatitudeLongitudeGrid and OrthogonalSphericalShellGrid
####
Expand Down Expand Up @@ -253,14 +251,16 @@ end
#####
#####

@inline Vᶜᶜᶜ(i, j, k, grid) = Azᶜᶜᶜ(i, j, k, grid) * Δzᶜᶜᶜ(i, j, k, grid)
@inline Vᶠᶜᶜ(i, j, k, grid) = Azᶠᶜᶜ(i, j, k, grid) * Δzᶠᶜᶜ(i, j, k, grid)
@inline Vᶜᶠᶜ(i, j, k, grid) = Azᶜᶠᶜ(i, j, k, grid) * Δzᶜᶠᶜ(i, j, k, grid)
@inline Vᶜᶜᶠ(i, j, k, grid) = Azᶜᶜᶠ(i, j, k, grid) * Δzᶜᶜᶠ(i, j, k, grid)
@inline Vᶠᶠᶜ(i, j, k, grid) = Azᶠᶠᶜ(i, j, k, grid) * Δzᶠᶠᶜ(i, j, k, grid)
@inline Vᶠᶜᶠ(i, j, k, grid) = Azᶠᶜᶠ(i, j, k, grid) * Δzᶠᶜᶠ(i, j, k, grid)
@inline Vᶜᶠᶠ(i, j, k, grid) = Azᶜᶠᶠ(i, j, k, grid) * Δzᶜᶠᶠ(i, j, k, grid)
@inline Vᶠᶠᶠ(i, j, k, grid) = Azᶠᶠᶠ(i, j, k, grid) * Δzᶠᶠᶠ(i, j, k, grid)
for LX in (:ᶠ, :ᶜ, :ᵃ), LY in (:ᶠ, :ᶜ, :ᵃ), LZ in (:ᶠ, :ᶜ, :ᵃ)

volume = Symbol(:V, LX, LY, LZ)
z_area = Symbol(:Az, LX, LY, LZ)
z_spacing = Symbol(:Δz, LX, LY, LZ)

@eval begin
@inline $volume(i, j, k, grid) = $z_area(i, j, k, grid) * $z_spacing(i, j, k, grid)
end
end

#####
##### Generic functions for specified locations
Expand Down

0 comments on commit 735a16f

Please sign in to comment.