From f696ed01dc6d024cd07d6bca8284c170376ad3da Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Wed, 27 May 2009 12:39:23 +0000
Subject: [PATCH] Removed some *_MEMORY macros

---
 AMDiS/src/DOFMatrix.cc             |  4 +-
 AMDiS/src/ProblemVec.cc            |  4 +-
 AMDiS/src/ResidualEstimator.cc     | 64 ++++++++++++++----------------
 AMDiS/src/RobinBC.cc               |  4 +-
 AMDiS/src/SMIAdapter.cc            | 49 +++++++++--------------
 AMDiS/src/parareal/AdaptParaReal.h |  2 -
 6 files changed, 56 insertions(+), 71 deletions(-)

diff --git a/AMDiS/src/DOFMatrix.cc b/AMDiS/src/DOFMatrix.cc
index 85e4affa..8b71e9a9 100644
--- a/AMDiS/src/DOFMatrix.cc
+++ b/AMDiS/src/DOFMatrix.cc
@@ -102,7 +102,9 @@ namespace AMDiS {
     std::cout.precision(10);
     for (cursor_type cursor = begin<major>(matrix), cend = end<major>(matrix); cursor != cend; ++cursor) {
       for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor)
-	std::cout << "(" << row(*icursor) << "," << col(*icursor) << "," << value(*icursor) << ") ";
+	if (value(*icursor) != 0.0)
+	  std::cout << "(" << row(*icursor) << "," << col(*icursor) << "," << value(*icursor) << ") ";
+
       std::cout << "\n";
     }
   }
diff --git a/AMDiS/src/ProblemVec.cc b/AMDiS/src/ProblemVec.cc
index 3f0aa3ad..ba7df9c0 100644
--- a/AMDiS/src/ProblemVec.cc
+++ b/AMDiS/src/ProblemVec.cc
@@ -781,7 +781,7 @@ namespace AMDiS {
       assembleBoundaryConditions(rhs->getDOFVector(i),
 				 solution->getDOFVector(i),
 				 componentMeshes[i],
-				 assembleFlag);
+				 assembleFlag);      
     }
 
     int nnz = 0;
@@ -792,7 +792,7 @@ namespace AMDiS {
  	if ((*systemMatrix)[i][j]) {
  	  (*systemMatrix)[i][j]->finishInsertion(); 
 	  nnz += (*systemMatrix)[i][j]->getBaseMatrix().nnz();
-	}
+	}    
 
     solverMatrix.setMatrix(*systemMatrix);
 
diff --git a/AMDiS/src/ResidualEstimator.cc b/AMDiS/src/ResidualEstimator.cc
index 66151c8d..f01ac356 100644
--- a/AMDiS/src/ResidualEstimator.cc
+++ b/AMDiS/src/ResidualEstimator.cc
@@ -38,8 +38,8 @@ namespace AMDiS {
     TEST_EXIT_DBG(nSystems > 0)("no system set\n");
 
     dim = mesh->getDim();
-    basFcts = GET_MEMORY(const BasisFunction*, nSystems);
-    quadFast = GET_MEMORY(FastQuadrature*, nSystems);
+    basFcts = new const BasisFunction*[nSystems];
+    quadFast = new FastQuadrature*[nSystems];
 
     degree = 0;
     for (int system = 0; system < nSystems; system++) {
@@ -63,21 +63,21 @@ namespace AMDiS {
 							       flag);
     }
   
-    uhEl = GET_MEMORY(double*, nSystems);
-    uhNeigh = GET_MEMORY(double*, nSystems);
-    uhOldEl = timestep ? GET_MEMORY(double*, nSystems) : NULL;
+    uhEl = new double*[nSystems];
+    uhNeigh = new double*[nSystems];
+    uhOldEl = timestep ? new double*[nSystems] : NULL;
 
     for (int system = 0; system < nSystems; system++) {
-      uhEl[system] = GET_MEMORY(double, basFcts[system]->getNumber()); 
-      uhNeigh[system] = GET_MEMORY(double, basFcts[system]->getNumber());
+      uhEl[system] = new double[basFcts[system]->getNumber()]; 
+      uhNeigh[system] = new double[basFcts[system]->getNumber()];
       if (timestep)
-	uhOldEl[system] = GET_MEMORY(double, basFcts[system]->getNumber());
+	uhOldEl[system] = new double[basFcts[system]->getNumber()];
     }
 
-    uhQP = timestep ? GET_MEMORY(double, nPoints) : NULL;
-    uhOldQP = timestep ? GET_MEMORY(double, nPoints) : NULL;
+    uhQP = timestep ? new double[nPoints] : NULL;
+    uhOldQP = timestep ? new double[nPoints] : NULL;
 
-    riq = GET_MEMORY(double, nPoints);
+    riq = new double[nPoints];
 
     grdUh_qp = NULL;
     D2uhqp = NULL;
@@ -131,42 +131,38 @@ namespace AMDiS {
     est_t_sum = sqrt(est_t_sum);
 
     for (int system = 0; system < nSystems; system++) {
-      FREE_MEMORY(uhEl[system], double, basFcts[system]->getNumber());
-      FREE_MEMORY(uhNeigh[system], double, basFcts[system]->getNumber());
+      delete [] uhEl[system];
+      delete [] uhNeigh[system];
       if (timestep)
-	FREE_MEMORY(uhOldEl[system], double, basFcts[system]->getNumber());    
+	delete [] uhOldEl[system];
     }
 
-    FREE_MEMORY(uhEl, double*, nSystems);
-    FREE_MEMORY(uhNeigh, double*, nSystems);
+    delete [] uhEl;
+    delete [] uhNeigh;
 
     if (timestep) {
-      FREE_MEMORY(uhOldEl, double*, nSystems);
-      FREE_MEMORY(uhQP, double, nPoints);
-      FREE_MEMORY(uhOldQP, double, nPoints);
+      delete [] uhOldEl;
+      delete [] uhQP;
+      delete [] uhOldQP;
     } else {
-      if (uhQP != NULL) {
-	FREE_MEMORY(uhQP, double, nPoints);
-      }
+      if (uhQP != NULL)
+	delete [] uhQP;
     }
 
     if (output) {
       MSG("estimate   = %.8e\n", est_sum);
-      if (C3) {
+      if (C3)
 	MSG("time estimate   = %.8e\n", est_t_sum);
-      }
     }
 
-    FREE_MEMORY(riq, double, nPoints);
-    FREE_MEMORY(basFcts, const BasisFunction*, nSystems);
-    FREE_MEMORY(quadFast, FastQuadrature*, nSystems);
+    delete [] riq;
+    delete [] basFcts;
+    delete [] quadFast;
 
-    if (grdUh_qp != NULL) {
-      FREE_MEMORY(grdUh_qp, WorldVector<double>, nPoints);
-    }
-    if (D2uhqp != NULL) {
-      FREE_MEMORY(D2uhqp, WorldMatrix<double>, nPoints);
-    }
+    if (grdUh_qp != NULL)
+      delete [] grdUh_qp;
+    if (D2uhqp != NULL)
+      delete [] D2uhqp;
 
     if (C1 && (dim > 1)) {
       delete lambdaNeigh_;
@@ -247,7 +243,7 @@ namespace AMDiS {
 	     ++it, ++itfac) {
 	  if (*itfac == NULL || **itfac != 0.0) {
 	    if ((uhQP == NULL) && (*it)->zeroOrderTerms()) {
-	      uhQP = GET_MEMORY(double, nPoints);
+	      uhQP = new double[nPoints];
 	      uh[system]->getVecAtQPs(elInfo, NULL, quadFast[system], uhQP);
 	    }
 	    if ((grdUh_qp == NULL) && ((*it)->firstOrderTermsGrdPsi() || (*it)->firstOrderTermsGrdPhi())) {
diff --git a/AMDiS/src/RobinBC.cc b/AMDiS/src/RobinBC.cc
index 46912617..b4c7cab8 100644
--- a/AMDiS/src/RobinBC.cc
+++ b/AMDiS/src/RobinBC.cc
@@ -238,7 +238,7 @@ namespace AMDiS {
 
     TEST_EXIT(basFcts == rowFESpace->getBasisFcts())("invalid basFcts\n");
 
-    double *uhEl = GET_MEMORY(double, basFcts->getNumber());
+    double *uhEl = new double[basFcts->getNumber()];
 
     dv->getLocalVector(elInfo->getElement(), uhEl);
 
@@ -332,7 +332,7 @@ namespace AMDiS {
       }
     }
 
-    FREE_MEMORY(uhEl, double, basFcts->getNumber());
+    delete [] uhEl;
 
     return det * val;
   }
diff --git a/AMDiS/src/SMIAdapter.cc b/AMDiS/src/SMIAdapter.cc
index 1c048816..5e0c68cf 100644
--- a/AMDiS/src/SMIAdapter.cc
+++ b/AMDiS/src/SMIAdapter.cc
@@ -185,7 +185,7 @@ namespace AMDiS {
     int numNewNodes;
     int numNodes;
     bool validElement;
-    double *nodeCoords = GET_MEMORY(double, numBasFcts * dim); 
+    double *nodeCoords = new double[numBasFcts * dim]; 
 
     DOFVector<char> alreadyAdded(feSpace_, "already added nodes");
     alreadyAdded.set(0);
@@ -198,8 +198,8 @@ namespace AMDiS {
 
     const DegreeOfFreedom *elementDofs = NULL;
     DegreeOfFreedom dof;
-    DegreeOfFreedom *nodeIndices = GET_MEMORY(int, numBasFcts);
-    DegreeOfFreedom *newNodeIndices = GET_MEMORY(int, numBasFcts);
+    DegreeOfFreedom *nodeIndices = new int[numBasFcts];
+    DegreeOfFreedom *newNodeIndices = new int[numBasFcts];
 
     Flag fillFlag = Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS;
   
@@ -391,12 +391,11 @@ namespace AMDiS {
       elInfo = stack.traverseNext(elInfo);
     }
   
-    FREE_MEMORY(nodeCoords, double, numBasFcts * dim);
-    FREE_MEMORY(nodeIndices, int, numBasFcts);
-    FREE_MEMORY(newNodeIndices, int, numBasFcts);
+    delete [] nodeCoords;
+    delete [] nodeIndices;
+    delete [] newNodeIndices;
 
-    smiError = SMI_End_write_transaction(smiApplicationId_,
-					 smiMeshId_);
+    smiError = SMI_End_write_transaction(smiApplicationId_, smiMeshId_);
 
     TEST_EXIT(smiError == SMI_OK)
       ("SMI_End_modification() failed with error %d\n", smiError);
@@ -423,9 +422,7 @@ namespace AMDiS {
     TEST_EXIT(smiError == SMI_OK)
       ("SMI_Get_all_nodes() failed with error %d\n", smiError);
 
-    //double *values = GET_MEMORY(double, numNodes);
-
-    if(quantityID == -1) {
+    if (quantityID == -1) {
       std::map<int, std::vector<DOFVector<double>*> >::iterator quantityIt;
       std::map<int, std::vector<DOFVector<double>*> >::iterator quantityEnd = 
 	  dofVectors_.end();
@@ -433,7 +430,7 @@ namespace AMDiS {
       for(quantityIt = dofVectors_.begin(); quantityIt != quantityEnd; ++quantityIt) {
 	int quantityDim = static_cast<int>(quantityIt->second.size());
 
-	double *values = GET_MEMORY(double, numNodes * quantityDim);
+	double *values = new double[numNodes * quantityDim];
 
 	int i, comp;
 	for(i = 0; i < numNodes; i++) {
@@ -459,12 +456,12 @@ namespace AMDiS {
 	TEST_EXIT(smiError == SMI_OK)
 	  ("SMI_Set_quantity_values() failed with error %d\n", smiError);
       
-	FREE_MEMORY(values, double, numNodes * quantityDim);
+	delete [] values;
       }
     } else {
       int quantityDim = static_cast<int>(dofVectors_[quantityID].size());
 
-      double *values = GET_MEMORY(double, numNodes * quantityDim);
+      double *values = new double[numNodes * quantityDim];
 
       int i, comp;
       for(i = 0; i < numNodes; i++) {
@@ -490,13 +487,10 @@ namespace AMDiS {
       TEST_EXIT(smiError == SMI_OK)
 	("SMI_Set_quantity_values() failed with error %d\n", smiError);
 
-      FREE_MEMORY(values, double, numNodes * quantityDim);
+      delete [] values;
     }
 
-    //FREE_MEMORY(values, double, numNodes);
-
-    smiError = SMI_End_write_transaction(smiApplicationId_,
-					 smiMeshId_);
+    smiError = SMI_End_write_transaction(smiApplicationId_, smiMeshId_);
 
     TEST_EXIT(smiError == SMI_OK)
       ("SMI_End_modification() failed with error %d\n", smiError);
@@ -523,16 +517,14 @@ namespace AMDiS {
     TEST_EXIT(smiError == SMI_OK)
       ("SMI_Get_all_nodes() failed with error %d\n", smiError);
 
-    //double *values = GET_MEMORY(double, numNodes);
-
-    if(quantityID == -1) {
+    if (quantityID == -1) {
       std::map<int, std::vector<DOFVector<double>*> >::iterator quantityIt;
       std::map<int, std::vector<DOFVector<double>*> >::iterator quantityEnd = 
 	  dofVectors_.end();
       for(quantityIt = dofVectors_.begin(); quantityIt != quantityEnd; ++quantityIt) {
 	int quantityDim = static_cast<int>(quantityIt->second.size());
 
-	double *values = GET_MEMORY(double, numNodes * quantityDim);
+	double *values = new double[numNodes * quantityDim];
 
 	smiError = SMI_Get_quantity_values(smiApplicationId_,
 					   smiMeshId_,
@@ -558,12 +550,12 @@ namespace AMDiS {
 	  }
 	}
 
-	FREE_MEMORY(values, double, numNodes * quantityDim);
+	delete [] values;
       }
     } else {
       int quantityDim = static_cast<int>(dofVectors_[quantityID].size());
 
-      double *values = GET_MEMORY(double, numNodes * quantityDim);
+      double *values = new double[numNodes * quantityDim];
 
       smiError = SMI_Get_quantity_values(smiApplicationId_,
 					 smiMeshId_,
@@ -589,13 +581,10 @@ namespace AMDiS {
 	}
       }
 
-      FREE_MEMORY(values, double, numNodes * quantityDim);
+      delete [] values;
     }
 
-    //FREE_MEMORY(values, double, numNodes);
-
-    smiError = SMI_End_read_transaction(smiApplicationId_,
-					smiMeshId_);
+    smiError = SMI_End_read_transaction(smiApplicationId_, smiMeshId_);
 
     TEST_EXIT(smiError == SMI_OK)
       ("SMI_End_modification() failed with error %d\n", smiError);
diff --git a/AMDiS/src/parareal/AdaptParaReal.h b/AMDiS/src/parareal/AdaptParaReal.h
index 943ddb5f..d24b0cca 100644
--- a/AMDiS/src/parareal/AdaptParaReal.h
+++ b/AMDiS/src/parareal/AdaptParaReal.h
@@ -30,8 +30,6 @@ namespace AMDiS {
   class AdaptParaReal : public AdaptInstationary
   {
   public:
-    MEMORY_MANAGED(AdaptParaReal);
-
     AdaptParaReal(const char *name, 
 		  ProblemIterationInterface *problemStat,
 		  AdaptInfo *info,
-- 
GitLab