|
207 | 207 | @test norm((D₁*(J .* g.:7) + D₂*(J .* g.:8) + D₃*(J .* g.:9)), |
208 | 208 | Inf) < 100*eps(T) |
209 | 209 | end |
| 210 | + |
| 211 | + @testset "1D perfect uniform brickgrid" begin |
| 212 | + cell = LobattoCell{T, A}(4) |
| 213 | + xrange = range(-T(1000), stop = T(1000), length = 21) |
| 214 | + grid = brickgrid(cell, (xrange,)) |
| 215 | + |
| 216 | + p = adapt(Array, points(grid)) |
| 217 | + x₁ = only(components(p)) |
| 218 | + |
| 219 | + @test all(x₁ .+ reverse(x₁, dims = (1, 2)) .== 0) |
| 220 | + |
| 221 | + g, J = adapt(Array, components(metrics(grid))) |
| 222 | + |
| 223 | + @test all(J .== step(xrange) / 2) |
| 224 | + @test all(g.:1 .== 2 / step(xrange)) |
| 225 | + end |
| 226 | + |
| 227 | + @testset "2D perfect uniform brickgrid" begin |
| 228 | + cell = LobattoCell{T, A}(4, 5) |
| 229 | + xrange = range(-T(1000), stop = T(1000), length = 21) |
| 230 | + yrange = range(-T(2000), stop = T(2000), length = 11) |
| 231 | + grid = brickgrid(cell, (xrange, yrange), |
| 232 | + ordering = CartesianOrdering()) |
| 233 | + |
| 234 | + p = adapt(Array, points(grid)) |
| 235 | + p = reshape(p, size(cell)..., size(grid)...) |
| 236 | + x₁, x₂ = components(p) |
| 237 | + |
| 238 | + @test all(x₁ .+ reverse(x₁, dims = (1, 3)) .== 0) |
| 239 | + @test all(x₂ .- reverse(x₂, dims = (1, 3)) .== 0) |
| 240 | + @test all(x₁ .- reverse(x₁, dims = (2, 4)) .== 0) |
| 241 | + @test all(x₂ .+ reverse(x₂, dims = (2, 4)) .== 0) |
| 242 | + |
| 243 | + g, J = adapt(Array, components(metrics(grid))) |
| 244 | + |
| 245 | + @test all(J .== step(xrange) * step(yrange) / 4) |
| 246 | + @test all(g.:1 .== 2 / step(xrange)) |
| 247 | + @test all(g.:2 .== 0) |
| 248 | + @test all(g.:3 .== 0) |
| 249 | + @test all(g.:4 .== 2 / step(yrange)) |
| 250 | + |
| 251 | + n, sJ = adapt(Array, components(facemetrics(grid))) |
| 252 | + n₁, n₂, n₃, n₄ = faceviews(cell, n) |
| 253 | + @test all(n₁ .== Ref(SVector(-1, 0))) |
| 254 | + @test all(n₂ .== Ref(SVector(1, 0))) |
| 255 | + @test all(n₃ .== Ref(SVector(0, -1))) |
| 256 | + @test all(n₄ .== Ref(SVector(0, 1))) |
| 257 | + |
| 258 | + sJ₁, sJ₂, sJ₃, sJ₄ = faceviews(cell, sJ) |
| 259 | + @test all(sJ₁ .== step(yrange) / 2) |
| 260 | + @test all(sJ₂ .== step(yrange) / 2) |
| 261 | + @test all(sJ₃ .== step(xrange) / 2) |
| 262 | + @test all(sJ₄ .== step(xrange) / 2) |
| 263 | + end |
| 264 | + |
| 265 | + @testset "3D perfect uniform brickgrid" begin |
| 266 | + cell = LobattoCell{T, A}(4, 5, 6) |
| 267 | + xrange = range(-T(1000), stop = T(1000), length = 21) |
| 268 | + yrange = range(-T(2000), stop = T(2000), length = 11) |
| 269 | + zrange = range(-T(3000), stop = T(3000), length = 6) |
| 270 | + grid = brickgrid(cell, (xrange, yrange, zrange), |
| 271 | + ordering = CartesianOrdering()) |
| 272 | + |
| 273 | + p = adapt(Array, points(grid)) |
| 274 | + p = reshape(p, size(cell)..., size(grid)...) |
| 275 | + x₁, x₂, x₃ = components(p) |
| 276 | + |
| 277 | + @test all(x₁ .+ reverse(x₁, dims = (1, 4)) .== 0) |
| 278 | + @test all(x₂ .- reverse(x₂, dims = (1, 4)) .== 0) |
| 279 | + @test all(x₃ .- reverse(x₃, dims = (1, 4)) .== 0) |
| 280 | + |
| 281 | + @test all(x₁ .- reverse(x₁, dims = (2, 5)) .== 0) |
| 282 | + @test all(x₂ .+ reverse(x₂, dims = (2, 5)) .== 0) |
| 283 | + @test all(x₃ .- reverse(x₃, dims = (2, 5)) .== 0) |
| 284 | + |
| 285 | + @test all(x₁ .- reverse(x₁, dims = (3, 6)) .== 0) |
| 286 | + @test all(x₂ .- reverse(x₂, dims = (3, 6)) .== 0) |
| 287 | + @test all(x₃ .+ reverse(x₃, dims = (3, 6)) .== 0) |
| 288 | + |
| 289 | + g, J = adapt(Array, components(metrics(grid))) |
| 290 | + |
| 291 | + @test all(J .== step(xrange) * step(yrange) * step(zrange) / 8) |
| 292 | + @test all(g.:1 .== 2 / step(xrange)) |
| 293 | + @test all(g.:2 .== 0) |
| 294 | + @test all(g.:3 .== 0) |
| 295 | + @test all(g.:4 .== 0) |
| 296 | + @test all(g.:5 .== 2 / step(yrange)) |
| 297 | + @test all(g.:6 .== 0) |
| 298 | + @test all(g.:7 .== 0) |
| 299 | + @test all(g.:8 .== 0) |
| 300 | + @test all(g.:9 .== 2 / step(zrange)) |
| 301 | + |
| 302 | + n, sJ = adapt(Array, components(facemetrics(grid))) |
| 303 | + n₁, n₂, n₃, n₄, n₅, n₆ = faceviews(cell, n) |
| 304 | + @test all(n₁ .== Ref(SVector(-1, 0, 0))) |
| 305 | + @test all(n₂ .== Ref(SVector(1, 0, 0))) |
| 306 | + @test all(n₃ .== Ref(SVector(0, -1, 0))) |
| 307 | + @test all(n₄ .== Ref(SVector(0, 1, 0))) |
| 308 | + @test all(n₅ .== Ref(SVector(0, 0, -1))) |
| 309 | + @test all(n₆ .== Ref(SVector(0, 0, 1))) |
| 310 | + |
| 311 | + sJ₁, sJ₂, sJ₃, sJ₄, sJ₅, sJ₆ = faceviews(cell, sJ) |
| 312 | + @test all(sJ₁ .== step(yrange) * step(zrange) / 4) |
| 313 | + @test all(sJ₂ .== step(yrange) * step(zrange) / 4) |
| 314 | + @test all(sJ₃ .== step(xrange) * step(zrange) / 4) |
| 315 | + @test all(sJ₄ .== step(xrange) * step(zrange) / 4) |
| 316 | + @test all(sJ₅ .== step(xrange) * step(yrange) / 4) |
| 317 | + @test all(sJ₆ .== step(xrange) * step(yrange) / 4) |
| 318 | + end |
210 | 319 | end |
211 | 320 | end |
0 commit comments