Mercurial > repos > public > sbplib_julia
comparison src/Grids/tensor_grid.jl @ 1251:6f75f2d2bf5c refactor/grids
Qualify package when using split_tuple and concatenate_tuple
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 22 Feb 2023 12:45:31 +0100 |
parents | 95e294576c2a |
children | 3fc78ad26d03 |
comparison
equal
deleted
inserted
replaced
1250:40ca0af6e480 | 1251:6f75f2d2bf5c |
---|---|
9 return new{T,D,RD,typeof(gs)}(gs) | 9 return new{T,D,RD,typeof(gs)}(gs) |
10 end | 10 end |
11 end | 11 end |
12 | 12 |
13 function Base.size(g::TensorGrid) | 13 function Base.size(g::TensorGrid) |
14 return concatenate_tuples(size.(g.grids)...) | 14 return LazyTensors.concatenate_tuples(size.(g.grids)...) |
15 end | 15 end |
16 | 16 |
17 function Base.getindex(g::TensorGrid, I...) | 17 function Base.getindex(g::TensorGrid, I...) |
18 szs = ndims.(g.grids) | 18 szs = ndims.(g.grids) |
19 | 19 |
20 Is = split_tuple(I, szs) | 20 Is = LazyTensors.split_tuple(I, szs) |
21 ps = map((g,I)->SVector(g[I...]), g.grids, Is) | 21 ps = map((g,I)->SVector(g[I...]), g.grids, Is) |
22 | 22 |
23 return vcat(ps...) | 23 return vcat(ps...) |
24 end | 24 end |
25 | 25 |
26 IndexStyle(::TensorGrid) = IndexCartesian() | 26 IndexStyle(::TensorGrid) = IndexCartesian() |
27 | 27 |
28 function Base.eachindex(g::TensorGrid) | 28 function Base.eachindex(g::TensorGrid) |
29 szs = concatenate_tuples(size.(g.grids)...) | 29 szs = LazyTensors.concatenate_tuples(size.(g.grids)...) |
30 return CartesianIndices(szs) | 30 return CartesianIndices(szs) |
31 end | 31 end |
32 | 32 |
33 | 33 |
34 struct TensorBoundary{N, BID<:BoundaryIdentifier} <: BoundaryIdentifier end | 34 struct TensorBoundary{N, BID<:BoundaryIdentifier} <: BoundaryIdentifier end |
44 function boundary_identifiers(g::TensorGrid) | 44 function boundary_identifiers(g::TensorGrid) |
45 n = length(g.grids) | 45 n = length(g.grids) |
46 per_grid = map(eachindex(g.grids)) do i | 46 per_grid = map(eachindex(g.grids)) do i |
47 return map(bid -> TensorBoundary{i, bid}(), boundary_identifiers(g.grids[i])) | 47 return map(bid -> TensorBoundary{i, bid}(), boundary_identifiers(g.grids[i])) |
48 end | 48 end |
49 return concatenate_tuples(per_grid...) | 49 return LazyTensors.concatenate_tuples(per_grid...) |
50 end | 50 end |
51 | 51 |
52 | 52 |
53 """ | 53 """ |
54 boundary_grid(grid::TensorGrid, id::TensorBoundary) | 54 boundary_grid(grid::TensorGrid, id::TensorBoundary) |