198int main(
int argc,
char *argv[])
201 bool success =
false;
204 Teuchos::RCP<const Thyra::ModelEvaluator<double> >
205 model = Teuchos::rcp(
new VanDerPol_ModelEvaluator_02<double>());
208 RCP<Thyra::VectorBase<double> > x_n =
209 model->getNominalValues().get_x()->clone_v();
210 RCP<Thyra::VectorBase<double> > xDot_n =
211 model->getNominalValues().get_x_dot()->clone_v();
215 double finalTime = 2.0;
216 int nTimeSteps = 2001;
217 const double constDT = finalTime/(nTimeSteps-1);
222 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
223 <<
" " << get_ele(*(x_n), 1) << endl;
224 while (passing && time < finalTime && n < nTimeSteps) {
227 RCP<Thyra::VectorBase<double> > x_np1 = x_n->clone_v();
235 auto inArgs = model->createInArgs();
236 auto outArgs = model->createOutArgs();
239 inArgs.set_x_dot(Teuchos::null);
240 outArgs.set_f(xDot_n);
243 model->evalModel(inArgs, outArgs);
246 Thyra::V_VpStV(x_np1.ptr(), *x_n, dt, *xDot_n);
249 if ( std::isnan(Thyra::norm(*x_np1)) ) {
254 Thyra::V_V(x_n.ptr(), *x_np1);
259 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
260 <<
" " << get_ele(*(x_n), 1) << endl;
264 RCP<Thyra::VectorBase<double> > x_regress = x_n->clone_v();
266 Thyra::DetachedVectorView<double> x_regress_view(*x_regress);
267 x_regress_view[0] = -1.59496108218721311;
268 x_regress_view[1] = 0.96359412806611255;
271 RCP<Thyra::VectorBase<double> > x_error = x_n->clone_v();
272 Thyra::V_VmV(x_error.ptr(), *x_n, *x_regress);
273 double x_L2norm_error = Thyra::norm_2(*x_error );
274 double x_L2norm_regress = Thyra::norm_2(*x_regress);
276 cout <<
"Relative L2 Norm of the error (regression) = "
277 << x_L2norm_error/x_L2norm_regress << endl;
278 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
280 cout <<
"FAILED regression constraint!" << endl;
283 RCP<Thyra::VectorBase<double> > x_best = x_n->clone_v();
285 Thyra::DetachedVectorView<double> x_best_view(*x_best);
286 x_best_view[0] = -1.59496108218721311;
287 x_best_view[1] = 0.96359412806611255;
290 Thyra::V_VmV(x_error.ptr(), *x_n, *x_best);
291 x_L2norm_error = Thyra::norm_2(*x_error);
292 double x_L2norm_best = Thyra::norm_2(*x_best );
294 cout <<
"Relative L2 Norm of the error (best) = "
295 << x_L2norm_error/x_L2norm_best << endl;
296 if ( x_L2norm_error > 0.02*x_L2norm_best) {
298 cout <<
"FAILED best constraint!" << endl;
300 if (passing) success =
true;
302 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
305 cout <<
"\nEnd Result: Test Passed!" << std::endl;
307 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );