dune-pdelab  2.7-git
topologyutility.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_PDELAB_COMMON_TOPOLOGYUTILITY_HH
4 #define DUNE_PDELAB_COMMON_TOPOLOGYUTILITY_HH
5 
6 #include <dune/geometry/type.hh>
7 
8 namespace Dune {
9 
10  namespace PDELab {
11 
12 
14 
24  template<int dimension, unsigned int topologyId>
26  {
27  static const bool isCube =
28  ((topologyId ^ ((1 << dimension)-1)) >> 1 == 0);
29 
30  static const bool isSimplex =
31  (topologyId | 1) == 1;
32 
34  static const GeometryType::BasicType value =
35  isSimplex ? GeometryType::simplex
36  : (
37  isCube ? GeometryType::cube
38  : GeometryType::none
39  );
40  };
41 
42 
48  Dune::GeometryType geometryTypeFromBasicType(Dune::GeometryType::BasicType basicType, int dim){
49 
50  unsigned int topologyId(0);
51 
52  if (dim > 1){
53  switch( basicType )
54  {
55  case GeometryType::simplex :
56  topologyId = 0;
57  break;
58  case GeometryType::cube :
59  topologyId = ((1 << dim) - 1);
60  break;
61  case GeometryType::pyramid :
62  if (dim == 3)
63  topologyId = 0b0011;
64  else
65  DUNE_THROW( RangeError,
66  "Invalid basic geometry type: no pyramids for dimension " << dim << "." );
67  break;
68  case GeometryType::prism :
69  if (dim == 3)
70  topologyId = 0b0101;
71  else
72  DUNE_THROW( RangeError,
73  "Invalid basic geometry type: no prisms for dimension " << dim << "." );
74  break;
75  case GeometryType::none :
76  break;
77  default :
78  DUNE_THROW( RangeError,
79  "Invalid basic geometry type: " << basicType << " for dimension " << dim << "." );
80  }
81  }
82 
83  return Dune::GeometryType(topologyId, dim);
84  }
85 
86  } // namespace PDELab
87 } // namespace Dune
88 
89 
90 #endif // DUNE_PDELAB_COMMON_TOPOLOGYUTILITY_HH
static const int dim
Definition: adaptivity.hh:84
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Dune::GeometryType geometryTypeFromBasicType(Dune::GeometryType::BasicType basicType, int dim)
Definition: topologyutility.hh:48
Utility TMP for determining the BasicType of a geometry from its dimension and topology id.
Definition: topologyutility.hh:26
static const bool isSimplex
Definition: topologyutility.hh:30
static const GeometryType::BasicType value
The BasicType of Topology.
Definition: topologyutility.hh:34
static const bool isCube
Definition: topologyutility.hh:27