From bb784de97f717f84a4bb5aa3f065c13011f16fb0 Mon Sep 17 00:00:00 2001
From: Nicolas Marsic <nicolas.marsic@gmail.com>
Date: Mon, 20 Jan 2014 18:36:57 +0000
Subject: [PATCH] Free Space test cases + Nodal Interpolation + Small Fix in
 FunctionSpace: Bug with cell function in 2D for 3D Function Space + Vertices
 of GroupOfElement

---
 FunctionSpace/FunctionSpace.cpp | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/FunctionSpace/FunctionSpace.cpp b/FunctionSpace/FunctionSpace.cpp
index 56d9c199d2..c6aebe8293 100644
--- a/FunctionSpace/FunctionSpace.cpp
+++ b/FunctionSpace/FunctionSpace.cpp
@@ -154,6 +154,13 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{
   const size_t nEdge   = element.getNumEdges();
   const size_t nFace   = element.getNumFaces();
 
+  // Number of cells //
+  size_t nCell;
+  if(element.getDim() == 3) // Need to be 3D to have one Cell
+    nCell = 1;
+  else
+    nCell = 0;
+
   vector<MVertex*> vertex(nVertex);
   vector<MEdge>    edge(nEdge);
   vector<MFace>    face(nFace);
@@ -172,7 +179,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{
     fPerVertex * nVertex +
     fPerEdge   * nEdge   +
     fPerFace   * nFace   +
-    fPerCell;
+    fPerCell   * nCell;
 
   vector<Dof> myDof(nDof);
 
@@ -203,9 +210,11 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{
   }
 
   // Add Cell Based Dof //
-  for(size_t j = 0; j < fPerCell; j++){
-    myDof[it].setDof(mesh->getGlobalId(element), j);
-    it++;
+  for(size_t i = 0; i < nCell; i++){
+    for(size_t j = 0; j < fPerCell; j++){
+      myDof[it].setDof(mesh->getGlobalId(element), j);
+      it++;
+    }
   }
 
   return myDof;
-- 
GitLab