dune-geometry  2.7.0
typefromvertexcount.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_GEOMETRY_TYPE_FROM_VERTEX_COUNT_HH
4 #define DUNE_GEOMETRY_TYPE_FROM_VERTEX_COUNT_HH
5 
6 #include <dune/geometry/type.hh>
7 
8 namespace Dune {
9 
14  inline
15  GeometryType geometryTypeFromVertexCount(unsigned int dim, unsigned int vertices)
16  {
17  switch (dim)
18  {
19  case 0 :
20  return GeometryTypes::vertex;
21  case 1 :
22  return GeometryTypes::line;
23  case 2 :
24  switch (vertices) {
25  case 3 :
27  case 4 :
29  default :
30  DUNE_THROW(NotImplemented, "2d elements with " << vertices << " corners are not supported!");
31  }
32  case 3 :
33  switch (vertices) {
34  case 4 :
36  case 5 :
38  case 6 :
39  return GeometryTypes::prism;
40  case 8 :
42  default :
43  DUNE_THROW(NotImplemented, "3d elements with " << vertices << " corners are not supported!");
44  }
45  default :
46  DUNE_THROW(NotImplemented, "geometryTypeFromVertexCount works only up to dim=3");
47  }
48  }
49 
50 }
51 
52 #endif // DUNE_GEOMETRY_TYPE_FROM_VERTEX_COUNT_HH
Dune::GeometryTypes::pyramid
constexpr GeometryType pyramid
GeometryType representing a 3D pyramid.
Definition: type.hh:827
Dune::GeometryTypes::prism
constexpr GeometryType prism
GeometryType representing a 3D prism.
Definition: type.hh:833
type.hh
A unique label for each type of element that can occur in a grid.
Dune::GeometryTypes::vertex
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:797
Dune::GeometryTypes::triangle
constexpr GeometryType triangle
GeometryType representing a triangle.
Definition: type.hh:809
Dune::GeometryType
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:278
Dune::GeometryTypes::line
constexpr GeometryType line
GeometryType representing a line.
Definition: type.hh:803
Dune::GeometryTypes::quadrilateral
constexpr GeometryType quadrilateral
GeometryType representing a quadrilateral (a square).
Definition: type.hh:815
Dune
Definition: affinegeometry.hh:18
Dune::GeometryTypes::tetrahedron
constexpr GeometryType tetrahedron
GeometryType representing a tetrahedron.
Definition: type.hh:821
Dune::GeometryTypes::hexahedron
constexpr GeometryType hexahedron
GeometryType representing a hexahedron.
Definition: type.hh:839
Dune::geometryTypeFromVertexCount
GeometryType geometryTypeFromVertexCount(unsigned int dim, unsigned int vertices)
Utitlity function to construct the correct geometry type given the dimension and the number of vertic...
Definition: typefromvertexcount.hh:15