Dune Core Modules (2.4.1)

referenceelements.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
4#ifndef DUNE_GEOMETRY_GENERICGEOMETRY_REFERENCEELEMENTS_HH
5#define DUNE_GEOMETRY_GENERICGEOMETRY_REFERENCEELEMENTS_HH
6
11#include <dune/common/array.hh>
15
16#include <dune/geometry/genericgeometry/referencedomain.hh>
17
18namespace Dune
19{
20
21 namespace GenericGeometry
22 {
23
24 // ReferenceElement
25 // ----------------
26
27 template< class Topology, class ctype >
28 struct ReferenceElement
29 {
30 static const unsigned int topologyId = Topology :: id;
31 static const unsigned int dimension = Topology :: dimension;
32
33 static const unsigned int numCorners = Topology :: numCorners;
34 static const unsigned int numNormals = ReferenceDomain< Topology > :: numNormals;
35
36 typedef FieldVector< ctype, dimension > CoordinateType;
37
38 template< unsigned int codim >
39 struct Codim
40 {
41 enum { size = Size< Topology, codim > :: value };
42 };
43
44 template< unsigned int codim, unsigned int subcodim >
45 static unsigned int subNumbering ( unsigned int i, unsigned int j )
46 {
47 return SubTopologyNumbering< Topology, codim, subcodim > :: number( i, j );
48 }
49
50 template< unsigned int codim, unsigned int subcodim >
51 static unsigned int size ( unsigned int i )
52 {
53 return SubTopologySize< Topology, codim, subcodim > :: size( i );
54 }
55
59 baryCenter ()
60 {
61 return instance().baryCenter_;
62 }
63
64 static const CoordinateType &corner ( unsigned int i )
65 {
66 assert( i < numCorners );
67 return instance().corners_[ i ];
68 }
69
70 static bool checkInside ( const CoordinateType &x )
71 {
72 return ReferenceDomain< Topology >::checkInside( x );
73 }
74
75 static const CoordinateType &
76 integrationOuterNormal ( unsigned int i )
77 {
78 assert( i < numNormals );
79 return instance().normals_[ i ];
80 }
81
82 static ctype volume ()
83 {
84 return ReferenceDomain< Topology > :: template volume< ctype >();
85 }
86
87 DUNE_EXPORT static const ReferenceElement &instance ()
88 {
89 static ReferenceElement inst;
90 return inst;
91 }
92
93 private:
94 class BaryCenterArray;
95
96 ReferenceElement ()
97 {
98 for( unsigned int i = 0; i < numCorners; ++i )
99 ReferenceDomain< Topology > :: corner( i, corners_[ i ] );
100 for( unsigned int i = 0; i < numNormals; ++i )
101 ReferenceDomain< Topology > :: integrationOuterNormal( i, normals_[ i ] );
102
103 // Compute the element barycenter
104 typedef SubTopologyNumbering< Topology, 0, dimension > Numbering;
105 typedef SubTopologySize< Topology, 0, dimension > Size;
106
107 baryCenter_ = 0;
108 const unsigned int numCorners = Size :: size( 0 );
109 for( unsigned int k = 0; k < numCorners; ++k )
110 {
111 unsigned int j = Numbering :: number( 0, k );
112
113 CoordinateType y;
114 ReferenceDomain< Topology > :: corner( j, y );
115 baryCenter_ += y;
116 }
117 baryCenter_ *= ctype( 1 ) / ctype( numCorners );
118 }
119
120 Dune::array< CoordinateType, numCorners > corners_;
121 CoordinateType baryCenter_;
122 Dune::array< CoordinateType, numNormals > normals_;
123 };
124
125 }
126
127}
128
129#endif // DUNE_GEOMETRY_GENERICGEOMETRY_REFERENCEELEMENTS_HH
Fallback implementation of the std::array class (a static array)
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignment.hh:10
Traits for type conversions and type information.
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:18
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)