| 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 |
|
| 10 |
#include "test_single_amesos2_tpetra_solver.hpp" |
| 11 |
#include "Teuchos_CommandLineProcessor.hpp" |
| 12 |
#include "Teuchos_ParameterList.hpp" |
| 13 |
#include "Teuchos_VerboseObject.hpp" |
| 14 |
#include "Tpetra_Core.hpp" |
| 15 |
#include "Teuchos_StandardCatchMacros.hpp" |
| 16 |
|
| 17 |
|
| 18 |
int main(int argc, char* argv[]) |
| 19 |
{ |
| 20 |
|
| 21 |
using Teuchos::CommandLineProcessor; |
| 22 |
|
| 23 |
bool success = true; |
| 24 |
bool verbose = true; |
| 25 |
|
| 26 |
Tpetra::ScopeGuard tpetraScope(&argc, &argv); |
| 27 |
auto comm = Tpetra::getDefaultComm(); |
| 28 |
|
| 29 |
Teuchos::RCP<Teuchos::FancyOStream> |
| 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 |
} |