API reference
Raven.GridArray — Type
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 flattened 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 — Method
GridArray{T}(undef, grid::Grid, continuous = Val(false))Create an array containing elements of type T for each point in the grid (including the ghost cells). When continuous = Val(false) the dimensions of the array is (size(referencecell(grid))..., length(grid)) as the ghost cells are hidden by default. When continuous = Val(true) the dimensions of the array is (numcnodes(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 = ComplexF32T = 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 2For 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 — Method
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.Raven.arraytype — Method
arraytype(A::GridArray) -> DataTypeReturns the DataType used to store the data, e.g., Array or CuArray.
Raven.comm — Method
comm(A::GridArray) -> MPI.CommMPI communicator used by A.
Raven.components — Method
components(A::GridArray{T})Splits A into a tuple of GridArrays 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 — Function
constructorof(T::Type) -> constructorReturn an object constructor that can be used to construct objects of type T from their field values.
julia> Raven.constructorof(Tuple{Int,Int})
tuple (built-in function)
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 — Method
function 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 — Method
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).
Raven.fieldindex — Method
fieldindex(A::GridArray{T})Returns the index used in A.data to store the fields of T.
Raven.fieldslength — Method
fieldslength(A::GridArray{T})Returns the number of fields used to store T.
Raven.flatten — Method
flatten(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 — Method
get_backend(::Type{T}) -> TypeReturns the KernelAbstractions backend to use with kernels where A is an argument.
Raven.get_backend — Method
get_backend(A::GridArray) -> KernelAbstractions.BackendReturns the KernelAbstractions.Backend used to launch kernels interacting with A.
Raven.linearpartition — Method
linearpartition(n, p, np)Partition the range 1:n into np pieces and return the pth piece as a range.
This will provide an equal partition when n is divisible by np and otherwise the ranges will have lengths of either floor(Int, n/np) or ceil(Int, n/np).
Raven.materializequadranttoglobalid — Method
materializequadranttoglobalid(forest, ghost)Generate the global ids for quadrants in the forest and the ghost layer.
Raven.numbercontiguous — Method
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
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
2Raven.parenttype — Method
parent_type(::Type{T}) -> TypeReturns the parent array that type T wraps.
Raven.parentwithghosts — Method
parentwithghosts(A::GridArray)Return the underlying "parent array" which includes the ghost cells.
Raven.semidiscretize — Function
semidiscretize(dg, tspan)Note: SciMLBase must be imported.
Raven.showingghosts — Method
showingghosts(A::GridArray) -> BoolPredicate indicating if the ghost layer is accessible to A.
Raven.sizewithghosts — Method
sizewithghosts(A::GridArray)Return a tuple containing the dimensions of A including the ghost cells.
Raven.sizewithoutghosts — Method
sizewithoutghosts(A::GridArray)Return a tuple containing the dimensions of A excluding the ghost cells.
Raven.unflatten — Function
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> unflatten(Tuple{Tuple{Int,Int},Complex{Int,Int}}, (1, 2, 3, 4))
((1, 2), 3 + 4im)
Raven.viewwithghosts — Method
viewwithghosts(A::GridArray)Return a GridArray with the same data as A but with the ghost cells accessible.
Raven.viewwithoutghosts — Method
viewwithoutghosts(A::GridArray)Return a GridArray with the same data as A but with the ghost cells inaccessible.