OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
SparseMatrix< T, id_t, PETSC_BASE > Class Template Reference

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

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.

#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.
 
 SparseMatrix ()
 Create an empty Matrix.
 
openfpm::vector< triplet_type > & getMatrixTriplets ()
 Get the Matrix triplets buffer.
 
const Mat & getMat () const
 Get the Patsc Matrix object.
 
Mat & getMat ()
 Get the Petsc Matrix object.
 
void resize (size_t row, size_t col, size_t l_row, size_t l_col)
 Resize the Sparse Matrix.
 
operator() (id_t i, id_t j)
 Get the row i and the colum j of the Matrix.
 
getValue (size_t r, size_t c)
 Get the value from triplet.
 
bool isMatrixFilled ()
 Return the state of matrix.
 
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.
 

Member Typedef Documentation

◆ triplet_impl

template<typename T , typename id_t >
typedef boost::mpl::int_<PETSC_BASE> SparseMatrix< T, id_t, PETSC_BASE >::triplet_impl

Triplet implementation id.

Definition at line 103 of file SparseMatrix_petsc.hpp.

◆ triplet_type

template<typename T , typename id_t >
typedef triplet<T,PETSC_BASE> SparseMatrix< T, id_t, PETSC_BASE >::triplet_type

Triplet type.

Definition at line 106 of file SparseMatrix_petsc.hpp.

Constructor & Destructor Documentation

◆ SparseMatrix() [1/3]

template<typename T , typename id_t >
SparseMatrix< T, id_t, PETSC_BASE >::SparseMatrix ( const SparseMatrix< T, id_t, PETSC_BASE > &  spm)
inlineprivate

Disable copy constructor.

Definition at line 209 of file SparseMatrix_petsc.hpp.

◆ SparseMatrix() [2/3]

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.

◆ SparseMatrix() [3/3]

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

Create an empty Matrix.

Definition at line 245 of file SparseMatrix_petsc.hpp.

◆ ~SparseMatrix()

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

Definition at line 254 of file SparseMatrix_petsc.hpp.

Member Function Documentation

◆ fill_petsc()

template<typename T , typename id_t >
void SparseMatrix< T, id_t, PETSC_BASE >::fill_petsc ( )
inlineprivate

Fill the petsc Matrix.

Definition at line 146 of file SparseMatrix_petsc.hpp.

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

◆ write()

template<typename T , typename id_t >
bool SparseMatrix< T, id_t, PETSC_BASE >::write ( std::string  out,
size_t  opt = VTK_WRITER 
)
inline

Definition at line 391 of file SparseMatrix_petsc.hpp.

Field Documentation

◆ cols

template<typename T , typename id_t >
openfpm::vector<PetscInt> SparseMatrix< T, id_t, PETSC_BASE >::cols
mutableprivate

temporary list of colums

Definition at line 136 of file SparseMatrix_petsc.hpp.

◆ d_nnz

template<typename T , typename id_t >
openfpm::vector<PetscInt> SparseMatrix< T, id_t, PETSC_BASE >::d_nnz
mutableprivate

PETSC d_nnz.

Definition at line 138 of file SparseMatrix_petsc.hpp.

◆ g_col

template<typename T , typename id_t >
size_t SparseMatrix< T, id_t, PETSC_BASE >::g_col
private

Number of matrix colums (global)

Definition at line 113 of file SparseMatrix_petsc.hpp.

◆ g_row

template<typename T , typename id_t >
size_t SparseMatrix< T, id_t, PETSC_BASE >::g_row
private

Number of matrix row (global)

Definition at line 111 of file SparseMatrix_petsc.hpp.

◆ l_col

template<typename T , typename id_t >
size_t SparseMatrix< T, id_t, PETSC_BASE >::l_col
private

Number of matrix colums (local)

Definition at line 118 of file SparseMatrix_petsc.hpp.

◆ l_row

template<typename T , typename id_t >
size_t SparseMatrix< T, id_t, PETSC_BASE >::l_row
private

Number of matrix row (local)

Definition at line 116 of file SparseMatrix_petsc.hpp.

◆ m_created

template<typename T , typename id_t >
bool SparseMatrix< T, id_t, PETSC_BASE >::m_created = false
private

indicate if the matrix has been created

Definition at line 124 of file SparseMatrix_petsc.hpp.

◆ mat

template<typename T , typename id_t >
Mat SparseMatrix< T, id_t, PETSC_BASE >::mat
private

PETSC Matrix.

Definition at line 127 of file SparseMatrix_petsc.hpp.

◆ o_nnz

template<typename T , typename id_t >
openfpm::vector<PetscInt> SparseMatrix< T, id_t, PETSC_BASE >::o_nnz
mutableprivate

PETSC o_nnz.

Definition at line 140 of file SparseMatrix_petsc.hpp.

◆ start_row

template<typename T , typename id_t >
size_t SparseMatrix< T, id_t, PETSC_BASE >::start_row
private

starting row for this processor

Definition at line 121 of file SparseMatrix_petsc.hpp.

◆ trpl

template<typename T , typename id_t >
openfpm::vector<triplet_type> SparseMatrix< T, id_t, PETSC_BASE >::trpl
private

Triplets of the matrix.

Definition at line 130 of file SparseMatrix_petsc.hpp.

◆ vals

template<typename T , typename id_t >
openfpm::vector<PetscScalar> SparseMatrix< T, id_t, PETSC_BASE >::vals
mutableprivate

temporary list of values

Definition at line 134 of file SparseMatrix_petsc.hpp.


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