Tempus
Version of the Day
Time Integration
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Tempus_StepperRKModifierXBase.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ****************************************************************************
3
// Tempus: Copyright (2017) Sandia Corporation
4
//
5
// Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6
// ****************************************************************************
7
// @HEADER
8
9
#ifndef Tempus_StepperRKModifierXBase_hpp
10
#define Tempus_StepperRKModifierXBase_hpp
11
12
#include "Tempus_config.hpp"
13
#include "Tempus_SolutionHistory.hpp"
14
#include "
Tempus_StepperRKAppAction.hpp
"
15
16
#include "Teuchos_SerialDenseVector.hpp"
17
18
namespace
Tempus
{
19
38
template
<
class
Scalar>
39
class
StepperRKModifierXBase
40
:
virtual
public
Tempus::StepperRKAppAction
<Scalar>
41
{
42
private
:
43
44
/* \brief Adaptor execute function
45
*
46
* This is an adaptor function to bridge between the AppAction
47
* interface and the ModifierX interface. It is meant to be private
48
* and non-virtual as deriving from this class should only need to
49
* implement the modify function.
50
*
51
* For the ModifierX interface, this adaptor maps the
52
* StepperRKAppAction::ACTION_LOCATION to the
53
* StepperRKModifierX::MODIFIERX_TYPE, and only pass the solution
54
* (\f$x\f$ and/or \f$\dot{x}\f$ and other parameters to the modify
55
* function.
56
*/
57
void
execute
(
58
Teuchos::RCP<
SolutionHistory<Scalar>
> sh,
59
Teuchos::RCP<
StepperRKBase<Scalar>
> stepper,
60
const
typename
StepperRKAppAction<Scalar>::ACTION_LOCATION
actLoc)
61
{
62
using
Teuchos::RCP;
63
64
MODIFIER_TYPE
modType =
X_BEGIN_STEP
;
65
const
int
stageNumber = stepper->getStageNumber();
66
Teuchos::SerialDenseVector<int,Scalar> c = stepper->getTableau()->c();
67
RCP<SolutionState<Scalar> > workingState = sh->getWorkingState();
68
const
Scalar dt = workingState->getTimeStep();
69
Scalar time = sh->getCurrentState()->getTime();
70
if
(stageNumber >= 0) time += c(stageNumber)*dt;
71
RCP<Thyra::VectorBase<Scalar> > x = workingState->getX();
72
73
switch
(actLoc) {
74
case
StepperRKAppAction<Scalar>::BEGIN_STEP
:
75
{
76
modType =
X_BEGIN_STEP
;
77
break
;
78
}
79
case
StepperRKAppAction<Scalar>::BEGIN_STAGE
:
80
{
81
modType =
X_BEGIN_STAGE
;
82
break
;
83
}
84
case
StepperRKAppAction<Scalar>::BEFORE_SOLVE
:
85
{
86
modType =
X_BEFORE_SOLVE
;
87
break
;
88
}
89
case
StepperRKAppAction<Scalar>::AFTER_SOLVE
:
90
{
91
modType =
X_AFTER_SOLVE
;
92
break
;
93
}
94
case
StepperRKAppAction<Scalar>::BEFORE_EXPLICIT_EVAL
:
95
{
96
modType =
X_BEFORE_EXPLICIT_EVAL
;
97
break
;
98
}
99
case
StepperRKAppAction<Scalar>::END_STAGE
:
100
{
101
modType =
X_END_STAGE
;
102
break
;
103
}
104
case
StepperRKAppAction<Scalar>::END_STEP
:
105
{
106
modType =
X_END_STEP
;
107
time = workingState->getTime();
108
break
;
109
}
110
default
:
111
TEUCHOS_TEST_FOR_EXCEPTION(
true
, std::logic_error,
112
"Error - unknown action location.\n"
);
113
}
114
115
this->
modify
(x, time, dt, stageNumber, modType);
116
}
117
118
public
:
119
121
enum
MODIFIER_TYPE
{
122
X_BEGIN_STEP
,
123
X_BEGIN_STAGE
,
124
X_BEFORE_SOLVE
,
125
X_AFTER_SOLVE
,
126
X_BEFORE_EXPLICIT_EVAL
,
127
X_END_STAGE
,
128
X_END_STEP
129
};
130
132
virtual
void
modify
(
133
Teuchos::RCP<
Thyra::VectorBase<Scalar>
>
/* x */
,
134
const
Scalar
/* time */
,
const
Scalar
/* dt */
,
135
const
int
/* stageNumber */
,
136
const
MODIFIER_TYPE
modType) = 0;
137
138
};
139
140
}
// namespace Tempus
141
142
#endif
// Tempus_StepperRKModifierXBase_hpp
Tempus_StepperRKAppAction.hpp
Tempus::SolutionHistory
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Definition
Tempus_SolutionHistory_decl.hpp:121
Tempus::StepperRKAppAction
Application Action for StepperRKBase.
Definition
Tempus_StepperRKAppAction.hpp:35
Tempus::StepperRKAppAction::ACTION_LOCATION
ACTION_LOCATION
Indicates the location of application action (see algorithm).
Definition
Tempus_StepperRKAppAction.hpp:39
Tempus::StepperRKAppAction::BEGIN_STEP
@ BEGIN_STEP
At the beginning of the step.
Definition
Tempus_StepperRKAppAction.hpp:40
Tempus::StepperRKAppAction::BEFORE_SOLVE
@ BEFORE_SOLVE
Before the implicit solve.
Definition
Tempus_StepperRKAppAction.hpp:42
Tempus::StepperRKAppAction::BEFORE_EXPLICIT_EVAL
@ BEFORE_EXPLICIT_EVAL
Before the explicit evaluation.
Definition
Tempus_StepperRKAppAction.hpp:44
Tempus::StepperRKAppAction::AFTER_SOLVE
@ AFTER_SOLVE
After the implicit solve.
Definition
Tempus_StepperRKAppAction.hpp:43
Tempus::StepperRKAppAction::BEGIN_STAGE
@ BEGIN_STAGE
At the beginning of the stage.
Definition
Tempus_StepperRKAppAction.hpp:41
Tempus::StepperRKAppAction::END_STAGE
@ END_STAGE
At the end of the stage.
Definition
Tempus_StepperRKAppAction.hpp:45
Tempus::StepperRKAppAction::END_STEP
@ END_STEP
At the end of the step.
Definition
Tempus_StepperRKAppAction.hpp:46
Tempus::StepperRKBase
Base class for Runge-Kutta methods, ExplicitRK, DIRK and IMEX.
Definition
Tempus_StepperRKBase.hpp:32
Tempus::StepperRKModifierXBase
Base ModifierX for StepperRK.
Definition
Tempus_StepperRKModifierXBase.hpp:41
Tempus::StepperRKModifierXBase::MODIFIER_TYPE
MODIFIER_TYPE
Indicates the location of application action (see algorithm).
Definition
Tempus_StepperRKModifierXBase.hpp:121
Tempus::StepperRKModifierXBase::X_END_STEP
@ X_END_STEP
Modify at the end of the step.
Definition
Tempus_StepperRKModifierXBase.hpp:128
Tempus::StepperRKModifierXBase::X_BEGIN_STEP
@ X_BEGIN_STEP
Modify at the beginning of the step.
Definition
Tempus_StepperRKModifierXBase.hpp:122
Tempus::StepperRKModifierXBase::X_AFTER_SOLVE
@ X_AFTER_SOLVE
Modify after the implicit solve.
Definition
Tempus_StepperRKModifierXBase.hpp:125
Tempus::StepperRKModifierXBase::X_END_STAGE
@ X_END_STAGE
Modify at the end of the stage.
Definition
Tempus_StepperRKModifierXBase.hpp:127
Tempus::StepperRKModifierXBase::X_BEFORE_SOLVE
@ X_BEFORE_SOLVE
Modify before the implicit solve.
Definition
Tempus_StepperRKModifierXBase.hpp:124
Tempus::StepperRKModifierXBase::X_BEFORE_EXPLICIT_EVAL
@ X_BEFORE_EXPLICIT_EVAL
Modify before the explicit evaluation.
Definition
Tempus_StepperRKModifierXBase.hpp:126
Tempus::StepperRKModifierXBase::X_BEGIN_STAGE
@ X_BEGIN_STAGE
Modify at the beginning of the stage.
Definition
Tempus_StepperRKModifierXBase.hpp:123
Tempus::StepperRKModifierXBase::modify
virtual void modify(Teuchos::RCP< Thyra::VectorBase< Scalar > >, const Scalar, const Scalar, const int, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE.
Tempus::StepperRKModifierXBase::execute
void execute(Teuchos::RCP< SolutionHistory< Scalar > > sh, Teuchos::RCP< StepperRKBase< Scalar > > stepper, const typename StepperRKAppAction< Scalar >::ACTION_LOCATION actLoc)
Execute application action for RK Stepper.
Definition
Tempus_StepperRKModifierXBase.hpp:57
Thyra::VectorBase
Tempus
Definition
Tempus_AdjointAuxSensitivityModelEvaluator_decl.hpp:21
Generated by
1.17.0