46 #ifndef Shards_CellTopology_hpp 
   47 #define Shards_CellTopology_hpp 
   49 #ifdef HAVE_SHARDS_DEBUG 
   50 #define SHARDS_REQUIRE( S )  S 
   52 #define SHARDS_REQUIRE( S )  
   57 #include <Shards_CellTopologyData.h> 
   58 #include <Shards_BasicTopologies.hpp> 
   75 std::ostream & 
operator << ( std::ostream & , 
const CellTopology & );
 
   87 inline std::string ECellTypeToString(
ECellType cellType) {
 
   88   std::string retString;
 
   90     case ALL_CELLS:         retString = 
"All";           
break;
 
   91     case STANDARD_CELL:     retString = 
"Standard";      
break;
 
   92     case NONSTANDARD_CELL:  retString = 
"Nonstandard";   
break;
 
   93     default:                retString = 
"Invalid Cell";
 
  108 inline std::string ETopologyTypeToString(
ETopologyType topologyType) {
 
  109   std::string retString;
 
  110   switch(topologyType){
 
  111     case ALL_TOPOLOGIES:      retString = 
"All";            
break;
 
  112     case BASE_TOPOLOGY:       retString = 
"Base";           
break;
 
  113     case EXTENDED_TOPOLOGY:   retString = 
"Extended";       
break;
 
  114     default:                  retString = 
"Invalid Topology";
 
  128 void getTopologies(std::vector<shards::CellTopology>& topologies,
 
  129                    const unsigned       cellDim   = 4,
 
  173   void requireCell() 
const ;
 
  180   void requireDimension( 
const unsigned subcellDim ) 
const ;
 
  188   void requireSubcell( 
const unsigned subcellDim ,
 
  189                        const unsigned subcellOrd ) 
const ;
 
  198   void requireNodeMap( 
const unsigned subcellDim ,
 
  199                        const unsigned subcellOrd ,
 
  200                        const unsigned nodeOrd ) 
const ;
 
  202   void requireNodePermutation( 
const unsigned permutationOrd ,
 
  203                                const unsigned nodeOrd ) 
const ;
 
  218       SHARDS_REQUIRE( requireCell() );
 
  230       SHARDS_REQUIRE( requireCell() );
 
  242       SHARDS_REQUIRE( requireCell() );
 
  255         SHARDS_REQUIRE( requireCell() );
 
  256         return m_cell->
name ;
 
  265       SHARDS_REQUIRE( requireCell() );
 
  273       SHARDS_REQUIRE( requireCell() );
 
  281       SHARDS_REQUIRE( requireCell() );
 
  289       SHARDS_REQUIRE( requireCell() );
 
  296       SHARDS_REQUIRE( requireCell() );
 
  304       SHARDS_REQUIRE( requireCell() );
 
  311     { 
return m_cell != 0 ; }
 
  322       SHARDS_REQUIRE( requireCell() );
 
  323       return m_cell->
base ;
 
  333                                                 const unsigned subcell_ord )
 const 
  335       SHARDS_REQUIRE( requireCell() );
 
  336       SHARDS_REQUIRE( requireDimension(subcell_dim) );
 
  337       SHARDS_REQUIRE( requireSubcell(subcell_dim,subcell_ord) );
 
  348                                                     const unsigned subcell_ord )
 const 
  358   unsigned getKey( 
const unsigned subcell_dim ,
 
  359                    const unsigned subcell_ord )
 const 
  370   const char * 
getName(
const unsigned subcell_dim,   
 
  371                        const unsigned subcell_ord)
 const 
  382                          const unsigned subcell_ord )
 const 
  393                            const unsigned subcell_ord )
 const 
  404                          const unsigned subcell_ord )
 const 
  415                          const unsigned subcell_ord )
 const 
  426       SHARDS_REQUIRE( requireCell() );
 
  427       SHARDS_REQUIRE( requireDimension(subcell_dim) );
 
  438       SHARDS_REQUIRE( requireCell() );
 
  439       SHARDS_REQUIRE( requireDimension(subcell_dim) );
 
  451                        const unsigned  subcell_ord ,
 
  452                        const unsigned  subcell_node_ord )
 const 
  454       SHARDS_REQUIRE( requireCell() );
 
  455       SHARDS_REQUIRE( requireDimension(subcell_dim) );
 
  456       SHARDS_REQUIRE( requireSubcell(subcell_dim,subcell_ord) );
 
  457       SHARDS_REQUIRE( requireNodeMap(subcell_dim,subcell_ord,subcell_node_ord));
 
  458       return m_cell->
