dune-grid
2.1.1
|
Provide a generic factory class for unstructured grids. More...
#include <dune/grid/common/gridfactory.hh>
Classes | |
struct | Codim |
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. | |
virtual void | insertElement (const GeometryType &type, const std::vector< unsigned int > &vertices, const shared_ptr< VirtualFunction< FieldVector< ctype, dimension >, FieldVector< ctype, dimworld > > > &elementParametrization) |
Insert a parametrized element into the coarse grid. | |
virtual void | insertBoundarySegment (const std::vector< unsigned int > &vertices)=0 |
insert a boundary segment | |
virtual void | insertBoundarySegment (const std::vector< unsigned int > &vertices, const shared_ptr< BoundarySegment< dimension, dimworld > > &boundarySegment) |
insert an arbitrarily shaped boundary segment | |
virtual GridType * | createGrid ()=0 |
Finalize grid creation and hand over the grid. | |
virtual unsigned int | insertionIndex (const typename Codim< 0 >::Entity &entity) const |
obtain an element's insertion index | |
virtual unsigned int | insertionIndex (const typename Codim< dimension >::Entity &entity) const |
obtain a vertex' insertion index | |
virtual unsigned int | insertionIndex (const typename GridType::LeafIntersection &intersection) const |
obtain a boundary's insertion index | |
virtual bool | wasInserted (const typename GridType::LeafIntersection &intersection) const |
determine whether an intersection was inserted | |
Protected Types | |
enum | { dimworld = GridType::dimensionworld } |
The grid world dimension. More... | |
typedef GridType::ctype | ctype |
Type used by the grid for coordinates. | |
Static Protected Attributes | |
static const int | dimension = GridType::dimension |
dimension of the grid |
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:
Dune::GridFactory<Grid> gf; Dune::FieldVector<typename Grid::ctype, 3> pos; 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); Dune::GeometryType type; type.makeTetrahedron(); 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); Dune::shared_ptr<Grid> gridp(gf.createGrid());
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);
typedef GridType::ctype Dune::GridFactoryInterface< GridType >::ctype [protected] |
Type used by the grid for coordinates.
Reimplemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::ALU3dGridFactory< ALUGrid >, Dune::ALU3dGridFactory< ALUSimplexGrid< 3, 3 > >, and Dune::ALU3dGridFactory< ALUCubeGrid< 3, 3 > >.
Dune::GridFactoryInterface< GridType >::GridFactoryInterface | ( | ) | [inline] |
Default constructor.
virtual Dune::GridFactoryInterface< GridType >::~GridFactoryInterface | ( | ) | [inline, virtual] |
virtual destructor
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< GridType >, Dune::GridFactory< Grid >, Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::ALU3dGridFactory< ALUGrid >, Dune::ALU3dGridFactory< ALUSimplexGrid< 3, 3 > >, Dune::ALU3dGridFactory< ALUCubeGrid< 3, 3 > >, Dune::ALU2dGridFactory< ALUGrid, dimw >, Dune::GridFactory< UGGrid< dimworld > >, Dune::ALU2dGridFactory< ALUConformGrid, dimw >, Dune::ALU2dGridFactory< ALUCubeGrid, dimw >, and Dune::ALU2dGridFactory< ALUSimplexGrid, dimw >.
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:
[in] | vertices | the indices of the vertices of the segment |
Implemented in Dune::GridFactory< GridType >, Dune::GridFactory< Grid >, Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::GridFactory< UGGrid< dimworld > >, Dune::ALU3dGridFactory< ALUGrid >, Dune::ALU3dGridFactory< ALUSimplexGrid< 3, 3 > >, Dune::ALU3dGridFactory< ALUCubeGrid< 3, 3 > >, Dune::ALU2dGridFactory< ALUGrid, dimw >, Dune::ALU2dGridFactory< ALUConformGrid, dimw >, Dune::ALU2dGridFactory< ALUCubeGrid, dimw >, and Dune::ALU2dGridFactory< ALUSimplexGrid, dimw >.
virtual void Dune::GridFactoryInterface< GridType >::insertBoundarySegment | ( | const std::vector< unsigned int > & | vertices, |
const shared_ptr< BoundarySegment< dimension, dimworld > > & | boundarySegment | ||
) | [inline, virtual] |
insert an arbitrarily shaped boundary segment
This method inserts a boundary segment into the coarse grid.
[in] | vertices | the indices of the vertices of the segment |
[in] | boundarySegment | user defined implementation of the boundary segment's geometry |
virtual void Dune::GridFactoryInterface< GridType >::insertElement | ( | const GeometryType & | type, |
const std::vector< unsigned int > & | vertices | ||
) | [pure virtual] |
Insert an element into the coarse grid.
type | The GeometryType of the new element |
vertices | The 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< GridType >, Dune::GridFactory< Grid >, Dune::GridFactory< UGGrid< dimworld > >, Dune::ALU3dGridFactory< ALUGrid >, Dune::ALU3dGridFactory< ALUSimplexGrid< 3, 3 > >, Dune::ALU3dGridFactory< ALUCubeGrid< 3, 3 > >, Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::ALU2dGridFactory< ALUGrid, dimw >, Dune::ALU2dGridFactory< ALUConformGrid, dimw >, Dune::ALU2dGridFactory< ALUCubeGrid, dimw >, and Dune::ALU2dGridFactory< ALUSimplexGrid, dimw >.
virtual void Dune::GridFactoryInterface< GridType >::insertElement | ( | const GeometryType & | type, |
const std::vector< unsigned int > & | vertices, | ||
const shared_ptr< VirtualFunction< FieldVector< ctype, dimension >, FieldVector< ctype, dimworld > > > & | elementParametrization | ||
) | [inline, virtual] |
Insert a parametrized element into the coarse grid.
type | The GeometryType of the new element |
vertices | The vertices of the new element, using the DUNE numbering |
elementParametrization | A 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.
virtual unsigned int Dune::GridFactoryInterface< GridType >::insertionIndex | ( | const typename Codim< 0 >::Entity & | entity | ) | const [inline, virtual] |
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.
[in] | entity | entity whose insertion index is requested |
Reimplemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::ALU3dGridFactory< ALUSimplexGrid< 3, 3 > >, Dune::ALU3dGridFactory< ALUCubeGrid< 3, 3 > >, Dune::ALU2dGridFactory< ALUConformGrid, dimw >, Dune::ALU2dGridFactory< ALUCubeGrid, dimw >, and Dune::ALU2dGridFactory< ALUSimplexGrid, dimw >.
Referenced by Dune::GridFactory< AlbertaGrid< dim, dimworld > >::insertionIndex(), Dune::DGFBaseFactory< ALUCubeGrid< 2, dimw > >::parameter(), and Dune::GridFactory< AlbertaGrid< dim, dimworld > >::wasInserted().
virtual unsigned int Dune::GridFactoryInterface< GridType >::insertionIndex | ( | const typename Codim< dimension >::Entity & | entity | ) | const [inline, virtual] |
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.
[in] | entity | entity whose insertion index is requested |
Reimplemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::ALU3dGridFactory< ALUSimplexGrid< 3, 3 > >, Dune::ALU3dGridFactory< ALUCubeGrid< 3, 3 > >, Dune::ALU2dGridFactory< ALUConformGrid, dimw >, Dune::ALU2dGridFactory< ALUCubeGrid, dimw >, and Dune::ALU2dGridFactory< ALUSimplexGrid, dimw >.
virtual unsigned int Dune::GridFactoryInterface< GridType >::insertionIndex | ( | const typename GridType::LeafIntersection & | intersection | ) | const [inline, virtual] |
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.
[in] | intersection | intersection whose insertion index is requested |
virtual void Dune::GridFactoryInterface< GridType >::insertVertex | ( | const FieldVector< ctype, dimworld > & | pos | ) | [pure virtual] |
Insert a vertex into the coarse grid.
Implemented in Dune::GridFactory< GridType >, Dune::GridFactory< Grid >, and Dune::GridFactory< UGGrid< dimworld > >.
virtual bool Dune::GridFactoryInterface< GridType >::wasInserted | ( | const typename GridType::LeafIntersection & | intersection | ) | const [inline, virtual] |
determine whether an intersection was inserted
This method allows checking wheter an intersection was actually inserted into the grid factory.
[in] | intersection | intersection in question |
Referenced by Dune::DGFBaseFactory< ALUCubeGrid< 2, dimw > >::wasInserted().
const int Dune::GridFactoryInterface< GridType >::dimension = GridType::dimension [static, protected] |
dimension of the grid
Reimplemented in Dune::GridFactory< AlbertaGrid< dim, dimworld > >, Dune::ALU3dGridFactory< ALUGrid >, Dune::ALU3dGridFactory< ALUSimplexGrid< 3, 3 > >, and Dune::ALU3dGridFactory< ALUCubeGrid< 3, 3 > >.
Referenced by Dune::GridFactory< AlbertaGrid< dim, dimworld > >::createGrid(), Dune::GridFactory< AlbertaGrid< dim, dimworld > >::insertBoundaryProjection(), Dune::GridFactory< AlbertaGrid< dim, dimworld > >::insertBoundarySegment(), Dune::GridFactory< AlbertaGrid< dim, dimworld > >::insertElement(), and Dune::GridFactory< AlbertaGrid< dim, dimworld > >::write().