libMesh::METIS_CSR_Graph< IndexType > Class Template Reference

Compressed graph data structure used by MetisPartitioner. More...

#include <metis_csr_graph.h>

Public Member Functions

void prep_n_nonzeros (const libMesh::dof_id_type row, const libMesh::dof_id_type n_nonzeros_in)
 
libMesh::dof_id_type n_nonzeros (const libMesh::dof_id_type row) const
 
void prepare_for_use ()
 
IndexType & operator() (const libMesh::dof_id_type row, const libMesh::dof_id_type nonzero)
 
const IndexType & operator() (const libMesh::dof_id_type row, const libMesh::dof_id_type nonzero) const
 

Public Attributes

std::vector< IndexType > offsets
 
std::vector< IndexType > vals
 

Detailed Description

template<class IndexType>
class libMesh::METIS_CSR_Graph< IndexType >

Compressed graph data structure used by MetisPartitioner.

This utility class provides a convenient implementation for building the compressed-row-storage graph required for the METIS/ParMETIS graph partitioning schemes.

Author
Benjamin S. Kirk
Date
2013

Definition at line 43 of file metis_csr_graph.h.

Member Function Documentation

template<class IndexType>
libMesh::dof_id_type libMesh::METIS_CSR_Graph< IndexType >::n_nonzeros ( const libMesh::dof_id_type  row) const
inline
Returns
the number of nonzeros in the requested row by subtracting the offsets vector entries.

Definition at line 63 of file metis_csr_graph.h.

64  {
65  libmesh_assert_less (row+1, offsets.size());
66  return (offsets[row+1] - offsets[row]);
67  }
std::vector< IndexType > offsets
template<class IndexType>
IndexType& libMesh::METIS_CSR_Graph< IndexType >::operator() ( const libMesh::dof_id_type  row,
const libMesh::dof_id_type  nonzero 
)
inline
Returns
a writable reference to the nonzero'th entry of row.

Definition at line 86 of file metis_csr_graph.h.

88  {
89  libmesh_assert_greater (vals.size(), offsets[row]+nonzero);
90 
91  return vals[offsets[row]+nonzero];
92  }
std::vector< IndexType > offsets
std::vector< IndexType > vals
template<class IndexType>
const IndexType& libMesh::METIS_CSR_Graph< IndexType >::operator() ( const libMesh::dof_id_type  row,
const libMesh::dof_id_type  nonzero 
) const
inline
Returns
a const reference to the nonzero'th entry of row.

Definition at line 97 of file metis_csr_graph.h.

99  {
100  libmesh_assert_greater (vals.size(), offsets[row]+nonzero);
101 
102  return vals[offsets[row]+nonzero];
103  }
std::vector< IndexType > offsets
std::vector< IndexType > vals
template<class IndexType>
void libMesh::METIS_CSR_Graph< IndexType >::prep_n_nonzeros ( const libMesh::dof_id_type  row,
const libMesh::dof_id_type  n_nonzeros_in 
)
inline

Sets the number of non-zero values in the given row. The internal indexing is 1-based.

Definition at line 52 of file metis_csr_graph.h.

Referenced by libMesh::MetisPartitioner::partition_range().

54  {
55  libmesh_assert_less (row+1, offsets.size());
56  offsets[row+1] = n_nonzeros_in;
57  }
std::vector< IndexType > offsets
template<class IndexType>
void libMesh::METIS_CSR_Graph< IndexType >::prepare_for_use ( )
inline

Replaces the entries in the offsets vector with their partial sums and resizes the val vector accordingly.

Definition at line 73 of file metis_csr_graph.h.

References libMesh::libmesh_assert().

Referenced by libMesh::MetisPartitioner::partition_range().

74  {
75  std::partial_sum (offsets.begin(), offsets.end(), offsets.begin());
76  libmesh_assert (!offsets.empty());
77  vals.resize(offsets.back());
78 
79  if (vals.empty())
80  vals.push_back(0);
81  }
libmesh_assert(j)
std::vector< IndexType > offsets
std::vector< IndexType > vals

Member Data Documentation

template<class IndexType>
std::vector<IndexType> libMesh::METIS_CSR_Graph< IndexType >::offsets

Definition at line 46 of file metis_csr_graph.h.

Referenced by libMesh::MetisPartitioner::partition_range().

template<class IndexType>
std::vector<IndexType> libMesh::METIS_CSR_Graph< IndexType >::vals

Definition at line 46 of file metis_csr_graph.h.

Referenced by libMesh::MetisPartitioner::partition_range().


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