Mercurial > repos > public > sbplib_julia
comparison src/Grids/EquidistantGrid.jl @ 661:f0ceddeae993 feature/get_boundary_identifiers
Fix and test type stability of boundary_identifiers.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Sun, 31 Jan 2021 13:04:19 +0100 |
parents | aa3066010569 |
children | 1d3e29ffc6c6 |
comparison
equal
deleted
inserted
replaced
660:b21fea54ca10 | 661:f0ceddeae993 |
---|---|
39 CartesianIndices(grid.size) | 39 CartesianIndices(grid.size) |
40 end | 40 end |
41 | 41 |
42 Base.size(g::EquidistantGrid) = g.size | 42 Base.size(g::EquidistantGrid) = g.size |
43 | 43 |
44 # TODO: Change to ndims? Seem to be the julia naming convention, at least for AbstractArrays. | |
45 """ | 44 """ |
46 dimension(grid::EquidistantGrid) | 45 dimension(grid::EquidistantGrid) |
47 | 46 |
48 The dimension of the grid. | 47 The dimension of the grid. |
49 """ | 48 """ |
101 (CartesianBoundary(1,Lower), | 100 (CartesianBoundary(1,Lower), |
102 CartesianBoundary(1,Upper), | 101 CartesianBoundary(1,Upper), |
103 CartesianBoundary(2,Lower), | 102 CartesianBoundary(2,Lower), |
104 ...) | 103 ...) |
105 """ | 104 """ |
106 function boundary_identifiers(g::EquidistantGrid) | 105 boundary_identifiers(g::EquidistantGrid) = (((ntuple(i->(CartesianBoundary{i,Lower}(),CartesianBoundary{i,Upper}()),dimension(g)))...)...,) |
107 bids = () | |
108 for i=1:dimension(g) | |
109 for r ∈ (Lower,Upper) | |
110 bids = (bids...,CartesianBoundary{i,r}()) | |
111 end | |
112 end | |
113 return bids | |
114 end | |
115 export boundary_identifiers | 106 export boundary_identifiers |