2 #include "Thyra_BelosLinearOpWithSolveFactory.hpp" 3 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp" 4 #include "Thyra_MultiVectorStdOps.hpp" 5 #include "Thyra_VectorBase.hpp" 6 #include "Thyra_VectorStdOps.hpp" 7 #include "Thyra_EpetraLinearOp.hpp" 8 #include "EpetraExt_readEpetraLinearSystem.h" 9 #include "Epetra_SerialComm.h" 11 #include "Teuchos_UnitTestHarness.hpp" 29 Epetra_SerialComm comm;
30 Teuchos::RCP<Epetra_CrsMatrix> epetra_A;
31 std::string matrixFile =
"FourByFour.mtx";
32 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A );
34 Teuchos::RCP<const LinearOpBase<double> > A = epetraLinearOp(epetra_A);
36 Teuchos::RCP<LinearOpWithSolveFactoryBase<double> >
39 Teuchos::RCP<BelosLinearOpWithSolveFactory<double> >
41 lowsFactory = belosLowsFactory;
44 Teuchos::ParameterList belosLOWSFPL;
46 belosLOWSFPL.set(
"Solver Type",
"Block GMRES");
48 Teuchos::ParameterList& belosLOWSFPL_solver =
49 belosLOWSFPL.sublist(
"Solver Types");
51 Teuchos::ParameterList& belosLOWSFPL_gmres =
52 belosLOWSFPL_solver.sublist(
"Block GMRES");
54 belosLOWSFPL_gmres.set(
"Maximum Iterations",
int(4));
55 belosLOWSFPL_gmres.set(
"Convergence Tolerance",
double(1.0e-4));
56 belosLOWSFPL_gmres.set(
"Maximum Restarts",
int(0));
57 belosLOWSFPL_gmres.set(
"Block Size",
int(1));
58 belosLOWSFPL_gmres.set(
"Num Blocks",
int(4));
59 belosLOWSFPL_gmres.set(
"Output Frequency",
int(1));
60 belosLOWSFPL_gmres.set(
"Show Maximum Residual Norm Only",
bool(
false));
62 lowsFactory->setParameterList(Teuchos::rcp(&belosLOWSFPL,
false));
65 Teuchos::RCP<LinearOpWithSolveBase<double> > nsA = lowsFactory->createOp();
66 Thyra::initializeOp<double>(*lowsFactory, A, nsA.ptr());
68 Teuchos::RCP<Thyra::VectorBase<double> > x = Thyra::createMember(A->domain());
69 Teuchos::RCP<Thyra::VectorBase<double> > f = Thyra::createMember(A->range());
71 Thyra::put_scalar(0.0,x.ptr());
72 Thyra::put_scalar(1.0,f.ptr());
75 Thyra::set_ele(0,Teuchos::ScalarTraits<double>::nan(),x.ptr());
77 Thyra::SolveStatus<double> status = Thyra::solve<double>(*nsA,Thyra::NOTRANS,*f,x.ptr());
79 TEST_EQUALITY(status.solveStatus, Thyra::SOLVE_STATUS_UNCONVERGED);
TEUCHOS_UNIT_TEST(belos, nan_handling)
LinearOpWithSolveFactoryBase subclass implemented in terms of Belos.