From d8fee70272d21ddef7788fc4fd415bf7d9370d04 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Fri, 17 Apr 2009 15:53:31 +0000
Subject: [PATCH] store local gradients in std::vector instead of Dune::array

[[Imported from SVN: r4039]]
---
 src/localgeodesicfestiffness.hh | 8 +++++---
 src/rodassembler.cc             | 2 +-
 src/rodlocalstiffness.hh        | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/localgeodesicfestiffness.hh b/src/localgeodesicfestiffness.hh
index cb7b3d9e..198b052e 100644
--- a/src/localgeodesicfestiffness.hh
+++ b/src/localgeodesicfestiffness.hh
@@ -87,8 +87,8 @@ public:
 
     /** \brief Assemble the element gradient of the energy functional */
     virtual void assembleGradient(const Entity& element,
-                          const std::vector<TargetSpace>& solution,
-                          Dune::array<Dune::FieldVector<double,blocksize>, 2>& gradient) const;
+                                  const std::vector<TargetSpace>& solution,
+                                  std::vector<Dune::FieldVector<double,blocksize> >& gradient) const;
     
 };
 
@@ -96,7 +96,7 @@ template <class GridView, class TargetSpace>
 void LocalGeodesicFEStiffness<GridView, TargetSpace>::
 assembleGradient(const Entity& element,
                  const std::vector<TargetSpace>& localSolution,
-                 Dune::array<Dune::FieldVector<double,blocksize>, 2>& localGradient) const
+                 std::vector<Dune::FieldVector<double,blocksize> >& localGradient) const
 {
     // ///////////////////////////////////////////////////////////
     //   Compute gradient by finite-difference approximation
@@ -104,6 +104,8 @@ assembleGradient(const Entity& element,
 
     double eps = 1e-6;
 
+    localGradient.resize(localSolution.size());
+
     std::vector<TargetSpace> forwardSolution = localSolution;
     std::vector<TargetSpace> backwardSolution = localSolution;
 
diff --git a/src/rodassembler.cc b/src/rodassembler.cc
index f177ae4b..3ab8a6db 100644
--- a/src/rodassembler.cc
+++ b/src/rodassembler.cc
@@ -152,7 +152,7 @@ assembleGradient(const std::vector<RigidBodyMotion<3> >& sol,
             localReferenceConfiguration[i] = referenceConfiguration_[indexSet.subIndex(*it,i,gridDim)];
 
         // Assemble local gradient
-        array<FieldVector<double,blocksize>, nDofs> localGradient;
+        std::vector<FieldVector<double,blocksize> > localGradient(nDofs);
 
         localStiffness.localReferenceConfiguration_ = localReferenceConfiguration;
         localStiffness.assembleGradient(*it, localSolution, localGradient);
diff --git a/src/rodlocalstiffness.hh b/src/rodlocalstiffness.hh
index 84e61ce4..4582b764 100644
--- a/src/rodlocalstiffness.hh
+++ b/src/rodlocalstiffness.hh
@@ -89,7 +89,7 @@ public:
     /** \brief Assemble the element gradient of the energy functional */
     void assembleGradient(const Entity& element,
                           const std::vector<RigidBodyMotion<3> >& solution,
-                          Dune::array<Dune::FieldVector<double,6>, 2>& gradient) const;
+                          std::vector<Dune::FieldVector<double,6> >& gradient) const;
     
     template <class T>
     static Dune::FieldVector<T,3> darboux(const Rotation<3,T>& q, const Dune::FieldVector<T,4>& q_s) 
@@ -458,7 +458,7 @@ template <class GridType, class RT>
 void RodLocalStiffness<GridType, RT>::
 assembleGradient(const Entity& element,
                  const std::vector<RigidBodyMotion<3> >& solution,
-                 Dune::array<Dune::FieldVector<double,6>, 2>& gradient) const
+                 std::vector<Dune::FieldVector<double,6> >& gradient) const
 {
     using namespace Dune;
 
@@ -468,6 +468,7 @@ assembleGradient(const Entity& element,
     const int numOfBaseFct = baseSet.size();  
         
     // init
+    gradient.resize(numOfBaseFct);
     for (size_t i=0; i<gradient.size(); i++)
         gradient[i] = 0;
 
-- 
GitLab