Public Types | Public Member Functions | Protected Member Functions | Private Attributes
NOX::StatusTest::SafeCombo Class Reference

Arbitrary combination of status tests, implemented with safe memory management. More...

List of all members.

Public Types

enum  ComboType { AND, OR }
 The test can be either the AND of all the component tests, or the OR of all the component tests. More...

Public Member Functions

 SafeCombo (ComboType t)
 Constructor.
 SafeCombo (ComboType t, const Teuchos::RCP< Generic > &a)
 Constructor with a single test.
 SafeCombo (ComboType t, const Teuchos::RCP< Generic > &a, const Teuchos::RCP< Generic > &b)
 Constructor with two tests.
virtual SafeComboaddStatusTest (const Teuchos::RCP< Generic > &a)
 Add another test to this combination.
virtual ~SafeCombo ()
 Destructor.
virtual StatusType checkStatus (const NOX::Solver::Generic &problem)
 Calls checkStatus(problem, NOX::StatusTest::Minimal)
virtual StatusType checkStatus (const NOX::Solver::Generic &problem, NOX::StatusTest::CheckType checkType)
 Tests stopping criterion.
virtual StatusType getStatus () const
virtual std::ostream & print (std::ostream &stream, int indent=0) const

Protected Member Functions

virtual void orOp (const Solver::Generic &problem, NOX::StatusTest::CheckType checkType)
 Use this for checkStatus when this is an OR type combo. Updates NOX::StatusTest::Combo::status.
virtual void andOp (const Solver::Generic &problem, NOX::StatusTest::CheckType checkType)
 Use this for checkStatus when this is an AND type combo. Updates NOX::StatusTest::Combo::status.
bool isSafe (const Teuchos::RCP< Generic > &a)
 Check whether or not it is safe to add a to this list of tests.

Private Attributes

const ComboType type
 Type of test.
std::vector< Teuchos::RCP
< Generic > > 
tests
 Vector of generic status tests.
StatusType status
 Status

Detailed Description

Arbitrary combination of status tests, implemented with safe memory management.

In the AND (see NOX::StatusTest::Combo::ComboType) combination, the result is Unconverged (see NOX::StatusTest::StatusType) if any of the tests is Unconverged. Otherwise, the result is equal to the result of the first test in the list that is either Converged or Failed. It is not recommended to mix Converged and Failed tests in an AND combination.

In the OR combination, the result is Unconverged if all of the tests are Unconverged. Otherwise, it is the result of the first test in the list that is either Converged or Failed. Therefore, it will generally make sense to put the Failed -type tests at the end of the OR list.

Note:
We call checkStatus on every convergence test, though some may be called with the NOX::StatusTest::None option.
This is identical in operation to StatusTest::Combo. but stores the constituent subtests using a reference-counted pointer. This ensures safe behavior if the constituent subtests go out of scope before the combo.
  • KL 24 August 2004.
Author:
Tammy Kolda (SNL 8950)
Kevin Long (SNL 8962)

Definition at line 88 of file NOX_StatusTest_SafeCombo.hpp.


Member Enumeration Documentation

The test can be either the AND of all the component tests, or the OR of all the component tests.

Enumerator:
AND 

Logically "AND" together the results of the tests in this combination.

OR 

Logically "OR" together the results of the tests in this combination.

Definition at line 96 of file NOX_StatusTest_SafeCombo.hpp.


Constructor & Destructor Documentation

Constructor.

Definition at line 62 of file NOX_StatusTest_SafeCombo.cpp.

References status.

NOX::StatusTest::SafeCombo::SafeCombo ( ComboType  t,
const Teuchos::RCP< Generic > &  a 
)

Constructor with a single test.

Definition at line 68 of file NOX_StatusTest_SafeCombo.cpp.

References status, and tests.

NOX::StatusTest::SafeCombo::SafeCombo ( ComboType  t,
const Teuchos::RCP< Generic > &  a,
const Teuchos::RCP< Generic > &  b 
)

