MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
mfem::HypreParMatrix Class Reference

Wrapper for hypre's ParCSR matrix class. More...

#include <hypre.hpp>

Inheritance diagram for mfem::HypreParMatrix:
[legend]
Collaboration diagram for mfem::HypreParMatrix:
[legend]

Public Member Functions

 HypreParMatrix ()
 An empty matrix to be used as a reference to an existing matrix. More...
 
 HypreParMatrix (hypre_ParCSRMatrix *a)
 Converts hypre's format to HypreParMatrix. More...
 
 HypreParMatrix (MPI_Comm comm, HYPRE_Int glob_size, HYPRE_Int *row_starts, SparseMatrix *diag)
 
 HypreParMatrix (MPI_Comm comm, HYPRE_Int global_num_rows, HYPRE_Int global_num_cols, HYPRE_Int *row_starts, HYPRE_Int *col_starts, SparseMatrix *diag)
 
 HypreParMatrix (MPI_Comm comm, HYPRE_Int global_num_rows, HYPRE_Int global_num_cols, HYPRE_Int *row_starts, HYPRE_Int *col_starts, SparseMatrix *diag, SparseMatrix *offd, HYPRE_Int *cmap)
 
 HypreParMatrix (MPI_Comm comm, HYPRE_Int global_num_rows, HYPRE_Int global_num_cols, HYPRE_Int *row_starts, HYPRE_Int *col_starts, HYPRE_Int *diag_i, HYPRE_Int *diag_j, double *diag_data, HYPRE_Int *offd_i, HYPRE_Int *offd_j, double *offd_data, HYPRE_Int offd_num_cols, HYPRE_Int *offd_col_map)
 
 HypreParMatrix (MPI_Comm comm, HYPRE_Int *row_starts, HYPRE_Int *col_starts, SparseMatrix *a)
 Creates a parallel matrix from SparseMatrix on processor 0. More...
 
 HypreParMatrix (MPI_Comm comm, HYPRE_Int global_num_rows, HYPRE_Int global_num_cols, HYPRE_Int *row_starts, HYPRE_Int *col_starts, Table *diag)
 
 HypreParMatrix (MPI_Comm comm, int id, int np, HYPRE_Int *row, HYPRE_Int *col, HYPRE_Int *i_diag, HYPRE_Int *j_diag, HYPRE_Int *i_offd, HYPRE_Int *j_offd, HYPRE_Int *cmap, HYPRE_Int cmap_size)
 
 HypreParMatrix (MPI_Comm comm, int nrows, HYPRE_Int glob_nrows, HYPRE_Int glob_ncols, int *I, HYPRE_Int *J, double *data, HYPRE_Int *rows, HYPRE_Int *cols)
 
void MakeRef (const HypreParMatrix &master)
 Make this HypreParMatrix a reference to 'master'. More...
 
MPI_Comm GetComm () const
 MPI communicator. More...
 
 operator hypre_ParCSRMatrix * ()
 Typecasting to hypre's hypre_ParCSRMatrix*. More...
 
 operator HYPRE_ParCSRMatrix ()
 Typecasting to hypre's HYPRE_ParCSRMatrix, a.k.a. void *. More...
 
hypre_ParCSRMatrix * StealData ()
 Changes the ownership of the the matrix. More...
 
void SetOwnerFlags (char diag, char offd, char colmap)
 Explicitly set the three ownership flags, see docs for diagOwner etc. More...
 
char OwnsDiag () const
 Get diag ownership flag. More...
 
char OwnsOffd () const
 Get offd ownership flag. More...
 
char OwnsColMap () const
 Get colmap ownership flag. More...
 
void CopyRowStarts ()
 
void CopyColStarts ()
 
HYPRE_Int NNZ ()
 Returns the global number of nonzeros. More...
 
HYPRE_Int * RowPart ()
 Returns the row partitioning. More...
 
HYPRE_Int * ColPart ()
 Returns the column partitioning. More...
 
HYPRE_Int M ()
 Returns the global number of rows. More...
 
HYPRE_Int N ()
 Returns the global number of columns. More...
 
void GetDiag (Vector &diag) const
 Get the local diagonal of the matrix. More...
 
void GetDiag (SparseMatrix &diag) const
 Get the local diagonal block. NOTE: 'diag' will not own any data. More...
 
void GetOffd (SparseMatrix &offd, HYPRE_Int *&cmap) const
 Get the local off-diagonal block. NOTE: 'offd' will not own any data. More...
 
