10 #ifndef Shards_CellTopology_hpp
11 #define Shards_CellTopology_hpp
13 #ifdef HAVE_SHARDS_DEBUG
14 #define SHARDS_REQUIRE( S ) S
16 #define SHARDS_REQUIRE( S )
21 #include <Shards_CellTopologyData.h>
22 #include <Shards_BasicTopologies.hpp>
39 std::ostream &
operator << ( std::ostream & ,
const CellTopology & );
51 inline std::string ECellTypeToString(
ECellType cellType) {
52 std::string retString;
54 case ALL_CELLS: retString =
"All";
break;
55 case STANDARD_CELL: retString =
"Standard";
break;
56 case NONSTANDARD_CELL: retString =
"Nonstandard";
break;
57 default: retString =
"Invalid Cell";
72 inline std::string ETopologyTypeToString(
ETopologyType topologyType) {
73 std::string retString;
75 case ALL_TOPOLOGIES: retString =
"All";
break;
76 case BASE_TOPOLOGY: retString =
"Base";
break;
77 case EXTENDED_TOPOLOGY: retString =
"Extended";
break;
78 default: retString =
"Invalid Topology";
92 void getTopologies(std::vector<shards::CellTopology>& topologies,
93 const unsigned cellDim = 4,
137 void requireCell()
const ;
144 void requireDimension(
const unsigned subcellDim )
const ;
152 void requireSubcell(
const unsigned subcellDim ,
153 const unsigned subcellOrd )
const ;
162 void requireNodeMap(
const unsigned subcellDim ,
163 const unsigned subcellOrd ,
164 const unsigned nodeOrd )
const ;
166 void requireNodePermutation(
const unsigned permutationOrd ,
167 const unsigned nodeOrd )
const ;
182 SHARDS_REQUIRE( requireCell() );
194 SHARDS_REQUIRE( requireCell() );
206 SHARDS_REQUIRE( requireCell() );
219 SHARDS_REQUIRE( requireCell() );
220 return m_cell->
name ;
229 SHARDS_REQUIRE( requireCell() );
237 SHARDS_REQUIRE( requireCell() );
245 SHARDS_REQUIRE( requireCell() );
253 SHARDS_REQUIRE( requireCell() );
260 SHARDS_REQUIRE( requireCell() );
268 SHARDS_REQUIRE( requireCell() );
275 {
return m_cell != 0 ; }
286 SHARDS_REQUIRE( requireCell() );
287 return m_cell->
base ;
297 const unsigned subcell_ord )
const
299 SHARDS_REQUIRE( requireCell() );
300 SHARDS_REQUIRE( requireDimension(subcell_dim) );
301 SHARDS_REQUIRE( requireSubcell(subcell_dim,subcell_ord) );
312 const unsigned subcell_ord )
const
322 unsigned getKey(
const unsigned subcell_dim ,
323 const unsigned subcell_ord )
const
334 const char *
getName(
const unsigned subcell_dim,
335 const unsigned subcell_ord)
const
346 const unsigned subcell_ord )
const
357 const unsigned subcell_ord )
const
368 const unsigned subcell_ord )
const
379 const unsigned subcell_ord )
const
390 SHARDS_REQUIRE( requireCell() );
391 SHARDS_REQUIRE( requireDimension(subcell_dim) );
402 SHARDS_REQUIRE( requireCell() );
403 SHARDS_REQUIRE( requireDimension(subcell_dim) );
415 const unsigned subcell_ord ,
416 const unsigned subcell_node_ord )
const
418 SHARDS_REQUIRE( requireCell() );
419 SHARDS_REQUIRE( requireDimension(subcell_dim) );
420 SHARDS_REQUIRE( requireSubcell(subcell_dim,subcell_ord) );
421 SHARDS_REQUIRE( requireNodeMap(subcell_dim,subcell_ord,subcell_node_ord));
422 return m_cell->
subcell[subcell_dim][subcell_ord].
node[subcell_node_ord];
429 SHARDS_REQUIRE(requireCell());
438 const unsigned node_ord )
const
440 SHARDS_REQUIRE(requireCell());
441 SHARDS_REQUIRE(requireNodePermutation(permutation_ord,node_ord));
442 return m_cell->
permutation[permutation_ord].node[node_ord];
451 SHARDS_REQUIRE(requireCell());
452 SHARDS_REQUIRE(requireNodePermutation(permutation_ord,0));
453 return m_cell->
permutation[permutation_ord].polarity;
461 const unsigned node_ord )
const
463 SHARDS_REQUIRE(requireCell());
464 SHARDS_REQUIRE(requireNodePermutation(permutation_ord,node_ord));
465 return m_cell->permutation_inverse[permutation_ord].node[node_ord];
497 const unsigned nodeCount);
510 const unsigned vertex_count,
511 const unsigned node_count,
512 const std::vector< const CellTopologyData * > & edges ,
513 const std::vector< unsigned > & edge_node_map ,
529 const unsigned vertex_count,
530 const unsigned node_count,
531 const std::vector< const CellTopologyData * > & edges ,
532 const std::vector< unsigned > & edge_node_map ,
533 const std::vector< const CellTopologyData * > & faces ,
534 const std::vector< unsigned > & face_node_map ,
561 template<
typename id_type >
563 const id_type *
const expected_node ,
564 const id_type *
const actual_node )
569 for ( ; p < np ; ++p ) {
570 const unsigned *
const perm_node = top.
permutation[p].node ;
572 for ( ; j < nv && actual_node[j] == expected_node[ perm_node[j] ] ; ++j );
573 if ( nv == j ) break ;
575 if ( np == p ) p = -1 ;
579 template<
typename id_type >
580 int findPermutation(
const CellTopology & top ,
581 const id_type *
const expected_node ,
582 const id_type *
const actual_node )
584 return findPermutation( * top.getCellTopologyData() , expected_node , actual_node );
598 const unsigned face_count ,
599 const unsigned edge_count ,
600 const unsigned vertex_count ,
601 const unsigned node_count );
614 const unsigned face_count ,
615 const unsigned edge_count ,
616 const unsigned vertex_count ,
617 const unsigned node_count )
619 const bool bad = ( dimension >> 3 ) ||
620 ( face_count >> 6 ) ||
621 ( edge_count >> 6 ) ||
622 ( vertex_count >> 6 ) ||
623 ( node_count >> 10 );
633 const unsigned key = ( dimension << 28 ) |
634 ( face_count << 22 ) |
635 ( edge_count << 16 ) |
636 ( vertex_count << 10 ) |
643 bool operator==(
const CellTopology &left,
const CellTopology &right)
645 return left.getCellTopologyData() == right.getCellTopologyData();
649 bool operator<(
const CellTopology &left,
const CellTopology &right)
651 return left.getCellTopologyData() < right.getCellTopologyData();
657 bool operator!=(
const CellTopology &left,
const CellTopology &right) {
658 return !(left == right);
666 #undef SHARDS_REQUIRE
668 #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...