From 241e3c50b27f03b8f728af477056648493fc2836 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Sun, 23 Jan 2011 14:38:00 +0000
Subject: [PATCH] Make getResultantForce return a
 RigidBodyMotion::TangentVector

Because that is what happens.  The previous solution of returning
to FieldVectors, one as the return value and the other one using
call-by-reference, was extremely ugly.

This is an API change.

[[Imported from SVN: r6840]]
---
 dune/gfe/rodassembler.cc | 15 ++++++++++-----
 dune/gfe/rodassembler.hh |  5 ++---
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/dune/gfe/rodassembler.cc b/dune/gfe/rodassembler.cc
index 87f6eb51..89a94c64 100644
--- a/dune/gfe/rodassembler.cc
+++ b/dune/gfe/rodassembler.cc
@@ -141,10 +141,9 @@ getStress(const std::vector<RigidBodyMotion<3> >& sol,
 
 template <class GridView>
 template <class PatchGridView>
-Dune::FieldVector<double,3> RodAssembler<GridView,3>::
+Dune::FieldVector<double,6> RodAssembler<GridView,3>::
 getResultantForce(const BoundaryPatchBase<PatchGridView>& boundary,
-                  const std::vector<RigidBodyMotion<3> >& sol,
-                  Dune::FieldVector<double,3>& canonicalTorque) const
+                  const std::vector<RigidBodyMotion<3> >& sol) const
 {
     using namespace Dune;
 
@@ -157,7 +156,7 @@ getResultantForce(const BoundaryPatchBase<PatchGridView>& boundary,
         DUNE_THROW(Exception, "Solution vector doesn't match the grid!");
 
     FieldVector<double,3> canonicalStress(0);
-    canonicalTorque = 0;
+    FieldVector<double,3> canonicalTorque(0);
 
     // Loop over the given boundary
     typename BoundaryPatchBase<PatchGridView>::iterator it    = boundary.begin();
@@ -210,7 +209,13 @@ getResultantForce(const BoundaryPatchBase<PatchGridView>& boundary,
             
     }
 
-    return canonicalStress;
+    Dune::FieldVector<double,6> result;
+    for (int i=0; i<3; i++) {
+        result[i] = canonicalStress[i];
+        result[i+3] = canonicalTorque[i];
+    }
+    
+    return result;
 }
 
 
diff --git a/dune/gfe/rodassembler.hh b/dune/gfe/rodassembler.hh
index c8db8c61..640736a8 100644
--- a/dune/gfe/rodassembler.hh
+++ b/dune/gfe/rodassembler.hh
@@ -79,9 +79,8 @@ public:
 
         \note Linear run-time in the size of the grid */
         template <class PatchGridView>
-        Dune::FieldVector<double,3> getResultantForce(const BoundaryPatchBase<PatchGridView>& boundary,
-                                                      const std::vector<RigidBodyMotion<3> >& sol,
-                                                      Dune::FieldVector<double,3>& canonicalTorque) const;
+        Dune::FieldVector<double,6> getResultantForce(const BoundaryPatchBase<PatchGridView>& boundary,
+                                                      const std::vector<RigidBodyMotion<3> >& sol) const;
 
     }; // end class
 
-- 
GitLab