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

#include <EdgeLengthMetric.hpp>

+ Inheritance diagram for MBMesquite::EdgeLengthMetric:
+ Collaboration diagram for MBMesquite::EdgeLengthMetric:

Public Member Functions

MESQUITE_EXPORT EdgeLengthMetric (double gamma=0.0)
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.
virtual MESQUITE_EXPORT bool evaluate_with_gradient (PatchData &pd, size_t handle, double &value, std::vector< size_t > &indices, std::vector< Vector3D > &gradient, MsqError &err)
 Get metric value and gradient at a logical location in the patch.

Private Attributes

double mGamma

Detailed Description

Definition at line 40 of file EdgeLengthMetric.hpp.


Constructor & Destructor Documentation

Definition at line 40 of file EdgeLengthMetric.cpp.

: mGamma( gamma ) {}

Member Function Documentation

bool MBMesquite::EdgeLengthMetric::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 53 of file EdgeLengthMetric.cpp.

References MBMesquite::EdgeQM::edge(), MBMesquite::EdgeQM::elem(), MBMesquite::PatchData::element_by_index(), MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::MsqMeshEntity::get_vertex_index(), mGamma, MSQ_ERRZERO, and MBMesquite::PatchData::vertex_by_index().

{
    MsqMeshEntity& e = pd.element_by_index( elem( p_handle ) );
    const unsigned* vert_nums;
    vert_nums = TopologyInfo::edge_vertices( e.get_element_type(), edge( p_handle ), err );
    MSQ_ERRZERO( err );
    size_t svi     = e.get_vertex_index( vert_nums[0] );
    size_t evi     = e.get_vertex_index( vert_nums[1] );
    Vector3D diff  = pd.vertex_by_index( svi ) - pd.vertex_by_index( evi );
    double len_sqr = diff % diff - mGamma;
    if( len_sqr <= 0.0 )
    {
        value = 0.0;
        return false;
    }
    value = sqrt( len_sqr );
    return true;
}
bool MBMesquite::EdgeLengthMetric::evaluate_with_gradient ( PatchData pd,
size_t  handle,
double &  value,
std::vector< size_t > &  indices,
std::vector< Vector3D > &  gradient,
MsqError err 
) [virtual]

Get metric value and gradient 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.
gradientThe gradient of the metric as a function of the coordinates of the free vertices passed back in the indices list.

Reimplemented from MBMesquite::QualityMetric.

Definition at line 72 of file EdgeLengthMetric.cpp.

References MBMesquite::EdgeQM::edge(), MBMesquite::EdgeQM::elem(), MBMesquite::PatchData::element_by_index(), MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::MsqMeshEntity::get_vertex_index(), mGamma, MSQ_ERRZERO, MBMesquite::PatchData::num_free_vertices(), value(), and MBMesquite::PatchData::vertex_by_index().

{
    MsqMeshEntity& e = pd.element_by_index( elem( p_handle ) );
    const unsigned* vert_nums;
    vert_nums = TopologyInfo::edge_vertices( e.get_element_type(), edge( p_handle ), err );
    MSQ_ERRZERO( err );
    size_t svi     = e.get_vertex_index( vert_nums[0] );
    size_t evi     = e.get_vertex_index( vert_nums[1] );
    Vector3D diff  = pd.vertex_by_index( svi ) - pd.vertex_by_index( evi );
    double val_sqr = diff % diff - mGamma;
    if( val_sqr <= 0.0 )
    {
        value = 0.0;
        return false;
    }
    value = sqrt( val_sqr );

    diff *= 1.0 / value;
    indices.clear();
    gradient.clear();
    if( svi < pd.num_free_vertices() )
    {
        indices.push_back( svi );
        gradient.push_back( diff );
    }
    if( evi < pd.num_free_vertices() )
    {
        indices.push_back( evi );
        gradient.push_back( -diff );
    }

    return true;
}
std::string MBMesquite::EdgeLengthMetric::get_name ( ) const [virtual]

Implements MBMesquite::QualityMetric.

Definition at line 42 of file EdgeLengthMetric.cpp.

{
    return "EdgeLength";
}

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

Implements MBMesquite::QualityMetric.

Definition at line 48 of file EdgeLengthMetric.cpp.

{
    return 1;
}

Member Data Documentation

Definition at line 59 of file EdgeLengthMetric.hpp.

Referenced by evaluate(), and evaluate_with_gradient().

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