Skip to content

Commit

Permalink
Merge pull request #7539 from trilinos/7522-Tempus-Cleanup-of-AppActi…
Browse files Browse the repository at this point in the history
…on-Includes

Tempus: Cleanup of AppAction Includes.
  • Loading branch information
ccober6 authored Jun 18, 2020
2 parents abeb459 + fd9733c commit 34b0144
Show file tree
Hide file tree
Showing 31 changed files with 295 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperBackwardEuler.hpp"


namespace Tempus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
#define Tempus_StepperBackwardEulerModifierDefault_hpp

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperBackwardEulerModifierBase.hpp"

// Applications can uncomment this include in their implementation,
// if they need access to the stepper methods.
//#include "Tempus_StepperBackwardEuler.hpp"


namespace Tempus {

/** \brief Default modifier for StepperBackwardEuler.
*
* The default modifier provides no-op functionality for the modifier.
* See StepperBackwardEulerModifierBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperBackwardEulerModifierDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define Tempus_StepperBackwardEulerModifierX_hpp

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperBackwardEulerModifierXBase.hpp"


Expand All @@ -20,6 +19,9 @@ namespace Tempus {
*
* The default provides no-op functionality for ModifierX.
* See StepperBackwardEulerModifierXBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperBackwardEulerModifierXDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
#define Tempus_StepperBackwardEulerObserverDefault_hpp

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperBackwardEulerObserverBase.hpp"

// Applications can uncomment this include in their implementation,
// if they need access to the stepper methods.
//#include "Tempus_StepperBackwardEuler.hpp"


namespace Tempus {

/** \brief Default observer for StepperBackwardEuler.
*
* The default observer provides no-op functionality for the observer.
* See StepperBackwardEulerObserverBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperBackwardEulerObserverDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperForwardEuler.hpp"


namespace Tempus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
#define Tempus_StepperForwardEulerModifierDefault_hpp

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperForwardEulerModifierBase.hpp"

// Applications can uncomment this include in their implementation,
// if they need access to the stepper methods.
//#include "Tempus_StepperForwardEuler.hpp"


namespace Tempus {

/** \brief Default modifier for StepperForwardEuler.
*
* The default modifier provides no-op functionality for the modifier.
* See StepperForwardEulerModifierBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperForwardEulerModifierDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define Tempus_StepperForwardEulerModifierX_hpp

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperForwardEulerModifierXBase.hpp"


Expand All @@ -20,6 +19,9 @@ namespace Tempus {
*
* The default provides no-op functionality for ModifierX.
* See StepperForwardEulerModifierXBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperForwardEulerModifierXDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
#define Tempus_StepperForwardEulerObserverDefault_hpp

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperForwardEulerObserverBase.hpp"

// Applications can uncomment this include in their implementation,
// if they need access to the stepper methods.
//#include "Tempus_StepperForwardEuler.hpp"


namespace Tempus {

/** \brief Default observer for StepperForwardEuler.
*
* The default observer provides no-op functionality for the observer.
* See StepperForwardEulerObserverBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperForwardEulerObserverDefault
Expand Down
18 changes: 9 additions & 9 deletions packages/tempus/src/Tempus_StepperOperatorSplitAppAction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperOperatorSplit.hpp"


namespace Tempus {

Expand All @@ -22,26 +22,26 @@ template<class Scalar> class StepperOperatorSplit;
*
* This is a means for application developers to perform tasks
* during the time steps, e.g.,
* - Compute specific quantities
* - Output information
* - Compute specific quantities
* - Output information
* - "Massage" the working solution state
* - ...
*
* <b>Design Considerations</b>
* - StepperOperatorSplitAppAction is not stateless! Developers may touch the
* solution state! Developers need to be careful not to break the
* restart (checkpoint) capability.
* restart (checkpoint) capability.
*/
template<class Scalar>
class StepperOperatorSplitAppAction
{
public:

enum ACTION_LOCATION {
BEGIN_STEP, ///< At the beginning of the step.
BEFORE_STEPPER, ///< Before a stepper evaluation.
AFTER_STEPPER, ///< After a stepper evaluation.
END_STEP ///< At the end of the step.
BEGIN_STEP, ///< At the beginning of the step.
BEFORE_STEPPER, ///< Before a stepper evaluation.
AFTER_STEPPER, ///< After a stepper evaluation.
END_STEP ///< At the end of the step.
};

/// Constructor
Expand All @@ -50,7 +50,7 @@ class StepperOperatorSplitAppAction
/// Destructor
virtual ~StepperOperatorSplitAppAction(){}

/// Execute application action for OperatorSplit Stepper.
/// Execute application action for OperatorSplit Stepper.
virtual void execute(
Teuchos::RCP<SolutionHistory<Scalar> > sh,
Teuchos::RCP<StepperOperatorSplit<Scalar> > stepper,
Expand Down
44 changes: 22 additions & 22 deletions packages/tempus/src/Tempus_StepperOperatorSplitModifierBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,41 @@

namespace Tempus {

/** \brief Base modifier for OperatorSplit.
*
* This class provides a means to modify values (e.g., solution variables
* through SolutionHistory, and stepper member data through the Stepper),
* and can be very powerful and easy to make changes to the stepper and
* the solution.
*
* Users deriving from this class can access a lot of data, and it is
* expected that those users know what changes are allowable without
* affecting the Stepper correctness, performance, accuracy and stability.
* Thus the user should be careful when accessing data through classes
* derived from the default modifier (i.e., USER BEWARE!!).
*
/** \brief Base modifier for OperatorSplit.
*
* This class provides a means to modify values (e.g., solution variables
* through SolutionHistory, and stepper member data through the Stepper),
* and can be very powerful and easy to make changes to the stepper and
* the solution.
*
* Users deriving from this class can access a lot of data, and it is
* expected that those users know what changes are allowable without
* affecting the Stepper correctness, performance, accuracy and stability.
* Thus the user should be careful when accessing data through classes
* derived from the default modifier (i.e., USER BEWARE!!).
*
*/
template<class Scalar>
class StepperOperatorSplitModifierBase
: virtual public Tempus::StepperOperatorSplitAppAction<Scalar>
{
private:
/* \brief Adaptor execute function
*
* This is an adaptor function to bridge between the AppAction
* interface and the Modifier interface. It is meant to be private
* and non-virtual as deriving from this class should only need to
* implement the modify function.
*
* For the Modifier interface, this adaptor is a "simple pass through".
/* \brief Adaptor execute function
*
* This is an adaptor function to bridge between the AppAction
* interface and the Modifier interface. It is meant to be private
* and non-virtual as deriving from this class should only need to
* implement the modify function.
*
* For the Modifier interface, this adaptor is a "simple pass through".
*/
void execute(
Teuchos::RCP<SolutionHistory<Scalar> > sh,
Teuchos::RCP<StepperOperatorSplit<Scalar> > stepper,
const typename StepperOperatorSplitAppAction<Scalar>::ACTION_LOCATION actLoc)
{ this->modify(sh, stepper, actLoc); }
public:
/// Modify OperatorSplit Stepper.
/// Modify OperatorSplit Stepper.
virtual void modify(
Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
Teuchos::RCP<StepperOperatorSplit<Scalar> > /* stepper */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
#define Tempus_StepperOperatorSplitModifierDefault_hpp

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperOperatorSplitModifierBase.hpp"

// Applications can uncomment this include in their implementation,
// if they need access to the stepper methods.
//#include "Tempus_StepperOperatorSplit.hpp"


namespace Tempus {

/** \brief Default modifier for StepperOperatorSplit.
*
* The default modifier provides no-op functionality for the modifier.
* See StepperOperatorSplitModifierBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperOperatorSplitModifierDefault
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// @HEADER
// ****************************************************************************
// Tempus: Copyright (2017) Sandia Corporation
//
// Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
// ****************************************************************************
// @HEADER

#ifndef Tempus_StepperOperatorSplitModifierXDefault_hpp
#define Tempus_StepperOperatorSplitModifierXDefault_hpp

#include "Tempus_config.hpp"
#include "Tempus_StepperOperatorSplitModifierXBase.hpp"

// Applications can uncomment this include in their implementation,
// if they need access to the stepper methods.
//#include "Tempus_StepperOperatorSplit.hpp"


namespace Tempus {

/** \brief Default ModifierX for StepperOperatorSplit.
*
* The default ModifierX provides no-op functionality for ModifierX.
* See StepperOperatorSplitModifierXBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperOperatorSplitModifierXDefault
: virtual public Tempus::StepperOperatorSplitModifierXBase<Scalar>
{
public:

/// Constructor
StepperOperatorSplitModifierXDefault(){}

/// Destructor
virtual ~StepperOperatorSplitModifierXDefault(){}

/// Modify OperatorSplit Stepper.
virtual void modify(
Teuchos::RCP<Thyra::VectorBase<Scalar> > /* x */,
const Scalar /* time */, const Scalar /* dt */,
const typename StepperOperatorSplitModifierXBase<Scalar>::MODIFIER_TYPE modType)
{
switch(modType) {
case StepperOperatorSplitModifierXBase<Scalar>::X_BEGIN_STEP:
case StepperOperatorSplitModifierXBase<Scalar>::X_BEFORE_STEPPER:
case StepperOperatorSplitModifierXBase<Scalar>::X_AFTER_STEPPER:
case StepperOperatorSplitModifierXBase<Scalar>::XDOT_END_STEP:
{
// No-op.
break;
}
default:
TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
"Error - unknown action location.\n");
}
}

};

} // namespace Tempus

#endif // Tempus_StepperOperatorSplitModifierXDefault_hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@
#define Tempus_StepperOperatorSplitObserverDefault_hpp

#include "Tempus_config.hpp"
#include "Tempus_SolutionHistory.hpp"
#include "Tempus_StepperOperatorSplitObserverBase.hpp"

// Applications can uncomment this include in their implementation,
// if they need access to the stepper methods.
//#include "Tempus_StepperOperatorSplit.hpp"


namespace Tempus {

/** \brief Default observer for StepperOperatorSplit.
*
* The default observer provides no-op functionality for the observer.
* See StepperOperatorSplitObserverBase for details on the algorithm.
*
* Applications can copy this implementation, rename, implement their
* action, and set on the stepper to get app-specific functionality.
*/
template<class Scalar>
class StepperOperatorSplitObserverDefault
Expand Down
2 changes: 1 addition & 1 deletion packages/tempus/src/Tempus_StepperOperatorSplit_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ void StepperOperatorSplit<Scalar>::takeStep(
typename std::vector<Teuchos::RCP<Stepper<Scalar> > >::iterator
subStepperIter = subStepperList_.begin();
for (; subStepperIter < subStepperList_.end() and pass; subStepperIter++) {
int index = subStepperIter - subStepperList_.begin();

#ifndef TEMPUS_HIDE_DEPRECATED_CODE
int index = subStepperIter - subStepperList_.begin();
stepperOSObserver_->observeBeforeStepper(index, solutionHistory, *this);
#endif
stepperOSAppAction_->execute(solutionHistory, thisStepper,
Expand Down
Loading

0 comments on commit 34b0144

Please sign in to comment.