Skip to content

Commit

Permalink
[DEL] remove generic stagger operations for vectors and fast stagger …
Browse files Browse the repository at this point in the history
…operations
  • Loading branch information
meudnaes committed Jun 24, 2024
1 parent e8a40af commit cdd524e
Showing 1 changed file with 0 additions and 152 deletions.
152 changes: 0 additions & 152 deletions src/stagger_operators.jl
Original file line number Diff line number Diff line change
@@ -1,155 +1,3 @@
# --- generic stagger operations for vectors

function up(vec::Vector{T}) where {T<:AbstractFloat}
n = size(vec)
if (n[1] == 1)
return vec
else
out = zeros(T, (n[1]+10))
out[5:n[1]+4] .= vec[:]
for i = 1:4
@inbounds out[5-i] = 2.0 .* out[5] .- out[5+i]
@inbounds out[n[1]+4+i] = 2.0 .* out[n[1]+4] .- out[n[1]+4-i]
end

c = 3.0/256.0
b = -25.0/256.0
a = 0.5-b-c

out = (a .* (circshift(out,-1) .+ circshift(out,0)) .+
b .* (circshift(out,-2) .+ circshift(out,1)) .+
c .* (circshift(out,-3) .+ circshift(out,2)) )

return out[5:n[1]+4]
end
end

function dup(vec::Vector{T}) where {T<:AbstractFloat}
n = size(vec)
if (n[1] == 1)
return vec
else
out = zeros(T, (n[1]+10))
out[5:n[1]+4] .= vec[:]
for i = 1:4
@inbounds out[5-i] = 2.0 .* out[5] .- out[5+i]
@inbounds out[n[1]+4+i] = 2.0 .* out[n[1]+4] .- out[n[1]+4-i]
end

d = -75.0 / 107520.0
c = 1029.0 / 107520.0
b = -8575.0 / 107520.0
a = 1. - 3 * b - 5 * c - 7 * d

out = (a .* (circshift(out,-1) .- circshift(out,0)) .+
b .* (circshift(out,-2) .- circshift(out,1)) .+
c .* (circshift(out,-3) .- circshift(out,2)) .+
d .* (circshift(out,-4) .- circshift(out,3)) )

return out[5:n[1]+4]
end
end

function dn(vec::Vector{T}) where {T<:AbstractFloat}
n = size(vec)
if (n[1] == 1)
return vec
else
out = zeros(T, (n[1]+10))
out[5:n[1]+4] .= vec[:]
for i = 1:4
@inbounds out[5-i] = 2.0 .* out[5] .- out[5+i]
@inbounds out[n[1]+4+i] = 2.0 .* out[n[1]+4] .- out[n[1]+4-i]
end

c = 3.0/256.0
b = -25.0/256.0
a = 0.5-b-c

out = (a .* (circshift(out, 0) .+ circshift(out,1)) .+
b .* (circshift(out,-1) .+ circshift(out,2)) .+
c .* (circshift(out,-2) .+ circshift(out,3)) )

return out[5:n[1]+4]
end
end

function ddn(vec::Vector{T}) where {T<:AbstractFloat}
n = size(vec)
if (n[1] == 1)
return vec
else
out = zeros(T, (n[1]+10))
out[5:n[1]+4] .= vec[:]
for i = 1:4
@inbounds out[5-i] = 2.0 .* out[5] .- out[5+i]
@inbounds out[n[1]+4+i] = 2.0 .* out[n[1]+4] .- out[n[1]+4-i]
end

d = -75.0 / 107520.0
c = 1029.0 / 107520.0
b = -8575.0 / 107520.0
a = 1. - 3 * b - 5 * c - 7 * d

out = (a .* (circshift(out, 0) .- circshift(out,1)) .+
b .* (circshift(out,-1) .- circshift(out,2)) .+
c .* (circshift(out,-2) .- circshift(out,3)) .+
d .* (circshift(out,-3) .- circshift(out,4)) )

return out[5:n[1]+4]
end
end

# --- fast stagger operations

function cdxdn(arr::Array{T,3}) where {T<:AbstractFloat}
return arr .- circshift(arr,[1,0,0])
end

function cdydn(arr::Array{T,3}) where {T<:AbstractFloat}
return arr .- circshift(arr,[0,1,0])
end

function cdzdn(arr::Array{T,3}) where {T<:AbstractFloat}
return arr .- circshift(arr,[0,0,1])
end

function cdxup(arr::Array{T,3}) where {T<:AbstractFloat}
return -(arr .- circshift(arr,[-1,0,0]))
end

function cdyup(arr::Array{T,3}) where {T<:AbstractFloat}
return -(arr .- circshift(arr,[0,-1,0]))
end

function cdzup(arr::Array{T,3}) where {T<:AbstractFloat}
return -(arr .- circshift(arr,[0,0,-1]))
end

function cdivup(varr::Vector{Array{T,3}}) where {T<:AbstractFloat}
return cdxup(varr[1]) .+ cdyup(varr[2]) .+ cdzup(varr[3])
end

function cdivdn(varr::Vector{Array{T,3}}) where {T<:AbstractFloat}
return cdxdn(varr[1]) .+ cdydn(varr[2]) .+ cdzdn(varr[3])
end

function cgrad_dn(arr::Array{T,3}) where {T<:AbstractFloat}
return [cdxdn(arr),cdydn(arr),cdzdn(arr)]
end

function cgrad_up(arr::Array{T,3}) where {T<:AbstractFloat}
return [cdxup(arr),cdyup(arr),cdzup(arr)]
end

function claplace_du(arr::Array{T,3}) where {T<:AbstractFloat}
return cdivdn(cgrad_up(arr))
end

function claplace_ud(arr::Array{T,3}) where {T<:AbstractFloat}
return cdivup(cgrad_dn(arr))
end

# --- stagger operations

"""
Expand Down

2 comments on commit cdd524e

@meudnaes
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register branch=develop

Release notes:

  • first release

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/109654

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" cdd524e19e9f7dd75f44d2fae840ba4e2454a525
git push origin v0.1.0

Please sign in to comment.