|
35 | 35 |
|
36 | 36 | # Default behavior for grids (assumed bipolar)
|
37 | 37 | # wrap around in the i direction (longitude)
|
38 |
| -i₊₁(C, g::AbstractGrid) = C.I[1] < g.nx ? C .+ CartesianIndex(1, 0, 0) : CartesianIndex(1, C.I[2], C.I[3]) |
39 |
| -i₋₁(C, g::AbstractGrid) = C.I[1] > 1 ? C .- CartesianIndex(1, 0, 0) : CartesianIndex(g.nx, C.I[2], C.I[3]) |
| 38 | +i₊₁(C, g::AbstractGrid) = C.I[1] < g.nx ? C + CartesianIndex(1, 0, 0) : CartesianIndex(1, C.I[2], C.I[3]) |
| 39 | +i₋₁(C, g::AbstractGrid) = C.I[1] > 1 ? C + CartesianIndex(-1, 0, 0) : CartesianIndex(g.nx, C.I[2], C.I[3]) |
40 | 40 | # No connection by default in the j direction (latitude)
|
41 |
| -j₊₁(C, g::AbstractGrid) = C.I[2] < g.ny ? C .+ CartesianIndex(0, 1, 0) : nothing |
42 |
| -j₋₁(C, ::AbstractGrid) = C.I[2] > 1 ? C .- CartesianIndex(0, 1, 0) : nothing |
| 41 | +j₊₁(C, g::AbstractGrid) = C.I[2] < g.ny ? C + CartesianIndex(0, 1, 0) : nothing |
| 42 | +j₋₁(C, ::AbstractGrid) = C.I[2] > 1 ? C + CartesianIndex(0, -1, 0) : nothing |
43 | 43 | # No connection by default in the k direction (depth)
|
44 |
| -k₊₁(C, g::AbstractGrid) = C.I[3] < g.nz ? C .+ CartesianIndex(0, 0, 1) : nothing |
45 |
| -k₋₁(C, ::AbstractGrid) = C.I[3] > 1 ? C .- CartesianIndex(0, 0, 1) : nothing |
| 44 | +k₊₁(C, g::AbstractGrid) = C.I[3] < g.nz ? C + CartesianIndex(0, 0, 1) : nothing |
| 45 | +k₋₁(C, ::AbstractGrid) = C.I[3] > 1 ? C + CartesianIndex(0, 0, -1) : nothing |
46 | 46 |
|
47 |
| -# Special behavior for tripolar grids |
48 |
| -j₊₁(C, g::TripolarGrid) = C.I[2] < g.ny ? C .+ CartesianIndex(0, 1, 0) : CartesianIndex(mod1(g.nx - C.I[1] + 1, g.nx), g.ny, C.I[3]) |
| 47 | +# Special behavior for tripolar grids where the seam connects the top and "folds" it around |
| 48 | +j₊₁(C, g::TripolarGrid) = C.I[2] < g.ny ? C + CartesianIndex(0, 1, 0) : CartesianIndex(mod1(g.nx - C.I[1] + 1, g.nx), g.ny, C.I[3]) |
49 | 49 |
|
50 | 50 | # error for unknown grids
|
51 | 51 | i₊₁(C, ::UnknownGrid) = error("Unknown grid type")
|
|
0 commit comments