Mercurial > repos > public > sbplib_julia
comparison src/Grids/equidistant_grid.jl @ 1557:9113f437431d feature/grids/curvilinear
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Sat, 13 Apr 2024 23:52:40 +0200 |
| parents | 4df668d00d03 43aaf710463e |
| children | b9c7bab94241 b02917bcd7d5 |
comparison
equal
deleted
inserted
replaced
| 1527:69790e9d1652 | 1557:9113f437431d |
|---|---|
| 86 return EquidistantGrid(change_length(g.points, new_sz)) | 86 return EquidistantGrid(change_length(g.points, new_sz)) |
| 87 end | 87 end |
| 88 | 88 |
| 89 | 89 |
| 90 """ | 90 """ |
| 91 equidistant_grid(size::Dims, limit_lower, limit_upper) | 91 equidistant_grid(limit_lower, limit_upper, dims...) |
| 92 | 92 |
| 93 Construct an equidistant grid with corners at the coordinates `limit_lower` and | 93 Construct an equidistant grid with corners at the coordinates `limit_lower` and |
| 94 `limit_upper`. | 94 `limit_upper`. |
| 95 | 95 |
| 96 The length of the domain sides are given by the components of | 96 The length of the domain sides are given by the components of |
| 97 `limit_upper-limit_lower`. E.g for a 2D grid with `limit_lower=(-1,0)` and | 97 `limit_upper-limit_lower`. E.g for a 2D grid with `limit_lower=(-1,0)` and |
| 98 `limit_upper=(1,2)` the domain is defined as `(-1,1)x(0,2)`. The side lengths | 98 `limit_upper=(1,2)` the domain is defined as `(-1,1)x(0,2)`. The side lengths |
| 99 of the grid are not allowed to be negative. | 99 of the grid are not allowed to be negative. |
| 100 | 100 |
| 101 The number of equispaced points in each coordinate direction are given | 101 The number of equispaced points in each coordinate direction are given |
| 102 by the tuple `size`. | 102 by the tuple `dims`. |
| 103 | 103 |
| 104 Note: If `limit_lower` and `limit_upper` are integers and `size` would allow a | 104 Note: If `limit_lower` and `limit_upper` are integers and `dims` would allow a |
| 105 completely integer grid, `equidistant_grid` will still return a floating point | 105 completely integer grid, `equidistant_grid` will still return a floating point |
| 106 grid. This simplifies the implementation and avoids certain surprise | 106 grid. This simplifies the implementation and avoids certain surprise |
| 107 behaviors. | 107 behaviors. |
| 108 """ | 108 """ |
| 109 # TODO: Change signature to `equidistant_grid(limit_lower,limit_upper, size...) | 109 function equidistant_grid(limit_lower, limit_upper, dims::Vararg{Int}) |
| 110 function equidistant_grid(size::Dims, limit_lower, limit_upper) | 110 gs = map(equidistant_grid, limit_lower, limit_upper, dims) |
| 111 gs = map(equidistant_grid, size, limit_lower, limit_upper) | |
| 112 return TensorGrid(gs...) | 111 return TensorGrid(gs...) |
| 113 end | 112 end |
| 114 | 113 |
| 115 """ | 114 """ |
| 116 equidistant_grid(size::Int, limit_lower::T, limit_upper::T) | 115 equidistant_grid(limit_lower::T, limit_upper::T, size::Int) |
| 117 | 116 |
| 118 Constructs a 1D equidistant grid. | 117 Constructs a 1D equidistant grid. |
| 119 """ | 118 """ |
| 120 function equidistant_grid(size::Int, limit_lower::T, limit_upper::T) where T | 119 function equidistant_grid(limit_lower::T, limit_upper::T, size::Int) where T |
| 121 if any(size .<= 0) | 120 if any(size .<= 0) |
| 122 throw(DomainError("size must be postive")) | 121 throw(DomainError("size must be postive")) |
| 123 end | 122 end |
| 124 | 123 |
| 125 if any(limit_upper.-limit_lower .<= 0) | 124 if any(limit_upper.-limit_lower .<= 0) |
