MOAB: Mesh Oriented datABase  (version 5.2.1)
MBMesquite::VertexPatches Class Reference

A PatchSet representing a decomposition of the mesh into patches containing a single free vertex and the adjacent elements. More...

#include <VertexPatches.hpp>

+ Inheritance diagram for MBMesquite::VertexPatches:
+ Collaboration diagram for MBMesquite::VertexPatches:

Public Member Functions

 VertexPatches (unsigned p_num_layers=1, bool p_free_vertices_only=true)
 constructor
MESQUITE_EXPORT ~VertexPatches ()
void set_num_layers (unsigned num_layers)
 Set number of layers of elements adjacent to each vertex.
unsigned get_num_layers () const
 Get number of layers of elements adjacent to each vertex.
void free_vertices_only (bool yesno)
 Skip fixed vertices if true.
bool free_vertices_only () const
 Skip fixed vertices if true.
virtual MESQUITE_EXPORT void get_patch_handles (std::vector< PatchHandle > &patch_handles_out, MsqError &err)
 Get a list of handles, one for each patch.
virtual MESQUITE_EXPORT void get_patch (PatchHandle patch_handle, std::vector< Mesh::ElementHandle > &elem_handles_out, std::vector< Mesh::VertexHandle > &free_vertices_out, MsqError &err)
 Get the mesh entities in a patch.

Private Attributes

std::vector< size_t > junk
unsigned numLayers
 number of layers of adjacent elements
bool freeVertices
 skip fixed vertices if true

Detailed Description

A PatchSet representing a decomposition of the mesh into patches containing a single free vertex and the adjacent elements.

Definition at line 45 of file VertexPatches.hpp.


Constructor & Destructor Documentation

MBMesquite::VertexPatches::VertexPatches ( unsigned  p_num_layers = 1,
bool  p_free_vertices_only = true 
) [inline]

constructor

Parameters:
num_layersNumber of layers of elements adjacent to each vertex
free_vertices_onlySkip fixed vertices if true.

Definition at line 52 of file VertexPatches.hpp.

        : numLayers( p_num_layers ), freeVertices( p_free_vertices_only )
    {
    }

Member Function Documentation

void MBMesquite::VertexPatches::free_vertices_only ( bool  yesno) [inline]

Skip fixed vertices if true.

Definition at line 73 of file VertexPatches.hpp.

References freeVertices.

    {
        freeVertices = yesno;
    }

Skip fixed vertices if true.

Definition at line 79 of file VertexPatches.hpp.

References freeVertices.

Referenced by get_patch(), and get_patch_handles().

    {
        return freeVertices;
    }
unsigned MBMesquite::VertexPatches::get_num_layers ( ) const [inline]

Get number of layers of elements adjacent to each vertex.

Definition at line 67 of file VertexPatches.hpp.

References numLayers.

Referenced by MBMesquite::PatchSetUser::num_element_on_vertex_layers().

    {
        return numLayers;
    }
void MBMesquite::VertexPatches::get_patch ( PatchHandle  patch_handle,
std::vector< Mesh::ElementHandle > &  elem_handles_out,
std::vector< Mesh::VertexHandle > &  free_vertices_out,
MsqError err 
) [virtual]

Get the mesh entities in a patch.

Given one of the handles returned by get_patch_handles(), return the mesh entities in the corresponding patch. If only free vertices are to be returned, this funtion will return empty lists for culled vertices.

Parameters:
patch_handleone of the handles returned by get_patch_handles()
elem_handles_outthe list of elements in the mesh
free_vertices_outthe list of vertices interior to the patch

Implements MBMesquite::PatchSet.

Definition at line 68 of file VertexPatches.cpp.

References MBMesquite::arrptr(), MBMesquite::Mesh::elements_get_attached_vertices(), free_vertices_only(), MBMesquite::PatchSet::get_mesh(), junk, MSQ_CHKERR, MBMesquite::MsqVertex::MSQ_CULLED, numLayers, MBMesquite::Mesh::vertices_get_attached_elements(), and MBMesquite::Mesh::vertices_get_byte().

Referenced by MBMesquite::QualityAssessor::loop_over_mesh_internal(), and PatchSetTest::test_vertex_patches().

{
    free_vertices_out.clear();
    elem_handles_out.clear();

    if( free_vertices_only() )
    {  // check if vertex is culled
        unsigned char byte;
        get_mesh()->vertices_get_byte( &patch_handle, &byte, 1, err );
        if( MSQ_CHKERR( err ) || ( byte & MsqVertex::MSQ_CULLED ) ) return;
    }

    free_vertices_out.push_back( patch_handle );
    if( !numLayers )  // if no layers of elements, then done.
        return;

    // get elements adjacent to free vertex
    get_mesh()->vertices_get_attached_elements( &patch_handle, 1, elem_handles_out, junk, err );
    if( MSQ_CHKERR( err ) ) return;

    unsigned remaining = numLayers;
    while( --remaining )
    {  // loop if more than one layer of elements
        if( elem_handles_out.empty() ) break;

        // Get vertices adjacent to elements
        free_vertices_out.clear();
        get_mesh()->elements_get_attached_vertices( arrptr( elem_handles_out ), elem_handles_out.size(),
                                                    free_vertices_out, junk, err );
        if( MSQ_CHKERR( err ) ) break;

        // remove duplicates from vertex list
        std::sort( free_vertices_out.begin(), free_vertices_out.end() );
        free_vertices_out.erase( std::unique( free_vertices_out.begin(), free_vertices_out.end() ),
                                 free_vertices_out.end() );

        // Get elements adjacent to vertices
        elem_handles_out.clear();
        get_mesh()->vertices_get_attached_elements( arrptr( free_vertices_out ), free_vertices_out.size(),
                                                    elem_handles_out, junk, err );
        if( MSQ_CHKERR( err ) ) break;

        // Remove duplicates from element list
        std::sort( elem_handles_out.begin(), elem_handles_out.end() );
        elem_handles_out.erase( std::unique( elem_handles_out.begin(), elem_handles_out.end() ),
                                elem_handles_out.end() );
    }
}
void MBMesquite::VertexPatches::get_patch_handles ( std::vector< PatchHandle > &  patch_handles_out,
MsqError err 
) [virtual]

Get a list of handles, one for each patch.

Implements MBMesquite::PatchSet.

Definition at line 47 of file VertexPatches.cpp.

References MBMesquite::arrptr(), free_vertices_only(), MBMesquite::Mesh::get_all_vertices(), MBMesquite::PatchSet::get_mesh(), MBMesquite::MsqVertex::MSQ_DEPENDENT, MSQ_ERRRTN, MBMesquite::MsqVertex::MSQ_HARD_FIXED, and MBMesquite::Mesh::vertices_get_byte().

Referenced by MBMesquite::QualityAssessor::loop_over_mesh_internal(), and PatchSetTest::test_vertex_patches().

{
    // get all vertex handles
    get_mesh()->get_all_vertices( patch_handles_out, err );MSQ_ERRRTN( err );
    if( patch_handles_out.empty() ) return;

    if( free_vertices_only() )
    {
        // get fixed flags for vertices
        std::vector< unsigned char > flags( patch_handles_out.size() );
        get_mesh()->vertices_get_byte( arrptr( patch_handles_out ), arrptr( flags ), patch_handles_out.size(), err );MSQ_ERRRTN( err );

        // remove fixed  and slaved vertices from list
        size_t write = 0;
        for( size_t read = 0; read < patch_handles_out.size(); ++read )
            if( !( flags[read] & ( MsqVertex::MSQ_HARD_FIXED | MsqVertex::MSQ_DEPENDENT ) ) )
                patch_handles_out[write++] = patch_handles_out[read];
        patch_handles_out.resize( write );
    }
}
void MBMesquite::VertexPatches::set_num_layers ( unsigned  num_layers) [inline]

Set number of layers of elements adjacent to each vertex.

Definition at line 61 of file VertexPatches.hpp.

References numLayers.

Referenced by MBMesquite::PatchSetUser::use_element_on_vertex_patch().

    {
        numLayers = num_layers;
    }

Member Data Documentation

skip fixed vertices if true

Definition at line 107 of file VertexPatches.hpp.

Referenced by free_vertices_only().

std::vector< size_t > MBMesquite::VertexPatches::junk [private]

Definition at line 104 of file VertexPatches.hpp.

Referenced by get_patch().

number of layers of adjacent elements

Definition at line 106 of file VertexPatches.hpp.

Referenced by get_num_layers(), get_patch(), and set_num_layers().

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