46 #ifndef Shards_CellTopologyTraits_hpp 
   47 #define Shards_CellTopologyTraits_hpp 
   49 #include <Shards_TypeList.hpp> 
   50 #include <Shards_IndexList.hpp> 
   51 #include <Shards_CellTopologyData.h> 
   62 template< 
class Traits >
 
   65 template< 
unsigned Dimension ,
 
   66           unsigned Number_Vertex ,
 
   67           unsigned Number_Node ,
 
   68           class    EdgeList = TypeListEnd ,
 
   69           class    EdgeMaps = TypeListEnd ,
 
   70           class    FaceList = TypeListEnd ,
 
   71           class    FaceMaps = TypeListEnd ,
 
   72           class    PermutationMaps = TypeListEnd ,
 
   73           class    PermutationPolarity = IndexList<> >
 
   82 #ifndef DOXYGEN_COMPILE 
   84 template< 
class CellTop , 
class CellMap , 
unsigned Index , 
bool Good >
 
   85 struct SubcellNodeIndex ;
 
   87 template< 
class CellTop , 
class CellMap , 
unsigned Index >
 
   88 struct SubcellNodeIndex< CellTop , CellMap , Index , false >
 
   89 { 
enum { value = ~0u }; };
 
   91 template< 
class CellTop , 
class CellMap , 
unsigned Index >
 
   92 struct SubcellNodeIndex< CellTop , CellMap , Index , true >
 
   95   typedef typename CellTop::template subcell<0> subcell_node ;
 
   97   enum { value = Index < subcell_node::count
 
   98                ? IndexListAt< CellMap , Index >::value : ~0u };
 
  103 template< 
unsigned SubcellDim , 
unsigned SubcellOrd , 
unsigned NodeIndex ,
 
  104           unsigned Dimension , 
unsigned Number_Vertex , 
unsigned Number_Node ,
 
  105           class EdgeList , 
class EdgeMaps ,
 
  106           class FaceList , 
class FaceMaps ,
 
  107           class PermMaps , 
class Pol>
 
  108 struct SubcellTopologyTraits ;
 
  110 template< 
class ListType > 
struct TypeListHomogeneous ;
 
  116 struct SubcellTopologyTraits<0,0,0,0,0,0,TypeListEnd,TypeListEnd,
 
  117                                          TypeListEnd,TypeListEnd,
 
  118                                          TypeListEnd,IndexList<> >
 
  120   typedef CellTopologyTraits<0,0,0> topology ;
 
  123   enum { homogeneity = 
true };
 
  126 template< 
unsigned NodeIndex ,
 
  127           unsigned NV , 
unsigned NN ,
 
  128           class EList , 
class EMaps ,
 
  129           class FList , 
class FMaps ,
 
  130           class PMaps , 
class Pol>
 
  131 struct SubcellTopologyTraits<1,0,NodeIndex, 1,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
 
  133   typedef CellTopologyTraits<1,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
 
  135   enum { node = NodeIndex < NN ? NodeIndex : ~0u };
 
  136   enum { homogeneity = 
true };
 
  139 template< 
unsigned NodeIndex ,
 
  140           unsigned NV , 
unsigned NN ,
 
  141           class EList , 
class EMaps ,
 
  142           class FList , 
class FMaps ,
 
  143           class PMaps , 
class Pol>
 
  144 struct SubcellTopologyTraits<2,0,NodeIndex, 2,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
 
  146   typedef CellTopologyTraits<2,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
 
  148   enum { node = NodeIndex < NN ? NodeIndex : ~0u };
 
  149   enum { homogeneity = 
true };
 
  152 template< 
unsigned NodeIndex ,
 
  153           unsigned NV , 
unsigned NN ,
 
  154           class EList , 
class EMaps ,
 
  155           class FList , 
class FMaps ,
 
  156           class PMaps , 
class Pol>
 
  157 struct SubcellTopologyTraits<3,0,NodeIndex, 3,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
 
  159   typedef CellTopologyTraits<3,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
 
  161   enum { node = NodeIndex < NN ? NodeIndex : ~0u };
 
  162   enum { homogeneity = 
true };
 
  168 template< 
unsigned SubcellOrd ,
 
  169           unsigned D , 
