Mercurial > repos > public > sbplib_julia
comparison src/Grids/mapped_grid.jl @ 1695:a4c52ae93b11 feature/grids/manifolds
Merge feature/grids/curvilinear
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 28 Aug 2024 10:35:08 +0200 |
parents | 13a7a4ff49e3 72776d3d5fd6 |
children | 03894fd7b132 |
comparison
equal
deleted
inserted
replaced
1686:b996c35dd647 | 1695:a4c52ae93b11 |
---|---|
59 lg, | 59 lg, |
60 map(x,lg), | 60 map(x,lg), |
61 map(J,lg), | 61 map(J,lg), |
62 ) | 62 ) |
63 end | 63 end |
64 # TODO: Delete this function | |
64 | 65 |
65 | 66 |
66 function jacobian_determinant(g::MappedGrid) | 67 function jacobian_determinant(g::MappedGrid) |
67 return map(jacobian(g)) do ∂x∂ξ | 68 return map(jacobian(g)) do ∂x∂ξ |
68 det(∂x∂ξ) | 69 det(∂x∂ξ) |
69 end | 70 end |
70 end | 71 end |
71 | 72 |
72 function geometric_tensor(g::MappedGrid) | 73 function metric_tensor(g::MappedGrid) |
73 return map(jacobian(g)) do ∂x∂ξ | 74 return map(jacobian(g)) do ∂x∂ξ |
74 ∂x∂ξ'*∂x∂ξ | 75 ∂x∂ξ'*∂x∂ξ |
75 end | 76 end |
76 end | 77 end |
77 | 78 |
78 function geometric_tensor_inverse(g::MappedGrid) | 79 function metric_tensor_inverse(g::MappedGrid) |
79 return map(jacobian(g)) do ∂x∂ξ | 80 return map(jacobian(g)) do ∂x∂ξ |
80 inv(∂x∂ξ'*∂x∂ξ) | 81 inv(∂x∂ξ'*∂x∂ξ) |
81 end | 82 end |
83 end | |
84 | |
85 function min_spacing(g::MappedGrid{T,1} where T) | |
86 n, = size(g) | |
87 | |
88 ms = Inf | |
89 for i ∈ 1:n-1 | |
90 ms = min(ms, norm(g[i+1]-g[i])) | |
91 end | |
92 | |
93 return ms | |
94 end | |
95 | |
96 function min_spacing(g::MappedGrid{T,2} where T) | |
97 n, m = size(g) | |
98 | |
99 ms = Inf | |
100 for i ∈ 1:n-1, j ∈ 1:m-1 # loop over each cell of the grid | |
101 | |
102 ms = min( | |
103 ms, | |
104 norm(g[i+1,j]-g[i,j]), | |
105 norm(g[i,j+1]-g[i,j]), | |
106 | |
107 norm(g[i+1,j]-g[i+1,j+1]), | |
108 norm(g[i,j+1]-g[i+1,j+1]), | |
109 | |
110 norm(g[i+1,j+1]-g[i,j]), | |
111 norm(g[i+1,j]-g[i,j+1]), | |
112 ) | |
113 # NOTE: This could be optimized to avoid checking all interior edges twice. | |
114 end | |
115 | |
116 return ms | |
82 end | 117 end |
83 | 118 |
84 """ | 119 """ |
85 normal(g::MappedGrid, boundary) | 120 normal(g::MappedGrid, boundary) |
86 | 121 |