OGS
MathLib::PETScSparsityPattern Struct Reference

Detailed Description

Sparsity pattern for the PETSc (parallel) build.

CSR representation with global column indices sorted within each local row. Used for type-agnostic preallocation via MATPREALLOCATOR. The index type is PetscInt, because that is the only type PETSc accepts.

Definition at line 42 of file SparsityPattern.h.

#include <SparsityPattern.h>

Public Member Functions

PetscInt nnzInRow (PetscInt const row) const
 Number of nonzeros in the given local row.
PetscInt numberOfRows () const
 Number of local rows the pattern describes.

Public Attributes

std::vector< PetscInt > row_ptr
 CSR row pointers (length n_local_rows + 1).
std::vector< PetscInt > col_idx
 Global column indices, sorted within each local row.

Member Function Documentation

◆ nnzInRow()

PetscInt MathLib::PETScSparsityPattern::nnzInRow ( PetscInt const row) const
inline

Number of nonzeros in the given local row.

Definition at line 50 of file SparsityPattern.h.

51 {
52 return row_ptr[row + 1] - row_ptr[row];
53 }
std::vector< PetscInt > row_ptr
CSR row pointers (length n_local_rows + 1).

References row_ptr.

Referenced by MathLib::PETScMatrix::preallocateFromSparsityPattern().

◆ numberOfRows()

PetscInt MathLib::PETScSparsityPattern::numberOfRows ( ) const
inline

Number of local rows the pattern describes.

Definition at line 56 of file SparsityPattern.h.

57 {
58 // A default-constructed pattern has an empty row_ptr and describes
59 // zero rows; only a populated pattern carries the trailing sentinel.
60 return row_ptr.empty() ? 0 : static_cast<PetscInt>(row_ptr.size()) - 1;
61 }

References row_ptr.

Referenced by MathLib::PETScMatrix::preallocateFromSparsityPattern().

Member Data Documentation

◆ col_idx

std::vector<PetscInt> MathLib::PETScSparsityPattern::col_idx

Global column indices, sorted within each local row.

Definition at line 47 of file SparsityPattern.h.

Referenced by computeSparsityPatternPETSc(), and MathLib::PETScMatrix::preallocateFromSparsityPattern().

◆ row_ptr

std::vector<PetscInt> MathLib::PETScSparsityPattern::row_ptr

CSR row pointers (length n_local_rows + 1).

Definition at line 45 of file SparsityPattern.h.

Referenced by computeSparsityPatternPETSc(), nnzInRow(), numberOfRows(), and MathLib::PETScMatrix::preallocateFromSparsityPattern().


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