dune-grid  2.2.0
uggridfactory.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=8 sw=4 sts=4:
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  dune_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 
219  private:
220 
221  // Initialize the grid structure in UG
222  void createBegin();
223 
224  // Pointer to the grid being built
225  UGGrid<dimworld>* grid_;
226 
227  // True if the factory allocated the grid itself, false if the
228  // grid was handed over from the outside
229  bool factoryOwnsGrid_;
230 
232  std::vector<array<int, dimworld*2-2> > boundarySegmentVertices_;
233 
236  std::vector<unsigned char> elementTypes_;
237 
240  std::vector<unsigned int> elementVertices_;
241 
243  std::vector<FieldVector<double, dimworld> > vertexPositions_;
244 
245  };
246 
247 }
248 
249 #endif