diff --git a/dune/tectonic/nicefunction.hh b/dune/tectonic/nicefunction.hh index efa0ba616e5d76b20efff30686b2ae58513a7489..f4dfc107472a19745d7c2a92b61f0190a32dde47 100644 --- a/dune/tectonic/nicefunction.hh +++ b/dune/tectonic/nicefunction.hh @@ -23,15 +23,19 @@ class Identity : public NiceFunction { double virtual rightDifferential(double s) const { return 1; } }; -class SampleFunction : public NiceFunction { +template <int slope> class SampleFunction : public NiceFunction { public: void virtual evaluate(double const& x, double& y) const { - y = (x < 1) ? x : (2 * x - 1); + y = (x < 1) ? x : (slope * (x - 1) + 1); } - double virtual leftDifferential(double s) const { return (s <= 1) ? 1 : 2; } + double virtual leftDifferential(double s) const { + return (s <= 1) ? 1 : slope; + } - double virtual rightDifferential(double s) const { return (s < 1) ? 1 : 2; } + double virtual rightDifferential(double s) const { + return (s < 1) ? 1 : slope; + } }; class SteepFunction : public NiceFunction { @@ -43,17 +47,6 @@ class SteepFunction : public NiceFunction { double virtual rightDifferential(double s) const { return 100; } }; -class SteepFunctionNonsmooth : public NiceFunction { -public: - void virtual evaluate(double const& x, double& y) const { - y = (x < 1) ? x : (100 * x - 99); - } - - double virtual leftDifferential(double s) const { return (s <= 1) ? 1 : 100; } - - double virtual rightDifferential(double s) const { return (s < 1) ? 1 : 100; } -}; - class TrivialFunction : public NiceFunction { public: void virtual evaluate(double const& x, double& y) const { y = 0; } diff --git a/src/test-gradient-method.cc b/src/test-gradient-method.cc index 92253a8185e148b14319c89866bd2c965689fcbe..9f312bd1033bd0a258236bf95767eb986bdd1618 100644 --- a/src/test-gradient-method.cc +++ b/src/test-gradient-method.cc @@ -70,7 +70,7 @@ void testSampleFunction() { b[0] = 1; b[1] = 2; - Dune::SampleFunction f; + Dune::SampleFunction<2> f; Functional J(A, b, Dune::MyNonlinearity<dim>(f)); Functional::SmallVector start = b; @@ -119,7 +119,7 @@ void testSampleFunctionNonsmooth() { b[0] = 1; b[1] = 2; - Dune::SampleFunction f; + Dune::SampleFunction<2> f; Functional J(A, b, Dune::MyNonlinearity<dim>(f)); Functional::SmallVector start; @@ -299,7 +299,7 @@ void testSampleFunction3D() { b[1] = 2; b[2] = 3; - Dune::SampleFunction f; + Dune::SampleFunction<2> f; Functional J(A, b, Dune::MyNonlinearity<dim>(f)); Functional::SmallVector start = b; @@ -337,7 +337,7 @@ void testSampleFunction2() { b[0] = 1; b[1] = 1; - Dune::SampleFunction f; + Dune::SampleFunction<2> f; Functional J(A, b, Dune::MyNonlinearity<dim>(f)); Functional::SmallVector start = b; @@ -371,7 +371,7 @@ void testSampleFunctionSteep1() { b[0] = 1; b[1] = 2; - Dune::SampleFunction f; + Dune::SampleFunction<2> f; Functional J(A, b, Dune::MyNonlinearity<dim>(f)); Functional::SmallVector start; @@ -408,7 +408,7 @@ void testSampleFunctionSteep2() { b[0] = 1; b[1] = 2.5; - Dune::SampleFunction f; + Dune::SampleFunction<2> f; Functional J(A, b, Dune::MyNonlinearity<dim>(f)); Functional::SmallVector start;