MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Public Member Functions | |
void | setUp () |
void | test_gradient_values (bool constant) |
void | test_gradient_constant () |
void | test_gradient_linear () |
void | test_handles_eval_failure () |
void | test_handles_eval_false () |
void | test_changed () |
void | test_unchanged () |
void | test_Hessian_fails () |
Private Member Functions | |
CPPUNIT_TEST_SUITE (NumericalOFTest) | |
CPPUNIT_TEST (test_gradient_constant) | |
CPPUNIT_TEST (test_gradient_linear) | |
CPPUNIT_TEST (test_handles_eval_failure) | |
CPPUNIT_TEST (test_handles_eval_false) | |
CPPUNIT_TEST (test_changed) | |
CPPUNIT_TEST (test_unchanged) | |
CPPUNIT_TEST (test_Hessian_fails) | |
CPPUNIT_TEST_SUITE_END () | |
Private Attributes | |
PatchData | pd |
Definition at line 45 of file NumericalOFTest.cpp.
NumericalOFTest::CPPUNIT_TEST | ( | test_gradient_constant | ) | [private] |
NumericalOFTest::CPPUNIT_TEST | ( | test_gradient_linear | ) | [private] |
NumericalOFTest::CPPUNIT_TEST | ( | test_handles_eval_failure | ) | [private] |
NumericalOFTest::CPPUNIT_TEST | ( | test_handles_eval_false | ) | [private] |
NumericalOFTest::CPPUNIT_TEST | ( | test_changed | ) | [private] |
NumericalOFTest::CPPUNIT_TEST | ( | test_unchanged | ) | [private] |
NumericalOFTest::CPPUNIT_TEST | ( | test_Hessian_fails | ) | [private] |
NumericalOFTest::CPPUNIT_TEST_SUITE | ( | NumericalOFTest | ) | [private] |
NumericalOFTest::CPPUNIT_TEST_SUITE_END | ( | ) | [private] |
void NumericalOFTest::setUp | ( | ) |
Definition at line 149 of file NumericalOFTest.cpp.
References ASSERT_NO_ERROR, and MBMesquite::TRIANGLE.
{ MsqPrintError err( std::cout ); // Create a triangle mesh with three free vertices const double coords[] = { 1, 1, 0, 2, 1, 0, 3, 1, 0, 2, 2, 0, 1, 3, 0, 1, 2, 0 }; const bool fixed_vtx[] = { true, false, true, false, true, false }; const size_t tri_conn[] = { 0, 1, 5, 1, 2, 3, 3, 4, 5, 1, 3, 5 }; pd.fill( 6, coords, 4, TRIANGLE, tri_conn, fixed_vtx, err ); ASSERT_NO_ERROR( err ); }
void NumericalOFTest::test_changed | ( | ) |
Definition at line 201 of file NumericalOFTest.cpp.
References ASSERT_NO_ERROR, NumericalTestOF::changed, CPPUNIT_ASSERT, MBMesquite::ObjectiveFunction::evaluate_with_gradient(), MBMesquite::gradient(), MBMesquite::ObjectiveFunction::SAVE, MBMesquite::ObjectiveFunction::UPDATE, and value().
{ MsqPrintError err( cout ); NumericalTestOF func( false, false, true ); double value; vector< Vector3D > gradient; bool rval; func.changed = false; rval = func.evaluate_with_gradient( ObjectiveFunction::SAVE, pd, value, gradient, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT( func.changed ); func.changed = false; rval = func.evaluate_with_gradient( ObjectiveFunction::UPDATE, pd, value, gradient, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT( func.changed ); }
void NumericalOFTest::test_gradient_constant | ( | ) | [inline] |
Definition at line 64 of file NumericalOFTest.cpp.
{ test_gradient_values( true ); }
void NumericalOFTest::test_gradient_linear | ( | ) | [inline] |
Definition at line 68 of file NumericalOFTest.cpp.
{ test_gradient_values( false ); }
void NumericalOFTest::test_gradient_values | ( | bool | constant | ) |
Definition at line 161 of file NumericalOFTest.cpp.
References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::EPSILON, MBMesquite::ObjectiveFunction::evaluate_with_gradient(), MBMesquite::gradient(), NumericalTestOF::linearGrad, and value().
{ NumericalTestOF func( false, false, constant ); MsqPrintError err( std::cout ); double value; vector< Vector3D > gradient; bool rval = func.evaluate_with_gradient( ObjectiveFunction::CALCULATE, pd, value, gradient, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); Vector3D expected = constant ? Vector3D( 0, 0, 0 ) : func.linearGrad; CPPUNIT_ASSERT( gradient.size() == pd.num_free_vertices() ); for( vector< Vector3D >::iterator i = gradient.begin(); i != gradient.end(); ++i ) CPPUNIT_ASSERT_VECTORS_EQUAL( expected, *i, EPSILON ); }
Definition at line 178 of file NumericalOFTest.cpp.
References MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, MBMesquite::ObjectiveFunction::evaluate_with_gradient(), MBMesquite::gradient(), and value().
{ MsqError err; NumericalTestOF func( true, false, true ); double value; vector< Vector3D > gradient; func.evaluate_with_gradient( ObjectiveFunction::CALCULATE, pd, value, gradient, err ); CPPUNIT_ASSERT( err ); }
Definition at line 189 of file NumericalOFTest.cpp.
References ASSERT_NO_ERROR, MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, MBMesquite::ObjectiveFunction::evaluate_with_gradient(), MBMesquite::gradient(), and value().
{ MsqError err; NumericalTestOF func( false, true, true ); double value; vector< Vector3D > gradient; bool rval = func.evaluate_with_gradient( ObjectiveFunction::CALCULATE, pd, value, gradient, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( !rval ); }
void NumericalOFTest::test_Hessian_fails | ( | ) |
Definition at line 237 of file NumericalOFTest.cpp.
References MBMesquite::ObjectiveFunction::CALCULATE, CPPUNIT_ASSERT, MBMesquite::ObjectiveFunction::evaluate_with_Hessian(), MBMesquite::gradient(), and value().
{ MsqError err; NumericalTestOF func( false, false, true ); double value; vector< Vector3D > gradient; MsqHessian Hessian; func.evaluate_with_Hessian( ObjectiveFunction::CALCULATE, pd, value, gradient, Hessian, err ); CPPUNIT_ASSERT( err ); }
void NumericalOFTest::test_unchanged | ( | ) |
Definition at line 222 of file NumericalOFTest.cpp.
References ASSERT_NO_ERROR, NumericalTestOF::changed, CPPUNIT_ASSERT, MBMesquite::ObjectiveFunction::evaluate_with_gradient(), MBMesquite::gradient(), MBMesquite::ObjectiveFunction::TEMPORARY, and value().
{ MsqPrintError err( cout ); NumericalTestOF func( false, false, true ); double value; vector< Vector3D > gradient; bool rval; func.changed = false; rval = func.evaluate_with_gradient( ObjectiveFunction::TEMPORARY, pd, value, gradient, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT( !func.changed ); }
PatchData NumericalOFTest::pd [private] |
Definition at line 58 of file NumericalOFTest.cpp.