dune-grid 3.0-git
common/gridfactory.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:
3#ifndef DUNE_GRID_FACTORY_HH
4#define DUNE_GRID_FACTORY_HH
5
10#include <memory>
11#include <vector>
12
13#include <dune/common/function.hh>
14#include <dune/common/fvector.hh>
15
16#include <dune/geometry/type.hh>
17
20
21namespace Dune
22{
23
72 template <class GridType>
74 {
75
76 protected:
78 static const int dimension = GridType::dimension;
79
81 enum {dimworld = GridType::dimensionworld};
82
84 typedef typename GridType::ctype ctype;
85
86 public:
87 template< int codim >
88 struct Codim
89 {
90 typedef typename GridType::template Codim< codim >::Entity Entity;
91 };
92
96
99 {}
100
102 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) = 0;
103
111 virtual void insertElement(const GeometryType& type,
112 const std::vector<unsigned int>& vertices) = 0;
113
122 virtual void insertElement(const GeometryType& type,
123 const std::vector<unsigned int>& vertices,
124 const std::shared_ptr<VirtualFunction<FieldVector<ctype,dimension>,FieldVector<ctype,dimworld> > >& elementParametrization)
125 {
126 DUNE_THROW(GridError, "This grid does not support parametrized elements!");
127 }
128
142 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices) = 0;
143
151 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices,
152 const std::shared_ptr<BoundarySegment<dimension,dimworld> >& boundarySegment)
153 {
154 DUNE_THROW(GridError, "This grid does not support parametrized boundary segments!");
155 }
156
161 virtual GridType* createGrid() = 0;
162
178 virtual unsigned int
179 insertionIndex ( const typename Codim< 0 >::Entity &entity ) const
180 {
181 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
182 }
183
199 virtual unsigned int
200 insertionIndex ( const typename Codim< dimension >::Entity &entity ) const
201 {
202 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
203 }
204
224 virtual unsigned int
225 insertionIndex ( const typename GridType::LeafIntersection &intersection ) const
226 {
227 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
228 }
229
230
244 virtual bool
245 wasInserted ( const typename GridType::LeafIntersection &intersection ) const
246 {
247 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
248 }
249
250 };
251
252
262 template <class GridType>
263 class GridFactory : public GridFactoryInterface<GridType> {
264
266 enum {dimworld = GridType::dimensionworld};
267
269 typedef typename GridType::ctype ctype;
270
271 public:
272
275 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
276 }
277
279 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) {
280 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
281 }
282
290 virtual void insertElement(const GeometryType& type,
291 const std::vector<unsigned int>& vertices) {
292 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
293 }
294
308 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices) {
309 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
310 }
311
316 virtual GridType* createGrid() {
317 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
318 }
319
320 };
321
322}
323
324#endif
Base class for grid boundary segments of arbitrary geometry.
Include standard header files.
Definition agrid.hh:60
Base class for classes implementing geometries of boundary segments.
Definition boundarysegment.hh:30
Base class for exceptions in Dune grid modules.
Definition exceptions.hh:18
Provide a generic factory class for unstructured grids.
Definition common/gridfactory.hh:74
virtual void insertBoundarySegment(const std::vector< unsigned int > &vertices, const std::shared_ptr< BoundarySegment< dimension, dimworld > > &boundarySegment)
insert an arbitrarily shaped boundary segment
Definition common/gridfactory.hh:151
virtual unsigned int insertionIndex(const typename Codim< 0 >::Entity &entity) const
obtain an element's insertion index
Definition common/gridfactory.hh:179
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)=0
Insert an element into the coarse grid.
@ dimworld
Definition common/gridfactory.hh:81
virtual void insertBoundarySegment(const std::vector< unsigned int > &vertices)=0
insert a boundary segment
virtual ~GridFactoryInterface()
virtual destructor
Definition common/gridfactory.hh:98
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)=0
Insert a vertex into the coarse grid.
static const int dimension
dimension of the grid
Definition common/gridfactory.hh:78
virtual GridType * createGrid()=0
Finalize grid creation and hand over the grid.
virtual unsigned int insertionIndex(const typename GridType::LeafIntersection &intersection) const
obtain a boundary's insertion index
Definition common/gridfactory.hh:225
GridType::ctype ctype
Type used by the grid for coordinates.
Definition common/gridfactory.hh:84
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices, const std::shared_ptr< VirtualFunction< FieldVector< ctype, dimension >, FieldVector< ctype, dimworld > > > &elementParametrization)
Insert a parametrized element into the coarse grid.
Definition common/gridfactory.hh:122
GridFactoryInterface()
Default constructor.
Definition common/gridfactory.hh:94
virtual unsigned int insertionIndex(const typename Codim< dimension >::Entity &entity) const
obtain a vertex' insertion index
Definition common/gridfactory.hh:200
virtual bool wasInserted(const typename GridType::LeafIntersection &intersection) const
determine whether an intersection was inserted
Definition common/gridfactory.hh:245
Definition common/gridfactory.hh:89
GridType::template Codim< codim >::Entity Entity
Definition common/gridfactory.hh:90
Provide a generic factory class for unstructured grids.
Definition common/gridfactory.hh:263
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Insert an element into the coarse grid.
Definition common/gridfactory.hh:290
virtual GridType * createGrid()
Finalize grid creation and hand over the grid.
Definition common/gridfactory.hh:316
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
Definition common/gridfactory.hh:279
virtual void insertBoundarySegment(const std::vector< unsigned int > &vertices)
insert a boundary segment
Definition common/gridfactory.hh:308
GridFactory()
Default constructor.
Definition common/gridfactory.hh:274
Different resources needed by all grid implementations.