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

Provide gradient implementation

parent dbb57cfb
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,13 @@ class GlobalNonlinearity {
res->addHessian(v[i], hessian[i][i]);
}
}
virtual void addGradient(const VectorType& v, VectorType& gradient) const {
for (size_t i = 0; i < v.size(); ++i) {
auto res = restriction(i);
res->addGradient(v[i], gradient[i]);
}
}
};
}
#endif
......@@ -78,6 +78,12 @@ template <int dimension> class LocalNonlinearity {
A[k][k] += (h2 - h1ox) * x[k] * x[k] / normX2 + h1ox;
}
void addGradient(VectorType const &x, VectorType &y) const {
VectorType tmp;
upperGradient(x, tmp); // TODO
y += tmp;
}
void upperGradient(VectorType const &x, VectorType &ret) const {
ret = x;
ret *= func_->rightDifferential(x.two_norm()) / x.two_norm();
......
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