3 #ifndef DUNE_GEOMETRY_TYPE_HH
4 #define DUNE_GEOMETRY_TYPE_HH
12 #include <dune/common/exceptions.hh>
13 #include <dune/common/unused.hh>
48 unsigned int topologyId_;
51 unsigned char dim_ : 7;
59 : topologyId_(0), dim_(0), none_(true)
64 : topologyId_(0), dim_(dim), none_((basicType ==
GeometryType::
none) ? true : false)
80 DUNE_THROW( RangeError,
81 "Invalid basic geometry type: no pyramids for dimension " << dim <<
"." );
87 DUNE_THROW( RangeError,
88 "Invalid basic geometry type: no prisms for dimension " << dim <<
"." );
93 DUNE_THROW( RangeError,
94 "Invalid basic geometry type: " << basicType <<
" for dimension " << dim <<
"." );
104 : topologyId_(topologyId), dim_(dim), none_(false)
117 template<
class TopologyType>
119 : topologyId_(TopologyType::
id), dim_(TopologyType::dimension), none_(false)
121 DUNE_UNUSED_PARAMETER(t);
126 : topologyId_(0), dim_(dim), none_(false)
136 : topologyId_(0), dim_(dim), none_(false)
203 topologyId_ = ((dim>1) ? ((1 << dim) - 1) : 0);
236 DUNE_THROW(NotImplemented,
"2d elements with " << vertices <<
" corners are not supported!");
253 DUNE_THROW(NotImplemented,
"3d elements with " << vertices <<
" corners are not supported!");
256 DUNE_THROW(NotImplemented,
"makeFromVertices only implemented up to 3d");
277 return ! none_ && dim_==2 && (topologyId_ | 1) ==
b0001;
282 return ! none_ && dim_==2 && (topologyId_ | 1) ==
b0011;
287 return ! none_ && dim_==3 && (topologyId_ | 1) ==
b0001;
292 return ! none_ && dim_==3 && (topologyId_ | 1) ==
b0011;
297 return ! none_ && dim_==3 && (topologyId_ | 1) ==
b0101;
302 return ! none_ && dim_==3 && (topologyId_ | 1) ==
b0111;
307 return ! none_ && (topologyId_ | 1) == 1;
312 return ! none_ && ((topologyId_ ^ ((1 << dim_)-1)) >> 1 == 0);
321 unsigned int dim()
const {
326 unsigned int id()
const {
336 return ( ( none_ == other.none_ )
337 && ( ( none_ ==
true )
338 || ( ( dim_ == other.dim_ )
339 && ( (topologyId_ >> 1) == (other.topologyId_ >> 1) )
347 return ! ((*this)==other);
352 return ( ( none_ < other.none_ )
353 || ( !( other.none_ < none_ )
354 && ( ( dim_ < other.dim_ )
355 || ( (other.dim_ == dim_)
356 && ((topologyId_ >> 1) < (other.topologyId_ >> 1) )
369 s <<
"(simplex, " << a.
dim() <<
")";
374 s <<
"(cube, " << a.
dim() <<
")";
389 s <<
"(none, " << a.
dim() <<
")";
392 s <<
"(other [" << a.
id() <<
"], " << a.
dim() <<
")";
418 DUNE_THROW(Exception,
"invalid GeometryType::BasicType");
424 #endif // DUNE_GEOMETRY_TYPE_HH
void makeCube(unsigned int dim)
Make a hypercube of given dimension.
Definition: type.hh:200
void makeNone(unsigned int dim)
Make a singular of given dimension.
Definition: type.hh:207
void makePrism()
Make a prism.
Definition: type.hh:181
unsigned int id() const
Return the topology id the type.
Definition: type.hh:326
bool isCube() const
Return true if entity is a cube of any dimension.
Definition: type.hh:311
BasicType
Each entity can be tagged by one of these basic types plus its space dimension.
Definition: type.hh:29
GeometryType(unsigned int dim)
Constructor for vertices and segments.
Definition: type.hh:125
bool operator<(const GeometryType &other) const
less-than operation for use with maps
Definition: type.hh:351
bool operator!=(const GeometryType &other) const
Check for inequality.
Definition: type.hh:346
void makeSimplex(unsigned int dim)
Make a simplex of given dimension.
Definition: type.hh:193
void makeVertex()
Make a vertex.
Definition: type.hh:145
Definition: affinegeometry.hh:18
void makeQuadrilateral()
Make a quadrilateral.
Definition: type.hh:164
void makeTetrahedron()
Make a tetrahedron.
Definition: type.hh:169
GeometryType(unsigned int topologyId, unsigned int dim)
Constructor, using the topologyId (integer) and the dimension.
Definition: type.hh:103
bool isHexahedron() const
Return true if entity is a hexahedron.
Definition: type.hh:301
bool isLine() const
Return true if entity is a line segment.
Definition: type.hh:271
Generic element in any nonnegative dimension.
Definition: type.hh:35
bool isPrism() const
Return true if entity is a prism.
Definition: type.hh:296
bool isPyramid() const
Return true if entity is a pyramid.
Definition: type.hh:291
bool isQuadrilateral() const
Return true if entity is a quadrilateral.
Definition: type.hh:281
bool isTetrahedron() const
Return true if entity is a tetrahedron.
Definition: type.hh:286
bool isVertex() const
Return true if entity is a vertex.
Definition: type.hh:266
void makeHexahedron()
Make a hexahedron.
Definition: type.hh:188
GeometryType(BasicType basicType, unsigned int dim)
Constructor, using the basic type and the dimension.
Definition: type.hh:63
bool isNone() const
Return true if entity is a singular of any dimension.
Definition: type.hh:316
bool isTriangle() const
Return true if entity is a triangle.
Definition: type.hh:276
GeometryType(int dim)
Constructor for vertices and segments.
Definition: type.hh:135
void makeTriangle()
Make a triangle.
Definition: type.hh:159
Prism element in three dimensions.
Definition: type.hh:33
GeometryType(TopologyType t)
Constructor from static TopologyType class.
Definition: type.hh:118
Four sided pyramid in three dimensions.
Definition: type.hh:32
void makeFromVertices(unsigned int dim, unsigned int vertices)
Construct the correct geometry type given the dimension and the number of vertices.
Definition: type.hh:217
Simplicial element in any nonnegative dimension.
Definition: type.hh:30
GeometryType()
Default constructor, not initializing anything.
Definition: type.hh:58
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:24
unsigned int dim() const
Return dimension of the type.
Definition: type.hh:321
Cube element in any nonnegative dimension.
Definition: type.hh:31
Binary
A few binary constants.
Definition: type.hh:39
void makePyramid()
Make a pyramid.
Definition: type.hh:174
Other, more general geometry, representable as topologyId.
Definition: type.hh:34
std::ostream & operator<<(std::ostream &s, const GeometryType &a)
Prints the type to an output stream.
Definition: type.hh:365
bool isSimplex() const
Return true if entity is a simplex of any dimension.
Definition: type.hh:306
void makeLine()
Make a line segment.
Definition: type.hh:152
bool operator==(const GeometryType &other) const
Check for equality. This method knows that in dimension 0 and 1 all BasicTypes are equal...
Definition: type.hh:335