82 Teuchos::RCP<const Thyra::ModelEvaluator<double> >
89 RCP<Thyra::VectorBase<double> > x_n =
90 model->getNominalValues().get_x()->clone_v();
91 RCP<Thyra::VectorBase<double> > xDot_n =
92 model->getNominalValues().get_x_dot()->clone_v();
95 double finalTime = 2.0;
96 int nTimeSteps = 2000;
97 const double constDT = finalTime/nTimeSteps;
101 cout << std::setw(8) <<
"index"
102 << std::setw(10) <<
"time"
103 << std::setw(12) <<
"x_0"
104 << std::setw(12) <<
"x_1" << endl;
106 cout << std::setw(8) << n
107 << std::setw(10) << std::setprecision(3) << time
108 << std::setw(12) << std::setprecision(4) << get_ele(*x_n, 0)
109 << std::setw(12) << std::setprecision(4) << get_ele(*x_n, 1) << endl;
112 while (passed && time < finalTime && n < nTimeSteps) {
115 RCP<Thyra::VectorBase<double> > x_np1 = x_n->clone_v();
123 auto inArgs = model->createInArgs();
124 auto outArgs = model->createOutArgs();
127 inArgs.set_x_dot(Teuchos::null);
128 outArgs.set_f(xDot_n);
131 model->evalModel(inArgs, outArgs);
134 Thyra::V_VpStV(x_np1.ptr(), *x_n, dt, *xDot_n);
137 if ( std::isnan(Thyra::norm(*x_np1)) ) {
141 Thyra::V_V(x_n.ptr(), *x_np1);
147 cout << std::setw(8) << n
148 << std::setw(10) << std::setprecision(3) << time
149 << std::setw(12) << std::setprecision(4) << get_ele(*x_n, 0)
150 << std::setw(12) << std::setprecision(4) << get_ele(*x_n, 1) << endl;
156 if (passed && regressionPassed) success =
true;
158 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
161 cout <<
"\nEnd Result: Test Passed!" << std::endl;
163 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
bool tutorialRegressionTest(const Teuchos::RCP< Thyra::VectorBase< double > > &x_n, std::ostream &out=std::cout, const double relTol=Teuchos::as< double >(1.0e-8))
Regression check for the Tempus tutorial van der Pol examples.