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

Object for computing the aspect ratio gamma of simplicial elements. More...

#include <AspectRatioGammaQualityMetric.hpp>

+ Inheritance diagram for MBMesquite::AspectRatioGammaQualityMetric:
+ Collaboration diagram for MBMesquite::AspectRatioGammaQualityMetric:

Public Member Functions

 AspectRatioGammaQualityMetric ()
virtual ~AspectRatioGammaQualityMetric ()
 virtual destructor ensures use of polymorphism during destruction
virtual std::string get_name () const
int get_negate_flag () const
 1 if metric should be minimized, -1 if metric should be maximized.
bool evaluate (PatchData &pd, size_t handle, double &value, MsqError &err)
 Evaluate aspect ratio gamma on ``element''.

Private Attributes

std::vector< Vector3Dvert

Detailed Description

Object for computing the aspect ratio gamma of simplicial elements.

Definition at line 50 of file AspectRatioGammaQualityMetric.hpp.


Constructor & Destructor Documentation

virtual destructor ensures use of polymorphism during destruction

Definition at line 56 of file AspectRatioGammaQualityMetric.hpp.

{}

Member Function Documentation

bool AspectRatioGammaQualityMetric::evaluate ( PatchData pd,
size_t  handle,
double &  value,
MsqError err 
) [virtual]

Evaluate aspect ratio gamma on ``element''.

Implements MBMesquite::QualityMetric.

Definition at line 62 of file AspectRatioGammaQualityMetric.cpp.

References moab::cross(), MBMesquite::PatchData::domain_set(), MBMesquite::PatchData::element_by_index(), fourDivRootThree, MBMesquite::PatchData::get_domain_normal_at_corner(), MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::PatchData::get_element_vertex_coordinates(), MBMesquite::Vector3D::length(), MBMesquite::length_squared(), MSQ_ERRZERO, MBMesquite::MSQ_MAX_CAP, MBMesquite::MSQ_MIN, MSQ_SETERR, MBMesquite::TETRAHEDRON, MBMesquite::TRIANGLE, twelveDivRootTwo, MBMesquite::MsqError::UNSUPPORTED_ELEMENT, and vert.

{
    MsqMeshEntity& element = pd.element_by_index( elem_index );
    EntityTopology entity  = element.get_element_type();
    double vol;
    Vector3D cross, normal( 0, 0, 0 );
    fval = MSQ_MAX_CAP;

    // get element's nodes
    vert.clear();
    pd.get_element_vertex_coordinates( elem_index, vert, err );
    MSQ_ERRZERO( err );

    switch( entity )
    {
        case TRIANGLE:
            // area
            cross = ( vert[1] - vert[0] ) * ( vert[2] - vert[0] );
            vol   = cross.length() / 2.0;
            if( vol < MSQ_MIN ) return false;

            if( pd.domain_set() )
            {  // need domain to check for inverted elements
                pd.get_domain_normal_at_corner( elem_index, 0, normal, err );
                MSQ_ERRZERO( err );
                if( ( cross % normal ) < -MSQ_MIN ) return false;
            }

            // sum squares of edge lengths
            fval = ( ( vert[1] - vert[0] ).length_squared() + ( vert[2] - vert[0] ).length_squared() +
                     ( vert[1] - vert[2] ).length_squared() );
            // average
            fval /= 3.0;

            // normalize to equil. and div by area
            fval /= vol * fourDivRootThree;

            break;

        case TETRAHEDRON:
            vol = ( vert[1] - vert[0] ) % ( ( vert[2] - vert[0] ) * ( vert[3] - vert[0] ) ) / 6.0;
            if( vol < MSQ_MIN )  // zero for degenerate and negative for inverted
                return false;

            // sum squares of edge lengths
            fval = ( vert[1] - vert[0] ).length_squared() + ( vert[2] - vert[0] ).length_squared() +
                   ( vert[3] - vert[0] ).length_squared() + ( vert[2] - vert[1] ).length_squared() +
                   ( vert[3] - vert[1] ).length_squared() + ( vert[3] - vert[2] ).length_squared();
            // average
            fval /= 6.0;

            fval *= sqrt( fval );
            // normalize to equil. and div by volume
            fval /= vol * twelveDivRootTwo;

            break;
        default:
            MSQ_SETERR( err )
            ( MsqError::UNSUPPORTED_ELEMENT, "Entity type %d is not valid for Aspect Ratio Gamma\n", (int)entity );
            return false;
    };

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

Implements MBMesquite::QualityMetric.

Definition at line 50 of file AspectRatioGammaQualityMetric.cpp.

{
    return "AspectRatioGamma";
}

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

Implements MBMesquite::QualityMetric.

Definition at line 55 of file AspectRatioGammaQualityMetric.cpp.

{
    return 1;
}

Member Data Documentation

Definition at line 65 of file AspectRatioGammaQualityMetric.hpp.

Referenced by evaluate().

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