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 &)=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... | |
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 |
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... | |
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 | |
Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject | |
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 50 of file matrix_vector_product.h.
|
inline |
Constructor.
Definition at line 54 of file matrix_vector_product.h.
References Column_distribution_pt, Epetra_matrix_pt, and Oomph_matrix_pt.
|
delete |
Broken copy constructor.
|
inline |
|
inline |
clear the memory
Definition at line 77 of file matrix_vector_product.h.
References Column_distribution_pt, Epetra_matrix_pt, and Oomph_matrix_pt.
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 108 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 oomph::FSIPreconditioner::preconditioner_solve(), oomph::PseudoElasticFSIPreconditioner::preconditioner_solve(), oomph::NavierStokesSchurComplementPreconditioner::preconditioner_solve(), oomph::PressureBasedSolidLSCPreconditioner::preconditioner_solve(), and oomph::SpaceTimeNavierStokesSubsidiaryPreconditioner::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 177 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 oomph::NavierStokesSchurComplementPreconditioner::preconditioner_solve(), oomph::PressureBasedSolidLSCPreconditioner::preconditioner_solve(), and oomph::SpaceTimeNavierStokesSubsidiaryPreconditioner::preconditioner_solve().
|
inline |
Access function to the number of columns.
Definition at line 110 of file matrix_vector_product.h.
References Ncol.
|
delete |
Broken assignment operator.
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().
|
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().
|
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().
|
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().
|
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().
|
private |
number of columns of the matrix
Definition at line 140 of file matrix_vector_product.h.
|
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().
|
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().