Mercurial > repos > public > sbplib_julia
comparison src/Grids/tensor_grid.jl @ 1827:ab397590898e refactor/grids/iterable_boundary_indices
Try to change the implementation
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Tue, 17 Sep 2024 11:19:08 +0200 |
| parents | b459082533f7 |
| children | 8adecef380b4 |
comparison
equal
deleted
inserted
replaced
| 1826:b0c019acb50b | 1827:ab397590898e |
|---|---|
| 82 local_boundary_grid = boundary_grid(g.grids[grid_id(id)], boundary_id(id)) | 82 local_boundary_grid = boundary_grid(g.grids[grid_id(id)], boundary_id(id)) |
| 83 new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(id)) | 83 new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(id)) |
| 84 return TensorGrid(new_grids...) | 84 return TensorGrid(new_grids...) |
| 85 end | 85 end |
| 86 | 86 |
| 87 | |
| 88 function boundary_indices(g::TensorGrid{T,1} where T, id::TensorGridBoundary) | |
| 89 return boundary_indices(g.grids[grid_id(id)], boundary_id(id)) | |
| 90 end | |
| 87 function boundary_indices(g::TensorGrid, id::TensorGridBoundary) | 91 function boundary_indices(g::TensorGrid, id::TensorGridBoundary) |
| 88 per_grid_ind = map(g.grids) do g | 92 all_indices = map(eachindex, g.grids) |
| 89 ntuple(i->:, ndims(g)) | |
| 90 end | |
| 91 | 93 |
| 92 local_b_ind = boundary_indices(g.grids[grid_id(id)], boundary_id(id)) | 94 local_b_ind = boundary_indices(g.grids[grid_id(id)], boundary_id(id)) |
| 93 b_ind = Base.setindex(per_grid_ind, local_b_ind, grid_id(id)) | |
| 94 | 95 |
| 95 return LazyTensors.concatenate_tuples(b_ind...) | 96 b_ind = Base.setindex(all_indices, local_b_ind, grid_id(id)) |
| 97 | |
| 98 return view(_combine_indices(all_indices...), LazyTensors.concatenate_tuples(bla.(b_ind)...)...) | |
| 96 end | 99 end |
| 100 | |
| 101 # function _combine_indices(Is::Vararg{Union{Int, <:AbstractRange}}) | |
| 102 function _combine_indices(Is...) | |
| 103 return CartesianIndices(LazyTensors.concatenate_tuples(bla.(Is)...)) | |
| 104 end | |
| 105 | |
| 106 bla(a) = (a,) | |
| 107 bla(a::CartesianIndices) = a.indices | |
| 97 | 108 |
| 98 function combined_coordinate_vector_type(coordinate_types...) | 109 function combined_coordinate_vector_type(coordinate_types...) |
| 99 combined_coord_length = mapreduce(_ncomponents, +, coordinate_types) | 110 combined_coord_length = mapreduce(_ncomponents, +, coordinate_types) |
| 100 combined_coord_type = mapreduce(eltype, promote_type, coordinate_types) | 111 combined_coord_type = mapreduce(eltype, promote_type, coordinate_types) |
| 101 | 112 |
