Mercurial > repos > public > sbplib_julia
comparison SbpOperators/test/runtests.jl @ 328:9cc5d1498b2d
Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 24 Sep 2020 22:31:48 +0200 |
parents | accb0876da12 |
children | 408c37b295c2 |
comparison
equal
deleted
inserted
replaced
327:802edc9f252e | 328:9cc5d1498b2d |
---|---|
117 e4 = collect(L*v4) - v2 | 117 e4 = collect(L*v4) - v2 |
118 e5 = collect(L*v5) - v5ₓₓ | 118 e5 = collect(L*v5) - v5ₓₓ |
119 @test sqrt(prod(h)*sum(collect(e4.^2))) <= accuracytol | 119 @test sqrt(prod(h)*sum(collect(e4.^2))) <= accuracytol |
120 @test sqrt(prod(h)*sum(collect(e5.^2))) <= accuracytol | 120 @test sqrt(prod(h)*sum(collect(e5.^2))) <= accuracytol |
121 end | 121 end |
122 # | 122 |
123 # @testset "Quadrature" begin | 123 @testset "DiagonalInnerProduct" begin |
124 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 124 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") |
125 # Lx = 2.3 | 125 L = 2.3 |
126 # Ly = 5.2 | 126 g = EquidistantGrid((77,), (0.0,), (L,)) |
127 # g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) | 127 h = spacing(g) |
128 # H = Quadrature(op,g) | 128 H = DiagonalInnerProduct(h[1],op.quadratureClosure) |
129 # v = ones(Float64, size(g)) | 129 v = ones(Float64, size(g)) |
130 # | 130 |
131 # @test H isa TensorOperator{T,2} where T | 131 @test H isa TensorOperator{T,1} where T |
132 # @test H' isa TensorMapping{T,2,2} where T | 132 @test H' isa TensorMapping{T,1,1} where T |
133 # @test sum(collect(H*v)) ≈ (Lx*Ly) | 133 @test sum(collect(H*v)) ≈ L |
134 # @test collect(H*v) == collect(H'*v) | 134 @test collect(H*v) == collect(H'*v) |
135 # end | 135 end |
136 | |
137 @testset "Quadrature" begin | |
138 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | |
139 Lx = 2.3 | |
140 Ly = 5.2 | |
141 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) | |
142 | |
143 h = spacing(g) | |
144 Hx = DiagonalInnerProduct(h[1],op.quadratureClosure); | |
145 Hy = DiagonalInnerProduct(h[2],op.quadratureClosure); | |
146 Q = Quadrature((Hx,Hy)) | |
147 | |
148 v = ones(Float64, size(g)) | |
149 | |
150 @test Q isa TensorOperator{T,2} where T | |
151 @test Q' isa TensorMapping{T,2,2} where T | |
152 @test sum(collect(Q*v)) ≈ (Lx*Ly) | |
153 @test collect(Q*v) == collect(Q'*v) | |
154 end | |
136 # | 155 # |
137 # @testset "InverseQuadrature" begin | 156 # @testset "InverseQuadrature" begin |
138 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 157 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") |
139 # Lx = 7.3 | 158 # Lx = 7.3 |
140 # Ly = 8.2 | 159 # Ly = 8.2 |