MOAB: Mesh Oriented datABase  (version 5.4.0)
smoab::Interface Class Reference

#include <SimpleMoab.h>

+ Collaboration diagram for smoab::Interface:

Public Member Functions

 Interface (const std::string &file)
 ~Interface ()
moab::Tag getMoabTag (const smoab::Tag &simpleTag) const
template<typename T >
T getDefaultTagVaue (moab::Tag tag) const
template<typename T >
T getDefaultTagVaue (smoab::Tag tag) const
template<typename T >
T getTagData (moab::Tag tag, const smoab::EntityHandle &entity, T value) const
template<typename T >
T getTagData (smoab::Tag tag, const smoab::EntityHandle &entity, T value=T()) const
std::string name (const smoab::EntityHandle &entity) const
int dimension (const smoab::EntityHandle &entity) const
smoab::EntityType entityType (const smoab::EntityHandle &entity) const
smoab::EntityHandle getRoot () const
smoab::Range findEntities (const smoab::EntityHandle root, moab::EntityType type) const
smoab::Range findAllMeshEntities (smoab::EntityHandle const &entity, bool recurse=false) const
smoab::Range findEntitiesWithTag (const smoab::Tag &tag, smoab::EntityHandle root, moab::EntityType type=moab::MBENTITYSET) const
smoab::Range findEntitiesWithDimension (const smoab::EntityHandle root, const int dimension, bool recurse=false) const
smoab::Range findHighestDimensionEntities (const smoab::EntityHandle &entity, bool recurse=false) const
smoab::Range findEntityRootParents (const smoab::EntityHandle &root) const
smoab::Range findDetachedEntities (const moab::EntityHandle &root) const
smoab::Range findEntitiesWithMultipleParents (const smoab::EntityHandle &root) const
smoab::Range findAdjacencies (const smoab::EntityHandle &entity, int dimension) const
smoab::Range findAdjacencies (const smoab::Range &range, int dimension, const smoab::adjacency_type type=smoab::UNION) const
smoab::Range createAdjacencies (const smoab::Range &range, int dimension, const smoab::adjacency_type type=smoab::UNION) const
int numChildMeshSets (const smoab::EntityHandle &root) const
smoab::Range getChildSets (const smoab::EntityHandle &root) const
void remove (smoab::Range const &toDelete) const
smoab::EntityHandle sideElement (smoab::EntityHandle const &cell, int dim, int side) const
std::vector< smoab::EntityHandlesideElements (smoab::EntityHandle const &cell, int dim) const
void printRange (const smoab::Range &range) const

Private Attributes

moab::InterfaceMoab

Friends

class smoab::DataSetConverter
class smoab::detail::LoadGeometry
class smoab::detail::LoadPoly

Detailed Description

Definition at line 123 of file SimpleMoab.h.


Constructor & Destructor Documentation

smoab::Interface::Interface ( const std::string &  file) [inline]

Definition at line 126 of file SimpleMoab.h.

References moab::Interface::load_file(), and Moab.

    {
        this->Moab = new moab::Core();
        this->Moab->load_file( file.c_str() );
    }

Definition at line 132 of file SimpleMoab.h.

References Moab.

    {
        if( this->Moab )
        {
            delete this->Moab;
            this->Moab = NULL;
        }
    }

Member Function Documentation

smoab::Range smoab::Interface::createAdjacencies ( const smoab::Range range,
int  dimension,
const smoab::adjacency_type  type = smoab::UNION 
) const [inline]

Definition at line 432 of file SimpleMoab.h.

References moab::Interface::get_adjacencies(), and Moab.

Referenced by smoab::ExtractShell::findSkins().

    {
        //the smoab and moab adjacent intersection enums are in the same order
        const int adjType = static_cast< int >( type );
        smoab::Range result;
        const bool create_if_missing = true;
        this->Moab->get_adjacencies( range, dimension, create_if_missing, result, adjType );

        return result;
    }
int smoab::Interface::dimension ( const smoab::EntityHandle entity) const [inline]

Definition at line 204 of file SimpleMoab.h.

References moab::Interface::dimension_from_handle(), and Moab.

    {
        return this->Moab->dimension_from_handle( entity );
    }

Definition at line 211 of file SimpleMoab.h.

References Moab, and moab::Interface::type_from_handle().

    {
        return this->Moab->type_from_handle( entity );
    }
smoab::Range smoab::Interface::findAdjacencies ( const smoab::EntityHandle entity,
int  dimension 
) const [inline]

