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 supportet:
template<GeometryType::BasicType geometryType, class CoordType, GeometryType::BasicType coerceTo, int dimension> class Refinement { public: enum { dimension }; template<int codimension> struct codim { class SubEntityIterator; }; typedef VertexIterator; // These are aliases for codim<codim>::SubEntityIterator typedef ElementIterator; typedef IndexVector; // These are FieldVectors typedef 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<GeometryType::BasicType geometryType, class CoordType, GeometryType::BasicType coerceTo, int dimension> class VertexIterator { public: typedef Refinement; int index() const; Refinement::CoordVector coords() const; } template<GeometryType::BasicType geometryType, class CoordType, GeometryType::BasicType coerceTo, int dimension> class ElementIterator { public: typedef Refinement; int index() const; Refinement::IndexVector vertexIndices() const; }
// Include the neccessary 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 Refinement<GeometryType::cube, SGrid<2, 2>::ctype, GeometryType::cube, 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; }
namespace Dune::RefinementImp { // the "dim" template parameter is ignored, since the dimension can be infered template<class CoordType> struct Traits<GeometryType::sphere, CoordType, GeometryType::cube, 2> { typedef SquaringTheCircle::RefinementImp<CoordType> Imp; }; // we're only implementing this for dim=2 template<class CoordType> struct Traits<GeometryType::sphere, CoordType, GeometryType::cube, 2> { typedef SquaringTheCircle::RefinementImp<CoordType> Imp; }; template<class CoordType> struct Traits<GeometryType::circle, CoordType, GeometryType::cube, 2> { typedef SquaringTheCircle::RefinementImp<CoordType> Imp; }; template<class CoordType> struct Traits<GeometryType::sphere, CoordType, GeometryType::quadrilateral, 2> { typedef SquaringTheCircle::RefinementImp<CoordType> Imp; }; }
This is enough to integrate your implementation into the Refinement system. You probably want to include it into VirtualRefinement also.
The complete VirtualRefinement stuff is directly in namespace Dune.
VirtualRefinement adds two more layers to the ones defined here.
Modules | |
Refinement implementation for hypercubes | |
Refinement implementation for triangulating hypercubes | |
Refinement implementation for simplices | |
Virtual Refinement |