Tempus
Version of the Day
Time Integration
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Tempus_WrapperModelEvaluatorBasic_impl.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_WrapperModelEvaluatorBasic_impl_hpp
10
#define Tempus_WrapperModelEvaluatorBasic_impl_hpp
11
12
namespace
Tempus
{
13
14
15
template
<
typename
Scalar>
16
Thyra::ModelEvaluatorBase::InArgs<Scalar>
17
WrapperModelEvaluatorBasic<Scalar>::
18
createInArgs
()
const
19
{
20
typedef
Thyra::ModelEvaluatorBase MEB;
21
//MEB::InArgsSetup<Scalar> inArgs(appModel_->createInArgs());
22
MEB::InArgsSetup<Scalar> inArgs(
appModel_
->getNominalValues());
23
24
inArgs.setModelEvalDescription(this->description());
25
return
std::move(inArgs);
26
}
27
28
29
template
<
typename
Scalar>
30
Thyra::ModelEvaluatorBase::OutArgs<Scalar>
31
WrapperModelEvaluatorBasic<Scalar>::
32
createOutArgsImpl
()
const
33
{
34
typedef
Thyra::ModelEvaluatorBase MEB;
35
MEB::OutArgsSetup<Scalar> outArgs(
appModel_
->createOutArgs());
36
outArgs.setModelEvalDescription(this->description());
37
return
std::move(outArgs);
38
}
39
40
41
template
<
typename
Scalar>
42
void
43
WrapperModelEvaluatorBasic<Scalar>::
44
evalModelImpl
(
const
Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
45
const
Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
46
{
47
using
Teuchos::RCP;
48
49
typedef
Thyra::ModelEvaluatorBase MEB;
50
MEB::InArgs<Scalar> appInArgs (
wrapperInArgs_
);
51
MEB::OutArgs<Scalar> appOutArgs(
wrapperOutArgs_
);
52
53
// Setup input and output arguments for application ME
54
switch
(
evaluationType_
)
55
{
56
case
EVALUATE_RESIDUAL
: {
57
58
// Setup input arguments
59
appInArgs.set_x (inArgs.get_x() );
60
appInArgs.set_x_dot(inArgs.get_x_dot());
61
62
// Setup output arguments
63
appOutArgs.set_f(outArgs.get_f());
64
65
break
;
66
}
67
case
SOLVE_FOR_X
: {
68
69
// This is the normal solution scheme where we are solving for x,
70
// and xDot is dependent on x through the definition of the time
71
// derivative for the Stepper.
72
73
// Setup input arguments
74
RCP<const Thyra::VectorBase<Scalar> > x = inArgs.get_x();
75
appInArgs.set_x(x);
// x is from solver.
76
RCP<Thyra::VectorBase<Scalar> > xDot =
77
Teuchos::rcp_const_cast<Thyra::VectorBase<Scalar> >(
78
appInArgs.get_x_dot());
// xDot is from the Stepper
79
timeDer_
->compute(x, xDot);
80
appInArgs.set_x_dot(xDot);
81
82
// Setup output arguments
83
// Note: For the use that Tempus does of this class, these three args
84
// *should* be enough. However, keep in mind that it *may* be
85
// necessary to add more outArgs in the future. The idea would
86
// be the same: if the underlying model supports the arg, then
87
// set it in the appOutArgs.
88
appOutArgs.set_f(outArgs.get_f());
89
appOutArgs.set_W_op(outArgs.get_W_op());
90
if
(outArgs.supports(MEB::OUT_ARG_W_prec)) {
91
appOutArgs.set_W_prec(outArgs.get_W_prec());
92
}
93
94
break
;
95
}
96
97
case
SOLVE_FOR_XDOT_CONST_X
: {
98
99
// This solution scheme is solving for xDot while keeping x constant.
100
// This is similar to evaluating an explicit ODE, xDot = f(x,t). The
101
// upside is the application does not need to write f(x,t) or worry
102
// about inverting a mass matrix. This solution scheme is mostly
103
// used for initial conditions to make the x and xDot consistent
104
// with the governing equations.
105
106
// Setup input arguments
107
appInArgs.set_x(
wrapperInArgs_
.get_x());
// x is from the Stepper.
108
appInArgs.set_x_dot(inArgs.get_x());
// xDot is from the solver.
109
110
// Setup output arguments
111
appOutArgs.set_f(outArgs.get_f());
112
appOutArgs.set_W_op(outArgs.get_W_op());
113
if
(outArgs.supports(MEB::OUT_ARG_W_prec)) {
114
appOutArgs.set_W_prec(outArgs.get_W_prec());
115
}
116
117
break
;
118
}
119
120
default
: {
121
TEUCHOS_TEST_FOR_EXCEPT(
"Invalid EVALUATION_TYPE!"
);
122
}
123
}
124
125
for
(
int
i=0; i<
appModel_
->Np(); ++i) {
126
if
(inArgs.get_p(i) != Teuchos::null)
127
appInArgs.set_p(i, inArgs.get_p(i));
128
}
129
130
appModel_
->evalModel(appInArgs, appOutArgs);
131
}
132
133
134
}
// namespace Tempus
135
136
#endif
// Tempus_WrapperModelEvaluatorBasic_impl_hpp
Tempus::WrapperModelEvaluatorBasic::wrapperOutArgs_
Thyra::ModelEvaluatorBase::OutArgs< Scalar > wrapperOutArgs_
Definition
Tempus_WrapperModelEvaluatorBasic_decl.hpp:123
Tempus::WrapperModelEvaluatorBasic::wrapperInArgs_
Thyra::ModelEvaluatorBase::InArgs< Scalar > wrapperInArgs_
Definition
Tempus_WrapperModelEvaluatorBasic_decl.hpp:122
Tempus::WrapperModelEvaluatorBasic::timeDer_
Teuchos::RCP< TimeDerivative< Scalar > > timeDer_
Definition
Tempus_WrapperModelEvaluatorBasic_decl.hpp:121
Tempus::WrapperModelEvaluatorBasic::evalModelImpl
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Definition
Tempus_WrapperModelEvaluatorBasic_impl.hpp:44
Tempus::WrapperModelEvaluatorBasic::createInArgs
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Definition
Tempus_WrapperModelEvaluatorBasic_impl.hpp:18
Tempus::WrapperModelEvaluatorBasic::createOutArgsImpl
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
Definition
Tempus_WrapperModelEvaluatorBasic_impl.hpp:32
Tempus::WrapperModelEvaluatorBasic::evaluationType_
EVALUATION_TYPE evaluationType_
Definition
Tempus_WrapperModelEvaluatorBasic_decl.hpp:124
Tempus::WrapperModelEvaluatorBasic::appModel_
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > appModel_
Definition
Tempus_WrapperModelEvaluatorBasic_decl.hpp:120
Tempus
Definition
Tempus_AdjointAuxSensitivityModelEvaluator_decl.hpp:21
Tempus::SOLVE_FOR_XDOT_CONST_X
@ SOLVE_FOR_XDOT_CONST_X
Solve for xDot keeping x constant (for ICs).
Definition
Tempus_WrapperModelEvaluator.hpp:22
Tempus::SOLVE_FOR_X
@ SOLVE_FOR_X
Solve for x and determine xDot from x.
Definition
Tempus_WrapperModelEvaluator.hpp:21
Tempus::EVALUATE_RESIDUAL
@ EVALUATE_RESIDUAL
Evaluate residual for the implicit ODE.
Definition
Tempus_WrapperModelEvaluator.hpp:20
Generated by
1.17.0