dune-grid  2.4
uggridfactory.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 
4 #ifndef DUNE_UGGRID_FACTORY_HH
5 #define DUNE_UGGRID_FACTORY_HH
6 
12 #include <vector>
13 
14 #include <dune/common/fvector.hh>
15 
18 #include <dune/grid/uggrid.hh>
19 
20 namespace Dune {
21 
22 
158  template <int dimworld>
159  class GridFactory<UGGrid<dimworld> > : public GridFactoryInterface<UGGrid<dimworld> > {
160 
162  typedef typename UGGrid<dimworld>::ctype ctype;
163 
164  // UGGrid only in 2d and 3d
165  static_assert(dimworld==2 || dimworld || 3, "UGGrid only in 2d and 3d");
166 
167  public:
168 
170  GridFactory();
171 
183 
185  ~GridFactory();
186 
188  virtual void insertVertex(const FieldVector<ctype,dimworld>& pos);
189 
194  virtual void insertElement(const GeometryType& type,
195  const std::vector<unsigned int>& vertices);
196 
203  void insertBoundarySegment(const std::vector<unsigned int>& vertices);
204 
209  void insertBoundarySegment(const std::vector<unsigned int>& vertices,
210  const shared_ptr<BoundarySegment<dimworld> > &boundarySegment);
211 
212 
217  virtual UGGrid<dimworld>* createGrid();
218 
220 
221  template< int codim >
222  struct Codim
223  {
225  };
226 
231  virtual unsigned int
232  insertionIndex ( const typename Codim< 0 >::Entity &entity ) const
233  {
234  return UG_NS<dimension>::levelIndex(grid_->getRealImplementation(entity).target_);
235  }
236 
241  virtual unsigned int
242  insertionIndex ( const typename Codim< dimension >::Entity &entity ) const
243  {
244  return UG_NS<dimension>::levelIndex(grid_->getRealImplementation(entity).target_);
245  }
246 
247  private:
248 
249  // Initialize the grid structure in UG
250  void createBegin();
251 
252  // Pointer to the grid being built
253  UGGrid<dimworld>* grid_;
254 
255  // True if the factory allocated the grid itself, false if the
256  // grid was handed over from the outside
257  bool factoryOwnsGrid_;
258 
260  std::vector<array<int, dimworld*2-2> > boundarySegmentVertices_;
261 
264  std::vector<unsigned char> elementTypes_;
265 
268  std::vector<unsigned int> elementVertices_;
269 
271  std::vector<FieldVector<double, dimworld> > vertexPositions_;
272 
273  };
274 
275 }
276 
277 #endif
UGGrid< dimworld >::template Codim< codim >::Entity Entity
Definition: uggridfactory.hh:224
virtual unsigned int insertionIndex(const typename Codim< 0 >::Entity &entity) const
Return the number of the element in the order of insertion into the factory.
Definition: uggridfactory.hh:232
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:73
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Include standard header files.
Definition: agrid.hh:59
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:29
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
Provide a generic factory class for unstructured grids.
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
The UGGrid class.
static const int dimension
dimension of the grid
Definition: common/gridfactory.hh:78
Base class for grid boundary segments of arbitrary geometry.
Front-end for the grid manager of the finite element toolbox UG.
Definition: uggrid.hh:207
virtual GridType * createGrid()
Finalize grid creation and hand over the grid.
Definition: common/gridfactory.hh:316
virtual unsigned int insertionIndex(const typename Codim< dimension >::Entity &entity) const
Return the number of the vertex in the order of insertion into the factory.
Definition: uggridfactory.hh:242