LCOV - code coverage report
Current view: top level - src/moab - CN.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 23 25 92.0 %
Date: 2020-12-16 07:07:30 Functions: 6 7 85.7 %
Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       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                 :            : /**
      17                 :            :  * \class moab::CN
      18                 :            :  * \author Tim Tautges
      19                 :            :  * \date April 2004
      20                 :            :  *
      21                 :            :  * \brief Canonical numbering data and functions
      22                 :            :  * This class represents canonical ordering of finite-element meshes.
      23                 :            :  * Elements in the finite element "zoo" are represented.  Canonical numbering
      24                 :            :  * denotes the vertex, edge, and face numbers making up each kind of element,
      25                 :            :  * and the vertex numbers defining those entities.  Functions for evaluating
      26                 :            :  * adjacencies and other things based on vertex numbering are also provided.
      27                 :            :  * By default, this class defines a zero-based numbering system.
      28                 :            :  * For a complete description of this class, see the document "MOAB Canonical
      29                 :            :  * Numbering Conventions", Timothy J. Tautges, Sandia National Laboratories
      30                 :            :  * Report #SAND2004-xxxx.
      31                 :            :  */
      32                 :            : #ifndef MOAB_CN_HPP
      33                 :            : #define MOAB_CN_HPP
      34                 :            : 
      35                 :            : #include <vector>
      36                 :            : #include <algorithm>
      37                 :            : #include <cassert>
      38                 :            : 
      39                 :            : #include "moab/EntityType.hpp"
      40                 :            : 
      41                 :            : #include "moab/win32_config.h"
      42                 :            : 
      43                 :            : namespace moab
      44                 :            : {
      45                 :            : 
      46                 :            : enum
      47                 :            : {
      48                 :            :     //! the maximum number n-1 dimension adjacencies a element may have
      49                 :            :     MAX_SUB_ENTITIES = 12,
      50                 :            :     //! the maximum number of nodes an n-1 dimensional element may have
      51                 :            :     MAX_SUB_ENTITY_VERTICES = 9
      52                 :            : };
      53                 :            : 
      54                 :            : typedef std::pair< EntityType, EntityType > DimensionPair;
      55                 :            : 
      56                 :            : class CN
      57                 :            : {
      58                 :            :   private:
      59                 :            :     //! entity names
      60                 :            :     static MOAB_EXPORT const char* entityTypeNames[];
      61                 :            : 
      62                 :            :     //! declare private constructor, since we don't want to create any of these
      63                 :            :     CN();
      64                 :            : 
      65                 :            :     //! the basis of the numbering system (normally 0 or 1, 0 by default)
      66                 :            :     static MOAB_EXPORT short int numberBasis;
      67                 :            : 
      68                 :            :     //! switch the basis
      69                 :            :     static void SwitchBasis( const int old_basis, const int new_basis );
      70                 :            : 
      71                 :            :     static MOAB_EXPORT short increasingInts[];
      72                 :            : 
      73                 :            :   public:
      74                 :            :     enum
      75                 :            :     {
      76                 :            :         MAX_NODES_PER_ELEMENT = 27
      77                 :            :     };
      78                 :            :     enum
      79                 :            :     {
      80                 :            :         MID_EDGE_BIT   = 1 << 1,
      81                 :            :         MID_FACE_BIT   = 1 << 2,
      82                 :            :         MID_REGION_BIT = 1 << 3
      83                 :            :     };
      84                 :            : 
      85                 :            :     //! enum used to specify operation type
      86                 :            :     enum
      87                 :            :     {
      88                 :            :         INTERSECT = 0,
      89                 :            :         UNION
      90                 :            :     };
      91                 :            : 
      92                 :            :     // each entity type has two ConnMap objects, holding information about the bounding
      93                 :            :     // edges and faces for each entity; see comment for mConnectivityMap
      94                 :            :     // (this struct not documented with Doxygen)
      95                 :            :     struct ConnMap
      96                 :            :     {
      97                 :            :         // Topological dimension of this entry
      98                 :            :         short int topo_dimension;
      99                 :            : 
     100                 :            :         // Number of sub-elements of this dimension
     101                 :            :         short int num_sub_elements;
     102                 :            : 
     103                 :            :         // Number of nodes in each sub-element of this dimension
     104                 :            :         short int num_corners_per_sub_element[MAX_SUB_ENTITIES];
     105                 :            : 
     106                 :            :         // Type of each sub-element
     107                 :            :         EntityType target_type[MAX_SUB_ENTITIES];
     108                 :            : 
     109                 :            :         // Connectivity of each of the sub-elements
     110                 :            :         short int conn[MAX_SUB_ENTITIES][MAX_SUB_ENTITY_VERTICES];
     111                 :            :     };
     112                 :            : 
     113                 :            :     // mConnectivityMap[i=entity type][j=0,1,2]:
     114                 :            :     //  num_sub_elements = # bounding edges(j=0) or faces(j=1) for entity type i, or self (j=2)
     115                 :            :     //  num_corners_per_sub_element[k] (k=0..num_sub_elements-1) = number of nodes in sub-facet k
     116                 :            :     //    (can vary over sub-facets, e.g. faces bounding a pyramid) or self (j=2)
     117                 :            :     //  target_type[k] = entity type of sub-facet k (e.g. MBTRI or MBQUAD bounding a pyramid) or
     118                 :            :     //  self (j=2) conn[k][l] (l=0..CN::VerticesPerEntity[target_type[k]]) = vertex connectivity of
     119                 :            :     //  sub-facet k,
     120                 :            :     //    with respect to entity i's canonical vertex ordering, or self (j=2)
     121                 :            :     // (not documented with Doxygen)
     122                 :            :     static MOAB_EXPORT const ConnMap mConnectivityMap[MBMAXTYPE][3];
     123                 :            : 
     124                 :            :     // structure used to define reverse canonical ordering information
     125                 :            :     // (not documented with Doxygen)
     126                 :            :     struct UpConnMap
     127                 :            :     {
     128                 :            :         // Number of higher-dimensional entities using each sub-entity
     129                 :            :         short int num_targets_per_source_element[MAX_SUB_ENTITIES];
     130                 :            : 
     131                 :            :         // Higher-dimensional entities using each sub-entity
     132                 :            :         short int targets_per_source_element[MAX_SUB_ENTITIES][MAX_SUB_ENTITIES];
     133                 :            :     };
     134                 :            : 
     135                 :            :     // Reverse canonical numbering, duplicates data in mConnectivityMap, but
     136                 :            :     // connectivity data in this table must be in ascending order (used for
     137                 :            :     // efficient sorting)
     138                 :            :     // (not documented with Doxygen)
     139                 :            :     static const UpConnMap mUpConnMap[MBMAXTYPE][4][4];
     140                 :            : 
     141                 :            :     // Mid-node bits indexed by number of nodes in element
     142                 :            :     static MOAB_EXPORT const unsigned char midNodesPerType[MBMAXTYPE][MAX_NODES_PER_ELEMENT + 1];
     143                 :            : 
     144                 :            :     //! Permutation and reverse permutation vectors
     145                 :            :     static short int permuteVec[MBMAXTYPE][3][MAX_SUB_ENTITIES + 1];
     146                 :            :     static short int revPermuteVec[MBMAXTYPE][3][MAX_SUB_ENTITIES + 1];
     147                 :            : 
     148                 :            :     //! this const vector defines the starting and ending EntityType for
     149                 :            :     //! each dimension, e.g. TypeDimensionMap[2] returns a pair of EntityTypes
     150                 :            :     //! bounding dimension 2.
     151                 :            :     static MOAB_EXPORT const DimensionPair TypeDimensionMap[];
     152                 :            : 
     153                 :            :     /// Get the dimension pair corresponding to a dimension
     154                 :            :     static DimensionPair getDimPair( int entity_type );
     155                 :            : 
     156                 :            :     //! get the basis of the numbering system
     157                 :            :     static short int GetBasis();
     158                 :            : 
     159                 :            :     //! set the basis of the numbering system
     160                 :            :     static void SetBasis( const int in_basis );
     161                 :            : 
     162                 :            :     //! return the string type name for this type
     163                 :            :     static const char* EntityTypeName( const EntityType this_type );
     164                 :            : 
     165                 :            :     //! given a name, find the corresponding entity type
     166                 :            :     static EntityType EntityTypeFromName( const char* name );
     167                 :            : 
     168                 :            :     //! return the topological entity dimension
     169                 :            :     static short int Dimension( const EntityType t );
     170                 :            : 
     171                 :            :     //! return the number of (corner) vertices contained in the specified type.
     172                 :            :     static short int VerticesPerEntity( const EntityType t );
     173                 :            : 
     174                 :            :     //! return the number of sub-entities bounding the entity.
     175                 :            :     static short int NumSubEntities( const EntityType t, const int d );
     176                 :            : 
     177                 :            :     //! return the type of a particular sub-entity.
     178                 :            :     //! \param this_type Type of entity for which sub-entity type is being queried
     179                 :            :     //! \param sub_dimension Topological dimension of sub-entity whose type is being queried
     180                 :            :     //! \param index Index of sub-entity whose type is being queried
     181                 :            :     //! \return type Entity type of sub-entity with specified dimension and index
     182                 :            :     static EntityType SubEntityType( const EntityType this_type, const int sub_dimension, const int index );
     183                 :            : 
     184                 :            :     //! return the vertex indices of the specified sub-entity.
     185                 :            :     //! \param this_type Type of entity for which sub-entity connectivity is being queried
     186                 :            :     //! \param sub_dimension Dimension of sub-entity
     187                 :            :     //! \param sub_index Index of sub-entity
     188                 :            :     //! \param sub_entity_conn Connectivity of sub-entity (returned to calling function)
     189                 :            :     static void inline SubEntityVertexIndices( const EntityType this_type, const int sub_dimension, const int sub_index,
     190                 :            :                                                int sub_entity_conn[] );
     191                 :            : 
     192                 :            :     //! return the vertex indices of the specified sub-entity.
     193                 :            :     //! \param this_type Type of entity for which sub-entity connectivity is being queried
     194                 :            :     //! \param sub_dimension Dimension of sub-entity
     195                 :            :     //! \param sub_index Index of sub-entity
     196                 :            :     //! \param num_sub_ent_vertices the number of vertices in the sub-entity
     197                 :            :     static const short* SubEntityVertexIndices( const EntityType this_type, const int sub_dimension,
     198                 :            :                                                 const int sub_index, EntityType& sub_type, int& num_sub_ent_vertices );
     199                 :            : 
     200                 :            :     //! return the node indices of the specified sub-entity.
     201                 :            :     //! \param this_topo            The topology of the queried element type
     202                 :            :     //! \param num_nodes            The number of nodes in the queried element type.
     203                 :            :     //! \param sub_dimension        Dimension of sub-entity
     204                 :            :     //! \param sub_index            Index of sub-entity
     205                 :            :     //! \param sub_entity_topo      (Output) Topology of requested sub-entity.
     206                 :            :     //! \param num_sub_entity_nodes (Output) Number of nodes in the requested sub-entity.
     207                 :            :     //! \param sub_entity_conn      (Output) Connectivity of sub-entity
     208                 :            :     static void SubEntityNodeIndices( const EntityType this_topo, const int num_nodes, const int sub_dimension,
     209                 :            :                                       const int sub_index, EntityType& sub_entity_topo, int& num_sub_entity_nodes,
     210                 :            :                                       int sub_entity_conn[] );
     211                 :            : 
     212                 :            :     //! return the vertices of the specified sub entity
     213                 :            :     //! \param parent_conn Connectivity of parent entity
     214                 :            :     //! \param parent_type Entity type of parent entity
     215                 :            :     //! \param sub_dimension Dimension of sub-entity being queried
     216                 :            :     //! \param sub_index Index of sub-entity being queried
     217                 :            :     //! \param sub_entity_conn Connectivity of sub-entity, based on parent_conn and canonical
     218                 :            :     //!           ordering for parent_type
     219                 :            :     //! \param num_sub_vertices Number of vertices in sub-entity
     220                 :            :     static void SubEntityConn( const void* parent_conn, const EntityType parent_type, const int sub_dimension,
     221                 :            :                                const int sub_index, void* sub_entity_conn, int& num_sub_vertices );
     222                 :            : 
     223                 :            :     //! For a specified set of sides of given dimension, return the intersection
     224                 :            :     //! or union of all sides of specified target dimension adjacent to those sides.
     225                 :            :     //! \param this_type Type of entity for which sub-entity connectivity is being queried
     226                 :            :     //! \param source_indices Indices of sides being queried
     227                 :            :     //! \param num_source_indices Number of entries in <em>source_indices</em>
     228                 :            :     //! \param source_dim Dimension of source entity
     229                 :            :     //! \param target_dim Dimension of target entity
     230                 :            :     //! \param index_list Indices of target entities (returned)
     231                 :            :     //! \param operation_type Specify either CN::INTERSECT or CN::UNION to get intersection
     232                 :            :     //!        or union of target entity lists over source entities
     233                 :            :     static short int AdjacentSubEntities( const EntityType this_type, const int* source_indices,
     234                 :            :                                           const int num_source_indices, const int source_dim, const int target_dim,
     235                 :            :                                           std::vector< int >& index_list, const int operation_type = CN::INTERSECT );
     236                 :            : 
     237                 :            :     //! return the side index represented in the input sub-entity connectivity in the input
     238                 :            :     //! parent entity connectivity array.
     239                 :            :     //! \param parent_conn Connectivity of parent entity being queried
     240                 :            :     //! \param parent_type Entity type of parent entity
     241                 :            :     //! \param child_conn Connectivity of child whose index is being queried
     242                 :            :     //! \param child_num_verts Number of vertices in <em>child_conn</em>
     243                 :            :     //! \param child_dim Dimension of child entity being queried
     244                 :            :     //! \param side_number Side number of child entity (returned)
     245                 :            :     //! \param sense Sense of child entity with respect to order in <em>child_conn</em> (returned)
     246                 :            :     //! \param offset Offset of <em>child_conn</em> with respect to canonical ordering data
     247                 :            :     //! (returned) \return status Returns zero if successful, -1 if not
     248                 :            :     static short int SideNumber( const EntityType parent_type, const int* parent_conn, const int* child_conn,
     249                 :            :                                  const int child_num_verts, const int child_dim, int& side_number, int& sense,
     250                 :            :                                  int& offset );
     251                 :            :     static short int SideNumber( const EntityType parent_type, const unsigned int* parent_conn,
     252                 :            :                                  const unsigned int* child_conn, const int child_num_verts, const int child_dim,
     253                 :            :                                  int& side_number, int& sense, int& offset );
     254                 :            :     static short int SideNumber( const EntityType parent_type, const long* parent_conn, const long* child_conn,
     255                 :            :                                  const int child_num_verts, const int child_dim, int& side_number, int& sense,
     256                 :            :                                  int& offset );
     257                 :            :     static short int SideNumber( const EntityType parent_type, const unsigned long* parent_conn,
     258                 :            :                                  const unsigned long* child_conn, const int child_num_verts, const int child_dim,
     259                 :            :                                  int& side_number, int& sense, int& offset );
     260                 :            :     static short int SideNumber( const EntityType parent_type, const unsigned long long* parent_conn,
     261                 :            :                                  const unsigned long long* child_conn, const int child_num_verts, const int child_dim,
     262                 :            :                                  int& side_number, int& sense, int& offset );
     263                 :            :     static short int SideNumber( const EntityType parent_type, void* const* parent_conn, void* const* child_conn,
     264                 :            :                                  const int child_num_verts, const int child_dim, int& side_number, int& sense,
     265                 :            :                                  int& offset );
     266                 :            : 
     267                 :            :     //! return the side index represented in the input sub-entity connectivity
     268                 :            :     //! \param parent_type Entity type of parent entity
     269                 :            :     //! \param child_conn_indices Child connectivity to query, specified as indices
     270                 :            :     //!                           into the connectivity list of the parent.
     271                 :            :     //! \param child_num_verts Number of values in <em>child_conn_indices</em>
     272                 :            :     //! \param child_dim Dimension of child entity being queried
     273                 :            :     //! \param side_number Side number of child entity (returned)
     274                 :            :     //! \param sense Sense of child entity with respect to order in <em>child_conn</em> (returned)
     275                 :            :     //! \param offset Offset of <em>child_conn</em> with respect to canonical ordering data
     276                 :            :     //! (returned) \return status Returns zero if successful, -1 if not
     277                 :            :     static short int SideNumber( const EntityType parent_type, const int* child_conn_indices, const int child_num_verts,
     278                 :            :                                  const int child_dim, int& side_number, int& sense, int& offset );
     279                 :            : 
     280                 :            :     //! return the dimension and index of the opposite side, given parent entity type and child
     281                 :            :     //! dimension and index.  This function is only defined for certain types of parent/child types:
     282                 :            :     //! (Parent, Child dim->Opposite dim):
     283                 :            :     //!  (Tri, 1->0), (Tri, 0->1), (Quad, 1->1), (Quad, 0->0),
     284                 :            :     //!  (Tet, 2->0), (Tet, 1->1), (Tet, 0->2),
     285                 :            :     //!  (Hex, 2->2), (Hex, 1->1)(diagonally across element), (Hex, 0->0) (diagonally across
     286                 :            :     //!  element)
     287                 :            :     //! All other parent types and child dimensions return an error.
     288                 :            :     //!
     289                 :            :     //! \param parent_type The type of parent element
     290                 :            :     //! \param child_type The type of child element
     291                 :            :     //! \param child_index The index of the child element
     292                 :            :     //! \param opposite_index The index of the opposite element
     293                 :            :     //! \return status Returns 0 if successful, -1 if not
     294                 :            :     static short int OppositeSide( const EntityType parent_type, const int child_index, const int child_dim,
     295                 :            :                                    int& opposite_index, int& opposite_dim );
     296                 :            : 
     297                 :            :     //! given two connectivity arrays, determine whether or not they represent the same entity.
     298                 :            :     //! \param conn1 Connectivity array of first entity
     299                 :            :     //! \param conn2 Connectivity array of second entity
     300                 :            :     //! \param num_vertices Number of entries in <em>conn1</em> and <em>conn2</em>
     301                 :            :     //! \param direct If positive, entities have the same sense (returned)
     302                 :            :     //! \param offset Offset of <em>conn2</em>'s first vertex in <em>conn1</em>
     303                 :            :     //! \return bool Returns true if <em>conn1</em> and <em>conn2</em> match
     304                 :            :     static bool ConnectivityMatch( const int* conn1, const int* conn2, const int num_vertices, int& direct,
     305                 :            :                                    int& offset );
     306                 :            :     static bool ConnectivityMatch( const unsigned int* conn1, const unsigned int* conn2, const int num_vertices,
     307                 :            :                                    int& direct, int& offset );
     308                 :            :     static bool ConnectivityMatch( const long* conn1, const long* conn2, const int num_vertices, int& direct,
     309                 :            :                                    int& offset );
     310                 :            :     static bool ConnectivityMatch( const unsigned long* conn1, const unsigned long* conn2, const int num_vertices,
     311                 :            :                                    int& direct, int& offset );
     312                 :            :     static bool ConnectivityMatch( const unsigned long long* conn1, const unsigned long long* conn2,
     313                 :            :                                    const int num_vertices, int& direct, int& offset );
     314                 :            :     static bool ConnectivityMatch( void* const* conn1, void* const* conn2, const int num_vertices, int& direct,
     315                 :            :                                    int& offset );
     316                 :            : 
     317                 :            :     //! Set permutation or reverse permutation vector
     318                 :            :     //! Forward permutation is from CN's numbering into application's ordering;
     319                 :            :     //! that is, if i is CN's index, pvec[i] is application's index.  This
     320                 :            :     //! function stores the permutation vector for this type and facet dimension,
     321                 :            :     //! which then is used in calls to permuteThis or revPermuteThis.
     322                 :            :     //! \param t EntityType for which to set permutation
     323                 :            :     //! \param dim Dimension of facets whose permutation array is being set
     324                 :            :     //! \param pvec Permutation array
     325                 :            :     //! \param num_entries Number of indicies in permutation array
     326                 :            :     //! \param is_reverse Array is reverse permutation
     327                 :            :     static inline void setPermutation( const EntityType t, const int dim, short int* pvec, const int num_entries,
     328                 :            :                                        const bool is_reverse = false );
     329                 :            : 
     330                 :            :     //! Reset permutation or reverse permutation vector
     331                 :            :     //! \param t EntityType whose permutation vector is being reset
     332                 :            :     //! \param dim Dimension of facets being reset; if -1 is input, all dimensions are reset
     333                 :            :     static inline void resetPermutation( const EntityType t, const int dim );
     334                 :            : 
     335                 :            :     //! Permute a handle array according to permutation vector set with setPermute;
     336                 :            :     //! permutation is done in-place
     337                 :            :     //! \param t EntityType of handles in pvec
     338                 :            :     //! \param dim Dimension of handles in pvec
     339                 :            :     //! \param pvec Handle array being permuted
     340                 :            :     //! \param indices_per_ent Number of indices per entity
     341                 :            :     //! \param num_entries Number of entities in pvec
     342                 :            :     static int permuteThis( const EntityType t, const int dim, int* pvec, const int indices_per_ent,
     343                 :            :                             const int num_entries );
     344                 :            :     static int permuteThis( const EntityType t, const int dim, unsigned int* pvec, const int indices_per_ent,
     345                 :            :                             const int num_entries );
     346                 :            :     static int permuteThis( const EntityType t, const int dim, long* pvec, const int indices_per_ent,
     347                 :            :                             const int num_entries );
     348                 :            :     static int permuteThis( const EntityType t, const int dim, void** pvec, const int indices_per_ent,
     349                 :            :                             const int num_entries );
     350                 :            : 
     351                 :            :     //! Reverse permute a handle array according to reverse permutation vector set with setPermute;
     352                 :            :     //! reverse permutation is done in-place
     353                 :            :     //! \param t EntityType of handles in pvec
     354                 :            :     //! \param dim Dimension of handles in pvec
     355                 :            :     //! \param pvec Handle array being reverse permuted
     356                 :            :     //! \param indices_per_ent Number of indices per entity
     357                 :            :     //! \param num_entries Number of entities in pvec
     358                 :            :     static int revPermuteThis( const EntityType t, const int dim, int* pvec, const int indices_per_ent,
     359                 :            :                                const int num_entries );
     360                 :            :     static int revPermuteThis( const EntityType t, const int dim, unsigned int* pvec, const int indices_per_ent,
     361                 :            :                                const int num_entries );
     362                 :            :     static int revPermuteThis( const EntityType t, const int dim, long* pvec, const int indices_per_ent,
     363                 :            :                                const int num_entries );
     364                 :            :     static int revPermuteThis( const EntityType t, const int dim, void** pvec, const int indices_per_ent,
     365                 :            :                                const int num_entries );
     366                 :            : 
     367                 :            :     //! true if entities of a given type and number of nodes indicates mid edge nodes are present.
     368                 :            :     //! \param this_type Type of entity for which sub-entity connectivity is being queried
     369                 :            :     //! \param num_verts Number of nodes defining entity
     370                 :            :     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
     371                 :            :     //!  mid-edge nodes are likely
     372                 :            :     static inline bool HasMidEdgeNodes( const EntityType this_type, const int num_verts );
     373                 :            : 
     374                 :            :     //! true if entities of a given type and number of nodes indicates mid face nodes are present.
     375                 :            :     //! \param this_type Type of entity for which sub-entity connectivity is being queried
     376                 :            :     //! \param num_verts Number of nodes defining entity
     377                 :            :     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
     378                 :            :     //!  mid-face nodes are likely
     379                 :            :     static inline bool HasMidFaceNodes( const EntityType this_type, const int num_verts );
     380                 :            : 
     381                 :            :     //! true if entities of a given type and number of nodes indicates mid region nodes are present.
     382                 :            :     //! \param this_type Type of entity for which sub-entity connectivity is being queried
     383                 :            :     //! \param num_verts Number of nodes defining entity
     384                 :            :     //! \return bool Returns true if <em>this_type</em> combined with <em>num_nodes</em> indicates
     385                 :            :     //!  mid-region nodes are likely
     386                 :            :     static inline bool HasMidRegionNodes( const EntityType this_type, const int num_verts );
     387                 :            : 
     388                 :            :     //! true if entities of a given type and number of nodes indicates mid edge/face/region nodes
     389                 :            :     //! are present.
     390                 :            :     //! \param this_type Type of entity for which sub-entity connectivity is being queried
     391                 :            :     //! \param num_verts Number of nodes defining entity
     392                 :            :     //! \param mid_nodes If <em>mid_nodes[i], i=1..2</em> is non-zero, indicates that mid-edge
     393                 :            :     //!    (i=1), mid-face (i=2), and/or mid-region (i=3) nodes are likely
     394                 :            :     static inline void HasMidNodes( const EntityType this_type, const int num_verts, int mid_nodes[4] );
     395                 :            : 
     396                 :            :     //! Same as above, except returns a single integer with the bits, from
     397                 :            :     //! least significant to most significant set to one if the corresponding
     398                 :            :     //! mid nodes on sub entities of the least dimension (0) to the highest
     399                 :            :     //! dimension (3) are present in the elment type.
     400                 :            :     static inline int HasMidNodes( const EntityType this_type, const int num_verts );
     401                 :            : 
     402                 :            :     //! given data about an element and a vertex in that element, return the dimension
     403                 :            :     //! and index of the sub-entity that the vertex resolves.  If it does not resolve a
     404                 :            :     //! sub-entity, either because it's a corner node or it's not in the element, -1 is
     405                 :            :     //! returned in both return values.
     406                 :            :     //! \param elem_type Type of entity being queried
     407                 :            :     //! \param num_nodes The number of nodes in the element connectivity
     408                 :            :     //! \param ho_node_index The position of the HO node in the connectivity list (zero based)
     409                 :            :     //! \param parent_dim Dimension of sub-entity high-order node resolves (returned)
     410                 :            :     //! \param parent_index Index of sub-entity high-order node resolves (returned)
     411                 :            :     static void HONodeParent( EntityType elem_type, int num_nodes, int ho_node_index, int& parent_dim,
     412                 :            :                               int& parent_index );
     413                 :            : 
     414                 :            :     //! for an entity of this type with num_verts vertices, and a specified subfacet
     415                 :            :     //! (dimension and index), return the index of the higher order node for that entity
     416                 :            :     //! in this entity's connectivity array
     417                 :            :     //! \param this_type Type of entity being queried
     418                 :            :     //! \param num_verts Number of vertices for the entity being queried
     419                 :            :     //! \param subfacet_dim Dimension of sub-entity being queried
     420                 :            :     //! \param subfacet_index Index of sub-entity being queried
     421                 :            :     //! \return index Index of sub-entity's higher-order node
     422                 :            :     static short int HONodeIndex( const EntityType this_type, const int num_verts, const int subfacet_dim,
     423                 :            :                                   const int subfacet_index );
     424                 :            : };
     425                 :            : 
     426                 :            : //! get the basis of the numbering system
     427                 :          0 : inline short int CN::GetBasis()
     428                 :            : {
     429                 :          0 :     return numberBasis;
     430                 :            : }
     431                 :            : 
     432                 :            : //! return the connectivity of the specified sub-entity.
     433                 :     298630 : inline void CN::SubEntityVertexIndices( const EntityType this_type, const int sub_dimension, const int index,
     434                 :            :                                         int sub_entity_conn[] )
     435                 :            : {
     436                 :            :     EntityType type;
     437                 :            :     int n;
     438         [ +  - ]:     298630 :     const short* indices = SubEntityVertexIndices( this_type, sub_dimension, index, type, n );
     439         [ +  - ]:     298630 :     std::copy( indices, indices + n, sub_entity_conn );
     440                 :     298630 : }
     441                 :            : 
     442                 :       1419 : inline bool CN::HasMidEdgeNodes( const EntityType this_type, const int num_nodes )
     443                 :            : {
     444                 :       1419 :     const int bits = HasMidNodes( this_type, num_nodes );
     445                 :       1419 :     return static_cast< bool >( ( bits & ( 1 << 1 ) ) >> 1 );
     446                 :            : }
     447                 :            : 
     448                 :        453 : inline bool CN::HasMidFaceNodes( const EntityType this_type, const int num_nodes )
     449                 :            : {
     450                 :        453 :     const int bits = HasMidNodes( this_type, num_nodes );
     451                 :        453 :     return static_cast< bool >( ( bits & ( 1 << 2 ) ) >> 2 );
     452                 :            : }
     453                 :            : 
     454                 :        106 : inline bool CN::HasMidRegionNodes( const EntityType this_type, const int num_nodes )
     455                 :            : {
     456                 :        106 :     const int bits = HasMidNodes( this_type, num_nodes );
     457                 :        106 :     return static_cast< bool >( ( bits & ( 1 << 3 ) ) >> 3 );
     458                 :            : }
     459                 :            : 
     460                 :     175317 : inline int CN::HasMidNodes( const EntityType this_type, const int num_nodes )
     461                 :            : {
     462         [ -  + ]:     175317 :     assert( (unsigned)num_nodes <= (unsigned)MAX_NODES_PER_ELEMENT );
     463                 :     175317 :     return midNodesPerType[this_type][num_nodes];
     464                 :            : }
     465                 :            : 
     466                 :     168794 : inline void CN::HasMidNodes( const EntityType this_type, const int num_nodes, int mid_nodes[4] )
     467                 :            : {
     468                 :     168794 :     const int bits = HasMidNodes( this_type, num_nodes );
     469                 :     168794 :     mid_nodes[0]   = 0;
     470                 :     168794 :     mid_nodes[1]   = ( bits & ( 1 << 1 ) ) >> 1;
     471                 :     168794 :     mid_nodes[2]   = ( bits & ( 1 << 2 ) ) >> 2;
     472                 :     168794 :     mid_nodes[3]   = ( bits & ( 1 << 3 ) ) >> 3;
     473                 :     168794 : }
     474                 :            : 
     475                 :            : //! Set permutation or reverse permutation vector
     476                 :            : inline void CN::setPermutation( const EntityType t, const int dim, short int* pvec, const int num_entries,
     477                 :            :                                 const bool is_reverse )
     478                 :            : {
     479                 :            :     short int *this_vec = permuteVec[t][dim], *that_vec = revPermuteVec[t][dim];
     480                 :            :     if( is_reverse )
     481                 :            :     {
     482                 :            :         this_vec = revPermuteVec[t][dim];
     483                 :            :         that_vec = permuteVec[t][dim];
     484                 :            :     }
     485                 :            : 
     486                 :            :     for( short int i = 0; i < num_entries; i++ )
     487                 :            :     {
     488                 :            :         this_vec[i]       = pvec[i];
     489                 :            :         that_vec[pvec[i]] = i;
     490                 :            :     }
     491                 :            : 
     492                 :            :     this_vec[MAX_SUB_ENTITIES] = that_vec[MAX_SUB_ENTITIES] = (short)num_entries;
     493                 :            : }
     494                 :            : 
     495                 :            : //! Reset permutation or reverse permutation vector
     496                 :            : inline void CN::resetPermutation( const EntityType t, const int dim )
     497                 :            : {
     498                 :            :     if( -1 == dim )
     499                 :            :     {
     500                 :            :         for( unsigned int i = 0; i < 3; i++ )
     501                 :            :             resetPermutation( t, i );
     502                 :            :         return;
     503                 :            :     }
     504                 :            : 
     505                 :            :     for( short unsigned int i = 0; i < MAX_SUB_ENTITIES; i++ )
     506                 :            :     {
     507                 :            :         revPermuteVec[t][dim][i] = permuteVec[t][dim][i] = i;
     508                 :            :     }
     509                 :            : 
     510                 :            :     revPermuteVec[t][dim][MAX_SUB_ENTITIES] = permuteVec[t][dim][MAX_SUB_ENTITIES] = MAX_SUB_ENTITIES + 1;
     511                 :            : }
     512                 :            : 
     513                 :            : }  // namespace moab
     514                 :            : 
     515                 :            : #endif

Generated by: LCOV version 1.11