Skip to content
Snippets Groups Projects
Commit 6d24c05e authored by Timo Koch's avatar Timo Koch
Browse files

[factory] Adapt to function.hh deprecation

parent 995e0a13
No related branches found
No related tags found
No related merge requests found
Pipeline #25190 passed
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <memory> #include <memory>
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
#define DUNE_FUNCTION_HH_SILENCE_DEPRECATION
#include <dune/common/function.hh> #include <dune/common/function.hh>
#include <dune/foamgrid/foamgrid/foamgridvertex.hh> #include <dune/foamgrid/foamgrid/foamgridvertex.hh>
...@@ -181,6 +183,7 @@ namespace Dune { ...@@ -181,6 +183,7 @@ namespace Dune {
bool isNew_; bool isNew_;
/** \brief The element parametrization */ /** \brief The element parametrization */
// TODO after deprecation period (release 2.8) change this to std::function
std::shared_ptr<VirtualFunction<FieldVector<ctype, dimgrid>, FieldVector<ctype, dimworld> > > elementParametrization_; std::shared_ptr<VirtualFunction<FieldVector<ctype, dimgrid>, FieldVector<ctype, dimworld> > > elementParametrization_;
/** \brief This flag is set by postGrow() if the element looses its right to coarsen /** \brief This flag is set by postGrow() if the element looses its right to coarsen
...@@ -366,6 +369,7 @@ namespace Dune { ...@@ -366,6 +369,7 @@ namespace Dune {
FoamGridEntityImp<dimgrid, dimgrid ,dimworld, ctype>* father_; FoamGridEntityImp<dimgrid, dimgrid ,dimworld, ctype>* father_;
/** \brief The element parametrization */ /** \brief The element parametrization */
// TODO after deprecation period (release 2.8) change this to std::function
std::shared_ptr<VirtualFunction<FieldVector<ctype, dimgrid>, FieldVector<ctype, dimworld> > > elementParametrization_; std::shared_ptr<VirtualFunction<FieldVector<ctype, dimgrid>, FieldVector<ctype, dimworld> > > elementParametrization_;
/** \brief This flag is set by postGrow() if the element looses its right to coarsen /** \brief This flag is set by postGrow() if the element looses its right to coarsen
......
...@@ -11,8 +11,11 @@ ...@@ -11,8 +11,11 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
#include <functional>
#include <dune/common/deprecated.hh>
#include <dune/common/version.hh> #include <dune/common/version.hh>
#define DUNE_FUNCTION_HH_SILENCE_DEPRECATION
#include <dune/common/function.hh> #include <dune/common/function.hh>
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/hash.hh> #include <dune/common/hash.hh>
...@@ -189,11 +192,17 @@ template <int dimworld, class ct> ...@@ -189,11 +192,17 @@ template <int dimworld, class ct>
); );
} }
#if DUNE_VERSION_GT(DUNE_COMMON, 2, 7)
DUNE_NO_DEPRECATED_BEGIN
#endif
/** \brief Insert a parametrized element into the coarse grid /** \brief Insert a parametrized element into the coarse grid
\param type The GeometryType of the new element \param type The GeometryType of the new element
\param vertices The vertices of the new element, using the DUNE numbering \param vertices The vertices of the new element, using the DUNE numbering
\param elementParametrization A function prescribing the shape of this element \param elementParametrization A function prescribing the shape of this element
*/ */
#if DUNE_VERSION_GT(DUNE_COMMON, 2, 7)
[[deprecated("After Dune 2.7: VirtualFunction is deprecated: use overload taking std::function!")]]
#endif
void insertElement(const GeometryType& type, void insertElement(const GeometryType& type,
const std::vector<unsigned int>& vertices, const std::vector<unsigned int>& vertices,
const std::shared_ptr<VirtualFunction<FieldVector<ctype,dimgrid>,FieldVector<ctype,dimworld> > >& elementParametrization) override const std::shared_ptr<VirtualFunction<FieldVector<ctype,dimgrid>,FieldVector<ctype,dimworld> > >& elementParametrization) override
...@@ -208,6 +217,28 @@ template <int dimworld, class ct> ...@@ -208,6 +217,28 @@ template <int dimworld, class ct>
std::get<dimgrid>(this->grid_->entityImps_[0]).push_back(newElement); std::get<dimgrid>(this->grid_->entityImps_[0]).push_back(newElement);
} }
#if DUNE_VERSION_GT(DUNE_COMMON, 2, 7)
DUNE_NO_DEPRECATED_END
/** \brief Insert a parametrized element into the coarse grid
\param type The GeometryType of the new element
\param vertices The vertices of the new element, using the DUNE numbering
\param elementParametrization A function prescribing the shape of this element
*/
void insertElement(const GeometryType& type,
const std::vector<unsigned int>& vertices,
std::function<FieldVector<ctype,dimworld>(FieldVector<ctype,dimgrid>)> elementParametrization) override
{
// for the deprecation period forward to the deprecated interface
// after release 2.8 remove old interface and adapt internal implementation to use std::function
using D = FieldVector<ctype,dimgrid>;
using R = FieldVector<ctype,dimworld>;
DUNE_NO_DEPRECATED_BEGIN
auto f = makeVirtualFunction<D,R>(std::move(elementParametrization));
insertElement(type, vertices, std::make_unique<decltype(f)>(std::move(f)));
DUNE_NO_DEPRECATED_END
}
#endif
/** \brief Finalize grid creation and hand over the grid /** \brief Finalize grid creation and hand over the grid
......
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