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 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Stratimikos: Thyra-based strategies for linear solvers
6 // Copyright (2006) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
44 
49 #include "Tpetra_Core.hpp"
51 
52 
53 int main(int argc, char* argv[])
54 {
55 
57 
58  bool success = true;
59  bool verbose = true;
60 
61  Tpetra::ScopeGuard tpetraScope(&argc, &argv);
62  auto comm = Tpetra::getDefaultComm();
63 
65  out = Teuchos::VerboseObjectBase::getDefaultOStream();
66 
67  try {
68 
69  //
70  // Read options from command-line
71  //
72 
73  std::string matrixFile = "";
74  std::string solverType = "";
75  int numRhs = 1;
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;
83  bool dumpAll = false;
84 
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;
102 
103  TEUCHOS_TEST_FOR_EXCEPT( matrixFile == "" );
104  TEUCHOS_TEST_FOR_EXCEPT( solverType == "" );
105 
106  Teuchos::ParameterList amesos2LOWSFPL("Amesos2");
107 
108  amesos2LOWSFPL.set("Solver Type",solverType);
109 
110  success
111  = Thyra::test_single_amesos2_tpetra_solver(
112  matrixFile,numRhs,numRandomVectors
113  ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll
114  ,&amesos2LOWSFPL
115  ,verbose?&*out:0
116  ,comm
117  );
118 
119  }
120  TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success)
121 
122  if (verbose) {
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";
125  }
126 
127  return ( success ? 0 : 1 );
128 }
int main(int argc, char *argv[])
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
bool showAllTests
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
bool dumpAll
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)