comparison 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
comparison
equal deleted inserted replaced
1464:37cf9f79caa4 1465:88e738d807cb
84 new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(id)) 84 new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(id))
85 return TensorGrid(new_grids...) 85 return TensorGrid(new_grids...)
86 end 86 end
87 87
88 88
89 function boundary_indices(g::TensorGrid, id::TensorGridBoundary)
90 per_grid_ind = map(g.grids) do g
91 ntuple(i->:, ndims(g))
92 end
93
94 local_b_ind = boundary_indices(g.grids[grid_id(id)], boundary_id(id))
95 b_ind = Base.setindex(per_grid_ind, local_b_ind, grid_id(id))
96
97 return LazyTensors.concatenate_tuples(b_ind...)
98 end
99
89 function combined_coordinate_vector_type(coordinate_types...) 100 function combined_coordinate_vector_type(coordinate_types...)
90 combined_coord_length = mapreduce(_ncomponents, +, coordinate_types) 101 combined_coord_length = mapreduce(_ncomponents, +, coordinate_types)
91 combined_coord_type = mapreduce(eltype, promote_type, coordinate_types) 102 combined_coord_type = mapreduce(eltype, promote_type, coordinate_types)
92 103
93 if combined_coord_length == 1 104 if combined_coord_length == 1