Mercurial > repos > public > sbplib_julia
comparison src/Grids/mapped_grid.jl @ 1688:72776d3d5fd6 feature/grids/curvilinear
Add min_spacing for 2D mapped grids
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 22 Aug 2024 08:14:04 +0200 |
parents | 22a9992471be |
children | a4c52ae93b11 6eb5b48607e0 |
comparison
equal
deleted
inserted
replaced
1687:3ac94e8f28b3 | 1688:72776d3d5fd6 |
---|---|
90 end | 90 end |
91 | 91 |
92 return ms | 92 return ms |
93 end | 93 end |
94 | 94 |
95 function min_spacing(g::MappedGrid{T,2} where T) | |
96 n, m = size(g) | |
97 | |
98 ms = Inf | |
99 for i ∈ 1:n-1, j ∈ 1:m-1 # loop over each cell of the grid | |
100 | |
101 ms = min( | |
102 ms, | |
103 norm(g[i+1,j]-g[i,j]), | |
104 norm(g[i,j+1]-g[i,j]), | |
105 | |
106 norm(g[i+1,j]-g[i+1,j+1]), | |
107 norm(g[i,j+1]-g[i+1,j+1]), | |
108 | |
109 norm(g[i+1,j+1]-g[i,j]), | |
110 norm(g[i+1,j]-g[i,j+1]), | |
111 ) | |
112 # NOTE: This could be optimized to avoid checking all interior edges twice. | |
113 end | |
114 | |
115 return ms | |
116 end | |
95 | 117 |
96 """ | 118 """ |
97 normal(g::MappedGrid, boundary) | 119 normal(g::MappedGrid, boundary) |
98 | 120 |
99 The outward pointing normal as a grid function on the boundary | 121 The outward pointing normal as a grid function on the boundary |