Dune Core Modules (2.5.0)

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
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
95 {}
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.
Wrapper class for entities.
Definition: entity.hh:65
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:268
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
Provide a generic factory class for unstructured grids.
Definition: 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: gridfactory.hh:151
virtual unsigned int insertionIndex(const typename Codim< 0 >::Entity &entity) const
obtain an element's insertion index
Definition: gridfactory.hh:179
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)=0
Insert an element into the coarse grid.
virtual void insertBoundarySegment(const std::vector< unsigned int > &vertices)=0
insert a boundary segment
virtual ~GridFactoryInterface()
virtual destructor
Definition: 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: 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: gridfactory.hh:225
GridType::ctype ctype
Type used by the grid for coordinates.
Definition: 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: gridfactory.hh:122
GridFactoryInterface()
Default constructor.
Definition: gridfactory.hh:94
virtual unsigned int insertionIndex(const typename Codim< dimension >::Entity &entity) const
obtain a vertex' insertion index
Definition: gridfactory.hh:200
virtual bool wasInserted(const typename GridType::LeafIntersection &intersection) const
determine whether an intersection was inserted
Definition: gridfactory.hh:245
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:263
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Insert an element into the coarse grid.
Definition: gridfactory.hh:290
virtual GridType * createGrid()
Finalize grid creation and hand over the grid.
Definition: gridfactory.hh:316
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
Definition: gridfactory.hh:279
virtual void insertBoundarySegment(const std::vector< unsigned int > &vertices)
insert a boundary segment
Definition: gridfactory.hh:308
GridFactory()
Default constructor.
Definition: gridfactory.hh:274
Default exception for dummy implementations.
Definition: exceptions.hh:261
Virtual base class template for function classes.
Definition: function.hh:68
Different resources needed by all grid implementations.
Simple base class templates for functions.
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignment.hh:11
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:30
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 23, 23:29, 2024)