dune-grid 2.9.0
Classes | Public Types | Public Member Functions | Static Public Attributes | Static Protected Attributes | List of all members
Dune::GridFactory< UGGrid< dimworld > > Class Template Referenceabstract

Specialization of the generic GridFactory for UGGrid. More...

#include <dune/grid/uggrid/uggridfactory.hh>

Inheritance diagram for Dune::GridFactory< UGGrid< dimworld > >:
Inheritance graph

Classes

struct  Codim
 

Public Types

using Communication = typename UGGrid< dimworld >::Communication
 

Public Member Functions

 GridFactory ()
 Default constructor. More...
 
 GridFactory (UGGrid< dimworld > *grid)
 Constructor for a given grid object. More...
 
 ~GridFactory ()
 Destructor. More...
 
virtual void insertVertex (const FieldVector< ctype, dimworld > &pos)
 Insert a vertex into the coarse grid. More...
 
virtual void insertElement (const GeometryType &type, const std::vector< unsigned int > &vertices)
 Insert an element into the coarse grid. More...
 
void insertBoundarySegment (const std::vector< unsigned int > &vertices)
 Method to insert a boundary segment into a coarse grid. More...
 
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. More...
 
virtual std::unique_ptr< UGGrid< dimworld > > createGrid ()
 Finalize grid creation and hand over the grid. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual bool wasInserted (const typename UGGrid< dimworld >::LeafIntersection &intersection) const
 Return true if the intersection has been explictily insterted into the factory. More...
 
Communication comm () const
 Return the Communication used by the grid factory. More...
 
virtual void insertVertex (const FieldVector< ctype, dimworld > &pos)=0
 Insert a vertex into the coarse grid. More...
 
virtual DUNE_NO_DEPRECATED_BEGIN 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 DUNE_NO_DEPRECATED_END void insertElement (const GeometryType &type, const std::vector< unsigned int > &vertices, std::function< FieldVector< ctype, dimworld >(FieldVector< ctype, dimension >)> elementParametrization)
 Insert a parametrized element into the coarse grid. 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 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...
 

Static Public Attributes

static const int dimension = UGGrid<dimworld>::dimension
 

Static Protected Attributes

static constexpr int dimworld
 The grid world dimension. More...
 

Detailed Description

template<int dimworld>
class Dune::GridFactory< UGGrid< dimworld > >

Specialization of the generic GridFactory for UGGrid.

If you want to write a routine that reads a grid from some file into a Dune UGGrid object you have to know how to use the UGGrid grid factory. In the following we assume that you have a grid in some file format and an empty UGGrid object, created by one of its constructors. Hence, your file reader method signature may look like this:

UGGrid<3>* readMyFileFormat(const std::string& filename)

Now, in order to create a valid UGGrid object do the following steps:

1) Create a GridFactory Object

Get a new GridFactory object by calling

GridFactory<UGGrid<dim> > factory;

2) Enter the Vertices

Insert the grid vertices by calling

factory.insertVertex(const FieldVector<double,dimworld>& position);

for each vertex. The order of insertion determines the level- and leaf indices of your level 0 vertices.

3) Enter the elements

For each element call

factory.insertElement(Dune::GeometryType type, const std::vector<int>& vertices);

The parameters are

The numbering of the vertices of each element is expected to follow the DUNE conventions. Refer to the page on reference elements for the details.

4) Parametrized Domains

UGGrid supports parametrized domains. That means that you can provide a smooth description of your grid boundary. The actual grid will always be piecewise linear; however, as you refine, the grid will approach your prescribed boundary. You don't have to do this. If your coarse grid boundary describes your domain well read on at Section 5.

In order to create curved boundary segments, for each segment you have to write a class which implements the correct geometry. These classes are then handed over to the UGGrid object. Boundary segment implementations must be derived from

template <int dimworld> Dune::BoundarySegment

This is an abstract base class which requires you to overload the method

