13 #include "Teuchos_StandardCatchMacros.hpp"
15 #include "Thyra_VectorStdOps.hpp"
16 #include "Thyra_DefaultSpmdVectorSpace.hpp"
17 #include "Thyra_DetachedVectorView.hpp"
202 int main(
int argc,
char *argv[])
205 bool success =
false;
216 model->getNominalValues().get_x()->clone_v();
218 model->getNominalValues().get_x_dot()->clone_v();
221 double finalTime = 2.0;
222 int nTimeSteps = 2001;
223 const double constDT = finalTime/(nTimeSteps-1);
226 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
227 <<
" " << get_ele(*(x_n), 1) << endl;
228 while (passed && time < finalTime && n < nTimeSteps) {
239 auto inArgs = model->createInArgs();
240 auto outArgs = model->createOutArgs();
243 inArgs.set_x_dot(Teuchos::null);
244 outArgs.set_f(xDot_n);
247 model->evalModel(inArgs, outArgs);
250 Thyra::V_VpStV(x_np1.
ptr(), *x_n, dt, *xDot_n);
253 if ( std::isnan(Thyra::norm(*x_np1)) ) {
257 Thyra::V_V(x_n.
ptr(), *x_np1);
263 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
264 <<
" " << get_ele(*(x_n), 1) << endl;
271 x_regress_view[0] = -1.59496108218721311;
272 x_regress_view[1] = 0.96359412806611255;
276 Thyra::V_VmV(x_error.
ptr(), *x_n, *x_regress);
277 double x_L2norm_error = Thyra::norm_2(*x_error );
278 double x_L2norm_regress = Thyra::norm_2(*x_regress);
280 cout <<
"Relative L2 Norm of the error (regression) = "
281 << x_L2norm_error/x_L2norm_regress << endl;
282 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
284 cout <<
"FAILED regression constraint!" << endl;
290 x_best_view[0] = -1.59496108218721311;
291 x_best_view[1] = 0.96359412806611255;
294 Thyra::V_VmV(x_error.
ptr(), *x_n, *x_best);
295 x_L2norm_error = Thyra::norm_2(*x_error);
296 double x_L2norm_best = Thyra::norm_2(*x_best );
298 cout <<
"Relative L2 Norm of the error (best) = "
299 << x_L2norm_error/x_L2norm_best << endl;
300 if ( x_L2norm_error > 0.02*x_L2norm_best) {
302 cout <<
"FAILED best constraint!" << endl;
304 if (passed) success =
true;
309 cout <<
"\nEnd Result: Test Passed!" << std::endl;
311 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
int main(int argc, char *argv[])
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
ModelEvaluator implementation for the example van der Pol Problem.
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)