Skip to content
Snippets Groups Projects
Commit f56a135e authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Add template parameter to SampleFunction class

Obsoletes SteepFunctionNonsmooth
parent 450ed427
No related branches found
No related tags found
No related merge requests found
......@@ -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; }
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment