Dune Core Modules (2.3.1)

geometry.hh
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 
4 #ifndef DUNE_GENERICGEOMETRY_GEOMETRY_HH
5 #define DUNE_GENERICGEOMETRY_GEOMETRY_HH
6 
7 #warning This header and the code it contains is deprecated. If you need functionality \
8  similar to BasicGeometry, please use the MultiLinearGeometry class.
9 
11 #include <dune/common/nullptr.hh>
12 
13 #include <dune/geometry/genericgeometry/mappingprovider.hh>
14 #include <dune/geometry/genericgeometry/geometrytraits.hh>
15 
16 namespace Dune
17 {
18 
19  namespace GenericGeometry
20  {
21 
172  // BasicGeometry
173  // -------------
174 
251  template< int mydim, class Traits >
253  {
254  typedef typename Traits :: CoordTraits CoordTraits;
255 
257  template< int, class > friend class BasicGeometry;
258 
259  public:
260 
262  static const int mydimension = mydim;
263 
265  static const int coorddimension = Traits :: dimWorld;
266 
268  typedef typename CoordTraits :: ctype ctype;
269 
272 
275 
276  private:
277  dune_static_assert( (0 <= mydimension), "Geometry dimension must be nonnegative." );
278 
279  template< bool >
280  struct Hybrid
281  {
282  typedef VirtualMappingFactory< mydimension, Traits > MappingFactory;
283  };
284 
285  template< bool >
286  struct NonHybrid
287  {
288  static const int topologyId = Traits::template hasSingleGeometryType< mydimension >::topologyId;
289  typedef typename GenericGeometry::Topology< topologyId, mydimension >::type Topology;
290  typedef GenericGeometry::NonHybridMappingFactory< Topology, Traits > MappingFactory;
291  };
292 
293  static const bool hybrid = !Traits::template hasSingleGeometryType< mydimension >::v;
294 
295  protected:
296  typedef typename conditional< hybrid, Hybrid< true >, NonHybrid< false > >::type::MappingFactory MappingFactory;
297  typedef typename MappingFactory::Mapping Mapping;
298 
299  public:
305  typedef typename Mapping::JacobianTransposed JacobianTransposed;
311  typedef typename Mapping::JacobianInverseTransposed Jacobian;
312  // for cenvencience, Jacobian is the name of the type in the geometry interface
313  typedef Jacobian JacobianInverseTransposed;
314 
315  public:
319  : mapping_( nullptr )
320  {}
321 
323  template< class CoordVector >
324  BasicGeometry ( const GeometryType &type, const CoordVector &coords )
325  {
326  assert(type.dim() == mydim);
327  mapping_ = MappingFactory::construct( type.id(), coords, mappingStorage_ );
328  }
329 
333  template< class CoordVector >
334  BasicGeometry ( const CoordVector &coords )
335  {
337  type.makeFromVertices( mydim, coords.size() );
338  mapping_ = MappingFactory::construct( type.id(), coords, mappingStorage_ );
339  }
340 
354  template< int fatherdim >
356  {
357  const unsigned int codim = fatherdim - mydim;
358  mapping_ = father.mapping_->template trace< codim >( i, mappingStorage_ );
359  }
360 
362  BasicGeometry ( const BasicGeometry &other )
363  : mapping_( other.mapping_ ? other.mapping_->clone( mappingStorage_ ) : nullptr )
364  {}
365 
368  {
369  if( mapping_ )
370  mapping_->~Mapping();
371  }
372 
374  const BasicGeometry &operator= ( const BasicGeometry &other )
375  {
376  if( mapping_ )
377  mapping_->~Mapping();
378  mapping_ = (other.mapping_) ? other.mapping_->clone( mappingStorage_ ) : nullptr;
379  return *this;
380  }
381 
389  operator bool () const
390  {
391  return bool( mapping_ );
392  }
393 
396  {
397  return mapping_->type();
398  }
399 
401  int corners () const
402  {
403  return mapping_->numCorners();
404  }
405 
407  GlobalCoordinate corner ( const int i ) const
408  {
409  return mapping_->corner( i );
410  }
411 
413  GlobalCoordinate global ( const LocalCoordinate &local ) const
414  {
415  return mapping_->global( local );
416  }
417 
419  LocalCoordinate local ( const GlobalCoordinate &global ) const
420  {
421  return mapping_->local( global );
422  }
423 
426  {
427  return mapping_->center();
428  }
429 
431  bool affine () const
432  {
433  return mapping_->affine();
434  }
435 
437  ctype integrationElement ( const LocalCoordinate &local ) const
438  {
439  return mapping_->integrationElement( local );
440  }
441 
443  ctype volume () const
444  {
445  return mapping_->volume();
446  }
447 
453  {
454  return mapping_->jacobianTransposed( local );
455  }
456 
459  const JacobianInverseTransposed &jacobianInverseTransposed ( const LocalCoordinate &local ) const
460  {
461  return mapping_->jacobianInverseTransposed( local );
462  }
463 
464  private:
465 
467  Mapping* mapping_;
468 
474  char mappingStorage_[ MappingFactory::maxMappingSize ];
475  };
476 
477 
478 
479  // Geometry
480  // --------
481 
494  template< int mydim, int cdim, class Grid >
495  class Geometry
496  : public BasicGeometry< mydim, GlobalGeometryTraits< Grid > >
497  {
499 
500  protected:
501  typedef typename Base::Mapping Mapping;
502 
503  public:
504 
505  Geometry ()
506  {}
507 
509  template< class Geo >
510  explicit Geometry ( const Geo &geo )
511  : Base( geo.type(), geo, geo.affine() )
512  {}
513 
515  template< class CoordVector >
516  Geometry ( const GeometryType &type, const CoordVector &coords )
517  : Base( type, coords )
518  {}
519 
521  template< int fatherdim >
523  : Base( father, i )
524  {}
525  };
526 
527 
528 
529  // LocalGeometry
530  // -------------
531 
544  template< int mydim, int cdim, class Grid >
546  : public BasicGeometry< mydim, LocalGeometryTraits< Grid > >
547  {
549 
550  protected:
551  typedef typename Base::Mapping Mapping;
552 
553  public:
555  template< class Geo >
556  explicit LocalGeometry ( const Geo &geo )
557  : Base( geo.type(), geo, geo.affine() )
558  {}
559 
561  template< class CoordVector >
562  LocalGeometry ( const GeometryType &type, const CoordVector &coords )
563  : Base( type, coords )
564  {}
565 
567  template< int fatherdim >
569  : Base( father, i )
570  {}
571  };
572 
573  }
574 
575 }
576 
577 #endif // #ifndef DUNE_GENERICGEOMETRY_GEOMETRY_HH
vector space out of a tensor product of fields.
Definition: fvector.hh:92
generic implementation of DUNE geometries
Definition: geometry.hh:253
GlobalCoordinate corner(const int i) const
Return the world coordinates of the i-th corner.
Definition: geometry.hh:407
ctype integrationElement(const LocalCoordinate &local) const
Return the factor $|det F|$ that appears in the integral transformation formula.
Definition: geometry.hh:437
BasicGeometry(const CoordVector &coords)
Constructor using a vector of corner coordinates and the dimension.
Definition: geometry.hh:334
GlobalCoordinate center() const
return center of element
Definition: geometry.hh:425
int corners() const
Return the number of corners.
Definition: geometry.hh:401
~BasicGeometry()
Destructor.
Definition: geometry.hh:367
FieldVector< ctype, mydimension > LocalCoordinate
Type used for parameter coordinates.
Definition: geometry.hh:271
Mapping::JacobianTransposed JacobianTransposed
Type used for Jacobian matrices.
Definition: geometry.hh:305
static const int coorddimension
The dimension of the world space of this geometry.
Definition: geometry.hh:265
BasicGeometry()
Default constructor.
Definition: geometry.hh:318
bool affine() const
Return true if this is an affine geometry.
Definition: geometry.hh:431
Mapping::JacobianInverseTransposed Jacobian
Type used for Jacobian matrices.
Definition: geometry.hh:311
FieldVector< ctype, coorddimension > GlobalCoordinate
Type used for world coordinates.
Definition: geometry.hh:274
BasicGeometry(const BasicGeometry< fatherdim, Traits > &father, int i)
obtain a geometry for a subentity
Definition: geometry.hh:355
static const int mydimension
The dimension of the parameter space of this geometry.
Definition: geometry.hh:262
CoordTraits ::ctype ctype
Type used for coordinate components.
Definition: geometry.hh:268
const BasicGeometry & operator=(const BasicGeometry &other)
Assignment from other BasicGeometry.
Definition: geometry.hh:374
const JacobianTransposed & jacobianTransposed(const LocalCoordinate &local) const
Compute the transpose of the Jacobian matrix of the transformation from the reference element into th...
Definition: geometry.hh:452
ctype volume() const
Return the volume of the element.
Definition: geometry.hh:443
BasicGeometry(const BasicGeometry &other)
Copy constructor.
Definition: geometry.hh:362
BasicGeometry(const GeometryType &type, const CoordVector &coords)
Constructor using a GeometryType and a list of corner coordinates.
Definition: geometry.hh:324
GlobalCoordinate global(const LocalCoordinate &local) const
Map local to global coordinates.
Definition: geometry.hh:413
GeometryType type() const
Return the topological type of this geometry.
Definition: geometry.hh:395
const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &local) const
Compute the transpose of the inverse Jacobian matrix of the transformation from the reference element...
Definition: geometry.hh:459
generic implementation of a DUNE (global) geometry
Definition: geometry.hh:497
Geometry(const GeometryType &type, const CoordVector &coords)
Constructor with a GeometryType and a set of coordinates.
Definition: geometry.hh:516
Geometry(const Geo &geo)
Copy constructor from another geometry.
Definition: geometry.hh:510
Geometry(const Geometry< fatherdim, cdim, Grid > &father, int i)
Definition: geometry.hh:522
generic implementation of a DUNE (local) geometry
Definition: geometry.hh:547
LocalGeometry(const Geometry< fatherdim, cdim, Grid > &father, int i)
Definition: geometry.hh:568
LocalGeometry(const GeometryType &type, const CoordVector &coords)
Constructor with a GeometryType and a set of coordinates.
Definition: geometry.hh:562
LocalGeometry(const Geo &geo)
Copy constructor from another geometry.
Definition: geometry.hh:556
interface for a mapping
Definition: mapping.hh:31
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
unsigned int dim() const
Return dimension of the type.
Definition: type.hh:322
void makeFromVertices(unsigned int dim, unsigned int vertices)
Construct the correct geometry type given the dimension and the number of vertices.
Definition: type.hh:218
unsigned int id() const
Return the topology id the type.
Definition: type.hh:327
#define dune_static_assert(COND, MSG)
Helper template so that compilation fails if condition is not true.
Definition: static_assert.hh:79
Dune namespace.
Definition: alignment.hh:14
Fallback implementation of the nullptr object in C++0x.
Select a type based on a condition.
Definition: typetraits.hh:419
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 7, 22:32, 2024)