Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundaryops/boundary_restriction_test.jl @ 750:f88b2117dc69 feature/laplace_opset
Merge in default
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 19 Mar 2021 16:52:53 +0100 |
parents | 6114274447f5 |
children | bea2feebbeca |
comparison
equal
deleted
inserted
replaced
723:c16abc564b82 | 750:f88b2117dc69 |
---|---|
1 using Test | |
2 | |
3 using Sbplib.SbpOperators | |
4 using Sbplib.Grids | |
5 using Sbplib.RegionIndices | |
6 using Sbplib.LazyTensors | |
7 | |
8 import Sbplib.SbpOperators.BoundaryOperator | |
9 | |
10 @testset "boundary_restriction" begin | |
11 op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4) | |
12 g_1D = EquidistantGrid(11, 0.0, 1.0) | |
13 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) | |
14 | |
15 @testset "boundary_restriction" begin | |
16 @testset "1D" begin | |
17 e_l = boundary_restriction(g_1D,op.eClosure,Lower()) | |
18 @test e_l == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Lower}()) | |
19 @test e_l == BoundaryOperator(g_1D,op.eClosure,Lower()) | |
20 @test e_l isa BoundaryOperator{T,Lower} where T | |
21 @test e_l isa TensorMapping{T,0,1} where T | |
22 | |
23 e_r = boundary_restriction(g_1D,op.eClosure,Upper()) | |
24 @test e_r == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Upper}()) | |
25 @test e_r == BoundaryOperator(g_1D,op.eClosure,Upper()) | |
26 @test e_r isa BoundaryOperator{T,Upper} where T | |
27 @test e_r isa TensorMapping{T,0,1} where T | |
28 end | |
29 | |
30 @testset "2D" begin | |
31 e_w = boundary_restriction(g_2D,op.eClosure,CartesianBoundary{1,Upper}()) | |
32 @test e_w isa InflatedTensorMapping | |
33 @test e_w isa TensorMapping{T,1,2} where T | |
34 end | |
35 end | |
36 | |
37 @testset "Application" begin | |
38 @testset "1D" begin | |
39 e_l = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Lower}()) | |
40 e_r = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Upper}()) | |
41 | |
42 v = evalOn(g_1D,x->1+x^2) | |
43 u = fill(3.124) | |
44 | |
45 @test (e_l*v)[] == v[1] | |
46 @test (e_r*v)[] == v[end] | |
47 @test (e_r*v)[1] == v[end] | |
48 end | |
49 | |
50 @testset "2D" begin | |
51 e_w = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Lower}()) | |
52 e_e = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Upper}()) | |
53 e_s = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Lower}()) | |
54 e_n = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Upper}()) | |
55 | |
56 v = rand(11, 15) | |
57 u = fill(3.124) | |
58 | |
59 @test e_w*v == v[1,:] | |
60 @test e_e*v == v[end,:] | |
61 @test e_s*v == v[:,1] | |
62 @test e_n*v == v[:,end] | |
63 end | |
64 end | |
65 end |