Mercurial > repos > public > sbplib_julia
comparison src/Grids/mapped_grid.jl @ 1659:3bbcd496e021 feature/grids/curvilinear
Add function for computing the normal at the boundary of a mapped grid as a grid function
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Fri, 28 Jun 2024 17:02:47 +0200 |
| parents | 64452a678e7a |
| children | 6d196fb85133 5ea0299b45b4 |
comparison
equal
deleted
inserted
replaced
| 1649:b02917bcd7d5 | 1659:3bbcd496e021 |
|---|---|
| 78 return map(jacobian(g)) do ∂x∂ξ | 78 return map(jacobian(g)) do ∂x∂ξ |
| 79 inv(∂x∂ξ'*∂x∂ξ) | 79 inv(∂x∂ξ'*∂x∂ξ) |
| 80 end | 80 end |
| 81 end | 81 end |
| 82 | 82 |
| 83 """ | |
| 84 normal(g::MappedGrid, boundary) | |
| 85 | |
| 86 The outward pointing normal as a grid function on the boundary | |
| 87 """ | |
| 88 function normal(g::MappedGrid, boundary) | |
| 89 b_indices = boundary_indices(g, boundary) | |
| 90 σ =_boundary_sign(component_type(g), boundary) | |
| 91 return map(jacobian(g)[b_indices...]) do ∂x∂ξ | |
| 92 ∂ξ∂x = inv(∂x∂ξ) | |
| 93 k = grid_id(boundary) | |
| 94 σ*∂ξ∂x[k,:]/norm(∂ξ∂x[k,:]) | |
| 95 end | |
| 96 end | |
| 97 | |
| 98 function _boundary_sign(T, boundary) | |
| 99 if boundary_id(boundary) == Upper() | |
| 100 return one(T) | |
| 101 elseif boundary_id(boundary) == Lower() | |
| 102 return -one(T) | |
| 103 else | |
| 104 throw(ArgumentError("The boundary identifier must be either `Lower()` or `Upper()`")) | |
| 105 end | |
| 106 end |
