From ee19a4fe5074f37e5cdf51f364c77b9aa08bbfc7 Mon Sep 17 00:00:00 2001
From: Simon Praetorius <simon.praetorius@tu-dresden.de>
Date: Thu, 23 Jul 2015 15:27:44 +0000
Subject: [PATCH] error corrected in MacroInfo::readAMDiSMacro due to
 line-length restrictions

---
 AMDiS/CMakeLists.txt                  |  4 ++--
 AMDiS/src/Expressions.hh              |  2 +-
 AMDiS/src/ProblemStat.cc              |  1 +
 AMDiS/src/config/Config_intel.h       |  2 +-
 AMDiS/src/expressions/coords_expr.hpp |  1 +
 AMDiS/src/io/MacroInfo.cc             |  4 ++--
 extensions/ExtendedProblemStat.h      | 31 +++++++++++++++++++--------
 extensions/pugixml/src/pugixml.hpp    |  3 ++-
 8 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/AMDiS/CMakeLists.txt b/AMDiS/CMakeLists.txt
index 82db8ade..333d3e7a 100644
--- a/AMDiS/CMakeLists.txt
+++ b/AMDiS/CMakeLists.txt
@@ -28,7 +28,7 @@ endif()
 if(NOT AMDIS_MINOR)
   set(AMDIS_MINOR "9")
 endif()
-set(COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}")
+list(APPEND COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}")
 
 #define the build type, empty can be everything and nothing
 if(CMAKE_BUILD_TYPE STREQUAL "")
@@ -37,7 +37,7 @@ endif()
 
 if(CMAKE_CXX_COMPILER MATCHES ".*icpc")
 	Message("Compiler: Intel")
-	set(CMAKE_CXX_FLAGS "-diag-disable 654 -diag-disable 858") 
+	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable 654 -diag-disable 858") 
 endif()
 
 
diff --git a/AMDiS/src/Expressions.hh b/AMDiS/src/Expressions.hh
index a45bf1a6..5f8df0be 100644
--- a/AMDiS/src/Expressions.hh
+++ b/AMDiS/src/Expressions.hh
@@ -133,7 +133,7 @@ transformDOF(Term term, DOFVector<T>* result)
   std::vector<DegreeOfFreedom> localIndices(nBasisFcts);
   TraverseStack stack;
   ElInfo *elInfo = stack.traverseFirst(mesh, -1,
-					Mesh::CALL_LEAF_EL | 
+					Mesh::CALL_LEAF_EL | Mesh::FILL_BOUND |
 					Mesh::FILL_COORDS | Mesh::FILL_GRD_LAMBDA);
   term.initElement(&ot, elInfo, NULL, NULL, basisFcts);
   
