Loading...
Searching...
No Matches
typefromvertexcount.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#ifndef DUNE_GEOMETRY_TYPE_FROM_VERTEX_COUNT_HH
#define DUNE_GEOMETRY_TYPE_FROM_VERTEX_COUNT_HH
#include <dune/geometry/type.hh>
namespace Dune {
inline
GeometryType geometryTypeFromVertexCount(unsigned int dim, unsigned int vertices)
{
switch (dim)
{
case 0 :
return GeometryTypes::vertex;
case 1 :
return GeometryTypes::line;
case 2 :
switch (vertices) {
case 3 :
return GeometryTypes::triangle;
case 4 :
return GeometryTypes::quadrilateral;
default :
DUNE_THROW(NotImplemented, "2d elements with " << vertices << " corners are not supported!");
}
case 3 :
switch (vertices) {
case 4 :
return GeometryTypes::tetrahedron;
case 5 :
return GeometryTypes::pyramid;
case 6 :
return GeometryTypes::prism;
case 8 :
return GeometryTypes::hexahedron;
default :
DUNE_THROW(NotImplemented, "3d elements with " << vertices << " corners are not supported!");
}
default :
DUNE_THROW(NotImplemented, "geometryTypeFromVertexCount works only up to dim=3");
}
}
}
#endif // DUNE_GEOMETRY_TYPE_FROM_VERTEX_COUNT_HH
type.hh
A unique label for each type of element that can occur in a grid.
Dune::GeometryTypes::line
constexpr GeometryType line
GeometryType representing a line.
Definition type.hh:498
Dune::GeometryTypes::prism
constexpr GeometryType prism
GeometryType representing a 3D prism.
Definition type.hh:528
Dune::GeometryTypes::triangle
constexpr GeometryType triangle
GeometryType representing a triangle.
Definition type.hh:504
Dune::GeometryTypes::quadrilateral
constexpr GeometryType quadrilateral
GeometryType representing a quadrilateral (a square).
Definition type.hh:510
Dune::GeometryTypes::hexahedron
constexpr GeometryType hexahedron
GeometryType representing a hexahedron.
Definition type.hh:534
Dune::GeometryTypes::pyramid
constexpr GeometryType pyramid
GeometryType representing a 3D pyramid.
Definition type.hh:522
Dune::GeometryTypes::tetrahedron
constexpr GeometryType tetrahedron
GeometryType representing a tetrahedron.
Definition type.hh:516
Dune::GeometryTypes::vertex
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition type.hh:492
Dune
Definition affinegeometry.hh:22
Dune::geometryTypeFromVertexCount
GeometryType geometryTypeFromVertexCount(unsigned int dim, unsigned int vertices)
Utility function to construct the correct geometry type given the dimension and the number of vertice...
Definition typefromvertexcount.hh:17
Dune::GeometryType
Unique label for each type of entities that can occur in DUNE grids.
Definition type.hh:114