Commit 3592dcb3 authored by Hanchuan Wu's avatar Hanchuan Wu Committed by Timo Koch
Browse files

Merge branch 'feature/remove-deprecation-warning-from-mapper-update' into 'master'

Remove deprecation warning from mapper.update()

Closes #1051

See merge request !2711

(cherry picked from commit 3d75f3fc)

9af849b7 [deprecated] Add deprecation helpers for mapper.update()
db174bd4 [mapper] Allow for new interface mapper.update(gridView) and deprecate usage of old mappers
parent 309e622c
Pipeline #6035 passed with stages
......@@ -25,6 +25,9 @@
#ifndef DUMUX_COMMON_DEPRECATED_HH
#define DUMUX_COMMON_DEPRECATED_HH
#include <dune/common/version.hh>
#include <dune/common/std/type_traits.hh>
namespace Dumux {
#ifndef DOXYGEN // hide from doxygen
......@@ -36,7 +39,20 @@ namespace Dumux {
// so most likely you don't want to use this in your code
namespace Deprecated {
// add helpers here
template <class Mapper, class GridView>
using GridViewDetector = decltype(std::declval<Mapper>().update(std::declval<GridView>()));
template<class Mapper, class GridView>
static constexpr bool hasUpdateGridView()
{ return Dune::Std::is_detected<GridViewDetector, Mapper, GridView>::value; }
// helper class to print deprecated message
template <class Mapper>
#if DUNE_VERSION_GTE(DUNE_GRID,2,8)
[[deprecated("The interface mapper.update() is deprecated. All mappers now have to implement `update(gridView)` instead (with a gridView as argument). Only mappers with the new interface will be support for dune-grid 2.7 is dropped.")]]
#endif
void update(Mapper& mapper)
{ mapper.update(); };
} // end namespace Deprecated
#endif
......
......@@ -29,6 +29,7 @@
#include <dune/grid/common/mcmgmapper.hh>
#include <dune/grid/common/rangegenerators.hh>
#include <dumux/common/deprecated.hh>
namespace Dumux {
......@@ -306,7 +307,10 @@ public:
void update()
{
elementMapper_.update();
if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
elementMapper_.update(gridView_);
else
Deprecated::update(elementMapper_);
intersectionMapGlobal_.clear();
intersectionMapGlobal_.resize(elementMapper_.size());
......
......@@ -28,6 +28,7 @@
#include <dune/grid/common/mcmgmapper.hh>
#include <dumux/common/deprecated.hh>
#include <dumux/common/entitymap.hh>
#include <dumux/common/indextraits.hh>
#include <dumux/geometry/boundingboxtree.hh>
......@@ -90,8 +91,15 @@ public:
void update()
{
//! Update the mappers
vertexMapper_.update();
elementMapper_.update();
if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
elementMapper_.update(gridView_);
else
Deprecated::update(elementMapper_);
if constexpr (Deprecated::hasUpdateGridView<VertexMapper, GridView>())
vertexMapper_.update(gridView_);
else
Deprecated::update(vertexMapper_);
//! Compute the bouding box of the entire domain, for e.g. setting boundary conditions
computeGlobalBoundingBox_();
......
......@@ -38,6 +38,8 @@
#include <dune/grid/io/file/vtk/vtkwriter.hh>
#include <dune/grid/io/file/vtk/function.hh>
#include <dumux/common/deprecated.hh>
#if HAVE_MPI
#include <mpi.h>
#endif
......@@ -196,8 +198,15 @@ public:
*/
void gridChanged()
{
elementMapper_.update();
vertexMapper_.update();
if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
elementMapper_.update(gridView_);
else
Deprecated::update(elementMapper_);
if constexpr (Deprecated::hasUpdateGridView<VertexMapper, GridView>())
vertexMapper_.update(gridView_);
else
Deprecated::update(vertexMapper_);
}
/*!
......
......@@ -41,6 +41,7 @@
#include<dune/istl/operators.hh>
#include<dune/istl/bcrsmatrix.hh>
#include <dumux/common/deprecated.hh>
#include <dumux/porousmediumflow/sequential/pressureproperties.hh>
#include <dumux/common/boundaryconditions.hh>
#include "localstiffness.hh"
......@@ -111,7 +112,10 @@ public:
//! Initialize the CR operator assembler
void initialize()
{
faceMapper_.update();
if constexpr (Deprecated::hasUpdateGridView<FaceMapper, GridView>())
faceMapper_.update(gridView_);
else
Deprecated::update(faceMapper_);
size_ = faceMapper_.size();
A_.setSize(size_, size_, nnz());
......
......@@ -25,6 +25,7 @@
#include <unordered_map>
#include <dune/grid/common/partitionset.hh>
#include <dumux/common/deprecated.hh>
#include "properties.hh"
#include "gridadaptproperties.hh"
......@@ -187,7 +188,11 @@ public:
// forceRefineRatio(1);
// update mapper to new cell indices
problem_.variables().elementMapper().update();
using ElementMapper = std::decay_t<decltype(problem_.variables().elementMapper())>;
if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
problem_.variables().elementMapper().update(problem_.gridView());
else
Deprecated::update(problem_.variables().elementMapper());
// adapt size of vectors
problem_.variables().adaptVariableSize(problem_.variables().elementMapper().size());
......
......@@ -20,7 +20,7 @@
#define DUMUX_VARIABLECLASS_HH
#include "properties.hh"
#include <dumux/common/deprecated.hh>
// for parallelization
//#include <dumux/parallel/elementhandles.hh>
......@@ -89,8 +89,16 @@ public:
*/
void initialize()
{
elementMapper_.update();
vertexMapper_.update();
if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
elementMapper_.update(gridView_);
else
Deprecated::update(elementMapper_);
if constexpr (Deprecated::hasUpdateGridView<VertexMapper, GridView>())
vertexMapper_.update(gridView_);
else
Deprecated::update(vertexMapper_);
cellDataVector_.resize(gridView_.size(0));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment