Commit fc853df5 authored by graeser's avatar graeser

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

Drop deprecated function interface

See merge request !71
parents 90180e6f 2c729a07
Pipeline #28179 passed with stage
in 10 minutes and 50 seconds
......@@ -3,13 +3,15 @@
#include <utility>
#include <dune/common/function.hh>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.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/fufem/staticmatrixtools.hh"
......@@ -37,10 +39,11 @@ class ConvolutionAssembler
typedef typename Dune::template FieldVector<double,AnsatzGridView::dimensionworld> AnsatzGlobalCoordinate;
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):
kernel_(kernel),
template<class KFunc>
ConvolutionAssembler(const KFunc& kernel, int tQuadOrder=2, int aQuadOrder=2):
kernel_(Dune::Impl::makeFunctionWithCallOperator<KernelArgument>(kernel)),
tQuadOrder_(tQuadOrder),
aQuadOrder_(aQuadOrder)
{}
......@@ -112,7 +115,7 @@ class ConvolutionAssembler
// 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)
{
......@@ -131,7 +134,7 @@ class ConvolutionAssembler
protected:
const KernelFunction& kernel_;
KernelFunction kernel_;
const int tQuadOrder_;
const int aQuadOrder_;
};
......
......@@ -11,8 +11,6 @@
#include <vector>
#include <map>
#include <dune/common/function.hh>
#include <dune/geometry/referenceelements.hh>
#include <dune/fufem/functions/cachedcomponentwrapper.hh>
......@@ -29,9 +27,7 @@
* \tparam LocalBasis The local basis type
*/
template <class Entity, class FE, class Base
=typename Dune::Function<
const typename FE::Traits::LocalBasisType::Traits::DomainType&,
typename FE::Traits::LocalBasisType::Traits::RangeType&> >
= typename FE::Traits::LocalBasisType::Traits>
class AlienElementLocalBasisFunction :
public CachedComponentWrapper<AlienElementLocalBasisFunction<Entity, FE, Base>,
typename std::vector<typename FE::Traits::LocalBasisType::Traits::RangeType>,
......
......@@ -11,7 +11,6 @@
#include <vector>
#include <map>
#include <dune/common/function.hh>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
......
......@@ -3,7 +3,9 @@
#ifndef 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.
*
......@@ -15,25 +17,23 @@
*/
template <typename AT, typename BT, typename CT>
class ComposedFunction
: public Dune::VirtualFunction<AT, CT>
{
typedef Dune::VirtualFunction<AT, CT> BaseType;
public:
typedef typename BaseType::DomainType DomainType;
typedef typename BaseType::RangeType RangeType;
using DomainType = AT;
using RangeType = CT;
typedef Dune::VirtualFunction<AT,BT> InnerFunctionType;
typedef Dune::VirtualFunction<BT,CT> OuterFunctionType;
using InnerFunctionType = std::function<BT(AT)>;
using OuterFunctionType = std::function<CT(BT)>;
/** \brief Constructor
*
* \param f_ outer function for composition
* \param g_ inner function for composition
* \param f outer function for composition
* \param g inner function for composition
*/
ComposedFunction(const OuterFunctionType& f_, const InnerFunctionType& g_) :
f(f_),
g(g_)
template<class F, class G>
ComposedFunction(const F& f, const 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
......@@ -41,19 +41,28 @@ public:
* \param x point in \f$ A \f$ at which to evaluate
* \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);
f.evaluate(ytemp,y);
/** \brief composed evaluation of one component using eval of the composed functions
*
* \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(){}
private:
const OuterFunctionType& f;
const InnerFunctionType& g;
OuterFunctionType f_;
InnerFunctionType g_;
};
......
......@@ -8,8 +8,6 @@
@author graeser@math.fu-berlin.de
*/
#include <dune/common/function.hh>
#include <dune/fufem/functions/localbasisjacobianfunction.hh>
......@@ -18,9 +16,7 @@
* \tparam LocalBasis The local basis type
*/
template <class FE, class Base
=typename Dune::Function<
const typename FE::Traits::LocalBasisType::Traits::DomainType&,
typename FE::Traits::LocalBasisType::Traits::RangeType&> >
= typename FE::Traits::LocalBasisType::Traits>
class LocalBasisDerivativeFunction :
public Base
{
......
......@@ -10,19 +10,22 @@
#include <vector>
#include <dune/common/function.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
*
* \tparam FE The local finite element type
*/
template <class FE, class Base
=typename Dune::Function<
const typename FE::Traits::LocalBasisType::Traits::DomainType&,
typename FE::Traits::LocalBasisType::Traits::JacobianType&> >
= Impl::LFEJacobianFunctionTraits<FE>>
class LocalBasisJacobianFunction :
public CachedComponentWrapper<
LocalBasisJacobianFunction<FE, Base>,
......
......@@ -25,14 +25,12 @@
*
*/
template <class DT, class RT>
class InflateOrCut_Base:
class InflateOrCut_Base :
public Dune::VirtualFunction<DT,RT>
{
typedef Dune::VirtualFunction<DT,RT> BaseType;
public:
typedef typename BaseType::DomainType DomainType;
typedef typename BaseType::RangeType RangeType;
using DomainType = DT;
using RangeType = RT;
enum {DomainDim = DomainType::dimension,
RangeDim = RangeType::dimension};
......@@ -40,16 +38,18 @@ class InflateOrCut_Base:
InflateOrCut_Base()
{}
virtual void evaluate(const DomainType& x, RangeType& y) const
void evaluate(const DomainType& x, RangeType& y) const
{
y = 0.0;
for (int i=0; i<DomainDim and i<RangeDim; ++i)
{
y[i]=x[i];
}
}
return;
RangeType operator()(const DomainType& x) const
{
RangeType y;
evaluate(x,y);
return y;
}
};
......
#include <config.h>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/function.hh>
#include <dune/fufem/assemblers/integraloperatorassembler.hh>
#include <dune/fufem/assemblers/localassemblers/convolutionassembler.hh>
......@@ -14,28 +13,27 @@
template <int N>
class Mollifier :
public Dune::VirtualFunction<std::pair<Dune::FieldVector<double, N>, Dune::FieldVector<double, N> >, double>
class Mollifier
{
private:
typedef typename Dune::template FieldVector<double, N> SingleDomain;
typedef typename std::template pair<SingleDomain, SingleDomain> PairDomain;
typedef typename Dune::template VirtualFunction<PairDomain, double> Base;
public:
typedef typename Base::RangeType RangeType;
typedef typename Base::DomainType DomainType;
using RangeType = double;
using DomainType = PairDomain;
Mollifier(double eps) :
eps_(eps)
{}
void evaluate(const DomainType& xy, RangeType& z) const
RangeType operator()(const DomainType& xy) const
{
SingleDomain diff = xy.first;
diff -= xy.second;
diff /= eps_;
z = exp(-1.0/(1.0-diff.two_norm2()));
return exp(-1.0/(1.0-diff.two_norm2()));
}
private:
......
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