"Fossies" - the Fresh Open Source Software Archive

Member "dune-geometry-2.6.0/dune/geometry/type.hh" (28 Mar 2018, 23455 Bytes) of package /linux/misc/dune/dune-geometry-2.6.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "type.hh" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 2.6.0rc1_vs_2.6.0 or 2.5.1_vs_2.6.0.

    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_HH
    4 #define DUNE_GEOMETRY_TYPE_HH
    5 
    6 /** \file
    7  *  \brief A unique label for each type of element that can occur in a grid
    8  */
    9 
   10 #include <cassert>
   11 
   12 #include <string>
   13 
   14 #include <dune/common/deprecated.hh>
   15 #include <dune/common/exceptions.hh>
   16 #include <dune/common/keywords.hh>
   17 #include <dune/common/typetraits.hh>
   18 #include <dune/common/unused.hh>
   19 
   20 namespace Dune
   21 {
   22 
   23   // forward declaration needed for deprecated makeFromVertices
   24   class GeometryType;
   25   GeometryType geometryTypeFromVertexCount(unsigned int dim, unsigned int vertices);
   26 
   27   namespace Impl
   28   {
   29 
   30     enum TopologyConstruction { pyramidConstruction = 0, prismConstruction = 1 };
   31 
   32 
   33 
   34     // Basic Topology Types
   35     // --------------------
   36 
   37     struct Point
   38     {
   39       static const unsigned int dimension = 0;
   40       static const unsigned int numCorners = 1;
   41 
   42       static const unsigned int id = 0;
   43 
   44       static std::string name () { return "p"; }
   45     };
   46 
   47 
   48     template< class BaseTopology >
   49     struct Prism
   50     {
   51       static const unsigned int dimension = BaseTopology::dimension + 1;
   52       static const unsigned int numCorners = 2 * BaseTopology::numCorners;
   53 
   54       static const unsigned int id = BaseTopology::id | ((unsigned int)prismConstruction << (dimension-1));
   55 
   56       static std::string name () { return BaseTopology::name() + "l"; }
   57     };
   58 
   59 
   60     template< class BaseTopology >
   61     struct Pyramid
   62     {
   63       static const unsigned int dimension = BaseTopology::dimension + 1;
   64       static const unsigned int numCorners = BaseTopology::numCorners + 1;
   65 
   66       static const unsigned int id = BaseTopology::id | ((unsigned int)pyramidConstruction << (dimension-1));
   67 
   68       static std::string name () { return BaseTopology::name() + "o"; }
   69     };
   70 
   71 
   72 
   73     // Properties of Topologies
   74     // ------------------------
   75 
   76     template< class Topology >
   77     struct IsSimplex
   78       : public std::integral_constant< bool, (Topology::id >> 1) == 0 >
   79     {};
   80 
   81     template< class Topology >
   82     struct IsCube
   83       : public std::integral_constant< bool,  (Topology::id | 1) == (1 << Topology::dimension) - 1 >
   84     {};
   85 
   86 
   87 
   88     // Dynamic Topology Properties
   89     // ---------------------------
   90 
   91     /** \brief obtain the number of topologies of a given dimension
   92      *
   93      *  \note Valid topology ids are 0,...,numTopologies(dim)-1.
   94      *
   95      *  \param[in]  dim  dimension
   96      *
   97      *  \returns number of topologies for the dimension
   98      */
   99     inline static unsigned int numTopologies ( int dim ) noexcept
  100     {
  101       return (1u << dim);
  102     }
  103 
  104     /** \brief check whether a pyramid construction was used to create a given
  105      *         codimension
  106      *
  107      *  \param[in]  topologyId  id of the topology
  108      *  \param[in]  dim         dimension of the topology
  109      *  \param[in]  codim       codimension for which the information is desired
  110      *                          (defaults to 0)
  111      *
  112      *  \returns true, if a pyramid construction was used to generate the
  113      *           codimension the topology.
  114      */
  115     inline bool static isPyramid ( unsigned int topologyId, int dim, int codim = 0 ) noexcept
  116     {
  117       assert( (dim > 0) && (topologyId < numTopologies( dim )) );
  118       assert( (0 <= codim) && (codim < dim) );
  119       return (((topologyId & ~1) & (1u << (dim-codim-1))) == 0);
  120     }
  121 
  122     /** \brief check whether a prism construction was used to create a given
  123      *         codimension
  124      *
  125      *  \param[in]  topologyId  id of the topology
  126      *  \param[in]  dim         dimension of the topology
  127      *  \param[in]  codim       codimension for which the information is desired
  128      *                          (defaults to 0)
  129      *
  130      *  \returns true, if a prism construction was used to generate the
  131      *           codimension the topology.
  132      */
  133     inline static bool isPrism ( unsigned int topologyId, int dim, int codim = 0 ) noexcept
  134     {
  135       assert( (dim > 0) && (topologyId < numTopologies( dim )) );
  136       assert( (0 <= codim) && (codim < dim) );
  137       return (( (topologyId | 1) & (1u << (dim-codim-1))) != 0);
  138     }
  139 
  140     /** \brief check whether a specific topology construction was used to create a
  141      *         given codimension
  142      *
  143      *  \param[in]  construction  construction to check for
  144      *  \param[in]  topologyId    id of the topology
  145      *  \param[in]  dim           dimension of the topology
  146      *  \param[in]  codim         codimension for which the information is desired
  147      *                            (defaults to 0)
  148      *
  149      *  \returns true, if construction was used to generate the codimension the
  150      *           topology.
  151      */
  152     inline static bool isTopology ( TopologyConstruction construction, unsigned int topologyId, int dim, int codim = 0 ) noexcept
  153     {
  154       assert( (dim > 0) && (topologyId < numTopologies( dim )) );
  155       assert( (0 <= codim) && (codim <= dim) );
  156       return (codim >= (dim-1)) || (((topologyId >> (dim-codim-1)) & 1) == (unsigned int)construction);
  157     }
  158 
  159     /** \brief obtain the base topology of a given codimension
  160      *
  161      *  \param[in]  topologyId    id of the topology
  162      *  \param[in]  dim           dimension of the topology
  163      *  \param[in]  codim         codimension for which the information is desired
  164      *                            (defaults to 1)
  165      */
  166     inline static unsigned int baseTopologyId ( unsigned int topologyId, int dim, int codim = 1 ) noexcept
  167     {
  168       assert( (dim >= 0) && (topologyId < numTopologies( dim )) );
  169       assert( (0 <= codim) && (codim <= dim) );
  170       return topologyId & ((1u << (dim-codim)) - 1);
  171     }
  172 
  173 
  174 
  175     // SimplexTopology
  176     // ---------------
  177 
  178     template< unsigned int dim >
  179     struct SimplexTopology
  180     {
  181       typedef Pyramid< typename SimplexTopology< dim-1 >::type > type;
  182     };
  183 
  184     template<>
  185     struct SimplexTopology< 0 >
  186     {
  187       typedef Point type;
  188     };
  189 
  190 
  191 
  192     // CubeTopology
  193     // ------------
  194 
  195     template< unsigned int dim >
  196     struct CubeTopology
  197     {
  198       typedef Prism< typename CubeTopology< dim-1 >::type > type;
  199     };
  200 
  201     template<>
  202     struct CubeTopology< 0 >
  203     {
  204       typedef Point type;
  205     };
  206 
  207 
  208 
  209     // PyramidTopology
  210     // ---------------
  211 
  212     template< unsigned int dim >
  213     struct PyramidTopology
  214     {
  215       typedef Pyramid< typename CubeTopology< dim-1 >::type > type;
  216     };
  217 
  218 
  219 
  220     // PrismTopology
  221     // -------------
  222 
  223     template< unsigned int dim >
  224     struct PrismTopology
  225     {
  226       typedef Prism< typename SimplexTopology< dim-1 >::type > type;
  227     };
  228 
  229 
  230 
  231 
  232     // IfTopology
  233     // ----------
  234 
  235     template< template< class > class Operation, int dim, class Topology = Point >
  236     struct IfTopology
  237     {
  238       template< class... Args >
  239       static auto apply ( unsigned int topologyId, Args &&... args )
  240       {
  241         if( topologyId & 1 )
  242           return IfTopology< Operation, dim-1, Prism< Topology > >::apply( topologyId >> 1, std::forward< Args >( args )... );
  243         else
  244           return IfTopology< Operation, dim-1, Pyramid< Topology > >::apply( topologyId >> 1, std::forward< Args >( args )... );
  245       }
  246     };
  247 
  248     template< template< class > class Operation, class Topology >
  249     struct IfTopology< Operation, 0, Topology >
  250     {
  251       template< class... Args >
  252       static auto apply ( unsigned int topologyId, Args &&... args )
  253       {
  254         DUNE_UNUSED_PARAMETER( topologyId );
  255         return Operation< Topology >::apply( std::forward< Args >( args )... );
  256       }
  257     };
  258 
  259   } // namespace Impl
  260 
  261 
  262 
  263   // GeometryType
  264   // -------------
  265 
  266   /** \brief Unique label for each type of entities that can occur in DUNE grids
  267    *
  268    * This class has to be extended if a grid implementation with new entity types
  269    * is added to DUNE.
  270    *
  271    * GeometryType is a C++ "literal type" and can be used in `constexpr` context if created
  272    * with a `constexpr` constructor.
  273    *
  274    * \ingroup GeometryType
  275    */
  276   class GeometryType
  277   {
  278   public:
  279 
  280     /** \brief Each entity can be tagged by one of these basic types
  281      *  plus its space dimension */
  282     enum
  283     BasicType {
  284       simplex,       //!< Simplicial element in any nonnegative dimension
  285       cube,          //!< Cube element in any nonnegative dimension
  286       pyramid,       //!< Four sided pyramid in three dimensions
  287       prism,         //!< Prism element in three dimensions
  288       extended,      //!< Other, more general topology, representable as topologyId
  289       none           //!< Even more general topology, cannot be specified by a topologyId. Two GeometryTypes with 'none' type are equal if and only if they have the same dimension.
  290     };
  291 
  292   private:
  293 
  294     /** \brief Topology Id element */
  295     unsigned int topologyId_;
  296 
  297     /** \brief Dimension of the element */
  298     unsigned char dim_  : 7;
  299 
  300     /** \brief bool if this is none-type */
  301     bool none_ : 1;
  302 
  303   public:
  304 
  305     /** @name Constructors */
  306     /*@{*/
  307 
  308     /** \brief Default constructor, not initializing anything */
  309     constexpr GeometryType ()
  310       : topologyId_(0), dim_(0), none_(true)
  311     {}
  312 
  313 #pragma GCC diagnostic push
  314 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  315     /** \brief Constructor, using the basic type and the dimension */
  316     GeometryType(BasicType basicType, unsigned int dim)
  317       DUNE_DEPRECATED_MSG("The GeometryType constructor taking BasicType is deprecated and will be removed after DUNE 2.6")
  318       : topologyId_(0), dim_(dim), none_((basicType == GeometryType::none) ? true : false)
  319     {
  320       if (dim < 2)
  321         return;
  322       switch( basicType )
  323       {
  324       case GeometryType::simplex :
  325         topologyId_ = 0;
  326         break;
  327       case GeometryType::cube :
  328         topologyId_ = ((1 << dim) - 1);
  329         break;
  330       case GeometryType::pyramid :
  331         if (dim == 3)
  332           topologyId_ = 0b0011;
  333         else
  334           DUNE_THROW( RangeError,
  335                       "Invalid basic geometry type: no pyramids for dimension " << dim << "." );
  336         break;
  337       case GeometryType::prism :
  338         if (dim == 3)
  339           topologyId_ = 0b0101;
  340         else
  341           DUNE_THROW( RangeError,
  342                       "Invalid basic geometry type: no prisms for dimension " << dim << "." );
  343         break;
  344       case GeometryType::none :
  345         break;
  346       default :
  347         DUNE_THROW( RangeError,
  348                     "Invalid basic geometry type: " << basicType << " for dimension " << dim << "." );
  349       }
  350     }
  351 #pragma GCC diagnostic pop
  352 
  353     /** \brief Constructor, using the topologyId (integer), the dimension and a flag for type none.
  354      * \note With this constructor, you can easily create an invalid GeometryType,
  355      *       it is mostly here for internal use!
  356      *       the TypologyType, users are encouraged to use the
  357      *       GeometryType(TopologyType t) constructor.
  358      */
  359     constexpr GeometryType(unsigned int topologyId, unsigned int dim, bool none)
  360       : topologyId_(topologyId), dim_(dim), none_(none)
  361     {}
  362 
  363     /** \brief Constructor, using the topologyId (integer) and the dimension
  364      * \note the topologyId is a binary encoded representation of
  365      *       the TypologyType, users are encouraged to use the
  366      *       GeometryType(TopologyType t) constructor.
  367      */
  368     constexpr GeometryType(unsigned int topologyId, unsigned int dim)
  369       : topologyId_(topologyId), dim_(dim), none_(false)
  370     {}
  371 
  372     /** \brief Constructor from static TopologyType class
  373      *
  374      * Constructs the GeometryType object from a static topology representation.
  375      *
  376      * \tparam TopologyType A class providing public static unsigned int members
  377      *                      TopologyType::dimension and TopologyType::id.
  378      *                      You can e.g. use the Point, Prism and Pyramid structs
  379      *                      from the Impl namespace.
  380      * \param t             Any object of type TopologyType. The object t itself is ignored.
  381      */
  382     template<class TopologyType,
  383       class = Dune::void_t<decltype(TopologyType::dimension), decltype(TopologyType::id)>>
  384     explicit GeometryType(TopologyType t)
  385       : topologyId_(TopologyType::id), dim_(TopologyType::dimension), none_(false)
  386     {
  387       DUNE_UNUSED_PARAMETER(t);
  388     }
  389 
  390     /** \brief Constructor for vertices and segments */
  391     explicit GeometryType(unsigned int dim)
  392       : topologyId_(0), dim_(dim), none_(false)
  393     {
  394       assert(dim < 2);
  395     }
  396 
  397     /** \brief Constructor for vertices and segments */
  398     // We need this constructor for "int" and "unsigned int",
  399     // because otherwise GeometryType(int) would try to call the
  400     // generic GeometryType(TopologyType) constructor
  401     explicit GeometryType(int dim)
  402       : topologyId_(0), dim_(dim), none_(false)
  403     {
  404       assert(dim < 2);
  405     }
  406 
  407     /** @} */
  408 
  409 
  410     /** @name Setup Methods */
  411     /*@{*/
  412 
  413     /** \brief Make a vertex */
  414     DUNE_DEPRECATED_MSG("makeVertex() is deprecated in DUNE 2.6, please use Dune::GeometryTypes::vertex instead")
  415     void makeVertex() {
  416       none_  = false;
  417       dim_ = 0;
  418       topologyId_ = 0;
  419     }
  420 
  421     /** \brief Make a line segment */
  422     DUNE_DEPRECATED_MSG("makeLine() is deprecated in DUNE 2.6, please use Dune::GeometryTypes::line instead")
  423     void makeLine() {
  424       none_  = false;
  425       dim_ = 1;
  426       topologyId_ = 0;
  427     }
  428 
  429     /** \brief Make a triangle */
  430     DUNE_DEPRECATED_MSG("makeTriangle() is deprecated in DUNE 2.6, please use Dune::GeometryTypes::triangle instead")
  431     void makeTriangle() {
  432       none_  = false;
  433       dim_ = 2;
  434       topologyId_ = 0;
  435     }
  436 
  437     /** \brief Make a quadrilateral */
  438     DUNE_DEPRECATED_MSG("makeQuadrilateral() is deprecated in DUNE 2.6, please use Dune::GeometryTypes::quadrilateral instead")
  439     void makeQuadrilateral() {
  440       none_  = false;
  441       dim_ = 2;
  442       topologyId_ = 0b0011;
  443     }
  444 
  445     /** \brief Make a tetrahedron */
  446     DUNE_DEPRECATED_MSG("makeTetrahedron() is deprecated in DUNE 2.6, please use Dune::GeometryTypes::tetrahedron instead")
  447     void makeTetrahedron() {
  448       none_  = false;
  449       dim_ = 3;
  450       topologyId_ = 0;
  451     }
  452 
  453     /** \brief Make a pyramid */
  454     DUNE_DEPRECATED_MSG("makePyramid() is deprecated in DUNE 2.6, please use Dune::GeometryTypes::pyramid instead")
  455     void makePyramid() {
  456       none_  = false;
  457       dim_ = 3;
  458       topologyId_ = 0b0011;
  459     }
  460 
  461     /** \brief Make a prism */
  462     DUNE_DEPRECATED_MSG("makePrism() is deprecated in DUNE 2.6, please use Dune::GeometryTypes::prism instead")
  463     void makePrism() {
  464       none_  = false;
  465       dim_ = 3;
  466       topologyId_ = 0b0101;       // (1 << (dim_-1)) - 1;
  467     }
  468 
  469     /** \brief Make a hexahedron */
  470     DUNE_DEPRECATED_MSG("makeHexahedron() is deprecated in DUNE 2.6, please use Dune::GeometryTypes::hexahedron instead")
  471     void makeHexahedron() {
  472       none_  = false;
  473       dim_ = 3;
  474       topologyId_ = 0b0111;
  475     }
  476 
  477     /** \brief Make a simplex of given dimension */
  478     DUNE_DEPRECATED_MSG("makeSimplex(dim) is deprecated in DUNE 2.6, please use Dune::GeometryTypes::simplex(dim) instead")
  479     void makeSimplex(unsigned int dim) {
  480       none_  = false;
  481       dim_ = dim;
  482       topologyId_ = 0;
  483     }
  484 
  485     /** \brief Make a hypercube of given dimension */
  486     DUNE_DEPRECATED_MSG("makeCube(dim) is deprecated in DUNE 2.6, please use Dune::GeometryTypes::cube(dim) instead")
  487     void makeCube(unsigned int dim) {
  488       none_  = false;
  489       dim_ = dim;
  490       topologyId_ = ((dim>1) ? ((1 << dim) - 1) : 0);
  491     }
  492 
  493     /** \brief Make a singular of given dimension */
  494     DUNE_DEPRECATED_MSG("makeNone(dim) is deprecated in DUNE 2.6, please use Dune::GeometryTypes::none(dim) instead")
  495     void makeNone(unsigned int dim) {
  496       none_ = true;
  497       dim_ = dim;
  498       topologyId_  = 0;
  499     }
  500 
  501     /** \brief Construct the correct geometry type given the dimension and the number of vertices
  502      *  \note This code only works up to dimension 3.
  503      *        In higher dimensions the number of vertices does not uniquely identify the type of polyhedron.
  504      */
  505     void makeFromVertices(unsigned int dim, unsigned int vertices) DUNE_DEPRECATED_MSG("Use the utility function geometryTypeFromVertexCount(...) instead.")
  506     {
  507       *this = geometryTypeFromVertexCount(dim, vertices);
  508       return;
  509     }
  510 
  511     /*@}*/
  512 
  513 
  514     /** @name Query Methods */
  515     /*@{*/
  516     /** \brief Return true if entity is a vertex */
  517     constexpr bool isVertex() const {
  518       return dim_==0;
  519     }
  520 
  521     /** \brief Return true if entity is a line segment */
  522     constexpr bool isLine() const {
  523       return dim_==1;
  524     }
  525 
  526     /** \brief Return true if entity is a triangle */
  527     constexpr bool isTriangle() const {
  528       return ! none_ && dim_==2 && (topologyId_ | 1) == 0b0001;
  529     }
  530 
  531     /** \brief Return true if entity is a quadrilateral */
  532     constexpr bool isQuadrilateral() const {
  533       return ! none_ && dim_==2 && (topologyId_ | 1) == 0b0011;
  534     }
  535 
  536     /** \brief Return true if entity is a tetrahedron */
  537     constexpr bool isTetrahedron() const {
  538       return ! none_ && dim_==3 && (topologyId_ | 1) == 0b0001;
  539     }
  540 
  541     /** \brief Return true if entity is a pyramid */
  542     constexpr bool isPyramid() const {
  543       return ! none_ && dim_==3 && (topologyId_ | 1) == 0b0011;
  544     }
  545 
  546     /** \brief Return true if entity is a prism */
  547     constexpr bool isPrism() const {
  548       return ! none_ && dim_==3 && (topologyId_ | 1) == 0b0101;
  549     }
  550 
  551     /** \brief Return true if entity is a hexahedron */
  552     constexpr bool isHexahedron() const {
  553       return ! none_ && dim_==3 && (topologyId_ | 1) == 0b0111;
  554     }
  555 
  556     /** \brief Return true if entity is a simplex of any dimension */
  557     constexpr bool isSimplex() const {
  558       return ! none_ && (topologyId_ | 1) == 1;
  559     }
  560 
  561     /** \brief Return true if entity is a cube of any dimension */
  562     constexpr bool isCube() const {
  563       return ! none_ && ((topologyId_ ^ ((1 << dim_)-1)) >> 1 == 0);
  564     }
  565 
  566     /** \brief Return true if entity is a singular of any dimension */
  567     constexpr bool isNone() const {
  568       return none_;
  569     }
  570 
  571     /** \brief Return dimension of the type */
  572     constexpr unsigned int dim() const {
  573       return dim_;
  574     }
  575 
  576     /** \brief Return the topology id of the type */
  577     constexpr unsigned int id() const {
  578       return topologyId_;
  579     }
  580 
  581     /*@}*/
  582 
  583 
  584     /** @name Comparison operators */
  585 
  586     /** \brief Check for equality. This method knows that in dimension 0 and 1
  587      *  all BasicTypes are equal.
  588      */
  589     constexpr bool operator==(const GeometryType& other) const {
  590       return ( ( none_ == other.none_ )
  591                && ( ( none_ == true )
  592                     || ( ( dim_ == other.dim_ )
  593                          && ( (topologyId_ >> 1) == (other.topologyId_ >> 1) )
  594                          )
  595                     )
  596                );
  597     }
  598 
  599     /** \brief Check for inequality */
  600     constexpr bool operator!=(const GeometryType& other) const {
  601       return ! ((*this)==other);
  602     }
  603 
  604     /** \brief less-than operation for use with maps */
  605     constexpr bool operator < (const GeometryType& other) const {
  606       return ( ( none_ < other.none_ )
  607                || ( !( other.none_ < none_ )
  608                     && ( ( dim_ < other.dim_ )
  609                          || ( (other.dim_ == dim_)
  610                               && ((topologyId_ >> 1) < (other.topologyId_ >> 1) )
  611                               )
  612                          )
  613                     )
  614                );
  615     }
  616 
  617     /*@}*/
  618 
  619   };
  620 
  621   /** \brief Prints the type to an output stream */
  622   inline std::ostream& operator<< (std::ostream& s, const GeometryType& a)
  623   {
  624     if (a.isSimplex())
  625     {
  626       s << "(simplex, " << a.dim() << ")";
  627       return s;
  628     }
  629     if (a.isCube())
  630     {
  631       s << "(cube, " << a.dim() << ")";
  632       return s;
  633     }
  634     if (a.isPyramid())
  635     {
  636       s << "(pyramid, 3)";
  637       return s;
  638     }
  639     if (a.isPrism())
  640     {
  641       s << "(prism, 3)";
  642       return s;
  643     }
  644     if (a.isNone())
  645     {
  646       s << "(none, " << a.dim() << ")";
  647       return s;
  648     }
  649     s << "(other [" << a.id() << "], " << a.dim() << ")";
  650     return s;
  651   }
  652 
  653 #pragma GCC diagnostic push
  654 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  655   /** \brief Prints a GeometryType::BasicType to an output stream */
  656   inline std::ostream& operator<< (std::ostream& s, GeometryType::BasicType type)
  657   {
  658     switch (type) {
  659     case GeometryType::simplex :
  660       s << "simplex";
  661       break;
  662     case GeometryType::cube :
  663       s << "cube";
  664       break;
  665     case GeometryType::pyramid :
  666       s << "pyramid";
  667       break;
  668     case GeometryType::prism :
  669       s << "prism";
  670       break;
  671     case GeometryType::extended :
  672       s << "other";
  673     case GeometryType::none :
  674       s << "none";
  675       break;
  676     default :
  677       DUNE_THROW(Exception, "invalid GeometryType::BasicType");
  678     }
  679     return s;
  680   }
  681 #pragma GCC diagnostic pop
  682 
  683 
  684 
  685   //! Predefined GeometryTypes for common geometries
  686   /**
  687    * \ingroup GeometryType
  688    * \related GeometryType
  689    */
  690   namespace GeometryTypes {
  691 
  692     //! Returns a GeometryType representing a simplex of dimension `dim`.
  693       /**
  694        * \ingroup GeometryType
  695        */
  696     inline constexpr GeometryType simplex(unsigned int dim)
  697     {
  698       return GeometryType(0,dim,false);
  699     }
  700 
  701     //! Returns a GeometryType representing a hypercube of dimension `dim`.
  702       /**
  703        * \ingroup GeometryType
  704        */
  705     inline constexpr GeometryType cube(unsigned int dim)
  706     {
  707       return GeometryType(((dim>1) ? ((1 << dim) - 1) : 0),dim,false);
  708     }
  709 
  710     //! Returns a GeometryType representing a singular of dimension `dim`.
  711       /**
  712        * \ingroup GeometryType
  713        */
  714     inline constexpr GeometryType none(unsigned int dim)
  715     {
  716       return GeometryType(0,dim,true);
  717     }
  718 
  719 #ifndef __cpp_inline_variables
  720     namespace {
  721 #endif
  722 
  723       //! GeometryType representing a vertex.
  724       /**
  725        * \ingroup GeometryType
  726        */
  727       DUNE_INLINE_VARIABLE constexpr GeometryType vertex = GeometryType(0,0,false);
  728 
  729       //! GeometryType representing a line.
  730       /**
  731        * \ingroup GeometryType
  732        */
  733       DUNE_INLINE_VARIABLE constexpr GeometryType line = GeometryType(0,1,false);
  734 
  735       //! GeometryType representing a triangle.
  736       /**
  737        * \ingroup GeometryType
  738        */
  739       DUNE_INLINE_VARIABLE constexpr GeometryType triangle = simplex(2);
  740 
  741       //! GeometryType representing a quadrilateral (a square).
  742       /**
  743        * \ingroup GeometryType
  744        */
  745       DUNE_INLINE_VARIABLE constexpr GeometryType quadrilateral = cube(2);
  746 
  747       //! GeometryType representing a tetrahedron.
  748       /**
  749        * \ingroup GeometryType
  750        */
  751       DUNE_INLINE_VARIABLE constexpr GeometryType tetrahedron = simplex(3);
  752 
  753       //! GeometryType representing a 3D pyramid.
  754       /**
  755        * \ingroup GeometryType
  756        */
  757       DUNE_INLINE_VARIABLE constexpr GeometryType pyramid = GeometryType(0b0011,3,false);
  758 
  759       //! GeometryType representing a 3D prism.
  760       /**
  761        * \ingroup GeometryType
  762        */
  763       DUNE_INLINE_VARIABLE constexpr GeometryType prism = GeometryType(0b0101,3,false);
  764 
  765       //! GeometryType representing a hexahedron.
  766       /**
  767        * \ingroup GeometryType
  768        */
  769       DUNE_INLINE_VARIABLE constexpr GeometryType hexahedron = cube(3);
  770 
  771 #ifndef __cpp_inline_variables
  772     }
  773 #endif
  774 
  775   }
  776 
  777 
  778 } // namespace Dune
  779 
  780 // include utility header needed for deprecated makeFromVertices
  781 #include "utility/typefromvertexcount.hh"
  782 
  783 #endif // DUNE_GEOMETRY_TYPE_HH