API reference
Raven.GridArray
— TypeGridArray{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
.
Raven.GridArray
— MethodGridArray{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> 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> 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.
Raven.abaqusmeshimport
— Methodfunction AbaqusMeshImport(filename::String)
This function will parse an abaqus (.inp) file of 2D or 3D mesh data.
Such meshes are generated with HOHQMesh.jl.
Raven.arraytype
— Methodarraytype(A::GridArray) -> DataType
Returns the DataType
used to store the data, e.g., Array
or CuArray
.
Raven.comm
— Methodcomm(A::GridArray) -> MPI.Comm
MPI communicator used by A
.
Raven.components
— Methodcomponents(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.
Raven.constructorof
— Functionconstructorof(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:
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.
Raven.cubeshell2dgrid
— Methodfunction cubeshell2dgrid(R::Real)
This function will construct the CoarseGrid of a cube shell of radius R.
A cube shell is a 2D connectivity.
Raven.expand
— Methodexpand(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)
.
Raven.fieldindex
— Methodfieldindex(A::GridArray{T})
Returns the index used in A.data
to store the fields of T
.
Raven.fieldslength
— Methodfieldslength(A::GridArray{T})
Returns the number of fields used to store T
.
Raven.flatten
— Methodflatten(obj, use=Real)
Flattens a hierarchical type to a tuple with elements of type use
.
Examples
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))
.
Raven.get_backend
— Methodget_backend(::Type{T}) -> Type
Returns the KernelAbstractions backend to use with kernels where A
is an argument.
Raven.get_backend
— Methodget_backend(A::GridArray) -> KernelAbstractions.Backend
Returns the KernelAbstractions.Backend
used to launch kernels interacting with A
.
Raven.materializequadranttoglobalid
— Methodmaterializequadranttoglobalid(forest, ghost)
Generate the global ids for quadrants in the forest
and the ghost
layer.
Raven.numbercontiguous
— Methodnumbercontiguous(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
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
Raven.parenttype
— Methodparent_type(::Type{T}) -> Type
Returns the parent array that type T
wraps.
Raven.parentwithghosts
— Methodparentwithghosts(A::GridArray)
Return the underlying "parent array" which includes the ghost cells.
Raven.pin
— Methodpin(T::Type, A::Array)
Pins the host array A for copying to arrays of type T
Raven.showingghosts
— Methodshowingghosts(A::GridArray) -> Bool
Predicate indicating if the ghost layer is accessible to A
.
Raven.sizewithghosts
— Methodsizewithghosts(A::GridArray)
Return a tuple containing the dimensions of A
including the ghost cells.
Raven.sizewithoutghosts
— Methodsizewithoutghosts(A::GridArray)
Return a tuple containing the dimensions of A
excluding the ghost cells.
Raven.unflatten
— Functionunflatten(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> unflatten(Tuple{Tuple{Int,Int},Complex{Int,Int}}, (1, 2, 3, 4))
((1, 2), 3 + 4im)
Raven.viewwithghosts
— Methodviewwithghosts(A::GridArray)
Return a GridArray
with the same data as A
but with the ghost cells accessible.
Raven.viewwithoutghosts
— Methodviewwithoutghosts(A::GridArray)
Return a GridArray
with the same data as A
but with the ghost cells inaccessible.