27 #ifdef HAVE_BELOS_TRIUTILS
28 #include "Trilinos_Util_iohb.h"
35 using namespace Teuchos;
37 int main(
int argc,
char *argv[]) {
39 typedef std::complex<double> ST;
41 typedef SCT::magnitudeType MT;
47 ST zero = SCT::zero();
51 bool norm_failure =
false;
61 bool proc_verbose =
false;
65 std::string
filename(
"mhd1280b.cua");
69 cmdp.
setOption(
"verbose",
"quiet",&verbose,
"Print messages and results.");
70 cmdp.
setOption(
"frequency",&frequency,
"Solvers frequency for printing residuals (#iters).");
71 cmdp.
setOption(
"filename",&filename,
"Filename for Harwell-Boeing test matrix.");
72 cmdp.
setOption(
"tol",&tol,
"Relative residual tolerance used by MINRES solver.");
73 cmdp.
setOption(
"num-rhs",&numrhs,
"Number of right-hand sides to be solved for.");
78 proc_verbose = verbose && (MyPID==0);
86 #ifndef HAVE_BELOS_TRIUTILS
87 std::cout <<
"This test requires Triutils. Please configure with --enable-triutils." << std::endl;
89 std::cout <<
"End Result: TEST FAILED" << std::endl;
100 info = readHB_newmat_double(filename.c_str(),&dim,&dim2,&nnz,
101 &colptr,&rowind,&dvals);
102 if (info == 0 || nnz < 0) {
104 std::cout <<
"Error reading '" << filename <<
"'" << std::endl;
105 std::cout <<
"End Result: TEST FAILED" << std::endl;
111 for (
int ii=0; ii<nnz; ii++) {
112 cvals[ii] = ST(dvals[ii*2],dvals[ii*2+1]);
121 int maxits = dim/blocksize;
124 belosList.
set(
"Maximum Iterations", maxits );
125 belosList.
set(
"Convergence Tolerance", tol );
130 belosList.
set(
"Output Frequency", frequency );
141 MVT::MvRandom( *soln );
142 OPT::Apply( *A, *soln, *rhs );
143 MVT::MvInit( *soln, zero );
149 bool set = problem->setProblem();
152 std::cout << std::endl <<
"ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
166 std::cout << std::endl << std::endl;
167 std::cout <<
"Dimension of matrix: " << dim << std::endl;
168 std::cout <<
"Number of right-hand sides: " << numrhs << std::endl;
169 std::cout <<
"Block size used by solver: " << blocksize << std::endl;
170 std::cout <<
"Max number of MINRES iterations: " << maxits << std::endl;
171 std::cout <<
"Relative residual tolerance: " << tol << std::endl;
172 std::cout << std::endl;
182 OPT::Apply( *A, *soln, *temp );
183 MVT::MvAddMv( one, *rhs, -one, *temp, *temp );
184 std::vector<MT> norm_num(numrhs), norm_denom(numrhs);
185 MVT::MvNorm( *temp, norm_num );
186 MVT::MvNorm( *rhs, norm_denom );
187 for (
int i=0; i<numrhs; ++i) {
189 std::cout <<
"Relative residual "<<i<<
" : " << norm_num[i] / norm_denom[i] << std::endl;
190 if ( norm_num[i] / norm_denom[i] > tol ) {
205 std::cout <<
"End Result: TEST PASSED" << std::endl;
208 std::cout <<
"End Result: TEST FAILED" << std::endl;
213 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 &&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.