Dune Core Modules (2.5.2)

Dune::GridFactoryInterface< GridType > Class Template Referenceabstract

Provide a generic factory class for unstructured grids. More...

#include <dune/grid/common/gridfactory.hh>

Public Member Functions

 GridFactoryInterface ()
 Default constructor.
 
virtual ~GridFactoryInterface ()
 virtual destructor
 
virtual void insertVertex (const FieldVector< ctype, dimworld > &pos)=0
 Insert a vertex into the coarse grid.
 
virtual void insertElement (const GeometryType &type, const std::vector< unsigned int > &vertices)=0
 Insert an element into the coarse grid. More...
 
virtual void insertElement (const GeometryType &type, const std::vector< unsigned int > &vertices, const std::shared_ptr< VirtualFunction< FieldVector< ctype, dimension >, FieldVector< ctype, dimworld > > > &elementParametrization)
 Insert a parametrized element into the coarse grid. More...
 
virtual void insertBoundarySegment (const std::vector< unsigned int > &vertices)=0
 insert a boundary segment More...
 
virtual void insertBoundarySegment (const std::vector< unsigned int > &vertices, const std::shared_ptr< BoundarySegment< dimension, dimworld > > &boundarySegment)
 insert an arbitrarily shaped boundary segment More...
 
virtual GridType * createGrid ()=0
 Finalize grid creation and hand over the grid. More...
 
virtual unsigned int insertionIndex (const typename Codim< 0 >::Entity &entity) const
 obtain an element's insertion index More...
 
virtual unsigned int insertionIndex (const typename Codim< dimension >::Entity &entity) const
 obtain a vertex' insertion index More...
 
virtual unsigned int insertionIndex (const typename GridType::LeafIntersection &intersection) const
 obtain a boundary's insertion index More...
 
virtual bool wasInserted (const typename GridType::LeafIntersection &intersection) const
 determine whether an intersection was inserted More...
 

Protected Types

enum  
 The grid world dimension.
 
typedef GridType::ctype ctype
 Type used by the grid for coordinates.
 

Static Protected Attributes

static const int dimension = GridType::dimension
 dimension of the grid
 

Detailed Description

template<class GridType>
class Dune::GridFactoryInterface< GridType >

Provide a generic factory class for unstructured grids.

This base class declares the interface.

Example use: create a grid consisting of a cube triangulated into 6 tetrahedra:

Left: cube with vertex numbers. Middle: cube triangulated into six tetrahedra. Right: exploded version of the middle figure, with number for the tetrahedra.
pos[0] = 0; pos[1] = 0; pos[2] = 0; gf.insertVertex(pos);
pos[0] = 1; pos[1] = 0; pos[2] = 0; gf.insertVertex(pos);
pos[0] = 0; pos[1] = 1; pos[2] = 0; gf.insertVertex(pos);
pos[0] = 1; pos[1] = 1; pos[2] = 0; gf.insertVertex(pos);
pos[0] = 0; pos[1] = 0; pos[2] = 1; gf.insertVertex(pos);
pos[0] = 1; pos[1] = 0; pos[2] = 1; gf.insertVertex(pos);
pos[0] = 0; pos[1] = 1; pos[2] = 1; gf.insertVertex(pos);
pos[0] = 1; pos[1] = 1; pos[2] = 1; gf.insertVertex(pos);
std::vector<unsigned int> vid(4);
vid[0] = 0; vid[1] = 1; vid[2] = 3; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 5; vid[2] = 1; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 4; vid[2] = 5; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 6; vid[2] = 4; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 2; vid[2] = 6; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 3; vid[2] = 2; vid[3] = 7; gf.insertElement(type, vid);
std::shared_ptr<Grid> gridp(gf.createGrid());
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:268
void makeTetrahedron()
Make a tetrahedron.
Definition: type.hh:413
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Insert an element into the coarse grid.
Definition: gridfactory.hh:290
virtual GridType * createGrid()
Finalize grid creation and hand over the grid.
Definition: gridfactory.hh:316
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
Definition: gridfactory.hh:279

Make sure that the inserted elements are not inverted, since not all grids support that. For instance, in the following code snippet the elements 1, 3 and 5 are inverted while elements 0, 2 and 4 are not.

vid[0] = 0; vid[1] = 1; vid[2] = 3; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 1; vid[2] = 5; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 4; vid[2] = 5; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 4; vid[2] = 6; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 2; vid[2] = 6; vid[3] = 7; gf.insertElement(type, vid);
vid[0] = 0; vid[1] = 2; vid[2] = 3; vid[3] = 7; gf.insertElement(type, vid);

Member Function Documentation

◆ createGrid()

template<class GridType >
virtual GridType * Dune::GridFactoryInterface< GridType >::createGrid ( )
pure virtual

Finalize grid creation and hand over the grid.

The receiver takes responsibility of the memory allocated for the grid

Implemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::GridFactory< GridType >, Dune::GridFactory< Grid >, and Dune::GridFactory< UGGrid< dimworld > >.

◆ insertBoundarySegment() [1/2]

template<class GridType >
virtual void Dune::GridFactoryInterface< GridType >::insertBoundarySegment ( const std::vector< unsigned int > &  vertices)
pure virtual

