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.
Offset | applyVertexMerges ()
| Apply vertex merges to all vertex groups.
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)
void | addVertexGroup (const std::vector< VertexID > &vertices)
| Add a group of vertices that should be merged together.
VertexID | getFinalVertexID (VertexID originalVertexID) const
| Get the final vertex ID after all merges and renumbering for a given original vertex ID.

## 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

  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.

## 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] | 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.

## addVertexGroup()

template<typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>

void Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >::addVertexGroup | ( | const std::vector< VertexID > & | vertices | ) |

Add a group of vertices that should be merged together.

Must be called before compress().

Parameters

  [in] | vertices | Vector of vertex IDs to merge

## 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] | 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 .

  [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.

## 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.

## getFinalVertexID()

template<typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>

VertexID Opm::utility::CSRGraphFromCoordinates< VertexID, TrackCompressedIdx, PermitSelfConnections >::getFinalVertexID | ( | VertexID | originalVertexID | ) | const

Get the final vertex ID after all merges and renumbering for a given original vertex ID.

Returns the original ID if no merging or renumbering has been done.

Parameters

  [in] | originalVertexID | The original vertex ID to look up

Returns
  The final vertex ID after merges and renumbering

## 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:

- opm/common/utility/CSRGraphFromCoordinates.hpp
- opm/common/utility/CSRGraphFromCoordinates_impl.hpp