unsigned NV , 
unsigned NN ,
 
  170           class EList , 
class EMaps ,
 
  171           class FList , 
class FMaps ,
 
  172           class PMaps , 
class Pol>
 
  173 struct SubcellTopologyTraits<0,SubcellOrd,0, D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
 
  175   typedef CellTopologyTraits<0,0,0> topology ;
 
  177   enum { node = SubcellOrd < NN ? SubcellOrd : ~0u };
 
  178   enum { homogeneity = 
true };
 
  183 template< 
unsigned SubcellOrd , 
unsigned NodeIndex ,
 
  184           unsigned D , 
unsigned NV , 
unsigned NN ,
 
  185           class EList , 
class EMaps ,
 
  186           class FList , 
class FMaps ,
 
  187           class PMaps , 
class Pol>
 
  188 struct SubcellTopologyTraits<1,SubcellOrd,NodeIndex,
 
  189                              D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
 
  192   typedef typename TypeListAt<EMaps,SubcellOrd>::type node_map ;
 
  195   typedef typename TypeListAt<EList,SubcellOrd>::type topology ;
 
  197   enum { count = TypeListLength<EList>::value };
 
  199   enum { node = SubcellNodeIndex< topology , node_map , NodeIndex ,
 
  200                                   SubcellOrd < count >::value };
 
  202   enum { homogeneity = TypeListHomogeneous<EList>::value };
 
  207 template< 
unsigned SubcellOrd , 
unsigned NodeIndex ,
 
  208           unsigned D , 
unsigned NV , 
unsigned NN ,
 
  209           class EList , 
class EMaps ,
 
  210           class FList , 
class FMaps ,
 
  211           class PMaps , 
class Pol>
 
  212 struct SubcellTopologyTraits< 2, SubcellOrd, NodeIndex,
 
  213                               D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol >
 
  216   typedef typename TypeListAt<FMaps,SubcellOrd>::type node_map ;
 
  219   typedef typename TypeListAt<FList,SubcellOrd>::type topology ;
 
  221   enum { count = TypeListLength<FList>::value };
 
  223   enum { node = SubcellNodeIndex< topology , node_map , NodeIndex ,
 
  224                                   SubcellOrd < count >::value };
 
  226   enum { homogeneity = TypeListHomogeneous<FList>::value };
 
  232 template< 
unsigned SubcellDim , 
unsigned SubcellOrd , 
unsigned NodeIndex ,
 
  234           unsigned Number_Vertex , 
unsigned Number_Node ,
 
  235           class EdgeList , 
class EdgeMaps ,
 
  236           class FaceList , 
class FaceMaps ,
 
  237           class PermMaps , 
class Pol >
 
  238 struct SubcellTopologyTraits
 
  240   typedef void topology ;
 
  243   enum { homogeneity = 
false };
 
  249 struct TypeListHomogeneous<TypeListEnd> {
 
  250   enum { value = 
true };
 
  254 struct TypeListHomogeneous< TypeList<T,TypeListEnd> > {
 
  255   enum { value = 
true };
 
  258 template< 
class T , 
class Tail >
 
  259 struct TypeListHomogeneous< TypeList< T, TypeList< T , Tail > > > {
 
  260   enum { value = TypeListHomogeneous< TypeList<T,Tail> >::value };
 
  263 template< 
class ListType >
 
  264 struct TypeListHomogeneous 
 
  266   enum { value = 
false };
 
  271 template< 
unsigned I , 
unsigned J > 
struct AssertEqual ;
 
  273 template< 
unsigned I > 
struct AssertEqual<I,I> { 
enum { OK = 
true }; };
 
  279 template< 
unsigned Dimension , 
unsigned Number_Vertex , 
unsigned Number_Node ,
 
  280           class EdgeList , 
class EdgeMaps ,
 
  281           class FaceList , 
class FaceMaps ,
 
  282           class PermutationMaps ,
 
  283           class PermutationPolarity >
 
  284 struct CellTopologyTraits
 
  287   typedef CellTopologyTraits< Dimension, Number_Vertex, Number_Node,
 
  288                               EdgeList, EdgeMaps, FaceList, FaceMaps,
 
  289                               PermutationMaps, PermutationPolarity > 
Traits ;
 
  304 #ifndef DOXYGEN_COMPILE 
  320            ( face_count   << 22  ) |
 
  332   template< 
unsigned Dim, 
unsigned Ord = 0, 
unsigned J = 0 >
 
  334     public SubcellTopologyTraits< Dim , Ord , J ,
 
  335                                   dimension , vertex_count , node_count ,
 
  336                                   EdgeList , EdgeMaps ,
 
  337                                   FaceList , FaceMaps ,
 
  338                                   PermutationMaps, PermutationPolarity > {};
 
  347   template< 
unsigned Ord = 0 , 
unsigned J = 0 >
 
  349     public SubcellTopologyTraits< ( 1 < dimension ? dimension - 1 : 4 ) ,
 
  351                                   dimension , vertex_count , node_count ,
 
  352                                   EdgeList , EdgeMaps ,
 
  353                                   FaceList , FaceMaps ,
 
  354                                   TypeListEnd , IndexList<> > {};
 
  363   template< unsigned Ord = 0 , unsigned J = 0 >
 
  365     public SubcellTopologyTraits< ( 1 < dimension ? 1 : 4 ) , Ord , J ,
 
  366                                   dimension , vertex_count , node_count ,
 
  367                                   EdgeList , EdgeMaps ,
 
  368                                   TypeListEnd , TypeListEnd ,
 
  369                                   TypeListEnd , IndexList<> > {};
 
  389   template< unsigned Perm , unsigned J = 0 >
 
  392     typedef typename TypeListAt< PermutationMaps , Perm >::type node_map ;
 
  394     enum { node = J < node_count ? IndexListAt< node_map , J >::value : ~0u };
 
  395     enum { polarity = IndexListAt< PermutationPolarity , Perm >::value };
 
  398   template< unsigned Perm , unsigned J = 0 >
 
  399   struct permutation_inverse {
 
  401     typedef typename TypeListAt< PermutationMaps , Perm >::type forward_map ;
 
  402     typedef typename IndexListInverse< forward_map >::type node_map ;
 
  404     enum { node = J < node_count ? IndexListAt< node_map , J >::value : ~0u };
 
  405     enum { polarity = IndexListAt< PermutationPolarity , Perm >::value };
 
  408   enum { permutation_count = TypeListLength< PermutationMaps >::value };
 
  414 #ifndef DOXYGEN_COMPILE
 
  416   enum { nedge_map = TypeListLength<EdgeMaps>::value ,
 
  417          nface_map = TypeListLength<FaceMaps>::value ,
 
  418          polarity_count = IndexListLength< PermutationPolarity >::value };
 
  420   enum { OK_edge  = AssertEqual< edge_count , nedge_map >::OK };
 
  421   enum { OK_face  = AssertEqual< face_count , nface_map >::OK };
 
  422   enum { OK_dimen = AssertEqual< 0 , (dimension    >>  3) >::OK };
 
  423   enum { OK_faceN = AssertEqual< 0 , (face_count   >>  6) >::OK };
 
  424   enum { OK_edgeN = AssertEqual< 0 , (edge_count   >>  6) >::OK };
 
  425   enum { OK_vertN = AssertEqual< 0 , (vertex_count >>  6) >::OK };
 
  426   enum { OK_nodeN = AssertEqual< 0 , (node_count   >> 10) >::OK };
 
  427   enum { OK_permN = AssertEqual< permutation_count, polarity_count >::OK };
 
  437 #endif // Shards_CellTopologyTraits_hpp 
Number of edges (a.k.a. Cell^1 subcells). 
Number of nodes (a.k.a. Cell^0 subcells). 
Member  enum { value = ... };  is the length of the type list. 
Side subcell information. 
CellTopologyTraits< Dimension, Number_Vertex, Number_Node, EdgeList, EdgeMaps, FaceList, FaceMaps, PermutationMaps, PermutationPolarity > Traits
The  self  type for the traits. 
Compile-time traits for a cell topology. 
Unique key for this topology. 
const CellTopologyData * getCellTopologyData()
Return a CellTopology singleton for the given cell topology traits. 
Topological traits: Dimension = 0, Vertices = 0, Nodes = 0. 
A simple 'C' struct of cell topology attributes. 
Number of sides (a.k.a. Cell^(D-1) subcells).