Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
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,
00052                                                Tag mid_nodes_tag,
00053                                                Tag geom_dimension_tag,
00054                                                EntityType indiv_entity_type = MBMAXTYPE )
00055     {
00056         return static_get_element_type( mMB, entity, mid_nodes_tag, geom_dimension_tag, indiv_entity_type );
00057     }
00058 
00059     virtual void has_mid_nodes( ExoIIElementType elem_type, int* array )
00060     {
00061         array[0] = HasMidNodes[elem_type][0];
00062         array[1] = HasMidNodes[elem_type][1];
00063         array[2] = HasMidNodes[elem_type][2];
00064         array[3] = HasMidNodes[elem_type][3];
00065     }
00066 
00067     virtual int has_mid_nodes( ExoIIElementType elem_type, int dimension )
00068     {
00069         return HasMidNodes[elem_type][dimension];
00070     }
00071 
00072     virtual int geometric_dimension( const ExoIIElementType elem_type )
00073     {
00074         return ElementGeometricDimension[elem_type];
00075     }
00076 
00077     virtual const char* element_type_name( ExoIIElementType type )
00078     {
00079         return ElementTypeNames[type];
00080     }
00081 
00082     //! given the element name, return the type
00083     static ExoIIElementType static_element_name_to_type( const char* name );
00084 
00085     //! get the element type of the entity; this entity can either be a meshset, in which
00086     //! case it will be assumed to be a material set meshset, or an individual entity.  If a
00087     //! meshset, and indiv_entity_type is input, that type is used to start the search for
00088     //! the connectivity tag which determines how many vertices per entity are defined for that
00089     //! meshset
00090     static ExoIIElementType static_get_element_type( Interface* mdbImpl,
00091                                                      const EntityHandle entity,
00092                                                      const Tag mid_nodes_tag,
00093                                                      const Tag geom_dimension_tag,
00094                                                      const EntityType indiv_entity_type = MBMAXTYPE );
00095 
00096     //! given the number of vertices in an entity, and optionally the entity type and
00097     //! geometric dimension, return the corresponding exodusII element type; dimension defaults
00098     //! to 3 following TSTT convention
00099     static ExoIIElementType get_element_type_from_num_verts( const int num_verts,
00100                                                              const EntityType entity_type = MBMAXTYPE,
00101                                                              const int dimension          = 3 );
00102 
00103     //! the MB entity type used for each element type
00104     static const EntityType ExoIIElementMBEntity[];
00105 
00106     //! names for all the element types that MB ExoII reader supports
00107     static const char* ElementTypeNames[];
00108 
00109     //! number of vertices per element
00110     static const int VerticesPerElement[];
00111 
00112     //! HasMidNode[elem_type][dim] = 1 denotes that elem_type has mid-nodes
00113     //! on sub-entities of dimension dim
00114     static const int HasMidNodes[][4];
00115 
00116     //! geometric dimension of each element
00117     static const int ElementGeometricDimension[];
00118 };
00119 
00120 //! postfix increment operator for EntityType
00121 inline ExoIIElementType operator++( ExoIIElementType& type, int )
00122 {
00123     return (ExoIIElementType)( ( (int&)type )++ );
00124 }
00125 
00126 //! prefix increment operator for EntityType
00127 inline ExoIIElementType& operator++( ExoIIElementType& type )
00128 {
00129     return (ExoIIElementType&)( ++( (int&)type ) );
00130 }
00131 
00132 }  // namespace moab
00133 
00134 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines