From 209f7b44526981045aa4fcdceee7066a09a83f0e Mon Sep 17 00:00:00 2001
From: Simon Praetorius <simon.praetorius@tu-dresden.de>
Date: Sat, 22 Oct 2016 17:35:37 +0200
Subject: [PATCH] changed DEBUG to NOT NDEBUG and removed separate debug target
 from cmake

---
 AMDiS/cmake/CMakeLists.txt                    |  5 --
 AMDiS/cmake3/AMDISConfig.cmake.in             |  4 +-
 AMDiS/cmake3/CMakeLists.txt                   |  8 +--
 AMDiS/cmake3/amdis_parallel.cmake             |  5 +-
 AMDiS/src/BoundaryObject.cc                   |  2 +-
 AMDiS/src/Config.h                            |  9 ---
 AMDiS/src/FiniteElemSpace.cc                  |  2 +-
 AMDiS/src/FiniteElemSpace.h                   |  2 +-
 AMDiS/src/Global.cc                           | 10 +--
 AMDiS/src/Mesh.cc                             |  6 +-
 AMDiS/src/MeshStructure.cc                    | 12 ++--
 AMDiS/src/MeshStructure.h                     |  6 +-
 AMDiS/src/OpenMP.h                            |  4 +-
 AMDiS/src/RefinementManager3d.cc              |  6 +-
 AMDiS/src/est/ResidualEstimator.cc            |  2 +-
 AMDiS/src/io/MacroReader.cc                   |  4 +-
 AMDiS/src/parallel/DofComm.cc                 |  2 +-
 AMDiS/src/parallel/ElementObjectDatabase.cc   |  2 +-
 AMDiS/src/parallel/MatrixNnzStructure.cc      |  2 +-
 AMDiS/src/parallel/MeshDistributor.cc         | 62 +++++++++----------
 AMDiS/src/parallel/MeshManipulation.cc        |  8 +--
 AMDiS/src/parallel/PetscHelper.cc             |  4 +-
 AMDiS/src/parallel/PetscSolverFeti.cc         |  8 +--
 .../parallel/PetscSolverGlobalBlockMatrix.cc  |  4 +-
 AMDiS/src/parallel/PetscSolverGlobalMatrix.cc | 10 +--
 AMDiS/src/parallel/StdMpi.h                   |  2 +-
 AMDiS/src/parallel/ZoltanPartitioner.cc       |  2 +-
 AMDiS/src/solver/LinearSolverInterface.h      |  2 +-
 28 files changed, 84 insertions(+), 111 deletions(-)

diff --git a/AMDiS/cmake/CMakeLists.txt b/AMDiS/cmake/CMakeLists.txt
index 606abc0c..21b5ec2a 100644
--- a/AMDiS/cmake/CMakeLists.txt
+++ b/AMDiS/cmake/CMakeLists.txt
@@ -19,11 +19,6 @@ endif()
 #TODO: use the cmake build type
 SET(MTL_INCLUDE_DIR ${LIB_DIR}/mtl4/ CACHE PATH "mtl4 directory")
 
-# set global compile_definitions for all target, depending on build-type
-set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
-    $<$<CONFIG:Debug>:DEBUG=1>
-    $<$<CONFIG:Release>:DEBUG=0>)
-
 # find_package(Subversion QUIET)
 # if(Subversion_FOUND)
 #   Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} svn_info)
diff --git a/AMDiS/cmake3/AMDISConfig.cmake.in b/AMDiS/cmake3/AMDISConfig.cmake.in
index d007f410..0396fdf8 100644
--- a/AMDiS/cmake3/AMDISConfig.cmake.in
+++ b/AMDiS/cmake3/AMDISConfig.cmake.in
@@ -39,9 +39,7 @@ set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
 add_library(amdis_base INTERFACE)
 add_library(AMDiS ALIAS amdis_base)
 
-target_compile_definitions(amdis_base INTERFACE
-      $<$<CONFIG:Release>:DEBUG=0>
-      $<$<NOT:$<CONFIG:Release>>:DEBUG=1>)
+target_compile_definitions(amdis_base INTERFACE)
 
 if (AMDIS_NEED_CXX11)
     set(CMAKE_CXX_STANDARD 11)
diff --git a/AMDiS/cmake3/CMakeLists.txt b/AMDiS/cmake3/CMakeLists.txt
index 5bd59bd6..ccc960a6 100644
--- a/AMDiS/cmake3/CMakeLists.txt
+++ b/AMDiS/cmake3/CMakeLists.txt
@@ -204,10 +204,7 @@ add_library(amdis
     ${SOURCE_DIR}/time/RosenbrockAdaptInstationary.cc
     ${SOURCE_DIR}/time/RosenbrockMethod.cc
     ${SOURCE_DIR}/time/RosenbrockStationary.cc
-)
-
-add_library(amdis_debug INTERFACE)
-target_sources(amdis_debug INTERFACE
+# debugging files
     ${SOURCE_DIR}/Debug.cc
     ${SOURCE_DIR}/GlobalDOFNumbering.cc      # not used by any other class
     ${SOURCE_DIR}/GlobalElementNumbering.cc  # not used by any other class
@@ -244,8 +241,7 @@ if (MSVC)
         _CRT_SECURE_NO_WARNINGS)
 endif (MSVC)
 
