From 53896f23fb6be10a0231285ba3e6b0cf8183ff02 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Tue, 21 Apr 2009 09:59:50 +0000
Subject: [PATCH] last bugfix extended to all dimensions

[[Imported from SVN: r4068]]
---
 src/localgeodesicfefunction.hh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/localgeodesicfefunction.hh b/src/localgeodesicfefunction.hh
index bb7bbd82..06d3f944 100644
--- a/src/localgeodesicfefunction.hh
+++ b/src/localgeodesicfefunction.hh
@@ -191,14 +191,18 @@ template <int dim, class ctype, class TargetSpace>
 TargetSpace LocalGeodesicFEFunction<dim,ctype,TargetSpace>::
 evaluate(const Dune::FieldVector<ctype, dim>& local)
 {
-    assert(dim==2);
-    ctype extraCoord = 1-local[0]-local[1];
-    ctype factor = extraCoord+local[0];
+    ctype extraCoord = 1;
+    for (int i=0; i<dim; i++)
+        extraCoord -= local[i];
 
-    TargetSpace result = TargetSpace::interpolate(coefficients_[0], coefficients_[1], local[0]/factor);
+    ctype normalizingFactor = extraCoord+local[0];
 
-    for (int i=1; i<dim; i++)
-        result = TargetSpace::interpolate(result, coefficients_[i+1], local[i]);
+    TargetSpace result = TargetSpace::interpolate(coefficients_[0], coefficients_[1], local[0]/normalizingFactor);
+
+    for (int i=1; i<dim; i++) {
+        normalizingFactor += local[i];
+        result = TargetSpace::interpolate(result, coefficients_[i+1], local[i] / normalizingFactor);
+    }
 
     return result;
 }
-- 
GitLab