63 using namespace Teuchos;
65 int main(
int argc,
char *argv[]) {
68 typedef std::complex<double> ST;
70 typedef std::complex<double> ST;
72 std::cout <<
"Not compiled with std::complex support." << std::endl;
73 std::cout <<
"End Result: TEST FAILED" << std::endl;
78 typedef SCT::magnitudeType MT;
84 ST zero = SCT::zero();
95 bool norm_failure =
false;
96 bool proc_verbose =
false;
101 int maxrestarts = 15;
106 cmdp.
setOption(
"verbose",
"quiet",&verbose,
"Print messages and results.");
107 cmdp.
setOption(
"pseudo",
"regular",&pseudo,
"Use pseudo-block TFQMR to solve the linear systems.");
108 cmdp.
setOption(
"frequency",&frequency,
"Solvers frequency for printing residuals (#iters).");
109 cmdp.
setOption(
"tol",&tol,
"Relative residual tolerance used by TFQMR solver.");
110 cmdp.
setOption(
"num-rhs",&numrhs,
"Number of right-hand sides to be solved for.");
111 cmdp.
setOption(
"num-restarts",&maxrestarts,
"Maximum number of restarts allowed for the TFQMR solver.");
112 cmdp.
setOption(
"blocksize",&blocksize,
"Block size used by TFQMR.");
113 cmdp.
setOption(
"subspace-length",&length,
"Maximum dimension of block-subspace used by TFQMR solver.");
118 proc_verbose = verbose && (MyPID==0);
125 #ifndef HAVE_BELOS_TRIUTILS
126 std::cout <<
"This test requires Triutils. Please configure with --enable-triutils." << std::endl;
128 std::cout <<
"End Result: TEST FAILED" << std::endl;
137 std::vector<ST> diag( dim, (ST)4.0 );
144 int maxits = dim/blocksize;
147 belosList.
set(
"Num Blocks", length );
148 belosList.
set(
"Block Size", blocksize );
149 belosList.
set(
"Maximum Iterations", maxits );
150 belosList.
set(
"Maximum Restarts", maxrestarts );
151 belosList.
set(
"Convergence Tolerance", tol );
156 belosList.
set(
"Output Frequency", frequency );
167 MVT::MvInit( *rhs, 1.0 );
168 MVT::MvInit( *soln, zero );
174 bool set = problem->setProblem();
177 std::cout << std::endl <<
"ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
196 std::cout << std::endl << std::endl;
197 std::cout <<
"Dimension of matrix: " << dim << std::endl;
198 std::cout <<
"Number of right-hand sides: " << numrhs << std::endl;
199 std::cout <<
"Block size used by solver: " << blocksize << std::endl;
200 std::cout <<
"Max number of TFQMR iterations: " << maxits << std::endl;
201 std::cout <<
"Relative residual tolerance: " << tol << std::endl;
202 std::cout << std::endl;
212 OPT::Apply( *A, *soln, *temp );
213 MVT::MvAddMv( one, *rhs, -one, *temp, *temp );
214 std::vector<MT> norm_num(numrhs), norm_denom(numrhs);
215 MVT::MvNorm( *temp, norm_num );
216 MVT::MvNorm( *rhs, norm_denom );
217 for (
int i=0; i<numrhs; ++i) {
219 std::cout <<
"Relative residual "<<i<<
" : " << norm_num[i] / norm_denom[i] << std::endl;
220 if ( norm_num[i] / norm_denom[i] > tol ) {
228 std::cout <<
"End Result: TEST PASSED" << std::endl;
231 std::cout <<
"End Result: TEST FAILED" << std::endl;
236 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 const &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.