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>
Public Member Functions | |
MatrixVectorProduct () | |
Constructor. More... | |
MatrixVectorProduct (const MatrixVectorProduct &) | |
Broken copy constructor. More... | |
void | operator= (const MatrixVectorProduct &) |
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... | |
![]() | |
DistributableLinearAlgebraObject () | |
Default constructor - create a distribution. More... | |
DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix) | |
Broken copy constructor. More... | |
void | operator= (const DistributableLinearAlgebraObject &) |
Broken assignment operator. More... | |
virtual | ~DistributableLinearAlgebraObject () |
Destructor. More... | |
LinearAlgebraDistribution * | distribution_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 |
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... | |
CRDoubleMatrix * | Oomph_matrix_pt |
an oomph-lib matrix More... | |
LinearAlgebraDistribution * | Column_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 | |
![]() | |
void | clear_distribution () |
clear the distribution of this distributable linear algebra object More... | |
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 55 of file matrix_vector_product.h.
|
inline |
Constructor.
Definition at line 61 of file matrix_vector_product.h.
References Column_distribution_pt, Epetra_matrix_pt, and Oomph_matrix_pt.
|
inline |
Broken copy constructor.
Definition at line 72 of file matrix_vector_product.h.
References oomph::BrokenCopy::broken_copy().
|
inline |
|
inline |
clear the memory
Definition at line 90 of file matrix_vector_product.h.
References Column_distribution_pt, Epetra_matrix_pt, multiply(), multiply_transpose(), Oomph_matrix_pt, and setup().
Referenced by oomph::PseudoElasticFSIPreconditioner::clean_up_memory(), setup(), and ~MatrixVectorProduct().
void oomph::MatrixVectorProduct::multiply | ( | const DoubleVector & | x, |
DoubleVector & | y | ||
) | const |
Apply the operator to the vector x and return the result in the vector y.
Definition at line 113 of file matrix_vector_product.cc.
References oomph::DoubleVector::build(), oomph::DoubleVector::built(), Column_distribution_pt, oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::CRDoubleMatrix::multiply(), Oomph_matrix_pt, trilinos_multiply_helper(), and Using_trilinos.
Referenced by clean_up_memory(), oomph::PseudoElasticFSIPreconditioner::preconditioner_solve(), oomph::FSIPreconditioner::preconditioner_solve(), and oomph::PressureBasedSolidLSCPreconditioner::preconditioner_solve().
void oomph::MatrixVectorProduct::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.
Definition at line 182 of file matrix_vector_product.cc.
References oomph::DoubleVector::build(), oomph::DoubleVector::built(), Column_distribution_pt, oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::CRDoubleMatrix::multiply_transpose(), Oomph_matrix_pt, trilinos_multiply_transpose_helper(), and Using_trilinos.
Referenced by clean_up_memory(), and oomph::PressureBasedSolidLSCPreconditioner::preconditioner_solve().
|
inline |
Access function to the number of columns.
Definition at line 123 of file matrix_vector_product.h.
References Ncol, trilinos_multiply_helper(), and trilinos_multiply_transpose_helper().
|
inline |
Broken assignment operator.
Definition at line 78 of file matrix_vector_product.h.
References oomph::BrokenCopy::broken_assign().
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 47 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(), Ncol, oomph::CRDoubleMatrix::ncol(), oomph::oomph_info, Oomph_matrix_pt, oomph::TimingHelpers::timer(), and Using_trilinos.
Referenced by clean_up_memory(), and oomph::BlockPreconditioner< CRDoubleMatrix >::setup_matrix_vector_product().
|
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 248 of file matrix_vector_product.cc.
References oomph::TrilinosEpetraHelpers::copy_to_oomphlib_vector(), oomph::TrilinosEpetraHelpers::create_distributed_epetra_vector(), Epetra_matrix_pt, and trilinos_multiply_transpose_helper().
Referenced by multiply(), and ncol().
|
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 296 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(), ncol(), and trilinos_multiply_helper().
|
private |
The distribution of: x if using multiply(...) or y if using multiply_transpose(...) where this is A x = y.
Definition at line 152 of file matrix_vector_product.h.
Referenced by clean_up_memory(), MatrixVectorProduct(), multiply(), multiply_transpose(), and setup().
|
private |
The Epetra version of the matrix.
Definition at line 140 of file matrix_vector_product.h.
Referenced by clean_up_memory(), MatrixVectorProduct(), setup(), trilinos_multiply_helper(), and trilinos_multiply_transpose_helper().
|
private |
number of columns of the matrix
Definition at line 155 of file matrix_vector_product.h.
|
private |
an oomph-lib matrix
Definition at line 148 of file matrix_vector_product.h.
Referenced by clean_up_memory(), MatrixVectorProduct(), multiply(), multiply_transpose(), and setup().
|
private |
boolean indicating whether we are using trilinos to perform matvec
Definition at line 145 of file matrix_vector_product.h.
Referenced by multiply(), multiply_transpose(), and setup().