Mercurial > repos > public > sbplib_julia
diff src/Grids/EquidistantGrid.jl @ 366:0af6da238d95
Merge feature/equidistant_grid/subgrid. Add function for getting isolated dimensions of EquidistantGrid
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Mon, 28 Sep 2020 22:49:21 +0200 |
| parents | 64ad8ec0eae0 |
| children | dacbcba33d7d |
line wrap: on
line diff
--- a/src/Grids/EquidistantGrid.jl Sun Sep 27 15:26:05 2020 +0200 +++ b/src/Grids/EquidistantGrid.jl Mon Sep 28 22:49:21 2020 +0200 @@ -66,6 +66,20 @@ return broadcast(I -> grid.limit_lower .+ (I.-1).*h, indices) end +""" + restrict(::EquidistantGrid, dim) + +Pick out given dimensions from the grid and return a grid for them +""" +function restrict(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 restrict + function pointsalongdim(grid::EquidistantGrid, dim::Integer) @assert dim<=dimension(grid) @assert dim>0
