Mercurial > repos > public > sbplib_julia
comparison test/testSbpOperators.jl @ 576:1d4417ced79f feature/boundary_ops
Put test sets around 1d and 2d tests
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 01 Dec 2020 16:48:34 +0100 |
parents | 5691606851d8 |
children | b24b910a9025 |
comparison
equal
deleted
inserted
replaced
575:5691606851d8 | 576:1d4417ced79f |
---|---|
177 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 177 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") |
178 g_1D = EquidistantGrid(11, 0.0, 1.0) | 178 g_1D = EquidistantGrid(11, 0.0, 1.0) |
179 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) | 179 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) |
180 | 180 |
181 @testset "Constructors" begin | 181 @testset "Constructors" begin |
182 # 1D | 182 @testset "1D" begin |
183 e_l = BoundaryRestriction{Float64,Lower,4}(op.eClosure,size(g_1D)[1]) | 183 e_l = BoundaryRestriction{Float64,Lower,4}(op.eClosure,size(g_1D)[1]) |
184 @test e_l == BoundaryRestriction(g_1D,op.eClosure,Lower()) | 184 @test e_l == BoundaryRestriction(g_1D,op.eClosure,Lower()) |
185 @test e_l == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Lower}()) | 185 @test e_l == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Lower}()) |
186 @test e_l isa TensorMapping{T,0,1} where T | 186 @test e_l isa TensorMapping{T,0,1} where T |
187 | 187 |
188 e_r = BoundaryRestriction{Float64,Upper,4}(op.eClosure,size(g_1D)[1]) | 188 e_r = BoundaryRestriction{Float64,Upper,4}(op.eClosure,size(g_1D)[1]) |
189 @test e_r == BoundaryRestriction(g_1D,op.eClosure,Upper()) | 189 @test e_r == BoundaryRestriction(g_1D,op.eClosure,Upper()) |
190 @test e_r == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Upper}()) | 190 @test e_r == boundary_restriction(g_1D,op.eClosure,CartesianBoundary{1,Upper}()) |
191 @test e_r isa TensorMapping{T,0,1} where T | 191 @test e_r isa TensorMapping{T,0,1} where T |
192 | 192 end |
193 # 2D | 193 |
194 e_w = boundary_restriction(g_2D,op.eClosure,CartesianBoundary{1,Upper}()) | 194 @testset "2D" begin |
195 @test e_w isa InflatedTensorMapping | 195 e_w = boundary_restriction(g_2D,op.eClosure,CartesianBoundary{1,Upper}()) |
196 @test e_w isa TensorMapping{T,1,2} where T | 196 @test e_w isa InflatedTensorMapping |
197 @test e_w isa TensorMapping{T,1,2} where T | |
198 end | |
197 end | 199 end |
198 | 200 |
199 e_l = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Lower}()) | 201 e_l = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Lower}()) |
200 e_r = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Upper}()) | 202 e_r = boundary_restriction(g_1D, op.eClosure, CartesianBoundary{1,Upper}()) |
201 | 203 |
203 e_e = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Upper}()) | 205 e_e = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{1,Upper}()) |
204 e_s = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Lower}()) | 206 e_s = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Lower}()) |
205 e_n = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Upper}()) | 207 e_n = boundary_restriction(g_2D, op.eClosure, CartesianBoundary{2,Upper}()) |
206 | 208 |
207 @testset "Sizes" begin | 209 @testset "Sizes" begin |
208 # 1D | 210 @testset "1D" begin |
209 @test domain_size(e_l) == (11,) | 211 @test domain_size(e_l) == (11,) |
210 @test domain_size(e_r) == (11,) | 212 @test domain_size(e_r) == (11,) |
211 | 213 |
212 @test range_size(e_l) == () | 214 @test range_size(e_l) == () |
213 @test range_size(e_r) == () | 215 @test range_size(e_r) == () |
214 | 216 end |
215 # 2D | 217 |
216 @test domain_size(e_w) == (11,15) | 218 @testset "2D" begin |
217 @test domain_size(e_e) == (11,15) | 219 @test domain_size(e_w) == (11,15) |
218 @test domain_size(e_s) == (11,15) | 220 @test domain_size(e_e) == (11,15) |
219 @test domain_size(e_n) == (11,15) | 221 @test domain_size(e_s) == (11,15) |
220 | 222 @test domain_size(e_n) == (11,15) |
221 @test range_size(e_w) == (15,) | 223 |
222 @test range_size(e_e) == (15,) | 224 @test range_size(e_w) == (15,) |
223 @test range_size(e_s) == (11,) | 225 @test range_size(e_e) == (15,) |
224 @test range_size(e_n) == (11,) | 226 @test range_size(e_s) == (11,) |
227 @test range_size(e_n) == (11,) | |
228 end | |
225 end | 229 end |
226 | 230 |
227 | 231 |
228 @testset "Application" begin | 232 @testset "Application" begin |
229 # 1D | 233 @testset "1D" begin |
230 v = evalOn(g_1D,x->1+x^2) | 234 v = evalOn(g_1D,x->1+x^2) |
231 u = fill(3.124) | 235 u = fill(3.124) |
232 @test (e_l*v)[] == v[1] | 236 @test (e_l*v)[] == v[1] |
233 @test (e_r*v)[] == v[end] | 237 @test (e_r*v)[] == v[end] |
234 @test (e_r*v)[1] == v[end] | 238 @test (e_r*v)[1] == v[end] |
235 @test e_l'*u == [u[]; zeros(10)] | 239 @test e_l'*u == [u[]; zeros(10)] |
236 @test e_r'*u == [zeros(10); u[]] | 240 @test e_r'*u == [zeros(10); u[]] |
237 | 241 end |
238 # 2D | 242 |
239 v = rand(11, 15) | 243 @testset "2D" begin |
240 | 244 v = rand(11, 15) |
241 @test e_w*v == v[1,:] | 245 u = fill(3.124) |
242 @test e_e*v == v[end,:] | 246 |
243 @test e_s*v == v[:,1] | 247 @test e_w*v == v[1,:] |
244 @test e_n*v == v[:,end] | 248 @test e_e*v == v[end,:] |
245 | 249 @test e_s*v == v[:,1] |
246 | 250 @test e_n*v == v[:,end] |
247 g_x = rand(11) | 251 |
248 g_y = rand(15) | 252 |
249 | 253 g_x = rand(11) |
250 G_w = zeros(Float64, (11,15)) | 254 g_y = rand(15) |
251 G_w[1,:] = g_y | 255 |
252 | 256 G_w = zeros(Float64, (11,15)) |
253 G_e = zeros(Float64, (11,15)) | 257 G_w[1,:] = g_y |
254 G_e[end,:] = g_y | 258 |
255 | 259 G_e = zeros(Float64, (11,15)) |
256 G_s = zeros(Float64, (11,15)) | 260 G_e[end,:] = g_y |
257 G_s[:,1] = g_x | 261 |
258 | 262 G_s = zeros(Float64, (11,15)) |
259 G_n = zeros(Float64, (11,15)) | 263 G_s[:,1] = g_x |
260 G_n[:,end] = g_x | 264 |
261 | 265 G_n = zeros(Float64, (11,15)) |
262 @test e_w'*g_y == G_w | 266 G_n[:,end] = g_x |
263 @test e_e'*g_y == G_e | 267 |
264 @test e_s'*g_x == G_s | 268 @test e_w'*g_y == G_w |
265 @test e_n'*g_x == G_n | 269 @test e_e'*g_y == G_e |
270 @test e_s'*g_x == G_s | |
271 @test e_n'*g_x == G_n | |
272 end | |
266 | 273 |
267 @testset "Regions" begin | 274 @testset "Regions" begin |
275 u = fill(3.124) | |
268 @test (e_l'*u)[Index(1,Lower)] == 3.124 | 276 @test (e_l'*u)[Index(1,Lower)] == 3.124 |
269 @test (e_l'*u)[Index(2,Lower)] == 0 | 277 @test (e_l'*u)[Index(2,Lower)] == 0 |
270 @test (e_l'*u)[Index(6,Interior)] == 0 | 278 @test (e_l'*u)[Index(6,Interior)] == 0 |
271 @test (e_l'*u)[Index(10,Upper)] == 0 | 279 @test (e_l'*u)[Index(10,Upper)] == 0 |
272 @test (e_l'*u)[Index(11,Upper)] == 0 | 280 @test (e_l'*u)[Index(11,Upper)] == 0 |