Skip to content

Commit

Permalink
Merge pull request #10698 from hkthorn/develop
Browse files Browse the repository at this point in the history
Belos: Removes unused Failure classes inheriting from Belos::Error
  • Loading branch information
hkthorn authored Jul 5, 2022
2 parents 0f5071f + 7aab16e commit a065479
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 251 deletions.
31 changes: 0 additions & 31 deletions packages/belos/src/BelosFixedPointIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,6 @@ namespace Belos {
{}
};

//! @name FixedPointIteration Exceptions
//@{

/** \brief FixedPointIterationInitFailure is thrown when the FixedPointIteration object is unable to
* generate an initial iterate in the FixedPointIteration::initialize() routine.
*
* This std::exception is thrown from the FixedPointIteration::initialize() method, which is
* called by the user or from the FixedPointIteration::iterate() method if isInitialized()
* == \c false.
*
* In the case that this std::exception is thrown,
* FixedPointIteration::isInitialized() will be \c false and the user will need to provide
* a new initial iterate to the iteration.
*/
class FixedPointIterationInitFailure : public BelosError {public:
FixedPointIterationInitFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief FixedPointIterateFailure is thrown when the FixedPointIteration object is unable to
* compute the next iterate in the FixedPointIteration::iterate() routine.
*
* This std::exception is thrown from the FixedPointIteration::iterate() method.
*
*/
class FixedPointIterateFailure : public BelosError {public:
FixedPointIterateFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

//@}


template<class ScalarType, class MV, class OP>
class FixedPointIteration : virtual public Iteration<ScalarType,MV,OP> {

Expand Down
15 changes: 0 additions & 15 deletions packages/belos/src/BelosLSQRIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,6 @@ namespace Belos {
//! @name LSQRIteration Exceptions
//@{

/** \brief LSQRIterationInitFailure is thrown when the LSQRIteration object is
* unable to generate an initial iterate in the initialize() routine.
*
* This std::exception is thrown from the initialize() method, which is
* called by the user or from the iterate() method if isInitialized()
* == \c false.
*
* In the case that this std::exception is thrown,
* isInitialized() will be \c false and the user will need to provide
* a new initial iterate to the iteration.
*/
class LSQRIterationInitFailure : public BelosError {public:
LSQRIterationInitFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief LSQRIterateFailure is thrown when the LSQRIteration object is unable to
* compute the next iterate in the iterate() routine.
*
Expand Down
15 changes: 0 additions & 15 deletions packages/belos/src/BelosMinresIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,6 @@ namespace Belos {
//! @name MinresIteration Exceptions
//@{

/** \brief MinresIterationInitFailure is thrown when the MinresIteration object is unable to
* generate an initial iterate in the MinresIteration::initialize() routine.
*
* This std::exception is thrown from the MinresIteration::initialize() method, which is
* called by the user or from the MinresIteration::iterate() method if isInitialized()
* == \c false.
*
* In the case that this std::exception is thrown,
* MinresIteration::isInitialized() will be \c false and the user will need to provide
* a new initial iterate to the iteration.
*/
class MinresIterationInitFailure : public BelosError {public:
MinresIterationInitFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief MinresIterateFailure is thrown when the MinresIteration object is unable to
* compute the next iterate in the MinresIteration::iterate() routine.
*
Expand Down
53 changes: 9 additions & 44 deletions packages/belos/src/BelosPCPGIter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "BelosStatusTest.hpp"
#include "BelosOperatorTraits.hpp"
#include "BelosMultiVecTraits.hpp"
#include "BelosCGIteration.hpp"

#include "Teuchos_SerialDenseMatrix.hpp"
#include "Teuchos_SerialDenseVector.hpp"
Expand Down Expand Up @@ -128,42 +129,6 @@ namespace Belos {

//@}

//! @name PCPGIter Exceptions
//@{

/** \brief PCPGIterInitFailure is thrown when the PCPGIter object is unable to
* generate an initial iterate in the PCPGIter::initialize() routine.
*
* This std::exception is thrown from the PCPGIter::initialize() method, which is
* called by the user or from the PCPGIter::iterate() method if isInitialized()
* == \c false.
*
* In the case that this std::exception is thrown,
* PCPGIter::isInitialized() will be \c false and the user will need to provide
* a new initial iterate to the iteration.
*/
class PCPGIterInitFailure : public BelosError {public:
PCPGIterInitFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief PCPGIterateFailure is thrown when the PCPGIter object breaks down.
* The std::exception is thrown from the PCPGIter::iterate() method, and
* is due to a coefficient matrix that is not positive definite.
*/
class PCPGIterateFailure : public BelosError {public:
PCPGIterateFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief PCPGIterOrthoFailure is thrown when the PCPGIter object is unable to
* compute independent direction vectors in the PCPGIter::iterate() routine.
*
* This std::exception is thrown from the PCPGIter::iterate() method.
*
*/
class PCPGIterOrthoFailure : public BelosError {public:
PCPGIterOrthoFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

template<class ScalarType, class MV, class OP>
class PCPGIter : virtual public Iteration<ScalarType,MV,OP> {

Expand Down Expand Up @@ -695,12 +660,12 @@ namespace Belos {
Teuchos::RCP<MV> cur_soln_vec = lp_->getCurrLHSVec();

// Check that the current solution std::vector only has one column.
TEUCHOS_TEST_FOR_EXCEPTION( MVT::GetNumberVecs(*cur_soln_vec) != 1, PCPGIterInitFailure,
"Belos::CGIter::iterate(): current linear system has more than one std::vector!" );
TEUCHOS_TEST_FOR_EXCEPTION( MVT::GetNumberVecs(*cur_soln_vec) != 1, CGIterationInitFailure,
"Belos::PCPGIter::iterate(): current linear system has more than one std::vector!" );

//Check that the input is correctly set up
TEUCHOS_TEST_FOR_EXCEPTION( curDim_ != prevUdim_ + 1, PCPGIterInitFailure,
"Belos::CGIter::iterate(): mistake in initialization !" );
TEUCHOS_TEST_FOR_EXCEPTION( curDim_ != prevUdim_ + 1, CGIterationInitFailure,
"Belos::PCPGIter::iterate(): mistake in initialization !" );


const ScalarType zero = Teuchos::ScalarTraits<ScalarType>::zero();
Expand Down Expand Up @@ -765,15 +730,15 @@ namespace Belos {
(*D_)(iter_ -1 ,iter_ -1 ) = pAp(0,0);

// positive pAp required
TEUCHOS_TEST_FOR_EXCEPTION( pAp(0,0) <= zero, PCPGIterateFailure,
"Belos::CGIter::iterate(): non-positive value for p^H*A*p encountered!" );
TEUCHOS_TEST_FOR_EXCEPTION( pAp(0,0) <= zero, CGPositiveDefiniteFailure,
"Belos::PCPGIter::iterate(): non-positive value for p^H*A*p encountered!" );

// alpha := <R_,Z_> / <P,AP>
alpha(0,0) = rHz(0,0) / pAp(0,0);

// positive alpha required
TEUCHOS_TEST_FOR_EXCEPTION( alpha(0,0) <= zero, PCPGIterateFailure,
"Belos::CGIter::iterate(): non-positive value for alpha encountered!" );
TEUCHOS_TEST_FOR_EXCEPTION( alpha(0,0) <= zero, CGPositiveDefiniteFailure,
"Belos::PCPGIter::iterate(): non-positive value for alpha encountered!" );

// solution update x += alpha * P
if( curDim_ < savedBlocks_ ){
Expand Down
18 changes: 0 additions & 18 deletions packages/belos/src/BelosPCPGSolMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,6 @@ namespace Belos {
PCPGSolMgrLAPACKFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief PCPGSolMgrRecyclingFailure is thrown when any problem occurs in using/creating
* the recycling subspace.
*
* The PCPGSolMgr::solve() method throws the exception.
*
*/
class PCPGSolMgrRecyclingFailure : public BelosError {public:
PCPGSolMgrRecyclingFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

//@}


Expand Down Expand Up @@ -902,14 +892,6 @@ ReturnType PCPGSolMgr<ScalarType,MV,OP,true>::solve() {
"Belos::PCPGSolMgr::solve(): Invalid return from PCPGIter::iterate().");
} // end if
} // end try
catch (const PCPGIterOrthoFailure &e) {

// Check to see if the most recent solution yielded convergence.
sTest_->checkStatus( &*pcpg_iter );
if (convTest_->getStatus() != Passed)
isConverged = false;
break;
}
catch (const std::exception &e) {
printer_->stream(Errors) << "Error! Caught exception in PCPGIter::iterate() at iteration "
<< pcpg_iter->getNumIters() << std::endl
Expand Down
10 changes: 0 additions & 10 deletions packages/belos/src/BelosPseudoBlockCGSolMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ namespace Belos {
PseudoBlockCGSolMgrLinearProblemFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief PseudoBlockCGSolMgrOrthoFailure is thrown when the orthogonalization manager is
* unable to generate orthonormal columns from the initial basis vectors.
*
* This std::exception is thrown from the PseudoBlockCGSolMgr::solve() method.
*
*/
class PseudoBlockCGSolMgrOrthoFailure : public BelosError {public:
PseudoBlockCGSolMgrOrthoFailure(const std::string& what_arg) : BelosError(what_arg)
{}};


// Partial specialization for unsupported ScalarType types.
// This contains a stub implementation.
Expand Down
16 changes: 0 additions & 16 deletions packages/belos/src/BelosPseudoBlockGmresIter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,6 @@ namespace Belos {
//! @name PseudoBlockGmresIter Exceptions
//@{

/** \brief PseudoBlockGmresIterInitFailure is thrown when the PseudoBlockGmresIter object is unable to
* generate an initial iterate in the PseudoBlockGmresIter::initialize() routine.
*
* This std::exception is thrown from the PseudoBlockGmresIter::initialize() method, which is
* called by the user or from the PseudoBlockGmresIter::iterate() method if isInitialized()
* == \c false.
*
* In the case that this std::exception is thrown,
* PseudoBlockGmresIter::isInitialized() will be \c false and the user will need to provide
* a new initial iterate to the iteration.
*
*/
class PseudoBlockGmresIterInitFailure : public BelosError {public:
PseudoBlockGmresIterInitFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief PseudoBlockGmresIterOrthoFailure is thrown when the orthogonalization manager is
* unable to generate orthonormal columns from the new basis vectors.
*
Expand Down
32 changes: 0 additions & 32 deletions packages/belos/src/BelosPseudoBlockTFQMRIter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,38 +110,6 @@ namespace Belos {
{}
};


//! @name PseudoBlockTFQMRIter Exceptions
//@{

/** \brief PseudoBlockTFQMRIterInitFailure is thrown when the PseudoBlockTFQMRIter object is unable to
* generate an initial iterate in the PseudoBlockTFQMRIter::initialize() routine.
*
* This std::exception is thrown from the PseudoBlockTFQMRIter::initialize() method, which is
* called by the user or from the PseudoBlockTFQMRIter::iterate() method if isInitialized()
* == \c false.
*
* In the case that this std::exception is thrown,
* PseudoBlockTFQMRIter::isInitialized() will be \c false and the user will need to provide
* a new initial iterate to the iteration.
*/
class PseudoBlockTFQMRIterInitFailure : public BelosError {public:
PseudoBlockTFQMRIterInitFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief PseudoBlockTFQMRIterateFailure is thrown when the PseudoBlockTFQMRIter object is unable to
* compute the next iterate in the PseudoBlockTFQMRIter::iterate() routine.
*
* This std::exception is thrown from the PseudoBlockTFQMRIter::iterate() method.
*
*/
class PseudoBlockTFQMRIterateFailure : public BelosError {public:
PseudoBlockTFQMRIterateFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

//@}


template <class ScalarType, class MV, class OP>
class PseudoBlockTFQMRIter : public Iteration<ScalarType,MV,OP> {
public:
Expand Down
51 changes: 6 additions & 45 deletions packages/belos/src/BelosRCGIter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "BelosStatusTest.hpp"
#include "BelosOperatorTraits.hpp"
#include "BelosMultiVecTraits.hpp"
#include "BelosCGIteration.hpp"

#include "Teuchos_LAPACK.hpp"
#include "Teuchos_SerialDenseMatrix.hpp"
Expand Down Expand Up @@ -140,47 +141,6 @@ namespace Belos {

//@}

//! @name RCGIter Exceptions
//@{

/** \brief RCGIterInitFailure is thrown when the RCGIter object is unable to
* generate an initial iterate in the RCGIter::initialize() routine.
*
* This std::exception is thrown from the RCGIter::initialize() method, which is
* called by the user or from the RCGIter::iterate() method if isInitialized()
* == \c false.
*
* In the case that this std::exception is thrown,
* RCGIter::isInitialized() will be \c false and the user will need to provide
* a new initial iterate to the iteration.
*/
class RCGIterInitFailure : public BelosError {public:
RCGIterInitFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief RCGIterFailure is thrown when the RCGIter object is unable to
* compute the next iterate in the RCGIter::iterate() routine.
*
* This std::exception is thrown from the RCGIter::iterate() method.
*
*/
class RCGIterFailure : public BelosError {public:
RCGIterFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief RCGIterLAPACKFailure is thrown when a nonzero return value is passed back
* from an LAPACK routine.
*
* This std::exception is thrown from the RCGIter::iterate() method.
*
*/
class RCGIterLAPACKFailure : public BelosError {public:
RCGIterLAPACKFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

//@}


template<class ScalarType, class MV, class OP>
class RCGIter : virtual public Iteration<ScalarType,MV,OP> {

Expand Down Expand Up @@ -529,7 +489,7 @@ namespace Belos {
template <class ScalarType, class MV, class OP>
void RCGIter<ScalarType,MV,OP>::iterate()
{
TEUCHOS_TEST_FOR_EXCEPTION( initialized_ == false, RCGIterFailure,
TEUCHOS_TEST_FOR_EXCEPTION( initialized_ == false, CGIterateFailure,
"Belos::RCGIter::iterate(): RCGIter class not initialized." );

// We'll need LAPACK
Expand All @@ -547,7 +507,7 @@ namespace Belos {
Teuchos::RCP<MV> cur_soln_vec = lp_->getCurrLHSVec();

// Check that the current solution std::vector only has one column.
TEUCHOS_TEST_FOR_EXCEPTION( MVT::GetNumberVecs(*cur_soln_vec) != 1, RCGIterFailure,
TEUCHOS_TEST_FOR_EXCEPTION( MVT::GetNumberVecs(*cur_soln_vec) != 1, CGIterateFailure,
"Belos::RCGIter::iterate(): current linear system has more than one std::vector!" );

// Compute the current search dimension.
Expand Down Expand Up @@ -579,7 +539,8 @@ namespace Belos {
(*Alpha_)(i_,0) = (*rTz_old_)(0,0) / pAp(0,0);

// Check that alpha is a positive number
TEUCHOS_TEST_FOR_EXCEPTION( SCT::real(pAp(0,0)) <= zero, RCGIterFailure, "Belos::RCGIter::iterate(): non-positive value for p^H*A*p encountered!" );
TEUCHOS_TEST_FOR_EXCEPTION( SCT::real(pAp(0,0)) <= zero, CGPositiveDefiniteFailure,
"Belos::RCGIter::iterate(): non-positive value for p^H*A*p encountered!" );

// x = x + (alpha * p);
MVT::MvAddMv( one, *cur_soln_vec, (*Alpha_)(i_,0), *p_, *cur_soln_vec );
Expand Down Expand Up @@ -624,7 +585,7 @@ namespace Belos {
char TRANS = 'N';
int info;
lapack.GETRS( TRANS, recycleBlocks_, 1, LUUTAU_->values(), LUUTAU_->stride(), &(*ipiv_)[0], mu.values(), mu.stride(), &info );
TEUCHOS_TEST_FOR_EXCEPTION(info != 0, RCGIterLAPACKFailure,
TEUCHOS_TEST_FOR_EXCEPTION(info != 0, CGIterationLAPACKFailure,
"Belos::RCGIter::solve(): LAPACK GETRS failed to compute a solution.");
// p = -(U*mu) + (beta*p) + z (in two steps)
// p = (beta*p) + z;
Expand Down
10 changes: 0 additions & 10 deletions packages/belos/src/BelosRCGSolMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ namespace Belos {
RCGSolMgrLAPACKFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

/** \brief RCGSolMgrRecyclingFailure is thrown when any problem occurs in using/creating
* the recycling subspace.
*
* This exception is thrown from the RCGSolMgr::solve() method.
*
*/
class RCGSolMgrRecyclingFailure : public BelosError {public:
RCGSolMgrRecyclingFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

//@}


Expand Down
Loading

0 comments on commit a065479

Please sign in to comment.