Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 7b390f8

Browse files
committed
add tests for regular-irrgular cases
1 parent f02c2f5 commit 7b390f8

File tree

1 file changed

+94
-2
lines changed

1 file changed

+94
-2
lines changed

test/2D_3D_fast_multiplication.jl

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,6 @@ end
477477
# Ly4 has 2 boundary points
478478
Ly4 = 4.567*CenteredDifference{2}(4,4,dy,N)
479479

480-
481-
482480
# Test composition of all first-dimension operators
483481
A = Lx2+Lx3+Lx4
484482
M_temp = zeros(N,N+2)
@@ -498,3 +496,97 @@ end
498496
@test M_temp ((Lx2*M)[1:N,2:N+1]+(Lx3*M)[1:N,2:N+1]+(Lx4*M)[1:N,2:N+1]+(Ly2*M)[2:N+1,1:N]+(Ly3*M)[2:N+1,1:N]+(Ly4*M)[2:N+1,1:N])
499497

500498
end
499+
500+
@testset "regular x grid (dx=0.25) and irregular y grid" begin
501+
502+
N = 100
503+
dx = 0.25
504+
dy = cumsum(rand(N+2))
505+
M = zeros(N+2,N+2)
506+
507+
for i in 1:N+2
508+
for j in 1:N+2
509+
M[i,j] = cos(dx*i)+sin(dy[j])
510+
end
511+
end
512+
513+
# Lx2 has 0 boundary points
514+
Lx2 = CenteredDifference{1}(2,2,dx,N)
515+
# Lx3 has 1 boundary point
516+
Lx3 = 1.45*CenteredDifference{1}(3,3,dx,N)
517+
# Lx4 has 2 boundary points
518+
Lx4 = CenteredDifference{1}(4,4,dx,N)
519+
520+
# Ly2 has 0 boundary points
521+
Ly2 = 8.14*CenteredDifference{2}(2,2,dy,N)
522+
# Ly3 has 1 boundary point
523+
Ly3 = CenteredDifference{2}(3,3,dy,N)
524+
# Ly4 has 2 boundary points
525+
Ly4 = 4.567*CenteredDifference{2}(4,4,dy,N)
526+
527+
# Test that composition of all x-operators works
528+
A = Lx2 + Lx3 + Lx4
529+
M_temp = zeros(N,N+2)
530+
mul!(M_temp, A, M)
531+
@test M_temp (Lx2*M + Lx3*M + Lx4*M)
532+
533+
# Test that composition of all y-operators works
534+
A = Ly2 + Ly3 + Ly4
535+
M_temp = zeros(N+2,N)
536+
mul!(M_temp, A, M)
537+
@test M_temp (Ly2*M + Ly3*M + Ly4*M)
538+
539+
# Test that composition of both x and y operators works
540+
A = Lx2 + Ly2 + Lx3 + Ly3 + Ly4 + Lx4
541+
M_temp = zeros(N,N)
542+
@test_broken mul!(M_temp, A, M)
543+
@test_broken M_temp ((Lx2*M)[1:N,2:N+1]+(Lx3*M)[1:N,2:N+1]+(Lx4*M)[1:N,2:N+1]+(Ly2*M)[2:N+1,1:N]+(Ly3*M)[2:N+1,1:N]+(Ly4*M)[2:N+1,1:N])
544+
545+
end
546+
547+
@testset "irregular x grid and regular y grid (dy = 0.25)" begin
548+
549+
N = 100
550+
dy = 0.25
551+
dx = cumsum(rand(N+2))
552+
M = zeros(N+2,N+2)
553+
554+
for i in 1:N+2
555+
for j in 1:N+2
556+
M[i,j] = cos(dx[i])+sin(dy*j)
557+
end
558+
end
559+
560+
# Lx2 has 0 boundary points
561+
Lx2 = CenteredDifference{1}(2,2,dx,N)
562+
# Lx3 has 1 boundary point
563+
Lx3 = 1.45*CenteredDifference{1}(3,3,dx,N)
564+
# Lx4 has 2 boundary points
565+
Lx4 = CenteredDifference{1}(4,4,dx,N)
566+
567+
# Ly2 has 0 boundary points
568+
Ly2 = 8.14*CenteredDifference{2}(2,2,dy,N)
569+
# Ly3 has 1 boundary point
570+
Ly3 = CenteredDifference{2}(3,3,dy,N)
571+
# Ly4 has 2 boundary points
572+
Ly4 = 4.567*CenteredDifference{2}(4,4,dy,N)
573+
574+
# Test that composition of all x-operators works
575+
A = Lx2 + Lx3 + Lx4
576+
M_temp = zeros(N,N+2)
577+
mul!(M_temp, A, M)
578+
@test M_temp (Lx2*M + Lx3*M + Lx4*M)
579+
580+
# Test that composition of all y-operators works
581+
A = Ly2 + Ly3 + Ly4
582+
M_temp = zeros(N+2,N)
583+
mul!(M_temp, A, M)
584+
@test M_temp (Ly2*M + Ly3*M + Ly4*M)
585+
586+
# Test that composition of both x and y operators works
587+
A = Lx2 + Ly2 + Lx3 + Ly3 + Ly4 + Lx4
588+
M_temp = zeros(N,N)
589+
@test_broken mul!(M_temp, A, M)
590+
@test_broken M_temp ((Lx2*M)[1:N,2:N+1]+(Lx3*M)[1:N,2:N+1]+(Lx4*M)[1:N,2:N+1]+(Ly2*M)[2:N+1,1:N]+(Ly3*M)[2:N+1,1:N]+(Ly4*M)[2:N+1,1:N])
591+
592+
end

0 commit comments

Comments
 (0)