Definition at line 406 of file SimpleMoab.h.

References moab::Interface::get_adjacencies(), smoab::INTERSECT, and Moab.

    {
        const int adjType = static_cast< int >( smoab::INTERSECT );
        smoab::Range result;
        const bool create_if_missing = false;
        this->Moab->get_adjacencies( &entity, 1, dimension, create_if_missing, result, adjType );
        return result;
    }
smoab::Range smoab::Interface::findAdjacencies ( const smoab::Range range,
int  dimension,
const smoab::adjacency_type  type = smoab::UNION 
) const [inline]

Definition at line 416 of file SimpleMoab.h.

References moab::Interface::get_adjacencies(), and Moab.

    {
        //the smoab and moab adjacent intersection enums are in the same order
        const int adjType = static_cast< int >( type );
        smoab::Range result;
        const bool create_if_missing = false;
        this->Moab->get_adjacencies( range, dimension, create_if_missing, result, adjType );

        return result;
    }
smoab::Range smoab::Interface::findAllMeshEntities ( smoab::EntityHandle const &  entity,
bool  recurse = false 
) const [inline]

Definition at line 234 of file SimpleMoab.h.

References moab::Interface::get_entities_by_handle(), and Moab.

    {
        smoab::Range result;
        this->Moab->get_entities_by_handle( entity, result, recurse );
        return result;
    }

Definition at line 358 of file SimpleMoab.h.

References moab::Range::begin(), moab::Range::end(), moab::Interface::get_entities_by_type(), moab::Range::insert(), MBENTITYSET, Moab, moab::Interface::num_child_meshsets(), and moab::Interface::num_parent_meshsets().

    {
        smoab::Range detached;

        typedef moab::Range::const_iterator iterator;
        moab::Range sets;

        this->Moab->get_entities_by_type( root, moab::MBENTITYSET, sets );
        for( iterator i = sets.begin(); i != sets.end(); ++i )
        {
            int numParents = 0, numChildren = 0;
            this->Moab->num_parent_meshsets( *i, &numParents );
            if( numParents == 0 )
            {
                this->Moab->num_child_meshsets( *i, &numChildren );
                if( numChildren == 0 )
                {
                    detached.insert( *i );
                }
            }
        }
        return detached;
    }
smoab::Range smoab::Interface::findEntities ( const smoab::EntityHandle  root,
moab::EntityType  type 
) const [inline]

Definition at line 223 of file SimpleMoab.h.

References moab::Interface::get_entities_by_type(), and Moab.

    {
        smoab::Range result;
        // get all the sets of that type in the mesh
        this->Moab->get_entities_by_type( root, type, result );
        return result;
    }
smoab::Range smoab::Interface::findEntitiesWithDimension ( const smoab::EntityHandle  root,
const int  dimension,
bool  recurse = false 
) const [inline]

Definition at line 285 of file SimpleMoab.h.

References moab::Range::begin(), children, moab::Range::end(), moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_dimension(), and Moab.

Referenced by smoab::DataSetConverter::fill(), and findHighestDimensionEntities().

    {
        typedef smoab::Range::const_iterator iterator;

        smoab::Range result;
        this->Moab->get_entities_by_dimension( root, dimension, result, recurse );

        if( recurse )
        {
            smoab::Range children;
            this->Moab->get_child_meshsets( root, children, 0 );
            for( iterator i = children.begin(); i != children.end(); ++i )
            {
                this->Moab->get_entities_by_dimension( *i, dimension, result );
            }
        }
        return result;
    }

Definition at line 384 of file SimpleMoab.h.

References moab::Range::begin(), children, moab::Range::end(), moab::Interface::get_child_meshsets(), moab::Range::insert(), Moab, and moab::Interface::num_parent_meshsets().

    {
        smoab::Range multipleParents;
        typedef moab::Range::const_iterator iterator;

        //for all the elements in the range, find all items with multiple parents
        moab::Range children;
        this->Moab->get_child_meshsets( root, children, 0 );
        for( iterator i = children.begin(); i != children.end(); ++i )
        {
            int numParents = 0;
            this->Moab->num_parent_meshsets( *i, &numParents );
            if( numParents > 1 )
            {
                multipleParents.insert( *i );
            }
        }
        return multipleParents;
    }
smoab::Range smoab::Interface::findEntitiesWithTag ( const smoab::Tag tag,
smoab::EntityHandle  root,
moab::EntityType  type = moab::MBENTITYSET 
) const [inline]

Definition at line 246 of file SimpleMoab.h.

