My Project
Loading...
Searching...
No Matches
Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections > Class Template Reference

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 StartstartPointers () const
 Read-only access to compressed structure's start pointers.
 
const NeighbourscolumnIndices () 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)
 

Detailed Description

template<typename VertexID = int, bool TrackCompressedIdx = false, bool PermitSelfConnections = false>
class Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >

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.

Template Parameters
VertexIDID 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.
TrackCompressedIdxWhether or not to form a mapping relation for vertex pairs to compressed indices. Default value, false, bypasses this mapping relation and conserves memory.
PermitSelfConnectionsWhether 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.

Member Function Documentation

◆ addConnection()

template<typename VertexID , bool TrackCompressedIdx, bool PermitSelfConnections>
void Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >::addConnection ( VertexID  v1,
VertexID  v2 
)

Add flow rate connection between regions.

Parameters
[in]v1First vertex in vertex pair. Used as row index.
[in]v2Second 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.

◆ compress()

template<typename VertexID , bool TrackCompressedIdx, bool PermitSelfConnections>
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().

Parameters
[in]maxNumVerticesNumber 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]expandExistingIdxMapWhether 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.

◆ compressedIndexMap()

template<typename VertexID = int, bool TrackCompressedIdx = false, bool PermitSelfConnections = false>
template<typename Ret = const Start&>
std::enable_if_t< TrackCompressedIdx, Ret > Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >::compressedIndexMap ( ) const
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.

◆ numVertices()

template<typename VertexID , bool TrackCompressedIdx, bool PermitSelfConnections>
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().


The documentation for this class was generated from the following files: