MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Public Member Functions | |
NumericalTestOF (bool should_fail, bool should_return_false, bool constant_func) | |
bool | evaluate (EvalType type, PatchData &pd, double &val, bool free, MsqError &) |
Evaluate objective function for specified patch. | |
ObjectiveFunction * | clone () const |
Create copy with same state. | |
void | clear () |
Public Attributes | |
bool | changed |
bool | fail |
bool | return_false |
bool | constant |
const Vector3D | linearGrad |
Define a dummy ObjectiveFunction on which to do numerical gradient calculation
If 'constant' flag is true, returns a constant value. If 'constant' flag is false, returns a linear function of vertex coordinates.
Definition at line 88 of file NumericalOFTest.cpp.
NumericalTestOF::NumericalTestOF | ( | bool | should_fail, |
bool | should_return_false, | ||
bool | constant_func | ||
) | [inline] |
Definition at line 91 of file NumericalOFTest.cpp.
: changed( false ), fail( should_fail ), return_false( should_return_false ), constant( constant_func ), linearGrad( 1, 2, 3 ) { }
void NumericalTestOF::clear | ( | ) | [inline, virtual] |
Clear any values accumulated for BCD-related eval calls
Implements MBMesquite::ObjectiveFunction.
Definition at line 104 of file NumericalOFTest.cpp.
{ changed = true; }
ObjectiveFunction* NumericalTestOF::clone | ( | ) | const [inline, virtual] |
Create copy with same state.
Create a new instance of the objective function that is a copy of the callee with the same accumulated values, parameters, etc.
Implements MBMesquite::ObjectiveFunction.
Definition at line 99 of file NumericalOFTest.cpp.
{ return new NumericalTestOF( *this ); }
bool NumericalTestOF::evaluate | ( | EvalType | type, |
PatchData & | pd, | ||
double & | value_out, | ||
bool | free, | ||
MsqError & | err | ||
) | [virtual] |
Evaluate objective function for specified patch.
Either evaluate the objective function over the passed patch or update the accumulated, global objective function value for changes in the passed patch, depending on the value of the EvalType.
type | Evaluation type. |
pd | The patch. |
value_out | The passed-back value of the objective fuction. |
free | If true, incorporate the quality metric values only for those metric evaluations that depend on at least one free vertex |
Implements MBMesquite::ObjectiveFunction.
Definition at line 117 of file NumericalOFTest.cpp.
References MBMesquite::ObjectiveFunction::CALCULATE, fail(), MBMesquite::MsqError::INVALID_ARG, MSQ_SETERR, MBMesquite::PatchData::num_free_vertices(), MBMesquite::PatchData::num_nodes(), MBMesquite::ObjectiveFunction::TEMPORARY, and MBMesquite::PatchData::vertex_by_index().
{ if( fail ) { MSQ_SETERR( err )( "Expected failure of OF::evaluate", MsqError::INVALID_ARG ); return false; } if( pd.num_free_vertices() < 1 ) { MSQ_SETERR( err )( "PatchData without free vertices.", MsqError::INVALID_ARG ); return false; } if( type != ObjectiveFunction::CALCULATE && type != ObjectiveFunction::TEMPORARY ) changed = true; if( constant ) { val = 1.0; return !return_false; } val = 0.0; for( size_t i = 0; i < pd.num_nodes(); ++i ) { const MsqVertex& v = pd.vertex_by_index( i ); val += linearGrad[0] * v[0] + linearGrad[1] * v[1] + linearGrad[2] * v[2]; } return !return_false; }
Definition at line 109 of file NumericalOFTest.cpp.
Referenced by NumericalOFTest::test_changed(), and NumericalOFTest::test_unchanged().
Definition at line 112 of file NumericalOFTest.cpp.
Definition at line 110 of file NumericalOFTest.cpp.
Definition at line 114 of file NumericalOFTest.cpp.
Referenced by NumericalOFTest::test_gradient_values().
Definition at line 111 of file NumericalOFTest.cpp.