Mercurial > repos > public > sbplib_julia
comparison test/Grids/geometry_test.jl @ 1977:270675bb97be feature/grids/geometry_functions
Implement Grids.jacobian for TransfiniteInterpolationSurface
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 25 Feb 2025 23:33:56 +0100 |
parents | 34a7e3919e9a |
children | 486b3c6f919e |
comparison
equal
deleted
inserted
replaced
1976:34a7e3919e9a | 1977:270675bb97be |
---|---|
169 cs = polygon_edges([0,0],[1,0],[1,1],[0,1]) | 169 cs = polygon_edges([0,0],[1,0],[1,1],[0,1]) |
170 @test TransfiniteInterpolationSurface(cs...) isa TransfiniteInterpolationSurface | 170 @test TransfiniteInterpolationSurface(cs...) isa TransfiniteInterpolationSurface |
171 end | 171 end |
172 | 172 |
173 @testset "Evaluation" begin | 173 @testset "Evaluation" begin |
174 a, b, c, d = [1,0],[2,1/4],[2.5,1],[-1/3,1] | |
175 cs = polygon_edges([0,0],[1,0],[1,1],[0,1]) | 174 cs = polygon_edges([0,0],[1,0],[1,1],[0,1]) |
176 ti = TransfiniteInterpolationSurface(cs...) | 175 ti = TransfiniteInterpolationSurface(cs...) |
177 | 176 |
178 @test ti(0,0) == [0,0] | 177 @test ti(0,0) == [0,0] |
179 @test ti([0,0]) == [0,0] | 178 @test ti([0,0]) == [0,0] |
234 @test_throws Exception check_transfiniteinterpolation(s1) | 233 @test_throws Exception check_transfiniteinterpolation(s1) |
235 @test_throws Exception check_transfiniteinterpolation(s2) | 234 @test_throws Exception check_transfiniteinterpolation(s2) |
236 @test_throws Exception check_transfiniteinterpolation(s3) | 235 @test_throws Exception check_transfiniteinterpolation(s3) |
237 @test_throws Exception check_transfiniteinterpolation(s4) | 236 @test_throws Exception check_transfiniteinterpolation(s4) |
238 end | 237 end |
239 end | 238 |
239 @testset "Grids.jacobian" begin | |
240 cs = polygon_edges([0,0],[1,0],[1,1],[0,1]) | |
241 ti = TransfiniteInterpolationSurface(cs...) | |
242 | |
243 @test Grids.jacobian(ti, [0,0]) isa SMatrix | |
244 | |
245 @test Grids.jacobian(ti, [0,0]) == [1 0; 0 1] | |
246 @test Grids.jacobian(ti, [1,0]) == [1 0; 0 1] | |
247 @test Grids.jacobian(ti, [1,1]) == [1 0; 0 1] | |
248 @test Grids.jacobian(ti, [0,1]) == [1 0; 0 1] | |
249 | |
250 @test Grids.jacobian(ti, [1/2, 0]) == [1 0; 0 1] | |
251 @test Grids.jacobian(ti, [1/2, 1]) == [1 0; 0 1] | |
252 @test Grids.jacobian(ti, [0,1/2]) == [1 0; 0 1] | |
253 @test Grids.jacobian(ti, [1,1/2]) == [1 0; 0 1] | |
254 | |
255 | |
256 a, b, c, d = [1,0],[2,1/4],[2.5,1],[-1/3,1] | |
257 cs = polygon_edges(a,b,c,d) | |
258 ti = TransfiniteInterpolationSurface(cs...) | |
259 | |
260 @test Grids.jacobian(ti, [0,0]) == [b-a d-a] | |
261 @test Grids.jacobian(ti, [1,0]) == [b-a c-b] | |
262 @test Grids.jacobian(ti, [1,1]) == [c-d c-b] | |
263 @test Grids.jacobian(ti, [0,1]) == [c-d d-a] | |
264 | |
265 | |
266 mid(x,y) = (x+y)/2 | |
267 @test Grids.jacobian(ti, [1/2, 0]) ≈ [b-a mid(c,d)-mid(a,b)] | |
268 @test Grids.jacobian(ti, [1/2, 1]) ≈ [c-d mid(c,d)-mid(a,b)] | |
269 @test Grids.jacobian(ti, [0, 1/2]) ≈ [mid(b,c)-mid(a,d) d-a] | |
270 @test Grids.jacobian(ti, [1, 1/2]) ≈ [mid(b,c)-mid(a,d) c-b] | |
271 | |
272 # TODO: Some test with curved edges? | |
273 end | |
274 end |