comparison test/Grids/mapped_grid_test.jl @ 1705:4870fc3faa25 feature/grids/curvilinear

Add tests for equallity of mapped grids
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 04 Sep 2024 15:38:10 +0200
parents e5e76c8e52c5
children 11640aa3e348
comparison
equal deleted inserted replaced
1704:e5e76c8e52c5 1705:4870fc3faa25
130 130
131 @testset "Base" begin 131 @testset "Base" begin
132 @test ndims(mg) == 2 132 @test ndims(mg) == 2
133 end 133 end
134 134
135 @testset "==" begin
136 sz = (15,11)
137 lg = equidistant_grid((0,0), (1,1), sz...)
138 x = rand(SVector{3,Float64}, sz...)
139 J = rand(SMatrix{2,3,Float64}, sz...)
140
141 sg = MappedGrid(lg, x, J)
142
143 sg1 = MappedGrid(equidistant_grid((0,0), (1,1), sz...), copy(x), copy(J))
144
145 sz2 = (15,12)
146 lg2 = equidistant_grid((0,0), (1,1), sz2...)
147 x2 = rand(SVector{3,Float64}, sz2...)
148 J2 = rand(SMatrix{2,3,Float64}, sz2...)
149 sg2 = MappedGrid(lg2, x2, J2)
150
151 sg3 = MappedGrid(lg, rand(SVector{3,Float64}, sz...), J)
152 sg4 = MappedGrid(lg, x, rand(SMatrix{2,3,Float64}, sz...))
153
154 @test sg == sg1
155 @test sg != sg2 # Different size
156 @test sg != sg3 # Different coordinates
157 @test sg != sg4 # Different jacobian
158 end
159
135 @testset "boundary_identifiers" begin 160 @testset "boundary_identifiers" begin
161 lg = equidistant_grid((0,0), (1,1), 11, 11) # TODO: Change dims of the grid to be different
162 x̄ = map(ξ̄ -> 2ξ̄, lg)
163 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg)
164 mg = MappedGrid(lg, x̄, J)
136 @test boundary_identifiers(mg) == boundary_identifiers(lg) 165 @test boundary_identifiers(mg) == boundary_identifiers(lg)
137 end 166 end
138 167
139 @testset "boundary_indices" begin 168 @testset "boundary_indices" begin
169 lg = equidistant_grid((0,0), (1,1), 11, 11) # TODO: Change dims of the grid to be different
170 x̄ = map(ξ̄ -> 2ξ̄, lg)
171 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg)
172 mg = MappedGrid(lg, x̄, J)
173
140 @test boundary_indices(mg, CartesianBoundary{1,Lower}()) == boundary_indices(lg,CartesianBoundary{1,Lower}()) 174 @test boundary_indices(mg, CartesianBoundary{1,Lower}()) == boundary_indices(lg,CartesianBoundary{1,Lower}())
141 @test boundary_indices(mg, CartesianBoundary{2,Lower}()) == boundary_indices(lg,CartesianBoundary{2,Lower}()) 175 @test boundary_indices(mg, CartesianBoundary{2,Lower}()) == boundary_indices(lg,CartesianBoundary{2,Lower}())
142 @test boundary_indices(mg, CartesianBoundary{1,Upper}()) == boundary_indices(lg,CartesianBoundary{1,Upper}()) 176 @test boundary_indices(mg, CartesianBoundary{1,Upper}()) == boundary_indices(lg,CartesianBoundary{1,Upper}())
143 end 177 end
144 178