Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundaryops/boundary_restriction_test.jl @ 728:45966c77cb20 feature/selectable_tests
Split tests for SbpOperators over several files
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 17 Mar 2021 20:34:40 +0100 |
parents | |
children | 6114274447f5 |
comparison
equal
deleted
inserted
replaced
727:95b207729b7a | 728:45966c77cb20 |
---|---|
1 using Test | |
2 | |
3 using Sbplib.SbpOperators | |
4 using Sbplib.Grids | |
5 | |
6 @testset "boundary_restriction" begin | |
7 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | |
8 g_1D = EquidistantGrid(11, 0.0, 1.0) | |
9 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) | |
10 | |
11 @testset "boundary_restriction" begin | |
12 @testset "1D" begin | |
13 e_l = boundary_restriction(g_1D,op.eClosure,Lower()) | |
14 @test e_l == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Lower}()) | |
15 @test e_l == BoundaryOperator(g_1D,op.eClosure,Lower()) | |
16 @test e_l isa BoundaryOperator{T,Lower} where T | |
17 @test e_l isa TensorMapping{T,0,1} where T | |
18 | |
19 e_r = boundary_restriction(g_1D,op.eClosure,Upper()) | |
20 @test e_r == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Upper}()) | |
21 @test e_r == BoundaryOperator(g_1D,op.eClosure,Upper()) | |
22 @test e_r isa BoundaryOperator{T,Upper} where T | |
23 @test e_r isa TensorMapping{T,0,1} where T | |
24 end | |
25 | |
26 @testset "2D" begin | |
27 e_w = boundary_restriction(g_2D,op.eClosure,CartesianBoundary{1,Upper}()) | |
28 @test e_w isa InflatedTensorMapping | |
29 @test e_w isa TensorMapping{T,1,2} where T | |
30 end | |
31 end | |
32 | |
33 @testset "Application" begin | |
34 @testset "1D" begin | |
35 e_l = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Lower}()) | |
36 e_r = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Upper}()) | |
37 | |
38 v = evalOn(g_1D,x->1+x^2) | |
39 u = fill(3.124) | |
40 | |
41 @test (e_l*v)[] == v[1] | |
42 @test (e_r*v)[] == v[end] | |
43 @test (e_r*v)[1] == v[end] | |
44 end | |
45 | |
46 @testset "2D" begin | |
47 e_w = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Lower}()) | |
48 e_e = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Upper}()) | |
49 e_s = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Lower}()) | |
50 e_n = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Upper}()) | |
51 | |
52 v = rand(11, 15) | |
53 u = fill(3.124) | |
54 | |
55 @test e_w*v == v[1,:] | |
56 @test e_e*v == v[end,:] | |
57 @test e_s*v == v[:,1] | |
58 @test e_n*v == v[:,end] | |
59 end | |
60 end | |
61 end |