Mercurial > repos > public > sbplib_julia
diff src/Grids/mapped_grid.jl @ 1660:6d196fb85133 feature/sbp_operators/laplace_curvilinear
Merge feature/grids/curvilinear
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 28 Jun 2024 17:04:05 +0200 |
parents | 8250cf5a3ce9 3bbcd496e021 |
children | a4c52ae93b11 |
line wrap: on
line diff
--- a/src/Grids/mapped_grid.jl Fri Jun 28 17:00:57 2024 +0200 +++ b/src/Grids/mapped_grid.jl Fri Jun 28 17:04:05 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