comparison test/SbpOperators/boundaryops/boundary_operator_test.jl @ 1281:1cc45207817e refactor/grids

Fix tests for boundary operator and boundary restriction
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 27 Feb 2023 08:48:38 +0100
parents ae006e844870
children 4684c7f1c4cb
comparison
equal deleted inserted replaced
1280:17d435c08773 1281:1cc45207817e
8 import Sbplib.SbpOperators.BoundaryOperator 8 import Sbplib.SbpOperators.BoundaryOperator
9 9
10 10
11 @testset "BoundaryOperator" begin 11 @testset "BoundaryOperator" begin
12 closure_stencil = Stencil(2.,1.,3.; center = 1) 12 closure_stencil = Stencil(2.,1.,3.; center = 1)
13 g_1D = EquidistantGrid(11, 0.0, 1.0) 13 g_1D = EquidistantGrid(range(0,1,length=11))
14 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0))
15 14
16 @testset "Constructors" begin 15 @testset "Constructors" begin
17 @test BoundaryOperator(g_1D, closure_stencil, Lower()) isa LazyTensor{T,0,1} where T 16 @test BoundaryOperator(g_1D, closure_stencil, Lower()) isa LazyTensor{T,0,1} where T
18 @test BoundaryOperator(g_1D, closure_stencil, Upper()) isa LazyTensor{T,0,1} where T 17 @test BoundaryOperator(g_1D, closure_stencil, Upper()) isa LazyTensor{T,0,1} where T
19 end 18 end
28 @test range_size(op_l) == () 27 @test range_size(op_l) == ()
29 @test range_size(op_r) == () 28 @test range_size(op_r) == ()
30 end 29 end
31 30
32 @testset "Application" begin 31 @testset "Application" begin
33 v = evalOn(g_1D,x->1+x^2) 32 v = eval_on(g_1D,x->1+x^2)
34 u = fill(3.124) 33 u = fill(3.124)
35 @test (op_l*v)[] == 2*v[1] + v[2] + 3*v[3] 34 @test (op_l*v)[] == 2*v[1] + v[2] + 3*v[3]
36 @test (op_r*v)[] == 2*v[end] + v[end-1] + 3*v[end-2] 35 @test (op_r*v)[] == 2*v[end] + v[end-1] + 3*v[end-2]
37 @test (op_r*v)[1] == 2*v[end] + v[end-1] + 3*v[end-2] 36 @test (op_r*v)[1] == 2*v[end] + v[end-1] + 3*v[end-2]
38 @test op_l'*u == [2*u[]; u[]; 3*u[]; zeros(8)] 37 @test op_l'*u == [2*u[]; u[]; 3*u[]; zeros(8)]
39 @test op_r'*u == [zeros(8); 3*u[]; u[]; 2*u[]] 38 @test op_r'*u == [zeros(8); 3*u[]; u[]; 2*u[]]
40 39
41 v = evalOn(g_1D, x->1. +x*im) 40 v = eval_on(g_1D, x->1. +x*im)
42 @test (op_l*v)[] isa ComplexF64 41 @test (op_l*v)[] isa ComplexF64
43 42
44 u = fill(1. +im) 43 u = fill(1. +im)
45 @test (op_l'*u)[1] isa ComplexF64 44 @test (op_l'*u)[1] isa ComplexF64
46 @test (op_l'*u)[5] isa ComplexF64 45 @test (op_l'*u)[5] isa ComplexF64