13 #include "Thyra_LinearOpTester.hpp"
14 #include "Thyra_LinearOpWithSolveTester.hpp"
15 #include "Thyra_LinearOpWithSolveFactoryExamples.hpp"
16 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
17 #include "EpetraExt_readEpetraLinearSystem.h"
21 # include "Epetra_MpiComm.h"
23 # include "Epetra_SerialComm.h"
37 using Teuchos::getParameter;
38 typedef double Scalar;
40 bool success =
true, result =
false;
47 paramList =
rcp(paramList_inout,
false);
50 *out <<
"\nEchoing input parameters ...\n";
51 paramList->print(*out,1,
true,
false);
56 validParamList.
set(
"Matrix File",
"fileName");
57 validParamList.
set(
"Solve Adjoint",
false);
58 validParamList.
sublist(
"Linear Solver Builder").disableRecursiveValidation();
59 validParamList.
sublist(
"LinearOpWithSolveTester").disableRecursiveValidation();
61 if(out) *out <<
"\nValidating top-level input parameters ...\n";
62 paramList->validateParametersAndSetDefaults(validParamList);
65 &matrixFile = getParameter<std::string>(*paramList,
"Matrix File");
67 solveAdjoint = getParameter<bool>(*paramList,
"Solve Adjoint");
69 solverBuilderSL = sublist(paramList,
"Linear Solver Builder",
true),
70 lowsTesterSL = sublist(paramList,
"LinearOpWithSolveTester",
true);
72 if(out) *out <<
"\nReading in an epetra matrix A from the file \'"<<matrixFile<<
"\' ...\n";
75 Epetra_MpiComm comm(MPI_COMM_WORLD);
77 Epetra_SerialComm comm;
80 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A );
83 A = Thyra::epetraLinearOp(epetra_A);
85 if(out) *out <<
"\nCreating a Stratimikos::DefaultLinearSolverBuilder object ...\n";
91 *out <<
"\nValid parameters for DefaultLinearSolverBuilder ...\n";
92 linearSolverBuilder->getValidParameters()->print(*out,1,
true,
false);
95 linearSolverBuilder->setParameterList(solverBuilderSL);
97 if(out) *out <<
"\nCreating the LinearOpWithSolveFactoryBase object lowsFactory ...\n";
99 lowsFactory = createLinearSolveStrategy(*linearSolverBuilder);
100 if(out) *out <<
"\nlowsFactory described as:\n" << describe(*lowsFactory,
Teuchos::VERB_MEDIUM) << std::endl;
102 if(out) *out <<
"\nRunning example use cases for not externally preconditioned ...\n";
105 nonExternallyPreconditionedLinearSolveUseCases(
106 *A, *lowsFactory, solveAdjoint, *out
109 Thyra::LinearOpWithSolveTester<Scalar> linearOpWithSolveTester;
110 linearOpWithSolveTester.setParameterList(lowsTesterSL);
111 linearOpWithSolveTester.turn_off_all_tests();
112 linearOpWithSolveTester.check_forward_default(
true);
113 linearOpWithSolveTester.check_forward_residual(
true);
115 linearOpWithSolveTester.check_adjoint_default(
true);
116 linearOpWithSolveTester.check_adjoint_residual(
true);
120 if(out) *out <<
"\nChecking the LOWSB interface ...\n";
122 lowsA = Thyra::linearOpWithSolve<Scalar>(*lowsFactory, A);
123 result = linearOpWithSolveTester.check(*lowsA, out);
124 if (!result) success =
false;
127 *out <<
"\nPrinting the parameter list (showing what was used) ...\n";
128 paramList->print(*out,1,
true,
true);
132 catch(
const std::exception &excpt ) {
133 std::cerr <<
"*** Caught standard exception : " << excpt.what() << std::endl;
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
basic_OSTab< char > OSTab
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool test_epetra_stratimikos_solver(Teuchos::ParameterList *paramList, const bool dumpAll, Teuchos::FancyOStream *out)
Testing function for a single epetra stratimikos solver for a single matrix.
Concrete subclass of Thyra::LinearSolverBuilderBase for creating Thyra::LinearOpWithSolveFactoryBase ...
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)