dune-fem  2.4.1-rc
geogridpart/geometry.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_GEOMETRY_HH
2 #define DUNE_FEM_GRIDPART_GEOGRIDPART_GEOMETRY_HH
3 
4 #include <type_traits>
5 
6 #include <dune/geometry/multilineargeometry.hh>
7 
8 #include <dune/grid/geometrygrid/geometry.hh>
9 
12 
13 namespace Dune
14 {
15 
16  namespace Fem
17  {
18 
19  // GeoGeometryTraits
20  // -----------------
21 
22  template< class GridFamily >
24  {
25  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
26 
27  typedef typename Traits::HostGridPartType HostGridPartType;
28 
29  static const int dimension = std::remove_const< GridFamily >::type::dimension;
30 
31  public:
32  typedef typename std::remove_const< GridFamily >::type::ctype ctype;
33 
34  typedef GenericGeometry::MatrixHelper< GenericGeometry::DuneCoordTraits< ctype > > MatrixHelper;
35 
36  static ctype tolerance () { return 16 * std::numeric_limits< ctype >::epsilon(); }
37 
38  template< int mydim, int cdim >
40  {
42  };
43 
44  template< int mydim >
46  : public Dune::GeoGrid::InferHasSingleGeometryType< GridPartCapabilities::hasSingleGeometryType< HostGridPartType >, dimension, mydim >
47  {};
48  };
49 
50 
51 
52  // GeoGeometry
53  // -----------
54 
55  template< int mydim, int cdim, class GridFamily >
57  {
59 
60  public:
61  typedef typename std::remove_const< GridFamily >::type::ctype ctype;
62 
63  static const int mydimension = mydim;
64  static const int coorddimension = cdim;
65  static const int dimension = std::remove_const< GridFamily >::type::dimension;
66  static const int codimension = dimension - mydimension;
67 
68  protected:
69  typedef CachedMultiLinearGeometry< ctype, mydimension, coorddimension, GeoGeometryTraits< GridFamily > > Mapping;
70 
71  public:
72  typedef typename Mapping::LocalCoordinate LocalCoordinate;
73  typedef typename Mapping::GlobalCoordinate GlobalCoordinate;
74 
75  typedef typename Mapping::JacobianTransposed JacobianTransposed;
76  typedef typename Mapping::JacobianInverseTransposed JacobianInverseTransposed;
77 
79  : mapping_( nullptr )
80  {}
81 
82  template< class CoordVector >
83  GeoGeometry ( const GeometryType &type, const CoordVector &coords )
84  {
85  assert( int( type.dim() ) == mydimension );
86  mapping_ = new( mappingStorage_ ) Mapping( type, coords );
87  }
88 
89  GeoGeometry ( const ThisType &other )
90  {
91  if( other.mapping_ )
92  mapping_ = new( mappingStorage_ ) Mapping( *other.mapping_ );
93  else
94  mapping_ = nullptr;
95  }
96 
98  {
99  if( mapping_ )
100  mapping_->~Mapping();
101  }
102 
103  const ThisType &operator= ( const ThisType &other )
104  {
105  if( mapping_ )
106  mapping_->~Mapping();
107  if( other.mapping_ )
108  mapping_ = new( mappingStorage_ ) Mapping( *other.mapping_ );
109  else
110  mapping_ = nullptr;
111  return *this;
112  }
113 
114  operator bool () const { return bool( mapping_ ); }
115 
116  bool affine () const { return mapping_->affine(); }
117  GeometryType type () const { return mapping_->type(); }
118 
119  int corners () const { return mapping_->corners(); }
120  GlobalCoordinate corner ( const int i ) const { return mapping_->corner( i ); }
121  GlobalCoordinate center () const { return mapping_->center(); }
122 
123  GlobalCoordinate global ( const LocalCoordinate &local ) const { return mapping_->global( local ); }
124  LocalCoordinate local ( const GlobalCoordinate &global ) const { return mapping_->local( global ); }
125 
126  ctype integrationElement ( const LocalCoordinate &local ) const { return mapping_->integrationElement( local ); }
127  ctype volume () const { return mapping_->volume(); }
128 
129  JacobianTransposed jacobianTransposed ( const LocalCoordinate &local ) const { return mapping_->jacobianTransposed( local ); }
130  JacobianInverseTransposed jacobianInverseTransposed ( const LocalCoordinate &local ) const { return mapping_->jacobianInverseTransposed( local ); }
131 
132  private:
133  Mapping* mapping_;
134  char mappingStorage_[ sizeof( Mapping ) ];
135  };
136 
137  } // namespace Fem
138 
139 
140 } // namespace Dune
141 
142 #endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_GEOMETRY_HH
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Definition: geogridpart/geometry.hh:130
LocalCoordinate local(const GlobalCoordinate &global) const
Definition: geogridpart/geometry.hh:124
Definition: geogridpart/geometry.hh:45
bool affine() const
Definition: geogridpart/geometry.hh:116
ctype volume() const
Definition: geogridpart/geometry.hh:127
GeoGeometry(const ThisType &other)
Definition: geogridpart/geometry.hh:89
Mapping::LocalCoordinate LocalCoordinate
Definition: geogridpart/geometry.hh:72
GlobalCoordinate corner(const int i) const
Definition: geogridpart/geometry.hh:120
GeometryType type() const
Definition: geogridpart/geometry.hh:117
~GeoGeometry()
Definition: geogridpart/geometry.hh:97
GlobalCoordinate center() const
Definition: geogridpart/geometry.hh:121
int corners() const
Definition: geogridpart/geometry.hh:119
ctype integrationElement(const LocalCoordinate &local) const
Definition: geogridpart/geometry.hh:126
Mapping::JacobianInverseTransposed JacobianInverseTransposed
Definition: geogridpart/geometry.hh:76
GeoCornerStorage< mydim, cdim, GridFamily > Type
Definition: geogridpart/geometry.hh:41
Definition: coordinate.hh:4
std::remove_const< GridFamily >::type::ctype ctype
Definition: geogridpart/geometry.hh:32
static ctype tolerance()
Definition: geogridpart/geometry.hh:36
std::remove_const< GridFamily >::type::ctype ctype
Definition: geogridpart/geometry.hh:61
CachedMultiLinearGeometry< ctype, mydimension, coorddimension, GeoGeometryTraits< GridFamily > > Mapping
Definition: geogridpart/geometry.hh:69
GenericGeometry::MatrixHelper< GenericGeometry::DuneCoordTraits< ctype > > MatrixHelper
Definition: geogridpart/geometry.hh:34
Definition: geogridpart/geometry.hh:23
GeoGeometry(const GeometryType &type, const CoordVector &coords)
Definition: geogridpart/geometry.hh:83
Mapping::GlobalCoordinate GlobalCoordinate
Definition: geogridpart/geometry.hh:73
Mapping::JacobianTransposed JacobianTransposed
Definition: geogridpart/geometry.hh:75
GlobalCoordinate global(const LocalCoordinate &local) const
Definition: geogridpart/geometry.hh:123
Definition: cornerstorage.hh:281
Definition: geogridpart/geometry.hh:39
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Definition: geogridpart/geometry.hh:129
GeoGeometry()
Definition: geogridpart/geometry.hh:78
Definition: geogridpart/geometry.hh:56