00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "test_single_stratimikos_solver.hpp"
00030 #include "Thyra_DefaultRealLinearSolverBuilder.hpp"
00031 #include "Thyra_EpetraLinearOp.hpp"
00032 #include "Thyra_LinearOpWithSolveFactoryExamples.hpp"
00033 #include "EpetraExt_readEpetraLinearSystem.h"
00034 #include "Teuchos_ParameterList.hpp"
00035
00036 #ifdef HAVE_MPI
00037 # include "Epetra_MpiComm.h"
00038 #else
00039 # include "Epetra_SerialComm.h"
00040 #endif
00041
00042 bool Thyra::test_single_stratimikos_solver(
00043 Teuchos::ParameterList *paramList_inout
00044 ,const bool dumpAll
00045 ,Teuchos::FancyOStream *out
00046 )
00047 {
00048
00049 using Teuchos::rcp;
00050 using Teuchos::RefCountPtr;
00051 using Teuchos::OSTab;
00052 using Teuchos::ParameterList;
00053 using Teuchos::getParameter;
00054 bool success = true;
00055
00056 try {
00057
00058 TEST_FOR_EXCEPT(!paramList_inout);
00059
00060 RefCountPtr<ParameterList>
00061 paramList = rcp(paramList_inout,false);
00062
00063 if(out) {
00064 *out << "\nEchoing input parameters ...\n";
00065 paramList->print(*out,1,true,false);
00066 }
00067
00068
00069 Teuchos::ParameterList validParamList("test_single_stratimikos_solver");
00070 validParamList.set("Matrix File","fileName");
00071 validParamList.sublist("Linear Solver Builder");
00072 validParamList.sublist("LinearOpTester");
00073 validParamList.sublist("LinearOpWithSolveTester");
00074
00075 if(out) *out << "\nValidating top-level input parameters ...\n";
00076 paramList->validateParameters(validParamList,0);
00077
00078 const std::string
00079 &matrixFile = getParameter<std::string>(*paramList,"Matrix File");
00080 RefCountPtr<ParameterList>
00081 solverBuilderSL = sublist(paramList,"Linear Solver Builder",true),
00082 loTesterSL = sublist(paramList,"LinearOpTester",true),
00083 lowsTesterSL = sublist(paramList,"LinearOpWithSolveTester",true);
00084
00085 if(out) *out << "\nReading in an epetra matrix A from the file \'"<<matrixFile<<"\' ...\n";
00086
00087 #ifdef HAVE_MPI
00088 Epetra_MpiComm comm(MPI_COMM_WORLD);
00089 #else
00090 Epetra_SerialComm comm;
00091 #endif
00092 Teuchos::RefCountPtr<Epetra_CrsMatrix> epetra_A;
00093 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A );
00094
00095 Teuchos::RefCountPtr<LinearOpBase<double> >
00096 A = Teuchos::rcp(new EpetraLinearOp(epetra_A));
00097
00098 if(out) *out << "\nCreating a Thyra::DefaultRealLinearSolverBuilder object ...\n";
00099
00100 RefCountPtr<Thyra::LinearSolverBuilderBase<double> >
00101 linearSolverBuilder = rcp(new Thyra::DefaultRealLinearSolverBuilder);
00102
00103 if(out) {
00104 *out << "\nValid parameters for DefaultRealLinearSolverBuilder ...\n";
00105 linearSolverBuilder->getValidParameters()->print(*out,1,true,false);
00106 }
00107
00108 linearSolverBuilder->setParameterList(solverBuilderSL);
00109
00110 if(out) *out << "\nCreating the LinearOpWithSolveFactoryBase object lowsFactory ...\n";
00111 RefCountPtr<LinearOpWithSolveFactoryBase<double> >
00112 lowsFactory = linearSolverBuilder->createLinearSolveStrategy();
00113 if(out) *out << "\nlowsFactory described as:\n" << describe(*lowsFactory,Teuchos::VERB_MEDIUM) << std::endl;
00114
00115 if(out) *out << "\nRunning example use cases ...\n";
00116
00117 nonExternallyPreconditionedLinearSolveUseCases(
00118 *A,*lowsFactory,false,*out
00119 );
00120
00121
00122
00123 if(out) {
00124 *out << "\nPrinting the parameter list (showing what was used) ...\n";
00125 paramList->print(*out,1,true,true);
00126 }
00127
00128 }
00129 catch( const std::exception &excpt ) {
00130 std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl;
00131 success = false;
00132 }
00133
00134 return success;
00135
00136 }