Dune Core Modules (2.7.1)

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
17#include <dune/common/to_unique_ptr.hh>
18
21#include <dune/grid/uggrid.hh>
22
23namespace Dune {
24
25
161 template <int dimworld>
162 class GridFactory<UGGrid<dimworld> > : public GridFactoryInterface<UGGrid<dimworld> > {
163
165 typedef typename UGGrid<dimworld>::ctype ctype;
166
167 // UGGrid only in 2d and 3d
168 static_assert(dimworld==2 || dimworld == 3, "UGGrid only in 2d and 3d");
169
170 public:
171
174
186
189
192
197 virtual void insertElement(const GeometryType& type,
198 const std::vector<unsigned int>& vertices);
199
206 void insertBoundarySegment(const std::vector<unsigned int>& vertices);
207
212 void insertBoundarySegment(const std::vector<unsigned int>& vertices,
213 const std::shared_ptr<BoundarySegment<dimworld> > &boundarySegment);
214
215
221
222 static const int dimension = UGGrid<dimworld>::dimension;
223
224 template< int codim >
225 struct Codim
226 {
227 typedef typename UGGrid<dimworld>::template Codim< codim >::Entity Entity;
228 };
229
234 virtual unsigned int
235 insertionIndex ( const typename Codim< 0 >::Entity &entity ) const
236 {
237 return UG_NS<dimension>::levelIndex(entity.impl().target_);
238 }
239
244 virtual unsigned int
245 insertionIndex ( const typename Codim< dimension >::Entity &entity ) const
246 {
247 return UG_NS<dimension>::levelIndex(entity.impl().target_);
248 }
249
254 virtual unsigned int
255 insertionIndex ( const typename UGGrid<dimworld>::LeafIntersection &intersection ) const
256 {
257 return intersection.boundarySegmentIndex();
258 }
259
261 virtual bool
262 wasInserted ( const typename UGGrid<dimworld>::LeafIntersection &intersection ) const
263 {
264 return (insertionIndex( intersection ) < boundarySegmentVertices_.size());
265 }
266
268
273 Communication comm() const
274 {
275 return grid_->comm();
276 }
277
278 private:
279
280 // Initialize the grid structure in UG
281 void createBegin();
282
283 // Pointer to the grid being built
284 UGGrid<dimworld>* grid_;
285
286 // True if the factory allocated the grid itself, false if the
287 // grid was handed over from the outside
288 bool factoryOwnsGrid_;
289
291 std::vector<std::array<int, dimworld*2-2> > boundarySegmentVertices_;
292
295 std::vector<unsigned char> elementTypes_;
296
299 std::vector<unsigned int> elementVertices_;
300
302 std::vector<FieldVector<double, dimworld> > vertexPositions_;
303
304 };
305
306}
307
308#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
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:70
virtual unsigned int insertionIndex(const typename Codim< 0 >::Entity &entity) const
obtain an element's insertion index
Definition: gridfactory.hh:175
static const int dimension
dimension of the grid
Definition: gridfactory.hh:74
void insertBoundarySegment(const std::vector< unsigned int > &vertices, const std::shared_ptr< BoundarySegment< dimworld > > &boundarySegment)
Method to insert an arbitrarily shaped boundary segment into a coarse grid.
virtual ToUniquePtr< UGGrid< dimworld > > createGrid()
Finalize grid creation and hand over the grid.
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
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:235
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Insert an element into the coarse grid.
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:245
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:262
Communication comm() const
Return the Communication used by the grid factory.
Definition: uggridfactory.hh:273
GridFactory(UGGrid< dimworld > *grid)
Constructor for a given grid object.
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:255
void insertBoundarySegment(const std::vector< unsigned int > &vertices)
Method to insert a boundary segment into a coarse grid.
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:269
An owning pointer wrapper that can be assigned to (smart) pointers. Cannot be copied....
Definition: to_unique_ptr.hh:37
Front-end for the grid manager of the finite element toolbox UG.
Definition: uggrid.hh:227
Provide a generic factory class for unstructured grids.
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:14
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:92
Static tag representing a codimension.
Definition: dimension.hh:22
The UGGrid class.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)