Constructor with two tests.

Definition at line 76 of file NOX_StatusTest_SafeCombo.cpp.

References addStatusTest(), status, and tests.

Destructor.

Definition at line 125 of file NOX_StatusTest_SafeCombo.cpp.


Member Function Documentation

NOX::StatusTest::SafeCombo & NOX::StatusTest::SafeCombo::addStatusTest ( const Teuchos::RCP< Generic > &  a) [virtual]

Add another test to this combination.

Calls isSafe() to determine if it is safe to add a to the combination.

Definition at line 86 of file NOX_StatusTest_SafeCombo.cpp.

Referenced by SafeCombo().

void NOX::StatusTest::SafeCombo::andOp ( const Solver::Generic &  problem,
NOX::StatusTest::CheckType  checkType 
) [protected, virtual]

Use this for checkStatus when this is an AND type combo. Updates NOX::StatusTest::Combo::status.

If any tests are NOX::StatusTest::Unconverged, then the status of this test is NOX::StatusTest::Unconverged. If there is a combination of NOX::StatusTest::Failed and NOX::StatusTest::Converged in the tests that are AND'd together, the value of status for this test is set to the status of the first test it encounters. The tests are evaluated in the order that they were added to the combination.

Note:
We compute the status of all tests in the combination for the sake of completeness, even if we could determine the status of this combination test without that check.

Definition at line 191 of file NOX_StatusTest_SafeCombo.cpp.

virtual StatusType NOX::StatusTest::SafeCombo::checkStatus ( const NOX::Solver::Generic &  problem) [virtual]

Calls checkStatus(problem, NOX::StatusTest::Minimal)

virtual StatusType NOX::StatusTest::SafeCombo::checkStatus ( const NOX::Solver::Generic &  problem,
NOX::StatusTest::CheckType  checkType 
) [virtual]

Tests stopping criterion.

See addOp() and orOp() for details.

NOX::StatusTest::StatusType NOX::StatusTest::SafeCombo::getStatus ( ) const [virtual]

Definition at line 156 of file NOX_StatusTest_SafeCombo.cpp.

bool NOX::StatusTest::SafeCombo::isSafe ( const Teuchos::RCP< Generic > &  a) [protected]

Check whether or not it is safe to add a to this list of tests.

This is necessary to avoid any infinite recursions (i.e., a test cannot own a copy of itself).

Definition at line 103 of file NOX_StatusTest_SafeCombo.cpp.

References isSafe().

Referenced by isSafe().

void NOX::StatusTest::SafeCombo::orOp ( const Solver::Generic &  problem,
NOX::StatusTest::CheckType  checkType 
) [protected, virtual]

Use this for checkStatus when this is an OR type combo. Updates NOX::StatusTest::Combo::status.

If there is a combination of NOX::StatusTest::Failed and NOX::StatusTest::Converged in the tests that are OR'd together, the value of status for this test is set to the status of the first test it encounters which is not NOX::Status::Unconvered. The tests are evaluated in the order that they were added to the combination.

Note:
We compute the status of all tests in the combination for the sake of completeness, even if we could determine the status of this combination test without that check.

Definition at line 161 of file NOX_StatusTest_SafeCombo.cpp.

ostream & NOX::StatusTest::SafeCombo::print ( std::ostream &  stream,
int  indent = 0 
) const [virtual]

Definition at line 234 of file NOX_StatusTest_SafeCombo.cpp.


Member Data Documentation

StatusType NOX::StatusTest::SafeCombo::status [private]

Status

Definition at line 194 of file NOX_StatusTest_SafeCombo.hpp.

Referenced by SafeCombo().

std::vector<Teuchos::RCP<Generic> > NOX::StatusTest::SafeCombo::tests [private]

Vector of generic status tests.

Definition at line 191 of file NOX_StatusTest_SafeCombo.hpp.

Referenced by SafeCombo().

Type of test.

Definition at line 188 of file NOX_StatusTest_SafeCombo.hpp.

Site Contact