DUNE-FEM (unstable)

geometry.hh
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
10#include <dune/fem/gridpart/common/capabilities.hh>
11#include <dune/fem/gridpart/geogridpart/cornerstorage.hh>
12
13namespace Dune
14{
15
16 namespace Fem
17 {
18
19 // GeoGeometryTraits
20 // -----------------
21
22 template< class GridFamily >
23 class GeoGeometryTraits
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 Dune::Impl::FieldMatrixHelper< ctype > MatrixHelper;
35
36 static ctype tolerance () { return 16 * std::numeric_limits< ctype >::epsilon(); }
37
38 template< int mydim, int cdim >
39 struct CornerStorage
40 {
41 typedef GeoCornerStorage< mydim, cdim, GridFamily > Type;
42 };
43
44 template< int mydim >
45 struct hasSingleGeometryType
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 >
56 class GeoGeometry
57 {
58 typedef GeoGeometry< mydim, cdim, GridFamily > ThisType;
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
78 typedef typename Mapping::Jacobian Jacobian;
79 typedef typename Mapping::JacobianInverse JacobianInverse;
80
81 GeoGeometry ()
82 : mapping_( nullptr )
83 {}
84
85 template< class CoordVector >
86 GeoGeometry ( const GeometryType &type, const CoordVector &coords )
87 {
88 assert( int( type.dim() ) == mydimension );
89 mapping_ = new( mappingStorage_ ) Mapping( type, coords );
90 }
91
92 GeoGeometry ( const ThisType &other )
93 {
94 if( other.mapping_ )
95 mapping_ = new( mappingStorage_ ) Mapping( *other.mapping_ );
96 else
97 mapping_ = nullptr;
98 }
99
100 ~GeoGeometry ()
101 {
102 if( mapping_ )
103 mapping_->~Mapping();
104 }
105
106 const ThisType &operator= ( const ThisType &other )
107 {
108 if( mapping_ )
109 mapping_->~Mapping();
110 if( other.mapping_ )
111 mapping_ = new( mappingStorage_ ) Mapping( *other.mapping_ );
112 else
113 mapping_ = nullptr;
114 return *this;
115 }
116
117 operator bool () const { return bool( mapping_ ); }
118
119 bool affine () const { return mapping_->affine(); }
120 GeometryType type () const { return mapping_->type(); }
121
122 int corners () const { return mapping_->corners(); }
123 GlobalCoordinate corner ( const int i ) const { return mapping_->corner( i ); }
124 GlobalCoordinate center () const { return mapping_->center(); }
125
126 GlobalCoordinate global ( const LocalCoordinate &local ) const { return mapping_->global( local ); }
127 LocalCoordinate local ( const GlobalCoordinate &global ) const { return mapping_->local( global ); }
128
129 ctype integrationElement ( const LocalCoordinate &local ) const { return mapping_->integrationElement( local ); }
130 ctype volume () const { return mapping_->volume(); }
131
132 JacobianTransposed jacobianTransposed ( const LocalCoordinate &local ) const { return mapping_->jacobianTransposed( local ); }
133 JacobianInverseTransposed jacobianInverseTransposed ( const LocalCoordinate &local ) const { return mapping_->jacobianInverseTransposed( local ); }
134
135 Jacobian jacobian ( const LocalCoordinate &local ) const { return mapping_->jacobian( local ); }
136 JacobianInverse jacobianInverse ( const LocalCoordinate &local ) const { return mapping_->jacobianInverse( local ); }
137
138 private:
139 Mapping* mapping_;
140 char mappingStorage_[ sizeof( Mapping ) ];
141 };
142
143 } // namespace Fem
144
145
146} // namespace Dune
147
148#endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_GEOMETRY_HH
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)