References moab::Range::begin(), moab::Range::end(), moab::Interface::get_entities_by_type_and_tag(), getMoabTag(), moab::Range::insert(), smoab::Tag::isComparable(), Moab, t, moab::Interface::tag_get_data(), smoab::Tag::value(), and value().

Referenced by vtkMoabReader::CreateSubBlocks().

    {
        smoab::Range result;

        moab::Tag t = this->getMoabTag( tag );

        // get all the entities of that type in the mesh
        this->Moab->get_entities_by_type_and_tag( root, type, &t, NULL, 1, result );

        if( tag.isComparable() )
        {
            int value = 0;
            //now we have to remove any that doesn't match the tag value
            smoab::Range resultMatchingTag;
            typedef moab::Range::const_iterator iterator;
            for( iterator i = result.begin(); i != result.end(); ++i )
            {
                value                     = 0;
                moab::EntityHandle handle = *i;
                this->Moab->tag_get_data( t, &handle, 1, &value );
                if( value == tag.value() )
                {
                    resultMatchingTag.insert( *i );
                }
            }

            return resultMatchingTag;
        }
        else
        {
            //we return all the items we found
            return result;
        }
    }

Definition at line 332 of file SimpleMoab.h.

References moab::Range::begin(), moab::Range::end(), moab::Interface::get_entities_by_type(), moab::Range::insert(), MBENTITYSET, Moab, moab::Interface::num_child_meshsets(), and moab::Interface::num_parent_meshsets().

Referenced by vtkMoabReader::CreateSubBlocks().

    {
        smoab::Range parents;

        typedef moab::Range::const_iterator iterator;
        moab::Range sets;

        this->Moab->get_entities_by_type( root, moab::MBENTITYSET, sets );
        for( iterator i = sets.begin(); i != sets.end(); ++i )
        {
            int numParents = 0, numChildren = 0;
            this->Moab->num_parent_meshsets( *i, &numParents );
            if( numParents == 0 )
            {
                this->Moab->num_child_meshsets( *i, &numChildren );
                if( numChildren >= 0 )
                {
                    parents.insert( *i );
                }
            }
        }
        return parents;
    }
smoab::Range smoab::Interface::findHighestDimensionEntities ( const smoab::EntityHandle entity,
bool  recurse = false 
) const [inline]

Definition at line 307 of file SimpleMoab.h.

References dim, findEntitiesWithDimension(), moab::Interface::get_number_entities_by_dimension(), and Moab.

Referenced by smoab::DataSetConverter::fill().

    {
        //the goal is to load all entities that are not entity sets of this
        //node, while also subsetting by the highest dimension

        //lets find the entities of only the highest dimension
        int num_ents = 0;
        int dim      = 3;
        while( num_ents <= 0 && dim > 0 )
        {
            this->Moab->get_number_entities_by_dimension( entity, dim, num_ents, recurse );
            --dim;
        }
        ++dim;  //reincrement to correct last decrement
        if( num_ents > 0 )
        {
            //we have found entities of a given dimension
            return this->findEntitiesWithDimension( entity, dim, recurse );
        }
        return smoab::Range();
    }

Definition at line 454 of file SimpleMoab.h.

References children, moab::Interface::get_child_meshsets(), and Moab.

    {
        smoab::Range children;
        this->Moab->get_child_meshsets( root, children, 0 );
        return children;
    }
template<typename T >
T smoab::Interface::getDefaultTagVaue ( moab::Tag  tag) const [inline]

Definition at line 151 of file SimpleMoab.h.

References Moab, T, and moab::Interface::tag_get_default_value().

Referenced by smoab::FaceAdjRegionValues(), and smoab::detail::ReadSparseTag::fillRawArray().

    {
        T defaultValue;
        this->Moab->tag_get_default_value( tag, &defaultValue );
        return defaultValue;
    }
template<typename T >
T smoab::Interface::getDefaultTagVaue ( smoab::Tag  tag) const [inline]

Definition at line 160 of file SimpleMoab.h.

References getMoabTag().

    {
        return this->getDefaultTagVaue< T >( getMoabTag( tag ) );
    }
moab::Tag smoab::Interface::getMoabTag ( const smoab::Tag simpleTag) const [inline]

Definition at line 217 of file SimpleMoab.h.

References moab::Interface::get_root_set(), and Moab.

Referenced by vtkMoabReader::CreateSubBlocks().

    {
        return this->Moab->get_root_set();
    }
