Mercurial > repos > public > sbplib_julia
comparison test/Grids/manifolds_test.jl @ 1954:b0915f43b122 feature/sbp_operators/laplace_curvilinear
Merge feature/grids/geometry_functions
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 08 Feb 2025 09:38:58 +0100 |
parents | c63116e2ec8e |
children | 6dd00ea0511a |
comparison
equal
deleted
inserted
replaced
1953:835b1dcee38e | 1954:b0915f43b122 |
---|---|
2 | 2 |
3 using Diffinitive.Grids | 3 using Diffinitive.Grids |
4 using Diffinitive.RegionIndices | 4 using Diffinitive.RegionIndices |
5 using Diffinitive.LazyTensors | 5 using Diffinitive.LazyTensors |
6 | 6 |
7 # using StaticArrays | 7 using StaticArrays |
8 | 8 |
9 @testset "ParameterSpace" begin | 9 west = CartesianBoundary{1,LowerBoundary} |
10 @test ndims(HyperBox([1,1], [2,2])) == 2 | 10 east = CartesianBoundary{1,UpperBoundary} |
11 @test ndims(unittetrahedron()) == 3 | 11 south = CartesianBoundary{2,LowerBoundary} |
12 end | 12 north = CartesianBoundary{2,UpperBoundary} |
13 | 13 bottom = CartesianBoundary{3, LowerBoundary} |
14 @testset "Interval" begin | 14 top = CartesianBoundary{3, UpperBoundary} |
15 @test Interval <: ParameterSpace{1} | |
16 | |
17 @test Interval(0,1) isa Interval{Int} | |
18 @test Interval(0,1.) isa Interval{Float64} | |
19 | |
20 @test unitinterval() isa Interval{Float64} | |
21 @test unitinterval() == Interval(0.,1.) | |
22 @test limits(unitinterval()) == (0.,1.) | |
23 | |
24 @test unitinterval(Int) isa Interval{Int} | |
25 @test unitinterval(Int) == Interval(0,1) | |
26 @test limits(unitinterval(Int)) == (0,1) | |
27 end | |
28 | |
29 @testset "HyperBox" begin | |
30 @test HyperBox{<:Any, 2} <: ParameterSpace{2} | |
31 @test HyperBox([1,1], [2,2]) isa HyperBox{Int, 2} | |
32 | |
33 @test HyperBox([1,2], [1.,2.]) isa HyperBox{Float64,2} | |
34 | |
35 @test limits(HyperBox([1,2], [3,4])) == ([1,2], [3,4]) | |
36 @test limits(HyperBox([1,2], [3,4]), 1) == (1,3) | |
37 @test limits(HyperBox([1,2], [3,4]), 2) == (2,4) | |
38 | |
39 @test unitsquare() isa HyperBox{Float64,2} | |
40 @test limits(unitsquare()) == ([0,0],[1,1]) | |
41 | |
42 @test unitcube() isa HyperBox{Float64,3} | |
43 @test limits(unitcube()) == ([0,0,0],[1,1,1]) | |
44 | |
45 @test unithyperbox(4) isa HyperBox{Float64,4} | |
46 @test limits(unithyperbox(4)) == ([0,0,0,0],[1,1,1,1]) | |
47 end | |
48 | |
49 @testset "Simplex" begin | |
50 @test Simplex{<:Any, 3} <: ParameterSpace{3} | |
51 @test Simplex([1,2], [3,4]) isa Simplex{Int, 2} | |
52 @test Simplex([1,2,3], [4,5,6],[1,1,1]) isa Simplex{Int, 3} | |
53 | |
54 @test Simplex([1,2], [3.,4.]) isa Simplex{Float64, 2} | |
55 | |
56 @test verticies(Simplex([1,2], [3,4])) == ([1,2], [3,4]) | |
57 | |
58 @test unittriangle() isa Simplex{Float64,2} | |
59 @test verticies(unittriangle()) == ([0,0], [1,0], [0,1]) | |
60 | |
61 @test unittetrahedron() isa Simplex{Float64,3} | |
62 @test verticies(unittetrahedron()) == ([0,0,0], [1,0,0], [0,1,0],[0,0,1]) | |
63 | |
64 @test unitsimplex(4) isa Simplex{Float64,4} | |
65 end | |
66 | 15 |
67 @testset "Chart" begin | 16 @testset "Chart" begin |
68 c = Chart(x->2x, unitsquare()) | 17 X(ξ) = 2ξ |
18 Grids.jacobian(::typeof(X), ξ) = @SVector[2,2] | |
19 c = Chart(X, unitsquare()) | |
69 @test c isa Chart{2} | 20 @test c isa Chart{2} |
70 @test c([3,2]) == [6,4] | 21 @test c([3,2]) == [6,4] |
71 @test parameterspace(c) == unitsquare() | 22 @test parameterspace(c) == unitsquare() |
72 @test ndims(c) == 2 | 23 @test ndims(c) == 2 |
24 | |
25 @test jacobian(c, [3,2]) == [2,2] | |
26 | |
27 @test Set(boundary_identifiers(Chart(X,unitsquare()))) == Set([east(),west(),south(),north()]) | |
73 end | 28 end |
74 | 29 |
75 @testset "Atlas" begin | 30 @testset "CartesianAtlas" begin |
76 | 31 @testset "Constructors" begin |
32 c = Chart(identity, unitsquare()) | |
33 @test CartesianAtlas([c c; c c]) isa Atlas | |
34 | |
35 c2 = Chart(x->2x, unitsquare()) | |
36 @test CartesianAtlas([c c2; c2 c]) isa CartesianAtlas | |
37 @test CartesianAtlas(@SMatrix[c c; c c]) isa CartesianAtlas | |
38 @test CartesianAtlas(@SMatrix[c c2; c2 c]) isa CartesianAtlas | |
39 end | |
40 | |
41 @testset "Getters" begin | |
42 c = Chart(identity, unitsquare()) | |
43 a = CartesianAtlas([c c; c c]) | |
44 @test charts(a) == [c c; c c] | |
45 end | |
46 | |
47 @testset "connections" begin | |
48 # 2D | |
49 a = CartesianAtlas(fill(Chart(identity, unitsquare()), 2,3)) | |
50 | |
51 @test Set(connections(a)) == Set([ | |
52 (MultiBlockBoundary{(1,1), east}(), MultiBlockBoundary{(2,1), west}()), | |
53 (MultiBlockBoundary{(1,1), north}(), MultiBlockBoundary{(1,2), south}()), | |
54 (MultiBlockBoundary{(2,1), north}(), MultiBlockBoundary{(2,2), south}()), | |
55 (MultiBlockBoundary{(1,2), east}(), MultiBlockBoundary{(2,2), west}()), | |
56 (MultiBlockBoundary{(1,2), north}(), MultiBlockBoundary{(1,3), south}()), | |
57 (MultiBlockBoundary{(2,2), north}(), MultiBlockBoundary{(2,3), south}()), | |
58 (MultiBlockBoundary{(1,3), east}(), MultiBlockBoundary{(2,3), west}()), | |
59 ]) | |
60 | |
61 # 3D | |
62 a = CartesianAtlas(fill(Chart(identity, unitcube()), 2,2,3)) | |
63 @test Set(connections(a)) == Set([ | |
64 (MultiBlockBoundary{(1,1,1), east}(), MultiBlockBoundary{(2,1,1), west}()), | |
65 (MultiBlockBoundary{(1,1,1), north}(), MultiBlockBoundary{(1,2,1), south}()), | |
66 (MultiBlockBoundary{(2,1,1), north}(), MultiBlockBoundary{(2,2,1), south}()), | |
67 (MultiBlockBoundary{(1,2,1), east}(), MultiBlockBoundary{(2,2,1), west}()), | |
68 | |
69 (MultiBlockBoundary{(1,1,2), east}(), MultiBlockBoundary{(2,1,2), west}()), | |
70 (MultiBlockBoundary{(1,1,2), north}(), MultiBlockBoundary{(1,2,2), south}()), | |
71 (MultiBlockBoundary{(2,1,2), north}(), MultiBlockBoundary{(2,2,2), south}()), | |
72 (MultiBlockBoundary{(1,2,2), east}(), MultiBlockBoundary{(2,2,2), west}()), | |
73 | |
74 (MultiBlockBoundary{(1,1,3), east}(), MultiBlockBoundary{(2,1,3), west}()), | |
75 (MultiBlockBoundary{(1,1,3), north}(), MultiBlockBoundary{(1,2,3), south}()), | |
76 (MultiBlockBoundary{(2,1,3), north}(), MultiBlockBoundary{(2,2,3), south}()), | |
77 (MultiBlockBoundary{(1,2,3), east}(), MultiBlockBoundary{(2,2,3), west}()), | |
78 | |
79 (MultiBlockBoundary{(1,1,1), top}(), MultiBlockBoundary{(1,1,2), bottom}()), | |
80 (MultiBlockBoundary{(2,1,1), top}(), MultiBlockBoundary{(2,1,2), bottom}()), | |
81 (MultiBlockBoundary{(1,2,1), top}(), MultiBlockBoundary{(1,2,2), bottom}()), | |
82 (MultiBlockBoundary{(2,2,1), top}(), MultiBlockBoundary{(2,2,2), bottom}()), | |
83 | |
84 (MultiBlockBoundary{(1,1,2), top}(), MultiBlockBoundary{(1,1,3), bottom}()), | |
85 (MultiBlockBoundary{(2,1,2), top}(), MultiBlockBoundary{(2,1,3), bottom}()), | |
86 (MultiBlockBoundary{(1,2,2), top}(), MultiBlockBoundary{(1,2,3), bottom}()), | |
87 (MultiBlockBoundary{(2,2,2), top}(), MultiBlockBoundary{(2,2,3), bottom}()), | |
88 ]) | |
89 end | |
90 | |
91 @testset "boundary_identifiers" begin | |
92 # 2D | |
93 a = CartesianAtlas(fill(Chart(identity, unitcube()), 2,3)) | |
94 @test Set(boundary_identifiers(a)) == Set([ | |
95 MultiBlockBoundary{(1,1), south}(), | |
96 MultiBlockBoundary{(2,1), south}(), | |
97 MultiBlockBoundary{(2,1), east}(), | |
98 MultiBlockBoundary{(2,2), east}(), | |
99 MultiBlockBoundary{(2,3), east}(), | |
100 MultiBlockBoundary{(1,3), north}(), | |
101 MultiBlockBoundary{(2,3), north}(), | |
102 MultiBlockBoundary{(1,1), west}(), | |
103 MultiBlockBoundary{(1,2), west}(), | |
104 MultiBlockBoundary{(1,3), west}(), | |
105 ]) | |
106 | |
107 # 3D | |
108 a = CartesianAtlas(fill(Chart(identity, unitsquare()), 2,2,3)) | |
109 @test Set(boundary_identifiers(a)) == Set([ | |
110 MultiBlockBoundary{(1,1,1), bottom}(), | |
111 MultiBlockBoundary{(2,1,1), bottom}(), | |
112 MultiBlockBoundary{(1,2,1), bottom}(), | |
113 MultiBlockBoundary{(2,2,1), bottom}(), | |
114 | |
115 MultiBlockBoundary{(1,1,3), top}(), | |
116 MultiBlockBoundary{(2,1,3), top}(), | |
117 MultiBlockBoundary{(1,2,3), top}(), | |
118 MultiBlockBoundary{(2,2,3), top}(), | |
119 | |
120 MultiBlockBoundary{(1,1,1), west}(), | |
121 MultiBlockBoundary{(1,2,1), west}(), | |
122 MultiBlockBoundary{(1,1,2), west}(), | |
123 MultiBlockBoundary{(1,2,2), west}(), | |
124 MultiBlockBoundary{(1,1,3), west}(), | |
125 MultiBlockBoundary{(1,2,3), west}(), | |
126 | |
127 MultiBlockBoundary{(2,1,1), east}(), | |
128 MultiBlockBoundary{(2,2,1), east}(), | |
129 MultiBlockBoundary{(2,1,2), east}(), | |
130 MultiBlockBoundary{(2,2,2), east}(), | |
131 MultiBlockBoundary{(2,1,3), east}(), | |
132 MultiBlockBoundary{(2,2,3), east}(), | |
133 | |
134 MultiBlockBoundary{(1,1,1), south}(), | |
135 MultiBlockBoundary{(2,1,1), south}(), | |
136 MultiBlockBoundary{(1,1,2), south}(), | |
137 MultiBlockBoundary{(2,1,2), south}(), | |
138 MultiBlockBoundary{(1,1,3), south}(), | |
139 MultiBlockBoundary{(2,1,3), south}(), | |
140 | |
141 MultiBlockBoundary{(1,2,1), north}(), | |
142 MultiBlockBoundary{(2,2,1), north}(), | |
143 MultiBlockBoundary{(1,2,2), north}(), | |
144 MultiBlockBoundary{(2,2,2), north}(), | |
145 MultiBlockBoundary{(1,2,3), north}(), | |
146 MultiBlockBoundary{(2,2,3), north}(), | |
147 ]) | |
148 end | |
77 end | 149 end |
150 | |
151 @testset "UnstructuredAtlas" begin | |
152 @testset "Constructors" begin | |
153 c1 = Chart(identity, unitsquare()) | |
154 c2 = Chart(x->2x, unitsquare()) | |
155 cn = [ | |
156 (MultiBlockBoundary{1, east}(), MultiBlockBoundary{2, west}()), | |
157 (MultiBlockBoundary{1, north}(), MultiBlockBoundary{3, west}()), | |
158 (MultiBlockBoundary{2, north}(), MultiBlockBoundary{3, south}()), | |
159 ] | |
160 | |
161 @test UnstructuredAtlas([c1, c1, c1], cn) isa UnstructuredAtlas | |
162 @test UnstructuredAtlas([c1, c2, c1, c2], cn) isa UnstructuredAtlas | |
163 | |
164 | |
165 cn = @SVector[ | |
166 (MultiBlockBoundary{1, east}(), MultiBlockBoundary{2, west}()), | |
167 (MultiBlockBoundary{1, north}(), MultiBlockBoundary{3, west}()), | |
168 (MultiBlockBoundary{2, north}(), MultiBlockBoundary{3, south}()), | |
169 ] | |
170 @test UnstructuredAtlas(@SVector[c1, c1, c1], cn) isa UnstructuredAtlas | |
171 @test UnstructuredAtlas(@SVector[c1, c2, c1, c2], cn) isa UnstructuredAtlas | |
172 end | |
173 | |
174 @testset "Getters" begin | |
175 c = Chart(identity, unitsquare()) | |
176 cn = [ | |
177 (MultiBlockBoundary{1, east}(), MultiBlockBoundary{2, west}()), | |
178 (MultiBlockBoundary{1, north}(), MultiBlockBoundary{3, west}()), | |
179 (MultiBlockBoundary{2, north}(), MultiBlockBoundary{3, south}()), | |
180 ] | |
181 | |
182 a = UnstructuredAtlas([c, c, c], cn) | |
183 | |
184 @test charts(a) == [c,c,c] | |
185 @test connections(a) == cn | |
186 end | |
187 | |
188 @testset "boundary_identifiers" begin | |
189 c = Chart(identity, unitsquare()) | |
190 cn = [ | |
191 (MultiBlockBoundary{1, east}(), MultiBlockBoundary{2, west}()), | |
192 (MultiBlockBoundary{1, north}(), MultiBlockBoundary{3, west}()), | |
193 (MultiBlockBoundary{2, north}(), MultiBlockBoundary{3, south}()), | |
194 ] | |
195 | |
196 a = UnstructuredAtlas([c, c, c], cn) | |
197 | |
198 @test Set(boundary_identifiers(a)) == Set([ | |
199 MultiBlockBoundary{1, west}(), | |
200 MultiBlockBoundary{1, south}(), | |
201 MultiBlockBoundary{2, south}(), | |
202 MultiBlockBoundary{2, east}(), | |
203 MultiBlockBoundary{3, north}(), | |
204 MultiBlockBoundary{3, east}(), | |
205 ]) | |
206 | |
207 end | |
208 end |