comparison src/Grids/zero_dim_grid.jl @ 1351:d7f29359b822

Merge refactor/grids
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 19 May 2023 23:53:36 +0200
parents 8860bfcaedaa
children 4ad1282f8bab
comparison
equal deleted inserted replaced
1323:95cac1ee8476 1351:d7f29359b822
1 """
2 ZeroDimGrid{T} <: Grid{T,0}
3
4 A zero dimensional grid consisting of a single point.
5 """
6 struct ZeroDimGrid{T} <: Grid{T,0}
7 point::T
8 end
9
10 # Indexing interface
11 Base.getindex(g::ZeroDimGrid) = g.point
12 Base.eachindex(g::ZeroDimGrid) = CartesianIndices(())
13
14 # Iteration interface
15 Base.iterate(g::ZeroDimGrid) = (g.point, nothing)
16 Base.iterate(g::ZeroDimGrid, ::Any) = nothing
17
18 Base.IteratorSize(::Type{<:ZeroDimGrid}) = Base.HasShape{0}()
19 Base.length(g::ZeroDimGrid) = 1
20 Base.size(g::ZeroDimGrid) = ()
21
22
23 refine(g::ZeroDimGrid, ::Int) = g
24 coarsen(g::ZeroDimGrid, ::Int) = g
25
26 boundary_identifiers(g::ZeroDimGrid) = ()
27 boundary_grid(g::ZeroDimGrid, ::Any) = throw(ArgumentError("ZeroDimGrid has no boundaries"))