My Project
|
Form CSR adjacency matrix representation of unstructured graphs. More...
#include <CSRGraphFromCoordinates.hpp>
Public Types | |
using | Neighbours = std::vector< BaseVertexID > |
Representation of neighbouring regions. | |
using | Offset = typename Neighbours::size_type |
Offset into neighbour array. | |
using | Start = std::vector< Offset > |
CSR start pointers. | |
Public Member Functions | |
void | clear () |
Clear all internal buffers, but preserve allocated capacity. | |
void | addConnection (VertexID v1, VertexID v2) |
Add flow rate connection between regions. | |
void | compress (Offset maxNumVertices, bool expandExistingIdxMap=false) |
Form CSR adjacency matrix representation of input graph from connections established in previous calls to addConnection(). | |
Offset | numVertices () const |
Retrieve number of rows (source entities) in input graph. | |
Offset | numEdges () const |
Retrieve number of edges (non-zero matrix elements) in input graph. | |
const Start & | startPointers () const |
Read-only access to compressed structure's start pointers. | |
const Neighbours & | columnIndices () const |
Read-only access to compressed structure's column indices, ascendingly sorted per row. | |
template<typename Ret = const Start&> | |
std::enable_if_t< TrackCompressedIdx, Ret > | compressedIndexMap () const |
Read-only access to mapping from input order vertex pairs to compressed structure's edge index (location in ja/sa). | |
template<class MessageBufferType > | |
void | write (MessageBufferType &buffer) const |
template<class MessageBufferType > | |
void | read (MessageBufferType &buffer) |
Form CSR adjacency matrix representation of unstructured graphs.
Optionally maps vertex pairs to compressed indices to enable O(1) per-element lookup in assembly-like operations.
VertexID | ID type of an abstract vertex in the graph. Could for instance be used to represent a cell index or a region index. Must be an integral type. |
TrackCompressedIdx | Whether or not to form a mapping relation for vertex pairs to compressed indices. Default value, false, bypasses this mapping relation and conserves memory. |
PermitSelfConnections | Whether or not to allow connections of the form i->i–i.e., diagonal elements. Default value, false , does not generate connections from a vertex to itself. |
void Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >::addConnection | ( | VertexID | v1, |
VertexID | v2 | ||
) |
Add flow rate connection between regions.
[in] | v1 | First vertex in vertex pair. Used as row index. |
[in] | v2 | Second vertex in vertex pair. Used as column index. |
If both vertex IDs are the same, and class template argument PermitSelfConnections
is in its default state of false
, then this function does nothing.
void Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >::compress | ( | Offset | maxNumVertices, |
bool | expandExistingIdxMap = false |
||
) |
Form CSR adjacency matrix representation of input graph from connections established in previous calls to addConnection().
[in] | maxNumVertices | Number of rows in resulting CSR matrix. If prior calls to addConnection() supply vertex IDs (row indices) greater than or equal to maxNumVertices , then method compress() will throw std::invalid_argument
|
[in] | expandExistingIdxMap | Whether or not preserve and update the existing compressed index map. This is potentially useful for the case of adding new connections to an already compressed graph. The default setting, false , will disregard any existing index map and create the index map from scratch. This runtime parameter is unused if the class is not configured to track compressed indices through the TrackCompressedIdx class parameter. |
|
inline |
Read-only access to mapping from input order vertex pairs to compressed structure's edge index (location in ja/sa).
Available only if client code sets TrackCompressedIdx=true. Compiler diagnostic, typically referring to 'enable_if', if client code tries to call this function without setting class parameter TrackCompressedIdx=true.
Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >::Offset Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >::numVertices | ( | ) | const |
Retrieve number of rows (source entities) in input graph.
Corresponds to value of argument passed to compress(). Valid only after calling compress().