60 #ifdef HAVE_BELOS_TRIUTILS
61 #include "Trilinos_Util_iohb.h"
68 using namespace Teuchos;
70 int main(
int argc,
char *argv[]) {
73 typedef std::complex<double> ST;
75 typedef std::complex<double> ST;
77 std::cout <<
"Not compiled with std::complex support." << std::endl;
78 std::cout <<
"End Result: TEST FAILED" << std::endl;
83 typedef SCT::magnitudeType MT;
89 ST zero = SCT::zero();
92 bool norm_failure =
false;
101 bool success =
false;
102 bool verbose =
false;
104 bool proc_verbose =
false;
108 std::string
filename(
"mhd1280b.cua");
112 cmdp.
setOption(
"verbose",
"quiet",&verbose,
"Print messages and results.");
113 cmdp.
setOption(
"frequency",&frequency,
"Solvers frequency for printing residuals (#iters).");
115 cmdp.
setOption(
"tol",&tol,
"Relative residual tolerance used by pseudo-block TFQMR solver.");
116 cmdp.
setOption(
"num-rhs",&numrhs,
"Number of right-hand sides to be solved for.");
121 proc_verbose = verbose && (MyPID==0);
129 #ifndef HAVE_BELOS_TRIUTILS
130 std::cout <<
"This test requires Triutils. Please configure with --enable-triutils." << std::endl;
132 std::cout <<
"End Result: TEST FAILED" << std::endl;
143 info = readHB_newmat_double(
filename.c_str(),&dim,&dim2,&nnz,
144 &colptr,&rowind,&dvals);
145 if (info == 0 || nnz < 0) {
147 std::cout <<
"Error reading '" <<
filename <<
"'" << std::endl;
148 std::cout <<
"End Result: TEST FAILED" << std::endl;
154 for (
int ii=0; ii<nnz; ii++) {
155 cvals[ii] = ST(dvals[ii*2],dvals[ii*2+1]);
164 int maxits = dim/blocksize;
167 belosList.
set(
"Maximum Iterations", maxits );
168 belosList.
set(
"Convergence Tolerance", tol );
173 belosList.
set(
"Output Frequency", frequency );
184 MVT::MvRandom( *soln );
185 OPT::Apply( *
A, *soln, *rhs );
186 MVT::MvInit( *soln, zero );
192 bool set = problem->setProblem();
195 std::cout << std::endl <<
"ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
209 std::cout << std::endl << std::endl;
210 std::cout <<
"Dimension of matrix: " << dim << std::endl;
211 std::cout <<
"Number of right-hand sides: " << numrhs << std::endl;
212 std::cout <<
"Block size used by solver: " << blocksize << std::endl;
213 std::cout <<
"Max number of pseudo-block TFQMR iterations: " << maxits << std::endl;
214 std::cout <<
"Relative residual tolerance: " << tol << std::endl;
215 std::cout << std::endl;
225 OPT::Apply( *
A, *soln, *temp );
226 MVT::MvAddMv( one, *rhs, -one, *temp, *temp );
227 std::vector<MT> norm_num(numrhs), norm_denom(numrhs);
228 MVT::MvNorm( *temp, norm_num );
229 MVT::MvNorm( *rhs, norm_denom );
230 for (
int i=0; i<numrhs; ++i) {
232 std::cout <<
"Relative residual "<<i<<
" : " << norm_num[i] / norm_denom[i] << std::endl;
233 if ( norm_num[i] / norm_denom[i] > tol ) {
247 std::cout <<
"End Result: TEST PASSED" << std::endl;
250 std::cout <<
"End Result: TEST FAILED" << std::endl;
255 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );