LifeV
MatrixEpetraStructured< DataType > Class Template Reference

MatrixEpetraStructured - class of block matrix. More...

#include <MatrixEpetraStructured.hpp>

+ Inheritance diagram for MatrixEpetraStructured< DataType >:
+ Collaboration diagram for MatrixEpetraStructured< DataType >:

Public Types

typedef MatrixEpetraStructuredView< DataType > block_type
 
typedef std::shared_ptr< block_typeblock_ptrType
 
- Public Types inherited from MatrixEpetra< DataType >
typedef Epetra_FECrsMatrix matrix_type
 
typedef std::shared_ptr< matrix_typematrix_ptrtype
 
typedef VectorEpetra vector_type
 
typedef std::shared_ptr< vector_typevectorPtr_Type
 

Private Attributes

MatrixBlockStructure M_blockStructure
 

Constructors, destructor

 MatrixEpetraStructured (const MapEpetra &map, int numEntries=50, bool ignoreNonLocalValues=false)
 default constructor. More...
 
 MatrixEpetraStructured (const MapVector< MapEpetra > &vector, int numEntries=50, bool ignoreNonLocalValues=false)
 Block constructor. More...
 
 MatrixEpetraStructured (const MatrixEpetra< DataType > &matrix)
 Casting constructor. More...
 
 MatrixEpetraStructured (const MatrixEpetraStructured &matrix)
 Copy constructor. More...
 
 ~MatrixEpetraStructured ()
 Destructor. More...
 

Set Methods

void setBlockStructure (const std::vector< UInt > &blockNumRows, const std::vector< UInt > &blockNumColumns)
 
void setBlockStructure (const MapVector< MapEpetra > &mapVector)
 
void setBlockStructure (const MatrixBlockStructure &blockStructure)
 Set the block structure from a matrix structure object. More...
 
void setBlockStructure (const VectorBlockStructure &rowsBlockStructure, const VectorBlockStructure &columnsBlockStructure)
 Set the block structure from row and column structures. More...
 
void setBlockStructure (const VectorBlockStructure &vectorBlockStructure)
 Set the block structure from row and column structures. More...
 

Get Methods

UInt blockNumRows (const UInt &rowIndex) const
 Returns the number of rows of the block. More...
 
UInt blockNumColumns (const UInt &columnIndex) const
 Returns the number of columns of the block. More...
 
void blockView (const UInt &rowIndex, const UInt &columnIndex, block_type &mbv)
 Returns the MatrixEpetraStructuredView at the (rowIndex,colIndex) location. More...
 
block_ptrType block (const UInt &rowIndex, const UInt &columnIndex)
 Returns the block (rowIndex,columnIndex) of the matrix. More...
 
VectorBlockStructure rowsBlockStructure () const
 Get the rows block structure. More...
 
VectorBlockStructure columnsBlockStructure () const
 Get the columns block structure. More...
 
MatrixBlockStructure blockStructure () const
 Get the matrix block structure. More...
 

Linear Algebra Methods

std::shared_ptr< MatrixEpetraStructured< DataType > > transpose ()
 Returns a pointer to a new matrix which contains the transpose of the current matrix. More...
 

Additional Inherited Members

- Public Member Functions inherited from MatrixEpetra< DataType >
 MatrixEpetra (const MapEpetra &map, const Epetra_CrsGraph &graph, bool ignoreNonLocalValues=false)
 Constructor from a graph. More...
 
 MatrixEpetra (const MapEpetra &map, const Epetra_FECrsGraph &graph, bool ignoreNonLocalValues=false)
 Constructor from a FE graph. More...
 
 MatrixEpetra (const MapEpetra &map, Int numEntries=50, bool ignoreNonLocalValues=false)
 Constructor for square and rectangular matrices. More...
 
 MatrixEpetra (const MapEpetra &map, Int *numEntriesPerRow, bool ignoreNonLocalValues=false)
 Constructor for square and rectangular matrices, knowing the number of entries per row. More...
 
 MatrixEpetra (const MatrixEpetra &matrix)
 Copy Constructor. More...
 
 MatrixEpetra (const MatrixEpetra &matrix, const UInt reduceToProc)
 Copies the matrix to a matrix which resides only on the processor. More...
 
 LIFEV_DEPRECATED (MatrixEpetra(matrix_ptrtype crsMatrixPtr))
 Constructs an MatrixEpetra view of an Epetra_FECrsMatrix. More...
 
 MatrixEpetra (const MapEpetra &map, matrix_ptrtype crsMatrixPtr)
 Constructs an MatrixEpetra view of an Epetra_FECrsMatrix. More...
 
