11 #include "Tpetra_Core.hpp"
12 #include "Tpetra_CrsMatrix.hpp"
15 #include "Thyra_LinearOpTester.hpp"
16 #include "Thyra_LinearOpWithSolveTester.hpp"
17 #include "Thyra_LinearOpWithSolveFactoryExamples.hpp"
18 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
19 #include "MatrixMarket_Tpetra.hpp"
33 using Teuchos::getParameter;
34 typedef double Scalar;
35 typedef Tpetra::Map<>::local_ordinal_type
LO;
36 typedef Tpetra::Map<>::global_ordinal_type
GO;
37 typedef Tpetra::Map<>::node_type NO;
39 bool success =
true, result =
false;
46 paramList =
rcp(paramList_inout,
false);
49 *out <<
"\nEchoing input parameters ...\n";
50 paramList->print(*out,1,
true,
false);
55 validParamList.
set(
"Matrix File",
"fileName");
56 validParamList.
set(
"Solve Adjoint",
false);
57 validParamList.
sublist(
"Linear Solver Builder").disableRecursiveValidation();
58 validParamList.
sublist(
"LinearOpWithSolveTester").disableRecursiveValidation();
60 if(out) *out <<
"\nValidating top-level input parameters ...\n";
61 paramList->validateParametersAndSetDefaults(validParamList);
64 &matrixFile = getParameter<std::string>(*paramList,
"Matrix File");
66 solveAdjoint = getParameter<bool>(*paramList,
"Solve Adjoint");
68 solverBuilderSL = sublist(paramList,
"Linear Solver Builder",
true),
69 lowsTesterSL = sublist(paramList,
"LinearOpWithSolveTester",
true);
71 if(out) *out <<
"\nReading in an tpetra matrix A from the file \'"<<matrixFile<<
"\' ...\n";
79 if(out) *out <<
"\nCreating a Stratimikos::DefaultLinearSolverBuilder object ...\n";
85 *out <<
"\nValid parameters for DefaultLinearSolverBuilder ...\n";
86 linearSolverBuilder->getValidParameters()->print(*out,1,
true,
false);
89 linearSolverBuilder->setParameterList(solverBuilderSL);
91 if(out) *out <<
"\nCreating the LinearOpWithSolveFactoryBase object lowsFactory ...\n";
93 lowsFactory = createLinearSolveStrategy(*linearSolverBuilder);
94 if(out) *out <<
"\nlowsFactory described as:\n" << describe(*lowsFactory,
Teuchos::VERB_MEDIUM) << std::endl;
96 if(out) *out <<
"\nRunning example use cases for not externally preconditioned ...\n";
99 nonExternallyPreconditionedLinearSolveUseCases(
100 *A, *lowsFactory, solveAdjoint, *out
103 Thyra::LinearOpWithSolveTester<Scalar> linearOpWithSolveTester;
104 linearOpWithSolveTester.setParameterList(lowsTesterSL);
105 linearOpWithSolveTester.turn_off_all_tests();
106 linearOpWithSolveTester.check_forward_default(
true);
107 linearOpWithSolveTester.check_forward_residual(
true);
109 linearOpWithSolveTester.check_adjoint_default(
true);
110 linearOpWithSolveTester.check_adjoint_residual(
true);
114 if(out) *out <<
"\nChecking the LOWSB interface ...\n";
116 lowsA = Thyra::linearOpWithSolve<Scalar>(*lowsFactory, A);
117 result = linearOpWithSolveTester.check(*lowsA, out);
118 if (!result) success =
false;
121 *out <<
"\nPrinting the parameter list (showing what was used) ...\n";
122 paramList->print(*out,1,
true,
true);
126 catch(
const std::exception &excpt ) {
127 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
RCP< const LinearOpBase< Scalar > > createConstLinearOp(const RCP< const Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraOperator, const RCP< const VectorSpaceBase< Scalar > > rangeSpace=Teuchos::null, const RCP< const VectorSpaceBase< Scalar > > domainSpace=Teuchos::null)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool test_tpetra_stratimikos_solver(Teuchos::ParameterList *paramList, const bool dumpAll, Teuchos::FancyOStream *out)
Testing function for a single tpetra stratimikos solver for a single matrix.
Concrete subclass of Thyra::LinearSolverBuilderBase for creating Thyra::LinearOpWithSolveFactoryBase ...
#define TEUCHOS_ASSERT(assertion_test)
map_type::local_ordinal_type LO
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
map_type::global_ordinal_type GO