virtual FieldVector< double, dimworld > operator() (const FieldVector< double, dimworld-1 > &local)

This methods must compute the world coordinates from the local ones on the boundary segment. Give these classes to your grid factory by calling

factory.insertBoundarySegment(const std::vector<int>& vertices,
                        const BoundarySegment<dimworld> *boundarySegment);

Control over the allocated objects is taken from you, and the grid object will take care of their destruction.

5) Finish construction

To finish off the construction of the UGGrid object call

std::unique_ptr<UGGrid<dim> > grid = factory.createGrid();

This time it is you who gets full responsibility for the allocated object.

Loading a Grid on a Parallel Machine

If you're working on a parallel machine, and you want to set up a parallel grid, proceed as described only on the rank-0 process. On the other processes just create a GridFactory and call createGrid() to obtain the grid object. This will create the grid on the master process and set up UG correctly on all other process. Call loadBalance() to actually distribute the grid.

Warning
To use a parametrized boundary on a parallel machine you need to hand over the boundary segments to the grid factory on all processes. This behavior violates the Dune grid interface specification and will be corrected in the future.

Member Typedef Documentation

◆ Communication

template<int dimworld>
using Dune::GridFactory< UGGrid< dimworld > >::Communication = typename UGGrid<dimworld>::Communication

Constructor & Destructor Documentation

◆ GridFactory() [1/2]

template<int dimworld>
Dune::GridFactory< UGGrid< dimworld > >::GridFactory ( )

Default constructor.

◆ GridFactory() [2/2]

template<int dimworld>
Dune::GridFactory< UGGrid< dimworld > >::GridFactory ( UGGrid< dimworld > *  grid)

Constructor for a given grid object.

If you already have your grid object constructed you can hand it over using this constructor.

If you construct your factory class using this constructor the pointer handed over to you by the method createGrid() is the one you supplied here.

◆ ~GridFactory()

template<int dimworld>
Dune::GridFactory< UGGrid< dimworld > >::~GridFactory ( )

Destructor.

Member Function Documentation

◆ comm()

template<int dimworld>
Communication Dune::GridFactory< UGGrid< dimworld > >::comm ( ) const
inline

Return the Communication used by the grid factory.

Use the Communication available from the grid.

◆ createGrid()

template<int dimworld>
virtual std::unique_ptr< UGGrid< dimworld > > Dune::GridFactory< UGGrid< dimworld > >::createGrid ( )
virtual

Finalize grid creation and hand over the grid.

The receiver takes responsibility of the memory allocated for the grid

Implements Dune::GridFactoryInterface< UGGrid< dimworld > >.

◆ insertBoundarySegment() [1/3]

template<int dimworld>
void Dune::GridFactory< UGGrid< dimworld > >::insertBoundarySegment ( const std::vector< unsigned int > &  vertices)
virtual

Method to insert a boundary segment into a coarse grid.

Using this method is optional. It only influences the ordering of the segments

Parameters
verticesThe indices of the vertices of the segment

Implements Dune::GridFactoryInterface< UGGrid< dimworld > >.

◆ insertBoundarySegment() [2/3]

virtual void Dune::GridFactoryInterface< UGGrid< dimworld > >::insertBoundarySegment ( const std::vector< unsigned int > &  vertices,
const std::shared_ptr< BoundarySegment< dimension, dimworld > > &  boundarySegment 
)
inlinevirtualinherited

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

◆ insertBoundarySegment() [3/3]

template<int dimworld>
void Dune::GridFactory< UGGrid< dimworld > >::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.

Parameters
verticesThe indices of the vertices of the segment
boundarySegmentClass implementing the geometry of the boundary segment.

◆ insertElement() [1/3]

template<int dimworld>
virtual void Dune::GridFactory< UGGrid< dimworld > >::insertElement ( const GeometryType &  type,
const std::vector< unsigned int > &  vertices 
)
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

Implements Dune::GridFactoryInterface< UGGrid< dimworld > >.

