Mercurial > repos > public > sbplib_julia
comparison src/Grids/EquidistantGrid.jl @ 658:26b0eb83aea4 feature/get_boundary_identifiers
Add function for getting boundary identifiers from equidistant grid
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Sat, 30 Jan 2021 20:18:37 +0100 |
parents | c377fc37c04b |
children | aa3066010569 |
comparison
equal
deleted
inserted
replaced
657:a768a9efb200 | 658:26b0eb83aea4 |
---|---|
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. | |
44 """ | 45 """ |
45 dimension(grid::EquidistantGrid) | 46 dimension(grid::EquidistantGrid) |
46 | 47 |
47 The dimension of the grid. | 48 The dimension of the grid. |
48 """ | 49 """ |
49 function dimension(grid::EquidistantGrid) | 50 dimension(grid::EquidistantGrid{Dim}) where Dim = Dim |
50 return length(grid.size) | |
51 end | |
52 | |
53 | 51 |
54 """ | 52 """ |
55 spacing(grid::EquidistantGrid) | 53 spacing(grid::EquidistantGrid) |
56 | 54 |
57 The spacing between the grid points of the grid. | 55 The spacing between the grid points of the grid. |
93 limit_upper = grid.limit_upper[dim] | 91 limit_upper = grid.limit_upper[dim] |
94 | 92 |
95 return EquidistantGrid(size, limit_lower, limit_upper) | 93 return EquidistantGrid(size, limit_lower, limit_upper) |
96 end | 94 end |
97 export restrict | 95 export restrict |
96 | |
97 """ | |
98 boundary_identifiers(::EquidistantGrid) | |
99 | |
100 Returns a tuple containing the boundary identifiers for the grid, stored as | |
101 (CartesianBoundary(1,Lower), | |
102 CartesianBoundary(1,Upper), | |
103 CartesianBoundary(2,Lower), | |
104 ...) | |
105 """ | |
106 function boundary_identifiers(g::EquidistantGrid{Dim}) where Dim | |
107 bids = () | |
108 for i=1:Dim | |
109 for r ∈ (Lower,Upper) | |
110 bids = (bids...,CartesianBoundary{i,r}()) | |
111 end | |
112 end | |
113 return bids | |
114 end | |
115 export boundary_identifiers |