14 #include "Teuchos_StandardCatchMacros.hpp"
217 int main(
int argc,
char *argv[])
220 bool success =
false;
229 double epsilon = 1.0e-1;
234 xDot_n[1] = -2.0/epsilon;
237 double finalTime = 2.0;
238 int nTimeSteps = 2001;
239 const double constDT = finalTime/(nTimeSteps-1);
242 cout << n <<
" " << time <<
" " << x_n[0] <<
" " << x_n[1] << endl;
243 while (passed && time < finalTime && n < nTimeSteps) {
256 xDot_n[1] = ((1.0 - x_n[0]*x_n[0])*x_n[1] - x_n[0])/epsilon;
259 x_np1[0] = x_n[0] + dt*xDot_n[0];
260 x_np1[1] = x_n[1] + dt*xDot_n[1];
263 if ( std::isnan(x_n[0]) || std::isnan(x_n[1]) ) {
274 cout << n <<
" " << time <<
" " << x_n[0] <<
" " << x_n[1] << endl;
280 x_regress[0] = -1.59496108218721311;
281 x_regress[1] = 0.96359412806611255;
282 double x_L2norm_error = 0.0;
283 double x_L2norm_regress = 0.0;
284 for (
int i=0; i < 2; i++) {
285 x_L2norm_error += (x_n[i]-x_regress[i])*(x_n[i]-x_regress[i]);
286 x_L2norm_regress += x_regress[1]*x_regress[1];
288 x_L2norm_error = sqrt(x_L2norm_error );
289 x_L2norm_regress = sqrt(x_L2norm_regress);
290 cout <<
"Relative L2 Norm of the error (regression) = "
291 << x_L2norm_error/x_L2norm_regress << endl;
292 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
294 cout <<
"FAILED regression constraint!" << endl;
298 x_best[0] = -1.58184083624543947;
299 x_best[1] = 0.97844890081968072;
300 x_L2norm_error = 0.0;
301 double x_L2norm_best = 0.0;
302 for (
int i=0; i < 2; i++) {
303 x_L2norm_error += (x_n[i]-x_best[i])*(x_n[i]-x_best[i]);
304 x_L2norm_best += x_best[1]*x_best[1];
306 x_L2norm_error = sqrt(x_L2norm_error);
307 x_L2norm_best = sqrt(x_L2norm_best );
308 cout <<
"Relative L2 Norm of the error (best) = "
309 << x_L2norm_error/x_L2norm_best << endl;
310 if ( x_L2norm_error > 0.02*x_L2norm_best) {
312 cout <<
"FAILED best constraint!" << endl;
314 if (passed) success =
true;
319 cout <<
"\nEnd Result: Test Passed!" << std::endl;
321 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
int main(int argc, char *argv[])
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)