Mercurial > repos > public > sbplib_julia
comparison test/Grids/curvilinear_grid_test.jl @ 1503:704a84eef8b6 feature/grids/curvilinear
Add tests for boundary_grid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 16 Feb 2024 14:31:27 +0100 |
parents | a2dc80396808 |
children |
comparison
equal
deleted
inserted
replaced
1502:a2dc80396808 | 1503:704a84eef8b6 |
---|---|
115 @test boundary_indices(cg, CartesianBoundary{2,Lower}()) == boundary_indices(lg,CartesianBoundary{2,Lower}()) | 115 @test boundary_indices(cg, CartesianBoundary{2,Lower}()) == boundary_indices(lg,CartesianBoundary{2,Lower}()) |
116 @test boundary_indices(cg, CartesianBoundary{1,Upper}()) == boundary_indices(lg,CartesianBoundary{1,Upper}()) | 116 @test boundary_indices(cg, CartesianBoundary{1,Upper}()) == boundary_indices(lg,CartesianBoundary{1,Upper}()) |
117 end | 117 end |
118 | 118 |
119 @testset "boundary_grid" begin | 119 @testset "boundary_grid" begin |
120 @test boundary_grid(cg, TensorGridBoundary{1, Lower}()) == 2. * boundary_grid(lg,TensorGridBoundary{1, Lower}()) | 120 x̄((ξ, η)) = @SVector[ξ, η*(1+ξ*(ξ-1))] |
121 @test_broken boundary_grid(cg, TensorGridBoundary{1, Upper}()) == 2. * boundary_grid(lg,TensorGridBoundary{1, Upper}()) | 121 J((ξ, η)) = @SMatrix[ |
122 @test_broken boundary_grid(cg, TensorGridBoundary{2, Lower}()) == 2. * boundary_grid(lg,TensorGridBoundary{2, Lower}()) | 122 1 0; |
123 @test_broken boundary_grid(cg, TensorGridBoundary{2, Upper}()) == 2. * boundary_grid(lg,TensorGridBoundary{2, Upper}()) | 123 η*(2ξ-1) 1+ξ*(ξ-1); |
124 ] | |
125 | |
126 cg = curvilinear_grid(x̄, J, 10, 11) | |
127 J1((ξ, η)) = @SMatrix[ | |
128 1 ; | |
129 η*(2ξ-1); | |
130 ] | |
131 J2((ξ, η)) = @SMatrix[ | |
132 0; | |
133 1+ξ*(ξ-1); | |
134 ] | |
135 | |
136 function test_boundary_grid(cg, bId, Jb) | |
137 bg = boundary_grid(cg, bId) | |
138 | |
139 lg = logicalgrid(cg) | |
140 expected_bg = CurvilinearGrid( | |
141 boundary_grid(lg, bId), | |
142 map(x̄, boundary_grid(lg, bId)), | |
143 map(Jb, boundary_grid(lg, bId)), | |
144 ) | |
145 | |
146 @testset let bId=bId, bg=bg, expected_bg=expected_bg | |
147 @test collect(bg) == collect(expected_bg) | |
148 @test logicalgrid(bg) == logicalgrid(expected_bg) | |
149 @test jacobian(bg) == jacobian(expected_bg) | |
150 # TODO: Implement equality of a curvilinear grid and simlify the above | |
151 end | |
152 end | |
153 | |
154 @testset test_boundary_grid(cg, TensorGridBoundary{1, Lower}(), J2) | |
155 @testset test_boundary_grid(cg, TensorGridBoundary{1, Upper}(), J2) | |
156 @testset test_boundary_grid(cg, TensorGridBoundary{2, Lower}(), J1) | |
157 @testset test_boundary_grid(cg, TensorGridBoundary{2, Upper}(), J1) | |
124 end | 158 end |
125 | 159 |
126 # TBD: Should curvilinear grid support refining and coarsening? | 160 # TBD: Should curvilinear grid support refining and coarsening? |
127 # This would require keeping the coordinate mapping around which seems burdensome, and might increase compilation time? | 161 # This would require keeping the coordinate mapping around which seems burdensome, and might increase compilation time? |
128 @testset "refine" begin | 162 @testset "refine" begin |
145 end | 179 end |
146 | 180 |
147 @testset "curvilinear_grid" begin | 181 @testset "curvilinear_grid" begin |
148 x̄((ξ, η)) = @SVector[ξ, η*(1+ξ*(ξ-1))] | 182 x̄((ξ, η)) = @SVector[ξ, η*(1+ξ*(ξ-1))] |
149 J((ξ, η)) = @SMatrix[ | 183 J((ξ, η)) = @SMatrix[ |
150 1 0; | 184 1 0; |
151 2ξ-1 1+ξ*(ξ-1); | 185 η*(2ξ-1) 1+ξ*(ξ-1); |
152 ] | 186 ] |
153 cg = curvilinear_grid(x̄, J, 10, 11) | 187 cg = curvilinear_grid(x̄, J, 10, 11) |
154 @test cg isa CurvilinearGrid{SVector{2,Float64}, 2} | 188 @test cg isa CurvilinearGrid{SVector{2,Float64}, 2} |
155 | 189 |
156 lg = equidistant_grid((10,11), (0,0), (1,1)) | 190 lg = equidistant_grid((10,11), (0,0), (1,1)) |