dune-grid  2.5.0
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 <array>
13 #include <memory>
14 #include <vector>
15 
16 #include <dune/common/fvector.hh>
17 
20 #include <dune/grid/uggrid.hh>
21 
22 namespace Dune {
23 
24 
160  template <int dimworld>
161  class GridFactory<UGGrid<dimworld> > : public GridFactoryInterface<UGGrid<dimworld> > {
162 
164  typedef typename UGGrid<dimworld>::ctype ctype;
165 
166  // UGGrid only in 2d and 3d
167  static_assert(dimworld==2 || dimworld == 3, "UGGrid only in 2d and 3d");
168 
169  public:
170 
172  GridFactory();
173 
185 
187  ~GridFactory();
188 
190  virtual void insertVertex(const FieldVector<ctype,dimworld>& pos);
191 
196  virtual void insertElement(const GeometryType& type,
197  const std::vector<unsigned int>& vertices);
198 
205  void insertBoundarySegment(const std::vector<unsigned int>& vertices);
206 
211  void insertBoundarySegment(const std::vector<unsigned int>& vertices,
212  const std::shared_ptr<BoundarySegment<dimworld> > &boundarySegment);
213 
214 
219  virtual UGGrid<dimworld>* createGrid();
220 
222 
223  template< int codim >
224  struct Codim
225  {
227  };
228 
233  virtual unsigned int
234  insertionIndex ( const typename Codim< 0 >::Entity &entity ) const
235  {
236  return UG_NS<dimension>::levelIndex(grid_->getRealImplementation(entity).target_);
237  }
238 
243  virtual unsigned int
244  insertionIndex ( const typename Codim< dimension >::Entity &entity ) const
245  {
246  return UG_NS<dimension>::levelIndex(grid_->getRealImplementation(entity).target_);
247  }
248 
253  virtual unsigned int
254  insertionIndex ( const typename UGGrid<dimworld>::LeafIntersection &intersection ) const
255  {
256  return intersection.boundarySegmentIndex();
257  }
258 
260  virtual bool
261  wasInserted ( const typename UGGrid<dimworld>::LeafIntersection &intersection ) const
262  {
263  return (insertionIndex( intersection ) < boundarySegmentVertices_.size());
264  }
265 
266  private:
267 
268  // Initialize the grid structure in UG
269  void createBegin();
270 
271  // Pointer to the grid being built
272  UGGrid<dimworld>* grid_;
273 
274  // True if the factory allocated the grid itself, false if the
275  // grid was handed over from the outside
276  bool factoryOwnsGrid_;
277 
279  std::vector<std::array<int, dimworld*2-2> > boundarySegmentVertices_;
280 
283  std::vector<unsigned char> elementTypes_;
284 
287  std::vector<unsigned int> elementVertices_;
288 
290  std::vector<FieldVector<double, dimworld> > vertexPositions_;
291 
292  };
293 
294 }
295 
296 #endif
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:234
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:263
Base class for grid boundary segments of arbitrary geometry.
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Insert an element into the coarse grid.
Definition: common/gridfactory.hh:290
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
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:244
Provide a generic factory class for unstructured grids.
static const int dimension
dimension of the grid
Definition: common/gridfactory.hh:78
virtual GridType * createGrid()
Finalize grid creation and hand over the grid.
Definition: common/gridfactory.hh:316
The UGGrid class.
virtual unsigned int insertionIndex(const typename Codim< 0 >::Entity &entity) const
obtain an element&#39;s insertion index
Definition: common/gridfactory.hh:179
UGGrid< dimworld >::template Codim< codim >::Entity Entity
Definition: uggridfactory.hh:226
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
Include standard header files.
Definition: agrid.hh:59
virtual unsigned int insertionIndex(const typename UGGrid< dimworld >::LeafIntersection &intersection) const
Return the number of the intersection in the order of insertion into the factory. ...
Definition: uggridfactory.hh:254
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
Definition: common/gridfactory.hh:279
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:29
Front-end for the grid manager of the finite element toolbox UG.
Definition: uggrid.hh:230
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:73
virtual bool wasInserted(const typename UGGrid< dimworld >::LeafIntersection &intersection) const
Return true if the intersection has been explictily insterted into the factory.
Definition: uggridfactory.hh:261