void GetBlocks (Array2D< HypreParMatrix * > &blocks, bool interleaved_rows=false, bool interleaved_cols=false) const
 
HypreParMatrixTranspose ()
 Returns the transpose of *this. More...
 
int GetNumRows () const
 Returns the number of rows in the diagonal block of the ParCSRMatrix. More...
 
int GetNumCols () const
 Returns the number of columns in the diagonal block of the ParCSRMatrix. More...
 
HYPRE_Int GetGlobalNumRows () const
 
HYPRE_Int GetGlobalNumCols () const
 
HYPRE_Int * GetRowStarts () const
 
HYPRE_Int * GetColStarts () const
 
HYPRE_Int Mult (HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
 Computes y = alpha * A * x + beta * y. More...
 
HYPRE_Int Mult (HYPRE_ParVector x, HYPRE_ParVector y, double alpha=1.0, double beta=0.0)
 Computes y = alpha * A * x + beta * y. More...
 
HYPRE_Int MultTranspose (HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
 Computes y = alpha * A^t * x + beta * y. More...
 
void Mult (double a, const Vector &x, double b, Vector &y) const
 
void MultTranspose (double a, const Vector &x, double b, Vector &y) const
 
virtual void Mult (const Vector &x, Vector &y) const
 Operator application. More...
 
virtual void MultTranspose (const Vector &x, Vector &y) const
 Action of the transpose operator. More...
 
void BooleanMult (int alpha, int *x, int beta, int *y)
 
HypreParMatrixLeftDiagMult (const SparseMatrix &D, HYPRE_Int *row_starts=NULL) const
 
void ScaleRows (const Vector &s)
 Scale the local row i by s(i). More...
 
void InvScaleRows (const Vector &s)
 Scale the local row i by 1./s(i) More...
 
void operator*= (double s)
 Scale all entries by s: A_scaled = s*A. More...
 
void Threshold (double threshold=0.0)
 Remove values smaller in absolute value than some threshold. More...
 
void EliminateZeroRows ()
 If a row contains only zeros, set its diagonal to 1. More...
 
void EliminateRowsCols (const Array< int > &rows_cols, const HypreParVector &X, HypreParVector &B)
 
HypreParMatrixEliminateRowsCols (const Array< int > &rows_cols)
 
void Print (const char *fname, HYPRE_Int offi=0, HYPRE_Int offj=0)
 Prints the locally owned rows in parallel. More...
 
void Read (MPI_Comm comm, const char *fname)
 Reads the matrix from a file. More...
 
virtual ~HypreParMatrix ()
 Calls hypre's destroy function. More...
 
- Public Member Functions inherited from mfem::Operator
 Operator (int s=0)
 Construct a square Operator with given size s (default 0) More...
 
 Operator (int h, int w)
 
int Height () const
 Get the height (size of output) of the Operator. Synonym with NumRows. More...
 
int NumRows () const
 
int Width () const
 Get the width (size of input) of the Operator. Synonym with NumCols. More...
 
int NumCols () const
 
virtual OperatorGetGradient (const Vector &x) const
 Evaluate the gradient operator at the point x. More...
 
void PrintMatlab (std::ostream &out, int n=0, int m=0)
 Prints operator with input size n and output size m in matlab format. More...
 
virtual ~Operator ()
 

Additional Inherited Members

- Protected Attributes inherited from mfem::Operator
int height
 
int width
 

Detailed Description

Wrapper for hypre's ParCSR matrix class.

Definition at line 143 of file hypre.hpp.

Constructor & Destructor Documentation

mfem::HypreParMatrix::HypreParMatrix ( )

An empty matrix to be used as a reference to an existing matrix.

Definition at line 211 of file hypre.cpp.

mfem::HypreParMatrix::HypreParMatrix ( hypre_ParCSRMatrix *  a)
inline

Converts hypre's format to HypreParMatrix.

Definition at line 195 of file hypre.hpp.

mfem::HypreParMatrix::HypreParMatrix ( MPI_Comm  comm,
HYPRE_Int  glob_size,
HYPRE_Int *  row_starts,
SparseMatrix diag 
)

Creates block-diagonal square parallel matrix. Diagonal is given by diag which must be in CSR format (finalized). The new HypreParMatrix does not take ownership of any of the input arrays.

Definition at line 269 of file hypre.cpp.

mfem::HypreParMatrix::HypreParMatrix ( MPI_Comm  comm,
HYPRE_Int  global_num_rows,
HYPRE_Int  global_num_cols,
HYPRE_Int *  row_starts,
HYPRE_Int *  col_starts,
SparseMatrix diag 
)

Creates block-diagonal rectangular parallel matrix. Diagonal is given by diag which must be in CSR format (finalized). The new HypreParMatrix does not take ownership of any of the input arrays.

Definition at line 304 of file hypre.cpp.

mfem::HypreParMatrix::HypreParMatrix ( MPI_Comm  comm,
HYPRE_Int  global_num_rows,
HYPRE_Int  global_num_cols,
HYPRE_Int *  row_starts,
HYPRE_Int *  col_starts,
SparseMatrix diag,
SparseMatrix offd,
HYPRE_Int *  cmap 
)

Creates general (rectangular) parallel matrix. The new HypreParMatrix does not take ownership of any of the input arrays.

Definition at line 341 of file hypre.cpp.

mfem::HypreParMatrix::HypreParMatrix ( MPI_Comm  comm,
HYPRE_Int  global_num_rows,
HYPRE_Int  global_num_cols,
HYPRE_Int *  row_starts,
HYPRE_Int *  col_starts,
HYPRE_Int *  diag_i,
HYPRE_Int *  diag_j,
double *  diag_data,
HYPRE_Int *  offd_i,
HYPRE_Int *  offd_j,
double *  offd_data,
HYPRE_Int  offd_num_cols,
HYPRE_Int *  offd_col_map 
)

Creates general (rectangular) parallel matrix. The new HypreParMatrix takes ownership of all input arrays, except col_starts and row_starts.

Definition at line 385 of file hypre.cpp.

mfem::HypreParMatrix::HypreParMatrix ( MPI_Comm  comm,
HYPRE_Int *  row_starts,
HYPRE_Int *  col_starts,
SparseMatrix a 
)

Creates a parallel matrix from SparseMatrix on processor 0.

Definition at line 439 of file hypre.cpp.

mfem::HypreParMatrix::HypreParMatrix ( MPI_Comm  comm,
HYPRE_Int  global_num_rows,
HYPRE_Int  global_num_cols,
HYPRE_Int *  row_starts,
HYPRE_Int *  col_starts,
Table diag 
)

Creates boolean block-diagonal rectangular parallel matrix. The new HypreParMatrix does not take ownership of any of the input arrays.

Definition at line 479 of file hypre.cpp.

mfem::HypreParMatrix::HypreParMatrix ( MPI_Comm  comm,
int  id,
int  np,
HYPRE_Int *  row,
HYPRE_Int *  col,
HYPRE_Int *  i_diag,
HYPRE_Int *  j_diag,
HYPRE_Int *  i_offd,
HYPRE_Int *  j_offd,
HYPRE_Int *  cmap,
HYPRE_Int  cmap_size 
)

Creates boolean rectangular parallel matrix. The new HypreParMatrix takes ownership of the arrays i_diag, j_diag, i_offd, j_offd, and cmap; does not take ownership of the arrays row and col.

Definition at line 518 of file hypre.cpp.

mfem::HypreParMatrix::HypreParMatrix ( MPI_Comm  comm,
int  nrows,
HYPRE_Int  glob_nrows,
HYPRE_Int  glob_ncols,
int *  I,
HYPRE_Int *  J,
double *  data,
HYPRE_Int *  rows,
HYPRE_Int *  cols 
)

Creates a general parallel matrix from a local CSR matrix on each processor described by the I, J and data arrays. The local matrix should be of size (local) nrows by (global) glob_ncols. The new parallel matrix contains copies of all input arrays (so they can be deleted).

Definition at line 598 of file hypre.cpp.

virtual mfem::HypreParMatrix::~HypreParMatrix ( )
inlinevirtual

Calls hypre's destroy function.

Definition at line 407 of file hypre.hpp.

Member Function Documentation

void mfem::HypreParMatrix::BooleanMult ( int  alpha,
int *  x,
int  beta,
int *  y 
)
inline

The "Boolean" analog of y = alpha * A * x + beta * y, where elements in the sparsity pattern of the matrix are treated as "true".

Definition at line 363 of file hypre.hpp.

HYPRE_Int* mfem::HypreParMatrix::ColPart ( )
inline

Returns the column partitioning.

Definition at line 297 of file hypre.hpp.

void mfem::HypreParMatrix::CopyColStarts ( )

If the HypreParMatrix does not own the col-starts array, make a copy of it that the HypreParMatrix will own. If the row-starts array is the same as the col-starts array, row-starts is also replaced.

Definition at line 787 of file hypre.cpp.

void mfem::HypreParMatrix::CopyRowStarts ( )

If the HypreParMatrix does not own the row-starts array, make a copy of it that the HypreParMatrix will own. If the col-starts array is the same as the row-starts array, col-starts is also replaced.

Definition at line 750 of file hypre.cpp.

void mfem::HypreParMatrix::EliminateRowsCols ( const Array< int > &  rows_cols,
const HypreParVector X,
HypreParVector B 
)

Eliminate rows and columns from the matrix, and rows from the vector B. Modify B with the BC values in X.

Definition at line 1213 of file hypre.cpp.

HypreParMatrix * mfem::HypreParMatrix::EliminateRowsCols ( const Array< int > &  rows_cols)

Eliminate rows and columns from the matrix and store the eliminated elements in a new matrix Ae (returned), so that the modified matrix and Ae sum to the original matrix.

Definition at line 1224 of file hypre.cpp.

void mfem::HypreParMatrix::EliminateZeroRows ( )
inline

If a row contains only zeros, set its diagonal to 1.

Definition at line 389 of file hypre.hpp.

void mfem::HypreParMatrix::GetBlocks ( Array2D< HypreParMatrix * > &  blocks,
bool  interleaved_rows = false,
bool  interleaved_cols = false 
) const

Split the matrix into M x N equally sized blocks of parallel matrices. The size of 'blocks' must already be set to M x N.

Definition at line 870 of file hypre.cpp.

HYPRE_Int* mfem::HypreParMatrix::GetColStarts ( ) const
inline

Definition at line 341 of file hypre.hpp.

MPI_Comm mfem::HypreParMatrix::GetComm ( ) const
inline

MPI communicator.

Definition at line 261 of file hypre.hpp.

void mfem::HypreParMatrix::GetDiag ( Vector diag) const

Get the local diagonal of the matrix.

Definition at line 828 of file hypre.cpp.

void mfem::HypreParMatrix::GetDiag ( SparseMatrix diag) const

Get the local diagonal block. NOTE: 'diag' will not own any data.

Definition at line 859 of file hypre.cpp.

HYPRE_Int mfem::HypreParMatrix::GetGlobalNumCols ( ) const
inline

Definition at line 336 of file hypre.hpp.

HYPRE_Int mfem::HypreParMatrix::GetGlobalNumRows ( ) const
inline

Definition at line 333 of file hypre.hpp.

int mfem::HypreParMatrix::GetNumCols ( ) const
inline

Returns the number of columns in the diagonal block of the ParCSRMatrix.

Definition at line 327 of file hypre.hpp.

int mfem::HypreParMatrix::GetNumRows ( ) const
inline

Returns the number of rows in the diagonal block of the ParCSRMatrix.

Definition at line 320 of file hypre.hpp.

void mfem::HypreParMatrix::GetOffd ( SparseMatrix offd,
HYPRE_Int *&  cmap 
) const

Get the local off-diagonal block. NOTE: 'offd' will not own any data.

Definition at line 864 of file hypre.cpp.

HYPRE_Int* mfem::HypreParMatrix::GetRowStarts ( ) const
inline

Definition at line 339 of file hypre.hpp.

void mfem::HypreParMatrix::InvScaleRows ( const Vector s)

Scale the local row i by 1./s(i)

Definition at line 1081 of file hypre.cpp.

HypreParMatrix * mfem::HypreParMatrix::LeftDiagMult ( const SparseMatrix D,
HYPRE_Int *  row_starts = NULL 
) const

Multiply A on the left by a block-diagonal parallel matrix D. Return a new parallel matrix, D*A. If D has a different number of rows than A, D's row starts array needs to be given (as returned by the methods GetDofOffsets/GetTrueDofOffsets of ParFiniteElementSpace). The new matrix D*A uses copies of the row-, column-starts arrays, so "this" matrix and "row_starts" can be deleted. NOTE: this operation is local and does not require communication.

Definition at line 969 of file hypre.cpp.

HYPRE_Int mfem::HypreParMatrix::M ( )
inline

Returns the global number of rows.

Definition at line 299 of file hypre.hpp.

void mfem::HypreParMatrix::MakeRef ( const HypreParMatrix master)

Make this HypreParMatrix a reference to 'master'.

Definition at line 726 of file hypre.cpp.

HYPRE_Int mfem::HypreParMatrix::Mult ( HypreParVector x,
HypreParVector y,
double  alpha = 1.0,
double  beta = 0.0 
)

Computes y = alpha * A * x + beta * y.

Definition at line 903 of file hypre.cpp.

HYPRE_Int mfem::HypreParMatrix::Mult ( HYPRE_ParVector  x,
HYPRE_ParVector  y,
double  alpha = 1.0,
double  beta = 0.0 
)

Computes y = alpha * A * x + beta * y.

Definition at line 956 of file hypre.cpp.

void mfem::HypreParMatrix::Mult ( double  a,
const Vector x,
double  b,
Vector y 
) const

Definition at line 909 of file hypre.cpp.

virtual void mfem::HypreParMatrix::Mult ( const Vector x,
Vector y 
) const
inlinevirtual

Operator application.

Implements mfem::Operator.

Definition at line 356 of file hypre.hpp.

HYPRE_Int mfem::HypreParMatrix::MultTranspose ( HypreParVector x,
HypreParVector y,
double  alpha = 1.0,
double  beta = 0.0 
)

Computes y = alpha * A^t * x + beta * y.

Definition at line 963 of file hypre.cpp.

void mfem::HypreParMatrix::MultTranspose ( double  a,
const Vector x,
double  b,
Vector y 
) const

Definition at line 931 of file hypre.cpp.

virtual void mfem::HypreParMatrix::MultTranspose ( const Vector x,
Vector y 
) const
inlinevirtual

Action of the transpose operator.

Reimplemented from mfem::Operator.

Definition at line 358 of file hypre.hpp.

HYPRE_Int mfem::HypreParMatrix::N ( )
inline

Returns the global number of columns.

Definition at line 301 of file hypre.hpp.

HYPRE_Int mfem::HypreParMatrix::NNZ ( )
inline

Returns the global number of nonzeros.

Definition at line 293 of file hypre.hpp.

mfem::HypreParMatrix::operator HYPRE_ParCSRMatrix ( )
inline

Typecasting to hypre's HYPRE_ParCSRMatrix, a.k.a. void *.

Definition at line 267 of file hypre.hpp.

mfem::HypreParMatrix::operator hypre_ParCSRMatrix * ( )
inline

Typecasting to hypre's hypre_ParCSRMatrix*.

Definition at line 264 of file hypre.hpp.

void mfem::HypreParMatrix::operator*= ( double  s)

Scale all entries by s: A_scaled = s*A.

Definition at line 1122 of file hypre.cpp.

char mfem::HypreParMatrix::OwnsColMap ( ) const
inline

Get colmap ownership flag.

Definition at line 281 of file hypre.hpp.

char mfem::HypreParMatrix::OwnsDiag ( ) const
inline

Get diag ownership flag.

Definition at line 277 of file hypre.hpp.

char mfem::HypreParMatrix::OwnsOffd ( ) const
inline

Get offd ownership flag.

Definition at line 279 of file hypre.hpp.

void mfem::HypreParMatrix::Print ( const char *  fname,
HYPRE_Int  offi = 0,
HYPRE_Int  offj = 0 
)

Prints the locally owned rows in parallel.

Definition at line 1236 of file hypre.cpp.

void mfem::HypreParMatrix::Read ( MPI_Comm  comm,
const char *  fname 
)

Reads the matrix from a file.

Definition at line 1241 of file hypre.cpp.

HYPRE_Int* mfem::HypreParMatrix::RowPart ( )
inline

Returns the row partitioning.

Definition at line 295 of file hypre.hpp.

void mfem::HypreParMatrix::ScaleRows ( const Vector s)

Scale the local row i by s(i).

Definition at line 1046 of file hypre.cpp.

void mfem::HypreParMatrix::SetOwnerFlags ( char  diag,
char  offd,
char  colmap 
)
inline

Explicitly set the three ownership flags, see docs for diagOwner etc.

Definition at line 273 of file hypre.hpp.

hypre_ParCSRMatrix * mfem::HypreParMatrix::StealData ( )

Changes the ownership of the the matrix.

Definition at line 736 of file hypre.cpp.

void mfem::HypreParMatrix::Threshold ( double  threshold = 0.0)

Remove values smaller in absolute value than some threshold.

Definition at line 1160 of file hypre.cpp.

HypreParMatrix * mfem::HypreParMatrix::Transpose ( )

Returns the transpose of *this.

Definition at line 892 of file hypre.cpp.


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