comparison src/Grids/EquidistantGrid.jl @ 1115:6530fceef37c feature/grids

Rename dimension to dim
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 15 Jul 2022 09:41:58 +0200
parents fc57804c9bf4
children
comparison
equal deleted inserted replaced
1114:fc57804c9bf4 1115:6530fceef37c
68 Base.eachindex(grid::EquidistantGrid) = CartesianIndices(grid.size) 68 Base.eachindex(grid::EquidistantGrid) = CartesianIndices(grid.size)
69 69
70 Base.size(g::EquidistantGrid) = g.size 70 Base.size(g::EquidistantGrid) = g.size
71 71
72 """ 72 """
73 dimension(grid::EquidistantGrid) 73 dim(grid::EquidistantGrid)
74 74
75 The dimension of the grid. 75 The dimension of the grid.
76 """ 76 """
77 dimension(grid::EquidistantGrid{Dim}) where Dim = Dim 77 dim(::EquidistantGrid{Dim}) where Dim = Dim
78 78
79 """ 79 """
80 spacing(grid::EquidistantGrid) 80 spacing(grid::EquidistantGrid)
81 81
82 The spacing between grid points. 82 The spacing between grid points.
139 (CartesianBoundary(1,Lower), 139 (CartesianBoundary(1,Lower),
140 CartesianBoundary(1,Upper), 140 CartesianBoundary(1,Upper),
141 CartesianBoundary(2,Lower), 141 CartesianBoundary(2,Lower),
142 ...) 142 ...)
143 """ 143 """
144 boundary_identifiers(g::EquidistantGrid) = (((ntuple(i->(CartesianBoundary{i,Lower}(),CartesianBoundary{i,Upper}()),dimension(g)))...)...,) 144 boundary_identifiers(g::EquidistantGrid) = (((ntuple(i->(CartesianBoundary{i,Lower}(),CartesianBoundary{i,Upper}()),dim(g)))...)...,)
145 145
146 146
147 """ 147 """
148 boundary_grid(grid::EquidistantGrid, id::CartesianBoundary) 148 boundary_grid(grid::EquidistantGrid, id::CartesianBoundary)
149 149
178 See also: [`coarsen`](@ref) 178 See also: [`coarsen`](@ref)
179 """ 179 """
180 function refine(grid::EquidistantGrid, r::Int) 180 function refine(grid::EquidistantGrid, r::Int)
181 sz = size(grid) 181 sz = size(grid)
182 new_sz = (sz .- 1).*r .+ 1 182 new_sz = (sz .- 1).*r .+ 1
183 return EquidistantGrid{dimension(grid), eltype(grid)}(new_sz, grid.limit_lower, grid.limit_upper) 183 return EquidistantGrid{dim(grid), eltype(grid)}(new_sz, grid.limit_lower, grid.limit_upper)
184 end 184 end
185 185
186 """ 186 """
187 coarsen(grid::EquidistantGrid, r::Int) 187 coarsen(grid::EquidistantGrid, r::Int)
188 188
199 throw(DomainError(r, "Size minus 1 must be divisible by the ratio.")) 199 throw(DomainError(r, "Size minus 1 must be divisible by the ratio."))
200 end 200 end
201 201
202 new_sz = (sz .- 1).÷r .+ 1 202 new_sz = (sz .- 1).÷r .+ 1
203 203
204 return EquidistantGrid{dimension(grid), eltype(grid)}(new_sz, grid.limit_lower, grid.limit_upper) 204 return EquidistantGrid{dim(grid), eltype(grid)}(new_sz, grid.limit_lower, grid.limit_upper)
205 end 205 end