Mercurial > repos > public > sbplib_julia
annotate test/SbpOperators/stencil_test.jl @ 1032:11767fbb29f4 feature/dissipation_operators
Add padding functions for stencils
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Mar 2022 11:18:57 +0100 |
parents | 4433be383840 |
children | 14cb97284373 |
rev | line source |
---|---|
728
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
1 using Test |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
2 using Sbplib.SbpOperators |
732
6114274447f5
Add missing using and imports in test files
Jonatan Werpers <jonatan@werpers.com>
parents:
728
diff
changeset
|
3 import Sbplib.SbpOperators.Stencil |
728
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
4 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
5 @testset "Stencil" begin |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
6 s = Stencil((-2,2), (1.,2.,2.,3.,4.)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
7 @test s isa Stencil{Float64, 5} |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
8 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
9 @test eltype(s) == Float64 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
10 @test SbpOperators.scale(s, 2) == Stencil((-2,2), (2.,4.,4.,6.,8.)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
11 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
12 @test Stencil(1,2,3,4; center=1) == Stencil((0, 3),(1,2,3,4)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
13 @test Stencil(1,2,3,4; center=2) == Stencil((-1, 2),(1,2,3,4)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
14 @test Stencil(1,2,3,4; center=4) == Stencil((-3, 0),(1,2,3,4)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
15 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
16 @test CenteredStencil(1,2,3,4,5) == Stencil((-2, 2), (1,2,3,4,5)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
17 @test_throws ArgumentError CenteredStencil(1,2,3,4) |
826
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
18 |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
19 # Changing the type of the weights |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
20 @test Stencil{Float64}(Stencil(1,2,3,4,5; center=2)) == Stencil(1.,2.,3.,4.,5.; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
21 @test Stencil{Float64}(CenteredStencil(1,2,3,4,5)) == CenteredStencil(1.,2.,3.,4.,5.) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
22 @test Stencil{Int}(Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1,2,3,4,5; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
23 @test Stencil{Rational}(Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1//1,2//1,3//1,4//1,5//1; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
24 |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
25 @testset "convert" begin |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
26 @test convert(Stencil{Float64}, Stencil(1,2,3,4,5; center=2)) == Stencil(1.,2.,3.,4.,5.; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
27 @test convert(Stencil{Float64}, CenteredStencil(1,2,3,4,5)) == CenteredStencil(1.,2.,3.,4.,5.) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
28 @test convert(Stencil{Int}, Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1,2,3,4,5; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
29 @test convert(Stencil{Rational}, Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1//1,2//1,3//1,4//1,5//1; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
30 end |
728
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
31 end |
1032
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
32 |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
33 @testset "left_pad" begin |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
34 @test SbpOperators.left_pad(Stencil(1,1, center = 1), 2) == Stencil(1,1, center=1) |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
35 @test SbpOperators.left_pad(Stencil(1,1, center = 1), 3) == Stencil(0,1,1, center=2) |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
36 @test SbpOperators.left_pad(Stencil(2,3, center = 2), 4) == Stencil(0,0,2,3, center=4) |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
37 |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
38 @test SbpOperators.left_pad(Stencil(2.,3., center = 2), 4) == Stencil(0.,0.,2.,3., center=4) |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
39 end |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
40 |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
41 @testset "right_pad" begin |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
42 @test SbpOperators.right_pad(Stencil(1,1, center = 1), 2) == Stencil(1,1, center=1) |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
43 @test SbpOperators.right_pad(Stencil(1,1, center = 1), 3) == Stencil(1,1,0, center=1) |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
44 @test SbpOperators.right_pad(Stencil(2,3, center = 2), 4) == Stencil(2,3,0,0, center=2) |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
45 |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
46 @test SbpOperators.right_pad(Stencil(2.,3., center = 2), 4) == Stencil(2.,3.,0.,0., center=2) |
11767fbb29f4
Add padding functions for stencils
Jonatan Werpers <jonatan@werpers.com>
parents:
826
diff
changeset
|
47 end |