dune-grid-glue  2.3.0
simplexgeometry.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
12 #ifndef DUNE_GRIDGLUE_COMMON_SIMPLEXGEOMETRY_HH
13 #define DUNE_GRIDGLUE_COMMON_SIMPLEXGEOMETRY_HH
14 
15 #include <dune/common/static_assert.hh>
16 #include <dune/common/array.hh>
17 #include <dune/geometry/genericgeometry/geometry.hh>
18 #include <dune/geometry/genericgeometry/geometrytraits.hh>
19 #include <dune/geometry/genericgeometry/cornermapping.hh>
20 #include <dune/geometry/genericgeometry/topologytypes.hh>
21 
22 namespace Dune {
23  namespace GridGlue {
24 
31  template<class ctype, int dim, int dimworld>
33  : public Dune::GenericGeometry::DefaultGeometryTraits<ctype, dim, dimworld, true>
34  {
35  typedef typename Dune::GenericGeometry::DefaultGeometryTraits<ctype, dim, dimworld, true> Base;
36 
37  // This traits class represents a single type only ...
38  static const bool hybrid = false;
39  // ... and this type is 'simplex'.
40  static const unsigned int topologyId = Dune::GenericGeometry::SimplexTopology< dim >::type::id;
41 
42  template<class Topology>
43  struct Mapping
44  {
45  typedef Dune::GenericGeometry::CoordStorage<typename Base::CoordTraits, Topology, Base::dimWorld> CornerStorage;
46  typedef Dune::GenericGeometry::CornerMapping<typename Base::CoordTraits, Topology, Base::dimWorld, CornerStorage, true> type;
47  };
48 
49  };
50 
51 
60  template<class ctype, int mydim, int coorddim>
61  class SimplexGeometry : public Dune::GenericGeometry::BasicGeometry<mydim, SimplexGeometryTraits<ctype, mydim, coorddim> >
62  {
63  typedef Dune::GenericGeometry::BasicGeometry<mydim, SimplexGeometryTraits<ctype, mydim, coorddim> > Base;
64 
65  enum { simplex_corners = mydim+1 };
66 
67  public:
68 
69  typedef typename Base::Mapping Mapping;
70 
71  template< class CoordVector>
72  SimplexGeometry(const Dune::GeometryType &type, const CoordVector &coords) : Base(type, coords)
73  {}
74 
75 
77  {}
78 
84  void setup(const Dune::GeometryType& type, const Dune::array<Dune::FieldVector<ctype, coorddim>, simplex_corners>& coordinates)
85  {
86  // Yes, a strange way, but the only way, as BasicGeometry doesn't have a setup method
87  Base::operator=(Base(type, coordinates));
88  }
89 
90  };
91 
92  } // end namespace GridGlue
93 } // end namespace Dune
94 
95 #endif // DUNE_GRIDGLUE_COMMON_SIMPLEXGEOMETRY_HH
Dune::GenericGeometry::CoordStorage< typename Base::CoordTraits, Topology, Base::dimWorld > CornerStorage
Definition: simplexgeometry.hh:45
This class is derived from BasicGeometry using tuned geometry traits.
Definition: simplexgeometry.hh:61
static const bool hybrid
Definition: simplexgeometry.hh:38
Definition: gridglue.hh:34
SimplexGeometry()
Definition: simplexgeometry.hh:76
void setup(const Dune::GeometryType &type, const Dune::array< Dune::FieldVector< ctype, coorddim >, simplex_corners > &coordinates)
Setup method with a geometry type and a set of corners.
Definition: simplexgeometry.hh:84
static const unsigned int topologyId
Definition: simplexgeometry.hh:40
Dune::GenericGeometry::DefaultGeometryTraits< ctype, dim, dimworld, true > Base
Definition: simplexgeometry.hh:35
Base::Mapping Mapping
Definition: simplexgeometry.hh:69
Dune::GenericGeometry::CornerMapping< typename Base::CoordTraits, Topology, Base::dimWorld, CornerStorage, true > type
Definition: simplexgeometry.hh:46
Geometry traits for simplices passed to GenericGeometry::BasicGeometry.
Definition: simplexgeometry.hh:32
SimplexGeometry(const Dune::GeometryType &type, const CoordVector &coords)
Definition: simplexgeometry.hh:72
Definition: simplexgeometry.hh:43