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_aztecoo_thyra_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 
15 int main(int argc, char* argv[])
16 {
17 
18  Teuchos::GlobalMPISession mpiSession(&argc,&argv);
19 
21 
22  bool success = true;
23  bool verbose = true;
24 
25  Teuchos::FancyOStream out(Teuchos::rcp(&std::cout,false));
26 
27  try {
28 
29  //
30  // Read options from command-line
31  //
32 
33  std::string matrixFile = "";
34  bool testTranspose = true;
35  int numRandomVectors = 1;
36  double maxFwdError = 1e-14;
37  int maxIterations = 400;
38  double maxResid = 1e-6;
39  double maxSolutionError = 1e-6;
40  bool showAllTests = false;
41  bool dumpAll = false;
42  std::string aztecOutputLevel = "freq";
43  int aztecOutputFreq = 0;
44  std::string aztecPrec = "none";
45  std::string aztecSubdomainSolve = "ilu";
46 
47  CommandLineProcessor clp(false); // Don't throw exceptions
48  clp.setOption( "matrix-file", &matrixFile, "Matrix input file [Required]." );
49  clp.setOption( "test-transpose", "no-test-transpose", &testTranspose, "Test the transpose solve or not." );
50  clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." );
51  clp.setOption( "max-fwd-error", &maxFwdError, "The maximum relative error in the forward operator." );
52  clp.setOption( "max-iters", &maxIterations, "The maximum number of linear solver iterations to take." );
53  clp.setOption( "max-resid", &maxResid, "The maximum relative error in the residual." );
54  clp.setOption( "max-solution-error", &maxSolutionError, "The maximum relative error in the solution of the linear system." );
55  clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." );
56  clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." );
57  clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." );
58  clp.setOption( "aztec-output-level", &aztecOutputLevel, "Aztec output level (freq,last,summary,warnings,all)" );
59  clp.setOption( "aztec-output-freq", &aztecOutputFreq, "Aztec output freqency (> 0)" );
60  clp.setOption( "aztec-prec", &aztecPrec, "Type of aztec preconditioner (none,sym_GS,Neumann,Jacobi,ls,dom_decomp)" );
61  clp.setOption( "aztec-subdomain-solve", &aztecSubdomainSolve, "Type of subdomain solve for --aztec-prec==dom_decomp only (ilu,ilut)" );
62  CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
63  if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
64 
65  TEUCHOS_TEST_FOR_EXCEPT( matrixFile == "" );
66 
68  paramList("AztecOOLinearOpWithSolve");
70  &fwdSolveParamList = paramList.sublist("Forward Solve"),
71  &adjSolveParamList = paramList.sublist("Adjoint Solve");
72  fwdSolveParamList.set("Max Iterations",maxIterations);
73  adjSolveParamList.set("Max Iterations",maxIterations);
74 /*
75  Teuchos::ParameterList
76  &fwdAztecOOParamList = fwdSolveParamList.sublist("AztecOO"),
77  &adjAztecOOParamList = fwdSolveParamList.sublist("AztecOO");
78  if( aztecOutputLevel != "freq" ) {
79  fwdAztecOOParamList.set("Output Frequency",aztecOutputLevel);
80  adjAztecOOParamList.set("Output Frequency",aztecOutputLevel);
81  }
82  else {
83  fwdAztecOOParamList.set("Output Frequency",aztecOutputFreq);
84  adjAztecOOParamList.set("Output Frequency",aztecOutputFreq);
85  }
86  if( aztecPrec != "none" ) {
87  fwdAztecOOParamList.set("Aztec Preconditioner",aztecPrec);
88  adjAztecOOParamList.set("Aztec Preconditioner",aztecPrec);
89  if(aztecPrec=="dom_decomp") {
90  fwdAztecOOParamList.set("AZ_subdomain_solve",aztecSubdomainSolve);
91  adjAztecOOParamList.set("AZ_subdomain_solve",aztecSubdomainSolve);
92  }
93  }
94 */
95 
96  success
97  = Thyra::test_single_aztecoo_thyra_solver(
98  matrixFile,testTranspose,numRandomVectors
99  ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll
100  ,&paramList
101  ,verbose?&out:0
102  );
103 
104  }
105  catch( const std::exception &excpt ) {
106  std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl;
107  success = false;
108  }
109  catch( ... ) {
110  std::cerr << "*** Caught an unknown exception\n";
111  success = false;
112  }
113 
114  if (verbose) {
115  if(success) out << "\nCongratulations! All of the tests checked out!\n";
116  else out << "\nOh no! At least one of the tests failed!\n";
117  }
118 
119  return ( success ? 0 : 1 );
120 }
int main(int argc, char *argv[])
bool showAllTests
RCP< ParameterList > sublist(const RCP< ParameterList > &paramList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool dumpAll
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)