Mercurial > repos > public > sbplib_julia
diff src/Grids/mapped_grid.jl @ 1801:2b5f81e288f1 feature/grids/manifolds
Merge feature/grids/curvilinear
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 02 Oct 2024 08:51:37 +0200 |
parents | 819ab806960f 8583f6379bd8 |
children | 1c58005429fd |
line wrap: on
line diff
--- a/src/Grids/mapped_grid.jl Mon Sep 16 09:53:29 2024 +0200 +++ b/src/Grids/mapped_grid.jl Wed Oct 02 08:51:37 2024 +0200 @@ -72,8 +72,6 @@ boundary_identifiers(g::MappedGrid) = boundary_identifiers(g.logical_grid) boundary_indices(g::MappedGrid, id::TensorGridBoundary) = boundary_indices(g.logical_grid, id) -# Review: Error when calling plot(boundary_grid(g, id)) -# Currently need to collect first, i.e., plot(collect(boundary_grid(g, id))) function boundary_grid(g::MappedGrid, id::TensorGridBoundary) b_indices = boundary_indices(g.logical_grid, id) @@ -98,9 +96,9 @@ """ mapped_grid(x, J, size::Vararg{Int}) -A `MappedGrid` with a default logical grid on a unit hyper box. `x` and `J` -are functions to be evaluated on the logical grid and `size` determines the -size of the logical grid. +A `MappedGrid` with a default logical grid on the D-dimensional unit hyper +box [0,1]ᴰ. `x` and `J`are functions to be evaluated on the logical grid +and `size` determines the size of the logical grid. """ function mapped_grid(x, J, size::Vararg{Int}) D = length(size) @@ -133,17 +131,6 @@ end end -""" - metric_tensor_inverse(g::MappedGrid) - -The inverse of the metric tensor of `g` as a grid function. -""" -function metric_tensor_inverse(g::MappedGrid) - return map(jacobian(g)) do ∂x∂ξ - inv(∂x∂ξ'*∂x∂ξ) - end -end - function min_spacing(g::MappedGrid{T,1} where T) n, = size(g) @@ -185,7 +172,7 @@ """ function normal(g::MappedGrid, boundary) b_indices = boundary_indices(g, boundary) - σ =_boundary_sign(component_type(g), boundary) + σ = _boundary_sign(component_type(g), boundary) return map(jacobian(g)[b_indices...]) do ∂x∂ξ ∂ξ∂x = inv(∂x∂ξ) k = grid_id(boundary) @@ -193,6 +180,15 @@ end end +function normal(g::MappedGrid, boundary, i...) + σ = _boundary_sign(component_type(g), boundary) + ∂ξ∂x = inv(jacobian(g)[i...]) + + k = grid_id(boundary) + return σ*∂ξ∂x[k,:]/norm(∂ξ∂x[k,:]) +end + + function _boundary_sign(T, boundary) if boundary_id(boundary) == UpperBoundary() return one(T)