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

Commit ec6129e

Browse files
ajozefiakChrisRackauckas
authored andcommitted
differing bpc support
1 parent a37685a commit ec6129e

File tree

2 files changed

+105
-7
lines changed

2 files changed

+105
-7
lines changed

src/derivative_operators/derivative_operator_functions.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,3}, A::AbstractDiffEqComposi
472472
convolve_BC_right!(view(x_temp,:,i,j), view(M,:,i+offset_y,j+offset_z), opsA[Lidx], overwrite = false)
473473
if i <= pad[2] || i > size(x_temp)[2]-pad[2] || j <= pad[3] || j > size(x_temp)[3]-pad[3]
474474
convolve_interior!(view(x_temp,:,i,j), view(M,:,i+offset_y,j+offset_z), opsA[Lidx], overwrite = false)
475-
elseif pad[1] - opsA[Lidx].boundary_point_count > 0 # TODO 475-477
476-
convolve_interior_add_range!(view(x_temp,:,i), view(M,:,i+offset_x), opsA[Lidx], pad[1] - opsA[Lidx].boundary_point_count)
475+
elseif pad[1] - opsA[Lidx].boundary_point_count > 0
476+
convolve_interior_add_range!(view(x_temp,:,i,j), view(M,:,i+offset_y,j+offset_z), opsA[Lidx], pad[1] - opsA[Lidx].boundary_point_count)
477477
end
478478
end
479479
end
@@ -506,8 +506,8 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,3}, A::AbstractDiffEqComposi
506506
convolve_BC_right!(view(x_temp,i,:,j), view(M,i+offset_x,:,j+offset_z), opsA[Lidx], overwrite = false)
507507
if i <= pad[1] || i > size(x_temp)[1]-pad[1] || j <= pad[3] || j > size(x_temp)[3]-pad[3]
508508
convolve_interior!(view(x_temp,i,:,j), view(M,i+offset_x,:,j+offset_z), opsA[Lidx], overwrite = false)
509-
elseif pad[2] - opsA[Lidx].boundary_point_count > 0 #TODO 509-511
510-
convolve_interior_add_range!(view(x_temp,i,:), view(M,i+offset_y,:), opsA[Lidx], pad[2] - opsA[Lidx].boundary_point_count)
509+
elseif pad[2] - opsA[Lidx].boundary_point_count > 0
510+
convolve_interior_add_range!(view(x_temp,i,:,j), view(M,i+offset_x,:,j+offset_z), opsA[Lidx], pad[2] - opsA[Lidx].boundary_point_count)
511511
end
512512
end
513513
end
@@ -523,7 +523,7 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,3}, A::AbstractDiffEqComposi
523523
convolve_BC_left!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[ops_3_max_bpc_idx...])
524524
convolve_BC_right!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[ops_3_max_bpc_idx...])
525525
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...])
526+
convolve_interior!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[ops_3_max_bpc_idx...])
527527
end
528528

529529
else
@@ -540,8 +540,8 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,3}, A::AbstractDiffEqComposi
540540
convolve_BC_right!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[Lidx], overwrite = false)
541541
if i <= pad[1] || i > size(x_temp)[1]-pad[1] || j <= pad[2] || j > size(x_temp)[2]-pad[2]
542542
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)
543+
elseif pad[3] - opsA[Lidx].boundary_point_count > 0
544+
convolve_interior_add_range!(view(x_temp,i,j,:), view(M,i+offset_x,j+offset_y,:), opsA[Lidx], pad[3] - opsA[Lidx].boundary_point_count)
545545
end
546546
end
547547
end

test/2D_3D_fast_multiplication.jl

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,3 +843,101 @@ end
843843
@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] + (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])
844844

