Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
test_single_aztecoo_thyra_solver_driver.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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #include "test_single_aztecoo_thyra_solver.hpp"
00043 #include "Teuchos_GlobalMPISession.hpp"
00044 #include "Teuchos_CommandLineProcessor.hpp"
00045 #include "Teuchos_ParameterList.hpp"
00046 
00047 int main(int argc, char* argv[])
00048 {
00049 
00050   Teuchos::GlobalMPISession mpiSession(&argc,&argv);
00051   
00052   using Teuchos::CommandLineProcessor;
00053 
00054   bool success = true;
00055   bool verbose = true;
00056 
00057   Teuchos::FancyOStream out(Teuchos::rcp(&std::cout,false));
00058 
00059   try {
00060 
00061     //
00062     // Read options from command-line
00063     //
00064     
00065     std::string     matrixFile             = "";
00066     bool            testTranspose          = true;
00067     int             numRandomVectors       = 1;
00068     double          maxFwdError            = 1e-14;
00069     int             maxIterations          = 400;
00070     double          maxResid               = 1e-6;
00071     double          maxSolutionError       = 1e-6;
00072     bool            showAllTests           = false;
00073     bool            dumpAll                = false;
00074     std::string     aztecOutputLevel       = "freq";
00075     int             aztecOutputFreq        = 0;
00076     std::string     aztecPrec              = "none";
00077     std::string     aztecSubdomainSolve    = "ilu";
00078 
00079     CommandLineProcessor  clp(false); // Don't throw exceptions
00080     clp.setOption( "matrix-file", &matrixFile, "Matrix input file [Required]." );
00081     clp.setOption( "test-transpose", "no-test-transpose", &testTranspose, "Test the transpose solve or not." );
00082     clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." );
00083     clp.setOption( "max-fwd-error", &maxFwdError, "The maximum relative error in the forward operator." );
00084     clp.setOption( "max-iters", &maxIterations, "The maximum number of linear solver iterations to take." );
00085     clp.setOption( "max-resid", &maxResid, "The maximum relative error in the residual." );
00086     clp.setOption( "max-solution-error", &maxSolutionError, "The maximum relative error in the solution of the linear system." );
00087     clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." );
00088     clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." );
00089     clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." );
00090     clp.setOption( "aztec-output-level", &aztecOutputLevel, "Aztec output level (freq,last,summary,warnings,all)" );
00091     clp.setOption( "aztec-output-freq", &aztecOutputFreq, "Aztec output freqency (> 0)" );
00092     clp.setOption( "aztec-prec", &aztecPrec, "Type of aztec preconditioner (none,sym_GS,Neumann,Jacobi,ls,dom_decomp)" );
00093     clp.setOption( "aztec-subdomain-solve", &aztecSubdomainSolve, "Type of subdomain solve for --aztec-prec==dom_decomp only (ilu,ilut)" );
00094     CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
00095     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
00096 
00097     TEUCHOS_TEST_FOR_EXCEPT( matrixFile == "" );
00098 
00099     Teuchos::ParameterList
00100       paramList("AztecOOLinearOpWithSolve");
00101     Teuchos::ParameterList
00102       &fwdSolveParamList = paramList.sublist("Forward Solve"),
00103       &adjSolveParamList = paramList.sublist("Adjoint Solve");
00104     fwdSolveParamList.set("Max Iterations",maxIterations);
00105     adjSolveParamList.set("Max Iterations",maxIterations);
00106 /*
00107     Teuchos::ParameterList
00108       &fwdAztecOOParamList = fwdSolveParamList.sublist("AztecOO"),
00109       &adjAztecOOParamList = fwdSolveParamList.sublist("AztecOO");
00110     if( aztecOutputLevel != "freq" ) {
00111       fwdAztecOOParamList.set("Output Frequency",aztecOutputLevel);
00112       adjAztecOOParamList.set("Output Frequency",aztecOutputLevel);
00113     }
00114     else {
00115       fwdAztecOOParamList.set("Output Frequency",aztecOutputFreq);
00116       adjAztecOOParamList.set("Output Frequency",aztecOutputFreq);
00117     }
00118     if( aztecPrec != "none" ) {
00119       fwdAztecOOParamList.set("Aztec Preconditioner",aztecPrec);
00120       adjAztecOOParamList.set("Aztec Preconditioner",aztecPrec);
00121       if(aztecPrec=="dom_decomp") {
00122         fwdAztecOOParamList.set("AZ_subdomain_solve",aztecSubdomainSolve);
00123         adjAztecOOParamList.set("AZ_subdomain_solve",aztecSubdomainSolve);
00124       }
00125     }
00126 */
00127     
00128     success
00129       = Thyra::test_single_aztecoo_thyra_solver(
00130         matrixFile,testTranspose,numRandomVectors
00131         ,maxFwdError,maxResid,maxSolutionError,showAllTests,dumpAll
00132         ,&paramList
00133         ,verbose?&out:0
00134         );
00135 
00136   }
00137   catch( const std::exception &excpt ) {
00138     std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl;
00139     success = false;
00140   }
00141   catch( ... ) {
00142     std::cerr << "*** Caught an unknown exception\n";
00143     success = false;
00144   }
00145   
00146   if (verbose) {
00147     if(success)  out << "\nCongratulations! All of the tests checked out!\n";
00148     else         out << "\nOh no! At least one of the tests failed!\n";
00149   }
00150 
00151   return ( success ? 0 : 1 );
00152 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines