comparison src/Grids/curvilinear_grid.jl @ 1450:647c8b18b84f feature/grids/curvilinear

Implement iterator interface
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 23 Nov 2023 10:16:19 +0100
parents a0b1449dba4e
children 2e08f3444354
comparison
equal deleted inserted replaced
1449:a0b1449dba4e 1450:647c8b18b84f
14 Base.eachindex(g::CurvilinearGrid) = eachindex(g.logicalgrid) 14 Base.eachindex(g::CurvilinearGrid) = eachindex(g.logicalgrid)
15 15
16 Base.firstindex(g::CurvilinearGrid, d) = firstindex(g.logicalgrid, d) 16 Base.firstindex(g::CurvilinearGrid, d) = firstindex(g.logicalgrid, d)
17 Base.lastindex(g::CurvilinearGrid, d) = lastindex(g.logicalgrid, d) 17 Base.lastindex(g::CurvilinearGrid, d) = lastindex(g.logicalgrid, d)
18 18
19 # Iteration interface
19 20
21 Base.iterate(g::CurvilinearGrid) = iterate(g.physicalcoordinates)
22 Base.iterate(g::CurvilinearGrid, state) = iterate(g.physicalcoordinates, state)
20 23
21 # # Iteration interface 24 Base.IteratorSize(::Type{<:CurvilinearGrid{<:Any, D}}) where D = Base.HasShape{D}()
22 # Base.iterate(g::TensorGrid) = iterate(Iterators.product(g.grids...)) |> _iterate_combine_coords 25 Base.length(g::CurvilinearGrid) = length(g.logicalgrid)
23 # Base.iterate(g::TensorGrid, state) = iterate(Iterators.product(g.grids...), state) |> _iterate_combine_coords 26 Base.size(g::CurvilinearGrid) = size(g.logicalgrid)
24 # _iterate_combine_coords(::Nothing) = nothing 27 Base.size(g::CurvilinearGrid, d) = size(g.logicalgrid, d)
25 # _iterate_combine_coords((next,state)) = combine_coordinates(next...), state
26
27 # Base.IteratorSize(::Type{<:TensorGrid{<:Any, D}}) where D = Base.HasShape{D}()
28 # Base.eltype(::Type{<:TensorGrid{T}}) where T = T
29 # Base.length(g::TensorGrid) = sum(length, g.grids)
30 # Base.size(g::TensorGrid) = LazyTensors.concatenate_tuples(size.(g.grids)...)
31 28
32 29
33 # refine(g::TensorGrid, r::Int) = mapreduce(g->refine(g,r), TensorGrid, g.grids) 30 # refine(g::TensorGrid, r::Int) = mapreduce(g->refine(g,r), TensorGrid, g.grids)
34 # coarsen(g::TensorGrid, r::Int) = mapreduce(g->coarsen(g,r), TensorGrid, g.grids) 31 # coarsen(g::TensorGrid, r::Int) = mapreduce(g->coarsen(g,r), TensorGrid, g.grids)
35 32