subcell[subcell_dim][subcell_ord].
node[subcell_node_ord];
 
  465       SHARDS_REQUIRE(requireCell());
 
  474                                const unsigned node_ord )
 const 
  476       SHARDS_REQUIRE(requireCell());
 
  477       SHARDS_REQUIRE(requireNodePermutation(permutation_ord,node_ord));
 
  478       return m_cell->
permutation[permutation_ord].node[node_ord];
 
  487       SHARDS_REQUIRE(requireCell());
 
  488       SHARDS_REQUIRE(requireNodePermutation(permutation_ord,0));
 
  489       return m_cell->
permutation[permutation_ord].polarity;
 
  497                                       const unsigned node_ord )
 const 
  499       SHARDS_REQUIRE(requireCell());
 
  500       SHARDS_REQUIRE(requireNodePermutation(permutation_ord,node_ord));
 
  501       return m_cell->permutation_inverse[permutation_ord].node[node_ord];
 
  533                 const unsigned      nodeCount);
 
  546                 const unsigned                                  vertex_count,
 
  547                 const unsigned                                  node_count,
 
  548                 const std::vector< const CellTopologyData * > & edges ,
 
  549                 const std::vector< unsigned >                 & edge_node_map ,
 
  565                 const unsigned                                  vertex_count,
 
  566                 const unsigned                                  node_count,
 
  567                 const std::vector< const CellTopologyData * > & edges ,
 
  568                 const std::vector< unsigned >                 & edge_node_map ,
 
  569                 const std::vector< const CellTopologyData * > & faces ,
 
  570                 const std::vector< unsigned >                 & face_node_map ,
 
  597 template< 
typename id_type >
 
  599                      const id_type * 
const expected_node ,
 
  600                      const id_type * 
const actual_node )
 
  605   for ( ; p < np ; ++p ) {
 
  606     const unsigned * 
const perm_node = top.
permutation[p].node ;
 
  608     for ( ; j < nv && actual_node[j] == expected_node[ perm_node[j] ] ; ++j );
 
  609     if ( nv == j ) break ;
 
  611   if ( np == p ) p = -1 ;
 
  615 template< 
typename id_type >
 
  616 int findPermutation( 
const CellTopology & top ,
 
  617                      const id_type * 
const expected_node ,
 
  618                      const id_type * 
const actual_node )
 
  620   return findPermutation( * top.getCellTopologyData() , expected_node , actual_node );
 
  634                          const unsigned face_count ,
 
  635                          const unsigned edge_count ,
 
  636                          const unsigned vertex_count ,
 
  637                          const unsigned node_count );
 
  650                           const unsigned face_count ,
 
  651                           const unsigned edge_count ,
 
  652                           const unsigned vertex_count ,
 
  653                           const unsigned node_count )
 
  655   const bool bad = ( dimension    >> 3 ) ||
 
  656                    ( face_count   >> 6 ) ||
 
  657                    ( edge_count   >> 6 ) ||
 
  658                    ( vertex_count >> 6 ) ||
 
  659                    ( node_count   >> 10 );
 
  669   const unsigned key = ( dimension    << 28  ) |
 
  670                        ( face_count   << 22  ) |
 
  671                        ( edge_count   << 16  ) |
 
  672                        ( vertex_count << 10  ) |
 
  679 bool operator==(
const CellTopology &left, 
const CellTopology &right)
 
  681   return left.getCellTopologyData() == right.getCellTopologyData();
 
  685 bool operator<(
const CellTopology &left, 
const CellTopology &right)
 
  687   return left.getCellTopologyData() < right.getCellTopologyData();
 
  693 bool operator!=(
const CellTopology &left, 
const CellTopology &right) {
 
  694   return !(left == right);
 
  702 #undef SHARDS_REQUIRE 
  704 #endif // Shards_CellTopology_hpp 
~CellTopology()
Destructor. 
unsigned getVertexCount(const unsigned subcell_dim, const unsigned subcell_ord) const 
Vertex count of a subcell of the given dimension and ordinal. 
unsigned getNodeMap(const unsigned subcell_dim, const unsigned subcell_ord, const unsigned subcell_node_ord) const 
Mapping from a subcell's node ordinal to a node ordinal of this parent cell topology. 
unsigned getNodePermutation(const unsigned permutation_ord, const unsigned node_ord) const 
Permutation of a cell's node ordinals. 
ETopologyType
Enumeration of topology types in Shards. 
unsigned getNodeCount() const 
Node count of this cell topology. 
struct CellTopologyData * base
Base, a.k.a. not-extended, version of this topology where vertex_count == node_count. 
unsigned subcell_homogeneity[4]
Flag if the subcells of a given dimension are homogeneous. 
unsigned key
Unique key for this topology. 
unsigned getKey() const 
Unique key for this cell topology; under certain subcell uniformity conditions. 
void getTopologies(std::vector< shards::CellTopology > &topologies, const unsigned cellDim=4, const ECellType cellType=ALL_CELLS, const ETopologyType topologyType=ALL_TOPOLOGIES)
Returns an std::vector with all cell topologies that meet the specified selection flags...
unsigned getNodePermutationPolarity(const unsigned permutation_ord) const 
Permutation of a cell's node ordinals. 
unsigned getNodeCount(const unsigned subcell_dim, const unsigned subcell_ord) const 
Node count of a subcell of the given dimension and ordinal. 
const CellTopologyData * getCellTopologyData() const 
This cell's raw topology data. 
unsigned vertex_count
Number of vertices. 
const CellTopologyData * getBaseCellTopologyData(const unsigned subcell_dim, const unsigned subcell_ord) const 
Raw cell topology data for the base topology of a subcell of the given dimension and ordinal...
ECellType
Enumeration of cell types in Shards. 
CellTopology()
Default constructor initializes to NULL. 
const char * getName() const 
Unique name for this cell topology;. 
unsigned subcell_count[4]
Number of subcells of each dimension. 
unsigned edge_count
Number of edges (a.k.a.  boundary subcells). 
unsigned getEdgeCount(const unsigned subcell_dim, const unsigned subcell_ord) const 
Edge count of a subcell of the given dimension and ordinal. 
unsigned dimension
Topological dimension. 
const CellTopologyData * getBaseCellTopologyData() const 
This cell's base cell topology's raw topology data. 
bool getSubcellHomogeneity(const unsigned subcell_dim) const 
Query if all subcells of the given dimension have the same cell topology. 
unsigned node_count
Number of nodes (a.k.a.  subcells). 
unsigned cellTopologyKey(const unsigned dimension, const unsigned face_count, const unsigned edge_count, const unsigned vertex_count, const unsigned node_count)
Generate integer key from topological dimensions. 
const unsigned * node
Subcell indexing of  with respect to parent cell. 
const char * name
Intuitive name for this topology. 
struct CellTopologyData * topology
Subcell topology. 
unsigned side_count
Number of sides (a.k.a.  boundary subcells). 
unsigned getSideCount(const unsigned subcell_dim, const unsigned subcell_ord) const 
Side count of a subcell of the given dimension and ordinal. 
unsigned getNodePermutationCount() const 
Number of node permutations defined for this cell. 
unsigned getKey(const unsigned subcell_dim, const unsigned subcell_ord) const 
Key of a subcell of the given dimension and ordinal. 
struct CellTopologyData_Subcell * subcell[4]
Array of subcells of each dimension. 
unsigned getBaseKey() const 
Unique key for this cell's base topology; under certain subcell uniformity conditions. 
int isPredefinedCell(const CellTopology &cell)
Checks if the cell topology is predefined in shards. 
unsigned getDimension() const 
Dimension of this cell topology. 
const CellTopologyData * getCellTopologyData(const unsigned subcell_dim, const unsigned subcell_ord) const 
Raw cell topology data for a subcell of the given dimension and ordinal. 
A simple 'C' struct of cell topology attributes. 
unsigned getNodePermutationInverse(const unsigned permutation_ord, const unsigned node_ord) const 
Inverse permutation of a cell's node ordinals. 
struct CellTopologyData_Permutation * permutation
Array of node permutations. 
unsigned getFaceCount() const 
Face boundary subcell count of this cell topology. 
const char * getBaseName() const 
Unique name for this cell's base topology. 
std::ostream & operator<<(std::ostream &, const CellTopology &)
Overloaded << operator for CellTopologyData objects. 
CellTopology(const CellTopologyData *cell)
Wrapper for safe access to a raw cell topology data. 
Provide input checked access (in debug mode) to cell topology data and a procedure to create custom c...
unsigned getEdgeCount() const 
Edge boundary subcell count of this cell topology. 
const char * getName(const unsigned subcell_dim, const unsigned subcell_ord) const 
Name of a subcell of the given dimension and ordinal. 
unsigned getSideCount() const 
Side boundary subcell count of this cell topology. 
CellTopology & operator=(const CellTopology &right)
Assignment operator *this = right. 
bool isValid() const 
This cell's raw topology data. 
unsigned getSubcellCount(const unsigned subcell_dim) const 
Subcell count of subcells of the given dimension. 
unsigned permutation_count
Number of defined permutations. 
unsigned getVertexCount() const 
Vertex count of this cell topology. 
void badCellTopologyKey(const unsigned dimension, const unsigned face_count, const unsigned edge_count, const unsigned vertex_count, const unsigned node_count)
Generates detailed message if one or more input parameters are out of their admissible bounds...