1 // -*- tab-width: 4; indent-tabs-mode: nil -*- 2 #ifndef DUNE_PDELAB_COMMON_GEOMETRYWRAPPER_HH 3 #define DUNE_PDELAB_COMMON_GEOMETRYWRAPPER_HH 4 5 #include <dune/common/fvector.hh> 6 7 namespace Dune { 8 namespace PDELab { 9 10 //! Wrap element 11 /** 12 * \todo Please doc me! 13 */ 14 template<typename E> 15 class ElementGeometry 16 { 17 public: 18 //! \todo Please doc me! 19 typedef typename E::Geometry Geometry; 20 //! \todo Please doc me! 21 typedef E Entity; 22 23 //! \todo Please doc me! ElementGeometry(const E & e_)24 ElementGeometry (const E& e_) 25 : e(e_) 26 {} 27 28 //! \todo Please doc me! geometry() const29 Geometry geometry () const 30 { 31 return e.geometry(); 32 } 33 34 //! \todo Please doc me! entity() const35 const Entity& entity () const 36 { 37 return e; 38 } 39 40 //! \todo Please doc me! hostEntity() const41 const Entity& hostEntity () const 42 { 43 return e; 44 } 45 46 private: 47 const E& e; 48 }; 49 50 51 //! Wrap intersection 52 /** 53 * \todo Please doc me! 54 */ 55 template<typename I> 56 class IntersectionGeometry 57 { 58 private: 59 const I& i; 60 const unsigned int index; 61 public: 62 //! \todo Please doc me! 63 typedef typename I::Geometry Geometry; 64 //! \todo Please doc me! 65 typedef typename I::LocalGeometry LocalGeometry; 66 //! \todo Please doc me! 67 typedef typename I::Entity Entity; 68 //! \todo Please doc me! 69 typedef typename Geometry::ctype ctype; 70 71 /** \brief Dimension of the domain space of the geometry */ 72 enum { mydimension=I::mydimension }; 73 74 /** \brief Dimension of the image space of the geometry */ 75 enum { coorddimension=Geometry::coorddimension }; 76 77 //! \todo Please doc me! IntersectionGeometry(const I & i_,unsigned int index_)78 IntersectionGeometry (const I& i_, unsigned int index_) 79 : i(i_), index(index_) 80 {} 81 82 //! \todo Please doc me! insideDomainIndex() const83 int insideDomainIndex() const 84 { 85 return 0; 86 } 87 88 //! \todo Please doc me! outsideDomainIndex() const89 int outsideDomainIndex() const 90 { 91 const bool is_boundary = i.boundary(); 92 return 0 - int(is_boundary); 93 } 94 95 //! return true if intersection is with interior or exterior boundary (see the cases above) boundary() const96 bool boundary () const 97 { 98 return i.boundary(); 99 } 100 101 //! @brief return true if intersection is shared with another element. neighbor() const102 bool neighbor () const 103 { 104 return i.neighbor(); 105 } 106 107 /*! @brief geometrical information about this intersection in local 108 coordinates of the inside() entity. 109 110 This method returns a Geometry object that provides a mapping from 111 local coordinates of the intersection to local coordinates of the 112 inside() entity. 113 */ geometryInInside() const114 LocalGeometry geometryInInside () const 115 { 116 return i.geometryInInside(); 117 } 118 119 /*! @brief geometrical information about this intersection in local 120 coordinates of the outside() entity. 121 122 This method returns a Geometry object that provides a mapping from 123 local coordinates of the intersection to local coordinates of the 124 outside() entity. 125 */ geometryInOutside() const126 LocalGeometry geometryInOutside () const 127 { 128 return i.geometryInOutside(); 129 } 130 131 /*! @brief geometrical information about this intersection in global coordinates. 132 133 This method returns a Geometry object that provides a mapping from 134 local coordinates of the intersection to global (world) coordinates. 135 */ geometry() const136 Geometry geometry () const 137 { 138 return i.geometry(); 139 } 140 141 //! Local number of codim 1 entity in the inside() Entity where intersection is contained in indexInInside() const142 int indexInInside () const 143 { 144 return i.indexInInside (); 145 } 146 147 //! Local number of codim 1 entity in outside() Entity where intersection is contained in indexInOutside() const148 int indexInOutside () const 149 { 150 return i.indexInOutside (); 151 } 152 153 /*! @brief Return an outer normal (length not necessarily 1) 154 155 The returned vector may depend on local position within the intersection. 156 */ outerNormal(const Dune::FieldVector<ctype,mydimension> & local) const157 Dune::FieldVector<ctype, coorddimension> outerNormal (const Dune::FieldVector<ctype, mydimension>& local) const 158 { 159 return i.outerNormal(local); 160 } 161 162 /*! @brief return outer normal scaled with the integration element 163 @copydoc outerNormal 164 The normal is scaled with the integration element of the intersection. This 165 method is redundant but it may be more efficent to use this function 166 rather than computing the integration element via intersectionGlobal(). 167 */ integrationOuterNormal(const Dune::FieldVector<ctype,mydimension> & local) const168 Dune::FieldVector<ctype, coorddimension> integrationOuterNormal (const Dune::FieldVector<ctype, mydimension>& local) const 169 { 170 return i.integrationOuterNormal(local); 171 } 172 173 /*! @brief Return unit outer normal (length == 1) 174 175 The returned vector may depend on the local position within the intersection. 176 It is scaled to have unit length. 177 */ unitOuterNormal(const Dune::FieldVector<ctype,mydimension> & local) const178 Dune::FieldVector<ctype, coorddimension> unitOuterNormal (const Dune::FieldVector<ctype, mydimension>& local) const 179 { 180 return i.unitOuterNormal(local); 181 } 182 183 /*! @brief Return unit outer normal (length == 1) 184 185 The returned vector may depend on the local position within the intersection. 186 It is scaled to have unit length. 187 */ centerUnitOuterNormal() const188 Dune::FieldVector<ctype, coorddimension> centerUnitOuterNormal () const 189 { 190 return i.centerUnitOuterNormal(); 191 } 192 193 /*! @brief return Entity on the inside of this intersection. 194 That is the Entity where we started this. 195 */ inside() const196 Entity inside() const 197 { 198 return i.inside(); 199 } 200 201 /*! @brief return Entity on the inside of this intersection. 202 That is the Entity where we started this. 203 */ insideHostEntity() const204 Entity insideHostEntity() const 205 { 206 DUNE_THROW(Dune::Exception,"This should never be called."); 207 return i.inside(); 208 } 209 210 /*! @brief return Entity on the outside of this intersection. 211 That is the neighboring Entity. 212 213 @warning Don't call this method if there is no neighboring Entity 214 (neighbor() returns false). In this case the result is undefined. 215 */ outside() const216 Entity outside() const 217 { 218 return i.outside(); 219 } 220 221 //! \todo Please doc me! intersection() const222 const I& intersection () const 223 { 224 return i; 225 } 226 intersectionIndex() const227 unsigned int intersectionIndex() const 228 { 229 return index; 230 } 231 }; 232 233 } 234 } 235 236 #endif // DUNE_PDELAB_COMMON_GEOMETRYWRAPPER_HH 237