dune-grid 2.9.0
uggridfactory.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5
6#ifndef DUNE_UGGRID_FACTORY_HH
7#define DUNE_UGGRID_FACTORY_HH
8
14#include <array>
15#include <memory>
16#include <vector>
17
18#include <dune/common/fvector.hh>
19
22#include <dune/grid/uggrid.hh>
23
24namespace Dune {
25
26
162 template <int dimworld>
163 class GridFactory<UGGrid<dimworld> > : public GridFactoryInterface<UGGrid<dimworld> > {
164
166 typedef typename UGGrid<dimworld>::ctype ctype;
167
168 // UGGrid only in 2d and 3d
169 static_assert(dimworld==2 || dimworld == 3, "UGGrid only in 2d and 3d");
170
171 public:
172
175
186
189
191 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos);
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
220 virtual std::unique_ptr<UGGrid<dimworld>> createGrid();
221
223
224 template< int codim >
225 struct Codim
226 {
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
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.
The UGGrid class.
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:94
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:73
virtual unsigned int insertionIndex(const typename Codim< 0 >::Entity &entity) const
obtain an element's insertion index
Definition: common/gridfactory.hh:220
static const int dimension
dimension of the grid
Definition: common/gridfactory.hh:77
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:314
Front-end for the grid manager of the finite element toolbox UG3.
Definition: uggrid.hh:207
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 void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
typename UGGrid< dimworld >::Communication Communication
Definition: uggridfactory.hh:267
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
virtual std::unique_ptr< UGGrid< dimworld > > createGrid()
Finalize grid creation and hand over the grid.
void insertBoundarySegment(const std::vector< unsigned int > &vertices)
Method to insert a boundary segment into a coarse grid.
UGGrid< dimworld >::template Codim< codim >::Entity Entity
Definition: uggridfactory.hh:227
Provide a generic factory class for unstructured grids.