comparison src/Grids/mapped_grid.jl @ 1901:edee7d677efb feature/grids/manifolds

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 01 Feb 2025 21:38:49 +0100
parents 81559cb7b11c 516eaabf1169
children 04c251bccbd4
comparison
equal deleted inserted replaced
1870:27534b471b6a 1901:edee7d677efb
80 all_indices = SVector{D}(1:D) 80 all_indices = SVector{D}(1:D)
81 free_variable_indices = deleteat(all_indices, grid_id(id)) 81 free_variable_indices = deleteat(all_indices, grid_id(id))
82 jacobian_components = (:, free_variable_indices) 82 jacobian_components = (:, free_variable_indices)
83 83
84 # Create grid function for boundary grid jacobian 84 # Create grid function for boundary grid jacobian
85 boundary_jacobian = componentview((@view g.jacobian[b_indices...]) , jacobian_components...) 85 boundary_jacobian = componentview((@view g.jacobian[b_indices]) , jacobian_components...)
86 boundary_physicalcoordinates = @view g.physicalcoordinates[b_indices...] 86 boundary_physicalcoordinates = @view g.physicalcoordinates[b_indices]
87 87
88 return MappedGrid( 88 return MappedGrid(
89 boundary_grid(g.logical_grid, id), 89 boundary_grid(g.logical_grid, id),
90 boundary_physicalcoordinates, 90 boundary_physicalcoordinates,
91 boundary_jacobian, 91 boundary_jacobian,
180 normal(g::MappedGrid, boundary) 180 normal(g::MappedGrid, boundary)
181 181
182 The outward pointing normal as a grid function on the corresponding boundary grid. 182 The outward pointing normal as a grid function on the corresponding boundary grid.
183 """ 183 """
184 function normal(g::MappedGrid, boundary) 184 function normal(g::MappedGrid, boundary)
185 b_indices = boundary_indices(g, boundary) 185 return map(boundary_indices(g, boundary)) do I
186 σ = _boundary_sign(component_type(g), boundary) 186 normal(g, boundary, Tuple(I)...)
187
188 # TODO: Refactor this when `boundary_indices(g, ...)` has been made iterable.
189 return map(jacobian(g)[b_indices...]) do ∂x∂ξ
190 ∂ξ∂x = inv(∂x∂ξ)
191 k = grid_id(boundary)
192 σ*∂ξ∂x[k,:]/norm(∂ξ∂x[k,:])
193 end 187 end
194 end 188 end
195 189
196 """ 190 """
197 normal(g::MappedGrid, boundary, i...) 191 normal(g::MappedGrid, boundary, i...)