55 Teuchos::ParameterList *paramList_inout
57 ,Teuchos::FancyOStream *out
64 using Teuchos::ParameterList;
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;
75 TEUCHOS_TEST_FOR_EXCEPT(!paramList_inout);
78 paramList = rcp(paramList_inout,
false);
81 *out <<
"\nEchoing input parameters ...\n";
82 paramList->print(*out,1,
true,
false);
86 Teuchos::ParameterList validParamList(
"test_tpetra_stratimikos_solver");
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";
105 RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
106 RCP<const Tpetra::CrsMatrix<Scalar, LO, GO, NO>> tpetra_A = Tpetra::MatrixMarket::Reader<Tpetra::CrsMatrix<Scalar, LO, GO, NO>>::readSparseFile( matrixFile, comm );
108 RCP<const LinearOpBase<double> >
109 A = Thyra::createConstLinearOp(Teuchos::rcp_dynamic_cast<
const Tpetra::Operator<Scalar,LO,GO,NO>>(tpetra_A));
111 if(out) *out <<
"\nCreating a Stratimikos::DefaultLinearSolverBuilder object ...\n";
113 RCP<Thyra::LinearSolverBuilderBase<double> >
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";
124 RCP<LinearOpWithSolveFactoryBase<double> >
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";
130 TEUCHOS_ASSERT(out != NULL);
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";
147 RCP<Thyra::LinearOpWithSolveBase<Scalar> >
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;