66int main(
int argc,
char *argv[])
72 Teuchos::RCP<const Thyra::ModelEvaluator<double> >
79 RCP<Thyra::VectorBase<double> > x_n =
80 model->getNominalValues().get_x()->clone_v();
81 RCP<Thyra::VectorBase<double> > xDot_n =
82 model->getNominalValues().get_x_dot()->clone_v();
85 double finalTime = 2.0;
86 int nTimeSteps = 2000;
87 const double constDT = finalTime/nTimeSteps;
90 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
91 <<
" " << get_ele(*(x_n), 1) << endl;
92 while (passed && time < finalTime && n < nTimeSteps) {
95 RCP<Thyra::VectorBase<double> > x_np1 = x_n->clone_v();
103 auto inArgs = model->createInArgs();
104 auto outArgs = model->createOutArgs();
107 inArgs.set_x_dot(Teuchos::null);
108 outArgs.set_f(xDot_n);
111 model->evalModel(inArgs, outArgs);
114 Thyra::V_VpStV(x_np1.ptr(), *x_n, dt, *xDot_n);
117 if ( std::isnan(Thyra::norm(*x_np1)) ) {
121 Thyra::V_V(x_n.ptr(), *x_np1);
127 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
128 <<
" " << get_ele(*(x_n), 1) << endl;
132 RCP<Thyra::VectorBase<double> > x_regress = x_n->clone_v();
134 Thyra::DetachedVectorView<double> x_regress_view(*x_regress);
135 x_regress_view[0] = -1.59496108218721311;
136 x_regress_view[1] = 0.96359412806611255;
139 RCP<Thyra::VectorBase<double> > x_error = x_n->clone_v();
140 Thyra::V_VmV(x_error.ptr(), *x_n, *x_regress);
141 double x_L2norm_error = Thyra::norm_2(*x_error );
142 double x_L2norm_regress = Thyra::norm_2(*x_regress);
144 cout <<
"Relative L2 Norm of the error (regression) = "
145 << x_L2norm_error/x_L2norm_regress << endl;
146 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
148 cout <<
"FAILED regression constraint!" << endl;
150 if (passed) success =
true;
152 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
155 cout <<
"\nEnd Result: Test Passed!" << std::endl;
157 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );