10 #ifndef Shards_CellTopologyTraits_hpp
11 #define Shards_CellTopologyTraits_hpp
13 #include <Shards_TypeList.hpp>
14 #include <Shards_IndexList.hpp>
15 #include <Shards_CellTopologyData.h>
26 template<
class Traits >
29 template<
unsigned Dimension ,
30 unsigned Number_Vertex ,
31 unsigned Number_Node ,
32 class EdgeList = TypeListEnd ,
33 class EdgeMaps = TypeListEnd ,
34 class FaceList = TypeListEnd ,
35 class FaceMaps = TypeListEnd ,
36 class PermutationMaps = TypeListEnd ,
37 class PermutationPolarity = IndexList<> >
46 #ifndef DOXYGEN_COMPILE
48 template<
class CellTop ,
class CellMap ,
unsigned Index ,
bool Good >
49 struct SubcellNodeIndex ;
51 template<
class CellTop ,
class CellMap ,
unsigned Index >
52 struct SubcellNodeIndex< CellTop , CellMap , Index , false >
53 {
enum { value = ~0u }; };
55 template<
class CellTop ,
class CellMap ,
unsigned Index >
56 struct SubcellNodeIndex< CellTop , CellMap , Index , true >
59 typedef typename CellTop::template subcell<0> subcell_node ;
61 enum { value = Index < subcell_node::count
62 ? IndexListAt< CellMap , Index >::value : ~0u };
67 template<
unsigned SubcellDim ,
unsigned SubcellOrd ,
unsigned NodeIndex ,
68 unsigned Dimension ,
unsigned Number_Vertex ,
unsigned Number_Node ,
69 class EdgeList ,
class EdgeMaps ,
70 class FaceList ,
class FaceMaps ,
71 class PermMaps ,
class Pol>
72 struct SubcellTopologyTraits ;
74 template<
class ListType >
struct TypeListHomogeneous ;
81 struct SubcellTopologyTraits<0,0,0,0,0,0,TypeListEnd,TypeListEnd,
82 TypeListEnd,TypeListEnd,
83 TypeListEnd,IndexList<> >
85 typedef CellTopologyTraits<0,0,0> topology ;
88 enum { homogeneity =
true };
93 struct SubcellTopologyTraits<0,0,0,0,1,1,TypeListEnd,TypeListEnd,
94 TypeListEnd,TypeListEnd,
95 TypeListEnd,IndexList<> >
97 typedef CellTopologyTraits<0,1,1> topology ;
100 enum { homogeneity =
true };
104 template<
unsigned NodeIndex ,
105 unsigned NV ,
unsigned NN ,
106 class EList ,
class EMaps ,
107 class FList ,
class FMaps ,
108 class PMaps ,
class Pol>
109 struct SubcellTopologyTraits<1,0,NodeIndex, 1,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
111 typedef CellTopologyTraits<1,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
113 enum { node = NodeIndex < NN ? NodeIndex : ~0u };
114 enum { homogeneity =
true };
118 template<
unsigned NodeIndex ,
119 unsigned NV ,
unsigned NN ,
120 class EList ,
class EMaps ,
121 class FList ,
class FMaps ,
122 class PMaps ,
class Pol>
123 struct SubcellTopologyTraits<2,0,NodeIndex, 2,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
125 typedef CellTopologyTraits<2,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
127 enum { node = NodeIndex < NN ? NodeIndex : ~0u };
128 enum { homogeneity =
true };
132 template<
unsigned NodeIndex ,
133 unsigned NV ,
unsigned NN ,
134 class EList ,
class EMaps ,
135 class FList ,
class FMaps ,
136 class PMaps ,
class Pol>
137 struct SubcellTopologyTraits<3,0,NodeIndex, 3,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
139 typedef CellTopologyTraits<3,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
141 enum { node = NodeIndex < NN ? NodeIndex : ~0u };
142 enum { homogeneity =
true };
148 template<
unsigned SubcellOrd ,
149 unsigned D ,
unsigned NV ,
unsigned NN ,
150 class EList ,
class EMaps ,
151 class FList ,
class FMaps ,
152 class PMaps ,
class Pol>
153 struct SubcellTopologyTraits<0,SubcellOrd,0, D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
155 typedef CellTopologyTraits<0,0,0> topology ;
157 enum { node = SubcellOrd < NN ? SubcellOrd : ~0u };
158 enum { homogeneity =
true };
163 template<
unsigned SubcellOrd ,
unsigned NodeIndex ,
164 unsigned D ,
unsigned NV ,
unsigned NN ,
165 class EList ,
class EMaps ,
166 class FList ,
class FMaps ,
167 class PMaps ,
class Pol>
168 struct SubcellTopologyTraits<1,SubcellOrd,NodeIndex,
169 D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
172 typedef typename TypeListAt<EMaps,SubcellOrd>::type node_map ;
175 typedef typename TypeListAt<EList,SubcellOrd>::type topology ;
177 enum { count = TypeListLength<EList>::value };
179 enum { node = SubcellNodeIndex< topology , node_map , NodeIndex ,
180 SubcellOrd < count >::value };
182 enum { homogeneity = TypeListHomogeneous<EList>::value };
187 template<
unsigned SubcellOrd ,
unsigned NodeIndex ,
188 unsigned D ,
unsigned NV ,
unsigned NN ,
189 class EList ,
class EMaps ,
190 class FList ,
class FMaps ,
191 class PMaps ,
class Pol>
192 struct SubcellTopologyTraits< 2, SubcellOrd, NodeIndex,
193 D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol >
196 typedef typename TypeListAt<FMaps,SubcellOrd>::type node_map ;
199 typedef typename TypeListAt<FList,SubcellOrd>::type topology ;
201 enum { count = TypeListLength<FList>::value };
203 enum { node = SubcellNodeIndex< topology , node_map , NodeIndex ,
204 SubcellOrd < count >::value };
206 enum { homogeneity = TypeListHomogeneous<FList>::value };
212 template<
unsigned SubcellDim ,
unsigned SubcellOrd ,
unsigned NodeIndex ,
214 unsigned Number_Vertex ,
unsigned Number_Node ,
215 class EdgeList ,
class EdgeMaps ,
216 class FaceList ,
class FaceMaps ,
217 class PermMaps ,
class Pol >
218 struct SubcellTopologyTraits
220 typedef void topology ;
223 enum { homogeneity =
false };
229 struct TypeListHomogeneous<TypeListEnd> {
230 enum { value =
true };
234 struct TypeListHomogeneous< TypeList<T,TypeListEnd> > {
235 enum { value =
true };
238 template<
class T ,
class Tail >
239 struct TypeListHomogeneous< TypeList< T, TypeList< T , Tail > > > {
240 enum { value = TypeListHomogeneous< TypeList<T,Tail> >::value };
243 template<
class ListType >
244 struct TypeListHomogeneous
246 enum { value =
false };
251 template<
unsigned I ,
unsigned J >
struct AssertEqual ;
253 template<
unsigned I >
struct AssertEqual<I,I> {
enum { OK =
true }; };
259 template<
unsigned Dimension ,
unsigned Number_Vertex ,
unsigned Number_Node ,
260 class EdgeList ,
class EdgeMaps ,
261 class FaceList ,
class FaceMaps ,
262 class PermutationMaps ,
263 class PermutationPolarity >
264 struct CellTopologyTraits
267 typedef CellTopologyTraits< Dimension, Number_Vertex, Number_Node,
268 EdgeList, EdgeMaps, FaceList, FaceMaps,
269 PermutationMaps, PermutationPolarity >
Traits ;
284 #ifndef DOXYGEN_COMPILE
300 ( face_count << 22 ) |
312 template<
unsigned Dim,
unsigned Ord = 0,
unsigned J = 0 >
314 public SubcellTopologyTraits< Dim , Ord , J ,
315 dimension , vertex_count , node_count ,
316 EdgeList , EdgeMaps ,
317 FaceList , FaceMaps ,
318 PermutationMaps, PermutationPolarity > {};
327 template<
unsigned Ord = 0 ,
unsigned J = 0 >
329 public SubcellTopologyTraits< ( 1 < dimension ? dimension - 1 : 4 ) ,
331 dimension , vertex_count , node_count ,
332 EdgeList , EdgeMaps ,
333 FaceList , FaceMaps ,
334 TypeListEnd , IndexList<> > {};
343 template< unsigned Ord = 0 , unsigned J = 0 >
345 public SubcellTopologyTraits< ( 1 < dimension ? 1 : 4 ) , Ord , J ,
346 dimension , vertex_count , node_count ,
347 EdgeList , EdgeMaps ,
348 TypeListEnd , TypeListEnd ,
349 TypeListEnd , IndexList<> > {};
369 template< unsigned Perm , unsigned J = 0 >
372 typedef typename TypeListAt< PermutationMaps , Perm >::type node_map ;
374 enum { node = J < node_count ? IndexListAt< node_map , J >::value : ~0u };
375 enum { polarity = IndexListAt< PermutationPolarity , Perm >::value };
378 template< unsigned Perm , unsigned J = 0 >
379 struct permutation_inverse {
381 typedef typename TypeListAt< PermutationMaps , Perm >::type forward_map ;
382 typedef typename IndexListInverse< forward_map >::type node_map ;
384 enum { node = J < node_count ? IndexListAt< node_map , J >::value : ~0u };
385 enum { polarity = IndexListAt< PermutationPolarity , Perm >::value };
388 enum { permutation_count = TypeListLength< PermutationMaps >::value };
394 #ifndef DOXYGEN_COMPILE
396 enum { nedge_map = TypeListLength<EdgeMaps>::value ,
397 nface_map = TypeListLength<FaceMaps>::value ,
398 polarity_count = IndexListLength< PermutationPolarity >::value };
400 enum { OK_edge = AssertEqual< edge_count , nedge_map >::OK };
401 enum { OK_face = AssertEqual< face_count , nface_map >::OK };
402 enum { OK_dimen = AssertEqual< 0 , (dimension >> 3) >::OK };
403 enum { OK_faceN = AssertEqual< 0 , (face_count >> 6) >::OK };
404 enum { OK_edgeN = AssertEqual< 0 , (edge_count >> 6) >::OK };
405 enum { OK_vertN = AssertEqual< 0 , (vertex_count >> 6) >::OK };
406 enum { OK_nodeN = AssertEqual< 0 , (node_count >> 10) >::OK };
407 enum { OK_permN = AssertEqual< permutation_count, polarity_count >::OK };
417 #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).