diff 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
line wrap: on
line diff
--- a/src/Grids/curvilinear_grid.jl	Thu Nov 23 10:16:19 2023 +0100
+++ b/src/Grids/curvilinear_grid.jl	Thu Nov 23 16:08:47 2023 +0100
@@ -26,48 +26,16 @@
 Base.size(g::CurvilinearGrid) = size(g.logicalgrid)
 Base.size(g::CurvilinearGrid, d) = size(g.logicalgrid, d)
 
-
-# refine(g::TensorGrid, r::Int) = mapreduce(g->refine(g,r), TensorGrid, g.grids)
-# coarsen(g::TensorGrid, r::Int) = mapreduce(g->coarsen(g,r), TensorGrid, g.grids)
-
-# """
-#     TensorGridBoundary{N, BID} <: BoundaryIdentifier
-
-# A boundary identifier for a tensor grid. `N` Specifies which grid in the
-# tensor product and `BID` which boundary on that grid.
-# """
-# struct TensorGridBoundary{N, BID} <: BoundaryIdentifier end
-# grid_id(::TensorGridBoundary{N, BID}) where {N, BID} = N
-# boundary_id(::TensorGridBoundary{N, BID}) where {N, BID} = BID()
-
-# """
-#     boundary_identifiers(g::TensorGrid)
+boundary_identifiers(g::CurvilinearGrid) = boundary_identifiers(g.logicalgrid)
 
-# Returns a tuple containing the boundary identifiers of `g`.
-# """
-# function boundary_identifiers(g::TensorGrid)
-#     per_grid = map(eachindex(g.grids)) do i
-#         return map(bid -> TensorGridBoundary{i, typeof(bid)}(), boundary_identifiers(g.grids[i]))
-#     end
-#     return LazyTensors.concatenate_tuples(per_grid...)
-# end
-
-
-# """
-#     boundary_grid(g::TensorGrid, id::TensorGridBoundary)
-
-# The grid for the boundary of `g` specified by `id`.
-# """
-# function boundary_grid(g::TensorGrid, id::TensorGridBoundary)
-#     local_boundary_grid = boundary_grid(g.grids[grid_id(id)], boundary_id(id))
-#     new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(id))
-#     return TensorGrid(new_grids...)
-# end
-
-
-
-
-
+function boundary_grid(g::CurvilinearGrid, id::TensorGridBoundary)
+    b_indices = boundary_indices(g.logicalgrid, id)
+    return CurvilinearGrid(
+        boundary_grid(g.logicalgrid, id),
+        g.physicalcoordinates[b_indices],
+        g.jacobian[b_indices],
+    )
+end