14 #include "Teuchos_StandardCatchMacros.hpp"
16 #include "Thyra_VectorStdOps.hpp"
17 #include "Thyra_DefaultSpmdVectorSpace.hpp"
18 #include "Thyra_DetachedVectorView.hpp"
214 int main(
int argc,
char *argv[])
217 bool success =
false;
220 int vectorLength = 2;
222 Thyra::defaultSpmdVectorSpace<double>(vectorLength);
230 double epsilon = 1.0e-1;
237 xDot_n_view[0] = 0.0;
238 xDot_n_view[1] = -2.0/epsilon;
242 double finalTime = 2.0;
243 int nTimeSteps = 2001;
244 const double constDT = finalTime/(nTimeSteps-1);
247 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
248 <<
" " << get_ele(*(x_n), 1) << endl;
249 while (passed && time < finalTime && n < nTimeSteps) {
262 xDot_n_view[0] = x_n_view[1];
264 ((1.0-x_n_view[0]*x_n_view[0])*x_n_view[1]-x_n_view[0])/epsilon;
268 Thyra::V_VpStV(x_np1.
ptr(), *x_n, dt, *xDot_n);
271 if ( std::isnan(Thyra::norm(*x_np1)) ) {
275 Thyra::V_V(x_n.ptr(), *x_np1);
281 cout << n <<
" " << time <<
" " << get_ele(*(x_n), 0)
282 <<
" " << get_ele(*(x_n), 1) << endl;
289 x_regress_view[0] = -1.59496108218721311;
290 x_regress_view[1] = 0.96359412806611255;
294 Thyra::V_VmV(x_error.
ptr(), *x_n, *x_regress);
295 double x_L2norm_error = Thyra::norm_2(*x_error );
296 double x_L2norm_regress = Thyra::norm_2(*x_regress);
298 cout <<
"Relative L2 Norm of the error (regression) = "
299 << x_L2norm_error/x_L2norm_regress << endl;
300 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
302 cout <<
"FAILED regression constraint!" << endl;
308 x_best_view[0] = -1.59496108218721311;
309 x_best_view[1] = 0.96359412806611255;
312 Thyra::V_VmV(x_error.
ptr(), *x_n, *x_best);
313 x_L2norm_error = Thyra::norm_2(*x_error);
314 double x_L2norm_best = Thyra::norm_2(*x_best );
316 cout <<
"Relative L2 Norm of the error (best) = "
317 << x_L2norm_error/x_L2norm_best << endl;
318 if ( x_L2norm_error > 0.02*x_L2norm_best) {
320 cout <<
"FAILED best constraint!" << endl;
322 if (passed) success =
true;
327 cout <<
"\nEnd Result: Test Passed!" << std::endl;
329 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
int main(int argc, char *argv[])
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)