48 #include "Thyra_BelosLinearOpWithSolveFactory.hpp" 
   49 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp" 
   51 #include "Thyra_LinearOpTester.hpp" 
   52 #include "Thyra_LinearOpWithSolveBase.hpp" 
   53 #include "Thyra_LinearOpWithSolveTester.hpp" 
   54 #include "Thyra_MultiVectorStdOps.hpp" 
   55 #include "Thyra_VectorStdOps.hpp" 
   56 #include "EpetraExt_readEpetraLinearSystem.h" 
   57 #include "Epetra_SerialComm.h" 
   59 #ifdef HAVE_BELOS_IFPACK 
   65 bool Thyra::test_single_belos_thyra_solver(
 
   66   const std::string                       matrixFile
 
   67   ,
const bool                             testTranspose
 
   68   ,
const bool                             usePreconditioner
 
   70   ,
const int                              numRandomVectors
 
   71   ,
const double                           maxFwdError
 
   72   ,
const double                           maxResid
 
   73   ,
const double                           maxSolutionError
 
   74   ,
const bool                             showAllTests
 
   83   bool result, success = 
true;
 
   93            << 
"\n*** Testing Thyra::BelosLinearOpWithSolveFactory (and Thyra::BelosLinearOpWithSolve)" 
   95            << 
"\nEchoing input options:" 
   96            << 
"\n  matrixFile             = " << matrixFile
 
   97            << 
"\n  testTranspose          = " << testTranspose
 
   98            << 
"\n  usePreconditioner      = " << usePreconditioner
 
   99            << 
"\n  numRhs                 = " << numRhs
 
  100            << 
"\n  numRandomVectors       = " << numRandomVectors
 
  101            << 
"\n  maxFwdError            = " << maxFwdError
 
  102            << 
"\n  maxResid               = " << maxResid
 
  103            << 
"\n  showAllTests           = " << showAllTests
 
  104            << 
"\n  dumpAll                = " << dumpAll
 
  108     if(out.
get()) *out << 
"\nA) Reading in an epetra matrix A from the file \'"<<matrixFile<<
"\' ...\n";
 
  110     Epetra_SerialComm comm;
 
  112     EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A );
 
  118     if(out.
get()) *out << 
"\nB) Creating a BelosLinearOpWithSolveFactory object opFactory ...\n";
 
  124         belosLowsFactory = 
Teuchos::rcp(
new BelosLinearOpWithSolveFactory<double>());
 
  125       lowsFactory = belosLowsFactory;
 
  129       *out << 
"\nlowsFactory.getValidParameters() before setting preconditioner factory:\n";
 
  130       lowsFactory->getValidParameters()->print(
OSTab(out).o(),0,
true,
false);
 
  133     if(usePreconditioner) {
 
  134 #ifdef HAVE_BELOS_IFPACK 
  136         *out << 
"\nSetting an Ifpack preconditioner factory ...\n";
 
  138       RCP<PreconditionerFactoryBase<double> >
 
  139         precFactory = 
Teuchos::rcp(
new IfpackPreconditionerFactory());
 
  141         precFactory->setParameterList(
rcp(precPL,
false));
 
  142       lowsFactory->setPreconditionerFactory(precFactory,
"Ifpack");
 
  149       *out << 
"\nlowsFactory.getValidParameters() after setting preconditioner factory:\n";
 
  150       lowsFactory->getValidParameters()->print(
OSTab(out).o(),0,
true,
false);
 
  151       *out << 
"\nbelosLOWSFPL before setting parameters:\n";
 
  155     lowsFactory->setParameterList(
Teuchos::rcp(belosLOWSFPL,
false));
 
  158       *out << 
"\nbelosLOWSFPL after setting parameters:\n";
 
  162     if(out.
get()) *out << 
"\nC) Creating a BelosLinearOpWithSolve object nsA from A ...\n";
 
  165     Thyra::initializeOp<double>(*lowsFactory,  A, nsA.
ptr());
 
  167     if(out.
get()) *out << 
"\nD) Testing the LinearOpBase interface of nsA ...\n";
 
  169     LinearOpTester<double> linearOpTester;
 
  170     linearOpTester.check_adjoint(testTranspose);
 
  171     linearOpTester.num_rhs(numRhs);
 
  172     linearOpTester.num_random_vectors(numRandomVectors);
 
  173     linearOpTester.set_all_error_tol(maxFwdError);
 
  174     linearOpTester.set_all_warning_tol(1e-2*maxFwdError);
 
  175     linearOpTester.show_all_tests(showAllTests);
 
  176     linearOpTester.dump_all(dumpAll);
 
  177     Thyra::seed_randomize<double>(0);
 
  179     if(!result) success = 
false;
 
  181     if(out.
get()) *out << 
"\nE) Testing the LinearOpWithSolveBase interface of nsA ...\n";
 
  183     LinearOpWithSolveTester<double> linearOpWithSolveTester;
 
  184     linearOpWithSolveTester.num_rhs(numRhs);
 
  185     linearOpWithSolveTester.turn_off_all_tests();
 
  186     linearOpWithSolveTester.check_forward_default(
true);
 
  187     linearOpWithSolveTester.check_forward_residual(
true);
 
  189       linearOpWithSolveTester.check_adjoint_default(
true);
 
  190       linearOpWithSolveTester.check_adjoint_residual(
true);
 
  193       linearOpWithSolveTester.check_adjoint_default(
false);
 
  194       linearOpWithSolveTester.check_adjoint_residual(
false);
 
  196     linearOpWithSolveTester.set_all_solve_tol(maxResid);
 
  197     linearOpWithSolveTester.set_all_slack_error_tol(maxResid);
 
  198     linearOpWithSolveTester.set_all_slack_warning_tol(1e+1*maxResid);
 
  199     linearOpWithSolveTester.forward_default_residual_error_tol(2*maxResid);
 
  200     linearOpWithSolveTester.forward_default_solution_error_error_tol(maxSolutionError);
 
  201     linearOpWithSolveTester.adjoint_default_residual_error_tol(2*maxResid);
 
  202     linearOpWithSolveTester.adjoint_default_solution_error_error_tol(maxSolutionError);
 
  203     linearOpWithSolveTester.show_all_tests(showAllTests);
 
  204     linearOpWithSolveTester.dump_all(dumpAll);
 
  205     Thyra::seed_randomize<double>(0);
 
  206     result = linearOpWithSolveTester.check(*nsA,out.
get());
 
  207     if(!result) success = 
false;
 
  210       *out << 
"\nbelosLOWSFPL after solving:\n";
 
  216     if(out.
get()) *out << 
"\nTest failed since is was not even compiled since SUN_CXX was defined!\n";
 
  222   catch( 
const std::exception &excpt ) {
 
  223     if(out.
get()) *out << std::flush;
 
  224     std::cerr << 
"*** Caught standard exception : " << excpt.what() << std::endl;
 
basic_OSTab< char > OSTab
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)