Adjacency
This handles adjacency matrices between entities of polyhedral complexes, e.g. nodes, cells, edges etc.
An adjacency is described by an Adjacency matrix, which is a sparse matrix whose entries a 0 or 1. While such a matrix always can be stored as a SparseMatrixCSC, in general this would be a waste of storage.
For the general case, it is sufficient to only store the column start indieces and the column entries (row numbers), and to implicitly assume that nonzero entries are 1. This kind of storage is realised in a VariableTargetAdjacency.
In many cases, this can be compressed even more, if each column has the same length. In that case, a Matrix is sufficient to store the data. This is the usual base for implementing FEM/FVM assembly, and the interface for the general case should be similar.
From these ideas we develop the following interface for an adjacency a.
In order to avoid name confusion, we introduce the following notation which should be consistent with the use in assembly loops.
source: source of adjacency link target: target of adjacency link
E.g. the cell-node adjacency for FEM assembly links a number of cells with a collection of nodes. The cells are the sources, and the targets are the nodes.
getindex(a,i,isource) aka a[i,isource]: return i-th target of source j numsources(a): overall number of sources, e.g. number of cells numtargets(a): overall number of targets numtargets(a,isource): number of targets for source given by isource numlinks(a): number of links aka nonzero entries of adjacency matrix show(a): print stuff
Further API ideas:
- Convert between Matrix and Variable target stuff using 0 entries as "padding"
API
ExtendableGrids.Adjacency — Type
Adjacency type as union of FixedTargetAdjacency and VariableTargetAdjacency
sourceExtendableGrids.Adjacency — Method
Constructors for Adjacency
sourceExtendableGrids.SerialVariableTargetAdjacency — Method
SerialVariableTargetAdjacency(
) -> SerialVariableTargetAdjacency{Int64}
Create an empty SerialVariableTargetAdjacency with default type
sourceExtendableGrids.SerialVariableTargetAdjacency — Method
SerialVariableTargetAdjacency(
t::Type{T}
) -> SerialVariableTargetAdjacency
Create an empty SerialVariableTargetAdjacency
sourceExtendableGrids.VariableTargetAdjacency — Type
struct VariableTargetAdjacency{T}Adjacency struct. Essentially, this is the sparsity pattern of a matrix whose nonzero elements all have the same value in the CSC format.
sourceExtendableGrids.VariableTargetAdjacency — Method
VariableTargetAdjacency() -> VariableTargetAdjacency{Int64}
Create an empty VariableTargetAdjacency with default type
sourceExtendableGrids.VariableTargetAdjacency — Method
VariableTargetAdjacency(
m::Array{T, 2}
) -> VariableTargetAdjacency
Create a VariableTargetAdjacency from Matrix
sourceExtendableGrids.VariableTargetAdjacency — Method
VariableTargetAdjacency(
m::SparseArrays.SparseMatrixCSC{Tv<:Integer, Ti<:Integer}
) -> VariableTargetAdjacency{Ti} where Ti<:Integer
Create variable target adjacency from adjacency matrix
sourceExtendableGrids.VariableTargetAdjacency — Method
VariableTargetAdjacency(
t::Type{T}
) -> VariableTargetAdjacency
Create an empty VariableTargetAdjacency
sourceBase.append! — Method
Base.append! — Method
Base.getindex — Method
getindex(
adj::SerialVariableTargetAdjacency,
i,
isource
) -> Any
Access adjacency as if it is a 2D Array
sourceBase.getindex — Method
getindex(adj::VariableTargetAdjacency, i, isource) -> Any
Access adjacency as if it is a 2D Array
sourceBase.maximum — Method
Base.minimum — Method
ExtendableGrids.asparse — Method
asparse(a::Matrix) -> SparseArrays.SparseMatrixCSC{Int64}
Create sparse incidence matrix from adjacency
sourceExtendableGrids.asparse — Method
asparse(
a::VariableTargetAdjacency
) -> SparseArrays.SparseMatrixCSC{Int64}
Create sparse incidence matrix from adjacency
sourceExtendableGrids.atranspose — Method
Transpose adjacency
sourceExtendableGrids.makevar — Method
makevar(a::Array{T, 2}) -> VariableTargetAdjacency
Turn fixed target adjacency into variable target adjacency
sourceExtendableGrids.max_num_targets_per_source — Method
max_num_targets_per_source(
adj::SerialVariableTargetAdjacency
) -> Any
Maximum number of targets per source
sourceExtendableGrids.max_num_targets_per_source — Method
max_num_targets_per_source(
adj::VariableTargetAdjacency
) -> Any
Maximum number of targets per source
sourceExtendableGrids.num_links — Method
ExtendableGrids.num_links — Method
ExtendableGrids.num_sources — Method
ExtendableGrids.num_sources — Method
ExtendableGrids.num_sources — Method
ExtendableGrids.num_targets — Method
num_targets(adj::Matrix, isource) -> Int64
Number of targets per source if adjacency is a matrix
sourceExtendableGrids.num_targets — Method
ExtendableGrids.num_targets — Method
num_targets(
adj::SerialVariableTargetAdjacency,
isource
) -> Any
Number of targets for given source
sourceExtendableGrids.num_targets — Method
ExtendableGrids.num_targets — Method
ExtendableGrids.tryfix — Method
tryfix(
a::Union{Array{T, 2}, VariableTargetAdjacency{T}}
) -> Any
Try to turn variable target adjacency into fixed target adjacency
source