Dune Core Modules (2.7.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_COMMON_GRIDFACTORY_HH
4#define DUNE_GRID_COMMON_GRIDFACTORY_HH
5
10#include <memory>
11#include <vector>
12
15#include <dune/common/to_unique_ptr.hh>
17
18#include <dune/geometry/type.hh>
19
22
23namespace Dune
24{
25
68 template <class GridType>
70 {
71
72 protected:
74 static const int dimension = GridType::dimension;
75
77 enum {dimworld = GridType::dimensionworld};
78
80 typedef typename GridType::ctype ctype;
81
82 public:
83 template< int codim >
84 struct Codim
85 {
86 typedef typename GridType::template Codim< codim >::Entity Entity;
87 };
88
91 {}
92
95 {}
96
98 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) = 0;
99
107 virtual void insertElement(const GeometryType& type,
108 const std::vector<unsigned int>& vertices) = 0;
109
118 virtual void insertElement(const GeometryType& type,
119 const std::vector<unsigned int>& vertices,
120 const std::shared_ptr<VirtualFunction<FieldVector<ctype,dimension>,FieldVector<ctype,dimworld> > >& elementParametrization)
121 {
122 DUNE_THROW(GridError, "This grid does not support parametrized elements!");
123 }
124
138 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices) = 0;
139
147 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices,
148 const std::shared_ptr<BoundarySegment<dimension,dimworld> >& boundarySegment)
149 {
150 DUNE_THROW(GridError, "This grid does not support parametrized boundary segments!");
151 }
152
158
174 virtual unsigned int
175 insertionIndex ( const typename Codim< 0 >::Entity &entity ) const
176 {
177 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
178 }
179
195 virtual unsigned int
196 insertionIndex ( const typename Codim< dimension >::Entity &entity ) const
197 {
198 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
199 }
200
220 virtual unsigned int
221 insertionIndex ( const typename GridType::LeafIntersection &intersection ) const
222 {
223 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
224 }
225
226
240 virtual bool
241 wasInserted ( const typename GridType::LeafIntersection &intersection ) const
242 {
243 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
244 }
245
247
253 {
255 }
256 };
257
258
268 template <class GridType>
269 class GridFactory : public GridFactoryInterface<GridType> {
270
272
274 enum {dimworld = GridType::dimensionworld};
275
277 typedef typename GridType::ctype ctype;
278
279 public:
280
281 // use default implementation from base class
283
286 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
287 }
288
290 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) {
291 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
292 }
293
301 virtual void insertElement(const GeometryType& type,
302 const std::vector<unsigned int>& vertices) {
303 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
304 }
305
319 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices) {
320 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
321 }
322
328 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
329 }
330
331 };
332
333}
334
335#endif
Base class for grid boundary segments of arbitrary geometry.
Collective communication interface and sequential default implementation.
Definition: communication.hh:81
Wrapper class for entities.
Definition: entity.hh:64
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:279
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:70
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:147
virtual unsigned int insertionIndex(const typename Codim< 0 >::Entity &entity) const
obtain an element's insertion index
Definition: gridfactory.hh:175
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:94
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:74
virtual unsigned int insertionIndex(const typename GridType::LeafIntersection &intersection) const
obtain a boundary's insertion index
Definition: gridfactory.hh:221
GridType::ctype ctype
Type used by the grid for coordinates.
Definition: gridfactory.hh:80
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:118
GridFactoryInterface()
Default constructor.
Definition: gridfactory.hh:90
Communication comm() const
Return the Communication used by the grid factory.
Definition: gridfactory.hh:252
virtual unsigned int insertionIndex(const typename Codim< dimension >::Entity &entity) const
obtain a vertex' insertion index
Definition: gridfactory.hh:196
virtual bool wasInserted(const typename GridType::LeafIntersection &intersection) const
determine whether an intersection was inserted
Definition: gridfactory.hh:241
virtual ToUniquePtr< GridType > createGrid()=0
Finalize grid creation and hand over the grid.
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:269
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Insert an element into the coarse grid.
Definition: gridfactory.hh:301
virtual ToUniquePtr< GridType > createGrid()
Finalize grid creation and hand over the grid.
Definition: gridfactory.hh:327
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
Definition: gridfactory.hh:290
virtual void insertBoundarySegment(const std::vector< unsigned int > &vertices)
insert a boundary segment
Definition: gridfactory.hh:319
GridFactory()
Default constructor.
Definition: gridfactory.hh:285
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition: mpihelper.hh:201
Default exception for dummy implementations.
Definition: exceptions.hh:261
An owning pointer wrapper that can be assigned to (smart) pointers. Cannot be copied....
Definition: to_unique_ptr.hh:37
Virtual base class template for function classes.
Definition: function.hh:72
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
Helpers for dealing with MPI.
Dune namespace.
Definition: alignedallocator.hh:14
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:92
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 (Jul 15, 22:36, 2024)