31 using namespace Teuchos;
33 int main(
int argc,
char *argv[]) {
35 typedef std::complex<double> ST;
37 typedef SCT::magnitudeType MT;
43 ST zero = SCT::zero();
54 bool norm_failure =
false;
55 bool proc_verbose =
false;
65 cmdp.
setOption(
"verbose",
"quiet",&verbose,
"Print messages and results.");
66 cmdp.
setOption(
"pseudo",
"regular",&pseudo,
"Use pseudo-block TFQMR to solve the linear systems.");
67 cmdp.
setOption(
"frequency",&frequency,
"Solvers frequency for printing residuals (#iters).");
68 cmdp.
setOption(
"tol",&tol,
"Relative residual tolerance used by TFQMR solver.");
69 cmdp.
setOption(
"num-rhs",&numrhs,
"Number of right-hand sides to be solved for.");
70 cmdp.
setOption(
"num-restarts",&maxrestarts,
"Maximum number of restarts allowed for the TFQMR solver.");
71 cmdp.
setOption(
"blocksize",&blocksize,
"Block size used by TFQMR.");
72 cmdp.
setOption(
"subspace-length",&length,
"Maximum dimension of block-subspace used by TFQMR solver.");
77 proc_verbose = verbose && (MyPID==0);
84 #ifndef HAVE_BELOS_TRIUTILS
85 std::cout <<
"This test requires Triutils. Please configure with --enable-triutils." << std::endl;
87 std::cout <<
"End Result: TEST FAILED" << std::endl;
96 std::vector<ST> diag( dim, (ST)4.0 );
103 int maxits = dim/blocksize;
106 belosList.
set(
"Num Blocks", length );
107 belosList.
set(
"Block Size", blocksize );
108 belosList.
set(
"Maximum Iterations", maxits );
109 belosList.
set(
"Maximum Restarts", maxrestarts );
110 belosList.
set(
"Convergence Tolerance", tol );
115 belosList.
set(
"Output Frequency", frequency );
126 MVT::MvInit( *rhs, 1.0 );
127 MVT::MvInit( *soln, zero );
133 bool set = problem->setProblem();
136 std::cout << std::endl <<
"ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
155 std::cout << std::endl << std::endl;
156 std::cout <<
"Dimension of matrix: " << dim << std::endl;
157 std::cout <<
"Number of right-hand sides: " << numrhs << std::endl;
158 std::cout <<
"Block size used by solver: " << blocksize << std::endl;
159 std::cout <<
"Max number of TFQMR iterations: " << maxits << std::endl;
160 std::cout <<
"Relative residual tolerance: " << tol << std::endl;
161 std::cout << std::endl;
171 OPT::Apply( *A, *soln, *temp );
172 MVT::MvAddMv( one, *rhs, -one, *temp, *temp );
173 std::vector<MT> norm_num(numrhs), norm_denom(numrhs);
174 MVT::MvNorm( *temp, norm_num );
175 MVT::MvNorm( *rhs, norm_denom );
176 for (
int i=0; i<numrhs; ++i) {
178 std::cout <<
"Relative residual "<<i<<
" : " << norm_num[i] / norm_denom[i] << std::endl;
179 if ( norm_num[i] / norm_denom[i] > tol ) {
187 std::cout <<
"End Result: TEST PASSED" << std::endl;
190 std::cout <<
"End Result: TEST FAILED" << std::endl;
195 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
std::string Belos_Version()
int main(int argc, char *argv[])
The Belos::PseudoBlockTFQMRSolMgr provides a solver manager for the pseudo-block TFQMR linear solver...
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Traits class which defines basic operations on multivectors.
Simple example of a user's defined Belos::MultiVec class.
Alternative run-time polymorphic interface for operators.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
A linear system to solve, and its associated information.
Class which describes the linear problem to be solved by the iterative solver.
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
The Belos::PseudoBlockTFQMRSolMgr provides a powerful and fully-featured solver manager over the pseu...
ReturnType
Whether the Belos solve converged for all linear systems.
The Belos::TFQMRSolMgr provides a powerful and fully-featured solver manager over the TFQMR linear so...
Simple example of a user's defined Belos::Operator class.
Interface for multivectors used by Belos' linear solvers.
Class which defines basic traits for the operator type.
Belos header file which uses auto-configuration information to include necessary C++ headers...
The Belos::TFQMRSolMgr provides a solver manager for the TFQMR linear solver.