diff --git a/CHANGELOG.md b/CHANGELOG.md index 1808860e97cfc808cf121104baa9854d634574ad..5045af9713cc40819a7068c14e5c906ecdc36e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,8 @@ by the assembler in future Dumux versions. - `Dumux::IsIndexable<T, I>` is deprecated, use `Dune::IsIndexable<T, I>`directly. - The property `NumEqVector` has been deprecated. The class `NumEqVector` is now defined in namespace `Dumux` in header file `dumux/common/numeqvector.hh`. +- The member function `update()` of mappers is deprecated, use `update(gridView)` when updating the mapper after a grid or grid view change. +- All custom mapper implementation should implement `update(gridView)` replacing `update()`. Mappers with `update()` will no longer be supported after support for dune 2.7 is dropped. ### New experimental features (possibly subject to backwards-incompatible changes in the future) diff --git a/dumux/common/intersectionmapper.hh b/dumux/common/intersectionmapper.hh index 402384b451c7358f15e36860089a917a61cf5ea8..e36081b30067e93f3caf5d0be549787a3496ccad 100644 --- a/dumux/common/intersectionmapper.hh +++ b/dumux/common/intersectionmapper.hh @@ -48,8 +48,23 @@ class ConformingGridIntersectionMapper public: ConformingGridIntersectionMapper(const GridView& gridView) - : gridView_(gridView) { } + : gridView_(gridView) + , indexSet_(&gridView.indexSet()) + {} + + void update (const GridView& gridView) + { + gridView_ = gridView; + indexSet_ = &gridView_.indexSet(); + } + + void update (GridView&& gridView) + { + gridView_ = std::move(gridView); + indexSet_ = &gridView_.indexSet(); + } + [[deprecated("Use update(gridView) instead! Will be removed after release 3.4.")]] void update() {} @@ -71,11 +86,12 @@ public: GridIndexType globalIntersectionIndex(const Element& element, const std::size_t localFaceIdx) const { - return gridView_.indexSet().subIndex(element, localFaceIdx, codimIntersection); + return indexSet_->subIndex(element, localFaceIdx, codimIntersection); } private: - const GridView gridView_; + GridView gridView_; + const typename GridView::IndexSet* indexSet_; }; /*! @@ -93,6 +109,7 @@ class NonConformingGridIntersectionMapper public: NonConformingGridIntersectionMapper(const GridView& gridview) : gridView_(gridview), + indexSet_(&gridView_.indexSet()), numIntersections_(gridView_.size(1)), intersectionMapGlobal_(gridView_.size(0)) { @@ -115,7 +132,33 @@ public: return intersectionMapGlobal_[index(element)].size(); } + void update (const GridView& gridView) + { + gridView_ = gridView; + indexSet_ = &gridView_.indexSet(); + update_(); + } + + void update (GridView&& gridView) + { + gridView_ = std::move(gridView); + indexSet_ = &gridView_.indexSet(); + update_(); + } + + [[deprecated("Use update(gridView) instead! Will be removed after release 3.4.")]] void update() + { + update_(); + } + +private: + GridIndexType index(const Element& element) const + { + return indexSet_->index(element); + } + + void update_() { intersectionMapGlobal_.clear(); intersectionMapGlobal_.resize(gridView_.size(0)); @@ -165,13 +208,8 @@ public: numIntersections_ = globalIntersectionIdx; } -private: - GridIndexType index(const Element& element) const - { - return gridView_.indexSet().index(element); - } - - const GridView gridView_; + GridView gridView_; + const typename GridView::IndexSet* indexSet_; unsigned int numIntersections_; std::vector<std::unordered_map<int, int> > intersectionMapGlobal_; }; @@ -305,7 +343,26 @@ public: return intersectionMapLocal_[index(element)].size(); } + void update (const GridView &gridView) + { + gridView_ = gridView; + update_(); + } + + void update (GridView&& gridView) + { + gridView_ = std::move(gridView); + update_(); + } + + [[deprecated("Use update(gridView) instead! Will be removed after release 3.4.")]] void update() + { + update_(); + } + +protected: + void update_() { if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>()) elementMapper_.update(gridView_); @@ -331,7 +388,6 @@ public: fIdx++; } } - int globalIntersectionIdx = 0; for (const auto& element : elements(gridView_)) { @@ -384,9 +440,7 @@ public: } size_ = globalIntersectionIdx; } - -protected: - const GridView gridView_; + GridView gridView_; ElementMapper elementMapper_; unsigned int size_; std::vector<std::unordered_map<int, int> > intersectionMapGlobal_; diff --git a/dumux/common/reorderingdofmapper.hh b/dumux/common/reorderingdofmapper.hh index ff4c87a5233f61c7aebf160c1b0d2bf648d6068e..64dddd2d34b0fcd643b4867452d9322ec90c9cec 100644 --- a/dumux/common/reorderingdofmapper.hh +++ b/dumux/common/reorderingdofmapper.hh @@ -57,8 +57,8 @@ public: template<class Layout> ReorderingDofMapper (const GridView& gridView, Layout&& layout) : gridView_(gridView) - , indexSet_(gridView.indexSet()) - , codimension_(layout(indexSet_.types(0)[0], GridView::dimension) ? 0 : GridView::dimension) + , indexSet_(&gridView.indexSet()) + , codimension_(layout(indexSet_->types(0)[0], GridView::dimension) ? 0 : GridView::dimension) { update(); } @@ -74,7 +74,7 @@ public: Index index (const EntityType& e) const { // map the index using the permutation obtained from the reordering algorithm - return static_cast<Index>(permutation_[indexSet_.index(e)]); + return static_cast<Index>(permutation_[indexSet_->index(e)]); } /** @brief Map subentity of codim 0 entity to array index. @@ -86,7 +86,7 @@ public: */ Index subIndex (const Element& e, int i, unsigned int codim) const { - return indexSet_.subIndex(e, i, codim); + return indexSet_->subIndex(e, i, codim); } /** @brief Return total number of entities in the entity set managed by the mapper. @@ -99,7 +99,7 @@ public: */ std::size_t size () const { - return indexSet_.size(codimension_); + return indexSet_->size(codimension_); } /** @brief Returns true if the entity is contained in the index set @@ -125,14 +125,38 @@ public: */ bool contains (const Element& e, int i, int cc, Index& result) const { - result = indexSet_.subIndex(e, i, cc); + result = indexSet_->subIndex(e, i, cc); return true; } /*! * \brief Recalculates map after mesh adaptation */ + void update (const GridView& gridView) + { + gridView_ = gridView; + indexSet_ = &gridView_.indexSet(); + update_(); + } + + void update (GridView&& gridView) + { + gridView_ = std::move(gridView); + indexSet_ = &gridView_.indexSet(); + update_(); + } + + /*! + * \brief Recalculates map after mesh adaptation + */ + [[deprecated("Use update(gridView) instead! Will be removed after release 3.4.")]] void update () + { + update_(); + } + +private: + void update_() { // Compute scotch reordering Dune::Timer watch; @@ -144,11 +168,11 @@ public: { for (const auto& element : elements(gridView_)) { - auto eIdx = indexSet_.index(element); + auto eIdx = indexSet_->index(element); for (const auto& intersection : intersections(gridView_, element)) { if (intersection.neighbor()) - graph[eIdx].push_back(indexSet_.index(intersection.outside())); + graph[eIdx].push_back(indexSet_->index(intersection.outside())); } } } @@ -157,10 +181,10 @@ public: { for (const auto& element : elements(gridView_)) { - auto eIdx = indexSet_.index(element); + auto eIdx = indexSet_->index(element); for (int vIdxLocal = 0; vIdxLocal < element.subEntities(codimension_); ++vIdxLocal) { - auto vIdxGlobal = indexSet_.subIndex(element, vIdxLocal, codimension_); + auto vIdxGlobal = indexSet_->subIndex(element, vIdxLocal, codimension_); graph[vIdxGlobal].push_back(eIdx); } } @@ -170,11 +194,9 @@ public: std::cout << "Scotch backend reordered index set of size " << size() << " in " << watch.elapsed() << " seconds." << std::endl; } - -private: // GridView is needed to keep the IndexSet valid - const GridView gridView_; - const typename GridView::IndexSet& indexSet_; + GridView gridView_; + const typename GridView::IndexSet* indexSet_; const int codimension_; // the map resulting from the reordering std::vector<int> permutation_; diff --git a/dumux/multidomain/facet/vertexmapper.hh b/dumux/multidomain/facet/vertexmapper.hh index 1ad999b5893c4991e0383e126d31cfe827cc51f6..50e349644feca54d7bcc06af3503abd5cbd1c87c 100644 --- a/dumux/multidomain/facet/vertexmapper.hh +++ b/dumux/multidomain/facet/vertexmapper.hh @@ -216,6 +216,19 @@ public: //! the update here simply updates the non-enriched map //! enrichment has to be done afterwards! + void update(const GV& gridView) + { + gridView_ = gridView; + initialize_(); + } + + void update(GV&& gridView) + { + gridView_ = std::move(gridView); + initialize_(); + } + + [[deprecated("Use update(gridView) instead! Will be removed after release 2.8.")]] void update() { initialize_(); @@ -285,7 +298,7 @@ private: // data members std::size_t size_; //! number of dofs mapped to by this mapper - const GV gridView_; //! the grid view + GV gridView_; //! the grid view MCMGMapper elementMapper_; //! unmodified element mapper MCMGMapper vertexMapper_; //! unmodified vertex mapper bool hasEnrichedVertices_; //! keeps track of if vertices are enriched