changeset 1832:85f8855473ab refactor/grids/iterable_boundary_indices

Update implementation of MappedGrid
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 20 Oct 2024 22:08:26 +0200
parents 27e74f524c4f
children 0e0833663dee
files src/Grids/mapped_grid.jl
diffstat 1 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/Grids/mapped_grid.jl	Sun Oct 20 21:50:18 2024 +0200
+++ b/src/Grids/mapped_grid.jl	Sun Oct 20 22:08:26 2024 +0200
@@ -82,8 +82,8 @@
     jacobian_components = (:, free_variable_indices)
 
     # Create grid function for boundary grid jacobian
-    boundary_jacobian = componentview((@view g.jacobian[b_indices...])  , jacobian_components...)
-    boundary_physicalcoordinates = @view g.physicalcoordinates[b_indices...]
+    boundary_jacobian = componentview((@view g.jacobian[b_indices])  , jacobian_components...)
+    boundary_physicalcoordinates = @view g.physicalcoordinates[b_indices]
 
     return MappedGrid(
         boundary_grid(g.logical_grid, id),
@@ -171,14 +171,8 @@
 The outward pointing normal as a grid function on the corresponding boundary grid.
 """
 function normal(g::MappedGrid, boundary)
-    b_indices = boundary_indices(g, boundary)
-    σ = _boundary_sign(component_type(g), boundary)
-
-    # TODO: Refactor this when `boundary_indices(g, ...)` has been made iterable.
-    return map(jacobian(g)[b_indices...]) do ∂x∂ξ
-        ∂ξ∂x = inv(∂x∂ξ)
-        k = grid_id(boundary)
-        σ*∂ξ∂x[k,:]/norm(∂ξ∂x[k,:])
+    return map(boundary_indices(g, boundary)) do I
+        normal(g, boundary, Tuple(I)...)
     end
 end