MOAB: Mesh Oriented datABase  (version 5.4.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,
00190                                                const int sub_dimension,
00191                                                const int sub_index,
00192                                                int sub_entity_conn[] );
00193 
00194     //! return the vertex indices of the specified sub-entity.
00195     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00196     //! \param sub_dimension Dimension of sub-entity
00197     //! \param sub_index Index of sub-entity
00198     //! \param num_sub_ent_vertices the number of vertices in the sub-entity
00199     static const short* SubEntityVertexIndices( const EntityType this_type,
00200                                                 const int sub_dimension,
00201                                                 const int sub_index,
00202                                                 EntityType& sub_type,
00203                                                 int& num_sub_ent_vertices );
00204 
00205     //! return the node indices of the specified sub-entity.
00206     //! \param this_topo            The topology of the queried element type
00207     //! \param num_nodes            The number of nodes in the queried element type.
00208     //! \param sub_dimension        Dimension of sub-entity
00209     //! \param sub_index            Index of sub-entity
00210     //! \param sub_entity_topo      (Output) Topology of requested sub-entity.
00211     //! \param num_sub_entity_nodes (Output) Number of nodes in the requested sub-entity.
00212     //! \param sub_entity_conn      (Output) Connectivity of sub-entity
00213     static void SubEntityNodeIndices( const EntityType this_topo,
00214                                       const int num_nodes,
00215                                       const int sub_dimension,
00216                                       const int sub_index,
00217                                       EntityType& sub_entity_topo,
00218                                       int& num_sub_entity_nodes,
00219                                       int sub_entity_conn[] );
00220 
00221     //! return the vertices of the specified sub entity
00222     //! \param parent_conn Connectivity of parent entity
00223     //! \param parent_type Entity type of parent entity
00224     //! \param sub_dimension Dimension of sub-entity being queried
00225     //! \param sub_index Index of sub-entity being queried
00226     //! \param sub_entity_conn Connectivity of sub-entity, based on parent_conn and canonical
00227     //!           ordering for parent_type
00228     //! \param num_sub_vertices Number of vertices in sub-entity
00229     static void SubEntityConn( const void* parent_conn,
00230                                const EntityType parent_type,
00231                                const int sub_dimension,
00232                                const int sub_index,
00233                                void* sub_entity_conn,
00234                                int& num_sub_vertices );
00235 
00236     //! For a specified set of sides of given dimension, return the intersection
00237     //! or union of all sides of specified target dimension adjacent to those sides.
00238     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00239     //! \param source_indices Indices of sides being queried
00240     //! \param num_source_indices Number of entries in <em>source_indices</em>
00241     //! \param source_dim Dimension of source entity
00242     //! \param target_dim Dimension of target entity
00243     //! \param index_list Indices of target entities (returned)
00244     //! \param operation_type Specify either CN::INTERSECT or CN::UNION to get intersection
00245     //!        or union of target entity lists over source entities
00246     static short int AdjacentSubEntities( const EntityType this_type,
00247                                           const int* source_indices,
00248                                           const int num_source_indices,
00249                                           const int source_dim,
00250                                           const int target_dim,
00251                                           std::vector< int >& index_list,
00252                                           const int operation_type = CN::INTERSECT );
00253 
00254     //! return the side index represented in the input sub-entity connectivity in the input
00255     //! parent entity connectivity array.
00256     //! \param parent_conn Connectivity of parent entity being queried
00257     //! \param parent_type Entity type of parent entity
00258     //! \param child_conn Connectivity of child whose index is being queried
00259     //! \param child_num_verts Number of vertices in <em>child_conn</em>
00260     //! \param child_dim Dimension of child entity being queried
00261     //! \param side_number Side number of child entity (returned)
00262     //! \param sense Sense of child entity with respect to order in <em>child_conn</em> (returned)
00263     //! \param offset Offset of <em>child_conn</em> with respect to canonical ordering data
00264     //! (returned) \return status Returns zero if successful, -1 if not
00265     static short int SideNumber( const EntityType parent_type,
00266                                  const int* parent_conn,
00267                                  const int* child_conn,
00268                                  const int child_num_verts,
00269                                  const int child_dim,
00270                                  int& side_number,
00271                                  int& sense,
00272                                  int& offset );
00273     static short int SideNumber( const EntityType parent_type,
00274                                  const unsigned int* parent_conn,
00275                                  const unsigned int* child_conn,
00276                                  const int child_num_verts,
00277                                  const int child_dim,
00278                                  int& side_number,
00279                                  int& sense,
00280                                  int& offset );
00281     static short int SideNumber( const EntityType parent_type,
00282                                  const long* parent_conn,
00283                                  const long* child_conn,
00284                                  const int child_num_verts,
00285                                  const int child_dim,
00286                                  int& side_number,
00287                                  int& sense,
00288                                  int& offset );
00289     static short int SideNumber( const EntityType parent_type,
00290                                  const unsigned long* parent_conn,
00291                                  const unsigned long* child_conn,
00292                                  const int child_num_verts,
00293                                  const int child_dim,
00294                                  int& side_number,
00295                                  int& sense,
00296                                  int& offset );
00297     static short int SideNumber( const EntityType parent_type,
00298                                  const unsigned long long* parent_conn,
00299                                  const unsigned long long* child_conn,
00300                                  const int child_num_verts,
00301                                  const int child_dim,
00302                                  int& side_number,
00303                                  int& sense,
00304                                  int& offset );
00305     static short int SideNumber( const EntityType parent_type,
00306                                  void* const* parent_conn,
00307                                  void* const* child_conn,
00308                                  const int child_num_verts,
00309                                  const int child_dim,
00310                                  int& side_number,
00311                                  int& sense,
00312                                  int& offset );
00313 
00314     //! return the side index represented in the input sub-entity connectivity
00315     //! \param parent_type Entity type of parent entity
00316     //! \param child_conn_indices Child connectivity to query, specified as indices
00317     //!                           into the connectivity list of the parent.
00318     //! \param child_num_verts Number of values in <em>child_conn_indices</em>
00319     //! \param child_dim Dimension of child entity being queried
00320     //! \param side_number Side number of child entity (returned)
00321     //! \param sense Sense of child entity with respect to order in <em>child_conn</em> (returned)
00322     //! \param offset Offset of <em>child_conn</em> with respect to canonical ordering data
00323     //! (returned) \return status Returns zero if successful, -1 if not
00324     static short int SideNumber( const EntityType parent_type,
00325                                  const int* child_conn_indices,
00326                                  const int child_num_verts,
00327                                  const int child_dim,
00328                                  int& side_number,
00329                                  int& sense,
00330                                  int& offset );
00331 
00332     //! return the dimension and index of the opposite side, given parent entity type and child
00333     //! dimension and index.  This function is only defined for certain types of parent/child types:
00334     //! (Parent, Child dim->Opposite dim):
00335     //!  (Tri, 1->0), (Tri, 0->1), (Quad, 1->1), (Quad, 0->0),
00336     //!  (Tet, 2->0), (Tet, 1->1), (Tet, 0->2),
00337     //!  (Hex, 2->2), (Hex, 1->1)(diagonally across element), (Hex, 0->0) (diagonally across
00338     //!  element)
00339     //! All other parent types and child dimensions return an error.
00340     //!
00341     //! \param parent_type The type of parent element
00342     //! \param child_type The type of child element
00343     //! \param child_index The index of the child element
00344     //! \param opposite_index The index of the opposite element
00345     //! \return status Returns 0 if successful, -1 if not
00346     static short int OppositeSide( const EntityType parent_type,
00347                                    const int child_index,
00348                                    const int child_dim,
00349                                    int& opposite_index,
00350                                    int& opposite_dim );
00351 
00352     //! given two connectivity arrays, determine whether or not they represent the same entity.
00353     //! \param conn1 Connectivity array of first entity
00354     //! \param conn2 Connectivity array of second entity
00355     //! \param num_vertices Number of entries in <em>conn1</em> and <em>conn2</em>
00356     //! \param direct If positive, entities have the same sense (returned)
00357     //! \param offset Offset of <em>conn2</em>'s first vertex in <em>conn1</em>
00358     //! \return bool Returns true if <em>conn1</em> and <em>conn2</em> match
00359     static bool ConnectivityMatch( const int* conn1,
00360                                    const int* conn2,
00361                                    const int num_vertices,
00362                                    int& direct,
00363                                    int& offset );
00364     static bool ConnectivityMatch( const unsigned int* conn1,
00365                                    const unsigned int* conn2,
00366                                    const int num_vertices,
00367                                    int& direct,
00368                                    int& offset );
00369     static bool ConnectivityMatch( const long* conn1,
00370                                    const long* conn2,
00371                                    const int num_vertices,
00372                                    int& direct,
00373                                    int& offset );
00374     static bool ConnectivityMatch( const unsigned long* conn1,
00375                                    const unsigned long* conn2,
00376                                    const int num_vertices,
00377                                    int& direct,
00378                                    int& offset );
00379     static bool ConnectivityMatch( const unsigned long long* conn1,
00380                                    const unsigned long long* conn2,
00381                                    const int num_vertices,
00382                                    int& direct,
00383                                    int& offset );
00384     static bool ConnectivityMatch( void* const* conn1,
00385                                    void* const* conn2,
00386                                    const int num_vertices,
00387                                    int& direct,
00388                                    int& offset );
00389 
00390     //! Set permutation or reverse permutation vector
00391     //! Forward permutation is from CN's numbering into application's ordering;
00392     //! that is, if i is CN's index, pvec[i] is application's index.  This
00393     //! function stores the permutation vector for this type and facet dimension,
00394     //! which then is used in calls to permuteThis or revPermuteThis.
00395     //! \param t EntityType for which to set permutation
00396     //! \param dim Dimension of facets whose permutation array is being set
00397     //! \param pvec Permutation array
00398     //! \param num_entries Number of indicies in permutation array
00399     //! \param is_reverse Array is reverse permutation
00400     static inline void setPermutation( const EntityType t,
00401                                        const int dim,
00402                                        short int* pvec,
00403                                        const int num_entries,
00404                                        const bool is_reverse = false );
00405 
00406     //! Reset permutation or reverse permutation vector
00407     //! \param t EntityType whose permutation vector is being reset
00408     //! \param dim Dimension of facets being reset; if -1 is input, all dimensions are reset
00409     static inline void resetPermutation( const EntityType t, const int dim );
00410 
00411     //! Permute a handle array according to permutation vector set with setPermute;
00412     //! permutation is done in-place
00413     //! \param t EntityType of handles in pvec
00414     //! \param dim Dimension of handles in pvec
00415     //! \param pvec Handle array being permuted
00416     //! \param indices_per_ent Number of indices per entity
00417     //! \param num_entries Number of entities in pvec
00418     static int permuteThis( const EntityType t,
00419                             const int dim,
00420                             int* pvec,
00421                             const int indices_per_ent,
00422                             const int num_entries );
00423     static int permuteThis( const EntityType t,
00424                             const int dim,
00425                             unsigned int* pvec,
00426                             const int indices_per_ent,
00427                             const int num_entries );
00428     static int permuteThis( const EntityType t,
00429                             const int dim,
00430                             long* pvec,
00431                             const int indices_per_ent,
00432                             const int num_entries );
00433     static int permuteThis( const EntityType t,
00434                             const int dim,
00435                             void** pvec,
00436                             const int indices_per_ent,
00437                             const int num_entries );
00438 
00439     //! Reverse permute a handle array according to reverse permutation vector set with setPermute;
00440     //! reverse permutation is done in-place
00441     //! \param t EntityType of handles in pvec
00442     //! \param dim Dimension of handles in pvec
00443     //! \param pvec Handle array being reverse permuted
00444     //! \param indices_per_ent Number of indices per entity
00445     //! \param num_entries Number of entities in pvec
00446     static int revPermuteThis( const EntityType t,
00447                                const int dim,
00448                                int* pvec,
00449                                const int indices_per_ent,
00450                                const int num_entries );
00451     static int revPermuteThis( const EntityType t,
00452                                const int dim,
00453                                unsigned int* pvec,
00454                                const int indices_per_ent,
00455                                const int num_entries );
00456     static int revPermuteThis( const EntityType t,
00457                                const int dim,
00458                                long* pvec,
00459                                const int indices_per_ent,
00460                                const int num_entries );
00461     static int revPermuteThis( const EntityType t,
00462                                const int dim,
00463                                void** pvec,
00464                                const int indices_per_ent,
00465                                const int num_entries );
00466 
00467     //! true if entities of a given type and number of nodes indicates mid edge nodes are present.
00468     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00469     //! \param num_verts Number of nodes defining entity
00470     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
00471     //!  mid-edge nodes are likely
00472     static inline bool HasMidEdgeNodes( const EntityType this_type, const int num_verts );
00473 
00474     //! true if entities of a given type and number of nodes indicates mid face nodes are present.
00475     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00476     //! \param num_verts Number of nodes defining entity
00477     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
00478     //!  mid-face nodes are likely
00479     static inline bool HasMidFaceNodes( const EntityType this_type, const int num_verts );
00480 
00481     //! true if entities of a given type and number of nodes indicates mid region nodes are present.
00482     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00483     //! \param num_verts Number of nodes defining entity
00484     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
00485     //!  mid-region nodes are likely
00486     static inline bool HasMidRegionNodes( const EntityType this_type, const int num_verts );
00487 
00488     //! true if entities of a given type and number of nodes indicates mid edge/face/region nodes
00489     //! are present.
00490     //! \param this_type Type of entity for which sub-entity connectivity is being queried
00491     //! \param num_verts Number of nodes defining entity
00492     //! \param mid_nodes If <em>mid_nodes[i], i=1..2</em> is non-zero, indicates that mid-edge
00493     //!    (i=1), mid-face (i=2), and/or mid-region (i=3) nodes are likely
00494     static inline void HasMidNodes( const EntityType this_type, const int num_verts, int mid_nodes[4] );
00495 
00496     //! Same as above, except returns a single integer with the bits, from
00497     //! least significant to most significant set to one if the corresponding
00498     //! mid nodes on sub entities of the least dimension (0) to the highest
00499     //! dimension (3) are present in the elment type.
00500     static inline int HasMidNodes( const EntityType this_type, const int num_verts );
00501 
00502     //! given data about an element and a vertex in that element, return the dimension
00503     //! and index of the sub-entity that the vertex resolves.  If it does not resolve a
00504     //! sub-entity, either because it's a corner node or it's not in the element, -1 is
00505     //! returned in both return values.
00506     //! \param elem_type Type of entity being queried
00507     //! \param num_nodes The number of nodes in the element connectivity
00508     //! \param ho_node_index The position of the HO node in the connectivity list (zero based)
00509     //! \param parent_dim Dimension of sub-entity high-order node resolves (returned)
00510     //! \param parent_index Index of sub-entity high-order node resolves (returned)
00511     static void HONodeParent( EntityType elem_type,
00512                               int num_nodes,
00513                               int ho_node_index,
00514                               int& parent_dim,
00515                               int& parent_index );
00516 
00517     //! for an entity of this type with num_verts vertices, and a specified subfacet
00518     //! (dimension and index), return the index of the higher order node for that entity
00519     //! in this entity's connectivity array
00520     //! \param this_type Type of entity being queried
00521     //! \param num_verts Number of vertices for the entity being queried
00522     //! \param subfacet_dim Dimension of sub-entity being queried
00523     //! \param subfacet_index Index of sub-entity being queried
00524     //! \return index Index of sub-entity's higher-order node
00525     static short int HONodeIndex( const EntityType this_type,
00526                                   const int num_verts,
00527                                   const int subfacet_dim,
00528                                   const int subfacet_index );
00529 };
00530 
00531 //! get the basis of the numbering system
00532 inline short int CN::GetBasis()
00533 {
00534     return numberBasis;
00535 }
00536 
00537 //! return the connectivity of the specified sub-entity.
00538 inline void CN::SubEntityVertexIndices( const EntityType this_type,
00539                                         const int sub_dimension,
00540                                         const int index,
00541                                         int sub_entity_conn[] )
00542 {
00543     EntityType type;
00544     int n;
00545     const short* indices = SubEntityVertexIndices( this_type, sub_dimension, index, type, n );
00546     std::copy( indices, indices + n, sub_entity_conn );
00547 }
00548 
00549 inline bool CN::HasMidEdgeNodes( const EntityType this_type, const int num_nodes )
00550 {
00551     const int bits = HasMidNodes( this_type, num_nodes );
00552     return static_cast< bool >( ( bits & ( 1 << 1 ) ) >> 1 );
00553 }
00554 
00555 inline bool CN::HasMidFaceNodes( const EntityType this_type, const int num_nodes )
00556 {
00557     const int bits = HasMidNodes( this_type, num_nodes );
00558     return static_cast< bool >( ( bits & ( 1 << 2 ) ) >> 2 );
00559 }
00560 
00561 inline bool CN::HasMidRegionNodes( const EntityType this_type, const int num_nodes )
00562 {
00563     const int bits = HasMidNodes( this_type, num_nodes );
00564     return static_cast< bool >( ( bits & ( 1 << 3 ) ) >> 3 );
00565 }
00566 
00567 inline int CN::HasMidNodes( const EntityType this_type, const int num_nodes )
00568 {
00569     assert( (unsigned)num_nodes <= (unsigned)MAX_NODES_PER_ELEMENT );
00570     return midNodesPerType[this_type][num_nodes];
00571 }
00572 
00573 inline void CN::HasMidNodes( const EntityType this_type, const int num_nodes, int mid_nodes[4] )
00574 {
00575     const int bits = HasMidNodes( this_type, num_nodes );
00576     mid_nodes[0]   = 0;
00577     mid_nodes[1]   = ( bits & ( 1 << 1 ) ) >> 1;
00578     mid_nodes[2]   = ( bits & ( 1 << 2 ) ) >> 2;
00579     mid_nodes[3]   = ( bits & ( 1 << 3 ) ) >> 3;
00580 }
00581 
00582 //! Set permutation or reverse permutation vector
00583 inline void CN::setPermutation( const EntityType t,
00584                                 const int dim,
00585                                 short int* pvec,
00586                                 const int num_entries,
00587                                 const bool is_reverse )
00588 {
00589     short int *this_vec = permuteVec[t][dim], *that_vec = revPermuteVec[t][dim];
00590     if( is_reverse )
00591     {
00592         this_vec = revPermuteVec[t][dim];
00593         that_vec = permuteVec[t][dim];
00594     }
00595 
00596     for( short int i = 0; i < num_entries; i++ )
00597     {
00598         this_vec[i]       = pvec[i];
00599         that_vec[pvec[i]] = i;
00600     }
00601 
00602     this_vec[MAX_SUB_ENTITIES] = that_vec[MAX_SUB_ENTITIES] = (short)num_entries;
00603 }
00604 
00605 //! Reset permutation or reverse permutation vector
00606 inline void CN::resetPermutation( const EntityType t, const int dim )
00607 {
00608     if( -1 == dim )
00609     {
00610         for( unsigned int i = 0; i < 3; i++ )
00611             resetPermutation( t, i );
00612         return;
00613     }
00614 
00615     for( short unsigned int i = 0; i < MAX_SUB_ENTITIES; i++ )
00616     {
00617         revPermuteVec[t][dim][i] = permuteVec[t][dim][i] = i;
00618     }
00619 
00620     revPermuteVec[t][dim][MAX_SUB_ENTITIES] = permuteVec[t][dim][MAX_SUB_ENTITIES] = MAX_SUB_ENTITIES + 1;
00621 }
00622 
00623 }  // namespace moab
00624 
00625 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines