From fec8463a7da11b43997ccfef1357e6e75fc1c209 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Tue, 21 Jul 2009 11:22:09 +0000
Subject: [PATCH] Removed some incorrect usage of c++ in DOFVector.

---
 AMDiS/src/DOFVector.h      | 15 ++----
 AMDiS/src/DOFVector.hh     | 95 ++++++++++++++++++--------------------
 AMDiS/src/ProblemInstat.cc | 13 ++----
 AMDiS/src/ProblemInstat.h  |  4 +-
 4 files changed, 55 insertions(+), 72 deletions(-)

diff --git a/AMDiS/src/DOFVector.h b/AMDiS/src/DOFVector.h
index 365dbfbe..8641e9b0 100644
--- a/AMDiS/src/DOFVector.h
+++ b/AMDiS/src/DOFVector.h
@@ -333,7 +333,6 @@ namespace AMDiS {
     /// Empty constructor. No initialization!
     DOFVector() 
       : DOFVectorBase<T>(), 
-	feSpace(NULL),
 	coarsenOperation(NO_OPERATION)
     {}
 
@@ -347,9 +346,9 @@ namespace AMDiS {
     DOFVector(const DOFVector& rhs) 
     {
       *this = rhs;   
-      name = rhs.name + "copy";
-      if (feSpace && feSpace->getAdmin())
-	(dynamic_cast<DOFAdmin*>(feSpace->getAdmin()))->addDOFIndexed(this);
+      this->name = rhs.name + "copy";
+      if (this->feSpace && this->feSpace->getAdmin())
+	(dynamic_cast<DOFAdmin*>(this->feSpace->getAdmin()))->addDOFIndexed(this);
     }
 
     /// Destructor
@@ -407,7 +406,7 @@ namespace AMDiS {
     /// Returns used size of the vector.
     inline int getUsedSize() const 
     { 
-      return feSpace->getAdmin()->getUsedSize(); 
+      return this->feSpace->getAdmin()->getUsedSize(); 
     }
 
     /// Resizes \ref vec to n
@@ -577,12 +576,6 @@ namespace AMDiS {
     static int DoubleWell_fct(ElInfo* elinfo);
 
   protected: 
-    /// Name of this DOFVector
-    std::string name; 
-
-    /// FiniteElemSpace of the vector
-    const FiniteElemSpace *feSpace; 
-
     /// Data container
     std::vector<T> vec; 
  
diff --git a/AMDiS/src/DOFVector.hh b/AMDiS/src/DOFVector.hh
index ad7c86a0..c761c559 100644
--- a/AMDiS/src/DOFVector.hh
+++ b/AMDiS/src/DOFVector.hh
@@ -109,25 +109,25 @@ namespace AMDiS {
     : DOFVectorBase<T>(f, n),
       coarsenOperation(NO_OPERATION)
   {
+    vec.resize(0);
     init(f, n);
   } 
 
   template<typename T>
   void DOFVector<T>::init(const FiniteElemSpace* f, std::string n)
   {
-    name = n;
-    feSpace = f;
-    if (feSpace && feSpace->getAdmin())
-      (feSpace->getAdmin())->addDOFIndexed(this);
-
+    this->name = n;
+    this->feSpace = f;
+    if (this->feSpace && this->feSpace->getAdmin())
+      (this->feSpace->getAdmin())->addDOFIndexed(this);
     this->boundaryManager = new BoundaryManager(f);
   }
 
   template<typename T>
   DOFVector<T>::~DOFVector()
   {
-    if (feSpace && feSpace->getAdmin())
-      (feSpace->getAdmin())->removeDOFIndexed(this);
+    if (this->feSpace && this->feSpace->getAdmin())
+      (this->feSpace->getAdmin())->removeDOFIndexed(this);
 
     if (this->boundaryManager)
       delete this->boundaryManager;
@@ -179,7 +179,7 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector<T>::nrm2()");
 
-    checkFeSpace(feSpace, vec);
+    checkFeSpace(this->feSpace, vec);
 
     double nrm = 0.0;
     Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)), 
@@ -195,7 +195,7 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector<T>::nrm2()");
 
-    checkFeSpace(feSpace, vec);
+    checkFeSpace(this->feSpace, vec);
     
     double nrm = 0.0;
     Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)), 
@@ -211,7 +211,7 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector<T>::asum()");
 
-    checkFeSpace(feSpace, vec);
+    checkFeSpace(this->feSpace, vec);
 
     double nrm = 0.0;
     Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)), 
@@ -227,7 +227,7 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector<T>::sum()");
 
-    checkFeSpace(feSpace, vec);
+    checkFeSpace(this->feSpace, vec);
 
     double nrm = 0.0;    
     Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(this)), 
@@ -243,7 +243,7 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector<T>::set()");
 
-    checkFeSpace(feSpace, vec);
+    checkFeSpace(this->feSpace, vec);
 
     Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(this), USED_DOFS);
     for (vecIterator.reset(); !vecIterator.end(); ++vecIterator)
@@ -256,11 +256,12 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector<T>::copy()");
 
-    checkFeSpace(feSpace, vec);
+    checkFeSpace(this->feSpace, vec);
 
-    TEST_EXIT_DBG(static_cast<int>(x.vec.size()) >= feSpace->getAdmin()->getUsedSize())
+    TEST_EXIT_DBG(static_cast<int>(x.vec.size()) >= 
+		  this->feSpace->getAdmin()->getUsedSize())
       ("x.size = %d too small: admin->sizeUsed = %d\n", x.vec.size(), 
-       feSpace->getAdmin()->getUsedSize());
+       this->feSpace->getAdmin()->getUsedSize());
     
     Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(this), USED_DOFS);
     Iterator xIterator(dynamic_cast<DOFVector<T>*>(const_cast<DOFVector<T>*>(&x)), 
@@ -276,7 +277,7 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector<T>::min()");
     
-    checkFeSpace(feSpace, vec);
+    checkFeSpace(this->feSpace, vec);
 
     T m;    
     Iterator vecIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(this)), USED_DOFS);
@@ -291,7 +292,7 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector<T>::max()");
     
-    checkFeSpace(feSpace, vec);
+    checkFeSpace(this->feSpace, vec);
 
     T m;    
     Iterator vecIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(this)), USED_DOFS);
