This repository was archived by the owner on Jul 19, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 72
Split Q Multidimensional BCs [Frozen, pending review] #135
Merged
Merged
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
fe48925
First go at Higher dim BCs, up to 3D.
xtalax 3e334e9
some fixes
xtalax 5d50e06
3rd order robin and General test
xtalax c218693
More type tree diversification and array like operations for Boundary…
xtalax c25e2c5
More type tree diversification and array like operations for Boundary…
xtalax c5c5b8c
GeneralBC fixes
xtalax ace5ef3
vim
xtalax 44effda
vim
xtalax a97edd1
Merge branch 'BC-Dev' into dev-bc
xtalax 575434f
added getindex and fixed type information
xtalax 53df121
added getindex and fixed type information
xtalax f54fa23
fixed above
xtalax 7a06bb9
a hash sign
xtalax b0d5c84
Added tests, got them passing, changed interface of AffineBC and subt…
xtalax c9e3432
tests passing
xtalax e26ecc7
Added tests up to 3D, fixed MixedBC
xtalax 44d2a8a
Added Extension for MultiDimensionalPeriodicBC
xtalax 14377d5
addressed the function subtypes directly in InteractiveUtils, added s…
xtalax fe12102
Split the BCs up so that they only act along one dimension
xtalax ba468fd
tests passing
xtalax 4d7e610
more constructors
xtalax 46c6300
BridgeBC, a 1 ended BC that must be composed in a MixedArray to be valid
xtalax 12fb57f
Dirichlet0 and Neumann0 constructors, simplified interface for BridgeBC
xtalax 3141e1b
end
xtalax 0c7524e
fixes
xtalax e1fbd40
Comments and exports
xtalax 8c12114
Re added the combined Q as ComposedBoundaryPaddedArray
xtalax 559ae9e
Re added the combined Q as ComposedBoundaryPaddedArray
xtalax 08ba0b1
.
xtalax 8d33fa6
Changed Test for generic operator validation - FiniteDifference no lo…
xtalax c0aa111
''
xtalax ef940fa
Added tests for ComposedPaddedArrays and ComposedBCs, some fixes
xtalax 5f492cc
fixed some strange broadcast outputs
xtalax 091ffdd
removed an @show that was spamming the repl
xtalax 786b0ff
Added Concretizations for everything, Changed BridgeBC so that they a…
xtalax c147c3f
Made the concretization of the PeriodicBC consistent
xtalax 0689ff5
marked broken jacvec test
xtalax b353c5f
Robin was working after all, error in hand calculations
xtalax 42013b6
Allowed non uniform grid for robin/general, updated MultiDimBC constr…
xtalax 92ccfe2
Added BandedMatrix Concretizations for all BC operators
xtalax b6adfa2
Merge pull request #10 from JuliaDiffEq/master
xtalax 8702746
Merge pull request #11 from xtalax/master
xtalax 4668ff5
trying to do something about this jacvec test
xtalax 5942688
commented out problem jacvec tests
xtalax d3206e8
Yingbo Ma's fix for the jacvec tests - now uncommented
xtalax d9d26d0
Merge branch 'master' into SplitBC-dev
xtalax 8020e9e
Change robin/general interface for uniform grid, depreciate old synta…
xtalax 9e30f82
Merge branch 'SplitBC-dev' of https://github.com/xtalax/DiffEqOperato…
xtalax 76a47db
moved boundary padded arrays to their own file, put concretizations i…
xtalax e30575a
added tests for BridgeBC
xtalax 2606a28
Merge pull request #12 from JuliaDiffEq/master
xtalax fa54e80
Merge pull request #13 from xtalax/master
xtalax 47af0e1
Get tests passing for BridgeBC, fix some issues
xtalax 2a3885f
split out multi dimensional BCs in to their own file for readability
xtalax 14cdde9
add include
xtalax c7ad2f7
moved perpsize
xtalax bc05268
slicemul now fully N dimensional - BC operators work up to any N
xtalax ecb8393
reduce size of needlessly large arrays in the BoundaryPaddedArray test
xtalax 45ebabf
spruced up the extra bridge BC constructors to work to N dimensions
xtalax cf1ae68
some fixes
xtalax 07c4210
Pulled out BridgeBC in to its own branch, since it was causing proble…
xtalax 055bec1
also removed MixedBC to other branch
xtalax af86556
exports
xtalax da3514e
cleaned up an unused function
xtalax 7b0b7fd
readded tests for ComposedBoundaryPaddedArray, added CartesianIndex g…
xtalax 8a2dce3
Got tests passing
xtalax e415be3
Merge branch 'bridge-bc' into SplitBC-dev
xtalax f0251a2
overwrite erroneous merge
xtalax fdaca9e
"
xtalax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| # Boundary Padded Arrays | ||
| abstract type AbstractBoundaryPaddedArray{T, N} <: AbstractArray{T, N} end | ||
|
|
||
| """ | ||
| A vector type that extends a vector u with ghost points at either end | ||
| """ | ||
| struct BoundaryPaddedVector{T,T2 <: AbstractVector{T}} <: AbstractBoundaryPaddedArray{T, 1} | ||
| l::T | ||
| r::T | ||
| u::T2 | ||
| end | ||
| Base.length(Q::BoundaryPaddedVector) = length(Q.u) + 2 | ||
| Base.size(Q::BoundaryPaddedVector) = (length(Q.u) + 2,) | ||
| Base.lastindex(Q::BoundaryPaddedVector) = Base.length(Q) | ||
|
|
||
| function Base.getindex(Q::BoundaryPaddedVector,i) | ||
| if i == 1 | ||
| return Q.l | ||
| elseif i == length(Q) | ||
| return Q.r | ||
| else | ||
| return Q.u[i-1] | ||
| end | ||
| end | ||
|
|
||
| """ | ||
| 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 | ||
|
|
||
| """ | ||
| struct BoundaryPaddedArray{T, D, N, M, V<:AbstractArray{T, N}, B<: AbstractArray{T, M}} <: AbstractBoundaryPaddedArray{T,N} | ||
| lower::B #an array of dimension M = N-1, used to extend the lower index boundary | ||
| upper::B #Ditto for the upper index boundary | ||
| u::V | ||
| end | ||
|
|
||
| getaxis(Q::BoundaryPaddedArray{T,D,N,M,V,B}) where {T,D,N,M,V,B} = D | ||
|
|
||
| function Base.size(Q::BoundaryPaddedArray) | ||
| S = [size(Q.u)...] | ||
| S[getaxis(Q)] += 2 | ||
| return Tuple(S) | ||
| end | ||
|
|
||
| """ | ||
| A = compose(padded_arrays::BoundaryPaddedArray...) | ||
|
|
||
| ------------------------------------------------------------------------------------- | ||
|
|
||
| Example: | ||
| A = compose(Ax, Ay, Az) # 3D domain | ||
| A = compose(Ax, Ay) # 2D Domain | ||
|
|
||
| Composes BoundaryPaddedArrays that extend the same u for each different dimension that u has in to a ComposedBoundaryPaddedArray | ||
|
|
||
| Ax Ay and Az can be passed in any order, as long as there is exactly one BoundaryPaddedArray that extends each dimension. | ||
| """ | ||
| function compose(padded_arrays::BoundaryPaddedArray...) | ||
| N = ndims(padded_arrays[1]) | ||
| Ds = getaxis.(padded_arrays) | ||
| (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).")) | ||
| for D in Ds | ||
| 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")) | ||
| end | ||
| 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!")) | ||
| padded_arrays = padded_arrays[sortperm([Ds...])] | ||
| lower = [padded_array.lower for padded_array in padded_arrays] | ||
| upper = [padded_array.upper for padded_array in padded_arrays] | ||
|
|
||
| ComposedBoundaryPaddedArray{gettype(padded_arrays[1]),N,N-1,typeof(padded_arrays[1].u),typeof(lower[1])}(lower, upper, padded_arrays[1].u) | ||
| end | ||
|
|
||
| # Composed BoundaryPaddedArray | ||
|
|
||
| struct ComposedBoundaryPaddedArray{T, N, M, V<:AbstractArray{T, N}, B<: AbstractArray{T, M}} <: AbstractBoundaryPaddedArray{T, N} | ||
| lower::Vector{B} | ||
| upper::Vector{B} | ||
| u::V | ||
| end | ||
|
|
||
| # Aliases | ||
| AbstractBoundaryPaddedMatrix{T} = AbstractBoundaryPaddedArray{T,2} | ||
| AbstractBoundaryPadded3Tensor{T} = AbstractBoundaryPaddedArray{T,3} | ||
|
|
||
| BoundaryPaddedMatrix{T, D, V, B} = BoundaryPaddedArray{T, D, 2, 1, V, B} | ||
| BoundaryPadded3Tensor{T, D, V, B} = BoundaryPaddedArray{T, D, 3, 2, V, B} | ||
|
|
||
| ComposedBoundaryPaddedMatrix{T,V,B} = ComposedBoundaryPaddedArray{T,2,1,V,B} | ||
| ComposedBoundaryPadded3Tensor{T,V,B} = ComposedBoundaryPaddedArray{T,3,2,V,B} | ||
|
|
||
| Base.size(Q::ComposedBoundaryPaddedArray) = size(Q.u).+2 | ||
|
|
||
| """ | ||
| Ax, Ay,... = decompose(A::ComposedBoundaryPaddedArray) | ||
|
|
||
| ------------------------------------------------------------------------------------- | ||
|
|
||
| Decomposes a ComposedBoundaryPaddedArray in to components that extend along each dimension individually | ||
| """ | ||
| 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 in 1:ndims(A)]) | ||
|
|
||
|
|
||
| Base.length(Q::AbstractBoundaryPaddedArray) = reduce((*), size(Q)) | ||
| Base.firstindex(Q::AbstractBoundaryPaddedArray, d::Int) = 1 | ||
| Base.lastindex(Q::AbstractBoundaryPaddedArray) = length(Q) | ||
| Base.lastindex(Q::AbstractBoundaryPaddedArray, d::Int) = size(Q)[d] | ||
| gettype(Q::AbstractBoundaryPaddedArray{T,N}) where {T,N} = T | ||
| Base.ndims(Q::AbstractBoundaryPaddedArray{T,N}) where {T,N} = N | ||
|
|
||
| add_dim(A::AbstractArray, i) = reshape(A, size(A)...,i) | ||
| add_dim(i) = i | ||
|
|
||
| function Base.getindex(Q::BoundaryPaddedArray{T,D,N,M,V,B}, _inds::Vararg{Int,N}) where {T,D,N,M,V,B} #supports range and colon indexing! | ||
| inds = [_inds...] | ||
| S = size(Q) | ||
| dim = D | ||
| otherinds = inds[setdiff(1:N, dim)] | ||
| @assert length(S) == N | ||
| if inds[dim] == 1 | ||
| return Q.lower[otherinds...] | ||
| elseif inds[dim] == S[dim] | ||
| return Q.upper[otherinds...] | ||
| elseif typeof(inds[dim]) <: Integer | ||
| inds[dim] = inds[dim] - 1 | ||
| return Q.u[inds...] | ||
| elseif typeof(inds[dim]) == Colon | ||
| if mapreduce(x -> typeof(x) != Colon, (|), otherinds) | ||
| return vcat(Q.lower[otherinds...], Q.u[inds...], Q.upper[otherinds...]) | ||
| else | ||
| throw("A colon on the extended dim is as yet incompatible with additional colons") | ||
| end | ||
| elseif typeof(inds[dim]) <: AbstractArray | ||
| throw("Range indexing not yet supported!") | ||
| end | ||
| end | ||
|
|
||
| function Base.getindex(Q::ComposedBoundaryPaddedArray{T, N, M, V, B} , inds::Vararg{Int, N}) where {T, N, M, V, B} #as yet no support for range indexing or colon indexing | ||
| S = size(Q) | ||
| @assert reduce((&), inds .<= S) | ||
| for (dim, index) in enumerate(inds) | ||
| if index == 1 | ||
| _inds = inds[setdiff(1:N, dim)] | ||
| if (1 ∈ _inds) | reduce((|), S[setdiff(1:N, dim)] .== _inds) | ||
| return zero(T) | ||
| else | ||
| return Q.lower[dim][(_inds.-1)...] | ||
| end | ||
| elseif index == S[dim] | ||
| _inds = inds[setdiff(1:N, dim)] | ||
| if (1 ∈ _inds) | reduce((|), S[setdiff(1:N, dim)] .== _inds) | ||
| return zero(T) | ||
| else | ||
| return Q.upper[dim][(_inds.-1)...] | ||
| end | ||
| end | ||
| end | ||
| return Q.u[(inds.-1)...] | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.