From ec03ab8b66471bd24afa181ec1d597b7ccd40617 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Mon, 7 Jun 2010 15:12:35 +0000
Subject: [PATCH] Andreas' last changes, but now with AMDiS code style.

---
 AMDiS/src/DOFVector.h            |   2 +-
 AMDiS/src/FixVec.h               |   3 +-
 AMDiS/src/ProblemImplicit.cc     | 134 +++++++++++++++----------------
 AMDiS/src/ProblemImplicit.h      |  42 +++++++---
 AMDiS/src/ProblemInterpolScal.cc |   5 +-
 5 files changed, 104 insertions(+), 82 deletions(-)

diff --git a/AMDiS/src/DOFVector.h b/AMDiS/src/DOFVector.h
index b4218b92..3841085d 100644
--- a/AMDiS/src/DOFVector.h
+++ b/AMDiS/src/DOFVector.h
@@ -209,7 +209,7 @@ namespace AMDiS {
 
     inline void setName(std::string n)
     {
-      name=n;
+      name = n;
     }
 
     inline BoundaryManager* getBoundaryManager() const 
diff --git a/AMDiS/src/FixVec.h b/AMDiS/src/FixVec.h
index 4836790a..5c332748 100644
--- a/AMDiS/src/FixVec.h
+++ b/AMDiS/src/FixVec.h
@@ -531,8 +531,9 @@ namespace AMDiS {
 
   inline WorldVector<double> operator*(double d, const WorldVector<double>& v)
   {
-    return v*d;
+    return v * d;
   }
+
   inline WorldVector<double> operator+(const WorldVector<double>& v1,
 				       const WorldVector<double>& v2) 
   {
diff --git a/AMDiS/src/ProblemImplicit.cc b/AMDiS/src/ProblemImplicit.cc
index 987184d6..7c84a3b9 100644
--- a/AMDiS/src/ProblemImplicit.cc
+++ b/AMDiS/src/ProblemImplicit.cc
@@ -2,56 +2,56 @@
 
 namespace AMDiS {
   namespace calcspace {
-    void readDofvec(std::istream& in, DOFVector< double >* vec, Mesh* mesh) 
+    void readDofvec(std::istream& in, DOFVector<double>* vec, Mesh* mesh) 
     {
       long size = mesh->getNumberOfVertices();
       std::string buf;
       getline(in, buf);
-      while(buf != "vertex values: solution") getline(in, buf);
-      for(long i = 0; i < size; i++)
-      {
+      while (buf != "vertex values: solution") 
+	getline(in, buf);
+      for (long i = 0; i < size; i++) {
         in >> buf;
         (*vec)[i] = atof(buf.c_str());
       }
     }
 
+
     void readR(std::istream& inStream, double eps, 
-		    DOFVector< double >* r, DOFVector< double >* phi1, 
-		    DOFVector< double >* phi2, DOFVector< double >* levelSet, 
-		    Mesh* mesh) 
+	       DOFVector<double>* r, DOFVector<double>* phi1, 
+	       DOFVector<double>* phi2, DOFVector<double>* levelSet, 
+	       Mesh* mesh) 
     {
       readDofvec(inStream, r, mesh);
-      std::vector< double >& vecR = r->getVector();
-      std::vector< double >& vecPhi1 = phi1->getVector();
-      std::vector< double >& vecPhi2 = phi2->getVector();
-      std::vector< double >& vecLevelSet = levelSet->getVector();
-      bool checkSize = vecR.size() != vecPhi1.size() &&
-	      vecPhi2.size() != vecR.size();
+      std::vector<double>& vecR = r->getVector();
+      std::vector<double>& vecPhi1 = phi1->getVector();
+      std::vector<double>& vecPhi2 = phi2->getVector();
+      std::vector<double>& vecLevelSet = levelSet->getVector();
+      bool checkSize = 
+	vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
       TEST_EXIT(checkSize)("something went wrong\n");
-      for (int i = vecR.size()-1; i >= 0; --i) 
-      {
+      for (int i = vecR.size() - 1; i >= 0; --i) {
         vecPhi1[i] = Phi1(vecR[i], eps);
         vecPhi2[i] = Phi2(vecR[i], eps);
         vecLevelSet[i] = LevelSet(vecR[i]);
       }
     }
 
+
     void readPhi1(istream& inStream, double eps, 
-		    DOFVector< double >* r, DOFVector< double >* phi1, 
-		    DOFVector< double >* phi2, DOFVector< double >* levelSet, 
-		    Mesh* mesh) 
+		  DOFVector<double>* r, DOFVector<double>* phi1, 
+		  DOFVector<double>* phi2, DOFVector<double>* levelSet, 
+		  Mesh* mesh) 
     {
       readDofvec(inStream, phi1, mesh);
-      std::vector< double >& vecR = r->getVector();
-      std::vector< double >& vecPhi1 = phi1->getVector();
-      std::vector< double >& vecPhi2 = phi2->getVector();
-      std::vector< double >& vecLevelSet = levelSet->getVector();
+      std::vector<double>& vecR = r->getVector();
+      std::vector<double>& vecPhi1 = phi1->getVector();
+      std::vector<double>& vecPhi2 = phi2->getVector();
+      std::vector<double>& vecLevelSet = levelSet->getVector();
       
-      bool checkSize = vecR.size() != vecPhi1.size() &&
-	      vecPhi2.size() != vecR.size();
+      bool checkSize = 
+	vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
       TEST_EXIT(checkSize)("something went wrong\n");
-      for (int i = vecR.size()-1; i>= 0; --i) 
-      {
+      for (int i = vecR.size() - 1; i>= 0; --i) {
         vecR[i] = Phi1ToR(vecPhi1[i], eps);
         //vecPhi2[i] = Phi2(vecR[i], eps);
         vecPhi2[i] = 1 - vecPhi1[i];
@@ -59,32 +59,30 @@ namespace AMDiS {
       }
     }
 
+
     void readPhi2(istream& inStream, double eps, 
-		    DOFVector< double >* r, DOFVector< double >* phi1, 
-		    DOFVector< double >* phi2, DOFVector< double >* levelSet, 
+		    DOFVector<double>* r, DOFVector<double>* phi1, 
+		    DOFVector<double>* phi2, DOFVector<double>* levelSet, 
 		    Mesh* mesh) 
     {
       readDofvec(inStream, phi2, mesh);
-      std::vector< double >& vecR = r->getVector();
-      std::vector< double >& vecPhi1 = phi1->getVector();
-      std::vector< double >& vecPhi2 = phi2->getVector();
-      std::vector< double >& vecLevelSet = levelSet->getVector();
+      std::vector<double>& vecR = r->getVector();
+      std::vector<double>& vecPhi1 = phi1->getVector();
+      std::vector<double>& vecPhi2 = phi2->getVector();
+      std::vector<double>& vecLevelSet = levelSet->getVector();
 
-      bool checkSize = vecR.size() != vecPhi1.size() &&
-	      vecPhi2.size() != vecR.size();
+      bool checkSize = vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
       TEST_EXIT(checkSize)("something went wrong\n");
-      for (int i = vecR.size()-1; i >= 0; --i) 
-      {
+      for (int i = vecR.size() - 1; i >= 0; --i) {
         vecR[i] = Phi2ToR(vecPhi2[i], eps);
         //vecPhi1[i] = Phi1(vecR[i], eps);
         vecPhi1[i] = 1 - vecPhi2[i];
         vecLevelSet[i] = LevelSet(vecR[i]);
       }
     }
-
-
   }
 
+
   bool ProblemImplicitScal::createImplicitMesh() 
   {
     std::string meshFilename("");
@@ -98,14 +96,14 @@ namespace AMDiS {
     if (dofFilename.length() == 0)
       return false;
 
-    double eps(-1);
+    double eps(-1.0);
     GET_PARAMETER(0, name + "->implicit mesh->eps", "%d", &eps);
-    if (eps<0)
+    if (eps < 0)
       return false;
 
     int serType(-1);
     GET_PARAMETER(0, name + "->implicit mesh->type", "%d", &serType);
-    if (serType<0)
+    if (serType < 0)
       return false;
 
     TEST_EXIT(mesh != NULL)("the mesh was not created\n");
@@ -139,16 +137,18 @@ namespace AMDiS {
     return true;
   }
 
+
   void ProblemImplicitScal::initialize(Flag initFlag,
 		  ProblemScal* adaptProblem, Flag adoptFlag)
   {
-     FUNCNAME("ImplicitScal::initialize()");
+     FUNCNAME("ProblemImplicitScal::initialize()");
      ProblemScal::initialize(CREATE_MESH);
      createImplicitMesh();
      initFlag = initFlag & ~CREATE_MESH;
      ProblemScal::initialize(initFlag);
   }
 
+
   bool ProblemImplicitVec::createImplicitMesh()
   {
     //check each mesh if it's an implicit one
@@ -156,15 +156,15 @@ namespace AMDiS {
     phi1.resize(meshes.size());
     phi2.resize(meshes.size());
     levelSet.resize(meshes.size());
-    for(int i=0;i<meshes.size();++i) {
-      createImplicitMesh(i);
-    }
+    for (int i = 0; i < meshes.size(); ++i)
+      createImplicitMesh(i);    
   }
 
+
   bool ProblemImplicitVec::createImplicitMesh(int p) 
   {
-    std::string path=name + "->implicit mesh[" +
-	    boost::lexical_cast< std::string >(p) + "]->";
+    std::string path = 
+      name + "->implicit mesh[" + boost::lexical_cast< std::string >(p) + "]->";
     std::string meshFilename("");
     GET_PARAMETER(0, path + "mesh file", &meshFilename);
     //if no file name is given, there's no implicit mesh
@@ -175,10 +175,10 @@ namespace AMDiS {
     if (dofFilename.length() == 0)
       return false;
 
-    double eps(-1);
+    double eps(-1.0);
     GET_PARAMETER(0, path + "eps", "%d", &eps);
-    if(eps < 0)
-        return false;
+    if (eps < 0.0)
+      return false;
     int serType(-1);
     GET_PARAMETER(0, path + "type", "%d", &serType);
     if (serType < 0)
@@ -194,31 +194,31 @@ namespace AMDiS {
     phi2[p] = new DOFVector<double>(getFeSpace(p), "phi2");
     levelSet[p] = new DOFVector< double >(getFeSpace(p), "levelSet");
     inStream.open(dofFilename.c_str());
-    switch (serType) 
-    {
-      case 0:
-        calcspace::readR(inStream, eps,r[p], phi1[p], phi2[p],
-		       	levelSet[p], meshes[p]);
-        break;
-      case 1:
-	calcspace::readPhi1(inStream, eps, r[p], phi1[p], phi2[p],
-		       	levelSet[p], meshes[p]);
-        break;
-      case 2:
-	calcspace::readPhi2(inStream,eps, r[p], phi1[p], phi2[p],
-		       	levelSet[p], meshes[p]);
-        break;
-      default:
-        WARNING("unknown implicit mesh type\n");
+    switch (serType) {
+    case 0:
+      calcspace::readR(inStream, eps,r[p], phi1[p], phi2[p],
+		       levelSet[p], meshes[p]);
+      break;
+    case 1:
+      calcspace::readPhi1(inStream, eps, r[p], phi1[p], phi2[p],
+			  levelSet[p], meshes[p]);
+      break;
+    case 2:
+      calcspace::readPhi2(inStream,eps, r[p], phi1[p], phi2[p],
+			  levelSet[p], meshes[p]);
+      break;
+    default:
+      WARNING("unknown implicit mesh type\n");
     }
     inStream.close();
     return true;
   }
 
+
   void ProblemImplicitVec::initialize(Flag initFlag,
 		  ProblemScal* adaptProblem, Flag adoptFlag)
   {
-     FUNCNAME("ImplicitScal::initialize()");
+     FUNCNAME("ProblemImplicitVec::initialize()");
      ProblemVec::initialize(CREATE_MESH);
      createImplicitMesh();
      initFlag = initFlag & ~CREATE_MESH;
diff --git a/AMDiS/src/ProblemImplicit.h b/AMDiS/src/ProblemImplicit.h
index 5ad9fd38..4047ab19 100644
--- a/AMDiS/src/ProblemImplicit.h
+++ b/AMDiS/src/ProblemImplicit.h
@@ -1,3 +1,24 @@
+// ============================================================================
+// ==                                                                        ==
+// == AMDiS - Adaptive multidimensional simulations                          ==
+// ==                                                                        ==
+// ============================================================================
+// ==                                                                        ==
+// ==  TU Dresden                                                            ==
+// ==                                                                        ==
+// ==  Institut für Wissenschaftliches Rechnen                               ==
+// ==  Zellescher Weg 12-14                                                  ==
+// ==  01069 Dresden                                                         ==
+// ==  germany                                                               ==
+// ==                                                                        ==
+// ============================================================================
+// ==                                                                        ==
+// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
+// ==                                                                        ==
+// ============================================================================
+
+/** \file ProblemImplicit.h */
+
 #ifndef AMDIS_PROBLEMIMPLICIT_H
 #define AMDIS_PROBLEMIMPLICIT_H
 
@@ -8,7 +29,6 @@
 namespace AMDiS {
   class ProblemImplicitScal : public ProblemScal 
   {
-
   public:
     ProblemImplicitScal(std::string name, ProblemIterationInterface* pis = NULL)
       : ProblemScal(name, pis),
@@ -37,17 +57,17 @@ namespace AMDiS {
 
   protected:
     /// DOFVector for a signed distance
-    DOFVector< double > *r;
+    DOFVector<double> *r;
 
     /// DOFVector for the phasefield function 0.5*(1-tanh(3*r/eps))
-    DOFVector< double > *phi1;
+    DOFVector<double> *phi1;
 
     /// DOFVector for the phasefield function 0.5*(1+tanh(3*r/eps))
-    DOFVector< double > *phi2;
+    DOFVector<double> *phi2;
 
     /// DOFVector for the levelset function 
     /// (levelSet(x): x \in \Omega: 1, x \not \in Omega: -1, x \in \Gamma: 0)
-    DOFVector< double > *levelSet;
+    DOFVector<double> *levelSet;
 
   };
 
@@ -61,27 +81,27 @@ namespace AMDiS {
 	phi1(0),
 	phi2(0),
 	levelSet(0)
-        {}
+    {}
 
     virtual bool createImplicitMesh();
     virtual void initialize(Flag initFlag, ProblemScal *adoptProblem=NULL, 
 		            Flag adoptFlag = INIT_NOTHING);
 
   protected:
-
     bool createImplicitMesh(int p); 
+
     /// DOFVector for a signed distance
-    std::vector< DOFVector< double >* > r;
+    std::vector<DOFVector<double>*> r;
 
     /// DOFVector for the phasefield function 0.5*(1-tanh(3*r/eps))
-    std::vector< DOFVector< double >* > phi1;
+    std::vector<DOFVector<double>*> phi1;
 
     /// DOFVector for the phasefield function 0.5*(1+tanh(3*r/eps))
-    std::vector< DOFVector< double >* > phi2;
+    std::vector<DOFVector<double>*> phi2;
 
     /// DOFVector for the levelset function 
     /// (levelSet(x): x \in \Omega: 1, x \not \in Omega: -1, x \in \Gamma: 0)
-    std::vector< DOFVector< double >* > levelSet;
+    std::vector<DOFVector<double>*> levelSet;
 
   };
 }
diff --git a/AMDiS/src/ProblemInterpolScal.cc b/AMDiS/src/ProblemInterpolScal.cc
index 56a7da5d..8c4f2bf0 100644
--- a/AMDiS/src/ProblemInterpolScal.cc
+++ b/AMDiS/src/ProblemInterpolScal.cc
@@ -15,8 +15,9 @@ namespace AMDiS {
       grdInterpolFct(grdFct)
   {
     Flag adoptFlag = INIT_SYSTEM | INIT_MESH | INIT_FE_SPACE;
-    Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER & ~INIT_ESTIMATOR & ~CREATE_MESH & ~INIT_FILEWRITER;
-    if(initFlag.isSet(CREATE_MESH))
+    Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER &
+      ~INIT_ESTIMATOR & ~CREATE_MESH & ~INIT_FILEWRITER;
+    if (initFlag.isSet(CREATE_MESH))
       WARNING("CREATE_MESH is set\n");
     initialize(initFlag, spaceProblem, adoptFlag);
   }
-- 
GitLab