DUNE-FEM (unstable)

elementquadrature.hh
1#ifndef DUNE_FEM_ELEMENTQUADRATURE_HH
2#define DUNE_FEM_ELEMENTQUADRATURE_HH
3
4#include <dune/fem/quadrature/elementpointlistbase.hh>
5#include <dune/fem/quadrature/caching/twistutility.hh>
6
7namespace Dune
8{
9
10 namespace Fem
11 {
12
13 template< typename GridPartImp, class IntegrationPointList >
14 class Agglomeration;
15
16 template< class GridPartImp, int codim, template< class, int > class QuadratureTraits >
17 struct ElementQuadratureTraits
18 {
19 // type of single coordinate
20 typedef typename GridPartImp :: ctype ctype;
21
22 // dimension of quadrature
23 enum { dimension = GridPartImp :: dimension };
24
25 // codimension of quadrature
26 enum { codimension = codim };
27
28 // type of used integration point list
29 typedef Quadrature< ctype, dimension-codim, QuadratureTraits > IntegrationPointListType;
30
31 // type of local coordinate (with respect to the codim-0 entity)
32 typedef typename Quadrature< ctype, dimension, QuadratureTraits > :: CoordinateType
33 CoordinateType;
34 };
35
72 template< class GridPartImp, int codim, class IntegrationTraits, bool isQuadrature >
73 class ElementQuadratureImpl;
74
75
77 template< class GridPartImp, class IntegrationTraits, bool isQuadrature >
78 class ElementQuadratureImpl< GridPartImp, 0, IntegrationTraits, isQuadrature >
79 : public ElementPointListBase< GridPartImp, 0, IntegrationTraits >
80 {
83
84 public:
86 typedef typename Base :: GridPartType GridPartType;
87
89 typedef typename Base::CoordinateType CoordinateType;
90
95
96 // for compatibility
97 typedef typename Base :: EntityType EntityType;
98
99 typedef typename Base :: IntegrationPointListType IntegrationPointListType;
100
101 protected:
102 template <class QuadratureKeyType>
103 IntegrationPointListType createQuadrature( const EntityType &entity, const QuadratureKeyType& quadKey, const bool checkGeomType )
104 {
105 const GeometryType geomType = entity.type();
106 if( checkGeomType && ! geomType.isNone() )
107 {
108 // return default element quadratures for given geometry type
109 return IntegrationPointListType( geomType, quadKey );
110 }
111 else // compute weights and points based on sub-triangulation
112 {
114 return AgglomerationType::computeQuadrature( entity, quadKey );
115 }
116 }
117
118 using Base::quadImp;
119
120 public:
121 using Base::localPoint;
122 using Base::nop;
123
130 template <class QuadratureKeyType>
131 ElementQuadratureImpl( const EntityType &entity, const QuadratureKeyType& quadKey, const bool checkGeomType = isQuadrature )
132 : Base( createQuadrature( entity, quadKey, checkGeomType ) )
133 {}
134
140 template <class QuadratureKeyType>
141 ElementQuadratureImpl( const GeometryType &geometry, const QuadratureKeyType& quadKey )
142 : Base( geometry, quadKey )
143 {}
144
145 const QuadraturePointWrapperType operator[] ( const size_t i ) const
146 {
147 return QuadraturePointWrapperType( *this, i );
148 }
149
150 IteratorType begin () const noexcept { return IteratorType( *this, 0 ); }
151 IteratorType end () const noexcept { return IteratorType( *this, nop() ); }
152
154 const CoordinateType &point ( const size_t i ) const
155 {
156 return localPoint( i );
157 }
158
160 auto weight( size_t i ) const
161 {
162 return quadImp().weight( i );
163 }
164 };
165
166
167
169 template< class GridPartImp, class IntegrationTraits, bool isQuadrature >
170 class ElementQuadratureImpl< GridPartImp, 1, IntegrationTraits, isQuadrature >
171 : public ElementPointListBase< GridPartImp, 1, IntegrationTraits >
172 {
175
176 public:
178 typedef GridPartImp GridPartType;
179
180 static const int dimension = Base::dimension;
181
183 typedef typename Base::CoordinateType CoordinateType;
184
187 typedef typename IntersectionIteratorType::Intersection IntersectionType;
188
193
196
197
198 // for compatibility
200 typedef IntersectionIteratorType IntersectionIterator;
201
202
203 using Base::localPoint;
204 using Base::elementGeometry;
205 using Base::nop;
206
218 template <class QuadratureKeyType>
220 const IntersectionType &intersection,
221 const QuadratureKeyType& quadKey,
222 const typename Base :: Side side )
223 : Base( getPointList( intersection, quadKey, side ) ),
224 side_(side),
225 intersection_(intersection),
226 referenceGeometry_( side == Base::INSIDE ? intersection.geometryInInside() : intersection.geometryInOutside())
227 {}
228
229 const QuadraturePointWrapperType operator[] ( size_t i ) const
230 {
231 return QuadraturePointWrapperType( *this, i );
232 }
233
234 IteratorType begin () const noexcept { return IteratorType( *this, 0 ); }
235 IteratorType end () const noexcept { return IteratorType( *this, nop() ); }
236 typename Base :: Side side() const { return side_; }
237 bool isInside() const { return side_ == Base::INSIDE; }
238
240 const CoordinateType &point ( size_t i ) const
241 {
242 dummy_ = referenceGeometry_.global( localPoint( i ) );
243 return dummy_;
244 }
245
247 auto weight( size_t i ) const
248 {
249 return quadImp().weight( i );
250 }
251
252 using Base::localFaceIndex;
253
254 const IntersectionType &intersection() const
255 {
256 return intersection_;
257 }
258
259 protected:
260 using Base::quadImp;
261
262 Base getPointList ( const IntersectionType &intersection, const int order,
263 const typename Base :: Side side )
264 {
265 switch( side )
266 {
267 case Base :: INSIDE:
268 return Base( TwistUtilityType::elementGeometry( intersection, true ),
269 intersection.type(), intersection.indexInInside(), order );
270
271 case Base ::OUTSIDE:
272 return Base( TwistUtilityType::elementGeometry( intersection, false ),
273 intersection.type(), intersection.indexInOutside(), order );
274
275 default:
276 DUNE_THROW( InvalidStateException, "ElementIntegrationPointList: side must either be INSIDE or OUTSIDE." );
277 }
278 }
279
280 private:
281 typedef typename IntersectionIteratorType::Intersection::LocalGeometry ReferenceGeometry;
282
283 const typename Base :: Side side_;
284 const IntersectionType &intersection_;
285 ReferenceGeometry referenceGeometry_;
286 mutable CoordinateType dummy_;
287 };
288
290 template< class GridPart, int codim, template <class, int> class IntegrationTraits = DefaultQuadratureTraits >
291 using ElementIntegrationPointList = ElementQuadratureImpl< GridPart, codim, ElementQuadratureTraits< GridPart, codim, IntegrationTraits>, false >;
292
293 template< class GridPart, int codim, template <class, int> class IntegrationTraits = DefaultQuadratureTraits >
294 using ElementQuadrature = ElementQuadratureImpl< GridPart, codim, ElementQuadratureTraits< GridPart, codim, IntegrationTraits>, true >;
295
296 template<class GridPart, class Entity>
297 static inline auto elementQuadrature(const GridPart& gridPart, const Entity& entity, unsigned quadOrder)
298 {
299 using Quadrature = Dune::Fem::ElementQuadrature<GridPart, 0>;
300 return Quadrature(entity, quadOrder);
301 }
302
303 } // namespace Fem
304
305} // namespace Dune
306
307#include "agglomerationquadrature.hh"
308
309#endif // #ifndef DUNE_FEM_ELEMENTQUADRATURE_HH
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: adaptiveleafgridpart.hh:92
Agglomeration is a simple quadrature for polyhedral cells based on sub triangulation
Definition: agglomerationquadrature.hh:22
ElementPointListBase.
Definition: elementpointlistbase.hh:193
IntegrationTraits::IntegrationPointListType IntegrationPointListType
type of the integration point list
Definition: elementpointlistbase.hh:213
QuadraturePointIterator< This > IteratorType
type of iterator
Definition: elementquadrature.hh:94
ElementQuadratureImpl(const EntityType &entity, const QuadratureKeyType &quadKey, const bool checkGeomType=isQuadrature)
constructor
Definition: elementquadrature.hh:131
ElementQuadratureImpl(const GeometryType &geometry, const QuadratureKeyType &quadKey)
constructor
Definition: elementquadrature.hh:141
QuadraturePointWrapper< This > QuadraturePointWrapperType
type of the quadrature point
Definition: elementquadrature.hh:92
Base::GridPartType GridPartType
type of grid part
Definition: elementquadrature.hh:86
auto weight(size_t i) const
obtain weight of i-th integration point (if quadrature, else 1.0)
Definition: elementquadrature.hh:160
Base::CoordinateType CoordinateType
type for coordinates in the codim-0 reference element
Definition: elementquadrature.hh:89
const CoordinateType & point(const size_t i) const
obtain coordinates of i-th integration point
Definition: elementquadrature.hh:154
QuadraturePointIterator< This > IteratorType
type of iterator
Definition: elementquadrature.hh:192
GridPartType::IntersectionIteratorType IntersectionIteratorType
Type of the intersection iterator.
Definition: elementquadrature.hh:186
auto weight(size_t i) const
obtain weight of i-th integration point (if quadrature, else 1.0)
Definition: elementquadrature.hh:247
QuadraturePointWrapper< This > QuadraturePointWrapperType
type of the quadrature point
Definition: elementquadrature.hh:190
ElementQuadratureImpl(const GridPartType &gridPart, const IntersectionType &intersection, const QuadratureKeyType &quadKey, const typename Base ::Side side)
constructor
Definition: elementquadrature.hh:219
const CoordinateType & point(size_t i) const
obtain coordinates of i-th integration point
Definition: elementquadrature.hh:240
Base::CoordinateType CoordinateType
Type of coordinates in codim-0 reference element.
Definition: elementquadrature.hh:183
GridPartImp GridPartType
type of the grid partition
Definition: elementquadrature.hh:178
This NonConformingQuadratureType
type quadrature for use on non-conforming intersections
Definition: elementquadrature.hh:195
iterator over quadrature points
Definition: quadrature.hh:103
wrapper for a (Quadrature,int) pair
Definition: quadrature.hh:42
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
constexpr bool isNone() const
Return true if entity is a singular of any dimension.
Definition: type.hh:355
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:281
quadrature on the codim-0 reference element
actual interface class for quadratures
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Utility to get twist from IntersectionIterator, if provided by grid (i.e. AlbertaGrid,...
Definition: twistutility.hh:107
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)