Skip to content
Snippets Groups Projects
Commit ad88e3cf authored by Hanchuan Wu's avatar Hanchuan Wu
Browse files

Merge branch 'cherry-pick-074f2c55' into 'releases/3.4'

Merge branch 'feature/deprecate-old-mapper-update-interface-in-dumux' into 'master'

See merge request !2715
parents fdb81fdc d25a63a0
No related branches found
No related tags found
1 merge request!2715Merge branch 'feature/deprecate-old-mapper-update-interface-in-dumux' into 'master'
Pipeline #6069 passed
+3
...@@ -77,6 +77,8 @@ by the assembler in future Dumux versions. ...@@ -77,6 +77,8 @@ by the assembler in future Dumux versions.
- `Dumux::IsIndexable<T, I>` is deprecated, use `Dune::IsIndexable<T, I>`directly. - `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 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) ### New experimental features (possibly subject to backwards-incompatible changes in the future)
......
...@@ -48,8 +48,23 @@ class ConformingGridIntersectionMapper ...@@ -48,8 +48,23 @@ class ConformingGridIntersectionMapper
public: public:
ConformingGridIntersectionMapper(const GridView& gridView) 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() void update()
{} {}
...@@ -71,11 +86,12 @@ public: ...@@ -71,11 +86,12 @@ public:
GridIndexType globalIntersectionIndex(const Element& element, const std::size_t localFaceIdx) const 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: private:
const GridView gridView_; GridView gridView_;
const typename GridView::IndexSet* indexSet_;
}; };
/*! /*!
...@@ -93,6 +109,7 @@ class NonConformingGridIntersectionMapper ...@@ -93,6 +109,7 @@ class NonConformingGridIntersectionMapper
public: public:
NonConformingGridIntersectionMapper(const GridView& gridview) NonConformingGridIntersectionMapper(const GridView& gridview)
: gridView_(gridview), : gridView_(gridview),
indexSet_(&gridView_.indexSet()),
numIntersections_(gridView_.size(1)), numIntersections_(gridView_.size(1)),
intersectionMapGlobal_(gridView_.size(0)) intersectionMapGlobal_(gridView_.size(0))
{ {
...@@ -115,7 +132,33 @@ public: ...@@ -115,7 +132,33 @@ public:
return intersectionMapGlobal_[index(element)].size(); 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() void update()
{
update_();
}
private:
GridIndexType index(const Element& element) const
{
return indexSet_->index(element);
}
void update_()
{ {
intersectionMapGlobal_.clear(); intersectionMapGlobal_.clear();
intersectionMapGlobal_.resize(gridView_.size(0)); intersectionMapGlobal_.resize(gridView_.size(0));
...@@ -165,13 +208,8 @@ public: ...@@ -165,13 +208,8 @@ public:
numIntersections_ = globalIntersectionIdx; numIntersections_ = globalIntersectionIdx;
} }
private: GridView gridView_;
GridIndexType index(const Element& element) const const typename GridView::IndexSet* indexSet_;
{
return gridView_.indexSet().index(element);
}
const GridView gridView_;
unsigned int numIntersections_; unsigned int numIntersections_;
std::vector<std::unordered_map<int, int> > intersectionMapGlobal_; std::vector<std::unordered_map<int, int> > intersectionMapGlobal_;
}; };
...@@ -305,7 +343,26 @@ public: ...@@ -305,7 +343,26 @@ public:
return intersectionMapLocal_[index(element)].size(); 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() void update()
{
update_();
}
protected:
void update_()
{ {
if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>()) if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
elementMapper_.update(gridView_); elementMapper_.update(gridView_);
...@@ -331,7 +388,6 @@ public: ...@@ -331,7 +388,6 @@ public:
fIdx++; fIdx++;
} }
} }
int globalIntersectionIdx = 0; int globalIntersectionIdx = 0;
for (const auto& element : elements(gridView_)) for (const auto& element : elements(gridView_))
{ {
...@@ -384,9 +440,7 @@ public: ...@@ -384,9 +440,7 @@ public:
} }
size_ = globalIntersectionIdx; size_ = globalIntersectionIdx;
} }
GridView gridView_;
protected:
const GridView gridView_;
ElementMapper elementMapper_; ElementMapper elementMapper_;
unsigned int size_; unsigned int size_;
std::vector<std::unordered_map<int, int> > intersectionMapGlobal_; std::vector<std::unordered_map<int, int> > intersectionMapGlobal_;
......
...@@ -57,8 +57,8 @@ public: ...@@ -57,8 +57,8 @@ public:
template<class Layout> template<class Layout>
ReorderingDofMapper (const GridView& gridView, Layout&& layout) ReorderingDofMapper (const GridView& gridView, Layout&& layout)
: gridView_(gridView) : gridView_(gridView)
, indexSet_(gridView.indexSet()) , indexSet_(&gridView.indexSet())
, codimension_(layout(indexSet_.types(0)[0], GridView::dimension) ? 0 : GridView::dimension) , codimension_(layout(indexSet_->types(0)[0], GridView::dimension) ? 0 : GridView::dimension)
{ {
update(); update();
} }
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
Index index (const EntityType& e) const Index index (const EntityType& e) const
{ {
// map the index using the permutation obtained from the reordering algorithm // 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. /** @brief Map subentity of codim 0 entity to array index.
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
*/ */
Index subIndex (const Element& e, int i, unsigned int codim) const 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. /** @brief Return total number of entities in the entity set managed by the mapper.
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
*/ */
std::size_t size () const 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 /** @brief Returns true if the entity is contained in the index set
...@@ -125,14 +125,38 @@ public: ...@@ -125,14 +125,38 @@ public:
*/ */
bool contains (const Element& e, int i, int cc, Index& result) const 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; return true;
} }
/*! /*!
* \brief Recalculates map after mesh adaptation * \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 () void update ()
{
update_();
}
private:
void update_()
{ {
// Compute scotch reordering // Compute scotch reordering
Dune::Timer watch; Dune::Timer watch;
...@@ -144,11 +168,11 @@ public: ...@@ -144,11 +168,11 @@ public:
{ {
for (const auto& element : elements(gridView_)) for (const auto& element : elements(gridView_))
{ {
auto eIdx = indexSet_.index(element); auto eIdx = indexSet_->index(element);
for (const auto& intersection : intersections(gridView_, element)) for (const auto& intersection : intersections(gridView_, element))
{ {
if (intersection.neighbor()) if (intersection.neighbor())
graph[eIdx].push_back(indexSet_.index(intersection.outside())); graph[eIdx].push_back(indexSet_->index(intersection.outside()));
} }
} }
} }
...@@ -157,10 +181,10 @@ public: ...@@ -157,10 +181,10 @@ public:
{ {
for (const auto& element : elements(gridView_)) 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) 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); graph[vIdxGlobal].push_back(eIdx);
} }
} }
...@@ -170,11 +194,9 @@ public: ...@@ -170,11 +194,9 @@ public:
std::cout << "Scotch backend reordered index set of size " << size() std::cout << "Scotch backend reordered index set of size " << size()
<< " in " << watch.elapsed() << " seconds." << std::endl; << " in " << watch.elapsed() << " seconds." << std::endl;
} }
private:
// GridView is needed to keep the IndexSet valid // GridView is needed to keep the IndexSet valid
const GridView gridView_; GridView gridView_;
const typename GridView::IndexSet& indexSet_; const typename GridView::IndexSet* indexSet_;
const int codimension_; const int codimension_;
// the map resulting from the reordering // the map resulting from the reordering
std::vector<int> permutation_; std::vector<int> permutation_;
......
...@@ -216,6 +216,19 @@ public: ...@@ -216,6 +216,19 @@ public:
//! the update here simply updates the non-enriched map //! the update here simply updates the non-enriched map
//! enrichment has to be done afterwards! //! 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() void update()
{ {
initialize_(); initialize_();
...@@ -285,7 +298,7 @@ private: ...@@ -285,7 +298,7 @@ private:
// data members // data members
std::size_t size_; //! number of dofs mapped to by this mapper 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 elementMapper_; //! unmodified element mapper
MCMGMapper vertexMapper_; //! unmodified vertex mapper MCMGMapper vertexMapper_; //! unmodified vertex mapper
bool hasEnrichedVertices_; //! keeps track of if vertices are enriched bool hasEnrichedVertices_; //! keeps track of if vertices are enriched
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment