Mercurial > repos > public > sbplib_julia
comparison src/Grids/equidistant_grid.jl @ 1247:2abec782cf5b refactor/grids
Add todo for EquidistantGrid docs, improve equidistant_grid docs
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 22 Feb 2023 12:41:14 +0100 |
| parents | 5f677cd6f0b6 |
| children | a5f2372d0e87 |
comparison
equal
deleted
inserted
replaced
| 1246:476b889f0ffa | 1247:2abec782cf5b |
|---|---|
| 1 """ | |
| 2 # TODO: | |
| 3 """ | |
| 4 #TODO: Document recomendations for type of range. (LinRange is faster?) | |
| 1 struct EquidistantGrid{T,R<:AbstractRange{T}} <: Grid{T,1,1} | 5 struct EquidistantGrid{T,R<:AbstractRange{T}} <: Grid{T,1,1} |
| 2 points::R | 6 points::R |
| 3 end | 7 end |
| 4 | 8 |
| 5 Base.eltype(g::EquidistantGrid{T}) where T = T | 9 Base.eltype(g::EquidistantGrid{T}) where T = T |
| 75 | 79 |
| 76 Construct an equidistant grid with corners at the coordinates `limit_lower` and | 80 Construct an equidistant grid with corners at the coordinates `limit_lower` and |
| 77 `limit_upper`. | 81 `limit_upper`. |
| 78 | 82 |
| 79 The length of the domain sides are given by the components of | 83 The length of the domain sides are given by the components of |
| 80 `limit_upper-limit_lower`. E.g for a 2D grid with `limit_lower=(-1,0)` and `limit_upper=(1,2)` the domain is defined | 84 `limit_upper-limit_lower`. E.g for a 2D grid with `limit_lower=(-1,0)` and |
| 81 as `(-1,1)x(0,2)`. The side lengths of the grid are not allowed to be negative. | 85 `limit_upper=(1,2)` the domain is defined as `(-1,1)x(0,2)`. The side lengths |
| 86 of the grid are not allowed to be negative. | |
| 82 | 87 |
| 83 The number of equidistantly spaced points in each coordinate direction are given | 88 The number of equidistantly spaced points in each coordinate direction are given |
| 84 by the tuple `size`. | 89 by the tuple `size`. |
| 90 | |
| 91 Note: If `limit_lower` and `limit_upper` are integers and `size` would allow a | |
| 92 completely integer grid, `equidistant_grid` will still return a floating point | |
| 93 grid. This simlifies the implementation and avoids certain surprise | |
| 94 behaviours. | |
| 85 """ | 95 """ |
| 86 function equidistant_grid(size::Dims, limit_lower, limit_upper) | 96 function equidistant_grid(size::Dims, limit_lower, limit_upper) |
| 87 gs = map(size, limit_lower, limit_upper) do s,l,u | 97 gs = map(size, limit_lower, limit_upper) do s,l,u |
| 88 EquidistantGrid(range(l, u, length=s)) # TBD: Should it use LinRange instead? | 98 EquidistantGrid(range(l, u, length=s)) # TBD: Should it use LinRange instead? |
| 89 end | 99 end |
