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 ;
117 struct SubcellTopologyTraits<0,0,0,0,0,0,TypeListEnd,TypeListEnd,
118 TypeListEnd,TypeListEnd,
119 TypeListEnd,IndexList<> >
121 typedef CellTopologyTraits<0,0,0> topology ;
124 enum { homogeneity =
true };
129 struct SubcellTopologyTraits<0,0,0,0,1,1,TypeListEnd,TypeListEnd,
130 TypeListEnd,TypeListEnd,
131 TypeListEnd,IndexList<> >
133 typedef CellTopologyTraits<0,1,1> topology ;
136 enum { homogeneity =
true };
140 template<
unsigned NodeIndex ,
141 unsigned NV ,
unsigned NN ,
142 class EList ,
class EMaps ,
143 class FList ,
class FMaps ,
144 class PMaps ,
class Pol>
145 struct SubcellTopologyTraits<1,0,NodeIndex, 1,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
147 typedef CellTopologyTraits<1,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
149 enum { node = NodeIndex < NN ? NodeIndex : ~0u };
150 enum { homogeneity =
true };
154 template<
unsigned NodeIndex ,
155 unsigned NV ,
unsigned NN ,
156 class EList ,
class EMaps ,
157 class FList ,
class FMaps ,
158 class PMaps ,
class Pol>
159 struct SubcellTopologyTraits<2,0,NodeIndex, 2,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
161 typedef CellTopologyTraits<2,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
163 enum { node = NodeIndex < NN ? NodeIndex : ~0u };
164 enum { homogeneity =
true };
168 template<
unsigned NodeIndex ,
169 unsigned NV ,
unsigned NN ,
170 class EList ,
class EMaps ,
171 class FList ,
class FMaps ,
172 class PMaps ,
class Pol>
173 struct SubcellTopologyTraits<3,0,NodeIndex, 3,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
175 typedef CellTopologyTraits<3,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol> topology ;
177 enum { node = NodeIndex < NN ? NodeIndex : ~0u };
178 enum { homogeneity =
true };
184 template<
unsigned SubcellOrd ,
185 unsigned D ,
unsigned NV ,
unsigned NN ,
186 class EList ,
class EMaps ,
187 class FList ,
class FMaps ,
188 class PMaps ,
class Pol>
189 struct SubcellTopologyTraits<0,SubcellOrd,0, D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
191 typedef CellTopologyTraits<0,0,0> topology ;
193 enum { node = SubcellOrd < NN ? SubcellOrd : ~0u };
194 enum { homogeneity =
true };
199 template<
unsigned SubcellOrd ,
unsigned NodeIndex ,
200 unsigned D ,
unsigned NV ,
unsigned NN ,
201 class EList ,
class EMaps ,
202 class FList ,
class FMaps ,
203 class PMaps ,
class Pol>
204 struct SubcellTopologyTraits<1,SubcellOrd,NodeIndex,
205 D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol>
208 typedef typename TypeListAt<EMaps,SubcellOrd>::type node_map ;
211 typedef typename TypeListAt<EList,SubcellOrd>::type topology ;
213 enum { count = TypeListLength<EList>::value };
215 enum { node = SubcellNodeIndex< topology , node_map , NodeIndex ,
216 SubcellOrd < count >::value };
218 enum { homogeneity = TypeListHomogeneous<EList>::value };
223 template<
unsigned SubcellOrd ,
unsigned NodeIndex ,
224 unsigned D ,
unsigned NV ,
unsigned NN ,
225 class EList ,
class EMaps ,
226 class FList ,
class FMaps ,
227 class PMaps ,
class Pol>
228 struct SubcellTopologyTraits< 2, SubcellOrd, NodeIndex,
229 D,NV,NN,EList,EMaps,FList,FMaps,PMaps,Pol >
232 typedef typename TypeListAt<FMaps,SubcellOrd>::type node_map ;
235 typedef typename TypeListAt<FList,SubcellOrd>::type topology ;
237 enum { count = TypeListLength<FList>::value };
239 enum { node = SubcellNodeIndex< topology , node_map , NodeIndex ,
240 SubcellOrd < count >::value };
242 enum { homogeneity = TypeListHomogeneous<FList>::value };
248 template<
unsigned SubcellDim ,
unsigned SubcellOrd ,
unsigned NodeIndex ,
250 unsigned Number_Vertex ,
unsigned Number_Node ,
251 class EdgeList ,
class EdgeMaps ,
252 class FaceList ,
class FaceMaps ,
253 class PermMaps ,
class Pol >
254 struct SubcellTopologyTraits
256 typedef void topology ;
259 enum { homogeneity =
false };
265 struct TypeListHomogeneous<TypeListEnd> {
266 enum { value =
true };
270 struct TypeListHomogeneous< TypeList<T,TypeListEnd> > {
271 enum { value =
true };
274 template<
class T ,
class Tail >
275 struct TypeListHomogeneous< TypeList< T, TypeList< T , Tail > > > {
276 enum { value = TypeListHomogeneous< TypeList<T,Tail> >::value };
279 template<
class ListType >
280 struct TypeListHomogeneous
282 enum { value =
false };
287 template<
unsigned I ,
unsigned J >
struct AssertEqual ;
289 template<
unsigned I >
struct AssertEqual<I,I> {
enum { OK =
true }; };
295 template<
unsigned Dimension ,
unsigned Number_Vertex ,
unsigned Number_Node ,
296 class EdgeList ,
class EdgeMaps ,
297 class FaceList ,
class FaceMaps ,
298 class PermutationMaps ,
299 class PermutationPolarity >
300 struct CellTopologyTraits
303 typedef CellTopologyTraits< Dimension, Number_Vertex, Number_Node,
304 EdgeList, EdgeMaps, FaceList, FaceMaps,
305 PermutationMaps, PermutationPolarity >
Traits ;
320 #ifndef DOXYGEN_COMPILE
336 ( face_count << 22 ) |
348 template<
unsigned Dim,
unsigned Ord = 0,
unsigned J = 0 >
350 public SubcellTopologyTraits< Dim , Ord , J ,
351 dimension , vertex_count , node_count ,
352 EdgeList , EdgeMaps ,
353 FaceList , FaceMaps ,
354 PermutationMaps, PermutationPolarity > {};
363 template<
unsigned Ord = 0 ,
unsigned J = 0 >
365 public SubcellTopologyTraits< ( 1 < dimension ? dimension - 1 : 4 ) ,
367 dimension , vertex_count , node_count ,
368 EdgeList , EdgeMaps ,
369 FaceList , FaceMaps ,
370 TypeListEnd , IndexList<> > {};
379 template< unsigned Ord = 0 , unsigned J = 0 >
381 public SubcellTopologyTraits< ( 1 < dimension ? 1 : 4 ) , Ord , J ,
382 dimension , vertex_count , node_count ,
383 EdgeList , EdgeMaps ,
384 TypeListEnd , TypeListEnd ,
385 TypeListEnd , IndexList<> > {};
405 template< unsigned Perm , unsigned J = 0 >
408 typedef typename TypeListAt< PermutationMaps , Perm >::type node_map ;
410 enum { node = J < node_count ? IndexListAt< node_map , J >::value : ~0u };
411 enum { polarity = IndexListAt< PermutationPolarity , Perm >::value };
414 template< unsigned Perm , unsigned J = 0 >
415 struct permutation_inverse {
417 typedef typename TypeListAt< PermutationMaps , Perm >::type forward_map ;
418 typedef typename IndexListInverse< forward_map >::type node_map ;
420 enum { node = J < node_count ? IndexListAt< node_map , J >::value : ~0u };
421 enum { polarity = IndexListAt< PermutationPolarity , Perm >::value };
424 enum { permutation_count = TypeListLength< PermutationMaps >::value };
430 #ifndef DOXYGEN_COMPILE
432 enum { nedge_map = TypeListLength<EdgeMaps>::value ,
433 nface_map = TypeListLength<FaceMaps>::value ,
434 polarity_count = IndexListLength< PermutationPolarity >::value };
436 enum { OK_edge = AssertEqual< edge_count , nedge_map >::OK };
437 enum { OK_face = AssertEqual< face_count , nface_map >::OK };
438 enum { OK_dimen = AssertEqual< 0 , (dimension >> 3) >::OK };
439 enum { OK_faceN = AssertEqual< 0 , (face_count >> 6) >::OK };
440 enum { OK_edgeN = AssertEqual< 0 , (edge_count >> 6) >::OK };
441 enum { OK_vertN = AssertEqual< 0 , (vertex_count >> 6) >::OK };
442 enum { OK_nodeN = AssertEqual< 0 , (node_count >> 10) >::OK };
443 enum { OK_permN = AssertEqual< permutation_count, polarity_count >::OK };
453 #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).