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

Base type for quality metrics evaluated for each edge. More...

#include <EdgeQM.hpp>

+ Inheritance diagram for MBMesquite::EdgeQM:
+ Collaboration diagram for MBMesquite::EdgeQM:

Public Types

enum  { ELEM_EDGE_BITS = 4, ELEM_INDEX_BITS = 8 * sizeof( size_t ) - ELEM_EDGE_BITS, ELEM_EDGE_MASK = ( ( (size_t)1 ) << ELEM_INDEX_BITS ) - 1 }

Public Member Functions

virtual MESQUITE_EXPORT ~EdgeQM ()
virtual MESQUITE_EXPORT MetricType get_metric_type () const
virtual MESQUITE_EXPORT void get_evaluations (PatchData &pd, std::vector< size_t > &handles, bool free_vertices_only, MsqError &err)
 Returns list of edge indices in PatchData.
virtual MESQUITE_EXPORT void get_single_pass (PatchData &pd, std::vector< size_t > &handles, bool free_vertices_only, MsqError &err)
 Returns list of edge indices in PatchData.
virtual MESQUITE_EXPORT bool evaluate_with_indices (PatchData &pd, size_t handle, double &value, std::vector< size_t > &indices, MsqError &err)
 Default implementation for all edge-based metrics.

Static Public Member Functions

static MESQUITE_EXPORT void get_edge_evaluations (PatchData &pd, std::vector< size_t > &handles, bool free_vertices_only, bool single_pass_evaluate, MsqError &err)
static size_t handle (unsigned edge_no, size_t elem_idx)
static unsigned edge (size_t handle)
static unsigned elem (size_t handle)

Detailed Description

Base type for quality metrics evaluated for each edge.

Definition at line 42 of file EdgeQM.hpp.


Member Enumeration Documentation

anonymous enum
Enumerator:
ELEM_EDGE_BITS 
ELEM_INDEX_BITS 
ELEM_EDGE_MASK 

Definition at line 98 of file EdgeQM.hpp.

    {
        ELEM_EDGE_BITS  = 4,
        ELEM_INDEX_BITS = 8 * sizeof( size_t ) - ELEM_EDGE_BITS,
        ELEM_EDGE_MASK  = ( ( (size_t)1 ) << ELEM_INDEX_BITS ) - 1
    };

Constructor & Destructor Documentation

Definition at line 41 of file EdgeQM.cpp.

{}

Member Function Documentation

static unsigned MBMesquite::EdgeQM::edge ( size_t  handle) [inline, static]
bool MBMesquite::EdgeQM::evaluate_with_indices ( PatchData pd,
size_t  handle,
double &  value,
std::vector< size_t > &  indices,
MsqError err 
) [virtual]

Default implementation for all edge-based metrics.

Fill 'indices' with all free vertex indices in element, and call 'evaluate'.

Implements MBMesquite::QualityMetric.

Definition at line 133 of file EdgeQM.cpp.

References conn, edge(), elem(), MBMesquite::PatchData::element_by_index(), MBMesquite::QualityMetric::evaluate(), MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::MsqMeshEntity::get_vertex_index_array(), and MBMesquite::PatchData::num_free_vertices().

Referenced by QualityMetricTester::test_get_edge_indices().

{
    const MsqMeshEntity& element = pd.element_by_index( elem( p_handle ) );
    EntityTopology type          = element.get_element_type();
    const unsigned* verts        = TopologyInfo::edge_vertices( type, edge( p_handle ) );
    const size_t* conn           = element.get_vertex_index_array();
    indices.clear();
    if( conn[verts[0]] < pd.num_free_vertices() ) indices.push_back( conn[verts[0]] );
    if( conn[verts[1]] < pd.num_free_vertices() ) indices.push_back( conn[verts[1]] );
    return evaluate( pd, p_handle, value, err );
}
void MBMesquite::EdgeQM::get_edge_evaluations ( PatchData pd,
std::vector< size_t > &  handles,
bool  free_vertices_only,
bool  single_pass_evaluate,
MsqError err 
) [static]

Definition at line 69 of file EdgeQM.cpp.

References MBMesquite::edges, elem(), MBMesquite::PatchData::element_by_index(), MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::PatchData::get_vertex_element_adjacencies(), MBMesquite::MsqMeshEntity::get_vertex_index_array(), handle(), MBMesquite::MsqVertex::is_flag_set(), MSQ_ERRRTN, MBMesquite::MsqVertex::MSQ_PATCH_FIXED, MBMesquite::PatchData::num_free_vertices(), MBMesquite::PatchData::num_nodes(), and MBMesquite::PatchData::vertex_by_index().

Referenced by get_evaluations(), and get_single_pass().

{
    std::vector< EdgeData > vtx_edges;
    size_t n_verts  = free_vertices_only ? pd.num_free_vertices() : pd.num_nodes();
    size_t n_cutoff = single_pass_evaluate ? pd.num_nodes() : n_verts;
    handles.clear();

    for( size_t i = 0; i < n_verts; ++i )
    {
        if( pd.vertex_by_index( i ).is_flag_set( MsqVertex::MSQ_PATCH_FIXED ) ) continue;

        vtx_edges.clear();

        size_t n_elems;
        const size_t* elems;
        elems = pd.get_vertex_element_adjacencies( i, n_elems, err );MSQ_ERRRTN( err );

        for( size_t j = 0; j < n_elems; ++j )
        {
            MsqMeshEntity& elem = pd.element_by_index( elems[j] );
            unsigned n_edges    = TopologyInfo::edges( elem.get_element_type() );
            for( unsigned k = 0; k < n_edges; ++k )
            {
                const unsigned* edge = TopologyInfo::edge_vertices( elem.get_element_type(), k, err );MSQ_ERRRTN( err );

                size_t vtx1 = elem.get_vertex_index_array()[edge[0]];
                size_t vtx2 = elem.get_vertex_index_array()[edge[1]];
                size_t other;
                if( vtx1 == i )
                    other = vtx2;
                else if( vtx2 == i )
                    other = vtx1;
                else
                    continue;

                // If !free_vertices_only, we'll visit every edge twice.
                // The first check below ensures that we only add each edge
                // once.  The second check is never true unless free_vertices_only
                // is true and single_pass_evaluate is false.  In that case, it
                // serves as an exception to the first rule for those cases in which
                // we visit an edge only once.  For single_pass_evaluate (e.g.
                // BCD initialization or QualityAssessor) we want to avoid visiting
                // and edge more than once for every patch rather than just within
                // this patch.
                if( other > i || other > n_cutoff )
                {
                    EdgeData d = { other, elems[j], k };
                    vtx_edges.push_back( d );
                }
            }  // end for each edge in element
        }      // end for each element adjacent to vertex

        std::sort( vtx_edges.begin(), vtx_edges.end() );
        std::vector< EdgeData >::iterator it, end;
        end = std::unique( vtx_edges.begin(), vtx_edges.end() );
        for( it = vtx_edges.begin(); it != end; ++it )
            handles.push_back( handle( it->elemEdge, it->adjElem ) );
    }  // end for each (free) vertex
}
void MBMesquite::EdgeQM::get_evaluations ( PatchData pd,
std::vector< size_t > &  handles,
bool  free_vertices_only,
MsqError err 
) [virtual]

Returns list of edge indices in PatchData.

This method returns metric evaluation points for every logical edge in the patch if free_vertices_only is false. If free_vertices_only is true then only the subset of edges adjacent to at least one free vertex are returned.

Implements MBMesquite::QualityMetric.

Definition at line 43 of file EdgeQM.cpp.

References get_edge_evaluations().

Referenced by QualityMetricTester::test_get_edge_evaluations(), and QualityMetricTester::test_get_edge_indices().

{
    get_edge_evaluations( pd, handles, free_vertices_only, false, err );
}
void MBMesquite::EdgeQM::get_single_pass ( PatchData pd,
std::vector< size_t > &  handles,
bool  free_vertices_only,
MsqError err 
) [virtual]

Returns list of edge indices in PatchData.

This method returns metric evaluation points only a subset of the logical edges in a patch such that if one iterates over the mesh using element-on-vertex patches a given edge is returned only once for the set of all patches. This is accomplished by returning only edges adjacent to vertices without the MSQ_PATCH_FIXED flag set, and only if the handle for the opposite vertex is greater than the one with the flag set.

Reimplemented from MBMesquite::QualityMetric.

Definition at line 48 of file EdgeQM.cpp.

References get_edge_evaluations().

{
    get_edge_evaluations( pd, handles, free_vertices_only, true, err );
}
static size_t MBMesquite::EdgeQM::handle ( unsigned  edge_no,
size_t  elem_idx 
) [inline, static]

Definition at line 105 of file EdgeQM.hpp.

References ELEM_EDGE_MASK, and ELEM_INDEX_BITS.

Referenced by get_edge_evaluations().

    {
        assert( elem_idx <= ELEM_EDGE_MASK );
        return ( ( (size_t)edge_no ) << ELEM_INDEX_BITS ) | elem_idx;
    }

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