template<typename T >
T smoab::Interface::getTagData ( moab::Tag  tag,
const smoab::EntityHandle entity,
T  value 
) const [inline]

Definition at line 167 of file SimpleMoab.h.

References Moab, moab::Interface::tag_get_data(), and value().

Referenced by smoab::FaceAdjRegionValues(), smoab::detail::ReadSparseTag::fillRawArray(), and getTagData().

    {
        this->Moab->tag_get_data( tag, &entity, 1, &value );
        return value;
    }
template<typename T >
T smoab::Interface::getTagData ( smoab::Tag  tag,
const smoab::EntityHandle entity,
T  value = T() 
) const [inline]

Definition at line 175 of file SimpleMoab.h.

References getMoabTag(), getTagData(), and value().

    {
        return this->getTagData( getMoabTag( tag ), entity, value );
    }
std::string smoab::Interface::name ( const smoab::EntityHandle entity) const [inline]

Definition at line 182 of file SimpleMoab.h.

References ErrorCode, MB_SUCCESS, MB_TYPE_OPAQUE, Moab, NAME_TAG_NAME, NAME_TAG_SIZE, nameTag, moab::Interface::tag_get_data(), and moab::Interface::tag_get_handle().

Referenced by vtkMoabReader::CreateSubBlocks().

    {
        moab::Tag nameTag;
        moab::ErrorCode rval =
            this->Moab->tag_get_handle( NAME_TAG_NAME, NAME_TAG_SIZE, moab::MB_TYPE_OPAQUE, nameTag );
        if( rval != moab::MB_SUCCESS )
        {
            return std::string();
        }

        char name[NAME_TAG_SIZE];
        rval = this->Moab->tag_get_data( nameTag, &entity, 1, &name );
        if( rval != moab::MB_SUCCESS )
        {
            return std::string();
        }

        return std::string( name );
    }
int smoab::Interface::numChildMeshSets ( const smoab::EntityHandle root) const [inline]

Definition at line 446 of file SimpleMoab.h.

References Moab, and moab::Interface::num_child_meshsets().

    {
        int numChildren;
        this->Moab->num_child_meshsets( root, &numChildren );
        return numChildren;
    }
void smoab::Interface::printRange ( const smoab::Range range) const [inline]

Definition at line 496 of file SimpleMoab.h.

References moab::Range::begin(), moab::Range::end(), moab::Interface::list_entity(), and Moab.

    {
        typedef Range::const_iterator iterator;
        for( iterator i = range.begin(); i != range.end(); ++i )
        {
            std::cout << "entity id: " << *i << std::endl;
            this->Moab->list_entity( *i );
        }
    }
void smoab::Interface::remove ( smoab::Range const &  toDelete) const [inline]

Definition at line 463 of file SimpleMoab.h.

References moab::Interface::delete_entities(), and Moab.

Referenced by smoab::ExtractShell::findSkins().

    {
        this->Moab->delete_entities( toDelete );
    }
smoab::EntityHandle smoab::Interface::sideElement ( smoab::EntityHandle const &  cell,
int  dim,
int  side 
) const [inline]

Definition at line 470 of file SimpleMoab.h.

References Moab, and moab::Interface::side_element().

    {
        smoab::EntityHandle result( 0 );
        this->Moab->side_element( cell, dim, side, result );
        return result;
    }
std::vector< smoab::EntityHandle > smoab::Interface::sideElements ( smoab::EntityHandle const &  cell,
int  dim 
) const [inline]

Definition at line 480 of file SimpleMoab.h.

References Moab, moab::CN::NumSubEntities(), moab::Interface::side_element(), and moab::Interface::type_from_handle().

Referenced by smoab::ExtractShell::findSkins().

    {
        const EntityType volumeCellType = this->Moab->type_from_handle( cell );
        const int numSides              = static_cast< int >( moab::CN::NumSubEntities( volumeCellType, dim ) );

        std::vector< smoab::EntityHandle > result( numSides );
        for( int side = 0; side < numSides; ++side )
        {
            smoab::EntityHandle* sideElem = &result[side];  //get memory of vector
            this->Moab->side_element( cell, dim, side, *sideElem );
        }
        return result;
    }

Friends And Related Function Documentation

friend class smoab::DataSetConverter [friend]

Definition at line 505 of file SimpleMoab.h.

friend class smoab::detail::LoadGeometry [friend]

Definition at line 506 of file SimpleMoab.h.

friend class smoab::detail::LoadPoly [friend]

Definition at line 507 of file SimpleMoab.h.


Member Data Documentation

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines