Mercurial > repos > public > sbplib_julia
diff 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 |
line wrap: on
line diff
--- a/src/Grids/mapped_grid.jl Wed Jun 26 12:42:28 2024 +0200 +++ b/src/Grids/mapped_grid.jl Sun Jun 30 10:50:44 2024 +0200 @@ -81,3 +81,27 @@ end end +""" + normal(g::MappedGrid, boundary) + +The outward pointing normal as a grid function on the boundary +""" +function normal(g::MappedGrid, boundary) + b_indices = boundary_indices(g, boundary) + σ =_boundary_sign(component_type(g), boundary) + return map(jacobian(g)[b_indices...]) do ∂x∂ξ + ∂ξ∂x = inv(∂x∂ξ) + k = grid_id(boundary) + σ*∂ξ∂x[k,:]/norm(∂ξ∂x[k,:]) + end +end + +function _boundary_sign(T, boundary) + if boundary_id(boundary) == Upper() + return one(T) + elseif boundary_id(boundary) == Lower() + return -one(T) + else + throw(ArgumentError("The boundary identifier must be either `Lower()` or `Upper()`")) + end +end