62 #ifdef HAVE_BELOS_TRIUTILS 63 #include "Trilinos_Util_iohb.h" 72 int main(
int argc,
char *argv[]) {
75 typedef std::complex<double> ST;
77 typedef std::complex<double> ST;
79 std::cout <<
"Not compiled with std::complex support." << std::endl;
80 std::cout <<
"End Result: TEST FAILED" << std::endl;
85 typedef SCT::magnitudeType MT;
91 ST zero = SCT::zero();
100 bool verbose =
false;
103 bool norm_failure =
false;
104 bool proc_verbose =
false;
109 int maxrestarts = 15;
111 std::string
filename(
"mhd1280b.cua");
115 cmdp.
setOption(
"verbose",
"quiet",&verbose,
"Print messages and results.");
116 cmdp.
setOption(
"pseudo",
"regular",&pseudo,
"Use pseudo-block GMRES to solve the linear systems.");
117 cmdp.
setOption(
"frequency",&frequency,
"Solvers frequency for printing residuals (#iters).");
119 cmdp.
setOption(
"tol",&tol,
"Relative residual tolerance used by GMRES solver.");
120 cmdp.
setOption(
"num-rhs",&numrhs,
"Number of right-hand sides to be solved for.");
121 cmdp.
setOption(
"num-restarts",&maxrestarts,
"Maximum number of restarts allowed for the GMRES solver.");
122 cmdp.
setOption(
"blocksize",&blocksize,
"Block size used by GMRES.");
123 cmdp.
setOption(
"subspace-length",&length,
"Maximum dimension of block-subspace used by GMRES solver.");
128 proc_verbose = verbose && (MyPID==0);
135 #ifndef HAVE_BELOS_TRIUTILS 136 std::cout <<
"This test requires Triutils. Please configure with --enable-triutils." << std::endl;
138 std::cout <<
"End Result: TEST FAILED" << std::endl;
149 info = readHB_newmat_double(
filename.c_str(),&dim,&dim2,&nnz,
150 &colptr,&rowind,&dvals);
151 if (info == 0 || nnz < 0) {
153 std::cout <<
"Error reading '" <<
filename <<
"'" << std::endl;
154 std::cout <<
"End Result: TEST FAILED" << std::endl;
160 for (
int ii=0; ii<nnz; ii++) {
161 cvals[ii] = ST(dvals[ii*2],dvals[ii*2+1]);
170 int maxits = dim/blocksize;
173 belosList.
set(
"Num Blocks", length );
174 belosList.
set(
"Block Size", blocksize );
175 belosList.
set(
"Maximum Iterations", maxits );
176 belosList.
set(
"Maximum Restarts", maxrestarts );
177 belosList.
set(
"Convergence Tolerance", tol );
182 belosList.
set(
"Output Frequency", frequency );
193 MVT::MvRandom( *soln );
194 OPT::Apply( *
A, *soln, *rhs );
195 MVT::MvInit( *soln, zero );
201 bool set = problem->setProblem();
204 std::cout << std::endl <<
"ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
221 std::cout << std::endl << std::endl;
222 std::cout <<
"Dimension of matrix: " << dim << std::endl;
223 std::cout <<
"Number of right-hand sides: " << numrhs << std::endl;
224 std::cout <<
"Block size used by solver: " << blocksize << std::endl;
225 std::cout <<
"Max number of Gmres iterations: " << maxits << std::endl;
226 std::cout <<
"Relative residual tolerance: " << tol << std::endl;
227 std::cout << std::endl;
237 OPT::Apply( *
A, *soln, *temp );
238 MVT::MvAddMv( one, *rhs, -one, *temp, *temp );
239 std::vector<MT> norm_num(numrhs), norm_denom(numrhs);
240 MVT::MvNorm( *temp, norm_num );
241 MVT::MvNorm( *rhs, norm_denom );
242 for (
int i=0; i<numrhs; ++i) {
244 std::cout <<
"Relative residual "<<i<<
" : " << norm_num[i] / norm_denom[i] << std::endl;
245 if ( norm_num[i] / norm_denom[i] > tol ) {
259 std::cout <<
"End Result: TEST PASSED" << std::endl;
262 std::cout <<
"End Result: TEST FAILED" << std::endl;
267 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
std::string Belos_Version()
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Interface to Block GMRES and Flexible GMRES.
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)
The Belos::BlockGmresSolMgr provides a solver manager for the BlockGmres linear solver.
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
#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.
Interface to standard and "pseudoblock" GMRES.
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.
The Belos::PseudoBlockGmresSolMgr provides a solver manager for the BlockGmres linear solver...
Belos header file which uses auto-configuration information to include necessary C++ headers...
int main(int argc, char *argv[])
Simple example of a user's defined Belos::Operator class.