From caf73d8fb1df7e53c80ce4d8a7b8bd4271aaec0d Mon Sep 17 00:00:00 2001
From: Nicolas Marsic <nicolas.marsic@gmail.com>
Date: Mon, 17 Sep 2012 14:39:32 +0000
Subject: [PATCH] Cleaning

---
 FunctionSpace/Basis.h               |  5 +++
 FunctionSpace/BasisScalar.cpp       | 12 +++++++
 FunctionSpace/BasisScalar.h         |  9 ++----
 FunctionSpace/BasisVector.cpp       | 15 +++++++++
 FunctionSpace/BasisVector.h         | 13 ++------
 FunctionSpace/FunctionSpace.cpp     | 28 ++--------------
 FunctionSpace/FunctionSpace.h       | 50 +++++++----------------------
 FunctionSpace/FunctionSpaceScalar.h |  6 ++++
 FunctionSpace/FunctionSpaceVector.h |  6 ++++
 9 files changed, 62 insertions(+), 82 deletions(-)

diff --git a/FunctionSpace/Basis.h b/FunctionSpace/Basis.h
index e3b6647aec..4c272d9988 100644
--- a/FunctionSpace/Basis.h
+++ b/FunctionSpace/Basis.h
@@ -1,6 +1,8 @@
 #ifndef _BASIS_H_
 #define _BASIS_H_
 
+#include <string>
+
 /**
    @interface Basis
    @brief Common Interface of all Basis
@@ -81,6 +83,9 @@ class Basis{
   //! (or Vector%s of Polynomial%s) in the Basis
   int getSize(void) const;
 
+  //! @return Returns the Basis String
+  virtual std::string toString(void) const = 0;
+
  protected:
   //! @internal
   //! Instantiate a new Basis
diff --git a/FunctionSpace/BasisScalar.cpp b/FunctionSpace/BasisScalar.cpp
index e902527ff8..bf2851f452 100644
--- a/FunctionSpace/BasisScalar.cpp
+++ b/FunctionSpace/BasisScalar.cpp
@@ -1,8 +1,20 @@
+#include <sstream>
 #include "BasisScalar.h"
 
+using namespace std;
+
 BasisScalar::BasisScalar(void){
   scalar = true;
 }
 
 BasisScalar::~BasisScalar(void){
 }
+
+string BasisScalar::toString(void) const{
+  stringstream stream;
+
+  for(int i = 0; i < size; i++)
+    stream << (*basis)[i]->toString() << endl;
+
+  return stream.str();
+}
diff --git a/FunctionSpace/BasisScalar.h b/FunctionSpace/BasisScalar.h
index 79b32e70ad..2b53803771 100644
--- a/FunctionSpace/BasisScalar.h
+++ b/FunctionSpace/BasisScalar.h
@@ -37,6 +37,8 @@ class BasisScalar: public Basis{
   //! defining this (scalar) Basis, for the given closure
   const std::vector<const Polynomial*>& getFunctions(unsigned int closure) const;
 
+  virtual std::string toString(void) const;
+
  protected:
   //! @internal
   //! Instantiates a new BasisScalar
@@ -49,13 +51,6 @@ class BasisScalar: public Basis{
 // Inline Functions //
 //////////////////////
 
-inline 
-const std::vector<const Polynomial*>& BasisScalar::
-getFunctions(void) const{
-
-  return *basis;
-}
-
 inline
 const std::vector<const Polynomial*>& BasisScalar::
 getFunctions(unsigned int closure) const{
diff --git a/FunctionSpace/BasisVector.cpp b/FunctionSpace/BasisVector.cpp
index e1d389822e..6eea126b47 100644
--- a/FunctionSpace/BasisVector.cpp
+++ b/FunctionSpace/BasisVector.cpp
@@ -1,8 +1,23 @@
+#include <sstream>
 #include "BasisVector.h"
 
+using namespace std;
+
 BasisVector::BasisVector(void){
   scalar = false;
 }
 
 BasisVector::~BasisVector(void){
 }
+
+string BasisVector::toString(void) const{
+  stringstream stream;
+
+  for(int i = 0; i < size; i++)
+    stream << "[" << (*basis)[i]->at(0).toString() << "]" << endl
+	   << "[" << (*basis)[i]->at(1).toString() << "]" << endl
+	   << "[" << (*basis)[i]->at(2).toString() << "]" << endl
+	   << endl;
+
+  return stream.str();
+}
diff --git a/FunctionSpace/BasisVector.h b/FunctionSpace/BasisVector.h
index 6344f5229c..66831266d4 100644
--- a/FunctionSpace/BasisVector.h
+++ b/FunctionSpace/BasisVector.h
@@ -28,16 +28,14 @@ class BasisVector: public Basis{
   //!
   virtual ~BasisVector(void);
 
-  //! @return Returns the set of @em Polynomial%s
-  //! defining this (vectorial) Basis
-  const std::vector<const std::vector<Polynomial>*>& getFunctions(void) const;
-
   //! @param closure A natural number
   //! @return Returns the set of @em Polynomial%s
   //! defining this (scalar) Basis, for the given closure
   const std::vector<const std::vector<Polynomial>*>& 
     getFunctions(unsigned int closure) const;
 
+  virtual std::string toString(void) const;
+
  protected:
   //! @internal
   //! Instantiate a new BasisVector
@@ -50,13 +48,6 @@ class BasisVector: public Basis{
 // Inline Functions //
 //////////////////////
 
-inline 
-const std::vector<const std::vector<Polynomial>*>& BasisVector::
-getFunctions(void) const{
-
-  return *basis;
-}
-
 inline
 const std::vector<const std::vector<Polynomial>*>& BasisVector::
 getFunctions(unsigned int closure) const{
diff --git a/FunctionSpace/FunctionSpace.cpp b/FunctionSpace/FunctionSpace.cpp
index 496ab8899d..d30040297e 100644
--- a/FunctionSpace/FunctionSpace.cpp
+++ b/FunctionSpace/FunctionSpace.cpp
@@ -1,7 +1,7 @@
+#include <sstream>
 #include "FunctionSpace.h"
 #include "BasisGenerator.h"
 
-
 using namespace std;
 
 FunctionSpace::FunctionSpace(void){
@@ -193,28 +193,6 @@ vector<Dof> FunctionSpace::getKeys(const MElement& elem) const{
   return myDof;
 }
 
-int FunctionSpace::getElementType(const Dof& dof) const{
-  // Get Entity //
-  const unsigned int entity = dof.getEntity();
-
-  // Total Number of Entities //
-  const unsigned int nVertex = mesh->getVertexNumber();
-  const unsigned int nEdge   = mesh->getEdgeNumber();
-  const unsigned int nFace   = mesh->getFaceNumber();
-  
-  // Vertex Based
-  if(entity < nVertex)
-    return 0; 
-
-  // Edge Based
-  else if(entity < nVertex + nEdge)
-    return 1;
-
-  // Face Based
-  else if(entity < nVertex + nEdge + nFace)
-    return 2;
-  
-  // Cell Based
-  else
-    return 3; 
+string FunctionSpace::toString(void) const{
+  return basis->toString();
 }
diff --git a/FunctionSpace/FunctionSpace.h b/FunctionSpace/FunctionSpace.h
index 79faa45b5e..e945a8dbb9 100644
--- a/FunctionSpace/FunctionSpace.h
+++ b/FunctionSpace/FunctionSpace.h
@@ -3,6 +3,7 @@
 
 #include <map>
 #include <vector>
+#include <string>
 
 #include "Basis.h"
 #include "Dof.h"
@@ -66,8 +67,7 @@ class FunctionSpace{
   std::vector<Dof> getKeys(const MEdge& edge) const;
   std::vector<Dof> getKeys(const MFace& face) const;
 
-  int getElementType(const Dof& dof) const;
-  int getElementGlobalId(const Dof& dof) const;
+  std::string toString(void) const;
 
  protected:
   FunctionSpace(void);
@@ -145,40 +145,9 @@ class FunctionSpace{
    @param face A MFace
    @return Returns all the Dof%s associated to the given MFace
    **
-   
-   @fn FunctionSpace::getElementType
-   @param dof A Dof
-   @return Returns the @em type of the @em element,
-   to which the given Dof is @em associated
-   
-   @note
-   Type is equal to:
-   @li @c 0, if the element is a  @em Vertex 
-   @li @c 1, if the element is an @em Edge
-   @li @c 2, if the element is a  @em Face
-   @li @c 3, if the element is a  @em Cell
-   
-   @warning
-   There are no error recovery if 
-   the Element is not in the Mesh
 
-   @todo
-   Error recovery if 
-   the Element is not in the Mesh   
-   **
-   
-   @fn FunctionSpace::getElementGlobalId
-   @param dof A Dof
-   @return Returns the @em Mesh @em Global @em @c ID of
-   the Element, to which the given Dof is @em associated
- 
-   @warning
-   There are no error recovery if 
-   the Element is not in the Mesh
-
-   @todo
-   Error recovery if 
-   the Element is not in the Mesh   
+   @fn FunctionSpace::toString
+   @return Returns the FunctionSpace string
    **
 
    @internal
@@ -191,6 +160,13 @@ class FunctionSpace{
 
    Initializes a FunctionSpace with the given parameters  
    @endinternal
+   **
+
+   @internal
+   @fn FunctionSpace::closure
+
+   Compute closure for Basis Functions  
+   @endinternal
 */
 
 
