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

Commit 31735b7

Browse files
committed
2 parents a986250 + 7a8eb16 commit 31735b7

19 files changed

+429
-1478
lines changed

appveyor.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/1.0/julia-1.0-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/1.0/julia-1.0-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
7-
matrix:
8-
allow_failures:
9-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
10-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 1
4+
5+
platform:
6+
- x64 # 64-bit
7+
8+
# # Uncomment the following lines to allow failures on nightly julia
9+
# # (tests will run but not make your overall status red)
10+
# matrix:
11+
# allow_failures:
12+
# - julia_version: nightly
13+
1114
branches:
1215
only:
1316
- master
@@ -20,19 +23,18 @@ notifications:
2023
on_build_status_changed: false
2124

2225
install:
23-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
24-
# Download most recent Julia Windows binary
25-
- ps: (new-object net.webclient).DownloadFile(
26-
$env:JULIA_URL,
27-
"C:\projects\julia-binary.exe")
28-
# Run installer silently, output to C:\projects\julia
29-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
26+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3027

3128
build_script:
32-
# Need to convert from shallow to complete for Pkg.clone to work
33-
- IF EXIST .git\shallow (git fetch --unshallow)
34-
- C:\projects\julia\bin\julia -e "versioninfo();
35-
Pkg.clone(pwd(), \"DiffEqOperators\"); Pkg.build(\"DiffEqOperators\")"
29+
- echo "%JL_BUILD_SCRIPT%"
30+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3631

3732
test_script:
38-
- C:\projects\julia\bin\julia -e "Pkg.test(\"DiffEqOperators\")"
33+
- echo "%JL_TEST_SCRIPT%"
34+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
35+
36+
# # Uncomment to support code coverage upload. Should only be enabled for packages
37+
# # which would have coverage gaps without running on Windows
38+
# on_success:
39+
# - echo "%JL_CODECOV_SCRIPT%"
40+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

src/DiffEqOperators.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ include("basic_operators.jl")
2020
include("matrixfree_operators.jl")
2121
include("jacvec_operators.jl")
2222

23+
### Boundary Operators
24+
include("derivative_operators/robin_bc_extended.jl")
25+
2326
### Derivative Operators
2427
include("derivative_operators/fornberg.jl")
2528
include("derivative_operators/upwind_operator.jl")
2629
include("derivative_operators/derivative_irreg_operator.jl")
2730
include("derivative_operators/derivative_operator.jl")
2831
include("derivative_operators/abstract_operator_functions.jl")
29-
include("derivative_operators/boundary_operators.jl")
32+
include("derivative_operators/convolutions.jl")
3033

3134
### Composite Operators
3235
include("composite_operators.jl")
@@ -41,4 +44,5 @@ end
4144
export MatrixFreeOperator
4245
export DiffEqScalar, DiffEqArrayOperator, DiffEqIdentity, JacVecOperator, getops
4346
export AbstractDerivativeOperator, DerivativeOperator, UpwindOperator, FiniteDifference
47+
export RobinBC
4448
end # module

src/derivative_operators/abstract_operator_functions.jl

Lines changed: 48 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ checkbounds(A::AbstractDerivativeOperator, k::Colon, j::Integer) =
1717
checkbounds(A::AbstractDerivativeOperator, k::Integer, j::Colon) =
1818
(0 < k size(A, 1) || throw(BoundsError(A, (k,size(A,2)))))
1919

20-
21-
# BandedMatrix{A,B,C,D}(A::DerivativeOperator{A,B,C,D}) = BandedMatrix(convert(Array, A, A.stencil_length), A.stencil_length, div(A.stencil_length,2), div(A.stencil_length,2))
22-
2320
# ~~ getindex ~~
2421
@inline function getindex(A::AbstractDerivativeOperator, i::Int, j::Int)
2522
@boundscheck checkbounds(A, i, j)
@@ -113,21 +110,6 @@ end
113110
end
114111
end
115112

116-
#=
117-
This the basic mul! function which is broken up into 3 parts ie. handling the left
118-
boundary, handling the interior and handling the right boundary. Finally the vector is
119-
scaled appropriately according to the derivative order and the degree of discretizaiton.
120-
We also update the time stamp of the DerivativeOperator inside to manage time dependent
121-
boundary conditions.
122-
=#
123-
function LinearAlgebra.mul!(x_temp::AbstractVector{T}, A::Union{DerivativeOperator{T},UpwindOperator{T}}, x::AbstractVector{T}) where T<:Real
124-
convolve_BC_left!(x_temp, x, A)
125-
convolve_interior!(x_temp, x, A)
126-
convolve_BC_right!(x_temp, x, A)
127-
rmul!(x_temp, @.(1/(A.dx^A.derivative_order)))
128-
A.t[] += 1 # incrementing the internal time stamp
129-
end
130-
131113
#=
132114
This definition of the mul! function makes it possible to apply the LinearOperator on
133115
a matrix and not just a vector. It basically transforms the rows one at a time.
@@ -159,58 +141,6 @@ Base.transpose(A::Union{DerivativeOperator,UpwindOperator}) = A
159141
Base.adjoint(A::Union{DerivativeOperator,UpwindOperator}) = A
160142
LinearAlgebra.issymmetric(::Union{DerivativeOperator,UpwindOperator}) = true
161143

162-
#=
163-
This function ideally should give us a matrix which when multiplied with the input vector
164-
returns the derivative. But the presence of different boundary conditons complicates the
165-
situation. It is not possible to incorporate the full information of the boundary conditions
166-
in the matrix as they are additive in nature. So in this implementation we will just
167-
return the inner stencil of the matrix transformation. The user will have to manually
168-
incorporate the BCs at the ends.
169-
=#
170-
function Base.convert(::Type{Array}, A::AbstractDerivativeOperator{T}, N::Int=A.dimension) where T
171-
@assert N >= A.stencil_length # stencil must be able to fit in the matrix
172-
mat = zeros(T, (N, N))
173-
v = zeros(T, N)
174-
for i=1:N
175-
v[i] = one(T)
176-
#=
177-
calculating the effect on a unit vector to get the matrix of transformation
178-
to get the vector in the new vector space.
179-
=#
180-
mul!(view(mat,:,i), A, v)
181-
v[i] = zero(T)
182-
end
183-
return mat
184-
end
185-
186-
187-
#=
188-
This function ideally should give us a matrix which when multiplied with the input vector
189-
returns the derivative. But the presence of different boundary conditons complicates the
190-
situation. It is not possible to incorporate the full information of the boundary conditions
191-
in the matrix as they are additive in nature. So in this implementation we will just
192-
return the inner stencil of the matrix transformation. The user will have to manually
193-
incorporate the BCs at the ends.
194-
=#
195-
function SparseArrays.sparse(A::AbstractDerivativeOperator{T}) where T
196-
N = A.dimension
197-
mat = spzeros(T, N, N)
198-
v = zeros(T, N)
199-
row = zeros(T, N)
200-
for i=1:N
201-
v[i] = one(T)
202-
#=
203-
calculating the effect on a unit vector to get the matrix of transformation
204-
to get the vector in the new vector space.
205-
=#
206-
mul!(row, A, v)
207-
copyto!(view(mat,:,i), row)
208-
@. row = 0 * row;
209-
v[i] = zero(T)
210-
end
211-
return mat
212-
end
213-
214144
#=
215145
Fallback methods that use the full representation of the operator
216146
=#
@@ -219,3 +149,51 @@ Base.:\(A::AbstractVecOrMat, B::AbstractDerivativeOperator) = A \ convert(Array,
219149
Base.:\(A::AbstractDerivativeOperator, B::AbstractVecOrMat) = convert(Array,A) \ B
220150
Base.:/(A::AbstractVecOrMat, B::AbstractDerivativeOperator) = A / convert(Array,B)
221151
Base.:/(A::AbstractDerivativeOperator, B::AbstractVecOrMat) = convert(Array,A) / B
152+
153+
########################################################################
154+
155+
# Are these necessary?
156+
157+
get_type(::AbstractDerivativeOperator{T}) where {T} = T
158+
159+
function *(A::AbstractDerivativeOperator,x::AbstractVector)
160+
#=
161+
We will output a vector which is a supertype of the types of A and x
162+
to ensure numerical stability
163+
=#
164+
get_type(A) != eltype(x) ? error("DiffEqOperator and array are not of same type!") : nothing
165+
y = zeros(promote_type(eltype(A),eltype(x)), length(x))
166+
LinearAlgebra.mul!(y, A::AbstractDerivativeOperator, x::AbstractVector)
167+
return y
168+
end
169+
170+
171+
function *(A::AbstractDerivativeOperator,M::AbstractMatrix)
172+
#=
173+
We will output a vector which is a supertype of the types of A and x
174+
to ensure numerical stability
175+
=#
176+
get_type(A) != eltype(M) ? error("DiffEqOperator and array are not of same type!") : nothing
177+
y = zeros(promote_type(eltype(A),eltype(M)), size(M))
178+
LinearAlgebra.mul!(y, A::AbstractDerivativeOperator, M::AbstractMatrix)
179+
return y
180+
end
181+
182+
183+
function *(M::AbstractMatrix,A::AbstractDerivativeOperator)
184+
#=
185+
We will output a vector which is a supertype of the types of A and x
186+
to ensure numerical stability
187+
=#
188+
get_type(A) != eltype(M) ? error("DiffEqOperator and array are not of same type!") : nothing
189+
y = zeros(promote_type(eltype(A),eltype(M)), size(M))
190+
LinearAlgebra.mul!(y, A::AbstractDerivativeOperator, M::AbstractMatrix)
191+
return y
192+
end
193+
194+
195+
function *(A::AbstractDerivativeOperator,B::AbstractDerivativeOperator)
196+
# TODO: it will result in an operator which calculates
197+
# the derivative of order A.dorder + B.dorder of
198+
# approximation_order = min(approx_A, approx_B)
199+
end

0 commit comments

Comments
 (0)