1 #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_GEOMETRY_HH 2 #define DUNE_FEM_GRIDPART_IDGRIDPART_GEOMETRY_HH 3 4 #include <type_traits> 5 6 #include <dune/grid/common/geometry.hh> 7 8 namespace Dune 9 { 10 11 namespace Fem 12 { 13 14 // Internal Forward Declarations 15 // ----------------------------- 16 17 template< int, int, class > class IdGeometry; 18 template< int, int, class > class IdLocalGeometry; 19 20 21 // IdBasicGeometry 22 // --------------- 23 24 template< class Traits > 25 struct IdBasicGeometry 26 { 27 typedef typename Traits::HostGeometryType HostGeometryType; 28 29 static const int mydimension = HostGeometryType::mydimension; 30 static const int coorddimension = HostGeometryType::coorddimension; 31 32 typedef typename HostGeometryType::ctype ctype; 33 typedef FieldVector< ctype, mydimension > LocalVector; 34 typedef FieldVector< ctype, coorddimension > GlobalVector; 35 36 typedef typename HostGeometryType::JacobianTransposed JacobianTransposed; 37 typedef typename HostGeometryType::JacobianInverseTransposed JacobianInverseTransposed; 38 IdBasicGeometryDune::Fem::IdBasicGeometry39 IdBasicGeometry ( const HostGeometryType &hostGeometry ) 40 : hostGeometry_( hostGeometry ) 41 {} 42 operator boolDune::Fem::IdBasicGeometry43 operator bool () const { return bool( hostGeometry_ ); } 44 typeDune::Fem::IdBasicGeometry45 GeometryType type () const { return hostGeometry_.type(); } affineDune::Fem::IdBasicGeometry46 bool affine () const { return hostGeometry_.affine(); } 47 cornersDune::Fem::IdBasicGeometry48 int corners () const { return hostGeometry_.corners(); } cornerDune::Fem::IdBasicGeometry49 GlobalVector corner ( const int i ) const { return hostGeometry_.corner( i ); } centerDune::Fem::IdBasicGeometry50 GlobalVector center () const { return hostGeometry_.center(); } 51 globalDune::Fem::IdBasicGeometry52 GlobalVector global ( const LocalVector &local ) const { return hostGeometry_.global( local ); } localDune::Fem::IdBasicGeometry53 LocalVector local ( const GlobalVector &global ) const { return hostGeometry_.local( global ); } 54 integrationElementDune::Fem::IdBasicGeometry55 ctype integrationElement ( const LocalVector &local ) const { return hostGeometry_.integrationElement( local ); } volumeDune::Fem::IdBasicGeometry56 ctype volume () const { return hostGeometry_.volume(); } 57 jacobianTransposedDune::Fem::IdBasicGeometry58 JacobianTransposed jacobianTransposed ( const LocalVector &local ) const 59 { 60 return hostGeometry_.jacobianTransposed( local ); 61 } 62 jacobianInverseTransposedDune::Fem::IdBasicGeometry63 JacobianInverseTransposed jacobianInverseTransposed ( const LocalVector &local ) const 64 { 65 return hostGeometry_.jacobianInverseTransposed( local ); 66 } 67 68 private: 69 HostGeometryType hostGeometry_; 70 }; 71 72 73 74 // IdGeometryTraits 75 // ---------------- 76 77 template< int mydim, class GridFamily > 78 struct IdGeometryTraits 79 { 80 typedef typename std::remove_const< GridFamily >::type::Traits::HostGridPartType HostGridPartType; 81 82 static const int dimension = HostGridPartType::dimension; 83 static const int mydimension = mydim; 84 static const int codimension = dimension - mydimension; 85 86 typedef typename HostGridPartType::template Codim< codimension >::GeometryType HostGeometryType; 87 }; 88 89 90 91 // IdGeometry 92 // ---------- 93 94 template< int mydim, int cdim, class GridFamily > 95 class IdGeometry 96 : public IdBasicGeometry< IdGeometryTraits< mydim, GridFamily > > 97 { 98 typedef IdBasicGeometry< IdGeometryTraits< mydim, GridFamily > > Base; 99 100 public: 101 typedef typename Base::HostGeometryType HostGeometryType; 102 IdGeometry()103 IdGeometry () 104 {} 105 IdGeometry(const HostGeometryType & hostGeometry)106 IdGeometry ( const HostGeometryType &hostGeometry ) 107 : Base( hostGeometry ) 108 {} 109 }; 110 111 112 113 // IdLocalGeometryTraits 114 // --------------------- 115 116 template< int mydim, class GridFamily > 117 struct IdLocalGeometryTraits 118 { 119 typedef typename std::remove_const< GridFamily >::type::Traits::HostGridPartType HostGridPartType; 120 121 static const int dimension = HostGridPartType::dimension; 122 static const int mydimension = mydim; 123 static const int codimension = dimension - mydimension; 124 125 typedef typename HostGridPartType::template Codim< codimension >::LocalGeometryType HostGeometryType; 126 }; 127 128 129 130 // IdLocalGeometry 131 // ------------------- 132 133 template< int mydim, int cdim, class GridFamily > 134 class IdLocalGeometry 135 : public IdBasicGeometry< IdLocalGeometryTraits< mydim, GridFamily > > 136 { 137 typedef IdBasicGeometry< IdLocalGeometryTraits< mydim, GridFamily > > Base; 138 139 public: 140 typedef typename Base::HostGeometryType HostGeometryType; 141 IdLocalGeometry()142 IdLocalGeometry () 143 {} 144 IdLocalGeometry(const HostGeometryType & hostGeometry)145 IdLocalGeometry ( const HostGeometryType &hostGeometry ) 146 : Base( hostGeometry ) 147 {} 148 }; 149 150 } // namespace Fem 151 152 } // namespace Dune 153 154 #endif // #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_GEOMETRY_HH 155