diff --git a/dune/gfe/symmetricmatrix.hh b/dune/gfe/symmetricmatrix.hh index a8d847bb45e34d10d7a466544112f0b4346a8f78..8eae7135f5fe1b4813d61f3dfa6ecef8cc12f696 100644 --- a/dune/gfe/symmetricmatrix.hh +++ b/dune/gfe/symmetricmatrix.hh @@ -2,6 +2,7 @@ #define DUNE_GFE_SYMMETRICMATRIX_HH #include <dune/common/fvector.hh> +#include <dune/common/fmatrix.hh> namespace Dune { @@ -79,6 +80,17 @@ public: data_.axpy(a,other.data_); } + /** \brief Return the FieldMatrix representation of the symmetric tensor.*/ + Dune::FieldMatrix<T,N,N> matrix() const + { + Dune::FieldMatrix<T,N,N> mat; + for (int i=0; i<N; i++) + for (int j=0; j<=i; j++) + mat[j][i] = mat[i][j] = this->operator()(i,j); + + return mat; + } + private: Dune::FieldVector<T,N*(N+1)/2> data_; }; diff --git a/test/localgeodesicfestiffnesstest.cc b/test/localgeodesicfestiffnesstest.cc index 9f79510eb6d8534242920f11bdde7a701d991be7..cbde11a70b82949c9c77d8c2567e005799b06b38 100644 --- a/test/localgeodesicfestiffnesstest.cc +++ b/test/localgeodesicfestiffnesstest.cc @@ -151,10 +151,10 @@ void testHessian() embeddedHessian = 0; embeddedHessian[0][0] = TargetSpace::secondDerivativeOfDistanceSquaredWRTSecondArgument(coefficients[1], - coefficients[0]); + coefficients[0]).matrix(); embeddedHessian[1][1] = TargetSpace::secondDerivativeOfDistanceSquaredWRTSecondArgument(coefficients[0], - coefficients[1]); + coefficients[1]).matrix(); embeddedHessian[0][1] = TargetSpace::secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument(coefficients[0], coefficients[1]);