comparison src/Grids/mapped_grid.jl @ 1678:13a7a4ff49e3 feature/grids/manifolds

Merge feature/grids/curvilinear
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 30 Jun 2024 10:50:44 +0200
parents 8250cf5a3ce9 3bbcd496e021
children a4c52ae93b11
comparison
equal deleted inserted replaced
1650:8250cf5a3ce9 1678:13a7a4ff49e3
79 return map(jacobian(g)) do ∂x∂ξ 79 return map(jacobian(g)) do ∂x∂ξ
80 inv(∂x∂ξ'*∂x∂ξ) 80 inv(∂x∂ξ'*∂x∂ξ)
81 end 81 end
82 end 82 end
83 83
84 """
85 normal(g::MappedGrid, boundary)
86
87 The outward pointing normal as a grid function on the boundary
88 """
89 function normal(g::MappedGrid, boundary)
90 b_indices = boundary_indices(g, boundary)
91 σ =_boundary_sign(component_type(g), boundary)
92 return map(jacobian(g)[b_indices...]) do ∂x∂ξ
93 ∂ξ∂x = inv(∂x∂ξ)
94 k = grid_id(boundary)
95 σ*∂ξ∂x[k,:]/norm(∂ξ∂x[k,:])
96 end
97 end
98
99 function _boundary_sign(T, boundary)
100 if boundary_id(boundary) == Upper()
101 return one(T)
102 elseif boundary_id(boundary) == Lower()
103 return -one(T)
104 else
105 throw(ArgumentError("The boundary identifier must be either `Lower()` or `Upper()`"))
106 end
107 end