Mercurial > repos > public > sbplib_julia
diff src/Grids/zero_dim_grid.jl @ 1395:bdcdbd4ea9cd feature/boundary_conditions
Merge with default. Comment out broken tests for boundary_conditions at sat
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 26 Jul 2023 21:35:50 +0200 |
parents | 8860bfcaedaa |
children | 4ad1282f8bab |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Grids/zero_dim_grid.jl Wed Jul 26 21:35:50 2023 +0200 @@ -0,0 +1,27 @@ +""" + ZeroDimGrid{T} <: Grid{T,0} + +A zero dimensional grid consisting of a single point. +""" +struct ZeroDimGrid{T} <: Grid{T,0} + point::T +end + +# Indexing interface +Base.getindex(g::ZeroDimGrid) = g.point +Base.eachindex(g::ZeroDimGrid) = CartesianIndices(()) + +# Iteration interface +Base.iterate(g::ZeroDimGrid) = (g.point, nothing) +Base.iterate(g::ZeroDimGrid, ::Any) = nothing + +Base.IteratorSize(::Type{<:ZeroDimGrid}) = Base.HasShape{0}() +Base.length(g::ZeroDimGrid) = 1 +Base.size(g::ZeroDimGrid) = () + + +refine(g::ZeroDimGrid, ::Int) = g +coarsen(g::ZeroDimGrid, ::Int) = g + +boundary_identifiers(g::ZeroDimGrid) = () +boundary_grid(g::ZeroDimGrid, ::Any) = throw(ArgumentError("ZeroDimGrid has no boundaries"))