-target_link_libraries(amdis AMDiS::base muparser
-    $<$<CONFIG:Debug>:amdis_debug>)
+target_link_libraries(amdis AMDiS::base muparser)
 
 # specify how to install this target:
 # -----------------------------------
diff --git a/AMDiS/cmake3/amdis_parallel.cmake b/AMDiS/cmake3/amdis_parallel.cmake
index c45993da..c5a4eb10 100644
--- a/AMDiS/cmake3/amdis_parallel.cmake
+++ b/AMDiS/cmake3/amdis_parallel.cmake
@@ -14,6 +14,7 @@ if (ENABLE_PARALLEL_DOMAIN)
         ${SOURCE_DIR}/parallel/MeshManipulation.cc
         ${SOURCE_DIR}/parallel/MeshPartitioner.cc
         ${SOURCE_DIR}/parallel/MpiHelper.cc
+        ${SOURCE_DIR}/parallel/ParallelDebug.cc
         ${SOURCE_DIR}/parallel/ParallelDofMapping.cc
         ${SOURCE_DIR}/parallel/ParallelProblemStat.cc
         ${SOURCE_DIR}/parallel/ParallelSolver.cc
@@ -22,10 +23,6 @@ if (ENABLE_PARALLEL_DOMAIN)
         ${SOURCE_DIR}/parallel/StdMpi.cc
     )
 
-    target_sources(amdis_debug INTERFACE
-        ${SOURCE_DIR}/parallel/ParallelDebug.cc
-    )
-
     target_compile_definitions(amdis_parallel INTERFACE
 	   HAVE_PARALLEL_DOMAIN_AMDIS=1)
 