◆ insertElement() [2/3]

virtual DUNE_NO_DEPRECATED_BEGIN void Dune::GridFactoryInterface< UGGrid< dimworld > >::insertElement ( const GeometryType &  type,
const std::vector< unsigned int > &  vertices,
const std::shared_ptr< VirtualFunction< FieldVector< ctype, dimension >, FieldVector< ctype, dimworld > > > &  elementParametrization 
)
inlinevirtualinherited

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.

Deprecated:
[After Dune 2.7] VirtualFunction is deprecated, use the overload taking a std::function instead

◆ insertElement() [3/3]

virtual DUNE_NO_DEPRECATED_END void Dune::GridFactoryInterface< UGGrid< dimworld > >::insertElement ( const GeometryType &  type,
const std::vector< unsigned int > &  vertices,
std::function< FieldVector< ctype, dimworld >(FieldVector< ctype, dimension >)>  elementParametrization 
)
inlinevirtualinherited

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.

◆ insertionIndex() [1/4]

template<int dimworld>
virtual unsigned int Dune::GridFactory< UGGrid< dimworld > >::insertionIndex ( const typename Codim< 0 >::Entity &  entity) const
inlinevirtual

Return the number of the element in the order of insertion into the factory.

For UGGrid elements this number is the same as the element level index

Reimplemented from Dune::GridFactoryInterface< UGGrid< dimworld > >.

◆ insertionIndex() [2/4]

template<int dimworld>
virtual unsigned int Dune::GridFactory< UGGrid< dimworld > >::insertionIndex ( const typename Codim< dimension >::Entity &  entity) const
inlinevirtual

Return the number of the vertex in the order of insertion into the factory.

For UGGrid vertices this number is the same as the vertex level index

Reimplemented from Dune::GridFactoryInterface< UGGrid< dimworld > >.

◆ insertionIndex() [3/4]

virtual unsigned int Dune::GridFactoryInterface< UGGrid< dimworld > >::insertionIndex ( const typename GridType::LeafIntersection &  intersection) const
inlinevirtualinherited

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).

◆ insertionIndex() [4/4]

template<int dimworld>
virtual unsigned int Dune::GridFactory< UGGrid< dimworld > >::insertionIndex ( const typename UGGrid< dimworld >::LeafIntersection &  intersection) const
inlinevirtual

Return the number of the intersection in the order of insertion into the factory.

For UGGrid intersections this number is the same as the boundary segment index

◆ insertVertex() [1/2]

template<int dimworld>
virtual void Dune::GridFactory< UGGrid< dimworld > >::insertVertex ( const FieldVector< ctype, dimworld > &  pos)
virtual

Insert a vertex into the coarse grid.

◆ insertVertex() [2/2]

virtual void Dune::GridFactoryInterface< UGGrid< dimworld > >::insertVertex ( const FieldVector< ctype, dimworld > &  pos)
pure virtualinherited

Insert a vertex into the coarse grid.

◆ wasInserted() [1/2]

virtual bool Dune::GridFactoryInterface< UGGrid< dimworld > >::wasInserted ( const typename GridType::LeafIntersection &  intersection) const
inlinevirtualinherited

determine whether an intersection was inserted

This method allows checking whether 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

◆ wasInserted() [2/2]

template<int dimworld>
virtual bool Dune::GridFactory< UGGrid< dimworld > >::wasInserted ( const typename UGGrid< dimworld >::LeafIntersection &  intersection) const
inlinevirtual

Return true if the intersection has been explictily insterted into the factory.

Member Data Documentation

◆ dimension

template<int dimworld>
const int Dune::GridFactory< UGGrid< dimworld > >::dimension = UGGrid<dimworld>::dimension
static

◆ dimworld

constexpr int Dune::GridFactoryInterface< UGGrid< dimworld > >::dimworld
staticconstexprprotectedinherited

The grid world dimension.


The documentation for this class was generated from the following file: