MOAB: Mesh Oriented datABase  (version 5.3.0)
CN.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 /**
00017  * \class moab::CN
00018  * \author Tim Tautges
00019  * \date April 2004
00020  *
00021  * \brief Canonical numbering data and functions
00022  * This class represents canonical ordering of finite-element meshes.
00023  * Elements in the finite element "zoo" are represented.  Canonical numbering
00024  * denotes the vertex, edge, and face numbers making up each kind of element,
00025  * and the vertex numbers defining those entities.  Functions for evaluating
00026  * adjacencies and other things based on vertex numbering are also provided.
00027  * By default, this class defines a zero-based numbering system.
00028  * For a complete description of this class, see the document "MOAB Canonical
00029  * Numbering Conventions", Timothy J. Tautges, Sandia National Laboratories
00030  * Report #SAND2004-xxxx.
00031  */
00032 #ifndef MOAB_CN_HPP
00033 #define MOAB_CN_HPP
00034 
00035 #include <vector>
00036 #include <algorithm>
00037 #include <cassert>
00038 
00039 #include "moab/EntityType.hpp"
00040 
00041 #include "moab/win32_config.h"
00042 
00043 namespace moab
00044 {
00045 
00046 enum
00047 {
00048     //! the maximum number n-1 dimension adjacencies a element may have
00049     MAX_SUB_ENTITIES = 12,
00050     //! the maximum number of nodes an n-1 dimensional element may have
00051     MAX_SUB_ENTITY_VERTICES = 9
00052 };
00053 
00054 typedef std::pair< EntityType, EntityType > DimensionPair;
00055 
00056 class CN
00057 {
00058   private:
00059     //! entity names
00060     static MOAB_EXPORT const char* entityTypeNames[];
00061 
00062     //! declare private constructor, since we don't want to create any of these
00063     CN();
00064 
00065     //! the basis of the numbering system (normally 0 or 1, 0 by default)
00066     static MOAB_EXPORT short int numberBasis;
00067 
00068     //! switch the basis
00069     static void SwitchBasis( const int old_basis, const int new_basis );
00070 
00071     static MOAB_EXPORT short increasingInts[];
00072 
00073   public:
00074     enum
00075     {
00076         MAX_NODES_PER_ELEMENT = 27
00077     };
00078     enum
00079     {
00080         MID_EDGE_BIT   = 1 << 1,
00081         MID_FACE_BIT   = 1 << 2,
00082         MID_REGION_BIT = 1 << 3
00083     };
00084 
00085     //! enum used to specify operation type
00086     enum
00087     {
00088         INTERSECT = 0,
00089         UNION
00090     };
00091 
00092     // each entity type has two ConnMap objects, holding information about the bounding
00093     // edges and faces for each entity; see comment for mConnectivityMap
00094     // (this struct not documented with Doxygen)
00095     struct ConnMap
00096     {
00097         // Topological dimension of this entry
00098         short int topo_dimension;
00099 
00100         // Number of sub-elements of this dimension
00101         short int num_sub_elements;
00102 
00103         // Number of nodes in each sub-element of this dimension
00104         short int num_corners_per_sub_element[MAX_SUB_ENTITIES];
00105 
00106         // Type of each sub-element
00107         EntityType target_type[MAX_SUB_ENTITIES];
00108 
00109         // Connectivity of each of the sub-elements
00110         short int conn[MAX_SUB_ENTITIES][MAX_SUB_ENTITY_VERTICES];
00111     };
00112 
00113     // mConnectivityMap[i=entity type][j=0,1,2]:
00114     //  num_sub_elements = # bounding edges(j=0) or faces(j=1) for entity type i, or self (j=2)
00115     //  num_corners_per_sub_element[k] (k=0..num_sub_elements-1) = number of nodes in sub-facet k
00116     //    (can vary over sub-facets, e.g. faces bounding a pyramid) or self (j=2)
00117     //  target_type[k] = entity type of sub-facet k (e.g. MBTRI or MBQUAD bounding a pyramid) or
00118     //  self (j=2) conn[k][l] (l=0..CN::VerticesPerEntity[target_type[k]]) = vertex connectivity of
00119     //  sub-facet k,
00120     //    with respect to entity i's canonical vertex ordering, or self (j=2)
00121     // (not documented with Doxygen)
00122     static MOAB_EXPORT const ConnMap mConnectivityMap[MBMAXTYPE][3];
00123 
00124     // structure used to define reverse canonical ordering information
00125     // (not documented with Doxygen)
00126     struct UpConnMap
00127     {
00128         // Number of higher-dimensional entities using each sub-entity
00129         short int num_targets_per_source_element[MAX_SUB_ENTITIES];
00130 
00131         // Higher-dimensional entities using each sub-entity
00132         short int targets_per_source_element[MAX_SUB_ENTITIES][MAX_SUB_ENTITIES];
00133     };
00134 
00135     // Reverse canonical numbering, duplicates data in mConnectivityMap, but
00136     // connectivity data in this table must be in ascending order (used for
00137     // efficient sorting)
00138     // (not documented with Doxygen)
00139     static const UpConnMap mUpConnMap[MBMAXTYPE][4][4];
00140 
00141     // Mid-node bits indexed by number of nodes in element
00142     static MOAB_EXPORT const unsigned char midNodesPerType[MBMAXTYPE][MAX_NODES_PER_ELEMENT + 1];
00143 
00144     //! Permutation and reverse permutation vectors
00145     static short int permuteVec[MBMAXTYPE][3][MAX_SUB_ENTITIES + 1];
00146     static short int revPermuteVec[MBMAXTYPE][3][MAX_SUB_ENTITIES + 1];
00147 
00148     //! this const vector defines the starting and ending EntityType for
00149     //! each dimension, e.g. TypeDimensionMap[2] returns a pair of EntityTypes
00150     //! bounding dimension 2.
00151     static MOAB_EXPORT const DimensionPair TypeDimensionMap[];
00152 
00153     /// Get the dimension pair corresponding to a dimension
00154     static DimensionPair getDimPair( int entity_type );
00155 
00156     //! get the basis of the numbering system
00157     static short int GetBasis();
00158 
00159     //! set the basis of the numbering system
00160     static void SetBasis( const int in_basis );
00161 
00162     //! return the string type name for this type
00163     static const char* EntityTypeName( const EntityType this_type );
00164 
00165     //! given a name, find the corresponding entity type
00166     static EntityType EntityTypeFromName( const char* name );
00167 
00168     //! return the topological entity dimension
00169     static short int Dimension( const EntityType t );
00170 
00171     //! return the number of (corner) vertices contained in the specified type.
00172     static short int VerticesPerEntity( const EntityType t );
00173 
00174     //! return the number of sub-entities bounding the entity.
00175     static short int NumSubEntities( const EntityType t, const int d );
00176 
00177     //! return the type of a particular sub-entity.
00178     //! \param this_type Type of entity for which sub-entity type is being queried
00179     //! \param sub_dimension Topological dimension of sub-entity whose type is being queried
00180     //! \param index Index of sub-entity whose type is being queried
00181     //! \return type Entity type of sub-entity with specified dimension and index
00182     static EntityType SubEntityType( const EntityType this_type, const int sub_dimension, const int index );
00183 
00184     //! return the vertex indices of the specified sub-entity.
00185     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00186     //! \param sub_dimension Dimension of sub-entity
00187     //! \param sub_index Index of sub-entity
00188     //! \param sub_entity_conn Connectivity of sub-entity (returned to calling function)
00189     static void inline SubEntityVertexIndices( const EntityType this_type, const int sub_dimension, const int sub_index,
00190                                                int sub_entity_conn[] );
00191 
00192     //! return the vertex indices of the specified sub-entity.
00193     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00194     //! \param sub_dimension Dimension of sub-entity
00195     //! \param sub_index Index of sub-entity
00196     //! \param num_sub_ent_vertices the number of vertices in the sub-entity
00197     static const short* SubEntityVertexIndices( const EntityType this_type, const int sub_dimension,
00198                                                 const int sub_index, EntityType& sub_type, int& num_sub_ent_vertices );
00199 
00200     //! return the node indices of the specified sub-entity.
00201     //! \param this_topo            The topology of the queried element type
00202     //! \param num_nodes            The number of nodes in the queried element type.
00203     //! \param sub_dimension        Dimension of sub-entity
00204     //! \param sub_index            Index of sub-entity
00205     //! \param sub_entity_topo      (Output) Topology of requested sub-entity.
00206     //! \param num_sub_entity_nodes (Output) Number of nodes in the requested sub-entity.
00207     //! \param sub_entity_conn      (Output) Connectivity of sub-entity
00208     static void SubEntityNodeIndices( const EntityType this_topo, const int num_nodes, const int sub_dimension,
00209                                       const int sub_index, EntityType& sub_entity_topo, int& num_sub_entity_nodes,
00210                                       int sub_entity_conn[] );
00211 
00212     //! return the vertices of the specified sub entity
00213     //! \param parent_conn Connectivity of parent entity
00214     //! \param parent_type Entity type of parent entity
00215     //! \param sub_dimension Dimension of sub-entity being queried
00216     //! \param sub_index Index of sub-entity being queried
00217     //! \param sub_entity_conn Connectivity of sub-entity, based on parent_conn and canonical
00218     //!           ordering for parent_type
00219     //! \param num_sub_vertices Number of vertices in sub-entity
00220     static void SubEntityConn( const void* parent_conn, const EntityType parent_type, const int sub_dimension,
00221                                const int sub_index, void* sub_entity_conn, int& num_sub_vertices );
00222 
00223     //! For a specified set of sides of given dimension, return the intersection
00224     //! or union of all sides of specified target dimension adjacent to those sides.
00225     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00226     //! \param source_indices Indices of sides being queried
00227     //! \param num_source_indices Number of entries in <em>source_indices</em>
00228     //! \param source_dim Dimension of source entity
00229     //! \param target_dim Dimension of target entity
00230     //! \param index_list Indices of target entities (returned)
00231     //! \param operation_type Specify either CN::INTERSECT or CN::UNION to get intersection
00232     //!        or union of target entity lists over source entities
00233     static short int AdjacentSubEntities( const EntityType this_type, const int* source_indices,
00234                                           const int num_source_indices, const int source_dim, const int target_dim,
00235                                           std::vector< int >& index_list, const int operation_type = CN::INTERSECT );
00236 
00237     //! return the side index represented in the input sub-entity connectivity in the input
00238     //! parent entity connectivity array.
00239     //! \param parent_conn Connectivity of parent entity being queried
00240     //! \param parent_type Entity type of parent entity
00241     //! \param child_conn Connectivity of child whose index is being queried
00242     //! \param child_num_verts Number of vertices in <em>child_conn</em>
00243     //! \param child_dim Dimension of child entity being queried
00244     //! \param side_number Side number of child entity (returned)
00245     //! \param sense Sense of child entity with respect to order in <em>child_conn</em> (returned)
00246     //! \param offset Offset of <em>child_conn</em> with respect to canonical ordering data
00247     //! (returned) \return status Returns zero if successful, -1 if not
00248     static short int SideNumber( const EntityType parent_type, const int* parent_conn, const int* child_conn,
00249                                  const int child_num_verts, const int child_dim, int& side_number, int& sense,
00250                                  int& offset );
00251     static short int SideNumber( const EntityType parent_type, const unsigned int* parent_conn,
00252                                  const unsigned int* child_conn, const int child_num_verts, const int child_dim,
00253                                  int& side_number, int& sense, int& offset );
00254     static short int SideNumber( const EntityType parent_type, const long* parent_conn, const long* child_conn,
00255                                  const int child_num_verts, const int child_dim, int& side_number, int& sense,
00256                                  int& offset );
00257     static short int SideNumber( const EntityType parent_type, const unsigned long* parent_conn,
00258                                  const unsigned long* child_conn, const int child_num_verts, const int child_dim,
00259                                  int& side_number, int& sense, int& offset );
00260     static short int SideNumber( const EntityType parent_type, const unsigned long long* parent_conn,
00261                                  const unsigned long long* child_conn, const int child_num_verts, const int child_dim,
00262                                  int& side_number, int& sense, int& offset );
00263     static short int SideNumber( const EntityType parent_type, void* const* parent_conn, void* const* child_conn,
00264                                  const int child_num_verts, const int child_dim, int& side_number, int& sense,
00265                                  int& offset );
00266 
00267     //! return the side index represented in the input sub-entity connectivity
00268     //! \param parent_type Entity type of parent entity
00269     //! \param child_conn_indices Child connectivity to query, specified as indices
00270     //!                           into the connectivity list of the parent.
00271     //! \param child_num_verts Number of values in <em>child_conn_indices</em>
00272     //! \param child_dim Dimension of child entity being queried
00273     //! \param side_number Side number of child entity (returned)
00274     //! \param sense Sense of child entity with respect to order in <em>child_conn</em> (returned)
00275     //! \param offset Offset of <em>child_conn</em> with respect to canonical ordering data
00276     //! (returned) \return status Returns zero if successful, -1 if not
00277     static short int SideNumber( const EntityType parent_type, const int* child_conn_indices, const int child_num_verts,
00278                                  const int child_dim, int& side_number, int& sense, int& offset );
00279 
00280     //! return the dimension and index of the opposite side, given parent entity type and child
00281     //! dimension and index.  This function is only defined for certain types of parent/child types:
00282     //! (Parent, Child dim->Opposite dim):
00283     //!  (Tri, 1->0), (Tri, 0->1), (Quad, 1->1), (Quad, 0->0),
00284     //!  (Tet, 2->0), (Tet, 1->1), (Tet, 0->2),
00285     //!  (Hex, 2->2), (Hex, 1->1)(diagonally across element), (Hex, 0->0) (diagonally across
00286     //!  element)
00287     //! All other parent types and child dimensions return an error.
00288     //!
00289     //! \param parent_type The type of parent element
00290     //! \param child_type The type of child element
00291     //! \param child_index The index of the child element
00292     //! \param opposite_index The index of the opposite element
00293     //! \return status Returns 0 if successful, -1 if not
00294     static short int OppositeSide( const EntityType parent_type, const int child_index, const int child_dim,
00295                                    int& opposite_index, int& opposite_dim );
00296 
00297     //! given two connectivity arrays, determine whether or not they represent the same entity.
00298     //! \param conn1 Connectivity array of first entity
00299     //! \param conn2 Connectivity array of second entity
00300     //! \param num_vertices Number of entries in <em>conn1</em> and <em>conn2</em>
00301     //! \param direct If positive, entities have the same sense (returned)
00302     //! \param offset Offset of <em>conn2</em>'s first vertex in <em>conn1</em>
00303     //! \return bool Returns true if <em>conn1</em> and <em>conn2</em> match
00304     static bool ConnectivityMatch( const int* conn1, const int* conn2, const int num_vertices, int& direct,
00305                                    int& offset );
00306     static bool ConnectivityMatch( const unsigned int* conn1, const unsigned int* conn2, const int num_vertices,
00307                                    int& direct, int& offset );
00308     static bool ConnectivityMatch( const long* conn1, const long* conn2, const int num_vertices, int& direct,
00309                                    int& offset );
00310     static bool ConnectivityMatch( const unsigned long* conn1, const unsigned long* conn2, const int num_vertices,
00311                                    int& direct, int& offset );
00312     static bool ConnectivityMatch( const unsigned long long* conn1, const unsigned long long* conn2,
00313                                    const int num_vertices, int& direct, int& offset );
00314     static bool ConnectivityMatch( void* const* conn1, void* const* conn2, const int num_vertices, int& direct,
00315                                    int& offset );
00316 
00317     //! Set permutation or reverse permutation vector
00318     //! Forward permutation is from CN's numbering into application's ordering;
00319     //! that is, if i is CN's index, pvec[i] is application's index.  This
00320     //! function stores the permutation vector for this type and facet dimension,
00321     //! which then is used in calls to permuteThis or revPermuteThis.
00322     //! \param t EntityType for which to set permutation
00323     //! \param dim Dimension of facets whose permutation array is being set
00324     //! \param pvec Permutation array
00325     //! \param num_entries Number of indicies in permutation array
00326     //! \param is_reverse Array is reverse permutation
00327     static inline void setPermutation( const EntityType t, const int dim, short int* pvec, const int num_entries,
00328                                        const bool is_reverse = false );
00329 
00330     //! Reset permutation or reverse permutation vector
00331     //! \param t EntityType whose permutation vector is being reset
00332     //! \param dim Dimension of facets being reset; if -1 is input, all dimensions are reset
00333     static inline void resetPermutation( const EntityType t, const int dim );
00334 
00335     //! Permute a handle array according to permutation vector set with setPermute;
00336     //! permutation is done in-place
00337     //! \param t EntityType of handles in pvec
00338     //! \param dim Dimension of handles in pvec
00339     //! \param pvec Handle array being permuted
00340     //! \param indices_per_ent Number of indices per entity
00341     //! \param num_entries Number of entities in pvec
00342     static int permuteThis( const EntityType t, const int dim, int* pvec, const int indices_per_ent,
00343                             const int num_entries );
00344     static int permuteThis( const EntityType t, const int dim, unsigned int* pvec, const int indices_per_ent,
00345                             const int num_entries );
00346     static int permuteThis( const EntityType t, const int dim, long* pvec, const int indices_per_ent,
00347                             const int num_entries );
00348     static int permuteThis( const EntityType t, const int dim, void** pvec, const int indices_per_ent,
00349                             const int num_entries );
00350 
00351     //! Reverse permute a handle array according to reverse permutation vector set with setPermute;
00352     //! reverse permutation is done in-place
00353     //! \param t EntityType of handles in pvec
00354     //! \param dim Dimension of handles in pvec
00355     //! \param pvec Handle array being reverse permuted
00356     //! \param indices_per_ent Number of indices per entity
00357     //! \param num_entries Number of entities in pvec
00358     static int revPermuteThis( const EntityType t, const int dim, int* pvec, const int indices_per_ent,
00359                                const int num_entries );
00360     static int revPermuteThis( const EntityType t, const int dim, unsigned int* pvec, const int indices_per_ent,
00361                                const int num_entries );
00362     static int revPermuteThis( const EntityType t, const int dim, long* pvec, const int indices_per_ent,
00363                                const int num_entries );
00364     static int revPermuteThis( const EntityType t, const int dim, void** pvec, const int indices_per_ent,
00365                                const int num_entries );
00366 
00367     //! true if entities of a given type and number of nodes indicates mid edge nodes are present.
00368     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00369     //! \param num_verts Number of nodes defining entity
00370     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
00371     //!  mid-edge nodes are likely
00372     static inline bool HasMidEdgeNodes( const EntityType this_type, const int num_verts );
00373 
00374     //! true if entities of a given type and number of nodes indicates mid face nodes are present.
00375     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00376     //! \param num_verts Number of nodes defining entity
00377     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
00378     //!  mid-face nodes are likely
00379     static inline bool HasMidFaceNodes( const EntityType this_type, const int num_verts );
00380 
00381     //! true if entities of a given type and number of nodes indicates mid region nodes are present.
00382     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00383     //! \param num_verts Number of nodes defining entity
00384     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
00385     //!  mid-region nodes are likely
00386     static inline bool HasMidRegionNodes( const EntityType this_type, const int num_verts );
00387 
00388     //! true if entities of a given type and number of nodes indicates mid edge/face/region nodes
00389     //! are present.
00390     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00391     //! \param num_verts Number of nodes defining entity
00392     //! \param mid_nodes If <em>mid_nodes[i], i=1..2</em> is non-zero, indicates that mid-edge
00393     //!    (i=1), mid-face (i=2), and/or mid-region (i=3) nodes are likely
00394     static inline void HasMidNodes( const EntityType this_type, const int num_verts, int mid_nodes[4] );
00395 
00396     //! Same as above, except returns a single integer with the bits, from
00397     //! least significant to most significant set to one if the corresponding
00398     //! mid nodes on sub entities of the least dimension (0) to the highest
00399     //! dimension (3) are present in the elment type.
00400     static inline int HasMidNodes( const EntityType this_type, const int num_verts );
00401 
00402     //! given data about an element and a vertex in that element, return the dimension
00403     //! and index of the sub-entity that the vertex resolves.  If it does not resolve a
00404     //! sub-entity, either because it's a corner node or it's not in the element, -1 is
00405     //! returned in both return values.
00406     //! \param elem_type Type of entity being queried
00407     //! \param num_nodes The number of nodes in the element connectivity
00408     //! \param ho_node_index The position of the HO node in the connectivity list (zero based)
00409     //! \param parent_dim Dimension of sub-entity high-order node resolves (returned)
00410     //! \param parent_index Index of sub-entity high-order node resolves (returned)
00411     static void HONodeParent( EntityType elem_type, int num_nodes, int ho_node_index, int& parent_dim,
00412                               int& parent_index );
00413 
00414     //! for an entity of this type with num_verts vertices, and a specified subfacet
00415     //! (dimension and index), return the index of the higher order node for that entity
00416     //! in this entity's connectivity array
00417     //! \param this_type Type of entity being queried
00418     //! \param num_verts Number of vertices for the entity being queried
00419     //! \param subfacet_dim Dimension of sub-entity being queried
00420     //! \param subfacet_index Index of sub-entity being queried
00421     //! \return index Index of sub-entity's higher-order node
00422     static short int HONodeIndex( const EntityType this_type, const int num_verts, const int subfacet_dim,
00423                                   const int subfacet_index );
00424 };
00425 
00426 //! get the basis of the numbering system
00427 inline short int CN::GetBasis()
00428 {
00429     return numberBasis;
00430 }
00431 
00432 //! return the connectivity of the specified sub-entity.
00433 inline void CN::SubEntityVertexIndices( const EntityType this_type, const int sub_dimension, const int index,
00434                                         int sub_entity_conn[] )
00435 {
00436     EntityType type;
00437     int n;
00438     const short* indices = SubEntityVertexIndices( this_type, sub_dimension, index, type, n );
00439     std::copy( indices, indices + n, sub_entity_conn );
00440 }
00441 
00442 inline bool CN::HasMidEdgeNodes( const EntityType this_type, const int num_nodes )
00443 {
00444     const int bits = HasMidNodes( this_type, num_nodes );
00445     return static_cast< bool >( ( bits & ( 1 << 1 ) ) >> 1 );
00446 }
00447 
00448 inline bool CN::HasMidFaceNodes( const EntityType this_type, const int num_nodes )
00449 {
00450     const int bits = HasMidNodes( this_type, num_nodes );
00451     return static_cast< bool >( ( bits & ( 1 << 2 ) ) >> 2 );
00452 }
00453 
00454 inline bool CN::HasMidRegionNodes( const EntityType this_type, const int num_nodes )
00455 {
00456     const int bits = HasMidNodes( this_type, num_nodes );
00457     return static_cast< bool >( ( bits & ( 1 << 3 ) ) >> 3 );
00458 }
00459 
00460 inline int CN::HasMidNodes( const EntityType this_type, const int num_nodes )
00461 {
00462     assert( (unsigned)num_nodes <= (unsigned)MAX_NODES_PER_ELEMENT );
00463     return midNodesPerType[this_type][num_nodes];
00464 }
00465 
00466 inline void CN::HasMidNodes( const EntityType this_type, const int num_nodes, int mid_nodes[4] )
00467 {
00468     const int bits = HasMidNodes( this_type, num_nodes );
00469     mid_nodes[0]   = 0;
00470     mid_nodes[1]   = ( bits & ( 1 << 1 ) ) >> 1;
00471     mid_nodes[2]   = ( bits & ( 1 << 2 ) ) >> 2;
00472     mid_nodes[3]   = ( bits & ( 1 << 3 ) ) >> 3;
00473 }
00474 
00475 //! Set permutation or reverse permutation vector
00476 inline void CN::setPermutation( const EntityType t, const int dim, short int* pvec, const int num_entries,
00477                                 const bool is_reverse )
00478 {
00479     short int *this_vec = permuteVec[t][dim], *that_vec = revPermuteVec[t][dim];
00480     if( is_reverse )
00481     {
00482         this_vec = revPermuteVec[t][dim];
00483         that_vec = permuteVec[t][dim];
00484     }
00485 
00486     for( short int i = 0; i < num_entries; i++ )
00487     {
00488         this_vec[i]       = pvec[i];
00489         that_vec[pvec[i]] = i;
00490     }
00491 
00492     this_vec[MAX_SUB_ENTITIES] = that_vec[MAX_SUB_ENTITIES] = (short)num_entries;
00493 }
00494 
00495 //! Reset permutation or reverse permutation vector
00496 inline void CN::resetPermutation( const EntityType t, const int dim )
00497 {
00498     if( -1 == dim )
00499     {
00500         for( unsigned int i = 0; i < 3; i++ )
00501             resetPermutation( t, i );
00502         return;
00503     }
00504 
00505     for( short unsigned int i = 0; i < MAX_SUB_ENTITIES; i++ )
00506     {
00507         revPermuteVec[t][dim][i] = permuteVec[t][dim][i] = i;
00508     }
00509 
00510     revPermuteVec[t][dim][MAX_SUB_ENTITIES] = permuteVec[t][dim][MAX_SUB_ENTITIES] = MAX_SUB_ENTITIES + 1;
00511 }
00512 
00513 }  // namespace moab
00514 
00515 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines