Mercurial > repos > public > sbplib_julia
changeset 1833:0e0833663dee refactor/grids/iterable_boundary_indices
Simplify code for tensor grids
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 21 Oct 2024 23:50:14 +0200 |
parents | 85f8855473ab |
children | aa7da5c899d8 |
files | src/Grids/tensor_grid.jl |
diffstat | 1 files changed, 2 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/tensor_grid.jl Sun Oct 20 22:08:26 2024 +0200 +++ b/src/Grids/tensor_grid.jl Mon Oct 21 23:50:14 2024 +0200 @@ -95,24 +95,13 @@ return boundary_indices(g.grids[grid_id(id)], boundary_id(id)) end function boundary_indices(g::TensorGrid, id::TensorGridBoundary) - all_indices = map(eachindex, g.grids) - local_b_ind = boundary_indices(g.grids[grid_id(id)], boundary_id(id)) - b_ind = Base.setindex(all_indices, local_b_ind, grid_id(id)) - - return view(_combine_indices(all_indices...), LazyTensors.concatenate_tuples(bla.(b_ind)...)...) -end -# TODO: There must be a way to make the above code cleaner? + b_ind = Base.setindex(map(eachindex, g.grids), local_b_ind, grid_id(id)) -# function _combine_indices(Is::Vararg{Union{Int, <:AbstractRange}}) -function _combine_indices(Is...) - return CartesianIndices(LazyTensors.concatenate_tuples(bla.(Is)...)) + return view(eachindex(g), b_ind...) end -bla(a) = (a,) -bla(a::CartesianIndices) = a.indices - function combined_coordinate_vector_type(coordinate_types...) combined_coord_length = mapreduce(_ncomponents, +, coordinate_types) combined_coord_type = mapreduce(eltype, promote_type, coordinate_types)