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