Dune Core Modules (2.3.1)

hybridmapping.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GEOMETRY_GENERICGEOMETRY_HYBRIDMAPPING_HH
4#define DUNE_GEOMETRY_GENERICGEOMETRY_HYBRIDMAPPING_HH
5
6#include <cstddef>
7
9
10#include <dune/geometry/genericgeometry/cachedmapping.hh>
11#include <dune/geometry/genericgeometry/geometrytraits.hh>
12#include <dune/geometry/genericgeometry/traceprovider.hh>
13
14namespace Dune
15{
16
17 namespace GenericGeometry
18 {
19
20 // Internal Forward Declarations
21 // -----------------------------
22
23 template< unsigned int dim, class GeometryTraits >
24 class HybridMapping;
25
26 template< class Topology, class GeometryTraits >
27 class VirtualMapping;
28
29
30
31 // HybridMappingBase
32 // -----------------
33
35 template< unsigned int dim, class GeometryTraits, unsigned int codim = dim >
36 class HybridMappingBase;
37
38 template< unsigned int dim, class GeometryTraits, unsigned int codim >
39 class HybridMappingBase
40 : public virtual HybridMappingBase< dim, GeometryTraits, codim-1 >
41 {
42 typedef HybridMapping< dim, GeometryTraits > Mapping;
43
44 public:
45 virtual ~HybridMappingBase() {}
46
47 protected:
48 using HybridMappingBase< dim, GeometryTraits, codim-1 >::trace;
49
50 virtual HybridMapping< dim - codim, GeometryTraits > *
51 trace ( integral_constant< int, codim >, unsigned int i, char *mappingStorage ) const = 0;
52 };
53
54 template< unsigned int dim, class GeometryTraits >
55 class HybridMappingBase< dim, GeometryTraits, 0 >
56 {
57 typedef HybridMapping< dim, GeometryTraits > Mapping;
58
59 public:
60 virtual ~HybridMappingBase() {}
61
62 protected:
63 virtual HybridMapping< dim, GeometryTraits > *
64 trace ( integral_constant< int, 0 >, unsigned int i, char *mappingStorage ) const = 0;
65 };
70 // HybridMapping
71 // -------------
72
80 template< unsigned int dim, class GeometryTraits >
83 : public virtual HybridMappingBase< dim, GeometryTraits >
85 {
87
88 protected:
90
91 public:
92 static const unsigned int dimension = Traits::dimension;
93 static const unsigned int dimWorld = Traits::dimWorld;
94
95 typedef typename Traits::FieldType FieldType;
96 typedef typename Traits::LocalCoordinate LocalCoordinate;
97 typedef typename Traits::GlobalCoordinate GlobalCoordinate;
98
99 typedef CachedJacobianTransposed< dimension, GeometryTraits > JacobianTransposed;
100 typedef CachedJacobianInverseTransposed< dimension, GeometryTraits > JacobianInverseTransposed;
101
102 template< int codim >
103 struct Codim
104 {
105 typedef HybridMapping< dimension - codim, GeometryTraits > Trace;
106 };
107
108 typedef typename GeometryTraits::Caching Caching;
109 typedef typename GeometryTraits::UserData UserData;
110
111 virtual ~HybridMapping ()
112 {}
113
115 virtual bool affine () const = 0;
117 virtual Dune::GeometryType type () const = 0;
118
120 virtual int numCorners () const = 0;
122 virtual GlobalCoordinate corner ( int i ) const = 0;
124 virtual GlobalCoordinate center () const = 0;
125
132 virtual GlobalCoordinate global ( const LocalCoordinate &x ) const = 0;
144 virtual LocalCoordinate local ( const GlobalCoordinate &y ) const = 0;
145
153 virtual bool checkInside ( const LocalCoordinate &x ) const = 0;
154
169 virtual FieldType integrationElement ( const LocalCoordinate &x ) const = 0;
178 virtual FieldType volume () const = 0;
179
189 virtual const JacobianTransposed &jacobianTransposed ( const LocalCoordinate &x ) const = 0;
196 virtual const JacobianInverseTransposed &jacobianInverseTransposed ( const LocalCoordinate &x ) const = 0;
197
198 protected:
199 using HybridMappingBase< dim, GeometryTraits >::trace;
200
201 public:
202 virtual This *clone () const = 0;
203 virtual This *clone ( char *mappingStorage ) const = 0;
204
205 template< int codim >
206 typename Codim< codim >::Trace *trace ( unsigned int i, char *mappingStorage ) const
207 {
209 return trace( codimVariable, i, mappingStorage );
210 }
211
212 const UserData &userData () const { return userData_; }
213 UserData &userData () { return userData_; }
214
215 private:
216 UserData userData_;
217 };
218
219
220
221 // VirtualMappingBase
222 // ------------------
223
225 template< class Topology, class GeometryTraits, unsigned int codim = Topology::dimension >
226 class VirtualMappingBase;
227
228 template< class Topology, class GeometryTraits, unsigned int codim >
229 class VirtualMappingBase
230 : public VirtualMappingBase< Topology, GeometryTraits, codim-1 >,
231 public virtual HybridMappingBase< Topology::dimension, GeometryTraits, codim >
232 {
233 typedef GenericGeometry::VirtualMapping< Topology, GeometryTraits >
234 VirtualMapping;
235
236 protected:
237 using VirtualMappingBase< Topology, GeometryTraits, codim-1 >::trace;
238
239 virtual HybridMapping< Topology::dimension - codim, GeometryTraits > *
240 trace ( integral_constant< int, codim >, unsigned int i, char *mappingStorage ) const
241 {
242 return static_cast< const VirtualMapping & >( *this ).template trace< codim >( i, mappingStorage );
243 }
244 };
245
246 template< class Topology, class GeometryTraits >
247 class VirtualMappingBase< Topology, GeometryTraits, 0 >
248 : public virtual HybridMappingBase< Topology::dimension, GeometryTraits, 0 >
249 {
250 typedef GenericGeometry::VirtualMapping< Topology, GeometryTraits >
251 VirtualMapping;
252
253 protected:
255 trace ( integral_constant< int, 0 >, unsigned int i, char *mappingStorage ) const
256 {
257 return static_cast< const VirtualMapping & >( *this ).template trace< 0 >( i, mappingStorage );
258 }
259 };
264 template< class Topology, class GeometryTraits >
265 class VirtualMapping
266 : public HybridMapping< Topology::dimension, GeometryTraits >,
268 public VirtualMappingBase< Topology, GeometryTraits >
270 {
272 typedef VirtualMapping< Topology, GeometryTraits > This;
273
274 typedef typename Base::Traits Traits;
275
276 typedef CachedMapping< Topology, GeometryTraits > Mapping;
277
278 public:
279 static const unsigned int dimension = Traits::dimension;
280 static const unsigned int dimWorld = Traits::dimWorld;
281
282 typedef typename Traits::FieldType FieldType;
283 typedef typename Traits::LocalCoordinate LocalCoordinate;
284 typedef typename Traits::GlobalCoordinate GlobalCoordinate;
285
286 typedef typename Base::JacobianTransposed JacobianTransposed;
287 typedef typename Base::JacobianInverseTransposed JacobianInverseTransposed;
288
289 typedef typename Mapping::ReferenceElement ReferenceElement;
290
291 template< unsigned int codim >
292 struct Codim
293 {
294 typedef typename TraceProvider< Topology, GeometryTraits, codim, true >::Trace Trace;
295 };
296
297 typedef typename GeometryTraits::Caching Caching;
298
299 template< class CoordVector >
300 explicit VirtualMapping ( const CoordVector &coordVector )
301 : mapping_( coordVector )
302 {}
303
304 virtual bool affine () const { return mapping_.affine(); }
305 virtual Dune::GeometryType type () const { return mapping_.type(); }
306
307 virtual int numCorners () const { return mapping_.numCorners(); }
308 virtual GlobalCoordinate corner ( int i ) const { return mapping_.corner( i ); }
309 virtual GlobalCoordinate center () const { return mapping_.center(); }
310
311 virtual GlobalCoordinate global ( const LocalCoordinate &local ) const { return mapping_.global( local ); }
312 virtual LocalCoordinate local ( const GlobalCoordinate &global ) const { return mapping_.local( global ); }
313
314 virtual bool checkInside ( const LocalCoordinate &local ) const { return mapping_.checkInside( local ); }
315
316 virtual FieldType integrationElement ( const LocalCoordinate &local ) const { return mapping_.integrationElement( local ); }
317 virtual FieldType volume () const { return mapping_.volume(); }
318
319 virtual const JacobianTransposed &jacobianTransposed ( const LocalCoordinate &local ) const { return mapping_.jacobianTransposed( local ); }
320 virtual const JacobianInverseTransposed &jacobianInverseTransposed ( const LocalCoordinate &local ) const { return mapping_.jacobianInverseTransposed( local ); }
321
322 virtual Base *clone () const { return new This( *this ); }
323 virtual Base* clone ( char *mappingStorage ) const { return new( mappingStorage ) This( *this ); }
324
325 template< int codim >
326 typename Codim< codim >::Trace *trace ( unsigned int i, char *mappingStorage ) const
327 {
328 return TraceProvider< Topology, GeometryTraits, codim, true >::construct( mapping_.mapping(), i, mappingStorage );
329 }
330
331 protected:
332 using VirtualMappingBase< Topology, GeometryTraits >::trace;
333
334 private:
335 Mapping mapping_;
336 };
337
338
339
340 // NonHybridMapping
341 // ----------------
342
350 template< class Topology, class GeometryTraits >
352 {
354
355 protected:
357
358 typedef CachedMapping< Topology, GeometryTraits > Mapping;
359
360 public:
361 static const unsigned int dimension = Traits::dimension;
362 static const unsigned int dimWorld = Traits::dimWorld;
363
364 typedef typename Traits::FieldType FieldType;
365 typedef typename Traits::LocalCoordinate LocalCoordinate;
366 typedef typename Traits::GlobalCoordinate GlobalCoordinate;
367
368 typedef CachedJacobianTransposed< dimension, GeometryTraits > JacobianTransposed;
369 typedef CachedJacobianInverseTransposed< dimension, GeometryTraits > JacobianInverseTransposed;
370
371 typedef typename Mapping::ReferenceElement ReferenceElement;
372
373 template< unsigned int codim >
374 struct Codim
375 {
376 typedef typename TraceProvider< Topology, GeometryTraits, codim, false >::Trace Trace;
377 };
378
379 typedef typename GeometryTraits::Caching Caching;
380 typedef typename GeometryTraits::UserData UserData;
381
382 template< class CoordVector >
383 explicit NonHybridMapping ( const CoordVector &coordVector )
384 : mapping_( coordVector )
385 {}
386
388 bool affine () const { return mapping_.affine(); }
390 Dune::GeometryType type () const { return mapping_.type(); }
391
393 int numCorners () const { return mapping_.numCorners(); }
395 GlobalCoordinate corner ( int i ) const { return mapping_.corner( i ); }
397 GlobalCoordinate center () const { return mapping_.center(); }
398
405 GlobalCoordinate global ( const LocalCoordinate &local ) const { return mapping_.global( local ); }
417 LocalCoordinate local ( const GlobalCoordinate &global ) const { return mapping_.local( global ); }
418
426 bool checkInside ( const LocalCoordinate &local ) const { return mapping_.checkInside( local ); }
427
442 FieldType integrationElement ( const LocalCoordinate &local ) const { return mapping_.integrationElement( local ); }
451 FieldType volume () const { return mapping_.volume(); }
452
462 const JacobianTransposed &jacobianTransposed ( const LocalCoordinate &local ) const { return mapping_.jacobianTransposed( local ); }
469 const JacobianInverseTransposed &jacobianInverseTransposed ( const LocalCoordinate &local ) const { return mapping_.jacobianInverseTransposed( local ); }
470
471 This *clone () const { return new This( *this ); }
472 This *clone ( char *mappingStorage ) const { return new( mappingStorage ) This( *this ); }
473
474 template< int codim >
475 typename Codim< codim >::Trace *trace ( unsigned int i, char *mappingStorage ) const
476 {
477 return TraceProvider< Topology, GeometryTraits, codim, false >::construct( mapping_.mapping(), i, mappingStorage );
478 }
479
480 const UserData &userData () const { return userData_; }
481 UserData &userData () { return userData_; }
482
483 private:
484 UserData userData_;
485 Mapping mapping_;
486 };
487
488 } // namespace GenericGeometry
489
490} // namespace Dune
491
492#endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_HYBRIDMAPPING_HH
abstract base class for generic mapping
Definition: hybridmapping.hh:85
virtual const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &x) const =0
obtain the transposed of the Jacobian's inverse
virtual bool checkInside(const LocalCoordinate &x) const =0
check whether a point lies within the reference element
virtual FieldType volume() const =0
obtain the volume of the mapping's image
virtual GlobalCoordinate center() const =0
obtain the centroid of the mapping's image
virtual GlobalCoordinate corner(int i) const =0
obtain coordinates of the i-th corner
virtual int numCorners() const =0
obtain number of corners of the corresponding reference element
virtual GlobalCoordinate global(const LocalCoordinate &x) const =0
evaluate the mapping
virtual bool affine() const =0
is this mapping affine?
virtual FieldType integrationElement(const LocalCoordinate &x) const =0
obtain the integration element
virtual Dune::GeometryType type() const =0
obtain the name of the reference element
virtual const JacobianTransposed & jacobianTransposed(const LocalCoordinate &x) const =0
obtain the transposed of the Jacobian
non-virtual geometric mapping
Definition: hybridmapping.hh:352
bool checkInside(const LocalCoordinate &local) const
check whether a point lies within the reference element
Definition: hybridmapping.hh:426
const JacobianTransposed & jacobianTransposed(const LocalCoordinate &local) const
obtain the transposed of the Jacobian
Definition: hybridmapping.hh:462
FieldType volume() const
obtain the volume of the mapping's image
Definition: hybridmapping.hh:451
const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &local) const
obtain the transposed of the Jacobian's inverse
Definition: hybridmapping.hh:469
FieldType integrationElement(const LocalCoordinate &local) const
obtain the integration element
Definition: hybridmapping.hh:442
GlobalCoordinate center() const
obtain the centroid of the mapping's image
Definition: hybridmapping.hh:397
GlobalCoordinate corner(int i) const
obtain coordinates of the i-th corner
Definition: hybridmapping.hh:395
Dune::GeometryType type() const
obtain the name of the reference element
Definition: hybridmapping.hh:390
GlobalCoordinate global(const LocalCoordinate &local) const
evaluate the mapping
Definition: hybridmapping.hh:405
bool affine() const
is this mapping affine?
Definition: hybridmapping.hh:388
int numCorners() const
obtain number of corners of the corresponding reference element
Definition: hybridmapping.hh:393
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Dune namespace.
Definition: alignment.hh:14
Default mapping traits using Dune::FieldVector and Dune::FieldMatrix.
Definition: geometrytraits.hh:53
Generate a type for a given integral constant.
Definition: typetraits.hh:457
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)