Mercurial > repos > public > sbplib_julia
diff src/Grids/tensor_grid.jl @ 1465:88e738d807cb feature/grids/boundary_indicies
Implement boundary_indices for TensorGrid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 29 Nov 2023 09:14:06 +0100 |
parents | c0c5e0620b83 |
children | de4e15924d26 |
line wrap: on
line diff
--- a/src/Grids/tensor_grid.jl Wed Nov 29 09:04:12 2023 +0100 +++ b/src/Grids/tensor_grid.jl Wed Nov 29 09:14:06 2023 +0100 @@ -86,6 +86,17 @@ end +function boundary_indices(g::TensorGrid, id::TensorGridBoundary) + per_grid_ind = map(g.grids) do g + ntuple(i->:, ndims(g)) + end + + local_b_ind = boundary_indices(g.grids[grid_id(id)], boundary_id(id)) + b_ind = Base.setindex(per_grid_ind, local_b_ind, grid_id(id)) + + return LazyTensors.concatenate_tuples(b_ind...) +end + function combined_coordinate_vector_type(coordinate_types...) combined_coord_length = mapreduce(_ncomponents, +, coordinate_types) combined_coord_type = mapreduce(eltype, promote_type, coordinate_types)