Commit 78660533 authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Merge branch 'remove-more-deprecated-function-stuff' into 'master'

Stop using deprecated class VirtualFunction

See merge request !19
parents 9861405e 39b1d069
Pipeline #32272 passed with stage
in 5 minutes and 15 seconds
......@@ -40,30 +40,6 @@
using namespace Dune;
template <class DomainType, class RangeType, class F>
class FunctionFromLambda :
public Dune::VirtualFunction<DomainType, RangeType>
{
public:
FunctionFromLambda(F f):
f_(f)
{}
void evaluate(const DomainType& x, RangeType& y) const
{
y = f_(x);
}
private:
F f_;
};
template<class Domain, class Range, class F>
auto makeFunction(F&& f)
{
return FunctionFromLambda<Domain, Range, std::decay_t<F>>(std::forward<F>(f));
}
template<class MatrixType, class VectorType, class BitVector>
void solveProblem(const MatrixType& mat, VectorType& x, const VectorType& rhs, const BitVector& ignore, int maxIterations=100, double tolerance=1.0e-8)
......@@ -186,8 +162,7 @@ bool checkWithGrid(const GridType& grid, const std::string fileName="")
rhs[_0].resize(A[_0][_0].N());
rhs[_1].resize(A[_1][_1].N());
rhs = 0;
// ConstantFunction<DomainType, RangeType> f(5);
auto f = makeFunction<DomainType, RangeType>([](const DomainType& x) { return (x.two_norm() < .7) ? 200 : 0;});
auto f = [](const DomainType& x) -> RangeType { return (x.two_norm() < .7) ? 200 : 0;};
assemblePQ1RHS(gridView, rhs[_0], f);
assemblePQ1RHS(gridView, rhs[_1], f);
......
......@@ -8,7 +8,6 @@
// dune-common includes
#include <dune/common/bitsetvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/function.hh>
#include <dune/common/fvector.hh>
#include <dune/common/timer.hh>
......@@ -30,30 +29,6 @@
#include <dune/solvers/test/common.hh>
template <class DomainType, class RangeType, class F>
class FunctionFromLambda :
public Dune::VirtualFunction<DomainType, RangeType>
{
public:
FunctionFromLambda(F f):
f_(f)
{}
void evaluate(const DomainType& x, RangeType& y) const
{
y = f_(x);
}
private:
F f_;
};
template<class Domain, class Range, class F>
auto makeFunction(F&& f)
{
return FunctionFromLambda<Domain, Range, std::decay_t<F>>(std::forward<F>(f));
}
template<class MatrixType, class VectorType, class BitVector>
......@@ -201,8 +176,7 @@ bool checkWithGrid(const GridType& grid, const std::string fileName="")
Vector rhs(A.N());
rhs = 0;
// ConstantFunction<DomainType, RangeType> f(5);
auto f = makeFunction<DomainType, RangeType>([](const DomainType& x) { return (x.two_norm() < .7) ? 200 : 0;});
auto f = [](const DomainType& x) -> RangeType { return (x.two_norm() < .7) ? 200 : 0;};
assemblePQ1RHS(gridView, rhs, f);
Vector u(A.N());
......
......@@ -45,30 +45,6 @@
#include <dune/solvers/test/common.hh>
template <class DomainType, class RangeType, class F>
class FunctionFromLambda :
public Dune::VirtualFunction<DomainType, RangeType>
{
public:
FunctionFromLambda(F f):
f_(f)
{}
void evaluate(const DomainType& x, RangeType& y) const
{
y = f_(x);
}
private:
F f_;
};
template<class Domain, class Range, class F>
auto makeFunction(F&& f)
{
return FunctionFromLambda<Domain, Range, std::decay_t<F>>(std::forward<F>(f));
}
// template<class F>
// std::tuple<double, double, int> bisection(const F& f, double start, double guess, double tol)
......@@ -265,8 +241,7 @@ bool checkWithGrid(const GridType& grid, const std::string fileName="")
Vector rhs(A.N());
rhs = 0;
// ConstantFunction<DomainType, RangeType> f(5);
auto f = makeFunction<DomainType, RangeType>([](const DomainType& x) { return (x.two_norm() < .7) ? 200 : 0;});
auto f = [](const DomainType& x) -> RangeType { return (x.two_norm() < .7) ? RangeType(200.0) : RangeType(0.0);};
assemblePQ1RHS(gridView, rhs, f);
Vector u(A.N());
......
......@@ -38,29 +38,6 @@
#include <dune/solvers/test/common.hh>
template <class DomainType, class RangeType, class F>
class FunctionFromLambda :
public Dune::VirtualFunction<DomainType, RangeType>
{
public:
FunctionFromLambda(F f):
f_(f)
{}
void evaluate(const DomainType& x, RangeType& y) const
{
y = f_(x);
}
private:
F f_;
};
template<class Domain, class Range, class F>
auto makeFunction(F&& f)
{
return FunctionFromLambda<Domain, Range, std::decay_t<F>>(std::forward<F>(f));
}
// TODO include those last two parameters
......@@ -186,7 +163,7 @@ Dune::TestSuite checkWithGrid(const GridType& grid)
Vector rhs(A.N());
rhs = 0;
auto f = makeFunction<DomainType, RangeType>([](const DomainType& x) { return (x.two_norm() < .7) ? 200 : 0;});
auto f = [](const DomainType& x) -> RangeType { return (x.two_norm() < .7) ? 200 : 0;};
assemblePQ1RHS(gridView, rhs, f);
Vector u(A.N());
......
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