63 template<
class ScalarType,
class FactoryType,
class SolverBaseType,
class SolverImplType>
69 using Teuchos::parameterList;
72 using Teuchos::rcp_dynamic_cast;
75 typedef ScalarType ST;
76 typedef SolverBaseType solver_base_type;
77 typedef SolverImplType solver_impl_type;
78 typedef FactoryType factory_type;
81 const bool testOutputFreq =
false;
84 out <<
"Test Belos::SolverFactory::create for solver \"" << solverName <<
"\"" << endl;
87 out <<
"ScalarType: " << TypeNameTraits<ScalarType>::name () << endl
88 <<
"FactoryType: " << TypeNameTraits<FactoryType>::name () << endl
89 <<
"SolverBaseType: " << TypeNameTraits<SolverBaseType>::name () << endl
90 <<
"SolverImplType: " << TypeNameTraits<SolverImplType>::name () << endl;
93 RCP<solver_base_type> solver;
95 out <<
"Test whether factory works when input ParameterList is null" << endl;
98 TEST_NOTHROW( solver = factory.create (solverName, Teuchos::null) );
100 if (! solver.is_null ()) {
102 RCP<solver_impl_type> solverImpl = rcp_dynamic_cast<solver_impl_type> (solver);
106 out <<
"Test whether factory works when input ParameterList is nonnull" << endl;
110 RCP<ParameterList> plist = parameterList (
"Belos");
112 const int maxNumIters = 42;
115 const int outputFreq = 3;
118 plist->set (
"Convergence Tolerance",
tol);
119 plist->set (
"Maximum Iterations", maxNumIters);
120 plist->set (
"Verbosity", verbosity);
121 plist->set (
"Output Style", outputStyle);
122 if (testOutputFreq) {
123 plist->set (
"Output Frequency", outputFreq);
125 TEST_ASSERT( ! plist->getEntry (
"Convergence Tolerance").isUsed () );
126 TEST_ASSERT( ! plist->getEntry (
"Maximum Iterations").isUsed () );
127 TEST_ASSERT( ! plist->getEntry (
"Verbosity").isUsed () );
128 TEST_ASSERT( ! plist->getEntry (
"Output Style").isUsed () );
129 if (testOutputFreq) {
130 TEST_ASSERT( ! plist->getEntry (
"Output Frequency").isUsed () );
133 out <<
"Input ParameterList: " << endl;
140 solver = factory.create (solverName, plist);
142 if (! solver.is_null ()) {
144 RCP<solver_impl_type> solverImpl = rcp_dynamic_cast<solver_impl_type> (solver);
148 TEST_ASSERT( plist->getEntry (
"Convergence Tolerance").isUsed () );
149 TEST_ASSERT( plist->getEntry (
"Maximum Iterations").isUsed () );
150 TEST_ASSERT( plist->getEntry (
"Verbosity").isUsed () );
151 TEST_ASSERT( plist->getEntry (
"Output Style").isUsed () );
152 if (testOutputFreq) {
153 TEST_ASSERT( plist->getEntry (
"Output Frequency").isUsed () );
157 RCP<const ParameterList> curParams = solver->getCurrentParameters ();
159 if (! curParams.is_null ()) {
162 TEST_NOTHROW( curTol = curParams->get<MT> (
"Convergence Tolerance") );
164 int curMaxNumIters = 0;
165 TEST_NOTHROW( curMaxNumIters = curParams->get<
int> (
"Maximum Iterations") );
167 int curVerbosity = 0;
168 TEST_NOTHROW( curVerbosity = curParams->get<
int> (
"Verbosity") );
170 int curOutputStyle = 0;
171 TEST_NOTHROW( curOutputStyle = curParams->get<
int> (
"Output Style") );
173 if (testOutputFreq) {
174 int curOutputFreq = 0;
175 TEST_NOTHROW( curOutputFreq = curParams->get<
int> (
"Output Frequency") );
193 #define BELOS_TEST_SOLVER( SOLVER_NAME ) \ 195 const std::string solverName (SOLVER_NAME); \ 197 bool curSuccess = true; \ 198 testSolver<ST, factory_type, solver_base_type, solver_impl_type> (curSuccess, out, solverName); \ 199 if (! curSuccess) { \ 200 failedSolvers.push_back (solverName); \ 202 success = success && curSuccess; \ 203 } catch (std::exception& e) { \ 204 out << "*** Solver \"" << solverName << "\" threw an exception: " \ 205 << e.what () << std::endl; \ 224 out <<
"Test for Bug 6383" << endl;
228 std::vector<std::string> failedSolvers;
300 out << endl <<
"*** Solvers that failed: ";
302 for (
size_t k = 0; k < failedSolvers.size (); ++k) {
303 out <<
"\"" << failedSolvers[k] <<
"\"";
304 if (k + 1 < failedSolvers.size ()) {
#define TEST_NOTHROW(code)
The Belos::FixedPointSolMgr provides a powerful and fully-featured solver manager over the FixedPoint...
The Belos::PseudoBlockCGSolMgr provides a solver manager for the BlockCG linear solver.
Implementation of the RCG (Recycling Conjugate Gradient) iterative linear solver. ...
The Belos::BlockCGSolMgr provides a powerful and fully-featured solver manager over the CG and BlockC...
The Belos::FixedPointSolMgr provides a solver manager for the FixedPoint linear solver.
Declaration and definition of Belos::PCPGSolMgr (PCPG iterative linear solver).
Interface to Block GMRES and Flexible GMRES.
#define BELOS_TEST_SOLVER(SOLVER_NAME)
TEUCHOS_UNIT_TEST(Factory, Bug6383)
The Belos::PseudoBlockCGSolMgr provides a powerful and fully-featured solver manager over the pseudo-...
Declaration and definition of Belos::GCRODRSolMgr, which implements the GCRODR (recycling GMRES) solv...
Alternative run-time polymorphic interface for operators.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
The Belos::BlockGmresSolMgr provides a solver manager for the BlockGmres linear solver.
The Belos::BiCGStabSolMgr provides a solver manager for the BiCGStab linear solver.
Class which describes the linear problem to be solved by the iterative solver.
void testSolver(bool &success, Teuchos::FancyOStream &out, const std::string &solverName)
Implementation of the GCRODR (Recycling GMRES) iterative linear solver.
Interface to standard and "pseudoblock" GMRES.
The Belos::SolverManager is a templated virtual base class that defines the basic interface that any ...
The Belos::BlockCGSolMgr provides a solver manager for the BlockCG linear solver. ...
LSQRSolMgr: interface to the LSQR method.
The Belos::BiCGStabSolMgr provides a powerful and fully-featured solver manager over the pseudo-block...
TEST_ASSERT(castedDep1->getValuesAndValidators().size()==2)
PCPG iterative linear solver.
Interface for multivectors used by Belos' linear solvers.
LSQR method (for linear systems and linear least-squares problems).
The Belos::RCGSolMgr provides a solver manager for the RCG (Recycling Conjugate Gradient) linear solv...
The Belos::PseudoBlockGmresSolMgr provides a solver manager for the BlockGmres linear solver...
TEST_EQUALITY(rcp_dynamic_cast< const EnhancedNumberValidator< double > >(castedDep1->getValuesAndValidators().find("val1") ->second, true) ->getMax(), double1Vali->getMax())
Factory for all solvers which Belos supports.