TrilinosCouplings  Development
Functions
TrilinosCouplings_IntrepidPoissonExample_SolveWithBelos.hpp File Reference

Generic Belos solver for the Intrepid Poisson test problem example. More...

#include "BelosConfigDefs.hpp"
#include "BelosLinearProblem.hpp"
#include "BelosSolverFactory.hpp"
Include dependency graph for TrilinosCouplings_IntrepidPoissonExample_SolveWithBelos.hpp:

Functions

template<class ST , class MV , class OP >
void TrilinosCouplings::IntrepidPoissonExample::solveWithBelos (bool &converged, int &numItersPerformed, const std::string &solverName, const typename Teuchos::ScalarTraits< ST >::magnitudeType &tol, const int maxNumIters, const int num_steps, const Teuchos::RCP< MV > &X, const Teuchos::RCP< const OP > &A, const Teuchos::RCP< const MV > &B, const Teuchos::RCP< const OP > &M_left, const Teuchos::RCP< const OP > &M_right)
 Solve the linear system(s) AX=B with Belos. More...
 

Detailed Description

Generic Belos solver for the Intrepid Poisson test problem example.

Function Documentation

template<class ST , class MV , class OP >
void TrilinosCouplings::IntrepidPoissonExample::solveWithBelos ( bool &  converged,
int &  numItersPerformed,
const std::string &  solverName,
const typename Teuchos::ScalarTraits< ST >::magnitudeType &  tol,
const int  maxNumIters,
const int  num_steps,
const Teuchos::RCP< MV > &  X,
const Teuchos::RCP< const OP > &  A,
const Teuchos::RCP< const MV > &  B,
const Teuchos::RCP< const OP > &  M_left,
const Teuchos::RCP< const OP > &  M_right 
)

Solve the linear system(s) AX=B with Belos.

This is a generic solve function: you can use any scalar, multivector, and operator types that Belos supports. We in turn use this as the implementation of solveWithBelos() functions for a specific Scalar, multivector, and operator type combination. This hopefully increases parallelism in the build.

Template Parameters
STThe type of entries in the matrix and vectors. For Epetra objects, this is always double. For Tpetra objects, this corresponds to the Scalar template parameter of Tpetra::MultiVector and Tpetra::Operator.
MVThe type of multivectors: for example, Epetra_MultiVector or a Tpetra::MultiVector specialization.
OPThe type of operators (from multivectors to multivectors): for example, Epetra_Operator or a Tpetra::Operator specialization.

The X and B arguments are both multivectors, meaning that you may ask Belos to solve more than one linear system at a time. X and B must have the same number of columns.

This interface will change in the future to accept the name of the Belos solver to use. For now, the solver is hard-coded to Pseudoblock CG (implemented by Belos::PseudoBlockCGSolMgr).

Parameters
converged[out] Whether Belos reported that the iterative method converged (solved the linear system to the desired tolerance).
numItersPerformed[out] Number of iterations that the Belos solver performed.
solverName[in] Name of Belos solver to use. You may use any name that Belos::SolverFactory understands.
tol[in] Convergence tolerance for the iterative method. The meaning of this depends on the particular iterative method.
maxNumIters[in] Maximum number of iterations that the iterative method should perform, regardless of whether it converged.
num_steps[in] Number of "time steps", i.e., the number of
X[in/out] On input: the initial guess(es) for the iterative method. On output: the computed approximate solution.
A[in] The matrix in the linear system(s) AX=B to solve.
B[in] The right-hand side(s) in the linear system AX=B to solve.
M_left[in] If nonnull, a left preconditioner that the iterative method may use. If null, the iterative method will not use a left preconditioner.
M_right[in] If nonnull, a right preconditioner that the iterative method may use. If null, the iterative method will not use a right preconditioner.