DUNE PDELab (git)

topologyutility.hh
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
7
8namespace 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
35 isSimplex ? GeometryType::simplex
36 : (
37 isCube ? GeometryType::cube
39 );
40 };
41
42
48 inline Dune::GeometryType geometryTypeFromBasicType(Dune::GeometryType::BasicType basicType, int dim){
49
50 unsigned int topologyId(0);
51
52 if (dim > 1){
53 switch( basicType )
54 {
56 topologyId = 0;
57 break;
59 topologyId = ((1 << dim) - 1);
60 break;
62 if (dim == 3)
63 topologyId = 0b0011;
64 else
66 "Invalid basic geometry type: no pyramids for dimension " << dim << "." );
67 break;
69 if (dim == 3)
70 topologyId = 0b0101;
71 else
73 "Invalid basic geometry type: no prisms for dimension " << dim << "." );
74 break;
76 break;
77 default :
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
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
BasicType
Each entity can be tagged by one of these basic types plus its space dimension.
Definition: type.hh:120
@ cube
Cube element in any nonnegative dimension.
Definition: type.hh:122
@ simplex
Simplicial element in any nonnegative dimension.
Definition: type.hh:121
@ pyramid
Four sided pyramid in three dimensions.
Definition: type.hh:123
@ none
Even more general topology, cannot be specified by a topologyId. Two GeometryTypes with 'none' type a...
Definition: type.hh:126
@ prism
Prism element in three dimensions.
Definition: type.hh:124
Default exception class for range errors.
Definition: exceptions.hh:254
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Utility TMP for determining the BasicType of a geometry from its dimension and topology id.
Definition: topologyutility.hh:26
static const GeometryType::BasicType value
The BasicType of Topology.
Definition: topologyutility.hh:34
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)