28 #ifdef HAVE_BELOS_TRIUTILS
29 #include "Trilinos_Util_iohb.h"
36 using namespace Teuchos;
38 int main(
int argc,
char *argv[]) {
40 typedef std::complex<double> ST;
42 typedef SCT::magnitudeType MT;
48 ST zero = SCT::zero();
51 bool norm_failure =
false;
63 bool proc_verbose =
false;
67 std::string
filename(
"mhd1280b.cua");
71 cmdp.
setOption(
"verbose",
"quiet",&verbose,
"Print messages and results.");
72 cmdp.
setOption(
"frequency",&frequency,
"Solvers frequency for printing residuals (#iters).");
73 cmdp.
setOption(
"filename",&filename,
"Filename for Harwell-Boeing test matrix.");
74 cmdp.
setOption(
"tol",&tol,
"Relative residual tolerance used by pseudo-block TFQMR solver.");
75 cmdp.
setOption(
"num-rhs",&numrhs,
"Number of right-hand sides to be solved for.");
80 proc_verbose = verbose && (MyPID==0);
88 #ifndef HAVE_BELOS_TRIUTILS
89 std::cout <<
"This test requires Triutils. Please configure with --enable-triutils." << std::endl;
91 std::cout <<
"End Result: TEST FAILED" << std::endl;
102 info = readHB_newmat_double(filename.c_str(),&dim,&dim2,&nnz,
103 &colptr,&rowind,&dvals);
104 if (info == 0 || nnz < 0) {
106 std::cout <<
"Error reading '" << filename <<
"'" << std::endl;
107 std::cout <<
"End Result: TEST FAILED" << std::endl;
113 for (
int ii=0; ii<nnz; ii++) {
114 cvals[ii] = ST(dvals[ii*2],dvals[ii*2+1]);
123 int maxits = dim/blocksize;
126 belosList.
set(
"Maximum Iterations", maxits );
127 belosList.
set(
"Convergence Tolerance", tol );
132 belosList.
set(
"Output Frequency", frequency );
143 MVT::MvRandom( *soln );
144 OPT::Apply( *A, *soln, *rhs );
145 MVT::MvInit( *soln, zero );
151 bool set = problem->setProblem();
154 std::cout << std::endl <<
"ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
168 std::cout << std::endl << std::endl;
169 std::cout <<
"Dimension of matrix: " << dim << std::endl;
170 std::cout <<
"Number of right-hand sides: " << numrhs << std::endl;
171 std::cout <<
"Block size used by solver: " << blocksize << std::endl;
172 std::cout <<
"Max number of pseudo-block TFQMR iterations: " << maxits << std::endl;
173 std::cout <<
"Relative residual tolerance: " << tol << std::endl;
174 std::cout << std::endl;
184 OPT::Apply( *A, *soln, *temp );
185 MVT::MvAddMv( one, *rhs, -one, *temp, *temp );
186 std::vector<MT> norm_num(numrhs), norm_denom(numrhs);
187 MVT::MvNorm( *temp, norm_num );
188 MVT::MvNorm( *rhs, norm_denom );
189 for (
int i=0; i<numrhs; ++i) {
191 std::cout <<
"Relative residual "<<i<<
" : " << norm_num[i] / norm_denom[i] << std::endl;
192 if ( norm_num[i] / norm_denom[i] > tol ) {
206 std::cout <<
"End Result: TEST PASSED" << std::endl;
209 std::cout <<
"End Result: TEST FAILED" << std::endl;
214 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)
ReturnType solve() override
This method performs possibly repeated calls to the underlying linear solver's iterate() routine unti...
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.
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...
Simple example of a user's defined Belos::Operator class.