Mercurial > repos > public > sbplib_julia
comparison test/Grids/mapped_grid_test.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 | e11b5b6940a2 |
comparison
equal
deleted
inserted
replaced
| 1687:3ac94e8f28b3 | 1688:72776d3d5fd6 |
|---|---|
| 1 using Sbplib.Grids | 1 using Sbplib.Grids |
| 2 using Sbplib.RegionIndices | 2 using Sbplib.RegionIndices |
| 3 using Test | 3 using Test |
| 4 using StaticArrays | 4 using StaticArrays |
| 5 using LinearAlgebra | |
| 5 | 6 |
| 6 @testset "MappedGrid" begin | 7 @testset "MappedGrid" begin |
| 7 lg = equidistant_grid((0,0), (1,1), 11, 11) # TODO: Change dims of the grid to be different | 8 lg = equidistant_grid((0,0), (1,1), 11, 11) # TODO: Change dims of the grid to be different |
| 8 x̄ = map(ξ̄ -> 2ξ̄, lg) | 9 x̄ = map(ξ̄ -> 2ξ̄, lg) |
| 9 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg) | 10 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg) |
| 180 end | 181 end |
| 181 | 182 |
| 182 let g = mapped_grid(x->x + x.*(1 .- x)/2, x->@SMatrix[1.5 .- x], 11) | 183 let g = mapped_grid(x->x + x.*(1 .- x)/2, x->@SMatrix[1.5 .- x], 11) |
| 183 @test min_spacing(g) ≈ 0.055 | 184 @test min_spacing(g) ≈ 0.055 |
| 184 end | 185 end |
| 186 | |
| 187 let g = mapped_grid(identity, x->@SMatrix[1 0; 0 1], 11,11) | |
| 188 @test min_spacing(g) ≈ 0.1 | |
| 189 end | |
| 190 | |
| 191 let g = mapped_grid(identity, x->@SMatrix[1 0; 0 1], 11,21) | |
| 192 @test min_spacing(g) ≈ 0.05 | |
| 193 end | |
| 194 | |
| 195 skew_grid(a,b, sz...) = mapped_grid(ξ̄->ξ̄[1]*a + ξ̄[2]*b, ξ̄->[a b], sz...) | |
| 196 | |
| 197 @testset let a = @SVector[1,0], b = @SVector[1,1]/√2 | |
| 198 g = skew_grid(a,b,11,11) | |
| 199 | |
| 200 @test min_spacing(g) ≈ 0.1*norm(b-a) | |
| 201 end | |
| 202 | |
| 203 @testset let a = @SVector[1,0], b = @SVector[-1,1]/√2 | |
| 204 g = skew_grid(a,b,11,11) | |
| 205 | |
| 206 @test min_spacing(g) ≈ 0.1*norm(a+b) | |
| 207 end | |
| 208 | |
| 209 # Skevt nät | |
| 185 end | 210 end |
| 186 | 211 |
| 187 end | 212 end |
| 188 | 213 |
| 189 @testset "mapped_grid" begin | 214 @testset "mapped_grid" begin |
