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"
53 # include "Epetra_MpiComm.h"
55 # include "Epetra_SerialComm.h"
69 using Teuchos::getParameter;
70 typedef double Scalar;
72 bool success =
true, result =
false;
79 paramList =
rcp(paramList_inout,
false);
82 *out <<
"\nEchoing input parameters ...\n";
83 paramList->print(*out,1,
true,
false);
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;
112 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A );
115 A = Thyra::epetraLinearOp(epetra_A);
117 if(out) *out <<
"\nCreating a Stratimikos::DefaultLinearSolverBuilder object ...\n";
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";
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";
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";
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;
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
basic_OSTab< char > OSTab
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)