comparison src/Grids/equidistant_grid.jl @ 1954:b0915f43b122 feature/sbp_operators/laplace_curvilinear

Merge feature/grids/geometry_functions
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 08 Feb 2025 09:38:58 +0100
parents 04c251bccbd4
children
comparison
equal deleted inserted replaced
1953:835b1dcee38e 1954:b0915f43b122
13 struct EquidistantGrid{T,R<:AbstractRange{T}} <: Grid{T,1} 13 struct EquidistantGrid{T,R<:AbstractRange{T}} <: Grid{T,1}
14 points::R 14 points::R
15 end 15 end
16 16
17 # Indexing interface 17 # Indexing interface
18 Base.getindex(g::EquidistantGrid, i) = g.points[i] 18 Base.getindex(g::EquidistantGrid, i::Int) = g.points[i]
19 Base.eachindex(g::EquidistantGrid) = eachindex(g.points) 19 Base.eachindex(g::EquidistantGrid) = eachindex(g.points)
20 Base.firstindex(g::EquidistantGrid) = firstindex(g.points) 20 Base.firstindex(g::EquidistantGrid) = firstindex(g.points)
21 Base.lastindex(g::EquidistantGrid) = lastindex(g.points) 21 Base.lastindex(g::EquidistantGrid) = lastindex(g.points)
22 22
23 Base.axes(g::EquidistantGrid, d) = axes(g.points, d) 23 Base.axes(g::EquidistantGrid, d) = axes(g.points, d)
69 69
70 70
71 boundary_identifiers(::EquidistantGrid) = (LowerBoundary(), UpperBoundary()) 71 boundary_identifiers(::EquidistantGrid) = (LowerBoundary(), UpperBoundary())
72 boundary_grid(g::EquidistantGrid, id::LowerBoundary) = ZeroDimGrid(g[begin]) 72 boundary_grid(g::EquidistantGrid, id::LowerBoundary) = ZeroDimGrid(g[begin])
73 boundary_grid(g::EquidistantGrid, id::UpperBoundary) = ZeroDimGrid(g[end]) 73 boundary_grid(g::EquidistantGrid, id::UpperBoundary) = ZeroDimGrid(g[end])
74 boundary_indices(g::EquidistantGrid, id::LowerBoundary) = (firstindex(g),) 74 boundary_indices(g::EquidistantGrid, id::LowerBoundary) = firstindex(g)
75 boundary_indices(g::EquidistantGrid, id::UpperBoundary) = (lastindex(g),) 75 boundary_indices(g::EquidistantGrid, id::UpperBoundary) = lastindex(g)
76 76
77 """ 77 """
78 refine(g::EquidistantGrid, r::Int) 78 refine(g::EquidistantGrid, r::Int)
79 79
80 The grid where `g` is refined by the factor `r`. The factor is applied to the number of 80 The grid where `g` is refined by the factor `r`. The factor is applied to the number of
153 153
154 equidistant_grid(d::Interval, size::Int) = equidistant_grid(limits(d)..., size) 154 equidistant_grid(d::Interval, size::Int) = equidistant_grid(limits(d)..., size)
155 equidistant_grid(hb::HyperBox, dims::Vararg{Int}) = equidistant_grid(limits(hb)..., dims...) 155 equidistant_grid(hb::HyperBox, dims::Vararg{Int}) = equidistant_grid(limits(hb)..., dims...)
156 156
157 function equidistant_grid(c::Chart, dims::Vararg{Int}) 157 function equidistant_grid(c::Chart, dims::Vararg{Int})
158 lg = equidistant_grid(parameterspace(c), dims...) 158 mapped_grid(c, ξ->jacobian(c,ξ), parameterspace(c), dims...)
159 return MappedGrid(
160 lg,
161 map(c,lg),
162 map(ξ->jacobian(c, ξ), lg),
163 )
164 end 159 end
165 160
166 161
167 CartesianBoundary{D,BID} = TensorGridBoundary{D,BID} # TBD: What should we do about the naming of this boundary? 162 CartesianBoundary{D,BID} = TensorGridBoundary{D,BID} # TBD: What should we do about the naming of this boundary?
168 163