845845
end
846+
847+
@testset "3D Multiplication with differing bpc and dx = dy = dz = 1.0" begin
848+
849+
N = 100
850+
M = zeros(N+2,N+2,N+2)
851+
for i in 1:N+2
852+
for j in 1:N+2
853+
for k in 1:N+2
854+
M[i,j,k] = cos(0.1i)+sin(0.1j) + exp(0.01k)
855+
end
856+
end
857+
end
858+
859+
# Lx2 has 0 boundary points
860+
Lx2 = CenteredDifference{1}(2,2,1.0,N)
861+
# Lx3 has 1 boundary point
862+
Lx3 = CenteredDifference{1}(3,3,1.0,N)
863+
# Lx4 has 2 boundary points
864+
Lx4 = CenteredDifference{1}(4,4,1.0,N)
865+
866+
# Test a single axis, multiple operators: (Lxx+Lxxxx)*M, dx = 1.0
867+
A = Lx2+Lx4
868+
M_temp = zeros(N,N+2,N+2)
869+
mul!(M_temp, A, M)
870+
@test M_temp ((Lx2*M) + (Lx4*M))
871+
872+
# Test a single axis, multiple operators: (Lxx++Lxxx+Lxxxx)*M, dx = 1.0
873+
A += Lx3
874+
mul!(M_temp, A, M)
875+
@test M_temp ((Lx2*M) + (Lx3*M) + (Lx4*M))
876+
877+
878+
# Ly2 has 0 boundary points
879+
Ly2 = CenteredDifference{2}(2,2,1.0,N)
880+
# Ly3 has 1 boundary point
881+
Ly3 = CenteredDifference{2}(3,3,1.0,N)
882+
# Ly4 has 2 boundary points
883+
Ly4 = CenteredDifference{2}(4,4,1.0,N)
884+
885+
# Test a single axis, multiple operators: (Lyy+Lyyyy)*M, dx = 1.0
886+
A = Ly2+Ly4
887+
M_temp = zeros(N+2,N,N+2)
888+
mul!(M_temp, A, M)
889+
@test M_temp ((Ly2*M) + (Ly4*M))
890+
891+
# Test a single axis, multiple operators: (Lyy++Lyyy+Lyyyy)*M, dx = 1.0
892+
A += Ly3
893+
mul!(M_temp, A, M)
894+
@test M_temp ((Ly2*M) + (Ly3*M) + (Ly4*M))
895+
896+
897+
# Lz2 has 0 boundary points
898+
Lz2 = CenteredDifference{3}(2,2,1.0,N)
899+
# Lz3 has 1 boundary point
900+
Lz3 = CenteredDifference{3}(3,3,1.0,N)
901+
# Lz4 has 2 boundary points
902+
Lz4 = CenteredDifference{3}(4,4,1.0,N)
903+
904+
# Test a single axis, multiple operators: (Lzy+Lzzzz)*M, dz = 1.0
905+
A = Lz2+Lz4
906+
M_temp = zeros(N+2,N+2,N)
907+
mul!(M_temp, A, M)
908+
@test M_temp ((Lz2*M) + (Lz4*M))
909+
910+
# Test a single axis, multiple operators: (Lzz++Lzzz+Lzzzz)*M, dz = 1.0
911+
A += Lz3
912+
mul!(M_temp, A, M)
913+
@test M_temp ((Lz2*M) + (Lz3*M) + (Lz4*M))
914+
915+
# Test multiple operators on two axis: (Lxx + Lyy + Lxxx + Lyyy + Lxxxx + Lyyyy)*M, no coefficient
916+
A = Lx2 + Ly2 + Lx3 + Ly3 + Lx4 + Ly4
917+
M_temp = zeros(N,N,N+2)
918+
mul!(M_temp, A, M)
919+
920+
@test M_temp ((Lx2*M)[1:N,2:N+1,:]+(Ly2*M)[2:N+1,1:N,:]+(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,:])
921+
922+
# Test multiple operators on two axis: (Lxx + Lzz + Lxxx + Lzzz + Lxxxx + Lzzzz)*M, no coefficient
923+
A = Lx2 + Lz2 + Lx3 + Lz3 + Lx4 + Lz4
924+
M_temp = zeros(N,N+2,N)
925+
mul!(M_temp, A, M)
926+
927+
@test M_temp ((Lx2*M)[1:N,:,2:N+1]+(Lz2*M)[2:N+1,:,1:N]+(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])
928+
929+
# Test multiple operators on two axis: (Lxx + Lzz + Lxxx + Lzzz + Lxxxx + Lzzzz)*M, no coefficient
930+
A = Ly2 + Lz2 + Ly3 + Lz3 + Ly4 + Lz4
931+
M_temp = zeros(N+2,N,N)
932+
mul!(M_temp, A, M)
933+
934+
@test M_temp ((Ly2*M)[:,1:N,2:N+1]+(Lz2*M)[:,2:N+1,1:N]+(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])
935+
936+
# Test operators on all three axis (Lxx + Lyy + Lzz + Lxxx + Lyyy + Lzzz + Lxxxx + Lyyyy + Lzzzz)*M, no coefficient
937+
A = Lx2 + Ly2 + Lz2 + Lx3 + Ly3 + Lz3 + Lx4 + Ly4 + Lz4
938+
M_temp = zeros(N,N,N)
939+
mul!(M_temp, A, M)
940+
@test M_temp ((Lx2*M)[1:N,2:N+1,2:N+1]+(Ly2*M)[2:N+1,1:N,2:N+1]+(Lz2*M)[2:N+1,2:N+1,1:N]+(Lx3*M)[1:N,2:N+1,2:N+1] +(Ly3*M)[2:N+1,1:N,2:N+1]
941+
+ (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]
942+
943+
end

0 commit comments

Comments
 (0)