void IntegrationTestCase::readParameters (const string & testName) { setDefaultParameterValues (); if (CppUnitTestHelper::getArgc () > 1) { char * argv1 = CppUnitTestHelper::getArgv (1); if (strcmp (argv1, "help") == 0 || strcmp (argv1, "--help") == 0 || strcmp (argv1, "-h") == 0) { // nop general help asked ... just for listing } else { if (strstr (argv1, testName.c_str ()) == argv1) { // parameter for me if (CppUnitTestHelper::getArgc () > 2) { char * argv2 = CppUnitTestHelper::getArgv (2); if (argv2 != NULL && (strcmp (argv2, "help") == 0 || strcmp (argv2, "--help") == 0 || strcmp (argv2, "-h") == 0)) { usage (); } else { setParameterValues (); } } } else { fprintf (stderr, "Do not know what to do with this test '%s'", testName.c_str ()); } } } }
void run() { BOOST_TEST_MESSAGE( "test_eval_at_point D=" << DimGeo << " P=" << OrderPoly << "..." ); Environment::changeRepository( boost::format( "%1%/D%2%/P%3%" ) % Environment::about().appName() % DimGeo % OrderPoly ); auto mesh = loadMesh(_mesh = new Mesh<Simplex<DimGeo>>); auto Vh = Pchv<OrderPoly>( mesh ); auto u = Vh->element(); std::string e_str; if ( DimGeo == 2 ) e_str = "{x*x*y,x*y*y}:x:y"; else if ( DimGeo == 3 ) e_str = "{x*x*y*z,x*y*y*z,x*y*z*z}:x:y:z"; auto e = expr<DimGeo,1>( e_str ); u = vf::project(Vh,elements(mesh), e ); node_type pt(DimGeo); pt[0] = 0.5; if ( DimGeo >= 2 ) pt[1] = 0.5; if ( DimGeo >= 3 ) pt[2] = 0.5; auto eval = u(pt)[0]; auto e_eval = e.evaluate(); if ( DimGeo >= 2 ) { e.setParameterValues( { { "x", 0.5 },{ "y", 0.5 } } ); if ( DimGeo >= 3 ) e.setParameterValues( { { "x", 0.5 },{ "y", 0.5 }, { "z", 0.5 } } ); auto sol = e.evaluate(); double min = doption(_name="gmsh.hsize"); #if USE_BOOST_TEST if ( OrderPoly < 4 ) BOOST_CHECK_SMALL( (eval-sol).cwiseQuotient(sol).norm(), min ); else BOOST_CHECK_SMALL( (eval-sol).cwiseQuotient(sol).norm(), 1e-13 ); #else CHECK( (eval-sol).norm() < min ) << "Error in evaluation at point " << pt << " value = [ " << eval << " ] expected = [ " << sol << " ] "; #endif BOOST_TEST_MESSAGE( "test_eval_at_point D=" << DimGeo << " P=" << OrderPoly << "done" ); } }