comparison test/testSbpOperators.jl @ 707:ee1808820929 feature/laplace_opset

Remove obsolete opset from tests
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 15 Feb 2021 17:59:51 +0100
parents 19301615b340
children
comparison
equal deleted inserted replaced
706:19301615b340 707:ee1808820929
334 end 334 end
335 335
336 @testset "Laplace" begin 336 @testset "Laplace" begin
337 g_1D = EquidistantGrid(101, 0.0, 1.) 337 g_1D = EquidistantGrid(101, 0.0, 1.)
338 g_3D = EquidistantGrid((51,101,52), (0.0, -1.0, 0.0), (1., 1., 1.)) 338 g_3D = EquidistantGrid((51,101,52), (0.0, -1.0, 0.0), (1., 1., 1.))
339 op2 = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) 339 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
340 op4 = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
341 @testset "Constructors" begin 340 @testset "Constructors" begin
342 341
343 @testset "1D" begin 342 @testset "1D" begin
344 # Create all tensor mappings included in Laplace 343 # Create all tensor mappings included in Laplace
345 Δ = laplace(g_1D, op4.innerStencil, op4.closureStencils) 344 Δ = laplace(g_1D, op.innerStencil, op.closureStencils)
346 H = inner_product(g_1D, op4.quadratureClosure) 345 H = inner_product(g_1D, op.quadratureClosure)
347 Hi = inverse_inner_product(g_1D, op4.quadratureClosure) 346 Hi = inverse_inner_product(g_1D, op.quadratureClosure)
348 347
349 (id_l, id_r) = boundary_identifiers(g_1D) 348 (id_l, id_r) = boundary_identifiers(g_1D)
350 349
351 e_l = boundary_restriction(g_1D,op4.eClosure,id_l) 350 e_l = boundary_restriction(g_1D,op.eClosure,id_l)
352 e_r = boundary_restriction(g_1D,op4.eClosure,id_r) 351 e_r = boundary_restriction(g_1D,op.eClosure,id_r)
353 e_dict = Dict(Pair(id_l,e_l),Pair(id_r,e_r)) 352 e_dict = Dict(Pair(id_l,e_l),Pair(id_r,e_r))
354 353
355 d_l = normal_derivative(g_1D,op4.dClosure,id_l) 354 d_l = normal_derivative(g_1D,op.dClosure,id_l)
356 d_r = normal_derivative(g_1D,op4.dClosure,id_r) 355 d_r = normal_derivative(g_1D,op.dClosure,id_r)
357 d_dict = Dict(Pair(id_l,d_l),Pair(id_r,d_r)) 356 d_dict = Dict(Pair(id_l,d_l),Pair(id_r,d_r))
358 357
359 H_l = inner_product(boundary_grid(g_1D,id_l),op4.quadratureClosure) 358 H_l = inner_product(boundary_grid(g_1D,id_l),op.quadratureClosure)
360 H_r = inner_product(boundary_grid(g_1D,id_r),op4.quadratureClosure) 359 H_r = inner_product(boundary_grid(g_1D,id_r),op.quadratureClosure)
361 Hb_dict = Dict(Pair(id_l,H_l),Pair(id_r,H_r)) 360 Hb_dict = Dict(Pair(id_l,H_l),Pair(id_r,H_r))
362 361
363 L = Laplace(g_1D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 362 L = Laplace(g_1D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
364 @test cmp_fields(L,Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict)) 363 @test cmp_fields(L,Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict))
365 @test L isa TensorMapping{T,1,1} where T 364 @test L isa TensorMapping{T,1,1} where T
366 @inferred Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict) 365 @inferred Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict)
367 end 366 end
368 @testset "3D" begin 367 @testset "3D" begin
369 # Create all tensor mappings included in Laplace 368 # Create all tensor mappings included in Laplace
370 Δ = laplace(g_3D, op4.innerStencil, op4.closureStencils) 369 Δ = laplace(g_3D, op.innerStencil, op.closureStencils)
371 H = inner_product(g_3D, op4.quadratureClosure) 370 H = inner_product(g_3D, op.quadratureClosure)
372 Hi = inverse_inner_product(g_3D, op4.quadratureClosure) 371 Hi = inverse_inner_product(g_3D, op.quadratureClosure)
373 372
374 (id_l, id_r, id_s, id_n, id_b, id_t) = boundary_identifiers(g_3D) 373 (id_l, id_r, id_s, id_n, id_b, id_t) = boundary_identifiers(g_3D)
375 374
376 e_l = boundary_restriction(g_3D,op4.eClosure,id_l) 375 e_l = boundary_restriction(g_3D,op.eClosure,id_l)
377 e_r = boundary_restriction(g_3D,op4.eClosure,id_r) 376 e_r = boundary_restriction(g_3D,op.eClosure,id_r)
378 e_s = boundary_restriction(g_3D,op4.eClosure,id_s) 377 e_s = boundary_restriction(g_3D,op.eClosure,id_s)
379 e_n = boundary_restriction(g_3D,op4.eClosure,id_n) 378 e_n = boundary_restriction(g_3D,op.eClosure,id_n)
380 e_b = boundary_restriction(g_3D,op4.eClosure,id_b) 379 e_b = boundary_restriction(g_3D,op.eClosure,id_b)
381 e_t = boundary_restriction(g_3D,op4.eClosure,id_t) 380 e_t = boundary_restriction(g_3D,op.eClosure,id_t)
382 e_dict = Dict(Pair(id_l,e_l),Pair(id_r,e_r), 381 e_dict = Dict(Pair(id_l,e_l),Pair(id_r,e_r),
383 Pair(id_s,e_s),Pair(id_n,e_n), 382 Pair(id_s,e_s),Pair(id_n,e_n),
384 Pair(id_b,e_b),Pair(id_t,e_t)) 383 Pair(id_b,e_b),Pair(id_t,e_t))
385 384
386 d_l = normal_derivative(g_3D,op4.dClosure,id_l) 385 d_l = normal_derivative(g_3D,op.dClosure,id_l)
387 d_r = normal_derivative(g_3D,op4.dClosure,id_r) 386 d_r = normal_derivative(g_3D,op.dClosure,id_r)
388 d_s = normal_derivative(g_3D,op4.dClosure,id_s) 387 d_s = normal_derivative(g_3D,op.dClosure,id_s)
389 d_n = normal_derivative(g_3D,op4.dClosure,id_n) 388 d_n = normal_derivative(g_3D,op.dClosure,id_n)
390 d_b = normal_derivative(g_3D,op4.dClosure,id_b) 389 d_b = normal_derivative(g_3D,op.dClosure,id_b)
391 d_t = normal_derivative(g_3D,op4.dClosure,id_t) 390 d_t = normal_derivative(g_3D,op.dClosure,id_t)
392 d_dict = Dict(Pair(id_l,d_l),Pair(id_r,d_r), 391 d_dict = Dict(Pair(id_l,d_l),Pair(id_r,d_r),
393 Pair(id_s,d_s),Pair(id_n,d_n), 392 Pair(id_s,d_s),Pair(id_n,d_n),
394 Pair(id_b,d_b),Pair(id_t,d_t)) 393 Pair(id_b,d_b),Pair(id_t,d_t))
395 394
396 H_l = inner_product(boundary_grid(g_3D,id_l),op4.quadratureClosure) 395 H_l = inner_product(boundary_grid(g_3D,id_l),op.quadratureClosure)
397 H_r = inner_product(boundary_grid(g_3D,id_r),op4.quadratureClosure) 396 H_r = inner_product(boundary_grid(g_3D,id_r),op.quadratureClosure)
398 H_s = inner_product(boundary_grid(g_3D,id_s),op4.quadratureClosure) 397 H_s = inner_product(boundary_grid(g_3D,id_s),op.quadratureClosure)
399 H_n = inner_product(boundary_grid(g_3D,id_n),op4.quadratureClosure) 398 H_n = inner_product(boundary_grid(g_3D,id_n),op.quadratureClosure)
400 H_b = inner_product(boundary_grid(g_3D,id_b),op4.quadratureClosure) 399 H_b = inner_product(boundary_grid(g_3D,id_b),op.quadratureClosure)
401 H_t = inner_product(boundary_grid(g_3D,id_t),op4.quadratureClosure) 400 H_t = inner_product(boundary_grid(g_3D,id_t),op.quadratureClosure)
402 Hb_dict = Dict(Pair(id_l,H_l),Pair(id_r,H_r), 401 Hb_dict = Dict(Pair(id_l,H_l),Pair(id_r,H_r),
403 Pair(id_s,H_s),Pair(id_n,H_n), 402 Pair(id_s,H_s),Pair(id_n,H_n),
404 Pair(id_b,H_b),Pair(id_t,H_t)) 403 Pair(id_b,H_b),Pair(id_t,H_t))
405 404
406 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 405 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
410 end 409 end
411 end 410 end
412 411
413 @testset "laplace" begin 412 @testset "laplace" begin
414 @testset "1D" begin 413 @testset "1D" begin
415 L = laplace(g_1D, op4.innerStencil, op4.closureStencils) 414 L = laplace(g_1D, op.innerStencil, op.closureStencils)
416 @test L == second_derivative(g_1D, op4.innerStencil, op4.closureStencils) 415 @test L == second_derivative(g_1D, op.innerStencil, op.closureStencils)
417 @test L isa TensorMapping{T,1,1} where T 416 @test L isa TensorMapping{T,1,1} where T
418 end 417 end
419 @testset "3D" begin 418 @testset "3D" begin
420 L = laplace(g_3D, op4.innerStencil, op4.closureStencils) 419 L = laplace(g_3D, op.innerStencil, op.closureStencils)
421 @test L isa TensorMapping{T,3,3} where T 420 @test L isa TensorMapping{T,3,3} where T
422 Dxx = second_derivative(g_3D, op4.innerStencil, op4.closureStencils,1) 421 Dxx = second_derivative(g_3D, op.innerStencil, op.closureStencils,1)
423 Dyy = second_derivative(g_3D, op4.innerStencil, op4.closureStencils,2) 422 Dyy = second_derivative(g_3D, op.innerStencil, op.closureStencils,2)
424 Dzz = second_derivative(g_3D, op4.innerStencil, op4.closureStencils,3) 423 Dzz = second_derivative(g_3D, op.innerStencil, op.closureStencils,3)
425 @test L == Dxx + Dyy + Dzz 424 @test L == Dxx + Dyy + Dzz
426 @test L isa TensorMapping{T,3,3} where T 425 @test L isa TensorMapping{T,3,3} where T
427 end 426 end
428 end 427 end
429 428
430 @testset "inner_product" begin 429 @testset "inner_product" begin
431 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 430 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
432 @test inner_product(L) == inner_product(g_3D,op4.quadratureClosure) 431 @test inner_product(L) == inner_product(g_3D,op.quadratureClosure)
433 end 432 end
434 433
435 @testset "inverse_inner_product" begin 434 @testset "inverse_inner_product" begin
436 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 435 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
437 @test inverse_inner_product(L) == inverse_inner_product(g_3D,op4.quadratureClosure) 436 @test inverse_inner_product(L) == inverse_inner_product(g_3D,op.quadratureClosure)
438 end 437 end
439 438
440 @testset "boundary_restriction" begin 439 @testset "boundary_restriction" begin
441 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 440 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
442 id_l = CartesianBoundary{1,Lower}() 441 id_l = CartesianBoundary{1,Lower}()
443 id_r = CartesianBoundary{1,Upper}() 442 id_r = CartesianBoundary{1,Upper}()
444 id_s = CartesianBoundary{2,Lower}() 443 id_s = CartesianBoundary{2,Lower}()
445 id_n = CartesianBoundary{2,Upper}() 444 id_n = CartesianBoundary{2,Upper}()
446 id_b = CartesianBoundary{3,Lower}() 445 id_b = CartesianBoundary{3,Lower}()
447 id_t = CartesianBoundary{3,Upper}() 446 id_t = CartesianBoundary{3,Upper}()
448 @test boundary_restriction(L,id_l) == boundary_restriction(g_3D,op4.eClosure,id_l) 447 @test boundary_restriction(L,id_l) == boundary_restriction(g_3D,op.eClosure,id_l)
449 @test boundary_restriction(L,id_r) == boundary_restriction(g_3D,op4.eClosure,id_r) 448 @test boundary_restriction(L,id_r) == boundary_restriction(g_3D,op.eClosure,id_r)
450 @test boundary_restriction(L,id_s) == boundary_restriction(g_3D,op4.eClosure,id_s) 449 @test boundary_restriction(L,id_s) == boundary_restriction(g_3D,op.eClosure,id_s)
451 @test boundary_restriction(L,id_n) == boundary_restriction(g_3D,op4.eClosure,id_n) 450 @test boundary_restriction(L,id_n) == boundary_restriction(g_3D,op.eClosure,id_n)
452 @test boundary_restriction(L,id_b) == boundary_restriction(g_3D,op4.eClosure,id_b) 451 @test boundary_restriction(L,id_b) == boundary_restriction(g_3D,op.eClosure,id_b)
453 @test boundary_restriction(L,id_t) == boundary_restriction(g_3D,op4.eClosure,id_t) 452 @test boundary_restriction(L,id_t) == boundary_restriction(g_3D,op.eClosure,id_t)
454 end 453 end
455 454
456 @testset "normal_derivative" begin 455 @testset "normal_derivative" begin
457 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 456 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
458 id_l = CartesianBoundary{1,Lower}() 457 id_l = CartesianBoundary{1,Lower}()
459 id_r = CartesianBoundary{1,Upper}() 458 id_r = CartesianBoundary{1,Upper}()
460 id_s = CartesianBoundary{2,Lower}() 459 id_s = CartesianBoundary{2,Lower}()
461 id_n = CartesianBoundary{2,Upper}() 460 id_n = CartesianBoundary{2,Upper}()
462 id_b = CartesianBoundary{3,Lower}() 461 id_b = CartesianBoundary{3,Lower}()
463 id_t = CartesianBoundary{3,Upper}() 462 id_t = CartesianBoundary{3,Upper}()
464 @test normal_derivative(L,id_l) == normal_derivative(g_3D,op4.dClosure,id_l) 463 @test normal_derivative(L,id_l) == normal_derivative(g_3D,op.dClosure,id_l)
465 @test normal_derivative(L,id_r) == normal_derivative(g_3D,op4.dClosure,id_r) 464 @test normal_derivative(L,id_r) == normal_derivative(g_3D,op.dClosure,id_r)
466 @test normal_derivative(L,id_s) == normal_derivative(g_3D,op4.dClosure,id_s) 465 @test normal_derivative(L,id_s) == normal_derivative(g_3D,op.dClosure,id_s)
467 @test normal_derivative(L,id_n) == normal_derivative(g_3D,op4.dClosure,id_n) 466 @test normal_derivative(L,id_n) == normal_derivative(g_3D,op.dClosure,id_n)
468 @test normal_derivative(L,id_b) == normal_derivative(g_3D,op4.dClosure,id_b) 467 @test normal_derivative(L,id_b) == normal_derivative(g_3D,op.dClosure,id_b)
469 @test normal_derivative(L,id_t) == normal_derivative(g_3D,op4.dClosure,id_t) 468 @test normal_derivative(L,id_t) == normal_derivative(g_3D,op.dClosure,id_t)
470 end 469 end
471 470
472 @testset "boundary_quadrature" begin 471 @testset "boundary_quadrature" begin
473 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 472 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
474 id_l = CartesianBoundary{1,Lower}() 473 id_l = CartesianBoundary{1,Lower}()
475 id_r = CartesianBoundary{1,Upper}() 474 id_r = CartesianBoundary{1,Upper}()
476 id_s = CartesianBoundary{2,Lower}() 475 id_s = CartesianBoundary{2,Lower}()
477 id_n = CartesianBoundary{2,Upper}() 476 id_n = CartesianBoundary{2,Upper}()
478 id_b = CartesianBoundary{3,Lower}() 477 id_b = CartesianBoundary{3,Lower}()
479 id_t = CartesianBoundary{3,Upper}() 478 id_t = CartesianBoundary{3,Upper}()
480 @test boundary_quadrature(L,id_l) == inner_product(boundary_grid(g_3D,id_l),op4.quadratureClosure) 479 @test boundary_quadrature(L,id_l) == inner_product(boundary_grid(g_3D,id_l),op.quadratureClosure)
481 @test boundary_quadrature(L,id_r) == inner_product(boundary_grid(g_3D,id_r),op4.quadratureClosure) 480 @test boundary_quadrature(L,id_r) == inner_product(boundary_grid(g_3D,id_r),op.quadratureClosure)
482 @test boundary_quadrature(L,id_s) == inner_product(boundary_grid(g_3D,id_s),op4.quadratureClosure) 481 @test boundary_quadrature(L,id_s) == inner_product(boundary_grid(g_3D,id_s),op.quadratureClosure)
483 @test boundary_quadrature(L,id_n) == inner_product(boundary_grid(g_3D,id_n),op4.quadratureClosure) 482 @test boundary_quadrature(L,id_n) == inner_product(boundary_grid(g_3D,id_n),op.quadratureClosure)
484 @test boundary_quadrature(L,id_b) == inner_product(boundary_grid(g_3D,id_b),op4.quadratureClosure) 483 @test boundary_quadrature(L,id_b) == inner_product(boundary_grid(g_3D,id_b),op.quadratureClosure)
485 @test boundary_quadrature(L,id_t) == inner_product(boundary_grid(g_3D,id_t),op4.quadratureClosure) 484 @test boundary_quadrature(L,id_t) == inner_product(boundary_grid(g_3D,id_t),op.quadratureClosure)
486 end 485 end
487 486
488 # Exact differentiation is measured point-wise. In other cases 487 # Exact differentiation is measured point-wise. In other cases
489 # the error is measured in the l2-norm. 488 # the error is measured in the l2-norm.
490 @testset "Accuracy" begin 489 @testset "Accuracy" begin