MOAB: Mesh Oriented datABase  (version 5.3.1)
ExoIIUtil.hpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 #ifndef EXOII_UTIL
00017 #define EXOII_UTIL
00018 
00019 //
00020 // ExoIIUtil class: utility class for functions used by both reader
00021 // and writer
00022 
00023 #ifndef IS_BUILDING_MB
00024 #error "ExoIIUtil.hpp isn't supposed to be included into an application"
00025 #endif
00026 
00027 #include "moab/Forward.hpp"
00028 #include "moab/ExoIIInterface.hpp"
00029 
00030 namespace moab
00031 {
00032 
00033 class ExoIIUtil : public ExoIIInterface
00034 {
00035 
00036     Interface* mMB;
00037 
00038   public:
00039     ExoIIUtil( Interface* mdb ) : mMB( mdb ) {}
00040     ~ExoIIUtil() {}
00041 
00042     //! given the element name, return the type
00043     virtual ExoIIElementType element_name_to_type( const char* name )
00044     {
00045         return static_element_name_to_type( name );
00046     }
00047 
00048     //! get the element type of the entity; this entity can either be a meshset,
00049     //! in which case it will be assumed to be a material set meshset, or an
00050     //! individual entity.
00051     virtual ExoIIElementType get_element_type( EntityHandle entity, Tag mid_nodes_tag, Tag geom_dimension_tag,
00052                                                EntityType indiv_entity_type = MBMAXTYPE )
00053     {
00054         return static_get_element_type( mMB, entity, mid_nodes_tag, geom_dimension_tag, indiv_entity_type );
00055     }
00056 
00057     virtual void has_mid_nodes( ExoIIElementType elem_type, int* array )
00058     {
00059         array[0] = HasMidNodes[elem_type][0];
00060         array[1] = HasMidNodes[elem_type][1];
00061         array[2] = HasMidNodes[elem_type][2];
00062         array[3] = HasMidNodes[elem_type][3];
00063     }
00064 
00065     virtual int has_mid_nodes( ExoIIElementType elem_type, int dimension )
00066     {
00067         return HasMidNodes[elem_type][dimension];
00068     }
00069 
00070     virtual int geometric_dimension( const ExoIIElementType elem_type )
00071     {
00072         return ElementGeometricDimension[elem_type];
00073     }
00074 
00075     virtual const char* element_type_name( ExoIIElementType type )
00076     {
00077         return ElementTypeNames[type];
00078     }
00079 
00080     //! given the element name, return the type
00081     static ExoIIElementType static_element_name_to_type( const char* name );
00082 
00083     //! get the element type of the entity; this entity can either be a meshset, in which
00084     //! case it will be assumed to be a material set meshset, or an individual entity.  If a
00085     //! meshset, and indiv_entity_type is input, that type is used to start the search for
00086     //! the connectivity tag which determines how many vertices per entity are defined for that
00087     //! meshset
00088     static ExoIIElementType static_get_element_type( Interface* mdbImpl, const EntityHandle entity,
00089                                                      const Tag mid_nodes_tag, const Tag geom_dimension_tag,
00090                                                      const EntityType indiv_entity_type = MBMAXTYPE );
00091 
00092     //! given the number of vertices in an entity, and optionally the entity type and
00093     //! geometric dimension, return the corresponding exodusII element type; dimension defaults
00094     //! to 3 following TSTT convention
00095     static ExoIIElementType get_element_type_from_num_verts( const int num_verts,
00096                                                              const EntityType entity_type = MBMAXTYPE,
00097                                                              const int dimension          = 3 );
00098 
00099     //! the MB entity type used for each element type
00100     static const EntityType ExoIIElementMBEntity[];
00101 
00102     //! names for all the element types that MB ExoII reader supports
00103     static const char* ElementTypeNames[];
00104 
00105     //! number of vertices per element
00106     static const int VerticesPerElement[];
00107 
00108     //! HasMidNode[elem_type][dim] = 1 denotes that elem_type has mid-nodes
00109     //! on sub-entities of dimension dim
00110     static const int HasMidNodes[][4];
00111 
00112     //! geometric dimension of each element
00113     static const int ElementGeometricDimension[];
00114 };
00115 
00116 //! postfix increment operator for EntityType
00117 inline ExoIIElementType operator++( ExoIIElementType& type, int )
00118 {
00119     return ( ExoIIElementType )( ( (int&)type )++ );
00120 }
00121 
00122 //! prefix increment operator for EntityType
00123 inline ExoIIElementType& operator++( ExoIIElementType& type )
00124 {
00125     return (ExoIIElementType&)( ++( (int&)type ) );
00126 }
00127 
00128 }  // namespace moab
00129 
00130 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines