dune-grid  2.3.1
geometryreference.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 #ifndef DUNE_GRID_GEOMETRYREFERENCE_HH
4 #define DUNE_GRID_GEOMETRYREFERENCE_HH
5 
10 #include <dune/common/typetraits.hh>
11 
12 #include <dune/geometry/type.hh>
13 
15 
16 namespace Dune
17 {
18 
19  // Internal Forward Declarations
20  // -----------------------------
21 
22  template< int mydim, int cdim, class Grid >
23  class GlobalGeometryReference;
24 
25  template< int mydim, int cdim, class Grid >
26  class LocalGeometryReference;
27 
28 
29 
30  // FacadeOptions
31  // -------------
32 
33  namespace FacadeOptions
34  {
35 
36  template< int mydim, int cdim, class GridImp, template< int, int, class > class GeometryImp >
37  struct StoreGeometryReference;
38 
39  template< int mydim, int cdim, class Grid >
41  {
42  static const bool v = false;
43  };
44 
45  template< int mydim, int cdim, class Grid >
47  {
48  static const bool v = false;
49  };
50 
51  } // namespace FacadeOptions
52 
53 
54 
55  // GeometryReference
56  // -----------------
57 
58  template< class Implementation >
60  {
62 
63  public:
66 
67  typedef typename Implementation::ctype ctype;
68 
69  typedef typename Implementation::LocalCoordinate LocalCoordinate;
70  typedef typename Implementation::GlobalCoordinate GlobalCoordinate;
71 
72  typedef typename Implementation::JacobianInverseTransposed JacobianInverseTransposed;
73  typedef typename Implementation::JacobianTransposed JacobianTransposed;
74 
75  explicit GeometryReference ( const Implementation &impl )
76  : impl_( &impl )
77  {}
78 
79  GeometryType type () const { return impl().type(); }
80 
81  bool affine() const { return impl().affine(); }
82 
83  int corners () const { return impl().corners(); }
84  GlobalCoordinate corner ( int i ) const { return impl().corner( i ); }
85  GlobalCoordinate center () const { return impl().center(); }
86 
88  {
89  return impl().global( local );
90  }
91 
93  {
94  return impl().local( global );
95  }
96 
98  {
99  return impl().integrationElement( local );
100  }
101 
102  ctype volume () const { return impl().volume(); }
103 
105  {
106  return impl().jacobianTransposed( local );
107  }
108 
110  {
111  return impl().jacobianInverseTransposed( local );
112  }
113 
114  const Implementation &impl () const { return *impl_; }
115 
116  private:
117  const Implementation *impl_;
118  };
119 
120 
121 
122  // GlobalGeometryReference
123  // -----------------------
124 
125  template< int mydim, int cdim, class Grid >
127  : public GeometryReference< typename remove_const< Grid >::type::Traits::template Codim< remove_const< Grid >::type::dimension - mydim >::GeometryImpl >
128  {
129  typedef typename remove_const< Grid >::type::Traits::template Codim< remove_const< Grid >::type::dimension - mydim >::GeometryImpl Implementation;
130 
131  public:
132  GlobalGeometryReference ( const Implementation &impl )
133  : GeometryReference< Implementation >( impl )
134  {}
135  };
136 
137 
138 
139  // LocalGeometryReference
140  // -----------------------
141 
142  template< int mydim, int cdim, class Grid >
144  : public GeometryReference< typename remove_const< Grid >::type::Traits::template Codim< remove_const< Grid >::type::dimension - mydim >::LocalGeometryImpl >
145  {
146  typedef typename remove_const< Grid >::type::Traits::template Codim< remove_const< Grid >::type::dimension - mydim >::LocalGeometryImpl Implementation;
147 
148  public:
149  LocalGeometryReference ( const Implementation &impl )
150  : GeometryReference< Implementation >( impl )
151  {}
152  };
153 
154 
155 
156  // Definitions of GeometryReference
157  // --------------------------------
158 
159  template< class Implementation >
160  const int GeometryReference< Implementation >::mydimension;
161 
162  template< class Implementation >
163  const int GeometryReference< Implementation >::coorddimension;
164 
165 } // namespace Dune
166 
167 #endif // #ifndef DUNE_GRID_GEOMETRYREFERENCE_HH