Public Member Functions | Private Member Functions | Private Attributes | List of all members
oomph::MatrixVectorProduct Class Reference

Matrix vector product helper class - primarily a wrapper to Trilinos's Epetra matrix vector product methods. This allows the epetra matrix to be assembled once and the matrix vector product to be performed many times. More...

#include <matrix_vector_product.h>

+ Inheritance diagram for oomph::MatrixVectorProduct:

Public Member Functions

 MatrixVectorProduct ()
 Constructor. More...
 
 MatrixVectorProduct (const MatrixVectorProduct &)=delete
 Broken copy constructor. More...
 
void operator= (const MatrixVectorProduct &)=delete
 Broken assignment operator. More...
 
 ~MatrixVectorProduct ()
 Destructor. More...
 
void clean_up_memory ()
 clear the memory More...
 
void setup (CRDoubleMatrix *matrix_pt, const LinearAlgebraDistribution *col_dist_pt=0)
 Setup the matrix vector product operator. WARNING: This class is wrapper to Trilinos Epetra matrix vector multiply methods, if Trilinos is not installed then this class will function as expected, but there will be no computational speed gain. By default the Epetra_CrsMatrix::multiply(...) are employed. The optional argument col_dist_pt is the distribution of: x if using multiply(...) or y if using multiply_transpose(...) where this is A x = y. By default, this is assumed to the uniformly distributed based on matrix_pt->ncol(). More...
 
void multiply (const DoubleVector &x, DoubleVector &y) const
 Apply the operator to the vector x and return the result in the vector y. More...
 
void multiply_transpose (const DoubleVector &x, DoubleVector &y) const
 Apply the transpose of the operator to the vector x and return the result in the vector y. More...
 
const unsigned & ncol () const
 Access function to the number of columns. More...
 
- Public Member Functions inherited from oomph::DistributableLinearAlgebraObject
 DistributableLinearAlgebraObject ()
 Default constructor - create a distribution. More...
 
 DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix)=delete
 Broken copy constructor. More...
 
void operator= (const DistributableLinearAlgebraObject &)=delete
 Broken assignment operator. More...
 
virtual ~DistributableLinearAlgebraObject ()
 Destructor. More...
 
LinearAlgebraDistributiondistribution_pt () const
 access to the LinearAlgebraDistribution More...
 
unsigned nrow () const
 access function to the number of global rows. More...
 
unsigned nrow_local () const
 access function for the num of local rows on this processor. More...
 
unsigned nrow_local (const unsigned &p) const
 access function for the num of local rows on this processor. More...
 
unsigned first_row () const
 access function for the first row on this processor More...
 
unsigned first_row (const unsigned &p) const
 access function for the first row on this processor More...
 
bool distributed () const
 distribution is serial or distributed More...
 
bool distribution_built () const
 if the communicator_pt is null then the distribution is not setup then false is returned, otherwise return true More...
 
void build_distribution (const LinearAlgebraDistribution *const dist_pt)
 setup the distribution of this distributable linear algebra object More...
 
void build_distribution (const LinearAlgebraDistribution &dist)
 setup the distribution of this distributable linear algebra object More...
 

Private Member Functions

void trilinos_multiply_helper (const DoubleVector &x, DoubleVector &y) const
 Helper function for multiply(...) More...
 
void trilinos_multiply_transpose_helper (const DoubleVector &x, DoubleVector &y) const
 Helper function for multiply_transpose(...) More...
 

Private Attributes

Epetra_CrsMatrix * Epetra_matrix_pt
 The Epetra version of the matrix. More...
 
bool Using_trilinos
 boolean indicating whether we are using trilinos to perform matvec More...
 
CRDoubleMatrixOomph_matrix_pt
 an oomph-lib matrix More...
 
LinearAlgebraDistributionColumn_distribution_pt
 The distribution of: x if using multiply(...) or y if using multiply_transpose(...) where this is A x = y. More...
 
unsigned Ncol
 number of columns of the matrix More...
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 clear the distribution of this distributable linear algebra object More...
 

Detailed Description

Matrix vector product helper class - primarily a wrapper to Trilinos's Epetra matrix vector product methods. This allows the epetra matrix to be assembled once and the matrix vector product to be performed many times.

Definition at line 50 of file matrix_vector_product.h.

Constructor & Destructor Documentation

◆ MatrixVectorProduct() [1/2]

oomph::MatrixVectorProduct::MatrixVectorProduct ( )
inline

Constructor.

Definition at line 54 of file matrix_vector_product.h.

References Column_distribution_pt, Epetra_matrix_pt, and Oomph_matrix_pt.

◆ MatrixVectorProduct() [2/2]

oomph::MatrixVectorProduct::MatrixVectorProduct ( const MatrixVectorProduct )
delete

Broken copy constructor.

◆ ~MatrixVectorProduct()

oomph::MatrixVectorProduct::~MatrixVectorProduct ( )
inline

Destructor.

Definition at line 71 of file matrix_vector_product.h.

References clean_up_memory().

Member Function Documentation

◆ clean_up_memory()

void oomph::MatrixVectorProduct::clean_up_memory ( )
inline

◆ multiply()

void oomph::MatrixVectorProduct::multiply ( const DoubleVector x,
DoubleVector y 
) const

◆ multiply_transpose()

void oomph::MatrixVectorProduct::multiply_transpose ( const DoubleVector x,
DoubleVector y 
) const

◆ ncol()

const unsigned& oomph::MatrixVectorProduct::ncol ( ) const
inline

Access function to the number of columns.

Definition at line 110 of file matrix_vector_product.h.

References Ncol.

◆ operator=()

void oomph::MatrixVectorProduct::operator= ( const MatrixVectorProduct )
delete

Broken assignment operator.

◆ setup()

void oomph::MatrixVectorProduct::setup ( CRDoubleMatrix matrix_pt,
const LinearAlgebraDistribution col_dist_pt = 0 
)

Setup the matrix vector product operator. WARNING: This class is wrapper to Trilinos Epetra matrix vector multiply methods, if Trilinos is not installed then this class will function as expected, but there will be no computational speed gain. By default the Epetra_CrsMatrix::multiply(...) are employed. The optional argument col_dist_pt is the distribution of: x if using multiply(...) or y if using multiply_transpose(...) where this is A x = y. By default, this is assumed to the uniformly distributed based on matrix_pt->ncol().

Definition at line 41 of file matrix_vector_product.cc.

References oomph::DistributableLinearAlgebraObject::build_distribution(), clean_up_memory(), Column_distribution_pt, oomph::LinearAlgebraDistribution::communicator_pt(), oomph::TrilinosEpetraHelpers::create_distributed_epetra_matrix(), oomph::LinearAlgebraDistribution::distributed(), oomph::DistributableLinearAlgebraObject::distribution_pt(), Epetra_matrix_pt, oomph::MPI_Helpers::mpi_has_been_initialised(), oomph::CRDoubleMatrix::ncol(), Ncol, oomph::oomph_info, Oomph_matrix_pt, oomph::TimingHelpers::timer(), and Using_trilinos.

Referenced by oomph::BlockPreconditioner< MATRIX >::setup_matrix_vector_product().

◆ trilinos_multiply_helper()

void oomph::MatrixVectorProduct::trilinos_multiply_helper ( const DoubleVector x,
DoubleVector y 
) const
private

Helper function for multiply(...)

Apply the operator to the vector x and return the result in the vector y (helper function)

Definition at line 242 of file matrix_vector_product.cc.

References oomph::TrilinosEpetraHelpers::copy_to_oomphlib_vector(), oomph::TrilinosEpetraHelpers::create_distributed_epetra_vector(), and Epetra_matrix_pt.

Referenced by multiply().

◆ trilinos_multiply_transpose_helper()

void oomph::MatrixVectorProduct::trilinos_multiply_transpose_helper ( const DoubleVector x,
DoubleVector y 
) const
private

Helper function for multiply_transpose(...)

Apply the transpose of the operator to the vector x and return the result in the vector y (helper function)

Definition at line 287 of file matrix_vector_product.cc.

References oomph::TrilinosEpetraHelpers::copy_to_oomphlib_vector(), oomph::TrilinosEpetraHelpers::create_distributed_epetra_vector(), and Epetra_matrix_pt.

Referenced by multiply_transpose().

Member Data Documentation

◆ Column_distribution_pt

LinearAlgebraDistribution* oomph::MatrixVectorProduct::Column_distribution_pt
private

The distribution of: x if using multiply(...) or y if using multiply_transpose(...) where this is A x = y.

Definition at line 137 of file matrix_vector_product.h.

Referenced by clean_up_memory(), MatrixVectorProduct(), multiply(), multiply_transpose(), and setup().

◆ Epetra_matrix_pt

Epetra_CrsMatrix* oomph::MatrixVectorProduct::Epetra_matrix_pt
private

The Epetra version of the matrix.

Definition at line 125 of file matrix_vector_product.h.

Referenced by clean_up_memory(), MatrixVectorProduct(), setup(), trilinos_multiply_helper(), and trilinos_multiply_transpose_helper().

◆ Ncol

unsigned oomph::MatrixVectorProduct::Ncol
private

number of columns of the matrix

Definition at line 140 of file matrix_vector_product.h.

Referenced by ncol(), and setup().

◆ Oomph_matrix_pt

CRDoubleMatrix* oomph::MatrixVectorProduct::Oomph_matrix_pt
private

an oomph-lib matrix

Definition at line 133 of file matrix_vector_product.h.

Referenced by clean_up_memory(), MatrixVectorProduct(), multiply(), multiply_transpose(), and setup().

◆ Using_trilinos

bool oomph::MatrixVectorProduct::Using_trilinos
private

boolean indicating whether we are using trilinos to perform matvec

Definition at line 130 of file matrix_vector_product.h.

Referenced by multiply(), multiply_transpose(), and setup().


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