Mercurial > repos > public > sbplib_julia
diff src/Grids/EquidistantGrid.jl @ 355:5c9212a8ee4f refactor/remove_dynamic_size_tensormapping
Merge in subgrid function
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 27 Sep 2020 21:08:18 +0200 |
parents | 8257cc75ea6b |
children | 64ad8ec0eae0 |
line wrap: on
line diff
--- a/src/Grids/EquidistantGrid.jl Sun Sep 27 13:48:13 2020 +0200 +++ b/src/Grids/EquidistantGrid.jl Sun Sep 27 21:08:18 2020 +0200 @@ -66,6 +66,20 @@ return broadcast(I -> grid.limit_lower .+ (I.-1).*h, indices) end +""" + subgrid(::EquidistantGrid, dim) + +Pick out given dimensions from the grid and return a grid for them +""" +function subgrid(grid::EquidistantGrid, dim) + size = grid.size[dim] + limit_lower = grid.limit_lower[dim] + limit_upper = grid.limit_upper[dim] + + return EquidistantGrid(size, limit_lower, limit_upper) +end +export subgrid + function pointsalongdim(grid::EquidistantGrid, dim::Integer) @assert dim<=dimension(grid) @assert dim>0