@@ -315,10 +316,10 @@ namespace AMDiS {
     const DOFAdmin *admin = NULL;
     const char *format;
 
-    if (feSpace) 
-      admin = feSpace->getAdmin();
+    if (this->feSpace) 
+      admin = this->feSpace->getAdmin();
 
-    MSG("Vec `%s':\n", name.c_str());
+    MSG("Vec `%s':\n", this->name.c_str());
     int j = 0;
     if (admin) {
       if (admin->getUsedSize() > 100)
@@ -450,22 +451,19 @@ namespace AMDiS {
   {
     FUNCNAME("DOFVector::Int()");
   
-    Mesh* mesh = feSpace->getMesh();
+    Mesh* mesh = this->feSpace->getMesh();
 
     if (!q) {
-      int deg = 2 * feSpace->getBasisFcts()->getDegree();
+      int deg = 2 * this->feSpace->getBasisFcts()->getDegree();
       q = Quadrature::provideQuadrature(this->dim, deg);
     }
 
-    quad_fast = FastQuadrature::provideFastQuadrature(feSpace->getBasisFcts(), *q, INIT_PHI);
+    quad_fast = FastQuadrature::provideFastQuadrature(this->feSpace->getBasisFcts(), 
+						      *q, INIT_PHI);
     norm = 0.0;
     traverseVector = const_cast<DOFVector<T>*>(this);
 
-    mesh->traverse(-1, 
-		   Mesh::CALL_LEAF_EL|
-		   Mesh::FILL_COORDS |
-		   Mesh::FILL_DET, 
-		   Int_fct);
+    mesh->traverse(-1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | Mesh::FILL_DET, Int_fct);
 
     return norm;  
   }
@@ -492,19 +490,17 @@ namespace AMDiS {
     FUNCNAME("DOFVector::L1Norm()");
   
     if (!q) {
-      int deg = 2 * feSpace->getBasisFcts()->getDegree();
+      int deg = 2 * this->feSpace->getBasisFcts()->getDegree();
       q = Quadrature::provideQuadrature(this->dim, deg);
     }
 
-    quad_fast = FastQuadrature::provideFastQuadrature(feSpace->getBasisFcts(),*q,INIT_PHI);
+    quad_fast = FastQuadrature::provideFastQuadrature(this-> feSpace->getBasisFcts(),
+						      *q, INIT_PHI);
     norm = 0.0;
     traverseVector = const_cast<DOFVector<T>*>(this);
-    Mesh* mesh = feSpace->getMesh();
+    Mesh* mesh = this->feSpace->getMesh();
 
-    mesh->traverse(-1, 
-		   Mesh::CALL_LEAF_EL|
-		   Mesh::FILL_COORDS |
-		   Mesh::FILL_DET, 
+    mesh->traverse(-1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | Mesh::FILL_DET, 
 		   L1Norm_fct);
 
     return norm;  
@@ -533,17 +529,16 @@ namespace AMDiS {
     FUNCNAME("DOFVector::L2NormSquare()");
 
     if (!q) {
-      int deg = 2 * feSpace->getBasisFcts()->getDegree();
+      int deg = 2 * this->feSpace->getBasisFcts()->getDegree();
       q = Quadrature::provideQuadrature(this->dim, deg);
     }
 
-    quad_fast = FastQuadrature::provideFastQuadrature(feSpace->getBasisFcts(), 
-						      *q, 
-						      INIT_PHI);
+    quad_fast = FastQuadrature::provideFastQuadrature(this->feSpace->getBasisFcts(), 
+						      *q, INIT_PHI);
 
     norm = 0.0;
     traverseVector = const_cast<DOFVector<T>*>(this);
-    Mesh* mesh = feSpace->getMesh();
+    Mesh* mesh = this->feSpace->getMesh();
     mesh->traverse(-1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | Mesh::FILL_DET, 
 		   L2Norm_fct);
 
@@ -595,20 +590,19 @@ namespace AMDiS {
     FUNCNAME("DOFVector::H1NormSquare()");
 
     if (!q) {
-      int deg = 2 * feSpace->getBasisFcts()->getDegree() - 2;
+      int deg = 2 * this->feSpace->getBasisFcts()->getDegree() - 2;
       q = Quadrature::provideQuadrature(this->dim, deg);
     }
 
-    quad_fast = FastQuadrature::provideFastQuadrature(feSpace->getBasisFcts(), 
+    quad_fast = FastQuadrature::provideFastQuadrature(this->feSpace->getBasisFcts(), 
 						      *q, INIT_GRD_PHI);
 
     norm = 0.0;
     traverseVector = const_cast<DOFVector<T>*>(this); 
-    Mesh *mesh = feSpace->getMesh();
+    Mesh *mesh = this->feSpace->getMesh();
 
-    mesh->traverse(-1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | 
-		   Mesh::FILL_DET | Mesh::FILL_GRD_LAMBDA,
-		   H1Norm_fct);
+    mesh->traverse(-1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | Mesh::FILL_DET | 
+		   Mesh::FILL_GRD_LAMBDA, H1Norm_fct);
 
     return norm;
   }
@@ -646,8 +640,7 @@ namespace AMDiS {
   template<typename T>
   DOFVector<T>& DOFVector<T>::operator=(const DOFVector<T>& rhs)
   {
-    feSpace = rhs.feSpace;
-    DOFVectorBase<T>::feSpace = rhs.feSpace;
+    this->feSpace = rhs.feSpace;
     this->nBasFcts = rhs.nBasFcts;
     vec = rhs.vec;
     this->elementVector.change_dim(this->nBasFcts);
@@ -1082,15 +1075,15 @@ namespace AMDiS {
     FUNCNAME("DOFVector::DoubleWell()");
   
     if (!q) {
-      int deg = 2 * feSpace->getBasisFcts()->getDegree();
+      int deg = 2 * this->feSpace->getBasisFcts()->getDegree();
       q = Quadrature::provideQuadrature(this->dim, deg);
     }
 
-    quad_fast = FastQuadrature::provideFastQuadrature(feSpace->getBasisFcts(), 
+    quad_fast = FastQuadrature::provideFastQuadrature(this->feSpace->getBasisFcts(), 
 						      *q, INIT_PHI);
     norm = 0.0;
     traverseVector = const_cast<DOFVector<T>*>(this);
-    Mesh* mesh = feSpace->getMesh();   
+    Mesh* mesh = this->feSpace->getMesh();   
     mesh->traverse(-1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | Mesh::FILL_DET, 
 		   DoubleWell_fct);
 
diff --git a/AMDiS/src/ProblemInstat.cc b/AMDiS/src/ProblemInstat.cc
index 91e02878..ebbb84bc 100644
--- a/AMDiS/src/ProblemInstat.cc
+++ b/AMDiS/src/ProblemInstat.cc
@@ -9,15 +9,12 @@
 namespace AMDiS {
 
   ProblemInstat::~ProblemInstat()
-  {
-  }
+  {}
 
   void ProblemInstat::initialize(Flag initFlag,
 				 ProblemInstat *adoptProblem/* = NULL*/,
 				 Flag adoptFlag /* = INIT_NOTHING*/) 
-  {
-    FUNCNAME("ProblemInstat::initialize()");
-  }
+  {}
 
   void ProblemInstat::solveInitialProblem(AdaptInfo *adaptInfo)
   {
@@ -45,7 +42,7 @@ namespace AMDiS {
   }
 
 
-  ProblemInstatScal::ProblemInstatScal(char* name_, 
+  ProblemInstatScal::ProblemInstatScal(std::string name_, 
 				       ProblemScal *prob,
 				       ProblemStatBase *initialProb)
     : ProblemInstat(name_, initialProb), 
@@ -115,7 +112,7 @@ namespace AMDiS {
     problemStat->writeFiles(adaptInfo, force);
   }
 
-  ProblemInstatVec::ProblemInstatVec(char* name_, 
+  ProblemInstatVec::ProblemInstatVec(std::string name_, 
 				     ProblemVec *prob,
 				     ProblemStatBase *initialProb)
     : ProblemInstat(name_, initialProb), 
@@ -134,7 +131,7 @@ namespace AMDiS {
   {
     FUNCNAME("ProblemInstatVec::initialize()");
   
-    ProblemInstat::initialize(initFlag,adoptProblem,adoptFlag);
+    ProblemInstat::initialize(initFlag, adoptProblem, adoptFlag);
 
     // === create vector for old solution ===
     if (oldSolution) {
diff --git a/AMDiS/src/ProblemInstat.h b/AMDiS/src/ProblemInstat.h
index e3a72b4f..c724fdee 100644
--- a/AMDiS/src/ProblemInstat.h
+++ b/AMDiS/src/ProblemInstat.h
@@ -115,7 +115,7 @@ namespace AMDiS {
   {
   public:
     /// Constructs a ProblemInstatScal with prob as its stationary problem.
-    ProblemInstatScal(char* name,
+    ProblemInstatScal(std::string name,
 		      ProblemScal *prob,
 		      ProblemStatBase *initialProb = NULL);
 
@@ -175,7 +175,7 @@ namespace AMDiS {
   {
   public:
     /// Constructs a ProblemInstatVec with prob as its stationary problem.
-    ProblemInstatVec(char *name, 
+    ProblemInstatVec(std::string name, 
 		     ProblemVec *prob,
 		     ProblemStatBase *initialProb = NULL);
 
-- 
GitLab