Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update annuli compat + add sparsearray interface #23

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- '1.9'
os:
- ubuntu-latest
- macOS-latest
# - macOS-latest
- windows-latest
arch:
- x64
Expand Down
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RadialPiecewisePolynomials"
uuid = "7dab568b-3cf7-4f91-a977-b4631dfca174"
authors = ["john.papad "]
version = "0.1.1"
version = "0.1.2"

[deps]
AnnuliOrthogonalPolynomials = "de1797fd-24c3-4035-91a2-b52aecdcfb01"
Expand All @@ -21,11 +21,12 @@ MultivariateOrthogonalPolynomials = "4f6956fd-4f93-5457-9149-7bfc4b2ce06d"
PiecewiseOrthogonalPolynomials = "4461d12d-4663-4550-8580-cb764c85e20f"
QuasiArrays = "c4ea9172-b204-11e9-377d-29865faadc5c"
SemiclassicalOrthogonalPolynomials = "291c01f3-23f6-4eb6-aeb0-063a639b53f2"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
AnnuliOrthogonalPolynomials = "0.0.4"
AnnuliOrthogonalPolynomials = "0.0.5"
BandedMatrices = "0.17, 1"
BlockArrays = "0.16"
BlockBandedMatrices = "0.12"
Expand Down
5 changes: 3 additions & 2 deletions src/RadialPiecewisePolynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module RadialPiecewisePolynomials

using AnnuliOrthogonalPolynomials, BandedMatrices, BlockArrays, BlockBandedMatrices, ClassicalOrthogonalPolynomials, ContinuumArrays, DomainSets,
FastTransforms, LinearAlgebra, MultivariateOrthogonalPolynomials, SemiclassicalOrthogonalPolynomials,
StaticArrays, QuasiArrays, FillArrays, LazyArrays, Memoization#, ArrayLayouts#, LazyBandedMatrices#,
StaticArrays, QuasiArrays, FillArrays, LazyArrays, Memoization, SparseArrays#, ArrayLayouts#, LazyBandedMatrices#,


import BlockArrays: BlockSlice, block, blockindex, blockvec
Expand All @@ -28,7 +28,8 @@ export SVector, Zeros, Ones, Vcat, Derivative, pad, paddeddata, Hcat, RadialCoor
ZernikeBasis, ZernikeBasisMode, ZernikeBasisModeElement,
BBBArrowheadMatrix,
get_rs, get_θs, getNs,
mass_matrix, assembly_matrix, stiffness_matrix, gram_matrix, piecewise_constant_assembly_matrix
mass_matrix, assembly_matrix, stiffness_matrix, gram_matrix, piecewise_constant_assembly_matrix,
sparse

get_rs(x) = x.r
get_θs(x) = x.θ
Expand Down
6 changes: 6 additions & 0 deletions src/continuouszernike.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ function zero_dirichlet_bcs!(Φ::ContinuousZernike{T}, Mf::AbstractVector{<:Pseu
zero_dirichlet_bcs!.(Fs, Mf)
end

function zero_dirichlet_bcs!(Φ::ContinuousZernike{T}, Mf::AbstractVector{<:AbstractVector}) where T
@assert length(Mf) == 2*Φ.N-1
Fs = Φ.Fs #_getFs(Φ.N, Φ.points)
zero_dirichlet_bcs!.(Fs, Mf)
end

function zero_dirichlet_bcs!(points::AbstractVector{T}, A::Matrix) where T
K = length(points)-1
if first(points) > 0
Expand Down
24 changes: 24 additions & 0 deletions src/continuouszernikemode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,19 @@ function zero_dirichlet_bcs!(F::ContinuousZernikeMode{T}, A::Matrix) where T
end
end

function zero_dirichlet_bcs!(F::ContinuousZernikeMode{T}, A::SparseMatrixCSC) where T
points = F.points
K = length(points)-1
if first(points) > 0
A[1,:] .= zero(T); A[:,1] .= zero(T)
A[K+1, :] .= zero(T); A[:, K+1] .= zero(T)
A[1,1] = one(T); A[K+1, K+1] = one(T)
else
A[K,:] .= zero(T); A[:,K] .= zero(T)
A[K,K] = one(T)
end
end

function zero_dirichlet_bcs!(F::ContinuousZernikeMode{T}, Mf::PseudoBlockVector) where T
points = F.points
K = length(points)-1
Expand All @@ -383,6 +396,17 @@ function zero_dirichlet_bcs!(F::ContinuousZernikeMode{T}, Mf::PseudoBlockVector)
end
end

function zero_dirichlet_bcs!(F::ContinuousZernikeMode{T}, Mf::AbstractVector) where T
points = F.points
K = length(points)-1
if !(first(points) ≈ 0)
Mf[1] = zero(T)
Mf[K+1] = zero(T)
else
Mf[K] = zero(T)
end
end

###
# Plotting
###
Expand Down
6 changes: 3 additions & 3 deletions src/plotting/plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ function _plot(K::Int, θs::AbstractVector, rs::AbstractVector, vals::AbstractVe
display(gcf())
end

function plot(F::FiniteContinuousZernike{T}, θs::AbstractVector, rs::AbstractVector, vals::AbstractVector;ρ::T=0.0, ttl=[], vminmax=[],K=0) where T
function plot(F::ContinuousZernike{T}, θs::AbstractVector, rs::AbstractVector, vals::AbstractVector;ρ::T=0.0, ttl=[], vminmax=[],K=0) where T
K = K ==0 ? lastindex(F.points)-1 : K
_plot(K, θs, rs, vals, ρ=ρ, ttl=ttl, vminmax=vminmax)
end

function plot(F::FiniteContinuousZernikeMode{T}, θs::AbstractVector, rs::AbstractVector, vals::AbstractVector;ρ::T=0.0, ttl=[], K=0) where T
function plot(F::ContinuousZernikeMode{T}, θs::AbstractVector, rs::AbstractVector, vals::AbstractVector;ρ::T=0.0, ttl=[], K=0) where T
K = K ==0 ? lastindex(Z.points)-1 : K
_plot(K, θs, rs, vals, ρ=ρ, ttl=ttl)
end

function plot(Z::FiniteZernikeBasis{T}, θs::AbstractVector, rs::AbstractVector, vals::AbstractVector;ρ::T=0.0, ttl=[], K=0) where T
function plot(Z::ZernikeBasis{T}, θs::AbstractVector, rs::AbstractVector, vals::AbstractVector;ρ::T=0.0, ttl=[], K=0) where T
K = K ==0 ? lastindex(Z.points)-1 : K
_plot(K, θs, rs, vals, ρ=ρ, ttl=ttl)
end
Expand Down
Loading