67int main(
int argc,
char *argv[])
73 Teuchos::RCP<const Thyra::ModelEvaluator<double> >
80 RCP<Thyra::VectorBase<double> > x_n =
81 model->getNominalValues().get_x()->clone_v();
82 RCP<Thyra::VectorBase<double> > xDot_n =
83 model->getNominalValues().get_x_dot()->clone_v();
86 double finalTime = 2.0;
87 int nTimeSteps = 2001;
88 const double constDT = finalTime/(nTimeSteps-1);
91 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
92 <<
" " << get_ele(*(x_n), 1) << endl;
93 while (passed && time < finalTime && n < nTimeSteps) {
96 RCP<Thyra::VectorBase<double> > x_np1 = x_n->clone_v();
104 auto inArgs = model->createInArgs();
105 auto outArgs = model->createOutArgs();
108 inArgs.set_x_dot(Teuchos::null);
109 outArgs.set_f(xDot_n);
112 model->evalModel(inArgs, outArgs);
115 Thyra::V_VpStV(x_np1.ptr(), *x_n, dt, *xDot_n);
118 if ( std::isnan(Thyra::norm(*x_np1)) ) {
122 Thyra::V_V(x_n.ptr(), *x_np1);
128 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
129 <<
" " << get_ele(*(x_n), 1) << endl;
133 RCP<Thyra::VectorBase<double> > x_regress = x_n->clone_v();
135 Thyra::DetachedVectorView<double> x_regress_view(*x_regress);
136 x_regress_view[0] = -1.59496108218721311;
137 x_regress_view[1] = 0.96359412806611255;
140 RCP<Thyra::VectorBase<double> > x_error = x_n->clone_v();
141 Thyra::V_VmV(x_error.ptr(), *x_n, *x_regress);
142 double x_L2norm_error = Thyra::norm_2(*x_error );
143 double x_L2norm_regress = Thyra::norm_2(*x_regress);
145 cout <<
"Relative L2 Norm of the error (regression) = "
146 << x_L2norm_error/x_L2norm_regress << endl;
147 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
149 cout <<
"FAILED regression constraint!" << endl;
152 RCP<Thyra::VectorBase<double> > x_best = x_n->clone_v();
154 Thyra::DetachedVectorView<double> x_best_view(*x_best);
155 x_best_view[0] = -1.59496108218721311;
156 x_best_view[1] = 0.96359412806611255;
159 Thyra::V_VmV(x_error.ptr(), *x_n, *x_best);
160 x_L2norm_error = Thyra::norm_2(*x_error);
161 double x_L2norm_best = Thyra::norm_2(*x_best );
163 cout <<
"Relative L2 Norm of the error (best) = "
164 << x_L2norm_error/x_L2norm_best << endl;
165 if ( x_L2norm_error > 0.02*x_L2norm_best) {
167 cout <<
"FAILED best constraint!" << endl;
169 if (passed) success =
true;
171 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
174 cout <<
"\nEnd Result: Test Passed!" << std::endl;
176 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );