Mercurial > repos > public > sbplib_julia
comparison src/Grids/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 | 4d628c83987e 86026367a9ff |
comparison
equal
deleted
inserted
replaced
1345:c2012db881cb | 1347:08f06bfacd5c |
---|---|
12 indexing and iteration. | 12 indexing and iteration. |
13 | 13 |
14 ## Note | 14 ## Note |
15 | 15 |
16 Importantly a grid does not have to be an `AbstractArray`. The reason is to | 16 Importantly a grid does not have to be an `AbstractArray`. The reason is to |
17 allow flexible handling of special types of grids like multiblock-grids, or | 17 allow flexible handling of special types of grids like multi-block grids, or |
18 grids with special indexing. | 18 grids with special indexing. |
19 """ | 19 """ |
20 abstract type Grid{T,D} end | 20 abstract type Grid{T,D} end |
21 | 21 |
22 Base.ndims(::Grid{T,D}) where {T,D} = D | 22 Base.ndims(::Grid{T,D}) where {T,D} = D |
23 Base.eltype(::Type{<:Grid{T}}) where T = T | 23 Base.eltype(::Type{<:Grid{T}}) where T = T |
24 | 24 |
25 """ | 25 """ |
26 coordinate_size(grid) | 26 coordinate_size(g) |
27 | 27 |
28 The lenght of the coordinate vector for the given grid. | 28 The lenght of the coordinate vector of `Grid` `g`. |
29 """ | 29 """ |
30 coordinate_size(::Type{<:Grid{T}}) where T = _ncomponents(T) | 30 coordinate_size(::Type{<:Grid{T}}) where T = _ncomponents(T) |
31 coordinate_size(g::Grid) = coordinate_size(typeof(g)) # TBD: Name of this function?! | 31 coordinate_size(g::Grid) = coordinate_size(typeof(g)) # TBD: Name of this function?! |
32 | 32 |
33 """ | 33 """ |
34 component_type(grid) | 34 component_type(g) |
35 | 35 |
36 The type of the components of the coordinate vector. | 36 The type of the components of the coordinate vector of `Grid` `g`. |
37 """ | 37 """ |
38 component_type(::Type{<:Grid{T}}) where T = eltype(T) | 38 component_type(::Type{<:Grid{T}}) where T = eltype(T) |
39 component_type(g::Grid) = component_type(typeof(g)) | 39 component_type(g::Grid) = component_type(typeof(g)) |
40 | 40 |
41 """ | 41 """ |
42 refine(g::Grid, r) | 42 refine(g::Grid, r) |
43 | 43 |
44 `g` refined by the factor `r`. | 44 The grid where `g` is refined by the factor `r`. |
45 | 45 |
46 See also: [`coarsen`](@ref). | 46 See also: [`coarsen`](@ref). |
47 """ | 47 """ |
48 function refine end | 48 function refine end |
49 | 49 |
50 """ | 50 """ |
51 coarsen(g::Grid, r) | 51 coarsen(g::Grid, r) |
52 | 52 |
53 `g` coarsened by the factor `r`. | 53 The grid where `g` is coarsened by the factor `r`. |
54 | 54 |
55 See also: [`refine`](@ref). | 55 See also: [`refine`](@ref). |
56 """ | 56 """ |
57 function coarsen end | 57 function coarsen end |
58 | 58 |
62 Identifiers for all the boundaries of `g`. | 62 Identifiers for all the boundaries of `g`. |
63 """ | 63 """ |
64 function boundary_identifiers end | 64 function boundary_identifiers end |
65 | 65 |
66 """ | 66 """ |
67 boundary_grid(g::Grid, bid::BoundaryIdentifier) | 67 boundary_grid(g::Grid, id::BoundaryIdentifier) |
68 | 68 |
69 The grid for the specified boundary. | 69 The grid for the boundary specified by `id`. |
70 """ | 70 """ |
71 function boundary_grid end | 71 function boundary_grid end |
72 # TBD: Can we implement a version here that accepts multiple ids and grouped boundaries? Maybe we need multiblock stuff? | 72 # TBD: Can we implement a version here that accepts multiple ids and grouped boundaries? Maybe we need multiblock stuff? |
73 | 73 |
74 """ | 74 """ |
76 | 76 |
77 Lazy evaluation `f` on the grid. `f` can either be on the form `f(x,y,...)` | 77 Lazy evaluation `f` on the grid. `f` can either be on the form `f(x,y,...)` |
78 with each coordinate as an argument, or on the form `f(x̄)` taking a | 78 with each coordinate as an argument, or on the form `f(x̄)` taking a |
79 coordinate vector. | 79 coordinate vector. |
80 | 80 |
81 If the goal is a concrete array `map(f,g)` can be used instead. | 81 For concrete array grid functions `map(f,g)` can be used instead. |
82 """ | 82 """ |
83 eval_on(g::Grid, f) = eval_on(g, f, Base.IteratorSize(g)) | 83 eval_on(g::Grid, f) = eval_on(g, f, Base.IteratorSize(g)) |
84 function eval_on(g::Grid, f, ::Base.HasShape) | 84 function eval_on(g::Grid, f, ::Base.HasShape) |
85 if hasmethod(f, (Any,)) | 85 if hasmethod(f, (Any,)) |
86 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g)) | 86 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g)) |