[Dune-devel] [PATCH 2/2] Add the IdentityGrid grid manager and rename all IdentityGrid to P4estGrid
Michaƫl Sghaier
sghaier.michael at gmail.com
Tue Mar 8 09:07:49 CET 2016
---
CMakeLists.txt | 2 +
dune/p4estgrid/p4estgrid.hh | 605 ++++++++++++++++++++-
dune/p4estgrid/p4estgrid/CMakeLists.txt | 14 +
dune/p4estgrid/p4estgrid/Makefile.am | 17 +
dune/p4estgrid/p4estgrid/p4estgridentity.hh | 466 ++++++++++++++++
dune/p4estgrid/p4estgrid/p4estgridentitypointer.hh | 120 ++++
dune/p4estgrid/p4estgrid/p4estgridentityseed.hh | 73 +++
dune/p4estgrid/p4estgrid/p4estgridgeometry.hh | 117 ++++
.../p4estgrid/p4estgridhierarchiciterator.hh | 60 ++
dune/p4estgrid/p4estgrid/p4estgridindexsets.hh | 300 ++++++++++
.../p4estgrid/p4estgridintersectioniterator.hh | 132 +++++
dune/p4estgrid/p4estgrid/p4estgridintersections.hh | 357 ++++++++++++
dune/p4estgrid/p4estgrid/p4estgridleafiterator.hh | 55 ++
dune/p4estgrid/p4estgrid/p4estgridleveliterator.hh | 59 ++
14 files changed, 2373 insertions(+), 4 deletions(-)
create mode 100644 dune/p4estgrid/p4estgrid/CMakeLists.txt
create mode 100644 dune/p4estgrid/p4estgrid/Makefile.am
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridentity.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridentitypointer.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridentityseed.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridgeometry.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridhierarchiciterator.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridindexsets.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridintersectioniterator.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridintersections.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridleafiterator.hh
create mode 100644 dune/p4estgrid/p4estgrid/p4estgridleveliterator.hh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec84852..df91a25 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,5 +24,7 @@ add_subdirectory("dune")
add_subdirectory("doc")
add_subdirectory("cmake/modules")
+set(ENABLE_HEADERCHECK 1)
+
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
diff --git a/dune/p4estgrid/p4estgrid.hh b/dune/p4estgrid/p4estgrid.hh
index 8aaaaaf..17f6d7c 100644
--- a/dune/p4estgrid/p4estgrid.hh
+++ b/dune/p4estgrid/p4estgrid.hh
@@ -1,6 +1,603 @@
-#ifndef DUNE_P4ESTGRID_HH
-#define DUNE_P4ESTGRID_HH
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_GRID_P4ESTGRID_HH
+#define DUNE_GRID_P4ESTGRID_HH
-// add your classes here
+/** \file
+ * \brief The P4estGrid class
+ */
-#endif // DUNE_P4ESTGRID_HH
+#include <string>
+#include <map>
+
+#include <dune/common/deprecated.hh>
+#include <dune/common/parallel/collectivecommunication.hh>
+#include <dune/grid/common/capabilities.hh>
+#include <dune/grid/common/grid.hh>
+
+// The components of the P4estGrid interface
+#include "p4estgrid/p4estgridgeometry.hh"
+#include "p4estgrid/p4estgridentity.hh"
+#include "p4estgrid/p4estgridentitypointer.hh"
+#include "p4estgrid/p4estgridentityseed.hh"
+#include "p4estgrid/p4estgridintersectioniterator.hh"
+#include "p4estgrid/p4estgridleveliterator.hh"
+#include "p4estgrid/p4estgridleafiterator.hh"
+#include "p4estgrid/p4estgridhierarchiciterator.hh"
+#include "p4estgrid/p4estgridindexsets.hh"
+
+namespace Dune
+{
+ // Forward declaration
+ template <class HostGrid>
+ class P4estGrid;
+
+ // External forward declarations
+ template< class Grid >
+ struct HostGridAccess;
+
+ namespace {
+
+ // This is just a placeholder to stuff into the standard
+ // GridTraits, as those expect an EntityPointer implementation
+ // with two template parameters, but our EntityPointer uses three.
+ template<int,typename>
+ struct DummyP4estGridEntityPointer
+ {};
+
+ }
+
+
+ template<int dim, class HostGrid>
+ struct P4estGridFamily
+ {
+
+ private:
+
+ // The type signature of our EntityPointer implementation does not fit into
+ // the scheme expected by GridTraits, so we have to provide our own Traits
+ // On the other hand, we don't want to retype everything, so we just inherit
+ // from the default Traits and just tweak the EntityPointer type in the derived
+ // Traits class
+
+ typedef GridTraits<
+ dim,
+ HostGrid::dimensionworld,
+ Dune::P4estGrid<HostGrid>,
+ P4estGridGeometry,
+ P4estGridEntity,
+ DummyP4estGridEntityPointer, // placeholder
+ P4estGridLevelIterator,
+ P4estGridLeafIntersection,
+ P4estGridLevelIntersection,
+ P4estGridLeafIntersectionIterator,
+ P4estGridLevelIntersectionIterator,
+ P4estGridHierarchicIterator,
+ P4estGridLeafIterator,
+ P4estGridLevelIndexSet< const P4estGrid<HostGrid> >,
+ P4estGridLeafIndexSet< const P4estGrid<HostGrid> >,
+ P4estGridGlobalIdSet< const P4estGrid<HostGrid> >,
+ typename HostGrid::Traits::GlobalIdSet::IdType,
+ P4estGridLocalIdSet< const P4estGrid<HostGrid> >,
+ typename HostGrid::Traits::LocalIdSet::IdType,
+ CollectiveCommunication<P4estGrid<HostGrid> >,
+ DefaultLevelGridViewTraits,
+ DefaultLeafGridViewTraits,
+ P4estGridEntitySeed
+ > BaseTraits;
+
+ public:
+
+ // inherit everyting from the default Traits...
+ struct Traits
+ : public BaseTraits
+ {
+
+ // Except for the Codim struct, which we reimplement, but which
+ // again inherits everything from the base class...
+ template<int codim>
+ struct Codim
+ : public BaseTraits::template Codim<codim>
+ {
+
+ // ... except for the EntityPointer, which we override with our
+ // actual implementation
+ typedef Dune::EntityPointer<
+ const typename BaseTraits::Grid,
+ P4estGridEntityPointer<
+ codim,
+ const typename BaseTraits::Grid,
+ typename HostGrid::template Codim<codim>::EntityPointer
+ >
+ > EntityPointer;
+
+ };
+
+ };
+
+ };
+
+ //**********************************************************************
+ //
+ // --P4estGrid
+ //
+ //************************************************************************
+ /*!
+ * \brief Provides a meta grid that is identical to its host
+ * \ingroup GridImplementations
+ * \ingroup P4estGrid
+ *
+ * \tparam HostGrid The host grid type wrapped by the P4estGrid
+ */
+ template <class HostGrid>
+ class P4estGrid
+ : public GridDefaultImplementation<HostGrid::dimension, HostGrid::dimensionworld,
+ typename HostGrid::ctype, P4estGridFamily<HostGrid::dimension, HostGrid> >
+ {
+ friend class P4estGridLevelIndexSet<const P4estGrid<HostGrid> >;
+ friend class P4estGridLeafIndexSet<const P4estGrid<HostGrid> >;
+ friend class P4estGridGlobalIdSet<const P4estGrid<HostGrid> >;
+ friend class P4estGridLocalIdSet<const P4estGrid<HostGrid> >;
+ friend class P4estGridHierarchicIterator<const P4estGrid<HostGrid> >;
+ friend class P4estGridLevelIntersectionIterator<const P4estGrid<HostGrid> >;
+ friend class P4estGridLeafIntersectionIterator<const P4estGrid<HostGrid> >;
+
+ template<int codim, PartitionIteratorType pitype, class GridImp_>
+ friend class P4estGridLevelIterator;
+
+ template<int codim, PartitionIteratorType pitype, class GridImp_>
+ friend class P4estGridLeafIterator;
+
+
+ template<int codim_, int dim_, class GridImp_>
+ friend class P4estGridEntity;
+
+ friend struct HostGridAccess< P4estGrid< HostGrid > >;
+
+ public:
+
+ /** \todo Should not be public */
+ typedef HostGrid HostGridType;
+
+ //**********************************************************
+ // The Interface Methods
+ //**********************************************************
+
+ //! type of the used GridFamily for this grid
+ typedef P4estGridFamily<HostGrid::dimension,HostGrid> GridFamily;
+
+ //! the Traits
+ typedef typename P4estGridFamily<HostGrid::dimension,HostGrid>::Traits Traits;
+
+ //! The type used to store coordinates, inherited from the HostGrid
+ typedef typename HostGrid::ctype ctype;
+
+
+ /** \brief Constructor
+ *
+ * \param hostgrid The host grid wrapped by the P4estGrid
+ */
+ explicit P4estGrid(HostGrid& hostgrid) :
+ hostgrid_(&hostgrid),
+ leafIndexSet_(*this),
+ globalIdSet_(*this),
+ localIdSet_(*this)
+ {
+ setIndices();
+ }
+
+ //! Desctructor
+ ~P4estGrid()
+ {
+ // Delete level index sets
+ for (size_t i=0; i<levelIndexSets_.size(); i++)
+ if (levelIndexSets_[i])
+ delete (levelIndexSets_[i]);
+ }
+
+
+ /** \brief Return maximum level defined in this grid.
+ *
+ * Levels are numbered 0 ... maxlevel with 0 the coarsest level.
+ */
+ int maxLevel() const {
+ return hostgrid_->maxLevel();
+ }
+
+ //! Iterator to first entity of given codim on level
+ template<int codim>
+ typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const {
+ return P4estGridLevelIterator<codim,All_Partition, const P4estGrid<HostGrid> >(this, level);
+ }
+
+
+ //! one past the end on this level
+ template<int codim>
+ typename Traits::template Codim<codim>::LevelIterator lend (int level) const {
+ return P4estGridLevelIterator<codim,All_Partition, const P4estGrid<HostGrid> >(this, level, true);
+ }
+
+
+ //! Iterator to first entity of given codim on level
+ template<int codim, PartitionIteratorType PiType>
+ typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const {
+ return P4estGridLevelIterator<codim,PiType, const P4estGrid<HostGrid> >(this, level);
+ }
+
+
+ //! one past the end on this level
+ template<int codim, PartitionIteratorType PiType>
+ typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const {
+ return P4estGridLevelIterator<codim,PiType, const P4estGrid<HostGrid> >(this, level, true);
+ }
+
+
+ //! Iterator to first leaf entity of given codim
+ template<int codim>
+ typename Traits::template Codim<codim>::LeafIterator leafbegin() const {
+ return P4estGridLeafIterator<codim,All_Partition, const P4estGrid<HostGrid> >(this);
+ }
+
+
+ //! one past the end of the sequence of leaf entities
+ template<int codim>
+ typename Traits::template Codim<codim>::LeafIterator leafend() const {
+ return P4estGridLeafIterator<codim,All_Partition, const P4estGrid<HostGrid> >(this, true);
+ }
+
+
+ //! Iterator to first leaf entity of given codim
+ template<int codim, PartitionIteratorType PiType>
+ typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const {
+ return P4estGridLeafIterator<codim,PiType, const P4estGrid<HostGrid> >(this);
+ }
+
+
+ //! one past the end of the sequence of leaf entities
+ template<int codim, PartitionIteratorType PiType>
+ typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const {
+ return P4estGridLeafIterator<codim,PiType, const P4estGrid<HostGrid> >(this, true);
+ }
+
+
+ /** \brief Number of grid entities per level and codim
+ */
+ int size (int level, int codim) const {
+ return hostgrid_->size(level,codim);
+ }
+
+ /** \brief returns the number of boundary segments within the macro grid
+ */
+ size_t numBoundarySegments () const {
+ return hostgrid_->numBoundarySegments();
+ }
+
+ //! number of leaf entities per codim in this process
+ int size (int codim) const {
+ return leafIndexSet().size(codim);
+ }
+
+
+ //! number of entities per level, codim and geometry type in this process
+ int size (int level, GeometryType type) const {
+ return levelIndexSets_[level]->size(type);
+ }
+
+
+ //! number of leaf entities per codim and geometry type in this process
+ int size (GeometryType type) const
+ {
+ return leafIndexSet().size(type);
+ }
+
+
+ /** \brief Access to the GlobalIdSet */
+ const typename Traits::GlobalIdSet& globalIdSet() const {
+ return globalIdSet_;
+ }
+
+
+ /** \brief Access to the LocalIdSet */
+ const typename Traits::LocalIdSet& localIdSet() const {
+ return localIdSet_;
+ }
+
+
+ /** \brief Access to the LevelIndexSets */
+ const typename Traits::LevelIndexSet& levelIndexSet(int level) const
+ {
+ if (level < 0 || level > maxLevel())
+ {
+ DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
+ }
+ return *levelIndexSets_[level];
+ }
+
+
+ /** \brief Access to the LeafIndexSet */
+ const typename Traits::LeafIndexSet& leafIndexSet() const
+ {
+ return leafIndexSet_;
+ }
+
+
+ /** \brief Create EntityPointer from EntitySeed
+ *
+ * \deprecated This method is deprecated and will be removed after the release of
+ * dune-grid 2.4. Please use entity() instead, which will directly return
+ * an Entity object that you can then store for later use. The EntityPointer
+ * concept in general is deprecated and will not be available after
+ * dune-grid 2.4 has been released.
+ */
+ template < class EntitySeed >
+ DUNE_DEPRECATED_MSG("entityPointer() is deprecated and will be removed after the release of dune-grid 2.4. Use entity() instead to directly obtain an Entity object.")
+ typename Traits::template Codim<EntitySeed::codimension>::EntityPointer
+ entityPointer(const EntitySeed& seed) const
+ {
+ typedef typename Traits::template Codim<EntitySeed::codimension>::EntityPointer EntityPointer;
+ typedef P4estGridEntityPointer<
+ EntitySeed::codimension,
+ const typename Traits::Grid,
+ typename HostGrid::template Codim<EntitySeed::codimension>::EntityPointer
+ > EntityPointerImp;
+
+ return EntityPointer(EntityPointerImp(this, hostgrid_->entity(this->getRealImplementation(seed).hostEntitySeed())));
+ }
+
+ /** \brief Create Entity from EntitySeed */
+ template < class EntitySeed >
+ typename Traits::template Codim<EntitySeed::codimension>::Entity
+ entity(const EntitySeed& seed) const
+ {
+ typedef P4estGridEntity<
+ EntitySeed::codimension,
+ HostGrid::dimension,
+ const typename Traits::Grid
+ > EntityImp;
+
+ return EntityImp(this, hostgrid_->entity(this->getRealImplementation(seed).hostEntitySeed()));
+ }
+
+
+ /** @name Grid Refinement Methods */
+ /*@{*/
+
+
+ /** global refinement
+ * \todo optimize implementation
+ */
+ void globalRefine (int refCount)
+ {
+ hostgrid_->globalRefine(refCount);
+ }
+
+ /** \brief Mark entity for refinement
+ *
+ * This only works for entities of codim 0.
+ * The parameter is currently ignored
+ *
+ * \return <ul>
+ * <li> true, if marking was succesfull </li>
+ * <li> false, if marking was not possible </li>
+ * </ul>
+ */
+ bool mark(int refCount, const typename Traits::template Codim<0>::Entity & e)
+ {
+ return hostgrid_->mark(refCount, getHostEntity<0>(e));
+ }
+
+ /** \brief Return refinement mark for entity
+ *
+ * \return refinement mark (1,0,-1)
+ */
+ int getMark(const typename Traits::template Codim<0>::Entity & e) const
+ {
+ return hostgrid_->getMark(getHostEntity<0>(e));
+ }
+
+ /** \brief returns true, if at least one entity is marked for adaption */
+ bool preAdapt() {
+ return hostgrid_->preAdapt();
+ }
+
+
+ //! Triggers the grid refinement process
+ bool adapt()
+ {
+ return hostgrid_->adapt();
+ }
+
+ /** \brief Clean up refinement markers */
+ void postAdapt() {
+ return hostgrid_->postAdapt();
+ }
+
+ /*@}*/
+
+ /** \brief Size of the overlap on the leaf level */
+ unsigned int overlapSize(int codim) const {
+ return hostgrid_->overlapSize(codim);
+ }
+
+
+ /** \brief Size of the ghost cell layer on the leaf level */
+ unsigned int ghostSize(int codim) const {
+ return hostgrid_->ghostSize(codim);
+ }
+
+
+ /** \brief Size of the overlap on a given level */
+ unsigned int overlapSize(int level, int codim) const {
+ return hostgrid_->overlapSize(level,codim);
+ }
+
+
+ /** \brief Size of the ghost cell layer on a given level */
+ unsigned int ghostSize(int level, int codim) const {
+ return hostgrid_->ghostSize(level,codim);
+ }
+
+
+#if 0
+ /** \brief Distributes this grid over the available nodes in a distributed machine
+ *
+ * \param minlevel The coarsest grid level that gets distributed
+ * \param maxlevel does currently get ignored
+ */
+ void loadBalance(int strategy, int minlevel, int depth, int maxlevel, int minelement){
+ DUNE_THROW(NotImplemented, "P4estGrid::loadBalance()");
+ }
+
+ /** \brief The communication interface
+ * @param T: array class holding data associated with the entities
+ * @param P: type used to gather/scatter data in and out of the message buffer
+ * @param codim: communicate entites of given codim
+ * @param if: one of the predifined interface types, throws error if it is not implemented
+ * @param level: communicate for entities on the given level
+ *
+ * Implements a generic communication function sending an object of type P for each entity
+ * in the intersection of two processors. P has two methods gather and scatter that implement
+ * the protocol. Therefore P is called the "protocol class".
+ */
+ template<class T, template<class> class P, int codim>
+ void communicate (T& t, InterfaceType iftype, CommunicationDirection dir, int level);
+
+ /*! The new communication interface
+
+ communicate objects for all codims on a given level
+ */
+ template<class DataHandle>
+ void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
+ {}
+
+ template<class DataHandle>
+ void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
+ {}
+#endif
+
+
+ /** \brief dummy collective communication */
+ const CollectiveCommunication<P4estGrid>& comm () const
+ {
+ return ccobj;
+ }
+
+
+ // **********************************************************
+ // End of Interface Methods
+ // **********************************************************
+
+ //! Returns the hostgrid this P4estGrid lives in
+ HostGridType& getHostGrid() const
+ {
+ return *hostgrid_;
+ }
+
+
+ //! Returns the hostgrid entity encapsulated in given P4estGrid entity
+ template <int codim>
+ DUNE_DEPRECATED_MSG("getHostEntityPointer() is deprecated and will be removed after the release of dune-grid 2.4. Use getHostEntity() instead to obtain a reference to the host entity object.")
+ typename HostGrid::Traits::template Codim<codim>::EntityPointer getHostEntityPointer(const typename Traits::template Codim<codim>::Entity& e) const
+ {
+ return this->getRealImplementation(e).hostEntity_;
+ }
+
+ template <int codim>
+ const typename HostGrid::Traits::template Codim<codim>::Entity& getHostEntity(const typename Traits::template Codim<codim>::Entity& e) const
+ {
+ return this->getRealImplementation(e).hostEntity_;
+ }
+
+ protected:
+
+ //! The host grid which contains the actual grid hierarchy structure
+ HostGrid* hostgrid_;
+
+ private:
+
+ //! compute the grid indices and ids
+ void setIndices()
+ {
+ localIdSet_.update();
+
+ globalIdSet_.update();
+
+ // //////////////////////////////////////////
+ // Create the index sets
+ // //////////////////////////////////////////
+ for (int i=levelIndexSets_.size(); i<=maxLevel(); i++) {
+ P4estGridLevelIndexSet<const P4estGrid<HostGrid> >* p
+ = new P4estGridLevelIndexSet<const P4estGrid<HostGrid> >();
+ levelIndexSets_.push_back(p);
+ }
+
+ for (int i=0; i<=maxLevel(); i++)
+ if (levelIndexSets_[i])
+ levelIndexSets_[i]->update(*this, i);
+
+ leafIndexSet_.update(*this);
+
+ }
+
+ //! \todo Please doc me !
+ CollectiveCommunication<P4estGrid> ccobj;
+
+ //! Our set of level indices
+ std::vector<P4estGridLevelIndexSet<const P4estGrid<HostGrid> >*> levelIndexSets_;
+
+ //! \todo Please doc me !
+ P4estGridLeafIndexSet<const P4estGrid<HostGrid> > leafIndexSet_;
+
+ //! \todo Please doc me !
+ P4estGridGlobalIdSet<const P4estGrid<HostGrid> > globalIdSet_;
+
+ //! \todo Please doc me !
+ P4estGridLocalIdSet<const P4estGrid<HostGrid> > localIdSet_;
+
+ }; // end Class P4estGrid
+
+
+
+
+ namespace Capabilities
+ {
+ /** \brief has entities for some codimensions as host grid
+ * \ingroup P4estGrid
+ */
+ template<class HostGrid, int codim>
+ struct hasEntity<P4estGrid<HostGrid>, codim>
+ {
+ static const bool v = hasEntity<HostGrid,codim>::v;
+ };
+
+ /** \brief is parallel when host grid is
+ * \ingroup P4estGrid
+ */
+ template<class HostGrid>
+ struct DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") isParallel<P4estGrid<HostGrid> >
+ {
+ static const bool DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") v = isParallel<HostGrid>::v;
+ };
+
+ /** \brief has conforming level grids when host grid has
+ * \ingroup P4estGrid
+ */
+ template<class HostGrid>
+ struct isLevelwiseConforming<P4estGrid<HostGrid> >
+ {
+ static const bool v = isLevelwiseConforming<HostGrid>::v;
+ };
+
+ /** \brief has conforming leaf grids when host grid has
+ * \ingroup P4estGrid
+ */
+ template<class HostGrid>
+ struct isLeafwiseConforming<P4estGrid<HostGrid> >
+ {
+ static const bool v = isLeafwiseConforming<HostGrid>::v;
+ };
+ } // end namespace Capabilities
+
+} // namespace Dune
+
+#endif // DUNE_GRID_P4ESTGRID_HH
diff --git a/dune/p4estgrid/p4estgrid/CMakeLists.txt b/dune/p4estgrid/p4estgrid/CMakeLists.txt
new file mode 100644
index 0000000..f3c1d0b
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/CMakeLists.txt
@@ -0,0 +1,14 @@
+set(HEADERS
+ p4estgridentity.hh
+ p4estgridentitypointer.hh
+ p4estgridentityseed.hh
+ p4estgridhierarchiciterator.hh
+ p4estgridgeometry.hh
+ p4estgridintersectioniterator.hh
+ p4estgridintersections.hh
+ p4estgridindexsets.hh
+ p4estgridleafiterator.hh
+ p4estgridleveliterator.hh)
+
+install(FILES ${HEADERS}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/grid/p4estgrid)
diff --git a/dune/p4estgrid/p4estgrid/Makefile.am b/dune/p4estgrid/p4estgrid/Makefile.am
new file mode 100644
index 0000000..21ff710
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/Makefile.am
@@ -0,0 +1,17 @@
+p4estgriddir = $(includedir)/dune/grid/p4estgrid
+
+p4estgrid_HEADERS = \
+ p4estgridentity.hh \
+ p4estgridentitypointer.hh \
+ p4estgridentityseed.hh \
+ p4estgridhierarchiciterator.hh \
+ p4estgridgeometry.hh \
+ p4estgridintersectioniterator.hh \
+ p4estgridintersections.hh \
+ p4estgridindexsets.hh \
+ p4estgridleafiterator.hh \
+ p4estgridleveliterator.hh
+
+EXTRA_DIST = CMakeLists.txt
+
+include $(top_srcdir)/am/global-rules
diff --git a/dune/p4estgrid/p4estgrid/p4estgridentity.hh b/dune/p4estgrid/p4estgrid/p4estgridentity.hh
new file mode 100644
index 0000000..c6b08d4
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridentity.hh
@@ -0,0 +1,466 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRIDENTITY_HH
+#define DUNE_P4ESTGRIDENTITY_HH
+
+/** \file
+ * \brief The P4estGridEntity class
+ */
+
+#include <dune/grid/common/grid.hh>
+
+namespace Dune {
+
+
+ // Forward declarations
+
+ template<int codim, int dim, class GridImp>
+ class P4estGridEntity;
+
+ template<int codim, class GridImp, typename HostEntityPointer>
+ class P4estGridEntityPointer;
+
+ template<int codim, PartitionIteratorType pitype, class GridImp>
+ class P4estGridLevelIterator;
+
+ template<class GridImp>
+ class P4estGridLevelIntersectionIterator;
+
+ template<class GridImp>
+ class P4estGridLeafIntersectionIterator;
+
+ template<class GridImp>
+ class P4estGridHierarchicIterator;
+
+
+ // External forward declarations
+ template< class Grid >
+ struct HostGridAccess;
+
+
+ //**********************************************************************
+ //
+ // --P4estGridEntity
+ // --Entity
+ //
+ /** \brief The implementation of entities in a P4estGrid
+ * \ingroup P4estGrid
+ *
+ * A Grid is a container of grid entities. An entity is parametrized by the codimension.
+ * An entity of codimension c in dimension d is a d-c dimensional object.
+ *
+ */
+ template<int codim, int dim, class GridImp>
+ class P4estGridEntity :
+ public EntityDefaultImplementation <codim,dim,GridImp,P4estGridEntity>
+ {
+
+ template <class GridImp_>
+ friend class P4estGridLevelIndexSet;
+
+ template <class GridImp_>
+ friend class P4estGridLeafIndexSet;
+
+ template <class GridImp_>
+ friend class P4estGridLocalIdSet;
+
+ template <class GridImp_>
+ friend class P4estGridGlobalIdSet;
+
+ template<int,typename, typename>
+ friend class P4estGridEntityPointer;
+
+ friend struct HostGridAccess< typename remove_const< GridImp >::type >;
+
+
+ private:
+
+ typedef typename GridImp::ctype ctype;
+
+ // The codimension of this entitypointer wrt the host grid
+ enum {CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension + codim};
+
+ // EntityPointer to the equivalent entity in the host grid
+ typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
+
+
+ public:
+
+ typedef typename GridImp::template Codim<codim>::Geometry Geometry;
+
+ //! The type of the EntitySeed interface class
+ typedef typename GridImp::template Codim<codim>::EntitySeed EntitySeed;
+
+ P4estGridEntity()
+ : p4estgrid_(nullptr)
+ {}
+
+ P4estGridEntity(const GridImp* p4estgrid, const HostGridEntity& hostEntity)
+ : hostEntity_(hostEntity)
+ , p4estgrid_(p4estgrid)
+ {}
+
+ P4estGridEntity(const GridImp* p4estgrid, HostGridEntity&& hostEntity)
+ : hostEntity_(std::move(hostEntity))
+ , p4estgrid_(p4estgrid)
+ {}
+
+ //! \todo Please doc me !
+ P4estGridEntity(const P4estGridEntity& original)
+ : hostEntity_(original.hostEntity_)
+ , p4estgrid_(original.p4estgrid_)
+ {}
+
+ P4estGridEntity(P4estGridEntity&& original)
+ : hostEntity_(std::move(original.hostEntity_))
+ , p4estgrid_(original.p4estgrid_)
+ {}
+
+ //! \todo Please doc me !
+ P4estGridEntity& operator=(const P4estGridEntity& original)
+ {
+ if (this != &original)
+ {
+ p4estgrid_ = original.p4estgrid_;
+ hostEntity_ = original.hostEntity_;
+ }
+ return *this;
+ }
+
+ //! \todo Please doc me !
+ P4estGridEntity& operator=(P4estGridEntity&& original)
+ {
+ if (this != &original)
+ {
+ p4estgrid_ = original.p4estgrid_;
+ hostEntity_ = std::move(original.hostEntity_);
+ }
+ return *this;
+ }
+
+ bool equals(const P4estGridEntity& other) const
+ {
+ return hostEntity_ == other.hostEntity_;
+ }
+
+ //! returns true if father entity exists
+ bool hasFather () const {
+ return hostEntity_.hasFather();
+ }
+
+ //! Create EntitySeed
+ EntitySeed seed () const
+ {
+ return EntitySeed(hostEntity_);
+ }
+
+ //! level of this element
+ int level () const {
+ return hostEntity_.level();
+ }
+
+
+ /** \brief The partition type for parallel computing
+ */
+ PartitionType partitionType () const {
+ return hostEntity_.partitionType();
+ }
+
+
+ /** Intra-element access to entities of codimension cc > codim. Return number of entities
+ * with codimension cc.
+ */
+ template<int cc> int count () const {
+ return hostEntity_.template count<cc>();
+ }
+
+
+ //! geometry of this entity
+ Geometry geometry () const
+ {
+ return Geometry( hostEntity_.geometry() );
+ }
+
+
+ HostGridEntity hostEntity_;
+
+ private:
+
+ const GridImp* p4estgrid_;
+
+ };
+
+
+
+
+ //***********************
+ //
+ // --P4estGridEntity
+ //
+ //***********************
+ /** \brief Specialization for codim-0-entities.
+ * \ingroup P4estGrid
+ *
+ * This class embodies the topological parts of elements of the grid.
+ * It has an extended interface compared to the general entity class.
+ * For example, Entities of codimension 0 allow to visit all neighbors.
+ */
+ template<int dim, class GridImp>
+ class P4estGridEntity<0,dim,GridImp> :
+ public EntityDefaultImplementation<0,dim,GridImp, P4estGridEntity>
+ {
+ friend struct HostGridAccess< typename remove_const< GridImp >::type >;
+
+ template<int,typename, typename>
+ friend class P4estGridEntityPointer;
+
+ public:
+
+ // The codimension of this entitypointer wrt the host grid
+ enum {CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension};
+
+ // EntityPointer to the equivalent entity in the host grid
+ typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
+
+ typedef typename GridImp::template Codim<0>::Geometry Geometry;
+
+ typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
+
+ //! The Iterator over intersections on this level
+ typedef P4estGridLevelIntersectionIterator<GridImp> LevelIntersectionIterator;
+
+ //! The Iterator over intersections on the leaf level
+ typedef P4estGridLeafIntersectionIterator<GridImp> LeafIntersectionIterator;
+
+ //! Iterator over descendants of the entity
+ typedef P4estGridHierarchicIterator<GridImp> HierarchicIterator;
+
+ //! The type of the EntitySeed interface class
+ typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
+
+
+
+ P4estGridEntity()
+ : p4estgrid_(nullptr)
+ {}
+
+ P4estGridEntity(const GridImp* p4estgrid, const HostGridEntity& hostEntity)
+ : hostEntity_(hostEntity)
+ , p4estgrid_(p4estgrid)
+ {}
+
+ P4estGridEntity(const GridImp* p4estgrid, HostGridEntity&& hostEntity)
+ : hostEntity_(std::move(hostEntity))
+ , p4estgrid_(p4estgrid)
+ {}
+
+ //! \todo Please doc me !
+ P4estGridEntity(const P4estGridEntity& original)
+ : hostEntity_(original.hostEntity_)
+ , p4estgrid_(original.p4estgrid_)
+ {}
+
+ P4estGridEntity(P4estGridEntity&& original)
+ : hostEntity_(std::move(original.hostEntity_))
+ , p4estgrid_(original.p4estgrid_)
+ {}
+
+ //! \todo Please doc me !
+ P4estGridEntity& operator=(const P4estGridEntity& original)
+ {
+ if (this != &original)
+ {
+ p4estgrid_ = original.p4estgrid_;
+ hostEntity_ = original.hostEntity_;
+ }
+ return *this;
+ }
+
+ //! \todo Please doc me !
+ P4estGridEntity& operator=(P4estGridEntity&& original)
+ {
+ if (this != &original)
+ {
+ p4estgrid_ = original.p4estgrid_;
+ hostEntity_ = std::move(original.hostEntity_);
+ }
+ return *this;
+ }
+
+ bool equals(const P4estGridEntity& other) const
+ {
+ return hostEntity_ == other.hostEntity_;
+ }
+
+ //! returns true if father entity exists
+ bool hasFather () const {
+ return hostEntity_.hasFather();
+ }
+
+ //! Create EntitySeed
+ EntitySeed seed () const
+ {
+ return EntitySeed(hostEntity_);
+ }
+
+ //! Level of this element
+ int level () const
+ {
+ return hostEntity_.level();
+ }
+
+
+ /** \brief The partition type for parallel computing */
+ PartitionType partitionType () const {
+ return hostEntity_.partitionType();
+ }
+
+
+ //! Geometry of this entity
+ Geometry geometry () const
+ {
+ return Geometry( hostEntity_.geometry() );
+ }
+
+
+ /** \brief Return the number of subEntities of codimension cc.
+ */
+ template<int cc>
+ int count () const
+ {
+ return hostEntity_.template count<cc>();
+ }
+
+
+ /** \brief Return the number of subEntities of codimension codim.
+ */
+ unsigned int subEntities (unsigned int codim) const
+ {
+ return hostEntity_.subEntities(codim);
+ }
+
+
+ /** \brief Provide access to sub entity i of given codimension. Entities
+ * are numbered 0 ... count<cc>()-1
+ */
+ template<int cc>
+ typename GridImp::template Codim<cc>::Entity subEntity (int i) const {
+ return P4estGridEntity<cc,dim,GridImp>(p4estgrid_, hostEntity_.template subEntity<cc>(i));
+ }
+
+
+ //! First level intersection
+ P4estGridLevelIntersectionIterator<GridImp> ilevelbegin () const {
+ return P4estGridLevelIntersectionIterator<GridImp>(
+ p4estgrid_,
+ p4estgrid_->getHostGrid().levelGridView(level()).ibegin(hostEntity_));
+ }
+
+
+ //! Reference to one past the last neighbor
+ P4estGridLevelIntersectionIterator<GridImp> ilevelend () const {
+ return P4estGridLevelIntersectionIterator<GridImp>(
+ p4estgrid_,
+ p4estgrid_->getHostGrid().levelGridView(level()).iend(hostEntity_));
+ }
+
+
+ //! First leaf intersection
+ P4estGridLeafIntersectionIterator<GridImp> ileafbegin () const {
+ return P4estGridLeafIntersectionIterator<GridImp>(
+ p4estgrid_,
+ p4estgrid_->getHostGrid().leafGridView().ibegin(hostEntity_));
+ }
+
+
+ //! Reference to one past the last leaf intersection
+ P4estGridLeafIntersectionIterator<GridImp> ileafend () const {
+ return P4estGridLeafIntersectionIterator<GridImp>(
+ p4estgrid_,
+ p4estgrid_->getHostGrid().leafGridView().iend(hostEntity_));
+ }
+
+
+ //! returns true if Entity has NO children
+ bool isLeaf() const {
+ return hostEntity_.isLeaf();
+ }
+
+
+ //! Inter-level access to father element on coarser grid.
+ //! Assumes that meshes are nested.
+ typename GridImp::template Codim<0>::Entity father () const {
+ return P4estGridEntity(p4estgrid_, hostEntity_.father());
+ }
+
+
+ /** \brief Location of this element relative to the reference element element of the father.
+ * This is sufficient to interpolate all dofs in conforming case.
+ * Nonconforming may require access to neighbors of father and
+ * computations with local coordinates.
+ * On the fly case is somewhat inefficient since dofs are visited several times.
+ * If we store interpolation matrices, this is tolerable. We assume that on-the-fly
+ * implementation of numerical algorithms is only done for simple discretizations.
+ * Assumes that meshes are nested.
+ */
+ LocalGeometry geometryInFather () const
+ {
+ return LocalGeometry( hostEntity_.geometryInFather() );
+ }
+
+
+ /** \brief Inter-level access to son elements on higher levels<=maxlevel.
+ * This is provided for sparsely stored nested unstructured meshes.
+ * Returns iterator to first son.
+ */
+ P4estGridHierarchicIterator<GridImp> hbegin (int maxLevel) const
+ {
+ return P4estGridHierarchicIterator<const GridImp>(p4estgrid_, *this, maxLevel);
+ }
+
+
+ //! Returns iterator to one past the last son
+ P4estGridHierarchicIterator<GridImp> hend (int maxLevel) const
+ {
+ return P4estGridHierarchicIterator<const GridImp>(p4estgrid_, *this, maxLevel, true);
+ }
+
+
+ //! \todo Please doc me !
+ bool wasRefined () const
+ {
+ if (p4estgrid_->adaptationStep!=GridImp::adaptDone)
+ return false;
+
+ int level = this->level();
+ int index = p4estgrid_->levelIndexSet(level).index(*this);
+ return p4estgrid_->refinementMark_[level][index];
+ }
+
+
+ //! \todo Please doc me !
+ bool mightBeCoarsened () const
+ {
+ return true;
+ }
+
+
+ // /////////////////////////////////////////
+ // Internal stuff
+ // /////////////////////////////////////////
+
+
+ HostGridEntity hostEntity_;
+ const GridImp* p4estgrid_;
+
+ private:
+
+ typedef typename GridImp::ctype ctype;
+
+ }; // end of P4estGridEntity codim = 0
+
+
+} // namespace Dune
+
+
+#endif
diff --git a/dune/p4estgrid/p4estgrid/p4estgridentitypointer.hh b/dune/p4estgrid/p4estgrid/p4estgridentitypointer.hh
new file mode 100644
index 0000000..2778dae
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridentitypointer.hh
@@ -0,0 +1,120 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRID_ENTITY_POINTER_HH
+#define DUNE_P4ESTGRID_ENTITY_POINTER_HH
+
+#include "p4estgridentity.hh"
+
+/** \file
+ * \brief The P4estGridEntityPointer class
+ */
+
+namespace Dune {
+
+
+ /** Acts as a pointer to an entities of a given codimension.
+ */
+ template<int codim, class GridImp, class HostGridEntityPointer_>
+ class P4estGridEntityPointer
+ {
+ private:
+
+ enum { dim = GridImp::dimension };
+
+ template<int, typename, typename>
+ friend class P4estGridEntityPointer;
+
+
+ public:
+
+ //! export the type of the EntityPointer Implementation.
+ //! Necessary for the typeconversion between Iterators and EntityPointer
+ typedef P4estGridEntityPointer EntityPointerImp;
+
+ /** \brief Codimension of entity pointed to */
+ enum { codimension = codim };
+
+ typedef typename GridImp::template Codim<codim>::Entity Entity;
+
+ // The codimension of this entitypointer wrt the host grid
+ enum {CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension + codim};
+
+ // EntityPointer to the equivalent entity in the host grid
+ typedef HostGridEntityPointer_ HostGridEntityPointer;
+
+
+ //! constructor
+ P4estGridEntityPointer (const GridImp* p4estgrid, const HostGridEntityPointer& hostEntityPointer)
+ : p4estgrid_(p4estgrid)
+ , hostEntityPointer_(hostEntityPointer)
+ {}
+
+ ///! copy constructor from EntityPointer storing different host EntityPointer
+ template<typename ForeignHostGridEntityPointer>
+ explicit P4estGridEntityPointer (const P4estGridEntityPointer<codim,GridImp,ForeignHostGridEntityPointer>& entityPointer)
+ : p4estgrid_(entityPointer.p4estgrid_)
+ , hostEntityPointer_(entityPointer.hostEntityPointer_)
+ {}
+
+ ///! assignment operator from EntityPointer storing different host EntityPointer
+ template<typename ForeignHostGridEntityPointer>
+ P4estGridEntityPointer& operator=(const P4estGridEntityPointer<codim,GridImp,ForeignHostGridEntityPointer>& entityPointer)
+ {
+ hostEntityPointer_ = entityPointer.hostEntityPointer_;
+ return *this;
+ }
+
+ //! Move constructor to avoid copying the host EntityPointer
+ P4estGridEntityPointer (const GridImp* p4estgrid, HostGridEntityPointer&& hostEntityPointer)
+ : p4estgrid_(p4estgrid)
+ , hostEntityPointer_(std::move(hostEntityPointer))
+ {}
+
+ //! Constructor from an P4estGrid entity
+ P4estGridEntityPointer (const P4estGridEntity<codim,dim,GridImp>& entity)
+ : p4estgrid_(entity.p4estgrid_)
+ , hostEntityPointer_(entity.hostEntity_)
+ {}
+
+ //! equality
+ bool equals(const P4estGridEntityPointer& i) const {
+ return hostEntityPointer_ == i.hostEntityPointer_;
+ }
+
+ //! equality with EntityPointer based on different host EntityPointer
+ template<typename ForeignHostGridEntityPointer>
+ bool equals(const P4estGridEntityPointer<codim,GridImp,ForeignHostGridEntityPointer>& entityPointer) const
+ {
+ return hostEntityPointer_ == entityPointer.hostEntityPointer_;
+ }
+
+ //! dereferencing
+ Entity dereference() const {
+ return Entity{{p4estgrid_,*hostEntityPointer_}};
+ }
+
+ //! Make this pointer as small as possible
+ void compactify () {
+ //virtualEntity_.getTarget().compactify();
+ }
+
+ //! ask for level of entity
+ int level () const {
+ return hostEntityPointer_->level();
+ }
+
+
+ protected:
+
+ const GridImp* p4estgrid_;
+
+ //! host EntityPointer
+ HostGridEntityPointer hostEntityPointer_;
+
+
+ };
+
+
+} // end namespace Dune
+
+#endif
diff --git a/dune/p4estgrid/p4estgrid/p4estgridentityseed.hh b/dune/p4estgrid/p4estgrid/p4estgridentityseed.hh
new file mode 100644
index 0000000..b25e4c7
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridentityseed.hh
@@ -0,0 +1,73 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_IDENTITY_GRID_ENTITY_SEED_HH
+#define DUNE_IDENTITY_GRID_ENTITY_SEED_HH
+
+/**
+ * \file
+ * \brief The P4estGridEntitySeed class
+ */
+
+
+namespace Dune {
+
+
+ /**
+ * \brief The EntitySeed class provides the minimal information needed to restore an Entity using the grid.
+ * \ingroup P4estGrid
+ *
+ */
+ template<int codim, class GridImp>
+ class P4estGridEntitySeed
+ {
+ protected:
+
+ // Entity type of the hostgrid
+ typedef typename GridImp::HostGridType::Traits::template Codim<codim>::Entity HostEntity;
+
+ // EntitySeed type of the hostgrid
+ typedef typename GridImp::HostGridType::Traits::template Codim<codim>::EntitySeed HostEntitySeed;
+
+ public:
+
+ enum {codimension = codim};
+
+ /**
+ * \brief Construct an empty (i.e. isValid() == false) seed.
+ */
+ P4estGridEntitySeed()
+ {}
+
+ /**
+ * \brief Create EntitySeed from hostgrid Entity
+ *
+ * We call hostEntity.seed() directly in the constructor
+ * of P4estGridEntitySeed to allow for return value optimization.
+ */
+ P4estGridEntitySeed(const HostEntity& hostEntity) :
+ hostEntitySeed_(hostEntity.seed())
+ {}
+
+ /**
+ * \brief Get stored HostEntitySeed
+ */
+ const HostEntitySeed& hostEntitySeed() const
+ {
+ return hostEntitySeed_;
+ }
+
+ /**
+ * \brief Check whether it is safe to create an Entity from this Seed
+ */
+ bool isValid() const
+ {
+ return hostEntitySeed_.isValid();
+ }
+ private:
+
+ HostEntitySeed hostEntitySeed_;
+ };
+
+} // namespace Dune
+
+#endif // #define DUNE_IDENTITY_GRID_ENTITY_SEED_HH
diff --git a/dune/p4estgrid/p4estgrid/p4estgridgeometry.hh b/dune/p4estgrid/p4estgrid/p4estgridgeometry.hh
new file mode 100644
index 0000000..3bb63ef
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridgeometry.hh
@@ -0,0 +1,117 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRIDGEOMETRY_HH
+#define DUNE_P4ESTGRIDGEOMETRY_HH
+
+/** \file
+ * \brief The P4estGridGeometry class and its specializations
+ */
+
+#include <dune/common/fmatrix.hh>
+#include <dune/common/typetraits.hh>
+#include <dune/grid/common/geometry.hh>
+
+namespace Dune {
+
+ template<int mydim, int coorddim, class GridImp>
+ class P4estGridGeometry :
+ public GeometryDefaultImplementation <mydim, coorddim, GridImp, P4estGridGeometry>
+ {
+ private:
+
+ typedef typename GridImp::ctype ctype;
+
+
+ public:
+
+ // The codimension of this entitypointer wrt the host grid
+ enum {CodimInHostGrid = GridImp::HostGridType::dimension - mydim};
+ enum {DimensionWorld = GridImp::HostGridType::dimensionworld};
+
+ // select appropiate hostgrid geometry via typeswitch
+ typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Geometry HostGridGeometryType;
+ typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Geometry HostGridLocalGeometryType;
+
+ typedef typename conditional<coorddim==DimensionWorld, HostGridGeometryType, HostGridLocalGeometryType>::type HostGridGeometry;
+
+ //! type of jacobian transposed
+ typedef typename HostGridGeometryType::JacobianInverseTransposed JacobianInverseTransposed;
+ typedef typename HostGridGeometryType::JacobianTransposed JacobianTransposed;
+
+
+ /** constructor from host geometry
+ */
+ P4estGridGeometry(const HostGridGeometry& hostGeometry)
+ : hostGeometry_(hostGeometry)
+ {}
+
+
+ /** \brief Return the element type identifier
+ */
+ GeometryType type () const {
+ return hostGeometry_.type();
+ }
+
+ // return wether we have an affine mapping
+ bool affine() const {
+ return hostGeometry_.affine();
+ }
+
+ //! return the number of corners of this element. Corners are numbered 0...n-1
+ int corners () const {
+ return hostGeometry_.corners();
+ }
+
+
+ //! access to coordinates of corners. Index is the number of the corner
+ const FieldVector<ctype, coorddim> corner (int i) const {
+ return hostGeometry_.corner(i);
+ }
+
+
+ /** \brief Maps a local coordinate within reference element to
+ * global coordinate in element */
+ FieldVector<ctype, coorddim> global (const FieldVector<ctype, mydim>& local) const {
+ return hostGeometry_.global(local);
+ }
+
+ /** \brief Return the transposed of the Jacobian
+ */
+ JacobianTransposed
+ jacobianTransposed ( const FieldVector<ctype, mydim>& local ) const {
+ return hostGeometry_.jacobianTransposed(local);
+ }
+
+ /** \brief Maps a global coordinate within the element to a
+ * local coordinate in its reference element */
+ FieldVector<ctype, mydim> local (const FieldVector<ctype, coorddim>& global) const {
+ return hostGeometry_.local(global);
+ }
+
+
+ //! Returns true if the point is in the current element
+ bool checkInside(const FieldVector<ctype, mydim> &local) const {
+ return hostGeometry_.checkInside(local);
+ }
+
+
+ /**
+ */
+ ctype integrationElement (const FieldVector<ctype, mydim>& local) const {
+ return hostGeometry_.integrationElement(local);
+ }
+
+
+ //! The Jacobian matrix of the mapping from the reference element to this element
+ JacobianInverseTransposed jacobianInverseTransposed (const FieldVector<ctype, mydim>& local) const {
+ return hostGeometry_.jacobianInverseTransposed(local);
+ }
+
+
+ HostGridGeometry hostGeometry_;
+
+ };
+
+} // namespace Dune
+
+#endif
diff --git a/dune/p4estgrid/p4estgrid/p4estgridhierarchiciterator.hh b/dune/p4estgrid/p4estgrid/p4estgridhierarchiciterator.hh
new file mode 100644
index 0000000..e03e368
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridhierarchiciterator.hh
@@ -0,0 +1,60 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRIDHIERITERATOR_HH
+#define DUNE_P4ESTGRIDHIERITERATOR_HH
+
+#include "p4estgridentitypointer.hh"
+/** \file
+ * \brief The P4estGridHierarchicIterator class
+ */
+
+namespace Dune {
+
+
+ //**********************************************************************
+ //
+ /** \brief Iterator over the descendants of an entity.
+ * \ingroup P4estGrid
+ Mesh entities of codimension 0 ("elements") allow to visit all entities of
+ codimension 0 obtained through nested, hierarchic refinement of the entity.
+ Iteration over this set of entities is provided by the HierarchicIterator,
+ starting from a given entity.
+ */
+ template<class GridImp>
+ class P4estGridHierarchicIterator :
+ public Dune::P4estGridEntityPointer<0,GridImp,typename GridImp::HostGridType::template Codim<0>::Entity::HierarchicIterator>
+ {
+
+ // Type of the corresponding HierarchicIterator in the host grid
+ typedef typename GridImp::HostGridType::template Codim<0>::Entity::HierarchicIterator HostGridHierarchicIterator;
+
+ typedef Dune::P4estGridEntityPointer<0,GridImp,typename GridImp::HostGridType::template Codim<0>::Entity::HierarchicIterator> Base;
+
+ public:
+
+ typedef typename Base::Entity Entity;
+
+ //! the default Constructor
+ explicit P4estGridHierarchicIterator(const GridImp* p4estgrid, const Entity& startEntity, int maxLevel) :
+ Base(p4estgrid, GridImp::getRealImplementation(startEntity).hostEntity_.hbegin(maxLevel))
+ {}
+
+
+ //! \todo Please doc me !
+ explicit P4estGridHierarchicIterator(const GridImp* p4estgrid, const Entity& startEntity, int maxLevel, bool endDummy) :
+ Base(p4estgrid, GridImp::getRealImplementation(startEntity).hostEntity_.hend(maxLevel))
+ {}
+
+
+ //! \todo Please doc me !
+ void increment()
+ {
+ ++this->hostEntityPointer_;
+ }
+
+ };
+
+
+} // end namespace Dune
+
+#endif
diff --git a/dune/p4estgrid/p4estgrid/p4estgridindexsets.hh b/dune/p4estgrid/p4estgrid/p4estgridindexsets.hh
new file mode 100644
index 0000000..059fcd9
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridindexsets.hh
@@ -0,0 +1,300 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRID_INDEXSETS_HH
+#define DUNE_P4ESTGRID_INDEXSETS_HH
+
+/** \file
+ * \brief The index and id sets for the P4estGrid class
+ */
+
+#include <dune/grid/common/indexidset.hh>
+
+#include <vector>
+
+namespace Dune {
+
+ /** \todo Take the index types from the host grid */
+ template<class GridImp>
+ class P4estGridLevelIndexSet :
+ public IndexSet<GridImp,
+ P4estGridLevelIndexSet<GridImp>,
+ typename remove_const<GridImp>::type::HostGridType::LevelGridView::IndexSet::IndexType,
+ typename remove_const<GridImp>::type::HostGridType::LevelGridView::IndexSet::Types
+ >
+ {
+ public:
+
+ typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
+ typedef typename HostGrid::LevelGridView::IndexSet::Types Types;
+
+ enum {dim = GridImp::dimension};
+
+ //! get index of an entity
+ template<int codim>
+ int index (const typename GridImp::Traits::template Codim<codim>::Entity& e) const
+ {
+ return grid_->hostgrid_->levelIndexSet(level_).template index<codim>(grid_->template getHostEntity<codim>(e));
+ }
+
+
+ //! get index of subEntity of a codim 0 entity
+ template<int cc>
+ int subIndex (const typename GridImp::Traits::template Codim<cc>::Entity& e, int i, int codim) const
+ {
+ return grid_->hostgrid_->levelIndexSet(level_).subIndex(grid_->template getHostEntity<cc>(e), i, codim);
+ }
+
+
+ //! get number of entities of given codim, type and on this level
+ int size (int codim) const {
+ return grid_->hostgrid_->levelIndexSet(level_).size(codim);
+ }
+
+
+ //! get number of entities of given codim, type and on this level
+ int size (GeometryType type) const
+ {
+ return grid_->hostgrid_->levelIndexSet(level_).size(type);
+ }
+
+
+ /** \brief Deliver all geometry types used in this grid */
+ const std::vector<GeometryType>& geomTypes (int codim) const
+ {
+ return grid_->hostgrid_->levelIndexSet(level_).geomTypes(codim);
+ }
+
+ /** \brief Deliver all geometry types used in this grid */
+ Types types (int codim) const
+ {
+ return grid_->hostgrid_->levelIndexSet(level_).types(codim);
+ }
+
+ /** \brief Return true if the given entity is contained in the index set */
+ template<class EntityType>
+ bool contains (const EntityType& e) const
+ {
+ return grid_->hostgrid_->levelIndexSet(level_).contains(grid_->template getHostEntity<EntityType::codimension>(e));
+ }
+
+ /** \brief Set up the index set */
+ void update(const GridImp& grid, int level)
+ {
+ grid_ = &grid;
+ level_ = level;
+ }
+
+
+ GridImp* grid_;
+
+ int level_;
+ };
+
+
+ template<class GridImp>
+ class P4estGridLeafIndexSet :
+ public IndexSet<GridImp,
+ P4estGridLeafIndexSet<GridImp>,
+ typename remove_const<GridImp>::type::HostGridType::LeafGridView::IndexSet::IndexType,
+ typename remove_const<GridImp>::type::HostGridType::LeafGridView::IndexSet::Types
+ >
+ {
+ typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
+
+ public:
+
+ typedef typename HostGrid::LevelGridView::IndexSet::Types Types;
+
+ /*
+ * We use the remove_const to extract the Type from the mutable class,
+ * because the const class is not instantiated yet.
+ */
+ enum {dim = remove_const<GridImp>::type::dimension};
+
+
+ //! constructor stores reference to a grid and level
+ P4estGridLeafIndexSet (const GridImp& grid)
+ : grid_(&grid)
+ {}
+
+
+ //! get index of an entity
+ /*
+ We use the RemoveConst to extract the Type from the mutable class,
+ because the const class is not instantiated yet.
+ */
+ template<int codim>
+ int index (const typename remove_const<GridImp>::type::template Codim<codim>::Entity& e) const
+ {
+ return grid_->hostgrid_->leafIndexSet().template index<codim>(grid_->template getHostEntity<codim>(e));
+ }
+
+
+ //! get index of subEntity of a codim 0 entity
+ /*
+ We use the RemoveConst to extract the Type from the mutable class,
+ because the const class is not instantiated yet.
+ */
+ template<int cc>
+ int subIndex (const typename remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e, int i, int codim) const
+ {
+ return grid_->hostgrid_->leafIndexSet().subIndex(grid_->template getHostEntity<cc>(e),i, codim);
+ }
+
+
+ //! get number of entities of given type
+ int size (GeometryType type) const
+ {
+ return grid_->hostgrid_->leafIndexSet().size(type);
+ }
+
+
+ //! get number of entities of given codim
+ int size (int codim) const
+ {
+ return grid_->hostgrid_->leafIndexSet().size(codim);
+ }
+
+
+ /** \brief Deliver all geometry types used in this grid */
+ const std::vector<GeometryType>& geomTypes (int codim) const
+ {
+ return grid_->hostgrid_->leafIndexSet().geomTypes(codim);
+ }
+
+ /** \brief Deliver all geometry types used in this grid */
+ Types types (int codim) const
+ {
+ return grid_->hostgrid_->leafIndexSet().types(codim);
+ }
+
+ /** \brief Return true if the given entity is contained in the index set */
+ template<class EntityType>
+ bool contains (const EntityType& e) const
+ {
+ return grid_->hostgrid_->leafIndexSet().contains(grid_->template getHostEntity<EntityType::codimension>(e));
+ }
+
+
+
+ /** \todo Currently we support only vertex and element indices */
+ void update(const GridImp& grid)
+ {
+ grid_ = &grid;
+ }
+
+
+ GridImp* grid_;
+ };
+
+
+
+
+ template <class GridImp>
+ class P4estGridGlobalIdSet :
+ public IdSet<GridImp,P4estGridGlobalIdSet<GridImp>,
+ typename remove_const<GridImp>::type::HostGridType::Traits::GlobalIdSet::IdType>
+ {
+
+ typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
+
+
+ public:
+ //! constructor stores reference to a grid
+ P4estGridGlobalIdSet (const GridImp& g) : grid_(&g) {}
+
+ //! define the type used for persistent indices
+ typedef typename HostGrid::Traits::GlobalIdSet::IdType IdType;
+
+
+ //! get id of an entity
+ /*
+ We use the remove_const to extract the Type from the mutable class,
+ because the const class is not instantiated yet.
+ */
+ template<int cd>
+ IdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
+ {
+ // Return id of the host entity
+ return grid_->hostgrid_->globalIdSet().id(grid_->getRealImplementation(e).hostEntity_);
+ }
+
+
+ //! get id of subEntity
+ /*
+ We use the remove_const to extract the Type from the mutable class,
+ because the const class is not instantiated yet.
+ */
+ IdType subId (const typename remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, int i, int codim) const
+ {
+ // Return sub id of the host entity
+ return grid_->hostgrid_->globalIdSet().subId(grid_->getRealImplementation(e).hostEntity_,i, codim);
+ }
+
+
+ /** \todo Should be private */
+ void update() {}
+
+
+ const GridImp* grid_;
+ };
+
+
+
+
+ template<class GridImp>
+ class P4estGridLocalIdSet :
+ public IdSet<GridImp,P4estGridLocalIdSet<GridImp>,
+ typename remove_const<GridImp>::type::HostGridType::Traits::LocalIdSet::IdType>
+ {
+ private:
+
+ typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
+
+
+ public:
+ //! define the type used for persistent local ids
+ typedef typename HostGrid::Traits::LocalIdSet::IdType IdType;
+
+
+ //! constructor stores reference to a grid
+ P4estGridLocalIdSet (const GridImp& g) : grid_(&g) {}
+
+
+ //! get id of an entity
+ /*
+ We use the remove_const to extract the Type from the mutable class,
+ because the const class is not instantiated yet.
+ */
+ template<int cd>
+ IdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
+ {
+ // Return id of the host entity
+ return grid_->hostgrid_->localIdSet().id(grid_->getRealImplementation(e).hostEntity_);
+ }
+
+
+ //! get id of subEntity
+ /*
+ * We use the remove_const to extract the Type from the mutable class,
+ * because the const class is not instantiated yet.
+ */
+ IdType subId (const typename remove_const<GridImp>::type::template Codim<0>::Entity& e, int i, int codim) const
+ {
+ // Return sub id of the host entity
+ return grid_->hostgrid_->localIdSet().subId(grid_->getRealImplementation(e).hostEntity_,i,codim);
+ }
+
+
+ /** \todo Should be private */
+ void update() {}
+
+
+ const GridImp* grid_;
+ };
+
+
+} // namespace Dune
+
+
+#endif
diff --git a/dune/p4estgrid/p4estgrid/p4estgridintersectioniterator.hh b/dune/p4estgrid/p4estgrid/p4estgridintersectioniterator.hh
new file mode 100644
index 0000000..d659edb
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridintersectioniterator.hh
@@ -0,0 +1,132 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRID_INTERSECTIONITERATOR_HH
+#define DUNE_P4ESTGRID_INTERSECTIONITERATOR_HH
+
+#include "p4estgridintersections.hh"
+#include "p4estgridentity.hh"
+
+#include <dune/grid/common/intersection.hh>
+
+/** \file
+ * \brief The P4estGridLeafIntersectionIterator and P4estGridLevelIntersectionIterator classes
+ */
+
+namespace Dune {
+
+ /** \brief Iterator over all element neighbors
+ * \ingroup P4estGrid
+ * Mesh entities of codimension 0 ("elements") allow to visit all neighbors, where
+ * a neighbor is an entity of codimension 0 which has a common entity of codimension 1
+ * These neighbors are accessed via a IntersectionIterator. This allows the implement
+ * non-matching meshes. The number of neighbors may be different from the number
+ * of an element!
+ */
+ template<class GridImp>
+ class P4estGridLeafIntersectionIterator
+ {
+
+ enum {dim=GridImp::dimension};
+
+ enum {dimworld=GridImp::dimensionworld};
+
+ // The type used to store coordinates
+ typedef typename GridImp::ctype ctype;
+
+ typedef typename GridImp::HostGridType::LeafGridView::IntersectionIterator HostLeafIntersectionIterator;
+
+ public:
+
+ typedef Dune::Intersection<const GridImp, Dune::P4estGridLeafIntersection<GridImp> > Intersection;
+
+ P4estGridLeafIntersectionIterator()
+ {}
+
+ P4estGridLeafIntersectionIterator(const GridImp* p4estgrid,
+ const HostLeafIntersectionIterator& hostIterator)
+ : p4estgrid_(p4estgrid)
+ , hostIterator_(hostIterator)
+ {}
+
+ //! equality
+ bool equals(const P4estGridLeafIntersectionIterator& other) const {
+ return hostIterator_ == other.hostIterator_;
+ }
+
+
+ //! prefix increment
+ void increment() {
+ ++hostIterator_;
+ }
+
+ //! \brief dereferencing
+ Intersection dereference() const {
+ return P4estGridLeafIntersection<GridImp>(p4estgrid_,*hostIterator_);
+ }
+
+ private:
+ //**********************************************************
+ // private data
+ //**********************************************************
+
+ const GridImp* p4estgrid_;
+ HostLeafIntersectionIterator hostIterator_;
+ };
+
+
+
+
+ //! \todo Please doc me !
+ template<class GridImp>
+ class P4estGridLevelIntersectionIterator
+ {
+ enum {dim=GridImp::dimension};
+
+ enum {dimworld=GridImp::dimensionworld};
+
+ // The type used to store coordinates
+ typedef typename GridImp::ctype ctype;
+
+ typedef typename GridImp::HostGridType::LevelGridView::IntersectionIterator HostLevelIntersectionIterator;
+
+ public:
+
+ typedef Dune::Intersection<const GridImp, Dune::P4estGridLevelIntersection<GridImp> > Intersection;
+
+ P4estGridLevelIntersectionIterator()
+ {}
+
+ P4estGridLevelIntersectionIterator(const GridImp* p4estgrid,
+ const HostLevelIntersectionIterator& hostIterator)
+ : p4estgrid_(p4estgrid)
+ , hostIterator_(hostIterator)
+ {}
+
+ //! equality
+ bool equals(const P4estGridLevelIntersectionIterator<GridImp>& other) const {
+ return hostIterator_ == other.hostIterator_;
+ }
+
+
+ //! prefix increment
+ void increment() {
+ ++hostIterator_;
+ }
+
+ //! \brief dereferencing
+ Intersection dereference() const {
+ return P4estGridLevelIntersection<GridImp>(p4estgrid_,*hostIterator_);
+ }
+
+ private:
+
+
+ const GridImp* p4estgrid_;
+ HostLevelIntersectionIterator hostIterator_;
+
+ };
+
+
+} // namespace Dune
+
+#endif
diff --git a/dune/p4estgrid/p4estgrid/p4estgridintersections.hh b/dune/p4estgrid/p4estgrid/p4estgridintersections.hh
new file mode 100644
index 0000000..3c2f098
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridintersections.hh
@@ -0,0 +1,357 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRID_INTERSECTIONS_HH
+#define DUNE_P4ESTGRID_INTERSECTIONS_HH
+
+#include "p4estgridleafiterator.hh"
+
+/** \file
+ * \brief The P4estGridLeafIntersection and P4estGridLevelIntersection classes
+ */
+
+namespace Dune {
+
+
+ // External forward declarations
+ template< class Grid >
+ struct HostGridAccess;
+
+
+ /** \brief An intersection with a leaf neighbor element
+ * \ingroup P4estGrid
+ * Mesh entities of codimension 0 ("elements") allow to visit all neighbors, where
+ * a neighbor is an entity of codimension 0 which has a common entity of codimension 1
+ * These neighbors are accessed via a IntersectionIterator. This allows the implement
+ * non-matching meshes. The number of neighbors may be different from the number
+ * of an element!
+ */
+ template<class GridImp>
+ class P4estGridLeafIntersection
+ {
+
+ friend class P4estGridLeafIntersectionIterator<GridImp>;
+
+ friend struct HostGridAccess< typename remove_const< GridImp >::type >;
+
+ enum {dim=GridImp::dimension};
+
+ enum {dimworld=GridImp::dimensionworld};
+
+ // The type used to store coordinates
+ typedef typename GridImp::ctype ctype;
+
+ typedef typename GridImp::HostGridType::LeafGridView::Intersection HostLeafIntersection;
+
+ public:
+
+ typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
+ typedef typename GridImp::template Codim<1>::Geometry Geometry;
+ typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
+ typedef typename GridImp::template Codim<0>::Entity Entity;
+ typedef FieldVector<ctype, dimworld> NormalVector;
+
+ P4estGridLeafIntersection()
+ {}
+
+ P4estGridLeafIntersection(const GridImp* p4estgrid,
+ const HostLeafIntersection& hostIntersection)
+ : p4estgrid_(p4estgrid)
+ , hostIntersection_(hostIntersection)
+ {}
+
+ P4estGridLeafIntersection(const GridImp* p4estgrid,
+ HostLeafIntersection&& hostIntersection)
+ : p4estgrid_(p4estgrid)
+ , hostIntersection_(std::move(hostIntersection))
+ {}
+
+ bool equals(const P4estGridLeafIntersection& other) const
+ {
+ return hostIntersection_ == other.hostIntersection_;
+ }
+
+ //! return EntityPointer to the Entity on the inside of this intersection
+ //! (that is the Entity where we started this Iterator)
+ Entity inside() const {
+ return P4estGridEntity<0,dim,GridImp>(p4estgrid_,hostIntersection_.inside());
+ }
+
+
+ //! return EntityPointer to the Entity on the outside of this intersection
+ //! (that is the neighboring Entity)
+ Entity outside() const {
+ return P4estGridEntity<0,dim,GridImp>(p4estgrid_,hostIntersection_.outside());
+ }
+
+
+ //! return true if intersection is with boundary.
+ bool boundary () const {
+ return hostIntersection_.boundary();
+ }
+
+ /** \brief Return unit outer normal (length == 1)
+ *
+ * The returned vector is the normal at the center() of the
+ * intersection's geometry.
+ * It is scaled to have unit length. */
+ NormalVector centerUnitOuterNormal () const {
+ return hostIntersection_.centerUnitOuterNormal();
+ }
+
+ //! return true if across the edge an neighbor on this level exists
+ bool neighbor () const {
+ return hostIntersection_.neighbor();
+ }
+
+
+ //! return information about the Boundary
+ int boundaryId () const {
+ return hostIntersection_.boundaryId();
+ }
+
+ //! return the boundary segment index
+ size_t boundarySegmentIndex() const {
+ return hostIntersection_.boundarySegmentIndex();
+ }
+
+ //! Return true if this is a conforming intersection
+ bool conforming () const {
+ return hostIntersection_.conforming();
+ }
+
+ //! Geometry type of an intersection
+ GeometryType type () const {
+ return hostIntersection_.type();
+ }
+
+
+ //! intersection of codimension 1 of this neighbor with element where
+ //! iteration started.
+ //! Here returned element is in LOCAL coordinates of the element
+ //! where iteration started.
+ LocalGeometry geometryInInside () const
+ {
+ return LocalGeometry( hostIntersection_.geometryInInside() );
+ }
+
+ //! intersection of codimension 1 of this neighbor with element where iteration started.
+ //! Here returned element is in LOCAL coordinates of neighbor
+ LocalGeometry geometryInOutside () const
+ {
+ return LocalGeometry( hostIntersection_.geometryInOutside() );
+ }
+
+ //! intersection of codimension 1 of this neighbor with element where iteration started.
+ //! Here returned element is in GLOBAL coordinates of the element where iteration started.
+ Geometry geometry () const
+ {
+ return Geometry( hostIntersection_.geometry() );
+ }
+
+
+ //! local number of codim 1 entity in self where intersection is contained in
+ int indexInInside () const {
+ return hostIntersection_.indexInInside();
+ }
+
+
+ //! local number of codim 1 entity in neighbor where intersection is contained
+ int indexInOutside () const {
+ return hostIntersection_.indexInOutside();
+ }
+
+
+ //! return outer normal
+ FieldVector<ctype, GridImp::dimensionworld> outerNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const {
+ return hostIntersection_.outerNormal(local);
+ }
+
+ //! return outer normal multiplied by the integration element
+ FieldVector<ctype, GridImp::dimensionworld> integrationOuterNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const {
+ return hostIntersection_.integrationOuterNormal(local);
+ }
+
+ //! return unit outer normal
+ FieldVector<ctype, GridImp::dimensionworld> unitOuterNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const {
+ return hostIntersection_.unitOuterNormal(local);
+ }
+
+
+ private:
+ //**********************************************************
+ // private methods
+ //**********************************************************
+
+ const GridImp* p4estgrid_;
+
+ HostLeafIntersection hostIntersection_;
+ };
+
+
+
+
+ //! \todo Please doc me !
+ template<class GridImp>
+ class P4estGridLevelIntersection
+ {
+
+ friend class P4estGridLevelIntersectionIterator<GridImp>;
+
+ friend struct HostGridAccess< typename remove_const< GridImp >::type >;
+
+ enum {dim=GridImp::dimension};
+
+ enum {dimworld=GridImp::dimensionworld};
+
+ // The type used to store coordinates
+ typedef typename GridImp::ctype ctype;
+
+ typedef typename GridImp::HostGridType::LevelGridView::Intersection HostLevelIntersection;
+
+ public:
+
+ typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
+ typedef typename GridImp::template Codim<1>::Geometry Geometry;
+ typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
+ typedef typename GridImp::template Codim<0>::Entity Entity;
+ typedef FieldVector<ctype, dimworld> NormalVector;
+
+ P4estGridLevelIntersection()
+ {}
+
+ P4estGridLevelIntersection(const GridImp* p4estgrid,
+ const HostLevelIntersection& hostIntersection)
+ : p4estgrid_(p4estgrid)
+ , hostIntersection_(hostIntersection)
+ {}
+
+ P4estGridLevelIntersection(const GridImp* p4estgrid,
+ HostLevelIntersection&& hostIntersection)
+ : p4estgrid_(p4estgrid)
+ , hostIntersection_(std::move(hostIntersection))
+ {}
+
+ bool equals(const P4estGridLevelIntersection& other) const
+ {
+ return hostIntersection_ == other.hostIntersection_;
+ }
+
+ //! return EntityPointer to the Entity on the inside of this intersection
+ //! (that is the Entity where we started this Iterator)
+ Entity inside() const {
+ return P4estGridEntity<0,dim,GridImp>(p4estgrid_,hostIntersection_.inside());
+ }
+
+
+ //! return EntityPointer to the Entity on the outside of this intersection
+ //! (that is the neighboring Entity)
+ Entity outside() const {
+ return P4estGridEntity<0,dim,GridImp>(p4estgrid_,hostIntersection_.outside());
+ }
+
+
+ /** \brief return true if intersection is with boundary.
+ */
+ bool boundary () const {
+ return hostIntersection_.boundary();
+ }
+
+ /** \brief Return unit outer normal (length == 1)
+ *
+ * The returned vector is the normal at the center() of the
+ * intersection's geometry.
+ * It is scaled to have unit length. */
+ NormalVector centerUnitOuterNormal () const {
+ return hostIntersection_.centerUnitOuterNormal();
+ }
+
+ //! return true if across the edge an neighbor on this level exists
+ bool neighbor () const {
+ return hostIntersection_.neighbor();
+ }
+
+
+ //! return information about the Boundary
+ int boundaryId () const {
+ return hostIntersection_.boundaryId();
+ }
+
+ //! return the boundary segment index
+ size_t boundarySegmentIndex() const {
+ return hostIntersection_.boundarySegmentIndex();
+ }
+
+ //! Return true if this is a conforming intersection
+ bool conforming () const {
+ return hostIntersection_.conforming();
+ }
+
+ //! Geometry type of an intersection
+ GeometryType type () const {
+ return hostIntersection_.type();
+ }
+
+
+ //! intersection of codimension 1 of this neighbor with element where
+ //! iteration started.
+ //! Here returned element is in LOCAL coordinates of the element
+ //! where iteration started.
+ LocalGeometry geometryInInside () const
+ {
+ return LocalGeometry( hostIntersection_.geometryInInside() );
+ }
+
+ //! intersection of codimension 1 of this neighbor with element where iteration started.
+ //! Here returned element is in LOCAL coordinates of neighbor
+ LocalGeometry geometryInOutside () const
+ {
+ return LocalGeometry( hostIntersection_.geometryInOutside() );
+ }
+
+ //! intersection of codimension 1 of this neighbor with element where iteration started.
+ //! Here returned element is in GLOBAL coordinates of the element where iteration started.
+ Geometry geometry () const
+ {
+ return Geometry( hostIntersection_.geometry() );
+ }
+
+
+ //! local number of codim 1 entity in self where intersection is contained in
+ int indexInInside () const {
+ return hostIntersection_.indexInInside();
+ }
+
+
+ //! local number of codim 1 entity in neighbor where intersection is contained
+ int indexInOutside () const {
+ return hostIntersection_.indexInOutside();
+ }
+
+
+ //! return outer normal
+ FieldVector<ctype, dimworld> outerNormal (const FieldVector<ctype, dim-1>& local) const {
+ return hostIntersection_.outerNormal(local);
+ }
+
+ //! return outer normal multiplied by the integration element
+ FieldVector<ctype, dimworld> integrationOuterNormal (const FieldVector<ctype, dim-1>& local) const {
+ return hostIntersection_.integrationOuterNormal(local);
+ }
+
+ //! return unit outer normal
+ FieldVector<ctype, dimworld> unitOuterNormal (const FieldVector<ctype, dim-1>& local) const {
+ return hostIntersection_.unitOuterNormal(local);
+ }
+
+ private:
+
+ const GridImp* p4estgrid_;
+
+ HostLevelIntersection hostIntersection_;
+
+ };
+
+
+} // namespace Dune
+
+#endif
diff --git a/dune/p4estgrid/p4estgrid/p4estgridleafiterator.hh b/dune/p4estgrid/p4estgrid/p4estgridleafiterator.hh
new file mode 100644
index 0000000..cddd7ad
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridleafiterator.hh
@@ -0,0 +1,55 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRIDLEAFITERATOR_HH
+#define DUNE_P4ESTGRIDLEAFITERATOR_HH
+
+#include "p4estgridentitypointer.hh"
+
+/** \file
+ * \brief The P4estGridLeafIterator class
+ */
+
+namespace Dune {
+
+
+ /** \brief Iterator over all entities of a given codimension and level of a grid.
+ * \ingroup P4estGrid
+ */
+ template<int codim, PartitionIteratorType pitype, class GridImp>
+ class P4estGridLeafIterator :
+ public Dune::P4estGridEntityPointer<codim,GridImp,typename GridImp::HostGridType::template Codim<codim>::template Partition<pitype>::LeafIterator>
+ {
+ private:
+
+ // LevelIterator to the equivalent entity in the host grid
+ typedef typename GridImp::HostGridType::template Codim<codim>::template Partition<pitype>::LeafIterator HostGridLeafIterator;
+
+ typedef Dune::P4estGridEntityPointer<codim,GridImp,HostGridLeafIterator> Base;
+
+ public:
+
+ //! \todo Please doc me !
+ explicit P4estGridLeafIterator(const GridImp* p4estgrid) :
+ Base(p4estgrid, p4estgrid->hostgrid_->leafGridView().template begin<codim,pitype>())
+ {}
+
+ /** \brief Constructor which create the end iterator
+ * \param endDummy Here only to distinguish it from the other constructor
+ * \param p4estgrid pointer to grid instance
+ */
+ explicit P4estGridLeafIterator(const GridImp* p4estgrid, bool endDummy) :
+ Base(p4estgrid, p4estgrid->hostgrid_->leafGridView().template end<codim,pitype>())
+ {}
+
+
+ //! prefix increment
+ void increment() {
+ ++this->hostEntityPointer_;
+ }
+
+ };
+
+
+} // namespace Dune
+
+#endif
diff --git a/dune/p4estgrid/p4estgrid/p4estgridleveliterator.hh b/dune/p4estgrid/p4estgrid/p4estgridleveliterator.hh
new file mode 100644
index 0000000..c3202cd
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid/p4estgridleveliterator.hh
@@ -0,0 +1,59 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+#ifndef DUNE_P4ESTGRIDLEVELITERATOR_HH
+#define DUNE_P4ESTGRIDLEVELITERATOR_HH
+
+#include "p4estgridentitypointer.hh"
+
+/** \file
+ * \brief The P4estGridLevelIterator class and its specializations
+ */
+
+namespace Dune {
+
+
+
+
+ //**********************************************************************
+ //
+ // --P4estGridLevelIterator
+ /** \brief Iterator over all entities of a given codimension and level of a grid.
+ * \ingroup P4estGrid
+ */
+ template<int codim, PartitionIteratorType pitype, class GridImp>
+ class P4estGridLevelIterator :
+ public Dune::P4estGridEntityPointer<codim,GridImp,typename GridImp::HostGridType::Traits::template Codim<codim>::template Partition<pitype>::LevelIterator>
+ {
+
+ typedef typename GridImp::HostGridType::Traits::template Codim<codim>::template Partition<pitype>::LevelIterator HostGridLevelIterator;
+ typedef Dune::P4estGridEntityPointer<codim,GridImp,HostGridLevelIterator> Base;
+
+ public:
+
+ //! Constructor
+ explicit P4estGridLevelIterator(const GridImp* p4estgrid, int level)
+ : Base(p4estgrid, p4estgrid->hostgrid_->levelGridView(level).template begin<codim,pitype>())
+ {}
+
+
+ /** \brief Constructor which create the end iterator
+ \param endDummy Here only to distinguish it from the other constructor
+ \param p4estgrid pointer to P4estGrid instance
+ \param level grid level on which the iterator shall be created
+ */
+ explicit P4estGridLevelIterator(const GridImp* p4estgrid, int level, bool endDummy)
+ : Base(p4estgrid, p4estgrid->hostgrid_->levelGridView(level).template end<codim,pitype>())
+ {}
+
+
+ //! prefix increment
+ void increment() {
+ ++this->hostEntityPointer_;
+ }
+
+ };
+
+
+} // namespace Dune
+
+#endif
--
2.7.2
More information about the Dune-devel
mailing list