46#include "Teuchos_CommandLineProcessor.hpp"
47#include "Teuchos_ParameterList.hpp"
48#include "Teuchos_VerboseObject.hpp"
49#include "Tpetra_Core.hpp"
50#include "Teuchos_StandardCatchMacros.hpp"
53int main(
int argc,
char* argv[])
56 using Teuchos::CommandLineProcessor;
61 Tpetra::ScopeGuard tpetraScope(&argc, &argv);
62 auto comm = Tpetra::getDefaultComm();
64 Teuchos::RCP<Teuchos::FancyOStream>
65 out = Teuchos::VerboseObjectBase::getDefaultOStream();
73 std::string matrixFile =
"";
74 std::string solverType =
"";
76 int numRandomVectors = 1;
77 double maxFwdError = 1e-14;
78 int outputFrequency = 10;
79 bool outputMaxResOnly =
true;
80 double maxResid = 1e-6;
81 double maxSolutionError = 1e-6;
82 bool showAllTests =
false;
85 CommandLineProcessor clp;
86 clp.throwExceptions(
false);
87 clp.addOutputSetupOptions(
true);
88 clp.setOption(
"matrix-file", &matrixFile,
"Matrix input file [Required]." );
89 clp.setOption(
"solver-type", &solverType,
"Type of solver to use [Required]." );
90 clp.setOption(
"num-rhs", &numRhs,
"Number of RHS in linear solve." );
91 clp.setOption(
"num-random-vectors", &numRandomVectors,
"Number of times a test is performed with different random vectors." );
92 clp.setOption(
"max-fwd-error", &maxFwdError,
"The maximum relative error in the forward operator." );
93 clp.setOption(
"output-frequency", &outputFrequency,
"Number of linear solver iterations between output" );
94 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." );
95 clp.setOption(
"max-resid", &maxResid,
"The maximum relative error in the residual." );
96 clp.setOption(
"max-solution-error", &maxSolutionError,
"The maximum relative error in the solution of the linear system." );
97 clp.setOption(
"verbose",
"quiet", &verbose,
"Set if output is printed or not." );
98 clp.setOption(
"show-all-tests",
"no-show-all-tests", &showAllTests,
"Set if all the tests are shown or not." );
99 clp.setOption(
"dump-all",
"no-dump-all", &dumpAll,
"Determines if vectors are printed or not." );
100 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
101 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
return parse_return;
103 TEUCHOS_TEST_FOR_EXCEPT( matrixFile ==
"" );
104 TEUCHOS_TEST_FOR_EXCEPT( solverType ==
"" );
106 Teuchos::ParameterList amesos2LOWSFPL(
"Amesos2");
108 amesos2LOWSFPL.set(
"Solver Type",solverType);
112 matrixFile,numRhs,numRandomVectors
113 ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll
120 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success)
123 if(success) *out <<
"\nCongratulations! All of the tests checked out!\n";
124 else *out <<
"\nOh no! At least one of the tests failed!\n";
127 return ( success ? 0 : 1 );
bool test_single_amesos2_tpetra_solver(const std::string matrixFile, const int numRhs, const int numRandomVectors, const double maxFwdError, const double maxResid, const double maxSolutionError, const bool showAllTests, const bool dumpAll, Teuchos::ParameterList *amesos2LOWSFPL, Teuchos::FancyOStream *out, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Testing function for a single belos solver with a single matrix.
int main(int argc, char *argv[])