Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/volumeops/derivatives/dissipation_test.jl @ 1020:3f5137ce3aa1 feature/dissipation_operators
Start adding helper functions for building dissipation operators
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 18 Mar 2022 12:24:10 +0100 |
parents | |
children | ee5a641a8277 |
comparison
equal
deleted
inserted
replaced
988:83046af6143a | 1020:3f5137ce3aa1 |
---|---|
1 using Test | |
2 | |
3 using Sbplib.SbpOperators | |
4 # using Sbplib.Grids | |
5 # using Sbplib.LazyTensors | |
6 | |
7 using Sbplib.SbpOperators: Stencil | |
8 | |
9 using Sbplib.SbpOperators: dissipation_interior_weights | |
10 using Sbplib.SbpOperators: dissipation_interior_stencil, dissipation_transpose_interior_stencil | |
11 using Sbplib.SbpOperators: midpoint, midpoint_transpose | |
12 using Sbplib.SbpOperators: dissipation_lower_closure_size, dissipation_upper_closure_size | |
13 using Sbplib.SbpOperators: dissipation_lower_closure_stencils,dissipation_upper_closure_stencils | |
14 using Sbplib.SbpOperators: dissipation_transpose_lower_closure_stencils, dissipation_transpose_upper_closure_stencils | |
15 | |
16 @testset "dissipation_interior_weights" begin | |
17 @test dissipation_interior_weights(1) == (-1, 1) | |
18 @test dissipation_interior_weights(2) == (1,-2, 1) | |
19 @test dissipation_interior_weights(3) == (-1, 3,-3, 1) | |
20 @test dissipation_interior_weights(4) == (1, -4, 6, -4, 1) | |
21 end | |
22 | |
23 @testset "dissipation_interior_stencil" begin | |
24 @test dissipation_interior_stencil(1) == Stencil(-1,1, center=2) | |
25 @test dissipation_interior_stencil(2) == Stencil(1,-2,1, center=2) | |
26 @test dissipation_interior_stencil(3) == Stencil(-1,3,-3,1, center=3) | |
27 @test dissipation_interior_stencil(4) == Stencil(1, -4, 6, -4, 1, center=3) | |
28 end | |
29 | |
30 @testset "dissipation_transpose_interior_stencil" begin | |
31 @test dissipation_transpose_interior_stencil(1) == Stencil(-1,1, center=1) | |
32 @test dissipation_transpose_interior_stencil(2) == Stencil(1,-2,1, center=2) | |
33 @test dissipation_transpose_interior_stencil(3) == Stencil(-1,3,-3,1, center=2) | |
34 @test dissipation_transpose_interior_stencil(4) == Stencil(1, -4, 6, -4, 1, center=3) | |
35 end | |
36 | |
37 @testset "midpoint" begin | |
38 @test midpoint((1,1)) == 2 | |
39 @test midpoint((1,1,1)) == 2 | |
40 @test midpoint((1,1,1,1)) == 3 | |
41 @test midpoint((1,1,1,1,1)) == 3 | |
42 end | |
43 | |
44 @testset "midpoint_transpose" begin | |
45 @test midpoint_transpose((1,1)) == 1 | |
46 @test midpoint_transpose((1,1,1)) == 2 | |
47 @test midpoint_transpose((1,1,1,1)) == 2 | |
48 @test midpoint_transpose((1,1,1,1,1)) == 3 | |
49 end | |
50 | |
51 @testset "dissipation_lower_closure_size" begin | |
52 @test dissipation_lower_closure_size((1,1)) == 1 | |
53 @test dissipation_lower_closure_size((1,1,1)) == 1 | |
54 @test dissipation_lower_closure_size((1,1,1,1)) == 2 | |
55 @test dissipation_lower_closure_size((1,1,1,1,1)) == 2 | |
56 end | |
57 | |
58 @testset "dissipation_upper_closure_size" begin | |
59 @test dissipation_upper_closure_size((1,1)) == 0 | |
60 @test dissipation_upper_closure_size((1,1,1)) == 1 | |
61 @test dissipation_upper_closure_size((1,1,1,1)) == 1 | |
62 @test dissipation_upper_closure_size((1,1,1,1,1)) == 2 | |
63 end | |
64 | |
65 @testset "dissipation_lower_closure_stencils" begin | |
66 cases = ( | |
67 (-1,1) => ( | |
68 Stencil(-1, 1, center=1), | |
69 ), | |
70 (1,-2,1) => ( | |
71 Stencil( 1,-2, 1, center=1), | |
72 ), | |
73 (-1,3,-3,1) => ( | |
74 Stencil(-1,3,-3,1, center=1), | |
75 Stencil(-1,3,-3,1, center=2), | |
76 ), | |
77 (1, -4, 6, -4, 1) => ( | |
78 Stencil(1, -4, 6, -4, 1, center=1), | |
79 Stencil(1, -4, 6, -4, 1, center=2), | |
80 ) | |
81 ) | |
82 @testset "interior_weights = $w" for (w, closure_stencils) ∈ cases | |
83 @test dissipation_lower_closure_stencils(w) == closure_stencils | |
84 end | |
85 end | |
86 | |
87 @testset "dissipation_upper_closure_stencils" begin | |
88 cases = ( | |
89 (-1,1) => (), | |
90 (1,-2,1) => ( | |
91 Stencil( 1,-2, 1, center=3), | |
92 ), | |
93 (-1,3,-3,1) => ( | |
94 Stencil(-1,3,-3,1, center=4), | |
95 ), | |
96 (1, -4, 6, -4, 1) => ( | |
97 Stencil(1, -4, 6, -4, 1, center=4), | |
98 Stencil(1, -4, 6, -4, 1, center=5), | |
99 ) | |
100 ) | |
101 @testset "interior_weights = $w" for (w, closure_stencils) ∈ cases | |
102 @test dissipation_upper_closure_stencils(w) == closure_stencils | |
103 end | |
104 end | |
105 | |
106 | |
107 @testset "dissipation_transpose_lower_closure_stencils" begin | |
108 cases = ( | |
109 (-1,1) => ( | |
110 Stencil(-1,-1, center=1), | |
111 Stencil( 1, 1,-1, center=2), | |
112 ), | |
113 (1,-2,1) => ( | |
114 Stencil( 1, 1, center=1), | |
115 Stencil(-2,-2, 1, center=2), | |
116 Stencil( 1, 1,-2, 1, center=3), | |
117 ), | |
118 (-1,3,-3,1) => ( | |
119 Stencil(-1,-1,-1, center=1), | |
120 Stencil( 3, 3, 3,-1, center=2), | |
121 Stencil(-3,-3,-3, 3,-1, center=3), | |
122 Stencil( 1, 1, 1,-3, 3,-1, center=4), | |
123 ), | |
124 ) | |
125 @testset "interior_weights = $w" for (w, closure_stencils) ∈ cases | |
126 @test dissipation_transpose_lower_closure_stencils(w) == closure_stencils | |
127 end | |
128 end | |
129 | |
130 @testset "dissipation_transpose_upper_closure_stencils" begin | |
131 cases = ( | |
132 (-1,1) => ( | |
133 Stencil( 1,-1, center = 1), | |
134 Stencil( 1, center = 1), | |
135 ), | |
136 (1,-2,1) => ( | |
137 Stencil( 1, -2, 1, 1, center=2), | |
138 Stencil( 1,-2,-2, center=2), | |
139 Stencil( 1, 1, center=2), | |
140 ), | |
141 (-1,3,-3,1) => ( | |
142 Stencil( 1,-3, 3,-1,-1, center=2), | |
143 Stencil( 1,-3, 3, 3, center=2), | |
144 Stencil( 1,-3,-3, center=2), | |
145 Stencil( 1, 1, center=2), | |
146 ), | |
147 ) | |
148 @testset "interior_weights = $w" for (w, closure_stencils) ∈ cases | |
149 @test dissipation_transpose_upper_closure_stencils(w) == closure_stencils | |
150 end | |
151 end |