insert a boundary segment

This method inserts a boundary segment into the coarse grid. Using this method has two advantages over not using it:

  • The boundary segment gets an insertion index.
  • The grid factory can verify that this is actually a boundary segment
Note
You are not forced to insert all boundary segments. The grid factory will find the remaining boundary segments itself.
Parameters
[in]verticesthe indices of the vertices of the segment

Implemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::GridFactory< GridType >, Dune::GridFactory< Grid >, and Dune::GridFactory< UGGrid< dimworld > >.

◆ insertBoundarySegment() [2/2]

template<class GridType >
virtual void Dune::GridFactoryInterface< GridType >::insertBoundarySegment ( const std::vector< unsigned int > &  vertices,
const std::shared_ptr< BoundarySegment< dimension, dimworld > > &  boundarySegment 
)
inlinevirtual

insert an arbitrarily shaped boundary segment

This method inserts a boundary segment into the coarse grid.

Parameters
[in]verticesthe indices of the vertices of the segment
[in]boundarySegmentuser defined implementation of the boundary segment's geometry

References DUNE_THROW.

◆ insertElement() [1/2]

template<class GridType >
virtual void Dune::GridFactoryInterface< GridType >::insertElement ( const GeometryType type,
const std::vector< unsigned int > &  vertices 
)
pure virtual

Insert an element into the coarse grid.

Parameters
typeThe GeometryType of the new element
verticesThe vertices of the new element, using the DUNE numbering

Make sure the inserted element is not inverted (this holds even for simplices). There are grids that can't handle inverted elements.

Implemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::GridFactory< GridType >, Dune::GridFactory< Grid >, and Dune::GridFactory< UGGrid< dimworld > >.

◆ insertElement() [2/2]

template<class GridType >
virtual void Dune::GridFactoryInterface< GridType >::insertElement ( const GeometryType type,
const std::vector< unsigned int > &  vertices,
const std::shared_ptr< VirtualFunction< FieldVector< ctype, dimension >, FieldVector< ctype, dimworld > > > &  elementParametrization 
)
inlinevirtual

Insert a parametrized element into the coarse grid.

Parameters
typeThe GeometryType of the new element
verticesThe vertices of the new element, using the DUNE numbering
elementParametrizationA function prescribing the shape of this element

Make sure the inserted element is not inverted (this holds even for simplices). There are grids that can't handle inverted elements.

References DUNE_THROW.

◆ insertionIndex() [1/3]

template<class GridType >
virtual unsigned int Dune::GridFactoryInterface< GridType >::insertionIndex ( const typename Codim< 0 >::Entity &  entity) const
inlinevirtual

obtain an element's insertion index

Data can be associated to the created macro grid using the insertion index of each entity that has been inserted during the grid creation process.

Between grid construction (createGrid) and the first grid modification, this method allows to obtain this insertion index from the grid factory. This way, data can be stored using the index maps provided by the grid.

Parameters
[in]entityentity whose insertion index is requested
Returns
insertion index of the entity

Reimplemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, and Dune::GridFactory< UGGrid< dimworld > >.

References DUNE_THROW.

Referenced by Dune::GridFactory< AlbertaGrid< dim, dimworld > >::insertionIndex(), and Dune::GridFactory< UGGrid< dimworld > >::wasInserted().

◆ insertionIndex() [2/3]

template<class GridType >
virtual unsigned int Dune::GridFactoryInterface< GridType >::insertionIndex ( const typename Codim< dimension >::Entity &  entity) const
inlinevirtual

obtain a vertex' insertion index

Data can be associated to the created macro grid using the insertion index of each entity that has been inserted during the grid creation process.

Between grid construction (createGrid) and the first grid modification, this method allows to obtain this insertion index from the grid factory. This way, data can be stored using the index maps provided by the grid.

Parameters
[in]entityentity whose insertion index is requested
Returns
insertion index of the entity

Reimplemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, and Dune::GridFactory< UGGrid< dimworld > >.

References DUNE_THROW.

◆ insertionIndex() [3/3]

template<class GridType >
virtual unsigned int Dune::GridFactoryInterface< GridType >::insertionIndex ( const typename GridType::LeafIntersection &  intersection) const
inlinevirtual

obtain a boundary's insertion index

Data can be associated to the created macro grid using the insertion index of each entity that has been inserted during the grid creation process.

Between grid construction (createGrid) and the first grid modification, this method allows to obtain this insertion index from the grid factory. This way, data can be stored using the index maps provided by the grid.

Parameters
[in]intersectionintersection whose insertion index is requested
Returns
insertion index of the intersection
Note
The insertion index can only be obtained for boundary intersections that were actually inserted (see also wasInserted).

References DUNE_THROW.

◆ wasInserted()

template<class GridType >
virtual bool Dune::GridFactoryInterface< GridType >::wasInserted ( const typename GridType::LeafIntersection &  intersection) const
inlinevirtual

determine whether an intersection was inserted

This method allows checking wheter an intersection was actually inserted into the grid factory.

Note
Not all boundary segments need to be inserted into the grid factory.
This method returns false for all interior intersections
Parameters
[in]intersectionintersection in question
Returns
true, if the intersection was inserted

References DUNE_THROW.


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)