44 #include "Thyra_EpetraLinearOp.hpp" 45 #include "Thyra_LinearOpTester.hpp" 46 #include "Thyra_LinearOpWithSolveTester.hpp" 47 #include "Thyra_LinearOpWithSolveFactoryExamples.hpp" 48 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp" 49 #include "EpetraExt_readEpetraLinearSystem.h" 50 #include "Teuchos_ParameterList.hpp" 53 # include "Epetra_MpiComm.h" 55 # include "Epetra_SerialComm.h" 59 Teuchos::ParameterList *paramList_inout
61 ,Teuchos::FancyOStream *out
68 using Teuchos::ParameterList;
69 using Teuchos::getParameter;
70 typedef double Scalar;
72 bool success =
true, result =
false;
76 TEUCHOS_TEST_FOR_EXCEPT(!paramList_inout);
79 paramList = rcp(paramList_inout,
false);
82 *out <<
"\nEchoing input parameters ...\n";
83 paramList->print(*out,1,
true,
false);
87 Teuchos::ParameterList validParamList(
"test_single_stratimikos_solver");
88 validParamList.set(
"Matrix File",
"fileName");
89 validParamList.set(
"Solve Adjoint",
false);
90 validParamList.sublist(
"Linear Solver Builder").disableRecursiveValidation();
91 validParamList.sublist(
"LinearOpWithSolveTester").disableRecursiveValidation();
93 if(out) *out <<
"\nValidating top-level input parameters ...\n";
94 paramList->validateParametersAndSetDefaults(validParamList);
97 &matrixFile = getParameter<std::string>(*paramList,
"Matrix File");
99 solveAdjoint = getParameter<bool>(*paramList,
"Solve Adjoint");
101 solverBuilderSL = sublist(paramList,
"Linear Solver Builder",
true),
102 lowsTesterSL = sublist(paramList,
"LinearOpWithSolveTester",
true);
104 if(out) *out <<
"\nReading in an epetra matrix A from the file \'"<<matrixFile<<
"\' ...\n";
107 Epetra_MpiComm comm(MPI_COMM_WORLD);
109 Epetra_SerialComm comm;
111 RCP<Epetra_CrsMatrix> epetra_A;
112 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A );
114 RCP<const LinearOpBase<double> >
115 A = Thyra::epetraLinearOp(epetra_A);
117 if(out) *out <<
"\nCreating a Stratimikos::DefaultLinearSolverBuilder object ...\n";
119 RCP<Thyra::LinearSolverBuilderBase<double> >
123 *out <<
"\nValid parameters for DefaultLinearSolverBuilder ...\n";
124 linearSolverBuilder->getValidParameters()->print(*out,1,
true,
false);
127 linearSolverBuilder->setParameterList(solverBuilderSL);
129 if(out) *out <<
"\nCreating the LinearOpWithSolveFactoryBase object lowsFactory ...\n";
130 RCP<LinearOpWithSolveFactoryBase<double> >
131 lowsFactory = createLinearSolveStrategy(*linearSolverBuilder);
132 if(out) *out <<
"\nlowsFactory described as:\n" << describe(*lowsFactory,Teuchos::VERB_MEDIUM) << std::endl;
134 if(out) *out <<
"\nRunning example use cases for not externally preconditioned ...\n";
136 TEUCHOS_ASSERT(out != NULL);
137 nonExternallyPreconditionedLinearSolveUseCases(
138 *A, *lowsFactory, solveAdjoint, *out
141 Thyra::LinearOpWithSolveTester<Scalar> linearOpWithSolveTester;
142 linearOpWithSolveTester.setParameterList(lowsTesterSL);
143 linearOpWithSolveTester.turn_off_all_tests();
144 linearOpWithSolveTester.check_forward_default(
true);
145 linearOpWithSolveTester.check_forward_residual(
true);
147 linearOpWithSolveTester.check_adjoint_default(
true);
148 linearOpWithSolveTester.check_adjoint_residual(
true);
152 if(out) *out <<
"\nChecking the LOWSB interface ...\n";
153 RCP<Thyra::LinearOpWithSolveBase<Scalar> >
154 lowsA = Thyra::linearOpWithSolve<Scalar>(*lowsFactory, A);
155 result = linearOpWithSolveTester.check(*lowsA, out);
156 if (!result) success =
false;
159 *out <<
"\nPrinting the parameter list (showing what was used) ...\n";
160 paramList->print(*out,1,
true,
true);
164 catch(
const std::exception &excpt ) {
165 std::cerr <<
"*** Caught standard exception : " << excpt.what() << std::endl;
Concrete subclass of Thyra::LinearSolverBuilderBase for creating LinearOpWithSolveFactoryBase objects...
bool test_single_stratimikos_solver(Teuchos::ParameterList *paramList, const bool dumpAll, Teuchos::FancyOStream *out)
Testing function for a single stratimikos solver for a single matrix.