licenses
sequencelengths 1
3
| version
stringclasses 677
values | tree_hash
stringlengths 40
40
| path
stringclasses 1
value | type
stringclasses 2
values | size
stringlengths 2
8
| text
stringlengths 25
67.1M
| package_name
stringlengths 2
41
| repo
stringlengths 33
86
|
---|---|---|---|---|---|---|---|---|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 3502 | # The parenttype function and get_backend were adapted from ArrayInterfaceCore
# with the following license.
# MIT License
#
# Copyright (c) 2022 SciML
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
parent_type(::Type{T}) -> Type
Returns the parent array that type `T` wraps.
"""
parenttype(x) = parenttype(typeof(x))
parenttype(::Type{Symmetric{T,S}}) where {T,S} = S
parenttype(@nospecialize T::Type{<:PermutedDimsArray}) = fieldtype(T, :parent)
parenttype(@nospecialize T::Type{<:Adjoint}) = fieldtype(T, :parent)
parenttype(@nospecialize T::Type{<:Transpose}) = fieldtype(T, :parent)
parenttype(@nospecialize T::Type{<:SubArray}) = fieldtype(T, :parent)
parenttype(@nospecialize T::Type{<:Base.ReinterpretArray}) = fieldtype(T, :parent)
parenttype(@nospecialize T::Type{<:Base.ReshapedArray}) = fieldtype(T, :parent)
parenttype(@nospecialize T::Type{<:Union{Base.Slice,Base.IdentityUnitRange}}) =
fieldtype(T, :indices)
parenttype(::Type{Diagonal{T,V}}) where {T,V} = V
parenttype(T::Type) = T
"""
get_backend(::Type{T}) -> Type
Returns the KernelAbstractions backend to use with kernels where `A` is an
argument.
"""
get_backend(A) = get_backend(typeof(A))
get_backend(::Type) = nothing
get_backend(::Type{T}) where {T<:Array} = CPU(; static = true)
get_backend(::Type{T}) where {T<:AbstractArray} = get_backend(parenttype(T))
arraytype(A) = arraytype(typeof(A))
arraytype(::Type) = nothing
arraytype(::Type{T}) where {T<:Array} = Array
arraytype(::Type{T}) where {T<:AbstractArray} = arraytype(parenttype(T))
"""
pin(T::Type, A::Array)
Pins the host array A for copying to arrays of type T
"""
pin(::Type, A::Array) = A
"""
numbercontiguous(T, A; by = identity)
Renumbers `A` contiguously in an `Array{T}` and returns it. The function
`by` is a mapping for the elements of `A` used during element comparison,
similar to `sort`.
# Examples
```jldoctest
julia> Raven.numbercontiguous(Int32, [13, 4, 5, 1, 5])
5-element Vector{Int32}:
4
2
3
1
3
julia> Raven.numbercontiguous(Int32, [13, 4, 5, 1, 5]; by = x->-x)
5-element Vector{Int32}:
1
3
2
4
2
```
"""
function numbercontiguous(::Type{T}, A; by = identity) where {T}
p = sortperm(vec(A); by = by)
B = similar(A, T)
csum = one(T)
B[p[begin]] = csum
for i in Iterators.drop(eachindex(p), 1)
csum += by(A[p[i]]) != by(A[p[i-1]])
B[p[i]] = csum
end
return B
end
viewwithghosts(A::AbstractArray) = A
viewwithoutghosts(A::AbstractArray) = A
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 575 | abstract type AbstractCell{T,A<:AbstractArray,N} end
floattype(::Type{<:AbstractCell{T}}) where {T} = T
arraytype(::Type{<:AbstractCell{T,A}}) where {T,A} = A
Base.ndims(::Type{<:AbstractCell{T,A,N}}) where {T,A,N} = N
floattype(cell::AbstractCell) = floattype(typeof(cell))
arraytype(cell::AbstractCell) = arraytype(typeof(cell))
Base.ndims(cell::AbstractCell) = Base.ndims(typeof(cell))
Base.size(cell::AbstractCell, i::Integer) = size(cell)[i]
Base.length(cell::AbstractCell) = prod(size(cell))
Base.strides(cell::AbstractCell) = Base.size_to_strides(1, size(cell)...)
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 15609 | abstract type AbstractCoarseGrid end
abstract type AbstractBrickGrid <: AbstractCoarseGrid end
isextruded(::AbstractCoarseGrid) = false
columnlength(::AbstractCoarseGrid) = 1
struct MeshImportCoarseGrid{C,V,L,W,U,M} <: AbstractCoarseGrid
connectivity::C
vertices::V
cells::L
warp::W
unwarp::U
MeshImport::AbstractMeshImport
end
connectivity(g::MeshImportCoarseGrid) = g.connectivity
vertices(g::MeshImportCoarseGrid) = g.vertices
cells(g::MeshImportCoarseGrid) = g.cells
meshimport(g::MeshImportCoarseGrid) = g.MeshImport
function coarsegrid(meshfilename::String, warp = identity, unwarp = identity)
meshimport = abaqusmeshimport(meshfilename)
cg_temp = coarsegrid(meshimport.nodes, meshimport.connectivity)
vertices = Raven.vertices(cg_temp)
cells = Raven.cells(cg_temp)
if length(cells[begin]) == 4
conn = P4estTypes.Connectivity{4}(vertices, cells)
elseif length(cells[begin]) == 8
conn = P4estTypes.Connectivity{8}(vertices, cells)
end
C, V, L, W, U, M = typeof.([conn, vertices, cells, warp, unwarp, meshimport])
return MeshImportCoarseGrid{C,V,L,W,U,M}(
conn,
vertices,
cells,
warp,
unwarp,
meshimport,
)
end
struct CoarseGrid{C,V,L,W,U} <: AbstractCoarseGrid
connectivity::C
vertices::V
cells::L
warp::W
unwarp::U
end
warp(::AbstractCoarseGrid) = identity
unwarp(::AbstractCoarseGrid) = identity
connectivity(g::CoarseGrid) = g.connectivity
vertices(g::CoarseGrid) = g.vertices
cells(g::CoarseGrid) = g.cells
warp(g::CoarseGrid) = g.warp
unwarp(g::CoarseGrid) = g.unwarp
function CoarseGrid(
vertices::AbstractVector,
cells::AbstractVector{<:NTuple{X}},
warp = identity,
unwarp = identity,
) where {X}
conn = P4estTypes.Connectivity{X}(vertices, cells)
C, V, L, W, U = typeof.([conn, vertices, cells, warp, unwarp])
return CoarseGrid{C,V,L,W,U}(conn, vertices, cells, warp, unwarp)
end
function coarsegrid(vertices, cells, warp = identity, unwarp = identity)
return CoarseGrid(vertices, cells, warp, unwarp)
end
function cubeshellgrid(R::Real, r::Real)
@assert R > r "R (outer radius) must be greater that r (inner radius)"
T = promote_type(typeof(R), typeof(r))
vertices = zeros(SVector{3,T}, 16)
vertices[1] = SVector(+R, +R, -R)
vertices[2] = SVector(+R, -R, -R)
vertices[3] = SVector(+R, +R, +R)
vertices[4] = SVector(+R, -R, +R)
vertices[5] = SVector(-R, +R, -R)
vertices[6] = SVector(-R, -R, -R)
vertices[7] = SVector(-R, +R, +R)
vertices[8] = SVector(-R, -R, +R)
vertices[9] = SVector(+r, +r, -r)
vertices[10] = SVector(+r, -r, -r)
vertices[11] = SVector(+r, +r, +r)
vertices[12] = SVector(+r, -r, +r)
vertices[13] = SVector(-r, +r, -r)
vertices[14] = SVector(-r, -r, -r)
vertices[15] = SVector(-r, +r, +r)
vertices[16] = SVector(-r, -r, +r)
cells = [
(1, 2, 3, 4, 9, 10, 11, 12),
(2, 6, 4, 8, 10, 14, 12, 16),
(6, 5, 8, 7, 14, 13, 16, 15),
(5, 1, 7, 3, 13, 9, 15, 11),
(3, 4, 7, 8, 11, 12, 15, 16),
(1, 2, 5, 6, 9, 10, 13, 14),
]
function cubespherewarp(point)
# Put the points in reverse magnitude order
p = sortperm(abs.(point))
point = point[p]
# Convert to angles
ξ = π * point[2] / 4point[3]
η = π * point[1] / 4point[3]
# Compute the ratios
y_x = tan(ξ)
z_x = tan(η)
# Compute the new points
x = point[3] / hypot(one(y_x), y_x, z_x)
y = x * y_x
z = x * z_x
# Compute the new points and unpermute
point = SVector(z, y, x)[sortperm(p)]
return point
end
function cubesphereunwarp(point)
# Put the points in reverse magnitude order
p = sortperm(abs.(point))
point = point[p]
# Convert to angles
ξ = 4atan(point[2] / point[3]) / π
η = 4atan(point[1] / point[3]) / π
R = sign(point[3]) * hypot(point...)
x = R
y = R * ξ
z = R * η
# Compute the new points and unpermute
point = SVector(z, y, x)[sortperm(p)]
return point
end
return coarsegrid(vertices, cells, cubespherewarp, cubesphereunwarp)
end
"""
function cubeshell2dgrid(R::Real)
This function will construct the CoarseGrid of a cube shell of radius R.
A cube shell is a 2D connectivity.
"""
function cubeshell2dgrid(R::Real)
vertices = zeros(SVector{3,typeof(R)}, 8)
vertices[1] = SVector(+R, +R, -R)
vertices[2] = SVector(+R, -R, -R)
vertices[3] = SVector(+R, +R, +R)
vertices[4] = SVector(+R, -R, +R)
vertices[5] = SVector(-R, +R, -R)
vertices[6] = SVector(-R, -R, -R)
vertices[7] = SVector(-R, +R, +R)
vertices[8] = SVector(-R, -R, +R)
cells =
[(1, 2, 3, 4), (4, 8, 2, 6), (6, 2, 5, 1), (1, 5, 3, 7), (7, 3, 8, 4), (5, 6, 7, 8)]
function cubespherewarp(point)
# Put the points in reverse magnitude order
p = sortperm(abs.(point))
point = point[p]
# Convert to angles
ξ = π * point[2] / 4point[3]
η = π * point[1] / 4point[3]
# Compute the ratios
y_x = tan(ξ)
z_x = tan(η)
# Compute the new points
x = point[3] / hypot(one(y_x), y_x, z_x)
y = x * y_x
z = x * z_x
# Compute the new points and unpermute
point = SVector(z, y, x)[sortperm(p)]
return point
end
function cubesphereunwarp(point)
# Put the points in reverse magnitude order
p = sortperm(abs.(point))
point = point[p]
# Convert to angles
ξ = 4atan(point[2] / point[3]) / π
η = 4atan(point[1] / point[3]) / π
R = sign(point[3]) * hypot(point...)
x = R
y = R * ξ
z = R * η
# Compute the new points and unpermute
point = SVector(z, y, x)[sortperm(p)]
return point
end
return coarsegrid(vertices, cells, cubespherewarp, cubesphereunwarp)
end
struct BrickGrid{T,N,C,D,P} <: AbstractBrickGrid
connectivity::C
coordinates::D
isperiodic::P
end
Base.ndims(::BrickGrid{T,N}) where {T,N} = N
connectivity(g::BrickGrid) = g.connectivity
coordinates(g::BrickGrid) = g.coordinates
isperiodic(g::BrickGrid) = g.isperiodic
function vertices(g::BrickGrid{T,2}) where {T}
conn = connectivity(g)
coords = coordinates(g)
indices =
GC.@preserve conn convert.(Tuple{Int,Int,Int}, P4estTypes.unsafe_vertices(conn))
verts = [SVector(coords[1][i[1]+1], coords[2][i[2]+1]) for i in indices]
return verts
end
function vertices(g::BrickGrid{T,3}) where {T}
conn = connectivity(g)
coords = coordinates(g)
indices =
GC.@preserve conn convert.(Tuple{Int,Int,Int}, P4estTypes.unsafe_vertices(conn))
verts =
[SVector(coords[1][i[1]+1], coords[2][i[2]+1], coords[3][i[3]+1]) for i in indices]
return verts
end
function cells(g::BrickGrid)
conn = connectivity(g)
GC.@preserve conn map.(x -> x + 1, P4estTypes.unsafe_trees(conn))
end
function BrickGrid{T}(coordinates, p) where {T}
N = length(coordinates)
n = length.(coordinates) .- 0x1
connectivity = P4estTypes.brick(n, p)
return BrickGrid{T,N,typeof(connectivity),typeof(coordinates),typeof(p)}(
connectivity,
coordinates,
p,
)
end
function brick(::Type{T}, coordinates, p) where {T}
return BrickGrid{T}(coordinates, p)
end
function brick(coordinates::Tuple{<:Any,<:Any}, p::Tuple{Bool,Bool} = (false, false))
T = promote_type(eltype.(coordinates)...)
return brick(T, coordinates, p)
end
function brick(
coordinates::Tuple{<:Any,<:Any,<:Any},
p::Tuple{Bool,Bool,Bool} = (false, false, false),
)
T = promote_type(eltype.(coordinates)...)
return brick(T, coordinates, p)
end
function brick(T::Type, n::Tuple{Integer,Integer}, p::Tuple{Bool,Bool} = (false, false))
coordinates = (zero(T):n[1], zero(T):n[2])
return brick(T, coordinates, p)
end
function brick(
T::Type,
n::Tuple{Integer,Integer,Integer},
p::Tuple{Bool,Bool,Bool} = (false, false, false),
)
coordinates = (zero(T):n[1], zero(T):n[2], zero(T):n[3])
return brick(T, coordinates, p)
end
function brick(n::Tuple{Integer,Integer}, p::Tuple{Bool,Bool} = (false, false))
return brick(Float64, n, p)
end
function brick(
n::Tuple{Integer,Integer,Integer},
p::Tuple{Bool,Bool,Bool} = (false, false, false),
)
return brick(Float64, n, p)
end
brick(a::AbstractArray, b::AbstractArray, p::Bool = false, q::Bool = false) =
brick((a, b), (p, q))
brick(l::Integer, m::Integer, p::Bool = false, q::Bool = false) =
brick(Float64, (l, m), (p, q))
brick(T::Type, l::Integer, m::Integer, p::Bool = false, q::Bool = false) =
brick(T, (l, m), (p, q))
function brick(
a::AbstractArray,
b::AbstractArray,
c::AbstractArray,
p::Bool = false,
q::Bool = false,
r::Bool = false,
)
return brick((a, b, c), (p, q, r))
end
function brick(
l::Integer,
m::Integer,
n::Integer,
p::Bool = false,
q::Bool = false,
r::Bool = false,
)
return brick(Float64, (l, m, n), (p, q, r))
end
function brick(
T::Type,
l::Integer,
m::Integer,
n::Integer,
p::Bool = false,
q::Bool = false,
r::Bool = false,
)
return brick(T, (l, m, n), (p, q, r))
end
struct ExtrudedBrickGrid{T,N,B,E} <: AbstractBrickGrid
basegrid::B
coordinates::E
isperiodic::Bool
end
function ExtrudedBrickGrid(coarsegrid::BrickGrid{T,N}, coordinates, isperiodic) where {T,N}
B = typeof(coarsegrid)
E = typeof(coordinates)
return ExtrudedBrickGrid{T,N + 1,B,E}(coarsegrid, coordinates, isperiodic)
end
function extrude(coarsegrid::BrickGrid, coordinates; isperiodic = false)
return ExtrudedBrickGrid(coarsegrid, coordinates, isperiodic)
end
function extrude(coarsegrid::BrickGrid{T}, n::Integer; isperiodic = false) where {T}
coordinates = (zero(T):n)
return extrude(coarsegrid, coordinates; isperiodic)
end
isextruded(::ExtrudedBrickGrid) = true
columnlength(g::ExtrudedBrickGrid) = length(g.coordinates) - 0x1
Base.ndims(::ExtrudedBrickGrid{T,N}) where {T,N} = N
Base.parent(g::ExtrudedBrickGrid) = g.basegrid
connectivity(g::ExtrudedBrickGrid) = connectivity(parent(g))
coordinates(g::ExtrudedBrickGrid) = (coordinates(parent(g))..., g.coordinates)
isperiodic(g::ExtrudedBrickGrid) = (isperiodic(parent(g))..., g.isperiodic)
function vertices(g::ExtrudedBrickGrid{T,3}) where {T}
conn = connectivity(g)
coords = coordinates(g)
indices =
GC.@preserve conn convert.(Tuple{Int,Int,Int}, P4estTypes.unsafe_vertices(conn))
verts = vec([
SVector(coords[1][i[1]+1], coords[2][i[2]+1], coords[3][j]) for
j in eachindex(coords[3]), i in indices
])
return verts
end
function cells(g::ExtrudedBrickGrid{T,3}) where {T}
conn = connectivity(g)
coords = coordinates(g)
GC.@preserve conn begin
trees = P4estTypes.unsafe_trees(conn)
I = eltype(eltype(trees))
Nextrude = I(length(coords[3]) - 1)
c = Vector{NTuple{8,I}}(undef, length(trees) * Nextrude)
for i = 1:length(trees)
tree = trees[i] .* (Nextrude .+ 0x1)
offset = 0x1
for j = 1:Nextrude
c[(i-0x1)*Nextrude+j] = ((tree .+ offset)..., (tree .+ offset .+ 0x1)...)
offset = offset + 0x1
end
end
end
return c
end
function Base.show(io::IO, b::BrickGrid{T,N}) where {T,N}
print(io, "Raven.BrickGrid{$T, $N}(")
Base.show(io, coordinates(b))
print(io, ", ")
Base.show(io, isperiodic(b))
print(io, ")")
return
end
function Base.showarg(io::IO, b::BrickGrid{T,N}, toplevel) where {T,N}
!toplevel && print(io, "::")
print(io, "Raven.BrickGrid{$T, $N}")
toplevel && print(io, " with periodicity $(isperiodic(b))")
return
end
function Base.summary(io::IO, b::BrickGrid)
n = length.(coordinates(b)) .- 0x1
d = Base.dims2string(n)
print(io, "$d ")
Base.showarg(io, b, true)
end
function Base.show(io::IO, b::ExtrudedBrickGrid{T,N}) where {T,N}
print(io, "Raven.ExtrudedBrickGrid{$T, $N}(")
Base.show(io, b.basegrid)
print(io, ", ")
Base.show(io, b.coordinates)
print(io, ", ")
Base.show(io, b.isperiodic)
print(io, ")")
return
end
function Base.showarg(io::IO, b::ExtrudedBrickGrid{T,N}, toplevel) where {T,N}
!toplevel && print(io, "::")
print(io, "Raven.ExtrudedBrickGrid{$T, $N}")
if toplevel
print(io, " with basegrid ")
Base.showarg(io, b.basegrid, toplevel = true)
end
return
end
function Base.summary(io::IO, b::ExtrudedBrickGrid)
n = length.(coordinates(b)) .- 0x1
d = Base.dims2string(n)
print(io, "$d ")
Base.showarg(io, b, true)
end
function Base.show(io::IO, c::CoarseGrid)
print(io, "Raven.CoarseGrid(")
Base.show(io, vertices(c))
print(io, ", ")
Base.show(io, cells(c))
print(io, ", ")
Base.show(io, warp(c))
print(io, ", ")
Base.show(io, unwarp(c))
print(io, ")")
return
end
function Base.showarg(io::IO, ::CoarseGrid, toplevel)
!toplevel && print(io, "::")
print(io, "Raven.CoarseGrid")
return
end
function Base.summary(io::IO, c::CoarseGrid)
n = length(cells(c))
w = warp(c) === identity ? "unwarped" : "warped"
print(io, "$n cell $w ")
Base.showarg(io, c, true)
end
@recipe function f(coarsegrid::AbstractBrickGrid)
cs = cells(coarsegrid)
vs = vertices(coarsegrid)
xlims = extrema(getindex.(vs, 1))
ylims = extrema(getindex.(vs, 2))
zlims = try
extrema(getindex.(vs, 3))
catch
(zero(eltype(xlims)), zero(eltype(xlims)))
end
isconstz = zlims[1] == zlims[2]
xlabel --> "x"
ylabel --> "y"
zlabel --> "z"
aspect_ratio --> :equal
legend --> false
grid --> false
@series begin
seriestype --> :path
linecolor --> :gray
linewidth --> 1
x = []
y = []
z = []
if length(first(cs)) == 4
for c in cs
for i in (1, 2, 4, 3, 1)
xs = vs[c[i]]
push!(x, xs[1])
push!(y, xs[2])
if !isconstz
push!(z, xs[3])
end
end
push!(x, NaN)
push!(y, NaN)
if !isconstz
push!(z, NaN)
end
end
elseif length(first(cs)) == 8
for c in cs
for j in (0, 4)
for i in (1 + j, 2 + j, 4 + j, 3 + j, 1 + j)
xi, yi, zi = vs[c[i]]
push!(x, xi)
push!(y, yi)
push!(z, zi)
end
push!(x, NaN)
push!(y, NaN)
push!(z, NaN)
end
for j = 0:3
for i in (1 + j, 5 + j)
xi, yi, zi = vs[c[i]]
push!(x, xi)
push!(y, yi)
push!(z, zi)
end
push!(x, NaN)
push!(y, NaN)
push!(z, NaN)
end
end
end
if isconstz
x, y
else
x, y, z
end
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 10604 | const COMM_MANAGERS = WeakRef[]
struct CommPattern{AT,RI,RR,RRI,SI,SR,SRI}
recvindices::RI
recvranks::RR
recvrankindices::RRI
sendindices::SI
sendranks::SR
sendrankindices::SRI
end
function CommPattern{AT}(
recvindices::RI,
recvranks::RR,
recvrankindices::RRI,
sendindices::SI,
sendranks::SR,
sendrankindices::SRI,
) where {AT,RI,RR,RRI,SI,SR,SRI}
return CommPattern{AT,RI,RR,RRI,SI,SR,SRI}(
recvindices,
recvranks,
recvrankindices,
sendindices,
sendranks,
sendrankindices,
)
end
arraytype(::CommPattern{AT}) where {AT} = AT
function Adapt.adapt_structure(to, obj::CommPattern)
CommPattern{to}(
adapt(to, obj.recvindices),
obj.recvranks,
obj.recvrankindices,
adapt(to, obj.sendindices),
obj.sendranks,
obj.sendrankindices,
)
end
function expand(r::UnitRange, factor)
a = (first(r) - 0x1) * factor + 0x1
b = last(r) * factor
return a:b
end
@kernel function expand_vector_kernel!(dest, src, factor, offset)
i = @index(Global)
@inbounds begin
b, a = fldmod1(src[i], offset)
for f = 1:factor
dest[f+(i-0x1)*factor] = a + (f - 0x1) * offset + (b - 0x1) * factor * offset
end
end
end
function expand(v::AbstractVector, factor, offset = 1)
w = similar(v, length(v) * factor)
expand_vector_kernel!(get_backend(w), 256)(w, v, factor, offset, ndrange = length(v))
return w
end
"""
expand(pattern::CommPattern, factor, offset)
Create a new `CommPattern` where the `recvindices` and `sendindices` are
expanded in size by `factor` entries and offset by `offset`.
For example, to expand a `nodecommpattern` to communicate all fields of an
array that is indexed via `(node, field, element)` use
`expand(nodecommpattern(grid), nfields, nnodes)`.
"""
function expand(pattern::CommPattern{AT}, factor, offset = 1) where {AT}
recvindices = expand(pattern.recvindices, factor, offset)
recvranks = copy(pattern.recvranks)
recvrankindices = similar(pattern.recvrankindices)
@assert eltype(recvrankindices) <: UnitRange
for i in eachindex(recvrankindices)
recvrankindices[i] = expand(pattern.recvrankindices[i], factor)
end
sendindices = expand(pattern.sendindices, factor, offset)
sendranks = copy(pattern.sendranks)
sendrankindices = similar(pattern.sendrankindices)
@assert eltype(sendrankindices) <: UnitRange
for i in eachindex(sendrankindices)
sendrankindices[i] = expand(pattern.sendrankindices[i], factor)
end
return CommPattern{AT}(
recvindices,
recvranks,
recvrankindices,
sendindices,
sendranks,
sendrankindices,
)
end
abstract type AbstractCommManager end
mutable struct CommManagerBuffered{CP,RBD,RB,SBD,SB} <: AbstractCommManager
comm::MPI.Comm
pattern::CP
tag::Cint
recvbufferdevice::RBD
recvbuffers::RB
recvrequests::MPI.UnsafeMultiRequest
sendbufferdevice::SBD
sendbuffers::SB
sendrequests::MPI.UnsafeMultiRequest
end
mutable struct CommManagerTripleBuffered{CP,RBC,RBH,RBD,RB,RS,SBC,SBH,SBD,SB,SS} <:
AbstractCommManager
comm::MPI.Comm
pattern::CP
tag::Cint
recvbuffercomm::RBC
recvbufferhost::RBH
recvbufferdevice::RBD
recvbufferes::RB
recvrequests::MPI.UnsafeMultiRequest
recvstream::RS
sendbuffercomm::SBC
sendbufferhost::SBH
sendbufferdevice::SBD
sendbuffers::SB
sendrequests::MPI.UnsafeMultiRequest
sendstream::SS
end
function _get_mpi_buffers(buffer, rankindices)
# Hack to make the element type of the buffer arrays concrete
@assert eltype(rankindices) == UnitRange{eltype(eltype(rankindices))}
T = typeof(view(buffer, 1:length(rankindices)))
bufs = Array{MPI.Buffer{T}}(undef, length(rankindices))
for i in eachindex(rankindices)
bufs[i] = MPI.Buffer(view(buffer, rankindices[i]))
end
return bufs
end
usetriplebuffer(::Type{Array}) = false
function commmanager(T, pattern; kwargs...)
AT = arraytype(pattern)
triplebuffer = usetriplebuffer(AT)
commmanager(T, pattern, Val(triplebuffer); kwargs...)
end
function commmanager(
T,
pattern,
::Val{triplebuffer};
comm = MPI.COMM_WORLD,
tag = 0,
) where {triplebuffer}
AT = arraytype(pattern)
if tag < 0 || tag > 32767
throw(ArgumentError("The tag=$tag is not in the valid range 0:32767"))
end
ctag = convert(Cint, tag)
recvsize = size(pattern.recvindices)
sendsize = size(pattern.sendindices)
recvbufferdevice = AT{T}(undef, recvsize)
sendbufferdevice = AT{T}(undef, sendsize)
recvrequests = MPI.UnsafeMultiRequest(length(pattern.recvranks))
sendrequests = MPI.UnsafeMultiRequest(length(pattern.sendranks))
if triplebuffer
recvbufferhost = Array{T}(undef, recvsize)
sendbufferhost = Array{T}(undef, sendsize)
recvbuffercomm = similar(recvbufferhost)
sendbuffercomm = similar(sendbufferhost)
else
recvbuffercomm = recvbufferdevice
sendbuffercomm = sendbufferdevice
end
recvbuffers = _get_mpi_buffers(recvbuffercomm, pattern.recvrankindices)
sendbuffers = _get_mpi_buffers(sendbuffercomm, pattern.sendrankindices)
for i in eachindex(pattern.recvranks)
#@info "Recv" pattern.recvranks[i] pattern.recvrankindices[i] recvbuffers[i]
MPI.Recv_init(
recvbuffers[i],
comm,
recvrequests[i];
source = pattern.recvranks[i],
tag = ctag,
)
end
for i in eachindex(pattern.sendranks)
#@info "Send" pattern.sendranks[i] pattern.sendrankindices[i] sendbuffers[i]
MPI.Send_init(
sendbuffers[i],
comm,
sendrequests[i];
dest = pattern.sendranks[i],
tag = ctag,
)
end
cm = if triplebuffer
backend = get_backend(arraytype(pattern))
recvstream = Stream(backend)
sendstream = Stream(backend)
CommManagerTripleBuffered(
comm,
pattern,
ctag,
recvbuffercomm,
recvbufferhost,
recvbufferdevice,
recvbuffers,
recvrequests,
recvstream,
sendbuffercomm,
sendbufferhost,
sendbufferdevice,
sendbuffers,
sendrequests,
sendstream,
)
else
CommManagerBuffered(
comm,
pattern,
ctag,
recvbufferdevice,
recvbuffers,
recvrequests,
sendbufferdevice,
sendbuffers,
sendrequests,
)
end
finalizer(cm) do cm
for reqs in (cm.recvrequests, cm.sendrequests)
for req in reqs
MPI.free(req)
end
end
end
push!(COMM_MANAGERS, WeakRef(cm))
return cm
end
get_backend(cm::AbstractCommManager) = get_backend(arraytype(cm.pattern))
@kernel function setbuffer_kernel!(buffer, src, Is)
i = @index(Global)
@inbounds buffer[i] = src[Is[i]]
end
function setbuffer!(buffer, src, Is)
axes(buffer) == axes(Is) || Broadcast.throwdm(axes(buffer), axes(Is))
isempty(buffer) && return
setbuffer_kernel!(get_backend(buffer), 256)(buffer, src, Is, ndrange = length(buffer))
return
end
@kernel function getbuffer_kernel!(dest, buffer, Is)
i = @index(Global)
@inbounds dest[Is[i]] = buffer[i]
end
function getbuffer!(dest, buffer, Is)
axes(buffer) == axes(Is) || Broadcast.throwdm(axes(buffer), axes(Is))
isempty(buffer) && return
getbuffer_kernel!(get_backend(buffer), 256)(dest, buffer, Is, ndrange = length(buffer))
return
end
function progress(::AbstractCommManager)
MPI.Iprobe(MPI.ANY_SOURCE, MPI.ANY_TAG, MPI.COMM_WORLD)
return
end
function start!(A, cm::CommManagerBuffered)
if !isempty(cm.sendrequests)
setbuffer!(cm.sendbufferdevice, A, cm.pattern.sendindices)
end
if !isempty(cm.sendrequests) || !isempty(cm.recvrequests)
KernelAbstractions.synchronize(get_backend(cm))
end
if !isempty(cm.recvrequests)
MPI.Startall(cm.recvrequests)
end
if !isempty(cm.sendrequests)
MPI.Startall(cm.sendrequests)
end
return
end
function finish!(A, cm::CommManagerBuffered)
if !isempty(cm.recvrequests)
MPI.Waitall(cm.recvrequests)
end
if !isempty(cm.sendrequests)
MPI.Waitall(cm.sendrequests)
end
if !isempty(cm.recvrequests)
A = viewwithghosts(A)
getbuffer!(A, cm.recvbufferdevice, cm.pattern.recvindices)
end
return
end
function start!(A, cm::CommManagerTripleBuffered)
# We use two host buffers each for send and receive. We do this to have
# one buffer pinned by the device stack and one pinned for the network
# interface. We see deadlocks if two separate buffers are not used. See,
# <https://developer.nvidia.com/blog/introduction-cuda-aware-mpi/> for more
# details.
if !isempty(cm.recvrequests)
MPI.Startall(cm.recvrequests)
end
if !isempty(cm.sendrequests)
backend = get_backend(cm)
# Wait for kernels on the main stream to finish before launching
# kernels on on different streams.
KernelAbstractions.synchronize(backend)
stream!(backend, cm.sendstream) do
setbuffer!(cm.sendbufferdevice, A, cm.pattern.sendindices)
KernelAbstractions.copyto!(backend, cm.sendbufferhost, cm.sendbufferdevice)
end
end
return
end
function finish!(A, cm::CommManagerTripleBuffered)
if !isempty(cm.sendrequests)
backend = get_backend(cm)
synchronize(backend, cm.sendstream)
copyto!(cm.sendbuffercomm, cm.sendbufferhost)
MPI.Startall(cm.sendrequests)
end
if !isempty(cm.recvrequests)
MPI.Waitall(cm.recvrequests)
copyto!(cm.recvbufferhost, cm.recvbuffercomm)
stream!(backend, cm.recvstream) do
KernelAbstractions.copyto!(backend, cm.recvbufferdevice, cm.recvbufferhost)
getbuffer!(viewwithghosts(A), cm.recvbufferdevice, cm.pattern.recvindices)
KernelAbstractions.synchronize(backend)
end
end
if !isempty(cm.sendrequests)
MPI.Waitall(cm.sendrequests)
end
return
end
function share!(A, cm::AbstractCommManager)
start!(A, cm)
progress(cm)
finish!(A, cm)
return
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 305 | struct Eye{T} <: AbstractArray{T,2}
N::Int
end
Base.size(eye::Eye{T}) where {T} = (eye.N, eye.N)
Base.IndexStyle(::Eye) = IndexCartesian()
@inline function Base.getindex(eye::Eye{T}, I::Vararg{Int,2}) where {T}
@boundscheck checkbounds(eye, I...)
return (I[1] == I[2]) ? one(T) : zero(T)
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 5637 | function decode(facecode::UInt8)
# Numbering of quadrant in facecode
# 2-----3-----3
# | |
# |y |
# 0^ 1
# || |
# |+-->x |
# 0-----2-----1
corner = facecode & 0x3
xfaceishanging = (facecode >> 0x2) & 0x1 == 0x1
yfaceishanging = (facecode >> 0x3) & 0x1 == 0x1
hangingface = (
((corner == 0x0) && xfaceishanging) ? 0x1 :
((corner == 0x2) && xfaceishanging) ? 0x2 : 0x0,
((corner == 0x1) && xfaceishanging) ? 0x1 :
((corner == 0x3) && xfaceishanging) ? 0x2 : 0x0,
((corner == 0x0) && yfaceishanging) ? 0x1 :
((corner == 0x1) && yfaceishanging) ? 0x2 : 0x0,
((corner == 0x2) && yfaceishanging) ? 0x1 :
((corner == 0x3) && yfaceishanging) ? 0x2 : 0x0,
)
return hangingface
end
function decode(facecode::UInt16)
# Numbering of octant in facecode
# 6-----3-----7
# | |
# |z |
# 10^ 3 11
# || |
# |+-->x |
# 6----10-----2-----1-----3----11-----7-----3-----6
# | | | | |
# | y|y |y | y|
# 6 0 ^4^ 4 5^ 1 7 5 ^6
# | ||| || | ||
# | z<--+|+-->x |+-->z | x<--+|
# 4-----8-----0-----0-----1-----9-----5-----2-----4
# |+-->x |
# || |
# 8v 2 9
# |z |
# | |
# 4-----2-----5
xfaceishanging = (facecode >> 0x3) & 0x1 == 0x1
yfaceishanging = (facecode >> 0x4) & 0x1 == 0x1
zfaceishanging = (facecode >> 0x5) & 0x1 == 0x1
xedgeishanging = (facecode >> 0x6) & 0x1 == 0x1
yedgeishanging = (facecode >> 0x7) & 0x1 == 0x1
zedgeishanging = (facecode >> 0x8) & 0x1 == 0x1
corner = facecode & 0x0007
xcornershift = (corner >> 0x0) & 0x1 == 0x1
ycornershift = (corner >> 0x1) & 0x1 == 0x1
zcornershift = (corner >> 0x2) & 0x1 == 0x1
hangingface = (
((corner === 0x0000) && xfaceishanging) ? 0x1 :
((corner === 0x0002) && xfaceishanging) ? 0x2 :
((corner === 0x0004) && xfaceishanging) ? 0x3 :
((corner === 0x0006) && xfaceishanging) ? 0x4 : 0x0,
((corner === 0x0001) && xfaceishanging) ? 0x1 :
((corner === 0x0003) && xfaceishanging) ? 0x2 :
((corner === 0x0005) && xfaceishanging) ? 0x3 :
((corner === 0x0007) && xfaceishanging) ? 0x4 : 0x0,
((corner === 0x0000) && yfaceishanging) ? 0x1 :
((corner === 0x0001) && yfaceishanging) ? 0x2 :
((corner === 0x0004) && yfaceishanging) ? 0x3 :
((corner === 0x0005) && yfaceishanging) ? 0x4 : 0x0,
((corner === 0x0002) && yfaceishanging) ? 0x1 :
((corner === 0x0003) && yfaceishanging) ? 0x2 :
((corner === 0x0006) && yfaceishanging) ? 0x3 :
((corner === 0x0007) && yfaceishanging) ? 0x4 : 0x0,
((corner === 0x0000) && zfaceishanging) ? 0x1 :
((corner === 0x0001) && zfaceishanging) ? 0x2 :
((corner === 0x0002) && zfaceishanging) ? 0x3 :
((corner === 0x0003) && zfaceishanging) ? 0x4 : 0x0,
((corner === 0x0004) && zfaceishanging) ? 0x1 :
((corner === 0x0005) && zfaceishanging) ? 0x2 :
((corner === 0x0006) && zfaceishanging) ? 0x3 :
((corner === 0x0007) && zfaceishanging) ? 0x4 : 0x0,
)
onhangingface = (
hangingface[3] > 0x0 || hangingface[5] > 0x0,
hangingface[4] > 0x0 || hangingface[5] > 0x0,
hangingface[3] > 0x0 || hangingface[6] > 0x0,
hangingface[4] > 0x0 || hangingface[6] > 0x0,
hangingface[1] > 0x0 || hangingface[5] > 0x0,
hangingface[2] > 0x0 || hangingface[5] > 0x0,
hangingface[1] > 0x0 || hangingface[6] > 0x0,
hangingface[2] > 0x0 || hangingface[6] > 0x0,
hangingface[1] > 0x0 || hangingface[3] > 0x0,
hangingface[2] > 0x0 || hangingface[3] > 0x0,
hangingface[1] > 0x0 || hangingface[4] > 0x0,
hangingface[2] > 0x0 || hangingface[4] > 0x0,
)
onhangingedge = (
xedgeishanging && (corner === 0x0000 || corner === 0x0001),
xedgeishanging && (corner === 0x0002 || corner === 0x0003),
xedgeishanging && (corner === 0x0004 || corner === 0x0005),
xedgeishanging && (corner === 0x0006 || corner === 0x0007),
yedgeishanging && (corner === 0x0000 || corner === 0x0002),
yedgeishanging && (corner === 0x0001 || corner === 0x0003),
yedgeishanging && (corner === 0x0004 || corner === 0x0006),
yedgeishanging && (corner === 0x0005 || corner === 0x0007),
zedgeishanging && (corner === 0x0000 || corner === 0x0004),
zedgeishanging && (corner === 0x0001 || corner === 0x0005),
zedgeishanging && (corner === 0x0002 || corner === 0x0006),
zedgeishanging && (corner === 0x0003 || corner === 0x0007),
)
shift = (
xcornershift,
xcornershift,
xcornershift,
xcornershift,
ycornershift,
ycornershift,
ycornershift,
ycornershift,
zcornershift,
zcornershift,
zcornershift,
zcornershift,
)
hangingedge = ntuple(Val(12)) do n
onhangingedge[n] ? ((onhangingface[n] ? 0x3 : 0x1) + shift[n]) :
(onhangingface[n] ? 0x5 : 0x0)
end
return (hangingface, hangingedge)
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 5431 | abstract type AbstractMeshImport end
struct AbaqusMeshImport{N,C,F,I,B,D} <: AbstractMeshImport
nodes::Any
connectivity::Any
face_iscurved::Any
face_degree::Int
face_interpolation::Any
type_boundary::Any
type_boundary_map::Any
end
dimensions(a::AbaqusMeshImport) = length(a.nodes[1])
interpolation_degree(a::AbaqusMeshImport) = a.face_degree
interpolation(a::AbaqusMeshImport) = a.face_interpolation
interpolationdegree(a::AbaqusMeshImport) = a.face_degree
function abaqusmeshimport(
nodes,
connectivity,
face_iscurved,
face_degree,
face_interpolation,
type_boundary,
type_boundary_map,
)
N, C, F, I, B, D =
typeof.([
nodes,
connectivity,
face_iscurved,
face_degree,
face_interpolation,
type_boundary,
type_boundary_map,
])
return AbaqusMeshImport{N,C,F,I,B,D}(
nodes,
connectivity,
face_iscurved,
face_degree,
face_interpolation,
type_boundary,
type_boundary_map,
)
end
"""
function AbaqusMeshImport(filename::String)
This function will parse an abaqus (.inp) file of 2D or 3D mesh data.
Such meshes are generated with HOHQMesh.jl.
"""
function abaqusmeshimport(filename::String)
@assert isfile(filename) "File does not exist"
file = open(filename)
filelines = readlines(file)
# indicate the line with the section header
nodes_linenum = findline("*NODE", filelines)
elements_linenum = findline("*ELEMENT", filelines)
curvature_linenum = findline("HOHQMesh boundary information", filelines)
node_count = elements_linenum - nodes_linenum - 1
element_count = curvature_linenum - elements_linenum - 1
type_boundary_linenum = length(filelines) - element_count + 1
@assert 0 < nodes_linenum < elements_linenum < curvature_linenum "Improper abaqus file"
@assert findline("mesh polynomial degree", filelines) == curvature_linenum + 1 "Missing Poly degree"
# degree of interpolant along curved edges.
face_degree = parse(Int8, split(filelines[curvature_linenum+1], " = ")[2])
type = split(filelines[elements_linenum], r", [a-zA-Z]*=")[2]
# CPS4 are 2D quads C3D8 are 3D hexs
@assert type == "CPS4" || type == "C3D8"
dims = (type == "CPS4") ? 2 : 3
FT = Float64
IT = Int
# Extract node coords
nodes = Vector{SVector{dims,FT}}(undef, node_count)
for nodeline in filelines[nodes_linenum+1:elements_linenum-1]
temp_data = split(nodeline, ", ")
nodenumber = parse(IT, temp_data[1])
nodes[nodenumber] = SVector{dims,FT}(parse.(FT, temp_data[2:dims+1]))
end
# Extract element coords
# HOHQMesh uses right hand rule for node numbering. We need Z order perm will reorder
nodes_per_element = (dims == 2) ? 4 : 8
perm = (dims == 2) ? [1, 2, 4, 3] : [1, 2, 4, 3, 5, 6, 8, 7]
connectivity = Vector{NTuple{nodes_per_element,IT}}(undef, element_count)
for elementline in filelines[elements_linenum+1:curvature_linenum-1]
temp_data = split(elementline, ", ")
elementnumber = parse(IT, temp_data[1])
connectivity[elementnumber] = Tuple(parse.(IT, temp_data[2:end]))[perm]
end
# Extract which edges are curved
scanningidx = curvature_linenum + 2
faces_per_element = (dims == 2) ? 4 : 6
face_iscurved = Vector{NTuple{faces_per_element,IT}}(undef, element_count)
for i = 1:element_count
scanningidx += 1
face_iscurved[i] = Tuple(parse.(IT, split(filelines[scanningidx])[2:end]))
scanningidx += sum(face_iscurved[i]) * (face_degree + 1)^(dims - 1) + 1
end
# Extract interpolation nodes of curved edges
face_interpolation = Vector{NTuple{dims,Float64}}(
undef,
sum(sum.(face_iscurved)) * (face_degree + 1)^(dims - 1),
)
scanningidx = curvature_linenum + 2
idx = 1
for i = 1:element_count
scanningidx += 2
for node = 1:(sum(face_iscurved[i])*(face_degree+1)^(dims-1))
face_interpolation[idx] =
Tuple(parse.(FT, split(filelines[scanningidx])[2:dims+1]))
idx += 1
scanningidx += 1
end
end
# Extract type_boundary data
type_boundary = Vector{NTuple{faces_per_element,Int64}}(undef, element_count)
# We will use integers to label boundary conditions on each element face for GPU compatibility.
# HOHQMesh uses strings so here we create the mapping. zero corresponds an face which is not along a boundary
# as does "---" with HOHQMesh
temp_key = Vector{String}(["---"])
for line in filelines[type_boundary_linenum:end]
append!(temp_key, split(line)[2:end])
end
key = unique(temp_key)
type_boundary_map = Dict(zip(key, 0:length(key)-1))
for (element, line) in enumerate(filelines[type_boundary_linenum:end])
data = split(line)[2:end]
type_boundary[element] = Tuple([type_boundary_map[word] for word in data])
end
return abaqusmeshimport(
nodes,
connectivity,
face_iscurved,
face_degree,
face_interpolation,
type_boundary,
type_boundary_map,
)
end
function findline(word::String, filelines::Vector{String})
for (i, line) in enumerate(filelines)
if occursin(word, line)
return i
end
end
return -1
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 8483 | # The following code was taken and modified from the following packages:
# - <https://github.com/JuliaObjects/ConstructionBase.jl>
# - <https://github.com/rafaqz/Flatten.jl>
#
# ConstructionBase.jl is distributed under the following license.
#
# > Copyright (c) 2019 Takafumi Arakaki, Rafael Schouten, Jan Weidner
# >
# > Permission is hereby granted, free of charge, to any person obtaining
# > a copy of this software and associated documentation files (the
# > "Software"), to deal in the Software without restriction, including
# > without limitation the rights to use, copy, modify, merge, publish,
# > distribute, sublicense, > and/or sell copies of the Software, and to
# > permit persons to whom the Software is furnished to do so, subject to
# > the following conditions:
# >
# > The above copyright notice and this permission notice shall be
# > included in all copies or substantial portions of the Software.
# >
# > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# > CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# > SOFTWARE OR THE USE OR OTHER
#
# Flatten.jl is distributed under the following license.
#
# > Copyright (c) 2018: Rafael Schouten and Robin Deits.
# >
# > Permission is hereby granted, free of charge, to any person obtaining
# > a copy of this software and associated documentation files (the
# > "Software"), to deal in the Software without restriction, including
# > without limitation the rights to use, copy, modify, merge, publish,
# > distribute, sublicense, and/or sell copies of the Software, and to
# > permit persons to whom the Software is furnished to do so, subject to
# > the following conditions:
# >
# > The above copyright notice and this permission notice shall be
# > included in all copies or substantial portions of the Software.
# >
# > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# > CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
const USE = Real
_fieldnames(::Type{<:Type}) = ()
_fieldnames(::Type{T}) where {T} = fieldnames(T)
# Generalized nested structure walker
function nested(name, ::Type{T}, ::Type{U}, expr_builder, expr_combiner) where {T,U}
expr_combiner(T, [Expr(:..., expr_builder(name, T, U, fn)) for fn in _fieldnames(T)])
end
function flatten_builder(name, ::Type{T}, ::Type{U}, fname) where {T,U}
newname = :(getfield($name, $(QuoteNode(fname))))
if fieldtype(T, fname) <: U
return Expr(:tuple, newname)
else
return nested(newname, fieldtype(T, fname), U, flatten_builder, flatten_combiner)
end
end
function flatten_combiner(_, expressions)
Expr(:tuple, expressions...)
end
function flatten_expr(::Type{T}, ::Type{U}) where {T,U}
nested(:(obj), T, U, flatten_builder, flatten_combiner)
end
"""
flatten(obj, use=Real)
Flattens a hierarchical type to a tuple with elements of type `use`.
# Examples
```jldoctest
julia> flatten((a=(Complex(1, 2), 3), b=4))
(1, 2, 3, 4)
```
To convert the tuple to a vector, simply use [flatten(x)...], or
using static arrays to avoid allocations: `SVector(flatten(x))`.
"""
@inline @generated function flatten(obj::T, use::Type{U} = USE) where {T,U}
if T <: U
return :((obj,))
else
return flatten_expr(T, U)
end
end
"""
constructorof(T::Type) -> constructor
Return an object `constructor` that can be used to construct objects of
type `T` from their field values. Typically, `constructor` will be the
type `T` with all parameters removed:
```jldoctest
julia> struct T{A,B}
a::A
b::B
end
julia> Raven.constructorof(T{Int,Int})
T
```
The returned constructor is used to `unflatten` objects hierarchical
types from a list of their values. For example, in this case `T(1,2)`
constructs an object where `T.a==1` an `T.b==2`.
The method `constructorof` should be defined for types that are not
constructed from a tuple of their values.
"""
function constructorof end
constructorof(::Type{<:Tuple}) = tuple
constructorof(::Type{<:Complex}) = complex
constructorof(::Type{<:NamedTuple{names}}) where {names} = NamedTupleConstructor{names}()
struct NamedTupleConstructor{names} end
@inline function (::NamedTupleConstructor{names})(args...) where {names}
NamedTuple{names}(args)
end
constructorof(::Type{T}) where {T<:StaticArray} = T
@generated function constructorof(::Type{T}) where {T}
getfield(parentmodule(T), nameof(T))
end
"""
unflatten(T::Type, data, use::Type=Real)
Construct an object from Tuple or Vector `data` and a Type `T`. The `data`
should be at least as long as the queried fields (of type `use`) in `T`.
# Examples
```julia
julia> unflatten(Tuple{Tuple{Int,Int},Complex{Int,Int}}, (1, 2, 3, 4))
((1, 2), 3 + 4im)
```
"""
function unflatten end
@inline Base.@propagate_inbounds unflatten(datatype, data, use::Type = USE) =
_unflatten(datatype, data, use, 1)[1]
# Internal type used to generate constructor expressions.
# Represents a bi-directional (doubly linked) type tree where
# child nodes correspond to fields of composite types.
mutable struct TypeNode{T,TChildren}
type::Type{T}
name::Union{Int,Symbol}
parent::Union{Missing,TypeNode}
children::TChildren
TypeNode(
type::Type{T},
name::Union{Int,Symbol},
children::Union{Missing,<:Tuple{Vararg{TypeNode}}} = missing,
) where {T} = new{T,typeof(children)}(type, name, missing, children)
end
function _buildtree(::Type{T}, name) where {T}
if isabstracttype(T) || isa(T, Union) || isa(T, UnionAll)
return TypeNode(T, name)
elseif T <: Type # treat meta types as leaf nodes
return TypeNode(T, name, ())
else
names = fieldnames(T)
types = fieldtypes(T)
children = map(_buildtree, types, names)
node = TypeNode(T, name, children)
# set parent field on children
for child in children
child.parent = node
end
return node
end
end
# Recursive accessor (getfield) expression builder
_accessor_expr(::Missing, child::TypeNode) = :obj
_accessor_expr(parent::TypeNode, child::TypeNode) =
Expr(:call, :getfield, _accessor_expr(parent.parent, parent), QuoteNode(child.name))
# Recursive construct expression builder;
# Case 1: Leaf node (i.e., no fields)
_unflatten_expr(node::TypeNode{T,Tuple{}}, use::Type{U}) where {T,U} =
:(($(_accessor_expr(node.parent, node)), n))
# Case 2: Matched type; value is taken from `data` at index `n`;
_unflatten_expr(node::TypeNode{<:U}, use::Type{U}) where {U} = __unflatten_expr(node, U)
_unflatten_expr(node::TypeNode{<:U,Tuple{}}, use::Type{U}) where {U} =
__unflatten_expr(node, U)
function __unflatten_expr(node::TypeNode{<:U}, use::Type{U}) where {U}
:(data[n], n + 1)
end
# Case 3: Composite type fields (i.e., with fields) are constructed recursively;
# Recursion is used only at compile time in building the constructor expression.
# This ensures type stability.
function _unflatten_expr(node::TypeNode{T}, ::Type{U}) where {T,U}
expr = Expr(:block)
argnames = []
# Generate constructor expression for each child/field
for child in node.children
flattened_expr = _unflatten_expr(child, U)
accessor_expr = _accessor_expr(node, child)
name = gensym("arg")
child_expr = quote
($name, n) = $flattened_expr
end
push!(expr.args, child_expr)
push!(argnames, name)
end
# Combine into constructor call
callexpr = Expr(:call, :(constructorof($T)), argnames...)
# Return result along with current `data` index, `n`
push!(expr.args, :(($callexpr, n)))
return expr
end
@inline Base.@propagate_inbounds @generated function _unflatten(
::Type{T},
data,
use::Type{U},
n,
) where {T,U}
_unflatten_expr(_buildtree(T, :obj), U)
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 9522 | function gaussoperators_1d(::Type{T}, M) where {T}
oldprecision = precision(BigFloat)
# Increase precision of the type used to compute the 1D operators to help
# ensure any symmetries. This is not thread safe so an alternative would
# be to use ArbNumerics.jl which keeps its precision in the type.
setprecision(BigFloat, 2^(max(8, ceil(Int, log2(precision(T))) + 2)))
points, weights = legendregauss(BigFloat, M)
lobattopoints, _ = legendregausslobatto(BigFloat, M)
derivative = spectralderivative(points)
weightedderivative = weights .* derivative
skewweightedderivative = (weightedderivative - weightedderivative') / 2
equallyspacedpoints = range(-one(BigFloat), stop = one(BigFloat), length = M)
toequallyspaced = spectralinterpolation(points, equallyspacedpoints)
tolowerhalf = spectralinterpolation(points, (points .- 1) ./ 2)
toupperhalf = spectralinterpolation(points, (points .+ 1) ./ 2)
togauss = spectralinterpolation(points, points)
tolobatto = spectralinterpolation(points, lobattopoints)
toboundary = spectralinterpolation(points, [-1, 1])
setprecision(oldprecision)
points = Array{T}(points)
weights = Array{T}(weights)
derivative = Array{T}(derivative)
weightedderivative = Array{T}(weightedderivative)
skewweightedderivative = Array{T}(skewweightedderivative)
toequallyspaced = Array{T}(toequallyspaced)
tohalves = (Array{T}(tolowerhalf), Array{T}(toupperhalf))
togauss = Array{T}(togauss)
tolobatto = Array{T}(tolobatto)
toboundary = Array{T}(toboundary)
return (;
points,
weights,
derivative,
weightedderivative,
skewweightedderivative,
toequallyspaced,
tohalves,
togauss,
tolobatto,
toboundary,
)
end
struct GaussCell{T,A,N,S,O,P,D,WD,SWD,M,FM,E,H,TG,TL,TB} <: AbstractCell{T,A,N}
size::S
points_1d::O
weights_1d::O
points::P
derivatives::D
weightedderivatives::WD
skewweightedderivatives::SWD
mass::M
facemass::FM
toequallyspaced::E
tohalves_1d::H
togauss::TG
tolobatto::TL
toboundary::TB
end
function Base.similar(::GaussCell{T,A}, dims::Dims) where {T,A}
return GaussCell{T,A}(dims...)
end
function Base.show(io::IO, cell::GaussCell{T,A,N}) where {T,A,N}
print(io, "GaussCell{")
Base.show(io, T)
print(io, ", ")
Base.show(io, A)
print(io, "}$(size(cell))")
end
function Base.showarg(io::IO, ::GaussCell{T,A,N}, toplevel) where {T,A,N}
!toplevel && print(io, "::")
print(io, "GaussCell{", T, ",", A, ",", N, "}")
return
end
function Base.summary(io::IO, cell::GaussCell{T,A,N}) where {T,A,N}
d = Base.dims2string(size(cell))
print(io, "$d GaussCell{", T, ",", A, ",", N, "}")
end
function GaussCell{T,A}(m) where {T,A}
o = adapt(A, gaussoperators_1d(T, m))
points_1d = (o.points,)
weights_1d = (o.weights,)
points = vec(SVector.(points_1d...))
derivatives = (Kron((o.derivative,)),)
weightedderivatives = (Kron((o.weightedderivative,)),)
skewweightedderivatives = (Kron((o.skewweightedderivative,)),)
mass = Diagonal(vec(.*(weights_1d...)))
facemass = adapt(A, Diagonal([T(1), T(1)]))
toequallyspaced = Kron((o.toequallyspaced,))
tohalves_1d = ((o.tohalves[1], o.tohalves[2]),)
togauss = Kron((o.togauss,))
tolobatto = Kron((o.tolobatto,))
toboundary = Kron((o.toboundary,))
args = (
(m,),
points_1d,
weights_1d,
points,
derivatives,
weightedderivatives,
skewweightedderivatives,
mass,
facemass,
toequallyspaced,
tohalves_1d,
togauss,
tolobatto,
toboundary,
)
GaussCell{T,A,1,typeof(args[1]),typeof.(args[3:end])...}(args...)
end
function GaussCell{T,A}(m1, m2) where {T,A}
o = adapt(A, (gaussoperators_1d(T, m1), gaussoperators_1d(T, m2)))
points_1d = (reshape(o[1].points, (m1, 1)), reshape(o[2].points, (1, m2)))
weights_1d = (reshape(o[1].weights, (m1, 1)), reshape(o[2].weights, (1, m2)))
points = vec(SVector.(points_1d...))
derivatives = (Kron((Eye{T}(m2), o[1].derivative)), Kron((o[2].derivative, Eye{T}(m1))))
weightedderivatives = (
Kron((Eye{T}(m2), o[1].weightedderivative)),
Kron((o[2].weightedderivative, Eye{T}(m1))),
)
skewweightedderivatives = (
Kron((Eye{T}(m2), o[1].skewweightedderivative)),
Kron((o[2].skewweightedderivative, Eye{T}(m1))),
)
mass = Diagonal(vec(.*(weights_1d...)))
ω1, ω2 = weights_1d
facemass = Diagonal(vcat(repeat(vec(ω2), 2), repeat(vec(ω1), 2)))
toequallyspaced = Kron((o[2].toequallyspaced, o[1].toequallyspaced))
tohalves_1d =
((o[1].tohalves[1], o[1].tohalves[2]), (o[2].tohalves[1], o[2].tohalves[2]))
togauss = Kron((o[2].togauss, o[1].togauss))
tolobatto = Kron((o[2].tolobatto, o[1].tolobatto))
toboundary = Kron((o[2].toboundary, o[1].toboundary))
args = (
(m1, m2),
points_1d,
weights_1d,
points,
derivatives,
weightedderivatives,
skewweightedderivatives,
mass,
facemass,
toequallyspaced,
tohalves_1d,
togauss,
tolobatto,
toboundary,
)
GaussCell{T,A,2,typeof(args[1]),typeof.(args[3:end])...}(args...)
end
function GaussCell{T,A}(m1, m2, m3) where {T,A}
o = adapt(
A,
(gaussoperators_1d(T, m1), gaussoperators_1d(T, m2), gaussoperators_1d(T, m3)),
)
points_1d = (
reshape(o[1].points, (m1, 1, 1)),
reshape(o[2].points, (1, m2, 1)),
reshape(o[3].points, (1, 1, m3)),
)
weights_1d = (
reshape(o[1].weights, (m1, 1, 1)),
reshape(o[2].weights, (1, m2, 1)),
reshape(o[3].weights, (1, 1, m3)),
)
points = vec(SVector.(points_1d...))
derivatives = (
Kron((Eye{T}(m3), Eye{T}(m2), o[1].derivative)),
Kron((Eye{T}(m3), o[2].derivative, Eye{T}(m1))),
Kron((o[3].derivative, Eye{T}(m2), Eye{T}(m1))),
)
weightedderivatives = (
Kron((Eye{T}(m3), Eye{T}(m2), o[1].weightedderivative)),
Kron((Eye{T}(m3), o[2].weightedderivative, Eye{T}(m1))),
Kron((o[3].weightedderivative, Eye{T}(m2), Eye{T}(m1))),
)
skewweightedderivatives = (
Kron((Eye{T}(m3), Eye{T}(m2), o[1].skewweightedderivative)),
Kron((Eye{T}(m3), o[2].skewweightedderivative, Eye{T}(m1))),
Kron((o[3].skewweightedderivative, Eye{T}(m2), Eye{T}(m1))),
)
mass = Diagonal(vec(.*(weights_1d...)))
ω1, ω2, ω3 = weights_1d
facemass = Diagonal(
vcat(repeat(vec(ω2 .* ω3), 2), repeat(vec(ω1 .* ω3), 2), repeat(vec(ω1 .* ω2), 2)),
)
toequallyspaced =
Kron((o[3].toequallyspaced, o[2].toequallyspaced, o[1].toequallyspaced))
tohalves_1d = (
(o[1].tohalves[1], o[1].tohalves[2]),
(o[2].tohalves[1], o[2].tohalves[2]),
(o[3].tohalves[1], o[3].tohalves[2]),
)
togauss = Kron((o[3].togauss, o[2].togauss, o[1].togauss))
tolobatto = Kron((o[3].tolobatto, o[2].tolobatto, o[1].tolobatto))
toboundary = Kron((o[3].toboundary, o[2].toboundary, o[1].toboundary))
args = (
(m1, m2, m3),
points_1d,
weights_1d,
points,
derivatives,
weightedderivatives,
skewweightedderivatives,
mass,
facemass,
toequallyspaced,
tohalves_1d,
togauss,
tolobatto,
toboundary,
)
GaussCell{T,A,3,typeof(args[1]),typeof.(args[3:end])...}(args...)
end
GaussCell{T}(args...) where {T} = GaussCell{T,Array}(args...)
GaussCell(args...) = GaussCell{Float64}(args...)
function Adapt.adapt_structure(to, cell::GaussCell{T,A,N}) where {T,A,N}
names = fieldnames(GaussCell)
args = ntuple(j -> adapt(to, getfield(cell, names[j])), length(names))
B = arraytype(to)
GaussCell{T,B,N,typeof(args[1]),typeof.(args[3:end])...}(args...)
end
const GaussLine{T,A} = GaussCell{Tuple{B},T,A} where {B}
const GaussQuad{T,A} = GaussCell{Tuple{B,C},T,A} where {B,C}
const GaussHex{T,A} = GaussCell{Tuple{B,C,D},T,A} where {B,C,D}
Base.size(cell::GaussCell) = cell.size
points_1d(cell::GaussCell) = cell.points_1d
weights_1d(cell::GaussCell) = cell.weights_1d
points(cell::GaussCell) = cell.points
derivatives(cell::GaussCell) = cell.derivatives
weightedderivatives(cell::GaussCell) = cell.weightedderivatives
skewweightedderivatives(cell::GaussCell) = cell.skewweightedderivatives
function derivatives_1d(cell::GaussCell)
N = ndims(cell)
ntuple(i -> cell.derivatives[i].args[N-i+1], Val(N))
end
function weightedderivatives_1d(cell::GaussCell)
N = ndims(cell)
ntuple(i -> cell.weightedderivatives[i].args[N-i+1], Val(N))
end
function skewweightedderivatives_1d(cell::GaussCell)
N = ndims(cell)
ntuple(i -> cell.skewweightedderivatives[i].args[N-i+1], Val(N))
end
mass(cell::GaussCell) = cell.mass
facemass(cell::GaussCell) = cell.facemass
toequallyspaced(cell::GaussCell) = cell.toequallyspaced
tohalves_1d(cell::GaussCell) = cell.tohalves_1d
degrees(cell::GaussCell) = size(cell) .- 1
togauss(cell::GaussCell) = cell.togauss
tolobatto(cell::GaussCell) = cell.tolobatto
toboundary(cell::GaussCell) = cell.toboundary
togauss_1d(cell::GaussCell) = reverse(cell.togauss.args)
tolobatto_1d(cell::GaussCell) = reverse(cell.tolobatto.args)
toboundary_1d(cell::GaussCell) = reverse(cell.toboundary.args)
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 16618 | function recursive_fieldtypes(::Type{T}, ::Type{U} = Real) where {T,U}
if T <: U
return (T,)
else
return recursive_fieldtypes.(fieldtypes(T), U)
end
end
@inline function insert(I::NTuple{N,Int}, ::Val{M}, i::Int) where {N,M}
m = M::Int
return (I[1:m-1]..., i, I[m:end]...)::NTuple{N + 1,Int}
end
"""
GridArray{T,N,A,G,F,L,C,D,W} <: AbstractArray{T,N}
`N`-dimensional array of values of type `T` for each grid point using a
struct-of-arrays like format that is GPU friendly. Type `T` is assumed to be
a hierarchical `struct` that can be `flatten`ed into an `NTuple{L,E<:Real}`.
The backing data array will be of type `A{E}` and will have the fields of `T`
indexed via index `F`.
`GridArray` also stores values for the ghost cells of the grid which are
accessible if `G==true`.
"""
struct GridArray{T,N,A,G,F,L,C,D,W} <: AbstractArray{T,N}
"""MPI.Comm used for communication"""
comm::C
"""View of the backing data array without the ghost cells"""
data::D
"""Backing data array with the ghost cells"""
datawithghosts::W
"""Dimensions of the array without the ghost cells"""
dims::NTuple{N,Int}
"""Dimensions of the array with the ghost cells"""
dimswithghosts::NTuple{N,Int}
end
const GridVecOrMat{T} = Union{GridArray{T,1},GridArray{T,2}}
function GridArray{T}(
::UndefInitializer,
::Type{A},
dims::NTuple{N,Int},
dimswithghosts::NTuple{N,Int},
comm,
withghosts::Bool,
fieldindex::Integer,
) where {T,A,N}
if !(all(dims[1:end-1] .== dimswithghosts[1:end-1]) && dims[end] <= dimswithghosts[end])
throw(
DimensionMismatch(
"dims ($dims) must equal to dimswithghosts ($dimswithghosts) in all but the last dimension where it should be less than",
),
)
end
types = flatten(recursive_fieldtypes(T), DataType)
L = length(types)::Int
if L == 0
throw(ArgumentError("Type T has no Real fields"))
end
E = first(types)
if !allequal(types)
throw(ArgumentError("Type T has different field types: $types"))
end
datawithghosts = A{E}(undef, insert(dimswithghosts, Val(fieldindex), L))
data = view(datawithghosts, (ntuple(_ -> Colon(), Val(N))..., Base.OneTo(dims[end]))...)
C = typeof(comm)
D = typeof(data)
W = typeof(datawithghosts)
return GridArray{T,N,A,withghosts,fieldindex,L,C,D,W}(
comm,
data,
datawithghosts,
dims,
dimswithghosts,
)
end
"""
GridArray{T}(undef, grid::Grid)
Create an array containing elements of type `T` for each point in the grid
(including the ghost cells). The dimensions of the array is
`(size(referencecell(grid))..., length(grid))` as the ghost cells are hidden by
default.
The type `T` is assumed to be able to be interpreted into an `NTuple{M,L}`.
Some example types (some using `StructArrays`) are:
- `T = NamedTuple{(:E,:B),Tuple{SVector{3,ComplexF64},SVector{3,ComplexF64}}}`
- `T = NTuple{5,Int64}`
- `T = SVector{5,Int64}`
- `T = ComplexF32`
- `T = Float32`
Instead of using an array-of-struct style storage, a GPU efficient
struct-of-arrays like storage is used. For example, instead of storing data
like
```julia-repl
julia> T = Tuple{Int,Int};
julia> data = Array{T}(undef, 3, 4, 2); a .= Ref((1,2))
3×4 Matrix{Tuple{Int64, Int64}}:
(1, 2) (1, 2) (1, 2) (1, 2)
(1, 2) (1, 2) (1, 2) (1, 2)
(1, 2) (1, 2) (1, 2) (1, 2)
```
the data would be stored in the order
```julia-repl
julia> permutedims(reinterpret(reshape, Int, data), (2,3,1,4))
3×4×2×2 Array{Int64, 4}:
[:, :, 1, 1] =
1 1 1 1
1 1 1 1
1 1 1 1
[:, :, 2, 1] =
2 2 2 2
2 2 2 2
2 2 2 2
[:, :, 1, 2] =
1 1 1 1
1 1 1 1
1 1 1 1
[:, :, 2, 2] =
2 2 2 2
2 2 2 2
2 2 2 2
```
For a `GridArray` the indices before the ones associated with `T` (the first
two in the example above) are associated with the degrees-of-freedoms of the
cells. The one after is associated with the number of cells.
"""
function GridArray{T}(::UndefInitializer, grid::Grid) where {T}
A = arraytype(grid)
dims = (size(referencecell(grid))..., Int(numcells(grid, Val(false))))
dimswithghosts = (size(referencecell(grid))..., Int(numcells(grid, Val(true))))
F = ndims(referencecell(grid)) + 1
return GridArray{T}(undef, A, dims, dimswithghosts, comm(grid), false, F)
end
GridArray(::UndefInitializer, grid::Grid) = GridArray{Float64}(undef, grid)
function Base.showarg(io::IO, a::GridArray{T,N,A,G,F}, toplevel) where {T,N,A,G,F}
!toplevel && print(io, "::")
print(io, "GridArray{", T, ",", N, ",", A, ",", G, ",", F, "}")
toplevel && print(io, " with data eltype ", eltype(parent(a)))
return
end
"""
viewwithoutghosts(A::GridArray)
Return a `GridArray` with the same data as `A` but with the ghost cells inaccessible.
"""
@inline function viewwithoutghosts(
a::GridArray{T,N,A,true,F,L,C,D,W},
) where {T,N,A,F,L,C,D,W}
GridArray{T,N,A,false,F,L,C,D,W}(
a.comm,
a.data,
a.datawithghosts,
a.dims,
a.dimswithghosts,
)
end
"""
viewwithghosts(A::GridArray)
Return a `GridArray` with the same data as `A` but with the ghost cells accessible.
"""
@inline function viewwithghosts(a::GridArray{T,N,A,false,F,L,C,D,W}) where {T,N,A,F,L,C,D,W}
GridArray{T,N,A,true,F,L,C,D,W}(
a.comm,
a.data,
a.datawithghosts,
a.dims,
a.dimswithghosts,
)
end
"""
get_backend(A::GridArray) -> KernelAbstractions.Backend
Returns the `KernelAbstractions.Backend` used to launch kernels interacting
with `A`.
"""
@inline get_backend(::GridArray{T,N,A}) where {T,N,A} = get_backend(A)
@inline GPUArraysCore.backend(x::GridArray{<:Any,<:Any,<:AbstractGPUArray}) =
GPUArraysCore.backend(x.datawithghosts)
"""
arraytype(A::GridArray) -> DataType
Returns the `DataType` used to store the data, e.g., `Array` or `CuArray`.
"""
@inline arraytype(::GridArray{T,N,A}) where {T,N,A} = A
"""
showingghosts(A::GridArray) -> Bool
Predicate indicating if the ghost layer is accessible to `A`.
"""
@inline showingghosts(::GridArray{T,N,A,G}) where {T,N,A,G} = G
"""
fieldindex(A::GridArray{T})
Returns the index used in `A.data` to store the fields of `T`.
"""
@inline fieldindex(::GridArray{T,N,A,G,F}) where {T,N,A,G,F} = F
"""
fieldslength(A::GridArray{T})
Returns the number of fields used to store `T`.
"""
@inline fieldslength(::GridArray{T,N,A,G,F,L}) where {T,N,A,G,F,L} = L
"""
comm(A::GridArray) -> MPI.Comm
MPI communicator used by `A`.
"""
@inline comm(a::GridArray) = a.comm
@inline Base.parent(a::GridArray{T,N,A,G}) where {T,N,A,G} =
ifelse(G, a.datawithghosts, a.data)
"""
parentwithghosts(A::GridArray)
Return the underlying "parent array" which includes the ghost cells.
"""
@inline parentwithghosts(a::GridArray) = a.datawithghosts
@inline Base.size(a::GridArray{T,N,A,false}) where {T,N,A} = a.dims
@inline Base.size(a::GridArray{T,N,A,true}) where {T,N,A} = a.dimswithghosts
"""
sizewithghosts(A::GridArray)
Return a tuple containing the dimensions of `A` including the ghost cells.
"""
@inline sizewithghosts(a::GridArray) = a.dimswithghosts
"""
sizewithoutghosts(A::GridArray)
Return a tuple containing the dimensions of `A` excluding the ghost cells.
"""
@inline sizewithoutghosts(a::GridArray) = a.dims
function Base.similar(
a::GridArray{S,N,A,G,F},
::Type{T},
dims::Tuple{Vararg{Int64,M}},
) where {S,N,A,G,F,T,M}
if M == N
if (!G && (dims[end] == a.dims[end])) || (G && (dims[end] == a.dimswithghosts[end]))
# Create ghost layer
dimswithghosts = (dims[1:end-1]..., a.dimswithghosts[end])
else
# No ghost layer
dimswithghosts = dims
end
return GridArray{T}(undef, A, dims, dimswithghosts, comm(a), G, F)
else
return A{T}(undef, dims)
end
end
function Base.checkbounds(::Type{Bool}, a::GridArray, I::NTuple{N,<:Integer}) where {N}
@inline
Base.checkbounds_indices(Bool, axes(a), I)
end
@inline function Base.getindex(
a::GridArray{T,N,A,G,F,L},
I::Vararg{Int,N},
) where {T,N,A,G,F,L}
@boundscheck checkbounds(a, I)
data = parent(a)
d = ntuple(
i -> (@inbounds getindex(data, insert(I, Val(F), i)...)),
Val(L),
)::NTuple{L,eltype(data)}
return unflatten(T, d)
end
@generated function _unsafe_setindex!(
a::GridArray{T,N,A,G,F,L},
v,
I::Vararg{Int,N},
) where {T,N,A,G,F,L}
quote
$(Expr(:meta, :inline))
data = parent(a)
vt = flatten(convert(T, v)::T)
Base.Cartesian.@nexprs $L i ->
@inbounds setindex!(data, vt[i], insert(I, Val(F), i)...)
return a
end
end
@inline function Base.setindex!(a::GridArray{<:Any,N}, v, I::Vararg{Int,N}) where {N}
@boundscheck checkbounds(a, I)
return _unsafe_setindex!(a, v, I...)
end
LinearAlgebra.norm(a::GridArray) = sqrt(MPI.Allreduce(norm(parent(a))^2, +, comm(a)))
@kernel function fill_kernel!(a, x)
I = @index(Global)
@inbounds a[I] = x
end
function Base.fill!(a::GridArray{T}, x) where {T}
fill_kernel!(get_backend(a), 256)(a, convert(T, x)::T, ndrange = length(a))
return a
end
@kernel function fillghosts_kernel!(a, x, dims)
i = @index(Global)
@inbounds begin
I = CartesianIndices(a)[i]
if any(Tuple(I) .> dims)
a[i] = x
end
end
end
function fillghosts!(a::GridArray{T}, x) where {T}
b = viewwithghosts(a)
fillghosts_kernel!(get_backend(b), 256)(
b,
convert(T, x)::T,
b.dims,
ndrange = length(b),
)
return a
end
function Adapt.adapt_structure(to, a::GridArray{T,N,A,G,F,L}) where {T,N,A,G,F,L}
newcomm = Adapt.adapt(to, a.comm)
newdatawithghosts = Adapt.adapt(to, a.datawithghosts)
newdata = view(newdatawithghosts, Base.OneTo.(insert(a.dims, Val(F), L))...)
NA = arraytype(newdatawithghosts)
NC = typeof(newcomm)
ND = typeof(newdata)
NW = typeof(newdatawithghosts)
GridArray{T,N,NA,G,F,L,NC,ND,NW}(
newcomm,
newdata,
newdatawithghosts,
a.dims,
a.dimswithghosts,
)
end
Base.BroadcastStyle(::Type{<:GridArray}) = Broadcast.ArrayStyle{GridArray}()
Base.Broadcast.BroadcastStyle(
::A,
::Base.Broadcast.ArrayStyle{GridArray},
) where {M,A<:Base.Broadcast.AbstractArrayStyle{M}} = Broadcast.ArrayStyle{GridArray}()
Base.Broadcast.BroadcastStyle(
::Base.Broadcast.ArrayStyle{GridArray},
::A,
) where {M,A<:Base.Broadcast.AbstractArrayStyle{M}} = Broadcast.ArrayStyle{GridArray}()
Base.Broadcast.BroadcastStyle(
::A,
::Base.Broadcast.ArrayStyle{GridArray},
) where {M,A<:Base.Broadcast.DefaultArrayStyle{M}} = Broadcast.ArrayStyle{GridArray}()
Base.Broadcast.BroadcastStyle(
::Base.Broadcast.ArrayStyle{GridArray},
::A,
) where {M,A<:Base.Broadcast.DefaultArrayStyle{M}} = Broadcast.ArrayStyle{GridArray}()
Base.Broadcast.BroadcastStyle(
::Base.Broadcast.ArrayStyle{GridArray},
::A,
) where {A<:Base.Broadcast.ArrayStyle} = Broadcast.ArrayStyle{GridArray}()
Base.Broadcast.BroadcastStyle(
::A,
::Base.Broadcast.ArrayStyle{GridArray},
) where {A<:Base.Broadcast.ArrayStyle} = Broadcast.ArrayStyle{GridArray}()
Base.Broadcast.BroadcastStyle(
::Base.Broadcast.ArrayStyle{GridArray},
::Base.Broadcast.ArrayStyle{GridArray},
) = Broadcast.ArrayStyle{GridArray}()
cat_gridarrays(t::Broadcast.Broadcasted, rest...) =
(cat_gridarrays(t.args...)..., cat_gridarrays(rest...)...)
cat_gridarrays(t::GridArray, rest...) = (t, cat_gridarrays(rest...)...)
cat_gridarrays(::Any, rest...) = cat_gridarrays(rest...)
cat_gridarrays() = ()
function Base.similar(
bc::Broadcast.Broadcasted{Broadcast.ArrayStyle{GridArray}},
::Type{T},
) where {T}
dims = length.(axes(bc))
gridarrays = cat_gridarrays(bc)
a = first(gridarrays)
A = arraytype(a)
G = showingghosts(a)
F = fieldindex(a)
elemdims = sizewithoutghosts(a)[F:end]
elemdimswithghosts = sizewithghosts(a)[F:end]
for b in gridarrays
if A != arraytype(b) ||
G != showingghosts(b) ||
F != fieldindex(b) ||
MPI.Comm_compare(comm(a), comm(b)) != MPI.IDENT ||
elemdimswithghosts != sizewithghosts(b)[F:end]
throw(ArgumentError("Incompatible GridArray arguments in broadcast"))
end
end
return GridArray{T}(
undef,
A,
(dims[1:F-1]..., elemdims...),
(dims[1:F-1]..., elemdimswithghosts...),
comm(a),
G,
F,
)
end
@kernel function broadcast_kernel!(dest, bc)
i = @index(Global)
@inbounds I = CartesianIndices(dest)[i]
@inbounds dest[I] = bc[I]
end
@inline function Base.copyto!(dest::GridArray, bc::Broadcast.Broadcasted{Nothing})
axes(dest) == axes(bc) || Broadcast.throwdm(axes(dest), axes(bc))
isempty(dest) && return dest
bcprime = Broadcast.preprocess(dest, bc)
broadcast_kernel!(get_backend(dest), 256)(dest, bcprime, ndrange = length(dest))
return dest
end
@inline function Base.copyto!(dest::GridArray, src::GridArray)
copyto!(dest.datawithghosts, src.datawithghosts)
return dest
end
function Base.copy(a::GridArray)
b = similar(a)
copyto!(b, a)
end
# We follow GPUArrays approach of coping the whole array to the host when
# outputting a GridArray backed by GPU arrays.
convert_to_cpu(xs) = Adapt.adapt_structure(Array, xs)
function Base.print_array(io::IO, X::GridArray{<:Any,0,<:AbstractGPUArray})
X = convert_to_cpu(X)
isassigned(X) ? show(io, X[]) : print(io, "#undef")
end
Base.print_array(io::IO, X::GridArray{<:Any,1,<:AbstractGPUArray}) =
Base.print_matrix(io, convert_to_cpu(X))
Base.print_array(io::IO, X::GridArray{<:Any,2,<:AbstractGPUArray}) =
Base.print_matrix(io, convert_to_cpu(X))
Base.print_array(io::IO, X::GridArray{<:Any,<:Any,<:AbstractGPUArray}) =
Base.show_nd(io, convert_to_cpu(X), Base.print_matrix, true)
function Base.show_nd(
io::IO,
X::Raven.GridArray{<:Any,<:Any,<:AbstractGPUArray},
print_matrix::Function,
show_full::Bool,
)
Base.show_nd(io, Raven.convert_to_cpu(X), print_matrix, show_full)
end
@inline components(::Type{T}) where {T} = fieldtypes(T)
@inline components(::Type{<:NamedTuple{E,T}}) where {E,T} = NamedTuple{E}(fieldtypes(T))
@inline components(::Type{T}) where {T<:Complex} = NamedTuple{(:re, :im)}(fieldtypes(T))
@inline components(::Type{T}) where {T<:SArray} = fieldtypes(fieldtype(T, 1))
@inline components(::Type{T}) where {T<:Real} = (T,)
@inline function componentoffset(::Type{T}, ::Type{E}, i::Int) where {T<:SArray,E}
return componentoffset(fieldtype(T, 1), E, i)
end
@inline function componentoffset(::Type{T}, ::Type{E}, i::Int) where {T,E}
if T <: E
return 0
else
return Int(fieldoffset(T, i) ÷ sizeof(E))
end
end
@inline function ncomponents(::Type{T}, ::Type{E}) where {T,E}
return Int(sizeof(T) ÷ sizeof(E))
end
"""
components(A::GridArray{T})
Splits `A` into a tuple of `GridArray`s where there is one for each component
of `T`.
Note, the data for the components is shared with the original array.
For example, if `A isa GridArray{SVector{3, Float64}}` then a tuple of type
`NTuple{3, GridArray{Float64}}` would be returned.
"""
function components(a::GridArray{T,N,A,G,F}) where {T,N,A,G,F}
componenttypes = components(T)
E = eltype(a.datawithghosts)
c = comm(a)
dims = size(a)
dimswithghosts = sizewithghosts(a)
comps = ntuple(length(componenttypes)) do n
Tn = componenttypes[n]
r = (1:ncomponents(Tn, E)) .+ componentoffset(T, E, n)
datawithghosts =
view(a.datawithghosts, setindex(axes(a.datawithghosts), r, F)...)
data = view(a.data, setindex(axes(a.data), r, F)...)
L = length(r)
C = typeof(c)
D = typeof(data)
W = typeof(datawithghosts)
GridArray{Tn,N,A,G,F,L,C,D,W}(c, data, datawithghosts, dims, dimswithghosts)
end
if T <: Union{NamedTuple,FieldArray}
comps = NamedTuple{fieldnames(T)}(comps)
end
if T <: SVector
if Size(T) == Size(1)
comps = NamedTuple{(:x,)}(comps)
elseif Size(T) == Size(2)
comps = NamedTuple{(:x, :y)}(comps)
elseif Size(T) == Size(3)
comps = NamedTuple{(:x, :y, :z)}(comps)
elseif Size(T) == Size(4)
comps = NamedTuple{(:x, :y, :z, :w)}(comps)
end
end
return comps
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 20347 | abstract type AbstractGridManager end
struct QuadData
old_id::P4estTypes.Locidx
old_level::Int8
adapt_flag::UInt8
end
const AdaptCoarsen = 0x00
const AdaptNone = 0x01
const AdaptRefine = 0x10
const AdaptTouched = 0x11
struct GridManager{C<:AbstractCell,G<:AbstractCoarseGrid,E,V,P} <: AbstractGridManager
comm::MPI.Comm
referencecell::C
coarsegrid::G
coarsegridcells::E
coarsegridvertices::V
forest::P
end
comm(gm::GridManager) = gm.comm
referencecell(gm::GridManager) = gm.referencecell
coarsegrid(gm::GridManager) = gm.coarsegrid
coarsegridcells(gm::GridManager) = gm.coarsegridcells
coarsegridvertices(gm::GridManager) = gm.coarsegridvertices
forest(gm::GridManager) = gm.forest
isextruded(gm::GridManager) = isextruded(coarsegrid(gm))
function GridManager(
referencecell,
coarsegrid;
comm = MPI.COMM_WORLD,
min_level = 0,
fill_uniform = true,
)
if !MPI.Initialized()
MPI.Init()
end
comm = MPI.Comm_dup(comm)
p = P4estTypes.pxest(
connectivity(coarsegrid);
min_level = first(min_level),
data_type = QuadData,
comm,
fill_uniform,
)
coarsegridcells = adapt(arraytype(referencecell), cells(coarsegrid))
coarsegridvertices = adapt(arraytype(referencecell), vertices(coarsegrid))
return GridManager(
comm,
referencecell,
coarsegrid,
coarsegridcells,
coarsegridvertices,
p,
)
end
Base.length(gm::GridManager) = P4estTypes.lengthoflocalquadrants(forest(gm))
function fill_quadrant_user_data(forest, _, quadrant, quadrantid, treeid, flags)
id = quadrantid + P4estTypes.offset(forest[treeid])
P4estTypes.unsafe_storeuserdata!(
quadrant,
QuadData(id, P4estTypes.level(quadrant), flags[id]),
)
end
function fill_adapt_flags(::P4estTypes.Pxest{X}, _, quadrant, _, _, flags) where {X}
d = P4estTypes.unsafe_loaduserdata(quadrant, QuadData)
if d.old_level < P4estTypes.level(quadrant)
flags[d.old_id] = AdaptRefine
elseif d.old_level > P4estTypes.level(quadrant)
flags[d.old_id] = AdaptCoarsen
else
flags[d.old_id] = AdaptNone
end
return
end
function replace_quads(_, _, outgoing, incoming)
outd = P4estTypes.unsafe_loaduserdata(first(outgoing), QuadData)
for quadrant in incoming
P4estTypes.unsafe_storeuserdata!(
quadrant,
QuadData(outd.old_id, outd.old_level, AdaptTouched),
)
end
return
end
function refine_quads(_, _, quadrant)
retval = P4estTypes.unsafe_loaduserdata(quadrant, QuadData).adapt_flag == AdaptRefine
return retval
end
function coarsen_quads(_, _, children)
coarsen = true
for child in children
coarsen &=
P4estTypes.unsafe_loaduserdata(child, QuadData).adapt_flag == AdaptCoarsen
end
return coarsen
end
function adapt!(gm::GridManager, flags)
@assert length(gm) == length(flags)
P4estTypes.iterateforest(forest(gm); userdata = flags, volume = fill_quadrant_user_data)
P4estTypes.coarsen!(forest(gm); coarsen = coarsen_quads, replace = replace_quads)
P4estTypes.refine!(forest(gm); refine = refine_quads, replace = replace_quads)
P4estTypes.balance!(forest(gm); replace = replace_quads)
P4estTypes.iterateforest(forest(gm); userdata = flags, volume = fill_adapt_flags)
return
end
generate(gm::GridManager) = generate(identity, gm)
function _offsets_to_ranges(offsets; by = identity)
indices = Cint[]
ranges = UnitRange{Int}[]
for r = 1:length(offsets)-1
if offsets[r+1] - offsets[r] > 0
ids = by(r - 1)
push!(indices, ids)
push!(ranges, (offsets[r]+1):offsets[r+1])
end
end
return (indices, ranges)
end
function materializequadrantcommpattern(forest, ghost)
ms = P4estTypes.mirrors(ghost)
gs = P4estTypes.ghosts(ghost)
GC.@preserve ghost begin
mirror_proc_mirrors = P4estTypes.unsafe_mirror_proc_mirrors(ghost)
mirror_proc_offsets = P4estTypes.unsafe_mirror_proc_offsets(ghost)
num_local = P4estTypes.lengthoflocalquadrants(forest)
T = typeof(num_local)
num_ghosts = T(length(gs))
sendindices = similar(mirror_proc_mirrors, T)
for i in eachindex(sendindices)
sendindices[i] = P4estTypes.unsafe_local_num(ms[mirror_proc_mirrors[i]+1])
end
(sendranks, sendrankindices) = _offsets_to_ranges(mirror_proc_offsets)
proc_offsets = P4estTypes.unsafe_proc_offsets(ghost)
recvindices = (num_local+0x1):(num_local+num_ghosts)
(recvranks, recvrankindices) = _offsets_to_ranges(proc_offsets)
end
return CommPattern{Array}(
recvindices,
recvranks,
recvrankindices,
sendindices,
sendranks,
sendrankindices,
)
end
function materializeforestvolumedata(forest, _, quadrant, quadid, treeid, data)
id = quadid + P4estTypes.offset(forest[treeid])
data.quadranttolevel[id] = P4estTypes.level(quadrant)
data.quadranttotreeid[id] = treeid
data.quadranttocoordinate[id, :] .= P4estTypes.coordinates(quadrant)
return
end
function materializequadrantdata(forest, ghost)
ghosts = P4estTypes.ghosts(ghost)
localnumberofquadrants = P4estTypes.lengthoflocalquadrants(forest)
ghostnumberofquadrants = length(ghosts)
totalnumberofquadrants = localnumberofquadrants + ghostnumberofquadrants
quadranttolevel = Array{Int8}(undef, totalnumberofquadrants)
quadranttotreeid = Array{Int32}(undef, totalnumberofquadrants)
quadranttocoordinate =
Array{Int32}(undef, totalnumberofquadrants, P4estTypes.quadrantndims(forest))
data = (; quadranttolevel, quadranttotreeid, quadranttocoordinate)
# Fill in information for the local quadrants
P4estTypes.iterateforest(
forest;
ghost,
userdata = data,
volume = materializeforestvolumedata,
)
# Fill in information for the ghost layer quadrants
for (quadid, quadrant) in enumerate(ghosts)
id = quadid + localnumberofquadrants
quadranttolevel[id] = P4estTypes.level(quadrant)
quadranttotreeid[id] = P4estTypes.unsafe_which_tree(quadrant)
quadranttocoordinate[id, :] .= P4estTypes.coordinates(quadrant)
end
return (quadranttolevel, quadranttotreeid, quadranttocoordinate)
end
function extrudequadrantdata(
unextrudedquadranttolevel,
unextrudedquadranttotreeid,
unextrudedquadranttocoordinate,
columnnumberofquadrants,
)
quadranttolevel = repeat(unextrudedquadranttolevel, inner = columnnumberofquadrants)
quadranttotreeid = similar(unextrudedquadranttotreeid, size(quadranttolevel))
for i = 1:length(unextrudedquadranttotreeid)
treeidoffset = (unextrudedquadranttotreeid[i] - 1) * columnnumberofquadrants
for j = 1:columnnumberofquadrants
quadranttotreeid[(i-1)*columnnumberofquadrants+j] = treeidoffset + j
end
end
u = unextrudedquadranttocoordinate
q = similar(u, (size(u, 1), size(u, 2) + 1))
q[:, 1:size(u, 2)] .= u
q[:, size(u, 2)+1] .= zero(eltype(u))
quadranttocoordinate = repeat(q, inner = (columnnumberofquadrants, 1))
return (quadranttolevel, quadranttotreeid, quadranttocoordinate)
end
"""
materializequadranttoglobalid(forest, ghost)
Generate the global ids for quadrants in the `forest` and the `ghost` layer.
"""
function materializequadranttoglobalid(forest, ghost)
rank = MPI.Comm_rank(forest.comm)
ghosts = P4estTypes.ghosts(ghost)
localnumberofquadrants = P4estTypes.lengthoflocalquadrants(forest)
ghostnumberofquadrants = length(ghosts)
totalnumberofquadrants = localnumberofquadrants + ghostnumberofquadrants
GC.@preserve forest ghost ghosts begin
global_first_quadrant = P4estTypes.unsafe_global_first_quadrant(forest)
gfq = global_first_quadrant[rank+1]
T = eltype(global_first_quadrant)
proc_offsets = P4estTypes.unsafe_proc_offsets(ghost)
globalquadrantids = zeros(T, totalnumberofquadrants)
for i = 1:localnumberofquadrants
globalquadrantids[i] = i + gfq
end
for i = 1:ghostnumberofquadrants
globalquadrantids[i+localnumberofquadrants] =
P4estTypes.unsafe_local_num(ghosts[i])
end
for r = 1:length(proc_offsets)-1
for o = (proc_offsets[r]+1):proc_offsets[r+1]
globalquadrantids[o+localnumberofquadrants] += global_first_quadrant[r]
end
end
end
return globalquadrantids
end
function extrudequadranttoglobalid(unextrudedquadranttoglobalid, columnnumberofquadrants)
unextrudednumberofquadrants = length(unextrudedquadranttoglobalid)
quadranttoglobalid = similar(
unextrudedquadranttoglobalid,
unextrudednumberofquadrants * columnnumberofquadrants,
)
for q = 1:unextrudednumberofquadrants
p = unextrudedquadranttoglobalid[q]
for c = 1:columnnumberofquadrants
quadranttoglobalid[(q-1)*columnnumberofquadrants+c] =
(p - 1) * columnnumberofquadrants + c
end
end
return quadranttoglobalid
end
function materializedtoc(forest, ghost, nodes, quadrantcommpattern, comm)
localnumberofquadrants = P4estTypes.lengthoflocalquadrants(forest)
ghostnumberofquadrants = length(P4estTypes.ghosts(ghost))
totalnumberofquadrants = localnumberofquadrants + ghostnumberofquadrants
dtoc_owned = P4estTypes.unsafe_element_nodes(nodes)
dtoc = zeros(eltype(dtoc_owned), size(dtoc_owned)[1:end-1]..., totalnumberofquadrants)
dtoc[1:length(dtoc_owned)] .= vec(dtoc_owned)
dtoc_global = P4estTypes.globalid.(Ref(nodes), dtoc) .+ 0x1
pattern = expand(quadrantcommpattern, prod(size(dtoc_owned)[1:end-1]))
cm = commmanager(eltype(dtoc_global), pattern; comm)
share!(dtoc_global, cm)
dtoc_local = numbercontiguous(eltype(dtoc_owned), dtoc_global)
return (dtoc_local, dtoc_global)
end
function extrudedtoc(
unextrudeddtoc::AbstractArray{T,3},
columnnumberofquadrants,
columnnumberofcelldofs,
columnisperiodic,
) where {T}
s = size(unextrudeddtoc)
dtoc = similar(
unextrudeddtoc,
s[1],
s[2],
columnnumberofcelldofs,
columnnumberofquadrants,
s[end],
)
numccnodes = columnnumberofquadrants * (columnnumberofcelldofs - 1) + !columnisperiodic
for q = 1:s[end], c = 1:columnnumberofquadrants
for k = 1:columnnumberofcelldofs
cnode = (c - 1) * (columnnumberofcelldofs - 1) + k
@assert cnode <= numccnodes
for j = 1:s[2], i = 1:s[1]
dtoc[i, j, k, c, q] = (unextrudeddtoc[i, j, q] - 1) * numccnodes + cnode
end
end
if columnisperiodic
for j = 1:s[2], i = 1:s[1]
dtoc[i, j, end, end, q] = dtoc[i, j, 1, 1, q]
end
end
end
return reshape(
dtoc,
s[1],
s[2],
columnnumberofcelldofs,
columnnumberofquadrants * s[end],
)
end
function materializectod(dtoc)
dtoc = vec(dtoc)
data = similar(dtoc, Bool)
fill!(data, true)
return sparse(1:length(dtoc), dtoc, data)
end
materializequadranttofacecode(nodes) = copy(P4estTypes.unsafe_face_code(nodes))
function extrudequadranttofacecode(unextrudedquadranttofacecode, columnnumberofquadrants)
return repeat(unextrudedquadranttofacecode, inner = columnnumberofquadrants)
end
function materializequadrantcommlists(localnumberofquadrants, quadrantcommpattern)
communicatingcells = unique!(sort(quadrantcommpattern.sendindices))
noncommunicatingcells = setdiff(0x1:localnumberofquadrants, communicatingcells)
return (communicatingcells, noncommunicatingcells)
end
function generate(warp::Function, gm::GridManager)
# Need to get integer coordinates of cells
A = arraytype(referencecell(gm))
ghost = P4estTypes.ghostlayer(forest(gm))
nodes = P4estTypes.lnodes(forest(gm); ghost, degree = 3)
P4estTypes.expand!(ghost, forest(gm), nodes)
localnumberofquadrants = P4estTypes.lengthoflocalquadrants(forest(gm))
(quadranttolevel, quadranttotreeid, quadranttocoordinate) =
materializequadrantdata(forest(gm), ghost)
quadranttoglobalid = materializequadranttoglobalid(forest(gm), ghost)
quadrantcommpattern = materializequadrantcommpattern(forest(gm), ghost)
(dtoc_degree3_local, dtoc_degree3_global) =
materializedtoc(forest(gm), ghost, nodes, quadrantcommpattern, comm(gm))
quadranttofacecode = materializequadranttofacecode(nodes)
if isextruded(coarsegrid(gm))
columnnumberofquadrants = columnlength(coarsegrid(gm))
localnumberofquadrants *= columnnumberofquadrants
(quadranttolevel, quadranttotreeid, quadranttocoordinate) = extrudequadrantdata(
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
columnnumberofquadrants,
)
quadranttoglobalid =
extrudequadranttoglobalid(quadranttoglobalid, columnnumberofquadrants)
quadrantcommpattern = expand(quadrantcommpattern, columnnumberofquadrants)
dtoc_degree3_local = extrudedtoc(
dtoc_degree3_local,
columnnumberofquadrants,
4,
last(isperiodic(coarsegrid(gm))),
)
dtoc_degree3_global = extrudedtoc(
dtoc_degree3_global,
columnnumberofquadrants,
4,
last(isperiodic(coarsegrid(gm))),
)
quadranttofacecode =
extrudequadranttofacecode(quadranttofacecode, columnnumberofquadrants)
end
discontinuoustocontinuous =
materializedtoc(referencecell(gm), dtoc_degree3_local, dtoc_degree3_global)
ctod_degree3_local = materializectod(dtoc_degree3_local)
facemaps, quadranttoboundary = materializefacemaps(
referencecell(gm),
localnumberofquadrants,
ctod_degree3_local,
dtoc_degree3_local,
dtoc_degree3_global,
quadranttolevel,
quadranttoglobalid,
)
continuoustodiscontinuous = materializectod(discontinuoustocontinuous)
nodecommpattern = materializenodecommpattern(
referencecell(gm),
continuoustodiscontinuous,
quadrantcommpattern,
)
parentnodes = materializeparentnodes(
referencecell(gm),
continuoustodiscontinuous,
quadranttoglobalid,
quadranttolevel,
)
communicatingquadrants, noncommunicatingquadrants =
materializequadrantcommlists(localnumberofquadrants, quadrantcommpattern)
# Send data to the device
quadranttolevel = A(pin(A, quadranttolevel))
quadranttotreeid = A(pin(A, quadranttotreeid))
quadranttocoordinate = A(pin(A, quadranttocoordinate))
quadranttofacecode = A(pin(A, quadranttofacecode))
quadranttoboundary = A(pin(A, quadranttoboundary))
parentnodes = A(pin(A, parentnodes))
nodecommpattern = Adapt.adapt(A, nodecommpattern)
continuoustodiscontinuous = adaptsparse(A, continuoustodiscontinuous)
discontinuoustocontinuous = Adapt.adapt(A, discontinuoustocontinuous)
communicatingquadrants = Adapt.adapt(A, communicatingquadrants)
noncommunicatingquadrants = Adapt.adapt(A, noncommunicatingquadrants)
facemaps = Adapt.adapt(A, facemaps)
if coarsegrid(gm) isa AbstractBrickGrid
points = materializebrickpoints(
referencecell(gm),
coarsegridcells(gm),
coarsegridvertices(gm),
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm(gm),
)
elseif coarsegrid(gm) isa MeshImportCoarseGrid
meshimport = Raven.meshimport(coarsegrid(gm))
quadranttointerpolation = materializequadranttointerpolation(meshimport)
quadranttointerpolation = A(pin(A, quadranttointerpolation))
faceinterpolation = interpolation(meshimport)
faceinterpolation = collect(
transpose(
reinterpret(reshape, eltype(eltype(faceinterpolation)), faceinterpolation),
),
)
faceinterpolation = A(pin(A, faceinterpolation))
points = materializepoints(
referencecell(gm),
coarsegridcells(gm),
coarsegridvertices(gm),
interpolationdegree(meshimport),
faceinterpolation,
quadranttointerpolation,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm(gm),
)
else
points = materializepoints(
referencecell(gm),
coarsegridcells(gm),
coarsegridvertices(gm),
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm(gm),
)
end
coarsegrid_warp = Raven.warp(coarsegrid(gm))
points = warp.(coarsegrid_warp.(points))
fillghosts!(points, fill(NaN, eltype(points)))
pcm = commmanager(eltype(points), nodecommpattern; comm = comm(gm))
share!(points, pcm)
isunwarpedbrick = coarsegrid(gm) isa AbstractBrickGrid && warp == identity
volumemetrics, surfacemetrics = materializemetrics(
referencecell(gm),
points,
facemaps,
comm(gm),
nodecommpattern,
isunwarpedbrick,
)
part = MPI.Comm_rank(comm(gm)) + 1
nparts = MPI.Comm_size(comm(gm))
GC.@preserve gm begin
global_first_quadrant = P4estTypes.unsafe_global_first_quadrant(forest(gm))
offset = global_first_quadrant[part]
end
if isextruded(coarsegrid(gm))
columnnumberofquadrants = columnlength(coarsegrid(gm))
offset *= columnnumberofquadrants
end
return Grid(
comm(gm),
part,
nparts,
referencecell(gm),
offset,
convert(Int, localnumberofquadrants),
points,
volumemetrics,
surfacemetrics,
quadranttolevel,
quadranttotreeid,
quadranttofacecode,
quadranttoboundary,
parentnodes,
nodecommpattern,
continuoustodiscontinuous,
discontinuoustocontinuous,
communicatingquadrants,
noncommunicatingquadrants,
facemaps,
)
end
function materializequadranttointerpolation(abaqus::AbaqusMeshImport)
dims = length(abaqus.connectivity[1]) == 4 ? 2 : 3
nodesperface = (abaqus.face_degree + 1)^(dims - 1)
numberofelements = length(abaqus.face_iscurved)
facesperelement = length(abaqus.face_iscurved[1])
quadranttointerpolation = Array{Int32}(undef, numberofelements, facesperelement)
idx = 1
for element = 1:numberofelements
for face = 1:facesperelement
if abaqus.face_iscurved[element][face] == 1
quadranttointerpolation[element, face] = idx
idx += nodesperface
else
quadranttointerpolation[element, face] = 0
end
end
end
return quadranttointerpolation
end
function Base.show(io::IO, g::GridManager)
compact = get(io, :compact, false)
print(io, "GridManager(")
show(io, referencecell(g))
print(io, ", ")
show(io, coarsegrid(g))
print(io, "; comm=")
show(io, comm(g))
print(io, ")")
if !compact
nlocal = P4estTypes.lengthoflocalquadrants(forest(g))
nglobal = P4estTypes.lengthofglobalquadrants(forest(g))
print(io, " with $nlocal of the $nglobal global elements")
end
return
end
function Base.showarg(io::IO, g::GridManager, toplevel)
!toplevel && print(io, "::")
print(io, "GridManager{")
Base.showarg(io, referencecell(g), false)
print(io, ", ")
Base.showarg(io, coarsegrid(g), false)
print(io, "}")
if toplevel
nlocal = P4estTypes.lengthoflocalquadrants(forest(g))
nglobal = P4estTypes.lengthofglobalquadrants(forest(g))
print(io, " with $nlocal of the $nglobal global elements")
end
return
end
Base.summary(io::IO, g::GridManager) = Base.showarg(io, g, true)
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 5324 | abstract type AbstractGrid{C<:AbstractCell} end
floattype(::Type{<:AbstractGrid{C}}) where {C} = floattype(C)
arraytype(::Type{<:AbstractGrid{C}}) where {C} = arraytype(C)
celltype(::Type{<:AbstractGrid{C}}) where {C} = C
floattype(grid::AbstractGrid) = floattype(typeof(grid))
arraytype(grid::AbstractGrid) = arraytype(typeof(grid))
celltype(grid::AbstractGrid) = celltype(typeof(grid))
struct Grid{C<:AbstractCell,P,V,S,L,T,F,B,PN,N,CTOD,DTOC,CC,NCC,FM} <: AbstractGrid{C}
comm::MPI.Comm
part::Int
nparts::Int
cell::C
offset::Int
locallength::Int
points::P
volumemetrics::V
surfacemetrics::S
levels::L
trees::T
facecodes::F
boundarycodes::B
parentnodes::PN
nodecommpattern::N
continuoustodiscontinuous::CTOD
discontinuoustocontinuous::DTOC
communicatingcells::CC
noncommunicatingcells::NCC
facemaps::FM
end
comm(grid::Grid) = grid.comm
referencecell(grid::Grid) = grid.cell
points(grid::Grid) = points(grid, Val(false))
points(grid::Grid, withghostlayer::Val{false}) = viewwithoutghosts(grid.points)
points(grid::Grid, withghostlayer::Val{true}) = viewwithghosts(grid.points)
levels(grid::Grid) = levels(grid, Val(false))
levels(grid::Grid, ::Val{false}) = view(grid.levels, Base.OneTo(grid.locallength))
levels(grid::Grid, ::Val{true}) = grid.levels
trees(grid::Grid) = trees(grid, Val(false))
trees(grid::Grid, ::Val{false}) = view(grid.trees, Base.OneTo(grid.locallength))
trees(grid::Grid, ::Val{true}) = grid.trees
facecodes(grid::Grid) = facecodes(grid, Val(false))
facecodes(grid::Grid, ::Val{false}) = grid.facecodes
facecodes(::Grid, ::Val{true}) =
throw(error("Face codes are currently stored for local quadrants."))
boundarycodes(grid::Grid) = boundarycodes(grid, Val(false))
boundarycodes(grid::Grid, ::Val{false}) = grid.boundarycodes
boundarycodes(::Grid, ::Val{true}) =
throw(error("Boundary codes are currently stored for local quadrants."))
nodecommpattern(grid::Grid) = grid.nodecommpattern
continuoustodiscontinuous(grid::Grid) = grid.continuoustodiscontinuous
communicatingcells(grid::Grid) = grid.communicatingcells
noncommunicatingcells(grid::Grid) = grid.noncommunicatingcells
volumemetrics(grid::Grid) = grid.volumemetrics
surfacemetrics(grid::Grid) = grid.surfacemetrics
facemaps(grid::Grid) = facemaps(grid, Val(false))
facemaps(grid::Grid, ::Val{false}) = grid.facemaps
facemaps(::Grid, ::Val{true}) =
throw(error("Face maps are currently stored for local quadrants."))
offset(grid::Grid) = grid.offset
numcells(grid::Grid) = numcells(grid, Val(false))
numcells(grid::Grid, ::Val{false}) = grid.locallength
numcells(grid::Grid, ::Val{true}) = length(grid.levels)
Base.length(grid::Grid) = grid.locallength
partitionnumber(grid::Grid) = grid.part
numberofpartitions(grid::Grid) = grid.nparts
@kernel function min_neighbour_distance_kernel(
min_neighbour_distance,
points,
::Val{S},
::Val{Np},
::Val{dims},
) where {S,Np,dims}
I = @index(Global, Linear)
@inbounds begin
e = (I - 1) ÷ Np + 1
ijk = (I - 1) % Np + 1
md = typemax(eltype(min_neighbour_distance))
x⃗ = points[ijk, e]
for d in dims
for m in (-1, 1)
ijknb = ijk + S[d] * m
if 1 <= ijknb <= Np
x⃗nb = points[ijknb, e]
md = min(norm(x⃗ - x⃗nb), md)
end
end
end
min_neighbour_distance[ijk, e] = md
end
end
function min_node_distance(grid::Grid; dims = 1:ndims(referencecell(grid)))
A = arraytype(grid)
T = floattype(grid)
cell = referencecell(grid)
if maximum(dims) > ndims(cell) || minimum(dims) < 1
throw(ArgumentError("dims are not valid"))
end
Np = length(cell)
x = reshape(points(grid), (Np, :))
min_neighbour_distance = A{T}(undef, size(x))
min_neighbour_distance_kernel(get_backend(A), 256)(
min_neighbour_distance,
x,
Val(strides(cell)),
Val(Np),
Val(dims);
ndrange = length(grid) * length(cell),
)
return MPI.Allreduce(minimum(min_neighbour_distance), min, comm(grid))
end
function faceviews(A::AbstractMatrix, cell::AbstractCell)
offsets = faceoffsets(cell)
facesizes = facedims(cell)
num_faces = length(facesizes)
if last(offsets) != size(A, 1)
throw(
ArgumentError(
"The first dimension of A needs to contain the face degrees of freedom.",
),
)
end
return ntuple(Val(num_faces)) do f
reshape(view(A, (1+offsets[f]):offsets[f+1], :), facesizes[f]..., :)
end
end
function Base.show(io::IO, g::Grid)
compact = get(io, :compact, false)
print(io, "Raven.Grid{")
show(io, referencecell(g))
print(io, "}()")
if !compact
nlocal = numcells(g, Val(false))
print(io, " with $nlocal local elements")
end
return
end
function Base.showarg(io::IO, g::Grid, toplevel)
!toplevel && print(io, "::")
print(io, "Raven.Grid{")
Base.showarg(io, referencecell(g), true)
print(io, "}")
if toplevel
nlocal = numcells(g, Val(false))
print(io, " with $nlocal local elements")
end
return
end
Base.summary(io::IO, g::Grid) = Base.showarg(io, g, true)
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 10685 | struct Kron{T}
args::T
Kron(args::Tuple) = new{typeof(args)}(args)
end
Adapt.adapt_structure(to, K::Kron) = Kron(map(x -> Adapt.adapt(to, x), K.args))
components(K::Kron) = K.args
Base.collect(K::Kron{Tuple{T}}) where {T} = collect(K.args[1])
Base.collect(K::Kron) = collect(kron(K.args...))
Base.size(K::Kron, j::Int) = prod(size.(K.args, j))
import Base.==
==(J::Kron, K::Kron) = all(J.args .== K.args)
import Base.*
@kernel function kron_D_kernel(r::AbstractArray{T}, d, g, ::Val{L}) where {T,L}
(i, j) = @index(Global, NTuple)
acc = zero(T)
@inbounds begin
@unroll for l in L
acc = muladd(d[i, l], g[l, j], acc)
end
r[i, j] = acc
end
end
function (*)(K::Kron{Tuple{D}}, f::F) where {D<:AbstractMatrix,F<:AbstractVecOrMat}
(d,) = components(K)
g = reshape(f, size(d, 2), :)
r = similar(f, size(d, 1), size(g, 2))
backend = get_backend(r)
kernel! = kron_D_kernel(backend, size(r, 1))
kernel!(r, d, g, Val(axes(d, 2)); ndrange = size(r))
return F <: AbstractVector ? vec(r) : reshape(r, size(K, 1), size(f, 2))
end
function (*)(K::Kron{Tuple{D}}, f::GridArray) where {D<:AbstractMatrix}
(d,) = components(K)
r = similar(f, size(d, 1), size(f, 2))
backend = get_backend(r)
kernel! = kron_D_kernel(backend, size(r, 1))
kernel!(r, d, f, Val(axes(d, 2)); ndrange = size(r))
return r
end
@kernel function kron_E_D_kernel(r::AbstractArray{T}, d, g, ::Val{L}) where {T,L}
(i, j, k) = @index(Global, NTuple)
acc = zero(T)
@inbounds begin
@unroll for l in L
acc = muladd(d[i, l], g[l, j, k], acc)
end
r[i, j, k] = acc
end
end
@inline (*)(::Kron{Tuple{E₂,E₁}}, f::F) where {E₁<:Eye,E₂<:Eye,F<:AbstractVecOrMat} =
copy(f)
@inline (*)(
::Kron{Tuple{E₃,E₂,E₁}},
f::F,
) where {E₁<:Eye,E₂<:Eye,E₃<:Eye,F<:AbstractVecOrMat} = copy(f)
@inline (*)(::Kron{Tuple{E₂,E₁}}, f::F) where {E₁<:Eye,E₂<:Eye,F<:GridVecOrMat} = copy(f)
@inline (*)(::Kron{Tuple{E₃,E₂,E₁}}, f::F) where {E₁<:Eye,E₂<:Eye,E₃<:Eye,F<:GridVecOrMat} =
copy(f)
@inline (*)(::Kron{Tuple{E₂,E₁}}, f::F) where {E₁<:Eye,E₂<:Eye,F<:GridArray} = copy(f)
@inline (*)(::Kron{Tuple{E₃,E₂,E₁}}, f::F) where {E₁<:Eye,E₂<:Eye,E₃<:Eye,F<:GridArray} =
copy(f)
function (*)(K::Kron{Tuple{E,D}}, f::F) where {D<:AbstractMatrix,E<:Eye,F<:AbstractVecOrMat}
e, d = components(K)
g = reshape(f, size(d, 2), size(e, 1), :)
r = similar(f, size(d, 1), size(e, 1), size(g, 3))
backend = get_backend(r)
kernel! = kron_E_D_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, g, Val(axes(d, 2)); ndrange = size(r))
return F <: AbstractVector ? vec(r) : reshape(r, size(K, 1), size(f, 2))
end
function (*)(K::Kron{Tuple{E,D}}, f::GridArray) where {D<:AbstractMatrix,E<:Eye}
e, d = components(K)
r = similar(f, size(d, 1), size(e, 1), size(f, 3))
backend = get_backend(r)
kernel! = kron_E_D_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, f, Val(axes(d, 2)); ndrange = size(r))
return r
end
@kernel function kron_D_E_kernel(r::AbstractArray{T}, d, g, ::Val{L}) where {T,L}
(i, j, k) = @index(Global, NTuple)
acc = zero(T)
@inbounds begin
@unroll for l in L
acc = muladd(d[j, l], g[i, l, k], acc)
end
r[i, j, k] = acc
end
end
function (*)(K::Kron{Tuple{D,E}}, f::F) where {D<:AbstractMatrix,E<:Eye,F<:AbstractVecOrMat}
d, e = components(K)
g = reshape(f, size(e, 1), size(d, 2), :)
r = similar(f, size(e, 1), size(d, 1), size(g, 3))
backend = get_backend(r)
kernel! = kron_D_E_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, g, Val(axes(d, 2)); ndrange = size(r))
return F <: AbstractVector ? vec(r) : reshape(r, size(K, 1), size(f, 2))
end
function (*)(K::Kron{Tuple{D,E}}, f::GridArray) where {D<:AbstractMatrix,E<:Eye}
d, e = components(K)
r = similar(f, size(e, 1), size(d, 1), size(f, 3))
backend = get_backend(r)
kernel! = kron_D_E_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, f, Val(axes(d, 2)); ndrange = size(r))
return r
end
@kernel function kron_B_A_kernel(
r::AbstractArray{T},
a,
b,
g,
::Val{L},
::Val{M},
) where {T,L,M}
(i, j, k) = @index(Global, NTuple)
acc = zero(T)
@inbounds begin
# TODO: use temporary space to reduce complexity
@unroll for m in M
@unroll for l in L
acc = muladd(b[j, m] * a[i, l], g[l, m, k], acc)
end
end
r[i, j, k] = acc
end
end
function (*)(
K::Kron{Tuple{B,A}},
f::F,
) where {A<:AbstractMatrix,B<:AbstractMatrix,F<:AbstractVecOrMat}
b, a = components(K)
g = reshape(f, size(a, 2), size(b, 2), :)
r = similar(f, size(a, 1), size(b, 1), size(g, 3))
backend = get_backend(r)
kernel! = kron_B_A_kernel(backend, size(r)[begin:end-1])
kernel!(r, a, b, g, Val(axes(a, 2)), Val(axes(b, 2)); ndrange = size(r))
return F <: AbstractVector ? vec(r) : reshape(r, size(K, 1), size(f, 2))
end
function (*)(K::Kron{Tuple{B,A}}, f::GridArray) where {A<:AbstractMatrix,B<:AbstractMatrix}
b, a = components(K)
r = similar(f, size(a, 1), size(b, 1), size(f, 3))
backend = get_backend(r)
kernel! = kron_B_A_kernel(backend, size(r)[begin:end-1])
kernel!(r, a, b, f, Val(axes(a, 2)), Val(axes(b, 2)); ndrange = size(r))
return r
end
@kernel function kron_E_E_D_kernel(r::AbstractArray{T}, d, g, ::Val{L}) where {T,L}
(i, j, k, e) = @index(Global, NTuple)
acc = zero(T)
@inbounds begin
@unroll for l in L
acc = muladd(d[i, l], g[l, j, k, e], acc)
end
r[i, j, k, e] = acc
end
end
function (*)(
K::Kron{Tuple{E₃,E₂,D}},
f::F,
) where {D<:AbstractMatrix,E₃<:Eye,E₂<:Eye,F<:AbstractVecOrMat}
e₃, e₂, d = components(K)
g = reshape(f, size(d, 2), size(e₂, 1), size(e₃, 1), :)
r = similar(f, size(d, 1), size(e₂, 1), size(e₃, 1), size(g, 4))
backend = get_backend(r)
kernel! = kron_E_E_D_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, g, Val(axes(d, 2)); ndrange = size(r))
return F <: AbstractVector ? vec(r) : reshape(r, size(K, 1), size(f, 2))
end
function (*)(
K::Kron{Tuple{E₃,E₂,D}},
f::GridArray,
) where {D<:AbstractMatrix,E₃<:Eye,E₂<:Eye}
e₃, e₂, d = components(K)
r = similar(f, size(d, 1), size(e₂, 1), size(e₃, 1), size(f, 4))
backend = get_backend(r)
kernel! = kron_E_E_D_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, f, Val(axes(d, 2)); ndrange = size(r))
return r
end
@kernel function kron_E_D_E_kernel(r::AbstractArray{T}, d, g, ::Val{L}) where {T,L}
(i, j, k, e) = @index(Global, NTuple)
acc = zero(T)
@inbounds begin
@unroll for l in L
acc = muladd(d[j, l], g[i, l, k, e], acc)
end
r[i, j, k, e] = acc
end
end
function (*)(
K::Kron{Tuple{E₃,D,E₁}},
f::F,
) where {D<:AbstractMatrix,E₁<:Eye,E₃<:Eye,F<:AbstractVecOrMat}
e₃, d, e₁ = components(K)
g = reshape(f, size(e₁, 1), size(d, 2), size(e₃, 1), :)
r = similar(f, size(e₁, 1), size(d, 1), size(e₃, 1), size(g, 4))
backend = get_backend(r)
kernel! = kron_E_D_E_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, g, Val(axes(d, 2)); ndrange = size(r))
return F <: AbstractVector ? vec(r) : reshape(r, size(K, 1), size(f, 2))
end
function (*)(
K::Kron{Tuple{E₃,D,E₁}},
f::GridArray,
) where {D<:AbstractMatrix,E₁<:Eye,E₃<:Eye}
e₃, d, e₁ = components(K)
r = similar(f, size(e₁, 1), size(d, 1), size(e₃, 1), size(f, 4))
backend = get_backend(r)
kernel! = kron_E_D_E_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, f, Val(axes(d, 2)); ndrange = size(r))
return r
end
@kernel function kron_D_E_E_kernel(r::AbstractArray{T}, d, g, ::Val{L}) where {T,L}
(i, j, k, e) = @index(Global, NTuple)
acc = zero(T)
@inbounds begin
@unroll for l in L
acc = muladd(d[k, l], g[i, j, l, e], acc)
end
r[i, j, k, e] = acc
end
end
function (*)(
K::Kron{Tuple{D,E₂,E₁}},
f::F,
) where {D<:AbstractMatrix,E₁<:Eye,E₂<:Eye,F<:AbstractVecOrMat}
d, e₂, e₁ = components(K)
g = reshape(f, size(e₁, 1), size(e₂, 1), size(d, 2), :)
r = similar(f, size(e₁, 1), size(e₂, 1), size(d, 1), size(g, 4))
backend = get_backend(r)
kernel! = kron_D_E_E_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, g, Val(axes(d, 2)); ndrange = size(r))
return F <: AbstractVector ? vec(r) : reshape(r, size(K, 1), size(f, 2))
end
function (*)(
K::Kron{Tuple{D,E₂,E₁}},
f::GridArray,
) where {D<:AbstractMatrix,E₁<:Eye,E₂<:Eye}
d, e₂, e₁ = components(K)
r = similar(f, size(e₁, 1), size(e₂, 1), size(d, 1), size(f, 4))
backend = get_backend(r)
kernel! = kron_D_E_E_kernel(backend, size(r)[begin:end-1])
kernel!(r, d, f, Val(axes(d, 2)); ndrange = size(r))
return r
end
@kernel function kron_C_B_A_kernel(
r::AbstractArray{T},
a,
b,
c,
g,
::Val{L},
::Val{M},
::Val{N},
) where {T,L,M,N}
(i, j, k, e) = @index(Global, NTuple)
acc = zero(T)
@inbounds begin
# TODO: use temporary space to reduce complexity
@unroll for l in L
@unroll for m in M
@unroll for n in N
acc = muladd(c[k, n] * b[j, m] * a[i, l], g[l, m, n, e], acc)
end
end
end
r[i, j, k, e] = acc
end
end
function (*)(
K::Kron{Tuple{C,B,A}},
f::F,
) where {A<:AbstractMatrix,B<:AbstractMatrix,C<:AbstractMatrix,F<:AbstractVecOrMat}
c, b, a = components(K)
g = reshape(f, size(a, 2), size(b, 2), size(c, 2), :)
r = similar(f, size(a, 1), size(b, 1), size(c, 1), size(g, 4))
backend = get_backend(r)
kernel! = kron_C_B_A_kernel(backend, size(r)[begin:end-1])
kernel!(
r,
a,
b,
c,
g,
Val(axes(a, 2)),
Val(axes(b, 2)),
Val(axes(c, 2));
ndrange = size(r),
)
return F <: AbstractVector ? vec(r) : reshape(r, size(K, 1), size(f, 2))
end
function (*)(
K::Kron{Tuple{C,B,A}},
f::GridArray,
) where {A<:AbstractMatrix,B<:AbstractMatrix,C<:AbstractMatrix}
c, b, a = components(K)
r = similar(f, size(a, 1), size(b, 1), size(c, 1), size(f, 4))
backend = get_backend(r)
kernel! = kron_C_B_A_kernel(backend, size(r)[begin:end-1])
kernel!(
r,
a,
b,
c,
f,
Val(axes(a, 2)),
Val(axes(b, 2)),
Val(axes(c, 2));
ndrange = size(r),
)
return r
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 84048 | function lobattooperators_1d(::Type{T}, M) where {T}
oldprecision = precision(BigFloat)
# Increase precision of the type used to compute the 1D operators to help
# ensure any symmetries. This is not thread safe so an alternative would
# be to use ArbNumerics.jl which keeps its precision in the type.
setprecision(BigFloat, 2^(max(8, ceil(Int, log2(precision(T))) + 2)))
points, weights = legendregausslobatto(BigFloat, M)
gausspoints, _ = legendregauss(BigFloat, M)
derivative = spectralderivative(points)
weightedderivative = weights .* derivative
skewweightedderivative = (weightedderivative - weightedderivative') / 2
equallyspacedpoints = range(-one(BigFloat), stop = one(BigFloat), length = M)
toequallyspaced = spectralinterpolation(points, equallyspacedpoints)
tolowerhalf = spectralinterpolation(points, (points .- 1) ./ 2)
toupperhalf = spectralinterpolation(points, (points .+ 1) ./ 2)
togauss = spectralinterpolation(points, gausspoints)
tolobatto = spectralinterpolation(points, points)
toboundary = spectralinterpolation(points, [-1, 1])
setprecision(oldprecision)
points = Array{T}(points)
weights = Array{T}(weights)
derivative = Array{T}(derivative)
weightedderivative = Array{T}(weightedderivative)
skewweightedderivative = Array{T}(skewweightedderivative)
toequallyspaced = Array{T}(toequallyspaced)
tohalves = (Array{T}(tolowerhalf), Array{T}(toupperhalf))
togauss = Array{T}(togauss)
tolobatto = Array{T}(tolobatto)
toboundary = Array{T}(toboundary)
return (;
points,
weights,
derivative,
weightedderivative,
skewweightedderivative,
toequallyspaced,
tohalves,
togauss,
tolobatto,
toboundary,
)
end
struct LobattoCell{T,A,N,S,O,P,D,WD,SWD,M,FM,E,H,TG,TL,TB} <: AbstractCell{T,A,N}
size::S
points_1d::O
weights_1d::O
points::P
derivatives::D
weightedderivatives::WD
skewweightedderivatives::SWD
mass::M
facemass::FM
toequallyspaced::E
tohalves_1d::H
togauss::TG
tolobatto::TL
toboundary::TB
end
function Base.similar(::LobattoCell{T,A}, dims::Dims) where {T,A}
return LobattoCell{T,A}(dims...)
end
function Base.show(io::IO, cell::LobattoCell{T,A}) where {T,A}
print(io, "LobattoCell{")
Base.show(io, T)
print(io, ", ")
Base.show(io, A)
print(io, "}$(size(cell))")
end
function Base.showarg(io::IO, ::LobattoCell{T,A,N}, toplevel) where {T,A,N}
!toplevel && print(io, "::")
print(io, "LobattoCell{", T, ",", A, ",", N, "}")
return
end
function Base.summary(io::IO, cell::LobattoCell{T,A,N}) where {T,A,N}
d = Base.dims2string(size(cell))
print(io, "$d LobattoCell{", T, ",", A, ",", N, "}")
end
function LobattoCell{T,A}(m) where {T,A}
o = adapt(A, lobattooperators_1d(T, m))
points_1d = (o.points,)
weights_1d = (o.weights,)
points = vec(SVector.(points_1d...))
derivatives = (Kron((o.derivative,)),)
weightedderivatives = (Kron((o.weightedderivative,)),)
skewweightedderivatives = (Kron((o.skewweightedderivative,)),)
mass = Diagonal(vec(.*(weights_1d...)))
facemass = adapt(A, Diagonal([T(1), T(1)]))
toequallyspaced = Kron((o.toequallyspaced,))
tohalves_1d = ((o.tohalves[1], o.tohalves[2]),)
togauss = Kron((o.togauss,))
tolobatto = Kron((o.tolobatto,))
toboundary = Kron((o.toboundary,))
args = (
(m,),
points_1d,
weights_1d,
points,
derivatives,
weightedderivatives,
skewweightedderivatives,
mass,
facemass,
toequallyspaced,
tohalves_1d,
togauss,
tolobatto,
toboundary,
)
LobattoCell{T,A,1,typeof(args[1]),typeof.(args[3:end])...}(args...)
end
function LobattoCell{T,A}(m1, m2) where {T,A}
o = adapt(A, (lobattooperators_1d(T, m1), lobattooperators_1d(T, m2)))
points_1d = (reshape(o[1].points, (m1, 1)), reshape(o[2].points, (1, m2)))
weights_1d = (reshape(o[1].weights, (m1, 1)), reshape(o[2].weights, (1, m2)))
points = vec(SVector.(points_1d...))
derivatives = (Kron((Eye{T}(m2), o[1].derivative)), Kron((o[2].derivative, Eye{T}(m1))))
weightedderivatives = (
Kron((Eye{T}(m2), o[1].weightedderivative)),
Kron((o[2].weightedderivative, Eye{T}(m1))),
)
skewweightedderivatives = (
Kron((Eye{T}(m2), o[1].skewweightedderivative)),
Kron((o[2].skewweightedderivative, Eye{T}(m1))),
)
mass = Diagonal(vec(.*(weights_1d...)))
ω1, ω2 = weights_1d
facemass = Diagonal(vcat(repeat(vec(ω2), 2), repeat(vec(ω1), 2)))
toequallyspaced = Kron((o[2].toequallyspaced, o[1].toequallyspaced))
tohalves_1d =
((o[1].tohalves[1], o[1].tohalves[2]), (o[2].tohalves[1], o[2].tohalves[2]))
togauss = Kron((o[2].togauss, o[1].togauss))
tolobatto = Kron((o[2].tolobatto, o[1].tolobatto))
toboundary = Kron((o[2].toboundary, o[1].toboundary))
args = (
(m1, m2),
points_1d,
weights_1d,
points,
derivatives,
weightedderivatives,
skewweightedderivatives,
mass,
facemass,
toequallyspaced,
tohalves_1d,
togauss,
tolobatto,
toboundary,
)
LobattoCell{T,A,2,typeof(args[1]),typeof.(args[3:end])...}(args...)
end
function LobattoCell{T,A}(m1, m2, m3) where {T,A}
o = adapt(
A,
(
lobattooperators_1d(T, m1),
lobattooperators_1d(T, m2),
lobattooperators_1d(T, m3),
),
)
points_1d = (
reshape(o[1].points, (m1, 1, 1)),
reshape(o[2].points, (1, m2, 1)),
reshape(o[3].points, (1, 1, m3)),
)
weights_1d = (
reshape(o[1].weights, (m1, 1, 1)),
reshape(o[2].weights, (1, m2, 1)),
reshape(o[3].weights, (1, 1, m3)),
)
points = vec(SVector.(points_1d...))
derivatives = (
Kron((Eye{T}(m3), Eye{T}(m2), o[1].derivative)),
Kron((Eye{T}(m3), o[2].derivative, Eye{T}(m1))),
Kron((o[3].derivative, Eye{T}(m2), Eye{T}(m1))),
)
weightedderivatives = (
Kron((Eye{T}(m3), Eye{T}(m2), o[1].weightedderivative)),
Kron((Eye{T}(m3), o[2].weightedderivative, Eye{T}(m1))),
Kron((o[3].weightedderivative, Eye{T}(m2), Eye{T}(m1))),
)
skewweightedderivatives = (
Kron((Eye{T}(m3), Eye{T}(m2), o[1].skewweightedderivative)),
Kron((Eye{T}(m3), o[2].skewweightedderivative, Eye{T}(m1))),
Kron((o[3].skewweightedderivative, Eye{T}(m2), Eye{T}(m1))),
)
mass = Diagonal(vec(.*(weights_1d...)))
ω1, ω2, ω3 = weights_1d
facemass = Diagonal(
vcat(repeat(vec(ω2 .* ω3), 2), repeat(vec(ω1 .* ω3), 2), repeat(vec(ω1 .* ω2), 2)),
)
toequallyspaced =
Kron((o[3].toequallyspaced, o[2].toequallyspaced, o[1].toequallyspaced))
tohalves_1d = (
(o[1].tohalves[1], o[1].tohalves[2]),
(o[2].tohalves[1], o[2].tohalves[2]),
(o[3].tohalves[1], o[3].tohalves[2]),
)
togauss = Kron((o[3].togauss, o[2].togauss, o[1].togauss))
tolobatto = Kron((o[3].tolobatto, o[2].tolobatto, o[1].tolobatto))
toboundary = Kron((o[3].toboundary, o[2].toboundary, o[1].toboundary))
args = (
(m1, m2, m3),
points_1d,
weights_1d,
points,
derivatives,
weightedderivatives,
skewweightedderivatives,
mass,
facemass,
toequallyspaced,
tohalves_1d,
togauss,
tolobatto,
toboundary,
)
LobattoCell{T,A,3,typeof(args[1]),typeof.(args[3:end])...}(args...)
end
LobattoCell{T}(args...) where {T} = LobattoCell{T,Array}(args...)
LobattoCell(args...) = LobattoCell{Float64}(args...)
function Adapt.adapt_structure(to, cell::LobattoCell{T,A,N}) where {T,A,N}
names = fieldnames(LobattoCell)
args = ntuple(j -> adapt(to, getfield(cell, names[j])), length(names))
B = arraytype(to)
LobattoCell{T,B,N,typeof(args[1]),typeof.(args[3:end])...}(args...)
end
const LobattoLine{T,A} = LobattoCell{T,A,1}
const LobattoQuad{T,A} = LobattoCell{T,A,2}
const LobattoHex{T,A} = LobattoCell{T,A,3}
Base.size(cell::LobattoCell) = cell.size
points_1d(cell::LobattoCell) = cell.points_1d
weights_1d(cell::LobattoCell) = cell.weights_1d
points(cell::LobattoCell) = cell.points
derivatives(cell::LobattoCell) = cell.derivatives
weightedderivatives(cell::LobattoCell) = cell.weightedderivatives
skewweightedderivatives(cell::LobattoCell) = cell.skewweightedderivatives
function derivatives_1d(cell::LobattoCell)
N = ndims(cell)
ntuple(i -> cell.derivatives[i].args[N-i+1], Val(N))
end
function weightedderivatives_1d(cell::LobattoCell)
N = ndims(cell)
ntuple(i -> cell.weightedderivatives[i].args[N-i+1], Val(N))
end
function skewweightedderivatives_1d(cell::LobattoCell)
N = ndims(cell)
ntuple(i -> cell.skewweightedderivatives[i].args[N-i+1], Val(N))
end
mass(cell::LobattoCell) = cell.mass
facemass(cell::LobattoCell) = cell.facemass
toequallyspaced(cell::LobattoCell) = cell.toequallyspaced
tohalves_1d(cell::LobattoCell) = cell.tohalves_1d
degrees(cell::LobattoCell) = size(cell) .- 1
togauss(cell::LobattoCell) = cell.togauss
tolobatto(cell::LobattoCell) = cell.tolobatto
toboundary(cell::LobattoCell) = cell.toboundary
togauss_1d(cell::LobattoCell) = reverse(cell.togauss.args)
tolobatto_1d(cell::LobattoCell) = reverse(cell.tolobatto.args)
toboundary_1d(cell::LobattoCell) = reverse(cell.toboundary.args)
faceoffsets(::LobattoLine) = (0, 1, 2)
function faceoffsets(cell::LobattoQuad)
Nf = (size(cell, 2), size(cell, 2), size(cell, 1), size(cell, 1))
return cumsum((0, Nf...))
end
function faceoffsets(cell::LobattoHex)
Nf = (
size(cell, 2) * size(cell, 3),
size(cell, 2) * size(cell, 3),
size(cell, 1) * size(cell, 3),
size(cell, 1) * size(cell, 3),
size(cell, 1) * size(cell, 2),
size(cell, 1) * size(cell, 2),
)
return cumsum((0, Nf...))
end
@kernel function quadpoints!(
points,
ri,
si,
coarsegridcells,
coarsegridvertices,
numberofquadrants,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
::Val{I},
::Val{J},
::Val{Q},
) where {I,J,Q}
i, j, q1 = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@uniform T = eltype(eltype(points))
treecoords = @localmem eltype(points) (2, 2, Q)
rl = @localmem eltype(ri) (I,)
sl = @localmem eltype(si) (J,)
@inbounds begin
if q ≤ numberofquadrants
if j == 1 && q1 == 1
rl[i] = ri[i]
end
if i == 1 && q1 == 1
sl[j] = si[j]
end
if i ≤ 2 && j ≤ 2
treeid = quadranttotreeid[q]
vids = coarsegridcells[treeid]
treecoords[i, j, q1] = coarsegridvertices[vids[i+2*(j-1)]]
end
end
end
@synchronize
@inbounds begin
if q ≤ numberofquadrants
treeid = quadranttotreeid[q]
level = quadranttolevel[q]
ix = quadranttocoordinate[q, 1]
iy = quadranttocoordinate[q, 2]
P4EST_MAXLEVEL = 30
P4EST_ROOT_LEN = 1 << P4EST_MAXLEVEL
cr = T(ix) / P4EST_ROOT_LEN
cs = T(iy) / P4EST_ROOT_LEN
h = one(T) / (1 << (level + 1))
r = cr + h * (rl[i] + 1)
s = cs + h * (sl[j] + 1)
w1 = (1 - r) * (1 - s)
w2 = r * (1 - s)
w3 = (1 - r) * s
w4 = r * s
c1 = treecoords[1, 1, q1]
c2 = treecoords[2, 1, q1]
c3 = treecoords[1, 2, q1]
c4 = treecoords[2, 2, q1]
points[i, j, q] = w1 * c1 + w2 * c2 + w3 * c3 + w4 * c4
end
end
end
function materializepoints(
referencecell::LobattoQuad,
coarsegridcells,
coarsegridvertices,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm,
)
r = vec.(points_1d(referencecell))
Q = max(512 ÷ prod(length.(r)), 1)
IntType = typeof(length(r))
num_local = IntType(localnumberofquadrants)
points = GridArray{eltype(coarsegridvertices)}(
undef,
arraytype(referencecell),
(length.(r)..., num_local),
(length.(r)..., length(quadranttolevel)),
comm,
false,
length(r) + 1,
)
backend = get_backend(points)
kernel! = quadpoints!(backend, (length.(r)..., Q))
kernel!(
points,
r...,
coarsegridcells,
coarsegridvertices,
length(quadranttolevel),
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
Val.(length.(r))...,
Val(Q);
ndrange = size(points),
)
return points
end
function materializepoints(
referencecell::LobattoQuad,
coarsegridcells,
coarsegridvertices,
interpolation_degree,
faceinterpolation,
quadranttointerpolation,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm,
)
r = vec.(points_1d(referencecell))
FT = floattype(referencecell)
AT = arraytype(referencecell)
N = (interpolation_degree + 1, interpolation_degree + 1)
interp_r = vec.(points_1d(LobattoCell{FT,AT}(N...)))
Q = max(512 ÷ prod(length.(r)), 1)
IntType = typeof(length(r))
num_local = IntType(localnumberofquadrants)
points = GridArray{eltype(coarsegridvertices)}(
undef,
arraytype(referencecell),
(length.(r)..., num_local),
(length.(r)..., length(quadranttolevel)),
comm,
false,
length(r) + 1,
)
backend = get_backend(points)
kernel! = curvedquadpoints!(backend, (length.(r)..., Q))
kernel!(
points,
r...,
interp_r...,
coarsegridcells,
coarsegridvertices,
interpolation_degree,
faceinterpolation,
quadranttointerpolation,
length(quadranttolevel),
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
Val.(length.(r))...,
Val(Q);
ndrange = size(points),
)
return points
end
@inline function interp(t, n, data, offset, degree)
x = zero(t)
y = zero(t)
t = 2 * t - 1
for i = 1:degree+1
li = one(t)
for j = 1:degree+1
if i != j
li *= (t - n[j]) / (n[i] - n[j])
end
end
x += data[offset+i-1, 1] * li
y += data[offset+i-1, 2] * li
end
return x, y
end
@inline function bary_interp(t, n, data, offset, degree)
x = zero(t)
y = zero(t)
denom = zero(t)
t = 2 * t - 1
w = ones(typeof(t), degree + 1)
for i = 1:degree+1
for j = 1:degree+1
if i ≠ j
w[i] *= (n[i] - n[j])
end
end
w[i] = 1 / w[i]
end
for i = 1:degree+1
if i != 1 || i != degree + 1
x += w[i] * data[offset+i-1, 1] / (t - n[i])
y += w[i] * data[offset+i-1, 2] / (t - n[i])
denom += w[i] / (t - n[i])
else
x += data[offset+i-1, 1]
y += data[offset+i-1, 2]
end
end
return x / denom, y / denom
end
@inline function interp(t, s, n_t, n_s, data, offset, degree)
x = zero(t)
y = zero(t)
z = zero(t)
for i = 1:degree+1
for j = 1:degree+1
li_t = one(t)
li_s = one(s)
for k = 1:degree+1
if i != k
li_t *= (t - n_t[k]) / (n_t[i] - n_t[k])
end
end
for k = 1:degree+1
if j != k
li_s *= (s - n_s[k]) / (n_s[j] - n_s[k])
end
end
x += data[offset+(j-1)*(degree+1)+i-1, 1] * li_t * li_s
y += data[offset+(j-1)*(degree+1)+i-1, 2] * li_t * li_s
z += data[offset+(j-1)*(degree+1)+i-1, 3] * li_t * li_s
end
end
return x, y, z
end
@kernel function curvedquadpoints!(
points,
ri,
si,
interp_r,
interp_s,
coarsegridcells,
coarsegridvertices,
interpolation_degree,
faceinterpolation,
quadranttointerpolation,
numberofquadrants,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
::Val{I},
::Val{J},
::Val{Q},
) where {I,J,Q}
i, j, q1 = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@uniform T = eltype(eltype(points))
treecoords = @localmem eltype(points) (2, 2, Q)
rl = @localmem eltype(ri) (I,)
sl = @localmem eltype(si) (J,)
@inbounds begin
if q ≤ numberofquadrants
if j == 1 && q1 == 1
rl[i] = ri[i]
end
if i == 1 && q1 == 1
sl[j] = si[j]
end
if i ≤ 2 && j ≤ 2
treeid = quadranttotreeid[q]
vids = coarsegridcells[treeid]
treecoords[i, j, q1] = coarsegridvertices[vids[i+2*(j-1)]]
end
end
end
@synchronize
@inbounds begin
if q ≤ numberofquadrants
treeid = quadranttotreeid[q]
level = quadranttolevel[q]
ix = quadranttocoordinate[q, 1]
iy = quadranttocoordinate[q, 2]
P4EST_MAXLEVEL = 30
P4EST_ROOT_LEN = 1 << P4EST_MAXLEVEL
cr = T(ix) / P4EST_ROOT_LEN
cs = T(iy) / P4EST_ROOT_LEN
h = one(T) / (1 << (level + 1))
r = cr + h * (rl[i] + 1)
s = cs + h * (sl[j] + 1)
interp_idx1 = quadranttointerpolation[treeid, 1]
interp_idx2 = quadranttointerpolation[treeid, 2]
interp_idx3 = quadranttointerpolation[treeid, 3]
interp_idx4 = quadranttointerpolation[treeid, 4]
c1 = treecoords[1, 1, q1]
c2 = treecoords[2, 1, q1]
c3 = treecoords[1, 2, q1]
c4 = treecoords[2, 2, q1]
if interp_idx1 != 0
f1x, f1y = interp(
r,
interp_r,
faceinterpolation,
interp_idx1,
interpolation_degree,
)
else
f1x, f1y = c1 .+ (r * (c2 - c1))
end
if interp_idx2 != 0
f2x, f2y = interp(
s,
interp_s,
faceinterpolation,
interp_idx2,
interpolation_degree,
)
else
f2x, f2y = c2 .+ (s * (c4 - c2))
end
if interp_idx3 != 0
f3x, f3y = interp(
r,
interp_r,
faceinterpolation,
interp_idx3,
interpolation_degree,
)
else
f3x, f3y = c3 .+ (r * (c4 - c3))
end
if interp_idx4 != 0
f4x, f4y = interp(
s,
interp_s,
faceinterpolation,
interp_idx4,
interpolation_degree,
)
else
f4x, f4y = c1 .+ (s * (c3 - c1))
end
x = (1 - s) * f1x + s * f3x + (1 - r) * f4x + r * f2x
-(1 - s) * (1 - r) * c1[1] - (1 - s) * r * c3[1]
-s * (1 - r) * c2[1] - s * r * c4[1]
y = (1 - s) * f1y + s * f3y + (1 - r) * f4y + r * f2y
-(1 - s) * (1 - r) * c1[2] - (1 - s) * r * c3[2]
-s * (1 - r) * c2[2] - s * r * c4[2]
points[i, j, q] = (x / 2, y / 2)
end
end
end
@kernel function quadbrickpoints!(
points,
ri,
si,
coarsegridcells,
coarsegridvertices,
numberofquadrants,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
::Val{I},
::Val{J},
::Val{Q},
) where {I,J,Q}
i, j, q1 = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@uniform T = eltype(eltype(points))
treecoords = @localmem eltype(points) (2, 2, Q)
rl = @localmem eltype(ri) (I,)
sl = @localmem eltype(si) (J,)
@inbounds begin
if q ≤ numberofquadrants
if j == 1 && q1 == 1
rl[i] = ri[i]
end
if i == 1 && q1 == 1
sl[j] = si[j]
end
if i ≤ 2 && j ≤ 2
treeid = quadranttotreeid[q]
vids = coarsegridcells[treeid]
treecoords[i, j, q1] = coarsegridvertices[vids[i+2*(j-1)]]
end
end
end
@synchronize
@inbounds begin
if q ≤ numberofquadrants
treeid = quadranttotreeid[q]
level = quadranttolevel[q]
ix = quadranttocoordinate[q, 1]
iy = quadranttocoordinate[q, 2]
P4EST_MAXLEVEL = 30
P4EST_ROOT_LEN = 1 << P4EST_MAXLEVEL
cr = T(ix) / P4EST_ROOT_LEN
cs = T(iy) / P4EST_ROOT_LEN
h = one(T) / (1 << (level + 1))
r = muladd(h, (rl[i] + 1), cr)
s = muladd(h, (sl[j] + 1), cs)
c1 = treecoords[1, 1, q1]
c2 = treecoords[2, 1, q1]
c3 = treecoords[1, 2, q1]
dx = c2[1] - c1[1]
dy = c3[2] - c1[2]
points[i, j, q] = SVector(muladd(dx, r, c1[1]), muladd(dy, s, c1[2]))
end
end
end
function materializebrickpoints(
referencecell::LobattoQuad,
coarsegridcells,
coarsegridvertices,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm,
)
r = vec.(points_1d(referencecell))
Q = max(512 ÷ prod(length.(r)), 1)
IntType = typeof(length(r))
num_local = IntType(localnumberofquadrants)
points = GridArray{eltype(coarsegridvertices)}(
undef,
arraytype(referencecell),
(length.(r)..., num_local),
(length.(r)..., length(quadranttolevel)),
comm,
false,
length(r) + 1,
)
backend = get_backend(points)
kernel! = quadbrickpoints!(backend, (length.(r)..., Q))
kernel!(
points,
r...,
coarsegridcells,
coarsegridvertices,
length(quadranttolevel),
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
Val.(length.(r))...,
Val(Q);
ndrange = size(points),
)
return points
end
@kernel function hexpoints!(
points,
ri,
si,
ti,
coarsegridcells,
coarsegridvertices,
numberofquadrants,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
::Val{I},
::Val{J},
::Val{K},
) where {I,J,K}
i, j, k = @index(Local, NTuple)
q = @index(Group, Linear)
@uniform T = eltype(eltype(points))
treecoords = @localmem eltype(points) (2, 2, 2)
rl = @localmem eltype(ri) (I,)
sl = @localmem eltype(si) (J,)
tl = @localmem eltype(ti) (K,)
@inbounds begin
if q ≤ numberofquadrants
if j == 1 && k == 1
rl[i] = ri[i]
end
if i == 1 && k == 1
sl[j] = si[j]
end
if i == 1 && j == 1
tl[k] = ti[k]
end
if i ≤ 2 && j ≤ 2 && k ≤ 2
treeid = quadranttotreeid[q]
vids = coarsegridcells[treeid]
id = i + 2 * (j - 1) + 4 * (k - 1)
treecoords[i, j, k] = coarsegridvertices[vids[id]]
end
end
end
@synchronize
@inbounds begin
if q ≤ numberofquadrants
treeid = quadranttotreeid[q]
level = quadranttolevel[q]
ix = quadranttocoordinate[q, 1]
iy = quadranttocoordinate[q, 2]
iz = quadranttocoordinate[q, 3]
P4EST_MAXLEVEL = 30
P4EST_ROOT_LEN = 1 << P4EST_MAXLEVEL
cr = T(ix) / P4EST_ROOT_LEN
cs = T(iy) / P4EST_ROOT_LEN
ct = T(iz) / P4EST_ROOT_LEN
h = one(T) / (1 << (level + 1))
r = cr + h * (rl[i] + 1)
s = cs + h * (sl[j] + 1)
t = ct + h * (tl[k] + 1)
w1 = (1 - r) * (1 - s) * (1 - t)
w2 = r * (1 - s) * (1 - t)
w3 = (1 - r) * s * (1 - t)
w4 = r * s * (1 - t)
w5 = (1 - r) * (1 - s) * t
w6 = r * (1 - s) * t
w7 = (1 - r) * s * t
w8 = r * s * t
points[i, j, k, q] =
w1 * treecoords[1] +
w2 * treecoords[2] +
w3 * treecoords[3] +
w4 * treecoords[4] +
w5 * treecoords[5] +
w6 * treecoords[6] +
w7 * treecoords[7] +
w8 * treecoords[8]
end
end
end
function materializepoints(
referencecell::LobattoHex,
coarsegridcells,
coarsegridvertices,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm,
)
r = vec.(points_1d(referencecell))
IntType = typeof(length(r))
num_local = IntType(localnumberofquadrants)
points = GridArray{eltype(coarsegridvertices)}(
undef,
arraytype(referencecell),
(length.(r)..., num_local),
(length.(r)..., length(quadranttolevel)),
comm,
false,
length(r) + 1,
)
backend = get_backend(points)
kernel! = hexpoints!(backend, length.(r))
kernel!(
points,
r...,
coarsegridcells,
coarsegridvertices,
length(quadranttolevel),
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
Val.(length.(r))...;
ndrange = size(points),
)
return points
end
@kernel function curvedhexpoints!(
points,
ri,
si,
ti,
interp_r,
interp_s,
interp_t,
coarsegridcells,
coarsegridvertices,
interpolation_degree,
faceinterpolation,
quadranttointerpolation,
numberofquadrants,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
::Val{I},
::Val{J},
::Val{K},
) where {I,J,K}
i, j, k = @index(Local, NTuple)
q = @index(Group, Linear)
@uniform T = eltype(eltype(points))
treecoords = @localmem eltype(points) (2, 2, 2)
rl = @localmem eltype(ri) (I,)
sl = @localmem eltype(si) (J,)
tl = @localmem eltype(ti) (K,)
@inbounds begin
if q ≤ numberofquadrants
if j == 1 && k == 1
rl[i] = ri[i]
end
if i == 1 && k == 1
sl[j] = si[j]
end
if i == 1 && j == 1
tl[k] = ti[k]
end
if i ≤ 2 && j ≤ 2 && k ≤ 2
treeid = quadranttotreeid[q]
vids = coarsegridcells[treeid]
id = i + 2 * (j - 1) + 4 * (k - 1)
treecoords[i, j, k] = coarsegridvertices[vids[id]]
end
end
end
@synchronize
@inbounds begin
if q ≤ numberofquadrants
treeid = quadranttotreeid[q]
level = quadranttolevel[q]
ix = quadranttocoordinate[q, 1]
iy = quadranttocoordinate[q, 2]
iz = quadranttocoordinate[q, 3]
P4EST_MAXLEVEL = 30
P4EST_ROOT_LEN = 1 << P4EST_MAXLEVEL
cr = T(ix) / P4EST_ROOT_LEN
cs = T(iy) / P4EST_ROOT_LEN
ct = T(iz) / P4EST_ROOT_LEN
h = one(T) / (1 << (level))
r = (2 * cr - 1) + h * (rl[i] + 1)
s = (2 * cs - 1) + h * (sl[j] + 1)
t = (2 * ct - 1) + h * (tl[k] + 1)
p1 = treecoords[1]
p2 = treecoords[2]
p3 = treecoords[4]
p4 = treecoords[3]
p5 = treecoords[5]
p6 = treecoords[6]
p7 = treecoords[8]
p8 = treecoords[7]
interp_idx1 = quadranttointerpolation[treeid, 1]
interp_idx2 = quadranttointerpolation[treeid, 2]
interp_idx3 = quadranttointerpolation[treeid, 3]
interp_idx4 = quadranttointerpolation[treeid, 4]
interp_idx5 = quadranttointerpolation[treeid, 5]
interp_idx6 = quadranttointerpolation[treeid, 6]
# Below f1x corresponds to the x component of the interpolation onto the hex face 1.
# f1e1x: face 1 edge 1 x coordinate
# HOHQMesh data is in rhr vertex order
#
# 8-----------7
# |\ \
# | \ \
# | \ \
# | 5-----------6
# | | |
# 4 | 3 |
# \ | |
# \ | |
# \| |
# 1-----------2
# t s
# | /
# |/
# --->r
if interp_idx1 != 0
f1x, f1y, f1z = interp(
r,
t,
interp_r,
interp_t,
faceinterpolation,
interp_idx1,
interpolation_degree,
)
# edge interpolation on face 1
f1e1x, f1e1y, f1e1z = interp(
r,
-1,
interp_r,
interp_t,
faceinterpolation,
interp_idx1,
interpolation_degree,
)
f1e2x, f1e2y, f1e2z = interp(
1,
t,
interp_r,
interp_t,
faceinterpolation,
interp_idx1,
interpolation_degree,
)
f1e3x, f1e3y, f1e3z = interp(
r,
1,
interp_r,
interp_t,
faceinterpolation,
interp_idx1,
interpolation_degree,
)
f1e4x, f1e4y, f1e4z = interp(
-1,
t,
interp_r,
interp_t,
faceinterpolation,
interp_idx1,
interpolation_degree,
)
else
f1x, f1y, f1z =
(
p1 * (1 - r) * (1 - t) +
p2 * (r + 1) * (1 - t) +
p5 * (1 - r) * (t + 1) +
p6 * (r + 1) * (t + 1)
) / 4
f1e1x, f1e1y, f1e1z = (p1 * (1 - r) + p2 * (r + 1)) / 2 #edge 1
f1e2x, f1e2y, f1e2z = (p2 * (1 - t) + p6 * (t + 1)) / 2 #edge 2
f1e3x, f1e3y, f1e3z = (p5 * (1 - r) + p6 * (r + 1)) / 2 #edge 3
f1e4x, f1e4y, f1e4z = (p1 * (1 - t) + p5 * (t + 1)) / 2 #edge 4
end
if interp_idx2 != 0
f2x, f2y, f2z = interp(
r,
t,
interp_r,
interp_t,
faceinterpolation,
interp_idx2,
interpolation_degree,
)
# edge interpolation on face 2
f2e1x, f2e1y, f2e1z = interp(
r,
-1,
interp_r,
interp_t,
faceinterpolation,
interp_idx2,
interpolation_degree,
)
f2e2x, f2e2y, f2e2z = interp(
1,
t,
interp_r,
interp_t,
faceinterpolation,
interp_idx2,
interpolation_degree,
)
f2e3x, f2e3y, f2e3z = interp(
r,
1,
interp_r,
interp_t,
faceinterpolation,
interp_idx2,
interpolation_degree,
)
f2e4x, f2e4y, f2e4z = interp(
-1,
t,
interp_r,
interp_t,
faceinterpolation,
interp_idx2,
interpolation_degree,
)
else
f2x, f2y, f2z =
(
p4 * (1 - r) * (1 - t) +
p3 * (r + 1) * (1 - t) +
p8 * (1 - r) * (t + 1) +
p7 * (r + 1) * (t + 1)
) / 4
f2e1x, f2e1y, f2e1z = (p4 * (1 - r) + p3 * (r + 1)) / 2 #edge 5
f2e2x, f2e2y, f2e2z = (p3 * (1 - t) + p7 * (t + 1)) / 2 #edge 6
f2e3x, f2e3y, f2e3z = (p8 * (1 - r) + p7 * (r + 1)) / 2 #edge 7
f2e4x, f2e4y, f2e4z = (p4 * (1 - t) + p8 * (t + 1)) / 2 #edge 8
end
if interp_idx3 != 0
f3x, f3y, f3z = interp(
r,
s,
interp_r,
interp_s,
faceinterpolation,
interp_idx3,
interpolation_degree,
)
else
f3x, f3y, f3z =
(
p1 * (1 - r) * (1 - s) +
p2 * (r + 1) * (1 - s) +
p4 * (1 - r) * (s + 1) +
p3 * (r + 1) * (s + 1)
) / 4
end
if interp_idx4 != 0
f4x, f4y, f4z = interp(
s,
t,
interp_s,
interp_t,
faceinterpolation,
interp_idx4,
interpolation_degree,
)
# edge interpolation on face 4
f4e1x, f4e1y, f4e1z = interp(
s,
-1,
interp_s,
interp_t,
faceinterpolation,
interp_idx4,
interpolation_degree,
)
f4e2x, f4e2y, f4e2z = interp(
s,
1,
interp_s,
interp_t,
faceinterpolation,
interp_idx4,
interpolation_degree,
)
else
f4x, f4y, f4z =
(
p2 * (1 - s) * (1 - t) +
p3 * (s + 1) * (1 - t) +
p6 * (1 - s) * (t + 1) +
p7 * (s + 1) * (t + 1)
) / 4
# edge interpolation on face 4 for linear face
f4e1x, f4e1y, f4e1z = (p2 * (1 - s) + p3 * (s + 1)) / 2 # edge 10
f4e2x, f4e2y, f4e2z = (p6 * (1 - s) + p7 * (s + 1)) / 2 # edge 11
end
if interp_idx5 != 0
f5x, f5y, f5z = interp(
r,
s,
interp_r,
interp_s,
faceinterpolation,
interp_idx5,
interpolation_degree,
)
else
f5x, f5y, f5z =
(
p5 * (1 - r) * (1 - s) +
p6 * (r + 1) * (1 - s) +
p8 * (1 - r) * (s + 1) +
p7 * (r + 1) * (s + 1)
) / 4
end
if interp_idx6 != 0
f6x, f6y, f6z = interp(
s,
t,
interp_s,
interp_t,
faceinterpolation,
interp_idx6,
interpolation_degree,
)
f6e1x, f6e1y, f6e1z = interp(
s,
-1,
interp_s,
interp_t,
faceinterpolation,
interp_idx6,
interpolation_degree,
)
f6e2x, f6e2y, f6e2z = interp(
s,
1,
interp_s,
interp_t,
faceinterpolation,
interp_idx6,
interpolation_degree,
)
else
f6x, f6y, f6z =
(
p1 * (1 - s) * (1 - t) +
p4 * (s + 1) * (1 - t) +
p5 * (1 - s) * (t + 1) +
p8 * (s + 1) * (t + 1)
) / 4
f6e1x, f6e1y, f6e1z = (p1 * (1 - s) + p4 * (s + 1)) / 2 # edge 9
f6e2x, f6e2y, f6e2z = (p5 * (1 - s) + p8 * (s + 1)) / 2 # edge 12
end
x =
(
(1 - r) * f6x +
(1 + r) * f4x +
(1 - s) * f1x +
(1 + s) * f2x +
(1 - t) * f3x +
(1 + t) * f5x
) / 2
y =
(
(1 - r) * f6y +
(1 + r) * f4y +
(1 - s) * f1y +
(1 + s) * f2y +
(1 - t) * f3y +
(1 + t) * f5y
) / 2
z =
(
(1 - r) * f6z +
(1 + r) * f4z +
(1 - s) * f1z +
(1 + s) * f2z +
(1 - t) * f3z +
(1 + t) * f5z
) / 2
x +=
(
p1[1] * (1 - r) * (1 - s) * (1 - t) +
p2[1] * (1 + r) * (1 - s) * (1 - t) +
p3[1] * (1 + r) * (1 + s) * (1 - t) +
p4[1] * (1 - r) * (1 + s) * (1 - t) +
p5[1] * (1 - r) * (1 - s) * (1 + t) +
p6[1] * (1 + r) * (1 - s) * (1 + t) +
p7[1] * (1 + r) * (1 + s) * (1 + t) +
p8[1] * (1 - r) * (1 + s) * (1 + t)
) / 8
y +=
(
p1[2] * (1 - r) * (1 - s) * (1 - t) +
p2[2] * (1 + r) * (1 - s) * (1 - t) +
p3[2] * (1 + r) * (1 + s) * (1 - t) +
p4[2] * (1 - r) * (1 + s) * (1 - t) +
p5[2] * (1 - r) * (1 - s) * (1 + t) +
p6[2] * (1 + r) * (1 - s) * (1 + t) +
p7[2] * (1 + r) * (1 + s) * (1 + t) +
p8[2] * (1 - r) * (1 + s) * (1 + t)
) / 8
z +=
(
p1[3] * (1 - r) * (1 - s) * (1 - t) +
p2[3] * (1 + r) * (1 - s) * (1 - t) +
p3[3] * (1 + r) * (1 + s) * (1 - t) +
p4[3] * (1 - r) * (1 + s) * (1 - t) +
p5[3] * (1 - r) * (1 - s) * (1 + t) +
p6[3] * (1 + r) * (1 - s) * (1 + t) +
p7[3] * (1 + r) * (1 + s) * (1 + t) +
p8[3] * (1 - r) * (1 + s) * (1 + t)
) / 8
x -=
(
(1 - s) * (1 - t) * f1e1x +
(1 + r) * (1 - s) * f1e2x +
(1 - s) * (1 + t) * f1e3x +
(1 - r) * (1 - s) * f1e4x +
(1 + s) * (1 - t) * f2e1x +
(1 + r) * (1 + s) * f2e2x +
(1 + s) * (1 + t) * f2e3x +
(1 - r) * (1 + s) * f2e4x +
(1 - r) * (1 - t) * f6e1x +
(1 + r) * (1 - t) * f4e1x +
(1 + r) * (1 + t) * f4e2x +
(1 - r) * (1 + t) * f6e2x
) / 4
y -=
(
(1 - s) * (1 - t) * f1e1y +
(1 + r) * (1 - s) * f1e2y +
(1 - s) * (1 + t) * f1e3y +
(1 - r) * (1 - s) * f1e4y +
(1 + s) * (1 - t) * f2e1y +
(1 + r) * (1 + s) * f2e2y +
(1 + s) * (1 + t) * f2e3y +
(1 - r) * (1 + s) * f2e4y +
(1 - r) * (1 - t) * f6e1y +
(1 + r) * (1 - t) * f4e1y +
(1 + r) * (1 + t) * f4e2y +
(1 - r) * (1 + t) * f6e2y
) / 4
z -=
(
(1 - s) * (1 - t) * f1e1z +
(1 + r) * (1 - s) * f1e2z +
(1 - s) * (1 + t) * f1e3z +
(1 - r) * (1 - s) * f1e4z +
(1 + s) * (1 - t) * f2e1z +
(1 + r) * (1 + s) * f2e2z +
(1 + s) * (1 + t) * f2e3z +
(1 - r) * (1 + s) * f2e4z +
(1 - r) * (1 - t) * f6e1z +
(1 + r) * (1 - t) * f4e1z +
(1 + r) * (1 + t) * f4e2z +
(1 - r) * (1 + t) * f6e2z
) / 4
points[i, j, k, q] = (x, y, z)
end
end
end
function materializepoints(
referencecell::LobattoHex,
coarsegridcells,
coarsegridvertices,
interpolation_degree,
faceinterpolation,
quadranttointerpolation,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm,
)
r = vec.(points_1d(referencecell))
FT = floattype(referencecell)
AT = arraytype(referencecell)
N = Tuple((interpolation_degree + 1) * ones(Int64, 3))
interp_r = vec.(points_1d(LobattoCell{FT,AT}(N...)))
IntType = typeof(length(r))
num_local = IntType(localnumberofquadrants)
points = GridArray{eltype(coarsegridvertices)}(
undef,
arraytype(referencecell),
(length.(r)..., num_local),
(length.(r)..., length(quadranttolevel)),
comm,
false,
length(r) + 1,
)
backend = get_backend(points)
kernel! = curvedhexpoints!(backend, length.(r))
kernel!(
points,
r...,
interp_r...,
coarsegridcells,
coarsegridvertices,
interpolation_degree,
faceinterpolation,
quadranttointerpolation,
length(quadranttolevel),
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
Val.(length.(r))...;
ndrange = size(points),
)
return points
end
@kernel function hexbrickpoints!(
points,
ri,
si,
ti,
coarsegridcells,
coarsegridvertices,
numberofquadrants,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
::Val{I},
::Val{J},
::Val{K},
) where {I,J,K}
i, j, k = @index(Local, NTuple)
q = @index(Group, Linear)
@uniform T = eltype(eltype(points))
treecoords = @localmem eltype(points) (2, 2, 2)
rl = @localmem eltype(ri) (I,)
sl = @localmem eltype(si) (J,)
tl = @localmem eltype(ti) (K,)
@inbounds begin
if q ≤ numberofquadrants
if j == 1 && k == 1
rl[i] = ri[i]
end
if i == 1 && k == 1
sl[j] = si[j]
end
if i == 1 && j == 1
tl[k] = ti[k]
end
if i ≤ 2 && j ≤ 2 && k ≤ 2
treeid = quadranttotreeid[q]
vids = coarsegridcells[treeid]
id = i + 2 * (j - 1) + 4 * (k - 1)
treecoords[i, j, k] = coarsegridvertices[vids[id]]
end
end
end
@synchronize
@inbounds begin
if q ≤ numberofquadrants
treeid = quadranttotreeid[q]
level = quadranttolevel[q]
ix = quadranttocoordinate[q, 1]
iy = quadranttocoordinate[q, 2]
iz = quadranttocoordinate[q, 3]
P4EST_MAXLEVEL = 30
P4EST_ROOT_LEN = 1 << P4EST_MAXLEVEL
cr = T(ix) / P4EST_ROOT_LEN
cs = T(iy) / P4EST_ROOT_LEN
ct = T(iz) / P4EST_ROOT_LEN
h = one(T) / (1 << (level + 1))
r = muladd(h, (rl[i] + 1), cr)
s = muladd(h, (sl[j] + 1), cs)
t = muladd(h, (tl[k] + 1), ct)
c1 = treecoords[1]
c2 = treecoords[2]
c3 = treecoords[3]
c5 = treecoords[5]
dx = c2[1] - c1[1]
dy = c3[2] - c1[2]
dz = c5[3] - c1[3]
points[i, j, k, q] =
SVector(muladd(dx, r, c1[1]), muladd(dy, s, c1[2]), muladd(dz, t, c1[3]))
end
end
end
function materializebrickpoints(
referencecell::LobattoHex,
coarsegridcells,
coarsegridvertices,
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
localnumberofquadrants,
comm,
)
r = vec.(points_1d(referencecell))
IntType = typeof(length(r))
num_local = IntType(localnumberofquadrants)
points = GridArray{eltype(coarsegridvertices)}(
undef,
arraytype(referencecell),
(length.(r)..., num_local),
(length.(r)..., length(quadranttolevel)),
comm,
false,
length(r) + 1,
)
backend = get_backend(points)
kernel! = hexbrickpoints!(backend, length.(r))
kernel!(
points,
r...,
coarsegridcells,
coarsegridvertices,
length(quadranttolevel),
quadranttolevel,
quadranttotreeid,
quadranttocoordinate,
Val.(length.(r))...;
ndrange = size(points),
)
return points
end
function materializedtoc(cell::LobattoCell, dtoc_degree3_local, dtoc_degree3_global)
cellsize = size(cell)
dtoc = zeros(Int, cellsize..., last(size(dtoc_degree3_local)))
if length(dtoc_degree3_global) > 0
# Compute the offsets for the cell node numbering
offsets = zeros(Int, maximum(dtoc_degree3_local) + 1)
for i in eachindex(IndexCartesian(), dtoc_degree3_local)
l = dtoc_degree3_local[i]
I = Tuple(i)
node = I[1:end-1]
if 3 ∈ node
# These points are just for orientation
continue
end
# compute the cell dofs for the corner, edge, face or volume identified by node.
# This is an exclusive count, so the number of dofs in the volume do not include
# the ones that are also on the faces, edges, or corners.
ds = ntuple(length(node)) do n
m = node[n]
if m == 2
d = cellsize[n] - 2
else
d = 1
end
return d
end
# is this needed???
if offsets[l+1] == 0
offsets[l+1] = prod(ds)
end
end
cumsum!(offsets, offsets)
for i in eachindex(IndexCartesian(), dtoc_degree3_local)
l = dtoc_degree3_local[i]
I = Tuple(i)
node = I[1:end-1]
quad = I[end]
if 3 ∈ node
offset_node = map(x -> x == 3 ? 2 : x, node)
offsets[l] = offsets[dtoc_degree3_local[offset_node..., quad]]
end
end
for i in eachindex(IndexCartesian(), dtoc_degree3_local)
l = dtoc_degree3_local[i]
offset = offsets[l]
I = Tuple(i)
node = I[1:end-1]
quad = I[end]
# These points are just for orientation they are not associated
# with any dofs.
if 3 ∈ node
continue
end
numtwos = sum(node .== 2)
dims = ntuple(length(cellsize)) do n
# We use a StepRange here so that the return type is the same
# whether or not the dim gets reversed.
dim =
node[n] == 2 ? StepRange(2, Int8(1), cellsize[n] - 1) :
node[n] == 1 ? StepRange(1, Int8(1), 1) :
StepRange(cellsize[n], Int8(1), cellsize[n])
return dim
end
unrotatedindices = CartesianIndices(dims)
if numtwos == 0
for (j, k) in enumerate(unrotatedindices)
dtoc[k, quad] = j + offset
end
elseif numtwos == 1
twoindex = findfirst(==(2), node)
@assert !isnothing(twoindex)
# edge
shift = ntuple(m -> m == twoindex ? 1 : 0, length(cellsize))
# get canonical orientation of the edge
M = (
dtoc_degree3_global[node..., quad]...,
dtoc_degree3_global[(node .+ shift)..., quad]...,
)
p = orient(Val(2), M)
edgedims = (cellsize[twoindex] - 2,)
for (j, ei) in enumerate(CartesianIndices(edgedims))
pei = orientindex(p, edgedims, ei)
k = unrotatedindices[LinearIndices(edgedims)[pei]]
dtoc[k, quad] = j + offset
end
elseif numtwos == 2
# face
twoindex1 = something(findfirst(==(2), node), 0)
twoindex2 = something(findnext(==(2), node, twoindex1 + 1), 0)
@assert twoindex1 != 0
@assert twoindex2 != 0
ashift = ntuple(m -> m == twoindex1 ? 1 : 0, length(cellsize))
bshift = ntuple(m -> m == twoindex2 ? 1 : 0, length(cellsize))
abshift = ashift .+ bshift
M = (
dtoc_degree3_global[node..., quad]...,
dtoc_degree3_global[(node .+ ashift)..., quad]...,
dtoc_degree3_global[(node .+ bshift)..., quad]...,
dtoc_degree3_global[(node .+ abshift)..., quad]...,
)
# get canonical orientation of the edge
p = orient(Val(4), M)
facedims = (cellsize[twoindex1] - 2, cellsize[twoindex2] - 2)
for (j, fi) in enumerate(CartesianIndices(facedims))
pfi = orientindex(p, facedims, fi)
k = unrotatedindices[LinearIndices(facedims)[pfi]]
dtoc[k, quad] = j + offset
end
elseif numtwos == 3
# volume
for (j, k) in enumerate(unrotatedindices)
dtoc[k, quad] = j + offset
end
else
error("Not implemented")
end
end
end
return dtoc
end
function _indextoface(::Val{2}, i)
degree3facelinearindices = ((5, 9), (8, 12), (2, 3), (14, 15))
f = 0
for (ff, findices) in enumerate(degree3facelinearindices)
if i ∈ findices
f = ff
break
end
end
@assert f != 0
return f
end
function _indextoface(::Val{3}, i)
degree3facelinearindices = (
(21, 25, 37, 41),
(24, 28, 40, 44),
(18, 19, 34, 35),
(30, 31, 46, 47),
(6, 7, 10, 11),
(54, 55, 58, 59),
)
f = 0
for (ff, findices) in enumerate(degree3facelinearindices)
if i ∈ findices
f = ff
break
end
end
@assert f != 0
return f
end
@inline facedims(cell::LobattoQuad) =
((size(cell, 2),), (size(cell, 2),), (size(cell, 1),), (size(cell, 1),))
@inline facedims(cell::LobattoHex) = (
(size(cell, 2), size(cell, 3)),
(size(cell, 2), size(cell, 3)),
(size(cell, 1), size(cell, 3)),
(size(cell, 1), size(cell, 3)),
(size(cell, 1), size(cell, 2)),
(size(cell, 1), size(cell, 2)),
)
function materializefacemaps(
cell::LobattoCell{T,A,N},
numcells_local,
ctod_degree3_local,
dtoc_degree3_local,
dtoc_degree3_global,
quadranttolevel,
quadranttoglobalid,
) where {T,A,N}
numcells = last(size(dtoc_degree3_local))
cellindices = LinearIndices(size(cell))
if cell isa LobattoQuad
numfaces = 4
degree3faceindices =
(((1, 2), (1, 3)), ((4, 2), (4, 3)), ((2, 1), (3, 1)), ((2, 4), (3, 4)))
cellfacedims = ((size(cell, 2),), (size(cell, 1),))
facefaceindices = (LinearIndices((size(cell, 2),)), LinearIndices((size(cell, 1),)))
cellfacedims2 =
((size(cell, 2),), (size(cell, 2),), (size(cell, 1),), (size(cell, 1),))
cellfaceindices = (
cellindices[1, 1:end],
cellindices[end, 1:end],
cellindices[1:end, 1],
cellindices[1:end, end],
)
elseif cell isa LobattoHex
numfaces = 6
degree3faceindices = (
((1, 2, 2), (1, 3, 2), (1, 2, 3), (1, 3, 3)),
((4, 2, 2), (4, 3, 2), (4, 2, 3), (4, 3, 3)),
((2, 1, 2), (3, 1, 2), (2, 1, 3), (3, 1, 3)),
((2, 4, 2), (3, 4, 2), (2, 4, 3), (3, 4, 3)),
((2, 2, 1), (3, 2, 1), (2, 3, 1), (3, 3, 1)),
((2, 2, 4), (3, 2, 4), (2, 3, 4), (3, 3, 4)),
)
cellfacedims = (
(size(cell, 2), size(cell, 3)),
(size(cell, 1), size(cell, 3)),
(size(cell, 1), size(cell, 2)),
)
facefaceindices = (
LinearIndices((size(cell, 2), size(cell, 3))),
LinearIndices((size(cell, 1), size(cell, 3))),
LinearIndices((size(cell, 1), size(cell, 2))),
)
cellfacedims2 = (
(size(cell, 2), size(cell, 3)),
(size(cell, 2), size(cell, 3)),
(size(cell, 1), size(cell, 3)),
(size(cell, 1), size(cell, 3)),
(size(cell, 1), size(cell, 2)),
(size(cell, 1), size(cell, 2)),
)
cellfaceindices = (
cellindices[1, 1:end, 1:end],
cellindices[end, 1:end, 1:end],
cellindices[1:end, 1, 1:end],
cellindices[1:end, end, 1:end],
cellindices[1:end, 1:end, 1],
cellindices[1:end, 1:end, end],
)
else
error("Unsupported element type $(typeof(cell))")
end
numchildfaces = 2^(ndims(cell) - 1)
faceoffsets = (0, cumsum(prod.(cellfacedims2))...)
faceorientations = zeros(Raven.Orientation{numchildfaces}, numfaces, numcells)
for q = 1:numcells
for (f, faceindices) in enumerate(degree3faceindices)
tmpface = ntuple(numchildfaces) do n
dtoc_degree3_global[faceindices[n]..., q]
end
faceorientations[f, q] = orient(Val(numchildfaces), tmpface)
end
end
# Note that ghost faces will be connected to themselves
mapM = reshape(collect(1:(last(faceoffsets)*numcells)), (last(faceoffsets), numcells))
mapP = reshape(collect(1:(last(faceoffsets)*numcells)), (last(faceoffsets), numcells))
quadranttoboundary = zeros(Int, numfaces, numcells_local)
numberofnonconfaces = @MVector zeros(Int, ndims(cell))
uniquenonconnfaces = @MVector zeros(Int, ndims(cell))
noncongfacedict = ntuple(ndims(cell)) do _
Dict{NTuple{numchildfaces,eltype(dtoc_degree3_global)},Int}()
end
for q = 1:numcells_local
for (f, faceindices) in enumerate(degree3faceindices)
facefirstindex = dtoc_degree3_local[faceindices[1]..., q]
kind = length(nzrange(ctod_degree3_local, facefirstindex))
if kind == 1
quadranttoboundary[f, q] = 1
elseif kind == 1 + numchildfaces
# Get the canonical orientation of the global face indices
fg, _ = fldmod1(f, 2)
gfaceindices = ntuple(numchildfaces) do n
dtoc_degree3_global[faceindices[n]..., q]
end
o = faceorientations[f, q]
gfaceindices = gfaceindices[perm(o)]
get!(noncongfacedict[fg], gfaceindices) do
uniquenonconnfaces[fg] += 1
end
numberofnonconfaces[fg] += 1
end
end
end
# Not sure why I could not use the following. Type inference
# was not working.
#
# vmapNC = ntuple(Val(ndims(cell))) do n
# zeros(
# Int,
# cellfacedims[n][1:(ndims(cell)-1)]...,
# 1 + numchildfaces,
# uniquenonconnfaces[n],
# )
# end
#
# so I ended up just explicitly writing it out
vmapNC = if ndims(cell) == 2
(
zeros(Int, cellfacedims[1][1], 1 + numchildfaces, uniquenonconnfaces[1]),
zeros(Int, cellfacedims[2][1], 1 + numchildfaces, uniquenonconnfaces[2]),
)
else
(
zeros(
Int,
cellfacedims[1][1],
cellfacedims[1][2],
1 + numchildfaces,
uniquenonconnfaces[1],
),
zeros(
Int,
cellfacedims[2][1],
cellfacedims[2][2],
1 + numchildfaces,
uniquenonconnfaces[2],
),
zeros(
Int,
cellfacedims[3][1],
cellfacedims[3][2],
1 + numchildfaces,
uniquenonconnfaces[3],
),
)
end
ncids = ntuple(ndims(cell)) do n
zeros(Int, numberofnonconfaces[n])
end
nctypes = ntuple(ndims(cell)) do n
zeros(Int8, numberofnonconfaces[n])
end
nctoface = ntuple(ndims(cell)) do n
zeros(Int8, 2, uniquenonconnfaces[n])
end
nonconface = zeros(Int, ndims(cell))
rows = rowvals(ctod_degree3_local)
for q = 1:numcells_local
for (f, faceindices3) in enumerate(degree3faceindices)
fg = fld1(f, 2)
facefirstindex = dtoc_degree3_local[faceindices3[1]..., q]
neighborsrange = nzrange(ctod_degree3_local, facefirstindex)
kind = length(neighborsrange)
if kind == 1
# boundary face
elseif kind == 2
# conforming face
nf = 0
nq = 0
for ii in neighborsrange
nq, pi = fldmod1(rows[ii], 4^ndims(cell))
nf = _indextoface(Val(N), pi)
if nq != q || nf != f
break
end
end
# Make sure we found the connecting face
@assert nf > 0
@assert nq > 0
# If faces are paired up from different face groups then
# make sure that each face has the same number of
# degrees-of-freedom
@assert fld1(f, ndims(cell)) == fld1(nf, ndims(cell)) ||
length(cellfaceindices[f]) == length(cellfaceindices[nf])
no = inv(faceorientations[f, q]) ∘ faceorientations[nf, nq]
for j in CartesianIndices(cellfacedims[fg])
nfg = fld1(nf, 2)
fij = orientindex(no, cellfacedims[fg], j)
mapP[faceoffsets[end]*(q-1)+faceoffsets[f]+facefaceindices[fg][j]] =
mapM[faceoffsets[end]*(nq-1)+faceoffsets[nf]+facefaceindices[nfg][fij]]
end
else
# non-conforming face
@assert kind == 1 + numchildfaces
nonconface[fg] += 1
o = faceorientations[f, q]
gface = ntuple(numchildfaces) do n
dtoc_degree3_global[faceindices3[n]..., q]
end
gface = gface[perm(o)]
ncid = noncongfacedict[fg][gface]
ncids[fg][nonconface[fg]] = ncid
# compute global quadrant ids that participate in the nonconforming interface
qs = fld1.(rows[neighborsrange], 4^ndims(cell))
fs = map(
x -> _indextoface(Val(N), x),
mod1.(rows[neighborsrange], 4^ndims(cell)),
)
# use level to figure out which ones are the smaller ones
ls = quadranttolevel[qs]
childlevel = maximum(ls)
cids = findall(==(childlevel), ls)
pids = findall(==(childlevel - 1), ls)
@assert length(cids) == numchildfaces
@assert length(pids) == 1
childquadrants = qs[cids]
childquadrants =
childquadrants[sortperm(quadranttoglobalid[childquadrants])]
parentquadrant = first(qs[pids])
# use orientation to transform the elements order
childface = fs[first(cids)]
childorientation = faceorientations[childface, first(childquadrants)]
childquadrants = childquadrants[perm(childorientation)]
nctype = if q == parentquadrant
1
else
something(findfirst(==(q), childquadrants), 0) + 1
end
nctypes[fg][nonconface[fg]] = nctype
if vmapNC[fg][ntuple((_ -> 1), ndims(cell) - 1)..., 1, ncid] == 0
# fill the non-conforming group
parentface = fs[first(pids)]
parentorientation = faceorientations[parentface, parentquadrant]
nctoface[fg][1, ncid] = parentface
nctoface[fg][2, ncid] = childface
for j in CartesianIndices(cellfacedims[fg])
pfi = orientindex(parentorientation, cellfacedims[fg], j)
cfi = orientindex(childorientation, cellfacedims[fg], j)
vmapNC[fg][j, 1, ncid] =
cellfaceindices[parentface][pfi] +
(parentquadrant - 1) * length(cell)
for c = 1:numchildfaces
vmapNC[fg][j, c+1, ncid] =
cellfaceindices[childface][cfi] +
(childquadrants[c] - 1) * length(cell)
end
end
end
end
end
end
vmapM = zeros(Int, size(mapM))
for q = 1:numcells,
fg = 1:ndims(cell),
fn = 1:2,
j in CartesianIndices(cellfacedims[fg])
f = 2 * (fg - 1) + fn
idx = faceoffsets[end] * (q - 1) + faceoffsets[f] + facefaceindices[fg][j]
vmapM[idx] = cellfaceindices[f][j] + (q - 1) * length(cell)
end
vmapP = zeros(Int, size(mapM))
for n in eachindex(vmapP, vmapM, mapP)
vmapP[n] = vmapM[mapP[n]]
end
return (; vmapM, vmapP, mapM, mapP, vmapNC, nctoface, nctypes, ncids),
quadranttoboundary
end
function materializenodecommpattern(cell::LobattoCell, ctod, quadrantcommpattern)
ghostranktompirank = quadrantcommpattern.recvranks
ghostranktoindices =
expand.(
[
quadrantcommpattern.recvindices[ids] for
ids in quadrantcommpattern.recvrankindices
],
length(cell),
)
ranktype = eltype(ghostranktompirank)
indicestype = eltype(eltype(ghostranktoindices))
if length(ghostranktompirank) == 0
return CommPattern{Array}(
indicestype[],
ranktype[],
UnitRange{indicestype}[],
indicestype[],
ranktype[],
UnitRange{indicestype}[],
)
end
dofstarts = zeros(indicestype, length(ghostranktoindices) + 1)
for (i, ids) in enumerate(ghostranktoindices)
dofstarts[i] = first(ids)
end
dofstarts[end] = last(last(ghostranktoindices)) + 0x1
senddofs = Dict{ranktype,Set{indicestype}}()
recvdofs = Dict{ranktype,Set{indicestype}}()
rows = rowvals(ctod)
n = size(ctod, 2)
remoteranks = Set{ranktype}()
for j = 1:n
containslocal = false
for k in nzrange(ctod, j)
i = rows[k]
s = searchsorted(dofstarts, i)
if last(s) > 0
push!(remoteranks, ghostranktompirank[last(s)])
end
if last(s) == 0
containslocal = true
end
end
if !isempty(remoteranks)
for k in nzrange(ctod, j)
i = rows[k]
s = searchsorted(dofstarts, i)
if last(s) == 0
for rank in remoteranks
# local node we need to send
sendset = get!(senddofs, rank) do
Set{indicestype}()
end
push!(sendset, i)
end
elseif containslocal
# remote node we need to recv
rank = ghostranktompirank[last(s)]
recvset = get!(recvdofs, rank) do
Set{indicestype}()
end
push!(recvset, i)
end
end
end
empty!(remoteranks)
end
numsendindices = 0
for dofs in keys(senddofs)
numsendindices += length(dofs)
end
sendindices = Int[]
sendrankindices = UnitRange{Int}[]
sendoffset = 0
for r in ghostranktompirank
dofs = senddofs[r]
append!(sendindices, sort(collect(dofs)))
push!(sendrankindices, (1:length(dofs)) .+ sendoffset)
sendoffset += length(dofs)
end
recvindices = Int[]
recvrankindices = UnitRange{Int}[]
recvoffset = 0
for r in ghostranktompirank
dofs = recvdofs[r]
append!(recvindices, sort(collect(dofs)))
push!(recvrankindices, (1:length(dofs)) .+ recvoffset)
recvoffset += length(dofs)
end
return CommPattern{Array}(
recvindices,
ghostranktompirank,
recvrankindices,
sendindices,
ghostranktompirank,
sendrankindices,
)
end
function materializeparentnodes(
cell::LobattoCell,
ctod,
quadranttoglobalid,
quadranttolevel,
)
Np = length(cell)
rows = rowvals(ctod)
m, n = size(ctod)
parentdofs = zeros(eltype(rows), m)
for j = 1:n
level = typemax(Int8)
gid = typemax(eltype(quadranttoglobalid))
pdof = 0
for ii in nzrange(ctod, j)
i = rows[ii]
e = cld(i, Np)
if quadranttolevel[e] ≤ level && quadranttoglobalid[e] < gid
level = quadranttolevel[e]
gid = quadranttoglobalid[e]
pdof = i
end
end
for ii in nzrange(ctod, j)
i = rows[ii]
@assert pdof != 0
parentdofs[i] = pdof
end
end
return reshape(parentdofs, size(cell)..., :)
end
@kernel function quadvolumemetrics!(
firstordermetrics,
secondordermetrics,
points,
Dr,
Ds,
wr,
ws,
::Val{IR},
::Val{IS},
::Val{Q},
) where {IR,IS,Q}
i, j, p = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@uniform T = eltype(points)
X = @localmem T (IR, IS, Q)
dXdr = @private T (1,)
dXds = @private T (1,)
@inbounds begin
X[i, j, p] = points[i, j, q]
@synchronize
dXdr[] = -zero(T)
dXds[] = -zero(T)
@unroll for m = 1:IR
dXdr[] += Dr[i, m] * X[m, j, p]
end
@unroll for n = 1:IS
dXds[] += Ds[j, n] * X[i, n, p]
end
G = SMatrix{2,2,eltype(Dr),4}(
dot(dXdr[], dXdr[]),
dot(dXdr[], dXds[]),
dot(dXdr[], dXds[]),
dot(dXds[], dXds[]),
)
invG = inv(G)
dRdX = invG * [dXdr[] dXds[]]'
J = norm(cross(dXdr[], dXds[]))
wJ = wr[i] * ws[j] * J
wJinvG = wJ * invG
firstordermetrics[i, j, q] = (; dRdX, J, wJ)
secondordermetrics[i, j, q] = (; wJinvG, wJ)
end
end
@kernel function quadvolumebrickmetrics!(
firstordermetrics,
secondordermetrics,
points,
wr,
ws,
::Val{IR},
::Val{IS},
::Val{Q},
) where {IR,IS,Q}
i, j, p = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@uniform T = eltype(points)
X = @localmem T (IR, IS, Q)
@inbounds begin
X[i, j, p] = points[i, j, q]
@synchronize
dx = X[end, 1, p][1] - X[1, 1, p][1]
dy = X[1, end, p][2] - X[1, 1, p][2]
dr = 2
ds = 2
drdx = dr / dx
dsdy = ds / dy
dRdX = SMatrix{2,2,typeof(dx),4}(drdx, -zero(dx), -zero(dx), dsdy)
J = (dx / dr) * (dy / ds)
wJ = wr[i] * ws[j] * J
# invwJ = inv(wJ)
wJinvG = SMatrix{2,2,typeof(dx),4}(
SVector(wJ * (drdx)^2, -zero(dx), -zero(dx), wJ * (dsdy)^2),
)
firstordermetrics[i, j, q] = (; dRdX, J, wJ)
secondordermetrics[i, j, q] = (; wJinvG, wJ)
end
end
@kernel function quadsurfacemetrics!(
surfacemetrics,
dRdXs,
Js,
_,
vmapM,
w,
fg,
facegroupsize,
facegroupoffsets,
)
j, fn, _ = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@inbounds begin
si =
facegroupoffsets[end] * (q - 1) +
facegroupoffsets[fg] +
(fn - 1) * facegroupsize[1] +
j
i = vmapM[si]
dRdX = dRdXs[i]
J = Js[i]
sn = fn == 1 ? -1 : 1
n = sn * J * dRdX[fg, :]
sJ = norm(n)
n = n / sJ
if fg == 1
wsJ = sJ * w[2][j]
elseif fg == 2
wsJ = sJ * w[1][j]
end
surfacemetrics[si] = (; n, sJ, wsJ)
end
end
@kernel function quadncsurfacemetrics!(surfacemetrics, dRdXs, Js, _, vmapNC, nctoface, w)
j, ft, _ = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@inbounds begin
i = vmapNC[j, ft, q]
dRdX = dRdXs[i]
J = Js[i]
f = ft == 1 ? nctoface[1, q] : nctoface[2, q]
fg, fn = fldmod1(f, 2)
sn = fn == 1 ? -1 : 1
n = sn * J * dRdX[fg, :]
sJ = norm(n)
n = n / sJ
if fg == 1
wsJ = sJ * w[2][j]
elseif fg == 2
wsJ = sJ * w[1][j]
end
surfacemetrics[j, ft, q] = (; n, sJ, wsJ)
end
end
function materializemetrics(
cell::LobattoQuad,
points::AbstractArray{SVector{N,FT}},
facemaps,
comm,
nodecommpattern,
isunwarpedbrick,
) where {N,FT}
Q = max(512 ÷ prod(size(cell)), 1)
D = derivatives_1d(cell)
w = vec.(weights_1d(cell))
T1 = NamedTuple{(:dRdX, :J, :wJ),Tuple{SMatrix{2,N,FT,2 * N},FT,FT}}
firstordermetrics = similar(points, T1)
T2 = NamedTuple{(:wJinvG, :wJ),Tuple{SHermitianCompact{2,FT,3},FT}}
secondordermetrics = similar(points, T2)
backend = get_backend(points)
if isunwarpedbrick
kernel! = quadvolumebrickmetrics!(backend, (size(cell)..., Q))
kernel!(
firstordermetrics,
secondordermetrics,
points,
w...,
Val.(size(cell))...,
Val(Q);
ndrange = size(points),
)
else
kernel! = quadvolumemetrics!(backend, (size(cell)..., Q))
kernel!(
firstordermetrics,
secondordermetrics,
points,
D...,
w...,
Val.(size(cell))...,
Val(Q);
ndrange = size(points),
)
end
fcm = commmanager(eltype(firstordermetrics), nodecommpattern; comm)
share!(firstordermetrics, fcm)
volumemetrics = (firstordermetrics, secondordermetrics)
TS = NamedTuple{(:n, :sJ, :wsJ),Tuple{SVector{N,FT},FT,FT}}
# TODO move this to cell
cellfacedims = ((size(cell, 2),), (size(cell, 1),))
facegroupsize = cellfacedims
facegroupoffsets = (0, cumsum(2 .* prod.(cellfacedims))...)
surfacemetrics = GridArray{TS}(
undef,
arraytype(points),
(facegroupoffsets[end], sizewithoutghosts(points)[end]),
(facegroupoffsets[end], sizewithghosts(points)[end]),
Raven.comm(points),
true,
1,
)
ncsurfacemetrics = ntuple(
n -> similar(points, TS, size(facemaps.vmapNC[n])),
Val(length(cellfacedims)),
)
for n in eachindex(cellfacedims)
J = cellfacedims[n]
Q = max(512 ÷ 2prod(J), 1)
kernel! = quadsurfacemetrics!(backend, (J..., 2, Q))
kernel!(
surfacemetrics,
components(viewwithghosts(firstordermetrics))...,
facemaps.vmapM,
w,
n,
facegroupsize[n],
facegroupoffsets,
ndrange = (J..., 2, last(size(surfacemetrics))),
)
M = 1 + 2^(ndims(cell) - 1)
Q = max(512 ÷ (M * prod(J)), 1)
kernel! = quadncsurfacemetrics!(backend, (J..., M, Q))
kernel!(
ncsurfacemetrics[n],
components(viewwithghosts(firstordermetrics))...,
facemaps.vmapNC[n],
facemaps.nctoface[n],
w,
ndrange = size(ncsurfacemetrics[n]),
)
end
surfacemetrics = (viewwithoutghosts(surfacemetrics), ncsurfacemetrics)
return (volumemetrics, surfacemetrics)
end
@kernel function hexvolumemetrics!(
firstordermetrics,
secondordermetrics,
points,
Dr,
Ds,
Dt,
wr,
ws,
wt,
::Val{IR},
::Val{IS},
::Val{IT},
::Val{Q},
) where {IR,IS,IT,Q}
i, j, p = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@uniform T = eltype(points)
@uniform FT = eltype(eltype(points))
vtmp = @localmem T (IR, IS, Q)
X = @private T (IT,)
dXdr = @private T (IT,)
dXds = @private T (IT,)
dXdt = @private T (IT,)
a1 = @private T (1,)
a2 = @private T (1,)
a3 = @private T (1,)
@inbounds begin
@unroll for k = 1:IT
dXdr[k] = -zero(T)
dXds[k] = -zero(T)
dXdt[k] = -zero(T)
end
@unroll for k = 1:IT
X[k] = points[i, j, k, q]
vtmp[i, j, p] = X[k]
@synchronize
@unroll for m = 1:IR
dXdr[k] += Dr[i, m] * vtmp[m, j, p]
end
@unroll for n = 1:IS
dXds[k] += Ds[j, n] * vtmp[i, n, p]
end
@unroll for o = 1:IT
dXdt[o] += Dt[o, k] * vtmp[i, j, p]
end
@synchronize
end
@unroll for k = 1:IT
# Instead of
# ```julia
# @. invJ = inv(J)
# ```
# we use the curl invariant formulation of Kopriva, equation (37) of
# <https://doi.org/10.1007/s10915-005-9070-8>.
a1[] = -zero(T) # Ds * cross(X, dXdt) - Dt * cross(X, dXds)
a2[] = -zero(T) # Dt * cross(X, dXdr) - Dr * cross(X, dXdt)
a3[] = -zero(T) # Dr * cross(X, dXds) - Ds * cross(X, dXdr)
# Dr * cross(X, dXds)
@synchronize
vtmp[i, j, p] = cross(X[k], dXds[k])
@synchronize
@unroll for m = 1:IR
a3[] += Dr[i, m] * vtmp[m, j, p]
end
# Dr * cross(X, dXdt)
@synchronize
vtmp[i, j, p] = cross(X[k], dXdt[k])
@synchronize
@unroll for m = 1:IR
a2[] -= Dr[i, m] * vtmp[m, j, p]
end
# Ds * cross(X, dXdt)
@synchronize
vtmp[i, j, p] = cross(X[k], dXdt[k])
@synchronize
@unroll for n = 1:IS
a1[] += Ds[j, n] * vtmp[i, n, p]
end
# Ds * cross(X, dXdr)
@synchronize
vtmp[i, j, p] = cross(X[k], dXdr[k])
@synchronize
@unroll for n = 1:IS
a3[] -= Ds[j, n] * vtmp[i, n, p]
end
# Dt * cross(X, dXdr)
@unroll for o = 1:IT
a2[] += Dt[k, o] * cross(X[o], dXdr[o])
end
# Dt * cross(X, dXds)
@unroll for o = 1:IT
a1[] -= Dt[k, o] * cross(X[o], dXds[o])
end
J = [dXdr[k] dXds[k] dXdt[k]]
detJ = det(J)
invJ = [a1[] a2[] a3[]]' ./ 2detJ
invG = invJ * invJ'
wJ = wr[i] * ws[j] * wt[k] * detJ
wJinvG = wJ * invG
firstordermetrics[i, j, k, q] = (; dRdX = invJ, J = detJ, wJ)
secondordermetrics[i, j, k, q] = (; wJinvG, wJ)
end
end
end
@kernel function hexvolumebrickmetrics!(
firstordermetrics,
secondordermetrics,
points,
wr,
ws,
wt,
::Val{IR},
::Val{IS},
::Val{IT},
::Val{Q},
) where {IR,IS,IT,Q}
i, j, p = @index(Local, NTuple)
_, _, q = @index(Global, NTuple)
@uniform T = eltype(points)
@uniform FT = eltype(eltype(points))
@inbounds begin
x = points[1, 1, 1, p]
dx = points[end, 1, 1, p][1] - x[1]
dy = points[1, end, 1, p][2] - x[2]
dz = points[1, 1, end, p][3] - x[3]
dr = 2
ds = 2
dt = 2
drdx = dr / dx
dsdy = ds / dy
dtdz = dt / dz
dRdX = SMatrix{3,3,typeof(dx),9}(
drdx,
-zero(dx),
-zero(dx),
-zero(dx),
dsdy,
-zero(dx),
-zero(dx),
-zero(dx),
dtdz,
)
J = (dx / dr) * (dy / ds) * (dz / dt)
@unroll for k = 1:IT
wJ = wr[i] * ws[j] * wt[k] * J
# invwJ = inv(wJ)
wJinvG = SMatrix{3,3,typeof(dx),9}(
wJ * (drdx)^2,
-zero(dx),
-zero(dx),
-zero(dx),
wJ * (dsdy)^2,
-zero(dx),
-zero(dx),
-zero(dx),
wJ * (dtdz)^2,
)
firstordermetrics[i, j, k, q] = (; dRdX, J, wJ)
secondordermetrics[i, j, k, q] = (; wJinvG, wJ)
end
end
end
@kernel function hexsurfacemetrics!(
surfacemetrics,
dRdXs,
Js,
_,
vmapM,
w,
fg,
facegroupsize,
facegroupoffsets,
)
i, j, fn, _ = @index(Local, NTuple)
_, _, _, q = @index(Global, NTuple)
begin
sk =
facegroupoffsets[end] * (q - 1) +
facegroupoffsets[fg] +
(fn - 1) * facegroupsize[1] * facegroupsize[2] +
(j - 1) * facegroupsize[1] +
i
k = vmapM[sk]
dRdX = dRdXs[k]
J = Js[k]
sn = fn == 1 ? -1 : 1
n = sn * J * dRdX[fg, :]
sJ = norm(n)
n = n / sJ
if fg == 1
wsJ = sJ * w[2][i] * w[3][j]
elseif fg == 2
wsJ = sJ * w[1][i] * w[3][j]
elseif fg == 3
wsJ = sJ * w[1][i] * w[2][j]
end
surfacemetrics[sk] = (; n, sJ, wsJ)
end
end
@kernel function hexncsurfacemetrics!(surfacemetrics, dRdXs, Js, _, vmapNC, nctoface, w)
i, j, ft, _ = @index(Local, NTuple)
_, _, _, q = @index(Global, NTuple)
@inbounds begin
k = vmapNC[i, j, ft, q]
dRdX = dRdXs[k]
J = Js[k]
f = ft == 1 ? nctoface[1, q] : nctoface[2, q]
fg, fn = fldmod1(f, 2)
sn = fn == 1 ? -1 : 1
n = sn * J * dRdX[fg, :]
sJ = norm(n)
n = n / sJ
if fg == 1
wsJ = sJ * w[2][i] * w[3][j]
elseif fg == 2
wsJ = sJ * w[1][i] * w[3][j]
elseif fg == 3
wsJ = sJ * w[1][i] * w[2][j]
end
surfacemetrics[i, j, ft, q] = (; n, sJ, wsJ)
end
end
function materializemetrics(
cell::LobattoHex,
points::AbstractArray{SVector{3,FT}},
facemaps,
comm,
nodecommpattern,
isunwarpedbrick,
) where {FT}
Q = max(512 ÷ (size(cell, 1) * size(cell, 2)), 1)
D = derivatives_1d(cell)
w = vec.(weights_1d(cell))
T1 = NamedTuple{(:dRdX, :J, :wJ),Tuple{SMatrix{3,3,FT,9},FT,FT}}
firstordermetrics = similar(points, T1)
T2 = NamedTuple{(:wJinvG, :wJ),Tuple{SHermitianCompact{3,FT,6},FT}}
secondordermetrics = similar(points, T2)
backend = get_backend(points)
if isunwarpedbrick
kernel! = hexvolumebrickmetrics!(backend, (size(cell, 1), size(cell, 2), Q))
kernel!(
firstordermetrics,
secondordermetrics,
points,
w...,
Val.(size(cell))...,
Val(Q);
ndrange = (size(cell, 1), size(cell, 2), size(points, 4)),
)
else
kernel! = hexvolumemetrics!(backend, (size(cell, 1), size(cell, 2), Q))
kernel!(
firstordermetrics,
secondordermetrics,
points,
D...,
w...,
Val.(size(cell))...,
Val(Q);
ndrange = (size(cell, 1), size(cell, 2), size(points, 4)),
)
end
# We need this to compute the normals and surface Jacobian on the
# non-conforming faces. Should we change the nonconforming surface
# information to avoid this communication?
fcm = commmanager(eltype(firstordermetrics), nodecommpattern; comm)
share!(firstordermetrics, fcm)
volumemetrics = (firstordermetrics, secondordermetrics)
TS = NamedTuple{(:n, :sJ, :wsJ),Tuple{SVector{3,FT},FT,FT}}
# TODO move this to cell
cellfacedims = (
(size(cell, 2), size(cell, 3)),
(size(cell, 1), size(cell, 3)),
(size(cell, 1), size(cell, 2)),
)
facegroupsize = cellfacedims
facegroupoffsets = (0, cumsum(2 .* prod.(cellfacedims))...)
surfacemetrics = GridArray{TS}(
undef,
arraytype(points),
(facegroupoffsets[end], sizewithoutghosts(points)[end]),
(facegroupoffsets[end], sizewithghosts(points)[end]),
Raven.comm(points),
false,
1,
)
ncsurfacemetrics = ntuple(
n -> similar(points, TS, size(facemaps.vmapNC[n])),
Val(length(cellfacedims)),
)
for n in eachindex(cellfacedims)
J = cellfacedims[n]
Q = max(512 ÷ prod(J), 1)
kernel! = hexsurfacemetrics!(backend, (J..., 2, Q))
kernel!(
surfacemetrics,
components(viewwithghosts(firstordermetrics))...,
facemaps.vmapM,
w,
n,
facegroupsize[n],
facegroupoffsets,
ndrange = (J..., 2, last(size(surfacemetrics))),
)
M = 1 + 2^(ndims(cell) - 1)
Q = max(512 ÷ (M * prod(J)), 1)
kernel! = hexncsurfacemetrics!(backend, (J..., M, Q))
kernel!(
ncsurfacemetrics[n],
components(viewwithghosts(firstordermetrics))...,
facemaps.vmapNC[n],
facemaps.nctoface[n],
w,
ndrange = size(ncsurfacemetrics[n]),
)
end
surfacemetrics = (viewwithoutghosts(surfacemetrics), ncsurfacemetrics)
return (volumemetrics, surfacemetrics)
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 4410 | _numkinds(::Val{2}) = 2
_numkinds(::Val{4}) = 8
#_numkinds(::Val{8}) = 48
struct Orientation{N}
kind::Int8
function Orientation{N}(kind) where {N}
if kind < 1 || kind > _numkinds(Val(N))
throw(BoundsError(1:_numkinds(Val(N)), kind))
end
new{N}(kind)
end
end
kind(o::Orientation) = o.kind
perm(o::Orientation{2}) = o.kind == 1 ? SA[1, 2] : SA[2, 1]
function perm(o::Orientation{4})
perm = if kind(o) == 1
SA[1, 2, 3, 4]
elseif kind(o) == 2
SA[2, 1, 4, 3]
elseif kind(o) == 3
SA[3, 4, 1, 2]
elseif kind(o) == 4
SA[4, 3, 2, 1]
elseif kind(o) == 5
SA[1, 3, 2, 4]
elseif kind(o) == 6
SA[2, 4, 1, 3]
elseif kind(o) == 7
SA[3, 1, 4, 2]
else # kind(o) == 8
SA[4, 2, 3, 1]
end
return perm
end
Base.zero(::Type{Orientation{N}}) where {N} = Orientation{N}(1)
@inline function orientindex(o::Orientation, dims::Dims, I...)
return orientindex(o, dims, CartesianIndex(I))
end
function orientindices(o::Orientation, dims::Dims)
return orientindex.(Ref(o), Ref(dims), CartesianIndices(dims))
end
function orientindices(o::Orientation{4}, dims::Dims{2})
indices = orientindex.(Ref(o), Ref(dims), CartesianIndices(dims))
if fld1(kind(o), 4) != 1
indices = reshape(indices, reverse(dims))
end
return indices
end
@inline function orientindex(
o::Orientation{2},
dims::Dims{1},
I::CartesianIndex{1},
::Bool = false,
)
@boundscheck Base.checkbounds_indices(Bool, (Base.OneTo(dims[1]),), Tuple(I)) ||
throw(BoundsError(o, I))
index = kind(o) == 1 ? I[1] : dims[1] - I[1] + 1
return CartesianIndex(index)
end
@inline function orientindex(o::Orientation{4}, dims::Dims{2}, I::CartesianIndex{2})
@boundscheck if !Base.checkbounds_indices(
Bool,
(Base.OneTo(dims[1]), Base.OneTo(dims[2])),
Tuple(I),
)
throw(BoundsError(o, I))
end
div, rem = divrem(kind(o) - 0x1, 4)
@inbounds if div != 0
li = LinearIndices(dims)[I]
ci = CartesianIndices(reverse(dims))[li]
I = CartesianIndex(reverse(Tuple(ci)))
end
i1 = rem & 0x1 == 0x1 ? dims[1] - I[1] + 1 : I[1]
i2 = rem & 0x2 == 0x2 ? dims[2] - I[2] + 1 : I[2]
return CartesianIndex(i1, i2)
end
# function orientindices(o::Orientation{8}, dims::Dims{3}, invert::Bool = false)
# is1 = StepRange(1, Int8(1), dims[1])
# is2 = StepRange(1, Int8(1), dims[2])
# is3 = StepRange(1, Int8(1), dims[3])
#
# div, rem = divrem(kind(o) - 0x1, 8)
#
# if rem & 0x1 == 0x1
# is1 = reverse(is1)
# end
#
# if rem & 0x2 == 0x2
# is2 = reverse(is2)
# end
#
# if rem & 0x4 == 0x4
# is3 = reverse(is3)
# end
#
# indices = (is1, is2, is3)
#
# if div == 0
# perm = (1, 2, 3)
# elseif div == 1
# perm = (1, 3, 2)
# elseif div == 2
# perm = (2, 1, 3)
# elseif div == 3
# perm = (2, 3, 1)
# elseif div == 4
# perm = (3, 1, 2)
# elseif div == 5
# perm = (3, 2, 1)
# else
# throw(ArgumentError("Orientation{8}($(kind(o))) is invalid"))
# end
#
# if invert
# indices = getindex.(Ref(indices), perm)
# perm = invperm(perm)
# end
#
# return PermutedDimsArray(CartesianIndices(indices), perm)
# end
Base.inv(p::Orientation{2}) = p
function Base.inv(p::Orientation{4})
invmap = SA{Int8}[1, 2, 3, 4, 5, 7, 6, 8]
return @inbounds Orientation{4}(invmap[kind(p)])
end
_permcomposition(::Val{2}) = SA{Int8}[1 2; 2 1]
_permcomposition(::Val{4}) = SA{Int8}[
1 2 3 4 5 6 7 8
2 1 4 3 7 8 5 6
3 4 1 2 6 5 8 7
4 3 2 1 8 7 6 5
5 6 7 8 1 2 3 4
6 5 8 7 3 4 1 2
7 8 5 6 2 1 4 3
8 7 6 5 4 3 2 1
]
function Base.:(∘)(p::Orientation{N}, q::Orientation{N}) where {N}
return @inbounds Orientation{N}(_permcomposition(Val(N))[p.kind, q.kind])
end
function orient(::Val{2}, src::NTuple{2})
k = src[1] ≤ src[2] ? 1 : 2
return Orientation{2}(k)
end
function orient(::Val{4}, src::NTuple{4})
i = argmin(src)
if i == 1
k = src[2] <= src[3] ? 1 : 5
elseif i == 2
k = src[4] <= src[1] ? 6 : 2
elseif i == 3
k = src[1] <= src[4] ? 7 : 3
else # i == 4
k = src[3] <= src[2] ? 4 : 8
end
return Orientation{4}(k)
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 3092 | # Based off of code from julia SparseArrays.jl
struct GeneralSparseMatrixCSC{
Tv,
Ti<:Integer,
VTv<:AbstractVector{Tv},
VTi<:AbstractVector{Ti},
} <: SparseArrays.AbstractSparseMatrixCSC{Tv,Ti}
m::Int # Number of rows
n::Int # Number of columns
colptr::VTi # Column i is in colptr[i]:(colptr[i+1]-1)
rowval::VTi # Row indices of stored values
nzval::VTv # Stored values, typically nonzeros
function GeneralSparseMatrixCSC{Tv,Ti,VTv,VTi}(
m::Integer,
n::Integer,
colptr::AbstractVector{Ti},
rowval::AbstractVector{Ti},
nzval::AbstractVector{Tv},
) where {Tv,Ti<:Integer,VTv<:AbstractVector{Tv},VTi<:AbstractVector{Ti}}
new(Int(m), Int(n), colptr, rowval, nzval)
end
end
const AnyGPUGeneralSparseMatrix =
GeneralSparseMatrixCSC{<:Any,<:Any,<:AnyGPUArray,<:AnyGPUArray}
const AnyGPUGeneralSparseMatrixCSCInclAdjointAndTranspose = Union{
AnyGPUGeneralSparseMatrix,
Adjoint{<:Any,<:AnyGPUGeneralSparseMatrix},
Transpose{<:Any,<:AnyGPUGeneralSparseMatrix},
}
function GeneralSparseMatrixCSC(
m::Integer,
n::Integer,
colptr::AbstractVector,
rowval::AbstractVector,
nzval::AbstractVector,
)
Tv = eltype(nzval)
VTv = typeof(nzval)
Ti = promote_type(eltype(colptr), eltype(rowval))
VTi = promote_type(typeof(colptr), typeof(rowval))
GeneralSparseMatrixCSC{Tv,Ti,VTv,VTi}(m, n, colptr, rowval, nzval)
end
SparseArrays.getcolptr(S::GeneralSparseMatrixCSC) = getfield(S, :colptr)
SparseArrays.rowvals(S::GeneralSparseMatrixCSC) = getfield(S, :rowval)
SparseArrays.nonzeros(S::GeneralSparseMatrixCSC) = getfield(S, :nzval)
function SparseArrays.nnz(S::AnyGPUGeneralSparseMatrix)
GPUArraysCore.@allowscalar Int(SparseArrays.getcolptr(S)[size(S, 2)+1]) - 1
end
Base.size(S::GeneralSparseMatrixCSC) = (S.m, S.n)
function GeneralSparseMatrixCSC(S::SparseArrays.AbstractSparseMatrixCSC)
m, n = size(S)
colptr = SparseArrays.getcolptr(S)
rowval = rowvals(S)
nzval = nonzeros(S)
return GeneralSparseMatrixCSC(m, n, colptr, rowval, nzval)
end
function Adapt.adapt_structure(to, S::GeneralSparseMatrixCSC)
m, n = size(S)
colptr = adapt(to, SparseArrays.getcolptr(S))
rowval = adapt(to, rowvals(S))
nzval = adapt(to, nonzeros(S))
return GeneralSparseMatrixCSC(m, n, colptr, rowval, nzval)
end
adaptsparse(_, S) = S
@static if VERSION >= v"1.7"
function Base.print_array(
io::IO,
S::AnyGPUGeneralSparseMatrixCSCInclAdjointAndTranspose,
)
Base.print_array(io, adapt(Array, S))
end
function Base.show(io::IO, S::AnyGPUGeneralSparseMatrixCSCInclAdjointAndTranspose)
Base.show(io, adapt(Array, S))
end
function SparseArrays._goodbuffers(S::AnyGPUGeneralSparseMatrix)
(_, n) = size(S)
colptr = SparseArrays.getcolptr(S)
rowval = rowvals(S)
nzval = nonzeros(S)
GPUArraysCore.@allowscalar (
length(colptr) == n + 1 && colptr[end] - 1 == length(rowval) == length(nzval)
)
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 119 | Stream(_) = nothing
synchronize(backend, _) = KernelAbstractions.synchronize(backend)
stream!(f::Function, _, _) = f()
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 320 | @testset "Arrays" begin
A = [13, 4, 5, 1, 5]
B = Raven.numbercontiguous(Int32, A)
@test eltype(B) == Int32
@test B == [4, 2, 3, 1, 3]
B = Raven.numbercontiguous(Int32, A, by = x -> -x)
@test eltype(B) == Int32
@test B == [1, 3, 2, 4, 2]
A = [1, 2]
@test viewwithghosts(A) == A
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 4532 | using Raven.StaticArrays: size_to_tuple
function cells_testsuite(AT, FT)
cell = LobattoCell{FT,AT}(3, 3)
@test floattype(typeof(cell)) == FT
@test arraytype(typeof(cell)) <: AT
@test ndims(typeof(cell)) == 2
@test floattype(cell) == FT
@test arraytype(cell) <: AT
@test ndims(cell) == 2
@test size(cell) == (3, 3)
@test length(cell) == 9
@test sum(mass(cell)) .≈ 4
@test mass(cell) isa Diagonal
@test sum(facemass(cell)) .≈ 8
@test facemass(cell) isa Diagonal
@test faceoffsets(cell) == (0, 3, 6, 9, 12)
@test strides(cell) == (1, 3)
D = derivatives(cell)
@test Array(D[1] * points(cell)) ≈ fill(SVector(one(FT), zero(FT)), 9)
@test Array(D[2] * points(cell)) ≈ fill(SVector(zero(FT), one(FT)), 9)
D1d = derivatives_1d(cell)
@test length(D1d) == ndims(cell)
@test all(
Array.(D1d) .==
setprecision(BigFloat, 2^(max(8, ceil(Int, log2(precision(FT))) + 2))) do
Matrix{
FT,
}.(spectralderivative.(first.(legendregausslobatto.(BigFloat, size(cell)))))
end,
)
h1d = tohalves_1d(cell)
@test length(h1d) == ndims(cell)
@test all(length.(h1d) .== 2)
setprecision(BigFloat, 2^(max(8, ceil(Int, log2(precision(FT))) + 2))) do
p, _ = legendregausslobatto(BigFloat, 3)
I1 = Matrix{FT}(spectralinterpolation(p, (p .- 1) / 2))
I2 = Matrix{FT}(spectralinterpolation(p, (p .+ 1) / 2))
@test Array(h1d[1][1]) == I1
@test Array(h1d[1][2]) == I2
@test Array(h1d[2][1]) == I1
@test Array(h1d[2][2]) == I2
end
@test adapt(Array, cell) isa LobattoCell{FT,Array}
S = (3, 4, 2)
cell = LobattoCell{FT,AT}(S...)
@test floattype(cell) == FT
@test arraytype(cell) <: AT
@test Base.ndims(cell) == 3
@test size(cell) == S
@test length(cell) == prod(S)
@test sum(mass(cell)) .≈ 8
@test mass(cell) isa Diagonal
@test sum(facemass(cell)) .≈ 24
@test facemass(cell) isa Diagonal
@test faceoffsets(cell) == (0, 8, 16, 22, 28, 40, 52)
@test strides(cell) == (1, 3, 12)
D = derivatives(cell)
@test Array(D[1] * points(cell)) ≈ fill(SVector(one(FT), zero(FT), zero(FT)), prod(S))
@test Array(D[2] * points(cell)) ≈ fill(SVector(zero(FT), one(FT), zero(FT)), prod(S))
@test Array(D[3] * points(cell)) ≈ fill(SVector(zero(FT), zero(FT), one(FT)), prod(S))
D1d = derivatives_1d(cell)
@test length(D1d) == ndims(cell)
@test all(
Array.(D1d) .==
setprecision(BigFloat, 2^(max(8, ceil(Int, log2(precision(FT))) + 2))) do
Matrix{
FT,
}.(spectralderivative.(first.(legendregausslobatto.(BigFloat, size(cell)))))
end,
)
h1d = tohalves_1d(cell)
@test length(h1d) == ndims(cell)
@test all(length.(h1d) .== 2)
setprecision(BigFloat, 2^(max(8, ceil(Int, log2(precision(FT))) + 2))) do
for (n, N) in enumerate(size(cell))
p, _ = legendregausslobatto(BigFloat, N)
@test Array(h1d[n][1]) == Matrix{FT}(spectralinterpolation(p, (p .- 1) ./ 2))
@test Array(h1d[n][2]) == Matrix{FT}(spectralinterpolation(p, (p .+ 1) ./ 2))
end
end
@test similar(cell, (3, 4)) isa LobattoCell{FT,AT}
cell = LobattoCell{FT,AT}(5)
@test floattype(cell) == FT
@test arraytype(cell) <: AT
@test Base.ndims(cell) == 1
@test size(cell) == (5,)
@test length(cell) == 5
@test sum(mass(cell)) .≈ 2
@test mass(cell) isa Diagonal
@test sum(facemass(cell)) .≈ 2
@test facemass(cell) isa Diagonal
@test faceoffsets(cell) == (0, 1, 2)
@test strides(cell) == (1,)
D = derivatives(cell)
@test Array(D[1] * points(cell)) ≈ fill(SVector(one(FT)), 5)
D1d = derivatives_1d(cell)
@test length(D1d) == ndims(cell)
@test all(
Array.(D1d) .==
setprecision(BigFloat, 2^(max(8, ceil(Int, log2(precision(FT))) + 2))) do
Matrix{
FT,
}.(spectralderivative.(first.(legendregausslobatto.(BigFloat, size(cell)))))
end,
)
h1d = tohalves_1d(cell)
@test length(h1d) == ndims(cell)
@test all(length.(h1d) .== 2)
setprecision(BigFloat, 2^(max(8, ceil(Int, log2(precision(FT))) + 2))) do
p, _ = legendregausslobatto(BigFloat, size(cell)[1])
@test Array(h1d[1][1]) == Matrix{FT}(spectralinterpolation(p, (p .- 1) ./ 2))
@test Array(h1d[1][2]) == Matrix{FT}(spectralinterpolation(p, (p .+ 1) ./ 2))
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 1592 | @testset "Communication" begin
@test Raven.expand(1:0, 4) == 1:0
@test Raven.expand([], 4) == []
@test Raven.expand(3:4, 4) isa UnitRange
@test Raven.expand(3:4, 4) == 9:16
@test Raven.expand([3, 4], 4) == 9:16
let
recvindices = [7, 8, 9, 10]
recvranks = Cint[1, 2]
recvrankindices = [1:1, 2:4]
sendindices = [1, 3, 1, 3, 5]
sendranks = Cint[1, 2]
sendrankindices = [1:2, 3:5]
originalpattern = Raven.CommPattern{Array}(
recvindices,
recvranks,
recvrankindices,
sendindices,
sendranks,
sendrankindices,
)
pattern = Raven.expand(originalpattern, 3, 5)
@test pattern.recvranks == recvranks
@test pattern.recvindices == [17, 22, 27, 18, 23, 28, 19, 24, 29, 20, 25, 30]
@test pattern.recvrankindices == UnitRange{Int64}[1:3, 4:12]
@test pattern.sendranks == sendranks
@test pattern.sendindices == [1, 6, 11, 3, 8, 13, 1, 6, 11, 3, 8, 13, 5, 10, 15]
@test pattern.sendrankindices == UnitRange{Int64}[1:6, 7:15]
pattern = Raven.expand(originalpattern, 3)
@test pattern.recvranks == recvranks
@test pattern.recvindices == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
@test pattern.recvrankindices == UnitRange{Int64}[1:3, 4:12]
@test pattern.sendranks == sendranks
@test pattern.sendindices == [1, 2, 3, 7, 8, 9, 1, 2, 3, 7, 8, 9, 13, 14, 15]
@test pattern.sendrankindices == UnitRange{Int64}[1:6, 7:15]
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 1095 | # This file was modified from P4est.jl
using Pkg
Pkg.add("MPIPreferences")
Pkg.add("Preferences")
Pkg.add("UUIDs")
@static if VERSION >= v"1.8"
Pkg.compat("MPIPreferences", "0.1")
Pkg.compat("Preferences", "1")
Pkg.compat("UUIDs", "1")
end
const RAVEN_TEST = get(ENV, "RAVEN_TEST", "RAVEN_JLL_MPI_DEFAULT")
const RAVEN_TEST_LIBP4EST = get(ENV, "RAVEN_TEST_LIBP4EST", "")
const RAVEN_TEST_LIBSC = get(ENV, "RAVEN_TEST_LIBSC", "")
@static if RAVEN_TEST == "RAVEN_CUSTOM_MPI_CUSTOM"
import MPIPreferences
MPIPreferences.use_system_binary()
end
@static if RAVEN_TEST == "RAVEN_CUSTOM_MPI_CUSTOM"
import UUIDs, Preferences
Preferences.set_preferences!(
UUIDs.UUID("7d669430-f675-4ae7-b43e-fab78ec5a902"), # UUID of P4est.jl
"libp4est" => RAVEN_TEST_LIBP4EST,
force = true,
)
Preferences.set_preferences!(
UUIDs.UUID("7d669430-f675-4ae7-b43e-fab78ec5a902"), # UUID of P4est.jl
"libsc" => RAVEN_TEST_LIBSC,
force = true,
)
end
@info "Raven.jl tests configured" RAVEN_TEST RAVEN_TEST_LIBP4EST RAVEN_TEST_LIBSC
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 2502 | function extrude_testsuite(AT, FT)
@testset "extrude" begin
b = brick(FT, 3, 1)
e = extrude(b, 2)
@test Raven.coordinates(e) == (zero(FT):3, zero(FT):1, zero(FT):2)
@test Raven.vertices(e) == [
SVector{3,FT}(0, 0, 0), # 01
SVector{3,FT}(0, 0, 1), # 02
SVector{3,FT}(0, 0, 2), # 03
SVector{3,FT}(1, 0, 0), # 04
SVector{3,FT}(1, 0, 1), # 05
SVector{3,FT}(1, 0, 2), # 06
SVector{3,FT}(0, 1, 0), # 07
SVector{3,FT}(0, 1, 1), # 08
SVector{3,FT}(0, 1, 2), # 09
SVector{3,FT}(1, 1, 0), # 10
SVector{3,FT}(1, 1, 1), # 11
SVector{3,FT}(1, 1, 2), # 12
SVector{3,FT}(2, 0, 0), # 13
SVector{3,FT}(2, 0, 1), # 14
SVector{3,FT}(2, 0, 2), # 15
SVector{3,FT}(2, 1, 0), # 16
SVector{3,FT}(2, 1, 1), # 17
SVector{3,FT}(2, 1, 2), # 18
SVector{3,FT}(3, 0, 0), # 19
SVector{3,FT}(3, 0, 1), # 20
SVector{3,FT}(3, 0, 2), # 21
SVector{3,FT}(3, 1, 0), # 22
SVector{3,FT}(3, 1, 1), # 23
SVector{3,FT}(3, 1, 2), # 24
]
# z = 2
# 09-----12-----21-----24
# | | | |
# | | | |
# | | | |
# 03-----06-----15-----18
# z = 1
# 08-----11-----20-----23
# | | | |
# | | | |
# | | | |
# 02-----05-----14-----17
# z = 0
# 07-----10-----19-----22
# | | | |
# | | | |
# | | | |
# 01-----04-----13-----16
@test Raven.cells(e) == [
(01, 04, 07, 10, 02, 05, 08, 11)
(02, 05, 08, 11, 03, 06, 09, 12)
(04, 13, 10, 16, 05, 14, 11, 17)
(05, 14, 11, 17, 06, 15, 12, 18)
(13, 19, 16, 22, 14, 20, 17, 23)
(14, 20, 17, 23, 15, 21, 18, 24)
]
c = LobattoCell{FT,AT}(2, 2, 2)
gm = GridManager(c, e)
grid = generate(gm)
pts = points(grid)
fm = facemaps(grid)
pts = Adapt.adapt(Array, pts)
fm = Adapt.adapt(Array, fm)
@test isapprox(pts[fm.vmapM], pts[fm.vmapP])
@test isapprox(pts[fm.vmapM[fm.mapM]], pts[fm.vmapM[fm.mapP]])
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 201646 | @testset "Decode face code" begin
@test @inferred(decode(0x00)) === (0x0, 0x0, 0x0, 0x0)
@test @inferred(decode(0x0000)) === (
(0x0, 0x0, 0x0, 0x0, 0x0, 0x0),
(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0),
)
for (code, val) in Any[
(0x00, (0x0, 0x0, 0x0, 0x0)),
(0x01, (0x0, 0x0, 0x0, 0x0)),
(0x02, (0x0, 0x0, 0x0, 0x0)),
(0x03, (0x0, 0x0, 0x0, 0x0)),
(0x04, (0x1, 0x0, 0x0, 0x0)),
(0x05, (0x0, 0x1, 0x0, 0x0)),
(0x06, (0x2, 0x0, 0x0, 0x0)),
(0x07, (0x0, 0x2, 0x0, 0x0)),
(0x08, (0x0, 0x0, 0x1, 0x0)),
(0x09, (0x0, 0x0, 0x2, 0x0)),
(0x0a, (0x0, 0x0, 0x0, 0x1)),
(0x0b, (0x0, 0x0, 0x0, 0x2)),
(0x0c, (0x1, 0x0, 0x1, 0x0)),
(0x0d, (0x0, 0x1, 0x2, 0x0)),
(0x0e, (0x2, 0x0, 0x0, 0x1)),
(0x0f, (0x0, 0x2, 0x0, 0x2)),
(
0x0000,
(
(0x0, 0x0, 0x0, 0x0, 0x0, 0x0),
(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0),
),
),
(
0x0001,
(
(0x0, 0x0, 0x0, 0x0, 0x0, 0x0),
(0x0, 0x0, 0x0, 0x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0, 0x0, 0x3, 0x0, 0x3),
(0x0, 0x5, 0x5, 0x3, 0x5, 0x0, 0x4, 0x5, 0x5, 0x0, 0x4, 0x5),
),
),
(
0x03ff,
(
(0x0, 0x4, 0x0, 0x4, 0x0, 0x4),
(0x0, 0x5, 0x5, 0x4, 0x0, 0x5, 0x5, 0x4, 0x0, 0x5, 0x5, 0x4),
),
),
]
@test decode(code) === val
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 1165 | function flatten_testsuite(AT, FT)
obj = (a = (Complex(FT(1), FT(2)), FT(3)), b = FT(4), c = SVector(FT(5)))
obj_flattened = (FT(1), FT(2), FT(3), FT(4), FT(5))
@test @inferred(flatten(obj)) == obj_flattened
@test @inferred(unflatten(typeof(obj), obj_flattened)) == obj
@test @inferred(flatten(zero(FT))) == (zero(FT),)
@test @inferred(unflatten(FT, (zero(FT),))) == zero(FT)
@kernel function foo!(y, @Const(x), ::Type{T}) where {T}
@inbounds begin
z = (x[1], x[2], x[3])
y[1] = unflatten(T, z)
end
end
@kernel function bar!(x, @Const(y))
@inbounds begin
z = flatten(y[1])
(x[1], x[2], x[3]) = z
end
end
T = Tuple{SVector{1,Complex{FT}},FT}
xh = [FT(1), FT(2), FT(3)]
x = AT(xh)
y = AT{T}([(SVector(complex(zero(FT), zero(FT))), zero(FT))])
backend = get_backend(x)
foo!(backend, 1, 1)(y, x, T)
KernelAbstractions.synchronize(backend)
@test Array(y)[1] == unflatten(T, xh)
fill!(x, 0.0)
bar!(backend, 1, 1)(x, y)
KernelAbstractions.synchronize(backend)
@test Array(x) == xh
return
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 617 | function gridarrays_testsuite(AT, FT)
let
N = (3, 2)
K = (2, 3)
L = 1
gm = GridManager(LobattoCell{FT,AT}(N...), Raven.brick(FT, K); min_level = L)
grid = generate(gm)
x = points(grid)
@test x isa GridArray
@test size(x) == (N..., prod(K) * 4^L)
y = AT(x)
@test y isa AT
F = Raven.fieldindex(x)
xp = parent(x)
nonfielddims = SVector((1:(F-1))..., ((F+1):ndims(xp))...)
perm = insert(nonfielddims, 1, F)
xp = permutedims(xp, perm)
@test reinterpret(reshape, FT, y) == xp
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 20228 | @testset "Grid Numbering" begin
function isisomorphic(a, b)
f = Dict{eltype(a),eltype(b)}()
g = Dict{eltype(b),eltype(a)}()
for i in eachindex(a, b)
if a[i] in keys(f)
if f[a[i]] != b[i]
@error "$(a[i]) -> $(f[a[i]]) exists when adding $(a[i]) -> $(b[i])"
return false
end
else
f[a[i]] = b[i]
end
if b[i] in keys(g)
if g[b[i]] != a[i]
@error "$(g[b[i]]) <- $(b[i]) exists when adding $(a[i]) <- $(b[i])"
return false
end
else
g[b[i]] = a[i]
end
end
return true
end
function istranspose(ctod, dtoc)
rows = rowvals(ctod)
vals = nonzeros(ctod)
_, n = size(ctod)
for j = 1:n
for k in nzrange(ctod, j)
if vals[k] == false
return false
end
i = rows[k]
if j != dtoc[i]
return false
end
end
end
return true
end
let
# Coarse Grid
# y
# ^
# 4 | 7------8------9
# | | | |
# | | | |
# | | | |
# 2 | 3------4------6
# | | | |
# | | | |
# | | | |
# 0 | 1------2------5
# |
# +------------------> x
# 0 2 4
vertices = [
SVector(0.0, 0.0), # 1
SVector(2.0, 0.0), # 2
SVector(0.0, 2.0), # 3
SVector(2.0, 2.0), # 4
SVector(4.0, 0.0), # 5
SVector(4.0, 2.0), # 6
SVector(0.0, 4.0), # 7
SVector(2.0, 4.0), # 8
SVector(4.0, 4.0), # 9
]
cells = [
(1, 2, 3, 4), # 1
(6, 4, 5, 2), # 2
(3, 4, 7, 8), # 3
(4, 6, 8, 9), # 4
]
cg = coarsegrid(vertices, cells)
forest = P4estTypes.pxest(Raven.connectivity(cg))
P4estTypes.refine!(forest; refine = (_, tid, _) -> tid == 4)
P4estTypes.balance!(forest)
ghost = P4estTypes.ghostlayer(forest)
nodes = P4estTypes.lnodes(forest; ghost, degree = 3)
P4estTypes.expand!(ghost, forest, nodes)
quadranttoglobalids = Raven.materializequadranttoglobalid(forest, ghost)
@test quadranttoglobalids == 1:7
quadrantcommpattern = Raven.materializequadrantcommpattern(forest, ghost)
@test quadrantcommpattern.recvindices == 8:7
@test quadrantcommpattern.recvranks == []
@test quadrantcommpattern.recvrankindices == []
@test quadrantcommpattern.sendindices == 8:7
@test quadrantcommpattern.sendranks == []
@test quadrantcommpattern.sendrankindices == []
# 21 32 33 33 36 37
# 18 30 31 31 34 35
# 9 24 25 25 28 29
#
# 19 20 21 21 24 25 25 28 29
# 16 17 18 18 22 23 23 26 27
# 7 8 9 9 11 10 9 11 10
#
# 7 8 9 9 11 10
# 4 5 6 6 13 12
# 1 2 3 3 15 14
(dtoc_degree_3_local, dtoc_degree_3_global) =
Raven.materializedtoc(forest, ghost, nodes, quadrantcommpattern, MPI.COMM_WORLD)
@test dtoc_degree_3_local == dtoc_degree_3_global
@test dtoc_degree_3_local == P4estTypes.unsafe_element_nodes(nodes) .+ 0x1
cell_degree_3 = LobattoCell{Float64,Array}(4, 4)
dtoc_degree_3 =
Raven.materializedtoc(cell_degree_3, dtoc_degree_3_local, dtoc_degree_3_global)
@test isisomorphic(dtoc_degree_3, dtoc_degree_3_global)
ctod_degree_3 = Raven.materializectod(dtoc_degree_3)
@test ctod_degree_3 isa AbstractSparseMatrix
@test istranspose(ctod_degree_3, dtoc_degree_3)
quadranttolevel = Int8[
P4estTypes.level.(Iterators.flatten(forest))
P4estTypes.level.(P4estTypes.ghosts(ghost))
]
parentnodes = Raven.materializeparentnodes(
cell_degree_3,
ctod_degree_3,
quadranttoglobalids,
quadranttolevel,
)
Np = length(cell_degree_3)
for lid in eachindex(parentnodes)
pid = parentnodes[lid]
qlid = cld(lid, Np)
qpid = cld(pid, Np)
@test quadranttolevel[qpid] <= quadranttolevel[qlid]
if quadranttolevel[qlid] == quadranttolevel[qpid]
@test quadranttoglobalids[qlid] >= quadranttoglobalids[qpid]
end
@test dtoc_degree_3[pid] == dtoc_degree_3[lid]
end
GC.@preserve nodes begin
@test Raven.materializequadranttofacecode(nodes) ==
P4estTypes.unsafe_face_code(nodes)
end
end
let
# Coarse Grid
# z = 0:
# y
# ^
# 4 | 7------8------9
# | | | |
# | | | |
# | | | |
# 2 | 3------4------6
# | | | |
# | | | |
# | | | |
# 0 | 1------2------5
# |
# +------------------> x
# 0 2 4
#
# z = 2:
# y
# ^
# 4 | 16-----17-----18
# | | | |
# | | | |
# | | | |
# 2 | 12-----13-----15
# | | | |
# | | | |
# | | | |
# 0 | 10-----11-----14
# |
# +------------------> x
# 0 2 4
vertices = [
SVector(0.0, 0.0, 0.0), # 1
SVector(2.0, 0.0, 0.0), # 2
SVector(0.0, 2.0, 0.0), # 3
SVector(2.0, 2.0, 0.0), # 4
SVector(4.0, 0.0, 0.0), # 5
SVector(4.0, 2.0, 0.0), # 6
SVector(0.0, 4.0, 0.0), # 7
SVector(2.0, 4.0, 0.0), # 8
SVector(4.0, 4.0, 0.0), # 9
SVector(0.0, 0.0, 2.0), # 10
SVector(2.0, 0.0, 2.0), # 11
SVector(0.0, 2.0, 2.0), # 12
SVector(2.0, 2.0, 2.0), # 13
SVector(4.0, 0.0, 2.0), # 14
SVector(4.0, 2.0, 2.0), # 15
SVector(0.0, 4.0, 2.0), # 16
SVector(2.0, 4.0, 2.0), # 17
SVector(4.0, 4.0, 2.0), # 18
]
cells = [
(1, 2, 3, 4, 10, 11, 12, 13), # 1
(6, 4, 5, 2, 15, 13, 14, 11), # 2
(3, 4, 7, 8, 12, 13, 16, 17), # 3
(4, 6, 8, 9, 13, 15, 17, 18), # 4
]
cg = coarsegrid(vertices, cells)
forest = P4estTypes.pxest(Raven.connectivity(cg))
P4estTypes.refine!(forest; refine = (_, tid, _) -> tid == 4)
P4estTypes.balance!(forest)
ghost = P4estTypes.ghostlayer(forest)
nodes = P4estTypes.lnodes(forest; ghost, degree = 3)
P4estTypes.expand!(ghost, forest, nodes)
quadranttoglobalids = Raven.materializequadranttoglobalid(forest, ghost)
@test quadranttoglobalids == 1:11
quadrantcommpattern = Raven.materializequadrantcommpattern(forest, ghost)
@test quadrantcommpattern.recvindices == 12:11
@test quadrantcommpattern.recvranks == []
@test quadrantcommpattern.recvrankindices == []
@test quadrantcommpattern.sendindices == 12:11
@test quadrantcommpattern.sendranks == []
@test quadrantcommpattern.sendrankindices == []
(dtoc_degree_3_local, dtoc_degree_3_global) =
Raven.materializedtoc(forest, ghost, nodes, quadrantcommpattern, MPI.COMM_WORLD)
@test dtoc_degree_3_local == dtoc_degree_3_global
@test dtoc_degree_3_local == P4estTypes.unsafe_element_nodes(nodes) .+ 0x1
cell_degree_3 = LobattoCell{Float64,Array}(4, 4, 4)
dtoc_degree_3 =
Raven.materializedtoc(cell_degree_3, dtoc_degree_3_local, dtoc_degree_3_global)
@test isisomorphic(dtoc_degree_3, dtoc_degree_3_global)
ctod_degree_3 = Raven.materializectod(dtoc_degree_3)
@test ctod_degree_3 isa AbstractSparseMatrix
@test istranspose(ctod_degree_3, dtoc_degree_3)
quadranttolevel = Int8[
P4estTypes.level.(Iterators.flatten(forest))
P4estTypes.level.(P4estTypes.ghosts(ghost))
]
parentnodes = Raven.materializeparentnodes(
cell_degree_3,
ctod_degree_3,
quadranttoglobalids,
quadranttolevel,
)
Np = length(cell_degree_3)
for lid in eachindex(parentnodes)
pid = parentnodes[lid]
qlid = cld(lid, Np)
qpid = cld(pid, Np)
@test quadranttolevel[qpid] <= quadranttolevel[qlid]
if quadranttolevel[qlid] == quadranttolevel[qpid]
@test quadranttoglobalids[qlid] >= quadranttoglobalids[qpid]
end
@test dtoc_degree_3[pid] == dtoc_degree_3[lid]
end
GC.@preserve nodes begin
@test Raven.materializequadranttofacecode(nodes) ==
P4estTypes.unsafe_face_code(nodes)
end
end
let
FT = Float64
AT = Array
N = 4
cell = LobattoCell{FT,AT}(N, N)
# 4--------5--------6
# | | |
# | | |
# | | |
# | | |
# 1--------2--------3
vertices = [
SVector{2,FT}(-1, -1), # 1
SVector{2,FT}(0, -1), # 2
SVector{2,FT}(1, -1), # 3
SVector{2,FT}(-1, 1), # 4
SVector{2,FT}(0, 1), # 5
SVector{2,FT}(1, 1), # 6
]
for cells in [[(1, 2, 4, 5), (2, 3, 5, 6)], [(1, 2, 4, 5), (5, 6, 2, 3)]]
cg = coarsegrid(vertices, cells)
gm = GridManager(cell, cg)
grid = generate(gm)
A = continuoustodiscontinuous(grid)
pts = points(grid)
rows = rowvals(A)
vals = nonzeros(A)
_, n = size(A)
ncontinuous = 0
ndiscontinuous = 0
for j = 1:n
x = pts[rows[first(nzrange(A, j))]]
if length(nzrange(A, j)) > 0
ncontinuous += 1
end
for ii in nzrange(A, j)
ndiscontinuous += 1
@test pts[rows[ii]] ≈ x
end
end
@test ncontinuous == 2N^2 - N
@test ndiscontinuous == 2N^2
pts = Adapt.adapt(Array, pts)
fm = Adapt.adapt(Array, facemaps(grid))
@test isapprox(pts[fm.vmapM], pts[fm.vmapP])
@test isapprox(pts[fm.vmapM[fm.mapM]], pts[fm.vmapM[fm.mapP]])
bc = boundarycodes(grid)
vmapM = reshape(fm.vmapM, (N, 4, :))
for q = 1:numcells(grid)
for f = 1:4
if bc[f, q] == 1
@test all(
isapprox.(
one(FT),
map(x -> maximum(abs.(x)), pts[vmapM[:, f, q]]),
),
)
else
@test !all(
isapprox.(
one(FT),
map(x -> maximum(abs.(x)), pts[vmapM[:, f, q]]),
),
)
end
end
end
end
end
let
cell = LobattoCell(2, 2, 2)
cg = brick((1, 1, 1), (true, true, true))
gm = GridManager(cell, cg)
grid = generate(gm)
fm = facemaps(grid)
@test fm.vmapP ==
[2; 4; 6; 8; 1; 3; 5; 7; 3; 4; 7; 8; 1; 2; 5; 6; 5; 6; 7; 8; 1; 2; 3; 4;;]
end
let
cell = LobattoCell(2, 2)
cg = brick((1, 1), (true, true))
gm = GridManager(cell, cg)
grid = generate(gm)
fm = facemaps(grid)
@test fm.vmapP == [2; 4; 1; 3; 3; 4; 1; 2;;]
end
let
FT = Float64
AT = Array
N = 5
cell = LobattoCell(N, N, N)
# 10-------11-------12
# /| /| /|
# / | / | / |
# / | / | / |
# 7--------8--------9 |
# | 4----|---5----|---6
# | / | / | /
# | / | / | /
# |/ |/ |/
# 1--------2--------3
#
vertices = [
SVector{3,FT}(-1, -1, -1), # 1
SVector{3,FT}(0, -1, -1), # 2
SVector{3,FT}(1, -1, -1), # 3
SVector{3,FT}(-1, 1, -1), # 4
SVector{3,FT}(0, 1, -1), # 5
SVector{3,FT}(1, 1, -1), # 6
SVector{3,FT}(-1, -1, 1), # 7
SVector{3,FT}(0, -1, 1), # 8
SVector{3,FT}(1, -1, 1), # 9
SVector{3,FT}(-1, 1, 1), #10
SVector{3,FT}(0, 1, 1), #12
SVector{3,FT}(1, 1, 1), #13
]
for cells in [
# 2--------6 55 4--------2
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 8--------6 |
# | 1----|---5 54 | 3----|---1
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 7--------5
[(4, 10, 1, 7, 5, 11, 2, 8), (6, 12, 5, 11, 3, 9, 2, 8)],
#
# 2--------6 55 7--------5
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 3--------1 |
# | 1----|---5 54 | 8----|---6
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 4--------2
[(4, 10, 1, 7, 5, 11, 2, 8), (9, 3, 8, 2, 12, 6, 11, 5)],
#
# 2--------6 55 8--------6
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 7--------5 |
# | 1----|---5 54 | 4----|---2
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 3--------1
[(4, 10, 1, 7, 5, 11, 2, 8), (3, 6, 2, 5, 9, 12, 8, 11)],
#
# 2--------6 55 3--------1
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 4--------2 |
# | 1----|---5 54 | 7----|---5
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 8--------6
[(4, 10, 1, 7, 5, 11, 2, 8), (12, 9, 11, 8, 6, 3, 5, 2)],
#
# 2--------6 55 5--------7
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 6--------8 |
# | 1----|---5 54 | 1----|---3
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 2--------4
[(4, 10, 1, 7, 5, 11, 2, 8), (5, 2, 6, 3, 11, 8, 12, 9)],
#
# 2--------6 55 5--------1
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 8--------3 |
# | 1----|---5 54 | 6----|---2
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 7--------4
[(4, 10, 1, 7, 5, 11, 2, 8), (12, 6, 9, 3, 11, 5, 8, 2)],
#
# 2--------6 55 8--------4
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 6--------2 |
# | 1----|---5 54 | 7----|---3
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 5--------1
[(4, 10, 1, 7, 5, 11, 2, 8), (3, 9, 6, 12, 2, 8, 5, 11)],
#
# 2--------6 55 6--------2
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 5--------1 |
# | 1----|---5 54 | 8----|---4
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 7--------3
[(4, 10, 1, 7, 5, 11, 2, 8), (9, 12, 3, 6, 8, 11, 2, 5)],
]
cg = coarsegrid(vertices, cells)
gm = GridManager(cell, cg)
grid = generate(gm)
A = grid.continuoustodiscontinuous
pts = points(grid)
rows = rowvals(A)
vals = nonzeros(A)
_, n = size(A)
ncontinuous = 0
ndiscontinuous = 0
for j = 1:n
x = pts[rows[first(nzrange(A, j))]]
if length(nzrange(A, j)) > 0
ncontinuous += 1
end
for ii in nzrange(A, j)
ndiscontinuous += 1
@test pts[rows[ii]] ≈ x
end
end
@test ncontinuous == 2N^3 - N^2
@test ndiscontinuous == 2N^3
pts = Adapt.adapt(Array, pts)
fm = Adapt.adapt(Array, facemaps(grid))
@test isapprox(pts[fm.vmapM], pts[fm.vmapP])
@test isapprox(pts[fm.vmapM[fm.mapM]], pts[fm.vmapM[fm.mapP]])
bc = boundarycodes(grid)
vmapM = reshape(fm.vmapM, (N, N, 6, :))
for q = 1:numcells(grid)
for f = 1:6
if bc[f, q] == 1
@test all(
isapprox.(
one(FT),
map(x -> maximum(abs.(x)), pts[vmapM[:, :, f, q]]),
),
)
else
@test !all(
isapprox.(
one(FT),
map(x -> maximum(abs.(x)), pts[vmapM[:, :, f, q]]),
),
)
end
end
end
end
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 28369 | using ReadVTK
function min_node_dist_warpfun(x⃗::SVector{2})
FT = eltype(x⃗)
ξ1, ξ2 = x⃗
ξ1 ≥ FT(1 / 2) && (ξ1 = FT(1 / 2) + 2 * (ξ1 - FT(1 / 2)))
ξ2 ≥ FT(3 / 2) && (ξ2 = FT(3 / 2) + 2 * (ξ2 - FT(3 / 2)))
return SVector(ξ1, ξ2)
end
function min_node_dist_warpfun(x⃗::SVector{3})
FT = eltype(x⃗)
ξ1, ξ2, ξ3 = x⃗
ξ1 ≥ FT(1 / 2) && (ξ1 = FT(1 / 2) + 2 * (ξ1 - FT(1 / 2)))
ξ2 ≥ FT(1 / 2) && (ξ2 = FT(1 / 2) + 2 * (ξ2 - FT(1 / 2)))
ξ3 ≥ FT(3 / 2) && (ξ3 = FT(3 / 2) + 2 * (ξ3 - FT(3 / 2)))
return SVector(ξ1, ξ2, ξ3)
end
function grids_testsuite(AT, FT)
rng = StableRNG(37)
let
N = (3, 2)
K = (2, 3)
coordinates =
ntuple(d -> range(-one(FT), stop = one(FT), length = K[d] + 1), length(K))
gm = GridManager(LobattoCell{FT,AT}(N...), Raven.brick(coordinates); min_level = 2)
indicator = rand(rng, (Raven.AdaptNone, Raven.AdaptRefine), length(gm))
adapt!(gm, indicator)
warp(x::SVector{2}) = SVector(
x[1] + cospi(3x[2] / 2) * cospi(x[1] / 2) * cospi(x[2] / 2) / 5,
x[2] + sinpi(3x[1] / 2) * cospi(x[1] / 2) * cospi(x[2] / 2) / 5,
)
grid = generate(warp, gm)
@test grid isa Raven.Grid
@test issparse(grid.continuoustodiscontinuous)
mktempdir() do tmpdir
vtk_grid("$tmpdir/grid", grid) do vtk
vtk["CellNumber"] = (1:length(grid)) .+ offset(grid)
P = toequallyspaced(referencecell(grid))
x = P * points(grid)
vtk["x"] = Adapt.adapt(Array, x)
end
@test isfile("$tmpdir/grid.pvtu")
@test isdir("$tmpdir/grid")
@test_nowarn VTKFile("$tmpdir/grid/grid_1.vtu")
end
end
let
N = (3, 3, 3)
R = FT(2)
r = FT(1)
coarse_grid = Raven.cubeshellgrid(R, r)
gm = GridManager(LobattoCell{FT,AT}(N...), coarse_grid, min_level = 2)
indicator = rand(rng, (Raven.AdaptNone, Raven.AdaptRefine), length(gm))
adapt!(gm, indicator)
grid = generate(gm)
@test grid isa Raven.Grid
@test issparse(grid.continuoustodiscontinuous)
mktempdir() do tmpdir
vtk_grid("$tmpdir/grid", grid) do vtk
vtk["CellNumber"] = (1:length(grid)) .+ offset(grid)
P = toequallyspaced(referencecell(grid))
x = P * reshape(points(grid), size(P, 2), :)
vtk["x"] = Adapt.adapt(Array, x)
end
@test isfile("$tmpdir/grid.pvtu")
@test isdir("$tmpdir/grid")
@test_nowarn VTKFile("$tmpdir/grid/grid_1.vtu")
end
end
let
N = (3, 3)
R = FT(1)
coarse_grid = Raven.cubeshell2dgrid(R)
gm = GridManager(LobattoCell{FT,AT}(N...), coarse_grid, min_level = 2)
indicator = rand(rng, (Raven.AdaptNone, Raven.AdaptRefine), length(gm))
adapt!(gm, indicator)
grid = generate(gm)
@test grid isa Raven.Grid
@test issparse(grid.continuoustodiscontinuous)
mktempdir() do tmpdir
vtk_grid("$tmpdir/grid", grid) do vtk
vtk["CellNumber"] = (1:length(grid)) .+ offset(grid)
P = toequallyspaced(referencecell(grid))
x = P * reshape(points(grid), size(P, 2), :)
vtk["x"] = Adapt.adapt(Array, x)
end
@test isfile("$tmpdir/grid.pvtu")
@test isdir("$tmpdir/grid")
@test_nowarn VTKFile("$tmpdir/grid/grid_1.vtu")
end
end
let
N = (4, 4)
K = (2, 1)
coordinates =
ntuple(d -> range(-one(FT), stop = one(FT), length = K[d] + 1), length(K))
cell = LobattoCell{FT,AT}(N...)
gm = GridManager(cell, brick(coordinates, (true, true)))
grid = generate(gm)
@test all(boundarycodes(grid) .== 0)
end
let
N = (3, 2, 4)
K = (2, 3, 1)
coordinates =
ntuple(d -> range(-one(FT), stop = one(FT), length = K[d] + 1), length(K))
gm = GridManager(LobattoCell{FT,AT}(N...), Raven.brick(coordinates); min_level = 1)
indicator = rand(rng, (Raven.AdaptNone, Raven.AdaptRefine), length(gm))
adapt!(gm, indicator)
warp(x::SVector{3}) = x
grid = generate(warp, gm)
@test grid isa Raven.Grid
@test issparse(grid.continuoustodiscontinuous)
mktempdir() do tmpdir
vtk_grid("$tmpdir/grid", grid) do vtk
vtk["CellNumber"] = (1:length(grid)) .+ offset(grid)
P = toequallyspaced(referencecell(grid))
x = P * points(grid)
vtk["x"] = Adapt.adapt(Array, x)
end
@test isfile("$tmpdir/grid.pvtu")
@test isdir("$tmpdir/grid")
@test_nowarn VTKFile("$tmpdir/grid/grid_1.vtu")
end
end
let
cell = LobattoCell{FT,AT}(4, 4)
vertices = [
SVector{2,FT}(0, 0), # 1
SVector{2,FT}(2, 0), # 2
SVector{2,FT}(0, 2), # 3
SVector{2,FT}(2, 2), # 4
SVector{2,FT}(4, 0), # 5
SVector{2,FT}(4, 2), # 6
]
cells = [(1, 2, 3, 4), (4, 2, 6, 5)]
cg = coarsegrid(vertices, cells)
gm = GridManager(cell, cg)
grid = generate(gm)
@test grid isa Raven.Grid
@test issparse(grid.continuoustodiscontinuous)
mktempdir() do tmpdir
vtk_grid("$tmpdir/grid", grid) do vtk
vtk["CellNumber"] = (1:length(grid)) .+ Raven.offset(grid)
P = toequallyspaced(referencecell(grid))
x = P * points(grid)
vtk["x"] = Adapt.adapt(Array, x)
end
@test isfile("$tmpdir/grid.pvtu")
@test isdir("$tmpdir/grid")
@test_nowarn VTKFile("$tmpdir/grid/grid_1.vtu")
end
end
let
cell = LobattoCell{FT,AT}(3, 3, 3)
vertices = [
SVector{3,FT}(0, 0, 0), # 1
SVector{3,FT}(2, 0, 0), # 2
SVector{3,FT}(0, 2, 0), # 3
SVector{3,FT}(2, 2, 0), # 4
SVector{3,FT}(0, 0, 2), # 5
SVector{3,FT}(2, 0, 2), # 6
SVector{3,FT}(0, 2, 2), # 7
SVector{3,FT}(2, 2, 2), # 8
SVector{3,FT}(4, 0, 0), # 9
SVector{3,FT}(4, 2, 0), # 10
SVector{3,FT}(4, 0, 2), # 11
SVector{3,FT}(4, 2, 2), # 12
]
cells = [(1, 2, 3, 4, 5, 6, 7, 8), (4, 2, 10, 9, 8, 6, 12, 11)]
cg = coarsegrid(vertices, cells)
gm = GridManager(cell, cg)
grid = generate(gm)
@test grid isa Raven.Grid
@test issparse(grid.continuoustodiscontinuous)
mktempdir() do tmpdir
vtk_grid("$tmpdir/grid", grid) do vtk
vtk["CellNumber"] = (1:length(grid)) .+ Raven.offset(grid)
P = toequallyspaced(referencecell(grid))
x = P * points(grid)
vtk["x"] = Adapt.adapt(Array, x)
end
@test isfile("$tmpdir/grid.pvtu")
@test isdir("$tmpdir/grid")
@test_nowarn VTKFile("$tmpdir/grid/grid_1.vtu")
end
end
@testset "2D metrics" begin
f(x) = SA[
9*x[1]-(1+x[1])*x[2]^2+(x[1]-1)^2*(1-x[2]^2+x[2]^3),
10*x[2]+x[1]*x[1]^3*(1-x[2])+x[1]^2*x[2]*(1+x[2]),
]
f11(x) = 7 + x[2]^2 - 2 * x[2]^3 + 2 * x[1] * (1 - x[2]^2 + x[2]^3)
f12(x) = -2 * (1 + x[1]) * x[2] + (-1 + x[1])^2 * x[2] * (-2 + 3 * x[2])
f21(x) = -4 * x[1]^3 * (-1 + x[2]) + 2 * x[1] * x[2] * (1 + x[2])
f22(x) = 10 - x[1] * x[1]^3 + x[1]^2 * (1 + 2 * x[2])
fJ(x, dx1, dx2, l) = SA[
f11(x)*(dx1/2^(l+1)) f12(x)*(dx2/2^(l+1))
f21(x)*(dx1/2^(l+1)) f22(x)*(dx2/2^(l+1))
]
coordinates = (
range(-one(FT), stop = one(FT), length = 6),
range(-one(FT), stop = one(FT), length = 5),
)
L = 10
M = 12
level = 2
gm = GridManager(
LobattoCell{FT,AT}(L, M),
Raven.brick(coordinates);
min_level = level,
)
unwarpedgrid = generate(gm)
grid = generate(f, gm)
wr, ws = weights_1d(referencecell(gm))
ux = points(unwarpedgrid)
uJ = fJ.(ux, step.(coordinates)..., level)
uwJ = wr .* ws .* det.(uJ)
uinvJ = inv.(uJ)
invJ, J, wJ = components(first(volumemetrics(grid)))
@test all(adapt(Array, J .≈ det.(uJ)))
@test all(adapt(Array, wJ .≈ uwJ))
@test all(adapt(Array, invJ .≈ uinvJ))
wJinvG, wJ = components(last(volumemetrics(grid)))
@test all(adapt(Array, wJ .≈ uwJ))
g(x) = x * x'
@test all(adapt(Array, wJinvG) .≈ adapt(Array, uwJ .* g.(uinvJ)))
uJ = adapt(Array, uJ)
wr = adapt(Array, wr)
ws = adapt(Array, ws)
sm, _ = surfacemetrics(grid)
sm = adapt(Array, sm)
n, sJ, wsJ = components(sm)
a = n .* wsJ
@test all(
a[1:M, 1:numcells(grid)] ./ vec(ws) .≈
map(g -> SA[-g[2, 2], g[1, 2]], uJ[1, :, :]),
)
@test all(
a[M.+(1:M), :] ./ vec(ws) .≈ map(g -> SA[g[2, 2], -g[1, 2]], uJ[end, :, :]),
)
@test all(
a[2M.+(1:L), 1:numcells(grid)] ./ vec(wr) .≈
map(g -> SA[g[2, 1], -g[1, 1]], uJ[:, 1, :]),
)
@test all(
a[2M.+L.+(1:L), 1:numcells(grid)] ./ vec(wr) .≈
map(g -> SA[-g[2, 1], g[1, 1]], uJ[:, end, :]),
)
a = n .* sJ
@test all(a[1:M, 1:numcells(grid)] .≈ map(g -> SA[-g[2, 2], g[1, 2]], uJ[1, :, :]))
@test all(a[M.+(1:M), :] .≈ map(g -> SA[g[2, 2], -g[1, 2]], uJ[end, :, :]))
@test all(
a[2M.+(1:L), 1:numcells(grid)] .≈ map(g -> SA[g[2, 1], -g[1, 1]], uJ[:, 1, :]),
)
@test all(
a[2M.+L.+(1:L), 1:numcells(grid)] .≈
map(g -> SA[-g[2, 1], g[1, 1]], uJ[:, end, :]),
)
@test all(norm.(n) .≈ 1)
end
@testset "2D spherical shell" begin
L = 6
level = 1
R = FT(3)
gm = GridManager(
# Polynomial orders need to be the same to match up faces.
# We currently do not support different polynomial orders for
# joining faces.
LobattoCell{FT,AT}(L, L),
Raven.cubeshell2dgrid(R);
min_level = level,
)
grid = generate(gm)
_, _, wJ = components(first(volumemetrics(grid)))
@test sum(adapt(Array, wJ)) ≈ pi * R^2 * 4
pts = points(grid)
fm = facemaps(grid)
pts = Adapt.adapt(Array, pts)
fm = Adapt.adapt(Array, fm)
@test isapprox(pts[fm.vmapM], pts[fm.vmapP])
@test isapprox(pts[fm.vmapM[fm.mapM]], pts[fm.vmapM[fm.mapP]])
end
@testset "2D constant preserving" begin
f(x) = SA[
9*x[1]-(1+x[1])*x[2]^2+(x[1]-1)^2*(1-x[2]^2+x[2]^3),
10*x[2]+x[1]*x[1]^3*(1-x[2])+x[1]^2*x[2]*(1+x[2]),
]
coordinates = (
range(-one(FT), stop = one(FT), length = 3),
range(-one(FT), stop = one(FT), length = 5),
)
L = 3
M = 4
level = 0
gm = GridManager(
LobattoCell{FT,AT}(L, M),
Raven.brick(coordinates);
min_level = level,
)
grid = generate(f, gm)
invJ, J, _ = components(first(volumemetrics(grid)))
invJ11, invJ21, invJ12, invJ22 = components(invJ)
Dr, Ds = derivatives(referencecell(grid))
cp1 = (Dr * (J .* invJ11) + Ds * (J .* invJ21))
cp2 = (Dr * (J .* invJ12) + Ds * (J .* invJ22))
@test norm(adapt(Array, cp1), Inf) < 200 * eps(FT)
@test norm(adapt(Array, cp2), Inf) < 200 * eps(FT)
end
@testset "3D metrics" begin
f(x) = SA[
3x[1]+x[2]/5+x[3]/10+x[1]*x[2]^2*x[3]^3/3,
4x[2]+x[1]^3*x[2]^2*x[3]/4,
2x[3]+x[1]^2*x[2]*x[3]^3/2,
]
f11(x) = 3 * oneunit(eltype(x)) + x[2]^2 * x[3]^3 / 3
f12(x) = oneunit(eltype(x)) / 5 + 2 * x[1] * x[2] * x[3]^3 / 3
f13(x) = oneunit(eltype(x)) / 10 + 3 * x[1] * x[2]^2 * x[3]^2 / 3
f21(x) = 3 * x[1]^2 * x[2]^2 * x[3] / 4
f22(x) = 4 * oneunit(eltype(x)) + 2 * x[1]^3 * x[2] * x[3] / 4
f23(x) = x[1]^3 * x[2]^2 / 4
f31(x) = 2 * x[1] * x[2] * x[3]^3 / 2
f32(x) = x[1]^2 * x[3]^3 / 2
f33(x) = 2 * oneunit(eltype(x)) + 3 * x[1]^2 * x[2] * x[3]^2 / 2
fJ(x, dx1, dx2, dx3, l) = SA[
f11(x)*(dx1/2^(l+1)) f12(x)*(dx2/2^(l+1)) f13(x)*(dx3/2^(l+1))
f21(x)*(dx1/2^(l+1)) f22(x)*(dx2/2^(l+1)) f23(x)*(dx3/2^(l+1))
f31(x)*(dx1/2^(l+1)) f32(x)*(dx2/2^(l+1)) f33(x)*(dx3/2^(l+1))
]
coordinates = (
range(-one(FT), stop = one(FT), length = 3),
range(-one(FT), stop = one(FT), length = 2),
range(-one(FT), stop = one(FT), length = 4),
)
L = 6
M = 8
N = 7
level = 0
gm = GridManager(
LobattoCell{FT,AT}(L, M, N),
Raven.brick(coordinates);
min_level = level,
)
unwarpedgrid = generate(gm)
grid = generate(f, gm)
wr, ws, wt = weights_1d(referencecell(gm))
ux = points(unwarpedgrid)
uJ = fJ.(ux, step.(coordinates)..., level)
uwJ = wr .* ws .* wt .* det.(uJ)
uinvJ = inv.(uJ)
invJ, J, wJ = components(first(volumemetrics(grid)))
@test all(adapt(Array, J .≈ det.(uJ)))
@test all(adapt(Array, wJ .≈ uwJ))
@test all(adapt(Array, invJ .≈ uinvJ))
wJinvG, wJ = components(last(volumemetrics(grid)))
@test all(adapt(Array, wJ .≈ uwJ))
g(x) = x * x'
@test all(adapt(Array, wJinvG) .≈ adapt(Array, uwJ .* g.(uinvJ)))
uJ = adapt(Array, uJ)
uinvJ = adapt(Array, uinvJ)
wr = adapt(Array, wr)
ws = adapt(Array, ws)
wt = adapt(Array, wt)
sm, _ = surfacemetrics(grid)
sm = adapt(Array, sm)
b = det.(uJ) .* uinvJ
n, sJ, wsJ = components(sm)
a = n .* wsJ
@test all(
reshape(a[1:M*N, 1:numcells(grid)], (M, N, numcells(grid))) ./
(vec(ws) .* vec(wt)') .≈ map(g -> -g[1, :], b[1, :, :, :]),
)
@test all(
reshape(a[M*N.+(1:M*N), 1:numcells(grid)], (M, N, numcells(grid))) ./
(vec(ws) .* vec(wt)') .≈ map(g -> g[1, :], b[end, :, :, :]),
)
@test all(
reshape(a[2*M*N.+(1:L*N), 1:numcells(grid)], (L, N, numcells(grid))) ./
(vec(wr) .* vec(wt)') .≈ map(g -> -g[2, :], b[:, 1, :, :]),
)
@test all(
reshape(a[2*M*N.+L*N.+(1:L*N), 1:numcells(grid)], (L, N, numcells(grid))) ./
(vec(wr) .* vec(wt)') .≈ map(g -> g[2, :], b[:, end, :, :]),
)
@test all(
reshape(a[2*L*N+2*M*N.+(1:L*M), 1:numcells(grid)], (L, M, numcells(grid))) ./
(vec(wr) .* vec(ws)') .≈ map(g -> -g[3, :], b[:, :, 1, :]),
)
@test all(
reshape(
a[2*L*N+2*M*N.+L*M.+(1:L*M), 1:numcells(grid)],
(L, M, numcells(grid)),
) ./ (vec(wr) .* vec(ws)') .≈ map(g -> g[3, :], b[:, :, end, :]),
)
a = n .* sJ
@test all(
reshape(a[1:M*N, 1:numcells(grid)], (M, N, numcells(grid))) .≈
map(g -> -g[1, :], b[1, :, :, :]),
)
@test all(
reshape(a[M*N.+(1:M*N), 1:numcells(grid)], (M, N, numcells(grid))) .≈
map(g -> g[1, :], b[end, :, :, :]),
)
@test all(
reshape(a[2*M*N.+(1:L*N), 1:numcells(grid)], (L, N, numcells(grid))) .≈
map(g -> -g[2, :], b[:, 1, :, :]),
)
@test all(
reshape(a[2*M*N.+L*N.+(1:L*N), 1:numcells(grid)], (L, N, numcells(grid))) .≈
map(g -> g[2, :], b[:, end, :, :]),
)
@test all(
reshape(a[2*L*N+2*M*N.+(1:L*M), 1:numcells(grid)], (L, M, numcells(grid))) .≈
map(g -> -g[3, :], b[:, :, 1, :]),
)
@test all(
reshape(
a[2*L*N+2*M*N.+L*M.+(1:L*M), 1:numcells(grid)],
(L, M, numcells(grid)),
) .≈ map(g -> g[3, :], b[:, :, end, :]),
)
@test all(norm.(n) .≈ 1)
end
@testset "3D constant preserving" begin
f(x) = SA[
3x[1]+x[2]/5+x[3]/10+x[1]*x[2]^2*x[3]^3/3,
4x[2]+x[1]^3*x[2]^2*x[3]/4,
2x[3]+x[1]^2*x[2]*x[3]^3/2,
]
coordinates = (
range(-one(FT), stop = one(FT), length = 3),
range(-one(FT), stop = one(FT), length = 5),
range(-one(FT), stop = one(FT), length = 4),
)
L = 3
M = 4
N = 2
level = 0
gm = GridManager(
LobattoCell{FT,AT}(L, M, N),
Raven.brick(coordinates);
min_level = level,
)
grid = generate(f, gm)
invJ, J, _ = components(first(volumemetrics(grid)))
invJc = components(invJ)
Dr, Ds, Dt = derivatives(referencecell(grid))
cp1 = (Dr * (J .* invJc[1]) + Ds * (J .* invJc[2]) + Dt * (J .* invJc[3]))
cp2 = (Dr * (J .* invJc[4]) + Ds * (J .* invJc[5]) + Dt * (J .* invJc[6]))
cp3 = (Dr * (J .* invJc[7]) + Ds * (J .* invJc[8]) + Dt * (J .* invJc[9]))
@test norm(adapt(Array, cp1), Inf) < 200 * eps(FT)
@test norm(adapt(Array, cp2), Inf) < 200 * eps(FT)
@test norm(adapt(Array, cp3), Inf) < 200 * eps(FT)
end
@testset "2D uniform brick grid" begin
cell = LobattoCell{FT,AT}(4, 5)
xrange = range(-FT(1000), stop = FT(1000), length = 21)
yrange = range(-FT(2000), stop = FT(2000), length = 11)
grid = generate(GridManager(cell, Raven.brick((xrange, yrange))))
# TODO get Cartesian ordering to check symmetry
# p = adapt(Array, points(grid))
# p = reshape(p, size(cell)..., size(grid)...)
# x₁, x₂ = components(p)
# @test all(x₁ .+ reverse(x₁, dims = (1, 3)) .== 0)
# @test all(x₂ .- reverse(x₂, dims = (1, 3)) .== 0)
# @test all(x₁ .- reverse(x₁, dims = (2, 4), cell) .== 0)
# @test all(x₂ .+ reverse(x₂, dims =, cell (2, 4)) .== 0)
g, J, wJ = adapt(Array, components(first(volumemetrics(grid))))
wr, ws = adapt(Array, weights_1d(cell))
@test all(J .== (step(xrange) * step(yrange) / 4))
@test all(wJ .== (step(xrange) * step(yrange) / 4) .* (wr .* ws))
@test all(getindex.(g, 1) .== 2 / step(xrange))
@test all(getindex.(g, 2) .== 0)
@test all(getindex.(g, 3) .== 0)
@test all(getindex.(g, 4) .== 2 / step(yrange))
n, sJ, swJ = adapt(Array, components(first(surfacemetrics(grid))))
n₁, n₂, n₃, n₄ = faceviews(n, cell)
@test all(n₁ .== Ref(SVector(-1, 0)))
@test all(n₂ .== Ref(SVector(1, 0)))
@test all(n₃ .== Ref(SVector(0, -1)))
@test all(n₄ .== Ref(SVector(0, 1)))
swJ₁, swJ₂, swJ₃, swJ₄ = faceviews(swJ, cell)
@test all(isapprox.(swJ₁, (step(yrange) / 2) .* vec(ws), rtol = 10eps(FT)))
@test all(isapprox.(swJ₂, (step(yrange) / 2) .* vec(ws), rtol = 10eps(FT)))
@test all(isapprox.(swJ₃, (step(xrange) / 2) .* vec(wr), rtol = 10eps(FT)))
@test all(isapprox.(swJ₄, (step(xrange) / 2) .* vec(wr), rtol = 10eps(FT)))
sJ₁, sJ₂, sJ₃, sJ₄ = faceviews(sJ, cell)
@test all(isapprox.(sJ₁, (step(yrange) / 2), rtol = 10eps(FT)))
@test all(isapprox.(sJ₂, (step(yrange) / 2), rtol = 10eps(FT)))
@test all(isapprox.(sJ₃, (step(xrange) / 2), rtol = 10eps(FT)))
@test all(isapprox.(sJ₄, (step(xrange) / 2), rtol = 10eps(FT)))
end
@testset "3D uniform brick grid" begin
cell = LobattoCell{FT,AT}(4, 5, 6)
xrange = range(-FT(1000), stop = FT(1000), length = 21)
yrange = range(-FT(2000), stop = FT(2000), length = 11)
zrange = range(-FT(3000), stop = FT(3000), length = 6)
grid = generate(GridManager(cell, Raven.brick((xrange, yrange, zrange))))
# TODO get Cartesian ordering to check symmetry
# p = adapt(Array, points(grid))
# p = reshape(p, size(cell)..., size(grid)...)
# x₁, x₂, x₃ = components(p)
# @test all(x₁ .+ reverse(x₁, dims = (1, 4)) .== 0)
# @test all(x₂ .- reverse(x₂, dims = (1, 4)) .== 0)
# @test all(x₃ .- reverse(x₃, dims = (1, 4)) .== 0)
# @test all(x₁ .- reverse(x₁, dims = (2, 5)) .== 0)
# @test all(x₂ .+ reverse(x₂, dims = (2, 5)) .== 0)
# @test all(x₃ .- reverse(x₃, dims = (2, 5)) .== 0)
# @test all(x₁ .- reverse(x₁, dims = (3, 6)) .== 0)
# @test all(x₂ .- reverse(x₂, dims = (3, 6)) .== 0)
# @test all(x₃ .+ reverse(x₃, dims = (3, 6)) .== 0)
g, J, wJ = adapt(Array, components(first(volumemetrics(grid))))
wr, ws, wt = adapt(Array, weights_1d(cell))
@test all(J .== (step(xrange) * step(yrange) * step(zrange) / 8))
@test all(
wJ .== (step(xrange) * step(yrange) * step(zrange) / 8) .* (wr .* ws .* wt),
)
@test all(getindex.(g, 1) .== 2 / step(xrange))
@test all(getindex.(g, 2) .== 0)
@test all(getindex.(g, 3) .== 0)
@test all(getindex.(g, 4) .== 0)
@test all(getindex.(g, 5) .== 2 / step(yrange))
@test all(getindex.(g, 6) .== 0)
@test all(getindex.(g, 7) .== 0)
@test all(getindex.(g, 8) .== 0)
@test all(getindex.(g, 9) .== 2 / step(zrange))
n, sJ, swJ = adapt(Array, components(first(surfacemetrics(grid))))
n₁, n₂, n₃, n₄, n₅, n₆ = faceviews(n, cell)
@test all(n₁ .== Ref(SVector(-1, 0, 0)))
@test all(n₂ .== Ref(SVector(1, 0, 0)))
@test all(n₃ .== Ref(SVector(0, -1, 0)))
@test all(n₄ .== Ref(SVector(0, 1, 0)))
@test all(n₅ .== Ref(SVector(0, 0, -1)))
@test all(n₆ .== Ref(SVector(0, 0, 1)))
# TODO Make check exact
swJ₁, swJ₂, swJ₃, swJ₄, swJ₅, swJ₆ = faceviews(swJ, cell)
@test all(
isapprox.(
swJ₁,
(step(yrange) * step(zrange) / 4) .* (vec(ws) .* vec(wt)'),
rtol = 10eps(FT),
),
)
@test all(
isapprox.(
swJ₂,
(step(yrange) * step(zrange) / 4) .* (vec(ws) .* vec(wt)'),
rtol = 10eps(FT),
),
)
@test all(
isapprox.(
swJ₃,
(step(xrange) * step(zrange) / 4) .* (vec(wr) .* vec(wt)'),
rtol = 10eps(FT),
),
)
@test all(
isapprox.(
swJ₄,
(step(xrange) * step(zrange) / 4) .* (vec(wr) .* vec(wt)'),
rtol = 10eps(FT),
),
)
@test all(
isapprox.(
swJ₅,
(step(xrange) * step(yrange) / 4) .* (vec(wr) .* vec(ws)'),
rtol = 10eps(FT),
),
)
@test all(
isapprox.(
swJ₆,
(step(xrange) * step(yrange) / 4) .* (vec(wr) .* vec(ws)'),
rtol = 10eps(FT),
),
)
sJ₁, sJ₂, sJ₃, sJ₄, sJ₅, sJ₆ = faceviews(sJ, cell)
@test all(isapprox.(sJ₁, (step(yrange) * step(zrange) / 4), rtol = 10eps(FT)))
@test all(isapprox.(sJ₂, (step(yrange) * step(zrange) / 4), rtol = 10eps(FT)))
@test all(isapprox.(sJ₃, (step(xrange) * step(zrange) / 4), rtol = 10eps(FT)))
@test all(isapprox.(sJ₄, (step(xrange) * step(zrange) / 4), rtol = 10eps(FT)))
@test all(isapprox.(sJ₅, (step(xrange) * step(yrange) / 4), rtol = 10eps(FT)))
@test all(isapprox.(sJ₆, (step(xrange) * step(yrange) / 4), rtol = 10eps(FT)))
end
@testset "min_node_distance" begin
Kh = 10
Kv = 4
Nqs = (((5, 5), (5, 4), (3, 4)), ((5, 5, 5), (3, 4, 5), (5, 4, 3), (5, 3, 4)))
for dim in (2, 3)
for Nq in Nqs[dim-1]
if dim == 2
brickrange = (
range(FT(0); length = Kh + 1, stop = FT(1)),
range(FT(1); length = Kv + 1, stop = FT(2)),
)
elseif dim == 3
brickrange = (
range(FT(0); length = Kh + 1, stop = FT(1)),
range(FT(0); length = Kh + 1, stop = FT(1)),
range(FT(1); length = Kv + 1, stop = FT(2)),
)
end
gm = GridManager(
LobattoCell{FT,AT}(Nq...),
Raven.brick(brickrange, ntuple(_ -> true, dim)),
)
grid = generate(min_node_dist_warpfun, gm)
ξ = Array.(points_1d(referencecell(grid)))
Δξ = ntuple(d -> ξ[d][2] - ξ[d][1], dim)
hmnd = minimum(Δξ[1:(dim-1)]) / (2Kh)
vmnd = Δξ[end] / (2Kv)
@test hmnd ≈ min_node_distance(grid)
@test vmnd ≈ min_node_distance(grid, dims = (dim,))
@test hmnd ≈ min_node_distance(grid, dims = 1:(dim-1))
end
end
end
@testset "curvedquadpoints" begin
N = (2, 2)
vertices = [
SVector{2,FT}(1.0, -1.0), #1
SVector{2,FT}(1.0, 1.0), #2
SVector{2,FT}(2.0, 0.0), #3
SVector{2,FT}(0.0, 0.0), #4
]
cells = [(4, 1, 2, 3)]
cg = coarsegrid(vertices, cells)
coarse_grid = coarsegrid("curvedboxmesh2d.inp")
gm = GridManager(LobattoCell{FT,AT}(N...), cg, min_level = 1)
gmcurved = GridManager(LobattoCell{FT,AT}(N...), coarse_grid, min_level = 1)
grid = generate(gm)
gridcurved = generate(gmcurved)
@test coarse_grid.vertices ≈ cg.vertices
cg1 = coarsegrid("flatGingerbreadMan.inp")
gm1 = GridManager(LobattoCell{FT,AT}(N...), cg1, min_level = 1)
grid = generate(gm1)
cg2 = coarsegrid("GingerbreadMan.inp")
gm2 = GridManager(LobattoCell{FT,AT}(N...), cg2, min_level = 1)
grid2 = generate(gm2)
@test cg1.vertices ≈ cg2.vertices
err = norm(parent(points(grid)) - parent(points(grid2)), Inf)
@test maximum(err) < 1 // 5
end
@testset "curvedHexpoints" begin
N = (2, 2, 2)
vertices = [
SVector{3,FT}(-0.4350800364851, -0.7033148310153, 0.0000000000000), #1
SVector{3,FT}(-0.2553059615836, -0.7194290918162, 0.0000000000000), #2
SVector{3,FT}(-0.5200431460828, -0.5200432080034, 0.0000000000000), #3
SVector{3,FT}(-0.2494272390808, -0.4937247409923, 0.0000000000000), #4
SVector{3,FT}(-0.4350800364851, -0.7033148310153, 0.3750000000000), #5
SVector{3,FT}(-0.2553059615836, -0.7194290918162, 0.3750000000000), #6
SVector{3,FT}(-0.5200431460828, -0.5200432080034, 0.3750000000000), #7
SVector{3,FT}(-0.2494272390808, -0.4937247409923, 0.3750000000000), #8
]
cells = [(1, 2, 3, 4, 5, 6, 7, 8)]
cg = coarsegrid(vertices, cells)
coarse_grid = coarsegrid("curvedboxmesh3d.inp")
gm = GridManager(LobattoCell{FT,AT}(N...), cg, min_level = 1)
gmcurved = GridManager(LobattoCell{FT,AT}(N...), coarse_grid, min_level = 1)
grid = generate(gm)
gridcurved = generate(gmcurved)
@test coarse_grid.vertices ≈ cg.vertices
cg1 = coarsegrid("flatHalfCircle3DRot.inp")
gm1 = GridManager(LobattoCell{FT,AT}(N...), cg1, min_level = 1)
grid = generate(gm1)
cg2 = coarsegrid("HalfCircle3DRot.inp")
gm2 = GridManager(LobattoCell{FT,AT}(N...), cg2, min_level = 1)
grid2 = generate(gm2)
@test cg1.vertices ≈ cg2.vertices
err = norm(parent(points(grid)) - parent(points(grid2)), Inf)
@test err < 1 // 5
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 3289 | function kron_testsuite(AT, FT)
rng = StableRNG(37)
a = adapt(AT, rand(rng, FT, 3, 2))
b = adapt(AT, rand(rng, FT, 4, 5))
c = adapt(AT, rand(rng, FT, 1, 7))
for args in (
(a,),
(a, Raven.Eye{FT}(5)),
(Raven.Eye{FT}(2), b),
(a, b),
(Raven.Eye{FT}(3), Raven.Eye{FT}(2), c),
(Raven.Eye{FT}(2), b, Raven.Eye{FT}(7)),
(a, Raven.Eye{FT}(4), Raven.Eye{FT}(7)),
(a, b, c),
)
K = adapt(AT, collect(Raven.Kron(adapt(Array, args))))
d = adapt(AT, rand(SVector{2,FT}, size(K, 2), 12))
e = adapt(AT, rand(SVector{2,FT}, size(K, 2)))
@test Array(Raven.Kron(args) * e) ≈ Array(K) * Array(e)
@test Array(Raven.Kron(args) * d) ≈ Array(K) * Array(d)
g = adapt(AT, rand(FT, 4, size(K, 2), 6))
gv1 = @view g[1, :, :]
gv2 = @view g[1, :, 1]
@test Array(Raven.Kron(args) * gv1) ≈ Array(K) * Array(gv1)
@test Array(Raven.Kron(args) * gv2) ≈ Array(K) * Array(gv2)
if isbits(FT)
f = rand(rng, FT, size(K, 2), 3, 2)
f = adapt(
AT,
reinterpret(reshape, SVector{2,FT}, PermutedDimsArray(f, (3, 1, 2))),
)
@test Array(Raven.Kron(args) * f) ≈ Array(K) * Array(f)
end
@test adapt(Array, Raven.Kron(args)) == Raven.Kron(adapt.(Array, args))
end
end
function kron2dgridarray_testsuite(AT, FT)
rng = StableRNG(37)
A = adapt(AT, rand(rng, FT, 5, 2))
B = adapt(AT, rand(rng, FT, 2, 3))
cell = LobattoCell{FT,AT}(2, 3)
gm = GridManager(cell, Raven.brick(2, 1); min_level = 1)
grid = generate(gm)
EntryType = SVector{2,FT}
v = GridArray{EntryType}(undef, grid)
v .= adapt(AT, rand(rng, EntryType, size(v)))
for args in ((Raven.Eye{FT}(3), A), (B, Raven.Eye{FT}(2)), (B, A))
K = adapt(AT, collect(Raven.Kron(adapt(Array, args))))
Kv1 = adapt(Array, Raven.Kron(args) * v)
dimsIn = (prod(size(v)[1:end-1]), size(v)[end])
dimsOut = (size.(reverse(args), 1)..., size(v)[end])
Kv2 = reshape(Array(K) * reshape(adapt(Array, v), dimsIn), dimsOut)
@test isapprox(Kv1, Kv2)
end
end
function kron3dgridarray_testsuite(AT, FT)
rng = StableRNG(37)
A = adapt(AT, rand(rng, FT, 5, 2))
B = adapt(AT, rand(rng, FT, 2, 3))
C = adapt(AT, rand(rng, FT, 3, 5))
cell = LobattoCell{FT,AT}(2, 3, 5)
gm = GridManager(cell, Raven.brick(2, 1, 1); min_level = 1)
grid = generate(gm)
EntryType = SVector{2,FT}
v = GridArray{EntryType}(undef, grid)
v .= adapt(AT, rand(rng, EntryType, size(v)))
for args in (
(Raven.Eye{FT}(5), Raven.Eye{FT}(3), A),
(Raven.Eye{FT}(5), B, Raven.Eye{FT}(2)),
(C, Raven.Eye{FT}(3), Raven.Eye{FT}(2)),
(Raven.Eye{FT}(5), B, A),
(C, Raven.Eye{FT}(3), A),
(C, B, Raven.Eye{FT}(2)),
(C, B, A),
)
K = adapt(AT, collect(Raven.Kron(adapt(Array, args))))
Kv1 = adapt(Array, Raven.Kron(args) * v)
dimsIn = (prod(size(v)[1:end-1]), size(v)[end])
dimsOut = (size.(reverse(args), 1)..., size(v)[end])
Kv2 = reshape(Array(K) * reshape(adapt(Array, v), dimsIn), dimsOut)
@test isapprox(Kv1, Kv2)
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 75 | using MPI
using Test
MPI.Init()
@test MPI.Comm_size(MPI.COMM_WORLD) == 2
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 1495 | using CUDA
using MPI
using Test
using Raven
using Raven.StaticArrays
using Raven.Adapt
MPI.Init()
function test(::Type{FT}, ::Type{AT}) where {FT,AT}
@testset "Communicate GridArray ($AT, $FT)" begin
N = (3, 2)
K = (2, 1)
min_level = 1
cell = LobattoCell{Float64,AT}(N...)
gm = GridManager(cell, Raven.brick(K...); min_level)
grid = generate(gm)
T = SVector{2,FT}
cm = Raven.commmanager(T, nodecommpattern(grid); comm = Raven.comm(grid), tag = 1)
A = GridArray{T}(undef, grid)
nan = convert(FT, NaN)
viewwithghosts(A) .= Ref((nan, nan))
A .= Ref((MPI.Comm_rank(Raven.comm(grid)) + 1, 0))
Raven.share!(A, cm)
@test all(A.data[:, :, 1, :] .== MPI.Comm_rank(Raven.comm(grid)) + 1)
@test all(A.data[:, :, 2, :] .== 0)
@test MPI.Comm_size(Raven.comm(grid)) == 2
r = MPI.Comm_rank(Raven.comm(grid))
if r == 0
@test all(A.datawithghosts[2:3, :, :, 5:6] .=== nan)
@test all(A.datawithghosts[1, :, 1, 5:6] .== 2)
@test all(A.datawithghosts[1, :, 2, 5:6] .== 0)
elseif r == 1
@test all(A.datawithghosts[1:2, :, :, 5:6] .=== nan)
@test all(A.datawithghosts[3, :, 1, 5:6] .== 1)
@test all(A.datawithghosts[3, :, 2, 5:6] .== 0)
end
end
end
function main()
test(Float64, Array)
if CUDA.functional()
test(Float32, CuArray)
end
end
main()
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 13066 | using CUDA
using CUDA.CUDAKernels
using MPI
using Test
using Raven
using Raven.StaticArrays
using Raven.P4estTypes
using Raven.SparseArrays
MPI.Init()
let
FT = Float64
AT = Array
N = 4
cell = LobattoCell{FT,AT}(N, N)
# 4--------5--------6
# | | |
# | | |
# | | |
# | | |
# 1--------2--------3
vertices = [
SVector{2,FT}(-1, -1), # 1
SVector{2,FT}(0, -1), # 2
SVector{2,FT}(1, -1), # 3
SVector{2,FT}(-1, 1), # 4
SVector{2,FT}(0, 1), # 5
SVector{2,FT}(1, 1), # 6
]
for cells in [[(1, 2, 4, 5), (2, 3, 5, 6)], [(1, 2, 4, 5), (5, 6, 2, 3)]]
min_level = 0
cg = coarsegrid(vertices, cells)
gm = GridManager(cell, cg; min_level)
grid = generate(gm)
A = continuoustodiscontinuous(grid)
pts = points(grid, Val(true))
rows = rowvals(A)
vals = nonzeros(A)
_, n = size(A)
ci = CartesianIndices(pts)
for j = 1:n
x = pts[rows[first(nzrange(A, j))]]
for ii in nzrange(A, j)
p = pts[rows[ii]]
@test x ≈ p || (all(isnan.(x)) && all(isnan.(p)))
# make sure all points that have all NaNs are in the
# ghost layer
if (all(isnan.(x)) && all(isnan.(p)))
i = rows[ii]
@test fld1(i, length(cell)) > numcells(grid)
end
end
end
cp = nodecommpattern(grid)
commcells = communicatingcells(grid)
noncommcells = noncommunicatingcells(grid)
for i in cp.sendindices
q = fld1(i, length(cell))
@test q ∈ commcells
end
@test noncommcells == setdiff(0x1:numcells(grid), commcells)
fm = facemaps(grid)
@test isapprox(
pts[fm.vmapM[:, 1:numcells(grid)]],
pts[fm.vmapP[:, 1:numcells(grid)]],
)
@test isapprox(
pts[fm.vmapM[fm.mapM[:, 1:numcells(grid)]]],
pts[fm.vmapM[fm.mapP[:, 1:numcells(grid)]]],
)
bc = boundarycodes(grid)
vmapM = reshape(fm.vmapM, (N, 4, :))
for q in numcells(grid)
for f = 1:4
if bc[f, q] == 1
@test all(
isapprox.(one(FT), map(x -> maximum(abs.(x)), pts[vmapM[:, f, q]])),
)
else
@test !all(
isapprox.(one(FT), map(x -> maximum(abs.(x)), pts[vmapM[:, f, q]])),
)
end
end
end
indicator =
map(tid -> (tid == 1 ? Raven.AdaptNone : Raven.AdaptRefine), trees(grid))
adapt!(gm, indicator)
grid = generate(gm)
fm = facemaps(grid)
tohalves = tohalves_1d(cell)
pts = points(grid, Val(true))
fgdims = ((2,), (1,))
_, ncsm = surfacemetrics(grid)
for fg in eachindex(fm.vmapNC)
for i = 1:last(size(fm.vmapNC[fg]))
ppts = pts[fm.vmapNC[fg][:, 1, i]]
c1pts = pts[fm.vmapNC[fg][:, 2, i]]
c2pts = pts[fm.vmapNC[fg][:, 3, i]]
@assert isapprox(tohalves[fgdims[fg][1]][1] * ppts, c1pts)
@assert isapprox(tohalves[fgdims[fg][1]][2] * ppts, c2pts)
end
if length(ncsm[fg]) > 0
n, wsJ = components(ncsm[fg])
@test all(n[:, 1, :] .≈ Ref(SA[1, 0]))
@test all(n[:, 2:end, :] .≈ Ref(SA[-1, 0]))
@test sum(wsJ[:, 1, :]) .≈ sum(wsJ[:, 2:end, :])
end
end
end
end
let
FT = Float64
AT = Array
N = 3
cell = LobattoCell(N, N, N)
# 10-------11-------12
# /| /| /|
# / | / | / |
# / | / | / |
# 7--------8--------9 |
# | 4----|---5----|---6
# | / | / | /
# | / | / | /
# |/ |/ |/
# 1--------2--------3
#
vertices = [
SVector{3,FT}(-1, -1, -1), # 1
SVector{3,FT}(0, -1, -1), # 2
SVector{3,FT}(1, -1, -1), # 3
SVector{3,FT}(-1, 1, -1), # 4
SVector{3,FT}(0, 1, -1), # 5
SVector{3,FT}(1, 1, -1), # 6
SVector{3,FT}(-1, -1, 1), # 7
SVector{3,FT}(0, -1, 1), # 8
SVector{3,FT}(1, -1, 1), # 9
SVector{3,FT}(-1, 1, 1), #10
SVector{3,FT}(0, 1, 1), #12
SVector{3,FT}(1, 1, 1), #13
]
for cells in [
# 2--------6 55 4--------2
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 8--------6 |
# | 1----|---5 54 | 3----|---1
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 7--------5
[(4, 10, 1, 7, 5, 11, 2, 8), (6, 12, 5, 11, 3, 9, 2, 8)],
#
# 2--------6 55 7--------5
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 3--------1 |
# | 1----|---5 54 | 8----|---6
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 4--------2
[(4, 10, 1, 7, 5, 11, 2, 8), (9, 3, 8, 2, 12, 6, 11, 5)],
#
# 2--------6 55 8--------6
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 7--------5 |
# | 1----|---5 54 | 4----|---2
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 3--------1
[(4, 10, 1, 7, 5, 11, 2, 8), (3, 6, 2, 5, 9, 12, 8, 11)],
#
# 2--------6 55 3--------1
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 4--------2 |
# | 1----|---5 54 | 7----|---5
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 8--------6
[(4, 10, 1, 7, 5, 11, 2, 8), (12, 9, 11, 8, 6, 3, 5, 2)],
#
# 2--------6 55 5--------7
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 6--------8 |
# | 1----|---5 54 | 1----|---3
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 2--------4
[(4, 10, 1, 7, 5, 11, 2, 8), (5, 2, 6, 3, 11, 8, 12, 9)],
#
# 2--------6 55 5--------1
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 8--------3 |
# | 1----|---5 54 | 6----|---2
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 7--------4
[(4, 10, 1, 7, 5, 11, 2, 8), (12, 6, 9, 3, 11, 5, 8, 2)],
#
# 2--------6 55 8--------4
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 6--------2 |
# | 1----|---5 54 | 7----|---3
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 5--------1
[(4, 10, 1, 7, 5, 11, 2, 8), (3, 9, 6, 12, 2, 8, 5, 11)],
#
# 2--------6 55 6--------2
# /| /| /| /|
# / | / | / | / |
# / | / | / | / |
# 4--------8 | 59 5--------1 |
# | 1----|---5 54 | 8----|---4
# | / | / | / | /
# | / | / | / | /
# |/ |/ |/ |/
# 3--------7 58 7--------3
[(4, 10, 1, 7, 5, 11, 2, 8), (9, 12, 3, 6, 8, 11, 2, 5)],
]
min_level = 1
cg = coarsegrid(vertices, cells)
gm = GridManager(cell, cg; min_level)
grid = generate(gm)
A = continuoustodiscontinuous(grid)
pts = points(grid, Val(true))
rows = rowvals(A)
vals = nonzeros(A)
_, n = size(A)
ci = CartesianIndices(pts)
for j = 1:n
x = pts[rows[first(nzrange(A, j))]]
for ii in nzrange(A, j)
p = pts[rows[ii]]
@test x ≈ p || (all(isnan.(x)) && all(isnan.(p)))
# make sure all points that have all NaNs are in the
# ghost layer
if (all(isnan.(x)) && all(isnan.(p)))
i = rows[ii]
@test fld1(i, length(cell)) > numcells(grid)
end
end
end
cp = nodecommpattern(grid)
commcells = communicatingcells(grid)
noncommcells = noncommunicatingcells(grid)
for i in cp.sendindices
q = fld1(i, length(cell))
@test q ∈ commcells
end
@test noncommcells == setdiff(0x1:numcells(grid), commcells)
fm = facemaps(grid)
@test isapprox(
pts[fm.vmapM[:, 1:numcells(grid)]],
pts[fm.vmapP[:, 1:numcells(grid)]],
)
@test isapprox(
pts[fm.vmapM[fm.mapM[:, 1:numcells(grid)]]],
pts[fm.vmapM[fm.mapP[:, 1:numcells(grid)]]],
)
bc = boundarycodes(grid)
vmapM = reshape(fm.vmapM, (N, N, 6, :))
for q in numcells(grid)
for f = 1:6
if bc[f, q] == 1
@test all(
isapprox.(
one(FT),
map(x -> maximum(abs.(x)), pts[vmapM[:, :, f, q]]),
),
)
else
@test !all(
isapprox.(
one(FT),
map(x -> maximum(abs.(x)), pts[vmapM[:, :, f, q]]),
),
)
end
end
end
indicator =
map(tid -> (tid == 1 ? Raven.AdaptNone : Raven.AdaptRefine), trees(grid))
adapt!(gm, indicator)
grid = generate(gm)
fm = facemaps(grid)
tohalves = tohalves_1d(cell)
pts = points(grid, Val(true))
fgdims = ((2, 3), (1, 3), (1, 2))
_, ncsm = surfacemetrics(grid)
for fg in eachindex(fm.vmapNC)
for i = 1:last(size(fm.vmapNC[fg]))
ppts = pts[fm.vmapNC[fg][:, :, 1, i]]
c1pts = pts[fm.vmapNC[fg][:, :, 2, i]]
c2pts = pts[fm.vmapNC[fg][:, :, 3, i]]
c3pts = pts[fm.vmapNC[fg][:, :, 4, i]]
c4pts = pts[fm.vmapNC[fg][:, :, 5, i]]
@assert isapprox(
tohalves[fgdims[fg][1]][1] * ppts * tohalves[fgdims[fg][2]][1]',
c1pts,
)
@assert isapprox(
tohalves[fgdims[fg][1]][2] * ppts * tohalves[fgdims[fg][2]][1]',
c2pts,
)
@assert isapprox(
tohalves[fgdims[fg][1]][1] * ppts * tohalves[fgdims[fg][2]][2]',
c3pts,
)
@assert isapprox(
tohalves[fgdims[fg][1]][2] * ppts * tohalves[fgdims[fg][2]][2]',
c4pts,
)
end
if length(ncsm[fg]) > 0
n, wsJ = components(ncsm[fg])
@test all(n[:, :, 1, :] .≈ Ref(SA[1, 0, 0]))
@test all(n[:, :, 2:end, :] .≈ Ref(SA[-1, 0, 0]))
@test sum(wsJ[:, :, 1, :]) .≈ sum(wsJ[:, :, 2:end, :])
end
end
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 2827 | using CUDA
using CUDA.CUDAKernels
using MPI
using Test
using Raven
MPI.Init()
let
mpisize = MPI.Comm_size(MPI.COMM_WORLD)
mpirank = MPI.Comm_rank(MPI.COMM_WORLD)
@test mpisize == 3
if mpirank == 0
datalength = 10
recvindices = [7, 8, 9, 10]
recvranks = Cint[1, 2]
recvrankindices = [1:1, 2:4]
sendindices = [1, 3, 1, 3, 5]
sendranks = Cint[1, 2]
sendrankindices = [1:2, 3:5]
datacomm = [1, 2, 3, 4, 5, 6, 102, 201, 202, 203]
elseif mpirank == 1
datalength = 16
recvindices = [11, 12, 13, 14, 15, 16]
recvranks = Cint[0, 2]
recvrankindices = [1:2, 3:6]
sendindices = [2, 2, 4, 6, 8, 10]
sendranks = Cint[0, 2]
sendrankindices = [1:1, 2:6]
datacomm =
[101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 1, 3, 202, 203, 204, 205]
elseif mpirank == 2
datalength = 20
recvindices = [8, 9, 10, 14, 15, 16, 17, 18]
recvranks = Cint[0, 1]
recvrankindices = [1:3, 4:8]
sendindices = [1, 2, 3, 2, 3, 4, 5]
sendranks = Cint[0, 1]
sendrankindices = [1:3, 4:7]
datacomm = [
201,
202,
203,
204,
205,
206,
207,
1,
3,
5,
211,
212,
213,
102,
104,
106,
108,
110,
219,
220,
]
end
to2(A) = Float64.(2A)
data1 = collect((1:datalength) .+ (100mpirank))
data2 = to2(data1)
data3 = data1
data4 = data2
pattern = Raven.CommPattern{Array}(
recvindices,
recvranks,
recvrankindices,
sendindices,
sendranks,
sendrankindices,
)
cm1 = Raven.commmanager(eltype(data1), pattern, Val(false); tag = 1)
cm2 = Raven.commmanager(eltype(data2), pattern, Val(true); tag = 2)
Raven.start!(data2, cm2)
Raven.share!(data1, cm1)
Raven.finish!(data2, cm2)
@test data1 == datacomm
@test data2 == to2(datacomm)
if CUDA.functional()
data3 = CuArray(data3)
data4 = CuArray(data4)
pattern = Raven.CommPattern{CuArray}(
CuArray(recvindices),
recvranks,
recvrankindices,
CuArray(sendindices),
sendranks,
sendrankindices,
)
cm3 = Raven.commmanager(eltype(data3), pattern; tag = 1)
cm4 = Raven.commmanager(eltype(data4), pattern, Val(true); tag = 2)
Raven.start!(data4, cm4)
Raven.share!(data3, cm3)
Raven.finish!(data4, cm4)
@test Array(data3) == datacomm
@test Array(data4) == to2(datacomm)
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 16846 | using MPI
using Test
using Raven
using Raven.Adapt
using Raven.StaticArrays
using Raven.SparseArrays
MPI.Init()
let
FT = Float32
AT = Array
b = brick(FT, 3, 1)
e = extrude(b, 2)
@test Raven.coordinates(e) == (zero(FT):3, zero(FT):1, zero(FT):2)
@test Raven.vertices(e) == [
SVector{3,FT}(0, 0, 0), # 01
SVector{3,FT}(0, 0, 1), # 02
SVector{3,FT}(0, 0, 2), # 03
SVector{3,FT}(1, 0, 0), # 04
SVector{3,FT}(1, 0, 1), # 05
SVector{3,FT}(1, 0, 2), # 06
SVector{3,FT}(0, 1, 0), # 07
SVector{3,FT}(0, 1, 1), # 08
SVector{3,FT}(0, 1, 2), # 09
SVector{3,FT}(1, 1, 0), # 10
SVector{3,FT}(1, 1, 1), # 11
SVector{3,FT}(1, 1, 2), # 12
SVector{3,FT}(2, 0, 0), # 13
SVector{3,FT}(2, 0, 1), # 14
SVector{3,FT}(2, 0, 2), # 15
SVector{3,FT}(2, 1, 0), # 16
SVector{3,FT}(2, 1, 1), # 17
SVector{3,FT}(2, 1, 2), # 18
SVector{3,FT}(3, 0, 0), # 19
SVector{3,FT}(3, 0, 1), # 20
SVector{3,FT}(3, 0, 2), # 21
SVector{3,FT}(3, 1, 0), # 22
SVector{3,FT}(3, 1, 1), # 23
SVector{3,FT}(3, 1, 2), # 24
]
# z = 2
# 09-----12-----21-----24
# | | | |
# | | | |
# | | | |
# 03-----06-----15-----18
# z = 1
# 08-----11-----20-----23
# | | | |
# | | | |
# | | | |
# 02-----05-----14-----17
# z = 0
# 07-----10-----19-----22
# | | | |
# | | | |
# | | | |
# 01-----04-----13-----16
@test Raven.cells(e) == [
(01, 04, 07, 10, 02, 05, 08, 11)
(02, 05, 08, 11, 03, 06, 09, 12)
(04, 13, 10, 16, 05, 14, 11, 17)
(05, 14, 11, 17, 06, 15, 12, 18)
(13, 19, 16, 22, 14, 20, 17, 23)
(14, 20, 17, 23, 15, 21, 18, 24)
]
c = LobattoCell{FT,AT}(2, 2, 2)
comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
gm = GridManager(c, e; comm)
grid = generate(gm)
fm = facemaps(grid)
ncp = nodecommpattern(grid)
if rank == 0
# Grid point numbering aka LinearIndices(points(grid, Val(true)))
# [:, :, 1, 1] =
# 1 3
# 2 4
#
# [:, :, 2, 1] =
# 5 7
# 6 8
#
# [:, :, 1, 2] =
# 9 11
# 10 12
#
# [:, :, 2, 2] =
# 13 15
# 14 16
#
# [:, :, 1, 3] =
# 17 19
# 18 20
#
# [:, :, 2, 3] =
# 21 23
# 22 24
#
# [:, :, 1, 4] =
# 25 27
# 26 28
#
# [:, :, 2, 4] =
# 29 31
# 30 32
@test levels(grid, Val(false)) == Int8[0, 0]
@test levels(grid, Val(true)) == Int8[0, 0, 0, 0]
@test trees(grid, Val(false)) == Int32[1, 2]
@test trees(grid, Val(true)) == Int32[1, 2, 3, 4]
@test points(grid) == SVector{3,FT}[
(0, 0, 0) (0, 1, 0); (1, 0, 0) (1, 1, 0);;; (0, 0, 1) (0, 1, 1); (1, 0, 1) (1, 1, 1);;;;
(0, 0, 1) (0, 1, 1); (1, 0, 1) (1, 1, 1);;; (0, 0, 2) (0, 1, 2); (1, 0, 2) (1, 1, 2)
]
@test facecodes(grid, Val(false)) == Int8[0, 0]
@test boundarycodes(grid) == [1 1; 0 0; 1 1; 1 1; 1 0; 0 1]
@test ncp.recvranks == Int32[1]
@test ncp.recvrankindices == UnitRange{Int64}[1:8]
@test ncp.recvindices == [17, 19, 21, 23, 25, 27, 29, 31]
@test ncp.sendranks == Int32[1]
@test ncp.sendrankindices == UnitRange{Int64}[1:8]
@test ncp.sendindices == [2, 4, 6, 8, 10, 12, 14, 16]
#! format: off
@test continuoustodiscontinuous(grid) == sparse(
[
1,
5, 9,
13,
2, 17,
6, 10, 21, 25,
14, 29,
3,
7, 11,
15,
4, 19,
8, 12, 23, 27,
16, 31,
18,
22, 26,
30,
20,
24, 28,
32,
],
[
1,
2, 2,
3,
4, 4,
5, 5, 5, 5,
6, 6,
7,
8, 8,
9,
10, 10,
11, 11, 11, 11,
12, 12,
13,
14, 14,
15,
16,
17, 17,
18,
],
Bool[
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
],
32,
18,
)
#! format: on
@test communicatingcells(grid) == [1, 2]
@test noncommunicatingcells(grid) == Int64[]
@test numcells(grid) == 2
@test numcells(grid, Val(true)) == 4
@test offset(grid) == 0
@test Raven.partitionnumber(grid) == 1
@test Raven.numberofpartitions(grid) == 3
@test fm.vmapM == [
01 09 17 25 #########
03 11 19 27
05 13 21 29
07 15 23 31
02 10 18 26 #########
04 12 20 28
06 14 22 30
08 16 24 32
01 09 17 25 #########
02 10 18 26
05 13 21 29
06 14 22 30
03 11 19 27 #########
04 12 20 28
07 15 23 31
08 16 24 32
01 09 17 25 #########
02 10 18 26
03 11 19 27
04 12 20 28
05 13 21 29 #########
06 14 22 30
07 15 23 31
08 16 24 32
]
@test fm.vmapP == [
01 09 17 25 #########
03 11 19 27
05 13 21 29
07 15 23 31
17 25 18 26 #########
19 27 20 28
21 29 22 30
23 31 24 32
01 09 17 25 #########
02 10 18 26
05 13 21 29
06 14 22 30
03 11 19 27 #########
04 12 20 28
07 15 23 31
08 16 24 32
01 05 17 25 #########
02 06 18 26
03 07 19 27
04 08 20 28
09 13 21 29 #########
10 14 22 30
11 15 23 31
12 16 24 32
]
elseif rank == 1
# Grid point numbering aka LinearIndices(points(grid, Val(true)))
# [:, :, 1, 1] =
# 1 3
# 2 4
#
# [:, :, 2, 1] =
# 5 7
# 6 8
#
# [:, :, 1, 2] =
# 9 11
# 10 12
#
# [:, :, 2, 2] =
# 13 15
# 14 16
#
# [:, :, 1, 3] =
# 17 19
# 18 20
#
# [:, :, 2, 3] =
# 21 23
# 22 24
#
# [:, :, 1, 4] =
# 25 27
# 26 28
#
# [:, :, 2, 4] =
# 29 31
# 30 32
#
# [:, :, 1, 5] =
# 33 35
# 34 36
#
# [:, :, 2, 5] =
# 37 39
# 38 40
#
# [:, :, 1, 6] =
# 41 43
# 42 44
#
# [:, :, 2, 6] =
# 45 47
# 46 48
@test levels(grid, Val(false)) == Int8[0, 0]
@test levels(grid, Val(true)) == Int8[0, 0, 0, 0, 0, 0]
@test trees(grid, Val(false)) == Int32[3, 4]
@test trees(grid, Val(true)) == Int32[3, 4, 1, 2, 5, 6]
@test points(grid) == SVector{3,FT}[
(1, 0, 0) (1, 1, 0); (2, 0, 0) (2, 1, 0);;; (1, 0, 1) (1, 1, 1); (2, 0, 1) (2, 1, 1);;;;
(1, 0, 1) (1, 1, 1); (2, 0, 1) (2, 1, 1);;; (1, 0, 2) (1, 1, 2); (2, 0, 2) (2, 1, 2)
]
@test facecodes(grid, Val(false)) == Int8[0, 0]
@test boundarycodes(grid) == [0 0; 0 0; 1 1; 1 1; 1 0; 0 1]
@test ncp.recvranks == Int32[0, 2]
@test ncp.recvrankindices == UnitRange{Int64}[1:8, 9:16]
@test ncp.recvindices ==
[18, 20, 22, 24, 26, 28, 30, 32, 33, 35, 37, 39, 41, 43, 45, 47]
@test ncp.sendranks == Int32[0, 2]
@test ncp.sendrankindices == UnitRange{Int64}[1:8, 9:16]
@test ncp.sendindices == [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16]
#! format: off
@test continuoustodiscontinuous(grid) == sparse(
[
17,
21, 25,
29,
1, 18,
5, 9, 22, 26,
13, 30,
19,
23, 27,
31,
3, 20,
7, 11, 24, 28,
15, 32,
2, 33,
6, 10, 37, 41,
14, 45,
4, 35,
8, 12, 39, 43,
16, 47,
34,
38, 42,
46,
36,
40, 44,
48,
],
[
1,
2, 2,
3,
4, 4,
5, 5, 5, 5,
6, 6,
7,
8, 8,
9,
10, 10,
11, 11, 11, 11,
12, 12,
13, 13,
14, 14, 14, 14,
15, 15,
16, 16,
17, 17, 17, 17,
18, 18,
19,
20, 20,
21,
22,
23, 23,
24,
],
Bool[
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
],
48,
24,
)
#! format: on
@test communicatingcells(grid) == [1, 2]
@test noncommunicatingcells(grid) == Int64[]
@test numcells(grid) == 2
@test numcells(grid, Val(true)) == 6
@test offset(grid) == 2
@test Raven.partitionnumber(grid) == 2
@test Raven.numberofpartitions(grid) == 3
@test fm.vmapM == [
01 09 17 25 33 41 #########
03 11 19 27 35 43
05 13 21 29 37 45
07 15 23 31 39 47
02 10 18 26 34 42 #########
04 12 20 28 36 44
06 14 22 30 38 46
08 16 24 32 40 48
01 09 17 25 33 41 #########
02 10 18 26 34 42
05 13 21 29 37 45
06 14 22 30 38 46
03 11 19 27 35 43 #########
04 12 20 28 36 44
07 15 23 31 39 47
08 16 24 32 40 48
01 09 17 25 33 41 #########
02 10 18 26 34 42
03 11 19 27 35 43
04 12 20 28 36 44
05 13 21 29 37 45 #########
06 14 22 30 38 46
07 15 23 31 39 47
08 16 24 32 40 48
]
@test fm.vmapP == [
18 26 17 25 33 41 #########
20 28 19 27 35 43
22 30 21 29 37 45
24 32 23 31 39 47
33 41 18 26 34 42 #########
35 43 20 28 36 44
37 45 22 30 38 46
39 47 24 32 40 48
01 09 17 25 33 41 #########
02 10 18 26 34 42
05 13 21 29 37 45
06 14 22 30 38 46
03 11 19 27 35 43 #########
04 12 20 28 36 44
07 15 23 31 39 47
08 16 24 32 40 48
01 05 17 25 33 41 #########
02 06 18 26 34 42
03 07 19 27 35 43
04 08 20 28 36 44
09 13 21 29 37 45 #########
10 14 22 30 38 46
11 15 23 31 39 47
12 16 24 32 40 48
]
elseif rank == 2
# Grid point numbering aka LinearIndices(points(grid, Val(true)))
# [:, :, 1, 1] =
# 1 3
# 2 4
#
# [:, :, 2, 1] =
# 5 7
# 6 8
#
# [:, :, 1, 2] =
# 9 11
# 10 12
#
# [:, :, 2, 2] =
# 13 15
# 14 16
#
# [:, :, 1, 3] =
# 17 19
# 18 20
#
# [:, :, 2, 3] =
# 21 23
# 22 24
#
# [:, :, 1, 4] =
# 25 27
# 26 28
#
# [:, :, 2, 4] =
# 29 31
# 30 32
@test levels(grid, Val(false)) == Int8[0, 0]
@test levels(grid, Val(true)) == Int8[0, 0, 0, 0]
@test trees(grid, Val(false)) == Int32[5, 6]
@test trees(grid, Val(true)) == Int32[5, 6, 3, 4]
@test points(grid) == SVector{3,FT}[
(2, 0, 0) (2, 1, 0); (3, 0, 0) (3, 1, 0);;; (2, 0, 1) (2, 1, 1); (3, 0, 1) (3, 1, 1);;;;
(2, 0, 1) (2, 1, 1); (3, 0, 1) (3, 1, 1);;; (2, 0, 2) (2, 1, 2); (3, 0, 2) (3, 1, 2)
]
@test facecodes(grid, Val(false)) == Int8[0, 0]
@test boundarycodes(grid) == [0 0; 1 1; 1 1; 1 1; 1 0; 0 1]
@test ncp.recvranks == Int32[1]
@test ncp.recvrankindices == UnitRange{Int64}[1:8]
@test ncp.recvindices == [18, 20, 22, 24, 26, 28, 30, 32]
@test ncp.sendranks == Int32[1]
@test ncp.sendrankindices == UnitRange{Int64}[1:8]
@test ncp.sendindices == [1, 3, 5, 7, 9, 11, 13, 15]
#! format: off
@test continuoustodiscontinuous(grid) == sparse(
[
17,
21, 25,
29,
19,
23, 27,
31,
1, 18,
5, 9, 22, 26,
13, 30,
3, 20,
7, 11, 24, 28,
15, 32,
2,
6, 10,
14,
4,
8, 12,
16,
],
[
1,
2, 2,
3,
4,
5, 5,
6,
7, 7,
8, 8, 8, 8,
9, 9,
10, 10,
11, 11, 11, 11,
12, 12,
13,
14, 14,
15,
16,
17, 17,
18,
],
Bool[
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
],
32,
18,
)
#! format: on
@test communicatingcells(grid) == [1, 2]
@test noncommunicatingcells(grid) == Int64[]
@test numcells(grid) == 2
@test numcells(grid, Val(true)) == 4
@test offset(grid) == 4
@test Raven.partitionnumber(grid) == 3
@test Raven.numberofpartitions(grid) == 3
@test fm.vmapM == [
01 09 17 25 #########
03 11 19 27
05 13 21 29
07 15 23 31
02 10 18 26 #########
04 12 20 28
06 14 22 30
08 16 24 32
01 09 17 25 #########
02 10 18 26
05 13 21 29
06 14 22 30
03 11 19 27 #########
04 12 20 28
07 15 23 31
08 16 24 32
01 09 17 25 #########
02 10 18 26
03 11 19 27
04 12 20 28
05 13 21 29 #########
06 14 22 30
07 15 23 31
08 16 24 32
]
@test fm.vmapP == [
18 26 17 25 #########
20 28 19 27
22 30 21 29
24 32 23 31
02 10 18 26 #########
04 12 20 28
06 14 22 30
08 16 24 32
01 09 17 25 #########
02 10 18 26
05 13 21 29
06 14 22 30
03 11 19 27 #########
04 12 20 28
07 15 23 31
08 16 24 32
01 05 17 25 #########
02 06 18 26
03 07 19 27
04 08 20 28
09 13 21 29 #########
10 14 22 30
11 15 23 31
12 16 24 32
]
end
# Note that vmapP can point into the ghost layer so we need to get the
# points including the ghost layer.
pts = points(grid, Val(true))
@test isapprox(pts[fm.vmapM[:, 1:numcells(grid)]], pts[fm.vmapP[:, 1:numcells(grid)]])
@test isapprox(
pts[fm.vmapM[fm.mapM[:, 1:numcells(grid)]]],
pts[fm.vmapM[fm.mapP[:, 1:numcells(grid)]]],
)
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 4062 | using CUDA
using CUDA.CUDAKernels
using MPI
using Test
using Raven
using Raven.StaticArrays
using LinearAlgebra
using Raven.Adapt
MPI.Init()
struct Stiffness <: FieldArray{Tuple{2,2},Float64,2}
xx::Float64
yx::Float64
xy::Float64
yy::Float64
end
function test(N, K, ::Type{FT}, ::Type{AT}) where {FT,AT}
@testset "GridArray ($N, $AT, $FT)" begin
minlvl = 1
cell = LobattoCell{Float64,AT}(N...)
gm = GridManager(cell, Raven.brick(K...); min_level = minlvl)
grid = generate(gm)
A = GridArray(undef, grid)
@test A isa GridArray{Float64}
@test arraytype(A) <: AT
T = NamedTuple{(:E, :B),Tuple{SVector{3,Complex{FT}},SVector{3,Complex{FT}}}}
A = GridArray{T}(undef, grid)
@test eltype(A) == T
val = (E = SA[1, 3, 5], B = SA[7, 9, 11])
A .= Ref(val)
@test CUDA.@allowscalar A[1] == val
Adata = AT(parent(A))
colons = ntuple(_ -> Colon(), Val(length(N)))
for i = 1:2:11
@test all(Adata[colons..., i, :] .== i)
end
for i = 2:2:12
@test all(Adata[colons..., i, :] .== 0)
end
val = (E = SA[2, 1, 3], B = SA[0, 2, 1])
fill!(A, val)
@test CUDA.@allowscalar A[1] == val
val2 =
(E = SVector{3,Complex{FT}}(2, 6, 10), B = SVector{3,Complex{FT}}(14, 18, 22))
B = Raven.viewwithghosts(A)
B .= Ref(val2)
@test CUDA.@allowscalar B[end] == val2
Adatadata = parentwithghosts(A)
colons = ntuple(_ -> Colon(), Val(length(N)))
for i = 1:2:11
@test all(Adatadata[colons..., i, :] .== 2i)
end
for i = 2:2:12
@test all(Adatadata[colons..., i, :] .== 0)
end
cval = convert(T, val)
L = length(flatten(cval))
@test arraytype(A) <: AT
@test Raven.showingghosts(A) == false
@test Raven.fieldindex(A) == length(N) + 1
@test Raven.fieldslength(A) == L
@test size(A) == (size(cell)..., numcells(grid))
@test sizewithghosts(A) == (size(cell)..., numcells(grid, Val(true)))
@test size(parent(A)) == (size(cell)..., L, numcells(grid))
@test size(parentwithghosts(A)) == (size(cell)..., L, numcells(grid, Val(true)))
C = components(A)
@test length(C) == 2
@test C isa NamedTuple{(:E, :B)}
@test C[1] isa GridArray{typeof(cval[1])}
@test C[2] isa GridArray{typeof(cval[2])}
D = components(C[1])
@test length(D) == 3
@test D[1] isa GridArray{Complex{FT}}
@test D[2] isa GridArray{Complex{FT}}
@test D[3] isa GridArray{Complex{FT}}
E = components(D[1])
@test length(E) == 2
@test E[1] isa GridArray{FT}
@test E[2] isa GridArray{FT}
F = components(E[1])
@test length(F) == 1
@test F[1] isa GridArray{FT}
val3 = (
E = SVector{3,Complex{FT}}(1 + 1im, 1 + 1im, 1 + 1im),
B = SVector{3,Complex{FT}}(1 + 1im, 1 + 1im, 1 + 1im),
)
L = length(flatten(cval))
B = Raven.viewwithghosts(A)
B .= Ref(val3)
normA = sqrt(FT(L * prod(N) * prod(K) * (2^(length(K) * minlvl))))
@test isapprox(norm(A), normA)
A = GridArray{Stiffness}(undef, grid)
@test eltype(A) == Stiffness
@test components(A) isa NamedTuple{(:xx, :yx, :xy, :yy)}
A = GridArray{FT}(undef, grid)
A .= FT(2)
B = 1 ./ A
@test all(adapt(Array, (B .== FT(0.5))))
B = copy(A)
@test all(adapt(Array, (B .== A)))
C = AT{FT}(undef, size(A))
C .= -zero(FT)
@test all(adapt(Array, (A .== (A .+ C))))
@test all(adapt(Array, (A .== (C .+ A))))
end
end
function main()
test((2, 3), (2, 1), Float64, Array)
test((2, 3, 2), (1, 2, 1), Float64, Array)
if CUDA.functional()
test((2, 3), (2, 1), Float32, CuArray)
test((2, 3, 2), (1, 2, 1), Float32, CuArray)
end
end
main()
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 16643 | using CUDA
using CUDA.CUDAKernels
using MPI
using Test
using Raven
using Raven.StaticArrays
using Raven.P4estTypes
MPI.Init()
function isisomorphic(a, b)
f = Dict{eltype(a),eltype(b)}()
g = Dict{eltype(b),eltype(a)}()
for i in eachindex(a, b)
if a[i] in keys(f)
if f[a[i]] != b[i]
return false
end
else
f[a[i]] = b[i]
end
if b[i] in keys(g)
if g[b[i]] != a[i]
return false
end
else
g[b[i]] = a[i]
end
end
return true
end
let
# Coarse Grid
# y
# ^
# 4 | 7------8------9
# | | | |
# | | | |
# | | | |
# 2 | 3------4------6
# | | | |
# | | | |
# | | | |
# 0 | 1------2------5
# |
# +------------------> x
# 0 2 4
vertices = [
SVector(0.0, 0.0), # 1
SVector(2.0, 0.0), # 2
SVector(0.0, 2.0), # 3
SVector(2.0, 2.0), # 4
SVector(4.0, 0.0), # 5
SVector(4.0, 2.0), # 6
SVector(0.0, 4.0), # 7
SVector(2.0, 4.0), # 8
SVector(4.0, 4.0), # 9
]
cells = [
(1, 2, 3, 4), # 1
(6, 4, 5, 2), # 2
(3, 4, 7, 8), # 3
(4, 6, 8, 9), # 4
]
cg = coarsegrid(vertices, cells)
rank = MPI.Comm_rank(MPI.COMM_WORLD)
forest = P4estTypes.pxest(Raven.connectivity(cg); comm = MPI.COMM_WORLD)
P4estTypes.refine!(forest; refine = (_, tid, _) -> tid == 4)
P4estTypes.balance!(forest)
ghost = P4estTypes.ghostlayer(forest)
nodes = P4estTypes.lnodes(forest; ghost, degree = 3)
P4estTypes.expand!(ghost, forest, nodes)
forest_self = P4estTypes.pxest(Raven.connectivity(cg); comm = MPI.COMM_SELF)
P4estTypes.refine!(forest_self; refine = (_, tid, _) -> tid == 4)
P4estTypes.balance!(forest_self)
ghost_self = P4estTypes.ghostlayer(forest_self)
nodes_self = P4estTypes.lnodes(forest_self; ghost = ghost_self, degree = 3)
P4estTypes.expand!(ghost_self, forest_self, nodes_self)
quadranttoglobalids = Raven.materializequadranttoglobalid(forest, ghost)
if rank == 0
@test quadranttoglobalids == [1, 2, 3, 4, 5, 6]
elseif rank == 1
@test quadranttoglobalids == [2, 1, 3, 4, 5, 6]
elseif rank == 2
@test quadranttoglobalids == [3, 4, 5, 6, 7, 1, 2]
end
quadrantcommpattern = Raven.materializequadrantcommpattern(forest, ghost)
if rank == 0
@test quadrantcommpattern.recvindices == 2:6
@test quadrantcommpattern.recvranks == [1, 2]
@test quadrantcommpattern.recvrankindices == [1:1, 2:5]
@test quadrantcommpattern.sendindices == [1, 1]
@test quadrantcommpattern.sendranks == [1, 2]
@test quadrantcommpattern.sendrankindices == [1:1, 2:2]
elseif rank == 1
@test quadrantcommpattern.recvindices == 2:6
@test quadrantcommpattern.recvranks == [0, 2]
@test quadrantcommpattern.recvrankindices == [1:1, 2:5]
@test quadrantcommpattern.sendindices == [1, 1]
@test quadrantcommpattern.sendranks == [0, 2]
@test quadrantcommpattern.sendrankindices == [1:1, 2:2]
elseif rank == 2
@test quadrantcommpattern.recvindices == 6:7
@test quadrantcommpattern.recvranks == [0, 1]
@test quadrantcommpattern.recvrankindices == [1:1, 2:2]
@test quadrantcommpattern.sendindices == [1, 2, 3, 4, 1, 2, 3, 4]
@test quadrantcommpattern.sendranks == [0, 1]
@test quadrantcommpattern.sendrankindices == [1:4, 5:8]
end
(dtoc_degree_3_local, dtoc_degree_3_global) =
Raven.materializedtoc(forest, ghost, nodes, quadrantcommpattern, MPI.COMM_WORLD)
quadrantcommpattern_self = Raven.materializequadrantcommpattern(forest_self, ghost_self)
(dtoc_degree_3_local_self, dtoc_degree_3_global_self) = Raven.materializedtoc(
forest_self,
ghost_self,
nodes_self,
quadrantcommpattern_self,
MPI.COMM_SELF,
)
@test dtoc_degree_3_local == Raven.numbercontiguous(Int32, dtoc_degree_3_global)
@test eltype(dtoc_degree_3_local) == Int32
if rank == 0
@test isisomorphic(
dtoc_degree_3_global[:, :, 1:1],
dtoc_degree_3_global_self[:, :, 1:1],
)
@test isisomorphic(
dtoc_degree_3_global[:, :, 2:6],
dtoc_degree_3_global_self[:, :, 2:6],
)
elseif rank == 1
@test isisomorphic(
dtoc_degree_3_global[:, :, 1:1],
dtoc_degree_3_global_self[:, :, 2:2],
)
@test isisomorphic(
dtoc_degree_3_global[:, :, 2:6],
dtoc_degree_3_global_self[:, :, vcat(1:1, 3:6)],
)
elseif rank == 2
@test isisomorphic(
dtoc_degree_3_global[:, :, 1:5],
dtoc_degree_3_global_self[:, :, 3:7],
)
@test isisomorphic(
dtoc_degree_3_global[:, :, 6:7],
dtoc_degree_3_global_self[:, :, [1, 2]],
)
end
cell_degree_3 = LobattoCell{Float64,Array}(4, 4)
dtoc_degree_3 =
Raven.materializedtoc(cell_degree_3, dtoc_degree_3_local, dtoc_degree_3_global)
if rank == 0
@test isisomorphic(dtoc_degree_3[:, :, 1:1], dtoc_degree_3_global_self[:, :, 1:1])
@test isisomorphic(dtoc_degree_3[:, :, 2:6], dtoc_degree_3_global_self[:, :, 2:6])
elseif rank == 1
@test isisomorphic(dtoc_degree_3[:, :, 1:1], dtoc_degree_3_global_self[:, :, 2:2])
@test isisomorphic(
dtoc_degree_3[:, :, 2:6],
dtoc_degree_3_global_self[:, :, vcat(1:1, 3:6)],
)
elseif rank == 2
@test isisomorphic(dtoc_degree_3[:, :, 1:5], dtoc_degree_3_global_self[:, :, 3:7])
@test isisomorphic(
dtoc_degree_3[:, :, 6:7],
dtoc_degree_3_global_self[:, :, [1, 2]],
)
end
ctod_degree_3 = Raven.materializectod(dtoc_degree_3)
nodecommpattern_degree_3 =
Raven.materializenodecommpattern(cell_degree_3, ctod_degree_3, quadrantcommpattern)
if rank == 0
@test nodecommpattern_degree_3.recvindices ==
[20, 24, 28, 32, 33, 34, 35, 36, 49, 65, 81]
@test nodecommpattern_degree_3.recvranks == Int32[1, 2]
@test nodecommpattern_degree_3.recvrankindices == UnitRange{Int64}[1:4, 5:11]
@test nodecommpattern_degree_3.sendindices == [4, 8, 12, 16, 13, 14, 15, 16]
@test nodecommpattern_degree_3.sendranks == Int32[1, 2]
@test nodecommpattern_degree_3.sendrankindices == UnitRange{Int64}[1:4, 5:8]
elseif rank == 1
@test nodecommpattern_degree_3.recvindices ==
[20, 24, 28, 32, 36, 49, 50, 51, 52, 65, 66, 67, 68, 81]
@test nodecommpattern_degree_3.recvranks == Int32[0, 2]
@test nodecommpattern_degree_3.recvrankindices == UnitRange{Int64}[1:4, 5:14]
@test nodecommpattern_degree_3.sendindices == [4, 8, 12, 16, 1, 2, 3, 4]
@test nodecommpattern_degree_3.sendranks == Int32[0, 2]
@test nodecommpattern_degree_3.sendrankindices == UnitRange{Int64}[1:4, 5:8]
elseif rank == 2
@test nodecommpattern_degree_3.recvindices == [93, 94, 95, 96, 97, 98, 99, 100]
@test nodecommpattern_degree_3.recvranks == Int32[0, 1]
@test nodecommpattern_degree_3.recvrankindices == UnitRange{Int64}[1:4, 5:8]
@test nodecommpattern_degree_3.sendindices ==
[1, 2, 3, 4, 17, 33, 49, 4, 17, 18, 19, 20, 33, 34, 35, 36, 49]
@test nodecommpattern_degree_3.sendranks == Int32[0, 1]
@test nodecommpattern_degree_3.sendrankindices == UnitRange{Int64}[1:7, 8:17]
end
end
let
# Coarse Grid
# z = 0:
# y
# ^
# 4 | 7------8------9
# | | | |
# | | | |
# | | | |
# 2 | 3------4------6
# | | | |
# | | | |
# | | | |
# 0 | 1------2------5
# |
# +------------------> x
# 0 2 4
#
# z = 2:
# y
# ^
# 4 | 16-----17-----18
# | | | |
# | | | |
# | | | |
# 2 | 12-----13-----15
# | | | |
# | | | |
# | | | |
# 0 | 10-----11-----14
# |
# +------------------> x
# 0 2 4
vertices = [
SVector(0.0, 0.0, 0.0), # 1
SVector(2.0, 0.0, 0.0), # 2
SVector(0.0, 2.0, 0.0), # 3
SVector(2.0, 2.0, 0.0), # 4
SVector(4.0, 0.0, 0.0), # 5
SVector(4.0, 2.0, 0.0), # 6
SVector(0.0, 4.0, 0.0), # 7
SVector(2.0, 4.0, 0.0), # 8
SVector(4.0, 4.0, 0.0), # 9
SVector(0.0, 0.0, 2.0), # 10
SVector(2.0, 0.0, 2.0), # 11
SVector(0.0, 2.0, 2.0), # 12
SVector(2.0, 2.0, 2.0), # 13
SVector(4.0, 0.0, 2.0), # 14
SVector(4.0, 2.0, 2.0), # 15
SVector(0.0, 4.0, 2.0), # 16
SVector(2.0, 4.0, 2.0), # 17
SVector(4.0, 4.0, 2.0), # 18
]
cells = [
(1, 2, 3, 4, 10, 11, 12, 13), # 1
(6, 4, 5, 2, 15, 13, 14, 11), # 2
(3, 4, 7, 8, 12, 13, 16, 17), # 3
(4, 6, 8, 9, 13, 15, 17, 18), # 4
]
cg = coarsegrid(vertices, cells)
rank = MPI.Comm_rank(MPI.COMM_WORLD)
forest = P4estTypes.pxest(Raven.connectivity(cg))
P4estTypes.refine!(forest; refine = (_, tid, _) -> tid == 4)
P4estTypes.balance!(forest)
ghost = P4estTypes.ghostlayer(forest)
nodes = P4estTypes.lnodes(forest; ghost, degree = 3)
P4estTypes.expand!(ghost, forest, nodes)
forest_self = P4estTypes.pxest(Raven.connectivity(cg); comm = MPI.COMM_SELF)
P4estTypes.refine!(forest_self; refine = (_, tid, _) -> tid == 4)
P4estTypes.balance!(forest_self)
ghost_self = P4estTypes.ghostlayer(forest_self)
nodes_self = P4estTypes.lnodes(forest_self; ghost = ghost_self, degree = 3)
P4estTypes.expand!(ghost_self, forest_self, nodes_self)
quadranttoglobalids = Raven.materializequadranttoglobalid(forest, ghost)
if rank == 0
@test quadranttoglobalids == [1, 2, 3, 4, 5, 6, 8, 9, 10]
elseif rank == 1
@test quadranttoglobalids == [2, 1, 3, 4, 5, 6, 8, 9, 10]
elseif rank == 2
@test quadranttoglobalids == [3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2]
end
quadrantcommpattern = Raven.materializequadrantcommpattern(forest, ghost)
if rank == 0
@test quadrantcommpattern.recvindices == 2:9
@test quadrantcommpattern.recvranks == [1, 2]
@test quadrantcommpattern.recvrankindices == [1:1, 2:8]
@test quadrantcommpattern.sendindices == [1, 1]
@test quadrantcommpattern.sendranks == [1, 2]
@test quadrantcommpattern.sendrankindices == [1:1, 2:2]
elseif rank == 1
@test quadrantcommpattern.recvindices == 2:9
@test quadrantcommpattern.recvranks == [0, 2]
@test quadrantcommpattern.recvrankindices == [1:1, 2:8]
@test quadrantcommpattern.sendindices == [1, 1]
@test quadrantcommpattern.sendranks == [0, 2]
@test quadrantcommpattern.sendrankindices == [1:1, 2:2]
elseif rank == 2
@test quadrantcommpattern.recvindices == 10:11
@test quadrantcommpattern.recvranks == [0, 1]
@test quadrantcommpattern.recvrankindices == [1:1, 2:2]
@test quadrantcommpattern.sendindices == [1, 2, 3, 4, 6, 7, 8, 1, 2, 3, 4, 6, 7, 8]
@test quadrantcommpattern.sendranks == [0, 1]
@test quadrantcommpattern.sendrankindices == [1:7, 8:14]
end
(dtoc_degree_3_local, dtoc_degree_3_global) =
Raven.materializedtoc(forest, ghost, nodes, quadrantcommpattern, MPI.COMM_WORLD)
quadrantcommpattern_self = Raven.materializequadrantcommpattern(forest_self, ghost_self)
(dtoc_degree_3_local_self, dtoc_degree_3_global_self) = Raven.materializedtoc(
forest_self,
ghost_self,
nodes_self,
quadrantcommpattern_self,
MPI.COMM_SELF,
)
@test dtoc_degree_3_local == Raven.numbercontiguous(Int32, dtoc_degree_3_global)
@test eltype(dtoc_degree_3_local) == Int32
if rank == 0
@test isisomorphic(
dtoc_degree_3_global[:, :, :, 1:1],
dtoc_degree_3_global_self[:, :, :, 1:1],
)
@test isisomorphic(
dtoc_degree_3_global[:, :, :, 2:9],
dtoc_degree_3_global_self[:, :, :, [2, 3, 4, 5, 6, 8, 9, 10]],
)
elseif rank == 1
@test isisomorphic(
dtoc_degree_3_global[:, :, :, 1:1],
dtoc_degree_3_global_self[:, :, :, 2:2],
)
@test isisomorphic(
dtoc_degree_3_global[:, :, :, 2:9],
dtoc_degree_3_global_self[:, :, :, [1, 3, 4, 5, 6, 8, 9, 10]],
)
elseif rank == 2
@test isisomorphic(
dtoc_degree_3_global[:, :, :, 1:9],
dtoc_degree_3_global_self[:, :, :, 3:11],
)
@test isisomorphic(
dtoc_degree_3_global[:, :, :, 10:11],
dtoc_degree_3_global_self[:, :, :, [1, 2]],
)
end
cell_degree_3 = LobattoCell{Float64,Array}(4, 4, 4)
dtoc_degree_3 =
Raven.materializedtoc(cell_degree_3, dtoc_degree_3_local, dtoc_degree_3_global)
if rank == 0
@test isisomorphic(
dtoc_degree_3[:, :, :, 1:1],
dtoc_degree_3_global_self[:, :, :, 1:1],
)
@test isisomorphic(
dtoc_degree_3[:, :, :, 2:9],
dtoc_degree_3_global_self[:, :, :, [2, 3, 4, 5, 6, 8, 9, 10]],
)
elseif rank == 1
@test isisomorphic(
dtoc_degree_3[:, :, :, 1:1],
dtoc_degree_3_global_self[:, :, :, 2:2],
)
@test isisomorphic(
dtoc_degree_3[:, :, :, 2:9],
dtoc_degree_3_global_self[:, :, :, [1, 3, 4, 5, 6, 8, 9, 10]],
)
elseif rank == 2
@test isisomorphic(
dtoc_degree_3[:, :, :, 1:9],
dtoc_degree_3_global_self[:, :, :, 3:11],
)
@test isisomorphic(
dtoc_degree_3[:, :, :, 10:11],
dtoc_degree_3_global_self[:, :, :, [1, 2]],
)
end
ctod_degree_3 = Raven.materializectod(dtoc_degree_3)
nodecommpattern_degree_3 =
Raven.materializenodecommpattern(cell_degree_3, ctod_degree_3, quadrantcommpattern)
dnodes = LinearIndices(dtoc_degree_3)
if rank == 0
recv_1 = vec(dnodes[end, :, :, 2])
recv_2 = vcat(
vec(dnodes[:, 1, :, 3]),
dnodes[1, 1, :, 4],
dnodes[1, 1, :, 5],
dnodes[1, 1, :, 6],
dnodes[1, 1, :, 7],
dnodes[1, 1, :, 8],
dnodes[1, 1, :, 9],
)
send_1 = vec(dnodes[end, :, :, 1])
send_2 = vec(dnodes[:, end, :, 1])
sendrecv_ranks = Int32[1, 2]
elseif rank == 1
recv_1 = vec(dnodes[end, :, :, 2])
recv_2 = vcat(
dnodes[end, 1, :, 3],
vec(dnodes[:, 1, :, 4]),
vec(dnodes[:, 1, :, 5]),
dnodes[1, 1, :, 6],
vec(dnodes[:, 1, :, 7]),
vec(dnodes[:, 1, :, 8]),
dnodes[1, 1, :, 9],
)
send_1 = vec(dnodes[end, :, :, 1])
send_2 = vec(dnodes[:, 1, :, 1])
sendrecv_ranks = Int32[0, 2]
elseif rank == 2
recv_1 = vec(dnodes[:, end, :, 10])
recv_2 = vec(dnodes[:, 1, :, 11])
send_1 = vcat(
vec(dnodes[:, 1, :, 1]),
dnodes[1, 1, :, 2],
dnodes[1, 1, :, 3],
dnodes[1, 1, :, 4],
dnodes[1, 1, :, 6],
dnodes[1, 1, :, 7],
dnodes[1, 1, :, 8],
)
send_2 = vcat(
dnodes[end, 1, :, 1],
vec(dnodes[:, 1, :, 2]),
vec(dnodes[:, 1, :, 3]),
dnodes[1, 1, :, 4],
vec(dnodes[:, 1, :, 6]),
vec(dnodes[:, 1, :, 7]),
dnodes[1, 1, :, 8],
)
sendrecv_ranks = Int32[0, 1]
end
@test nodecommpattern_degree_3.recvindices == vcat(recv_1, recv_2)
@test nodecommpattern_degree_3.recvranks == sendrecv_ranks
@test nodecommpattern_degree_3.recvrankindices ==
UnitRange{Int64}[1:length(recv_1), (1:length(recv_2)).+length(recv_1)]
@test nodecommpattern_degree_3.sendindices == vcat(send_1, send_2)
@test nodecommpattern_degree_3.sendranks == sendrecv_ranks
@test nodecommpattern_degree_3.sendrankindices ==
UnitRange{Int64}[1:length(send_1), (1:length(send_2)).+length(send_1)]
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 9961 | function findorient(::Val{2}, dest::AbstractArray{<:Any,1}, src::AbstractArray{<:Any,1})
if size(dest) != (2,) && size(src) != (2,)
throw(ArgumentError("Arguments dest=$dest src=$src need to be of size (2,)"))
end
k = dest == src ? 1 : 2
return Raven.Orientation{2}(k)
end
function findorient(::Val{4}, dest::AbstractArray{<:Any,2}, src::AbstractArray{<:Any,2})
if size(dest) != (2, 2) && size(src) != (2, 2)
throw(ArgumentError("Arguments dest=$dest src=$src need to be of size (2,2)"))
end
k = 0
for (i, perm) in enumerate((
(1, 2, 3, 4),
(2, 1, 4, 3),
(3, 4, 1, 2),
(4, 3, 2, 1),
(1, 3, 2, 4),
(2, 4, 1, 3),
(3, 1, 4, 2),
(4, 2, 3, 1),
))
if src[perm[1]] == dest[1] &&
src[perm[2]] == dest[2] &&
src[perm[3]] == dest[3] &&
src[perm[4]] == dest[4]
k = i
break
end
end
if k == 0
throw(ArgumentError("Orientation from $src to $dest is unknown"))
end
return Raven.Orientation{4}(k)
end
# function findorient(::Val{8}, dest::AbstractArray{<:Any,3}, src::AbstractArray{<:Any,3})
# if size(dest) != (2, 2, 2) && size(src) != (2, 2, 2)
# throw(ArgumentError("Arguments dest=$dest src=$src need to be of size (2,2,2)"))
# end
#
# k = 0
#
# for (i, perm) in enumerate((
# (1, 2, 3, 4, 5, 6, 7, 8),
# (2, 1, 4, 3, 6, 5, 8, 7),
# (3, 4, 1, 2, 7, 8, 5, 6),
# (4, 3, 2, 1, 8, 7, 6, 5),
# (5, 6, 7, 8, 1, 2, 3, 4),
# (6, 5, 8, 7, 2, 1, 4, 3),
# (7, 8, 5, 6, 3, 4, 1, 2),
# (8, 7, 6, 5, 4, 3, 2, 1),
# (1, 2, 5, 6, 3, 4, 7, 8),
# (2, 1, 6, 5, 4, 3, 8, 7),
# (3, 4, 7, 8, 1, 2, 5, 6),
# (4, 3, 8, 7, 2, 1, 6, 5),
# (5, 6, 1, 2, 7, 8, 3, 4),
# (6, 5, 2, 1, 8, 7, 4, 3),
# (7, 8, 3, 4, 5, 6, 1, 2),
# (8, 7, 4, 3, 6, 5, 2, 1),
# (1, 3, 2, 4, 5, 7, 6, 8),
# (2, 4, 1, 3, 6, 8, 5, 7),
# (3, 1, 4, 2, 7, 5, 8, 6),
# (4, 2, 3, 1, 8, 6, 7, 5),
# (5, 7, 6, 8, 1, 3, 2, 4),
# (6, 8, 5, 7, 2, 4, 1, 3),
# (7, 5, 8, 6, 3, 1, 4, 2),
# (8, 6, 7, 5, 4, 2, 3, 1),
# (1, 3, 5, 7, 2, 4, 6, 8),
# (2, 4, 6, 8, 1, 3, 5, 7),
# (3, 1, 7, 5, 4, 2, 8, 6),
# (4, 2, 8, 6, 3, 1, 7, 5),
# (5, 7, 1, 3, 6, 8, 2, 4),
# (6, 8, 2, 4, 5, 7, 1, 3),
# (7, 5, 3, 1, 8, 6, 4, 2),
# (8, 6, 4, 2, 7, 5, 3, 1),
# (1, 5, 2, 6, 3, 7, 4, 8),
# (2, 6, 1, 5, 4, 8, 3, 7),
# (3, 7, 4, 8, 1, 5, 2, 6),
# (4, 8, 3, 7, 2, 6, 1, 5),
# (5, 1, 6, 2, 7, 3, 8, 4),
# (6, 2, 5, 1, 8, 4, 7, 3),
# (7, 3, 8, 4, 5, 1, 6, 2),
# (8, 4, 7, 3, 6, 2, 5, 1),
# (1, 5, 3, 7, 2, 6, 4, 8),
# (2, 6, 4, 8, 1, 5, 3, 7),
# (3, 7, 1, 5, 4, 8, 2, 6),
# (4, 8, 2, 6, 3, 7, 1, 5),
# (5, 1, 7, 3, 6, 2, 8, 4),
# (6, 2, 8, 4, 5, 1, 7, 3),
# (7, 3, 5, 1, 8, 4, 6, 2),
# (8, 4, 6, 2, 7, 3, 5, 1),
# ))
# if src[perm[1]] == dest[1] &&
# src[perm[2]] == dest[2] &&
# src[perm[3]] == dest[3] &&
# src[perm[4]] == dest[4] &&
# src[perm[5]] == dest[5] &&
# src[perm[6]] == dest[6] &&
# src[perm[7]] == dest[7] &&
# src[perm[8]] == dest[8]
# k = i
# break
# end
# end
#
# if k == 0
# throw(ArgumentError("Orientation from $src to $dest is unknown"))
# end
#
# return Raven.Orientation{8}(k)
# end
@testset "Orientation" begin
@testset "Orientation{2}" begin
@test Raven.orientindices(Raven.Orientation{2}(1), (3,)) ==
[CartesianIndex(1), CartesianIndex(2), CartesianIndex(3)]
@test Raven.orientindices(Raven.Orientation{2}(2), (3,)) ==
[CartesianIndex(3), CartesianIndex(2), CartesianIndex(1)]
L = LinearIndices((1:2,))
for j = 1:2
p = Raven.Orientation{2}(j)
pL = L[Raven.orientindices(p, (2,))]
for i = 1:2
q = Raven.Orientation{2}(i)
qpL = pL[Raven.orientindices(q, (2,))]
qp = findorient(Val(2), qpL, L)
@test qp == q ∘ p
end
end
@test inv(Raven.Orientation{2}(1)) == Raven.Orientation{2}(1)
@test inv(Raven.Orientation{2}(2)) == Raven.Orientation{2}(2)
L = LinearIndices((1:2,))
for j = 1:2
p = Raven.Orientation{2}(j)
pL = L[Raven.orientindices(p, (2,))]
q = Raven.orient(Val(2), Tuple(pL))
@test q == inv(p)
end
A = [1, -1]
for i = 1:2
o = Raven.Orientation{2}(i)
p = findorient(Val(2), A[Raven.orientindices(o, size(A))], A)
@test o == p
end
@test Raven.perm(Raven.Orientation{2}(1)) == SA[1, 2]
@test Raven.perm(Raven.Orientation{2}(2)) == SA[2, 1]
end
@testset "Orientation{4}" begin
dims = (3, 4)
A = reshape(1:prod(dims), dims)
L = LinearIndices((1:2, 1:2))
for j = 1:8
p = Raven.Orientation{4}(j)
pL = L[Raven.orientindices(p, (2, 2))]
for i = 1:8
q = Raven.Orientation{4}(i)
qpL = pL[Raven.orientindices(q, (2, 2))]
qp = findorient(Val(4), qpL, L)
@test qp == q ∘ p
end
end
@test inv(Raven.Orientation{4}(1)) == Raven.Orientation{4}(1)
@test inv(Raven.Orientation{4}(2)) == Raven.Orientation{4}(2)
@test inv(Raven.Orientation{4}(3)) == Raven.Orientation{4}(3)
@test inv(Raven.Orientation{4}(4)) == Raven.Orientation{4}(4)
@test inv(Raven.Orientation{4}(5)) == Raven.Orientation{4}(5)
@test inv(Raven.Orientation{4}(6)) == Raven.Orientation{4}(7)
@test inv(Raven.Orientation{4}(7)) == Raven.Orientation{4}(6)
@test inv(Raven.Orientation{4}(8)) == Raven.Orientation{4}(8)
L = LinearIndices((1:2, 1:2))
for j = 1:8
p = Raven.Orientation{4}(j)
pL = L[Raven.orientindices(p, (2, 2))]
q = Raven.orient(Val(4), Tuple(pL))
@test q == inv(p)
end
A = reshape([1, 30, 23, -1], (2, 2))
for i = 1:8
o = Raven.Orientation{4}(i)
p = findorient(Val(4), A[Raven.orientindices(o, size(A))], A)
@test o == p
end
for (o, perm) in enumerate((
SA[1, 2, 3, 4],
SA[2, 1, 4, 3],
SA[3, 4, 1, 2],
SA[4, 3, 2, 1],
SA[1, 3, 2, 4],
SA[2, 4, 1, 3],
SA[3, 1, 4, 2],
SA[4, 2, 3, 1],
))
src = reshape(1:4, (2, 2))
dest = reshape(perm, (2, 2))
@test findorient(Val(4), dest, src) == Raven.Orientation{4}(o)
@test perm == Raven.perm(Raven.Orientation{4}(o))
end
end
# @testset "Orientation{8}" begin
# dims = (3, 4, 5)
# A = reshape(1:prod(dims), dims)
#
# for i = 1:48
# o = Raven.Orientation{8}(i)
# B = A[Raven.orientindices(o, dims)]
# C = B[Raven.orientindices(o, dims, true)]
# @test A == C
# end
#
# A = reshape([1, 30, 23, 32, 4, 9, 99, -1], (2, 2, 2))
# for i = 1:48
# o = Raven.Orientation{8}(i)
# p = findorient(Val(8), A[Raven.orientindices(o, size(A))], A)
# @test o == p
# end
#
# for (o, perm) in enumerate((
# SA[1, 2, 3, 4, 5, 6, 7, 8],
# SA[2, 1, 4, 3, 6, 5, 8, 7],
# SA[3, 4, 1, 2, 7, 8, 5, 6],
# SA[4, 3, 2, 1, 8, 7, 6, 5],
# SA[5, 6, 7, 8, 1, 2, 3, 4],
# SA[6, 5, 8, 7, 2, 1, 4, 3],
# SA[7, 8, 5, 6, 3, 4, 1, 2],
# SA[8, 7, 6, 5, 4, 3, 2, 1],
# SA[1, 2, 5, 6, 3, 4, 7, 8],
# SA[2, 1, 6, 5, 4, 3, 8, 7],
# SA[3, 4, 7, 8, 1, 2, 5, 6],
# SA[4, 3, 8, 7, 2, 1, 6, 5],
# SA[5, 6, 1, 2, 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(perm, (2, 2, 2))
# @test findorient(Val(8), dest, src) == Raven.Orientation{8}(o)
# end
# end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 2352 | using CUDA
using CUDA.CUDAKernels
using MPI
using Pkg
using Raven
import Raven.Adapt
import Raven.P4estTypes
using Raven.StaticArrays
using Raven.SparseArrays
using Test
using Aqua
Aqua.test_all(Raven; stale_deps = (ignore = [:Requires],))
function runmpitests()
test_dir = @__DIR__
istest(f) = endswith(f, ".jl") && startswith(f, "mpitest_")
testfiles = sort(filter(istest, readdir(test_dir)))
mktempdir() do tmp_dir
base_dir = joinpath(@__DIR__, "..")
# Change to temporary directory so that any files created by the
# example get cleaned up after execution.
cd(tmp_dir)
test_project = Pkg.Types.projectfile_path(test_dir)
tmp_project = Pkg.Types.projectfile_path(tmp_dir)
cp(test_project, tmp_project)
# Copy data files to temporary directory
# test_data_dir = joinpath(test_dir, "data")
# tmp_data_dir = joinpath(tmp_dir, "data")
# mkdir(tmp_data_dir)
# for f in readdir(test_data_dir)
# cp(joinpath(test_data_dir, f), joinpath(tmp_data_dir, f))
# end
# Setup MPI and P4est preferences
code = "import Pkg; Pkg.develop(path=raw\"$base_dir\"); Pkg.instantiate(); Pkg.precompile(); include(joinpath(raw\"$test_dir\", \"configure_packages.jl\"))"
cmd = `$(Base.julia_cmd()) --startup-file=no --project=$tmp_project -e "$code"`
@info "Initializing MPI and P4est with" cmd
@test success(pipeline(cmd, stderr = stderr, stdout = stdout))
@info "Running MPI tests..."
@testset "$f" for f in testfiles
nprocs = parse(Int, first(match(r"_n(\d*)_", f).captures))
cmd = `$(mpiexec()) -n $nprocs $(Base.julia_cmd()) --startup-file=no --project=$tmp_project $(joinpath(test_dir, f))`
@test success(pipeline(cmd, stderr = stderr, stdout = stdout))
end
end
end
MPI.Initialized() || MPI.Init()
include("arrays.jl")
include("communication.jl")
include("facecode.jl")
include("gridnumbering.jl")
include("orientation.jl")
include("sparsearrays.jl")
include("testsuite.jl")
Testsuite.testsuite(Array, Float64)
Testsuite.testsuite(Array, BigFloat)
if CUDA.functional()
@info "Running test suite with CUDA"
CUDA.versioninfo()
CUDA.allowscalar(false)
Testsuite.testsuite(CuArray, Float32)
end
runmpitests()
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 708 | @testset "Sparse Arrays" begin
S = sparse([1], [2], [3])
G = Raven.GeneralSparseMatrixCSC(S)
AT = CUDA.functional() ? CuArray : Array
H = Adapt.adapt(AT, G)
for A in (G, H)
@test size(S) == size(A)
@test SparseArrays.getcolptr(S) == Array(SparseArrays.getcolptr(A))
@test rowvals(S) == Array(rowvals(A))
@test nonzeros(S) == Array(nonzeros(A))
@test nnz(S) == nnz(A)
@static if VERSION >= v"1.7"
ioS = IOBuffer()
ioA = IOBuffer()
show(ioS, S)
show(ioA, A)
@test take!(ioS) == take!(ioA)
@test_nowarn show(IOBuffer(), MIME"text/plain"(), A)
end
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | code | 1381 | module Testsuite
using Raven
using Raven.Adapt
using Raven.KernelAbstractions
using Raven.LinearAlgebra
using Raven.OneDimensionalNodes
import Raven.P4estTypes
using Raven.SparseArrays
using Raven.StaticArrays
using StableRNGs
using Test
using WriteVTK
include("cells.jl")
include("flatten.jl")
include("grids.jl")
include("gridarrays.jl")
include("kron.jl")
include("extrude.jl")
function testsuite(AT, FT)
@testset "Cells ($AT, $FT)" begin
cells_testsuite(AT, FT)
end
@testset "Flatten ($AT, $FT)" begin
flatten_testsuite(AT, FT)
end
# Unfortunately, our KernelAbstractions kernels do not work
# when FT is not an `isbitstype`.
if isbitstype(FT)
@testset "Grid generation ($AT, $FT)" begin
grids_testsuite(AT, FT)
end
@testset "Grid arrays ($AT, $FT)" begin
gridarrays_testsuite(AT, FT)
end
@testset "Grid extrude ($AT, $FT)" begin
extrude_testsuite(AT, FT)
end
@testset "Kronecker operators (GridArray 2D) ($AT, $FT)" begin
kron2dgridarray_testsuite(AT, FT)
end
@testset "Kronecker operators (GridArray 3D) ($AT, $FT)" begin
kron3dgridarray_testsuite(AT, FT)
end
end
@testset "Kronecker operators (primitive) ($AT, $FT)" begin
kron_testsuite(AT, FT)
end
end
end
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | docs | 1009 | # Raven 𓅂
<p align="center">
<a href="https://HorribleSanity.github.io/Raven.jl/dev/">Documentation</a> •
<a href="#contributing">Contributing</a>
</p>
[Raven](https://github.com/HorribleSanity/Raven.jl)
is a toolbox for adapted discontinuous spectral element discretizations of
partial differential equations that supports execution on distributed manycore
devices (via
[KernelAbstractions](https://github.com/JuliaGPU/KernelAbstractions.jl) and
[MPI](https://github.com/JuliaParallel/MPI.jl)).
Some of our previous efforts in this area resulted in
[Canary](https://github.com/Clima/Canary.jl),
[Bennu](https://github.com/lcw/Bennu.jl), and
[Atum](https://github.com/mwarusz/Atum.jl).
## Contributing
Contributions are encouraged. If there are additional features you would like
to use, please open an [issue](https://github.com/HorribleSanity/Raven.jl/issues) or [pull
request](https://github.com/HorribleSanity/Raven.jl/pulls).
Additional examples and documentation improvements are also welcome.
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | docs | 863 | # Raven 𓅂
[Raven](https://github.com/HorribleSanity/Raven.jl)
is a toolbox for adapted discontinuous spectral element discretizations of
partial differential equations that supports execution on distributed manycore
devices (via
[KernelAbstractions](https://github.com/JuliaGPU/KernelAbstractions.jl) and
[MPI](https://github.com/JuliaParallel/MPI.jl)).
Some of our previous efforts in this area resulted in
[Canary](https://github.com/Clima/Canary.jl),
[Bennu](https://github.com/lcw/Bennu.jl), and
[Atum](https://github.com/mwarusz/Atum.jl).
## Contributing
Contributions are encouraged. If there are additional features you would like
to use, please open an [issue](https://github.com/HorribleSanity/Raven.jl/issues) or [pull
request](https://github.com/HorribleSanity/Raven.jl/pulls).
Additional examples and documentation improvements are also welcome.
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 0.2.3 | a630dec3c3d292bda4ab57468fda5f832772fa0e | docs | 88 | # API reference
```@meta
CurrentModule = Raven
```
```@autodocs
Modules = [Raven]
```
| Raven | https://github.com/HorribleSanity/Raven.jl.git |
|
[
"MIT"
] | 3.7.5 | 8836d8846919670cec877e4002d972c23e9dde29 | code | 619 | using Documenter
using DynamicSumTypes
println("Documentation Build")
makedocs(
modules = [DynamicSumTypes],
sitename = "DynamicSumTypes.jl",
warnonly = [:doctest, :missing_docs, :cross_references],
pages = [
"API" => "index.md",
],
)
@info "Deploying Documentation"
CI = get(ENV, "CI", nothing) == "true" || get(ENV, "GITHUB_TOKEN", nothing) !== nothing
if CI
deploydocs(
repo = "github.com/JuliaDynamics/DynamicSumTypes.jl.git",
target = "build",
push_preview = true,
devbranch = "main",
)
end
println("Finished boulding and deploying docs.")
| DynamicSumTypes | https://github.com/JuliaDynamics/DynamicSumTypes.jl.git |
|
[
"MIT"
] | 3.7.5 | 8836d8846919670cec877e4002d972c23e9dde29 | code | 6368 |
module DynamicSumTypes
using MacroTools: namify
export @sumtype, variant, variantof, allvariants, is_sumtype
unwrap(sumt) = getfield(sumt, :variants)
"""
@sumtype SumTypeName(Types) [<: AbstractType]
The macro creates a sumtypes composed by the given types.
It optionally accept also an abstract supertype.
## Example
```julia
julia> using DynamicSumTypes
julia> struct A x::Int end;
julia> struct B end;
julia> @sumtype AB(A, B)
```
"""
macro sumtype(typedef)
if typedef.head === :call
abstract_type = :Any
type_with_variants = typedef
elseif typedef.head === :(<:)
abstract_type = typedef.args[2]
type_with_variants = typedef.args[1]
else
error("Invalid syntax")
end
type = type_with_variants.args[1]
typename = namify(type)
typeparams = type isa Symbol ? [] : type.args[2:end]
variants = type_with_variants.args[2:end]
!allunique(variants) && error("Duplicated variants in sumtype")
variants_with_P = [v for v in variants if v isa Expr && !isempty(intersect(typeparams, v.args[2:end]))]
variants_bounded = [v in variants_with_P ? namify(v) : v for v in variants]
check_if_typeof(v) = v isa Expr && v.head == :call && v.args[1] == :typeof
variants_names = namify.([check_if_typeof(v) ? v.args[2] : v for v in variants])
for vname in unique(variants_names)
inds = findall(==(vname), variants_names)
length(inds) == 1 && continue
for (k, i) in enumerate(inds)
variant_args = check_if_typeof(variants[i]) ? variants[i].args[2] : variants[i].args
variants_names[i] = Symbol([i == length(variant_args) ? a : Symbol(a, :_) for (i, a) in enumerate(variant_args)]...)
end
end
constructors = [:(@inline $(namify(type))(v::Union{$(variants...)}) where {$(typeparams...)} =
$(branchs(variants, variants_with_P, :(return new{$(typeparams...)}(v)))...))]
constructors_extra = [:($Base.adjoint(SumT::Type{$typename}) = $(Expr(:tuple, (:($nv = (args...; kwargs...) ->
$DynamicSumTypes.constructor($typename, $v, args...; kwargs...)) for (nv, v) in
zip(variants_names, variants_bounded))...)))]
if type isa Expr
push!(
constructors,
:(@inline $type(v::Union{$(variants...)}) where {$(typeparams...)} =
$(branchs(variants, variants_with_P, :(return new{$(typeparams...)}(v)))...))
)
push!(
constructors_extra,
:($Base.adjoint(SumT::Type{$type}) where {$(typeparams...)} =
$(Expr(:tuple, (:($nv = (args...; kwargs...) -> $DynamicSumTypes.constructor($type, $v, args...; kwargs...))
for (nv, v) in zip(variants_names, variants))...)))
)
end
esc(quote
struct $type <: $(abstract_type)
variants::Union{$(variants...)}
$(constructors...)
end
$(constructors_extra...)
@inline function $Base.getproperty(sumt::$typename, s::Symbol)
v = $DynamicSumTypes.unwrap(sumt)
$(branchs(variants, variants_with_P, :(return $Base.getproperty(v, s)))...)
end
@inline function $Base.setproperty!(sumt::$typename, s::Symbol, value)
v = $DynamicSumTypes.unwrap(sumt)
$(branchs(variants, variants_with_P, :(return $Base.setproperty!(v, s, value)))...)
end
function $Base.propertynames(sumt::$typename)
v = $DynamicSumTypes.unwrap(sumt)
$(branchs(variants, variants_with_P, :(return $Base.propertynames(v)))...)
end
function $Base.hasproperty(sumt::$typename, s::Symbol)
v = $DynamicSumTypes.unwrap(sumt)
$(branchs(variants, variants_with_P, :(return $Base.hasproperty(v, s)))...)
end
function $Base.copy(sumt::$typename)
v = $DynamicSumTypes.unwrap(sumt)
$(branchs(variants, variants_with_P, :(return $type(Base.copy(v))))...)
end
@inline $DynamicSumTypes.variant(sumt::$typename) = $DynamicSumTypes.unwrap(sumt)
@inline function $DynamicSumTypes.variant_idx(sumt::$typename)
v = $DynamicSumTypes.unwrap(sumt)
$(branchs(variants, variants_with_P, [:(return $i) for i in 1:length(variants)])...)
end
$DynamicSumTypes.variantof(sumt::$typename) = typeof($DynamicSumTypes.variant(sumt))
$DynamicSumTypes.allvariants(sumt::Type{$typename}) = $(Expr(:tuple, (:($nv = $(v in variants_with_P ? namify(v) : v))
for (nv, v) in zip(variants_names, variants))...))
$DynamicSumTypes.is_sumtype(sumt::Type{$typename}) = true
nothing
end)
end
function branchs(variants, variants_with_P, outputs)
!(outputs isa Vector) && (outputs = repeat([outputs], length(variants)))
branchs = [Expr(:if, :(v isa $(variants[1] in variants_with_P ? namify(variants[1]) : variants[1])), outputs[1])]
for i in 2:length(variants)
push!(branchs, Expr(:elseif, :(v isa $(variants[i] in variants_with_P ? namify(variants[i]) : variants[i])), outputs[i]))
end
push!(branchs, :(error("THIS_SHOULD_BE_UNREACHABLE")))
return branchs
end
constructor(T, V, args::Vararg{Any, N}; kwargs...) where N = T(V(args...; kwargs...))
"""
variant(inst)
Returns the variant enclosed in the sum type.
## Example
```julia
julia> using DynamicSumTypes
julia> struct A x::Int end;
julia> struct B end;
julia> @sumtype AB(A, B)
julia> a = AB(A(0))
AB'.A(0)
julia> variant(a)
A(0)
```
"""
function variant end
"""
allvariants(SumType)
Returns all the enclosed variants types in the sum type
in a namedtuple.
## Example
```julia
julia> using DynamicSumTypes
julia> struct A x::Int end;
julia> struct B end;
julia> @sumtype AB(A, B)
julia> allvariants(AB)
(A = A, B = B)
```
"""
function allvariants end
"""
variantof(inst)
Returns the type of the variant enclosed in
the sum type.
"""
function variantof end
"""
is_sumtype(T)
Returns true if the type is a sum type otherwise
returns false.
"""
is_sumtype(T::Type) = false
function variant_idx end
include("deprecations.jl")
end
| DynamicSumTypes | https://github.com/JuliaDynamics/DynamicSumTypes.jl.git |
|
[
"MIT"
] | 3.7.5 | 8836d8846919670cec877e4002d972c23e9dde29 | code | 32442 |
using MacroTools
using ExprTools
export @sum_structs
export @pattern
export @finalize_patterns
export export_variants
export kindof
export allkinds
export variant_constructor
const __modules_cache__ = Set{Module}()
const __variants_types_cache__ = Dict{Module, Dict{Any, Any}}()
const __variants_types_with_params_cache__ = Dict{Module, Dict{Any, Vector{Any}}}()
"""
kindof(instance)
Return a symbol representing the conceptual type of an instance:
```julia
julia> @sum_structs AB begin
struct A x::Int end
struct B y::Int end
end
julia> a = AB'.A(1);
julia> kindof(a)
:A
```
"""
function kindof end
"""
allkinds(type)
Return a `Tuple` containing all kinds associated with the overarching
type defined with `@sum_structs`
```julia
julia> @sum_structs AB begin
struct A x::Int end
struct B y::Int end
end
julia> allkinds(AB)
(:A, :B)
```
"""
function allkinds end
"""
variant_constructor(instance)
Return the constructor of an instance in a more
efficient way than doing `typeof(inst)'[kindof(inst)]`:
```julia
julia> @sum_structs AB begin
struct A x::Int end
struct B y::Int end
end
julia> a = AB'.A(1)
AB'.A(1)
julia> typeof(a)'[kindof(a)]
AB'.A
julia> variant_constructor(a)
AB'.A
```
"""
function variant_constructor end
"""
export_variants(T)
Export all variants types into the module the
function it is called into.
## Example
```julia
julia> @sum_structs AB begin
struct A x::Int end
struct B y::Int end
end
julia> AB'.A(1)
AB'.A(1)
julia> export_variants(AB)
julia> A(1) # now this also works
AB'.A(1)
```
"""
function export_variants end
"""
@pattern(function_definition)
This macro allows to pattern on types created by [`@sum_structs`](@ref).
Notice that this only works when the kinds in the macro are not wrapped
by any type containing them.
## Example
```julia
julia> @sum_structs AB begin
struct A x::Int end
struct B y::Int end
end
julia> @pattern f(::AB'.A) = 1;
julia> @pattern f(::AB'.B) = 2;
julia> @pattern f(::Vector{AB}) = 3; # this works
julia> @pattern f(::Vector{AB'.B}) = 3; # this doesn't work
ERROR: LoadError: It is not possible to dispatch on a variant wrapped in another type
...
julia> f(AB'.A(0))
1
julia> f(AB'.B(0))
2
julia> f([AB'.A(0), AB'.B(0)])
3
```
"""
macro pattern(f_def)
vtc = __variants_types_cache__[__module__]
vtwpc = __variants_types_with_params_cache__[__module__]
f_sub, f_super_dict, f_cache = _pattern(f_def, vtc, vtwpc)
if f_super_dict == nothing
return Expr(:toplevel, esc(f_sub))
end
if __module__ in __modules_cache__
is_first = false
else
is_first = true
push!(__modules_cache__, __module__)
end
if is_first
expr_m = quote
const __pattern_cache__ = Dict{Any, Any}()
const __finalized_methods_cache__ = Set{Expr}()
end
else
expr_m = :()
end
expr_d = :(DynamicSumTypes.define_f_super($(__module__), $(QuoteNode(f_super_dict)), $(QuoteNode(f_cache))))
expr_fire = quote
if isinteractive() && (@__MODULE__) == Main
DynamicSumTypes.@finalize_patterns
$(f_super_dict[:name])
end
end
return Expr(:toplevel, esc(f_sub), esc(expr_m), esc(expr_d), esc(expr_fire))
end
function _pattern(f_def, vtc, vtwpc)
macros = []
while f_def.head == :macrocall
f_def_comps = rmlines(f_def.args)
push!(macros, f_def.args[1])
f_def = f_def.args[end]
end
is_arg_no_name(s) = s isa Expr && s.head == :(::) && length(s.args) == 1
f_comps = ExprTools.splitdef(f_def; throw=true)
f_args = f_comps[:args]
f_args = [x isa Symbol ? :($x::Any) : x for x in f_args]
f_args_t = [is_arg_no_name(a) ? a.args[1] : a.args[2] for a in f_args]
f_args_n = [dotted_arg(a) for a in f_args_t]
idxs_mctc = findall(a -> a in values(vtc), f_args_n)
idxs_mvtc = findall(a -> a in keys(vtc), f_args_n)
f_args = [restructure_arg(f_args[i], i, idxs_mvtc) for i in 1:length(f_args)]
f_args_t = [is_arg_no_name(a) ? a.args[1] : a.args[2] for a in f_args]
for k in keys(vtc)
if any(a -> inexpr(a[2], k) && !(a[1] in idxs_mvtc), enumerate(f_args_t))
error("It is not possible to dispatch on a variant wrapped in another type")
end
end
if !isempty(idxs_mctc) && !isempty(idxs_mvtc)
error("Using `@pattern` with signatures containing sum types and variants at the same time is not supported")
end
if isempty(idxs_mvtc) && isempty(idxs_mctc)
return f_def, nothing, nothing
end
new_arg_types = [vtc[f_args_n[i]] for i in idxs_mvtc]
transform_name(v) = v isa Expr && v.head == :. ? v.args[2].value : v
is_variant_symbol(s, variant) = s isa Symbol && s == variant
whereparams = []
if :whereparams in keys(f_comps)
whereparams = f_comps[:whereparams]
end
f_args_name = Symbol[]
for i in idxs_mvtc
variant = f_args_n[i]
type = vtc[variant]
if f_args_t[i] isa Symbol
v = transform_name(variant)
f_args[i] = MacroTools.postwalk(s -> is_variant_symbol(s, v) ? type : s, f_args[i])
else
y, y_w = f_args_t[i], []
arg_abstract, type_abstract = vtwpc[f_args_n[i]]
type_abstract = deepcopy(type_abstract)
type_abstract_args = type_abstract.args[2:end]
arg_abstract = arg_abstract.args[2:end]
arg_abstract = [x isa Expr && x.head == :(<:) ? x.args[1] : x for x in arg_abstract]
pos_args = []
if y.head == :where
y_w = y.args[2:end]
y = y.args[1]
end
arg_concrete = y.args[2:end]
for x in arg_abstract[1:length(arg_concrete)]
j = findfirst(t -> t == x, type_abstract_args)
push!(pos_args, j)
end
pos_no_args = [i for i in 1:length(type_abstract_args)
if !(i in pos_args) && (
type_abstract_args[i] != :(DynamicSumTypes.Uninitialized) &&
type_abstract_args[i] != :(DynamicSumTypes.SumTypes.Uninit))]
@capture(y, _{t_params__})
for (p, q) in enumerate(pos_args)
type_abstract_args[q] = MacroTools.postwalk(s -> s isa Symbol && s == arg_abstract[p] ? arg_concrete[p] : s,
type_abstract_args[q])
end
idx = is_arg_no_name(f_args[i]) ? 1 : 2
ps = [y_w..., type_abstract_args[pos_no_args]...]
if !(isempty(ps))
f_args[i].args[idx] = :($(type_abstract.args[1]){$(type_abstract_args...)} where {$(ps...)})
else
f_args[i].args[idx] = :($(type_abstract.args[1]){$(type_abstract_args...)})
end
end
a = gensym(:argv)
f_args[i] = MacroTools.postwalk(s -> is_arg_no_name(s) ? (pushfirst!(s.args, a); s) : s, f_args[i])
push!(f_args_name, f_args[i].args[1])
end
for i in 1:length(f_args)
if f_args[i] isa Expr && f_args[i].head == :(::) && length(f_args[i].args) == 1
push!(f_args[i].args, gensym(:a))
f_args[i].args[1], f_args[i].args[2] = f_args[i].args[2], f_args[i].args[1]
end
end
g_args = deepcopy(f_args)
for i in 1:length(f_args)
a = Symbol("##argv#563487$i")
if !(g_args[i] isa Symbol)
g_args[i].args[1] = a
else
g_args[i] = a
end
end
g_args_names = Any[namify(a) for a in g_args]
if g_args[end] isa Expr && namify(g_args[end].args[2]) == :(Vararg)
g_args_names[end] = :($(g_args_names[end])...)
end
idx_and_variant0 = collect(zip(idxs_mvtc, map(i -> transform_name(f_args_n[i]), idxs_mvtc)))
idx_and_type = collect(zip(idxs_mctc, map(i -> f_args_n[i], idxs_mctc)))
all_types_args0 = idx_and_variant0 != [] ? sort(idx_and_variant0) : sort(idx_and_type)
all_types_args1 = sort(collect(zip(idxs_mvtc, map(i -> vtc[f_args_n[i]], idxs_mvtc))))
f_args_cache = deepcopy(f_args)
for i in eachindex(f_args_cache)
for p in whereparams
p_n = p isa Symbol ? p : p.args[1]
p_t = p isa Symbol ? :Any : (p.head == :(<:) ? p.args[2] : error())
if f_args_cache[i] isa Symbol
f_args_cache[i] = MacroTools.postwalk(s -> s isa Symbol && s == p_n ? p_t : s, f_args_cache[i])
else
f_args_cache[i] = MacroTools.postwalk(s -> s isa Symbol && s == p_n ? :(<:($p_t)) : s, f_args_cache[i])
end
i == length(f_args_cache) && (f_args_cache[i] = MacroTools.postwalk(s -> sub_vararg_any(s), f_args_cache[i]))
end
end
f_args_cache = map(MacroTools.splitarg, f_args_cache)
f_args_cache = [(x[2], x[3]) for x in f_args_cache]
f_cache = f_args_cache
f_sub_dict = define_f_sub(whereparams, f_comps, all_types_args0, f_args)
f_sub = ExprTools.combinedef(f_sub_dict)
f_super_dict = Dict{Symbol, Any}()
f_super_dict[:name] = f_comps[:name]
f_super_dict[:args] = g_args
a_cond = [:(DynamicSumTypes.kindof($(g_args[i].args[1])) === $(Expr(:quote, x))) for (i, x) in idx_and_variant0]
new_cond = nothing
if length(a_cond) == 1
new_cond = a_cond[1]
elseif length(a_cond) > 1
new_cond = Expr(:&&, a_cond[1], a_cond[2])
for x in a_cond[3:end]
new_cond = Expr(:&&, x, new_cond)
end
end
f_super_dict[:whereparams] = whereparams
f_super_dict[:kwargs] = :kwargs in keys(f_comps) ? f_comps[:kwargs] : []
f_super_dict[:macros] = macros
f_super_dict[:condition] = new_cond
f_super_dict[:subcall] = :(return $(f_sub_dict[:name])($(g_args_names...)))
f_sub_name_default = Symbol(Symbol("##"), f_comps[:name], :_, collect(Iterators.flatten(all_types_args1))...)
f_super_dict[:subcall_default] = :(return $(f_sub_name_default)($(g_args_names...)))
return f_sub, f_super_dict, f_cache
end
function dotted_arg(a)
while true
a isa Symbol && return a
a.head == :. && a.args[1] isa Expr && a.args[1].head == Symbol("'") && return a
a = a.args[1]
end
end
function restructure_arg(a, i, idxs_mvtc)
(!(i in idxs_mvtc) || a isa Symbol) && return a
return MacroTools.postwalk(s -> s isa Expr && s.head == :. ? s.args[2].value : s, a)
end
function sub_vararg_any(s)
s isa Symbol && return s
length(s.args) != 3 && return s
return s.args[1] == :(Vararg) && s.args[3] == :(<:Any) ? :Any : s
end
function define_f_sub(whereparams, f_comps, all_types_args0, f_args)
f_sub_dict = Dict{Symbol, Any}()
f_sub_name = Symbol(Symbol("##"), f_comps[:name], :_, collect(Iterators.flatten(all_types_args0))...)
f_sub_dict[:name] = f_sub_name
f_sub_dict[:args] = f_args
f_sub_dict[:kwargs] = :kwargs in keys(f_comps) ? f_comps[:kwargs] : []
f_sub_dict[:body] = f_comps[:body]
whereparams != [] && (f_sub_dict[:whereparams] = whereparams)
return f_sub_dict
end
function inspect_sig end
function define_f_super(mod, f_super_dict, f_cache)
f_name = f_super_dict[:name]
cache = mod.__pattern_cache__
if !(f_name in keys(cache))
cache[f_name] = Dict{Any, Any}(f_cache => [f_super_dict])
else
never_same = true
f_sig = Base.signature_type(mod.DynamicSumTypes.inspect_sig, Tuple(Base.eval(mod, :(tuple($(map(x -> x[1], f_cache)...))))))
for sig in keys(cache[f_name])
k_sig = Base.signature_type(mod.DynamicSumTypes.inspect_sig, Tuple(Base.eval(mod, :(tuple($(map(x -> x[1], sig)...))))))
same_sig = f_sig == k_sig
if same_sig
same_cond = findfirst(f_prev -> f_prev[:condition] == f_super_dict[:condition], cache[f_name][sig])
same_cond === nothing && push!(cache[f_name][sig], f_super_dict)
never_same = false
break
end
end
if never_same
cache[f_name][f_cache] = [f_super_dict]
end
end
end
function generate_defs(mod)
cache = mod.__pattern_cache__
return generate_defs(mod, cache)
end
function generate_defs(mod, cache)
defs = []
for f in keys(cache)
for ds in values(cache[f])
new_d = Dict{Symbol, Any}()
new_d[:args] = ds[end][:args]
new_d[:name] = ds[end][:name]
!allequal(d[:whereparams] for d in ds) && error("Parameters in where {...} should be the same for all @pattern methods with same signature")
new_d[:whereparams] = ds[end][:whereparams]
!allequal(d[:kwargs] for d in ds) && error("Keyword arguments should be the same for all @pattern methods with same signature")
new_d[:kwargs] = ds[end][:kwargs]
default = findfirst(d -> d[:condition] == nothing, ds)
subcall_default = nothing
if default != nothing
subcall_default = ds[default][:subcall]
ds[default], ds[end] = ds[end], ds[default]
end
body = nothing
if default != nothing && length(ds) == 1
body = subcall_default
else
body = Expr(:if, ds[1][:condition], ds[1][:subcall])
body_prev = body
for d in ds[2:end-(default != nothing)]
push!(body_prev.args, Expr(:elseif, d[:condition], d[:subcall]))
body_prev = body_prev.args[end]
end
f_end = ds[1][:subcall_default]
push!(body_prev.args, f_end)
end
new_d[:body] = quote $body end
new_df = mod.DynamicSumTypes.ExprTools.combinedef(new_d)
!allequal(d[:macros] for d in ds) && error("Applied macros should be the same for all @pattern methods with same signature")
for m in ds[end][:macros]
new_df = Expr(:macrocall, m, :(), new_df)
end
push!(defs, [new_df, ds[1][:subcall_default].args[1].args[1]])
end
end
return defs
end
"""
@finalize_patterns
Calling `@finalize_patterns` is needed to define at some
points all the functions `@pattern` constructed in that
module.
If you don't need to call any of them before the functions
are imported, you can just put a single invocation at the end of
the module.
"""
macro finalize_patterns()
quote
defs = DynamicSumTypes.generate_defs($__module__)
for (d, f_default) in defs
if d in $__module__.__finalized_methods_cache__
continue
else
!isdefined($__module__, f_default) && evaluate_func($__module__, :(function $f_default end))
push!($__module__.__finalized_methods_cache__, d)
$__module__.DynamicSumTypes.evaluate_func($__module__, d)
end
end
end
end
function evaluate_func(mod, d)
@eval mod $d
end
struct Uninitialized end
const uninit = Uninitialized()
"""
@sum_structs [version] type_definition begin
structs_definitions
end
This macro allows to combine multiple types in a single one.
The default version is `:on_fields` which has been built to yield
a performance almost identical to having just one type. Using
`:on_types` consumes less memory at the cost of being a bit slower.
## Example
```julia
julia> @sum_structs AB begin
struct A x::Int end
struct B y::Int end
end
julia> a = AB'.A(1)
AB'.A(1)
julia> a.x
1
```
"""
macro sum_structs(new_type, struct_defs)
@warn "@sum_structs is deprecated in v3 in favour of a much simpler methodology using @sumtype.
Please update your package to use that."
vtc = get!(__variants_types_cache__, __module__, Dict{Any, Any}())
vtwpc = get!(__variants_types_with_params_cache__, __module__, Dict{Any, Vector{Any}}())
return esc(_compact_structs(new_type, struct_defs, vtc, vtwpc))
end
function _compact_structs(new_type, struct_defs, vtc, vtwpc)
if new_type isa Expr && new_type.head == :(<:)
new_type, abstract_type = new_type.args
else
new_type, abstract_type = new_type, :(Any)
end
structs_specs = decompose_struct_base(struct_defs)
structs_specs_new = []
is_kws = []
for x in structs_specs
v1 = @capture(x, @kwdef d_)
v1 == false && (v2 = @capture(x, Base.@kwdef d_))
if d == nothing
push!(structs_specs_new, x)
push!(is_kws, false)
else
push!(structs_specs_new, d)
push!(is_kws, true)
end
end
structs_specs = structs_specs_new
is_mutable = []
for x in structs_specs
push!(is_mutable, x.args[1])
end
if !allequal(is_mutable)
return error("`@sum_structs :on_fields` does not accept mixing mutable and immutable structs.")
end
is_mutable = all(x -> x == true, is_mutable)
types_each, fields_each, default_each = [], [], []
for struct_spec in structs_specs
a_comps = decompose_struct_no_base(struct_spec)
push!(types_each, a_comps[1])
push!(fields_each, a_comps[2][1])
push!(default_each, a_comps[2][2])
end
common_fields = intersect(fields_each...)
all_fields = union(fields_each...)
all_fields_n = retrieve_fields_names(all_fields)
noncommon_fields = setdiff(all_fields, common_fields)
all_fields_transf = [transform_field(x, noncommon_fields) for x in all_fields]
gensym_type = gensym(:(_kind))
field_type = is_mutable ? Expr(:const, :($(gensym_type)::Symbol)) : (:($(gensym_type)::Symbol))
types_each_vis = types_each
types_each = [t isa Symbol ? Symbol("###", namify(new_type), "###", t) :
:($(Symbol("###", namify(new_type), "###", t.args[1])){$(t.args[2:end]...)})
for t in types_each]
expr_comp_types = [Expr(:struct, false, t, :(begin sdfnsdfsdfak() = 1 end)) for t in types_each]
type_name = new_type isa Symbol ? new_type : new_type.args[1]
type_no_constr = MacroTools.postwalk(s -> s isa Expr && s.head == :(<:) ? s.args[1] : s, new_type)
type_params = new_type isa Symbol ? [] : [x isa Expr && x.head == :(<:) ? x.args[1] : x for x in new_type.args[2:end]]
uninit_val = :(DynamicSumTypes.Uninitialized)
compact_t = MacroTools.postwalk(s -> s isa Expr && s.head == :(<:) ? make_union_uninit(s, type_name, uninit_val) : s, new_type)
expr_new_type = Expr(:struct, is_mutable, :($compact_t <: $abstract_type),
:(begin
$field_type
$(all_fields_transf...)
end))
expr_params_each = []
expr_functions = []
for (struct_t, kind_t, struct_f, struct_d, is_kw) in zip(types_each, types_each_vis, fields_each, default_each, is_kws)
struct_spec_n = retrieve_fields_names(struct_f)
struct_spec_n_d = [d != "#32872248308323039203329" ? Expr(:kw, n, d) : (:($n))
for (n, d) in zip(struct_spec_n, struct_d)]
f_params_kwargs = struct_spec_n_d
f_params_kwargs = Expr(:parameters, f_params_kwargs...)
f_params_args = struct_spec_n
f_params_args_with_T = retrieve_fields_names(struct_f, true)
@capture(new_type, new_type_n_{new_type_p__})
if new_type_p === nothing
new_type_n, new_type_p = new_type, []
end
new_type_p = [t isa Expr && t.head == :(<:) ? t.args[1] : t for t in new_type_p]
f_params_args_with_T = [!any(p -> inexpr(x, p), new_type_p) ? (x isa Symbol ? x : x.args[1]) : x
for x in f_params_args_with_T]
struct_spec_n2_d = [d != "#32872248308323039203329" ? Expr(:kw, n, d) : (:($n))
for (n, d) in zip(f_params_args_with_T, struct_d)]
f_params_kwargs_with_T = struct_spec_n2_d
f_params_kwargs_with_T = Expr(:parameters, f_params_kwargs_with_T...)
type = Symbol(string(namify(kind_t)))
f_inside_args = all_fields_n
conv_maybe = [x isa Symbol ? :() : x.args[2] for x in retrieve_fields_names(all_fields, true)]
f_inside_args_no_t = maybe_convert_fields(conv_maybe, f_inside_args, new_type_p, struct_spec_n)
f_inside_args2_no_t = maybe_convert_fields(conv_maybe, f_inside_args, new_type_p, struct_spec_n; with_params=true)
f_inside_args = [Expr(:quote, type), f_inside_args_no_t...]
f_inside_args2 = [Expr(:quote, type), f_inside_args2_no_t...]
@capture(struct_t, struct_t_n_{struct_t_p__})
struct_t_p === nothing && (struct_t_p = [])
struct_t_p_no_sup = [p isa Expr && p.head == :(<:) ? p.args[1] : p for p in struct_t_p]
struct_t_arg = struct_t_p_no_sup != [] ? :($struct_t_n{$(struct_t_p_no_sup...)}) : struct_t
new_type_p = [t in struct_t_p_no_sup ? t : (:(DynamicSumTypes.Uninitialized))
for t in new_type_p]
expr_function_kwargs = :()
expr_function_kwargs2 = :()
expr_function_args = :()
expr_function_args2 = :()
struct_t_p_in = [p for p in struct_t_p if any(x -> inexpr(x, p isa Expr && p.head == :(<:) ? p.args[1] : p), f_params_args_with_T)]
struct_t_p_in_no_sup = [p isa Expr && p.head == :(<:) ? p.args[1] : p for p in struct_t_p_in]
new_type_p_in = [t in struct_t_p_in_no_sup ? t : (:(DynamicSumTypes.Uninitialized))
for t in new_type_p]
push!(expr_params_each, :($new_type_n{$(new_type_p...)}))
if isempty(new_type_p)
expr_function_args = :(
function $(namify(struct_t))($(f_params_args...))
return $(namify(new_type))($(f_inside_args...))
end)
if is_kw
expr_function_kwargs = :(
function $(namify(struct_t))($f_params_kwargs)
return $(namify(new_type))($(f_inside_args...))
end)
end
else
expr_function_args = :(
function $(namify(struct_t))($(f_params_args_with_T...)) where {$(struct_t_p_in...)}
return $new_type_n{$(new_type_p_in...)}($(f_inside_args...))
end)
if !isempty(struct_t_p)
expr_function_args2 = :(function $(struct_t_arg)($(f_params_args...)) where {$(struct_t_p...)}
return $new_type_n{$(new_type_p...)}($(f_inside_args2...))
end)
end
if is_kw
expr_function_kwargs = :(
function $(namify(struct_t))($f_params_kwargs_with_T) where {$(struct_t_p_in...)}
return $new_type_n{$(new_type_p_in...)}($(f_inside_args...))
end)
if !isempty(struct_t_p)
expr_function_kwargs2 = :(
function $(struct_t_arg)($f_params_kwargs) where {$(struct_t_p...)}
return $new_type_n{$(new_type_p...)}($(f_inside_args2...))
end)
end
end
end
push!(expr_functions, expr_function_kwargs)
push!(expr_functions, expr_function_args)
push!(expr_functions, expr_function_kwargs2)
push!(expr_functions, expr_function_args2)
end
add_types_to_cache(type_name, types_each_vis, vtc)
add_types_params_to_cache(expr_params_each, types_each_vis, type_name, vtwpc)
expr_kindof = :(DynamicSumTypes.kindof(a::$(namify(new_type))) = getfield(a, $(Expr(:quote, gensym_type))))
expr_allkinds = []
expr_allkinds1 = :(DynamicSumTypes.allkinds(a::Type{$(namify(new_type))}) = $(Tuple(namify.(types_each_vis))))
push!(expr_allkinds, expr_allkinds1)
if namify(type_no_constr) !== type_no_constr
expr_allkinds2 = :(DynamicSumTypes.allkinds(a::Type{$type_no_constr} where {$(type_params...)}) = $(Tuple(namify.(types_each_vis))))
push!(expr_allkinds, expr_allkinds2)
end
branching_constructor = generate_branching_types(namify.(types_each_vis), [:(return $v) for v in namify.(types_each)])
expr_constructor = :(function DynamicSumTypes.variant_constructor(a::$(namify(new_type)))
kind = kindof(a)
$(branching_constructor...)
end)
expr_show = :(function Base.show(io::IO, a::$(namify(new_type)))
f_vals = [getfield(a, x) for x in fieldnames(typeof(a))[2:end] if getfield(a, x) != DynamicSumTypes.uninit]
vals = join([DynamicSumTypes.print_transform(x) for x in f_vals], ", ")
params = [x for x in typeof(a).parameters if x != DynamicSumTypes.Uninitialized]
if isempty(params)
print(io, $(namify(new_type)), "'.", string(kindof(a)), "($vals)")
else
print(io, $(namify(new_type)), "'.", string(kindof(a), "{", join(params, ", "), "}"), "($vals)")
end
end
)
expr_getprop = :(function Base.getproperty(a::$(namify(new_type)), s::Symbol)
f = getfield(a, s)
if f isa DynamicSumTypes.Uninitialized
return error(lazy"type $(kindof(a)) has no field $s")
end
return f
end)
if is_mutable
expr_setprop = :(function Base.setproperty!(a::$(namify(new_type)), s::Symbol, v)
f = getfield(a, s)
if f isa DynamicSumTypes.Uninitialized
return error(lazy"type $(kindof(a)) has no field $s")
end
setfield!(a, s, v)
end)
else
expr_setprop = :()
end
fields_each_symbol = [:(return $(Tuple(f))) for f in retrieve_fields_names.(fields_each)]
branching_propnames = generate_branching_types(namify.(types_each_vis), fields_each_symbol)
expr_propnames = :(function Base.propertynames(a::$(namify(new_type)))
kind = kindof(a)
$(branching_propnames...)
$(fields_each_symbol[end])
end)
expr_copy = :(function Base.copy(a::$(namify(new_type)))
A = typeof(a)
return A((getfield(a, x) for x in fieldnames(A))...)
end)
expr_adjoint = :(Base.adjoint(::Type{<:$(namify(new_type))}) =
$NamedTuple{$(Expr(:tuple, QuoteNode.(namify.(types_each_vis))...))}($(Expr(:tuple, namify.(types_each)...))))
fake_prints = [:($Base.show(io::IO, ::MIME"text/plain", T::Type{<:$(namify(fn))}) = print(io, $(string(namify(new_type), "'.", namify(v)))))
for (fn, v) in zip(types_each, types_each_vis)]
expr_exports = def_export_variants(new_type)
expr = quote
$(expr_comp_types...)
$(fake_prints...)
$(Base.@__doc__ expr_new_type)
$(expr_functions...)
$(expr_kindof)
$(expr_allkinds...)
$(expr_getprop)
$(expr_setprop)
$(expr_propnames)
$(expr_copy)
$(expr_constructor)
$(expr_show)
$(expr_adjoint)
$(expr_exports)
nothing
end
return expr
end
function decompose_struct_base(struct_repr)
@capture(struct_repr, begin new_fields__ end)
return new_fields
end
function decompose_struct_no_base(struct_repr, split_default=true)
@capture(struct_repr, struct new_type_ new_fields__ end)
new_fields == nothing && @capture(struct_repr, mutable struct new_type_ new_fields__ end)
if split_default
new_fields_with_defs = [[], []]
for f in new_fields
if !@capture(f, const t_ = k_)
if !@capture(f, t_ = k_)
@capture(f, t_)
k = "#32872248308323039203329"
end
end
push!(new_fields_with_defs[1], t)
push!(new_fields_with_defs[2], k)
end
new_fields = new_fields_with_defs
end
return new_type, new_fields
end
function maybe_convert_fields(conv_maybe, f_inside_args, new_type_p, struct_spec_n; with_params=false)
f_inside_args_new = []
i = 1
for f in f_inside_args
if f in struct_spec_n
t = conv_maybe[i]
if (with_params || !any(p -> inexpr(t, p), new_type_p)) && t != :()
new_f = :(Base.convert($t, $f))
else
new_f = f
end
else
new_f = :(DynamicSumTypes.uninit)
end
i += 1
push!(f_inside_args_new, new_f)
end
return f_inside_args_new
end
function retrieve_fields_names(fields, only_consts = false)
field_names = []
for f in fields
if f isa Symbol
push!(field_names, f)
else
f.head == :const && (f = f.args[1])
!only_consts && (f = namify(f))
push!(field_names, f)
end
end
return field_names
end
function generate_branching_types(variants_types, res)
if !(res isa Vector)
res = repeat([res], length(variants_types))
end
branchs = [Expr(:if, :(kind === $(Expr(:quote, variants_types[1]))), res[1])]
for i in 2:length(variants_types)
push!(branchs, Expr(:elseif, :(kind === $(Expr(:quote, variants_types[i]))), res[i]))
end
push!(branchs, :(error("unreacheable")))
return branchs
end
function transform_field(x, noncommon_fields)
x isa Symbol && return x
const_x = x.head == :const
if const_x
x_args = x.args[1]
else
x_args = x
end
if x_args isa Symbol
return x
else
if x in noncommon_fields
name, T = x_args.args
f = :($name::Union{DynamicSumTypes.Uninitialized, $T})
if const_x
f = Expr(:const, f)
end
return f
else
return x
end
end
end
function add_types_to_cache(type, variants, vtc)
type = namify(type)
variants = namify.(variants)
for v in variants
vtc[:(($type)'.$v)] = type
end
end
function add_types_params_to_cache(params, variants, type, vtwpc)
type = namify(type)
variants_n = namify.(variants)
for (v1, v2, p) in zip(variants, variants_n, params)
vtwpc[:(($type)'.$v2)] = [v1, p]
end
end
function def_export_variants(type)
t = namify(type)
return quote
function DynamicSumTypes.export_variants(T::Type{<:$t})
Ts = $(QuoteNode(t))
vtc = DynamicSumTypes.__variants_types_cache__[@__MODULE__]
vtwpc = DynamicSumTypes.__variants_types_with_params_cache__[@__MODULE__]
for V in allkinds(T)
eval(:(const $V = ($(Ts))'.$V))
for k in collect(keys(vtc))
b = DynamicSumTypes.MacroTools.inexpr(k, :(($Ts)'))
b == true && (vtc[V] = vtc[k])
end
for k in collect(keys(vtwpc))
b = DynamicSumTypes.MacroTools.inexpr(k, :(($Ts)'))
b == true && (vtwpc[k.args[2].value] = vtwpc[k])
end
end
end
end
end
macro sum_structs(version, type, struct_defs)
return esc(:(DynamicSumTypes.@sum_structs $type $struct_defs))
end
function print_transform(x)
x isa String && return "\"$x\""
x isa Symbol && return QuoteNode(x)
return x
end
function make_union_uninit(s, type_name, uninit_val)
s.args[1] == type_name && return s
s.args[2] = :(Union{$(s.args[2]), $uninit_val})
return s
end
| DynamicSumTypes | https://github.com/JuliaDynamics/DynamicSumTypes.jl.git |
|
[
"MIT"
] | 3.7.5 | 8836d8846919670cec877e4002d972c23e9dde29 | code | 123 |
using Aqua
@testset "Code quality" begin
Aqua.test_all(DynamicSumTypes, ambiguities = true, unbound_args = true)
end
| DynamicSumTypes | https://github.com/JuliaDynamics/DynamicSumTypes.jl.git |
|
[
"MIT"
] | 3.7.5 | 8836d8846919670cec877e4002d972c23e9dde29 | code | 158 |
using Test
using DynamicSumTypes
@testset "DynamicSumTypes.jl Tests" begin
include("package_sanity_tests.jl")
include("sumtype_macro_tests.jl")
end
| DynamicSumTypes | https://github.com/JuliaDynamics/DynamicSumTypes.jl.git |
|
[
"MIT"
] | 3.7.5 | 8836d8846919670cec877e4002d972c23e9dde29 | code | 4112 |
struct ST1 end
@sumtype SingleT1(ST1)
Base.copy(x::ST1) = ST1()
@kwdef mutable struct F{X<:Integer}
a::Tuple{X, X}
b::Tuple{Float64, Float64}
const c::Symbol
end
@kwdef mutable struct G{X}
a::Tuple{X, X}
d::Int
e::Int
const c::Symbol
end
@kwdef mutable struct H{X,Y<:Real}
a::Tuple{X, X}
f::Y
g::Tuple{Complex, Complex}
const c::Symbol
end
abstract type AbstractE end
@sumtype E(F,G,H) <: AbstractE
@sumtype FF(F{Int32}, F{Int64})
@kwdef mutable struct Wolf{T,N}
energy::T = 0.5
ground_speed::N
const fur_color::Symbol
end
@kwdef mutable struct Hawk{T,N,J}
energy::T = 0.1
ground_speed::N
flight_speed::J
end
@sumtype Animal(Wolf, Hawk)
abstract type AbstractSimple end
struct SimpleA
x
z::Int
end
struct SimpleB
y
q::String
end
@sumtype Simple(SimpleA, SimpleB) <: AbstractSimple
struct Some{T}
val::T
end
struct None end
@sumtype Option{T}(None, Some{T})
@testset "@sumtype" begin
st = SingleT1(ST1())
@test propertynames(st) == ()
@test copy(st) == st
f = E(F((1,1), (1.0, 1.0), :s))
g1 = E(G((1,1), 1, 1, :c))
g2 = E(G(; a = (1,1), d = 1, e = 1, c = :c))
g3 = E'.G((1,1), 1, 1, :c)
g4 = E'.G(; a = (1,1), d = 1, e = 1, c = :c)
h = E(H((1,1), 1, (im, im), :j))
@test_throws "" eval(:(@sumtype Z.E))
@test_throws "" E(F((1.0,1.0), (1.0, 1.0), :s))
@test_throws "" E(G((1,1), im, (im, im), :d))
@test_throws "" E(G((im,im), 1, (im, im), :d))
@test f.a == (1,1)
@test f.b == (1.0, 1.0)
@test f.c == :s
@test g1.d === g2.d === 1
@test g1.e === g2.e === 1
@test hasproperty(g1, :e) == true
@test hasproperty(g1, :w) == false
@test is_sumtype(typeof(g1)) == true
@test is_sumtype(G) == false
@test variantof(g1) == G{Int}
f.a = (3, 3)
@test f.a == (3, 3)
@test variant(f) isa F
@test propertynames(f) == (:a, :b, :c)
@test allvariants(E) == allvariants(typeof(f)) == (F = F, G = G, H = H)
ff1 = FF(F((1,1), (1.0, 1.0), :s))
ff2 = FF(F((Int32(1),Int32(1)), (1.0, 1.0), :s))
@test allvariants(FF) == (F_Int32 = F{Int32}, F_Int64 = F{Int64})
hawk_1 = Animal(Hawk(1.0, 2.0, 3))
hawk_2 = Animal(Hawk(; ground_speed = 2.3, flight_speed = 2))
wolf_1 = Animal(Wolf(2.0, 3.0, :black))
wolf_2 = Animal(Wolf(; ground_speed = 2.0, fur_color = :white))
wolf_3 = Animal(Wolf{Int, Float64}(2.0, 3.0, :black))
wolf_4 = Animal(Wolf{Float64, Float64}(; ground_speed = 2.0, fur_color = :white))
@test hawk_1.energy == 1.0
@test hawk_2.energy == 0.1
@test wolf_1.energy == 2.0
@test wolf_2.energy == 0.5
@test wolf_3.energy === 2 && wolf_4.energy === 0.5
@test hawk_1.flight_speed == 3
@test hawk_2.flight_speed == 2
@test wolf_1.fur_color == :black
@test wolf_2.fur_color == :white
@test_throws "" hawk_1.fur_color
@test_throws "" wolf_1.flight_speed
@test variant(hawk_1) isa Hawk
@test variant(wolf_1) isa Wolf
@test allvariants(Animal) == allvariants(typeof(wolf_3)) == (Wolf = Wolf, Hawk = Hawk)
b = Simple(SimpleA(1, 3))
c = Simple(SimpleB(2, "a"))
@test b.x == 1 && b.z == 3
@test c.y == 2 && c.q == "a"
@test_throws "" b.y
@test_throws "" b.q
@test_throws "" c.x
@test_throws "" c.z
@test variant(b) isa SimpleA
@test variant(c) isa SimpleB
@test Simple <: AbstractSimple
@test b isa Simple && c isa Simple
@test allvariants(Simple) == allvariants(typeof(b)) == (SimpleA = SimpleA, SimpleB = SimpleB)
option_none = Option{Int}(None())
option_none2 = Option{Int}'.None()
option_some = Option(Some(1))
option_some2 = Option{Int}(Some(1))
option_some3 = Option{Int}'.Some(1)
option_some4 = Option'.Some(1)
@test variant(option_none) isa None
@test variant(option_some) isa Some{Int}
@test variant(option_some2) isa Some{Int}
@test variant(option_some3) isa Some{Int}
@test variant(option_some4) isa Some{Int}
@test allvariants(Option) == (None = None, Some = Some)
@test option_some.val == 1
end
| DynamicSumTypes | https://github.com/JuliaDynamics/DynamicSumTypes.jl.git |
|
[
"MIT"
] | 3.7.5 | 8836d8846919670cec877e4002d972c23e9dde29 | docs | 7014 | # DynamicSumTypes.jl
[](https://github.com/JuliaDynamics/DynamicSumTypes.jl/actions?query=workflow%3ACI)
[](https://juliadynamics.github.io/DynamicSumTypes.jl/stable/)
[](https://codecov.io/gh/JuliaDynamics/DynamicSumTypes.jl)
[](https://github.com/JuliaTesting/Aqua.jl)
[](https://zenodo.org/doi/10.5281/zenodo.12826686)
This package allows to combine multiple heterogeneous types in a single one. This helps to write
type-stable code by avoiding `Union` performance drawbacks when many types are unionized. Another
aim of this library is to provide a syntax as similar as possible to standard Julia
structs to facilitate its integration within other libraries.
The `@sumtype` macro takes inspiration from [SumTypes.jl](https://github.com/MasonProtter/SumTypes.jl),
but it offers a much more simple and idiomatic interface. Working with it is almost like working with `Union` types.
## Definition
To define a sum type you can just take an arbitrary number of types and enclose them in it
like so:
```julia
julia> using DynamicSumTypes
julia> abstract type AbstractS end
julia> struct A{X}
x::X
end
julia> mutable struct B{Y}
y::Y
end
julia> struct C
z::Int
end
julia> @sumtype S{X}(A{X},B{Int},C) <: AbstractS
```
## Construction
Then constructing instances is just a matter of enclosing the type constructed in the
predefined sum type:
```julia
julia> a = S(A(1))
S{Int64}(A{Int64}(1))
julia> b = S{Int}(B(1))
S{Int64}(B{Int64}(1))
julia> c = S{Int}(C(1))
S{Int64}(C(1))
```
a different syntax is also provided for convenience:
```julia
julia> a = S'.A(1)
S{Int64}(A{Int64}(1))
julia> b = S{Int}'.B(1)
S{Int64}(B{Int64}(1))
julia> c = S{Int}'.C(1)
S{Int64}(C(1))
```
## Access and Mutation
This works like if they were normal Julia types:
```julia
julia> a.x
1
julia> b.y = 3
3
```
## Dispatch
For this, you can simply access the variant
inside the sum type and then dispatch on it:
```julia
julia> f(x::S) = f(variant(x))
julia> f(x::A) = 1
julia> f(x::B) = 2
julia> f(x::C) = 3
julia> f(a)
1
julia> f(b)
2
julia> f(c)
3
```
## Micro-benchmarks
<details>
<summary>Benchmark code</summary>
```julia
using BenchmarkTools
using DynamicSumTypes
struct A end
struct B end
struct C end
struct D end
struct E end
struct F end
@sumtype S(A, B, C, D, E, F)
f(s::S) = f(variant(s));
f(::A) = 1;
f(::B) = 2;
f(::C) = 3;
f(::D) = 4;
f(::E) = 5;
f(::F) = 6;
vals = rand((A(), B(), C(), D(), E(), F()), 1000);
tuple_manytypes = Tuple(vals);
vec_manytypes = collect(Union{A, B, C, D, E, F}, vals);
iter_manytypes = (x for x in vec_manytypes);
tuple_sumtype = Tuple(S.(vals));
vec_sumtype = S.(vals);
iter_sumtype = (x for x in vec_sumtype)
@benchmark sum($f, $tuple_manytypes)
@benchmark sum($f, $tuple_sumtype)
@benchmark sum($f, $vec_manytypes)
@benchmark sum($f, $vec_sumtype)
@benchmark sum($f, $iter_manytypes)
@benchmark sum($f, $iter_sumtype)
```
</details>
```julia
julia> @benchmark sum($f, $tuple_manytypes)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 81.092 μs … 1.267 ms ┊ GC (min … max): 0.00% … 90.49%
Time (median): 85.791 μs ┊ GC (median): 0.00%
Time (mean ± σ): 87.779 μs ± 18.802 μs ┊ GC (mean ± σ): 0.35% ± 1.67%
▂ ▃▇█▆▆▅▃▂▂▂▁▁ ▂
█████████████████▇▇▇▅▆▅▄▅▅▅▄▄▄▄▄▄▅▄▄▄▄▄▄▄▃▄▅▅▄▃▅▄▅▅▅▄▅▅▄▅▅▅ █
81.1 μs Histogram: log(frequency) by time 130 μs <
Memory estimate: 13.42 KiB, allocs estimate: 859.
julia> @benchmark sum($f, $tuple_sumtype)
BenchmarkTools.Trial: 10000 samples with 107 evaluations.
Range (min … max): 770.514 ns … 4.624 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 823.514 ns ┊ GC (median): 0.00%
Time (mean ± σ): 826.188 ns ± 42.968 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█ ▁ ▂ ▂
▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▇▂█▃██▃█▅█▄▂██▂█▅▃▃▂▂▃▂▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ ▃
771 ns Histogram: frequency by time 900 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark sum($f, $vec_manytypes)
BenchmarkTools.Trial: 10000 samples with 207 evaluations.
Range (min … max): 367.164 ns … 566.816 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 389.280 ns ┊ GC (median): 0.00%
Time (mean ± σ): 390.919 ns ± 9.984 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▁ ▇▁ ▃ ▁ █ ▂
▂▂▃▂▁▁▂▁▁▂▂▁▂▂▄█▃██▃█▃▄█▂█▇▃█▅▃█▃▃▃▂▃▂▂▃▂▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ ▃
367 ns Histogram: frequency by time 424 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark sum($f, $vec_sumtype)
BenchmarkTools.Trial: 10000 samples with 254 evaluations.
Range (min … max): 297.016 ns … 464.575 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 308.811 ns ┊ GC (median): 0.00%
Time (mean ± σ): 306.702 ns ± 7.518 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▁ ▆█▅ ▅█▆▁▁▅▄ ▂▂ ▁ ▁▄▄▁ ▂▁ ▂
▇██████▇▅▅▄▅▅▄▄▄▃▄▄▅▅▅▆████████▇▆██▆▅▇██▅███████▇██▇▃▄▅▆▅▅▄▃▅ █
297 ns Histogram: log(frequency) by time 326 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark sum($f, $iter_manytypes)
BenchmarkTools.Trial: 10000 samples with 10 evaluations.
Range (min … max): 1.323 μs … 3.407 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 1.390 μs ┊ GC (median): 0.00%
Time (mean ± σ): 1.389 μs ± 54.987 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▅▄▁▂ ▃█▇▇
▃▄▆████▅▄▇████▆▇▆▅▄▄▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▁▂▁▂▂▂▂▁▁▂▂▁▂▂▂▂▂▂▂▂▂ ▃
1.32 μs Histogram: frequency by time 1.67 μs <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark sum($f, $iter_sumtype)
BenchmarkTools.Trial: 10000 samples with 258 evaluations.
Range (min … max): 310.236 ns … 370.112 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 318.971 ns ┊ GC (median): 0.00%
Time (mean ± σ): 319.347 ns ± 5.859 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▁ ▄▇▆▁▃▆█▃ ▃▆▅ ▄▆▄ ▃▆▇▃▁▄▇▇▃▁▂▅▄▁ ▁▂▁ ▁ ▁▁ ▁ ▃
▅█▂▆████████▇███▅███████████████████▇██████████████████▇▅█▆▇▅ █
310 ns Histogram: log(frequency) by time 338 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
```
<sub>*These benchmarks have been run on Julia 1.11*</sub>
## Contributing
Contributions are welcome! If you encounter any issues, have suggestions for improvements, or would like to add new
features, feel free to open an issue or submit a pull request.
| DynamicSumTypes | https://github.com/JuliaDynamics/DynamicSumTypes.jl.git |
|
[
"MIT"
] | 3.7.5 | 8836d8846919670cec877e4002d972c23e9dde29 | docs | 70 | # API
```@docs
@sumtype
variant
allvariants
variantof
is_sumtype
```
| DynamicSumTypes | https://github.com/JuliaDynamics/DynamicSumTypes.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 1434 | # Case insensitive Dict - a simple wrapper over Dict
struct CIDict{K, T}
dct::Dict{K, T}
# type checking
check(K) = K <: AbstractString || K <: Symbol ||
throw(ArgumentError("Key must be Symbol or String type"))
# constructors
CIDict{K, T}() where {K,T} = (check(K); new(Dict{K,T}()))
CIDict{K, T}(d::Dict{K,T}) where {K,T} = begin
check(K)
d2 = Dict{K,T}()
for k in keys(d)
d2[lcase(k)] = d[k]
end
new(d2)
end
end
lcase(s::Symbol) = Symbol(lowercase(String(s)))
lcase(s::AbstractString) = lowercase(s)
Base.getindex(d::CIDict, s::Symbol) = d.dct[lcase(s)]
Base.getindex(d::CIDict, s::String) = d.dct[lcase(s)]
Base.setindex!(d::CIDict, v, s::Symbol) = d.dct[lcase(s)] = v
Base.setindex!(d::CIDict, v, s::String) = d.dct[lcase(s)] = v
Base.haskey(d::CIDict, s::Symbol) = haskey(d.dct, lcase(s))
Base.haskey(d::CIDict, s::String) = haskey(d.dct, lcase(s))
Base.keys(d::CIDict) = keys(d.dct)
Base.values(d::CIDict) = values(d.dct)
Base.iterate(d::CIDict) = Base.iterate(d.dct)
Base.iterate(d::CIDict, state) = Base.iterate(d.dct, state)
Base.length(d::CIDict) = length(d.dct)
issym(x) = typeof(x) == Symbol
function Base.show(io::IO, d::SASLib.CIDict)
print(io, "CIDict(")
for (i, (k,v)) in enumerate(d.dct)
i > 1 && print(io, ", ")
print(io, issym(k) ? ":" : "", k, " => ", v)
end
print(io, ")")
end
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 2509 | export metadata
"""
Metadata contains information about a SAS data file.
*Fields*
- `filename`: file name/path of the SAS data set
- `encoding`: file encoding e.g. "ISO8859-1"
- `endianness`: either `:LittleEndian`` or `:BigEndian`
- `compression`: could be `:RLE`, `:RDC`, or `:none`
- `pagesize`: size of each data page in bytes
- `npages`: number of pages in the file
- `nrows`: number of data rows in the file
- `ncols`: number of data columns in the file
- `columnsinfo`: vector of column symbols and their respective types
"""
struct Metadata
filename::AbstractString
encoding::AbstractString # e.g. "ISO8859-1"
endianness::Symbol # :LittleEndian, :BigEndian
compression::Symbol # :RDC, :RLE
pagesize::Int
npages::Int
nrows::Int
ncols::Int
columnsinfo::Vector{Pair{Symbol, Type}}
end
"""
Return metadata of a SAS data file. See `SASLib.Metadata`.
"""
function metadata(fname::AbstractString)
h = nothing
try
h = SASLib.open(fname, verbose_level = 0)
rs = read(h, 1)
_metadata(h, rs)
finally
h !== nothing && SASLib.close(h)
end
end
# construct Metadata struct using handler & result set data
function _metadata(h::Handler, rs::ResultSet)
cmp = h.compression == compression_method_rle ?
:RLE : (h.compression == compression_method_rdc ? :RDC : :none)
Metadata(
h.config.filename,
h.file_encoding,
h.file_endianness,
cmp,
h.page_length,
h.page_count,
h.row_count,
h.column_count,
[Pair(x, eltype(rs[x])) for x in names(rs)]
)
end
# pretty print
function Base.show(io::IO, md::Metadata)
println(io, "File: ", md.filename, " (", md.nrows, " x ", md.ncols, ")")
displaytable(io, colfmt(md); index=true)
end
# Column display format
function colfmt(md::Metadata)
[string(first(p), "(", typesfmt(typesof(last(p))),
")") for p in md.columnsinfo]
end
# Compact types format
# e.g. (Date, Missing) => "Date/Missing"
function typesfmt(ty::Tuple; excludemissing = false)
ar = excludemissing ?
collect(Iterators.filter(x -> x != Missing, ty)) : [ty...]
join(string.(ar), "/")
end
# Extract types from a Union
# e.g.
# Union{Int64, Int32, Float32} => (Int64, Int32, Float32)
# Int32 => (Int32,)
function typesof(ty::Type)
if ty isa Union
y = typesof(ty.b)
y isa Tuple ? (ty.a, y...) : (ty.a, y)
else
(ty,)
end
end
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 3743 | """
ObjectPool is a fixed-size one-dimensional array that does not store
any duplicate copies of the same object. So the benefit is space-efficiency.
The tradeoff is the time used to maintain the index.
This is useful for denormalized data frames where string values
may be repeated many times.
An ObjectPool must be initialize with a default value and a fixed
array size. If your requirement does not fit such assumptions,
you may want to look into using `PooledArrays` or
`CategoricalArrays` package instead.
The implementation is very primitive and is tailor for application
that knows exactly how much memory to allocate.
"""
mutable struct ObjectPool{T, S <: Unsigned} <: AbstractArray{T, 1}
pool::Array{T} # maintains the pool of unique things
idx::Array{S} # index references into `pool`
indexcache::Dict{T, S} # dict for fast lookups (K=object, V=index)
uniqueitemscount::Int64 # how many items in `pool`, always start with 1
itemscount::Int64 # how many items perceived in this array
capacity::Int64 # max number of items in the pool
end
# Initially, there is only one item in the pool and the `idx` array has
# elements all pointing to that one default vaue. The dictionary `indexcache`
# also has one item that points to that one value. Hence `uniqueitemcount`
# would be 1 and `itemscount` would be `n`.
function ObjectPool{T, S}(val::T, n::Integer) where {T, S <: Unsigned}
# Note: 64-bit case is constrainted by Int64 type (for convenience)
maxsize = ifelse(S == UInt8, 2 << 7 - 1,
ifelse(S == UInt16, 2 << 15 - 1,
ifelse(S == UInt32, 2 << 31 - 1,
2 << 62 - 1)))
ObjectPool{T, S}([val], fill(1, n), Dict(val => 1), 1, n, maxsize)
end
# If the value already exist in the pool then just the index value is stored.
function Base.setindex!(op::ObjectPool, val::T, i::Integer) where T
if haskey(op.indexcache, val)
# The value `val` already exists in the cache.
# Just set the array element to the index value from cache.
op.idx[i] = op.indexcache[val]
else
if op.uniqueitemscount >= op.capacity
throw(BoundsError("Exceeded pool capacity $(op.capacity). Consider using a larger pool size e.g. UInt32."))
end
# Encountered a new value `val`:
# 1. add ot the object pool array
# 2. increment the number of unique items
# 3. store the new index in the cache
# 4. set the array element with the new index value
push!(op.pool, val)
op.uniqueitemscount += 1
op.indexcache[val] = op.uniqueitemscount
op.idx[i] = op.uniqueitemscount
end
op
end
# AbstractArray trait
# Base.IndexStyle(::Type{<:ObjectPool}) = IndexLinear()
# single indexing
Base.getindex(op::ObjectPool, i::Integer) = op.pool[op.idx[convert(Int, i)]]
# general sizes
Base.size(op::ObjectPool) = (op.itemscount, )
# Base.length(op::ObjectPool) = op.itemscount
# Base.endof(op::ObjectPool) = op.itemscount
# typing
#Base.eltype(op::ObjectPool) = eltype(op.pool)
# make it iterable
# Base.start(op::ObjectPool) = 1
# Base.next(op::ObjectPool, state) = (op.pool[op.idx[state]], state + 1)
# Base.done(op::ObjectPool, state) = state > op.itemscount
# custom printing
# function Base.show(io::IO, op::ObjectPool)
# L = op.itemscount
# print(io, "$L-element ObjectPool with $(op.uniqueitemscount) unique items:\n")
# if L > 20
# for i in 1:10 print(io, " ", op[i], "\n") end
# print(io, " ⋮\n")
# for i in L-9:L print(io, " ", op[i], "\n") end
# else
# for i in 1:L print(io, " ", op[i], "\n") end
# end
# end
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 3932 | #using IteratorInterfaceExtensions, TableTraits, TableTraitsUtils
"""
ResultSet is the primary object that represents data returned from
reading a SAS data file. ResultSet implements the Base.Iteration
interface as well as the IterableTables.jl interface.
*Fields*
- `columns`: a vector of columns, each being a vector itself
- `names`: a vector of column symbols
- `size`: a tuple (nrows, ncols)
*Accessors*
- `columns(::ResultSet)`
- `names(::ResultSet)`
- `size(::ResultSet)`
- `size(::ResultSet, dim::Integer)`
*Single Row/Column Indexing*
- `rs[i]` returns a tuple for row `i`
- `rs[:c]` returns a vector for column `c`
*Multiple Row/Column Indexing*
- `rs[i:j]` returns a view of ResultSet with rows between `i` and `j`
- `rs[:c...]` returns a view of ResultSet with columns specified e.g. `rs[:A, :B]`
*Cell Indexing*
- `rs[i,j]` returns a single value for row `i` column `j`
- `rs[i,:c]` returns a single value for row `i` column `c`
- Specific cell can be assigned using the above indexing methods
"""
struct ResultSet
columns::AbstractVector{AbstractVector}
names::AbstractVector{Symbol}
size::NTuple{2, Int}
ResultSet() = new([], [], (0,0)) # special case
ResultSet(c,n,s) = new(c, n, s)
end
# exports
export columns
# accessors
columns(rs::ResultSet) = getfield(rs, :columns)
Base.names(rs::ResultSet) = getfield(rs, :names)
Base.size(rs::ResultSet) = getfield(rs, :size)
Base.size(rs::ResultSet, i::Integer) = getfield(rs, :size)[i]
Base.length(rs::ResultSet) = getfield(rs, :size)[1]
# Size displayed as a string
sizestr(rs::ResultSet) = string(size(rs, 1)) * " rows x " * string(size(rs, 2)) * " columns"
# find index for the column symbol
function symindex(rs::ResultSet, s::Symbol)
n = findfirst(x -> x == s, names(rs))
n == 0 && error("column symbol not found: $s")
n
end
# Direct cell access
Base.getindex(rs::ResultSet, i::Integer, j::Integer) = columns(rs)[j][i]
Base.getindex(rs::ResultSet, i::Integer, s::Symbol) = columns(rs)[symindex(rs, s)][i]
Base.setindex!(rs::ResultSet, val, i::Integer, j::Integer) = columns(rs)[j][i] = val
Base.setindex!(rs::ResultSet, val, i::Integer, s::Symbol) = columns(rs)[symindex(rs, s)][i] = val
# Return a single row as a named tuple
Base.getindex(rs::ResultSet, i::Integer) =
NamedTuple{Tuple(names(rs))}([c[i] for c in columns(rs)])
# Return a single column
Base.getindex(rs::ResultSet, c::Symbol) = columns(rs)[symindex(rs, c)]
# index by row range => returns ResultSet object
function Base.getindex(rs::ResultSet, r::UnitRange{Int})
ResultSet(map(x -> view(x, r), columns(rs)), names(rs), (length(r), size(rs, 2)))
end
# index by columns => returns ResultSet object
function Base.getindex(rs::ResultSet, ss::Symbol...)
v = Int[]
for (idx, nam) in enumerate(names(rs))
nam in ss && push!(v, idx)
end
ResultSet(columns(rs)[v], names(rs)[v], (size(rs, 1), length(v)))
end
# Each property must represent a column to satisfy Tables.jl Columns interface
Base.propertynames(rs::ResultSet) = names(rs)
function Base.getproperty(rs::ResultSet, s::Symbol)
s ∈ names(rs) && return rs[s]
error("Column $s not found")
end
# Iterators
Base.iterate(rs::ResultSet, i=1) = i > size(rs,1) ? nothing : (rs[i], i+1)
# Display ResultSet object
function Base.show(io::IO, rs::ResultSet)
println(io, "SASLib.ResultSet (", sizestr(rs), ")")
max_rows = 5
max_cols = 10
n = min(size(rs, 1), max_rows)
m = min(size(rs, 2), max_cols)
(n < 1 || m < 1) && return
print(io, "Columns ")
for i in 1:m
i > 1 && print(io, ", ")
print(io, i, ":", names(rs)[i])
end
m < length(names(rs)) && print(io, " …")
println(io)
for i in 1:n
print(io, i, ": ")
for j in 1:m
j > 1 && print(io, ", ")
print(io, columns(rs)[j][i])
end
println(io)
end
n < size(rs, 1) && println(io, "⋮")
end
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 68455 | module SASLib
using StringEncodings
using TabularDisplay
using Tables
using Dates
import IteratorInterfaceExtensions, TableTraits
export readsas, REGULAR_STR_ARRAY
import Base: show, size
include("constants.jl")
include("utils.jl")
include("ObjectPool.jl")
include("CIDict.jl")
include("Types.jl")
include("ResultSet.jl")
include("Metadata.jl")
include("tables.jl")
function _open(config::ReaderConfig)
# println("Opening $(config.filename)")
handler = Handler(config)
init_handler(handler)
read_header(handler)
read_file_metadata(handler)
populate_column_names(handler)
check_user_column_types(handler)
read_first_page(handler)
return handler
end
"""
open(filename::AbstractString;
encoding::AbstractString = "",
convert_dates::Bool = true,
include_columns::Vector = [],
exclude_columns::Vector = [],
string_array_fn::Dict = Dict(),
number_array_fn::Dict = Dict(),
column_types::Dict = Dict{Symbol,Type}(),
verbose_level::Int64 = 1)
Open a SAS7BDAT data file. Returns a `SASLib.Handler` object that can be used in
the subsequent `SASLib.read` and `SASLib.close` functions.
"""
function open(filename::AbstractString;
encoding::AbstractString = "",
convert_dates::Bool = true,
include_columns::Vector = [],
exclude_columns::Vector = [],
string_array_fn::Dict = Dict(),
number_array_fn::Dict = Dict(),
column_types::Dict = Dict{Symbol,Type}(),
verbose_level::Int64 = 1)
return _open(ReaderConfig(filename, encoding, default_chunk_size, convert_dates,
include_columns, exclude_columns, string_array_fn, number_array_fn,
column_types, verbose_level))
end
"""
read(handler::Handler, nrows=0)
Read data from the `handler` (see `SASLib.open`). If `nrows` is not specified,
read the entire file content. When called again, fetch the next `nrows` rows.
"""
function read(handler::Handler, nrows=0)
# println("Reading $(handler.config.filename)")
elapsed = @elapsed result = read_chunk(handler, nrows)
elapsed = round(elapsed, digits = 5)
println1(handler, "Read $(handler.config.filename) with size $(size(result, 1)) x $(size(result, 2)) in $elapsed seconds")
return result
end
"""
close(handler::Handler)
Close the `handler` object. This function effectively closes the
underlying iostream. It must be called after the program
finished reading data.
This function is needed only when `SASLib.open` and `SASLib.read`
functions are used instead of the more convenient `readsas` function.
"""
function close(handler::Handler)
# println("Closing $(handler.config.filename)")
Base.close(handler.io)
end
"""
readsas(filename::AbstractString;
encoding::AbstractString = "",
convert_dates::Bool = true,
include_columns::Vector = [],
exclude_columns::Vector = [],
string_array_fn::Dict = Dict(),
number_array_fn::Dict = Dict(),
column_types::Dict = Dict{Symbol,Type}(),
verbose_level::Int64 = 1)
Read a SAS7BDAT file.
`Encoding` may be used as an override only if the file cannot be read
using the encoding specified in the file. If you receive a warning
about unknown encoding then check your system's supported encodings from
the iconv library e.g. using the `iconv --list` command.
If `convert_dates == false` then no conversion is made
and you will get the number of days for Date columns (or number of
seconds for DateTime columns) since 1-JAN-1960.
By default, all columns will be read. If you only need a subset of the
columns, you may specify
either `include_columns` or `exclude_columns` but not both. They are just
arrays of columns indices or symbols e.g. [1, 2, 3] or [:employeeid, :firstname, :lastname]
String columns by default are stored in `SASLib.ObjectPool`, which is an array-like
structure that is more space-efficient when there is a high number of duplicate
values. However, if there are too many unique items (> 10%) then it's automatically
switched over to a regular Array.
If you wish to use a different kind of array, you can pass your
array constructor via the `string_array_fn` dict. The constructor must
take a single integer argument that represents the size of the array.
The convenient `REGULAR_STR_ARRAY` function can be used if you just want to
use the regular Array{String} type.
For examples,
`string_array_fn = Dict(:column1 => (n)->CategoricalArray{String}((n,)))`
or
`string_array_fn = Dict(:column1 => REGULAR_STR_ARRAY)`.
For numeric columns, you may specify your own array constructors using
the `number_array_fn` parameter. Perhaps you have a different kind of
array to store the values e.g. SharedArray.
Specify `column_type` argument if any conversion is required. It should
be a Dict, mapping column symbol to a data type.
For debugging purpose, `verbose_level` may be set to a value higher than 1.
Verbose level 0 will output nothing to the console, essentially a total quiet
option.
"""
function readsas(filename::AbstractString;
encoding::AbstractString = "",
convert_dates::Bool = true,
include_columns::Vector = [],
exclude_columns::Vector = [],
string_array_fn::Dict = Dict(),
number_array_fn::Dict = Dict(),
column_types::Dict = Dict{Symbol,Type}(),
verbose_level::Int64 = 1)
handler = nothing
try
handler = _open(ReaderConfig(filename, encoding, default_chunk_size, convert_dates,
include_columns, exclude_columns, string_array_fn, number_array_fn,
column_types, verbose_level))
return read(handler)
finally
isdefined(handler, :string_decoder) && Base.close(handler.string_decoder)
handler !== nothing && close(handler)
end
end
# Read a single float of the given width (4 or 8).
function _read_float(handler, offset, width)
if !(width in [4, 8])
throw(ArgumentError("invalid float width $(width)"))
end
buf = _read_bytes(handler, offset, width)
value = reinterpret(width == 4 ? Float32 : Float64, buf)[1]
if (handler.byte_swap)
value = bswap(value)
end
return value
end
# Read a single signed integer of the given width (1, 2, 4 or 8).
@inline function _read_int(handler, offset, width)
b = _read_bytes(handler, offset, width)
width == 1 ? Int64(b[1]) :
(handler.file_endianness == :BigEndian ? convertint64B(b...) : convertint64L(b...))
end
@inline function _read_bytes(handler, offset, len)
return handler.cached_page[offset+1:offset+len] #offset is 0-based
# => too conservative.... we expect cached_page to be filled before this function is called
# if handler.cached_page == []
# @warn("_read_byte function going to disk")
# seek(handler.io, offset)
# try
# return Base.read(handler.io, len)
# catch
# throw(FileFormatError("Unable to read $(len) bytes from file position $(offset)"))
# end
# else
# if offset + len > length(handler.cached_page)
# throw(FileFormatError(
# "The cached page $(length(handler.cached_page)) is too small " *
# "to read for range positions $offset to $len"))
# end
# return handler.cached_page[offset+1:offset+len] #offset is 0-based
# end
end
# Get file properties from the header (first page of the file).
#
# At least 2 i/o operation is required:
# 1. First 288 bytes contain some important info e.g. header_length
# 2. Rest of the bytes in the header is just header_length - 288
#
function read_header(handler)
# read header section
seekstart(handler.io)
handler.cached_page = Base.read(handler.io, 288)
# Check magic number
if handler.cached_page[1:length(magic)] != magic
throw(FileFormatError("magic number mismatch (not a SAS file?)"))
end
# println("good magic number")
# Get alignment debugrmation
align1, align2 = 0, 0
buf = _read_bytes(handler, align_1_offset, align_1_length)
if buf == u64_byte_checker_value
align2 = align_2_value
handler.U64 = true
handler.int_length = 8
handler.page_bit_offset = page_bit_offset_x64
handler.subheader_pointer_length = subheader_pointer_length_x64
else
handler.U64 = false
handler.int_length = 4
handler.page_bit_offset = page_bit_offset_x86
handler.subheader_pointer_length = subheader_pointer_length_x86
end
# println2(handler, "U64 = $(handler.U64)")
buf = _read_bytes(handler, align_2_offset, align_2_length)
if buf == align_1_checker_value
align1 = align_2_value
end
total_align = align1 + align2
# println("successful reading alignment debugrmation")
# println3(handler, "align1 = $align1, align2 = $align2, total_align=$total_align")
# println3(handler, "header[33 ] = $([handler.cached_page[33]]) (align1)")
# println3(handler, "header[34:35] = $(handler.cached_page[34:35]) (unknown)")
# println3(handler, "header[36 ] = $([handler.cached_page[36]]) (align2)")
# println3(handler, "header[37 ] = $([handler.cached_page[37]]) (unknown)")
# println3(handler, "header[41:56] = $([handler.cached_page[41:56]]) (unknown)")
# println3(handler, "header[57:64] = $([handler.cached_page[57:64]]) (unknown)")
# println3(handler, "header[65:84] = $([handler.cached_page[65:84]]) (unknown)")
# Get endianness information
buf = _read_bytes(handler, endianness_offset, endianness_length)
if buf == b"\x01"
handler.file_endianness = :LittleEndian
else
handler.file_endianness = :BigEndian
end
# println2(handler, "file_endianness = $(handler.file_endianness)")
# Detect system-endianness and determine if byte swap will be required
handler.sys_endianness = ENDIAN_BOM == 0x04030201 ? :LittleEndian : :BigEndian
# println2(handler, "system endianess = $(handler.sys_endianness)")
handler.byte_swap = handler.sys_endianness != handler.file_endianness
# println2(handler, "byte_swap = $(handler.byte_swap)")
# Get encoding information
buf = _read_bytes(handler, encoding_offset, 1)[1]
if haskey(encoding_names, buf)
handler.file_encoding = "$(encoding_names[buf])"
else
handler.file_encoding = FALLBACK_ENCODING # hope for the best
handler.config.verbose_level > 0 &&
@warn("Unknown file encoding value ($buf), defaulting to $(handler.file_encoding)")
end
#println2(handler, "file_encoding = $(handler.file_encoding)")
# User override for encoding
if handler.config.encoding != ""
handler.config.verbose_level > 0 &&
@warn("Encoding has been overridden from $(handler.file_encoding) to $(handler.config.encoding)")
handler.file_encoding = handler.config.encoding
end
# println2(handler, "Final encoding = $(handler.file_encoding)")
# remember if Base.transcode should be used
handler.use_base_transcoder = uppercase(handler.file_encoding) in
ENCODINGS_OK_WITH_BASE_TRANSCODER
# println2(handler, "Use base encoder = $(handler.use_base_transcoder)")
# prepare string decoder if needed
if !handler.use_base_transcoder
println2(handler, "creating string buffer/decoder for with $(handler.file_encoding)")
handler.string_decoder_buffer = IOBuffer()
handler.string_decoder = StringDecoder(handler.string_decoder_buffer,
handler.file_encoding)
end
# Get platform information
buf = _read_bytes(handler, platform_offset, platform_length)
if buf == b"1"
handler.platform = "Unix"
elseif buf == b"2"
handler.platform = "Windows"
else
handler.platform = "Unknown"
end
# println("platform = $(handler.platform)")
buf = _read_bytes(handler, dataset_offset, dataset_length)
handler.name = transcode_metadata(brstrip(buf, zero_space))
buf = _read_bytes(handler, file_type_offset, file_type_length)
handler.file_type = transcode_metadata(brstrip(buf, zero_space))
# Timestamp is epoch 01/01/1960
epoch = DateTime(1960, 1, 1, 0, 0, 0)
x = _read_float(handler, date_created_offset + align1, date_created_length)
handler.date_created = epoch + Millisecond(round(x * 1000))
# println("date created = $(x) => $(handler.date_created)")
x = _read_float(handler, date_modified_offset + align1, date_modified_length)
handler.date_modified = epoch + Millisecond(round(x * 1000))
# println("date modified = $(x) => $(handler.date_modified)")
handler.header_length = _read_int(handler, header_size_offset + align1, header_size_length)
# Read the rest of the header into cached_page.
# println3(handler, "Reading rest of page, header_length=$(handler.header_length) willread=$(handler.header_length - 288)")
buf = Base.read(handler.io, handler.header_length - 288)
append!(handler.cached_page, buf)
if length(handler.cached_page) != handler.header_length
throw(FileFormatError("The SAS7BDAT file appears to be truncated."))
end
# debug
# println3(handler, "header[209+a1+a2] = $([handler.cached_page[209+align1+align2:209+align1+align2+8]]) (unknown)")
# println3(handler, "header[289+a1+a2] = $([handler.cached_page[289+align1+align2:289+align1+align2+8]]) (unknown)")
# println3(handler, "header[297+a1+a2] = $([handler.cached_page[297+align1+align2:297+align1+align2+8]]) (unknown)")
# println3(handler, "header[305+a1+a2] = $([handler.cached_page[305+align1+align2:305+align1+align2+8]]) (unknown)")
# println3(handler, "header[313+a1+a2] = $([handler.cached_page[313+align1+align2:313+align1+align2+8]]) (unknown)")
handler.page_length = _read_int(handler, page_size_offset + align1, page_size_length)
# println("page_length = $(handler.page_length)")
handler.page_count = _read_int(handler, page_count_offset + align1, page_count_length)
# println("page_count = $(handler.page_count)")
buf = _read_bytes(handler, sas_release_offset + total_align, sas_release_length)
handler.sas_release = transcode_metadata(brstrip(buf, zero_space))
# println2(handler, "SAS Release = $(handler.sas_release)")
# determine vendor - either SAS or STAT_TRANSFER
_determine_vendor(handler)
# println2(handler, "Vendor = $(handler.vendor)")
buf = _read_bytes(handler, sas_server_type_offset + total_align, sas_server_type_length)
handler.server_type = transcode_metadata(brstrip(buf, zero_space))
# println("server_type = $(handler.server_type)")
buf = _read_bytes(handler, os_version_number_offset + total_align, os_version_number_length)
handler.os_version = transcode_metadata(brstrip(buf, zero_space))
# println2(handler, "os_version = $(handler.os_version)")
buf = _read_bytes(handler, os_name_offset + total_align, os_name_length)
buf = brstrip(buf, zero_space)
if length(buf) > 0
handler.os_name = transcode_metadata(buf)
else
buf = _read_bytes(handler, os_maker_offset + total_align, os_maker_length)
handler.os_name = transcode_metadata(brstrip(buf, zero_space))
end
# println("os_name = $(handler.os_name)")
end
# Read all pages to find metadata
# TODO however, this is inefficient since it reads a lot of data from disk
# TODO can we tell if metadata is complete and break out of loop early?
function read_file_metadata(handler)
# println3(handler, "IN: _parse_metadata")
i = 1
while true
# println3(handler, " filepos=$(position(handler.io)) page_length=$(handler.page_length)")
handler.cached_page = Base.read(handler.io, handler.page_length)
if length(handler.cached_page) <= 0
break
end
if length(handler.cached_page) != handler.page_length
throw(FileFormatError("Failed to read a meta data page from the SAS file."))
end
# println("page $i = $(current_page_type_str(handler))")
_process_page_meta(handler)
i += 1
end
end
# Check user's provided column types has keys that matches column symbols in the file
function check_user_column_types(handler)
# save a copy of column types in a case insensitive dict
handler.column_types_dict = CIDict{Symbol,Type}(handler.config.column_types)
# check column_types
for k in keys(handler.config.column_types)
if !case_insensitive_in(k, handler.column_symbols)
@warn("Unknown column symbol ($k) in column_types. Ignored.")
end
end
end
function _process_page_meta(handler)
# println3(handler, "IN: _process_page_meta")
_read_page_header(handler)
pt = vcat([page_meta_type, page_amd_type], page_mix_types)
# println(" pt=$pt handler.current_page_type=$(handler.current_page_type)")
if handler.current_page_type in pt
# println3(handler, " current_page_type = $(current_page_type_str(handler))")
# println3(handler, " current_page = $(handler.current_page)")
# println3(handler, " $(concatenate(stringarray(currentpos(handler))))")
_process_page_metadata(handler)
end
# println(" condition var #1: handler.current_page_type=$(handler.current_page_type)")
# println(" condition var #2: page_mix_types=$(page_mix_types)")
# println(" condition var #3: handler.current_page_data_subheader_pointers=$(handler.current_page_data_subheader_pointers)")
return ((handler.current_page_type in vcat([256], page_mix_types)) ||
(handler.current_page_data_subheader_pointers != []))
end
function _read_page_header(handler)
# println3(handler, "IN: _read_page_header")
bit_offset = handler.page_bit_offset
tx = page_type_offset + bit_offset
handler.current_page_type = _read_int(handler, tx, page_type_length)
# println(" bit_offset=$bit_offset tx=$tx handler.current_page_type=$(handler.current_page_type)")
tx = block_count_offset + bit_offset
handler.current_page_block_count = _read_int(handler, tx, block_count_length)
# println3(handler, " tx=$tx handler.current_page_block_count=$(handler.current_page_block_count)")
tx = subheader_count_offset + bit_offset
handler.current_page_subheaders_count = _read_int(handler, tx, subheader_count_length)
# println3(handler, " tx=$tx handler.current_page_subheaders_count=$(handler.current_page_subheaders_count)")
end
function _process_page_metadata(handler)
# println3(handler, "IN: _process_page_metadata")
bit_offset = handler.page_bit_offset
# println(" bit_offset=$bit_offset")
# println3(handler, " filepos=$(Base.position(handler.io))")
# println3(handler, " loop from 0 to $(handler.current_page_subheaders_count-1)")
for i in 0:handler.current_page_subheaders_count-1
# println3(handler, " i=$i")
pointer = _process_subheader_pointers(handler, subheader_pointers_offset + bit_offset, i)
# ignore subheader when no data is present (variable QL == 0)
if pointer.length == 0
# println3(handler, " pointer.length==0, ignoring subheader")
continue
end
# subheader with truncated compression flag may be ignored (variable COMP == 1)
if pointer.compression == subheader_comp_truncated
# println3(handler, " subheader truncated, ignoring subheader")
continue
end
subheader_signature = _read_subheader_signature(handler, pointer.offset)
subheader_index =
_get_subheader_index(handler, subheader_signature, pointer.compression, pointer.shtype)
# println3(handler, " subheader_index = $subheader_index")
if subheader_index == index_end_of_header
break
end
_process_subheader(handler, subheader_index, pointer)
end
end
function _process_subheader_pointers(handler, offset, subheader_pointer_index)
# println3(handler, "IN: _process_subheader_pointers")
# println3(handler, " offset=$offset (beginning of the pointers array)")
# println3(handler, " subheader_pointer_index=$subheader_pointer_index")
# deference the array by index
# handler.subheader_pointer_length is 12 or 24 (variable SL)
total_offset = (offset + handler.subheader_pointer_length * subheader_pointer_index)
# println3(handler, " handler.subheader_pointer_length=$(handler.subheader_pointer_length)")
# println3(handler, " total_offset=$total_offset")
# handler.int_length is either 4 or 8 (based on u64 flag)
# subheader_offset contains where to find the subheader
subheader_offset = _read_int(handler, total_offset, handler.int_length)
# println3(handler, " subheader_offset=$subheader_offset")
total_offset += handler.int_length
# println3(handler, " total_offset=$total_offset")
# subheader_length contains the length of the subheader (variable QL)
# QL is sometimes zero, which indicates that no data is referenced by the
# corresponding subheader pointer. When this occurs, the subheader pointer may be ignored.
subheader_length = _read_int(handler, total_offset, handler.int_length)
# println3(handler, " subheader_length=$subheader_length")
total_offset += handler.int_length
# println3(handler, " total_offset=$total_offset")
# subheader_compression contains the compression flag (variable COMP)
subheader_compression = _read_int(handler, total_offset, 1)
# println3(handler, " subheader_compression=$subheader_compression")
total_offset += 1
# println3(handler, " total_offset=$total_offset")
# subheader_type contains the subheader type (variable ST)
subheader_type = _read_int(handler, total_offset, 1)
return SubHeaderPointer(
subheader_offset,
subheader_length,
subheader_compression,
subheader_type)
end
# Read the subheader signature from the first 4 or 8 bytes.
# `offset` contains the offset from the start of page that contains the subheader
function _read_subheader_signature(handler, offset)
# println("IN: _read_subheader_signature (offset=$offset)")
bytes = _read_bytes(handler, offset, handler.int_length)
return bytes
end
# Identify the type of subheader from the signature
function _get_subheader_index(handler, signature, compression, shtype)
# println3(handler, "IN: _get_subheader_index")
# println3(handler, " signature=$signature")
# println3(handler, " compression=$compression <-> subheader_comp_compressed=$subheader_comp_compressed")
# println3(handler, " shtype=$shtype <-> subheader_comp_compressed=$subheader_comp_compressed")
val = get(subheader_signature_to_index, signature, nothing)
# if the signature is not found then it's likely storing binary data.
# RLE (variable COMP == 4)
# Uncompress (variable COMP == 0)
if val === nothing
if compression == subheader_comp_uncompressed || compression == subheader_comp_compressed
val = index_dataSubheaderIndex
else
val = index_end_of_header
end
end
return val
end
function _process_subheader(handler, subheader_index, pointer)
# println3(handler, "IN: _process_subheader")
offset = pointer.offset
length = pointer.length
# println3(handler, " $(tostring(pointer))")
if subheader_index == index_rowSizeIndex
processor = _process_rowsize_subheader
elseif subheader_index == index_columnSizeIndex
processor = _process_columnsize_subheader
elseif subheader_index == index_columnTextIndex
processor = _process_columntext_subheader
elseif subheader_index == index_columnNameIndex
processor = _process_columnname_subheader
elseif subheader_index == index_columnAttributesIndex
processor = _process_columnattributes_subheader
elseif subheader_index == index_formatAndLabelIndex
processor = _process_format_subheader
elseif subheader_index == index_columnListIndex
processor = _process_columnlist_subheader
elseif subheader_index == index_subheaderCountsIndex
processor = _process_subheader_counts
elseif subheader_index == index_dataSubheaderIndex
# do not process immediately and just accumulate the pointers
push!(handler.current_page_data_subheader_pointers, pointer)
return
else
throw(FileFormatError("unknown subheader index"))
end
processor(handler, offset, length)
end
function _process_rowsize_subheader(handler, offset, length)
println3(handler, "IN: _process_rowsize_subheader")
int_len = handler.int_length
lcs_offset = offset
lcp_offset = offset
if handler.U64
lcs_offset += 682
lcp_offset += 706
else
lcs_offset += 354
lcp_offset += 378
end
handler.row_length = _read_int(handler,
offset + row_length_offset_multiplier * int_len, int_len)
handler.row_count = _read_int(handler,
offset + row_count_offset_multiplier * int_len, int_len)
handler.col_count_p1 = _read_int(handler,
offset + col_count_p1_multiplier * int_len, int_len)
handler.col_count_p2 = _read_int(handler,
offset + col_count_p2_multiplier * int_len, int_len)
mx = row_count_on_mix_page_offset_multiplier * int_len
handler.mix_page_row_count = _read_int(handler, offset + mx, int_len)
handler.lcs = _read_int(handler, lcs_offset, 2)
handler.lcp = _read_int(handler, lcp_offset, 2)
# println3(handler, " handler.row_length=$(handler.row_length)")
# println3(handler, " handler.row_count=$(handler.row_count)")
# println3(handler, " handler.mix_page_row_count=$(handler.mix_page_row_count)")
end
function _process_columnsize_subheader(handler, offset, length)
# println("IN: _process_columnsize_subheader")
int_len = handler.int_length
offset += int_len
handler.column_count = _read_int(handler, offset, int_len)
if (handler.col_count_p1 + handler.col_count_p2 != handler.column_count)
@warn("Warning: column count mismatch ($(handler.col_count_p1) + $(handler.col_count_p2) != $(handler.column_count))")
end
end
# Unknown purpose
function _process_subheader_counts(handler, offset, length)
# println("IN: _process_subheader_counts")
end
function _process_columntext_subheader(handler, offset, length)
# println3(handler, "IN: _process_columntext_subheader")
p = offset + handler.int_length
text_block_size = _read_int(handler, p, text_block_size_length)
# println3(handler, " text_block_size=$text_block_size")
# println(" before reading buf: offset=$offset")
# TODO this buffer includes the text_block_size itself in the beginning...
buf = _read_bytes(handler, p, text_block_size)
cname_raw = brstrip(buf[1:text_block_size], zero_space)
# println3(handler, " cname_raw=$cname_raw")
cname = cname_raw
# println3(handler, " decoded=$(transcode_metadata(cname))")
push!(handler.column_names_strings, cname)
#println3(handler, " handler.column_names_strings=$(handler.column_names_strings)")
# println(" type=$(typeof(handler.column_names_strings))")
# println(" content=$(handler.column_names_strings)")
# println3(handler, " content=$(size(handler.column_names_strings, 2))")
# figure out some metadata if this is the first column
if size(handler.column_names_strings, 2) == 1
# check if there's compression signature
if contains(cname_raw, rle_compression)
compression_method = compression_method_rle
elseif contains(cname_raw, rdc_compression)
compression_method = compression_method_rdc
else
compression_method = compression_method_none
end
# println3(handler, " handler.lcs = $(handler.lcs)")
# println3(handler, " handler.lcp = $(handler.lcp)")
# save compression info in the handler
handler.compression = compression_method
# look for the compression & creator proc offset (16 or 20)
offset1 = offset + 16
if handler.U64
offset1 += 4
end
# per doc, if first 8 bytes are _blank_ then file is not compressed, set LCS = 0
# howver, we will use the above signature identification method instead.
# buf = _read_bytes(handler, offset1, handler.lcp)
# compression_literal = brstrip(buf, b"\x00")
# if compression_literal == ""
if compression_method == compression_method_none
handler.lcs = 0
offset1 = offset + 32
if handler.U64
offset1 += 4
end
buf = _read_bytes(handler, offset1, handler.lcp)
creator_proc = buf[1:handler.lcp]
# println3(handler, " uncompressed: creator proc=$creator_proc decoded=$(transcode_metadata(creator_proc))")
elseif compression_method == compression_method_rle
offset1 = offset + 40
if handler.U64
offset1 += 4
end
buf = _read_bytes(handler, offset1, handler.lcp)
creator_proc = buf[1:handler.lcp]
# println3(handler, " RLE compression: creator proc=$creator_proc decoded=$(transcode_metadata(creator_proc))")
elseif handler.lcs > 0
handler.lcp = 0
offset1 = offset + 16
if handler.U64
offset1 += 4
end
buf = _read_bytes(handler, offset1, handler.lcs)
creator_proc = buf[1:handler.lcp]
# println3(handler, " LCS>0: creator proc=$creator_proc decoded=$(transcode_metadata(creator_proc))")
else
creator_proc = nothing
end
end
end
function _process_columnname_subheader(handler, offset, length)
# println3(handler, "IN: _process_columnname_subheader")
int_len = handler.int_length
# println(" int_len=$int_len")
# println(" offset=$offset")
offset += int_len
# println(" offset=$offset (after adding int_len)")
column_name_pointers_count = fld(length - 2 * int_len - 12, 8)
# println(" column_name_pointers_count=$column_name_pointers_count")
for i in 1:column_name_pointers_count
text_subheader = offset + column_name_pointer_length *
i + column_name_text_subheader_offset
# println(" i=$i text_subheader=$text_subheader")
col_name_offset = offset + column_name_pointer_length *
i + column_name_offset_offset
# println(" i=$i col_name_offset=$col_name_offset")
col_name_length = offset + column_name_pointer_length *
i + column_name_length_offset
# println(" i=$i col_name_length=$col_name_length")
idx = _read_int(handler,
text_subheader, column_name_text_subheader_length)
# println(" i=$i idx=$idx")
col_offset = _read_int(handler,
col_name_offset, column_name_offset_length)
# println(" i=$i col_offset=$col_offset")
col_len = _read_int(handler,
col_name_length, column_name_length_length)
# println(" i=$i col_len=$col_len")
cnp = ColumnNamePointer(idx + 1, col_offset, col_len)
push!(handler.column_name_pointers, cnp)
end
end
function _process_columnattributes_subheader(handler, offset, length)
# println("IN: _process_columnattributes_subheader")
int_len = handler.int_length
N = fld(length - 2 * int_len - 12, int_len + 8)
# println(" column_attributes_vectors_count = $column_attributes_vectors_count")
ty = fill(column_type_none, N)
len = fill(0::Int64, N)
off = fill(0::Int64, N)
# handler.column_types = fill(column_type_none, column_attributes_vectors_count)
# handler.column_data_lengths = fill(0::Int64, column_attributes_vectors_count)
# handler.column_data_offsets = fill(0::Int64, column_attributes_vectors_count)
for i in 0:N-1
col_data_offset = (offset + int_len +
column_data_offset_offset +
i * (int_len + 8))
col_data_len = (offset + 2 * int_len +
column_data_length_offset +
i * (int_len + 8))
col_types = (offset + 2 * int_len +
column_type_offset + i * (int_len + 8))
j = i + 1
off[j] = _read_int(handler, col_data_offset, int_len)
len[j] = _read_int(handler, col_data_len, column_data_length_length)
x = _read_int(handler, col_types, column_type_length)
ty[j] = (x == 1) ? column_type_decimal : column_type_string
end
push!(handler.column_types, ty...)
push!(handler.column_data_lengths, len...)
push!(handler.column_data_offsets, off...)
end
function _process_columnlist_subheader(handler, offset, length)
# println("IN: _process_columnlist_subheader")
# unknown purpose
end
function _process_format_subheader(handler, offset, length)
# println3(handler, "IN: _process_format_subheader")
int_len = handler.int_length
col_format_idx = offset + 22 + 3 * int_len
col_format_offset = offset + 24 + 3 * int_len
col_format_len = offset + 26 + 3 * int_len
col_label_idx = offset + 28 + 3 * int_len
col_label_offset = offset + 30 + 3 * int_len
col_label_len = offset + 32 + 3 * int_len
format_idx = _read_int(handler, col_format_idx, 2)
# println3(handler, " format_idx=$format_idx")
# TODO julia bug? must reference Base.length explicitly or else we get MethodError: objects of type Int64 are not callable
format_idx = min(format_idx, Base.length(handler.column_names_strings) - 1)
format_start = _read_int(handler, col_format_offset, 2)
format_len = _read_int(handler, col_format_len, 2)
# println3(handler, " format_idx=$format_idx, format_start=$format_start, format_len=$format_len")
format_names = handler.column_names_strings[format_idx+1]
column_format = transcode_metadata(format_names[format_start+1: format_start + format_len])
push!(handler.column_formats, column_format)
# The following code isn't used and it's not working for some files e.g. topical.sas7bdat from AHS
# label_idx = _read_int(handler, col_label_idx, 2)
# # TODO julia bug? must reference Base.length explicitly or else we get MethodError: objects of type Int64 are not callable
# label_idx = min(label_idx, Base.length(handler.column_names_strings) - 1)
# label_start = _read_int(handler, col_label_offset, 2)
# label_len = _read_int(handler, col_label_len, 2)
# println3(handler, " label_idx=$label_idx, label_start=$label_start, label_len=$label_len")
# println3(handler, " handler.column_names_strings=$(size(handler.column_names_strings[1], 1))")
# label_names = handler.column_names_strings[label_idx+1]
# column_label = label_names[label_start+1: label_start + label_len]
# println3(handler, " column_label=$column_label decoded=$(transcode_metadata(column_label))")
# current_column_number = size(handler.columns, 2)
# println3(handler, " current_column_number=$current_column_number")
# col = Column(
# current_column_number,
# handler.column_names[current_column_number],
# column_label,
# column_format,
# handler.column_types[current_column_number],
# handler.column_data_lengths[current_column_number])
# push!(handler.columns, col)
end
function read_chunk(handler, nrows=0)
if !isdefined(handler, :column_types)
@warn("No columns to parse from file")
return ResultSet()
end
# println("column_types = $(handler.column_types)")
if handler.row_count == 0
@warn("File has no data")
return ResultSet()
end
# println("IN: read_chunk")
#println(handler.config)
if (nrows == 0) && (handler.config.chunk_size > 0)
nrows = handler.config.chunk_size
elseif nrows == 0
nrows = handler.row_count
end
# println("nrows = $nrows")
# println("row_count = $(handler.row_count)")
m = handler.row_count - handler.current_row_in_file_index
if nrows > m
nrows = m
end
# println("nrows = $(nrows)")
#info("Reading $nrows x $(length(handler.column_types)) data set")
# TODO not the most efficient but normally it should be ok for non-wide tables
nd = count(x -> x == column_type_decimal, handler.column_types)
ns = count(x -> x == column_type_string, handler.column_types)
# println("nd = $nd (number of decimal columns)")
# println("ns = $ns (number of string columns)")
# ns > 0 && !handler.use_base_transcoder &&
# info("Note: encoding incompatible with UTF-8, reader will take more time")
populate_column_indices(handler)
# allocate columns
handler.byte_chunk = Dict()
handler.string_chunk = Dict()
for (k, name, ty) in handler.column_indices
if ty == column_type_decimal
handler.byte_chunk[name] = fill(UInt8(0), Int64(8 * nrows)) # 8-byte values
elseif ty == column_type_string
handler.string_chunk[name] = createstrarray(handler, name, nrows)
else
throw(FileFormatError("unknown column type: $ty for column $name"))
end
end
# don't do this or else the state is polluted if user wants to
# read lines separately.
# handler.current_page = 0
handler.current_row_in_chunk_index = 0
perf_read_data = @elapsed(read_data(handler, nrows))
perf_chunk_to_data_frame = @elapsed(rslt = _chunk_to_dataframe(handler, nrows))
if handler.config.verbose_level > 1
println("Read data in ", perf_read_data, " msec")
println("Converted data in ", perf_chunk_to_data_frame, " msec")
end
column_symbols = [sym for (k, sym, ty) in handler.column_indices]
return ResultSet([rslt[s] for s in column_symbols], column_symbols,
(nrows, length(column_symbols)))
end
# not extremely efficient but is a safe way to do it
function createstrarray(handler, column_symbol, nrows)
if haskey(handler.config.string_array_fn, column_symbol)
handler.config.string_array_fn[column_symbol](nrows)
elseif haskey(handler.config.string_array_fn, :_all_)
handler.config.string_array_fn[:_all_](nrows)
else
if nrows + 1 < 2 << 7
ObjectPool{String, UInt8}(EMPTY_STRING, nrows)
elseif nrows < 2 << 15
ObjectPool{String, UInt16}(EMPTY_STRING, nrows)
elseif nrows < 2 << 31
ObjectPool{String, UInt32}(EMPTY_STRING, nrows)
else
ObjectPool{String, UInt64}(EMPTY_STRING, nrows)
end
end
end
# create numeric array
function createnumarray(handler, column_symbol, nrows)
if haskey(handler.config.number_array_fn, column_symbol)
handler.config.number_array_fn[column_symbol](nrows)
elseif haskey(handler.config.number_array_fn, :_all_)
handler.config.number_array_fn[:_all_](nrows)
else
zeros(Float64, nrows)
end
end
function _read_next_page_content(handler)
# println3(handler, "IN: _read_next_page_content")
# println3(handler, " positions = $(concatenate(stringarray(currentpos(handler))))")
handler.current_page += 1
# println3(handler, " current_page = $(handler.current_page)")
# println3(handler, " file position = $(Base.position(handler.io))")
# println3(handler, " page_length = $(handler.page_length)")
handler.current_page_data_subheader_pointers = []
handler.cached_page = Base.read(handler.io, handler.page_length)
if length(handler.cached_page) <= 0
return true
elseif length(handler.cached_page) != handler.page_length
throw(FileFormatError("Failed to read complete page from file ($(length(handler.cached_page)) of $(handler.page_length) bytes"))
end
_read_page_header(handler)
if handler.current_page_type == page_meta_type
_process_page_metadata(handler)
end
# println3(handler, " type=$(current_page_type_str(handler))")
if ! (handler.current_page_type in page_meta_data_mix_types)
# println3(handler, "page type not found $(handler.current_page_type)... reading next one")
return _read_next_page_content(handler)
end
return false
end
# test -- copied from _read_next_page_content
function my_read_next_page(handler)
handler.current_page += 1
handler.current_page_data_subheader_pointers = []
handler.cached_page = Base.read(handler.io, handler.page_length)
_read_page_header(handler)
handler.current_row_in_page_index = 0
end
# convert Float64 value into Date object
function date_from_float(x::Vector{Float64})
v = Vector{Union{Date, Missing}}(undef, length(x))
for i in 1:length(x)
v[i] = isnan(x[i]) ? missing : (sas_date_origin + Dates.Day(round(Int64, x[i])))
end
v
end
# convert Float64 value into DateTime object
function datetime_from_float(x::Vector{Float64})
v = Vector{Union{DateTime, Missing}}(undef, length(x))
for i in 1:length(x)
v[i] = isnan(x[i]) ? missing : (sas_datetime_origin + Dates.Second(round(Int64, x[i])))
end
v
end
# Construct Dict object that holds the columns.
# For date or datetime columns, convert from numeric value to Date/DateTime type column.
# The resulting dictionary uses column symbols as the key.
function _chunk_to_dataframe(handler, nrows)
# println("IN: _chunk_to_dataframe")
n = handler.current_row_in_chunk_index
m = handler.current_row_in_file_index
rslt = Dict()
# println("handler.column_names=$(handler.column_names)")
for (k, name, ty) in handler.column_indices
if ty == column_type_decimal # number, date, or datetime
# println(" String: size=$(size(handler.byte_chunk))")
# println(" Decimal: column $j, name $name, size=$(size(handler.byte_chunk[jb, :]))")
bytes = handler.byte_chunk[name]
#if j == 1 && length(bytes) < 100 #debug only
# println(" bytes=$bytes")
#end
values = createnumarray(handler, name, nrows)
convertfloat64f!(values, bytes, handler.file_endianness)
#println(length(bytes))
#rslt[name] = bswap(rslt[name])
rslt[name] = values
if handler.config.convert_dates
if handler.column_formats[k] in sas_date_formats
rslt[name] = date_from_float(rslt[name])
elseif handler.column_formats[k] in sas_datetime_formats
# TODO probably have to deal with timezone somehow
rslt[name] = datetime_from_float(rslt[name])
end
end
convert_column_type_if_needed!(handler, rslt, name)
elseif ty == column_type_string
# println(" String: size=$(size(handler.string_chunk))")
# println(" String: column $j, name $name, size=$(size(handler.string_chunk[js, :]))")
rslt[name] = handler.string_chunk[name]
else
throw(FileFormatError("Unknown column type: $ty"))
end
end
return rslt
end
# If the user specified a type for the column, try to convert the column data.
function convert_column_type_if_needed!(handler, rslt, name)
if haskey(handler.column_types_dict, name)
type_wanted = handler.column_types_dict[name]
#println("$name exists in config.column_types, type_wanted=$type_wanted")
if type_wanted != Float64
try
rslt[name] = convert(Vector{type_wanted}, rslt[name])
catch ex
@warn("Unable to convert column to type $type_wanted, error=$ex")
end
end
end
end
# Simple loop that reads data row-by-row.
function read_data(handler, nrows)
# println("IN: read_data, nrows=$nrows")
for i in 1:nrows
done = readline(handler)
if done
break
end
end
end
function read_next_page(handler)
done = _read_next_page_content(handler)
if done
handler.cached_page = []
else
handler.current_row_in_page_index = 0
end
return done
end
# Return `true` when there is nothing else to read
function readline(handler)
# println("IN: readline")
subheader_pointer_length = handler.subheader_pointer_length
# If there is no page, go to the end of the header and read a page.
# TODO commented out for performance reason... do we really need this?
# if handler.cached_page == []
# println(" no cached page... seeking past header")
# seek(handler.io, handler.header_length)
# println(" reading next page")
# done = read_next_page(handler)
# if done
# println(" no page! returning")
# return true
# end
# end
# Loop until a data row is read
# println(" start loop")
while true
if handler.current_page_type == page_meta_type
#println(" page type == page_meta_type")
flag = handler.current_row_in_page_index >= length(handler.current_page_data_subheader_pointers)
if flag
# println(" reading next page")
done = read_next_page(handler)
if done
# println(" all done, returning #1")
return true
end
continue
end
current_subheader_pointer =
handler.current_page_data_subheader_pointers[handler.current_row_in_page_index+1]
# println3(handler, " current_subheader_pointer = $(current_subheader_pointer)")
# println3(handler, " handler.compression = $(handler.compression)")
cm = compression_method_none
if current_subheader_pointer.compression == subheader_comp_compressed
if handler.compression != compression_method_none
cm = handler.compression
else
cm = compression_method_rle # default to RLE if handler doesn't have the info yet
end
end
process_byte_array_with_data(handler,
current_subheader_pointer.offset,
current_subheader_pointer.length, cm)
return false
elseif (handler.current_page_type == page_mix_types[1] ||
handler.current_page_type == page_mix_types[2])
# println3(handler, " page type == page_mix_types_1/2")
offset = handler.page_bit_offset
offset += subheader_pointers_offset
offset += (handler.current_page_subheaders_count * subheader_pointer_length)
align_correction = offset % 8
offset += align_correction
# hack for stat_transfer files
if align_correction == 4 && handler.vendor == VENDOR_STAT_TRANSFER
# println3(handler, "alignment hack, vendor=$(handler.vendor) align_correction=$align_correction")
offset -= align_correction
end
# locate the row
offset += handler.current_row_in_page_index * handler.row_length
process_byte_array_with_data(handler, offset, handler.row_length, handler.compression)
mn = min(handler.row_count, handler.mix_page_row_count)
# println(" handler.current_row_in_page_index=$(handler.current_row_in_page_index)")
# println(" mn = $mn")
if handler.current_row_in_page_index == mn
# println(" reading next page")
done = read_next_page(handler)
if done
# println(" all done, returning #2")
return true
end
end
return false
elseif handler.current_page_type == page_data_type
#println(" page type == page_data_type")
process_byte_array_with_data(handler,
handler.page_bit_offset + subheader_pointers_offset +
handler.current_row_in_page_index * handler.row_length,
handler.row_length,
handler.compression)
# println(" handler.current_row_in_page_index=$(handler.current_row_in_page_index)")
# println(" handler.current_page_block_count=$(handler.current_page_block_count)")
flag = (handler.current_row_in_page_index == handler.current_page_block_count)
#println("$(handler.current_row_in_page_index) $(handler.current_page_block_count)")
if flag
# println(" reading next page")
done = read_next_page(handler)
if done
# println(" all done, returning #3")
return true
end
end
return false
else
throw(FileFormatError("unknown page type: $(handler.current_page_type)"))
end
end
end
function process_byte_array_with_data(handler, offset, length, compression)
# println("IN: process_byte_array_with_data, offset=$offset, length=$length")
# Original code below. Julia type is already Vector{UInt8}
# source = np.frombuffer(
# handler.cached_page[offset:offset + length], dtype=np.uint8)
source = handler.cached_page[offset+1:offset+length]
# TODO decompression
# if handler.decompress != NULL and (length < handler.row_length)
# println(" length=$length")
# println(" handler.row_length=$(handler.row_length)")
if length < handler.row_length
if compression == compression_method_rle
# println3(handler, "decompress using rle_compression method, length=$length, row_length=$(handler.row_length)")
source = rle_decompress(handler.row_length, source)
elseif compression == compression_method_rdc
# println3(handler, "decompress using rdc_compression method, length=$length, row_length=$(handler.row_length)")
source = rdc_decompress(handler.row_length, source)
else
# println3(handler, "process_byte_array_with_data")
# println3(handler, " length=$length")
# println3(handler, " handler.row_length=$(handler.row_length)")
# println3(handler, " source=$source")
throw(FileFormatError("Unknown compression method: $(handler.compression)"))
end
end
current_row = handler.current_row_in_chunk_index
s = 8 * current_row
# TODO PERF there's not reason to deference by name everytime.
# Ideally, we can still go by the result's column index
# and then only at the very end (outer loop) we assign them to
# the column symbols
@inbounds for (k, name, ty) in handler.column_indices
lngt = handler.column_data_lengths[k]
start = handler.column_data_offsets[k]
ct = handler.column_types[k]
if ct == column_type_decimal
# The data may have 3,4,5,6,7, or 8 bytes (lngt)
# and we need to copy into an 8-byte destination.
# Hence endianness matters - for Little Endian file
# copy it to the right side, else left side.
if handler.file_endianness == :LittleEndian
m = s + 8 - lngt
else
m = s
end
# if current_row == 0 && k == 1
# println3(handler, "First cell:")
# println3(handler, " k=$k name=$name ty=$ty")
# println3(handler, " s=$s m=$m lngt=$lngt start=$start")
# println3(handler, " source =$(source[start+1:start+lngt])")
# end
dst = handler.byte_chunk[name]
for i in 1:lngt
@inbounds dst[m + i] = source[start + i]
end
# @inbounds handler.byte_chunk[name][m+1:m+lngt] = source[start+1:start+lngt]
#println3(handler, "byte_chunk[$name][$(m+1):$(m+lngt)] = source[$(start+1):$(start+lngt)] => $(source[start+1:start+lngt])")
elseif ct == column_type_string
# issue 12 - heuristic for switching to regular Array type
ar = handler.string_chunk[name]
if handler.current_row_in_chunk_index > 2000 &&
handler.current_row_in_chunk_index % 200 == 0 &&
isa(ar, ObjectPool) &&
ar.uniqueitemscount / ar.itemscount > 0.10
println2(handler, "Bumping column $(name) to regular array due to too many unique items $(ar.uniqueitemscount) out of $(ar.itemscount)")
ar = Array(ar)
handler.string_chunk[name] = ar
end
pos = lastcharpos(source, start, lngt)
@inbounds ar[current_row+1] =
# rstrip2(transcode_data(handler, source, start+1, start+lngt, lngt))
transcode_data(handler, source, start+1, start+pos, pos)
end
end
handler.current_row_in_page_index += 1
handler.current_row_in_chunk_index += 1
handler.current_row_in_file_index += 1
end
# Notes about performance enhancement related to stripping off space characters.
#
# Apparently SAS always use 0x20 (space) even for non-ASCII encodings
# but what if 0x20 happens to be there as part of a multi-byte encoding?
# ```
# julia> decode([0x02, 0x20], "UTF-16")
# "Ƞ"
# ````
#
# Knowing that we can only understand a certain set of char encodings as in
# the constants.jl file, we just need to make sure that the ones that we
# support does not use 0x20 as part of any multi-byte chars.
#
# Seems ok. Some info available at
# https://www.debian.org/doc/manuals/intro-i18n/ch-codes.en.html
#
# find the last char position that is not space
function lastcharpos(source::Vector{UInt8}, start::Int64, lngt::Int64)
i = lngt
while i ≥ 1
if source[start + i] != 0x20
break
end
i -= 1
end
return i
end
# TODO possible issue with the 7-bit check... maybe not all encodings are ascii compatible for 7-bit values?
# Use unsafe_string to avoid bounds check for performance reason
# Use custom decode_string function with our own decoder/decoder buffer to avoid unncessary objects creation
@inline transcode_data(handler::Handler, source::Vector{UInt8}, startidx::Int64, endidx::Int64, lngt::Int64) =
handler.use_base_transcoder || seven_bit_data(source, startidx, endidx) ?
unsafe_string(pointer(source) + startidx - 1, lngt) :
decode_string(source, startidx, endidx, handler.string_decoder_buffer, handler.string_decoder)
#decode_string2(source[startidx:endidx], handler.file_encoding)
# metadata is always ASCII-based (I think)
@inline transcode_metadata(bytes::Vector{UInt8}) =
Base.transcode(String, bytes)
# determine if string data contains only 7-bit characters
@inline function seven_bit_data(source::Vector{UInt8}, startidx::Int64, endidx::Int64)
for i in startidx:endidx
if source[i] > 0x7f
return false
end
end
true
end
@inline function decode_string(source::Vector{UInt8}, startidx::Int64, endidx::Int64, io::IOBuffer, decoder::StringDecoder)
truncate(io, 0)
for i in startidx:endidx
write(io, source[i])
end
seek(io, 0)
str = String(Base.read(decoder))
# println("decoded ", str)
str
end
# @inline function decode_string2(bytes, encoding)
# decode(bytes, encoding)
# end
# Courtesy of ReadStat project
# https://github.com/WizardMac/ReadStat
const SAS_RLE_COMMAND_COPY64 = 0
const SAS_RLE_COMMAND_INSERT_BYTE18 = 4
const SAS_RLE_COMMAND_INSERT_AT17 = 5
const SAS_RLE_COMMAND_INSERT_BLANK17 = 6
const SAS_RLE_COMMAND_INSERT_ZERO17 = 7
const SAS_RLE_COMMAND_COPY1 = 8
const SAS_RLE_COMMAND_COPY17 = 9
const SAS_RLE_COMMAND_COPY33 = 10 # 0x0A
const SAS_RLE_COMMAND_COPY49 = 11 # 0x0B
const SAS_RLE_COMMAND_INSERT_BYTE3 = 12 # 0x0C
const SAS_RLE_COMMAND_INSERT_AT2 = 13 # 0x0D
const SAS_RLE_COMMAND_INSERT_BLANK2 = 14 # 0x0E
const SAS_RLE_COMMAND_INSERT_ZERO2 = 15 # 0x0F
function rle_decompress(output_len, input::Vector{UInt8})
#error("stopped for debugging $output_len $input")
input_len = length(input)
output = zeros(UInt8, output_len)
# logdebug("rle_decompress: output_len=$output_len, input_len=$input_len")
ipos = 1
rpos = 1
while ipos <= input_len
control = input[ipos]
ipos += 1
command = (control & 0xF0) >> 4
dlen = (control & 0x0F)
copy_len = 0
insert_len = 0
insert_byte = 0x00
if command == SAS_RLE_COMMAND_COPY64
# logdebug(" SAS_RLE_COMMAND_COPY64")
copy_len = input[ipos] + 64 + dlen * 256
ipos += 1
elseif command == SAS_RLE_COMMAND_INSERT_BYTE18
# logdebug(" SAS_RLE_COMMAND_INSERT_BYTE18")
insert_len = input[ipos] + 18 + dlen * 16
ipos += 1
insert_byte = input[ipos]
ipos += 1
elseif command == SAS_RLE_COMMAND_INSERT_AT17
# logdebug(" SAS_RLE_COMMAND_INSERT_AT17")
insert_len = input[ipos] + 17 + dlen * 256
insert_byte = 0x40 # char: @
ipos += 1
elseif command == SAS_RLE_COMMAND_INSERT_BLANK17
# logdebug(" SAS_RLE_COMMAND_INSERT_BLANK17")
insert_len = input[ipos] + 17 + dlen * 256
insert_byte = 0x20 # char: <space>
ipos += 1
elseif command == SAS_RLE_COMMAND_INSERT_ZERO17
# logdebug(" SAS_RLE_COMMAND_INSERT_ZERO17")
insert_len = input[ipos] + 17 + dlen * 256
insert_byte = 0x00
ipos += 1
elseif command == SAS_RLE_COMMAND_COPY1
# logdebug(" SAS_RLE_COMMAND_COPY1")
copy_len = dlen + 1
elseif command == SAS_RLE_COMMAND_COPY17
# logdebug(" SAS_RLE_COMMAND_COPY17")
copy_len = dlen + 17
elseif command == SAS_RLE_COMMAND_COPY33
# logdebug(" SAS_RLE_COMMAND_COPY33")
copy_len = dlen + 33
elseif command == SAS_RLE_COMMAND_COPY49
# logdebug(" SAS_RLE_COMMAND_COPY49")
copy_len = dlen + 49
elseif command == SAS_RLE_COMMAND_INSERT_BYTE3
# logdebug(" SAS_RLE_COMMAND_INSERT_BYTE3")
insert_len = dlen + 3
insert_byte = input[ipos]
ipos += 1
elseif command == SAS_RLE_COMMAND_INSERT_AT2
# logdebug(" SAS_RLE_COMMAND_INSERT_AT2")
insert_len = dlen + 2
insert_byte = 0x40 # char: @
elseif command == SAS_RLE_COMMAND_INSERT_BLANK2
# logdebug(" SAS_RLE_COMMAND_INSERT_BLANK2")
insert_len = dlen + 2
insert_byte = 0x20 # char: <space>
elseif command == SAS_RLE_COMMAND_INSERT_ZERO2
# logdebug(" SAS_RLE_COMMAND_INSERT_ZERO2")
insert_len = dlen + 2
insert_byte = 0x00 # char: @
end
if copy_len > 0
# logdebug(" ipos=$ipos rpos=$rpos copy_len=$copy_len => output[$rpos:$(rpos+copy_len-1)] = input[$ipos:$(ipos+copy_len-1)]")
for i in 0:copy_len-1
output[rpos + i] = input[ipos + i]
#output[rpos:rpos+copy_len-1] = input[ipos:ipos+copy_len-1]
end
rpos += copy_len
ipos += copy_len
end
if insert_len > 0
# logdebug(" ipos=$ipos rpos=$rpos insert_len=$insert_len insert_byte=0x$(hex(insert_byte))")
for i in 0:insert_len-1
output[rpos + i] = insert_byte
#output[rpos:rpos+insert_len-1] = insert_byte
end
rpos += insert_len
end
end
output
end
# rdc_decompress decompresses data using the Ross Data Compression algorithm:
#
# http://collaboration.cmc.ec.gc.ca/science/rpn/biblio/ddj/Website/articles/CUJ/1992/9210/ross/ross.htm
function rdc_decompress(result_length, inbuff::Vector{UInt8})
ctrl_bits = UInt16(0)
ctrl_mask = UInt16(0)
ipos = 1
rpos = 1
outbuff = zeros(UInt8, result_length)
while ipos <= length(inbuff)
ctrl_mask = ctrl_mask >> 1
if ctrl_mask == 0
ctrl_bits = (UInt16(inbuff[ipos]) << 8) + UInt16(inbuff[ipos + 1])
ipos += 2
ctrl_mask = 0x8000
end
if ctrl_bits & ctrl_mask == 0
outbuff[rpos] = inbuff[ipos]
ipos += 1
rpos += 1
continue
end
cmd = (inbuff[ipos] >> 4) & 0x0F
cnt = UInt16(inbuff[ipos] & 0x0F)
ipos += 1
# short RLE
if cmd == 0
cnt += 3
for k in 0:cnt-1
outbuff[rpos + k] = inbuff[ipos]
end
rpos += cnt
ipos += 1
# long RLE
elseif cmd == 1
cnt += UInt16(inbuff[ipos]) << 4
cnt += 19
ipos += 1
for k in 0:cnt-1
outbuff[rpos + k] = inbuff[ipos]
end
rpos += cnt
ipos += 1
# long pattern
elseif cmd == 2
ofs = cnt + 3
ofs += UInt16(inbuff[ipos]) << 4
ipos += 1
cnt = UInt16(inbuff[ipos])
ipos += 1
cnt += 16
for k in 0:cnt-1
outbuff[rpos + k] = outbuff[rpos - ofs + k]
end
rpos += cnt
# short pattern
elseif (cmd >= 3) & (cmd <= 15)
ofs = cnt + 3
ofs += UInt16(inbuff[ipos]) << 4
ipos += 1
for k in 0:cmd-1
outbuff[rpos + k] = outbuff[rpos - ofs + k]
end
rpos += cmd
else
throw(FileFormatError("unknown RDC command"))
end
end
if length(outbuff) != result_length
throw(FileFormatError("RDC: $(length(outbuff)) != $result_length"))
end
return outbuff
end
# ---- Debugging methods ----
# verbose printing. 1=little verbose, 2=medium verbose, 3=very verbose, 4=very very verbose :-)
@inline println1(handler::Handler, msg::String) = handler.config.verbose_level >= 1 && println(msg)
@inline println2(handler::Handler, msg::String) = handler.config.verbose_level >= 2 && println(msg)
@inline println3(handler::Handler, msg::String) = handler.config.verbose_level >= 3 && println(msg)
logdebug = println
# string representation of the SubHeaderPointer structure
# function tostring(x::SubHeaderPointer)
# "<SubHeaderPointer: offset=$(x.offset), length=$(x.length), compression=$(x.compression), type=$(x.shtype)>"
# end
# Return the current position in various aspects (file, page, chunk)
# This is useful for debugging purpose especially during incremental reads.
# function currentpos(handler)
# d = Dict()
# if isdefined(handler, :current_row_in_file_index)
# d[:current_row_in_file] = handler.current_row_in_file_index
# end
# if isdefined(handler, :current_row_in_page_index)
# d[:current_row_in_page] = handler.current_row_in_page_index
# end
# if isdefined(handler, :current_row_in_chunk_index)
# d[:current_row_in_chunk] = handler.current_row_in_chunk_index
# end
# return d
# end
# case insensitive column mapping
Base.lowercase(s::Symbol) = Symbol(lowercase(String(s)))
case_insensitive_in(s::Symbol, ar::AbstractArray) =
lowercase(s) in [x isa Symbol ? lowercase(x) : x for x in ar]
# fill column indices as a dictionary (key = column index, value = column symbol)
function populate_column_indices(handler)
handler.column_indices = Vector{Tuple{Int64, Symbol, UInt8}}()
inflag = length(handler.config.include_columns) > 0
exflag = length(handler.config.exclude_columns) > 0
inflag && exflag && throw(ConfigError("You can specify either include_columns or exclude_columns but not both."))
processed = []
# println("handler.column_symbols = $(handler.column_symbols) len=$(length(handler.column_symbols))")
# println("handler.column_types = $(handler.column_types) len=$(length(handler.column_types))")
for j in 1:length(handler.column_symbols)
name = handler.column_symbols[j]
if inflag
if j in handler.config.include_columns ||
case_insensitive_in(name, handler.config.include_columns)
push!(handler.column_indices, (j, name, handler.column_types[j]))
push!(processed, lowercase(name))
end
elseif exflag
if !(j in handler.config.exclude_columns ||
case_insensitive_in(name, handler.config.exclude_columns))
push!(handler.column_indices, (j, name, handler.column_types[j]))
else
push!(processed, lowercase(name))
end
else
push!(handler.column_indices, (j, name, handler.column_types[j]))
end
end
if inflag && length(processed) != length(handler.config.include_columns)
diff = setdiff(handler.config.include_columns, processed)
for c in diff
@warn("Unknown include column $c")
end
end
if exflag && length(processed) != length(handler.config.exclude_columns)
diff = setdiff(handler.config.exclude_columns, processed)
for c in diff
@warn("Unknown exclude column $c")
end
end
# println2(handler, "column_indices = $(handler.column_indices)")
end
function _determine_vendor(handler::Handler)
# convert a release string into "9.0401M1" into 3 separate numbers
(version, revision) = split(handler.sas_release, "M")
(major, minor) = split(version, ".")
(major, minor, revision) = parse.(Int, (major, minor, revision))
if major == 9 && minor == 0 && revision == 0
# A bit of a hack, but most SAS installations are running a minor update
handler.vendor = VENDOR_STAT_TRANSFER
else
handler.vendor = VENDOR_SAS
end
end
# Populate column names after all meta info is read
function populate_column_names(handler)
for cnp in handler.column_name_pointers
if cnp.index > length(handler.column_names_strings)
name = "unknown_$(cnp.index)_$(cnp.offset)"
else
name_str = handler.column_names_strings[cnp.index]
name = transcode_metadata(name_str[cnp.offset+1:cnp.offset + cnp.length])
end
push!(handler.column_names, name)
push!(handler.column_symbols, Symbol(name))
end
# println("column_names=", handler.column_names)
# println("column_symbols=", handler.column_symbols)
end
# Returns current page type as a string at the current state
function current_page_type_str(handler)
pt = _read_int(handler, handler.page_bit_offset, page_type_length)
return page_type_str(pt)
end
# Convert page type value to human readable string
function page_type_str(pt)
if pt == page_meta_type return "META"
elseif pt == page_amd_type return "AMD"
elseif pt == page_data_type return "DATA"
elseif pt in page_mix_types return "MIX"
else return "UNKNOWN $(pt)"
end
end
# Go back and read the first page again and be ready for read
# This is needed after all metadata is written and the system needs to rewind
function read_first_page(handler)
seek(handler.io, handler.header_length)
my_read_next_page(handler)
end
# Initialize handler object
function init_handler(handler)
handler.compression = compression_method_none
handler.column_names_strings = []
handler.column_names = []
handler.column_symbols = []
handler.column_name_pointers = []
handler.column_formats = []
handler.column_types = []
handler.column_data_lengths = []
handler.column_data_offsets = []
handler.current_page_data_subheader_pointers = []
handler.current_row_in_file_index = 0
handler.current_row_in_chunk_index = 0
handler.current_row_in_page_index = 0
handler.current_page = 0
end
Base.show(io::IO, h::Handler) = print(io, "SASLib.Handler[", h.config.filename, "]")
end # module
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 3133 | struct FileFormatError <: Exception
message::AbstractString
end
struct ConfigError <: Exception
message::AbstractString
end
struct ReaderConfig
filename::AbstractString
encoding::AbstractString
chunk_size::Int64
convert_dates::Bool
include_columns::Vector
exclude_columns::Vector
string_array_fn::Dict{Symbol, Function}
number_array_fn::Dict{Symbol, Function}
column_types::Dict{Symbol, Type}
verbose_level::Int64
end
struct Column
id::Int64
name::AbstractString
label::Vector{UInt8} # really?
format::AbstractString
coltype::UInt8
length::Int64
end
struct ColumnNamePointer
index::Int
offset::Int
length::Int
end
# technically these fields may have lower precision (need casting?)
struct SubHeaderPointer
offset::Int64
length::Int64
compression::Int64
shtype::Int64
end
mutable struct Handler
io::IOStream
config::ReaderConfig
compression::UInt8
column_names_strings::Vector{Vector{UInt8}}
column_names::Vector{AbstractString}
column_symbols::Vector{Symbol}
column_types::Vector{UInt8}
column_formats::Vector{AbstractString}
columns::Vector{Column}
# column indices being read/returned
# tuple of column index, column symbol, column type
column_indices::Vector{Tuple{Int64, Symbol, UInt8}}
column_name_pointers::Vector{ColumnNamePointer}
current_page_data_subheader_pointers::Vector{SubHeaderPointer}
cached_page::Vector{UInt8}
column_data_lengths::Vector{Int64}
column_data_offsets::Vector{Int64}
current_row_in_file_index::Int64
current_row_in_page_index::Int64
file_endianness::Symbol
sys_endianness::Symbol
byte_swap::Bool
U64::Bool
int_length::Int8
page_bit_offset::Int8
subheader_pointer_length::UInt8
file_encoding::AbstractString
platform::AbstractString
name::Union{AbstractString,Vector{UInt8}}
file_type::Union{AbstractString,Vector{UInt8}}
date_created::DateTime
date_modified::DateTime
header_length::Int64
page_length::Int64
page_count::Int64
sas_release::Union{AbstractString,Vector{UInt8}}
server_type::Union{AbstractString,Vector{UInt8}}
os_version::Union{AbstractString,Vector{UInt8}}
os_name::Union{AbstractString,Vector{UInt8}}
row_length::Int64
row_count::Int64
col_count_p1::Int64
col_count_p2::Int64
mix_page_row_count::Int64
lcs::Int64
lcp::Int64
current_page_type::Int64
current_page_block_count::Int64 # number of records in current page
current_page_subheaders_count::Int64
column_count::Int64
# creator_proc::Union{Void, Vector{UInt8}}
byte_chunk::Dict{Symbol, Vector{UInt8}}
string_chunk::Dict{Symbol, AbstractVector{String}}
current_row_in_chunk_index::Int64
current_page::Int64
vendor::UInt8
use_base_transcoder::Bool
string_decoder_buffer::IOBuffer
string_decoder::StringDecoder
column_types_dict::CIDict{Symbol,Type}
Handler(config::ReaderConfig) = new(
Base.open(config.filename),
config)
end
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 8273 | # default settings
const default_chunk_size = 0
const default_verbose_level = 1
# interesting... using semicolons would make it into a 1-dimensional array
const magic = [
b"\x00\x00\x00\x00\x00\x00\x00\x00" ;
b"\x00\x00\x00\x00\xc2\xea\x81\x60" ;
b"\xb3\x14\x11\xcf\xbd\x92\x08\x00" ;
b"\x09\xc7\x31\x8c\x18\x1f\x10\x11" ]
const align_1_checker_value = b"3"
const align_1_offset = 32
const align_1_length = 1
const align_1_value = 4
const u64_byte_checker_value = b"3"
const align_2_offset = 35
const align_2_length = 1
const align_2_value = 4
const endianness_offset = 37
const endianness_length = 1
const platform_offset = 39
const platform_length = 1
const encoding_offset = 70
const encoding_length = 1
const dataset_offset = 92
const dataset_length = 64
const file_type_offset = 156
const file_type_length = 8
const date_created_offset = 164
const date_created_length = 8
const date_modified_offset = 172
const date_modified_length = 8
const header_size_offset = 196
const header_size_length = 4
const page_size_offset = 200
const page_size_length = 4
const page_count_offset = 204
const page_count_length = 4
const sas_release_offset = 216
const sas_release_length = 8
const sas_server_type_offset = 224
const sas_server_type_length = 16
const os_version_number_offset = 240
const os_version_number_length = 16
const os_maker_offset = 256
const os_maker_length = 16
const os_name_offset = 272
const os_name_length = 16
const page_bit_offset_x86 = 16
const page_bit_offset_x64 = 32
const subheader_pointer_length_x86 = 12
const subheader_pointer_length_x64 = 24
const page_type_offset = 0
const page_type_length = 2
const block_count_offset = 2
const block_count_length = 2
const subheader_count_offset = 4
const subheader_count_length = 2
const page_meta_type = 0
const page_data_type = 256
const page_amd_type = 1024
const page_metc_type = 16384
const page_comp_type = -28672
const page_mix_types = [512, 640]
const page_meta_data_mix_types = vcat(page_meta_type, page_data_type, page_mix_types)
const subheader_pointers_offset = 8
const subheader_comp_uncompressed = 0
const subheader_comp_truncated = 1
const subheader_comp_compressed = 4
const text_block_size_length = 2
const row_length_offset_multiplier = 5
const row_count_offset_multiplier = 6
const col_count_p1_multiplier = 9
const col_count_p2_multiplier = 10
const row_count_on_mix_page_offset_multiplier = 15
const column_name_pointer_length = 8
const column_name_text_subheader_offset = 0
const column_name_text_subheader_length = 2
const column_name_offset_offset = 2
const column_name_offset_length = 2
const column_name_length_offset = 4
const column_name_length_length = 2
const column_data_offset_offset = 8
const column_data_length_offset = 8
const column_data_length_length = 4
const column_type_offset = 14
const column_type_length = 1
const sas_date_origin = Date(1960, 1, 1)
const sas_datetime_origin = DateTime(sas_date_origin)
const rle_compression = b"SASYZCRL"
const rdc_compression = b"SASYZCR2"
const compression_method_none = 0x00
const compression_method_rle = 0x01
const compression_method_rdc = 0x02
# Courtesy of Evan Miller's ReadStat project
# Source: https://github.com/WizardMac/ReadStat/blob/master/src/sas/readstat_sas.c
const encoding_names = Dict(
20 => "UTF-8",
28 => "US-ASCII",
29 => "ISO-8859-1",
30 => "ISO-8859-2",
31 => "ISO-8859-3",
34 => "ISO-8859-6",
35 => "ISO-8859-7",
36 => "ISO-8859-8",
39 => "ISO-8859-11",
40 => "ISO-8859-9",
60 => "WINDOWS-1250",
61 => "WINDOWS-1251",
62 => "WINDOWS-1252",
63 => "WINDOWS-1253",
64 => "WINDOWS-1254",
65 => "WINDOWS-1255",
66 => "WINDOWS-1256",
67 => "WINDOWS-1257",
118 => "CP950",
119 => "EUC-TW",
123 => "BIG5-HKSCS",
125 => "GB18030",
126 => "CP936",
134 => "EUC-JP",
138 => "CP932",
140 => "EUC-KR",
141 => "CP949"
)
const index_rowSizeIndex = 0
const index_rowSizeIndex = 0
const index_columnSizeIndex = 1
const index_subheaderCountsIndex = 2
const index_columnTextIndex = 3
const index_columnNameIndex = 4
const index_columnAttributesIndex = 5
const index_formatAndLabelIndex = 6
const index_columnListIndex = 7
const index_dataSubheaderIndex = 8
const index_end_of_header = 100
const subheader_signature_to_index = Dict(
b"\xF7\xF7\xF7\xF7" => index_rowSizeIndex,
b"\xF7\xF7\xF7\xF7\x00\x00\x00\x00" => index_rowSizeIndex,
b"\x00\x00\x00\x00\xF7\xF7\xF7\xF7" => index_rowSizeIndex,
b"\xF7\xF7\xF7\xF7\xFF\xFF\xFB\xFE" => index_rowSizeIndex,
b"\xF6\xF6\xF6\xF6" => index_columnSizeIndex,
b"\x00\x00\x00\x00\xF6\xF6\xF6\xF6" => index_columnSizeIndex,
b"\xF6\xF6\xF6\xF6\x00\x00\x00\x00" => index_columnSizeIndex,
b"\xF6\xF6\xF6\xF6\xFF\xFF\xFB\xFE" => index_columnSizeIndex,
b"\x00\xFC\xFF\xFF" => index_subheaderCountsIndex,
b"\xFF\xFF\xFC\x00" => index_subheaderCountsIndex,
b"\x00\xFC\xFF\xFF\xFF\xFF\xFF\xFF" => index_subheaderCountsIndex,
b"\xFF\xFF\xFF\xFF\xFF\xFF\xFC\x00" => index_subheaderCountsIndex,
b"\xFD\xFF\xFF\xFF" => index_columnTextIndex,
b"\xFF\xFF\xFF\xFD" => index_columnTextIndex,
b"\xFD\xFF\xFF\xFF\xFF\xFF\xFF\xFF" => index_columnTextIndex,
b"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD" => index_columnTextIndex,
b"\xFF\xFF\xFF\xFF" => index_columnNameIndex,
b"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" => index_columnNameIndex,
b"\xFC\xFF\xFF\xFF" => index_columnAttributesIndex,
b"\xFF\xFF\xFF\xFC" => index_columnAttributesIndex,
b"\xFC\xFF\xFF\xFF\xFF\xFF\xFF\xFF" => index_columnAttributesIndex,
b"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC" => index_columnAttributesIndex,
b"\xFE\xFB\xFF\xFF" => index_formatAndLabelIndex,
b"\xFF\xFF\xFB\xFE" => index_formatAndLabelIndex,
b"\xFE\xFB\xFF\xFF\xFF\xFF\xFF\xFF" => index_formatAndLabelIndex,
b"\xFF\xFF\xFF\xFF\xFF\xFF\xFB\xFE" => index_formatAndLabelIndex,
b"\xFE\xFF\xFF\xFF" => index_columnListIndex,
b"\xFF\xFF\xFF\xFE" => index_columnListIndex,
b"\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF" => index_columnListIndex,
b"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE" => index_columnListIndex
)
# List of frequently used SAS date and datetime formats
# http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_intervals_sect009.htm
# https://github.com/epam/parso/blob/master/src/main/java/com/epam/parso/impl/SasFileConstants.java
const sas_date_formats = ["DATE", "DAY", "DDMMYY", "DOWNAME", "JULDAY", "JULIAN",
"MMDDYY", "MMYY", "MMYYC", "MMYYD", "MMYYP", "MMYYS",
"MMYYN", "MONNAME", "MONTH", "MONYY", "QTR", "QTRR",
"NENGO", "WEEKDATE", "WEEKDATX", "WEEKDAY", "WEEKV",
"WORDDATE", "WORDDATX", "YEAR", "YYMM", "YYMMC", "YYMMD",
"YYMMP", "YYMMS", "YYMMN", "YYMON", "YYMMDD", "YYQ",
"YYQC", "YYQD", "YYQP", "YYQS", "YYQN", "YYQR", "YYQRC",
"YYQRD", "YYQRP", "YYQRS", "YYQRN",
"YYMMDDP", "YYMMDDC", "E8601DA", "YYMMDDN", "MMDDYYC",
"MMDDYYS", "MMDDYYD", "YYMMDDS", "B8601DA", "DDMMYYN",
"YYMMDDD", "DDMMYYB", "DDMMYYP", "MMDDYYP", "YYMMDDB",
"MMDDYYN", "DDMMYYC", "DDMMYYD", "DDMMYYS",
"MINGUO"]
const sas_datetime_formats = ["DATETIME", "DTWKDATX",
"B8601DN", "B8601DT", "B8601DX", "B8601DZ", "B8601LX",
"E8601DN", "E8601DT", "E8601DX", "E8601DZ", "E8601LX",
"DATEAMPM", "DTDATE", "DTMONYY", "DTMONYY", "DTWKDATX",
"DTYEAR", "TOD", "MDYAMPM"]
const zero_space = b"\x00 "
const column_type_none = 0x00
const column_type_decimal = 0x01
const column_type_string = 0x02
const VENDOR_STAT_TRANSFER = 0x00
const VENDOR_SAS = 0x01
const FALLBACK_ENCODING = "UTF-8"
const ENCODINGS_OK_WITH_BASE_TRANSCODER = [ "UTF-8" , "US-ASCII" ]
const REGULAR_STR_ARRAY(n) = Array{String}(undef, n)
const EMPTY_STRING = ""
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 864 | # This file implements Tables interface and provide compatibility
# to the Queryverse ecosystem.
# -----------------------------------------------------------------------------
# Tables.jl implementation
Tables.istable(::Type{<:ResultSet}) = true
# AbstractColumns interface
Tables.columnaccess(::Type{<:ResultSet}) = true
Tables.columns(rs::ResultSet) = rs
Tables.getcolumn(rs::ResultSet, i::Int) = rs[names(rs)[i]]
# AbstractRow interface
Tables.rowaccess(::Type{<:ResultSet}) = true
Tables.rows(rs::ResultSet) = rs
# Schema definition
Tables.schema(rs::ResultSet) = Tables.Schema(names(rs), eltype.(columns(rs)))
# -----------------------------------------------------------------------------
# Queryverse compatibility
IteratorInterfaceExtensions.getiterator(rs::ResultSet) = Tables.datavaluerows(rs)
TableTraits.isiterabletable(x::ResultSet) = true
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 8415 | """
Strip from the right end of the `bytes` array for any byte that matches the ones
specified in the `remove` argument. See Python's bytes.rstrip function.
"""
function brstrip(bytes::AbstractVector{UInt8}, remove::AbstractVector{UInt8})
for i in length(bytes):-1:1
x = bytes[i]
found = false
for m in remove
if x == m
found = true
break
end
end
if !found
return bytes[1:i]
end
end
return Vector{UInt8}()
end
# """
# Faster version of rstrip (slightly modified version from julia master branch)
# """
# function rstrip2(s::String)
# i = endof(s)
# while 1 ≤ i
# c = s[i]
# j = prevind(s, i)
# c == ' ' || return s[1:i]
# i = j
# end
# EMPTY_STRING
# end
"""
Find needle in the haystack with both `Vector{UInt8}` type arguments.
"""
function contains(haystack::AbstractVector{UInt8}, needle::AbstractVector{UInt8})
hlen = length(haystack)
nlen = length(needle)
if hlen >= nlen
for i in 1:hlen-nlen+1
if haystack[i:i+nlen-1] == needle
return true
end
end
end
return false
end
# Fast implementation to `reinterpret` int/floats
# See https://discourse.julialang.org/t/newbie-question-convert-two-8-byte-values-into-a-single-16-byte-value/7662/5
# Version a. Original implementation... slow.
# """
# Byte swap is needed only if file the array represent a different endianness
# than the system. This function does not make any assumption and the caller
# is expected to pass `true` to the `swap` argument when needed.
# """
# function convertfloat64a(bytes::Vector{UInt8}, swap::Bool)
# # global count_a
# # count_a::Int64 += 1
# values = [bytes[i:i+8-1] for i in 1:8:length(bytes)]
# values = map(x -> reinterpret(Float64, x)[1], values)
# swap ? bswap.(values) : values
# end
# Version b. Should be a lot faster.
# julia> @btime convertfloat64b(r, :LittleEndian);
# 370.677 μs (98 allocations: 395.41 KiB)
# """
# It turns out that `reinterpret` consider a single UInt64 as BigEndian
# Hence it's necessary to swap bytes if the array is in LittleEndian convention.
# This function does not make any assumption and the caller
# is expected to pass `true` to the `swap` argument when needed.
# """
# function convertfloat64b(bytes::Vector{UInt8}, endianess::Symbol)
# # global count_b
# # count_b::Int64 += 1
# v = endianess == :LittleEndian ? reverse(bytes) : bytes
# c = convertint64.(v[1:8:end],v[2:8:end],v[3:8:end],v[4:8:end],
# v[5:8:end], v[6:8:end], v[7:8:end], v[8:8:end])
# r = reinterpret.(Float64, c)
# endianess == :LittleEndian ? reverse(r) : r
# end
# Version c
# julia> @btime convertfloat64c(r, :LittleEndian);
# 75.835 μs (2 allocations: 78.20 KiB)
# function convertfloat64c(bytes::Vector{UInt8}, endianess::Symbol)
# L = length(bytes)
# n = div(L, 8) # numbers to convert
# r = zeros(Float64, n) # results
# j = 1 # result index
# @inbounds for i in 1:8:L
# if endianess == :LittleEndian
# r[j] = reinterpret(Float64, convertint64(
# bytes[i+7], bytes[i+6], bytes[i+5], bytes[i+4],
# bytes[i+3], bytes[i+2], bytes[i+1], bytes[i]))
# else
# r[j] = reinterpret(Float64, convertint64(
# bytes[i], bytes[i+1], bytes[i+2], bytes[i+3],
# bytes[i+4], bytes[i+5], bytes[i+6], bytes[i+7]))
# end
# j += 1
# end
# r
# end
# Version d
# julia> @btime convertfloat64d(r, :LittleEndian);
# 184.463 μs (4 allocations: 156.47 KiB)
# function convertfloat64d(bytes::Vector{UInt8}, endianess::Symbol)
# if endianess == :LittleEndian
# v = reverse(bytes)
# else
# v = bytes
# end
# L = length(bytes)
# n = div(L, 8) # numbers to convert
# r = zeros(Float64, n) # results
# j = n # result index
# for i in 1:8:L
# r[j] = reinterpret(Float64, convertint64(
# v[i], v[i+1], v[i+2], v[i+3],
# v[i+4], v[i+5], v[i+6], v[i+7]))
# j -= 1
# end
# r
# end
# Version e - same as version c except that it does bit-shifting
# inline here in a new way.
# julia> @btime convertfloat64e(r, :LittleEndian);
# 174.685 μs (2 allocations: 78.20 KiB)
# function convertfloat64e(bytes::Vector{UInt8}, endianess::Symbol)
# L = length(bytes)
# n = div(L, 8) # numbers to convert
# r = zeros(Float64, n) # results
# j = 1 # result index
# for i in 1:8:L
# v = UInt64(0)
# if endianess == :LittleEndian
# for k in 7:-1:1
# v = (v | bytes[i + k]) << 8
# end
# v |= bytes[i]
# else
# for k in 0:6
# v = (v | bytes[i + k]) << 8
# end
# v |= bytes[i + 7]
# end
# r[j] = reinterpret(Float64, v)
# j += 1
# end
# r
# end
# Version f. Best one so far!
# julia> @btime convertfloat64f(r, :LittleEndian)
# 35.132 μs (2 allocations: 78.20 KiB)
#
# results will be updated directly in the provided array `r`
function convertfloat64f!(r::AbstractVector{Float64}, bytes::Vector{UInt8}, endianess::Symbol)
L = length(bytes)
n = div(L, 8) # numbers to convert
j = 1 # result index
@inbounds for i in 1:8:L
if endianess == :LittleEndian
r[j] = reinterpret(Float64,
UInt64(bytes[i+7]) << 56 |
UInt64(bytes[i+6]) << 48 |
UInt64(bytes[i+5]) << 40 |
UInt64(bytes[i+4]) << 32 |
UInt64(bytes[i+3]) << 24 |
UInt64(bytes[i+2]) << 16 |
UInt64(bytes[i+1]) << 8 |
UInt64(bytes[i]))
else
r[j] = reinterpret(Float64,
UInt64(bytes[i]) << 56 |
UInt64(bytes[i+1]) << 48 |
UInt64(bytes[i+2]) << 40 |
UInt64(bytes[i+3]) << 32 |
UInt64(bytes[i+4]) << 24 |
UInt64(bytes[i+5]) << 16 |
UInt64(bytes[i+6]) << 8 |
UInt64(bytes[i+7]))
end
j += 1
end
r
end
# Conversion routines for 1,2,4,8-byte words into a single 64-bit integer
@inline function convertint64B(a::UInt8,b::UInt8,c::UInt8,d::UInt8,e::UInt8,f::UInt8,g::UInt8,h::UInt8)
(Int64(a) << 56) | (Int64(b) << 48) | (Int64(c) << 40) | (Int64(d) << 32) |
(Int64(e) << 24) | (Int64(f) << 16) | (Int64(g) << 8) | Int64(h)
end
@inline function convertint64L(a::UInt8,b::UInt8,c::UInt8,d::UInt8,e::UInt8,f::UInt8,g::UInt8,h::UInt8)
(Int64(h) << 56) | (Int64(g) << 48) | (Int64(f) << 40) | (Int64(e) << 32) |
(Int64(d) << 24) | (Int64(c) << 16) | (Int64(b) << 8) | Int64(a)
end
@inline function convertint64B(a::UInt8,b::UInt8,c::UInt8,d::UInt8)
(Int64(a) << 24) | (Int64(b) << 16) | (Int64(c) << 8) | Int64(d)
end
@inline function convertint64L(a::UInt8,b::UInt8,c::UInt8,d::UInt8)
(Int64(d) << 24) | (Int64(c) << 16) | (Int64(b) << 8) | Int64(a)
end
@inline function convertint64B(a::UInt8,b::UInt8)
(Int64(a) << 8) | Int64(b)
end
@inline function convertint64L(a::UInt8,b::UInt8)
(Int64(b) << 8) | Int64(a)
end
# this version is slightly slower
# function convertint64b(a::UInt8,b::UInt8,c::UInt8,d::UInt8,e::UInt8,f::UInt8,g::UInt8,h::UInt8)
# v = UInt64(a) << 8
# v |= b ; v <<= 8
# v |= c ; v <<= 8
# v |= d ; v <<= 8
# v |= e ; v <<= 8
# v |= f ; v <<= 8
# v |= g ; v <<= 8
# v |= h
# v
# end
# TODO cannot use AbstractString for some reasons
# """
# Concatenate an array of strings to a single string
# """
# concatenate(strArray::Vector{T} where T <: AbstractString, separator=",") =
# foldl((x, y) -> *(x, y, separator), "", strArray)[1:end-length(separator)]
# """
# Convert a dictionary to an array of k=>v strings
# """
# stringarray(dict::Dict) =
# ["$x => $y" for (x, y) in dict]
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 878 | using SASLib, PooledArrays, BenchmarkTools
versioninfo()
opfn(size) = SASLib.ObjectPool{String}{UInt32}("", size)
pafn(size) = PooledArray{String,UInt32}(fill("", size))
rafn(size) = fill("", size)
size = 100000
dishes = ["food$i" for i in 1:size]
assignitems = (x::AbstractArray, y::AbstractArray) -> x[1:end] = y[1:end]
nsamples = 5000
nseconds = 600
println("** Regular Array **")
bra = @benchmarkable assignitems(x, y) setup=((x,y)=($rafn($size), $dishes)) samples=nsamples seconds=nseconds
display(run(bra))
println("\n\n** Pooled Array (Dict Pool) **")
bpa = @benchmarkable assignitems(x, y) setup=((x,y)=($pafn($size), $dishes)) samples=nsamples seconds=nseconds
display(run(bpa))
println("\n\n** Object Pool **")
bop = @benchmarkable assignitems(x, y) setup=((x,y)=($opfn($size), $dishes)) samples=nsamples seconds=nseconds
display(run(bop))
println()
println()
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 370 | using BenchmarkTools
using InteractiveUtils
using Printf
if length(ARGS) != 2
println("Usage: $PROGRAM_FILE <filename> <count>")
exit()
end
versioninfo()
println()
load_time = @elapsed using SASLib
@printf "Loaded library in %.3f seconds\n" load_time
b = @benchmark readsas($ARGS[1], verbose_level=0) samples=parse(Int, ARGS[2])
display(b)
println()
println()
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 3809 | using BenchmarkTools
using SASLib
using ReadStat
using Printf
if length(ARGS) != 1
println("Usage: julia ", PROGRAM_FILE, " <output-dir>")
exit(1)
end
dir = ARGS[1]
if !isdir(dir)
println("Error: ", dir, " does not exist")
exit(2)
end
function performtest(io, f, samples, seconds)
println(io, "\n\n================ $f =================")
mime = MIME("text/plain")
try
@info("testing $f with ReadStat")
println(io, "ReadStat:")
b1 = @benchmark read_sas7bdat($f) samples=samples seconds=seconds
show(io, mime, b1)
println(io)
@info("testing $f with SASLib")
println(io, "SASLib:")
b2 = @benchmark readsas($f, verbose_level=0) samples=samples seconds=seconds
show(io, mime, b2)
println(io)
@info("testing $f with SASLib regular string")
println(io, "SASLib (regular string):")
b3 = @benchmark readsas($f, string_array_fn=Dict(:_all_ => REGULAR_STR_ARRAY), verbose_level=0) samples=samples seconds=seconds
show(io, mime, b3)
println(io)
md = metadata(f)
nd = count(x -> last(x) == Float64, md.columnsinfo)
ns = count(x -> last(x) == String, md.columnsinfo)
nt = md.ncols - ns - nd
println("debug: meta nd=$nd ns=$ns nt=$nt")
t1 = minimum(b1).time / 1000000
t2 = minimum(b2).time / 1000000
t3 = minimum(b3).time / 1000000
p2 = round(Int, t2/t1*100)
p3 = round(Int, t3/t1*100)
comp = md.compression
@info("Results: ", join(string.([f,t1,t2,p2,t3,p3,nd,ns,nt,comp]), ","))
@printf io "%-40s: %8.3f ms %8.3f ms (%3d%%) %8.3f ms (%3d%%) %4d %4d %4d %4s\n" f t1 t2 p2 t3 p3 nd ns nt comp
catch ex
println(ex)
b = " "
@printf io "%-40s: %8s ms %8s ms (%3s%%) %8s ms (%3s%%) %4s %4s %4s %4s\n" f b b b b b b b b b
finally
flush(io)
end
end
open("$dir/saslib_vs_readstat.log", "w") do io
@printf io "%-40s: %8s %8s %3s %8s %3s %4s %4s %4s %4s\n" "Filename" "ReadStat" "SASLib" "S/R" "SASLibA" "SA/R" "F64" "STR" "DT" "COMP"
files = [
("data_pandas/test3.sas7bdat", 10000, 5),
("data_misc/numeric_1000000_2.sas7bdat", 100, 5),
("data_misc/types.sas7bdat", 10000, 5),
("data_AHS2013/homimp.sas7bdat", 10000, 5),
("data_AHS2013/omov.sas7bdat", 10000, 5),
("data_AHS2013/owner.sas7bdat", 10000, 5),
("data_AHS2013/ratiov.sas7bdat", 10000,5),
("data_AHS2013/rmov.sas7bdat", 10000, 5),
("data_AHS2013/topical.sas7bdat", 10000, 30),
("data_pandas/airline.sas7bdat", 10000, 5),
("data_pandas/datetime.sas7bdat", 10000, 5),
("data_pandas/productsales.sas7bdat", 10000, 10),
("data_pandas/test1.sas7bdat", 10000, 5),
("data_pandas/test2.sas7bdat", 10000, 5),
("data_pandas/test4.sas7bdat", 10000, 5),
("data_pandas/test5.sas7bdat", 10000, 5),
("data_pandas/test6.sas7bdat", 10000, 5),
("data_pandas/test7.sas7bdat", 10000, 5),
("data_pandas/test8.sas7bdat", 10000, 5),
("data_pandas/test9.sas7bdat", 10000, 5),
("data_pandas/test11.sas7bdat", 10000, 5),
("data_pandas/test10.sas7bdat", 10000, 5),
("data_pandas/test12.sas7bdat", 10000, 5),
("data_pandas/test13.sas7bdat", 10000, 5),
("data_pandas/test14.sas7bdat", 10000, 5),
("data_pandas/test15.sas7bdat", 10000, 5),
("data_pandas/test16.sas7bdat", 10000, 5),
("data_pandas/zero_variables.sas7bdat", 10000, 5),
("data_reikoch/barrows.sas7bdat", 10000, 5),
("data_reikoch/binary.sas7bdat", 10000, 5),
("data_reikoch/extr.sas7bdat", 10000, 5),
("data_reikoch/ietest2.sas7bdat", 10000, 5),
]
for (f, x, y) in files
performtest(io, f, x, y)
end
end
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 366 | using BenchmarkTools
if length(ARGS) != 2
println("Usage: $PROGRAM_FILE <filename> <count>")
exit()
end
versioninfo()
println()
tic()
using SASLib
@printf "Loaded library in %.3f seconds\n" toq()
b = @benchmark readsas($ARGS[1], verbose_level=0, string_array_fn=Dict(:_all_ => REGULAR_STR_ARRAY)) samples=parse(Int, ARGS[2])
display(b)
println()
println()
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 3161 | # Compare loading one file in Python vs Julia
using Dates
using InteractiveUtils: versioninfo
if length(ARGS) != 3
println("Usage: $PROGRAM_FILE <filename> <count> <outputdir>")
exit()
end
using SASLib, BenchmarkTools
using Humanize: datasize
file = ARGS[1]
cnt = ARGS[2]
dir = ARGS[3]
basename = split(file, "/")[end]
shortname = replace(basename, r"\.sas7bdat" => "")
output = "$dir/py_jl_$(shortname)_$(cnt).md"
prt(msg...) = println(now(), " ", msg...)
# run python part
# result is minimum time in seconds
prt("Running python test for file ", file, " ", cnt, " times")
pyver_cmd = `python -V`
pyres_cmd = `python perf_test1.py $file $cnt`
pyver = readlines(open(pyver_cmd))[1]
pyres = readlines(open(pyres_cmd))[1] # first line of result is Minimum
py = parse(Float64, match(r"[0-9]*\.[0-9]*", pyres).match)
# read metadata
prt("Reading metadata of data file")
meta = metadata(file)
nrows = meta.nrows
ncols = meta.ncols
nnumcols = count(x -> x == Float64, [ty for (name, ty) in meta.columnsinfo])
nstrcols = ncols - nnumcols
# run julia part
prt("Running julia test")
jlb1 = @benchmark readsas(file, verbose_level=0) samples=parse(Int, cnt)
jl1 = jlb1.times[1] / 1e9 # convert nanoseconds to seconds
# run julia part using regular string array
if nstrcols > 0
prt("Running julia test (regular string array)")
jlb2 = @benchmark readsas(file, string_array_fn=Dict(:_all_=>REGULAR_STR_ARRAY),
verbose_level=0) samples=parse(Int, cnt)
jl2 = jlb2.times[1] / 1e9 # convert nanoseconds to seconds
jl = min(jl1, jl2) # pick faster run
jltitle = "Julia (ObjectPool)"
else
jl = jl1
jltitle = "Julia"
end
# analysis
direction = jl < py ? "faster" : "slower"
ratio = round(direction == "faster" ? py/jl : jl/py, digits = 1)
io = nothing
try
io = open(output, "w")
println(io, "# Julia/Python Performance Test Result")
println(io)
println(io, "## Summary")
println(io)
println(io, "Julia is ~$(ratio)x $direction than Python/Pandas")
println(io)
println(io, "## Test File")
println(io)
println(io, "Iterations: $cnt")
println(io)
println(io, "Filename|Size|Rows|Columns|Numeric Columns|String Columns")
println(io, "--------|----|----|-------|---------------|--------------")
println(io, "$basename|$(datasize(lstat(file).size))|$nrows|$ncols|$nnumcols|$nstrcols")
println(io, "")
println(io, "## Python")
println(io, "```")
println(io, "\$ $(join(pyver_cmd.exec, " "))")
println(io, pyver)
println(io, "\$ $(join(pyres_cmd.exec, " "))")
println(io, pyres)
println(io, "```")
println(io)
println(io, "## $jltitle")
println(io, "```")
versioninfo(io)
println(io)
show(io, MIME"text/plain"(), jlb1)
println(io, "\n```")
if nstrcols > 0
println(io)
println(io, "## Julia (Regular String Array)")
println(io, "```")
versioninfo(io)
println(io)
show(io, MIME"text/plain"(), jlb2)
println(io, "\n```")
end
catch err
println(err)
finally
io !== nothing && try close(io) catch e println(e) end
end
prt("Written file $output")
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 155 | using SASLib
files = filter(x -> endswith(x, "sas7bdat"), Base.Filesystem.readdir())
for f in files
println("=== $f ===")
result = readsas(f)
end
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | code | 18418 | using Test
using SASLib
using Dates
using Statistics: mean
using SharedArrays: SharedArray
using Tables
import IteratorInterfaceExtensions, TableTraits
using StringEncodings: encode,decode
function getpath(dir, file)
path = joinpath(dir, file)
#println("================ $path ================")
path
end
readfile(dir, file; kwargs...) = readsas(getpath(dir, file); kwargs...)
openfile(dir, file; kwargs...) = SASLib.open(getpath(dir, file), kwargs...)
getmetadata(dir, file; kwargs...) = metadata(getpath(dir, file), kwargs...)
# Struct used for column type conversion test case below
struct YearStr year::String end
Base.convert(::Type{YearStr}, v::Float64) = YearStr(string(round(Int, v)))
@testset "SASLib" begin
@testset "object pool" begin
println("Testing object pool...")
# string pool
default = ""
x = SASLib.ObjectPool{String, UInt8}(default, 5)
@test length(x) == 5
@test size(x) == (5, )
@test lastindex(x) == 5
@test count(v -> v == default, x) == 5
@test count(v -> v === default, x) == 5
@test map(v -> "x$v", x) == [ "x", "x", "x", "x", "x" ]
x[1] = "abc"
@test x[1] == "abc"
@test x.uniqueitemscount == 2
x[2] = "abc"
@test x[2] == "abc"
@test x.uniqueitemscount == 2
x[3] = "xyz"
@test x.uniqueitemscount == 3
@test x.itemscount == 5
@test_throws BoundsError x[6] == ""
# tuple pool
y = SASLib.ObjectPool{Tuple, UInt8}((1,1,1), 100)
y[1:100] = [(v, v, v) for v in 1:100]
@test y[1] == (1,1,1)
@test y[2] == (2,2,2)
@test y[100] == (100,100,100)
@test y.uniqueitemscount == 100 # first one is the same as the default
# more error conditions
z = SASLib.ObjectPool{Int, UInt8}(0, 1000)
@test_throws BoundsError z[1:300] = 1:300
end
@testset "object pool datatype" begin
println("Testing object pool datatype selection...")
# should not error when nrow = 255 due to incorrect datatype selected for ObjectPool
s = SASLib.readsas("data_objectpool/pooltest255.sas7bdat")
@test size(s, 1) == 255
end
@testset "case insensitive dict" begin
function testdict(lowercase_key, mixedcase_key, second_lowercase_key)
T = typeof(lowercase_key)
d = SASLib.CIDict{T,Int}()
# getindex/setindex!
d[lowercase_key] = 99
@test d[lowercase_key] == 99
@test d[mixedcase_key] == 99
d[mixedcase_key] = 88 # should replace original value
@test length(d) == 1 # still 1 element
@test d[lowercase_key] == 88
@test d[mixedcase_key] == 88
# haskey
@test haskey(d, lowercase_key) == true
@test haskey(d, mixedcase_key) == true
# iteration
d[second_lowercase_key] = 77
ks = T[]
vs = Int[]
for (k,v) in d
push!(ks, k)
push!(vs, v)
end
@test ks == [lowercase_key, second_lowercase_key]
@test vs == [88, 77]
# keys/values
@test collect(keys(d)) == [lowercase_key, second_lowercase_key]
@test collect(values(d)) == [88, 77]
# show
@test show(d) == nothing
end
testdict(:abc, :ABC, :def)
testdict("abc", "ABC", "def")
end
@testset "open and close" begin
handler = openfile("data_pandas", "test1.sas7bdat")
@test typeof(handler) == SASLib.Handler
@test handler.config.filename == getpath("data_pandas", "test1.sas7bdat")
@test SASLib.close(handler) == nothing
end
@testset "read basic test files (test*.sas7bdat)" begin
dir = "data_pandas"
files = filter(x -> endswith(x, "sas7bdat") && startswith(x, "test"),
Base.Filesystem.readdir("$dir"))
for f in files
result = readfile(dir, f)
@test size(result) == (10, 100)
end
end
@testset "incremental read" begin
handler = openfile("data_pandas", "test1.sas7bdat")
@test handler.config.filename == getpath("data_pandas", "test1.sas7bdat")
result = SASLib.read(handler, 3) # read 3 rows
@test size(result, 1) == 3
result = SASLib.read(handler, 4) # read 4 rows
@test size(result, 1) == 4
result = SASLib.read(handler, 5) # should read only 3 rows even though we ask for 5
@test size(result, 1) == 3
end
@testset "various data types" begin
rs = readfile("data_pandas", "test1.sas7bdat")
@test sum(rs[:Column1][1:5]) == 2.066
@test count(isnan, rs[:Column1]) == 1
@test rs[:Column98][1:3] == [ "apple", "dog", "pear" ]
@test rs[:Column4][1:3] == [Date("1965-12-10"), Date("1977-03-07"), Date("1983-08-15")]
end
@testset "datetime with missing values" begin
rs = readfile("data_pandas", "datetime.sas7bdat")
@test size(rs) == (5, 4)
@test rs[:mtg][1] == Date(2017, 11, 24)
@test rs[:dt][5] == DateTime(2018, 3, 31, 14, 20, 33)
@test count(ismissing, rs[:mtg]) == 1
@test count(ismissing, rs[:dt]) == 3
end
@testset "include/exclude columns" begin
fname = getpath("data_pandas", "productsales.sas7bdat")
rs = readsas(fname, include_columns=[:MONTH, :YEAR])
@test size(rs, 2) == 2
@test sort(names(rs)) == sort([:MONTH, :YEAR])
rs = readsas(fname, include_columns=[1, 2, 7])
@test size(rs, 2) == 3
@test sort(names(rs)) == sort([:ACTUAL, :PREDICT, :PRODUCT])
rs = readsas(fname, exclude_columns=[:DIVISION])
@test size(rs, 2) == 9
@test !(:DIVISION in names(rs))
rs = readsas(fname, exclude_columns=collect(2:10))
@test size(rs, 2) == 1
@test sort(names(rs)) == sort([:ACTUAL])
# case insensitive include/exclude
rs = readsas(fname, include_columns=[:month, :Year])
@test size(rs, 2) == 2
rs = readsas(fname, exclude_columns=[:diVisiON])
@test size(rs, 2) == 9
# test bad include/exclude param
# see https://discourse.julialang.org/t/test-warn-doesnt-work-with-warn-in-0-7/9001
@test_logs (:warn, "Unknown include column blah") (:warn,
"Unknown include column Year") readsas(fname, include_columns=[:blah, :Year])
@test_logs (:warn, "Unknown exclude column blah") (:warn,
"Unknown exclude column Year") readsas(fname, exclude_columns=[:blah, :Year])
# error handling
@test_throws SASLib.ConfigError readsas(fname,
include_columns=[1], exclude_columns=[1])
end
@testset "ResultSet" begin
rs = readfile("data_pandas", "productsales.sas7bdat")
# metadata for result set
@test size(rs) == (1440, 10)
@test size(rs,1) == 1440
@test size(rs,2) == 10
@test length(columns(rs)) == 10
@test length(names(rs)) == 10
# cell indexing
@test rs[1][1] ≈ 925.0
@test rs[1,1] ≈ 925.0
@test rs[1,:ACTUAL] ≈ 925.0
# row/column indexing
@test typeof(rs[1]) == NamedTuple{
(:ACTUAL, :PREDICT, :COUNTRY, :REGION, :DIVISION, :PRODTYPE, :PRODUCT, :QUARTER, :YEAR, :MONTH),
Tuple{Float64,Float64,String,String,String,String,String,Float64,Float64,Dates.Date}}
@test typeof(rs[:ACTUAL]) == Array{Float64,1}
@test sum(rs[:ACTUAL]) ≈ 730337.0
# iteration
@test sum(r[1] for r in rs) ≈ 730337.0
# portion of result set
@test typeof(rs[1:2]) == SASLib.ResultSet
@test typeof(rs[:ACTUAL, :PREDICT]) == SASLib.ResultSet
@test rs[1:2][1][1] ≈ 925.0
@test rs[:ACTUAL, :PREDICT][1][1] ≈ 925.0
# setindex!
let rscopy = deepcopy(rs)
rs[1,1] = 100.0
@test rs[1,1] ≈ 100.0
rs[1,:ACTUAL] = 200.0
@test rs[1,:ACTUAL] ≈ 200.0
end
# display related
@test show(rs) == nothing
@test SASLib.sizestr(rs) == "1440 rows x 10 columns"
# Tables.jl
let twocols = rs[:ACTUAL, :PREDICT]
# General
@test Tables.istable(typeof(rs))
@test Tables.rowaccess(typeof(rs))
@test Tables.columnaccess(typeof(rs))
# AbstractRow interface
let row = twocols[3] # (ACTUAL = 608.0, PREDICT = 846.0)
@test Tables.getcolumn(row, 1) ≈ 608.0
@test Tables.getcolumn(row, :ACTUAL) ≈ 608.0
@test Tables.columnnames(row) === (:ACTUAL, :PREDICT)
end
# AbstractColumns interface
let tab = Tables.columns(twocols)
@test Tables.getcolumn(tab, 1) isa Array{Float64,1}
@test Tables.getcolumn(tab, 1) |> size === (1440,)
@test Tables.getcolumn(tab, :ACTUAL) isa Array{Float64,1}
@test Tables.getcolumn(tab, :ACTUAL) |> size === (1440,)
@test Tables.columnnames(tab) === propertynames(twocols)
end
# Usages
@test size(Tables.matrix(twocols)) == (1440, 2)
end
# old tests
#@test Tables.schema(rs).names == Tuple(names(rs))
#@test Tables.schema(rs).types == Tuple(eltype.([rs[s] for s in names(rs)]))
#@test length(Tables.rowtable(rs)) == 1440
#@test length(Tables.columntable(rs)) == 10
#@test size(Tables.matrix(rs[:ACTUAL, :PREDICT])) == (1440,2)
#@test Tables.rows(rs) |> first |> propertynames |> Tuple == Tuple(names(rs))
#@test Tables.columns(rs) |> propertynames |> Tuple == Tuple(names(rs))
# Queryverse integration
@test TableTraits.isiterabletable(rs) == true
@test eltype(IteratorInterfaceExtensions.getiterator(rs)) <: NamedTuple
@test IteratorInterfaceExtensions.getiterator(rs) |> first |> propertynames |> Tuple == Tuple(names(rs))
end
@testset "metadata" begin
md = getmetadata("data_pandas", "test1.sas7bdat")
@test md.filename == getpath("data_pandas", "test1.sas7bdat")
@test md.encoding == "WINDOWS-1252"
@test md.endianness == :LittleEndian
@test md.compression == :none
@test md.pagesize == 65536
@test md.npages == 1
@test md.nrows == 10
@test md.ncols == 100
@test length(md.columnsinfo) == 100
@test md.columnsinfo[1] == Pair(:Column1, Float64)
md = getmetadata("data_pandas", "productsales.sas7bdat")
@test show(md) == nothing
println()
# convenient comparison routine since v0.6/v0.7 displays different order
same(x,y) = sort(string.(collect(x))) == sort(string.(collect(y)))
@test same(SASLib.typesof(Int64), (Int64,))
@test same(SASLib.typesof(Union{Int64,Int32}), (Int64,Int32))
@test same(SASLib.typesof(Union{Int64,Int32,Missing}),
(Int64,Int32,Missing))
@test SASLib.typesfmt((Int64,)) == "Int64"
@test SASLib.typesfmt((Int64,Int32)) == "Int64/Int32"
@test SASLib.typesfmt((Int64,Int32,Missing)) == "Int64/Int32/Missing"
@test SASLib.typesfmt((Int64,Int32); excludemissing=true) == "Int64/Int32"
@test SASLib.typesfmt((Int64,Int32,Missing); excludemissing=true) == "Int64/Int32"
@test SASLib.colfmt(md)[1] == "ACTUAL(Float64)"
end
@testset "stat_transfer" begin
rs = readfile("data_misc", "types.sas7bdat")
@test sum(rs[:vbyte][1:2]) == 9
@test sum(rs[:vint][1:2]) == 9
@test sum(rs[:vlong][1:2]) == 9
@test sum(rs[:vfloat][1:2]) ≈ 10.14000010
@test sum(rs[:vdouble][1:2]) ≈ 10.14000000
end
# topical.sas7bdat contains columns labels which should be ignored anywas
@testset "AHS2013" begin
handler = openfile("data_AHS2013", "topical.sas7bdat")
rs = SASLib.read(handler, 1000)
@test size(rs) == (1000, 114)
@test show(handler) == nothing
SASLib.close(handler)
# @test result[:page_count] == 10
# @test result[:page_length] == 16384
# @test result[:system_endianness] == :LittleEndian
@test count(x -> x == "B", rs[:DPEVVEHIC]) == 648
@test mean(filter(!isnan, rs[:PTCOSTGAS])) ≈ 255.51543209876544
end
@testset "file encodings" begin
rs = readfile("data_reikoch", "extr.sas7bdat")
# @test result[:file_encoding] == "CP932"
@test rs[:AETXT][1] == "眠気"
rs = readfile("data_pandas", "test1.sas7bdat", encoding = "US-ASCII")
# @test result[:file_encoding] == "US-ASCII"
@test rs[:Column42][3] == "dog"
end
@testset "taiwan encodings" begin
# check cp950 support , the most prevalent encoding on traditional Han characters ;compatible with big5-2003
@test encode("€","CP950")==[0xa3, 0xe1]
# check big5-hkscs 2008 support, stringencodings is based on iconv but old version iconv had problem on east asian character esp. on hkscs
@test encode("鿋","big5-hkscs") == [0x87, 0xdf] # big5-hkscs is compatible with big5-2003 but not fully compatible with CP950
# cp950 encoding
rs = readfile("data_big5", "cp950.sas7bdat")
@test rs[1,1] == "我愛你"
# wlatin1 encoding , this works on winxp ansi system but not in new unicode system
rs = readfile("data_big5", "testbig5.sas7bdat", encoding = "cp950")
@test rs[1,1] == "我愛你"
# wlatin1 encoding , format on winxp ansi system
rs = readfile("data_big5", "testbig5.sas7bdat")
@test decode(encode(rs[1,1],"cp1252"),"cp950") == "我愛你"
end
@testset "handler object" begin
handler = openfile("data_reikoch", "binary.sas7bdat")
@test handler.U64 == true
@test handler.byte_swap == true
@test handler.column_data_lengths == [8,8,8,8,8,8,8,8,8,8,14]
@test handler.column_data_offsets == [0,8,16,24,32,40,48,56,64,72,80]
@test handler.column_names == ["I","I1","I2","I3","I4","I5","I6","I7","I8","I9","CHAR"]
@test handler.column_symbols == [:I,:I1,:I2,:I3,:I4,:I5,:I6,:I7,:I8,:I9,:CHAR]
@test handler.compression == 0x02
@test handler.file_encoding == "ISO-8859-1"
@test handler.file_endianness == :BigEndian
@test handler.header_length == 8192
@test handler.page_length == 8192
@test handler.row_count == 100
@test handler.vendor == 0x01
@test handler.config.convert_dates == true
@test handler.config.include_columns == []
@test handler.config.exclude_columns == []
@test handler.config.encoding == ""
end
@testset "array constructors" begin
rs = readfile("data_AHS2013", "homimp.sas7bdat")
@test typeof(rs[:RAS]) == SASLib.ObjectPool{String,UInt16}
# string_array_fn test for specific string columns
rs = readfile("data_AHS2013", "homimp.sas7bdat",
string_array_fn = Dict(:RAS => REGULAR_STR_ARRAY))
@test typeof(rs[:RAS]) == Array{String,1}
@test typeof(rs[:RAH]) != Array{String,1}
# string_array_fn test for all string columns
rs = readfile("data_AHS2013", "homimp.sas7bdat",
string_array_fn = Dict(:_all_ => REGULAR_STR_ARRAY))
@test typeof(rs[:RAS]) == Array{String,1}
@test typeof(rs[:RAH]) == Array{String,1}
@test typeof(rs[:JRAS]) == Array{String,1}
@test typeof(rs[:JRAD]) == Array{String,1}
@test typeof(rs[:CONTROL]) == Array{String,1}
# number_array_fn test by column name
makesharedarray(n) = SharedArray{Float64}(n)
rs = readfile("data_misc", "numeric_1000000_2.sas7bdat",
number_array_fn = Dict(:f => makesharedarray))
@test typeof(rs[:f]) == SharedArray{Float64,1}
@test typeof(rs[:x]) == Array{Float64,1}
# number_array_fn test for all numeric columns
rs = readfile("data_misc", "numeric_1000000_2.sas7bdat",
number_array_fn = Dict(:_all_ => makesharedarray))
@test typeof(rs[:f]) == SharedArray{Float64,1}
@test typeof(rs[:x]) == SharedArray{Float64,1}
end
# column type conversion
@testset "user specified column types" begin
# normal use case
rs = readfile("data_pandas", "productsales.sas7bdat";
verbose_level = 0, column_types = Dict(:YEAR => Int16, :QUARTER => Int8))
@test eltype(rs[:YEAR]) == Int16
@test eltype(rs[:QUARTER]) == Int8
# error handling - warn() when a column cannot be converted
rs = readfile("data_pandas", "productsales.sas7bdat";
verbose_level = 0, column_types = Dict(:YEAR => Int8, :QUARTER => Int8))
@test eltype(rs[:YEAR]) == Float64
@test eltype(rs[:QUARTER]) == Int8
#TODO expect warning for :YEAR conversion
# case insensitive column symbol
rs = readfile("data_pandas", "productsales.sas7bdat";
verbose_level = 0, column_types = Dict(:Quarter => Int8))
@test eltype(rs[:QUARTER]) == Int8
# conversion to custom types
rs = readfile("data_pandas", "productsales.sas7bdat";
verbose_level = 0, column_types = Dict(:Year => YearStr))
@test eltype(rs[:YEAR]) == YearStr
# test Union type
let T = Union{Int,Missing}
rs = readfile("data_pandas", "productsales.sas7bdat";
verbose_level = 0, column_types = Dict(:Year => T))
@test eltype(rs[:YEAR]) == T
end
end
# see output; keep this for coverage reason
@testset "verbosity" begin
rs = readfile("data_pandas", "test1.sas7bdat"; verbose_level = 2)
@test size(rs, 1) > 0
end
@testset "just reads" begin
for dir in ["data_pandas", "data_reikoch", "data_AHS2013", "data_misc"]
for f in readdir(dir)
if endswith(f, ".sas7bdat") &&
!(f in ["zero_variables.sas7bdat"])
rs = readfile(dir, f)
@test size(rs, 1) > 0
end
end
end
end
@testset "exception" begin
@test_throws SASLib.FileFormatError readsas("runtests.jl")
end
end
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 3213 | # Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 160 | # Contribution Guidelines
Thank you for considering contribution to this project!
Any help is greatly appreciated, no matter how small your pull request is.
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 158 | Please write a concise summary of the issue.
Include expected & actual results for bug reports and
attach any relevant data files for reproducing the issue.
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 16008 | # SASLib.jl
[](https://github.com/tk3369/SASLib.jl/actions?query=workflow%3ACI)
[](https://ci.appveyor.com/project/tk3369/saslib-jl/branch/master)
[](http://codecov.io/github/tk3369/SASLib.jl?branch=master)

SASLib is a fast reader for sas7bdat files. The goal is to allow easier integration with SAS processes. Only `sas7bdat` format is supported. SASLib is licensed under the MIT Expat license.
## Installation
```
Pkg.add("SASLib")
```
## Read Performance
I did benchmarking mostly on my Macbook Pro laptop. In general, the Julia implementation is somewhere between 10-100x faster than the Python Pandas. Test results are documented in the `test/perf_results_<version>` folders.
Latest performance [test results for v1.0.0](test/perf_results_1.0.0) is as follows:
Test|Result|
----|------|
py\_jl\_homimp\_50.md |30x faster than Python/Pandas|
py\_jl\_numeric\_1000000\_2\_100.md |10x faster than Python/Pandas|
py\_jl\_productsales\_100.md |50x faster than Python/Pandas|
py\_jl\_test1\_100.md |120x faster than Python/Pandas|
py\_jl\_topical\_30.md |30x faster than Python/Pandas|
## User Guide
```
julia> using SASLib
```
### Reading SAS Files
Use the `readsas` function to read a SAS7BDAT file.
```julia
julia> rs = readsas("productsales.sas7bdat")
Read productsales.sas7bdat with size 1440 x 10 in 0.00256 seconds
SASLib.ResultSet (1440 rows x 10 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:COUNTRY, 4:REGION, 5:DIVISION, 6:PRODTYPE, 7:PRODUCT, 8:QUARTER, 9:YEAR, 10:MONTH
1: 925.0, 850.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-01-01
2: 999.0, 297.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-02-01
3: 608.0, 846.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-03-01
4: 642.0, 533.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 2.0, 1993.0, 1993-04-01
5: 656.0, 646.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 2.0, 1993.0, 1993-05-01
⋮
```
### Accessing Results
There are several ways to access the data conveniently without using any third party packages. Each cell value may be retrieved directly via the regular `[i,j]` index. Accessing an entire row or column returns a tuple and a vector respectively.
#### Direct cell access
```
julia> rs[4,2]
533.0
julia> rs[4, :PREDICT]
533.0
```
#### Indexing by row number returns a named tuple
```
julia> rs[1]
(ACTUAL = 925.0, PREDICT = 850.0, COUNTRY = "CANADA", REGION = "EAST", DIVISION = "EDUCATION", PRODTYPE = "FURNITURE", PRODUCT = "SOFA", QUARTER = 1.0, YEAR = 1993.0, MONTH = 1993-01-01)
```
#### Columns access by name via indexing or as a property
```
julia> rs[:ACTUAL]
1440-element Array{Float64,1}:
925.0
999.0
608.0
⋮
julia> rs.ACTUAL
1440-element Array{Float64,1}:
925.0
999.0
608.0
⋮
```
#### Slice a range of rows
```
julia> rs[2:4]
SASLib.ResultSet (3 rows x 10 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:COUNTRY, 4:REGION, 5:DIVISION, 6:PRODTYPE, 7:PRODUCT, 8:QUARTER, 9:YEAR, 10:MONTH
1: 999.0, 297.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-02-01
2: 608.0, 846.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-03-01
3: 642.0, 533.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 2.0, 1993.0, 1993-04-01
```
#### Slice a subset of columns
```
julia> rs[:ACTUAL, :PREDICT, :YEAR, :MONTH]
SASLib.ResultSet (1440 rows x 4 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:YEAR, 4:MONTH
1: 925.0, 850.0, 1993.0, 1993-01-01
2: 999.0, 297.0, 1993.0, 1993-02-01
3: 608.0, 846.0, 1993.0, 1993-03-01
4: 642.0, 533.0, 1993.0, 1993-04-01
5: 656.0, 646.0, 1993.0, 1993-05-01
⋮
```
### Mutation
You may assign values at the cell level, causing a side effect in memory:
```
julia> srs = rs[:ACTUAL, :PREDICT, :YEAR, :MONTH][1:2]
SASLib.ResultSet (2 rows x 4 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:YEAR, 4:MONTH
1: 925.0, 850.0, 1993.0, 1993-01-01
2: 999.0, 297.0, 1993.0, 1993-02-01
julia> srs[2,2] = 3
3
julia> rs[1:2]
SASLib.ResultSet (2 rows x 10 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:COUNTRY, 4:REGION, 5:DIVISION, 6:PRODTYPE, 7:PRODUCT, 8:QUARTER, 9:YEAR, 10:MONTH
1: 925.0, 850.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-01-01
2: 999.0, 3.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-02-01
```
### Iteration
ResultSet implements the usual standard iteration interface, so it's easy to walk through the results:
```
julia> mean(r.ACTUAL - r.PREDICT for r in rs)
16.695833333333333
```
### Metadata
There are simple functions to retrieve meta information about a ResultSet.
```
names(rs)
size(rs)
length(rs)
```
### Tables.jl / DataFrame
It may be beneficial to convert the result set to DataFrame for more complex queries and manipulations.
The `SASLib.ResultSet` object implements the [Tables.jl](https://github.com/JuliaData/Tables.jl) interface,
so you can directly create a DataFrame as shown below:
```julia
julia> df = DataFrame(rs);
julia> first(df, 5)
5×10 DataFrame
│ Row │ ACTUAL │ PREDICT │ COUNTRY │ REGION │ DIVISION │ PRODTYPE │ PRODUCT │ QUARTER │ YEAR │ MONTH │
│ │ Float64 │ Float64 │ String │ String │ String │ String │ String │ Float64 │ Float64 │ Dates…⍰ │
├─────┼─────────┼─────────┼─────────┼────────┼───────────┼───────────┼─────────┼─────────┼─────────┼────────────┤
│ 1 │ 925.0 │ 850.0 │ CANADA │ EAST │ EDUCATION │ FURNITURE │ SOFA │ 1.0 │ 1993.0 │ 1993-01-01 │
│ 2 │ 999.0 │ 297.0 │ CANADA │ EAST │ EDUCATION │ FURNITURE │ SOFA │ 1.0 │ 1993.0 │ 1993-02-01 │
│ 3 │ 608.0 │ 846.0 │ CANADA │ EAST │ EDUCATION │ FURNITURE │ SOFA │ 1.0 │ 1993.0 │ 1993-03-01 │
│ 4 │ 642.0 │ 533.0 │ CANADA │ EAST │ EDUCATION │ FURNITURE │ SOFA │ 2.0 │ 1993.0 │ 1993-04-01 │
│ 5 │ 656.0 │ 646.0 │ CANADA │ EAST │ EDUCATION │ FURNITURE │ SOFA │ 2.0 │ 1993.0 │ 1993-05-01 │
```
### Inclusion/Exclusion of Columns
**Column Inclusion**
It is always faster to read only the columns that you need. The `include_columns` argument comes in handy:
```
julia> rs = readsas("productsales.sas7bdat", include_columns=[:YEAR, :MONTH, :PRODUCT, :ACTUAL])
Read productsales.sas7bdat with size 1440 x 4 in 0.00151 seconds
SASLib.ResultSet (1440 rows x 4 columns)
Columns 1:ACTUAL, 2:PRODUCT, 3:YEAR, 4:MONTH
1: 925.0, SOFA, 1993.0, 1993-01-01
2: 999.0, SOFA, 1993.0, 1993-02-01
3: 608.0, SOFA, 1993.0, 1993-03-01
4: 642.0, SOFA, 1993.0, 1993-04-01
5: 656.0, SOFA, 1993.0, 1993-05-01
⋮
```
**Column Exclusion**
Likewise, you can read all columns except the ones you don't want as specified in `exclude_columns` argument:
```
julia> rs = readsas("productsales.sas7bdat", exclude_columns=[:YEAR, :MONTH, :PRODUCT, :ACTUAL])
Read productsales.sas7bdat with size 1440 x 6 in 0.00265 seconds
SASLib.ResultSet (1440 rows x 6 columns)
Columns 1:PREDICT, 2:COUNTRY, 3:REGION, 4:DIVISION, 5:PRODTYPE, 6:QUARTER
1: 850.0, CANADA, EAST, EDUCATION, FURNITURE, 1.0
2: 297.0, CANADA, EAST, EDUCATION, FURNITURE, 1.0
3: 846.0, CANADA, EAST, EDUCATION, FURNITURE, 1.0
4: 533.0, CANADA, EAST, EDUCATION, FURNITURE, 2.0
5: 646.0, CANADA, EAST, EDUCATION, FURNITURE, 2.0
⋮
```
**Case Sensitivity and Column Number**
Column symbols are matched in a case insensitive manner with SAS column names.
Both `include_columns` and `exclude_columns` accept column number. In fact, you can mixed column symbols and column numbers as such:
```
julia> readsas("productsales.sas7bdat", include_columns=[:actual, :predict, 8, 9, 10])
Read productsales.sas7bdat with size 1440 x 5 in 0.16378 seconds
SASLib.ResultSet (1440 rows x 5 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:QUARTER, 4:YEAR, 5:MONTH
1: 925.0, 850.0, 1.0, 1993.0, 1993-01-01
2: 999.0, 297.0, 1.0, 1993.0, 1993-02-01
3: 608.0, 846.0, 1.0, 1993.0, 1993-03-01
4: 642.0, 533.0, 2.0, 1993.0, 1993-04-01
5: 656.0, 646.0, 2.0, 1993.0, 1993-05-01
⋮
```
### Incremental Reading
If you need to read files incrementally, you can use the `SASLib.open` function to obtain a handle of the file. Then, use the `SASLib.read` function to fetch a number of rows. Remember to close the handler with `SASLib.close` to avoid memory leak.
```julia
julia> handler = SASLib.open("productsales.sas7bdat")
SASLib.Handler[productsales.sas7bdat]
julia> rs = SASLib.read(handler, 2)
Read productsales.sas7bdat with size 2 x 10 in 0.06831 seconds
SASLib.ResultSet (2 rows x 10 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:COUNTRY, 4:REGION, 5:DIVISION, 6:PRODTYPE, 7:PRODUCT, 8:QUARTER, 9:YEAR, 10:MONTH
1: 925.0, 850.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-01-01
2: 999.0, 297.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-02-01
julia> rs = SASLib.read(handler, 3)
Read productsales.sas7bdat with size 3 x 10 in 0.00046 seconds
SASLib.ResultSet (3 rows x 10 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:COUNTRY, 4:REGION, 5:DIVISION, 6:PRODTYPE, 7:PRODUCT, 8:QUARTER, 9:YEAR, 10:MONTH
1: 608.0, 846.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-03-01
2: 642.0, 533.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 2.0, 1993.0, 1993-04-01
3: 656.0, 646.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 2.0, 1993.0, 1993-05-01
julia> SASLib.close(handler)
```
Note that there is no facility at the moment to jump and read a subset of rows.
SASLib always read from the beginning.
### String Column Constructor
By default, string columns are read into a special AbstractArray structure called `ObjectPool` in order to conserve memory space that might otherwise be wasted for duplicate string values. SASLib tries to be smart -- when it encounters too many unique values (> 10%) in a large array (> 2000 rows), it falls back to a regular Julia array.
You can use a different array type (e.g. [CategoricalArray](https://github.com/JuliaData/CategoricalArrays.jl) or [PooledArray](https://github.com/JuliaComputing/PooledArrays.jl)) for any columns as you wish by specifying a `string_array_fn` parameter when reading the file. This argument must be a Dict that maps a column symbol into a function that takes an integer argument and returns any array of that size.
Here's the normal case:
```
julia> rs = readsas("productsales.sas7bdat", include_columns=[:COUNTRY, :REGION]);
Read productsales.sas7bdat with size 1440 x 2 in 0.00193 seconds
julia> typeof.(columns(rs))
2-element Array{DataType,1}:
SASLib.ObjectPool{String,UInt16}
SASLib.ObjectPool{String,UInt16}
```
If you really want a regular String array, you can force SASLib to do so as such:
```
julia> rs = readsas("productsales.sas7bdat", include_columns=[:COUNTRY, :REGION],
string_array_fn=Dict(:COUNTRY => (n)->fill("",n)));
Read productsales.sas7bdat with size 1440 x 2 in 0.00333 seconds
julia> typeof.(columns(rs))
2-element Array{DataType,1}:
Array{String,1}
SASLib.ObjectPool{String,UInt16}
```
For convenience, `SASLib.REGULAR_STR_ARRAY` is a function that does exactly that. In addition, if you need all columns to be configured the same then the key of the `string_array_fn` dict may be just the symbol `:_all_`.
```
julia> rs = readsas("productsales.sas7bdat", include_columns=[:COUNTRY, :REGION],
string_array_fn=Dict(:_all_ => REGULAR_STR_ARRAY));
Read productsales.sas7bdat with size 1440 x 2 in 0.00063 seconds
julia> typeof.(columns(rs))
2-element Array{DataType,1}:
Array{String,1}
Array{String,1}
```
### Numeric Columns Constructor
In general, SASLib allocates native arrays when returning numerical column data. However, you can provide a custom constructor so you would be able to either pre-allcoate the array or construct a different type of array. The `number_array_fn` parameter is a `Dict` that maps column symbols to the custom constructors. Similar to `string_array_fn`, this Dict may be specified with a special symbol `:_all_` to indicate such constructor be used for all numeric columns.
Example - create `SharedArray`:
```
julia> rs = readsas("productsales.sas7bdat", include_columns=[:ACTUAL,:PREDICT],
number_array_fn=Dict(:ACTUAL => (n)->SharedArray{Float64}(n)));
Read productsales.sas7bdat with size 1440 x 2 in 0.00385 seconds
julia> typeof.(columns(rs))
2-element Array{DataType,1}:
SharedArray{Float64,1}
Array{Float64,1}
```
Example - preallocate arrays:
```
julia> A = zeros(1440, 2);
julia> f1(n) = @view A[:, 1];
julia> f2(n) = @view A[:, 2];
julia> readsas("productsales.sas7bdat", include_columns=[:ACTUAL,:PREDICT],
number_array_fn=Dict(:ACTUAL => f1, :PREDICT => f2));
Read productsales.sas7bdat with size 1440 x 2 in 0.00041 seconds
julia> A[1:5,:]
5×2 Array{Float64,2}:
925.0 850.0
999.0 297.0
608.0 846.0
642.0 533.0
656.0 646.0
```
### Column Type Conversion
Often, you want a column to be an integer but the SAS7BDAT stores everything as Float64. Specifying the `column_type` argument does the conversion for you.
```
julia> rs = readsas("productsales.sas7bdat", column_types=Dict(:ACTUAL=>Int))
Read productsales.sas7bdat with size 1440 x 10 in 0.08043 seconds
SASLib.ResultSet (1440 rows x 10 columns)
Columns 1:ACTUAL, 2:PREDICT, 3:COUNTRY, 4:REGION, 5:DIVISION, 6:PRODTYPE, 7:PRODUCT, 8:QUARTER, 9:YEAR, 10:MONTH
1: 925, 850.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-01-01
2: 999, 297.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-02-01
3: 608, 846.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 1.0, 1993.0, 1993-03-01
4: 642, 533.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 2.0, 1993.0, 1993-04-01
5: 656, 646.0, CANADA, EAST, EDUCATION, FURNITURE, SOFA, 2.0, 1993.0, 1993-05-01
julia> typeof(rs[:ACTUAL])
Array{Int64,1}
```
### File Metadata
You may obtain meta data for a SAS data file using the `metadata` function.
```julia
julia> md = metadata("productsales.sas7bdat")
File: productsales.sas7bdat (1440 x 10)
1:ACTUAL(Float64) 5:DIVISION(String) 9:YEAR(Float64)
2:PREDICT(Float64) 6:PRODTYPE(String) 10:MONTH(Date/Missings.Missing)
3:COUNTRY(String) 7:PRODUCT(String)
4:REGION(String) 8:QUARTER(Float64)
```
It's OK to access the fields directly.
```julia
julia> fieldnames(SASLib.Metadata)
9-element Array{Symbol,1}:
:filename
:encoding
:endianness
:compression
:pagesize
:npages
:nrows
:ncols
:columnsinfo
julia> md = metadata("test3.sas7bdat");
julia> md.compression
:RDC
```
## Related Packages
[ReadStat.jl](https://github.com/davidanthoff/ReadStat.jl) uses the [ReadStat C-library](https://github.com/WizardMac/ReadStat). However, ReadStat-C does not support reading RDC-compressed binary files.
[StatFiles.jl](https://github.com/davidanthoff/StatFiles.jl) is a higher-level package built on top of ReadStat.jl and implements the [FileIO](https://github.com/JuliaIO/FileIO.jl) interface.
[Python Pandas](https://github.com/pandas-dev/pandas) package has an implementation of SAS file reader that SASLib borrows heavily from.
## Credits
- Jared Hobbs, the author of the SAS reader code from Pandas. See LICENSE_SAS7BDAT.md.
- [Evan Miller](https://github.com/evanmiller), the author of ReadStat C/C++ library. See LICENSE_READSTAT.md.
- [David Anthoff](https://github.com/davidanthoff), who provided many valuable ideas at the early stage of development.
- [Tyler Beason](https://github.com/tbeason)
- [susabi](https://github.com/xiaodaigh)
I also want to thank all the active members at the [Julia Discourse community](https://discourse.julialang.org). This project wouldn't be possible without all the help I got from the community. That's the beauty of open-source development.
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 207 | The data sets here are borrowed from US Census American Housing Survey (AHS)
https://www.census.gov/programs-surveys/ahs/data/2013/ahs-2013-public-use-file--puf-/ahs-2013-national-public-use-file--puf-.html
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 182 | The data sets here are borrowed from the Pandas package
http://pandas.pydata.org/
The files are located at
https://github.com/pandas-dev/pandas/tree/master/pandas/tests/io/sas/data
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 150 | The data sets here are borrowed from https://github.com/reikoch/testfiles/
Note:
The file `tt.sas7bdat` isn't used here as it seems to be corrupted.
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1425 | # Performance Test 1
## Summary
Python is approximately 10% faster than the Julia implementation.
## Test File
Filename|Rows|Columns|Numeric Columns|String Columns
--------|----|-------|---------------|--------------
numeric_1000000_2.sas7bdat|1,000,000|2|2|0
## Test Environment
Test system information:
```
julia> versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py numeric_1000000_2.sas7bdat
1: elapsed 1.844023 seconds
2: elapsed 1.806474 seconds
3: elapsed 1.795621 seconds
4: elapsed 1.812769 seconds
5: elapsed 1.850064 seconds
6: elapsed 1.882453 seconds
7: elapsed 1.863802 seconds
8: elapsed 1.871220 seconds
9: elapsed 1.874004 seconds
10: elapsed 1.861223 seconds
Average: 1.8462 seconds
```
## Julia
```
$ julia perf_test1.jl numeric_1000000_2.sas7bdat
Loaded library in 0.225 seconds
Bootstrap elapsed 4.569 seconds
Elapsed 2.133 seconds
Elapsed 2.107 seconds
Elapsed 2.146 seconds
Elapsed 1.995 seconds
Elapsed 2.072 seconds
Elapsed 2.103 seconds
Elapsed 2.040 seconds
Elapsed 2.082 seconds
Elapsed 2.070 seconds
Elapsed 2.013 seconds
Average: 2.076054688 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1358 | # Performance Test 2
## Summary
Julia is 8x faster than Python!
## Test File
Filename |Rows|Columns|Numeric Columns|String Columns
--------------|----|-------|---------------|--------------
test1.sas7bdat|10 |100 |73 |27
## Test Environment
```
julia> versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py test1.sas7bdat
1: elapsed 0.127801 seconds
2: elapsed 0.104040 seconds
3: elapsed 0.115647 seconds
4: elapsed 0.102978 seconds
5: elapsed 0.100335 seconds
6: elapsed 0.101916 seconds
7: elapsed 0.099474 seconds
8: elapsed 0.097988 seconds
9: elapsed 0.102512 seconds
10: elapsed 0.097088 seconds
Average: 0.1050 seconds
```
## Julia
```
$ julia perf_test1.jl test1.sas7bdat
Loaded library in 0.224 seconds
Bootstrap elapsed 2.829 seconds
Elapsed 0.010 seconds
Elapsed 0.017 seconds
Elapsed 0.011 seconds
Elapsed 0.015 seconds
Elapsed 0.010 seconds
Elapsed 0.010 seconds
Elapsed 0.014 seconds
Elapsed 0.024 seconds
Elapsed 0.009 seconds
Elapsed 0.012 seconds
Average: 0.0131050582 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1411 | # Performance Test 3
## Summary
Julia is 3.5x _slower_ than Python!
## Test File
Filename |Rows |Columns|Numeric Columns|String Columns
---------------------|------|-------|---------------|--------------
productsales.sas7bdat|1440 |10 |4 |6
## Test Environment
```
julia> versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py productsales.sas7bdat
1: elapsed 0.038040 seconds
2: elapsed 0.030986 seconds
3: elapsed 0.039832 seconds
4: elapsed 0.031767 seconds
5: elapsed 0.041312 seconds
6: elapsed 0.033195 seconds
7: elapsed 0.039814 seconds
8: elapsed 0.030574 seconds
9: elapsed 0.040095 seconds
10: elapsed 0.031431 seconds
Average: 0.0357 seconds
```
## Julia
```
$ julia perf_test1.jl productsales.sas7bdat
Loaded library in 0.212 seconds
Bootstrap elapsed 2.920 seconds
Elapsed 0.129 seconds
Elapsed 0.128 seconds
Elapsed 0.126 seconds
Elapsed 0.123 seconds
Elapsed 0.126 seconds
Elapsed 0.128 seconds
Elapsed 0.129 seconds
Elapsed 0.128 seconds
Elapsed 0.124 seconds
Elapsed 0.125 seconds
Average: 0.12677397689999997 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1396 | # Performance Test 1
## Summary
Julia is ~4.8x faster than Python.
## Test File
Filename|Rows|Columns|Numeric Columns|String Columns
--------|----|-------|---------------|--------------
numeric_1000000_2.sas7bdat|1,000,000|2|2|0
## Test Environment
Test system information:
```
julia> versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py numeric_1000000_2.sas7bdat
1: elapsed 1.904393 seconds
2: elapsed 1.862869 seconds
3: elapsed 1.849762 seconds
4: elapsed 1.869796 seconds
5: elapsed 1.851429 seconds
6: elapsed 1.847917 seconds
7: elapsed 1.858680 seconds
8: elapsed 1.897174 seconds
9: elapsed 1.877440 seconds
10: elapsed 1.860925 seconds
Average: 1.8680 seconds
```
## Julia
```
$ julia perf_test1.jl numeric_1000000_2.sas7bdat
Loaded library in 2.387 seconds
Bootstrap elapsed 3.018 seconds
Elapsed 0.456 seconds
Elapsed 0.455 seconds
Elapsed 0.466 seconds
Elapsed 0.364 seconds
Elapsed 0.468 seconds
Elapsed 0.464 seconds
Elapsed 0.366 seconds
Elapsed 0.464 seconds
Elapsed 0.459 seconds
Elapsed 0.367 seconds
Average: 0.432819138 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1351 | # Performance Test 2
## Summary
Julia is 7.6x faster than Python.
## Test File
Filename |Rows|Columns|Numeric Columns|String Columns
--------------|----|-------|---------------|--------------
test1.sas7bdat|10 |100 |73 |27
## Test Environment
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py test1.sas7bdat
1: elapsed 0.160085 seconds
2: elapsed 0.102635 seconds
3: elapsed 0.106069 seconds
4: elapsed 0.099819 seconds
5: elapsed 0.097443 seconds
6: elapsed 0.096373 seconds
7: elapsed 0.104192 seconds
8: elapsed 0.096230 seconds
9: elapsed 0.103648 seconds
10: elapsed 0.099993 seconds
Average: 0.1066 seconds
```
## Julia
```
$ julia perf_test1.jl test1.sas7bdat
Loaded library in 0.233 seconds
Bootstrap elapsed 2.821 seconds
Elapsed 0.011 seconds
Elapsed 0.010 seconds
Elapsed 0.011 seconds
Elapsed 0.017 seconds
Elapsed 0.022 seconds
Elapsed 0.012 seconds
Elapsed 0.012 seconds
Elapsed 0.014 seconds
Elapsed 0.010 seconds
Elapsed 0.021 seconds
Average: 0.013979034499999998 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1382 | # Performance Test 3
## Summary
Julia is 4.1x faster than Python
## Test File
Filename |Rows |Columns|Numeric Columns|String Columns
---------------------|------|-------|---------------|--------------
productsales.sas7bdat|1440 |10 |4 |6
## Test Environment
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py productsales.sas7bdat
1: elapsed 0.034272 seconds
2: elapsed 0.030726 seconds
3: elapsed 0.036244 seconds
4: elapsed 0.031315 seconds
5: elapsed 0.036770 seconds
6: elapsed 0.028680 seconds
7: elapsed 0.038459 seconds
8: elapsed 0.033905 seconds
9: elapsed 0.036311 seconds
10: elapsed 0.031037 seconds
Average: 0.0338 seconds
```
## Julia
```
$ julia perf_test1.jl productsales.sas7bdat
Loaded library in 0.222 seconds
Bootstrap elapsed 2.571 seconds
Elapsed 0.007 seconds
Elapsed 0.006 seconds
Elapsed 0.007 seconds
Elapsed 0.006 seconds
Elapsed 0.007 seconds
Elapsed 0.018 seconds
Elapsed 0.008 seconds
Elapsed 0.008 seconds
Elapsed 0.007 seconds
Elapsed 0.010 seconds
Average: 0.0082903935 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1305 | # Read performance when reading only half of the data
## Results
Read time is reduced by 40% when reading half of the data.
## Test Scenario
This test file has just 2 numeric columns. We would like to know the performance
of reading only 1 column from this file.
Filename|Rows|Columns|Numeric Columns|String Columns
--------|----|-------|---------------|--------------
numeric_1000000_2.sas7bdat|1,000,000|2|2|0
## Test Log
```
julia> @benchmark readsas("numeric_1000000_2.sas7bdat", verbose_level=0)
BenchmarkTools.Trial:
memory estimate: 399.04 MiB
allocs estimate: 3031083
--------------
minimum time: 358.695 ms (9.31% GC)
median time: 442.709 ms (25.96% GC)
mean time: 427.870 ms (20.97% GC)
maximum time: 482.786 ms (25.29% GC)
--------------
samples: 12
evals/sample: 1
julia> @benchmark readsas("numeric_1000000_2.sas7bdat", include_columns=[:f], verbose_level=0)
BenchmarkTools.Trial:
memory estimate: 261.71 MiB
allocs estimate: 2031028
--------------
minimum time: 222.832 ms (9.67% GC)
median time: 235.396 ms (9.70% GC)
mean time: 261.782 ms (20.75% GC)
maximum time: 327.359 ms (33.53% GC)
--------------
samples: 20
evals/sample: 1
julia> 262/428
0.6121495327102804
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1397 | # Performance Test 1
## Summary
SASLib is ~4.3x faster than Pandas.
## Test File
Filename|Rows|Columns|Numeric Columns|String Columns
--------|----|-------|---------------|--------------
numeric_1000000_2.sas7bdat|1,000,000|2|2|0
## Test Environment
Test system information:
```
julia> versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py numeric_1000000_2.sas7bdat
1: elapsed 1.976702 seconds
2: elapsed 1.984404 seconds
3: elapsed 2.266284 seconds
4: elapsed 1.978403 seconds
5: elapsed 1.946053 seconds
6: elapsed 1.919336 seconds
7: elapsed 1.918322 seconds
8: elapsed 1.926547 seconds
9: elapsed 1.962013 seconds
10: elapsed 1.939654 seconds
Average: 1.9818 seconds
```
## Julia
```
$ julia perf_test1.jl numeric_1000000_2.sas7bdat
Loaded library in 0.343 seconds
Bootstrap elapsed 4.211 seconds
Elapsed 0.481 seconds
Elapsed 0.462 seconds
Elapsed 0.414 seconds
Elapsed 0.480 seconds
Elapsed 0.473 seconds
Elapsed 0.472 seconds
Elapsed 0.473 seconds
Elapsed 0.479 seconds
Elapsed 0.401 seconds
Elapsed 0.463 seconds
Average: 0.4598392924 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1344 | # Performance Test 2
## Summary
SASLib is 16.9x faster than Pandas.
## Test File
Filename |Rows|Columns|Numeric Columns|String Columns
--------------|----|-------|---------------|--------------
test1.sas7bdat|10 |100 |73 |27
## Test Environment
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py test1.sas7bdat
1: elapsed 0.099821 seconds
2: elapsed 0.116454 seconds
3: elapsed 0.095141 seconds
4: elapsed 0.100083 seconds
5: elapsed 0.100060 seconds
6: elapsed 0.098249 seconds
7: elapsed 0.101819 seconds
8: elapsed 0.099673 seconds
9: elapsed 0.096865 seconds
10: elapsed 0.109412 seconds
Average: 0.1018 seconds
```
## Julia
```
$ julia perf_test1.jl test1.sas7bdat
Loaded library in 0.326 seconds
Bootstrap elapsed 3.606 seconds
Elapsed 0.011 seconds
Elapsed 0.004 seconds
Elapsed 0.004 seconds
Elapsed 0.004 seconds
Elapsed 0.004 seconds
Elapsed 0.004 seconds
Elapsed 0.010 seconds
Elapsed 0.013 seconds
Elapsed 0.004 seconds
Elapsed 0.004 seconds
Average: 0.0060341937 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1393 | # Performance Test 3
## Summary
SASLib is 5.2x faster than Pandas.
## Test File
Filename |Rows |Columns|Numeric Columns|String Columns
---------------------|------|-------|---------------|--------------
productsales.sas7bdat|1440 |10 |4 |6
## Test Environment
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
```
## Python
```
$ python perf_test1.py productsales.sas7bdat
1: elapsed 0.035160 seconds
2: elapsed 0.031523 seconds
3: elapsed 0.041026 seconds
4: elapsed 0.033476 seconds
5: elapsed 0.045547 seconds
6: elapsed 0.030253 seconds
7: elapsed 0.038022 seconds
8: elapsed 0.032196 seconds
9: elapsed 0.046579 seconds
10: elapsed 0.033603 seconds
Average: 0.0367 seconds
```
## Julia
```
$ julia perf_test1.jl productsales.sas7bdat
Loaded library in 0.328 seconds
Bootstrap elapsed 3.613 seconds
Elapsed 0.013 seconds
Elapsed 0.005 seconds
Elapsed 0.005 seconds
Elapsed 0.004 seconds
Elapsed 0.007 seconds
Elapsed 0.008 seconds
Elapsed 0.007 seconds
Elapsed 0.011 seconds
Elapsed 0.007 seconds
Elapsed 0.005 seconds
Average: 0.0071251584000000005 seconds
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1189 | # Performance Test 1
## Summary
SASLib is ~11x faster than Pandas.
## Test File
Filename|Rows|Columns|Numeric Columns|String Columns
--------|----|-------|---------------|--------------
numeric_1000000_2.sas7bdat|1,000,000|2|2|0
## Python
```
$ python perf_test1.py data_misc/numeric_1000000_2.sas7bdat 30
Minimum: 1.8642 seconds
Median: 2.0716 seconds
Mean: 2.1451 seconds
Maximum: 2.7522 seconds
```
## Julia
```
$ julia perf_test1.jl data_misc/numeric_1000000_2.sas7bdat 30
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 0.655 seconds
BenchmarkTools.Trial:
memory estimate: 155.12 MiB
allocs estimate: 1035407
--------------
minimum time: 161.779 ms (3.74% GC)
median time: 211.446 ms (22.19% GC)
mean time: 211.389 ms (22.93% GC)
maximum time: 259.749 ms (34.46% GC)
--------------
samples: 24
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1172 | # Performance Test 2
## Summary
SASLib is 24x faster than Pandas.
## Test File
Filename |Rows|Columns|Numeric Columns|String Columns
--------------|----|-------|---------------|--------------
test1.sas7bdat|10 |100 |73 |27
## Python
```
$ python perf_test1.py data_pandas/test1.sas7bdat 100
Minimum: 0.0811 seconds
Median: 0.0871 seconds
Mean: 0.0890 seconds
Maximum: 0.1208 seconds
```
## Julia
```
$ julia perf_test1.jl data_pandas/test1.sas7bdat 100
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 0.705 seconds
BenchmarkTools.Trial:
memory estimate: 2.72 MiB
allocs estimate: 35788
--------------
minimum time: 3.384 ms (0.00% GC)
median time: 3.561 ms (0.00% GC)
mean time: 4.190 ms (8.75% GC)
maximum time: 9.082 ms (39.94% GC)
--------------
samples: 100
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 2030 | # Performance Test 3
## Summary
SASLib is ~7x faster than Pandas.
## Test File
Filename |Rows |Columns|Numeric Columns|String Columns
---------------------|------|-------|---------------|--------------
productsales.sas7bdat|1440 |10 |4 |6
## Python
```
$ python perf_test1.py data_pandas/productsales.sas7bdat 100
Minimum: 0.0281 seconds
Median: 0.0324 seconds
Mean: 0.0357 seconds
Maximum: 0.1242 seconds
```
## Julia (ObjectPool string array)
```
$ julia perf_test1.jl data_pandas/productsales.sas7bdat 100
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 0.630 seconds
BenchmarkTools.Trial:
memory estimate: 2.33 MiB
allocs estimate: 38737
--------------
minimum time: 3.984 ms (0.00% GC)
median time: 4.076 ms (0.00% GC)
mean time: 4.547 ms (7.03% GC)
maximum time: 8.595 ms (43.79% GC)
--------------
samples: 100
evals/sample: 1
```
## Julia (regular string array)
```
$ julia perf_test_regarray.jl data_pandas/productsales.sas7bdat 100
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 0.619 seconds
BenchmarkTools.Trial:
memory estimate: 2.31 MiB
allocs estimate: 38664
--------------
minimum time: 3.299 ms (0.00% GC)
median time: 3.725 ms (0.00% GC)
mean time: 4.223 ms (9.15% GC)
maximum time: 9.616 ms (43.66% GC)
--------------
samples: 100
evals/sample: 1
``` | SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1376 | ```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
** Regular Array **
BenchmarkTools.Trial:
memory estimate: 781.33 KiB
allocs estimate: 2
--------------
minimum time: 170.532 μs (0.00% GC)
median time: 368.824 μs (0.00% GC)
mean time: 630.629 μs (21.69% GC)
maximum time: 23.323 ms (0.00% GC)
--------------
samples: 5000
evals/sample: 1
** Pooled Array (Dict Pool) **
BenchmarkTools.Trial:
memory estimate: 9.43 MiB
allocs estimate: 65
--------------
minimum time: 35.474 ms (0.00% GC)
median time: 42.527 ms (0.00% GC)
mean time: 43.822 ms (5.10% GC)
maximum time: 110.314 ms (0.00% GC)
--------------
samples: 5000
evals/sample: 1
** Object Pool **
BenchmarkTools.Trial:
memory estimate: 7.10 MiB
allocs estimate: 51
--------------
minimum time: 28.510 ms (0.00% GC)
median time: 34.356 ms (0.00% GC)
mean time: 35.081 ms (3.44% GC)
maximum time: 80.241 ms (0.00% GC)
--------------
samples: 5000
evals/sample: 1
``` | SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 2688 | ```
Summary data_misc/numeric_1000000_2.sas7bdat : 207.649 ms , 188.812 ms ( 91%), 180.369 ms ( 87%)
Summary data_misc/types.sas7bdat : 0.093 ms , 0.410 ms (441%), 0.408 ms (439%)
Summary data_AHS2013/homimp.sas7bdat : 40.031 ms , 78.469 ms (196%), 66.235 ms (165%)
Summary data_AHS2013/omov.sas7bdat : 2.562 ms , 12.410 ms (484%), 10.991 ms (429%)
Summary data_AHS2013/owner.sas7bdat : 13.667 ms , 23.267 ms (170%), 17.216 ms (126%)
Summary data_AHS2013/ratiov.sas7bdat : 4.742 ms , 11.082 ms (234%), 7.611 ms (161%)
Summary data_AHS2013/rmov.sas7bdat : 56.492 ms , 202.621 ms (359%), 210.545 ms (373%)
Summary data_AHS2013/topical.sas7bdat : 2417.321 ms , 4157.654 ms (172%), 5371.401 ms (222%)
Summary data_pandas/airline.sas7bdat : 0.106 ms , 0.413 ms (389%), 0.419 ms (395%)
Summary data_pandas/datetime.sas7bdat : 0.080 ms , 0.425 ms (529%), 0.425 ms (529%)
Summary data_pandas/productsales.sas7bdat : 2.277 ms , 4.046 ms (178%), 3.309 ms (145%)
Summary data_pandas/test1.sas7bdat : 0.837 ms , 3.344 ms (399%), 3.322 ms (397%)
Summary data_pandas/test2.sas7bdat : 0.855 ms , 3.234 ms (378%), 3.197 ms (374%)
Summary data_pandas/test4.sas7bdat : 0.839 ms , 3.381 ms (403%), 3.327 ms (396%)
Summary data_pandas/test5.sas7bdat : 0.855 ms , 3.310 ms (387%), 3.167 ms (371%)
Summary data_pandas/test7.sas7bdat : 0.841 ms , 3.365 ms (400%), 3.299 ms (392%)
Summary data_pandas/test9.sas7bdat : 0.857 ms , 3.233 ms (377%), 3.169 ms (370%)
Summary data_pandas/test10.sas7bdat : 0.840 ms , 3.433 ms (409%), 3.399 ms (405%)
Summary data_pandas/test12.sas7bdat : 0.858 ms , 3.325 ms (388%), 3.280 ms (382%)
Summary data_pandas/test13.sas7bdat : 0.840 ms , 3.450 ms (411%), 3.384 ms (403%)
Summary data_pandas/test15.sas7bdat : 0.859 ms , 3.328 ms (387%), 3.279 ms (382%)
Summary data_pandas/test16.sas7bdat : 0.851 ms , 6.301 ms (740%), 6.242 ms (733%)
Summary data_pandas/zero_variables.sas7bdat : 0.052 ms , 0.254 ms (491%), 0.252 ms (487%)
Summary data_reikoch/barrows.sas7bdat : 6.991 ms , 10.496 ms (150%), 10.496 ms (150%)
Summary data_reikoch/extr.sas7bdat : 0.177 ms , 3.202 ms (1814%), 3.186 ms (1805%)
Summary data_reikoch/ietest2.sas7bdat : 0.060 ms , 0.266 ms (441%), 0.268 ms (443%)
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1243 | # Performance Test 1
## Summary
SASLib is ~12x faster than Pandas.
## Test File
Filename|Rows|Columns|Numeric Columns|String Columns
--------|----|-------|---------------|--------------
numeric_1000000_2.sas7bdat|1,000,000|2|2|0
## Python
```
$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)
$ python perf_test1.py data_misc/numeric_1000000_2.sas7bdat 30
Minimum: 1.8377 seconds
Median: 1.9093 seconds
Mean: 1.9168 seconds
Maximum: 2.0423 seconds
```
## Julia
```
$ julia perf_test1.jl data_misc/numeric_1000000_2.sas7bdat 30
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 0.656 seconds
BenchmarkTools.Trial:
memory estimate: 153.16 MiB
allocs estimate: 1002726
--------------
minimum time: 151.382 ms (3.41% GC)
median time: 235.003 ms (35.13% GC)
mean time: 202.453 ms (23.83% GC)
maximum time: 272.253 ms (35.25% GC)
--------------
samples: 25
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1988 | # Performance Test 2
## Summary
SASLib is 24-72x faster than Pandas.
## Test File
Filename |Rows|Columns|Numeric Columns|String Columns
--------------|----|-------|---------------|--------------
test1.sas7bdat|10 |100 |73 |27
## Python
```
$ python perf_test1.py data_pandas/test1.sas7bdat 100
Minimum: 0.0800 seconds
Median: 0.0868 seconds
Mean: 0.0920 seconds
Maximum: 0.1379 seconds
```
## Julia (ObjectPool String Array)
```
$ julia perf_test1.jl data_pandas/test1.sas7bdat 100
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 0.664 seconds
BenchmarkTools.Trial:
memory estimate: 988.28 KiB
allocs estimate: 9378
--------------
minimum time: 1.149 ms (0.00% GC)
median time: 1.222 ms (0.00% GC)
mean time: 1.358 ms (6.98% GC)
maximum time: 4.425 ms (55.85% GC)
--------------
samples: 100
evals/sample: 1
```
## Julia (Regular String Array)
```
$ julia perf_test_regarray.jl data_pandas/test1.sas7bdat 100
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 0.680 seconds
BenchmarkTools.Trial:
memory estimate: 949.63 KiB
allocs estimate: 8967
--------------
minimum time: 1.106 ms (0.00% GC)
median time: 1.339 ms (0.00% GC)
mean time: 1.482 ms (6.61% GC)
maximum time: 4.545 ms (57.52% GC)
--------------
samples: 100
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 2019 | # Performance Test 3
## Summary
SASLib is ~14-22x faster than Pandas.
## Test File
Filename |Rows |Columns|Numeric Columns|String Columns
---------------------|------|-------|---------------|--------------
productsales.sas7bdat|1440 |10 |4 |6
## Python
```
$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)
$ python perf_test1.py data_pandas/productsales.sas7bdat 100
Minimum: 0.0286 seconds
Median: 0.0316 seconds
Mean: 0.0329 seconds
Maximum: 0.0894 seconds
```
## Julia (ObjectPool string array)
```
$ julia perf_test1.jl data_pandas/productsales.sas7bdat 100
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 4.693 seconds
BenchmarkTools.Trial:
memory estimate: 1.07 MiB
allocs estimate: 18573
--------------
minimum time: 2.088 ms (0.00% GC)
median time: 2.133 ms (0.00% GC)
mean time: 2.320 ms (4.10% GC)
maximum time: 5.123 ms (47.12% GC)
--------------
samples: 100
evals/sample: 1
```
## Julia (regular string array)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Loaded library in 0.651 seconds
BenchmarkTools.Trial:
memory estimate: 1.05 MiB
allocs estimate: 18500
--------------
minimum time: 1.337 ms (0.00% GC)
median time: 1.385 ms (0.00% GC)
mean time: 1.556 ms (8.02% GC)
maximum time: 5.486 ms (69.40% GC)
--------------
samples: 100
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 3316 | ## SASLib vs ReadStat results
Key | Description |
--------|-------------------------|
F64 | number of Float64 columns|
STR | number of String columns|
DT | number of date/time coumns|
COMP | compression method|
S/R | SASLib time divided by ReadStat time|
SA/R | SASLib time (regular string arrays) divided by ReadStat time|
SASLibA | SASLib (regular string arrays)|
```
Filename : ReadStat SASLib S/R SASLibA SA/R F64 STR DT COMP
data_misc/numeric_1000000_2.sas7bdat : 205.002 ms 152.764 ms ( 75%) 154.288 ms ( 75%) 2 0 0 None
data_misc/types.sas7bdat : 0.093 ms 0.179 ms (194%) 0.180 ms (194%) 5 1 0 None
data_AHS2013/homimp.sas7bdat : 40.138 ms 51.994 ms (130%) 24.975 ms ( 62%) 1 5 0 None
data_AHS2013/omov.sas7bdat : 2.557 ms 5.136 ms (201%) 3.485 ms (136%) 3 5 0 RLE
data_AHS2013/owner.sas7bdat : 13.859 ms 17.104 ms (123%) 9.272 ms ( 67%) 0 3 0 None
data_AHS2013/ratiov.sas7bdat : 4.820 ms 8.170 ms (169%) 3.577 ms ( 74%) 0 9 0 None
data_AHS2013/rmov.sas7bdat : 56.358 ms 101.530 ms (180%) 70.293 ms (125%) 2 21 0 RLE
data_AHS2013/topical.sas7bdat : 2609.437 ms 2876.122 ms (110%) 1104.849 ms ( 42%) 8 106 0 RLE
data_pandas/airline.sas7bdat : 0.105 ms 0.170 ms (161%) 0.172 ms (164%) 6 0 0 None
data_pandas/datetime.sas7bdat : 0.080 ms 0.235 ms (293%) 0.234 ms (291%) 1 1 2 None
data_pandas/productsales.sas7bdat : 2.276 ms 2.374 ms (104%) 1.355 ms ( 60%) 4 5 1 None
data_pandas/test1.sas7bdat : 0.831 ms 1.162 ms (140%) 1.101 ms (132%) 73 25 2 None
data_pandas/test2.sas7bdat : 0.846 ms 1.029 ms (122%) 0.971 ms (115%) 73 25 2 RLE
data_pandas/test4.sas7bdat : 0.829 ms 1.162 ms (140%) 1.103 ms (133%) 73 25 2 None
data_pandas/test5.sas7bdat : 0.848 ms 1.034 ms (122%) 0.974 ms (115%) 73 25 2 RLE
data_pandas/test7.sas7bdat : 0.832 ms 1.182 ms (142%) 1.111 ms (133%) 73 25 2 None
data_pandas/test9.sas7bdat : 0.850 ms 1.057 ms (124%) 0.993 ms (117%) 73 25 2 RLE
data_pandas/test10.sas7bdat : 0.833 ms 1.166 ms (140%) 1.102 ms (132%) 73 25 2 None
data_pandas/test12.sas7bdat : 0.849 ms 1.038 ms (122%) 0.974 ms (115%) 73 25 2 RLE
data_pandas/test13.sas7bdat : 0.831 ms 1.180 ms (142%) 1.110 ms (134%) 73 25 2 None
data_pandas/test15.sas7bdat : 0.852 ms 1.048 ms (123%) 0.988 ms (116%) 73 25 2 RLE
data_pandas/test16.sas7bdat : 0.842 ms 2.236 ms (265%) 2.152 ms (255%) 73 25 2 None
data_reikoch/barrows.sas7bdat : 6.923 ms 6.031 ms ( 87%) 6.047 ms ( 87%) 72 0 0 RLE
data_reikoch/extr.sas7bdat : 0.177 ms 0.381 ms (215%) 0.368 ms (208%) 0 1 0 None
data_reikoch/ietest2.sas7bdat : 0.061 ms 0.139 ms (229%) 0.138 ms (228%) 0 1 0 RLE
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1891 | # Julia/Python Performance Test Result
## Summary
Julia is ~10.7x faster than Python/Pandas
## Test File
Iterations: 50
Filename|Size|Rows|Columns|Numeric Columns|String Columns
--------|----|----|-------|---------------|--------------
homimp.sas7bdat|1.2 MB|46641|6|1|5
## Python
```
$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)
$ python perf_test1.py data_AHS2013/homimp.sas7bdat 50
Minimum: 0.2720 seconds
Median: 0.3014 seconds
Mean: 0.3140 seconds
Maximum: 0.4728 seconds
```
## Julia (ObjectPool)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 20.56 MiB
allocs estimate: 513299
--------------
minimum time: 47.109 ms (0.00% GC)
median time: 56.312 ms (11.21% GC)
mean time: 57.920 ms (10.72% GC)
maximum time: 78.471 ms (9.23% GC)
--------------
samples: 50
evals/sample: 1
```
## Julia (Regular String Array)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 19.37 MiB
allocs estimate: 512178
--------------
minimum time: 25.528 ms (0.00% GC)
median time: 39.970 ms (33.88% GC)
mean time: 41.932 ms (35.10% GC)
maximum time: 113.933 ms (76.81% GC)
--------------
samples: 50
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1208 | # Julia/Python Performance Test Result
## Summary
Julia is ~11.8x faster than Python/Pandas
## Test File
Iterations: 100
Filename|Size|Rows|Columns|Numeric Columns|String Columns
--------|----|----|-------|---------------|--------------
numeric_1000000_2.sas7bdat|16.3 MB|1000000|2|2|0
## Python
```
$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)
$ python perf_test1.py data_misc/numeric_1000000_2.sas7bdat 100
Minimum: 1.7937 seconds
Median: 1.8426 seconds
Mean: 1.8485 seconds
Maximum: 2.0821 seconds
```
## Julia
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 153.16 MiB
allocs estimate: 1002737
--------------
minimum time: 152.629 ms (3.05% GC)
median time: 231.873 ms (35.79% GC)
mean time: 203.540 ms (23.47% GC)
maximum time: 257.027 ms (38.52% GC)
--------------
samples: 25
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1892 | # Julia/Python Performance Test Result
## Summary
Julia is ~21.1x faster than Python/Pandas
## Test File
Iterations: 100
Filename|Size|Rows|Columns|Numeric Columns|String Columns
--------|----|----|-------|---------------|--------------
productsales.sas7bdat|148.5 kB|1440|10|5|5
## Python
```
$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)
$ python perf_test1.py data_pandas/productsales.sas7bdat 100
Minimum: 0.0292 seconds
Median: 0.0316 seconds
Mean: 0.0325 seconds
Maximum: 0.0572 seconds
```
## Julia (ObjectPool)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 1.07 MiB
allocs estimate: 18583
--------------
minimum time: 2.084 ms (0.00% GC)
median time: 2.188 ms (0.00% GC)
mean time: 2.408 ms (3.88% GC)
maximum time: 5.143 ms (47.78% GC)
--------------
samples: 100
evals/sample: 1
```
## Julia (Regular String Array)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 1.05 MiB
allocs estimate: 18510
--------------
minimum time: 1.382 ms (0.00% GC)
median time: 1.430 ms (0.00% GC)
mean time: 1.608 ms (7.05% GC)
maximum time: 5.258 ms (65.43% GC)
--------------
samples: 100
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1881 | # Julia/Python Performance Test Result
## Summary
Julia is ~72.8x faster than Python/Pandas
## Test File
Iterations: 100
Filename|Size|Rows|Columns|Numeric Columns|String Columns
--------|----|----|-------|---------------|--------------
test1.sas7bdat|131.1 kB|10|100|75|25
## Python
```
$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)
$ python perf_test1.py data_pandas/test1.sas7bdat 100
Minimum: 0.0806 seconds
Median: 0.0861 seconds
Mean: 0.0872 seconds
Maximum: 0.1226 seconds
```
## Julia (ObjectPool)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 989.53 KiB
allocs estimate: 9388
--------------
minimum time: 1.147 ms (0.00% GC)
median time: 1.233 ms (0.00% GC)
mean time: 1.439 ms (6.35% GC)
maximum time: 4.053 ms (56.94% GC)
--------------
samples: 100
evals/sample: 1
```
## Julia (Regular String Array)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 950.88 KiB
allocs estimate: 8977
--------------
minimum time: 1.107 ms (0.00% GC)
median time: 1.194 ms (0.00% GC)
mean time: 1.379 ms (7.08% GC)
maximum time: 4.468 ms (61.84% GC)
--------------
samples: 100
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1890 | # Julia/Python Performance Test Result
## Summary
Julia is ~16.1x faster than Python/Pandas
## Test File
Iterations: 30
Filename|Size|Rows|Columns|Numeric Columns|String Columns
--------|----|----|-------|---------------|--------------
topical.sas7bdat|13.6 MB|84355|114|8|106
## Python
```
$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)
$ python perf_test1.py data_AHS2013/topical.sas7bdat 30
Minimum: 18.1696 seconds
Median: 19.7381 seconds
Mean: 20.0185 seconds
Maximum: 23.0960 seconds
```
## Julia (ObjectPool)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 632.37 MiB
allocs estimate: 18653672
--------------
minimum time: 2.296 s (9.82% GC)
median time: 2.422 s (11.51% GC)
mean time: 2.388 s (11.26% GC)
maximum time: 2.445 s (11.40% GC)
--------------
samples: 3
evals/sample: 1
```
## Julia (Regular String Array)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 596.26 MiB
allocs estimate: 18608580
--------------
minimum time: 1.129 s (0.00% GC)
median time: 2.220 s (47.16% GC)
mean time: 1.953 s (41.51% GC)
maximum time: 2.511 s (55.19% GC)
--------------
samples: 3
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 3316 | ## SASLib vs ReadStat results
Key | Description |
--------|-------------------------|
F64 | number of Float64 columns|
STR | number of String columns|
DT | number of date/time coumns|
COMP | compression method|
S/R | SASLib time divided by ReadStat time|
SA/R | SASLib time (regular string arrays) divided by ReadStat time|
SASLibA | SASLib (regular string arrays)|
```
Filename : ReadStat SASLib S/R SASLibA SA/R F64 STR DT COMP
data_AHS2013/homimp.sas7bdat : 39.610 ms 46.910 ms (118%) 25.087 ms ( 63%) 1 5 0 None
data_AHS2013/omov.sas7bdat : 2.590 ms 4.736 ms (183%) 3.485 ms (135%) 3 5 0 RLE
data_AHS2013/owner.sas7bdat : 13.884 ms 15.026 ms (108%) 9.513 ms ( 69%) 0 3 0 None
data_AHS2013/ratiov.sas7bdat : 4.853 ms 6.950 ms (143%) 3.715 ms ( 77%) 0 9 0 None
data_AHS2013/rmov.sas7bdat : 57.023 ms 84.570 ms (148%) 63.294 ms (111%) 2 21 0 RLE
data_AHS2013/topical.sas7bdat : 2175.098 ms 2433.403 ms (112%) 1123.849 ms ( 52%) 8 106 0 RLE
data_misc/numeric_1000000_2.sas7bdat : 222.189 ms 154.134 ms ( 69%) 157.427 ms ( 71%) 2 0 0 None
data_misc/types.sas7bdat : 0.094 ms 0.184 ms (196%) 0.183 ms (196%) 5 1 0 None
data_pandas/airline.sas7bdat : 0.108 ms 0.177 ms (164%) 0.181 ms (167%) 6 0 0 None
data_pandas/datetime.sas7bdat : 0.082 ms 0.243 ms (295%) 0.243 ms (295%) 1 1 2 None
data_pandas/productsales.sas7bdat : 2.305 ms 2.119 ms ( 92%) 1.360 ms ( 59%) 4 5 1 None
data_pandas/test1.sas7bdat : 0.841 ms 1.167 ms (139%) 1.113 ms (132%) 73 25 2 None
data_pandas/test10.sas7bdat : 0.843 ms 1.173 ms (139%) 1.117 ms (132%) 73 25 2 None
data_pandas/test12.sas7bdat : 0.860 ms 1.047 ms (122%) 0.990 ms (115%) 73 25 2 RLE
data_pandas/test13.sas7bdat : 0.845 ms 1.189 ms (141%) 1.132 ms (134%) 73 25 2 None
data_pandas/test15.sas7bdat : 0.862 ms 1.058 ms (123%) 1.006 ms (117%) 73 25 2 RLE
data_pandas/test16.sas7bdat : 0.854 ms 2.329 ms (273%) 2.295 ms (269%) 73 25 2 None
data_pandas/test2.sas7bdat : 0.860 ms 1.042 ms (121%) 0.990 ms (115%) 73 25 2 RLE
data_pandas/test4.sas7bdat : 0.842 ms 1.171 ms (139%) 1.113 ms (132%) 73 25 2 None
data_pandas/test5.sas7bdat : 0.861 ms 1.034 ms (120%) 0.982 ms (114%) 73 25 2 RLE
data_pandas/test7.sas7bdat : 0.843 ms 1.185 ms (141%) 1.125 ms (133%) 73 25 2 None
data_pandas/test9.sas7bdat : 0.858 ms 1.063 ms (124%) 1.006 ms (117%) 73 25 2 RLE
data_reikoch/barrows.sas7bdat : 7.449 ms 6.059 ms ( 81%) 6.063 ms ( 81%) 72 0 0 RLE
data_reikoch/extr.sas7bdat : 0.178 ms 0.388 ms (218%) 0.382 ms (215%) 0 1 0 None
data_reikoch/ietest2.sas7bdat : 0.061 ms 0.142 ms (231%) 0.141 ms (230%) 0 1 0 RLE
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1881 | # Julia/Python Performance Test Result
## Summary
Julia is ~10.5x faster than Python/Pandas
## Test File
Iterations: 50
Filename|Size|Rows|Columns|Numeric Columns|String Columns
--------|----|----|-------|---------------|--------------
homimp.sas7bdat|1.2 MB|46641|6|1|5
## Python
```
$ python -V
Python 3.6.3 :: Anaconda, Inc.
$ python perf_test1.py data_AHS2013/homimp.sas7bdat 50
Minimum: 0.2726 seconds
Median: 0.2953 seconds
Mean: 0.2944 seconds
Maximum: 0.3236 seconds
```
## Julia (ObjectPool)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 20.56 MiB
allocs estimate: 513212
--------------
minimum time: 45.918 ms (0.00% GC)
median time: 52.767 ms (10.15% GC)
mean time: 53.208 ms (9.78% GC)
maximum time: 60.720 ms (14.54% GC)
--------------
samples: 50
evals/sample: 1
```
## Julia (Regular String Array)
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 19.38 MiB
allocs estimate: 512257
--------------
minimum time: 25.901 ms (0.00% GC)
median time: 39.589 ms (34.18% GC)
mean time: 40.855 ms (34.82% GC)
maximum time: 121.562 ms (76.55% GC)
--------------
samples: 50
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
|
[
"MIT"
] | 1.3.1 | c0f87a4a459e6ac5eb4fa8eea7b1357a4b5fc10b | docs | 1198 | # Julia/Python Performance Test Result
## Summary
Julia is ~11.3x faster than Python/Pandas
## Test File
Iterations: 100
Filename|Size|Rows|Columns|Numeric Columns|String Columns
--------|----|----|-------|---------------|--------------
numeric_1000000_2.sas7bdat|16.3 MB|1000000|2|2|0
## Python
```
$ python -V
Python 3.6.3 :: Anaconda, Inc.
$ python perf_test1.py data_misc/numeric_1000000_2.sas7bdat 100
Minimum: 1.7591 seconds
Median: 1.8164 seconds
Mean: 1.8219 seconds
Maximum: 1.9256 seconds
```
## Julia
```
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
BenchmarkTools.Trial:
memory estimate: 153.16 MiB
allocs estimate: 1002641
--------------
minimum time: 155.898 ms (3.20% GC)
median time: 239.698 ms (36.41% GC)
mean time: 203.995 ms (24.49% GC)
maximum time: 254.561 ms (35.91% GC)
--------------
samples: 25
evals/sample: 1
```
| SASLib | https://github.com/tk3369/SASLib.jl.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.