10 #ifndef Tempus_WrapperModelEvaluatorSecondOrder_impl_hpp
11 #define Tempus_WrapperModelEvaluatorSecondOrder_impl_hpp
15 template <
typename Scalar>
19 #ifdef VERBOSE_DEBUG_OUTPUT
20 *out_ <<
"DEBUG: " << __PRETTY_FUNCTION__ <<
"\n";
24 MEB::InArgsSetup<Scalar> inArgs;
25 inArgs.setModelEvalDescription(this->description());
26 inArgs.set_Np(appModel_->Np());
27 inArgs.setSupports(MEB::IN_ARG_x);
29 return std::move(inArgs);
32 template <
typename Scalar>
36 #ifdef VERBOSE_DEBUG_OUTPUT
37 *out_ <<
"DEBUG: " << __PRETTY_FUNCTION__ <<
"\n";
41 MEB::OutArgsSetup<Scalar> outArgs;
42 outArgs.setModelEvalDescription(this->description());
43 outArgs.set_Np_Ng(appModel_->Np(), 0);
44 outArgs.setSupports(MEB::OUT_ARG_f);
45 outArgs.setSupports(MEB::OUT_ARG_W_op);
47 return std::move(outArgs);
50 template <
typename Scalar>
55 #ifdef VERBOSE_DEBUG_OUTPUT
56 *out_ <<
"DEBUG: " << __PRETTY_FUNCTION__ <<
"\n";
63 MEB::InArgs<Scalar> appInArgs = appModel_->createInArgs();
64 MEB::OutArgs<Scalar> appOutArgs = appModel_->createOutArgs();
66 switch (schemeType_) {
67 case NEWMARK_IMPLICIT_AFORM: {
75 appInArgs.set_x_dot_dot(inArgs.
get_x());
79 auto velocity = Thyra::createMember(inArgs.
get_x()->space());
80 Thyra::V_StVpStV(velocity.ptr(), Scalar(1.0), *v_pred_, delta_t_ * gamma_,
82 appInArgs.set_x_dot(velocity);
86 auto displacement = Thyra::createMember(inArgs.
get_x()->space());
87 Thyra::V_StVpStV(displacement.ptr(), Scalar(1.0), *d_pred_,
88 beta_ * delta_t_ * delta_t_, *inArgs.
get_x());
89 appInArgs.set_x(displacement);
91 appInArgs.set_W_x_dot_dot_coeff(Scalar(1.0));
92 appInArgs.set_alpha(gamma_ * delta_t_);
93 appInArgs.set_beta(beta_ * delta_t_ * delta_t_);
96 for (
int i = 0; i < appModel_->Np(); ++i) {
97 if (inArgs.
get_p(i) != Teuchos::null)
98 appInArgs.set_p(i, inArgs.
get_p(i));
103 appOutArgs.set_f(outArgs.
get_f());
104 appOutArgs.set_W_op(outArgs.
get_W_op());
107 appModel_->evalModel(appInArgs, appOutArgs);
111 case NEWMARK_IMPLICIT_DFORM: {
114 RCP<Thyra::VectorBase<Scalar>
const> d = inArgs.
get_x();
116 RCP<Thyra::VectorBase<Scalar>> v =
117 Thyra::createMember(inArgs.
get_x()->space());
119 RCP<Thyra::VectorBase<Scalar>> a =
120 Thyra::createMember(inArgs.
get_x()->space());
125 *out_ <<
"\n*** d_bef ***\n";
126 RTOpPack::ConstSubVectorView<Scalar> dov;
127 d->acquireDetachedView(range, &dov);
128 auto doa = dov.values();
129 for (
auto i = 0; i < doa.size(); ++i) *out_ << doa[i] <<
" ";
130 *out_ <<
"\n*** d_bef ***\n";
132 *out_ <<
"\n*** v_bef ***\n";
133 RTOpPack::ConstSubVectorView<Scalar> vov;
134 v->acquireDetachedView(range, &vov);
135 auto voa = vov.values();
136 for (
auto i = 0; i < voa.size(); ++i) *out_ << voa[i] <<
" ";
137 *out_ <<
"\n*** v_bef ***\n";
139 *out_ <<
"\n*** a_bef ***\n";
140 RTOpPack::ConstSubVectorView<Scalar> aov;
141 a->acquireDetachedView(range, &aov);
142 auto aoa = aov.values();
143 for (
auto i = 0; i < aoa.size(); ++i) *out_ << aoa[i] <<
" ";
144 *out_ <<
"\n*** a_bef ***\n";
147 Scalar
const c = 1.0 / beta_ / delta_t_ / delta_t_;
151 Thyra::V_StVpStV(Teuchos::ptrFromRef(*a), c, *d, -c, *d_pred_);
155 Thyra::V_StVpStV(Teuchos::ptrFromRef(*v), 1.0, *v_pred_,
156 delta_t_ * gamma_, *a);
159 appInArgs.set_x_dot(v);
160 appInArgs.set_x_dot_dot(a);
162 appInArgs.set_W_x_dot_dot_coeff(c);
163 appInArgs.set_alpha(gamma_ / delta_t_ / beta_);
164 appInArgs.set_beta(1.0);
167 for (
int i = 0; i < appModel_->Np(); ++i) {
168 if (inArgs.
get_p(i) != Teuchos::null)
169 appInArgs.set_p(i, inArgs.
get_p(i));
174 appOutArgs.set_f(outArgs.
get_f());
175 appOutArgs.set_W_op(outArgs.
get_W_op());
178 appModel_->evalModel(appInArgs, appOutArgs);
182 Thyra::V_StVpStV(Teuchos::ptrFromRef(*a), c, *d, -c, *d_pred_);
186 Thyra::V_StVpStV(Teuchos::ptrFromRef(*v), 1.0, *v_pred_,
187 delta_t_ * gamma_, *a);
190 appInArgs.set_x_dot(v);
191 appInArgs.set_x_dot_dot(a);
194 *out_ <<
"\n*** d_aft ***\n";
195 RTOpPack::ConstSubVectorView<Scalar> dnv;
196 d->acquireDetachedView(range, &dnv);
197 auto dna = dnv.values();
198 for (
auto i = 0; i < dna.size(); ++i) *out_ << dna[i] <<
" ";
199 *out_ <<
"\n*** d_aft ***\n";
201 *out_ <<
"\n*** v_aft ***\n";
202 RTOpPack::ConstSubVectorView<Scalar> vnv;
203 v->acquireDetachedView(range, &vnv);
204 auto vna = vnv.values();
205 for (
auto i = 0; i < vna.size(); ++i) *out_ << vna[i] <<
" ";
206 *out_ <<
"\n*** v_aft ***\n";
208 *out_ <<
"\n*** a_aft ***\n";
209 RTOpPack::ConstSubVectorView<Scalar> anv;
210 a->acquireDetachedView(range, &anv);
211 auto ana = anv.values();
212 for (
auto i = 0; i < ana.size(); ++i) *out_ << ana[i] <<
" ";
213 *out_ <<
"\n*** a_aft ***\n";
222 #endif // Tempus_WrapperModelEvaluatorSecondOrder_impl_hpp
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
Evaluation< VectorBase< Scalar > > get_f() const
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
RCP< LinearOpBase< Scalar > > get_W_op() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
RCP< const VectorBase< Scalar > > get_x() const
RCP< const VectorBase< Scalar > > get_p(int l) const