Dune Core Modules (2.10.0)

uggridfactory.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © 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
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
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
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:100
Wrapper class for entities.
Definition: entity.hh:66
vector space out of a tensor product of fields.
Definition: fvector.hh:91
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
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:181
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 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 explicitly inserted 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.
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:275
Front-end for the grid manager of the finite element toolbox UG3.
Definition: uggrid.hh:208
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:13
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:94
Static tag representing a codimension.
Definition: dimension.hh:24
The UGGrid class.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 28, 23:30, 2024)