Skip to content

Commit

Permalink
more fixes for lazyarrays + some methods for ADI
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannisPApapadopoulos committed Aug 10, 2023
1 parent 8ed9f8c commit 35ed20a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/RadialPiecewisePolynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export SVector, Zeros, Ones, Vcat, Derivative, pad, paddeddata, Hcat, RadialCoor
FiniteContinuousZernikeMode, FiniteContinuousZernike, inf_error,
FiniteZernikeBasis, ZernikeBasisMode, FiniteZernikeBasisMode,
ArrowheadMatrix,
modaltravcellwise, listtravcellwise
list_2_modaltrav, modaltrav_2_list, adi_2_modaltrav, adi_2_list

include("arrowhead.jl")
include("diskelement.jl")
Expand Down
6 changes: 4 additions & 2 deletions src/annuluselement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,13 @@ end

function bubble2ann(C::ContinuousZernikeAnnulusElementMode, c::AbstractVector{T}) where T
L₁₁, L₀₁, L₁₀ = C.L₁₁, C.L₀₁, C.L₁₀
= [L₁₀[:,1] L₀₁[:,1] L₁₁]
if c isa LazyArray
c = paddeddata(c)
end
R̃[1:length(c), 1:length(c)] * c # coefficients for ZernikeAnnulus(ρ,0,0)
N = length(c)
= Hcat(view(L₁₀,1:N,1), view(L₀₁,1:N,1), view(L₁₁,1:N, 1:N-2))

* c # coefficients for ZernikeAnnulus(ρ,0,0)
end

function plotvalues(u::ApplyQuasiVector{T,typeof(*),<:Tuple{ContinuousZernikeAnnulusElementMode, AbstractVector}}) where T
Expand Down
57 changes: 57 additions & 0 deletions src/finitecontinuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,61 @@ end
function inf_error(F::FiniteContinuousZernike{T}, θs::AbstractVector, rs::AbstractVector, vals::AbstractVector, u::Function) where T
K = lastindex(F.points)-1
_inf_error(K, θs, rs, vals, u)
end

function modaltrav_2_list(F::FiniteContinuousZernike{T}, u::AbstractArray{Vector{T}}) where T
N, points = F.N, F.points
K = length(points) - 1
Ns, _, _ = _getMs_ms_js(N)

cs = []
u = ModalTrav.(u)
for i in 1:2N-1
v = zeros(T, Ns[i]-1, K)
for k in 1:K
v[:, k] = u[k].matrix[1:Ns[i]-1,i]
end
append!(cs, [pad(vec(v'), blockedrange(Fill(K, Ns[i]-1)))])
end
return cs
end

function adi_2_modaltrav(F::FiniteContinuousZernike{T}, wQ::Weighted{<:Any, <:Jacobi}, Us::AbstractArray, z::AbstractArray{T}) where T
N, points = F.N, F.points
K = length(points) - 1
Ns, _, _ = _getMs_ms_js(N)

Y = [zeros(T, sum(1:N), length(z)) for k in 1:K]
for zi in 1:lastindex(z)
X = [zeros(T, Ns[1], 2N-1) for k in 1:K]
for k in 1:K
for n in 1:2N-1
us = Us[n][k:K:end, zi]
X[k][1:lastindex(us), n] = us
end
Y[k][:,zi] = ModalTrav(X[k])
end
end
return Y
end

function adi_2_list(F::FiniteContinuousZernike{T}, wQ::Weighted{<:Any, <:Jacobi}, Us::AbstractArray, z::AbstractArray{T}) where T
N, points = F.N, F.points
K = length(points) - 1
Ns, _, _ = _getMs_ms_js(N)

Y = []

for zi in 1:lastindex(z)
cs = []
for n in 1:2N-1
v = zeros(T, Ns[n]-1, K)
for k in 1:K
v[:, k] = Us[n][k:K:end, zi]
end
append!(cs, [pad(vec(v'), blockedrange(Fill(K, Ns[n]-1)))])
end
append!(Y, [cs])
end
return Y
end
23 changes: 21 additions & 2 deletions src/finitezernike.jl
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function inf_error(Z::FiniteZernikeBasis{T}, θs::AbstractVector, rs::AbstractVe
end

## Coefficient storage conversion
function modaltravcellwise(Z::FiniteZernikeBasis{T}, u::AbstractArray) where T
function list_2_modaltrav(Z::FiniteZernikeBasis{T}, u::AbstractArray) where T
N, points = Z.N, Z.points
K = length(points) - 1
U = [zeros(T, N ÷ K, 2N-1) for i in 1:K]
Expand All @@ -359,7 +359,7 @@ function modaltravcellwise(Z::FiniteZernikeBasis{T}, u::AbstractArray) where T
return ModalTrav.(U)
end

function listtravcellwise(Z::FiniteZernikeBasis{T}, u::AbstractArray{Vector{T}}) where T
function modaltrav_2_list(Z::FiniteZernikeBasis{T}, u::AbstractArray{Vector{T}}) where T
N, points = Z.N, Z.points
K = length(points) - 1
Ns, _, _ = _getMs_ms_js(N)
Expand All @@ -374,4 +374,23 @@ function listtravcellwise(Z::FiniteZernikeBasis{T}, u::AbstractArray{Vector{T}})
append!(cs, [pad(vec(v'), blockedrange(Fill(K, Ns[i])))])
end
return cs
end

function adi_2_modaltrav(Z::FiniteZernikeBasis{T}, P::Legendre{T}, Us::AbstractArray, z::AbstractArray{T}) where T
N, points = Z.N, Z.points
K = length(points) - 1
Ns, _, _ = _getMs_ms_js(N)

Y = [zeros(T, sum(1:N), length(z)) for k in 1:K]
for i in 1:lastindex(z)
X = [zeros(T, Ns[1], 2N-1) for k in 1:K]
for k in 1:K
for n in 1:2N-1
us = Us[n][k:K:end, i]
X[k][1:lastindex(us), n] = us
end
Y[k][:,i] = ModalTrav(X[k])
end
end
return Y
end

0 comments on commit 35ed20a

Please sign in to comment.