Stratimikos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
test_single_amesos_thyra_solver_driver.cpp
Go to the documentation of this file.
1/*
2// @HEADER
3// ***********************************************************************
4//
5// Stratimikos: Thyra-based strategies for linear solvers
6// Copyright (2006) Sandia Corporation
7//
8// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9// license for use of this work by or on behalf of the U.S. Government.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39//
40// ***********************************************************************
41// @HEADER
42*/
43
45#include "Teuchos_CommandLineProcessor.hpp"
46#include "Teuchos_VerboseObject.hpp"
47#include "Epetra_ConfigDefs.h"
48#ifdef EPETRA_MPI
49#include <mpi.h>
50#endif
51
52int main(int argc, char* argv[])
53{
54
55#ifdef EPETRA_MPI
56 MPI_Init(&argc, &argv);
57#endif
58
59 using Teuchos::CommandLineProcessor;
60
61 bool success = true;
62 bool verbose = true;
63
64 Teuchos::RCP<Teuchos::FancyOStream>
65 out = Teuchos::VerboseObjectBase::getDefaultOStream();
66
67 try {
68
69 //
70 // Read options from command-line
71 //
72
73 std::string matrixFile = "";
75#ifdef HAVE_AMESOS_KLU
76 = Thyra::Amesos::KLU;
77#else
79#endif
81 bool testTranspose = true;
82 int numRandomVectors = 1;
83 double maxFwdError = 1e-14;
84 double maxError = 1e-10;
85 double maxResid = 1e-10;
86 bool showAllTests = false;
87 bool dumpAll = false;
88
89 CommandLineProcessor clp;
90 clp.throwExceptions(false);
91 clp.addOutputSetupOptions(true);
92 clp.setOption( "matrix-file", &matrixFile, "Matrix iput file [Required]." );
93 clp.setOption(
94 "solver-type", &solverType
96 ,"Type of direct solver."
97 );
98 clp.setOption(
99 "refactorization-policy", &refactorizationPolicy
101 ,"Pivoting policy used on refactorizations."
102 );
103 clp.setOption( "test-transpose", "no-test-transpose", &testTranspose, "Test the transpose solve or not." );
104 clp.setOption( "num-random-vectors", &numRandomVectors, "Number of times a test is performed with different random vectors." );
105 clp.setOption( "max-fwd-error", &maxFwdError, "The maximum relative error in the forward operator." );
106 clp.setOption( "max-error", &maxError, "The maximum relative error in the solution." );
107 clp.setOption( "max-resid", &maxResid, "The maximum relative error in the residual." );
108 clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." );
109 clp.setOption( "show-all-tests", "no-show-all-tests", &showAllTests, "Set if all the tests are shown or not." );
110 clp.setOption( "dump-all", "no-dump-all", &dumpAll, "Determines if vectors are printed or not." );
111 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
112 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
113
114 TEUCHOS_TEST_FOR_EXCEPT( matrixFile == "" );
115
116 Teuchos::ParameterList amesosLOWSFPL;
117 amesosLOWSFPL.set("Solver Type",toString(solverType));
118 amesosLOWSFPL.set("Refactorization Policy",toString(refactorizationPolicy));
119
120 success
122 matrixFile,&amesosLOWSFPL,testTranspose,numRandomVectors
123 ,maxFwdError,maxError,maxResid,showAllTests,dumpAll,verbose?&*out:0
124 );
125
126 }
127 catch( const std::exception &excpt ) {
128 std::cerr << "*** Caught standard exception : " << excpt.what() << std::endl;
129 success = false;
130 }
131 catch( ... ) {
132 std::cerr << "*** Caught an unknown exception\n";
133 success = false;
134 }
135
136 if (verbose) {
137 if(success) *out << "\nCongratulations! All of the tests checked out!\n";
138 else *out << "\nOh no! At least one of the tests failed!\n";
139 }
140
141#ifdef EPETRA_MPI
142 MPI_Finalize();
143#endif
144
145 return ( success ? 0 : 1 );
146}
const ESolverType solverTypeValues[numSolverTypes]
const ERefactorizationPolicy refactorizationPolicyValues[numRefactorizationPolices]
ERefactorizationPolicy
The policy used on refactoring a matrix.
const char * solverTypeNames[numSolverTypes]
const int numRefactorizationPolices
@ REPIVOT_ON_REFACTORIZATION
Completely new pivoting will be used on refactorizations!
const char * refactorizationPolicyNames[numRefactorizationPolices]
bool test_single_amesos_thyra_solver(const std::string matrixFile, Teuchos::ParameterList *amesosLOWSFPL, const bool testTranspose, const int numRandomVectors, const double maxFwdError, const double maxError, const double maxResid, const bool showAllTests, const bool dumpAll, Teuchos::FancyOStream *out)
Testing function for a single amesos solver with a single matrix.
int main(int argc, char *argv[])