9 #ifndef Tempus_WrapperModelEvaluatorSecondOrder_impl_hpp
10 #define Tempus_WrapperModelEvaluatorSecondOrder_impl_hpp
15 template <
typename Scalar>
16 Thyra::ModelEvaluatorBase::InArgs<Scalar>
20 #ifdef VERBOSE_DEBUG_OUTPUT
21 *out_ <<
"DEBUG: " << __PRETTY_FUNCTION__ <<
"\n";
23 typedef Thyra::ModelEvaluatorBase MEB;
25 MEB::InArgsSetup<Scalar> inArgs;
26 inArgs.setModelEvalDescription(this->description());
27 inArgs.set_Np(appModel_->Np());
28 inArgs.setSupports(MEB::IN_ARG_x);
30 return std::move(inArgs);
34 template <
typename Scalar>
35 Thyra::ModelEvaluatorBase::OutArgs<Scalar>
39 #ifdef VERBOSE_DEBUG_OUTPUT
40 *out_ <<
"DEBUG: " << __PRETTY_FUNCTION__ <<
"\n";
42 typedef Thyra::ModelEvaluatorBase MEB;
44 MEB::OutArgsSetup<Scalar> outArgs;
45 outArgs.setModelEvalDescription(this->description());
46 outArgs.set_Np_Ng(appModel_->Np(),0);
47 outArgs.setSupports(MEB::OUT_ARG_f);
48 outArgs.setSupports(MEB::OUT_ARG_W_op);
50 return std::move(outArgs);
54 template <
typename Scalar>
58 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
60 #ifdef VERBOSE_DEBUG_OUTPUT
61 *out_ <<
"DEBUG: " << __PRETTY_FUNCTION__ <<
"\n";
63 typedef Thyra::ModelEvaluatorBase MEB;
68 MEB::InArgs<Scalar> appInArgs = appModel_->createInArgs();
69 MEB::OutArgs<Scalar> appOutArgs = appModel_->createOutArgs();
73 case NEWMARK_IMPLICIT_AFORM: {
81 appInArgs.set_x_dot_dot(inArgs.get_x());
85 auto velocity = Thyra::createMember(inArgs.get_x()->space());
86 Thyra::V_StVpStV(velocity.ptr(),
87 Scalar(1.0), *v_pred_, delta_t_*gamma_, *inArgs.get_x());
88 appInArgs.set_x_dot(velocity);
92 auto displacement = Thyra::createMember(inArgs.get_x()->space());
93 Thyra::V_StVpStV(displacement.ptr(),
94 Scalar(1.0), *d_pred_, beta_*delta_t_*delta_t_, *inArgs.get_x());
95 appInArgs.set_x(displacement);
97 appInArgs.set_W_x_dot_dot_coeff(Scalar(1.0));
98 appInArgs.set_alpha(gamma_*delta_t_);
99 appInArgs.set_beta(beta_*delta_t_*delta_t_);
102 for (
int i=0; i<appModel_->Np(); ++i) {
103 if (inArgs.get_p(i) != Teuchos::null)
104 appInArgs.set_p(i, inArgs.get_p(i));
109 appOutArgs.set_f(outArgs.get_f());
110 appOutArgs.set_W_op(outArgs.get_W_op());
113 appModel_->evalModel(appInArgs,appOutArgs);
117 case NEWMARK_IMPLICIT_DFORM: {
120 RCP<Thyra::VectorBase<Scalar>
const>
123 RCP<Thyra::VectorBase<Scalar>>
124 v = Thyra::createMember(inArgs.get_x()->space());
126 RCP<Thyra::VectorBase<Scalar>>
127 a = Thyra::createMember(inArgs.get_x()->space());
130 Teuchos::Range1D range;
132 *out_ <<
"\n*** d_bef ***\n";
133 RTOpPack::ConstSubVectorView<Scalar> dov;
134 d->acquireDetachedView(range, &dov);
135 auto doa = dov.values();
136 for (
auto i = 0; i < doa.size(); ++i) *out_ << doa[i] <<
" ";
137 *out_ <<
"\n*** d_bef ***\n";
139 *out_ <<
"\n*** v_bef ***\n";
140 RTOpPack::ConstSubVectorView<Scalar> vov;
141 v->acquireDetachedView(range, &vov);
142 auto voa = vov.values();
143 for (
auto i = 0; i < voa.size(); ++i) *out_ << voa[i] <<
" ";
144 *out_ <<
"\n*** v_bef ***\n";
146 *out_ <<
"\n*** a_bef ***\n";
147 RTOpPack::ConstSubVectorView<Scalar> aov;
148 a->acquireDetachedView(range, &aov);
149 auto aoa = aov.values();
150 for (
auto i = 0; i < aoa.size(); ++i) *out_ << aoa[i] <<
" ";
151 *out_ <<
"\n*** a_bef ***\n";
155 c = 1.0 / beta_ / delta_t_ / delta_t_;
159 Thyra::V_StVpStV(Teuchos::ptrFromRef(*a), c, *d, -c, *d_pred_);
164 Teuchos::ptrFromRef(*v), 1.0, *v_pred_, delta_t_ * gamma_, *a);
167 appInArgs.set_x_dot(v);
168 appInArgs.set_x_dot_dot(a);
170 appInArgs.set_W_x_dot_dot_coeff(c);
171 appInArgs.set_alpha(gamma_ / delta_t_ / beta_);
172 appInArgs.set_beta(1.0);
175 for (
int i = 0; i < appModel_->Np(); ++i) {
176 if (inArgs.get_p(i) != Teuchos::null)
177 appInArgs.set_p(i, inArgs.get_p(i));
182 appOutArgs.set_f(outArgs.get_f());
183 appOutArgs.set_W_op(outArgs.get_W_op());
186 appModel_->evalModel(appInArgs, appOutArgs);
190 Thyra::V_StVpStV(Teuchos::ptrFromRef(*a), c, *d, -c, *d_pred_);
195 Teuchos::ptrFromRef(*v), 1.0, *v_pred_, delta_t_ * gamma_, *a);
198 appInArgs.set_x_dot(v);
199 appInArgs.set_x_dot_dot(a);
202 *out_ <<
"\n*** d_aft ***\n";
203 RTOpPack::ConstSubVectorView<Scalar> dnv;
204 d->acquireDetachedView(range, &dnv);
205 auto dna = dnv.values();
206 for (
auto i = 0; i < dna.size(); ++i) *out_ << dna[i] <<
" ";
207 *out_ <<
"\n*** d_aft ***\n";
209 *out_ <<
"\n*** v_aft ***\n";
210 RTOpPack::ConstSubVectorView<Scalar> vnv;
211 v->acquireDetachedView(range, &vnv);
212 auto vna = vnv.values();
213 for (
auto i = 0; i < vna.size(); ++i) *out_ << vna[i] <<
" ";
214 *out_ <<
"\n*** v_aft ***\n";
216 *out_ <<
"\n*** a_aft ***\n";
217 RTOpPack::ConstSubVectorView<Scalar> anv;
218 a->acquireDetachedView(range, &anv);
219 auto ana = anv.values();
220 for (
auto i = 0; i < ana.size(); ++i) *out_ << ana[i] <<
" ";
221 *out_ <<
"\n*** a_aft ***\n";
231 #endif // Tempus_WrapperModelEvaluatorSecondOrder_impl_hpp
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const