virtual ~MatrixEpetra ()
 Destructor. More...
 
MatrixEpetraoperator+= (const MatrixEpetra &matrix)
 Addition operator. More...
 
MatrixEpetraoperator-= (const MatrixEpetra &matrix)
 Subtraction operator. More...
 
MatrixEpetraoperator= (const MatrixEpetra &matrix)
 Assignment operator. More...
 
vector_type operator* (const vector_type &vector) const
 Matrix-Vector multiplication. More...
 
MatrixEpetraoperator*= (const DataType scalar)
 Multiplication operator. More...
 
MatrixEpetra operator* (const DataType scalar) const
 Multiplication operator. More...
 
void openCrsMatrix ()
 If the matrix has been filled, this function will reopen the Matrix. More...
 
void removeZeros ()
 This function removes all the zeros in the matrix and add zero on the diagonal. More...
 
void swapCrsMatrix (matrix_ptrtype &matrixPtr)
 Swap the given shared pointer with the one of the matrix. More...
 
void swapCrsMatrix (MatrixEpetra< DataType > &matrix)
 Swap the matrix with the one given as argument. More...
 
Int multiply (bool transposeCurrent, const MatrixEpetra< DataType > &matrix, bool transposeMatrix, MatrixEpetra< DataType > &result, bool callFillCompleteOnResult=true) const
 Multiply the MatrixEpetra by the first given matrix and put the result in the second given matrix. More...
 
Int multiply (bool transposeCurrent, const vector_type &vector1, vector_type &vector2) const
 Multiply the first VectorEpetra given as a parameter by the MatrixEpetra and put the result into the second given VectorEpetra. More...
 
void addDyadicProduct (const vector_type &uniqueVector1, const vector_type &uniqueVector2)
 Add to the matrix a dyadic product:

\[ C += A \otimes B + \]

, where

\[ C \]

is the matrix. More...

 
void add (const DataType scalar, const MatrixEpetra &matrix)
 Add a multiple of a given matrix: *this += scalar*matrix. More...
 
std::shared_ptr< MatrixEpetra< DataType > > transpose ()
 Returns a pointer to a new matrix which contains the transpose of the current matrix. More...
 
void diagonalize (std::vector< UInt > rVec, DataType const coefficient, UInt offset=0)
 Set entries (rVec(i),rVec(i)) to coefficient and the rest of the row entries to zero. More...
 
void diagonalize (UInt const entryIndex, DataType const coefficient, UInt offset=0)
 Set entry (entryIndex,entryIndex) to coefficient and the rest of the row to zero. More...
 
void diagonalize (std::vector< UInt > rVec, DataType const coefficient, vector_type &rhs, std::vector< DataType > datumVector, UInt offset=0)
 apply constraint on all rows rVec More...
 
void diagonalize (UInt const row, DataType const coefficient, vector_type &rhs, DataType datum, UInt offset=0)
 apply constraint on row "row" More...
 
void matrixMarket (std::string const &fileName, const bool headers=true)
 Save the matrix into a MatrixMarket (.mtx) file. More...
 
void spy (std::string const &fileName)
 Save the matrix into a Matlab (.m) file. More...
 
void exportToHDF5 (std::string const &fileName, std::string const &matrixName="matrix", bool const &truncate=true)
 Save the matrix into a HDF5 (.h5) file. More...
 
void importFromHDF5 (std::string const &fileName, std::string const &matrixName="matrix")
 Read a matrix from a HDF5 (.h5) file. More...
 
void showMe (std::ostream &output=std::cout) const
 Print the contents of the matrix. More...
 
Int globalAssemble ()
 Global assemble of a square matrix with default domain and range map. More...
 
Int globalAssemble (const std::shared_ptr< const MapEpetra > &domainMap, const std::shared_ptr< const MapEpetra > &rangeMap)
 Global assemble for rectangular matrices. More...
 
Int fillComplete ()
 Fill complete of a square matrix with default domain and range map. More...
 
void insertValueDiagonal (const DataType entry, const MapEpetra &Map, const UInt offset=0)
 insert the given value into the diagonal More...
 
void insertValueDiagonal (const DataType &value, Int from=-1, Int to=-2)
 insert the given value into the diagonal More...
 
void insertOneDiagonal (Int from=-1, Int to=-2)
 insert ones into the diagonal to ensure the matrix' graph has a entry there More...
 
void insertZeroDiagonal (Int from=-1, Int to=-2)
 insert zeros into the diagonal to ensure the matrix' graph has a entry there More...
 
Real norm1 () const
 Compute the norm 1 of the global matrix. More...
 
