Advanced
Custom partitions
PartitionedArrays.LocalIndices
— Typestruct LocalIndices
Container for arbitrary local indices.
Properties
n_global::Int
: Number of global indices.owner::Int32
: Id of the part that stores the local indiceslocal_to_global::Vector{Int}
: Global ids of the local indices in this part.local_to_global[i_local]
is the global id corresponding to the local index numberi_local
.local_to_owner::Vector{Int32}
: Owners of the local ids.local_to_owner[i_local]
is the id of the owner of the local index numberi_local
.
Supertype hierarchy
LocalIndices <: AbstractLocalIndices
PartitionedArrays.LocalIndices
— MethodLocalIndices(n_global,owner,local_to_global,local_to_owner)
Build an instance of LocalIndices
from the underlying properties n_global
, owner
, local_to_global
, and local_to_owner
. The types of these variables need to match the type of the properties in LocalIndices
.
PartitionedArrays.OwnAndGhostIndices
— TypeOwnAndGhostIndices
Container for local indices stored as own and ghost indices separately. Local indices are defined by concatenating own and ghost ones.
Properties
own::OwnIndices
: Container for the own indices.ghost::GhostIndices
: Container for the ghost indices.global_to_owner
: [optional: it can benothing
] Vector containing the owner of each global id.
Supertype hierarchy
OwnAndGhostIndices{A} <: AbstractLocalIndices
where A=typeof(global_to_owner)
.
PartitionedArrays.OwnAndGhostIndices
— MethodOwnAndGhostIndices(own::OwnIndices,ghost::GhostIndices,global_to_owner=nothing)
Build an instance of OwnAndGhostIndices
from the underlying properties own
, ghost
, and global_to_owner
.
PartitionedArrays.OwnIndices
— Typestruct OwnIndices
Container for own indices.
Properties
n_global::Int
: Number of global indicesowner::Int32
: Id of the part that owns these indicesown_to_global::Vector{Int}
: Global ids of the indices owned by this part.own_to_global[i_own]
is the global id corresponding to the own index numberi_own
.
Supertype hierarchy
OwnIndices <: Any
PartitionedArrays.OwnIndices
— MethodOwnIndices(n_global,owner,own_to_global)
Build an instance of OwnIndices
from the underlying properties n_global
, owner
, and own_to_global
. The types of these variables need to match the type of the properties in OwnIndices
.
PartitionedArrays.GhostIndices
— Typestruct GhostIndices
Container for ghost indices.
Properties
n_global::Int
: Number of global indicesghost_to_global::Vector{Int}
: Global ids of the ghost indices in this part.ghost_to_global[i_ghost]
is the global id corresponding to the ghost index numberi_ghost
.ghost_to_owner::Vector{Int32}
: Owners of the ghost ids.ghost_to_owner[i_ghost]
is the id of the owner of the ghost index numberi_ghost
.
Supertype hierarchy
GhostIndices <: Any
PartitionedArrays.GhostIndices
— MethodGhostIndices(n_global,ghost_to_global,ghost_to_owner)
Build an instance of GhostIndices
from the underlying fields n_global
, ghost_to_global
, and ghost_to_owner
. The types of these variables need to match the type of the properties in GhostIndices
.
Transform partitions
PartitionedArrays.replace_ghost
— Functionreplace_ghost(indices,gids,owners)
Replaces the ghost indices in indices
with global ids in gids
and owners in owners
. Returned object takes ownership of gids
and owners
. This method only makes sense if indices
stores ghost ids in separate vectors like in OwnAndGhostIndices
. gids
should be unique and not being owned by indices
.
PartitionedArrays.union_ghost
— Functionunion_ghost(indices,gids,owners)
Make the union of the ghost indices in indices
with the global indices gids
and owners owners
. Return an object of the same type as indices
with the new ghost indices and the same own indices as in indices
. The result does not take ownership of gids
and owners
.
PartitionedArrays.permute_indices
— Functionpermute_indices(indices,perm)
PartitionedArrays.find_owner
— Functionfind_owner(index_partition,global_ids)
Find the owners of the global ids in global_ids
. The input global_ids
is a vector of vectors distributed over the same parts as index_partition
. Each part will look for the owners in parallel, when using a parallel back-end.
Example
julia> using PartitionedArrays
julia> rank = LinearIndices((4,));
julia> index_partition = uniform_partition(rank,10)
4-element Vector{PartitionedArrays.LocalIndicesWithConstantBlockSize{1}}:
[1, 2]
[3, 4]
[5, 6, 7]
[8, 9, 10]
julia> gids = [[3],[4,5],[7,2],[9,10,1]]
4-element Vector{Vector{Int64}}:
[3]
[4, 5]
[7, 2]
[9, 10, 1]
julia> find_owner(index_partition,gids)
4-element Vector{Vector{Int32}}:
[2]
[2, 3]
[3, 1]
[4, 4, 1]
Transform indices
PartitionedArrays.to_global!
— Functionto_global!(I,indices)
Transform the local indices in I
into global ids according to indices
.
PartitionedArrays.to_local!
— Functionto_local!(I,indices)
Transform the global indices in I
into local ids according to indices
.
Local vector storage
PartitionedArrays.OwnAndGhostVectors
— Typestruct OwnAndGhostVectors{A,C,T}
Vector type that stores the local values of a PVector
instance using a vector of own values, a vector of ghost values, and a permutation. This is not the default data layout of PVector
(which is a plain vector), but corresponds to the layout of distributed vectors in other packages, such as PETSc. Use this type to avoid duplicating memory when passing data to these other packages.
Properties
own_values::A
: The vector of own values.ghost_values::A
: The vector of ghost values.permumation::C
: A permutation vector such thatvcat(own_values,ghost_values)[permutation]
corresponds to the local values.
Supertype hierarchy
OwnAndGhostVectors{A,C,T} <: AbstractVector{T}
PartitionedArrays.OwnAndGhostVectors
— MethodOwnAndGhostVectors(own_values,ghost_values,permutation)
Build an instance of OwnAndGhostVectors
from the underlying fields.
Assembly
PartitionedArrays.assembly_graph
— Functionassembly_graph(index_partition;kwargs...)
Return an instance of ExchangeGraph
representing the communication graph needed to perform assembly of distributed vectors defined on the index partition index_partition
. kwargs
are delegated to ExchangeGraph
in order to find the receiving neighbors from the sending ones.
Equivalent to
neighbors = assembly_neighbors(index_partition;kwargs...)
ExchangeGraph(neighbors...)
PartitionedArrays.assembly_neighbors
— Functionneigs_snd, neigs_rcv = assembly_neighbors(index_partition;kwargs...)
Return the ids of the neighbor parts from we send and receive data respectively in the assembly of distributed vectors defined on the index partition index_partition
. partition index_partition
. kwargs
are delegated to ExchangeGraph
in order to find the receiving neighbors from the sending ones.
PartitionedArrays.assembly_local_indices
— Functionids_snd, ids_rcv = assembly_local_indices(index_partition)
Return the local ids to be sent and received in the assembly of distributed vectors defined on the index partition index_partition
.
Local values corresponding to the local indices in ids_snd[i]
(respectively ids_rcv[i]
) are sent to part neigs_snd[i]
(respectively neigs_rcv[i]
), where neigs_snd, neigs_rcv = assembly_neighbors(index_partition)
.