Skip to content
Snippets Groups Projects

[factory] Adapt to function.hh deprecation

Merged Timo Koch requested to merge feature/update-element-param-interface into master
All threads resolved!
@@ -11,8 +11,12 @@
#include <vector>
#include <memory>
#include <unordered_map>
#include <functional>
#include <dune/common/deprecated.hh>
#include <dune/common/version.hh>
// TODO remove header and macro after release Dune 2.8
#define DUNE_FUNCTION_HH_SILENCE_DEPRECATION // silence deprecation warning from <dune/common/function.hh>
#include <dune/common/function.hh>
#include <dune/common/fvector.hh>
#include <dune/common/hash.hh>
@@ -189,14 +193,19 @@ template <int dimworld, class ct>
);
}
DUNE_NO_DEPRECATED_BEGIN
/** \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
*/
[[deprecated("Signature with VirtualFunction is deprecated and will be removed after Dune 2.8. Use signature with std::function.")]]
void insertElement(const GeometryType& type,
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)
#if DUNE_VERSION_LT(DUNE_COMMON, 2, 8)
override
#endif
{
assert(type.isLine());
EntityImp<1> newElement(this->vertexArray_[vertices[0]],
@@ -204,8 +213,36 @@ template <int dimworld, class ct>
0, // level
this->grid_->getNextFreeId());
// save the pointer to the element parametrization
newElement.elementParametrization_ = elementParametrization;
newElement.elementParametrization_ =
[elementParametrization](const FieldVector<ctype,dimgrid>& x){
FieldVector<ctype,dimworld> y;
elementParametrization->evaluate(x, y);
return y;
};
std::get<dimgrid>(this->grid_->entityImps_[0]).push_back(newElement);
}
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)
#if DUNE_VERSION_GT(DUNE_COMMON, 2, 7)
override
#endif
{
assert(type.isLine());
EntityImp<1> newElement(this->vertexArray_[vertices[0]],
this->vertexArray_[vertices[1]],
0, // level
this->grid_->getNextFreeId());
newElement.elementParametrization_ = elementParametrization;
std::get<dimgrid>(this->grid_->entityImps_[0]).push_back(newElement);
}
@@ -355,14 +392,19 @@ template <int dimworld, class ct>
std::get<dimgrid>(this->grid_->entityImps_[0]).push_back(newElement);
}
DUNE_NO_DEPRECATED_BEGIN
/** \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
*/
[[deprecated("Signature with VirtualFunction is deprecated and will be removed after Dune 2.8. Use signature with std::function.")]]
void insertElement(const GeometryType& type,
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)
#if DUNE_VERSION_LT(DUNE_COMMON, 2, 8)
override
#endif
{
assert(type.isTriangle());
EntityImp<dimgrid> newElement(/*level=*/0, this->grid_->getNextFreeId());
@@ -370,8 +412,35 @@ template <int dimworld, class ct>
newElement.vertex_[1] = this->vertexArray_[vertices[1]];
newElement.vertex_[2] = this->vertexArray_[vertices[2]];
// save the pointer to the element parametrization
newElement.elementParametrization_ = elementParametrization;
newElement.elementParametrization_ =
[elementParametrization](const FieldVector<ctype,dimgrid>& x){
FieldVector<ctype,dimworld> y;
elementParametrization->evaluate(x, y);
return y;
};
std::get<dimgrid>(this->grid_->entityImps_[0]).push_back(newElement);
}
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)
#if DUNE_VERSION_GT(DUNE_COMMON, 2, 7)
override
#endif
{
assert(type.isTriangle());
EntityImp<dimgrid> newElement(/*level=*/0, this->grid_->getNextFreeId());
newElement.vertex_[0] = this->vertexArray_[vertices[0]];
newElement.vertex_[1] = this->vertexArray_[vertices[1]];
newElement.vertex_[2] = this->vertexArray_[vertices[2]];
newElement.elementParametrization_ = elementParametrization;
std::get<dimgrid>(this->grid_->entityImps_[0]).push_back(newElement);
}
Loading