From fffdc47320fa8444873e337677b524a266292180 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sun, 9 Jun 2019 23:29:43 +0200 Subject: [PATCH 01/11] added computation of global DOF ids for pre-bases --- src/amdis/common/TupleUtility.hpp | 12 + src/amdis/functions/GlobalDofIds.hpp | 347 +++++++++++++++++++++++++++ test/CMakeLists.txt | 3 + test/GlobalDofIdsTest.cpp | 57 +++++ 4 files changed, 419 insertions(+) create mode 100644 src/amdis/functions/GlobalDofIds.hpp create mode 100644 test/GlobalDofIdsTest.cpp diff --git a/src/amdis/common/TupleUtility.hpp b/src/amdis/common/TupleUtility.hpp index 2f6aaead..7914ae00 100644 --- a/src/amdis/common/TupleUtility.hpp +++ b/src/amdis/common/TupleUtility.hpp @@ -32,4 +32,16 @@ namespace AMDiS } // end namespace Impl + template class Map> + struct MapTuple; + + template class Map> + using MapTuple_t = typename MapTuple::type; + + template class Map> + struct MapTuple, Map> + { + using type = std::tuple...>; + }; + } // end namespace AMDiS diff --git a/src/amdis/functions/GlobalDofIds.hpp b/src/amdis/functions/GlobalDofIds.hpp new file mode 100644 index 00000000..d40e556a --- /dev/null +++ b/src/amdis/functions/GlobalDofIds.hpp @@ -0,0 +1,347 @@ +#pragma once + +#include + +#include +#include + +#include + + +namespace Dune +{ + namespace Functions + { + template + class DefaultGlobalBasis; + + template + class SubspaceBasis; + + template + class CompositePreBasis; + + template + class LagrangePreBasis; + + template + class PowerPreBasis; + + template + class LagrangeDGPreBasis; + } +} + + +namespace AMDiS +{ + template + class GlobalDofIds; + + + template + class GlobalDofIds> + { + public: + using GlobalBasis = Dune::Functions::DefaultGlobalBasis; + using NodeIdSet = GlobalDofIds; + using size_type = std::size_t; + + using Grid = typename PB::GridView::Grid; + using IdType = std::pair; + using Tree = typename GlobalBasis::PreBasis::Node; + + public: + GlobalDofIds(GlobalBasis const& globalBasis) + : globalBasis_(&globalBasis) + , tree_(globalBasis_->preBasis().makeNode()) + , nodeIdSet_(globalBasis_->preBasis()) + { + initializeTree(tree_); + } + + template + void bind(Element const& element) + { + bindTree(tree_, element); + nodeIdSet_.bind(tree_); + ids_.resize(size()); + nodeIdSet_.insert(ids_.begin()); + } + + void unbind() + { + nodeIdSet_.unbind(); + } + + size_type size() const + { + return tree_.size(); + } + + IdType id(size_type i) const + { + return ids_[i]; + } + + protected: + const GlobalBasis* globalBasis_; + Tree tree_; + NodeIdSet nodeIdSet_; + std::vector ids_; + }; + + + template + class GlobalDofIds> + : public GlobalDofIds + { + public: + GlobalDofIds(Dune::Functions::SubspaceBasis const& basis) + : GlobalDofIds(basis.rootBasis()) + {} + }; + + + template + class GlobalDofIds> + { + public: + using PreBasis = Dune::Functions::PowerPreBasis; + using Node = typename PreBasis::Node; + using size_type = std::size_t; + + protected: + using SubPreBasis = typename PreBasis::SubPreBasis; + static const std::size_t children = C; + + public: + GlobalDofIds(const PreBasis& preBasis) + : preBasis_(&preBasis) + , subIds_(preBasis_->subPreBasis()) + {} + + /// \brief Bind the view to a grid element + void bind(const Node& node) + { + node_ = &node; + subIds_.bind(node.child(0)); + } + + /// \brief Unbind the view + void unbind() + { + node_ = nullptr; + subIds_.unbind(); + } + + /// \brief Number of DOFs in this node + size_type size() const + { + return node_->size(); + } + + /// Maps from subtree index set [0..size-1] to a globally unique id in global basis + template + Iter insert(Iter it) const + { + size_type shift = 0; + for (std::size_t child = 0; child < children; ++child) + { + size_type subTreeSize = subIds_.size(); + subIds_.insert(it); + for (size_type i = 0; i < subTreeSize; ++i) + it[i].second += shift; + it += subTreeSize; + shift += subTreeSize; + } + return it; + } + + protected: + const PreBasis* preBasis_; + const Node* node_; + GlobalDofIds subIds_; + }; + + + template + class GlobalDofIds> + { + public: + using PreBasis = Dune::Functions::CompositePreBasis; + using Node = typename PreBasis::Node; + using size_type = std::size_t; + + protected: + static const std::size_t children = sizeof...(SPB); + using ChildIndices = std::make_index_sequence; + + // The I'th SubPreBasis + template + using SubPreBasis = std::tuple_element_t; + + // A tuple of GlobalDofIds for the SubPreBases + using IdsTuple = MapTuple_t; + + public: + GlobalDofIds(PreBasis const& preBasis) + : preBasis_(&preBasis) + , idsTuple_(Tools::apply_indices([&](auto... i) { + return std::make_tuple(GlobalDofIds>(preBasis.subPreBasis(i))...); + })) + , node_(nullptr) + {} + + void bind(const Node& node) + { + node_ = &node; + Tools::for_range<0,children>([&](auto i) { + std::get(idsTuple_).bind(node.child(i)); + }); + } + + void unbind() + { + node_ = nullptr; + Tools::for_each(idsTuple_, [](auto const& ids) { + ids.unbind(); + }); + } + + size_type size() const + { + return node_->size(); + } + + //! Maps from subtree index set [0..size-1] to a globally unique id in global basis + template + It insert(It it) const + { + size_type shift = 0; + Tools::for_each(idsTuple_, [&](auto const& ids) { + size_type subTreeSize = ids.size(); + ids.insert(it); + for (size_type i = 0; i < subTreeSize; ++i) + it[i].second += shift; + it += subTreeSize; + shift += subTreeSize; + }); + return it; + } + + private: + const PreBasis* preBasis_; + IdsTuple idsTuple_; + const Node* node_; + }; + + + template + class GlobalDofIds> + { + public: + using PreBasis = Dune::Functions::LagrangePreBasis; + using Node = typename PreBasis::Node; + using size_type = std::size_t; + + GlobalDofIds(PreBasis const& preBasis) + : preBasis_(&preBasis) + {} + + /// \brief Bind the view to a grid element + void bind(const Node& node) + { + node_ = &node; + size_ = node_->finiteElement().size(); + } + + /// \brief Unbind the view + void unbind() + { + node_ = nullptr; + } + + size_type size() const + { + return size_; + } + + /// Maps from subtree index set [0..size-1] to a globally unique id in global basis + template + Iter insert(Iter it) const + { + const auto& gridIdSet = preBasis_->gridView().grid().globalIdSet(); + + for (size_type i = 0; i < size_ ; ++i, ++it) { + Dune::LocalKey localKey = node_->finiteElement().localCoefficients().localKey(i); + unsigned int s = localKey.subEntity(); + unsigned int c = localKey.codim(); + unsigned int idx = localKey.index(); + if (!(c == GV::dimension || c == 0 || idx == 0)) + DUNE_THROW(Dune::NotImplemented, "Bases with more then one DoF per subentity are not supported."); + + *it = {gridIdSet.subId(node_->element(), s, c), idx}; + } + + return it; + } + + protected: + const PreBasis* preBasis_; + const Node* node_; + size_type size_; + }; + + + template + class GlobalDofIds> + { + public: + using PreBasis = Dune::Functions::LagrangeDGPreBasis; + using Node = typename PreBasis::Node; + using size_type = std::size_t; + + GlobalDofIds(PreBasis const& preBasis) + : preBasis_(&preBasis) + {} + + /// \brief Bind the view to a grid element + void bind(const Node& node) + { + node_ = &node; + size_ = node_->finiteElement().size(); + } + + /// \brief Unbind the view + void unbind() + { + node_ = nullptr; + } + + size_type size() const + { + return size_; + } + + /// Maps from subtree index set [0..size-1] to a globally unique id in global basis + template + Iter insert(Iter it) const + { + const auto& gridIdSet = preBasis_->gridView().grid().globalIdSet(); + auto elementId = gridIdSet.id(node_->element()); + + for (size_type i = 0; i < size_; ++i, ++it) + *it = {elementId, i}; + + return it; + } + + protected: + const PreBasis* preBasis_; + const Node* node_; + size_type size_; + }; + + +} // end namespace AMDiS diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 282214b3..df926c33 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -46,6 +46,9 @@ dune_add_test(SOURCES FiniteElementTypeTest.cpp dune_add_test(SOURCES FilesystemTest.cpp LINK_LIBRARIES amdis) +dune_add_test(SOURCES GlobalDofIdsTest.cpp + LINK_LIBRARIES amdis) + dune_add_test(SOURCES GradientTest.cpp LINK_LIBRARIES amdis) diff --git a/test/GlobalDofIdsTest.cpp b/test/GlobalDofIdsTest.cpp new file mode 100644 index 00000000..56420b81 --- /dev/null +++ b/test/GlobalDofIdsTest.cpp @@ -0,0 +1,57 @@ +#include +#include +#include + +#include "Tests.hpp" + +using namespace AMDiS; + +template +void checkBasisIds(const Basis& basis) +{ + using IdSet = GlobalDofIds; + using IdType = typename IdSet::IdType; + + std::set cache{}; + + IdSet idSet(basis); + for (const auto& e : elements(basis.gridView())) + { + idSet.bind(e); + + for (std::size_t i = 0; i < idSet.size(); ++i) + { + auto id = idSet.id(i); + cache.insert(id); + } + } + + AMDIS_TEST(cache.size() == basis.dimension()); +} + +template +void checkBasis(const Basis& basis) +{ + checkBasisIds(basis); +} + +int main(int argc, char** argv) +{ + Environment env(argc, argv); + + // create grid + Dune::YaspGrid<2> grid({1.0, 1.0}, {4,4}); + auto gridView = grid.leafGridView(); + + // create basis + using namespace Dune::Functions::BasisBuilder; + auto taylorHoodBasis = makeBasis(gridView, + composite( + power<2>(lagrange<2>()), + lagrange<1>() + )); + + checkBasis(taylorHoodBasis); + + return report_errors(); +} -- GitLab From af963255d5a14f5f2608ff4480c3fc673bdbc2e3 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Mon, 10 Jun 2019 14:20:08 +0200 Subject: [PATCH 02/11] Global basis ids for dune 2.6 and dune 2.7 --- src/amdis/common/TupleUtility.hpp | 12 ++ src/amdis/functions/CMakeLists.txt | 2 + .../{GlobalDofIds.hpp => GlobalIdSet.hpp} | 170 +++++++++--------- src/amdis/functions/Nodes.hpp | 28 +++ test/CMakeLists.txt | 2 +- ...obalDofIdsTest.cpp => GlobalIdSetTest.cpp} | 4 +- 6 files changed, 132 insertions(+), 86 deletions(-) rename src/amdis/functions/{GlobalDofIds.hpp => GlobalIdSet.hpp} (55%) create mode 100644 src/amdis/functions/Nodes.hpp rename test/{GlobalDofIdsTest.cpp => GlobalIdSetTest.cpp} (92%) diff --git a/src/amdis/common/TupleUtility.hpp b/src/amdis/common/TupleUtility.hpp index 7914ae00..e7eca21d 100644 --- a/src/amdis/common/TupleUtility.hpp +++ b/src/amdis/common/TupleUtility.hpp @@ -44,4 +44,16 @@ namespace AMDiS using type = std::tuple...>; }; + template class Map> + struct IndexMapTuple; + + template class Map> + using IndexMapTuple_t = typename IndexMapTuple::type; + + template class Map> + struct IndexMapTuple, Map> + { + using type = std::tuple...>; + }; + } // end namespace AMDiS diff --git a/src/amdis/functions/CMakeLists.txt b/src/amdis/functions/CMakeLists.txt index 13244525..3d89bca7 100644 --- a/src/amdis/functions/CMakeLists.txt +++ b/src/amdis/functions/CMakeLists.txt @@ -1,6 +1,8 @@ #install headers install(FILES + GlobalIdSet.hpp HierarchicNodeToRangeMap.hpp Interpolate.hpp + Nodes.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/functions) diff --git a/src/amdis/functions/GlobalDofIds.hpp b/src/amdis/functions/GlobalIdSet.hpp similarity index 55% rename from src/amdis/functions/GlobalDofIds.hpp rename to src/amdis/functions/GlobalIdSet.hpp index d40e556a..65ebcc0e 100644 --- a/src/amdis/functions/GlobalDofIds.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -1,20 +1,22 @@ #pragma once +#include #include #include +#include #include +#include +#include #include - +#include namespace Dune { namespace Functions { - template - class DefaultGlobalBasis; - + // forward declarations... template class SubspaceBasis; @@ -35,38 +37,41 @@ namespace Dune namespace AMDiS { - template - class GlobalDofIds; - + // forward declaration + template + class NodeIdSet; - template - class GlobalDofIds> + template + class GlobalBasisIdSet { public: - using GlobalBasis = Dune::Functions::DefaultGlobalBasis; - using NodeIdSet = GlobalDofIds; + using GlobalBasis = GB; + using Tree = typename GB::LocalView::Tree; using size_type = std::size_t; - using Grid = typename PB::GridView::Grid; + using GridView = typename GlobalBasis::GridView; + using Grid = typename GridView::Grid; + using Element = typename GridView::template Codim<0>::Entity; using IdType = std::pair; - using Tree = typename GlobalBasis::PreBasis::Node; + + using PreBasis = typename GlobalBasis::PreBasis; + using TreePath = typename GlobalBasis::PrefixPath; + using NodeIdSet = AMDiS::NodeIdSet; public: - GlobalDofIds(GlobalBasis const& globalBasis) - : globalBasis_(&globalBasis) - , tree_(globalBasis_->preBasis().makeNode()) - , nodeIdSet_(globalBasis_->preBasis()) + GlobalBasisIdSet(GlobalBasis const& globalBasis) + : tree_(makeNode(globalBasis.preBasis(), TreePath{})) + , nodeIdSet_(globalBasis.gridView()) { - initializeTree(tree_); + Dune::Functions::initializeTree(tree_); } - template void bind(Element const& element) { - bindTree(tree_, element); + Dune::Functions::bindTree(tree_, element); nodeIdSet_.bind(tree_); ids_.resize(size()); - nodeIdSet_.insert(ids_.begin()); + nodeIdSet_.fillIn(ids_.begin()); } void unbind() @@ -85,7 +90,6 @@ namespace AMDiS } protected: - const GlobalBasis* globalBasis_; Tree tree_; NodeIdSet nodeIdSet_; std::vector ids_; @@ -93,32 +97,34 @@ namespace AMDiS template - class GlobalDofIds> - : public GlobalDofIds + class GlobalBasisIdSet> + : public GlobalBasisIdSet { public: - GlobalDofIds(Dune::Functions::SubspaceBasis const& basis) - : GlobalDofIds(basis.rootBasis()) + GlobalBasisIdSet(Dune::Functions::SubspaceBasis const& basis) + : GlobalBasisIdSet(basis.rootBasis()) {} }; - template - class GlobalDofIds> + template + class NodeIdSet, TP> { public: using PreBasis = Dune::Functions::PowerPreBasis; - using Node = typename PreBasis::Node; + using Node = Node_t; + using GridView = typename PreBasis::GridView; using size_type = std::size_t; protected: using SubPreBasis = typename PreBasis::SubPreBasis; + using SubTreePath = decltype(Dune::TypeTree::push_back(std::declval(), std::size_t(0))); + using SubNodeIdSet = NodeIdSet; static const std::size_t children = C; public: - GlobalDofIds(const PreBasis& preBasis) - : preBasis_(&preBasis) - , subIds_(preBasis_->subPreBasis()) + NodeIdSet(GridView const& gridView) + : subIds_(gridView) {} /// \brief Bind the view to a grid element @@ -143,34 +149,30 @@ namespace AMDiS /// Maps from subtree index set [0..size-1] to a globally unique id in global basis template - Iter insert(Iter it) const + Iter fillIn(Iter it, size_type shift = 0) const { - size_type shift = 0; for (std::size_t child = 0; child < children; ++child) { size_type subTreeSize = subIds_.size(); - subIds_.insert(it); - for (size_type i = 0; i < subTreeSize; ++i) - it[i].second += shift; - it += subTreeSize; + it = subIds_.fillIn(it, shift); shift += subTreeSize; } return it; } protected: - const PreBasis* preBasis_; - const Node* node_; - GlobalDofIds subIds_; + SubNodeIdSet subIds_; + const Node* node_ = nullptr; }; - template - class GlobalDofIds> + template + class NodeIdSet, TP> { public: using PreBasis = Dune::Functions::CompositePreBasis; - using Node = typename PreBasis::Node; + using Node = Node_t; + using GridView = typename PreBasis::GridView; using size_type = std::size_t; protected: @@ -179,18 +181,22 @@ namespace AMDiS // The I'th SubPreBasis template - using SubPreBasis = std::tuple_element_t; + using SubPreBasis = typename PreBasis::template SubPreBasis; - // A tuple of GlobalDofIds for the SubPreBases - using IdsTuple = MapTuple_t; + template + using SubTreePath = decltype(Dune::TypeTree::push_back(std::declval(), Dune::index_constant{})); + + template + using SubNodeIdSet = NodeIdSet, SubTreePath>; + + // A tuple of NodeIdSets for the SubPreBases + using IdsTuple = IndexMapTuple_t, SubNodeIdSet>; public: - GlobalDofIds(PreBasis const& preBasis) - : preBasis_(&preBasis) - , idsTuple_(Tools::apply_indices([&](auto... i) { - return std::make_tuple(GlobalDofIds>(preBasis.subPreBasis(i))...); + NodeIdSet(GridView const& gridView) + : idsTuple_(Tools::apply_indices([&](auto... i) { + return std::make_tuple(SubNodeIdSet(gridView)...); })) - , node_(nullptr) {} void bind(const Node& node) @@ -216,37 +222,34 @@ namespace AMDiS //! Maps from subtree index set [0..size-1] to a globally unique id in global basis template - It insert(It it) const + It fillIn(It it, size_type shift = 0) const { - size_type shift = 0; - Tools::for_each(idsTuple_, [&](auto const& ids) { + Tools::for_each(idsTuple_, [&](auto const& ids) + { size_type subTreeSize = ids.size(); - ids.insert(it); - for (size_type i = 0; i < subTreeSize; ++i) - it[i].second += shift; - it += subTreeSize; + it = ids.fillIn(it, shift); shift += subTreeSize; }); return it; } private: - const PreBasis* preBasis_; IdsTuple idsTuple_; - const Node* node_; + const Node* node_ = nullptr; }; - template - class GlobalDofIds> + template + class NodeIdSet, TP> { public: using PreBasis = Dune::Functions::LagrangePreBasis; - using Node = typename PreBasis::Node; + using Node = Node_t; + using GridView = typename PreBasis::GridView; using size_type = std::size_t; - GlobalDofIds(PreBasis const& preBasis) - : preBasis_(&preBasis) + NodeIdSet(GridView const& gridView) + : gridView_(gridView) {} /// \brief Bind the view to a grid element @@ -269,9 +272,9 @@ namespace AMDiS /// Maps from subtree index set [0..size-1] to a globally unique id in global basis template - Iter insert(Iter it) const + Iter fillIn(Iter it, size_type shift = 0) const { - const auto& gridIdSet = preBasis_->gridView().grid().globalIdSet(); + const auto& gridIdSet = gridView_.grid().globalIdSet(); for (size_type i = 0; i < size_ ; ++i, ++it) { Dune::LocalKey localKey = node_->finiteElement().localCoefficients().localKey(i); @@ -281,29 +284,30 @@ namespace AMDiS if (!(c == GV::dimension || c == 0 || idx == 0)) DUNE_THROW(Dune::NotImplemented, "Bases with more then one DoF per subentity are not supported."); - *it = {gridIdSet.subId(node_->element(), s, c), idx}; + *it = {gridIdSet.subId(node_->element(), s, c), shift + idx}; } return it; } protected: - const PreBasis* preBasis_; - const Node* node_; - size_type size_; + GridView gridView_; + const Node* node_ = nullptr; + size_type size_ = 0; }; - template - class GlobalDofIds> + template + class NodeIdSet, TP> { public: using PreBasis = Dune::Functions::LagrangeDGPreBasis; - using Node = typename PreBasis::Node; + using Node = Node_t; + using GridView = typename PreBasis::GridView; using size_type = std::size_t; - GlobalDofIds(PreBasis const& preBasis) - : preBasis_(&preBasis) + NodeIdSet(GridView const& gridView) + : gridView_(gridView) {} /// \brief Bind the view to a grid element @@ -326,21 +330,21 @@ namespace AMDiS /// Maps from subtree index set [0..size-1] to a globally unique id in global basis template - Iter insert(Iter it) const + Iter fillIn(Iter it, size_type shift = 0) const { - const auto& gridIdSet = preBasis_->gridView().grid().globalIdSet(); + const auto& gridIdSet = gridView_.grid().globalIdSet(); auto elementId = gridIdSet.id(node_->element()); for (size_type i = 0; i < size_; ++i, ++it) - *it = {elementId, i}; + *it = {elementId, shift + i}; return it; } protected: - const PreBasis* preBasis_; - const Node* node_; - size_type size_; + GridView gridView_; + const Node* node_ = nullptr; + size_type size_ = 0; }; diff --git a/src/amdis/functions/Nodes.hpp b/src/amdis/functions/Nodes.hpp new file mode 100644 index 00000000..9977490e --- /dev/null +++ b/src/amdis/functions/Nodes.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include + +namespace AMDiS +{ + // dune version independent extraction of node type from preBasis + template + using Node_t = +#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7) + typename PB::template Node; +#else + typename PB::Node; +#endif + + // dune version independent creation of node from preBasis + template + auto makeNode(PB const& preBasis, TP const& treePath) + { +#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7) + return preBasis.node(treePath); +#else + DUNE_UNUSED_PARAMETER(treePath); + return preBasis.makeNode(); +#endif + } + +} // end namespace AMDiS diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index df926c33..f9e5dae9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -46,7 +46,7 @@ dune_add_test(SOURCES FiniteElementTypeTest.cpp dune_add_test(SOURCES FilesystemTest.cpp LINK_LIBRARIES amdis) -dune_add_test(SOURCES GlobalDofIdsTest.cpp +dune_add_test(SOURCES GlobalIdSetTest.cpp LINK_LIBRARIES amdis) dune_add_test(SOURCES GradientTest.cpp diff --git a/test/GlobalDofIdsTest.cpp b/test/GlobalIdSetTest.cpp similarity index 92% rename from test/GlobalDofIdsTest.cpp rename to test/GlobalIdSetTest.cpp index 56420b81..999e6ae6 100644 --- a/test/GlobalDofIdsTest.cpp +++ b/test/GlobalIdSetTest.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "Tests.hpp" @@ -9,7 +9,7 @@ using namespace AMDiS; template void checkBasisIds(const Basis& basis) { - using IdSet = GlobalDofIds; + using IdSet = GlobalBasisIdSet; using IdType = typename IdSet::IdType; std::set cache{}; -- GitLab From 8d90ea21b660bac6ffb8658e542ef4dff303877a Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Tue, 11 Jun 2019 15:42:41 +0200 Subject: [PATCH 03/11] corrected the unbind function --- src/amdis/functions/GlobalIdSet.hpp | 2 +- test/GlobalIdSetTest.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index 65ebcc0e..88c8fef8 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -210,7 +210,7 @@ namespace AMDiS void unbind() { node_ = nullptr; - Tools::for_each(idsTuple_, [](auto const& ids) { + Tools::for_each(idsTuple_, [](auto& ids) { ids.unbind(); }); } diff --git a/test/GlobalIdSetTest.cpp b/test/GlobalIdSetTest.cpp index 999e6ae6..4dd81eb0 100644 --- a/test/GlobalIdSetTest.cpp +++ b/test/GlobalIdSetTest.cpp @@ -24,6 +24,8 @@ void checkBasisIds(const Basis& basis) auto id = idSet.id(i); cache.insert(id); } + + idSet.unbind(e); } AMDIS_TEST(cache.size() == basis.dimension()); -- GitLab From 0f366d3d793a8ef6b942d5df7e7d78dd0c95794d Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Tue, 11 Jun 2019 15:58:16 +0200 Subject: [PATCH 04/11] wrong unbind function call corrected --- test/GlobalIdSetTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/GlobalIdSetTest.cpp b/test/GlobalIdSetTest.cpp index 4dd81eb0..8239c9ee 100644 --- a/test/GlobalIdSetTest.cpp +++ b/test/GlobalIdSetTest.cpp @@ -25,7 +25,7 @@ void checkBasisIds(const Basis& basis) cache.insert(id); } - idSet.unbind(e); + idSet.unbind(); } AMDIS_TEST(cache.size() == basis.dimension()); -- GitLab From 43b395c27414c943d16e2e2f6778fb2028104935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20M=C3=BCller?= Date: Tue, 11 Jun 2019 18:19:16 +0200 Subject: [PATCH 05/11] Added partition type query to GlobalIdSet --- src/amdis/functions/GlobalIdSet.hpp | 51 +++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index 88c8fef8..05778df9 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -1,16 +1,20 @@ #pragma once -#include #include +#include +#include #include +#include #include +#include #include #include #include #include #include +#include namespace Dune { @@ -53,6 +57,7 @@ namespace AMDiS using Grid = typename GridView::Grid; using Element = typename GridView::template Codim<0>::Entity; using IdType = std::pair; + using PartitionType = Dune::PartitionType; using PreBasis = typename GlobalBasis::PreBasis; using TreePath = typename GlobalBasis::PrefixPath; @@ -70,8 +75,8 @@ namespace AMDiS { Dune::Functions::bindTree(tree_, element); nodeIdSet_.bind(tree_); - ids_.resize(size()); - nodeIdSet_.fillIn(ids_.begin()); + data_.resize(size()); + nodeIdSet_.fillIn(data_.begin()); } void unbind() @@ -86,13 +91,19 @@ namespace AMDiS IdType id(size_type i) const { - return ids_[i]; + return data_[i].first; + } + + PartitionType partitionType(size_type i) const + { + return data_[i].second; } protected: Tree tree_; NodeIdSet nodeIdSet_; - std::vector ids_; + using Data = std::pair; + std::vector data_; }; @@ -148,8 +159,8 @@ namespace AMDiS } /// Maps from subtree index set [0..size-1] to a globally unique id in global basis - template - Iter fillIn(Iter it, size_type shift = 0) const + template + It fillIn(It it, size_type shift = 0) const { for (std::size_t child = 0; child < children; ++child) { @@ -248,6 +259,10 @@ namespace AMDiS using GridView = typename PreBasis::GridView; using size_type = std::size_t; + private: + static constexpr int dim = GridView::template Codim<0>::Entity::mydimension; + + public: NodeIdSet(GridView const& gridView) : gridView_(gridView) {} @@ -271,8 +286,8 @@ namespace AMDiS } /// Maps from subtree index set [0..size-1] to a globally unique id in global basis - template - Iter fillIn(Iter it, size_type shift = 0) const + template + It fillIn(It it, size_type shift = 0) const { const auto& gridIdSet = gridView_.grid().globalIdSet(); @@ -284,7 +299,14 @@ namespace AMDiS if (!(c == GV::dimension || c == 0 || idx == 0)) DUNE_THROW(Dune::NotImplemented, "Bases with more then one DoF per subentity are not supported."); - *it = {gridIdSet.subId(node_->element(), s, c), shift + idx}; + it->first = {gridIdSet.subId(node_->element(), s, c), shift + idx}; + + it->second = Dune::Hybrid::switchCases(std::make_index_sequence{}, c, + [&](auto codim) { return node_->element().template subEntity(s).partitionType(); }, + [&]() { + error_exit("Invalid codimension c = {}", c); + return Dune::PartitionType{}; + }); } return it; @@ -329,14 +351,17 @@ namespace AMDiS } /// Maps from subtree index set [0..size-1] to a globally unique id in global basis - template - Iter fillIn(Iter it, size_type shift = 0) const + template + It fillIn(It it, size_type shift = 0) const { const auto& gridIdSet = gridView_.grid().globalIdSet(); auto elementId = gridIdSet.id(node_->element()); for (size_type i = 0; i < size_; ++i, ++it) - *it = {elementId, shift + i}; + { + it->first = {elementId, shift + i}; + it->second = node_->element().partitionType(); + } return it; } -- GitLab From 7c1e0082f31b3232e30d37eaeb60b677fd18bc54 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 12 Jun 2019 12:31:50 +0200 Subject: [PATCH 06/11] added documentation and extended the test --- src/amdis/functions/GlobalIdSet.hpp | 43 ++++++++++++++++++++------- test/CMakeLists.txt | 5 +++- test/GlobalIdSetTest.cpp | 46 ++++++++++++++++++++--------- 3 files changed, 69 insertions(+), 25 deletions(-) diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index 05778df9..88dc790d 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -71,6 +71,12 @@ namespace AMDiS Dune::Functions::initializeTree(tree_); } + /// \brief Bind the IdSet to a grid element. + /** + * Binding the IdSet to an element collects the ids from all DOFs + * on that element and stores it in a local vector. Thus, the global + * DOF ids can be extracted using \ref id() afterwards cheaply. + **/ void bind(Element const& element) { Dune::Functions::bindTree(tree_, element); @@ -79,23 +85,31 @@ namespace AMDiS nodeIdSet_.fillIn(data_.begin()); } + /// \brief unbind from the element void unbind() { nodeIdSet_.unbind(); } + /// \brief The number of DOFs on the current element in the basis tree size_type size() const { return tree_.size(); } + /// \brief Return the global unique ID of the `i`th DOF on the + /// currently bound element in the basis tree. IdType id(size_type i) const { + assert( i < data_.size() ); return data_[i].first; } + /// \brief Return the partition type of the `i`th DOF on the + /// currently bound element in the basis tree. PartitionType partitionType(size_type i) const { + assert( i < data_.size() ); return data_[i].second; } @@ -138,14 +152,14 @@ namespace AMDiS : subIds_(gridView) {} - /// \brief Bind the view to a grid element + /// \brief Bind the idset to a tree node void bind(const Node& node) { node_ = &node; subIds_.bind(node.child(0)); } - /// \brief Unbind the view + /// \brief Unbind the idset void unbind() { node_ = nullptr; @@ -158,7 +172,8 @@ namespace AMDiS return node_->size(); } - /// Maps from subtree index set [0..size-1] to a globally unique id in global basis + /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis + // [[expects: node_ != nullptr]] template It fillIn(It it, size_type shift = 0) const { @@ -210,6 +225,7 @@ namespace AMDiS })) {} + /// \brief Bind the idset to a tree node void bind(const Node& node) { node_ = &node; @@ -218,6 +234,7 @@ namespace AMDiS }); } + /// \brief Unbind the idset void unbind() { node_ = nullptr; @@ -226,12 +243,14 @@ namespace AMDiS }); } + /// \brief Number of DOFs in this node size_type size() const { return node_->size(); } - //! Maps from subtree index set [0..size-1] to a globally unique id in global basis + /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis + // [[expects: node_ != nullptr]] template It fillIn(It it, size_type shift = 0) const { @@ -267,25 +286,27 @@ namespace AMDiS : gridView_(gridView) {} - /// \brief Bind the view to a grid element + /// \brief Bind the idset to a tree node void bind(const Node& node) { node_ = &node; size_ = node_->finiteElement().size(); } - /// \brief Unbind the view + /// \brief Unbind the idset void unbind() { node_ = nullptr; } + /// \brief Number of DOFs in this node size_type size() const { return size_; } - /// Maps from subtree index set [0..size-1] to a globally unique id in global basis + /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis + // [[expects: node_ != nullptr]] template It fillIn(It it, size_type shift = 0) const { @@ -332,25 +353,27 @@ namespace AMDiS : gridView_(gridView) {} - /// \brief Bind the view to a grid element + /// \brief Bind the idset to a tree node void bind(const Node& node) { node_ = &node; size_ = node_->finiteElement().size(); } - /// \brief Unbind the view + /// \brief Unbind the idset void unbind() { node_ = nullptr; } + /// \brief Number of DOFs in this node size_type size() const { return size_; } - /// Maps from subtree index set [0..size-1] to a globally unique id in global basis + /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis + // [[expects: node_ != nullptr]] template It fillIn(It it, size_type shift = 0) const { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f9e5dae9..98126731 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -47,7 +47,10 @@ dune_add_test(SOURCES FilesystemTest.cpp LINK_LIBRARIES amdis) dune_add_test(SOURCES GlobalIdSetTest.cpp - LINK_LIBRARIES amdis) + LINK_LIBRARIES amdis + MPI_RANKS 2 + TIMEOUT 300 + CMAKE_GUARD MPI_FOUND) dune_add_test(SOURCES GradientTest.cpp LINK_LIBRARIES amdis) diff --git a/test/GlobalIdSetTest.cpp b/test/GlobalIdSetTest.cpp index 8239c9ee..4c9fc35f 100644 --- a/test/GlobalIdSetTest.cpp +++ b/test/GlobalIdSetTest.cpp @@ -2,6 +2,8 @@ #include #include +#include + #include "Tests.hpp" using namespace AMDiS; @@ -23,6 +25,8 @@ void checkBasisIds(const Basis& basis) { auto id = idSet.id(i); cache.insert(id); + + DUNE_UNUSED auto pt = idSet.partitionType(i); } idSet.unbind(); @@ -31,29 +35,43 @@ void checkBasisIds(const Basis& basis) AMDIS_TEST(cache.size() == basis.dimension()); } -template -void checkBasis(const Basis& basis) +template +void checkGrid(const Grid& grid) { - checkBasisIds(basis); + // create basis + using namespace Dune::Functions::BasisBuilder; + auto basis1 = makeBasis(grid.leafGridView(), + composite( + power<2>(lagrange<2>()), + lagrange<1>() + )); + + auto basis2 = makeBasis(grid.leafGridView(), + composite( + power<2>(lagrangeDG<2>()), + lagrangeDG<1>() + )); + + checkBasisIds(basis1); + checkBasisIds(basis2); } int main(int argc, char** argv) { Environment env(argc, argv); - // create grid - Dune::YaspGrid<2> grid({1.0, 1.0}, {4,4}); - auto gridView = grid.leafGridView(); + // non-overlapping + Dune::YaspGrid<2> grid1({1.0, 1.0}, {8,8}, 0, 0); + Dune::YaspGrid<3> grid2({1.0, 1.0, 1.0}, {8,8,8}, 0, 0); - // create basis - using namespace Dune::Functions::BasisBuilder; - auto taylorHoodBasis = makeBasis(gridView, - composite( - power<2>(lagrange<2>()), - lagrange<1>() - )); + // overlapping + Dune::YaspGrid<2> grid3({1.0, 1.0}, {8,8}, 0, 1); + Dune::YaspGrid<3> grid4({1.0, 1.0, 1.0}, {8,8,8}, 0, 1); - checkBasis(taylorHoodBasis); + checkGrid(grid1); + checkGrid(grid2); + checkGrid(grid3); + checkGrid(grid4); return report_errors(); } -- GitLab From 7a4b78c2b7987ecf69f3f3bb841fb3ea79cbbcb9 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 12 Jun 2019 15:18:51 +0200 Subject: [PATCH 07/11] add general implementation and specialization for TaylorHoodBasis --- src/amdis/functions/GlobalIdSet.hpp | 155 +++++++++++++++++++++++----- src/amdis/functions/Nodes.hpp | 9 ++ test/GlobalIdSetTest.cpp | 4 + 3 files changed, 140 insertions(+), 28 deletions(-) diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index 88dc790d..d7152b8b 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -35,6 +35,9 @@ namespace Dune template class LagrangeDGPreBasis; + + template + class TaylorHoodPreBasis; } } @@ -45,6 +48,27 @@ namespace AMDiS template class NodeIdSet; + /// \brief PRovide global ids for all DOFs in a global basis + /** + * A GlobalBasisIdSet provides and interface to retrieve unique IDs + * (over all partitions) for all DOFs in the basis. It is implemented + * in terms of the \ref NodeIdSet for each basis node that locally + * on each element calculates a global unique id. + * + * **Examples:** + * ``` + GlobalBasisIdSet idSet(basis); + for (const auto& e : elements(basis.gridView())) { + idSet.bind(e); + for (std::size_t i = 0; i < idSet.size(); ++i) { + auto id = idSet.id(i); // global unique ID of i'th local DOF + auto pt = idSet.partitionType(i); // partition type of i'th local DOF + } + idSet.unbind(); + } + * ``` + * + **/ template class GlobalBasisIdSet { @@ -132,6 +156,79 @@ namespace AMDiS }; + template + class NodeIdSet + { + public: + using PreBasis = PB; + using Node = Node_t; + using GridView = typename PreBasis::GridView; + using size_type = std::size_t; + + static_assert(Node::isLeaf, "Generic NodeIdSet implemented for LeafNodes only. Provide a spcialization for your node!"); + + private: + static constexpr int dim = GridView::template Codim<0>::Entity::mydimension; + + public: + NodeIdSet(GridView const& gridView) + : gridView_(gridView) + {} + + /// \brief Bind the idset to a tree node + void bind(const Node& node) + { + node_ = &node; + size_ = node_->finiteElement().size(); + } + + /// \brief Unbind the idset + void unbind() + { + node_ = nullptr; + } + + /// \brief Number of DOFs in this node + size_type size() const + { + return size_; + } + + /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis + // [[expects: node_ != nullptr]] + template + It fillIn(It it, size_type shift = 0) const + { + const auto& gridIdSet = gridView_.grid().globalIdSet(); + + for (size_type i = 0; i < size_ ; ++i, ++it) { + Dune::LocalKey localKey = node_->finiteElement().localCoefficients().localKey(i); + unsigned int s = localKey.subEntity(); + unsigned int c = localKey.codim(); + unsigned int idx = localKey.index(); + if (!(c == GridView::dimension || c == 0 || idx == 0)) + DUNE_THROW(Dune::NotImplemented, "Bases with more then one DoF per subentity are not supported."); + + it->first = {gridIdSet.subId(node_->element(), s, c), shift + idx}; + + it->second = Dune::Hybrid::switchCases(std::make_index_sequence{}, c, + [&](auto codim) { return node_->element().template subEntity(s).partitionType(); }, + [&]() { + error_exit("Invalid codimension c = {}", c); + return Dune::PartitionType{}; + }); + } + + return it; + } + + protected: + GridView gridView_; + const Node* node_ = nullptr; + size_type size_ = 0; + }; + + template class NodeIdSet, TP> { @@ -269,40 +366,56 @@ namespace AMDiS }; - template - class NodeIdSet, TP> + template + class NodeIdSet, TP> { public: - using PreBasis = Dune::Functions::LagrangePreBasis; + using PreBasis = Dune::Functions::TaylorHoodPreBasis; using Node = Node_t; using GridView = typename PreBasis::GridView; using size_type = std::size_t; private: - static constexpr int dim = GridView::template Codim<0>::Entity::mydimension; + using VTP = decltype(Dune::TypeTree::push_back(std::declval(), Dune::index_constant<0>{})); + using PTP = decltype(Dune::TypeTree::push_back(std::declval(), Dune::index_constant<1>{})); + + // Note: PreBasis::PQ1PReBasis is private + using PQ1PreBasis = typename NodeIndexSet_t::PQ1NodeIndexSet::PreBasis; + using PQ2PreBasis = typename NodeIndexSet_t::PQ2NodeIndexSet::PreBasis; + + using PQ1NodeIdSet = NodeIdSet; // pressure + using PQ2NodeIdSet = NodeIdSet; // velocity + + private: + static constexpr int dow = GridView::dimensionworld; public: NodeIdSet(GridView const& gridView) - : gridView_(gridView) + : pq1NodeIdSet_(gridView) + , pq2NodeIdSet_(gridView) {} /// \brief Bind the idset to a tree node void bind(const Node& node) { node_ = &node; - size_ = node_->finiteElement().size(); + using namespace Dune::Indices; + pq1NodeIdSet_.bind(node.child(_1)); + pq2NodeIdSet_.bind(node.child(_0, 0)); } /// \brief Unbind the idset void unbind() { + pq1NodeIdSet_.unbind(); + pq2NodeIdSet_.unbind(); node_ = nullptr; } /// \brief Number of DOFs in this node size_type size() const { - return size_; + return node_->size(); } /// \brief Maps from subtree index set [0..size-1] to a globally unique id in global basis @@ -310,33 +423,19 @@ namespace AMDiS template It fillIn(It it, size_type shift = 0) const { - const auto& gridIdSet = gridView_.grid().globalIdSet(); - - for (size_type i = 0; i < size_ ; ++i, ++it) { - Dune::LocalKey localKey = node_->finiteElement().localCoefficients().localKey(i); - unsigned int s = localKey.subEntity(); - unsigned int c = localKey.codim(); - unsigned int idx = localKey.index(); - if (!(c == GV::dimension || c == 0 || idx == 0)) - DUNE_THROW(Dune::NotImplemented, "Bases with more then one DoF per subentity are not supported."); - - it->first = {gridIdSet.subId(node_->element(), s, c), shift + idx}; - - it->second = Dune::Hybrid::switchCases(std::make_index_sequence{}, c, - [&](auto codim) { return node_->element().template subEntity(s).partitionType(); }, - [&]() { - error_exit("Invalid codimension c = {}", c); - return Dune::PartitionType{}; - }); + for (int child = 0; child < dow; ++child) { + size_type subTreeSize = pq2NodeIdSet_.size(); + it = pq2NodeIdSet_.fillIn(it, shift); + shift += subTreeSize; } - + it = pq1NodeIdSet_.fillIn(it, shift); return it; } protected: - GridView gridView_; + PQ1NodeIdSet pq1NodeIdSet_; + PQ2NodeIdSet pq2NodeIdSet_; const Node* node_ = nullptr; - size_type size_ = 0; }; diff --git a/src/amdis/functions/Nodes.hpp b/src/amdis/functions/Nodes.hpp index 9977490e..5a247083 100644 --- a/src/amdis/functions/Nodes.hpp +++ b/src/amdis/functions/Nodes.hpp @@ -13,6 +13,15 @@ namespace AMDiS typename PB::Node; #endif + // dune version independent extraction of node indexset type from preBasis + template + using NodeIndexSet_t = +#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7) + typename PB::template IndexSet; +#else + typename PB::IndexSet; +#endif + // dune version independent creation of node from preBasis template auto makeNode(PB const& preBasis, TP const& treePath) diff --git a/test/GlobalIdSetTest.cpp b/test/GlobalIdSetTest.cpp index 4c9fc35f..b332cf98 100644 --- a/test/GlobalIdSetTest.cpp +++ b/test/GlobalIdSetTest.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "Tests.hpp" @@ -52,8 +53,11 @@ void checkGrid(const Grid& grid) lagrangeDG<1>() )); + auto basis3 = makeBasis(grid.leafGridView(), taylorHood()); + checkBasisIds(basis1); checkBasisIds(basis2); + checkBasisIds(basis3); } int main(int argc, char** argv) -- GitLab From 63213d401cc183d018092fdf55fac676213ae6c3 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 12 Jun 2019 15:53:56 +0200 Subject: [PATCH 08/11] corrected treepath of velocity component in taylorhoodbasis --- src/amdis/functions/GlobalIdSet.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index d7152b8b..604818df 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -376,15 +376,16 @@ namespace AMDiS using size_type = std::size_t; private: - using VTP = decltype(Dune::TypeTree::push_back(std::declval(), Dune::index_constant<0>{})); using PTP = decltype(Dune::TypeTree::push_back(std::declval(), Dune::index_constant<1>{})); + using VTP = decltype(Dune::TypeTree::push_back(std::declval(), Dune::index_constant<0>{})); + using V0TP = decltype(Dune::TypeTree::push_back(std::declval(), std::size_t(0))); - // Note: PreBasis::PQ1PReBasis is private + // Note: PreBasis::PQ1PreBasis is private using PQ1PreBasis = typename NodeIndexSet_t::PQ1NodeIndexSet::PreBasis; using PQ2PreBasis = typename NodeIndexSet_t::PQ2NodeIndexSet::PreBasis; using PQ1NodeIdSet = NodeIdSet; // pressure - using PQ2NodeIdSet = NodeIdSet; // velocity + using PQ2NodeIdSet = NodeIdSet; // velocity private: static constexpr int dow = GridView::dimensionworld; -- GitLab From 807819eb376d15aafe2e680ac523e8b2d6e9ee91 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 12 Jun 2019 16:28:58 +0200 Subject: [PATCH 09/11] add missing include --- src/amdis/functions/GlobalIdSet.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index 604818df..2ba0436a 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include -- GitLab From 0e93dd0929c5709aaed1ebf0ead267c67d4da01b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=BCller=2C=20Felix?= Date: Thu, 13 Jun 2019 12:21:12 +0200 Subject: [PATCH 10/11] Added function returning the entityID of a DOF --- src/amdis/functions/GlobalIdSet.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index 2ba0436a..1727e1eb 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -130,6 +130,13 @@ namespace AMDiS return data_[i].first; } + /// \brief Return the global unique ID of the entity associated to the + /// `i`th DOF on the currently bound element in the basis tree. + IdType entityId(size_type i) const + { + return id(i).first; + } + /// \brief Return the partition type of the `i`th DOF on the /// currently bound element in the basis tree. PartitionType partitionType(size_type i) const -- GitLab From 984f5d9e8a02b9680fd661a650f2494d71821269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=BCller=2C=20Felix?= Date: Thu, 13 Jun 2019 12:25:37 +0200 Subject: [PATCH 11/11] Corrected returned type --- src/amdis/functions/GlobalIdSet.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/amdis/functions/GlobalIdSet.hpp b/src/amdis/functions/GlobalIdSet.hpp index 1727e1eb..b2c089d0 100644 --- a/src/amdis/functions/GlobalIdSet.hpp +++ b/src/amdis/functions/GlobalIdSet.hpp @@ -81,7 +81,8 @@ namespace AMDiS using GridView = typename GlobalBasis::GridView; using Grid = typename GridView::Grid; using Element = typename GridView::template Codim<0>::Entity; - using IdType = std::pair; + using EntityIdType = typename Grid::GlobalIdSet::IdType; + using IdType = std::pair; using PartitionType = Dune::PartitionType; using PreBasis = typename GlobalBasis::PreBasis; @@ -132,7 +133,7 @@ namespace AMDiS /// \brief Return the global unique ID of the entity associated to the /// `i`th DOF on the currently bound element in the basis tree. - IdType entityId(size_type i) const + EntityIdType entityId(size_type i) const { return id(i).first; } -- GitLab