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

Use a pointer instead of a reference

parent 3b2d6611
No related branches found
No related tags found
No related merge requests found
......@@ -18,11 +18,11 @@ template <int dimension> class LocalNonlinearity {
typedef FieldVector<double, dimension> VectorType;
typedef FieldMatrix<double, dimension, dimension> MatrixType;
LocalNonlinearity(NiceFunction const &func) : func_(func) {}
LocalNonlinearity(NiceFunction const *func) : func_(func) {}
double operator()(VectorType const x) const {
double ret;
func_.evaluate(x.two_norm(), ret);
func_->evaluate(x.two_norm(), ret);
return ret;
}
......@@ -31,29 +31,29 @@ template <int dimension> class LocalNonlinearity {
void directionalSubDiff(VectorType const u, VectorType const v,
Interval<double> &D) const {
if (u.two_norm() == 0) {
D[0] = D[1] = func_.rightDifferential(0) * v.two_norm();
D[0] = D[1] = func_->rightDifferential(0) * v.two_norm();
return;
}
double const un = u.two_norm();
double const ndotp = (u * v) / un;
// Our coordinate system is now such that v is a unit vector!
if (ndotp > 0) {
D[1] = ndotp * func_.rightDifferential(un);
D[0] = ndotp * func_.leftDifferential(un);
D[1] = ndotp * func_->rightDifferential(un);
D[0] = ndotp * func_->leftDifferential(un);
} else {
D[1] = ndotp * func_.leftDifferential(un);
D[0] = ndotp * func_.rightDifferential(un);
D[1] = ndotp * func_->leftDifferential(un);
D[0] = ndotp * func_->rightDifferential(un);
}
}
void upperGradient(VectorType const x, VectorType &ret) const {
ret = x;
ret *= func_.rightDifferential(x.two_norm()) / x.two_norm();
ret *= func_->rightDifferential(x.two_norm()) / x.two_norm();
}
void lowerGradient(VectorType const x, VectorType &ret) const {
ret = x;
ret *= func_.leftDifferential(x.two_norm()) / x.two_norm();
ret *= func_->leftDifferential(x.two_norm()) / x.two_norm();
}
void directionalDomain(VectorType const &, VectorType const &,
......@@ -63,7 +63,7 @@ template <int dimension> class LocalNonlinearity {
}
private:
NiceFunction const &func_;
NiceFunction const *func_;
};
}
#endif
......@@ -114,7 +114,7 @@ class MyBlockProblem<MyConvexProblemTypeTEMPLATE>::IterateObject {
assert(localA != NULL);
auto const f = problem.phi.restriction(m);
Dune::LocalNonlinearity<block_size> const phi(*f);
Dune::LocalNonlinearity<block_size> const phi(f);
Dune::SampleFunctional<block_size> localJ(*localA, localb, phi,
ignore_component);
......
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