46#include "Teuchos_CommandLineProcessor.hpp"
47#include "Teuchos_ParameterList.hpp"
48#include "Teuchos_VerboseObject.hpp"
49#include "Teuchos_GlobalMPISession.hpp"
50#include "Teuchos_StandardCatchMacros.hpp"
53int main(
int argc,
char* argv[])
56 using Teuchos::CommandLineProcessor;
61 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
63 Teuchos::RCP<Teuchos::FancyOStream>
64 out = Teuchos::VerboseObjectBase::getDefaultOStream();
72 std::string matrixFile =
"";
73 bool testTranspose =
false;
74 bool usePreconditioner =
true;
76 int numRandomVectors = 1;
77 double maxFwdError = 1e-14;
78 int maxIterations = 400;
80 int gmresKrylovLength = 25;
81 int outputFrequency = 10;
82 bool outputMaxResOnly =
true;
84 double maxResid = 1e-6;
85 double maxSolutionError = 1e-6;
86 bool showAllTests =
false;
89 CommandLineProcessor clp;
90 clp.throwExceptions(
false);
91 clp.addOutputSetupOptions(
true);
92 clp.setOption(
"matrix-file", &matrixFile,
"Matrix input file [Required]." );
93 clp.setOption(
"test-transpose",
"no-test-transpose", &testTranspose,
"Test the transpose solve or not." );
94 clp.setOption(
"use-preconditioner",
"no-use-preconditioner", &usePreconditioner,
"Use the preconditioner or not." );
95 clp.setOption(
"num-rhs", &numRhs,
"Number of RHS in linear solve." );
96 clp.setOption(
"num-random-vectors", &numRandomVectors,
"Number of times a test is performed with different random vectors." );
97 clp.setOption(
"max-fwd-error", &maxFwdError,
"The maximum relative error in the forward operator." );
98 clp.setOption(
"max-iters", &maxIterations,
"The maximum number of linear solver iterations to take." );
99 clp.setOption(
"max-restarts", &maxRestarts,
"???." );
100 clp.setOption(
"gmres-krylov-length", &gmresKrylovLength,
"???." );
101 clp.setOption(
"output-frequency", &outputFrequency,
"Number of linear solver iterations between output" );
102 clp.setOption(
"output-max-res-only",
"output-all-res", &outputMaxResOnly,
"Determines if only the max residual is printed or if all residuals are printed per iteration." );
103 clp.setOption(
"block-size", &blockSize,
"???." );
104 clp.setOption(
"max-resid", &maxResid,
"The maximum relative error in the residual." );
105 clp.setOption(
"max-solution-error", &maxSolutionError,
"The maximum relative error in the solution of the linear system." );
106 clp.setOption(
"verbose",
"quiet", &verbose,
"Set if output is printed or not." );
107 clp.setOption(
"show-all-tests",
"no-show-all-tests", &showAllTests,
"Set if all the tests are shown or not." );
108 clp.setOption(
"dump-all",
"no-dump-all", &dumpAll,
"Determines if vectors are printed or not." );
109 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
110 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
return parse_return;
112 TEUCHOS_TEST_FOR_EXCEPT( matrixFile ==
"" );
114 Teuchos::ParameterList belosLOWSFPL;
116 belosLOWSFPL.set(
"Solver Type",
"Block GMRES");
118 Teuchos::ParameterList& belosLOWSFPL_solver =
119 belosLOWSFPL.sublist(
"Solver Types");
121 Teuchos::ParameterList& belosLOWSFPL_gmres =
122 belosLOWSFPL_solver.sublist(
"Block GMRES");
124 belosLOWSFPL_gmres.set(
"Maximum Iterations",
int(maxIterations));
125 belosLOWSFPL_gmres.set(
"Convergence Tolerance",
double(maxResid));
126 belosLOWSFPL_gmres.set(
"Maximum Restarts",
int(maxRestarts));
127 belosLOWSFPL_gmres.set(
"Block Size",
int(blockSize));
128 belosLOWSFPL_gmres.set(
"Num Blocks",
int(gmresKrylovLength));
129 belosLOWSFPL_gmres.set(
"Output Frequency",
int(outputFrequency));
130 belosLOWSFPL_gmres.set(
"Show Maximum Residual Norm Only",
bool(outputMaxResOnly));
132 Teuchos::ParameterList precPL(
"Ifpack");
133 if(usePreconditioner) {
134 precPL.set(
"Overlap",
int(2));
135 precPL.set(
"Prec Type",
"ILUT");
140 matrixFile,testTranspose,usePreconditioner,numRhs,numRandomVectors
141 ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll
142 ,&belosLOWSFPL,&precPL
147 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success)
150 if(success) *out <<
"\nCongratulations! All of the tests checked out!\n";
151 else *out <<
"\nOh no! At least one of the tests failed!\n";
154 return ( success ? 0 : 1 );
bool test_single_belos_thyra_solver(const std::string matrixFile, const bool testTranspose, const bool usePreconditioner, const int numRhs, const int numRandomVectors, const double maxFwdError, const double maxResid, const double maxSolutionError, const bool showAllTests, const bool dumpAll, Teuchos::ParameterList *belosLOWSFPL, Teuchos::ParameterList *precPL, Teuchos::FancyOStream *out)
Testing function for a single belos solver with a single matrix.
int main(int argc, char *argv[])