Real normInf () const
 Compute the norm inf of the global matrix. More...
 
Real normFrobenius () const
 Compute the frobenius norm of the global matrix. More...
 
void zero ()
 set zero in all the matrix entries More...
 
void setCoefficients (Int const numRows, Int const numColumns, std::vector< Int > const &rowIndices, std::vector< Int > const &columnIndices, DataType *const *const localValues, Int format=Epetra_FECrsMatrix::COLUMN_MAJOR)
 Set a set of values to the corresponding set of coefficient in the matrix. More...
 
void setCoefficient (UInt row, UInt column, DataType localValue)
 Set a coefficient of the matrix. More...
 
void addToCoefficients (Int const numRows, Int const numColumns, std::vector< Int > const &rowIndices, std::vector< Int > const &columnIndices, DataType *const *const localValues, Int format=Epetra_FECrsMatrix::COLUMN_MAJOR)
 Add a set of values to the corresponding set of coefficient in the matrix. More...
 
void sumIntoCoefficients (Int const numRows, Int const numColumns, std::vector< Int > const &rowIndices, std::vector< Int > const &columnIndices, DataType *const *const localValues, Int format=Epetra_FECrsMatrix::COLUMN_MAJOR)
 Add a set of values to the corresponding set of coefficient in the closed matrix. More...
 
void addToCoefficient (UInt const row, UInt const column, DataType const localValue)
 Add a value at a coefficient of the matrix. More...
 
void setUseTranspose (const bool &transpose=false)
 If set true, transpose of this operator will be applied. More...
 
bool filled () const
 Return the fill-complete status of the Epetra_FECrsMatrix. More...
 
matrix_ptrtypematrixPtr ()
 Return the shared_pointer of the Epetra_FECrsMatrix. More...
 
std::shared_ptr< MapEpetramapPtr ()
 Return the shared_pointer of the Epetra_Map. More...
 
const matrix_ptrtypematrixPtr () const
 Return the const shared_pointer of the Epetra_FECrsMatrix. More...
 
Int meanNumEntries () const
 Return the mean number of entries in the matrix rows. More...
 
Int processorId ()
 Return the Id of the processor. More...
 
const MapEpetramap () const
 Return the row MapEpetra of the MatrixEpetra used in the assembling. More...
 
const MapEpetradomainMap () const
 Return the domain MapEpetra of the MatrixEpetra. More...
 
const boost::shared_ptr< const MapEpetra > & domainMapPtr () const
 
const MapEpetrarangeMap () const
 Return the range MapEpetra of the MatrixEpetra. More...
 
const boost::shared_ptr< const MapEpetra > & rangeMapPtr () const
 
void restrict (const std::shared_ptr< MapEpetra > &map, const std::shared_ptr< VectorEpetra > &numeration, const UInt &offset, std::shared_ptr< MatrixEpetra< DataType > > &matrix_out)
 Restrict the matrix to the dofs contained in the input map. More...
 

Detailed Description

template<typename DataType>
class LifeV::MatrixEpetraStructured< DataType >

MatrixEpetraStructured - class of block matrix.

Author
Gwenol Grandperrin
Samuel Quinodoz samue.nosp@m.l.qu.nosp@m.inodo.nosp@m.z@ep.nosp@m.fl.ch

The MatrixEpetraStructured class contains data related to block matrix. It is an extension to MatrixEpetra where data about blocks have been set. For an introduction to the block structures in LifeV, see this page.

There are mainly two ways to define a MatrixEpetraStructured:

  • Construct it using the same syntax as for LifeV::MatrixEpetra and the use a setter for the structure.
  • Construct it directly with the maps of the blocks.

Both ways are equivalent.

To access the blocks, one uses then the blockView or block methods.

Definition at line 72 of file MatrixEpetraStructured.hpp.

Member Typedef Documentation

◆ block_type

Definition at line 76 of file MatrixEpetraStructured.hpp.

◆ block_ptrType

typedef std::shared_ptr<block_type> block_ptrType

Definition at line 77 of file MatrixEpetraStructured.hpp.

Constructor & Destructor Documentation

◆ MatrixEpetraStructured() [1/4]

MatrixEpetraStructured ( const MapEpetra map,
int  numEntries = 50,
bool  ignoreNonLocalValues = false 
)

default constructor.

Definition at line 208 of file MatrixEpetraStructured.hpp.

◆ MatrixEpetraStructured() [2/4]

MatrixEpetraStructured ( const MapVector< MapEpetra > &  vector,
int  numEntries = 50,
bool  ignoreNonLocalValues = false 
)

Block constructor.

This is the most complete constructor, as it builds the whole block structure of the matrix, using the maps stored in the vector.

