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

Commit 40afc18

Browse files
ajozefiakChrisRackauckas
authored andcommitted
solely irregular, winding, or non-constant coefficient case handling
1 parent ec6129e commit 40afc18

File tree

2 files changed

+75
-20
lines changed

2 files changed

+75
-20
lines changed

src/derivative_operators/derivative_operator_functions.jl

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -594,35 +594,26 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,3}, A::AbstractDiffEqComposi
594594

595595
# Handle first case non-additively
596596
N = diff_axis(A.ops[1])
597+
597598
if N == 1
598-
if operating_dims[2] == 1
599-
mul!(x_temp,A.ops[1],view(M,1:x_temp_1+2,1:x_temp_2))
600-
else
601-
mul!(x_temp,A.ops[1],M)
602-
end
599+
mul!(x_temp, A.ops[1], view(M,1:x_temp_1+2,1:x_temp_2,1:x_temp_3))
600+
elseif N == 2
601+
mul!(x_temp, A.ops[1], view(M,1:x_temp_1,1:x_temp_2+2,1:x_temp_3))
603602
else
604-
if operating_dims[1] == 1
605-
mul!(x_temp,A.ops[1],view(M,1:x_temp_1,1:x_temp_2+2))
606-
else
607-
mul!(x_temp,A.ops[1],M)
608-
end
603+
mul!(x_temp, A.ops[1], view(M,1:x_temp_1,1:x_temp_2,1:x_temp_3+2))
609604
end
610605

611606
for L in A.ops[2:end]
612607
N = diff_axis(L)
608+
613609
if N == 1
614-
if operating_dims[2] == 1
615-
mul!(x_temp,L,view(M,1:x_temp_1+2,1:x_temp_2), overwrite = false)
616-
else
617-
mul!(x_temp,L,M, overwrite = false)
618-
end
610+
mul!(x_temp, L, view(M,1:x_temp_1+2,1:x_temp_2,1:x_temp_3), overwrite = false)
611+
elseif N == 2
612+
mul!(x_temp, L, view(M,1:x_temp_1,1:x_temp_2+2,1:x_temp_3), overwrite = false)
619613
else
620-
if operating_dims[1] == 1
621-
mul!(x_temp,L,view(M,1:x_temp_1,1:x_temp_2+2), overwrite = false)
622-
else
623-
mul!(x_temp,L,M, overwrite = false)
624-
end
614+
mul!(x_temp, L, view(M,1:x_temp_1,1:x_temp_2,1:x_temp_3+2), overwrite = false)
625615
end
616+
626617
end
627618
end
628619
end

test/2D_3D_fast_multiplication.jl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,3 +941,67 @@ end
941941
+ (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]
942942

943943
end
944+
945+
@testset "x, y, and z are both irregular grids" begin
946+
947+
N = 100
948+
dx = cumsum(rand(N+2))
949+
dy = cumsum(rand(N+2))
950+
dz = cumsum(rand(N+2))
951+
M = zeros(N+2,N+2,N+2)
952+
953+
for i in 1:N+2
954+
for j in 1:N+2
955+
for k in 1:N+2
956+
M[i,j,k] = cos(dx[i])+sin(dy[j]) + exp(dz[k])
957+
end
958+
end
959+
end
960+
961+
# Lx2 has 0 boundary points
962+
Lx2 = CenteredDifference{1}(2,2,dx,N)
963+
# Lx3 has 1 boundary point
964+
Lx3 = 1.45*CenteredDifference{1}(3,3,dx,N)
965+
# Lx4 has 2 boundary points
966+
Lx4 = CenteredDifference{1}(4,4,dx,N)
967+
968+
# Ly2 has 0 boundary points
969+
Ly2 = 8.14*CenteredDifference{2}(2,2,dy,N)
970+
# Ly3 has 1 boundary point
971+
Ly3 = CenteredDifference{2}(3,3,dy,N)
972+
# Ly4 has 2 boundary points
973+
Ly4 = 4.567*CenteredDifference{2}(4,4,dy,N)
974+
975+
# Lz2 has 0 boundary points
976+
Lz2 = CenteredDifference{3}(2,2,dz,N)
977+
# Lz3 has 1 boundary point
978+
Lz3 = CenteredDifference{3}(3,3,dz,N)
979+
# Lz4 has 2 boundary points
980+
Lz4 = CenteredDifference{3}(4,4,dz,N)
981+
982+
# Test composition of all first-dimension operators
983+
A = Lx2+Lx3+Lx4
984+
M_temp = zeros(N,N+2,N+2)
985+
mul!(M_temp, A, M)
986+
@test M_temp (Lx2*M + Lx3*M + Lx4*M)
987+
988+
# Test composition of all second-dimension operators
989+
A = Ly2+Ly3+Ly4
990+
M_temp = zeros(N+2,N,N+2)
991+
mul!(M_temp, A, M)
992+
@test M_temp (Ly2*M + Ly3*M + Ly4*M)
993+
994+
# Test composition of all second-dimension operators
995+
A = Lz2+Lz3+Lz4
996+
M_temp = zeros(N+2,N+2,N)
997+
mul!(M_temp, A, M)
998+
@test M_temp (Lz2*M + Lz3*M + Lz4*M)
999+
1000+
# Test composition of all operators
1001+
A = Lx2+Lx3+Lx4+Ly2+Ly3+Ly4+Lz2+Lz3+Lz4
1002+
M_temp = zeros(N,N,N)
1003+
mul!(M_temp, A, M)
1004+
@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]
1005+
+ (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]
1006+
1007+
end

0 commit comments

Comments
 (0)