Skip to content
Snippets Groups Projects
Commit 9ea062b0 authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

implement fd approximation of the gradient for unit-vector-valued functions

[[Imported from SVN: r5590]]
parent 3353c00c
No related branches found
No related tags found
No related merge requests found
...@@ -304,7 +304,7 @@ class LocalGeodesicFEStiffness <GridView,UnitVector<dim> > ...@@ -304,7 +304,7 @@ class LocalGeodesicFEStiffness <GridView,UnitVector<dim> >
/** \brief For the fd approximations /** \brief For the fd approximations
*/ */
static Dune::FieldVector<double,dim> infinitesimalVariation(UnitVector<dim>& c, double eps, int i) static Dune::FieldVector<double,dim> infinitesimalVariation(const UnitVector<dim>& c, double eps, int i)
{ {
Dune::FieldVector<double,dim> result = c.globalCoordinates(); Dune::FieldVector<double,dim> result = c.globalCoordinates();
result[i] += eps; result[i] += eps;
...@@ -386,12 +386,13 @@ assembleGradient(const Entity& element, ...@@ -386,12 +386,13 @@ assembleGradient(const Entity& element,
for (int j=0; j<blocksize; j++) { for (int j=0; j<blocksize; j++) {
infinitesimalVariation(forwardSolution[i], eps, j); // Brute force: the return value does not have unit norm. Stuff it in there anyways
infinitesimalVariation(backwardSolution[i], -eps, j); forwardSolution[i].data_ = infinitesimalVariation(localSolution[i], eps, j);
backwardSolution[i].data_ = infinitesimalVariation(localSolution[i], -eps, j);
localGradient[i][j] = (energy(element,forwardSolution) - energy(element,backwardSolution)) localGradient[i][j] = (energy(element,forwardSolution) - energy(element,backwardSolution))
/ (2*eps); / (2*eps);
forwardSolution[i] = localSolution[i]; forwardSolution[i] = localSolution[i];
backwardSolution[i] = localSolution[i]; backwardSolution[i] = localSolution[i];
} }
......
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