Commit aaf814f1 authored by Sander, Oliver's avatar Sander, Oliver
Browse files

Finish the implementation of the 'gradient' method

No real way to test it though, yet.
parent 72150e55
......@@ -485,24 +485,18 @@ public:
Vector gradient(const Vector& v)
{
typedef typename Vector::block_type LocalGradientVector;
// TODO: I don't really know what to replace the '3' with
typedef typename Dune::FieldVector<double, 3> FunctionalGradient;
Vector result;
LocalGradientVector BiXv;
FunctionalGradient Dgamma;
Solvers::resizeInitializeZero(result,v);
typename LocalEnergy::Domain BiXv;
for (std::size_t i=0; i<evaluationMatrix().N(); ++i)
{
BiXv = 0.0;
addRowXVector(evaluationMatrix()[i], v, BiXv);
// TODO: What happens to the 'variants' in the following line stolen from couplednonlinearity.hh?
// Dgamma = gamma_[i % variants]->d(BiXv);
auto localEnergyDerivative = derivative(localEnergy());
// TODO: The following line does not compile -- I must be getting one of the types wrong
//Dgamma = localEnergyDerivative(BiXv);
auto Dgamma = localEnergyDerivative(BiXv);
Dgamma *= (*weightVector_)[i];
addRowTransposedXVector(evaluationMatrix()[i], Dgamma, result);
......@@ -516,7 +510,7 @@ protected:
static void addRowXVector(const typename EvaluationMatrix::row_type& evaluationMatrixRow,
const Vector& x,
typename Vector::block_type& y)
typename LocalEnergy::Domain& y)
{
auto it = evaluationMatrixRow.begin();
auto end = evaluationMatrixRow.end();
......@@ -525,7 +519,7 @@ protected:
}
static void addRowTransposedXVector(const typename EvaluationMatrix::row_type& evaluationMatrixRow,
const Dune::FieldVector<double,3>& x,
const typename LocalEnergy::Domain& x, // Actually: the range of the gradient
Vector& y)
{
auto it = evaluationMatrixRow.begin();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment