13 #include "Teuchos_StandardCatchMacros.hpp"
15 #include "Thyra_VectorStdOps.hpp"
16 #include "Thyra_DefaultSpmdVectorSpace.hpp"
17 #include "Thyra_DetachedVectorView.hpp"
213 int main(
int argc,
char *argv[])
216 bool success =
false;
219 int vectorLength = 2;
221 Thyra::defaultSpmdVectorSpace<double>(vectorLength);
229 double epsilon = 1.0e-1;
236 xDot_n_view[0] = 0.0;
237 xDot_n_view[1] = -2.0/epsilon;
241 double finalTime = 2.0;
242 int nTimeSteps = 2001;
243 const double constDT = finalTime/(nTimeSteps-1);
246 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
247 <<
" " << get_ele(*(x_n), 1) << endl;
248 while (passed && time < finalTime && n < nTimeSteps) {
261 xDot_n_view[0] = x_n_view[1];
263 ((1.0-x_n_view[0]*x_n_view[0])*x_n_view[1]-x_n_view[0])/epsilon;
267 Thyra::V_VpStV(x_np1.
ptr(), *x_n, dt, *xDot_n);
270 if ( std::isnan(Thyra::norm(*x_np1)) ) {
274 Thyra::V_V(x_n.ptr(), *x_np1);
280 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
281 <<
" " << get_ele(*(x_n), 1) << endl;
288 x_regress_view[0] = -1.59496108218721311;
289 x_regress_view[1] = 0.96359412806611255;
293 Thyra::V_VmV(x_error.
ptr(), *x_n, *x_regress);
294 double x_L2norm_error = Thyra::norm_2(*x_error );
295 double x_L2norm_regress = Thyra::norm_2(*x_regress);
297 cout <<
"Relative L2 Norm of the error (regression) = "
298 << x_L2norm_error/x_L2norm_regress << endl;
299 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
301 cout <<
"FAILED regression constraint!" << endl;
307 x_best_view[0] = -1.59496108218721311;
308 x_best_view[1] = 0.96359412806611255;
311 Thyra::V_VmV(x_error.
ptr(), *x_n, *x_best);
312 x_L2norm_error = Thyra::norm_2(*x_error);
313 double x_L2norm_best = Thyra::norm_2(*x_best );
315 cout <<
"Relative L2 Norm of the error (best) = "
316 << x_L2norm_error/x_L2norm_best << endl;
317 if ( x_L2norm_error > 0.02*x_L2norm_best) {
319 cout <<
"FAILED best constraint!" << endl;
321 if (passed) success =
true;
326 cout <<
"\nEnd Result: Test Passed!" << std::endl;
328 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
int main(int argc, char *argv[])
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)