Mercurial > repos > public > sbplib_julia
view src/Grids/zero_dim_grid.jl @ 1354:150313ed2cae
Merge refactor/grids (missed delete of a note)
Changes from previous merge:
* `EquidistantGrid` is now only a 1D thing.
* Higher dimensions are supported through `TensorGrid`.
* The old behavior of `EquidistantGrid` has been moved to the function `equidistant_grid`.
* Grids embedded in higher dimensions are now supported through tensor products with `ZeroDimGrid`s.
* Vector valued grid functions are now supported and the default element type is `SVector`.
* Grids are now expected to support Julia's indexing and iteration interface.
* `eval_on` can be called with both `f(x,y,...)` and `f(x̄)`.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 20 May 2023 14:19:20 +0200 |
parents | 8860bfcaedaa |
children | 4ad1282f8bab |
line wrap: on
line source
""" 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"))