|
14 | 14 | function slice_rmul(A::AbstractDiffEqLinearOperator, u::AbstractArray{T,N}, dim::Int) where {T,N} |
15 | 15 | @assert N != 1 |
16 | 16 | u_temp = similar(u) |
17 | | - pre = axes(u)[1:dim-1] |
18 | | - post = axes(u)[dim+1:end] |
19 | | - _slice_rmul!(u_temp, A, u, dim, pre, post) |
| 17 | + _slice_rmul!(u_temp, A, u, dim, axes(u)[1:dim-1], axes(u)[dim+1:end]) |
20 | 18 | return u_temp |
21 | 19 | end |
22 | 20 |
|
23 | | -@noinline function _slice_rmul!(lower::Array{T, M}, upper::Array{T, M}, A::AbstractArray{B,M}, u::AbstractArray{T,N}, dim::Int, pre, post) where {T,B,N,M} |
| 21 | +@noinline function _slice_rmul!(lower::AbstractArray, upper::AbstractArray, A::AbstractArray{B,M}, u::AbstractArray{T,N}, dim::Int, pre, post) where {T,B,N,M} |
24 | 22 | for J in CartesianIndices(post) |
25 | 23 | for I in CartesianIndices(pre) |
26 | 24 | tmp = A[I,J]*u[I, :, J] |
|
32 | 30 |
|
33 | 31 | function slice_rmul(A::AbstractArray{B,M}, u::AbstractArray{T,N}, dim::Int) where {T, B, N,M} |
34 | 32 | @assert N != 1 |
| 33 | + @assert M == N-1 |
35 | 34 | lower = zeros(T,perpsize(u,dim)) |
36 | 35 | upper = zeros(T,perpsize(u,dim)) |
37 | | - pre = axes(u)[1:dim-1] |
38 | | - post = axes(u)[dim+1:end] |
39 | | - _slice_rmul!(lower, upper, A, u, dim, pre, post) |
| 36 | + _slice_rmul!(lower, upper, A, u, dim, axes(u)[1:dim-1], axes(u)[dim+1:end]) |
40 | 37 | return (lower, upper) |
41 | 38 | end |
42 | 39 |
|
@@ -100,73 +97,6 @@ GeneralBC(αl::AbstractVector{T}, αr::AbstractVector{T}, dxyz, order, s) where |
100 | 97 |
|
101 | 98 | perpsize(A::AbstractArray{T,N}, dim::Integer) where {T,N} = size(A)[setdiff(1:N, dim)] #the size of A perpendicular to dim |
102 | 99 |
|
103 | | -# Constructors for Bridge BC to make it easier to join domains together. See docs on BrigeBC in BC_operators.jl for info on usage |
104 | | -function BridgeBC(bc1::MultiDimDirectionalBC, u1::AbstractArray{T,N}, dim1::Int, hilo1::String, dim2::Int, hilo2::String, u2::AbstractArray{T,N}, bc2::MultiDimDirectionalBC) where {T, N} |
105 | | - @assert 1 ≤ dim1 ≤ N "dim1 must be 1≤dim1≤N, got dim1 = $dim1" |
106 | | - @assert 1 ≤ dim1 ≤ N "dim2 must be 1≤dim1≤N, got dim1 = $dim1" |
107 | | - s1 = perpsize(u1, dim1) # |
108 | | - s2 = perpsize(u2, dim2) |
109 | | - @assert s1 == s2 "Arrays must be same size along boundary to be joined, got boundary sizes u1 = $s1, u2 = $s2" |
110 | | - if hilo1 == "low" |
111 | | - view1 = selectdim(u1, dim1, 1) |
112 | | - if hilo2 == "low" |
113 | | - BC1 = Array{MixedBC{T, BridgeBC{T, N, eltype(s1)}, getboundarytype(bc1)}}(undef, s1...) |
114 | | - BC2 = Array{MixedBC{T, BridgeBC{T, N, eltype(s2)}, getboundarytype(bc2)}}(undef, s2...) |
115 | | - view2 = selectdim(u2, dim2, 1) |
116 | | - R = CartesianIndices(BC1) |
117 | | - for I in R |
118 | | - BC1[I] = MixedBC(BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view2, I), zeros(T, 1), view(view2, I)), bc1.BCs[I]) |
119 | | - BC2[I] = MixedBC(BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view1, I), zeros(T, 1), view(view1, I)), bc2.BCs[I]) |
120 | | - end |
121 | | - elseif hilo2 == "high" |
122 | | - BC1 = Array{MixedBC{T, BridgeBC{T, N, eltype(s1)}, getboundarytype(bc1)}}(undef, s1...) |
123 | | - BC2 = Array{MixedBC{T, getboundarytype(bc2), BridgeBC{T, N, eltype(s2)}}}(undef, s2...) |
124 | | - view2 = selectdim(u2, dim2, size(u2)[dim2]) |
125 | | - R = CartesianIndices(BC1) |
126 | | - for I in R |
127 | | - BC1[I] = MixedBC(BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view2, I), zeros(T, 1), view(view2, I)), bc1.BCs[I]) |
128 | | - BC2[I] = MixedBC(bc2.BCs[I], BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view1, I), zeros(T, 1), view(view1, I))) |
129 | | - end |
130 | | - else |
131 | | - throw(ArgumentError("hilo2 not recognized, please use \"high\" to connect u1 to u2 along the upper index of dim2 of u2 or \"low\" to connect along the lower index end")) |
132 | | - end |
133 | | - elseif hilo1 == "high" |
134 | | - view1 = selectdim(u1, dim1, size(u1)[dim1]) |
135 | | - if hilo2 == "low" |
136 | | - BC1 = Array{MixedBC{T, getboundarytype(bc1), BridgeBC{T, N, eltype(s1)}}}(undef, s1...) |
137 | | - BC2 = Array{MixedBC{T, BridgeBC{T, N, eltype(s2)}, getboundarytype(bc2)}}(undef, s2...) |
138 | | - view2 = selectdim(u2, dim2, 1) |
139 | | - R = CartesianIndices(BC1) |
140 | | - for I in R |
141 | | - BC1[I] = MixedBC(bc1.BCs[I], BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view2, I), zeros(T, 1), view(view2, I))) |
142 | | - BC2[I] = MixedBC(BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view1, I), zeros(T, 1), view(view1, I)), bc2.BCs[I]) |
143 | | - end |
144 | | - elseif hilo2 == "high" |
145 | | - BC1 = Array{MixedBC{T, getboundarytype(bc1), BridgeBC{T, N, eltype(s1)}}}(undef, s1...) |
146 | | - BC2 = Array{MixedBC{T, getboundarytype(bc2), BridgeBC{T, N, eltype(s2)}}}(undef, s2...) |
147 | | - view2 = selectdim(u2, dim2, size(u2)[dim2]) |
148 | | - R = CartesianIndices(BC1) |
149 | | - for I in R |
150 | | - BC1[I] = MixedBC(bc1.BCs[I], BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view2, I), zeros(T, 1), view(view2, I))) |
151 | | - BC2[I] = MixedBC(bc2.BCs[I], BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view1, I), zeros(T, 1), view(view1, I))) |
152 | | - end |
153 | | - else |
154 | | - throw(ArgumentError("hilo2 not recognized, please use \"high\" to connect u1 to u2 along the upper index of dim2 of u2 or \"low\" to connect along the lower index end")) |
155 | | - end |
156 | | - else |
157 | | - throw("hilo1 not recognized, please use \"high\" to connect u1 to u2 along the upper index of dim1 of u1 or \"low\" to connect along the lower index end") |
158 | | - end |
159 | | - return (MultiDimBC(BC1, dim1), MultiDimBC(BC2, dim2)) |
160 | | -end |
161 | | - |
162 | | -""" |
163 | | - Q1, Q2 = BridgeBC(bc1::MultiDimDirectionalBC, u1::AbstractArray, dim1::Int, dim2::Int, u2::AbstractArray, bc2::MultiDimDirectionalBC) |
164 | | -Create BC operators that connect `u1` to `u2`, at the high index end of `dim1` for `u1`, and the low index end of `dim2` for `u2`. |
165 | | -`bc1` and `bc2` are then the boundary conditions at the unconnected ends of `u1` and `u2` respectively. |
166 | | -""" |
167 | | -BridgeBC(bc1::MultiDimDirectionalBC, u1::AbstractArray, dim1::Int, dim2::Int, u2::AbstractArray, bc2::MultiDimDirectionalBC) = BridgeBC(u1, dim1, "high", bc1, u2, dim2, "low", bc2) |
168 | | - |
169 | | - |
170 | 100 | """ |
171 | 101 | Q = compose(BCs...) |
172 | 102 |
|
|
0 commit comments