@@ -222,8 +198,4 @@ inline unsigned int FunctionSpace::getNFunctionPerCell(const MElement& element)
   return fPerCell;
 }
 
-inline int FunctionSpace::getElementGlobalId(const Dof& dof) const{
-  return dof.getEntity();
-}
-
 #endif
diff --git a/FunctionSpace/FunctionSpaceScalar.h b/FunctionSpace/FunctionSpaceScalar.h
index 85f5f21e38..7f1b536cb3 100644
--- a/FunctionSpace/FunctionSpaceScalar.h
+++ b/FunctionSpace/FunctionSpaceScalar.h
@@ -60,6 +60,12 @@ class FunctionSpaceScalar : public FunctionSpace{
    ---> check
    **
 
+   @fn FunctionSpaceScalar::getLocalFunctions
+   @param element A MElement
+   @return Returns the basis functions associated
+   to the given element (with correct @em closure)
+   **
+
    @fn FunctionSpaceScalar::getBasis
    @param element A MElement of the support 
    of this FunctionSpace
diff --git a/FunctionSpace/FunctionSpaceVector.h b/FunctionSpace/FunctionSpaceVector.h
index 8c7f5fb3ae..30d2ddb914 100644
--- a/FunctionSpace/FunctionSpaceVector.h
+++ b/FunctionSpace/FunctionSpaceVector.h
@@ -60,6 +60,12 @@ class FunctionSpaceVector : public FunctionSpace{
    ---> check
    **
 
+   @fn FunctionSpaceVector::getLocalFunctions
+   @param element A MElement
+   @return Returns the basis functions associated
+   to the given element (with correct @em closure)
+   **
+
    @fn FunctionSpaceVector::getBasis
    @param element A MElement of the support 
    of this FunctionSpace
-- 
GitLab