comparison src/Grids/curvilinear_grid.jl @ 1451:2e08f3444354 feature/grids/curvilinear

Implement boundary_identifiers, and a wishful implementation of boundary_grid
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 23 Nov 2023 16:08:47 +0100
parents 647c8b18b84f
children 58b8da9c7e56
comparison
equal deleted inserted replaced
1450:647c8b18b84f 1451:2e08f3444354
24 Base.IteratorSize(::Type{<:CurvilinearGrid{<:Any, D}}) where D = Base.HasShape{D}() 24 Base.IteratorSize(::Type{<:CurvilinearGrid{<:Any, D}}) where D = Base.HasShape{D}()
25 Base.length(g::CurvilinearGrid) = length(g.logicalgrid) 25 Base.length(g::CurvilinearGrid) = length(g.logicalgrid)
26 Base.size(g::CurvilinearGrid) = size(g.logicalgrid) 26 Base.size(g::CurvilinearGrid) = size(g.logicalgrid)
27 Base.size(g::CurvilinearGrid, d) = size(g.logicalgrid, d) 27 Base.size(g::CurvilinearGrid, d) = size(g.logicalgrid, d)
28 28
29 boundary_identifiers(g::CurvilinearGrid) = boundary_identifiers(g.logicalgrid)
29 30
30 # refine(g::TensorGrid, r::Int) = mapreduce(g->refine(g,r), TensorGrid, g.grids) 31 function boundary_grid(g::CurvilinearGrid, id::TensorGridBoundary)
31 # coarsen(g::TensorGrid, r::Int) = mapreduce(g->coarsen(g,r), TensorGrid, g.grids) 32 b_indices = boundary_indices(g.logicalgrid, id)
32 33 return CurvilinearGrid(
33 # """ 34 boundary_grid(g.logicalgrid, id),
34 # TensorGridBoundary{N, BID} <: BoundaryIdentifier 35 g.physicalcoordinates[b_indices],
35 36 g.jacobian[b_indices],
36 # A boundary identifier for a tensor grid. `N` Specifies which grid in the 37 )
37 # tensor product and `BID` which boundary on that grid. 38 end
38 # """
39 # struct TensorGridBoundary{N, BID} <: BoundaryIdentifier end
40 # grid_id(::TensorGridBoundary{N, BID}) where {N, BID} = N
41 # boundary_id(::TensorGridBoundary{N, BID}) where {N, BID} = BID()
42
43 # """
44 # boundary_identifiers(g::TensorGrid)
45
46 # Returns a tuple containing the boundary identifiers of `g`.
47 # """
48 # function boundary_identifiers(g::TensorGrid)
49 # per_grid = map(eachindex(g.grids)) do i
50 # return map(bid -> TensorGridBoundary{i, typeof(bid)}(), boundary_identifiers(g.grids[i]))
51 # end
52 # return LazyTensors.concatenate_tuples(per_grid...)
53 # end
54
55
56 # """
57 # boundary_grid(g::TensorGrid, id::TensorGridBoundary)
58
59 # The grid for the boundary of `g` specified by `id`.
60 # """
61 # function boundary_grid(g::TensorGrid, id::TensorGridBoundary)
62 # local_boundary_grid = boundary_grid(g.grids[grid_id(id)], boundary_id(id))
63 # new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(id))
64 # return TensorGrid(new_grids...)
65 # end
66
67
68
69
70
71 39
72 40
73 41
74 # Do we add a convenience function `curvilinear_grid`? It could help with 42 # Do we add a convenience function `curvilinear_grid`? It could help with
75 # creating the logical grid, evaluating functions and possibly calculating the 43 # creating the logical grid, evaluating functions and possibly calculating the