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

Commit 45ebabf

Browse files
committed
spruced up the extra bridge BC constructors to work to N dimensions
1 parent ecb8393 commit 45ebabf

File tree

6 files changed

+109
-167
lines changed

6 files changed

+109
-167
lines changed

src/boundary_padded_arrays.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ Composes BoundaryPaddedArrays that extend the same u for each different dimensio
5454
5555
Ax Ay and Az can be passed in any order, as long as there is exactly one BoundaryPaddedArray that extends each dimension.
5656
"""
57-
function compose(padded_arrays::BoundaryPaddedArray ...)
57+
function compose(padded_arrays::BoundaryPaddedArray...)
5858
N = ndims(padded_arrays[1])
5959
Ds = getaxis.(padded_arrays)
60-
(length(padded_arrays) == N) || throw("The padded_arrays must cover every dimension - make sure that the number of padded_arrays is equal to ndims(u).")
60+
(length(padded_arrays) == N) || throw(ArgumentError("The padded_arrays must cover every dimension - make sure that the number of padded_arrays is equal to ndims(u)."))
6161
for D in Ds
62-
length(setdiff(Ds, D)) == (N-1) || throw("There are multiple Arrays that extend along $D - make sure every dimension has a unique extension")
62+
length(setdiff(Ds, D)) == (N-1) || throw(ArgumentError("There are multiple Arrays that extend along dimension $D - make sure every dimension has a unique extension"))
6363
end
64-
reduce((|), fill(padded_arrays[1].u, (length(padded_arrays),)) .== getfield.(padded_arrays, :u)) || throw("The padded_arrays do not all extend the same u!")
64+
reduce((|), fill(padded_arrays[1].u, (length(padded_arrays),)) .== getfield.(padded_arrays, :u)) || throw(ArgumentError("The padded_arrays do not all extend the same u!"))
6565
padded_arrays = padded_arrays[sortperm([Ds...])]
6666
lower = [padded_array.lower for padded_array in padded_arrays]
6767
upper = [padded_array.upper for padded_array in padded_arrays]

src/derivative_operators/BC_operators.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ function BridgeBC(u_low::AbstractArray{T,N}, indslow, u_up::AbstractArray{T,N},
214214
end
215215

216216
"""
217-
Q1, Q2 = BridgeBC(u1::AbstractVector{T}, hilo1::String, bc1::AtomicBC{T}, u2::AbstractVector{T}, hilo2::AbstractVector{T}, bc2::AtomicBC{T})
217+
Q1, Q2 = BridgeBC(bc1::AtomicBC, u1::AbstractArray{T,1}, hilo1::String, hilo2::String, u2::AbstractArray{T,1}, bc2::AtomicBC)
218218
-------------------------------------------------------------------------------------
219219
Creates two BC operators that join array `u1` to `u2` at the `hilo1` end ("high" or "low" index end), and joins `u2` to `u1` with simalar settings given in `hilo2`.
220220
The ends of `u1` and `u2` that are not connected will use the boundary conditions `bc1` and `bc2` respectively.
@@ -225,18 +225,20 @@ When using these with a time/space stepping solve, please use elementwise equals
225225
u_t1 .= L*Q*u_t0
226226
-----------------------------------------------------------------------------------
227227
Connecting two multi dimensional Arrays:
228-
Q1, Q2 = BridgeBC(u1::AbstractArray{T,N}, dim1::Int, hilo1::String, bc1, u2::AbstractArray{T,N}, dim2::Int, hilo2::String, bc2)
228+
Q1, Q2 = BridgeBC(bc1::MultiDimDirectionalBC, u1::AbstractArray{T,N}, dim1::Int, hilo1::String, dim2::Int, hilo2::String, u2::AbstractArray{T,N}, bc2::MultiDimDirectionalBC)
229229
-----------------------------------------------------------------------------------
230230
231231
Creates two BC operators that join array `u1` to `u2` at the `hilo1` end ("high" or "low" index end) of dimension `dim1`, and joins `u2` to `u1` with simalar settings given in `hilo2` and `dim2`.
232232
The ends of `u1` and `u2` that are not connected will use the boundary conditions `bc1` and `bc2` respectively.
233233
234+
Drop `dim1` and `dim2` when your `u1` and `u2` are vectors.
235+
234236
Use `Q1` to extend `u1` and `Q2` to extend `u2`.
235237
236238
When using these with a time/space stepping solve, please use elementwise equals on your u1 and u2 to avoid the need to create new BC operators each time, as follows:
237239
u_t1 .= L*Q*u_t0
238240
"""
239-
function BridgeBC(u1::AbstractVector{T}, hilo1::String, bc1::AtomicBC{T}, u2::AbstractVector{T}, hilo2::AbstractVector{T}, bc2::AtomicBC{T}) where T
241+
function BridgeBCBridgeBC(bc1::AtomicBC, u1::AbstractArray{T,1}, hilo1::String, hilo2::String, u2::AbstractArray{T,1}, bc2::AtomicBC) where T
240242
if hilo1 == "low"
241243
view1 = view(u1, 1)
242244
if hilo2 == "low"

src/derivative_operators/multi_dim_bc_operators.jl

Lines changed: 44 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ abstract type MultiDimensionalBC{T, N} <: AbstractBC{T} end
1212
end
1313

1414
function slice_rmul(A::AbstractDiffEqLinearOperator, u::AbstractArray{T,N}, dim::Int) where {T,N}
15+
@assert N != 1
1516
u_temp = similar(u)
1617
pre = axes(u)[1:dim-1]
1718
post = axes(u)[dim+1:end]
@@ -30,6 +31,7 @@ end
3031
end
3132

3233
function slice_rmul(A::AbstractArray{B,M}, u::AbstractArray{T,N}, dim::Int) where {T, B, N,M}
34+
@assert N != 1
3335
lower = zeros(T,perpsize(u,dim))
3436
upper = zeros(T,perpsize(u,dim))
3537
pre = axes(u)[1:dim-1]
@@ -52,8 +54,8 @@ end
5254

5355
"""
5456
A multiple dimensional BC, supporting arbitrary BCs at each boundary point.
55-
To construct an arbitrary BC, pass an Array of BCs with dimension one less than that of your domain u - denoted N,
56-
with a size of size(u)[setdiff(1:N, dim)], where dim is the dimension orthogonal to the boundary that you want to extend.
57+
To construct an arbitrary BC, pass an Array of BCs with dimension `N-1`, if `N` is the dimensionality of your domain `u`
58+
with a size of `size(u)[setdiff(1:N, dim)]`, where dim is the dimension orthogonal to the boundary that you want to extend.
5759
5860
It is also possible to call
5961
Q_dim = MultiDimBC(YourBC, size(u), dim)
@@ -69,7 +71,7 @@ In the case where you want to extend the same Robin/GeneralBC to the whole bound
6971
or
7072
Qx, Qy, Qz... = GeneralBC(αl, αr, (dx::Vector, dy::Vector, dz::Vector ...), approximation_order, size(u))
7173
72-
There are also constructors for NeumannBC, DirichletBC, Neumann0BC and Dirichlet0BC. Simply replace dx with the tuple as above, and append size(u) to the argument signature.
74+
There are also constructors for NeumannBC, DirichletBC, Neumann0BC and Dirichlet0BC. Simply replace `dx` in the call with the tuple dxyz... as above, and append `size(u)`` to the argument signature.
7375
The order is a required argument in this case.
7476
7577
where dx, dy, and dz are vectors of grid steps.
@@ -99,114 +101,72 @@ GeneralBC(αl::AbstractVector{T}, αr::AbstractVector{T}, dxyz, order, s) where
99101
perpsize(A::AbstractArray{T,N}, dim::Integer) where {T,N} = size(A)[setdiff(1:N, dim)] #the size of A perpendicular to dim
100102

101103
# Constructors for Bridge BC to make it easier to join domains together. See docs on BrigeBC in BC_operators.jl for info on usage
102-
function BridgeBC(u1::AbstractArray{T,2}, dim1::Int, hilo1::String, bc1::MultiDimDirectionalBC, u2::AbstractArray{T,2}, dim2::Int, hilo2::String, bc2::MultiDimDirectionalBC) where {T}
103-
@assert 1 dim1 2 "dim1 must be 1≤dim1≤2, got dim1 = $dim1"
104-
@assert 1 dim1 2 "dim2 must be 1≤dim1≤2, got dim1 = $dim1"
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"
105107
s1 = perpsize(u1, dim1) #
106108
s2 = perpsize(u2, dim2)
107109
@assert s1 == s2 "Arrays must be same size along boundary to be joined, got boundary sizes u1 = $s1, u2 = $s2"
108110
if hilo1 == "low"
109111
view1 = selectdim(u1, dim1, 1)
110112
if hilo2 == "low"
111-
BC1 = Array{MixedBC{T, BridgeBC{T, 2, eltype(s1)}, getboundarytype(bc1)}}(undef, s1...)
112-
BC2 = Array{MixedBC{T, BridgeBC{T, 2, eltype(s2)}, getboundarytype(bc2)}}(undef, s2...)
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...)
113115
view2 = selectdim(u2, dim2, 1)
114-
for i in 1:s1[1]
115-
BC1[i] = MixedBC(BridgeBC{T, 2, eltype(s1)}(zeros(T, 1), view(view2, i), zeros(T, 1), view(view2, i)), bc1.BCs[i])
116-
BC2[i] = MixedBC(BridgeBC{T, 2, eltype(s1)}(zeros(T, 1), view(view1, i), zeros(T, 1), view(view1, i)), bc2.BCs[i])
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])
117120
end
118121
elseif hilo2 == "high"
119-
BC1 = Array{MixedBC{T, BridgeBC{T, 2, eltype(s1)}, getboundarytype(bc1)}}(undef, s1...)
120-
BC2 = Array{MixedBC{T, getboundarytype(bc2), BridgeBC{T, 2, eltype(s2)}}}(undef, s2...)
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...)
121124
view2 = selectdim(u2, dim2, size(u2)[dim2])
122-
for i in 1:s1[1]
123-
BC1[i] = MixedBC(BridgeBC{T, 2, eltype(s1)}(zeros(T, 1), view(view2, i), zeros(T, 1), view(view2, i)), bc1.BCs[i])
124-
BC2[i] = MixedBC(bc2.BCs[i], BridgeBC{T, 2, eltype(s1)}(zeros(T, 1), view(view1, i), zeros(T, 1), view(view1, i)))
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)))
125129
end
126130
else
127-
throw("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")
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"))
128132
end
129133
elseif hilo1 == "high"
130134
view1 = selectdim(u1, dim1, size(u1)[dim1])
131135
if hilo2 == "low"
132-
BC1 = Array{MixedBC{T, getboundarytype(bc1), BridgeBC{T, 2, eltype(s1)}}}(undef, s1...)
133-
BC2 = Array{MixedBC{T, BridgeBC{T, 2, eltype(s2)}, getboundarytype(bc2)}}(undef, s2...)
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...)
134138
view2 = selectdim(u2, dim2, 1)
135-
for i in 1:s1[1]
136-
BC1[i] = MixedBC(bc1.BCs[i], BridgeBC{T, 2, eltype(s1)}(zeros(T, 1), view(view2, i), zeros(T, 1), view(view2, i)))
137-
BC2[i] = MixedBC(BridgeBC{T, 2, eltype(s1)}(zeros(T, 1), view(view1, i), zeros(T, 1), view(view1, i)), bc2.BCs[i])
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])
138143
end
139144
elseif hilo2 == "high"
140-
BC1 = Array{MixedBC{T, getboundarytype(bc1), BridgeBC{T, 2, eltype(s1)}}}(undef, s1...)
141-
BC2 = Array{MixedBC{T, getboundarytype(bc2), BridgeBC{T, 2, eltype(s2)}}}(undef, s2...)
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...)
142147
view2 = selectdim(u2, dim2, size(u2)[dim2])
143-
for i in 1:s1[1]
144-
BC1[i] = MixedBC(bc1.BCs[i], BridgeBC{T, 2, eltype(s1)}(zeros(T, 1), view(view2, i), zeros(T, 1), view(view2, i)))
145-
BC2[i] = MixedBC(bc2.BCs[i], BridgeBC{T, 2, eltype(s1)}(zeros(T, 1), view(view1, i), zeros(T, 1), view(view1, i)))
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)))
146152
end
147153
else
148-
throw("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")
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"))
149155
end
150156
else
151157
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")
152158
end
153159
return (MultiDimBC(BC1, dim1), MultiDimBC(BC2, dim2))
154160
end
155161

156-
function BridgeBC(u1::AbstractArray{T,3}, dim1::Int, hilo1::String, bc1::MultiDimDirectionalBC, u2::AbstractArray{T,3}, dim2::Int, hilo2::String, bc2::MultiDimDirectionalBC) where {T}
157-
@assert 1 dim1 3 "dim1 must be 1≤dim1≤3, got dim1 = $dim1"
158-
@assert 1 dim1 3 "dim2 must be 1≤dim1≤3, got dim1 = $dim1"
159-
s1 = perpsize(u1, dim1) #
160-
s2 = perpsize(u2, dim2)
161-
@assert s1 == s2 "Arrays must be same size along boundary to be joined, got boundary sizes u1 = $s1, u2 = $s2"
162-
if hilo1 == "low"
163-
view1 = selectdim(u1, dim1, 1)
164-
if hilo2 == "low"
165-
BC1 = Array{MixedBC{T, BridgeBC{T, 3, eltype(s1)}, getboundarytype(bc1)}}(undef, s1...)
166-
BC2 = Array{MixedBC{T, BridgeBC{T, 3, eltype(s2)}, getboundarytype(bc2)}}(undef, s2...)
167-
view2 = selectdim(u2, dim2, 1)
168-
for j in 1:s1[2], i in 1:s1[1]
169-
BC1[i, j] = MixedBC(BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view2, i, j), zeros(T, 1), view(view2, i, j)), bc1.BCs[i,j])
170-
BC2[i, j] = MixedBC(BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view1, i, j), zeros(T, 1), view(view1, i, j)), bc2.BCs[i,j])
171-
end
172-
elseif hilo2 == "high"
173-
BC1 = Array{MixedBC{T, BridgeBC{T, 3, eltype(s1)}, getboundarytype(bc1)}}(undef, s1...)
174-
BC2 = Array{MixedBC{T, getboundarytype(bc2), BridgeBC{T, 3, eltype(s2)}}}(undef, s2...)
175-
view2 = selectdim(u2, dim2, size(u2)[dim2])
176-
for j in 1:s1[2], i in 1:s1[1]
177-
BC1[i, j] = MixedBC(BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view2, i, j), zeros(T, 1), view(view2, i, j)), bc1.BCs[i,j])
178-
BC2[i, j] = MixedBC(bc2.BCs[i,j], BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view1, i, j), zeros(T, 1), view(view1, i, j)))
179-
end
180-
else
181-
throw("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")
182-
end
183-
elseif hilo1 == "high"
184-
view1 = selectdim(u1, dim1, size(u1)[dim1])
185-
if hilo2 == "low"
186-
BC1 = Array{MixedBC{T, getboundarytype(bc1), BridgeBC{T, 3, eltype(s1)}}}(undef, s1...)
187-
BC2 = Array{MixedBC{T, BridgeBC{T, 3, eltype(s2)}, getboundarytype(bc2)}}(undef, s2...)
188-
view2 = selectdim(u2, dim2, 1)
189-
view2 = selectdim(u2, dim2, 1)
190-
for j in 1:s1[2], i in 1:s1[1]
191-
BC1[i, j] = MixedBC(bc1.BCs[i,j], BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view2, i, j), zeros(T, 1), view(view2, i, j)))
192-
BC2[i, j] = MixedBC(BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view1, i, j), zeros(T, 1), view(view1, i, j)), bc2.BCs[i,j])
193-
end
194-
elseif hilo2 == "high"
195-
BC1 = Array{MixedBC{T, getboundarytype(bc1), BridgeBC{T, 3, eltype(s1)}}}(undef, s1...)
196-
BC2 = Array{MixedBC{T, getboundarytype(bc2), BridgeBC{T, 3, eltype(s2)}}}(undef, s2...)
197-
view2 = selectdim(u2, dim2, size(u2)[dim2])
198-
for j in 1:s1[2], i in 1:s1[1]
199-
BC1[i, j] = MixedBC(bc1.BCs[i,j], BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view2, i, j), zeros(T, 1), view(view2, i, j)))
200-
BC2[i, j] = MixedBC(bc2.BCs[i,j], BridgeBC{T, N, eltype(s1)}(zeros(T, 1), view(view1, i, j), zeros(T, 1), view(view1, i, j)))
201-
end
202-
else
203-
throw("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")
204-
end
205-
else
206-
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")
207-
end
208-
return (MultiDimBC(BC1, dim1), MultiDimBC(BC2, dim2))
209-
end
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+
210170
"""
211171
Q = compose(BCs...)
212172
@@ -224,9 +184,9 @@ function compose(BCs...)
224184
T = gettype(BCs[1])
225185
N = ndims(BCs[1])
226186
Ds = getaxis.(BCs)
227-
(length(BCs) == N) || throw("There must be enough BCs to cover every dimension - check that the number of MultiDimBCs == N")
187+
(length(BCs) == N) || throw(ArgumentError("There must be enough BCs to cover every dimension - check that the number of MultiDimBCs == N"))
228188
for D in Ds
229-
length(setdiff(Ds, D)) == (N-1) || throw("There are multiple boundary conditions that extend along $D - make sure every dimension has a unique extension")
189+
length(setdiff(Ds, D)) == (N-1) || throw(ArgumentError("There are multiple boundary conditions that extend along $D - make sure every dimension has a unique extension"))
230190
end
231191
BCs = BCs[sortperm([Ds...])]
232192

test/MultiDimBC_test.jl

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ using LinearAlgebra, DiffEqOperators, Random, Test
44
################################################################################
55

66
#Create Array
7-
n = 100
8-
m = 120
7+
n = 12
8+
m = 25
99
A = rand(n,m)
1010

1111
#Create atomic BC
@@ -38,9 +38,9 @@ end
3838
################################################################################
3939

4040
#Create Array
41-
n = 100
42-
m = 120
43-
o = 78
41+
n = 31
42+
m = 25
43+
o = 12
4444
A = rand(n,m, o)
4545

4646
#Create atomic BC
@@ -60,19 +60,8 @@ Ay = Qy*A
6060
Az = Qz*A
6161
# Test padded array compositions
6262

63-
Aextended = compose(Az,Ax,Ay) #Arrays in wierd order to show that this still works
64-
@test_broken compose(Ax, Az, Az) #these tests should not work, if they are broken then they are passing
65-
66-
#test BC compositions
67-
Q = compose(Qy, Qx,Qz)
68-
@test_broken compose(Qx, Qx, Qz) #these tests should not work, if they are broken then they are passing
69-
7063
QA = Q*A
7164

72-
for i in 1:(n+2), j in 1:(m+2), k in 1:(o+2)
73-
@test Aextended[i,j,k] == QA[i,j,k]
74-
end
75-
7665
@test size(Ax)[1] == size(A)[1]+2
7766
@test size(Ay)[2] == size(A)[2]+2
7867
@test size(Az)[3] == size(A)[3]+2
@@ -85,3 +74,18 @@ end
8574
for i in 1:n, j in 1:m
8675
@test Az[i, j, :] == Array(BCz[i, j]*A[i, j, :])
8776
end
77+
78+
#test compositions to higher dimension
79+
for N in 2:7
80+
sizes = rand(5:10)
81+
A = rand(sizes...)
82+
83+
Q1_N = Neumann0BC(1.0, 3.0, size(A))
84+
85+
Q = compose(Q1_N...)
86+
87+
A1_N = Q1_N.*fill(A, N)
88+
89+
A_extended = Q*A
90+
@test Array(A_extended) == Array(compose(A1_N...))
91+
end

0 commit comments

Comments
 (0)