Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_single_amesos2_tpetra_solver_driver.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stratimikos: Thyra-based strategies for linear solvers
4 //
5 // Copyright 2006 NTESS and the Stratimikos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
14 #include "Tpetra_Core.hpp"
16 
17 
18 int main(int argc, char* argv[])
19 {
20 
22 
23  bool success = true;
24  bool verbose = true;
25 
26  Tpetra::ScopeGuard tpetraScope(&argc, &argv);
27  auto comm = Tpetra::getDefaultComm();
28 
30  out = Teuchos::VerboseObjectBase::getDefaultOStream();
31 
32  try {
33 
34  //
35  // Read options from command-line
36  //
37 
38  std::string matrixFile = "";
39  std::string solverType = "";
40  int numRhs = 1;
41  int numRandomVectors = 1;
42  double maxFwdError = 1e-14;
43  int outputFrequency = 10;
44  bool outputMaxResOnly = true;
45  double maxResid = 1e-6;
46  double maxSolutionError = 1e-6;
47  bool showAllTests = false;
48  bool dumpAll = false;
49 
50  CommandLineProcessor clp;
51  clp.throwExceptions(false);
52  clp.addOutputSetupOptions(true);
53  clp.setOption( "matrix-file", &matrixFile, "Matrix input file [Required]." );
54  clp.setOption( "solver-type", &solverType, "Type of solver to use [Required]." );
55  clp.setOption( "num-rhs", &numRhs, "Number of RHS in linear solve." );
56  clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." );
57  clp.setOption( "max-fwd-error", &maxFwdError, "The maximum relative error in the forward operator." );
58  clp.setOption( "output-frequency", &outputFrequency, "Number of linear solver iterations between output" );
59  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." );
60  clp.setOption( "max-resid", &maxResid, "The maximum relative error in the residual." );
61  clp.setOption( "max-solution-error", &maxSolutionError, "The maximum relative error in the solution of the linear system." );
62  clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." );
63  clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." );
64  clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." );
65  CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
66  if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
67 
68  TEUCHOS_TEST_FOR_EXCEPT( matrixFile == "" );
69  TEUCHOS_TEST_FOR_EXCEPT( solverType == "" );
70 
71  Teuchos::ParameterList amesos2LOWSFPL("Amesos2");
72 
73  amesos2LOWSFPL.set("Solver Type",solverType);
74 
75  success
76  = Thyra::test_single_amesos2_tpetra_solver(
77  matrixFile,numRhs,numRandomVectors
78  ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll
79  ,&amesos2LOWSFPL
80  ,verbose?&*out:0
81  ,comm
82  );
83 
84  }
85  TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success)
86 
87  if (verbose) {
88  if(success) *out << "\nCongratulations! All of the tests checked out!\n";
89  else *out << "\nOh no! At least one of the tests failed!\n";
90  }
91 
92  return ( success ? 0 : 1 );
93 }
int main(int argc, char *argv[])
bool showAllTests
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
bool dumpAll
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)