DOLFIN
DOLFIN C++ interface
Public Types | Public Member Functions | List of all members
dolfin::SparsityPattern Class Reference

#include <SparsityPattern.h>

Public Types

enum  Type { sorted, unsorted }
 Whether SparsityPattern is sorted.
 

Public Member Functions

 SparsityPattern (MPI_Comm comm, std::size_t primary_dim)
 Create empty sparsity pattern.
 
 SparsityPattern (MPI_Comm comm, std::vector< std::shared_ptr< const IndexMap >> index_maps, std::size_t primary_dim)
 Create sparsity pattern for a generic tensor.
 
void init (std::vector< std::shared_ptr< const IndexMap >> index_maps)
 Initialize sparsity pattern for a generic tensor.
 
void insert_global (dolfin::la_index i, dolfin::la_index j)
 Insert a global entry - will be fixed by apply()
 
void insert_global (const std::vector< ArrayView< const dolfin::la_index >> &entries)
 Insert non-zero entries using global indices.
 
void insert_local (const std::vector< ArrayView< const dolfin::la_index >> &entries)
 Insert non-zero entries using local (process-wise) indices.
 
void insert_local_global (const std::vector< ArrayView< const dolfin::la_index >> &entries)
 
void insert_full_rows_local (const std::vector< std::size_t > &rows)
 
std::size_t rank () const
 Return rank.
 
std::size_t primary_dim () const
 
std::pair< std::size_t, std::size_t > local_range (std::size_t dim) const
 Return local range for dimension dim.
 
std::size_t num_nonzeros () const
 Return number of local nonzeros.
 
void num_nonzeros_diagonal (std::vector< std::size_t > &num_nonzeros) const
 
void num_nonzeros_off_diagonal (std::vector< std::size_t > &num_nonzeros) const
 
void num_local_nonzeros (std::vector< std::size_t > &num_nonzeros) const
 
void apply ()
 Finalize sparsity pattern.
 
MPI_Comm mpi_comm () const
 Return MPI communicator.
 
std::string str (bool verbose) const
 Return informal string representation (pretty-print)
 
std::vector< std::vector< std::size_t > > diagonal_pattern (Type type) const
 
std::vector< std::vector< std::size_t > > off_diagonal_pattern (Type type) const
 

Detailed Description

This class implements a sparsity pattern data structure. It is used by most linear algebra backends.

Member Function Documentation

◆ diagonal_pattern()

std::vector< std::vector< std::size_t > > SparsityPattern::diagonal_pattern ( Type  type) const

Return underlying sparsity pattern (diagonal). Options are 'sorted' and 'unsorted'.

◆ insert_full_rows_local()

void SparsityPattern::insert_full_rows_local ( const std::vector< std::size_t > &  rows)

Insert full rows (or columns, according to primary dimension) using local (process-wise) indices. This must be called before any other sparse insertion occurs to avoid quadratic complexity of dense rows insertion

◆ insert_local_global()

void SparsityPattern::insert_local_global ( const std::vector< ArrayView< const dolfin::la_index >> &  entries)

Insert non-zero entries using local (process-wise) indices for the primary dimension and global indices for the co-dimension

◆ num_local_nonzeros()

void SparsityPattern::num_local_nonzeros ( std::vector< std::size_t > &  num_nonzeros) const

Fill vector with number of nonzeros in local_range for dimension 0

◆ num_nonzeros_diagonal()

void SparsityPattern::num_nonzeros_diagonal ( std::vector< std::size_t > &  num_nonzeros) const

Fill array with number of nonzeros for diagonal block in local_range for dimension 0. For matrices, fill array with number of nonzeros per local row for diagonal block

◆ num_nonzeros_off_diagonal()

void SparsityPattern::num_nonzeros_off_diagonal ( std::vector< std::size_t > &  num_nonzeros) const

Fill array with number of nonzeros for off-diagonal block in local_range for dimension 0. For matrices, fill array with number of nonzeros per local row for off-diagonal block. If there is no off-diagonal pattern, the vector is resized to zero-length

◆ off_diagonal_pattern()

std::vector< std::vector< std::size_t > > SparsityPattern::off_diagonal_pattern ( Type  type) const

Return underlying sparsity pattern (off-diagonal). Options are 'sorted' and 'unsorted'. Empty vector is returned if there is no off-diagonal contribution.

◆ primary_dim()

std::size_t dolfin::SparsityPattern::primary_dim ( ) const
inline

Return primary dimension (e.g., 0=row partition, 1=column partition)


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