diff --git a/AMDiS/src/ProblemStat.cc b/AMDiS/src/ProblemStat.cc
index 36e10401..bbb0540d 100644
--- a/AMDiS/src/ProblemStat.cc
+++ b/AMDiS/src/ProblemStat.cc
@@ -243,6 +243,7 @@ namespace AMDiS {
 	feSpaces = adoptProblem->getFeSpaces();
 	traverseInfo = adoptProblem->traverseInfo;
 	
+	componentSpaces.clear();
 	if (feSpaces.size() == 1)
 	  componentSpaces.resize(nComponents, feSpaces[0]);
 	else if (adoptProblem->getNumComponents() >= nComponents) {
diff --git a/AMDiS/src/config/Config_intel.h b/AMDiS/src/config/Config_intel.h
index 71d2bc0e..c4623f0f 100644
--- a/AMDiS/src/config/Config_intel.h
+++ b/AMDiS/src/config/Config_intel.h
@@ -55,7 +55,7 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
 // workaround needed to test for -std=c++11 enabled, since __cplusplus gives wrong values
 #include <vector>
 #include <functional>
-#if defined(_GLIBCXX_TUPLE) || defined(_GLIBCXX_TYPE_TRAITS) || defined(_GLIBCXX_ARRAY)
+#if defined(_GLIBCXX_TUPLE) || defined(_GLIBCXX_TYPE_TRAITS) || defined(_GLIBCXX_ARRAY) || (__cplusplus > 199711L)
 
 #define HAS_CXX11 1
 
diff --git a/AMDiS/src/expressions/coords_expr.hpp b/AMDiS/src/expressions/coords_expr.hpp
index f8efe5d2..c4167969 100644
--- a/AMDiS/src/expressions/coords_expr.hpp
+++ b/AMDiS/src/expressions/coords_expr.hpp
@@ -191,6 +191,7 @@ namespace AMDiS
 		       const BasisFunction *basisFct = NULL)
       {
 	int dim = elInfo->getMesh()->getDim();
+	normal.set(0.0);
 	for (int side = 0; side < dim+1; ++side) {
 	  if (elInfo->getBoundary(side) == boundary) {
 	    elInfo->getNormal(side, normal);
diff --git a/AMDiS/src/io/MacroInfo.cc b/AMDiS/src/io/MacroInfo.cc
index 6e1a7387..5f107214 100644
--- a/AMDiS/src/io/MacroInfo.cc
+++ b/AMDiS/src/io/MacroInfo.cc
@@ -167,7 +167,7 @@ namespace AMDiS {
     int nElements, nVertices;
     int j, k;
     double dbl;
-    char line[256];
+    char line[1024];
     int line_no, n_keys, sort_key[N_KEYS], nv_key, ne_key;
     int key_def[N_KEYS] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
     const char *key;
@@ -183,7 +183,7 @@ namespace AMDiS {
     // === Looking for all keys in the macro file. ===
 
     line_no = n_keys = 0;
-    while (fgets(line, 255, file)) {
+    while (fgets(line, 1023, file)) {
       line_no++;
       if (!strchr(line, ':'))  
 	continue;
diff --git a/extensions/ExtendedProblemStat.h b/extensions/ExtendedProblemStat.h
index 1e42e1ae..24f5f25b 100644
--- a/extensions/ExtendedProblemStat.h
+++ b/extensions/ExtendedProblemStat.h
@@ -124,7 +124,20 @@ public:
   { FUNCNAME_DBG("ExtendedProblemStat::buildAfterCoarsen()");
   
     ProblemStat_::buildAfterCoarsen(adaptInfo, flag, asmMatrix, asmVector);
-
+    
+    bool addPBC = insertPeriodicBC(flag, asmMatrix, asmVector);
+    bool addDBC = insertDirichletBC(flag, asmMatrix, asmVector);
+    
+    // update solverMatrix
+    if (asmMatrix && (addPBC || addDBC))
+      solverMatrix.setMatrix(*getSystemMatrix());
+    
+    bc_dof.clear();
+  }
+  
+  
+  virtual bool insertPeriodicBC(Flag flag, bool asmMatrix, bool asmVector)
+  {
     // update periodic data
     if (oldMeshChangeIdx != getMesh()->getChangeIndex()
       || flag.isSet(UPDATE_PERIODIC_BC)
@@ -138,7 +151,13 @@ public:
     // apply periodic boundary conditions
     for (size_t k = 0; k < manualPeriodicBC.size(); k++)
       applyPeriodicBC(manualPeriodicBC[k], asmMatrix, asmVector);
-    
+      
+    return (manualPeriodicBC.size() > 0);
+  }
+  
+
+  virtual bool insertDirichletBC(Flag flag, bool asmMatrix, bool asmVector)
+  {
     // update dirichlet data
     if (oldMeshChangeIdx != getMesh()->getChangeIndex()
       || flag.isSet(UPDATE_DIRICHLET_BC)
@@ -160,14 +179,8 @@ public:
     MSG("DBC applied at %d DOFs\n", num_dbc);
     #endif
     
-    // update solverMatrix
-    if (asmMatrix && (singularDirichletBC.size() > 0 || manualPeriodicBC.size() > 0)) {
-      solverMatrix.setMatrix(*getSystemMatrix());
-    }
-    
-    bc_dof.clear();
+    return (singularDirichletBC.size() > 0);
   }
-
   
   //////////////////////////////////////////////////////////////////////////////
   void solve(AdaptInfo *adaptInfo,
diff --git a/extensions/pugixml/src/pugixml.hpp b/extensions/pugixml/src/pugixml.hpp
index 43609962..0953824f 100644
--- a/extensions/pugixml/src/pugixml.hpp
+++ b/extensions/pugixml/src/pugixml.hpp
@@ -15,6 +15,7 @@
 #define HEADER_PUGIXML_HPP
 
 #include "pugiconfig.hpp"
+#include <string>
 
 #ifndef PUGIXML_NO_STL
 namespace std
@@ -34,7 +35,7 @@ namespace std
 	template <class _Ty> struct char_traits;
 	template <class _Elem, class _Traits> class basic_istream;
 	template <class _Elem, class _Traits> class basic_ostream;
-	template <class _Elem, class _Traits, class _Ax> class basic_string;
+// 	template <class _Elem, class _Traits, class _Ax> class basic_string;
 #endif
 
 	// Digital Mars compiler has a bug which requires a forward declaration for explicit instantiation (otherwise type selection is messed up later, producing link errors)
-- 
GitLab