diff --git a/AMDiS/src/BoundaryObject.cc b/AMDiS/src/BoundaryObject.cc
index ea8501ce..667095b7 100644
--- a/AMDiS/src/BoundaryObject.cc
+++ b/AMDiS/src/BoundaryObject.cc
@@ -73,7 +73,7 @@ namespace AMDiS {
       if (obj0.subObj == EDGE) {
 	int el0_v0 = obj0.el->getVertexOfEdge(obj0.ithObj, 0);
 	int el1_v0 = obj0.el->getVertexOfEdge(obj1.ithObj, 0);
-#if DEBUG != 0
+#ifndef NDEBUG
 	int el0_v1 = obj0.el->getVertexOfEdge(obj0.ithObj, 1);
 	int el1_v1 = obj0.el->getVertexOfEdge(obj1.ithObj, 1);
 #endif
diff --git a/AMDiS/src/Config.h b/AMDiS/src/Config.h
index c8f3e42e..bfa6428b 100644
--- a/AMDiS/src/Config.h
+++ b/AMDiS/src/Config.h
@@ -29,15 +29,6 @@
 #define AMDIS_VERSION  "AMDiS: Version 0.9.1"
 #endif
 
-#ifdef DEBUG
-#undef DEBUG
-#endif
-#ifdef NDEBUG
-#define DEBUG 0
-#else
-#define DEBUG 1
-#endif
-
 #include <boost/config.hpp>
 
 #define CACHE_LINE 16
diff --git a/AMDiS/src/FiniteElemSpace.cc b/AMDiS/src/FiniteElemSpace.cc
index d4cb79af..a47b1673 100644
--- a/AMDiS/src/FiniteElemSpace.cc
+++ b/AMDiS/src/FiniteElemSpace.cc
@@ -122,7 +122,7 @@ namespace AMDiS {
     feSpaces.resize(0);
   }
 
-#if DEBUG
+#ifndef NDEBUG
   FiniteElemSpace* FiniteElemSpace::provideFeSpace(Mesh *mesh)
   {
     FUNCNAME("FiniteElemSpace::provideFeSpace()");
diff --git a/AMDiS/src/FiniteElemSpace.h b/AMDiS/src/FiniteElemSpace.h
index 52cb52ec..5412ad15 100644
--- a/AMDiS/src/FiniteElemSpace.h
+++ b/AMDiS/src/FiniteElemSpace.h
@@ -53,7 +53,7 @@ namespace AMDiS {
 
     static void destroyFeSpaces();
 
-#if DEBUG
+#ifndef NDEBUG
     /// For debugging it may be useful to get some FE space for a given mesh at a
     /// position in code where it is not possible to access the FE space directly. The
     /// function assumes that there is only one FE space defined for the mesh.
diff --git a/AMDiS/src/Global.cc b/AMDiS/src/Global.cc
index 44acf4ed..bace7aee 100644
--- a/AMDiS/src/Global.cc
+++ b/AMDiS/src/Global.cc
@@ -187,7 +187,7 @@ namespace AMDiS {
     vsprintf(buff, format, arg);
     PRINT_LINE((*error), buff);
     va_end(arg);
-#if defined HAVE_PARALLEL_DOMAIN_AMDIS && !defined HAVE_PARALLEL_MTL4 && (DEBUG == 0 || defined NDEBUG)
+#if defined HAVE_PARALLEL_DOMAIN_AMDIS && !defined HAVE_PARALLEL_MTL4 && (defined NDEBUG)
   #if (PETSC_VERSION_MINOR >= 5)
     PetscError(MPI_COMM_WORLD, __LINE__, "Msg::print_error_exit", "Global.cc", 1, PETSC_ERROR_INITIAL, buff);
   #else
@@ -220,11 +220,9 @@ namespace AMDiS {
 				const char *file,
 				int line)
   {
-#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
-#if (DEBUG == 0)
+#if defined(HAVE_PARALLEL_DOMAIN_AMDIS) && defined(NDEBUG)
     if (outputMainRank && MPI::COMM_WORLD.Get_rank() != 0)
       return;
-#endif
 #endif
 
     static int old_line = -1;
@@ -256,11 +254,9 @@ namespace AMDiS {
 
   void Msg::print_warn(const char *format, ...)
   {
-#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
-#if (DEBUG == 0)
+#if defined(HAVE_PARALLEL_DOMAIN_AMDIS) && defined(NDEBUG)
     if (outputMainRank && MPI::COMM_WORLD.Get_rank() != 0)
       return;
-#endif
 #endif
     va_list arg;
     char buff[255];
diff --git a/AMDiS/src/Mesh.cc b/AMDiS/src/Mesh.cc
index de1b5870..2ad5905e 100644
--- a/AMDiS/src/Mesh.cc
+++ b/AMDiS/src/Mesh.cc
@@ -1161,7 +1161,7 @@ namespace AMDiS {
     in >> name;
     in.get();
 
-#if DEBUG != 0
+#ifndef NDEBUG
     int oldVal = dim;
 #endif
     SerUtil::deserialize(in, dim);
@@ -1178,7 +1178,7 @@ namespace AMDiS {
 
     SerUtil::deserialize(in, preserveCoarseDOFs);
 
-#if DEBUG != 0
+#ifndef NDEBUG
     oldVal = nDofEl;
 #endif
     SerUtil::deserialize(in, nDofEl);
@@ -1186,7 +1186,7 @@ namespace AMDiS {
 
     nDof.deserialize(in);
 
-#if DEBUG != 0
+#ifndef NDEBUG
     oldVal = nNodeEl;
 #endif
     SerUtil::deserialize(in, nNodeEl);
diff --git a/AMDiS/src/MeshStructure.cc b/AMDiS/src/MeshStructure.cc
index 601953ae..b23b4911 100644
--- a/AMDiS/src/MeshStructure.cc
+++ b/AMDiS/src/MeshStructure.cc
@@ -280,23 +280,23 @@ namespace AMDiS {
     bool cont = true;
     while (cont) {
       bool cont1;
-#if DEBUG != 0
+#ifndef NDEBUG
       bool cont2;
 #endif
       if (structure1->isLeafElement() == structure2->isLeafElement()) {
 	cont1 = structure1->nextElement(result);
-#if DEBUG != 0
+#ifndef NDEBUG
 	cont2 = structure2->nextElement();
 #endif
       } else {
 	if (structure1->isLeafElement()) {
 	  cont1 = structure1->nextElement();
-#if DEBUG != 0
+#ifndef NDEBUG
 	  cont2 = structure2->skipBranch(result);
 #endif
 	} else {
 	  cont1 = structure1->skipBranch(result);
-#if DEBUG != 0
+#ifndef NDEBUG
 	  cont2 = structure2->nextElement();
 #endif
 	}
@@ -385,7 +385,7 @@ namespace AMDiS {
       }
 
       if (!finished) {
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	int oldMeshIndex = mesh->getChangeIndex();
 #endif
 
@@ -394,7 +394,7 @@ namespace AMDiS {
 	else
 	  manager->refineMacroElement(mesh, macroElIndex);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	TEST_EXIT(oldMeshIndex != mesh->getChangeIndex())
 	  ("Mesh has not been changed by refinement procedure!\n");
 #endif
diff --git a/AMDiS/src/MeshStructure.h b/AMDiS/src/MeshStructure.h
index 24e04e0d..e0ed3c5e 100644
--- a/AMDiS/src/MeshStructure.h
+++ b/AMDiS/src/MeshStructure.h
@@ -32,10 +32,10 @@
 #include "Global.h"
 #include "BoundaryObject.h"
 
-#if (DEBUG != 0)
-#define WITH_ELINDEX true
+#ifndef NDEBUG
+  #define WITH_ELINDEX true
 #else
-#define WITH_ELINDEX false
+  #define WITH_ELINDEX false
 #endif
 
 namespace AMDiS {
diff --git a/AMDiS/src/OpenMP.h b/AMDiS/src/OpenMP.h
index 0c7fbf93..5bb186e3 100644
--- a/AMDiS/src/OpenMP.h
+++ b/AMDiS/src/OpenMP.h
@@ -47,7 +47,7 @@ namespace AMDiS {
 
     inline T& get()
     {
-#if (DEBUG != 0)
+#ifndef NDEBUG
       if (omp_get_thread_num() >= data.size()) {
 	std::cout << "Error in ThreadPrivate::get()!\n";
 	exit(0);
@@ -58,7 +58,7 @@ namespace AMDiS {
 
     inline void set(T& val)
     {
-#if (DEBUG != 0)
+#ifndef NDEBUG
       if (omp_get_thread_num() >= data.size()) {
 	std::cout << "Error in ThreadPrivate::set()!\n";
 	exit(0);
diff --git a/AMDiS/src/RefinementManager3d.cc b/AMDiS/src/RefinementManager3d.cc
index 26daa484..81ed5a98 100644
--- a/AMDiS/src/RefinementManager3d.cc
+++ b/AMDiS/src/RefinementManager3d.cc
@@ -422,7 +422,7 @@ namespace AMDiS {
       return true;
 
     int oppVertex = (*elInfo)->getOppVertex(localNeighbour);
-#if DEBUG
+#ifndef NDEBUG
     int testIndex = (*elInfo)->getNeighbour(localNeighbour)->getIndex();
 #endif
     ElInfo *neighInfo = stack->traverseNeighbour3d((*elInfo), localNeighbour);
@@ -573,7 +573,7 @@ namespace AMDiS {
 	if (neighInfo->getNeighbour(i)) {
 	  oppVertex = neighInfo->getOppVertex(i);
 
-#if DEBUG
+#ifndef NDEBUG
 	  int testIndex = neighInfo->getNeighbour(i)->getIndex();
 #endif
 
@@ -607,7 +607,7 @@ namespace AMDiS {
 	("While looping back domains boundary was reached or i == 0\n");
       oppVertex = refineList.getOppVertex(i--, 0);
 
-#if DEBUG
+#ifndef NDEBUG
       int testIndex = neighInfo->getNeighbour(oppVertex)->getIndex();
 #endif
       neighInfo = stack->traverseNeighbour3d(neighInfo, oppVertex);
diff --git a/AMDiS/src/est/ResidualEstimator.cc b/AMDiS/src/est/ResidualEstimator.cc
index 22e0c155..d4fb4ec7 100644
--- a/AMDiS/src/est/ResidualEstimator.cc
+++ b/AMDiS/src/est/ResidualEstimator.cc
@@ -194,7 +194,7 @@ namespace AMDiS {
     Parallel::InteriorBoundary &intBoundary =
       Parallel::MeshDistributor::globalMeshDistributor->getIntBoundary(0);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     // Make sure interior boundary is correct
     Parallel::ParallelDebug::testInteriorBoundary(*(Parallel::MeshDistributor::globalMeshDistributor));
 #endif
diff --git a/AMDiS/src/io/MacroReader.cc b/AMDiS/src/io/MacroReader.cc
index 35298834..996370f6 100644
--- a/AMDiS/src/io/MacroReader.cc
+++ b/AMDiS/src/io/MacroReader.cc
@@ -228,7 +228,7 @@ namespace AMDiS { namespace io {
 	  }
 
 	  for (int j = 0; j < dim; j++) {
-#ifdef DEBUG
+#ifndef NDEBUG
 	  {
 		  unsigned initData(melVertex[el1][verticesEl1[j]]);
 		  unsigned oldData((*associated)[melVertex[el1][verticesEl1[j]]]);
@@ -272,7 +272,7 @@ namespace AMDiS { namespace io {
 	}
       }
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
       std::map<BoundaryType, VertexVector*>::iterator assoc;
       std::map<BoundaryType, VertexVector*>::iterator assocEnd =
 	mesh->periodicAssociations.end();
diff --git a/AMDiS/src/parallel/DofComm.cc b/AMDiS/src/parallel/DofComm.cc
index 6abc9be8..f2caf888 100644
--- a/AMDiS/src/parallel/DofComm.cc
+++ b/AMDiS/src/parallel/DofComm.cc
@@ -54,7 +54,7 @@ namespace AMDiS { namespace Parallel {
     createContainer(mesh, boundary, boundary.getOwn(), sendDofs);
     createContainer(mesh, boundary, boundary.getOther(), recvDofs);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     {
       std::set<DegreeOfFreedom> sds;
       for (DofComm::Iterator it(sendDofs, feSpaces[0]);
diff --git a/AMDiS/src/parallel/ElementObjectDatabase.cc b/AMDiS/src/parallel/ElementObjectDatabase.cc
index 1c538c86..622f21d8 100644
--- a/AMDiS/src/parallel/ElementObjectDatabase.cc
+++ b/AMDiS/src/parallel/ElementObjectDatabase.cc
@@ -452,7 +452,7 @@ namespace AMDiS { namespace Parallel {
     // === in a symmetric way, i.e., if A -> B for a specific boundary type,    ===
     // === there must be a mapping B -> A with the same boundary type.          ===
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     for (PerBoundMap<DegreeOfFreedom>::iterator it = periodicVertices.begin();
 	 it != periodicVertices.end(); ++it) {
       pair<DegreeOfFreedom, DegreeOfFreedom> testVertex =
diff --git a/AMDiS/src/parallel/MatrixNnzStructure.cc b/AMDiS/src/parallel/MatrixNnzStructure.cc
index 845b62d2..497e26ae 100644
--- a/AMDiS/src/parallel/MatrixNnzStructure.cc
+++ b/AMDiS/src/parallel/MatrixNnzStructure.cc
@@ -334,7 +334,7 @@ namespace AMDiS { namespace Parallel {
 	onnz[i] = std::min(onnz[i], nOverallCols - nRankCols);
     }
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     int nMax = 0;
     int nSum = 0;
     for (int i = 0; i < nRankRows; i++) {
diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc
index 2afb73e3..4d153aca 100644
--- a/AMDiS/src/parallel/MeshDistributor.cc
+++ b/AMDiS/src/parallel/MeshDistributor.cc
@@ -29,8 +29,8 @@
 
 #include "parallel/MeshDistributor.h"
 #include "parallel/MeshManipulation.h"
-#if (DEBUG != 0)
-#include "parallel/ParallelDebug.h"
+#ifndef NDEBUG
+  #include "parallel/ParallelDebug.h"
 #endif
 #include "parallel/StdMpi.h"
 #include "parallel/MeshPartitioner.h"
@@ -63,8 +63,8 @@
 #include "ProblemStat.h"
 #include "ProblemInstat.h"
 #include "RefinementManager3d.h"
-#if (DEBUG != 0)
-#include "Debug.h"
+#ifndef NDEBUG
+  #include "Debug.h"
 #endif
 #include "Timer.h"
 #include "io/MacroReader.h"
@@ -264,7 +264,7 @@ namespace AMDiS { namespace Parallel {
     // already refined in some way.
     testForMacroMesh();
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     // Check whether meshes come from the same macro mesh. The way is to compare
     // the node coords of each macro element in the meshes.
     debug::ElementIdxToCoords macroCoords;
@@ -297,7 +297,7 @@ namespace AMDiS { namespace Parallel {
 
       elObjDb.setData(partitionMap, levelData);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
       TEST_EXIT_DBG(dofMaps.size())("No DOF mapping defined!\n");
       ParallelDebug::writeDebugFile(feSpaces[feSpaces.size() - 1],
 				    *(dofMaps[0]),
@@ -313,7 +313,7 @@ namespace AMDiS { namespace Parallel {
     createInitialPartitioning();
 
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     std::vector<debug::ElementIdxToDofs> elMap(meshes.size());
     for (size_t i = 0; i < meshes.size(); i++) {
       debug::createSortedDofs(meshes[i], elMap[i]);
@@ -407,7 +407,7 @@ namespace AMDiS { namespace Parallel {
 
     // === If in debug mode, make some tests. ===
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("AMDiS runs in debug mode, so make some test ...\n");
 
     ParallelDebug::testAllElements(*this);
@@ -424,7 +424,7 @@ namespace AMDiS { namespace Parallel {
     // Remove periodic boundary conditions in sequential problem definition.
     removePeriodicBoundaryConditions();
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     ParallelDebug::testPeriodicBoundary(*this);
 #endif
 
@@ -471,7 +471,7 @@ namespace AMDiS { namespace Parallel {
 	}
 	updateDofRelatedStruct(meshes[i]);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
       ParallelDebug::testPeriodicBoundary(*this);
 #endif
       }
@@ -946,7 +946,7 @@ namespace AMDiS { namespace Parallel {
 	      pair<Element*, int> edge1 =
 		make_pair(elObjDb.getElementPtr(*elIt, meshes[i]), edgeNoInEl[*elIt]);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	      DofEdge dofEdge0 = edge0.first->getEdge(edge0.second);
 	      DofEdge dofEdge1 = edge1.first->getEdge(edge1.second);
 
@@ -1226,7 +1226,7 @@ namespace AMDiS { namespace Parallel {
     vector<int> meshAllValues(meshes.size(), 0);
 
     for (size_t i = 0; i < meshes.size(); i++) {
-#if (DEBUG != 0)
+#ifndef NDEBUG
       MSG("mesh[%d] change index = %d, stored last index = %d.\n",
 	  i, meshes[i]->getChangeIndex(), lastMeshChangeIndexs[meshes[i]]);
 #endif
@@ -1280,7 +1280,7 @@ namespace AMDiS { namespace Parallel {
 	  bool meshChanged = false;
 
 	// === Check the boundaries and adapt mesh if necessary. ===
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	  MSG("Run checkAndAdaptBoundary for mesh[%d]...\n", i);
 #endif
 
@@ -1325,7 +1325,7 @@ namespace AMDiS { namespace Parallel {
 
     updateLocalGlobalNumbering();
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     debug::writeMesh(feSpaces[0], -1, debugOutputDir + "mesh");
     ParallelDebug::testPeriodicBoundary(*this);
 #endif
@@ -1337,7 +1337,7 @@ namespace AMDiS { namespace Parallel {
 
 
     if (repartitioningFailed > 0) {
-#if (DEBUG != 0)
+#ifndef NDEBUG
       MSG("Repartitioning not tried because it has failed in the past!\n");
 #endif
 
@@ -1463,7 +1463,7 @@ namespace AMDiS { namespace Parallel {
 	MeshStructure elCode;
 	elCode.init(boundIt->rankObj, elObjDb.getElementPtr(boundIt->rankObj.elIndex, mesh));
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	ParallelDebug::followBoundary(mesh, *boundIt, elCode);
 #endif
 
@@ -1581,7 +1581,7 @@ namespace AMDiS { namespace Parallel {
     } else {
       mpiComm.Bcast(&repartitioning, 1, MPI_INT, 0);
     }
-#if (DEBUG != 0)
+#ifndef NDEBUG
     if (repartitioning == 0) {
       MSG("imbalanceFactor = %f < %f = imbalanceRepartitionBound\n", imbalanceFactor, imbalanceRepartitionBound);
     }
@@ -1633,7 +1633,7 @@ namespace AMDiS { namespace Parallel {
 
     Timer t;
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     for (size_t i = 0; i < meshes.size(); i++)
       ParallelDebug::testDoubleDofs(meshes[i]);
     int writePartMesh = 1;
@@ -1709,7 +1709,7 @@ namespace AMDiS { namespace Parallel {
     updateLocalGlobalNumbering();
 
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("AMDiS runs in debug mode, so make some test ...\n");
 
     ParallelDebug::writePartitioningFile(debugOutputDir + "partitioning",
@@ -1734,7 +1734,7 @@ namespace AMDiS { namespace Parallel {
   {
     FUNCNAME("MeshDistributor::quickRepartition()");
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("... Run quickRepartition ...\n");
 #endif
 
@@ -1954,7 +1954,7 @@ namespace AMDiS { namespace Parallel {
   {
     FUNCNAME("MeshDistributor::fullRepartition()");
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("... Run fullRepartition ...\n");
 #endif
 
@@ -1966,7 +1966,7 @@ namespace AMDiS { namespace Parallel {
 
     MPI::Intracomm &mpiComm = MPI::COMM_WORLD;
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     int nOldLeaves = mesh->getNumberOfLeaves();
     mpi::globalAdd(mpiComm, nOldLeaves);
 #endif
@@ -2190,7 +2190,7 @@ namespace AMDiS { namespace Parallel {
 					      interchangeVectors[i],
 					      domainMacroValues[macroId][j++]);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	MeshStructure code;
 	code.init(mesh, macroId);
 	TEST_EXIT(code.getCode() == domainMacroCodes[macroId].getCode())
@@ -2224,7 +2224,7 @@ namespace AMDiS { namespace Parallel {
     }
     updateDofRelatedStruct(mesh);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     int nNewLeaves = mesh->getNumberOfLeaves();
     mpi::globalAdd(mpiComm, nNewLeaves);
 
@@ -2242,7 +2242,7 @@ namespace AMDiS { namespace Parallel {
       elObjDb.create(partitionMap, levelData);
     elObjDb.updateRankData();
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     if (mpiRank == 0)
       ParallelDebug::writePeriodicElObjInfo(*this, debugOutputDir);
 #endif
@@ -2260,7 +2260,7 @@ namespace AMDiS { namespace Parallel {
 
     intBoundary.create(levelData, elObjDb);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     for (int level = 0; level < levelData.getNumberOfLevels(); level++)
       ParallelDebug::printBoundaryInfo(intBoundary[level]);
 #endif
@@ -2383,7 +2383,7 @@ namespace AMDiS { namespace Parallel {
 
     mesh->dofCompress();
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     debug::ElementIdxToDofs elMap;
     debug::createSortedDofs(mesh, elMap);
 #endif
@@ -2400,7 +2400,7 @@ namespace AMDiS { namespace Parallel {
     lastMeshChangeIndexs[mesh] = mesh->getChangeIndex();
 
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     static int fileNumber(0);		//improvised counter for adapt Iteration
     stringstream ss;
     ss << debugOutputDir << "elementMaps." << fileNumber ;
@@ -2434,14 +2434,14 @@ namespace AMDiS { namespace Parallel {
     FUNCNAME("MeshDistributor::updateLocalGlobalNumbering()");
 
     Timer t;
-#if (DEBUG != 0)
+#ifndef NDEBUG
     bool printInfo = true;
     Parameters::get("parallel->print dofmap info", printInfo);
 #endif
 
     for (size_t i = 0; i < dofMaps.size(); i++) {
       dofMaps[i]->update();
-#if (DEBUG != 0)
+#ifndef NDEBUG
       if (printInfo)
 	dofMaps[i]->printInfo();
 #endif
@@ -2456,7 +2456,7 @@ namespace AMDiS { namespace Parallel {
 	dofMaps[i]->updateMatIndex();
     }
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     if (printInfo) {
       int test = 0;
       Parameters::get("parallel->remove periodic boundary", test);
diff --git a/AMDiS/src/parallel/MeshManipulation.cc b/AMDiS/src/parallel/MeshManipulation.cc
index 49fe0e69..9b59b18e 100644
--- a/AMDiS/src/parallel/MeshManipulation.cc
+++ b/AMDiS/src/parallel/MeshManipulation.cc
@@ -98,7 +98,7 @@ namespace AMDiS { namespace Parallel {
       elInfo = stack.traverseNext(elInfo);
     }
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     DOFVector<WorldVector<double> > coords(feSpace, "dofCorrds");
     feSpace->getMesh()->getDofIndexCoords(coords);
 #endif
@@ -173,7 +173,7 @@ namespace AMDiS { namespace Parallel {
 	    el1->getAllDofs(feSpace, b1, dofs1, true, &dofGeoIndex1);
 
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	    if (feSpaces.size())
 	      debug::testDofsByCoords(coords, dofs0, dofs1);
 	    else
@@ -222,7 +222,7 @@ namespace AMDiS { namespace Parallel {
 	    el0->getAllDofs(feSpace, b0, dofs0, true, &dofGeoIndex0);
 	    el1->getAllDofs(feSpace, b1, dofs1, true, &dofGeoIndex1);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	    if (feSpaces.size())
 	      debug::testDofsByCoords(coords, dofs0, dofs1);
 	    else
@@ -327,7 +327,7 @@ namespace AMDiS { namespace Parallel {
       // Create traverse stack and traverse within the mesh until the element,
       // which should be fitted to the mesh structure code, is reached.
       TraverseStack stack;
-#if (DEBUG != 0)
+#ifndef NDEBUG
       ElInfo *elInfo =
 	stack.traverseFirstOneMacro(mesh, boundEl.elIndex, -1, traverseFlag);
 
diff --git a/AMDiS/src/parallel/PetscHelper.cc b/AMDiS/src/parallel/PetscHelper.cc
index 16e7baf1..873bef5a 100644
--- a/AMDiS/src/parallel/PetscHelper.cc
+++ b/AMDiS/src/parallel/PetscHelper.cc
@@ -177,7 +177,7 @@ namespace AMDiS
 	int firstRow = firstRow0 + firstRow1;
 
 	int mpiSize = MPI::COMM_WORLD.Get_size();
-#if (DEBUG != 0)
+#ifndef NDEBUG
 	int mpiRank = MPI::COMM_WORLD.Get_rank();
 #endif
 	vector<int> allFirstRow0(mpiSize + 1, 0);
@@ -303,7 +303,7 @@ namespace AMDiS
 	  PCFactorSetMatSolverPackage(pc, matSolverPackage);
 	PCSetFromOptions(pc);
 
-#if DEBUG != 0
+#ifndef NDEBUG
     MSG("PetscOptionsView:\n");
     PetscViewer viewer;
     PetscViewerCreate(PETSC_COMM_WORLD, &viewer);
diff --git a/AMDiS/src/parallel/PetscSolverFeti.cc b/AMDiS/src/parallel/PetscSolverFeti.cc
index 626441b1..c277617f 100644
--- a/AMDiS/src/parallel/PetscSolverFeti.cc
+++ b/AMDiS/src/parallel/PetscSolverFeti.cc
@@ -147,7 +147,7 @@ namespace AMDiS { namespace Parallel {
   {
     FUNCNAME("PetscSolverFeti::initialize()");
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("Init FETI-DP on mesh level %d\n", meshLevel);
 #endif
 
@@ -751,7 +751,7 @@ namespace AMDiS { namespace Parallel {
     MatAssemblyEnd(mat_lagrange, MAT_FINAL_ASSEMBLY);
 
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     {
       int nZeroRows = PetscSolverFetiDebug::testZeroRows(mat_lagrange);
       int m,n;
@@ -1833,7 +1833,7 @@ namespace AMDiS { namespace Parallel {
     Vec nullSpaceBasis;
     VecCreateNest(domainComm, 2, PETSC_NULL, vecArray, &nullSpaceBasis);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     PetscSolverFetiDebug::writeNullSpace(*this, nullSpaceBasis);
 #endif
 
@@ -1870,7 +1870,7 @@ namespace AMDiS { namespace Parallel {
       return;
     }
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     PetscInt nRow, nCol;
     MatGetLocalSize(subdomain->getMatInterior(), &nRow, &nCol);
     mpi::globalAdd(nRow);
diff --git a/AMDiS/src/parallel/PetscSolverGlobalBlockMatrix.cc b/AMDiS/src/parallel/PetscSolverGlobalBlockMatrix.cc
index e348a7e8..aea0fb81 100644
--- a/AMDiS/src/parallel/PetscSolverGlobalBlockMatrix.cc
+++ b/AMDiS/src/parallel/PetscSolverGlobalBlockMatrix.cc
@@ -44,7 +44,7 @@ namespace AMDiS { namespace Parallel {
     int nRankRows = (*interiorMap)[feSpace].nRankDofs;
     int nOverallRows = (*interiorMap)[feSpace].nOverallDofs;
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("Fill petsc matrix 1 needed %.5f seconds\n", MPI::Wtime() - wtime);
 #endif
 
@@ -97,7 +97,7 @@ namespace AMDiS { namespace Parallel {
     MatCreateNest(domainComm, nBlocks, PETSC_NULL, nBlocks, PETSC_NULL,
 		  &(nestMat[0]), &getMatInterior());
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("Fill petsc matrix 2 needed %.5f seconds\n", MPI::Wtime() - wtime);
 #endif
 
diff --git a/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc b/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
index a8e5982e..286cc91e 100644
--- a/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
+++ b/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
@@ -87,7 +87,7 @@ namespace AMDiS { namespace Parallel {
     }
     Parameters::get("parallel->print matrix info", printMatInfo);
 
-#if DEBUG != 0
+#ifndef NDEBUG
     bool printOptionsInfo = false;
     Parameters::get("parallel->debug->print options info", printOptionsInfo);
     if (printOptionsInfo) {
@@ -110,7 +110,7 @@ namespace AMDiS { namespace Parallel {
     TEST_EXIT_DBG(interiorMap)("No parallel mapping object defined!\n");
     TEST_EXIT_DBG(seqMat)("No DOF matrix defined!\n");
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     Timer t;
 #endif
 
@@ -123,7 +123,7 @@ namespace AMDiS { namespace Parallel {
 
     // === Create PETSc vector (solution and a temporary vector). ===
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("Fill petsc matrix 1 needed %.5f seconds\n", t.elapsed());
     t.reset();
 #endif
@@ -136,7 +136,7 @@ namespace AMDiS { namespace Parallel {
 	if ((*seqMat)[i][j])
 	  setDofMatrix((*seqMat)[i][j], i, j);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("Fill petsc matrix 2 needed %.5f seconds\n", t.elapsed());
     t.reset();
 #endif
@@ -162,7 +162,7 @@ namespace AMDiS { namespace Parallel {
     initPreconditioner(*seqMat, mat[0][0]);
 
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     MSG("Fill petsc matrix 3 needed %.5f seconds\n", t.elapsed());
 #endif
 
diff --git a/AMDiS/src/parallel/StdMpi.h b/AMDiS/src/parallel/StdMpi.h
index 0c8819ca..53433146 100644
--- a/AMDiS/src/parallel/StdMpi.h
+++ b/AMDiS/src/parallel/StdMpi.h
@@ -532,7 +532,7 @@ namespace AMDiS { namespace Parallel {
 
       MPI::Request::Waitall(requestCounter, request);
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
       bool testall = MPI::Request::Testall(requestCounter, request);
       TEST_EXIT(testall)("Should not happen!\n");
 #endif
diff --git a/AMDiS/src/parallel/ZoltanPartitioner.cc b/AMDiS/src/parallel/ZoltanPartitioner.cc
index 0deb14b0..5d4ac072 100644
--- a/AMDiS/src/parallel/ZoltanPartitioner.cc
+++ b/AMDiS/src/parallel/ZoltanPartitioner.cc
@@ -140,7 +140,7 @@ namespace AMDiS { namespace Parallel {
 
     zoltan.Set_Param("OBJ_WEIGHT_DIM", "1");
 
-#if (DEBUG != 0)
+#ifndef NDEBUG
     zoltan.Set_Param("DEBUG_LEVEL", "1");
 #else
     zoltan.Set_Param("DEBUG_LEVEL", "0");
diff --git a/AMDiS/src/solver/LinearSolverInterface.h b/AMDiS/src/solver/LinearSolverInterface.h
index 61d79fca..ea69db6c 100644
--- a/AMDiS/src/solver/LinearSolverInterface.h
+++ b/AMDiS/src/solver/LinearSolverInterface.h
@@ -127,7 +127,7 @@ namespace AMDiS {
 	  MSG("Residual norm: ||b-Ax|| = %e\n", residual);
 	}
 
-#if DEBUG != 0
+#ifndef NDEBUG
 	if (getIterations() > 0) {
 	  MSG("Nr. of iterations needed = %d\n", getIterations());
 	}
-- 
GitLab