1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
 * MOAB, a Mesh-Oriented datABase, is a software component for creating,
 * storing and accessing finite element mesh data.
 *
 * Copyright 2004 Sandia Corporation.  Under the terms of Contract
 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
 * retains certain rights in this software.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 */

#ifndef EXOII_UTIL
#define EXOII_UTIL

//
// ExoIIUtil class: utility class for functions used by both reader
// and writer

#ifndef IS_BUILDING_MB
#error "ExoIIUtil.hpp isn't supposed to be included into an application"
#endif

#include "moab/Forward.hpp"
#include "moab/ExoIIInterface.hpp"

namespace moab
{

class ExoIIUtil : public ExoIIInterface
{

    Interface* mMB;

  public:
    ExoIIUtil( Interface* mdb ) : mMB( mdb ) {}
    ~ExoIIUtil() {}

    //! given the element name, return the type
    virtual ExoIIElementType element_name_to_type( const char* name )<--- Function in derived class<--- Function in derived class<--- Function in derived class
    {
        return static_element_name_to_type( name );
    }

    //! get the element type of the entity; this entity can either be a meshset,
    //! in which case it will be assumed to be a material set meshset, or an
    //! individual entity.
    virtual ExoIIElementType get_element_type( EntityHandle entity,<--- Function in derived class<--- Function in derived class<--- Function in derived class
                                               Tag mid_nodes_tag,
                                               Tag geom_dimension_tag,
                                               EntityType indiv_entity_type = MBMAXTYPE )
    {
        return static_get_element_type( mMB, entity, mid_nodes_tag, geom_dimension_tag, indiv_entity_type );
    }

    virtual void has_mid_nodes( ExoIIElementType elem_type, int* array )<--- Function in derived class<--- Function in derived class<--- Function in derived class
    {
        array[0] = HasMidNodes[elem_type][0];
        array[1] = HasMidNodes[elem_type][1];
        array[2] = HasMidNodes[elem_type][2];
        array[3] = HasMidNodes[elem_type][3];
    }

    virtual int has_mid_nodes( ExoIIElementType elem_type, int dimension )<--- Function in derived class<--- Function in derived class<--- Function in derived class
    {
        return HasMidNodes[elem_type][dimension];
    }

    virtual int geometric_dimension( const ExoIIElementType elem_type )<--- Function in derived class<--- Function in derived class<--- Function in derived class
    {
        return ElementGeometricDimension[elem_type];
    }

    virtual const char* element_type_name( ExoIIElementType type )<--- Function in derived class<--- Function in derived class<--- Function in derived class
    {
        return ElementTypeNames[type];
    }

    //! given the element name, return the type
    static ExoIIElementType static_element_name_to_type( const char* name );

    //! get the element type of the entity; this entity can either be a meshset, in which
    //! case it will be assumed to be a material set meshset, or an individual entity.  If a
    //! meshset, and indiv_entity_type is input, that type is used to start the search for
    //! the connectivity tag which determines how many vertices per entity are defined for that
    //! meshset
    static ExoIIElementType static_get_element_type( Interface* mdbImpl,
                                                     const EntityHandle entity,
                                                     const Tag mid_nodes_tag,
                                                     const Tag geom_dimension_tag,
                                                     const EntityType indiv_entity_type = MBMAXTYPE );

    //! given the number of vertices in an entity, and optionally the entity type and
    //! geometric dimension, return the corresponding exodusII element type; dimension defaults
    //! to 3 following TSTT convention
    static ExoIIElementType get_element_type_from_num_verts( const int num_verts,
                                                             const EntityType entity_type = MBMAXTYPE,
                                                             const int dimension          = 3 );

    //! the MB entity type used for each element type
    static const EntityType ExoIIElementMBEntity[];

    //! names for all the element types that MB ExoII reader supports
    static const char* ElementTypeNames[];

    //! number of vertices per element
    static const int VerticesPerElement[];

    //! HasMidNode[elem_type][dim] = 1 denotes that elem_type has mid-nodes
    //! on sub-entities of dimension dim
    static const int HasMidNodes[][4];

    //! geometric dimension of each element
    static const int ElementGeometricDimension[];
};

//! postfix increment operator for EntityType
inline ExoIIElementType operator++( ExoIIElementType& type, int )
{
    return (ExoIIElementType)( ( (int&)type )++ );
}

//! prefix increment operator for EntityType
inline ExoIIElementType& operator++( ExoIIElementType& type )
{
    return (ExoIIElementType&)( ++( (int&)type ) );
}

}  // namespace moab

#endif