Mercurial > repos > public > sbplib_julia
diff src/Grids/equidistant_grid.jl @ 1282:11b08b242e48 refactor/grids
Make equdistant_grid return an EquidistantGrid for the 1d Case
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 27 Feb 2023 15:39:13 +0100 |
parents | 17d435c08773 |
children | ed3ea0630825 |
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl Mon Feb 27 08:48:38 2023 +0100 +++ b/src/Grids/equidistant_grid.jl Mon Feb 27 15:39:13 2023 +0100 @@ -96,30 +96,24 @@ behaviours. """ function equidistant_grid(size::Dims, limit_lower, limit_upper) - if any(size .<= 0) - throw(DomainError("all components of size must be postive")) - end - - if any(limit_upper.-limit_lower .<= 0) - throw(DomainError("all side lengths must be postive")) - end - - gs = map(size, limit_lower, limit_upper) do s,l,u - EquidistantGrid(range(l, u, length=s)) # TBD: Should it use LinRange instead? - end - + gs = map(equidistant_grid, size, limit_lower, limit_upper) return TensorGrid(gs...) end - """ equidistant_grid(size::Int, limit_lower::T, limit_upper::T) Constructs a 1D equidistant grid. """ function equidistant_grid(size::Int, limit_lower::T, limit_upper::T) where T - # TBD: Should this really return a TensorGrid? - return equidistant_grid((size,),(limit_lower,),(limit_upper,)) + if any(size .<= 0) + throw(DomainError("size must be postive")) + end + + if any(limit_upper.-limit_lower .<= 0) + throw(DomainError("side length must be postive")) + end + return EquidistantGrid(range(limit_lower, limit_upper, length=size)) # TBD: Should it use LinRange instead? end CartesianBoundary{D,BID} = TensorGridBoundary{D,BID} # TBD: What should we do about the naming of this boundary?