MOAB: Mesh Oriented datABase  (version 5.4.1)
OFTestQM Class Reference

#include <ObjectiveFunctionTests.hpp>

+ Inheritance diagram for OFTestQM:
+ Collaboration diagram for OFTestQM:

Public Member Functions

 OFTestQM ()
 OFTestQM (const double *values, unsigned num_values)
void set_values (const double *values, unsigned num_values)
void append_values (const double *values, unsigned num_values)
virtual MetricType get_metric_type () const
virtual string get_name () const
virtual int get_negate_flag () const
 1 if metric should be minimized, -1 if metric should be maximized.
void set_negate_flag (int value)
virtual void get_evaluations (PatchData &, vector< size_t > &h, bool, MsqError &)
virtual bool evaluate (PatchData &, size_t h, double &v, MsqError &err)
 Get metric value at a logical location in the patch.
virtual bool evaluate_with_indices (PatchData &pd, size_t h, double &v, vector< size_t > &i, MsqError &err)
virtual bool evaluate_with_gradient (PatchData &pd, size_t h, double &v, vector< size_t > &i, vector< Vector3D > &g, MsqError &err)
virtual bool evaluate_with_Hessian (PatchData &pd, size_t h, double &v, vector< size_t > &i, vector< Vector3D > &g, vector< Matrix3D > &H, MsqError &err)

Private Attributes

vector< double > mValues
int negateFlag

Detailed Description

The QualityMetric to use for testing purposes

Just pass a specified list of values to the OF

Definition at line 124 of file ObjectiveFunctionTests.hpp.


Constructor & Destructor Documentation

OFTestQM::OFTestQM ( ) [inline]

Definition at line 127 of file ObjectiveFunctionTests.hpp.

: negateFlag( 1 ) {}
OFTestQM::OFTestQM ( const double *  values,
unsigned  num_values 
) [inline]

Definition at line 129 of file ObjectiveFunctionTests.hpp.

                                                          : mValues( num_values ), negateFlag( 1 )
    {
        copy( values, values + num_values, mValues.begin() );
    }

Member Function Documentation

void OFTestQM::append_values ( const double *  values,
unsigned  num_values 
) [inline]

Definition at line 140 of file ObjectiveFunctionTests.hpp.

Referenced by ObjectiveFunctionTests::test_clone(), and ObjectiveFunctionTests::test_eval_type().

    {
        copy( values, values + num_values, back_inserter( mValues ) );
    }
virtual bool OFTestQM::evaluate ( PatchData pd,
size_t  handle,
double &  value,
MsqError err 
) [inline, virtual]

Get metric value at a logical location in the patch.

Evaluate the metric at one location in the PatchData.

Parameters:
pdThe patch.
handleThe location in the patch (as passed back from get_evaluations).
valueThe output metric value.

Implements MBMesquite::QualityMetric.

Definition at line 172 of file ObjectiveFunctionTests.hpp.

References MBMesquite::MsqError::INVALID_ARG, and MSQ_SETERR.

    {
        if( h >= mValues.size() )
        {
            MSQ_SETERR( err )( "handle out of range", MsqError::INVALID_ARG );
            return false;
        }
        v = mValues[h];
        return true;
    }
virtual bool OFTestQM::evaluate_with_gradient ( PatchData pd,
size_t  h,
double &  v,
vector< size_t > &  i,
vector< Vector3D > &  g,
MsqError err 
) [inline, virtual]

Definition at line 191 of file ObjectiveFunctionTests.hpp.

    {
        g.clear();
        bool rval = evaluate_with_indices( pd, h, v, i, err );
        // grad values are just used to test negate flag, so just
        // pass back an arbitrary value for each free vertex
        for( unsigned j = 0; j < i.size(); ++j )
            g.push_back( Vector3D( 1, 0, 2 ) );
        return rval;
    }
virtual bool OFTestQM::evaluate_with_Hessian ( PatchData pd,
size_t  h,
double &  v,
vector< size_t > &  i,
vector< Vector3D > &  g,
vector< Matrix3D > &  H,
MsqError err 
) [inline, virtual]

Definition at line 207 of file ObjectiveFunctionTests.hpp.

    {
        H.clear();
        bool rval = evaluate_with_gradient( pd, h, v, i, g, err );
        // Hessian values are just used to test negate flag, so
        // pass back arbirary values.
        for( unsigned r = 0; r < i.size(); ++r )
            for( unsigned c = r; c < i.size(); ++c )
                H.push_back( Matrix3D( 1.0 ) );
        return rval;
    }
virtual bool OFTestQM::evaluate_with_indices ( PatchData pd,
size_t  h,
double &  v,
vector< size_t > &  i,
MsqError err 
) [inline, virtual]

Definition at line 183 of file ObjectiveFunctionTests.hpp.

References MBMesquite::PatchData::num_free_vertices().

    {
        i.clear();
        for( unsigned j = 0; j < pd.num_free_vertices(); ++j )
            i.push_back( j );
        return evaluate( pd, h, v, err );
    }
virtual void OFTestQM::get_evaluations ( PatchData ,
vector< size_t > &  h,
bool  ,
MsqError  
) [inline, virtual]

Definition at line 165 of file ObjectiveFunctionTests.hpp.

    {
        h.resize( mValues.size() );
        for( unsigned i = 0; i < mValues.size(); ++i )
            h[i] = i;
    }
virtual MetricType OFTestQM::get_metric_type ( ) const [inline, virtual]

Implements MBMesquite::QualityMetric.

Definition at line 145 of file ObjectiveFunctionTests.hpp.

    {
        return ELEMENT_BASED;
    }
virtual string OFTestQM::get_name ( ) const [inline, virtual]

Implements MBMesquite::QualityMetric.

Definition at line 150 of file ObjectiveFunctionTests.hpp.

    {
        return "ObjectiveFunctionTests";
    }
virtual int OFTestQM::get_negate_flag ( ) const [inline, virtual]

1 if metric should be minimized, -1 if metric should be maximized.

Implements MBMesquite::QualityMetric.

Definition at line 155 of file ObjectiveFunctionTests.hpp.

    {
        return negateFlag;
    }
void OFTestQM::set_values ( const double *  values,
unsigned  num_values 
) [inline]

Definition at line 134 of file ObjectiveFunctionTests.hpp.

Referenced by ObjectiveFunctionTests::test_clone(), and ObjectiveFunctionTests::test_eval_type().

    {
        mValues.resize( num_values );
        copy( values, values + num_values, mValues.begin() );
    }

Member Data Documentation

vector< double > OFTestQM::mValues [private]

Definition at line 226 of file ObjectiveFunctionTests.hpp.

int OFTestQM::negateFlag [private]

Definition at line 227 of file ObjectiveFunctionTests.hpp.

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines