Mercurial > repos > public > sbplib_julia
comparison src/Grids/mapped_grid.jl @ 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 | f21bfc5f21aa |
children | 516eaabf1169 |
comparison
equal
deleted
inserted
replaced
1831:27e74f524c4f | 1832:85f8855473ab |
---|---|
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, |
169 normal(g::MappedGrid, boundary) | 169 normal(g::MappedGrid, boundary) |
170 | 170 |
171 The outward pointing normal as a grid function on the corresponding boundary grid. | 171 The outward pointing normal as a grid function on the corresponding boundary grid. |
172 """ | 172 """ |
173 function normal(g::MappedGrid, boundary) | 173 function normal(g::MappedGrid, boundary) |
174 b_indices = boundary_indices(g, boundary) | 174 return map(boundary_indices(g, boundary)) do I |
175 σ = _boundary_sign(component_type(g), boundary) | 175 normal(g, boundary, Tuple(I)...) |
176 | |
177 # TODO: Refactor this when `boundary_indices(g, ...)` has been made iterable. | |
178 return map(jacobian(g)[b_indices...]) do ∂x∂ξ | |
179 ∂ξ∂x = inv(∂x∂ξ) | |
180 k = grid_id(boundary) | |
181 σ*∂ξ∂x[k,:]/norm(∂ξ∂x[k,:]) | |
182 end | 176 end |
183 end | 177 end |
184 | 178 |
185 """ | 179 """ |
186 normal(g::MappedGrid, boundary, i...) | 180 normal(g::MappedGrid, boundary, i...) |