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

Make NiceFunction a proper (ctor-)parameter

parent e50a0fc7
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,7 @@
#include "nicefunction.hh"
namespace Dune {
template <int dimension, class OuterFunction = Dune::TrivialFunction>
class MyNonlinearity {
template <int dimension> class MyNonlinearity {
public:
typedef Dune::FieldVector<double, dimension> SmallVector;
typedef Dune::FieldMatrix<double, dimension, dimension> SmallMatrix;
......@@ -22,6 +21,8 @@ class MyNonlinearity {
typedef SmallVector VectorType;
typedef SmallMatrix MatrixType;
MyNonlinearity(NiceFunction const &func) : func_(func) {}
double operator()(VectorType const x) const {
double ret;
func_.evaluate(x.two_norm(), ret);
......@@ -65,7 +66,7 @@ class MyNonlinearity {
}
private:
OuterFunction func_;
NiceFunction const &func_;
};
}
#endif
......@@ -20,9 +20,11 @@ class SampleFunctional {
typedef Dune::FieldVector<double, dimension> SmallVector;
typedef Dune::FieldMatrix<double, dimension, dimension> SmallMatrix;
typedef MyNonlinearity<dimension, Function> NonlinearityType;
typedef MyNonlinearity<dimension> NonlinearityType;
SampleFunctional(SmallMatrix _A, SmallVector _b) : A(_A), b(_b) {}
SampleFunctional(SmallMatrix _A, SmallVector _b,
MyNonlinearity<dimension> _phi)
: A(_A), b(_b), phi(_phi) {}
double operator()(const SmallVector v) const {
SmallVector y;
......
......@@ -41,7 +41,8 @@ void testSampleFunction() {
b[0] = 1;
b[1] = 2;
SampleFunctional J(A, b);
Dune::SampleFunction f;
SampleFunctional J(A, b, Dune::MyNonlinearity<dim>(f));
SampleFunctional::SmallVector start = b;
start *= 17;
......@@ -88,7 +89,8 @@ void testSampleFunctionNonsmooth() {
b[0] = 1;
b[1] = 2;
SampleFunctional J(A, b);
Dune::SampleFunction f;
SampleFunctional J(A, b, Dune::MyNonlinearity<dim>(f));
SampleFunctional::SmallVector start;
SampleFunctional::SmallVector error;
......@@ -149,7 +151,8 @@ void testTrivialFunction() {
b[0] = 1;
b[1] = 2;
SampleFunctional J(A, b);
Dune::TrivialFunction f;
SampleFunctional J(A, b, Dune::MyNonlinearity<dim>(f));
SampleFunctional::SmallVector start = b;
start *= 17;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment