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

Commit 58c71ab

Browse files
ajozefiakChrisRackauckas
authored andcommitted
tests for same bpc fleshed out and all are passing
1 parent 2c2ec5b commit 58c71ab

File tree

2 files changed

+100
-7
lines changed

2 files changed

+100
-7
lines changed

src/derivative_operators/derivative_operator_functions.jl

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,3}, A::AbstractDiffEqComposi
488488
if length(ops_1) == 0
489489
convolve_BC_left!(view(x_temp,i,:,j), view(M,i+offset_x,:,j+offset_z), opsA[ops_2_max_bpc_idx...])
490490
convolve_BC_right!(view(x_temp,i,:,j), view(M,i+offset_x,:,j+offset_z), opsA[ops_2_max_bpc_idx...])
491-
if i <= pad[1] || i > size(x_temp)[1]-pad[1] #TODO 491-493
492-
convolve_interior!(view(x_temp,i,:), view(M,i+offset_y,:), opsA[ops_2_max_bpc_idx...])
491+
if i <= pad[1] || i > size(x_temp)[1]-pad[1] || j <= pad[3] || j > size(x_temp)[3]-pad[3]
492+
convolve_interior!(view(x_temp,i,:,j), view(M,i+offset_x,:,j+offset_z), opsA[ops_2_max_bpc_idx...])
493493
end
494494

495495
else
@@ -514,6 +514,40 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,3}, A::AbstractDiffEqComposi
514514
end
515515
end
516516
end
517+
# convolve boundaries and unaccounted for interior in axis 3
518+
if length(ops_3) > 0
519+
for i in 1:size(x_temp)[1]
520+
for j in 1:size(x_temp)[2]
521+
# in the case of no axis 1 and 2 operators, we need to overwrite x_temp
522+
if length(ops_1) == 0 && length(ops_2) == 0
523+
convolve_BC_left!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[ops_3_max_bpc_idx...])
524+
convolve_BC_right!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[ops_3_max_bpc_idx...])
525+
if i <= pad[1] || i > size(x_temp)[1]-pad[1] #TODO 525-527
526+
convolve_interior!(view(x_temp,i,:), view(M,i+offset_y,:), opsA[ops_3_max_bpc_idx...])
527+
end
528+
529+
else
530+
convolve_BC_left!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[ops_3_max_bpc_idx...], overwrite = false)
531+
convolve_BC_right!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[ops_3_max_bpc_idx...], overwrite = false)
532+
if i <= pad[1] || i > size(x_temp)[1]-pad[1] || j <= pad[2] || j > size(x_temp)[2]-pad[2]
533+
convolve_interior!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[ops_3_max_bpc_idx...], overwrite = false)
534+
end
535+
536+
end
537+
for Lidx in ops_3
538+
if Lidx != ops_3_max_bpc_idx[1]
539+
convolve_BC_left!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[Lidx], overwrite = false)
540+
convolve_BC_right!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[Lidx], overwrite = false)
541+
if i <= pad[1] || i > size(x_temp)[1]-pad[1] || j <= pad[2] || j > size(x_temp)[2]-pad[2]
542+
convolve_interior!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[Lidx], overwrite = false)
543+
elseif pad[3] - opsA[Lidx].boundary_point_count > 0 #TODO 543-545
544+
convolve_interior_add_range!(view(x_temp,i,:), view(M,i+offset_y,:), opsA[Lidx], pad[2] - opsA[Lidx].boundary_point_count)
545+
end
546+
end
547+
end
548+
end
549+
end
550+
end
517551
end
518552

519553
# Here we compute mul! (additively) for every operator in opsB

test/2D_3D_fast_multiplication.jl

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -754,12 +754,11 @@ end
754754
A = Lz3 + Lz4
755755

756756
M_temp = zeros(N+2,N+2,N)
757-
@test_broken mul!(M_temp, A, M)
757+
mul!(M_temp, A, M)
758758

759-
@test_broken M_temp ((Lz3*M)+(Lz4*M))
759+
@test M_temp ((Lz3*M)+(Lz4*M))
760760

761761
# Test (Lxxxx + Lyyyy)*M, dx = 1.0, no coefficient, two boundary points on each axis
762-
763762
M_temp = zeros(N,N,N+2)
764763
A = Lx4 + Ly4
765764
mul!(M_temp, A, M)
@@ -780,7 +779,67 @@ end
780779

781780
@test M_temp ((Lx3*M)[1:N,2:N+1,:] +(Ly3*M)[2:N+1,1:N,:] + (Lx4*M)[1:N,2:N+1,:] +(Ly4*M)[2:N+1,1:N,:])
782781

783-
# TODO implement/test all combinations of x-z and y-z compositions.
784-
# TODO implement/test combinations of x-y-z compositions
782+
# Test (Lxxxx + Lzzzz)*M, dx = 1.0, no coefficient, two boundary points on each axis
783+
M_temp = zeros(N,N+2,N)
784+
A = Lx4 + Lz4
785+
mul!(M_temp, A, M)
786+
787+
@test M_temp ((Lx4*M)[1:N,:,2:N+1] +(Lz4*M)[2:N+1,:,1:N])
788+
789+
# Test (Lxxx + Lzzz)*M, no coefficient. These operators have non-symmetric interior stencils
790+
A = Lx3 + Lz3
791+
M_temp = zeros(N,N+2,N)
792+
mul!(M_temp, A, M)
793+
794+
@test M_temp ((Lx3*M)[1:N,:,2:N+1] +(Lz3*M)[2:N+1,:,1:N])
795+
796+
# Test multiple operators on both axis: (Lxxx + Lzzz + Lxxxx + Lzzzz)*M, no coefficient
797+
A = Lx3 + Lz3 + Lx4 + Lz4
798+
M_temp = zeros(N,N+2,N)
799+
mul!(M_temp, A, M)
800+
801+
@test M_temp ((Lx3*M)[1:N,:,2:N+1] +(Lz3*M)[2:N+1,:,1:N] + (Lx4*M)[1:N,:,2:N+1] +(Lz4*M)[2:N+1,:,1:N])
802+
803+
# Test (Lyyyy + Lzzzz)*M, dx = 1.0, no coefficient, two boundary points on each axis
804+
M_temp = zeros(N+2,N,N)
805+
A = Ly4 + Lz4
806+
mul!(M_temp, A, M)
807+
808+
@test M_temp ((Ly4*M)[:,1:N,2:N+1] +(Lz4*M)[:,2:N+1,1:N])
809+
810+
# Test (Lyyy + Lzzz)*M, no coefficient. These operators have non-symmetric interior stencils
811+
A = Ly3 + Lz3
812+
M_temp = zeros(N+2,N,N)
813+
mul!(M_temp, A, M)
814+
815+
@test M_temp ((Ly3*M)[:,1:N,2:N+1] +(Lz3*M)[:,2:N+1,1:N])
816+
817+
# Test multiple operators on both axis: (Lyyy + Lzzz + Lyyyy + Lzzzz)*M, no coefficient
818+
A = Ly3 + Lz3 + Ly4 + Lz4
819+
M_temp = zeros(N+2,N,N)
820+
mul!(M_temp, A, M)
821+
822+
@test M_temp ((Ly3*M)[:,1:N,2:N+1] +(Lz3*M)[:,2:N+1,1:N] + (Ly4*M)[:,1:N,2:N+1] +(Lz4*M)[:,2:N+1,1:N])
823+
824+
# Test a single operator on each axis: (Lx3 + Ly3 + Lz3)*M, no coefficient
825+
A = Lx3 + Ly3 + Lz3
826+
M_temp = zeros(N,N,N)
827+
mul!(M_temp, A, M)
828+
829+
@test M_temp ((Lx3*M)[1:N,2:N+1,2:N+1] + (Ly3*M)[2:N+1,1:N,2:N+1] +(Lz3*M)[2:N+1,2:N+1,1:N])
830+
831+
# Test a single operator on each axis: (Lx4 + Ly4 + Lz4)*M, no coefficient
832+
A = Lx4 + Ly4 + Lz4
833+
M_temp = zeros(N,N,N)
834+
mul!(M_temp, A, M)
835+
836+
@test M_temp ((Lx4*M)[1:N,2:N+1,2:N+1] + (Ly4*M)[2:N+1,1:N,2:N+1] +(Lz4*M)[2:N+1,2:N+1,1:N])
837+
838+
# Test multiple operators on each axis: (Lx3 + Ly3 + Lz3 + Lx4 + Ly4 + Lz4)*M, no coefficient
839+
A = Lx3 + Ly3 + Lz3 + Lx4 + Ly4 + Lz4
840+
M_temp = zeros(N,N,N)
841+
mul!(M_temp, A, M)
842+
843+
@test M_temp ((Lx3*M)[1:N,2:Ns+1,2:N+1] + (Ly3*M)[2:N+1,1:N,2:N+1] +(Lz3*M)[2:N+1,2:N+1,1:N] + (Lx4*M)[1:N,2:N+1,2:N+1] + (Ly4*M)[2:N+1,1:N,2:N+1] +(Lz4*M)[2:N+1,2:N+1,1:N])
785844

786845
end

0 commit comments

Comments
 (0)