59 #ifdef HAVE_BELOS_TRIUTILS
60 #include "Trilinos_Util_iohb.h"
67 using namespace Teuchos;
69 int main(
int argc,
char *argv[]) {
71 typedef std::complex<double> ST;
73 typedef SCT::magnitudeType MT;
79 ST zero = SCT::zero();
83 bool norm_failure =
false;
93 bool proc_verbose =
false;
97 std::string
filename(
"mhd1280b.cua");
101 cmdp.
setOption(
"verbose",
"quiet",&verbose,
"Print messages and results.");
102 cmdp.
setOption(
"frequency",&frequency,
"Solvers frequency for printing residuals (#iters).");
103 cmdp.
setOption(
"filename",&filename,
"Filename for Harwell-Boeing test matrix.");
104 cmdp.
setOption(
"tol",&tol,
"Relative residual tolerance used by MINRES solver.");
105 cmdp.
setOption(
"num-rhs",&numrhs,
"Number of right-hand sides to be solved for.");
110 proc_verbose = verbose && (MyPID==0);
118 #ifndef HAVE_BELOS_TRIUTILS
119 std::cout <<
"This test requires Triutils. Please configure with --enable-triutils." << std::endl;
121 std::cout <<
"End Result: TEST FAILED" << std::endl;
132 info = readHB_newmat_double(filename.c_str(),&dim,&dim2,&nnz,
133 &colptr,&rowind,&dvals);
134 if (info == 0 || nnz < 0) {
136 std::cout <<
"Error reading '" << filename <<
"'" << std::endl;
137 std::cout <<
"End Result: TEST FAILED" << std::endl;
143 for (
int ii=0; ii<nnz; ii++) {
144 cvals[ii] = ST(dvals[ii*2],dvals[ii*2+1]);
153 int maxits = dim/blocksize;
156 belosList.
set(
"Maximum Iterations", maxits );
157 belosList.
set(
"Convergence Tolerance", tol );
162 belosList.
set(
"Output Frequency", frequency );
173 MVT::MvRandom( *soln );
174 OPT::Apply( *A, *soln, *rhs );
175 MVT::MvInit( *soln, zero );
181 bool set = problem->setProblem();
184 std::cout << std::endl <<
"ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
198 std::cout << std::endl << std::endl;
199 std::cout <<
"Dimension of matrix: " << dim << std::endl;
200 std::cout <<
"Number of right-hand sides: " << numrhs << std::endl;
201 std::cout <<
"Block size used by solver: " << blocksize << std::endl;
202 std::cout <<
"Max number of MINRES iterations: " << maxits << std::endl;
203 std::cout <<
"Relative residual tolerance: " << tol << std::endl;
204 std::cout << std::endl;
214 OPT::Apply( *A, *soln, *temp );
215 MVT::MvAddMv( one, *rhs, -one, *temp, *temp );
216 std::vector<MT> norm_num(numrhs), norm_denom(numrhs);
217 MVT::MvNorm( *temp, norm_num );
218 MVT::MvNorm( *rhs, norm_denom );
219 for (
int i=0; i<numrhs; ++i) {
221 std::cout <<
"Relative residual "<<i<<
" : " << norm_num[i] / norm_denom[i] << std::endl;
222 if ( norm_num[i] / norm_denom[i] > tol ) {
237 std::cout <<
"End Result: TEST PASSED" << std::endl;
240 std::cout <<
"End Result: TEST FAILED" << std::endl;
245 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
Solver manager for the MINRES linear solver.
std::string Belos_Version()
int main(int argc, char *argv[])
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)
MINRES linear solver solution manager.
#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
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...
ReturnType solve() override
Iterate until the status test tells us to stop.
Simple example of a user's defined Belos::Operator class.