MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::ElementAvgQM Class Reference

#include <ElementAvgQM.hpp>

+ Inheritance diagram for MBMesquite::ElementAvgQM:
+ Collaboration diagram for MBMesquite::ElementAvgQM:

Public Member Functions

MESQUITE_EXPORT ElementAvgQM (ElemSampleQM *metric)
virtual MESQUITE_EXPORT ~ElementAvgQM ()
MESQUITE_EXPORT ElemSampleQMget_quality_metric () const
virtual MESQUITE_EXPORT std::string get_name () const
virtual MESQUITE_EXPORT int get_negate_flag () const
 1 if metric should be minimized, -1 if metric should be maximized.
virtual MESQUITE_EXPORT bool evaluate (PatchData &pd, size_t handle, double &value, MsqError &err)
 Get metric value at a logical location in the patch.

Private Attributes

ElemSampleQMmMetric
std::vector< size_t > mHandles

Detailed Description

Definition at line 41 of file ElementAvgQM.hpp.


Constructor & Destructor Documentation

Definition at line 40 of file ElementAvgQM.cpp.

: mMetric( metric ) {}

Definition at line 42 of file ElementAvgQM.cpp.

{}

Member Function Documentation

bool MBMesquite::ElementAvgQM::evaluate ( PatchData pd,
size_t  handle,
double &  value,
MsqError err 
) [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 57 of file ElementAvgQM.cpp.

References MBMesquite::QualityMetric::evaluate(), MBMesquite::ElemSampleQM::get_element_evaluations(), get_quality_metric(), mHandles, MSQ_ERRFALSE, and MSQ_ERRZERO.

{
    ElemSampleQM* qm = get_quality_metric();
    mHandles.clear();
    qm->get_element_evaluations( pd, handle, mHandles, err );
    MSQ_ERRFALSE( err );

    bool valid = true;
    double tmpval;
    double accumulate = 0.0;
    int num_values    = 0;
    bool tmpvalid;

    value = -std::numeric_limits< double >::infinity();
    for( std::vector< size_t >::iterator h = mHandles.begin(); h != mHandles.end(); ++h )
    {
        tmpvalid = qm->evaluate( pd, *h, tmpval, err );
        MSQ_ERRZERO( err );
        if( !tmpvalid )
        {
            valid = false;
            break;
        }
        else
        {
            accumulate += tmpval;
            num_values++;
        }
    }
    if( valid ) value = accumulate / num_values;

    return valid;
}
std::string MBMesquite::ElementAvgQM::get_name ( ) const [virtual]

Implements MBMesquite::QualityMetric.

Definition at line 44 of file ElementAvgQM.cpp.

References MBMesquite::QualityMetric::get_name(), and mMetric.

{
    std::string result( "ElementAvgQM(" );
    result += mMetric->get_name();
    result += ")";
    return result;
}

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

Implements MBMesquite::QualityMetric.

Definition at line 52 of file ElementAvgQM.cpp.

References MBMesquite::QualityMetric::get_negate_flag(), and get_quality_metric().


Member Data Documentation

std::vector< size_t > MBMesquite::ElementAvgQM::mHandles [mutable, private]

Definition at line 61 of file ElementAvgQM.hpp.

Referenced by evaluate().

Definition at line 60 of file ElementAvgQM.hpp.

Referenced by get_name(), and get_quality_metric().

List of all members.


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