Mercurial > repos > public > sbplib_julia
comparison DiffOps/test/runtests.jl @ 262:f1e90a92ad74 boundary_conditions
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 26 Nov 2019 08:28:26 -0800 |
parents | 5571d2c5bf0f |
children | ce6a2f3f732a |
comparison
equal
deleted
inserted
replaced
261:01017d2b46b0 | 262:f1e90a92ad74 |
---|---|
3 using Grids | 3 using Grids |
4 using SbpOperators | 4 using SbpOperators |
5 using RegionIndices | 5 using RegionIndices |
6 using LazyTensors | 6 using LazyTensors |
7 | 7 |
8 @testset "Quadrature" begin | |
9 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | |
10 Lx = 2.3 | |
11 Ly = 5.2 | |
12 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) | |
13 H = Quadrature(op,g) | |
14 v = ones(Float64, size(g)) | |
15 | |
16 @test H isa TensorMapping{T,2,2} where T | |
17 @test H' isa TensorMapping{T,2,2} where T | |
18 @test sum(collect(H*v)) ≈ (Lx*Ly) | |
19 @test collect(H*v) == collect(H'*v) | |
20 end | |
21 | |
22 @testset "InverseQuadrature" begin | |
23 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | |
24 Lx = 7.3 | |
25 Ly = 8.2 | |
26 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) | |
27 H = Quadrature(op,g) | |
28 Hinv = InverseQuadrature(op,g) | |
29 v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y) | |
30 | |
31 @test Hinv isa TensorMapping{T,2,2} where T | |
32 @test Hinv' isa TensorMapping{T,2,2} where T | |
33 @test collect(Hinv*H*v) ≈ v | |
34 @test collect(Hinv*v) == collect(Hinv'*v) | |
35 end | |
36 | |
8 @testset "BoundaryValue" begin | 37 @testset "BoundaryValue" begin |
9 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 38 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") |
10 g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0)) | 39 g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0)) |
11 | 40 |
12 e_w = BoundaryValue(op, g, CartesianBoundary{1,Lower}()) | 41 e_w = BoundaryValue(op, g, CartesianBoundary{1,Lower}()) |
182 | 211 |
183 @test collect(H_w*v_w) ≈ q_y.*v_w | 212 @test collect(H_w*v_w) ≈ q_y.*v_w |
184 @test collect(H_e*v_e) ≈ q_y.*v_e | 213 @test collect(H_e*v_e) ≈ q_y.*v_e |
185 @test collect(H_s*v_s) ≈ q_x.*v_s | 214 @test collect(H_s*v_s) ≈ q_x.*v_s |
186 @test collect(H_n*v_n) ≈ q_x.*v_n | 215 @test collect(H_n*v_n) ≈ q_x.*v_n |
187 end | 216 |
217 @test collect(H_w'*v_w) == collect(H_w'*v_w) | |
218 @test collect(H_e'*v_e) == collect(H_e'*v_e) | |
219 @test collect(H_s'*v_s) == collect(H_s'*v_s) | |
220 @test collect(H_n'*v_n) == collect(H_n'*v_n) | |
221 end |