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 implicitely 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
— TypeAdjacency type as union of FixedTargetAdjacency and VariableTargetAdjacency
ExtendableGrids.Adjacency
— MethodConstructors for Adjacency
ExtendableGrids.FixedTargetAdjacency
— Typemutable struct Array{T, 2} <: DenseArray{T, 2}
Use Matrix to store fixed target adjacency
ExtendableGrids.SerialVariableTargetAdjacency
— MethodSerialVariableTargetAdjacency(
) -> SerialVariableTargetAdjacency{Int64}
Create an empty SerialVariableTargetAdjacency with default type
ExtendableGrids.SerialVariableTargetAdjacency
— MethodSerialVariableTargetAdjacency(
t::Type{T}
) -> SerialVariableTargetAdjacency
Create an empty SerialVariableTargetAdjacency
ExtendableGrids.VariableTargetAdjacency
— Typestruct 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.
ExtendableGrids.VariableTargetAdjacency
— MethodVariableTargetAdjacency() -> VariableTargetAdjacency{Int64}
Create an empty VariableTargetAdjacency with default type
ExtendableGrids.VariableTargetAdjacency
— MethodVariableTargetAdjacency(
m::Array{T, 2}
) -> VariableTargetAdjacency
Create a VariableTargetAdjacency from Matrix
ExtendableGrids.VariableTargetAdjacency
— MethodVariableTargetAdjacency(
m::SparseArrays.SparseMatrixCSC{Tv<:Integer, Ti<:Integer}
) -> VariableTargetAdjacency{Ti} where Ti<:Integer
Create variable target adjacency from adjacency matrix
ExtendableGrids.VariableTargetAdjacency
— MethodVariableTargetAdjacency(
t::Type{T}
) -> VariableTargetAdjacency
Create an empty VariableTargetAdjacency
Base.:==
— Method==(a, b)
Comparison of two adjacencies
Base.:==
— Method==(a, b)
Comparison of two adjacencies
Base.append!
— Methodappend!(adj::SerialVariableTargetAdjacency, len) -> Vector
Append a column to adjacency.
Base.append!
— Methodappend!(adj::VariableTargetAdjacency, column) -> Vector
Append a column to adjacency.
Base.getindex
— Methodgetindex(
adj::SerialVariableTargetAdjacency,
i,
isource
) -> Any
Access adjacency as if it is a 2D Array
Base.getindex
— Methodgetindex(adj::VariableTargetAdjacency, i, isource) -> Any
Access adjacency as if it is a 2D Array
Base.show
— Methodshow(io::IO, adj::SerialVariableTargetAdjacency)
Show adjacency (in trasposed form; preliminary)
Base.show
— Methodshow(io::IO, adj::VariableTargetAdjacency)
Show adjacency (in trasposed form; preliminary)
ExtendableGrids.asparse
— Methodasparse(a::Matrix) -> SparseArrays.SparseMatrixCSC{Int64}
Create sparse incidence matrix from adjacency
ExtendableGrids.asparse
— Methodasparse(
a::VariableTargetAdjacency
) -> SparseArrays.SparseMatrixCSC{Int64}
Create sparse incidence matrix from adjacency
ExtendableGrids.atranspose
— MethodTranspose adjacency
ExtendableGrids.makevar
— Methodmakevar(a::Array{T, 2}) -> VariableTargetAdjacency
Turn fixed target adjacency into variable target adjacency
ExtendableGrids.max_num_targets_per_source
— Methodmax_num_targets_per_source(adj::Matrix) -> Int64
Maximum number of targets per source
ExtendableGrids.max_num_targets_per_source
— Methodmax_num_targets_per_source(
adj::SerialVariableTargetAdjacency
) -> Any
Maximum number of targets per source
ExtendableGrids.max_num_targets_per_source
— Methodmax_num_targets_per_source(
adj::VariableTargetAdjacency
) -> Any
Maximum number of targets per source
ExtendableGrids.num_links
— Methodnum_links(adj::Matrix) -> Int64
Number of entries
ExtendableGrids.num_links
— Methodnum_links(adj::VariableTargetAdjacency) -> Int64
Number of links
ExtendableGrids.num_sources
— Methodnum_sources(adj::Matrix) -> Int64
Number of sources in adjacency
ExtendableGrids.num_sources
— Methodnum_sources(adj::SerialVariableTargetAdjacency) -> Int64
Number of sources in adjacency
ExtendableGrids.num_sources
— Methodnum_sources(adj::VariableTargetAdjacency) -> Int64
Number of sources in adjacency
ExtendableGrids.num_targets
— Methodnum_targets(adj::Matrix, isource) -> Int64
Number of targets per source if adjacency is a matrix
ExtendableGrids.num_targets
— Methodnum_targets(adj::Matrix) -> Any
Overall number of targets
ExtendableGrids.num_targets
— Methodnum_targets(
adj::SerialVariableTargetAdjacency,
isource
) -> Any
Number of targets for given source
ExtendableGrids.num_targets
— Methodnum_targets(adj::VariableTargetAdjacency, isource) -> Any
Number of targets for given source
ExtendableGrids.num_targets
— Methodnum_targets(adj::VariableTargetAdjacency) -> Any
Number of targeta
ExtendableGrids.tryfix
— Methodtryfix(
a::Union{Array{T, 2}, VariableTargetAdjacency{T}}
) -> Any
Try to turn variable target adjacency into fixed target adjacency