dune-geometry  2.4
Modules | Namespaces | Classes
Refinement
Collaboration diagram for Refinement:

Modules

 Refinement implementation for hypercubes
 
 Refinement implementation for triangulating hypercubes
 
 Refinement implementation for simplices
 
 Virtual Refinement
 

Namespaces

 Dune::RefinementImp
 This namespace contains the implementation of Refinement.
 

Classes

struct  Dune::RefinementImp::Traits< topologyId, CoordType, coerceToId, dimension, Dummy >
 Mapping from geometryType, CoordType and coerceTo to a particular Refinement implementation. More...
 
struct  Dune::StaticRefinement< topologyId, CoordType, coerceToId, dimension_ >::Codim< codimension >
 The Codim struct inherited from the Refinement implementation. More...
 
class  Dune::StaticRefinement< topologyId, CoordType, coerceToId, dimension_ >
 Wrap each Refinement implementation to get a consistent interface. More...
 

Detailed Description

General

The Refinement system allows to temporarily refine a grid or single entities without changing the grid itself. You may want to do this because you want to write your data to a file and have to do subsampling, but want to continue the calculation with the unmodified grid afterwards.

What Refinement can do for you

For a given geometry type and refinement level, Refinement will

The geometry type of the refined entity and of the subelements may be different, for example you can refine a quadrilateral but get subelements which are triangles.

Currently the following geometry types are supported:

What Refinement can't do for you

The user interface

template<unsigned topologyId, class CoordType,
unsigned coerceToId, int dimension>
class StaticRefinement
{
public:
enum { dimension };
template<int codimension>
struct codim
{
class SubEntityIterator;
};
typedef ImplementationDefined VertexIterator; // These are aliases for codim<codim>::SubEntityIterator
typedef ImplementationDefined ElementIterator;
typedef ImplementationDefined IndexVector; // These are FieldVectors
typedef ImplementationDefined CoordVector;
static int nVertices(int level);
static VertexIterator vBegin(int level);
static VertexIterator vEnd(int level);
static int nElements(int level);
static ElementIterator eBegin(int level);
static ElementIterator eEnd(int level);
}

The Iterators can do all the usual things that Iterators can do, except dereferencing. In addition, to do something useful, they support some additional methods:

template<unsigned topologyId, class CoordType, unsigned coerceToId, int dimension>
class VertexIterator
{
public:
typedef ImplementationDefined Refinement;
int index() const;
Refinement::CoordVector coords() const;
}
template<unsigned topologyId, class CoordType, unsigned coerceToId, int dimension>
class ElementIterator
{
public:
typedef ImplementationDefined Refinement;
int index() const;
// Coords of the center of mass of the element
Refinement::CoordVector coords() const;
Refinement::IndexVector vertexIndices() const;
}

How to use it

Either use VirtualRefinement, or if you don't want to do that, read on.

// Include the necessary files
#include <dune/grid/common/refinement.hh>
// If you know that you are only ever going to need one refinement
// backend, you can include the corresponding file directly:
//#include <dune/grid/common/refinement/hcube.cc>
// Get yourself the Refinement you need:
typedef StaticRefinement<GenericGeometry::CubeTopology<2>::type::id,
SGrid<2, 2>::ctype,
2> MyRefinement;
int main()
{
const int refinementlevel = 2;
cout << "Using refinementlevel = " << refinementlevel << endl << endl;
// get Number of Vertices
cout << "Number of Vertices: "
<< MyRefinement::nVertices(refinementlevel)
<< endl;
// Iterate over Vertices
cout << "Index\tx\ty" << endl;
MyRefinement::VertexIterator vEnd = MyRefinement::vEnd(refinementlevel);
for(MyRefinement::VertexIterator i = MyRefinement::vBegin(refinementlevel); i != vEnd; ++i)
cout << i.index() << "\t" << i.coords()[0] << "\t" << i.coords()[1] << endl;
cout << endl;
// Iterate over Vertices
cout << "Index\tEcke0\tEcke1\tEcke2\tEcke3" << endl;
MyRefinement::ElementIterator eEnd = MyRefinement::eEnd(refinementlevel);
for(MyRefinement::ElementIterator i = MyRefinement::eBegin(refinementlevel); i != eEnd; ++i)
cout << i.index() << "\t"
<< i.indexVertices()[0] << "\t" << i.indexVertices()[1] << "\t"
<< i.indexVertices()[2] << "\t" << i.indexVertices()[3] << endl;
cout << endl;
}

Guarantees

The Refinement system gives this guarantee (besides conforming to the above interface:

Implementing a new Refinement type

If you want to write a Refinement implementation for a particular geometry type, e.g. SquaringTheCircle (or a particular set of geometry types) here is how:

This is enough to integrate your implementation into the Refinement system. You probably want to include it into VirtualRefinement also.

Namespaces

The (non-virtual) Refinement system is organized in the following way into namespaces:

The complete VirtualRefinement stuff is directly in namespace Dune.

Conceptual layers

VirtualRefinement adds two more layers to the ones defined here.