Skip to content

Commit 063dfec

Browse files
authored
Generalize dispatch to OrthoRectilinearGrid and OrthoStructuredGrid (#1080)
1 parent ba58b2a commit 063dfec

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

src/boundingboxes.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ boundingbox(t::Torus) = _pboxes(pointify(t))
7171

7272
boundingbox(g::OrthoRegularGrid) = Box(extrema(g)...)
7373

74-
boundingbox(g::RectilinearGrid) = Box(extrema(g)...)
74+
boundingbox(g::OrthoRectilinearGrid) = Box(extrema(g)...)
7575

76-
boundingbox(g::TransformedGrid{<:Any,<:Any,<:CartesianGrid}) = boundingbox(parent(g)) |> transform(g) |> boundingbox
76+
boundingbox(g::TransformedGrid{<:Any,<:Any,<:OrthoRegularGrid}) = boundingbox(parent(g)) |> transform(g) |> boundingbox
7777

78-
boundingbox(g::TransformedGrid{<:Any,<:Any,<:RectilinearGrid}) = boundingbox(parent(g)) |> transform(g) |> boundingbox
78+
boundingbox(g::TransformedGrid{<:Any,<:Any,<:OrthoRectilinearGrid}) =
79+
boundingbox(parent(g)) |> transform(g) |> boundingbox
7980

8081
boundingbox(m::Mesh) = _pboxes(vertices(m))
8182

src/centroid.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function centroid(g::OrthoRegularGrid, ind::Int)
7070
vertex(g, ijk) + Vec(spacing(g) ./ 2)
7171
end
7272

73-
function centroid(g::RectilinearGrid{<:𝔼,<:CartesianOrProjected}, ind::Int)
73+
function centroid(g::OrthoRectilinearGrid, ind::Int)
7474
ijk = elem2cart(topology(g), ind)
7575
p1 = vertex(g, ijk)
7676
p2 = vertex(g, ijk .+ 1)

src/domains/meshes.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,5 +247,7 @@ include("meshes/structuredgrid.jl")
247247
include("meshes/simplemesh.jl")
248248
include("meshes/transformedmesh.jl")
249249

250-
# alias for dispatch purposes
250+
# aliases for dispatch purposes
251251
const OrthoRegularGrid{M<:𝔼,C<:Union{Cartesian,Projected}} = RegularGrid{M,C}
252+
const OrthoRectilinearGrid{M<:𝔼,C<:Union{Cartesian,Projected}} = RectilinearGrid{M,C}
253+
const OrthoStructuredGrid{M<:𝔼,C<:Union{Cartesian,Projected}} = StructuredGrid{M,C}

src/indices.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ end
6666

6767
indices(grid::OrthoRegularGrid, multi::Multi) = mapreduce(geom -> indices(grid, geom), vcat, parent(multi)) |> unique
6868

69-
function indices(grid::RectilinearGrid, box::Box)
69+
function indices(grid::OrthoRectilinearGrid, box::Box)
7070
# cartesian range
7171
range = cartesianrange(grid, box)
7272

@@ -106,7 +106,7 @@ function _euclideanrange(grid::OrthoRegularGrid, box::Box)
106106
CartesianIndex(Tuple(ijkₛ)):CartesianIndex(Tuple(ijkₑ))
107107
end
108108

109-
function _euclideanrange(grid::RectilinearGrid, box::Box)
109+
function _euclideanrange(grid::OrthoRectilinearGrid, box::Box)
110110
# grid properties
111111
nd = paramdim(grid)
112112

src/refinement/regular.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function refine(grid::RectilinearGrid, method::RegularRefinement)
3232
RectilinearGrid{manifold(grid),crs(grid)}(xyzₜ)
3333
end
3434

35-
function refine(grid::StructuredGrid, method::RegularRefinement)
35+
function refine(grid::OrthoStructuredGrid, method::RegularRefinement)
3636
factors = fitdims(method.factors, paramdim(grid))
3737
XYZ′ = _XYZ(grid, factors)
3838
StructuredGrid{manifold(grid),crs(grid)}(XYZ′)
@@ -49,9 +49,9 @@ function _refinedims(x, f)
4949
x′
5050
end
5151

52-
_XYZ(grid::StructuredGrid, factors::Dims) = _XYZ(grid, Val(paramdim(grid)), factors)
52+
_XYZ(grid::OrthoStructuredGrid, factors::Dims) = _XYZ(grid, Val(paramdim(grid)), factors)
5353

54-
function _XYZ(grid::StructuredGrid, ::Val{2}, factors::Dims{2})
54+
function _XYZ(grid::OrthoStructuredGrid, ::Val{2}, factors::Dims{2})
5555
T = numtype(lentype(grid))
5656
fᵢ, fⱼ = factors
5757
sᵢ, sⱼ = size(grid)
@@ -77,7 +77,7 @@ function _XYZ(grid::StructuredGrid, ::Val{2}, factors::Dims{2})
7777
(X, Y)
7878
end
7979

80-
function _XYZ(grid::StructuredGrid, ::Val{3}, factors::Dims{3})
80+
function _XYZ(grid::OrthoStructuredGrid, ::Val{3}, factors::Dims{3})
8181
T = numtype(lentype(grid))
8282
fᵢ, fⱼ, fₖ = factors
8383
sᵢ, sⱼ, sₖ = size(grid)

src/utils.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# Licensed under the MIT License. See LICENSE in the project root.
33
# ------------------------------------------------------------------
44

5-
# auxiliary types for dispatch purposes
5+
# auxiliary type for dispatch purposes
66
const GeometryOrDomain = Union{Geometry,Domain}
7-
const CartesianOrProjected = Union{Cartesian,Projected}
87

98
include("utils/basic.jl")
109
include("utils/assert.jl")

0 commit comments

Comments
 (0)