forked from trilinos/Trilinos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request trilinos#7086 from trilinos/7082-Prototype-of-New-…
…Interface-for-FE Commiting the Forward Euler AppAction changes
- Loading branch information
Showing
12 changed files
with
1,053 additions
and
21 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
packages/tempus/src/Tempus_StepperForwardEulerAppAction.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// @HEADER | ||
// **************************************************************************** | ||
// Tempus: Copyright (2017) Sandia Corporation | ||
// | ||
// Distributed under BSD 3-clause license (See accompanying file Copyright.txt) | ||
// **************************************************************************** | ||
// @HEADER | ||
|
||
#ifndef Tempus_StepperForwardEulerAppAction_hpp | ||
#define Tempus_StepperForwardEulerAppAction_hpp | ||
|
||
#include "Tempus_config.hpp" | ||
#include "Tempus_SolutionHistory.hpp" | ||
#include "Tempus_StepperForwardEuler.hpp" | ||
|
||
|
||
namespace Tempus { | ||
|
||
// Forward Declaration for recursive includes (this AppAction <--> Stepper) | ||
template<class Scalar> class StepperForwardEuler; | ||
|
||
/** \brief Application Action for StepperForwardEuler. | ||
* | ||
* This class provides a means to apply various actions with the ForwardEuler time step. | ||
* The data available to this class is solution variables (through | ||
* SolutionHistory), and stepper data (through the Stepper). It allows | ||
* the application to just observe this data (i.e., use but not change the | ||
* data) to change any of it (USER BEWARE!). | ||
* | ||
* Below is the ForwardEuler algorithm and includes the locations where the | ||
* application can take actions (in italicized). | ||
* | ||
* \f{algorithm}{ | ||
* \renewcommand{\thealgorithm}{} | ||
* \caption{Forward Euler with the locations of the application actions indicated.} | ||
* \begin{algorithmic}[1] | ||
* \State Start with $x_n$, $\Delta t_n$ | ||
* \State {\it appAction.execute(solutionHistory, stepper, BEGIN\_STEP)} | ||
* \State Form $f(x_{n},t_{n})$ | ||
* \State {\it appAction.execute(solutionHistory, stepper, BEFORE\_EXPLICIT\_EVAL)} | ||
* \State Form $x_n \leftarrow x_{n} + \Delta t_n f(x_{n},t_n)$ | ||
* \State {\it appAction.execute(solutionHistory, stepper, END\_STEP)} | ||
* \end{algorithmic} | ||
* \f} | ||
*/ | ||
template<class Scalar> | ||
class StepperForwardEulerAppAction | ||
{ | ||
public: | ||
|
||
/// Indicates the location of application action (see algorithm). | ||
enum ACTION_LOCATION { | ||
BEGIN_STEP, ///< At the beginning of the step. | ||
BEFORE_EXPLICIT_EVAL, ///< Before the explicit evaluation. | ||
END_STEP ///< At the end of the step. | ||
}; | ||
|
||
/// Constructor | ||
StepperForwardEulerAppAction(){} | ||
|
||
/// Destructor | ||
virtual ~StepperForwardEulerAppAction(){} | ||
|
||
/// Execute application action for ForwardEuler Stepper. | ||
virtual void execute( | ||
Teuchos::RCP<SolutionHistory<Scalar> > sh, | ||
Teuchos::RCP<StepperForwardEuler<Scalar> > stepper, | ||
const typename StepperForwardEulerAppAction<Scalar>::ACTION_LOCATION actLoc) = 0; | ||
}; | ||
|
||
} // namespace Tempus | ||
|
||
#endif // Tempus_StepperForwardEulerAppAction_hpp |
65 changes: 65 additions & 0 deletions
65
packages/tempus/src/Tempus_StepperForwardEulerAppActionComposite.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// @HEADER | ||
// **************************************************************************** | ||
// Tempus: Copyright (2017) Sandia Corporation | ||
// | ||
// Distributed under BSD 3-clause license (See accompanying file Copyright.txt) | ||
// **************************************************************************** | ||
// @HEADER | ||
|
||
#ifndef Tempus_StepperForwardEulerAppActionComposite_hpp | ||
#define Tempus_StepperForwardEulerAppActionComposite_hpp | ||
|
||
#include "Tempus_StepperForwardEulerAppAction.hpp" | ||
#include "Tempus_TimeStepControl.hpp" | ||
#include <vector> | ||
|
||
namespace Tempus { | ||
|
||
/** \brief This composite AppAction loops over added AppActions. | ||
* | ||
* Inidividual AppActions are executed in the order in which they | ||
* were added. | ||
*/ | ||
template<class Scalar> | ||
class StepperForwardEulerAppActionComposite | ||
: virtual public Tempus::StepperForwardEulerAppAction<Scalar> | ||
{ | ||
public: | ||
|
||
/// Default constructor | ||
StepperForwardEulerAppActionComposite(); | ||
|
||
/// Destructor | ||
virtual ~StepperForwardEulerAppActionComposite(); | ||
|
||
/// Execute application action for ForwardEuler Stepper. | ||
virtual void execute( | ||
Teuchos::RCP<SolutionHistory<Scalar> > sh, | ||
Teuchos::RCP<StepperForwardEuler<Scalar> > stepper, | ||
const typename StepperForwardEulerAppAction<Scalar>::ACTION_LOCATION actLoc) | ||
{ | ||
for(auto& a : appActions_) | ||
a->execute(sh, stepper, actLoc); | ||
} | ||
|
||
// Add AppAction to the AppAction vector. | ||
void addForwardEulerAppAction(Teuchos::RCP<StepperForwardEulerAppAction<Scalar> > appAction); | ||
{ | ||
appActions_.push_back(appAction); | ||
} | ||
|
||
// Clear the AppAction vector. | ||
void clearForwardEulerAppActions(); | ||
{ appActions_.clear();} | ||
|
||
// Return the size of the AppAction vector. | ||
std::size_t getSize() const { return appActions_.size(); } | ||
|
||
private: | ||
|
||
std::vector<Teuchos::RCP<StepperForwardEulerAppAction<Scalar > > > appActions_; | ||
|
||
}; | ||
|
||
} // namespace Tempus | ||
#endif // Tempus_StepperForwardEulerAppActionComposite_hpp |
78 changes: 78 additions & 0 deletions
78
packages/tempus/src/Tempus_StepperForwardEulerModifierBase.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// @HEADER | ||
// **************************************************************************** | ||
// Tempus: Copyright (2017) Sandia Corporation | ||
// | ||
// Distributed under BSD 3-clause license (See accompanying file Copyright.txt) | ||
// **************************************************************************** | ||
// @HEADER | ||
|
||
#ifndef Tempus_StepperForwardEulerModifierBase_hpp | ||
#define Tempus_StepperForwardEulerModifierBase_hpp | ||
|
||
#include "Tempus_config.hpp" | ||
#include "Tempus_SolutionHistory.hpp" | ||
#include "Tempus_StepperForwardEulerAppAction.hpp" | ||
|
||
namespace Tempus { | ||
|
||
/** \brief Base modifier for StepperBackwardEuler. | ||
* | ||
* 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!!). | ||
* | ||
* \f{algorithm}{ | ||
* \renewcommand{\thealgorithm}{} | ||
* \caption{Forward Euler with the locations of the application actions indicated.} | ||
* \begin{algorithmic}[1] | ||
* \State Start with $x_n$, $\Delta t_n$ | ||
* \State {\it appAction.execute(solutionHistory, stepper, BEGIN\_STEP)} | ||
* \State Form $f(x_{n},t_{n})$ | ||
* \State {\it appAction.execute(solutionHistory, stepper, BEFORE\_EXPLICIT\_EVAL)} | ||
* \State Form $x_n \leftarrow x_{n} + \Delta t_n f(x_{n},t_n)$ | ||
* \State {\it appAction.execute(solutionHistory, stepper, END\_STEP)} | ||
* \end{algorithmic} | ||
* \f} | ||
*/ | ||
|
||
template<class Scalar> | ||
class StepperForwardEulerModifierBase | ||
: virtual public Tempus::StepperForwardEulerAppAction<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". | ||
*/ | ||
void execute( | ||
Teuchos::RCP<SolutionHistory<Scalar> > sh, | ||
Teuchos::RCP<StepperForwardEuler<Scalar> > stepper, | ||
const typename StepperForwardEulerAppAction<Scalar>::ACTION_LOCATION actLoc) | ||
{ this->modify(sh, stepper, actLoc); } | ||
|
||
public: | ||
|
||
/// Modify ForwardEuler Stepper. | ||
virtual void modify( | ||
Teuchos::RCP<SolutionHistory<Scalar> > /* sh */, | ||
Teuchos::RCP<StepperForwardEuler<Scalar> > /* stepper */, | ||
const typename StepperForwardEulerAppAction<Scalar>::ACTION_LOCATION actLoc) = 0; | ||
|
||
}; | ||
|
||
} // namespace Tempus | ||
|
||
#endif // Tempus_StepperForwardEulerModifierBase_hpp |
60 changes: 60 additions & 0 deletions
60
packages/tempus/src/Tempus_StepperForwardEulerModifierDefault.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// @HEADER | ||
// **************************************************************************** | ||
// Tempus: Copyright (2017) Sandia Corporation | ||
// | ||
// Distributed under BSD 3-clause license (See accompanying file Copyright.txt) | ||
// **************************************************************************** | ||
// @HEADER | ||
|
||
#ifndef Tempus_StepperForwardEulerModifierDefault_hpp | ||
#define Tempus_StepperForwardEulerModifierDefault_hpp | ||
|
||
#include "Tempus_config.hpp" | ||
#include "Tempus_SolutionHistory.hpp" | ||
#include "Tempus_StepperForwardEulerModifierBase.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. | ||
*/ | ||
template<class Scalar> | ||
class StepperForwardEulerModifierDefault | ||
: virtual public Tempus::StepperForwardEulerModifierBase<Scalar> | ||
{ | ||
public: | ||
|
||
/// Constructor | ||
StepperForwardEulerModifierDefault(){} | ||
|
||
/// Destructor | ||
virtual ~StepperForwardEulerModifierDefault(){} | ||
|
||
/// Modify ForwardEuler Stepper. | ||
virtual void modify( | ||
Teuchos::RCP<SolutionHistory<Scalar> > /* sh */, | ||
Teuchos::RCP<StepperForwardEuler<Scalar> > /* stepper */, | ||
const typename StepperForwardEulerAppAction<Scalar>::ACTION_LOCATION actLoc) | ||
{ | ||
switch(actLoc) { | ||
case StepperForwardEulerAppAction<Scalar>::BEGIN_STEP: | ||
case StepperForwardEulerAppAction<Scalar>::BEFORE_EXPLICIT_EVAL: | ||
case StepperForwardEulerAppAction<Scalar>::END_STEP: | ||
{ | ||
// No-op. | ||
break; | ||
} | ||
default: | ||
TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, | ||
"Error - unknown action location.\n"); | ||
} | ||
} | ||
|
||
}; | ||
|
||
} // namespace Tempus | ||
|
||
#endif // Tempus_StepperForwardEulerModifierDefault_hpp |
Oops, something went wrong.