43 #include "Tpetra_Core.hpp"
44 #include "Tpetra_CrsMatrix.hpp"
47 #include "Thyra_LinearOpTester.hpp"
48 #include "Thyra_LinearOpWithSolveTester.hpp"
49 #include "Thyra_LinearOpWithSolveFactoryExamples.hpp"
50 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
51 #include "MatrixMarket_Tpetra.hpp"
65 using Teuchos::getParameter;
66 typedef double Scalar;
67 typedef Tpetra::Map<>::local_ordinal_type
LO;
68 typedef Tpetra::Map<>::global_ordinal_type
GO;
69 typedef Tpetra::Map<>::node_type NO;
71 bool success =
true, result =
false;
78 paramList =
rcp(paramList_inout,
false);
81 *out <<
"\nEchoing input parameters ...\n";
82 paramList->print(*out,1,
true,
false);
87 validParamList.
set(
"Matrix File",
"fileName");
88 validParamList.
set(
"Solve Adjoint",
false);
89 validParamList.
sublist(
"Linear Solver Builder").disableRecursiveValidation();
90 validParamList.
sublist(
"LinearOpWithSolveTester").disableRecursiveValidation();
92 if(out) *out <<
"\nValidating top-level input parameters ...\n";
93 paramList->validateParametersAndSetDefaults(validParamList);
96 &matrixFile = getParameter<std::string>(*paramList,
"Matrix File");
98 solveAdjoint = getParameter<bool>(*paramList,
"Solve Adjoint");
100 solverBuilderSL = sublist(paramList,
"Linear Solver Builder",
true),
101 lowsTesterSL = sublist(paramList,
"LinearOpWithSolveTester",
true);
103 if(out) *out <<
"\nReading in an tpetra matrix A from the file \'"<<matrixFile<<
"\' ...\n";
111 if(out) *out <<
"\nCreating a Stratimikos::DefaultLinearSolverBuilder object ...\n";
117 *out <<
"\nValid parameters for DefaultLinearSolverBuilder ...\n";
118 linearSolverBuilder->getValidParameters()->print(*out,1,
true,
false);
121 linearSolverBuilder->setParameterList(solverBuilderSL);
123 if(out) *out <<
"\nCreating the LinearOpWithSolveFactoryBase object lowsFactory ...\n";
125 lowsFactory = createLinearSolveStrategy(*linearSolverBuilder);
126 if(out) *out <<
"\nlowsFactory described as:\n" << describe(*lowsFactory,
Teuchos::VERB_MEDIUM) << std::endl;
128 if(out) *out <<
"\nRunning example use cases for not externally preconditioned ...\n";
131 nonExternallyPreconditionedLinearSolveUseCases(
132 *A, *lowsFactory, solveAdjoint, *out
135 Thyra::LinearOpWithSolveTester<Scalar> linearOpWithSolveTester;
136 linearOpWithSolveTester.setParameterList(lowsTesterSL);
137 linearOpWithSolveTester.turn_off_all_tests();
138 linearOpWithSolveTester.check_forward_default(
true);
139 linearOpWithSolveTester.check_forward_residual(
true);
141 linearOpWithSolveTester.check_adjoint_default(
true);
142 linearOpWithSolveTester.check_adjoint_residual(
true);
146 if(out) *out <<
"\nChecking the LOWSB interface ...\n";
148 lowsA = Thyra::linearOpWithSolve<Scalar>(*lowsFactory, A);
149 result = linearOpWithSolveTester.check(*lowsA, out);
150 if (!result) success =
false;
153 *out <<
"\nPrinting the parameter list (showing what was used) ...\n";
154 paramList->print(*out,1,
true,
true);
158 catch(
const std::exception &excpt ) {
159 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
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