101 "Error, setupInOutArgs_ must be called first!\n");
102 Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs =
inArgs_;
106 TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(j, 0,
np_);
112 inArgs.set_t(exact_t);
113 Teuchos::RCP<Thyra::VectorBase<Scalar> > exact_s = createMember(
x_space_);
115 Thyra::DetachedVectorView<Scalar> exact_s_view(*exact_s);
117 exact_s_view[0] = 1.0;
118 exact_s_view[1] = 0.0;
121 exact_s_view[0] = (b / L) * t * cos((f / L) * t + phi);
122 exact_s_view[1] = (b / L) * cos((f / L) * t + phi) -
123 (b * f * t / (L * L)) * sin((f / L) * t + phi);
126 exact_s_view[0] = -(b * f * t / (L * L)) * cos((f / L) * t + phi);
127 exact_s_view[1] = -(b * f / (L * L)) * cos((f / L) * t + phi) +
128 (b * f * f * t / (L * L * L)) * sin((f / L) * t + phi);
131 inArgs.set_x(exact_s);
132 Teuchos::RCP<Thyra::VectorBase<Scalar> > exact_s_dot = createMember(
x_space_);
134 Thyra::DetachedVectorView<Scalar> exact_s_dot_view(*exact_s_dot);
136 exact_s_dot_view[0] = 0.0;
137 exact_s_dot_view[1] = 0.0;
140 exact_s_dot_view[0] = (b / L) * cos((f / L) * t + phi) -
141 (b * f * t / (L * L)) * sin((f / L) * t + phi);
142 exact_s_dot_view[1] =
143 -(2.0 * b * f / (L * L)) * sin((f / L) * t + phi) -
144 (b * f * f * t / (L * L * L)) * cos((f / L) * t + phi);
147 exact_s_dot_view[0] =
148 -(b * f / (L * L)) * cos((f / L) * t + phi) +
149 (b * f * f * t / (L * L * L)) * sin((f / L) * t + phi);
150 exact_s_dot_view[1] =
151 (2.0 * b * f * f / (L * L * L)) * sin((f / L) * t + phi) +
152 (b * f * f * f * t / (L * L * L * L)) * cos((f / L) * t + phi);
155 inArgs.set_x_dot(exact_s_dot);
275 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
276 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
278 typedef Thyra::DefaultMultiVectorProductVector<Scalar> DMVPV;
280 using Teuchos::rcp_dynamic_cast;
284 "Error, setupInOutArgs_ must be called first!\n");
286 const RCP<const VectorBase<Scalar> > x_in = inArgs.get_x().assert_not_null();
287 Thyra::ConstDetachedVectorView<Scalar> x_in_view(*x_in);
294 const RCP<const VectorBase<Scalar> > p_in =
295 inArgs.get_p(0).assert_not_null();
296 Thyra::ConstDetachedVectorView<Scalar> p_in_view(*p_in);
302 RCP<const MultiVectorBase<Scalar> > DxDp_in, DxdotDp_in;
304 if (inArgs.get_p(1) != Teuchos::null)
306 rcp_dynamic_cast<const DMVPV>(inArgs.get_p(1))->getMultiVector();
307 if (inArgs.get_p(2) != Teuchos::null)
309 rcp_dynamic_cast<const DMVPV>(inArgs.get_p(2))->getMultiVector();
312 Scalar beta = inArgs.get_beta();
314 const RCP<VectorBase<Scalar> > f_out = outArgs.get_f();
315 const RCP<Thyra::LinearOpBase<Scalar> > W_out = outArgs.get_W_op();
316 RCP<Thyra::MultiVectorBase<Scalar> > DfDp_out;
318 Thyra::ModelEvaluatorBase::Derivative<Scalar> DfDp = outArgs.get_DfDp(0);
319 DfDp_out = DfDp.getMultiVector();
322 if (inArgs.get_x_dot().is_null()) {
324 if (!is_null(f_out)) {
325 Thyra::DetachedVectorView<Scalar> f_out_view(*f_out);
326 f_out_view[0] = x_in_view[1];
327 f_out_view[1] = (f / L) * (f / L) * (a - x_in_view[0]);
329 if (!is_null(W_out)) {
330 RCP<Thyra::MultiVectorBase<Scalar> > matrix =
331 Teuchos::rcp_dynamic_cast<Thyra::MultiVectorBase<Scalar> >(W_out,
333 Thyra::DetachedMultiVectorView<Scalar> matrix_view(*matrix);
334 matrix_view(0, 0) = 0.0;
335 matrix_view(0, 1) = +beta;
336 matrix_view(1, 0) = -beta * (f / L) * (f / L);
337 matrix_view(1, 1) = 0.0;
340 if (!is_null(DfDp_out)) {
341 Thyra::DetachedMultiVectorView<Scalar> DfDp_out_view(*DfDp_out);
342 DfDp_out_view(0, 0) = 0.0;
343 DfDp_out_view(0, 1) = 0.0;
344 DfDp_out_view(0, 2) = 0.0;
345 DfDp_out_view(1, 0) = (f / L) * (f / L);
346 DfDp_out_view(1, 1) = (2.0 * f / (L * L)) * (a - x_in_view[0]);
347 DfDp_out_view(1, 2) = -(2.0 * f * f / (L * L * L)) * (a - x_in_view[0]);
351 Thyra::ConstDetachedMultiVectorView<Scalar> DxDp(*DxDp_in);
352 DfDp_out_view(0, 0) += DxDp(1, 0);
353 DfDp_out_view(0, 1) += DxDp(1, 1);
354 DfDp_out_view(0, 2) += DxDp(1, 2);
355 DfDp_out_view(1, 0) += -(f / L) * (f / L) * DxDp(0, 0);
356 DfDp_out_view(1, 1) += -(f / L) * (f / L) * DxDp(0, 1);
357 DfDp_out_view(1, 2) += -(f / L) * (f / L) * DxDp(0, 2);
363 RCP<const VectorBase<Scalar> > x_dot_in;
364 x_dot_in = inArgs.get_x_dot().assert_not_null();
365 Scalar alpha = inArgs.get_alpha();
366 if (!is_null(f_out)) {
367 Thyra::DetachedVectorView<Scalar> f_out_view(*f_out);
368 Thyra::ConstDetachedVectorView<Scalar> x_dot_in_view(*x_dot_in);
369 f_out_view[0] = x_dot_in_view[0] - x_in_view[1];
370 f_out_view[1] = x_dot_in_view[1] - (f / L) * (f / L) * (a - x_in_view[0]);
372 if (!is_null(W_out)) {
373 RCP<Thyra::MultiVectorBase<Scalar> > matrix =
374 Teuchos::rcp_dynamic_cast<Thyra::MultiVectorBase<Scalar> >(W_out,
376 Thyra::DetachedMultiVectorView<Scalar> matrix_view(*matrix);
377 matrix_view(0, 0) = alpha;
378 matrix_view(0, 1) = -beta;
379 matrix_view(1, 0) = +beta * (f / L) * (f / L);
380 matrix_view(1, 1) = alpha;
383 if (!is_null(DfDp_out)) {
384 Thyra::DetachedMultiVectorView<Scalar> DfDp_out_view(*DfDp_out);
385 DfDp_out_view(0, 0) = 0.0;
386 DfDp_out_view(0, 1) = 0.0;
387 DfDp_out_view(0, 2) = 0.0;
388 DfDp_out_view(1, 0) = -(f / L) * (f / L);
389 DfDp_out_view(1, 1) = -(2.0 * f / (L * L)) * (a - x_in_view[0]);
390 DfDp_out_view(1, 2) = +(2.0 * f * f / (L * L * L)) * (a - x_in_view[0]);
394 Thyra::ConstDetachedMultiVectorView<Scalar> DxdotDp(*DxdotDp_in);
395 DfDp_out_view(0, 0) += DxdotDp(0, 0);
396 DfDp_out_view(0, 1) += DxdotDp(0, 1);
397 DfDp_out_view(0, 2) += DxdotDp(0, 2);
398 DfDp_out_view(1, 0) += DxdotDp(1, 0);
399 DfDp_out_view(1, 1) += DxdotDp(1, 1);
400 DfDp_out_view(1, 2) += DxdotDp(1, 2);
403 Thyra::ConstDetachedMultiVectorView<Scalar> DxDp(*DxDp_in);
404 DfDp_out_view(0, 0) += -DxDp(1, 0);
405 DfDp_out_view(0, 1) += -DxDp(1, 1);
406 DfDp_out_view(0, 2) += -DxDp(1, 2);
407 DfDp_out_view(1, 0) += (f / L) * (f / L) * DxDp(0, 0);
408 DfDp_out_view(1, 1) += (f / L) * (f / L) * DxDp(0, 1);
409 DfDp_out_view(1, 2) += (f / L) * (f / L) * DxDp(0, 2);
416 RCP<VectorBase<Scalar> > g_out = outArgs.get_g(0);
417 if (g_out != Teuchos::null) Thyra::assign(g_out.ptr(), *x_in);
419 RCP<Thyra::MultiVectorBase<Scalar> > DgDp_out =
420 outArgs.get_DgDp(0, 0).getMultiVector();
421 if (DgDp_out != Teuchos::null) Thyra::assign(DgDp_out.ptr(), Scalar(0.0));
423 RCP<Thyra::MultiVectorBase<Scalar> > DgDx_out =
424 outArgs.get_DgDx(0).getMultiVector();
425 if (DgDx_out != Teuchos::null) {
426 Thyra::DetachedMultiVectorView<Scalar> DgDx_out_view(*DgDx_out);
427 DgDx_out_view(0, 0) = 1.0;
428 DgDx_out_view(0, 1) = 0.0;
429 DgDx_out_view(1, 0) = 0.0;
430 DgDx_out_view(1, 1) = 1.0;
696 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
697 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
700 using Teuchos::rcp_dynamic_cast;
703 TEUCHOS_TEST_FOR_EXCEPTION(!this->
isInitialized_, std::logic_error,
704 "Error, setupInOutArgs_ must be called first!\n");
706 const RCP<const VectorBase<Scalar> > x_in = inArgs.get_x().assert_not_null();
707 Thyra::ConstDetachedVectorView<Scalar> x_in_view(*x_in);
714 const RCP<const VectorBase<Scalar> > p_in =
715 inArgs.get_p(0).assert_not_null();
716 Thyra::ConstDetachedVectorView<Scalar> p_in_view(*p_in);
722 Scalar beta = inArgs.get_beta();
724 const RCP<Thyra::LinearOpBase<Scalar> > W_out = outArgs.get_W_op();
725 if (inArgs.get_x_dot().is_null()) {
727 if (!is_null(W_out)) {
728 RCP<Thyra::MultiVectorBase<Scalar> > matrix =
729 Teuchos::rcp_dynamic_cast<Thyra::MultiVectorBase<Scalar> >(W_out,
731 Thyra::DetachedMultiVectorView<Scalar> matrix_view(*matrix);
732 matrix_view(0, 0) = 0.0;
733 matrix_view(1, 0) = +beta;
734 matrix_view(0, 1) = -beta * (f / L) * (f / L);
735 matrix_view(1, 1) = 0.0;
741 RCP<const VectorBase<Scalar> > x_dot_in;
742 x_dot_in = inArgs.get_x_dot().assert_not_null();
743 Scalar alpha = inArgs.get_alpha();
744 if (!is_null(W_out)) {
745 RCP<Thyra::MultiVectorBase<Scalar> > matrix =
746 Teuchos::rcp_dynamic_cast<Thyra::MultiVectorBase<Scalar> >(W_out,
748 Thyra::DetachedMultiVectorView<Scalar> matrix_view(*matrix);
749 matrix_view(0, 0) = alpha;
750 matrix_view(1, 0) = -beta;
751 matrix_view(0, 1) = +beta * (f / L) * (f / L);
752 matrix_view(1, 1) = alpha;