Mercurial > repos > public > sbplib_julia
comparison src/Grids/equidistant_grid.jl @ 1347:08f06bfacd5c refactor/grids
Fix typos and formatting of documentation
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 18 May 2023 22:53:31 +0200 |
parents | 760a4a1ec4b7 |
children | 4684c7f1c4cb |
comparison
equal
deleted
inserted
replaced
1345:c2012db881cb | 1347:08f06bfacd5c |
---|---|
51 | 51 |
52 | 52 |
53 """ | 53 """ |
54 refine(g::EquidistantGrid, r::Int) | 54 refine(g::EquidistantGrid, r::Int) |
55 | 55 |
56 Refines `grid` by a factor `r`. The factor is applied to the number of | 56 The grid where `g` is refined by the factor `r`. The factor is applied to the number of |
57 intervals which is 1 less than the size of the grid. | 57 intervals, i.e., 1 less than the size of `g`. |
58 | 58 |
59 See also: [`coarsen`](@ref) | 59 See also: [`coarsen`](@ref) |
60 """ | 60 """ |
61 function refine(g::EquidistantGrid, r::Int) | 61 function refine(g::EquidistantGrid, r::Int) |
62 new_sz = (length(g) - 1)*r + 1 | 62 new_sz = (length(g) - 1)*r + 1 |
63 return EquidistantGrid(change_length(g.points, new_sz)) | 63 return EquidistantGrid(change_length(g.points, new_sz)) |
64 end | 64 end |
65 | 65 |
66 """ | 66 """ |
67 coarsen(grid::EquidistantGrid, r::Int) | 67 coarsen(g::EquidistantGrid, r::Int) |
68 | 68 |
69 Coarsens `grid` by a factor `r`. The factor is applied to the number of | 69 The grid where `g` is coarsened by the factor `r`. The factor is applied to the number of |
70 intervals which is 1 less than the size of the grid. If the number of | 70 intervals, i.e., 1 less than the size of `g`. If the number of |
71 intervals are not divisible by `r` an error is raised. | 71 intervals are not divisible by `r` an error is raised. |
72 | 72 |
73 See also: [`refine`](@ref) | 73 See also: [`refine`](@ref) |
74 """ | 74 """ |
75 function coarsen(g::EquidistantGrid, r::Int) | 75 function coarsen(g::EquidistantGrid, r::Int) |
92 The length of the domain sides are given by the components of | 92 The length of the domain sides are given by the components of |
93 `limit_upper-limit_lower`. E.g for a 2D grid with `limit_lower=(-1,0)` and | 93 `limit_upper-limit_lower`. E.g for a 2D grid with `limit_lower=(-1,0)` and |
94 `limit_upper=(1,2)` the domain is defined as `(-1,1)x(0,2)`. The side lengths | 94 `limit_upper=(1,2)` the domain is defined as `(-1,1)x(0,2)`. The side lengths |
95 of the grid are not allowed to be negative. | 95 of the grid are not allowed to be negative. |
96 | 96 |
97 The number of equidistantly spaced points in each coordinate direction are given | 97 The number of equispaced points in each coordinate direction are given |
98 by the tuple `size`. | 98 by the tuple `size`. |
99 | 99 |
100 Note: If `limit_lower` and `limit_upper` are integers and `size` would allow a | 100 Note: If `limit_lower` and `limit_upper` are integers and `size` would allow a |
101 completely integer grid, `equidistant_grid` will still return a floating point | 101 completely integer grid, `equidistant_grid` will still return a floating point |
102 grid. This simlifies the implementation and avoids certain surprise | 102 grid. This simlifies the implementation and avoids certain surprise |
125 | 125 |
126 CartesianBoundary{D,BID} = TensorGridBoundary{D,BID} # TBD: What should we do about the naming of this boundary? | 126 CartesianBoundary{D,BID} = TensorGridBoundary{D,BID} # TBD: What should we do about the naming of this boundary? |
127 | 127 |
128 | 128 |
129 """ | 129 """ |
130 change_length(::AbstractRange, n) | 130 change_length(r::AbstractRange, n) |
131 | 131 |
132 Change the length of a range to `n`, keeping the same start and stop. | 132 Change the length of `r` to `n`, keeping the same start and stop. |
133 """ | 133 """ |
134 function change_length end | 134 function change_length end |
135 | 135 |
136 change_length(r::UnitRange, n) = StepRange{Int,Int}(range(r[begin], r[end], n)) | 136 change_length(r::UnitRange, n) = StepRange{Int,Int}(range(r[begin], r[end], n)) |
137 change_length(r::StepRange, n) = StepRange{Int,Int}(range(r[begin], r[end], n)) | 137 change_length(r::StepRange, n) = StepRange{Int,Int}(range(r[begin], r[end], n)) |