Definition at line 218 of file MatrixEpetraStructured.hpp.

◆ MatrixEpetraStructured() [3/4]

MatrixEpetraStructured ( const MatrixEpetra< DataType > &  matrix)

Casting constructor.

Definition at line 231 of file MatrixEpetraStructured.hpp.

◆ MatrixEpetraStructured() [4/4]

MatrixEpetraStructured ( const MatrixEpetraStructured< DataType > &  matrix)

Copy constructor.

Definition at line 237 of file MatrixEpetraStructured.hpp.

◆ ~MatrixEpetraStructured()

Destructor.

Definition at line 243 of file MatrixEpetraStructured.hpp.

Member Function Documentation

◆ setBlockStructure() [1/5]

void setBlockStructure ( const std::vector< UInt > &  blockNumRows,
const std::vector< UInt > &  blockNumColumns 
)

Set the size of the blocks of the matrix

Parameters
blockNumRowsNumber of rows in the blocks
blockNumColumnsNumber of columns in the blocks

Definition at line 251 of file MatrixEpetraStructured.hpp.

◆ setBlockStructure() [2/5]

void setBlockStructure ( const MapVector< MapEpetra > &  mapVector)

Set the size of the blocks of the matrix using the maps stored in the vector of map. The resulting block structure in symmetric (same blocks in the rows and in the columns).

This method does not involve large computations. The global size and the map of the matrix cannot be changed with this method (and the block structure has to be compatible with the global size).

Definition at line 263 of file MatrixEpetraStructured.hpp.

◆ setBlockStructure() [3/5]

void setBlockStructure ( const MatrixBlockStructure blockStructure)

Set the block structure from a matrix structure object.

Definition at line 275 of file MatrixEpetraStructured.hpp.

◆ setBlockStructure() [4/5]

void setBlockStructure ( const VectorBlockStructure rowsBlockStructure,
const VectorBlockStructure columnsBlockStructure 
)

Set the block structure from row and column structures.

Definition at line 282 of file MatrixEpetraStructured.hpp.

◆ setBlockStructure() [5/5]

void setBlockStructure ( const VectorBlockStructure vectorBlockStructure)

Set the block structure from row and column structures.

Definition at line 290 of file MatrixEpetraStructured.hpp.

◆ blockNumRows()

UInt blockNumRows ( const UInt rowIndex) const

Returns the number of rows of the block.

Parameters
rowIndexRow index of the block

Definition at line 300 of file MatrixEpetraStructured.hpp.

◆ blockNumColumns()

UInt blockNumColumns ( const UInt columnIndex) const

Returns the number of columns of the block.

Parameters
columnIndexColumn index of the block

Definition at line 307 of file MatrixEpetraStructured.hpp.

◆ blockView()

void blockView ( const UInt rowIndex,
const UInt columnIndex,
block_type mbv 
)

Returns the MatrixEpetraStructuredView at the (rowIndex,colIndex) location.

Parameters
rowIndexRow position of the block in the matrix
columnIndexColumn position of the block in the matrix
mbvMatrixEpetraStructuredView to be filled

Definition at line 314 of file MatrixEpetraStructured.hpp.

◆ block()

MatrixEpetraStructured< DataType >::block_ptrType block ( const UInt rowIndex,
const UInt columnIndex 
)

Returns the block (rowIndex,columnIndex) of the matrix.

Remark that the returned block is a shared pointer. This is a limitation due to the non-copiability of the blocks.

Parameters
rowIndexThe index of the block w.r. to the block structure
columnIndexThe index of the block w.r. to the block structure

Definition at line 327 of file MatrixEpetraStructured.hpp.

◆ rowsBlockStructure()

VectorBlockStructure rowsBlockStructure ( ) const

Get the rows block structure.

Definition at line 342 of file MatrixEpetraStructured.hpp.

◆ columnsBlockStructure()

VectorBlockStructure columnsBlockStructure ( ) const

Get the columns block structure.

Definition at line 349 of file MatrixEpetraStructured.hpp.

◆ blockStructure()

MatrixBlockStructure blockStructure ( ) const

Get the matrix block structure.

Definition at line 356 of file MatrixEpetraStructured.hpp.

◆ transpose()

std::shared_ptr<MatrixEpetraStructured<DataType> > transpose ( )
inline

Returns a pointer to a new matrix which contains the transpose of the current matrix.

Definition at line 188 of file MatrixEpetraStructured.hpp.

Field Documentation

◆ M_blockStructure

MatrixBlockStructure M_blockStructure
private

Definition at line 197 of file MatrixEpetraStructured.hpp.


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