Skip to content
Snippets Groups Projects
Commit fc853df5 authored by graeser's avatar graeser
Browse files

Merge branch 'feature/drop-deprecated-function-interface' into 'master'

Drop deprecated function interface

See merge request !71
parents 90180e6f 2c729a07
No related branches found
No related tags found
1 merge request!71Drop deprecated function interface
Pipeline #28179 passed
...@@ -3,13 +3,15 @@ ...@@ -3,13 +3,15 @@
#include <utility> #include <utility>
#include <dune/common/function.hh>
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
#include <dune/istl/matrix.hh> #include <dune/istl/matrix.hh>
// Borrow internal helper from dune-localfunctions
// for transition of function interface
#include <dune/localfunctions/common/localinterpolation.hh>
#include <dune/matrix-vector/addtodiagonal.hh> #include <dune/matrix-vector/addtodiagonal.hh>
#include "dune/fufem/staticmatrixtools.hh" #include "dune/fufem/staticmatrixtools.hh"
...@@ -37,10 +39,11 @@ class ConvolutionAssembler ...@@ -37,10 +39,11 @@ class ConvolutionAssembler
typedef typename Dune::template FieldVector<double,AnsatzGridView::dimensionworld> AnsatzGlobalCoordinate; typedef typename Dune::template FieldVector<double,AnsatzGridView::dimensionworld> AnsatzGlobalCoordinate;
typedef typename std::template pair<TrialGlobalCoordinate, AnsatzGlobalCoordinate> KernelArgument; typedef typename std::template pair<TrialGlobalCoordinate, AnsatzGlobalCoordinate> KernelArgument;
typedef typename Dune::VirtualFunction<KernelArgument, double> KernelFunction; typedef typename std::function<double(KernelArgument)> KernelFunction;
ConvolutionAssembler(const KernelFunction& kernel, int tQuadOrder=2, int aQuadOrder=2): template<class KFunc>
kernel_(kernel), ConvolutionAssembler(const KFunc& kernel, int tQuadOrder=2, int aQuadOrder=2):
kernel_(Dune::Impl::makeFunctionWithCallOperator<KernelArgument>(kernel)),
tQuadOrder_(tQuadOrder), tQuadOrder_(tQuadOrder),
aQuadOrder_(aQuadOrder) aQuadOrder_(aQuadOrder)
{} {}
...@@ -112,7 +115,7 @@ class ConvolutionAssembler ...@@ -112,7 +115,7 @@ class ConvolutionAssembler
// evauluate integration kernel at quadrature points // evauluate integration kernel at quadrature points
kernel_.evaluate(std::make_pair(tGlobalQuadPos, aGlobalQuadPos), kernelValue); kernelValue = kernel_(std::make_pair(tGlobalQuadPos, aGlobalQuadPos));
for (size_t i=0; i<tFE.localBasis().size(); ++i) for (size_t i=0; i<tFE.localBasis().size(); ++i)
{ {
...@@ -131,7 +134,7 @@ class ConvolutionAssembler ...@@ -131,7 +134,7 @@ class ConvolutionAssembler
protected: protected:
const KernelFunction& kernel_; KernelFunction kernel_;
const int tQuadOrder_; const int tQuadOrder_;
const int aQuadOrder_; const int aQuadOrder_;
}; };
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include <dune/common/function.hh>
#include <dune/geometry/referenceelements.hh> #include <dune/geometry/referenceelements.hh>
#include <dune/fufem/functions/cachedcomponentwrapper.hh> #include <dune/fufem/functions/cachedcomponentwrapper.hh>
...@@ -29,9 +27,7 @@ ...@@ -29,9 +27,7 @@
* \tparam LocalBasis The local basis type * \tparam LocalBasis The local basis type
*/ */
template <class Entity, class FE, class Base template <class Entity, class FE, class Base
=typename Dune::Function< = typename FE::Traits::LocalBasisType::Traits>
const typename FE::Traits::LocalBasisType::Traits::DomainType&,
typename FE::Traits::LocalBasisType::Traits::RangeType&> >
class AlienElementLocalBasisFunction : class AlienElementLocalBasisFunction :
public CachedComponentWrapper<AlienElementLocalBasisFunction<Entity, FE, Base>, public CachedComponentWrapper<AlienElementLocalBasisFunction<Entity, FE, Base>,
typename std::vector<typename FE::Traits::LocalBasisType::Traits::RangeType>, typename std::vector<typename FE::Traits::LocalBasisType::Traits::RangeType>,
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include <dune/common/function.hh>
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
#ifndef COMPOSED_FUNCTION_HH #ifndef COMPOSED_FUNCTION_HH
#define COMPOSED_FUNCTION_HH #define COMPOSED_FUNCTION_HH
#include <dune/common/function.hh> // Borrow internal helper from dune-localfunctions
// for transition of function interface
#include <dune/localfunctions/common/localinterpolation.hh>
/** \brief A class implementing the composition of two functions. /** \brief A class implementing the composition of two functions.
* *
...@@ -15,25 +17,23 @@ ...@@ -15,25 +17,23 @@
*/ */
template <typename AT, typename BT, typename CT> template <typename AT, typename BT, typename CT>
class ComposedFunction class ComposedFunction
: public Dune::VirtualFunction<AT, CT>
{ {
typedef Dune::VirtualFunction<AT, CT> BaseType;
public: public:
typedef typename BaseType::DomainType DomainType; using DomainType = AT;
typedef typename BaseType::RangeType RangeType; using RangeType = CT;
typedef Dune::VirtualFunction<AT,BT> InnerFunctionType; using InnerFunctionType = std::function<BT(AT)>;
typedef Dune::VirtualFunction<BT,CT> OuterFunctionType; using OuterFunctionType = std::function<CT(BT)>;
/** \brief Constructor /** \brief Constructor
* *
* \param f_ outer function for composition * \param f outer function for composition
* \param g_ inner function for composition * \param g inner function for composition
*/ */
ComposedFunction(const OuterFunctionType& f_, const InnerFunctionType& g_) : template<class F, class G>
f(f_), ComposedFunction(const F& f, const G& g) :
g(g_) f_(Dune::Impl::makeFunctionWithCallOperator<BT>(f)),
g_(Dune::Impl::makeFunctionWithCallOperator<AT>(g))
{} {}
/** \brief composed evaluation of one component using eval of the composed functions /** \brief composed evaluation of one component using eval of the composed functions
...@@ -41,19 +41,28 @@ public: ...@@ -41,19 +41,28 @@ public:
* \param x point in \f$ A \f$ at which to evaluate * \param x point in \f$ A \f$ at which to evaluate
* \param y vector in \f$ C \f$ to store the function value in * \param y vector in \f$ C \f$ to store the function value in
*/ */
virtual void evaluate(const DomainType& x, RangeType& y) const RangeType operator()(const DomainType& x)
{ {
BT ytemp; return f_(g_(x));
}
g.evaluate(x,ytemp); /** \brief composed evaluation of one component using eval of the composed functions
f.evaluate(ytemp,y); *
* \deprecated Use operator() instead
*
* \param x point in \f$ A \f$ at which to evaluate
* \param y vector in \f$ C \f$ to store the function value in
*/
void evaluate(const DomainType& x, RangeType& y) const
{
y = f_(g_(x));
} }
~ComposedFunction(){} ~ComposedFunction(){}
private: private:
const OuterFunctionType& f; OuterFunctionType f_;
const InnerFunctionType& g; InnerFunctionType g_;
}; };
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
@author graeser@math.fu-berlin.de @author graeser@math.fu-berlin.de
*/ */
#include <dune/common/function.hh>
#include <dune/fufem/functions/localbasisjacobianfunction.hh> #include <dune/fufem/functions/localbasisjacobianfunction.hh>
...@@ -18,9 +16,7 @@ ...@@ -18,9 +16,7 @@
* \tparam LocalBasis The local basis type * \tparam LocalBasis The local basis type
*/ */
template <class FE, class Base template <class FE, class Base
=typename Dune::Function< = typename FE::Traits::LocalBasisType::Traits>
const typename FE::Traits::LocalBasisType::Traits::DomainType&,
typename FE::Traits::LocalBasisType::Traits::RangeType&> >
class LocalBasisDerivativeFunction : class LocalBasisDerivativeFunction :
public Base public Base
{ {
......
...@@ -10,19 +10,22 @@ ...@@ -10,19 +10,22 @@
#include <vector> #include <vector>
#include <dune/common/function.hh>
#include <dune/fufem/functions/cachedcomponentwrapper.hh> #include <dune/fufem/functions/cachedcomponentwrapper.hh>
namespace Impl {
template<class FE>
struct LFEJacobianFunctionTraits {
using DomainType = typename FE::Traits::LocalBasisType::Traits::DomainType;
using RangeType = typename FE::Traits::LocalBasisType::Traits::JacobianType;
};
}
/** \brief Wrap partial derivative of local basis functions /** \brief Wrap partial derivative of local basis functions
* *
* \tparam FE The local finite element type * \tparam FE The local finite element type
*/ */
template <class FE, class Base template <class FE, class Base
=typename Dune::Function< = Impl::LFEJacobianFunctionTraits<FE>>
const typename FE::Traits::LocalBasisType::Traits::DomainType&,
typename FE::Traits::LocalBasisType::Traits::JacobianType&> >
class LocalBasisJacobianFunction : class LocalBasisJacobianFunction :
public CachedComponentWrapper< public CachedComponentWrapper<
LocalBasisJacobianFunction<FE, Base>, LocalBasisJacobianFunction<FE, Base>,
......
...@@ -28,11 +28,9 @@ template <class DT, class RT> ...@@ -28,11 +28,9 @@ template <class DT, class RT>
class InflateOrCut_Base : class InflateOrCut_Base :
public Dune::VirtualFunction<DT,RT> public Dune::VirtualFunction<DT,RT>
{ {
typedef Dune::VirtualFunction<DT,RT> BaseType;
public: public:
typedef typename BaseType::DomainType DomainType; using DomainType = DT;
typedef typename BaseType::RangeType RangeType; using RangeType = RT;
enum {DomainDim = DomainType::dimension, enum {DomainDim = DomainType::dimension,
RangeDim = RangeType::dimension}; RangeDim = RangeType::dimension};
...@@ -40,16 +38,18 @@ class InflateOrCut_Base: ...@@ -40,16 +38,18 @@ class InflateOrCut_Base:
InflateOrCut_Base() InflateOrCut_Base()
{} {}
virtual void evaluate(const DomainType& x, RangeType& y) const void evaluate(const DomainType& x, RangeType& y) const
{ {
y = 0.0; y = 0.0;
for (int i=0; i<DomainDim and i<RangeDim; ++i) for (int i=0; i<DomainDim and i<RangeDim; ++i)
{
y[i]=x[i]; y[i]=x[i];
} }
return; RangeType operator()(const DomainType& x) const
{
RangeType y;
evaluate(x,y);
return y;
} }
}; };
......
#include <config.h> #include <config.h>
#include <dune/common/parallel/mpihelper.hh> #include <dune/common/parallel/mpihelper.hh>
#include <dune/common/function.hh>
#include <dune/fufem/assemblers/integraloperatorassembler.hh> #include <dune/fufem/assemblers/integraloperatorassembler.hh>
#include <dune/fufem/assemblers/localassemblers/convolutionassembler.hh> #include <dune/fufem/assemblers/localassemblers/convolutionassembler.hh>
...@@ -14,28 +13,27 @@ ...@@ -14,28 +13,27 @@
template <int N> template <int N>
class Mollifier : class Mollifier
public Dune::VirtualFunction<std::pair<Dune::FieldVector<double, N>, Dune::FieldVector<double, N> >, double>
{ {
private: private:
typedef typename Dune::template FieldVector<double, N> SingleDomain; typedef typename Dune::template FieldVector<double, N> SingleDomain;
typedef typename std::template pair<SingleDomain, SingleDomain> PairDomain; typedef typename std::template pair<SingleDomain, SingleDomain> PairDomain;
typedef typename Dune::template VirtualFunction<PairDomain, double> Base;
public: public:
typedef typename Base::RangeType RangeType; using RangeType = double;
typedef typename Base::DomainType DomainType; using DomainType = PairDomain;
Mollifier(double eps) : Mollifier(double eps) :
eps_(eps) eps_(eps)
{} {}
void evaluate(const DomainType& xy, RangeType& z) const
RangeType operator()(const DomainType& xy) const
{ {
SingleDomain diff = xy.first; SingleDomain diff = xy.first;
diff -= xy.second; diff -= xy.second;
diff /= eps_; diff /= eps_;
z = exp(-1.0/(1.0-diff.two_norm2())); return exp(-1.0/(1.0-diff.two_norm2()));
} }
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment