// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_MULTIMESH_ENTITY_HH #define DUNE_MULTIMESH_ENTITY_HH #include #include #include "mmentityseed.hh" #include "mmgeometry.hh" namespace Dune { template class MultiEntity : public std::vector::Entity> { private: using ctype = typename HostGrid::ctype; public: enum { dimension = HostGrid::dimension }; /// The type of a local geometry using LocalGeometry = MultiMeshLocalGeometry; using EntitySeed = MultiMeshEntitySeed<0, HostGrid>; /// Entity in the host grid using HostGridEntity = typename HostGrid::Traits::template Codim<0>::Entity; /// Containertype using Super = std::vector; /// Constructor from std::vector using Super::vector; /// Return a local geometry of source in target static LocalGeometry localGeometry (HostGridEntity const& source, HostGridEntity const& target) { return {source, target}; } /// Return a local geometry of source_i'th entity in target_t'th entity LocalGeometry localGeometry (std::size_t source_i, std::size_t target_i) const { return {(*this)[source_i], (*this)[target_i]}; } /// Return coordinate `sourceLocal` in coordinates of target entity static typename LocalGeometry::GlobalCoordinate local ( const HostGridEntity& source, const HostGridEntity& target, const typename LocalGeometry::LocalCoordinate& sourceLocal) { if (source.level() == target.level()) return sourceLocal; else if (source.level() < target.level()) return localGeometry(target, source).local(sourceLocal); else return localGeometry(source, target).global(sourceLocal); } /// \brief Return the entity seed which contains sufficient information /// to generate the entity again and uses as little memory as possible. /** * The MultiMeshEntitySeed contains the HostGridEntitySeed and the index of * the grid it is extracted from. **/ EntitySeed seed (std::size_t entity_i) const { return {(*this)[entity_i], entity_i}; } /// Return the entity with maximal level HostGridEntity const& max() const { // TODO: cache max-element auto it_max = std::max_element(this->begin(), this->end(), [](auto const& e1, auto const& e2) { return e1.level() < e2.level(); }); return *it_max; } /// Return the entity with minimal level HostGridEntity const& min() const { // TODO: cache min-element auto it_min = std::min_element(this->begin(), this->end(), [](auto const& e1, auto const& e2) { return e1.level() < e2.level(); }); return *it_min; } }; } // end namespace Dune #endif // DUNE_MULTIMESH_ENTITY_HH