diff --git a/dumux/common/deprecated.hh b/dumux/common/deprecated.hh index e502f2475ea178272ad2627f75de37d640f03aa7..76e3b726529ebc1e4ae51eef511bb36d952462e2 100644 --- a/dumux/common/deprecated.hh +++ b/dumux/common/deprecated.hh @@ -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 diff --git a/dumux/common/intersectionmapper.hh b/dumux/common/intersectionmapper.hh index fe782b2b4029ab680e19723e0819e103dbfcc84a..402384b451c7358f15e36860089a917a61cf5ea8 100644 --- a/dumux/common/intersectionmapper.hh +++ b/dumux/common/intersectionmapper.hh @@ -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()); diff --git a/dumux/discretization/basegridgeometry.hh b/dumux/discretization/basegridgeometry.hh index 40de731121ee629d8ea65d3ef148ed42326ef1a6..56f76901357e07a753a53e8947c98a4dd2659640 100644 --- a/dumux/discretization/basegridgeometry.hh +++ b/dumux/discretization/basegridgeometry.hh @@ -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_(); diff --git a/dumux/io/vtkmultiwriter.hh b/dumux/io/vtkmultiwriter.hh index 2dea5ea4e2040e57cedb6f1d34ae97061614a9f1..9a9ace09e1df573e4b3c1025e4bc6facf082a735 100644 --- a/dumux/io/vtkmultiwriter.hh +++ b/dumux/io/vtkmultiwriter.hh @@ -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_); } /*! diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/croperator.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/croperator.hh index 3999c466d5ecdac07c22061a2f93093bf2473204..dc09d7d8ef9d445680e408ec4f3cd615efe4d3f8 100644 --- a/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/croperator.hh +++ b/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/croperator.hh @@ -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()); diff --git a/dumux/porousmediumflow/sequential/gridadapt.hh b/dumux/porousmediumflow/sequential/gridadapt.hh index 9d123472c7f996623266397d193704abe939841c..3818baa59510476c756e11b831b3b9b88a473758 100644 --- a/dumux/porousmediumflow/sequential/gridadapt.hh +++ b/dumux/porousmediumflow/sequential/gridadapt.hh @@ -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()); diff --git a/dumux/porousmediumflow/sequential/variableclass.hh b/dumux/porousmediumflow/sequential/variableclass.hh index a0ce8afe8d1c6071ef7b9bd527ee3b9ad25c55ee..ec3e242424fe1c044a1c3bbd3175c24d4a225d88 100644 --- a/dumux/porousmediumflow/sequential/variableclass.hh +++ b/dumux/porousmediumflow/sequential/variableclass.hh @@ -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)); }