dune-geometry  2.4
genericgeometry/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>
12 #include <dune/common/fvector.hh>
13 #include <dune/common/typetraits.hh>
14 #include <dune/common/visibility.hh>
15 
17 
18 namespace Dune
19 {
20 
21  namespace GenericGeometry
22  {
23 
24  // ReferenceElement
25  // ----------------
26 
27  template< class Topology, class ctype >
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;
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  {
48  }
49 
50  template< unsigned int codim, unsigned int subcodim >
51  static unsigned int size ( unsigned int i )
52  {
54  }
55 
58  static const FieldVector< ctype, dimension > &
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  {
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 
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 )
102 
103  // Compute the element barycenter
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;
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
Definition: quadraturerules.hh:88
static unsigned int size(unsigned int i)
Definition: genericgeometry/referenceelements.hh:51
static bool checkInside(const FieldVector< ctype, dimension > &x)
Definition: referencedomain.hh:257
Definition: referencedomain.hh:27
static bool checkInside(const CoordinateType &x)
Definition: genericgeometry/referenceelements.hh:70
Definition: affinegeometry.hh:18
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:533
static const CoordinateType & integrationOuterNormal(unsigned int i)
Definition: genericgeometry/referenceelements.hh:76
static ctype volume()
Definition: genericgeometry/referenceelements.hh:82
static DUNE_EXPORT const ReferenceElement & instance()
Definition: genericgeometry/referenceelements.hh:87
Definition: subtopologies.hh:35
static const unsigned int dimension
Definition: genericgeometry/referenceelements.hh:31
Definition: genericgeometry/referenceelements.hh:39
Definition: genericgeometry/referenceelements.hh:41
static const FieldVector< ctype, dimension > & baryCenter()
Return the element barycenter.
Definition: genericgeometry/referenceelements.hh:59
Statically compute the number of subentities of a given codimension.
Definition: subtopologies.hh:23
static unsigned int subNumbering(unsigned int i, unsigned int j)
Definition: genericgeometry/referenceelements.hh:45
static const unsigned int topologyId
Definition: genericgeometry/referenceelements.hh:30
static const unsigned int numNormals
Definition: genericgeometry/referenceelements.hh:34
Definition: genericgeometry/referenceelements.hh:28
static const CoordinateType & corner(unsigned int i)
Definition: genericgeometry/referenceelements.hh:64
static const unsigned int numCorners
Definition: genericgeometry/referenceelements.hh:33
FieldVector< ctype, dimension > CoordinateType
Definition: genericgeometry/referenceelements.hh:36
Definition: subtopologies.hh:29
static unsigned int size(unsigned int i)
Definition: subtopologies.hh:303
static void corner(unsigned int i, FieldVector< ctype, dimension > &x)
Definition: referencedomain.hh:250