comparison src/Grids/grid.jl @ 1330:5f05a708d730 refactor/grids

grid.l: More documentation
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 02 May 2023 22:42:25 +0200
parents 0713175a5743
children ed3ea0630825
comparison
equal deleted inserted replaced
1329:e94ddef5e72f 1330:5f05a708d730
13 Base.eltype(::Type{<:Grid{T}}) where T = T 13 Base.eltype(::Type{<:Grid{T}}) where T = T
14 target_manifold_dim(::Grid{T}) where T = _ncomponents(T) # TBD: Name of this function?! 14 target_manifold_dim(::Grid{T}) where T = _ncomponents(T) # TBD: Name of this function?!
15 component_type(::Grid{T}) where T = eltype(T) 15 component_type(::Grid{T}) where T = eltype(T)
16 16
17 """ 17 """
18 # TODO 18 refine(g::Grid, r)
19
20 `g` refined by the factor `r`.
21
22 See also: [`coarsen`](@ref).
19 """ 23 """
20 function refine end 24 function refine end
21 25
22 """ 26 """
23 # TODO 27 coarsen(g::Grid, r)
28
29 `g` coarsened by the factor `r`.
30
31 See also: [`refine`](@ref).
24 """ 32 """
25 function coarsen end 33 function coarsen end
26 34
27 """ 35 """
28 # TODO 36 boundary_identifiers(g::Grid)
37
38 Identifiers for all the boundaries of `g`.
29 """ 39 """
30 function boundary_identifiers end 40 function boundary_identifiers end
31 41
32 """ 42 """
33 # TODO 43 boundary_grid(g::Grid, bid::BoundaryIdentifier)
44
45 The grid for the specified boundary.
34 """ 46 """
35 function boundary_grid end 47 function boundary_grid end
36 # TBD Can we implement a version here that accepts multiple ids and grouped boundaries? Maybe we need multiblock stuff? 48 # TBD: Can we implement a version here that accepts multiple ids and grouped boundaries? Maybe we need multiblock stuff?
37 49
38 50
39 # TODO: Make sure that all grids implement all of the above. 51 # TODO: Make sure that all grids implement all of the above.
40 52
41 53
42 """ 54 """
43 TODO: 55 eval_on(g::Grid, f)
44 56
45 * Mention map(f,g) if you want a concrete array 57 Lazy evaluation `f` on the grid. `f` can either be on the form `f(x,y,...)`
58 with each coordinate as an argument, or on the form `f(x̄)` taking a
59 coordinate vector.
60
61 TODO: Mention map(f,g) if you want a concrete array
46 """ 62 """
47 eval_on(g::Grid, f) = eval_on(g, f, Base.IteratorSize(g)) # TBD: Borde f vara först som i alla map, sum, och dylikt 63 eval_on(g::Grid, f) = eval_on(g, f, Base.IteratorSize(g)) # TBD: Borde f vara först som i alla map, sum, och dylikt
48 function eval_on(g::Grid, f, ::Base.HasShape) 64 function eval_on(g::Grid, f, ::Base.HasShape)
49 if hasmethod(f, (Any,)) 65 if hasmethod(f, (Any,))
50 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g)) 66 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g))
51 else 67 else
52 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]...), size(g)) 68 return LazyTensors.LazyFunctionArray((I...)->f(g[I...]...), size(g))
53 end 69 end
54 end 70 end
71 # TBD: How does `eval_on` relate to `map`. Should the be closer in name?
55 72
56 73
57 # TODO: Explain how and where these are intended to be used 74 # TODO: Explain how and where these are intended to be used
58 _ncomponents(::Type{<:Number}) = 1 75 _ncomponents(::Type{<:Number}) = 1
59 _ncomponents(T::Type{<:SVector}) = length(T) 76 _ncomponents(T::Type{<:SVector}) = length(T)