Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundaryops/boundary_restriction_test.jl @ 926:47425442bbc5 feature/laplace_opset
Fix tests after refactoring
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 21 Feb 2022 23:33:29 +0100 |
parents | beae513ef8b3 |
children | af670581b464 |
comparison
equal
deleted
inserted
replaced
925:6b47a9ee1632 | 926:47425442bbc5 |
---|---|
1 using Test | 1 using Test |
2 | 2 |
3 using Sbplib.SbpOperators | 3 using Sbplib.SbpOperators |
4 using Sbplib.Grids | 4 using Sbplib.Grids |
5 using Sbplib.RegionIndices | |
6 using Sbplib.LazyTensors | 5 using Sbplib.LazyTensors |
7 | 6 |
8 import Sbplib.SbpOperators.BoundaryOperator | 7 import Sbplib.SbpOperators.BoundaryOperator |
9 | 8 |
10 @testset "boundary_restriction" begin | 9 @testset "boundary_restriction" begin |
13 g_1D = EquidistantGrid(11, 0.0, 1.0) | 12 g_1D = EquidistantGrid(11, 0.0, 1.0) |
14 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) | 13 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) |
15 | 14 |
16 @testset "boundary_restriction" begin | 15 @testset "boundary_restriction" begin |
17 @testset "1D" begin | 16 @testset "1D" begin |
18 e_l = boundary_restriction(g_1D,e_closure,Lower()) | 17 e_l = boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Lower}()) |
19 @test e_l == boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Lower}()) | |
20 @test e_l == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Lower()) | 18 @test e_l == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Lower()) |
21 @test e_l isa BoundaryOperator{T,Lower} where T | 19 @test e_l isa BoundaryOperator{T,Lower} where T |
22 @test e_l isa TensorMapping{T,0,1} where T | 20 @test e_l isa TensorMapping{T,0,1} where T |
23 | 21 |
24 e_r = boundary_restriction(g_1D,e_closure,Upper()) | 22 e_r = boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Upper}()) |
25 @test e_r == boundary_restriction(g_1D,e_closure,CartesianBoundary{1,Upper}()) | |
26 @test e_r == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Upper()) | 23 @test e_r == BoundaryOperator(g_1D,Stencil{Float64}(e_closure),Upper()) |
27 @test e_r isa BoundaryOperator{T,Upper} where T | 24 @test e_r isa BoundaryOperator{T,Upper} where T |
28 @test e_r isa TensorMapping{T,0,1} where T | 25 @test e_r isa TensorMapping{T,0,1} where T |
29 end | 26 end |
30 | 27 |
35 end | 32 end |
36 end | 33 end |
37 | 34 |
38 @testset "Application" begin | 35 @testset "Application" begin |
39 @testset "1D" begin | 36 @testset "1D" begin |
40 e_l = boundary_restriction(g_1D, e_closure, CartesianBoundary{1,Lower}()) | 37 (e_l, e_r) = |
41 e_r = boundary_restriction(g_1D, e_closure, CartesianBoundary{1,Upper}()) | 38 map(id -> boundary_restriction(g_1D, e_closure, id), boundary_identifiers(g_1D)) |
42 | 39 |
43 v = evalOn(g_1D,x->1+x^2) | 40 v = evalOn(g_1D,x->1+x^2) |
44 u = fill(3.124) | 41 u = fill(3.124) |
45 | 42 |
46 @test (e_l*v)[] == v[1] | 43 @test (e_l*v)[] == v[1] |
47 @test (e_r*v)[] == v[end] | 44 @test (e_r*v)[] == v[end] |
48 @test (e_r*v)[1] == v[end] | 45 @test (e_r*v)[1] == v[end] |
49 end | 46 end |
50 | 47 |
51 @testset "2D" begin | 48 @testset "2D" begin |
52 e_w = boundary_restriction(g_2D, e_closure, CartesianBoundary{1,Lower}()) | 49 (e_w, e_e, e_s, e_n) = |
53 e_e = boundary_restriction(g_2D, e_closure, CartesianBoundary{1,Upper}()) | 50 map(id -> boundary_restriction(g_2D, e_closure, id), boundary_identifiers(g_2D)) |
54 e_s = boundary_restriction(g_2D, e_closure, CartesianBoundary{2,Lower}()) | |
55 e_n = boundary_restriction(g_2D, e_closure, CartesianBoundary{2,Upper}()) | |
56 | 51 |
57 v = rand(11, 15) | 52 v = rand(11, 15) |
58 u = fill(3.124) | 53 u = fill(3.124) |
59 | 54 |
60 @test e_w*v == v[1,:] | 55 @test e_w*v == v[1,:] |