test_single_stratimikos_solver.cpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //         Stratimikos: Thyra-based strategies for linear solvers
00005 //                Copyright (2006) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
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     // Create list of valid parameter sublists
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     // ToDo: Finish tests!
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 }

Generated on Thu Sep 18 12:37:35 2008 for Stratimikos Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1