comparison test/Grids/mapped_grid_test.jl @ 1689:e11b5b6940a2 feature/grids/curvilinear

Add more tests for `normal`
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 23 Aug 2024 09:22:29 +0200
parents 72776d3d5fd6
children 5eabe1f560f0
comparison
equal deleted inserted replaced
1688:72776d3d5fd6 1689:e11b5b6940a2
231 @test normal(mg, CartesianBoundary{2,Lower}()) == fill(@SVector[0,-1], 10) 231 @test normal(mg, CartesianBoundary{2,Lower}()) == fill(@SVector[0,-1], 10)
232 @test normal(mg, CartesianBoundary{2,Upper}()) ≈ map(boundary_grid(mg,CartesianBoundary{2,Upper}())|>logicalgrid) do ξ̄ 232 @test normal(mg, CartesianBoundary{2,Upper}()) ≈ map(boundary_grid(mg,CartesianBoundary{2,Upper}())|>logicalgrid) do ξ̄
233 α = 1-2ξ̄[1] 233 α = 1-2ξ̄[1]
234 @SVector[α,1]/√(α^2 + 1) 234 @SVector[α,1]/√(α^2 + 1)
235 end 235 end
236
237
238 x̄((ξ, η)) = @SVector[2ξ + η*(1-η), 3η+(1+η/2)*ξ^2]
239 J((ξ, η)) = @SMatrix[
240 2 1-2η;
241 (2+η)*ξ 3+1/2*ξ^2;
242 ]
243
244 g = mapped_grid(x̄,J,21,14)
245 g = mapped_grid(x̄,J,3,4)
246
247 unit(v) = v/norm(v)
248 @testset let bId = CartesianBoundary{1,Lower}()
249 lbg = boundary_grid(logicalgrid(g), bId)
250 @test normal(g, bId) ≈ map(lbg) do (ξ, η)
251 -unit(@SVector[1/2, η/3-1/6])
252 end
253 end
254
255 @testset let bId = CartesianBoundary{1,Upper}()
256 lbg = boundary_grid(logicalgrid(g), bId)
257 @test normal(g, bId) ≈ map(lbg) do (ξ, η)
258 unit(@SVector[7/2, 2η-1]/(5 + 3η + 2η^2))
259 end
260 end
261
262 @testset let bId = CartesianBoundary{2,Lower}()
263 lbg = boundary_grid(logicalgrid(g), bId)
264 @test normal(g, bId) ≈ map(lbg) do (ξ, η)
265 -unit(@SVector[-2ξ, 2]/(6 + ξ^2 - 2ξ))
266 end
267 end
268
269 @testset let bId = CartesianBoundary{2,Upper}()
270 lbg = boundary_grid(logicalgrid(g), bId)
271 @test normal(g, bId) ≈ map(lbg) do (ξ, η)
272 unit(@SVector[-3ξ, 2]/(6 + ξ^2 + 3ξ))
273 end
274 end
236 end 275 end
237 end 276 end
277
278 # TODO: Reorganize tests to not be nested.
279 # Want to ues "mapped_grid" to contruct tests for some of the differential geometry methods