MOAB: Mesh Oriented datABase  (version 5.3.0)
MBMesquite::EdgeLengthQualityMetric Class Reference

Computes the lengths of the edges connected to given a vertex.. More...

#include <EdgeLengthQualityMetric.hpp>

+ Inheritance diagram for MBMesquite::EdgeLengthQualityMetric:
+ Collaboration diagram for MBMesquite::EdgeLengthQualityMetric:

Public Member Functions

MESQUITE_EXPORT EdgeLengthQualityMetric ()
virtual MESQUITE_EXPORT ~EdgeLengthQualityMetric ()
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 vertex, double &value, MsqError &err)
 Get metric value at a logical location in the patch.
virtual MESQUITE_EXPORT bool evaluate_with_indices (PatchData &pd, size_t vertex, double &value, std::vector< size_t > &indices, MsqError &err)
 Get metric value at a logical location in the patch.

Private Member Functions

bool evaluate_common (PatchData &pd, size_t vertex, double &value, std::vector< size_t > &vertices, MsqError &err)

Detailed Description

Computes the lengths of the edges connected to given a vertex..

EdgeLengthQualityMetric is a vertex based metric which computes the lengths of the edges connected to a given vertex and then averages those together, using the specified averaging method The metric uses SUM as the default averaging method.

Definition at line 55 of file EdgeLengthQualityMetric.hpp.


Constructor & Destructor Documentation


Member Function Documentation

bool EdgeLengthQualityMetric::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 72 of file EdgeLengthQualityMetric.cpp.

References evaluate_common(), and MSQ_CHKERR.

{
    std::vector< size_t > verts;
    bool rval = evaluate_common( pd, vertex, value, verts, err );
    return !MSQ_CHKERR( err ) && rval;
}
bool EdgeLengthQualityMetric::evaluate_common ( PatchData pd,
size_t  vertex,
double &  value,
std::vector< size_t > &  vertices,
MsqError err 
) [private]

Definition at line 55 of file EdgeLengthQualityMetric.cpp.

References MBMesquite::AveragingQM::average_metrics(), MBMesquite::PatchData::get_adjacent_vertex_indices(), MBMesquite::PatchData::get_vertex_array(), MSQ_CHKERR, and MSQ_ERRZERO.

Referenced by evaluate(), and evaluate_with_indices().

{
    fval = 0.0;
    pd.get_adjacent_vertex_indices( this_vert, adj_verts, err );
    MSQ_ERRZERO( err );
    const unsigned num_sample_points = adj_verts.size();
    double* metric_values            = new double[num_sample_points];
    const MsqVertex* verts           = pd.get_vertex_array( err );
    MSQ_ERRZERO( err );
    for( unsigned i = 0; i < num_sample_points; ++i )
        metric_values[i] = ( verts[this_vert] - verts[adj_verts[i]] ).length();
    fval = average_metrics( metric_values, num_sample_points, err );
    delete[] metric_values;
    return !MSQ_CHKERR( err );
}
bool EdgeLengthQualityMetric::evaluate_with_indices ( PatchData pd,
size_t  handle,
double &  value,
std::vector< size_t > &  indices,
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.
indicesThe free vertices that the evaluation is a function of, specified as vertex indices in the PatchData.

Implements MBMesquite::QualityMetric.

Definition at line 79 of file EdgeLengthQualityMetric.cpp.

References evaluate_common(), MSQ_CHKERR, and MBMesquite::PatchData::num_free_vertices().

{
    indices.clear();
    bool rval = evaluate_common( pd, vertex, value, indices, err );

    std::vector< size_t >::iterator r, w;
    for( r = w = indices.begin(); r != indices.end(); ++r )
    {
        if( *r < pd.num_free_vertices() )
        {
            *w = *r;
            ++w;
        }
    }
    indices.erase( w, indices.end() );
    if( vertex < pd.num_free_vertices() ) indices.push_back( vertex );

    return !MSQ_CHKERR( err ) && rval;
}
std::string EdgeLengthQualityMetric::get_name ( ) const [virtual]

Implements MBMesquite::QualityMetric.

Definition at line 45 of file EdgeLengthQualityMetric.cpp.

{
    return "Edge Length";
}

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

Implements MBMesquite::QualityMetric.

Definition at line 50 of file EdgeLengthQualityMetric.cpp.

{
    return 1;
}

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