OpenFPM  5.2.0
Project that contain the implementation of distributed structures
SparseMatrix< T, id_t, PETSC_BASE > Class Template Reference

Sparse Matrix implementation, that map over Eigen. More...

#include <SparseMatrix_petsc.hpp>

Public Types

typedef boost::mpl::int_< PETSC_BASE > triplet_impl
 Triplet implementation id.
 
typedef triplet< T, PETSC_BASE > triplet_type
 Triplet type.
 

Public Member Functions

 SparseMatrix (size_t N1, size_t N2, size_t n_row_local)
 Create an empty Matrix. More...
 
 SparseMatrix ()
 Create an empty Matrix.
 
openfpm::vector< triplet_type > & getMatrixTriplets ()
 Get the Matrix triplets buffer. More...
 
const Mat & getMat () const
 Get the Patsc Matrix object. More...
 
Mat & getMat ()
 Get the Petsc Matrix object. More...
 
void resize (size_t row, size_t col, size_t l_row, size_t l_col)
 Resize the Sparse Matrix. More...
 
operator() (id_t i, id_t j)
 Get the row i and the colum j of the Matrix. More...
 
getValue (size_t r, size_t c)
 Get the value from triplet. More...
 
bool isMatrixFilled ()
 Return the state of matrix. More...
 
bool write (std::string out, size_t opt=VTK_WRITER)
 

Private Member Functions

void fill_petsc ()
 Fill the petsc Matrix.
 
 SparseMatrix (const SparseMatrix< T, id_t, PETSC_BASE > &spm)
 Disable copy constructor.
 

Private Attributes

size_t g_row
 Number of matrix row (global)
 
size_t g_col
 Number of matrix colums (global)
 
size_t l_row
 Number of matrix row (local)
 
size_t l_col
 Number of matrix colums (local)
 
size_t start_row
 starting row for this processor
 
bool m_created = false
 indicate if the matrix has been created
 
Mat mat
 PETSC Matrix.
 
openfpm::vector< triplet_typetrpl
 Triplets of the matrix.
 
openfpm::vector< PetscScalar > vals
 temporary list of values
 
openfpm::vector< PetscInt > cols
 temporary list of colums
 
openfpm::vector< PetscInt > d_nnz
 PETSC d_nnz.
 
openfpm::vector< PetscInt > o_nnz
 PETSC o_nnz.
 

Detailed Description

template<typename T, typename id_t>
class SparseMatrix< T, id_t, PETSC_BASE >

Sparse Matrix implementation, that map over Eigen.

Template Parameters
TType of the sparse Matrix store on each row,colums
id_ttype of id
implimplementation

Definition at line 98 of file SparseMatrix_petsc.hpp.

Constructor & Destructor Documentation

◆ SparseMatrix()

template<typename T , typename id_t >
SparseMatrix< T, id_t, PETSC_BASE >::SparseMatrix ( size_t  N1,
size_t  N2,
size_t  n_row_local 
)
inline

Create an empty Matrix.

Parameters
N1number of row
N2number of colums
N1_locnumber of local row

Definition at line 221 of file SparseMatrix_petsc.hpp.

Member Function Documentation

◆ getMat() [1/2]

template<typename T , typename id_t >
Mat& SparseMatrix< T, id_t, PETSC_BASE >::getMat ( )
inline

Get the Petsc Matrix object.

Returns
the Petsc Matrix

Definition at line 293 of file SparseMatrix_petsc.hpp.

◆ getMat() [2/2]

template<typename T , typename id_t >
const Mat& SparseMatrix< T, id_t, PETSC_BASE >::getMat ( ) const
inline

Get the Patsc Matrix object.

Returns
the Eigen Matrix

Definition at line 280 of file SparseMatrix_petsc.hpp.

◆ getMatrixTriplets()

template<typename T , typename id_t >
openfpm::vector<triplet_type>& SparseMatrix< T, id_t, PETSC_BASE >::getMatrixTriplets ( )
inline

Get the Matrix triplets buffer.

It return a buffer that can be filled with triplets

Returns
Petsc Matrix

Definition at line 268 of file SparseMatrix_petsc.hpp.

◆ getValue()

template<typename T , typename id_t >
T SparseMatrix< T, id_t, PETSC_BASE >::getValue ( size_t  r,
size_t  c 
)
inline

Get the value from triplet.

Warning
It is extremly slow because it do a full search across the triplets elements
Parameters
rrow
ccolum

Definition at line 364 of file SparseMatrix_petsc.hpp.

◆ isMatrixFilled()

template<typename T , typename id_t >
bool SparseMatrix< T, id_t, PETSC_BASE >::isMatrixFilled ( )
inline

Return the state of matrix.

Returns a bool flag that indicated whether the matrix has already been filled via MatSetValues

Definition at line 381 of file SparseMatrix_petsc.hpp.

◆ operator()()

template<typename T , typename id_t >
T SparseMatrix< T, id_t, PETSC_BASE >::operator() ( id_t  i,
id_t  j 
)
inline

Get the row i and the colum j of the Matrix.

Warning
it is slow, consider to get blocks of the matrix
Returns
the value of the matrix at row i colum j

Definition at line 347 of file SparseMatrix_petsc.hpp.

◆ resize()

template<typename T , typename id_t >
void SparseMatrix< T, id_t, PETSC_BASE >::resize ( size_t  row,
size_t  col,
size_t  l_row,
size_t  l_col 
)
inline

Resize the Sparse Matrix.

Parameters
rownumber for row
colnumber of colums
localnumber of row
localnumber of colums

Definition at line 309 of file SparseMatrix_petsc.hpp.


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