You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 19, 2023. It is now read-only.
Higher dimensional generalization of BoundaryPaddedVector, pads an array of dimension N along the dimension D with 2 Arrays of dimension N-1, stored in lower and upper
28
30
29
31
"""
30
-
struct BoundaryPaddedArray{T, D, N, M, V<:AbstractArray{T, N}, B<:AbstractArray{T, M}} <:AbstractBoundaryPaddedArray{T,N}
32
+
struct BoundaryPaddedArray{T, D, N, M, V<:AbstractArray{T, N}, B<:AbstractArray{T, M}} <:AbstractDirectionalBoundaryPaddedArray{T,N, D}
31
33
lower::B#an array of dimension M = N-1, used to extend the lower index boundary
32
34
upper::B#Ditto for the upper index boundary
33
35
u::V
@@ -59,9 +61,9 @@ function compose(padded_arrays::BoundaryPaddedArray...)
59
61
Ds =getaxis.(padded_arrays)
60
62
(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)."))
61
63
for D in Ds
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"))
64
+
length(setdiff(Ds, D)) < N||throw(ArgumentError("There are multiple Arrays that extend along dimension $D - make sure every dimension has a unique extension"))
63
65
end
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!"))
66
+
any(fill(padded_arrays[1].u, (length(padded_arrays),)) .==getfield.(padded_arrays, :u)) ||throw(ArgumentError("The padded_arrays do not all extend the same u!"))
65
67
padded_arrays = padded_arrays[sortperm([Ds...])]
66
68
lower = [padded_array.lower for padded_array in padded_arrays]
67
69
upper = [padded_array.upper for padded_array in padded_arrays]
@@ -71,7 +73,7 @@ end
71
73
72
74
# Composed BoundaryPaddedArray
73
75
74
-
struct ComposedBoundaryPaddedArray{T, N, M, V<:AbstractArray{T, N}, B<:AbstractArray{T, M}} <:AbstractBoundaryPaddedArray{T, N}
76
+
struct ComposedBoundaryPaddedArray{T, N, M, V<:AbstractArray{T, N}, B<:AbstractArray{T, M}} <:AbstractComposedBoundaryPaddedArray{T, N}
Decomposes a ComposedBoundaryPaddedArray in to components that extend along each dimension individually
98
100
"""
99
-
decompose(A::ComposedBoundaryPaddedArray) =Tuple([BoundaryPaddedArray{gettype(A), ndims(A), ndims(A)-1, typeof(lower[1])}(A.lower[i], A.upper[i], A.u) for i in1:ndims(A)])
100
-
101
+
decompose(A::ComposedBoundaryPaddedArray) =Tuple([BoundaryPaddedArray{gettype(A), i, ndims(A), ndims(A)-1, typeof(lower[1])}(A.lower[i], A.upper[i], A.u) for i in1:ndims(A)])
@@ -91,10 +91,10 @@ This time there are multiple stencils for multiple derivative orders - these can
91
91
All components that multiply u(0) are factored out, turns out to only involve the first colum of S, s̄0. The rest of S is denoted S`. the coeff of u(0) is s̄0⋅ᾱ[3:end] + α[2].
92
92
the remaining components turn out to be ᾱ[3:end]⋅(S`ū`) or equivalantly (transpose(ᾱ[3:end])*S`)⋅ū`. Rearranging, a stencil q_a to be dotted with ū` upon extension can readily be found, along with a constant component q_b
#implement Neumann and Dirichlet as special cases of RobinBC
159
-
NeumannBC(α::AbstractVector{T}, dx::Union{AbstractVector{T}, T}, order =1) where T =RobinBC([zero(T), one(T), α[1]], [zero(T), one(T), α[2]], dx, order)
160
-
DirichletBC(αl::T, αr::T) where T =RobinBC([one(T), zero(T), αl], [one(T), zero(T), αr], 1.0, 2.0 )
159
+
NeumannBC(α::NTuple{2,T}, dx::Union{AbstractVector{T}, T}, order =1) where T =RobinBC((zero(T), one(T), α[1]), (zero(T), one(T), α[2]), dx, order)
160
+
DirichletBC(αl::T, αr::T) where T =RobinBC((one(T), zero(T), αl), (one(T), zero(T), αr), 1.0, 2.0 )
161
161
#specialized constructors for Neumann0 and Dirichlet0
0 commit comments