Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
ExoIIUtil.hpp
Go to the documentation of this file.
1 /**
2  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3  * storing and accessing finite element mesh data.
4  *
5  * Copyright 2004 Sandia Corporation. Under the terms of Contract
6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7  * retains certain rights in this software.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  */
15 
16 #ifndef EXOII_UTIL
17 #define EXOII_UTIL
18 
19 //
20 // ExoIIUtil class: utility class for functions used by both reader
21 // and writer
22 
23 #ifndef IS_BUILDING_MB
24 #error "ExoIIUtil.hpp isn't supposed to be included into an application"
25 #endif
26 
27 #include "moab/Forward.hpp"
28 #include "moab/ExoIIInterface.hpp"
29 
30 namespace moab
31 {
32 
33 class ExoIIUtil : public ExoIIInterface
34 {
35 
37 
38  public:
39  ExoIIUtil( Interface* mdb ) : mMB( mdb ) {}
41 
42  //! given the element name, return the type
43  virtual ExoIIElementType element_name_to_type( const char* name )
44  {
45  return static_element_name_to_type( name );
46  }
47 
48  //! get the element type of the entity; this entity can either be a meshset,
49  //! in which case it will be assumed to be a material set meshset, or an
50  //! individual entity.
52  Tag mid_nodes_tag,
53  Tag geom_dimension_tag,
54  EntityType indiv_entity_type = MBMAXTYPE )
55  {
56  return static_get_element_type( mMB, entity, mid_nodes_tag, geom_dimension_tag, indiv_entity_type );
57  }
58 
59  virtual void has_mid_nodes( ExoIIElementType elem_type, int* array )
60  {
61  array[0] = HasMidNodes[elem_type][0];
62  array[1] = HasMidNodes[elem_type][1];
63  array[2] = HasMidNodes[elem_type][2];
64  array[3] = HasMidNodes[elem_type][3];
65  }
66 
67  virtual int has_mid_nodes( ExoIIElementType elem_type, int dimension )
68  {
69  return HasMidNodes[elem_type][dimension];
70  }
71 
72  virtual int geometric_dimension( const ExoIIElementType elem_type )
73  {
74  return ElementGeometricDimension[elem_type];
75  }
76 
77  virtual const char* element_type_name( ExoIIElementType type )
78  {
79  return ElementTypeNames[type];
80  }
81 
82  //! given the element name, return the type
83  static ExoIIElementType static_element_name_to_type( const char* name );
84 
85  //! get the element type of the entity; this entity can either be a meshset, in which
86  //! case it will be assumed to be a material set meshset, or an individual entity. If a
87  //! meshset, and indiv_entity_type is input, that type is used to start the search for
88  //! the connectivity tag which determines how many vertices per entity are defined for that
89  //! meshset
91  const EntityHandle entity,
92  const Tag mid_nodes_tag,
93  const Tag geom_dimension_tag,
94  const EntityType indiv_entity_type = MBMAXTYPE );
95 
96  //! given the number of vertices in an entity, and optionally the entity type and
97  //! geometric dimension, return the corresponding exodusII element type; dimension defaults
98  //! to 3 following TSTT convention
99  static ExoIIElementType get_element_type_from_num_verts( const int num_verts,
100  const EntityType entity_type = MBMAXTYPE,
101  const int dimension = 3 );
102 
103  //! the MB entity type used for each element type
104  static const EntityType ExoIIElementMBEntity[];
105 
106  //! names for all the element types that MB ExoII reader supports
107  static const char* ElementTypeNames[];
108 
109  //! number of vertices per element
110  static const int VerticesPerElement[];
111 
112  //! HasMidNode[elem_type][dim] = 1 denotes that elem_type has mid-nodes
113  //! on sub-entities of dimension dim
114  static const int HasMidNodes[][4];
115 
116  //! geometric dimension of each element
117  static const int ElementGeometricDimension[];
118 };
119 
120 //! postfix increment operator for EntityType
122 {
123  return (ExoIIElementType)( ( (int&)type )++ );
124 }
125 
126 //! prefix increment operator for EntityType
128 {
129  return (ExoIIElementType&)( ++( (int&)type ) );
130 }
131 
132 } // namespace moab
133 
134 #endif