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>
51inline 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";
72inline 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";
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() );
183 return m_cell->dimension ;
194 SHARDS_REQUIRE( requireCell() );
206 SHARDS_REQUIRE( requireCell() );
207 return m_cell->base->key ;
219 SHARDS_REQUIRE( requireCell() );
220 return m_cell->name ;
229 SHARDS_REQUIRE( requireCell() );
230 return m_cell->base->name ;
237 SHARDS_REQUIRE( requireCell() );
238 return m_cell->node_count ;
245 SHARDS_REQUIRE( requireCell() );
246 return m_cell->vertex_count ;
253 SHARDS_REQUIRE( requireCell() );
254 return m_cell->edge_count ;
260 SHARDS_REQUIRE( requireCell() );
261 return m_cell->dimension == 3 ? m_cell->side_count : 0 ;
268 SHARDS_REQUIRE( requireCell() );
269 return m_cell->side_count ;
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) );
302 return m_cell->subcell[subcell_dim][subcell_ord].topology ;
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) );
392 return m_cell->subcell_count[subcell_dim] ;
402 SHARDS_REQUIRE( requireCell() );
403 SHARDS_REQUIRE( requireDimension(subcell_dim) );
404 return 0 != m_cell->subcell_homogeneity[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());
430 return m_cell->permutation_count ;
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];
500 const unsigned vertex_count,
501 const unsigned node_count,
502 const std::vector< const CellTopologyData * > & edges ,
503 const std::vector< unsigned > & edge_node_map ,
504 const std::vector< const CellTopologyData * > & faces ,
505 const std::vector< unsigned > & face_node_map ,
532template<
typename id_type >
534 const id_type *
const expected_node ,
535 const id_type *
const actual_node )
540 for ( ; p < np ; ++p ) {
541 const unsigned *
const perm_node = top.
permutation[p].node ;
543 for ( ; j < nv && actual_node[j] == expected_node[ perm_node[j] ] ; ++j );
544 if ( nv == j ) break ;
546 if ( np == p ) p = -1 ;
550template<
typename id_type >
552 const id_type *
const expected_node ,
553 const id_type *
const actual_node )
555 return findPermutation( * top.getCellTopologyData() , expected_node , actual_node );
569 const unsigned face_count ,
570 const unsigned edge_count ,
571 const unsigned vertex_count ,
572 const unsigned node_count );
585 const unsigned face_count ,
586 const unsigned edge_count ,
587 const unsigned vertex_count ,
588 const unsigned node_count )
590 const bool bad = ( dimension >> 3 ) ||
591 ( face_count >> 6 ) ||
592 ( edge_count >> 6 ) ||
593 ( vertex_count >> 6 ) ||
594 ( node_count >> 10 );
604 const unsigned key = ( dimension << 28 ) |
605 ( face_count << 22 ) |
606 ( edge_count << 16 ) |
607 ( vertex_count << 10 ) |
614bool operator==(
const CellTopology &left,
const CellTopology &right)
616 return left.getCellTopologyData() == right.getCellTopologyData();
622 return left.getCellTopologyData() < right.getCellTopologyData();
629 return !(left == right);
Provide input checked access (in debug mode) to cell topology data and a procedure to create custom c...
const CellTopologyData * getCellTopologyData() const
This cell's raw topology data.
unsigned getNodeCount(const unsigned subcell_dim, const unsigned subcell_ord) const
Node count 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.
const char * getName() const
Unique name for this cell topology;.
unsigned getBaseKey() const
Unique key for this cell's base topology; under certain subcell uniformity conditions.
unsigned getSideCount(const unsigned subcell_dim, const unsigned subcell_ord) const
Side count of a subcell of the given dimension and ordinal.
unsigned getSubcellCount(const unsigned subcell_dim) const
Subcell count of subcells of the given dimension.
unsigned getEdgeCount() const
Edge boundary subcell count of this cell topology.
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.
unsigned getNodePermutationCount() const
Number of node permutations defined for this cell.
~CellTopology()
Destructor.
CellTopology(const CellTopology &right)
Copy constructor.
const CellTopologyData * getBaseCellTopologyData() const
This cell's base cell topology's raw topology data.
unsigned getNodePermutationPolarity(const unsigned permutation_ord) const
Permutation of a cell's node ordinals.
unsigned getNodeCount() const
Node count of this cell topology.
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.
CellTopology(const std::string &name, const unsigned vertex_count, const unsigned node_count, const std::vector< const CellTopologyData * > &edges, const std::vector< unsigned > &edge_node_map, const std::vector< const CellTopologyData * > &faces, const std::vector< unsigned > &face_node_map, const CellTopologyData *base=NULL)
Construct custom 3-cell (polyhedron) from a list of edges and sides. The default base topology is the...
unsigned getKey(const unsigned subcell_dim, const unsigned subcell_ord) const
Key of a subcell of the given dimension and ordinal.
CellTopology()
Default constructor initializes to NULL.
unsigned getVertexCount(const unsigned subcell_dim, const unsigned subcell_ord) const
Vertex count of a subcell of the given dimension and ordinal.
CellTopology(const CellTopologyData *cell)
Wrapper for safe access to a raw cell topology data.
bool getSubcellHomogeneity(const unsigned subcell_dim) const
Query if all subcells of the given dimension have the same 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 getNodePermutationInverse(const unsigned permutation_ord, const unsigned node_ord) const
Inverse permutation of a cell's node ordinals.
unsigned getKey() const
Unique key for this cell topology; under certain subcell uniformity conditions.
unsigned getFaceCount() const
Face boundary subcell count of this cell topology.
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.
unsigned getVertexCount() const
Vertex count of this cell topology.
const char * getBaseName() const
Unique name for this cell's base topology.
unsigned getEdgeCount(const unsigned subcell_dim, const unsigned subcell_ord) const
Edge count of a subcell of the given dimension and ordinal.
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 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.
ECellType
Enumeration of cell types in Shards.
std::ostream & operator<<(std::ostream &, const CellTopology &)
Overloaded << operator for CellTopologyData objects.
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.
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.
int isPredefinedCell(const CellTopology &cell)
Checks if the cell topology is predefined in shards.
A simple 'C' struct of cell topology attributes.
unsigned node_count
Number of nodes (a.k.a. subcells).
unsigned side_count
Number of sides (a.k.a. boundary subcells).
const struct CellTopologyData * base
Base, a.k.a. not-extended, version of this topology where vertex_count == node_count.
unsigned key
Unique key for this topology.
unsigned edge_count
Number of edges (a.k.a. boundary subcells).
unsigned vertex_count
Number of vertices.
unsigned permutation_count
Number of defined permutations.
const struct CellTopologyData_Permutation * permutation
Array of node permutations.