45 #include "Teuchos_CommandLineProcessor.hpp" 46 #include "Teuchos_GlobalMPISession.hpp" 47 #include "Teuchos_VerboseObject.hpp" 50 MatrixTestPacket(std::string _matrixFile,
bool _unsymmetric,
double _maxFwdError,
double _maxError,
double _maxResid)
59 int main(
int argc,
char* argv[])
62 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
64 using Teuchos::CommandLineProcessor;
67 bool result, success =
true;
71 Teuchos::RCP<Teuchos::FancyOStream>
72 out = Teuchos::VerboseObjectBase::getDefaultOStream();
80 std::string matrixDir =
".";
81 bool testTranspose =
true;
82 int numRandomVectors = 1;
83 bool showAllTests =
false;
84 bool showAllTestsDetails =
false;
87 CommandLineProcessor clp;
88 clp.throwExceptions(
false);
89 clp.addOutputSetupOptions(
true);
90 clp.setOption(
"matrix-dir", &matrixDir,
"Base directory for the test matrices" );
91 clp.setOption(
"test-transpose",
"no-test-transpose", &testTranspose,
"Test the transpose solve or not." );
92 clp.setOption(
"num-random-vectors", &numRandomVectors,
"Number of times a test is performed with different random vectors." );
93 clp.setOption(
"verbose",
"quiet", &verbose,
"Set if output is printed or not." );
94 clp.setOption(
"show-all-tests",
"no-show-all-tests", &showAllTests,
"Set if all the tests are shown or not." );
95 clp.setOption(
"show-all-tests-details",
"no-show-all-tests-details", &showAllTestsDetails,
"Set if all the details of the tests are shown or not." );
96 clp.setOption(
"dump-all",
"no-dump-all", &dumpAll,
"Determines if vectors are printed or not." );
97 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
98 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
return parse_return;
100 TEUCHOS_TEST_FOR_EXCEPT( matrixDir ==
"" );
106 const int numTestMatrices = 9;
112 const MTP testMatrices[numTestMatrices] =
114 MTP(
"bcsstk01.mtx",
false,1e-12,1e-12,1e-12)
115 ,MTP(
"bcsstk02.mtx",
false,1e-12,1e-12,1e-12)
116 ,MTP(
"bcsstk04.mtx",
false,1e-12,1e-10,1e-12)
117 ,MTP(
"Diagonal.mtx",
false,1e-12,1e-12,1e-12)
118 ,MTP(
"FourByFour.mtx",
true,1e-12,1e-12,1e-12)
119 ,MTP(
"KheadK.mtx",
false,1e-12,1e-12,1e-12)
120 ,MTP(
"KheadSorted.mtx",
false,1e-12,1e-12,1e-12)
121 ,MTP(
"nos1.mtx",
false,1e-11,1e-10,1e-12)
122 ,MTP(
"nos5.mtx",
false,1e-12,1e-12,1e-12)
127 for(
int matrix_i = 0; matrix_i < numTestMatrices; ++matrix_i ) {
129 mtp = testMatrices[matrix_i];
141 bool BadMatrixForSuperlu =
155 << std::endl<<matrix_i<<
"."<<solver_i<<
"."<<factorizationPolicy_i<<
": " 156 <<
"Testing, matrixFile=\'"<<mtp.
matrixFile<<
"\', solverType=\'"<<
toString(solverType)<<
"\', refactorizationPolicy=\'"<<
toString(refactorizationPolicy)<<
"\' ...";
158 *out <<
" : Skipping since unsymmetric and not supported!\n";
162 std::string StrSolverType =
toString(solverType) ;
163 std::string StrSuperlu =
"Superlu";
164 if ( StrSolverType==StrSuperlu && BadMatrixForSuperlu ) {
165 *out <<
" : Skipping since Superlu fails on this matrix!\n";
168 std::ostringstream ossStore;
169 Teuchos::RCP<Teuchos::FancyOStream>
170 oss = Teuchos::rcp(
new Teuchos::FancyOStream(Teuchos::rcp(&ossStore,
false)));
171 Teuchos::ParameterList amesosLOWSFPL;
172 amesosLOWSFPL.set(
"Solver Type",
toString(solverType));
173 amesosLOWSFPL.set(
"Refactorization Policy",
toString(refactorizationPolicy));
176 matrixDir+
"/"+mtp.
matrixFile,&amesosLOWSFPL,testTranspose,numRandomVectors
179 if(!result) success =
false;
183 *out << std::endl << ossStore.str();
185 *out <<
" : passed!\n";
189 *out << std::endl << ossStore.str();
191 *out <<
" : failed!\n";
201 catch(
const std::exception &excpt ) {
202 std::cerr <<
"*** Caught standard exception : " << excpt.what() << std::endl;
206 std::cerr <<
"*** Caught an unknown exception\n";
211 if(success) *out <<
"\nCongratulations! All of the tests checked out!\n";
212 else *out <<
"\nOh no! At least one of the tests failed!\n";
215 return ( success ? 0 : 1 );
ERefactorizationPolicy
The policy used on refactoring a matrix.
bool test_single_amesos_thyra_solver(const std::string matrixFile, Teuchos::ParameterList *amesosLOWSFPL, const bool testTranspose, const int numRandomVectors, const double maxFwdError, const double maxError, const double maxResid, const bool showAllTests, const bool dumpAll, Teuchos::FancyOStream *out)
Testing function for a single amesos solver with a single matrix.
MatrixTestPacket(std::string _matrixFile, bool _unsymmetric, double _maxFwdError, double _maxError, double _maxResid)
const ERefactorizationPolicy refactorizationPolicyValues[numRefactorizationPolices]
int main(int argc, char *argv[])
const int numRefactorizationPolices
const ESolverType solverTypeValues[numSolverTypes]
const bool supportsUnsymmetric[numSolverTypes]
const char * toString(const ESolverType solverType)