Mercurial > repos > public > sbplib_julia
comparison src/Grids/tensor_grid.jl @ 1829:871f3f1decea refactor/grids/iterable_boundary_indices
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 20 Oct 2024 21:38:09 +0200 |
parents | 8adecef380b4 863385aae454 |
children | 0e0833663dee |
comparison
equal
deleted
inserted
replaced
1828:8adecef380b4 | 1829:871f3f1decea |
---|---|
45 Base.IteratorSize(::Type{<:TensorGrid{<:Any, D}}) where D = Base.HasShape{D}() | 45 Base.IteratorSize(::Type{<:TensorGrid{<:Any, D}}) where D = Base.HasShape{D}() |
46 Base.length(g::TensorGrid) = prod(length, g.grids) | 46 Base.length(g::TensorGrid) = prod(length, g.grids) |
47 Base.size(g::TensorGrid) = LazyTensors.concatenate_tuples(size.(g.grids)...) | 47 Base.size(g::TensorGrid) = LazyTensors.concatenate_tuples(size.(g.grids)...) |
48 Base.size(g::TensorGrid, d) = size(g)[d] | 48 Base.size(g::TensorGrid, d) = size(g)[d] |
49 | 49 |
50 | |
51 function min_spacing(g::TensorGrid) | |
52 relevant_grids = filter(g->!isa(g,ZeroDimGrid),g.grids) | |
53 d = min_spacing.(relevant_grids) | |
54 return minimum(d) | |
55 end | |
50 | 56 |
51 refine(g::TensorGrid, r::Int) = mapreduce(g->refine(g,r), TensorGrid, g.grids) | 57 refine(g::TensorGrid, r::Int) = mapreduce(g->refine(g,r), TensorGrid, g.grids) |
52 coarsen(g::TensorGrid, r::Int) = mapreduce(g->coarsen(g,r), TensorGrid, g.grids) | 58 coarsen(g::TensorGrid, r::Int) = mapreduce(g->coarsen(g,r), TensorGrid, g.grids) |
53 | 59 |
54 """ | 60 """ |
121 function combine_coordinates(coords...) | 127 function combine_coordinates(coords...) |
122 return mapreduce(SVector, vcat, coords) | 128 return mapreduce(SVector, vcat, coords) |
123 end | 129 end |
124 | 130 |
125 """ | 131 """ |
126 grid_and_local_dim_index(nds, d) | 132 grid_and_local_dim_index(nds, d) |
127 | 133 |
128 Given a tuple of number of dimensions `nds`, and a global dimension index `d`, | 134 Given a tuple of number of dimensions `nds`, and a global dimension index `d`, |
129 calculate which grid index, and local dimension, `d` corresponds to. | 135 calculate which grid index, and local dimension, `d` corresponds to. |
130 | 136 |
131 `nds` would come from broadcasting `ndims` on the grids tuple of a | 137 `nds` would come from broadcasting `ndims` on the grids tuple of a |