From 884ca79b294fe78fa463494ff6a625c47bbda82f Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Tue, 18 Aug 2009 15:41:02 +0000
Subject: [PATCH] Speedup assembling.

---
 AMDiS/libtool             | 64 +++++++++++++++++-----------------
 AMDiS/src/BasisFunction.h | 11 ++++++
 AMDiS/src/DOFMatrix.cc    | 72 +++++++++++++++++++--------------------
 AMDiS/src/DOFMatrix.h     | 16 ++++-----
 AMDiS/src/ProblemVec.cc   | 20 -----------
 5 files changed, 85 insertions(+), 98 deletions(-)

diff --git a/AMDiS/libtool b/AMDiS/libtool
index 0034ec22..41ace2e6 100755
--- a/AMDiS/libtool
+++ b/AMDiS/libtool
@@ -30,10 +30,10 @@
 # the same distribution terms that you use for the rest of that program.
 
 # A sed program that does not truncate output.
-SED="/usr/bin/sed"
+SED="/bin/sed"
 
 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="/usr/bin/sed -e 1s/^X//"
+Xsed="/bin/sed -e 1s/^X//"
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
@@ -44,7 +44,7 @@ available_tags=" CXX F77"
 
 # ### BEGIN LIBTOOL CONFIG
 
-# Libtool was configured on host p2d020:
+# Libtool was configured on host NWRW15:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
@@ -66,12 +66,12 @@ fast_install=yes
 
 # The host system.
 host_alias=
-host=x86_64-unknown-linux-gnu
+host=i686-pc-linux-gnu
 host_os=linux-gnu
 
 # The build system.
 build_alias=
-build=x86_64-unknown-linux-gnu
+build=i686-pc-linux-gnu
 build_os=linux-gnu
 
 # An echo program that does not interpret backslashes.
@@ -82,13 +82,13 @@ AR="ar"
 AR_FLAGS="cru"
 
 # A C compiler.
-LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc"
+LTCC="gcc"
 
 # LTCC compiler flags.
 LTCFLAGS="-g -O2"
 
 # A language-specific compiler.
-CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc"
+CC="gcc"
 
 # Is the compiler the GNU C compiler?
 with_gcc=yes
@@ -97,7 +97,7 @@ with_gcc=yes
 EGREP="grep -E"
 
 # The linker used to build libraries.
-LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64"
+LD="/usr/bin/ld"
 
 # Whether we need hard or soft links.
 LN_S="ln -s"
@@ -171,7 +171,7 @@ dlopen_self=unknown
 dlopen_self_static=unknown
 
 # Compiler flag to prevent dynamic linking.
-link_static_flag=""
+link_static_flag="-static"
 
 # Compiler flag to turn off builtin functions.
 no_builtin_flag=" -fno-builtin"
@@ -325,10 +325,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM
 link_all_deplibs=unknown
 
 # Compile-time system search path for libraries
-sys_lib_search_path_spec=" /usr/lib64/gcc/x86_64-suse-linux/4.1.2/ /usr/lib/gcc/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/ /lib/x86_64-suse-linux/4.1.2/ /lib/../lib64/ /usr/lib/x86_64-suse-linux/4.1.2/ /usr/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../ /lib/ /usr/lib/"
+sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/"
 
 # Run-time system search path for libraries
-sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso "
+sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib "
 
 # Fix the shell variable $srcfile for the compiler.
 fix_srcfile_path=""
@@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
 # End:
 # ### BEGIN LIBTOOL TAG CONFIG: CXX
 
-# Libtool was configured on host p2d020:
+# Libtool was configured on host NWRW15:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
@@ -6782,12 +6782,12 @@ fast_install=yes
 
 # The host system.
 host_alias=
-host=x86_64-unknown-linux-gnu
+host=i686-pc-linux-gnu
 host_os=linux-gnu
 
 # The build system.
 build_alias=
-build=x86_64-unknown-linux-gnu
+build=i686-pc-linux-gnu
 build_os=linux-gnu
 
 # An echo program that does not interpret backslashes.
@@ -6798,13 +6798,13 @@ AR="ar"
 AR_FLAGS="cru"
 
 # A C compiler.
-LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc"
+LTCC="gcc"
 
 # LTCC compiler flags.
 LTCFLAGS="-g -O2"
 
 # A language-specific compiler.
-CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpiCC"
+CC="g++"
 
 # Is the compiler the GNU C compiler?
 with_gcc=yes
@@ -6813,7 +6813,7 @@ with_gcc=yes
 EGREP="grep -E"
 
 # The linker used to build libraries.
-LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64"
+LD="/usr/bin/ld"
 
 # Whether we need hard or soft links.
 LN_S="ln -s"
@@ -6887,7 +6887,7 @@ dlopen_self=unknown
 dlopen_self_static=unknown
 
 # Compiler flag to prevent dynamic linking.
-link_static_flag=""
+link_static_flag="-static"
 
 # Compiler flag to turn off builtin functions.
 no_builtin_flag=" -fno-builtin"
@@ -6942,11 +6942,11 @@ striplib="strip --strip-unneeded"
 
 # Dependencies to place before the objects being linked to create a
 # shared library.
-predep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbeginS.o"
+predep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o"
 
 # Dependencies to place after the objects being linked to create a
 # shared library.
-postdep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o"
+postdep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o"
 
 # Dependencies to place before the objects being linked to create a
 # shared library.
@@ -6954,11 +6954,11 @@ predeps=""
 
 # Dependencies to place after the objects being linked to create a
 # shared library.
-postdeps="-lmpi_cxx -lmpi -lopen-rte -lopen-pal -libverbs -lrt -lnuma -ldl -lnsl -lutil -ldl -lstdc++ -lm -lgcc_s -lpthread -lc -lgcc_s"
+postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s"
 
 # The library search path used internally by the compiler when linking
 # a shared library.
-compiler_lib_search_path="-L/usr/lib64 -L/licsoft/libraries/openmpi/1.2.6/64bit/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.."
+compiler_lib_search_path="-L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.."
 
 # Method to check whether dependent libraries are shared objects.
 deplibs_check_method="pass_all"
@@ -7038,10 +7038,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM
 link_all_deplibs=unknown
 
 # Compile-time system search path for libraries
-sys_lib_search_path_spec=" /usr/lib64/gcc/x86_64-suse-linux/4.1.2/ /usr/lib/gcc/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/ /lib/x86_64-suse-linux/4.1.2/ /lib/../lib64/ /usr/lib/x86_64-suse-linux/4.1.2/ /usr/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../ /lib/ /usr/lib/"
+sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/"
 
 # Run-time system search path for libraries
-sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso "
+sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib "
 
 # Fix the shell variable $srcfile for the compiler.
 fix_srcfile_path=""
@@ -7065,7 +7065,7 @@ include_expsyms=""
 
 # ### BEGIN LIBTOOL TAG CONFIG: F77
 
-# Libtool was configured on host p2d020:
+# Libtool was configured on host NWRW15:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
@@ -7087,12 +7087,12 @@ fast_install=yes
 
 # The host system.
 host_alias=
-host=x86_64-unknown-linux-gnu
+host=i686-pc-linux-gnu
 host_os=linux-gnu
 
 # The build system.
 build_alias=
-build=x86_64-unknown-linux-gnu
+build=i686-pc-linux-gnu
 build_os=linux-gnu
 
 # An echo program that does not interpret backslashes.
@@ -7103,7 +7103,7 @@ AR="ar"
 AR_FLAGS="cru"
 
 # A C compiler.
-LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc"
+LTCC="gcc"
 
 # LTCC compiler flags.
 LTCFLAGS="-g -O2"
@@ -7112,13 +7112,13 @@ LTCFLAGS="-g -O2"
 CC="g77"
 
 # Is the compiler the GNU C compiler?
-with_gcc=
+with_gcc=yes
 
 # An ERE matcher.
 EGREP="grep -E"
 
 # The linker used to build libraries.
-LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64"
+LD="/usr/bin/ld"
 
 # Whether we need hard or soft links.
 LN_S="ln -s"
@@ -7346,10 +7346,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM
 link_all_deplibs=unknown
 
 # Compile-time system search path for libraries
-sys_lib_search_path_spec=" /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/ /usr/lib/gcc/x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../ /lib/x86_64-suse-linux/3.3.5/ /lib/ /usr/lib/x86_64-suse-linux/3.3.5/ /usr/lib/"
+sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../ /lib/i386-redhat-linux/3.4.6/ /lib/ /usr/lib/i386-redhat-linux/3.4.6/ /usr/lib/"
 
 # Run-time system search path for libraries
-sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso "
+sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib "
 
 # Fix the shell variable $srcfile for the compiler.
 fix_srcfile_path=""
diff --git a/AMDiS/src/BasisFunction.h b/AMDiS/src/BasisFunction.h
index 51157157..798bafaf 100644
--- a/AMDiS/src/BasisFunction.h
+++ b/AMDiS/src/BasisFunction.h
@@ -285,6 +285,17 @@ namespace AMDiS {
       return NULL;
     }
 
+    inline void getLocalIndices(const Element *el,
+				const DOFAdmin *admin,
+				std::vector<DegreeOfFreedom> &indices) const
+    {
+      FUNCNAME("BasisFunction::getLocalIndices()");
+      
+      TEST_EXIT_DBG(indices.size() >= nBasFcts)("Index vector is too small!\n");
+
+      getLocalIndices(el, admin, &(indices[0]));
+    }
+
     /// Returns local dof indices of the element for the given fe space.
     virtual void getLocalIndicesVec(const Element *el,
 				    const DOFAdmin *admin,
diff --git a/AMDiS/src/DOFMatrix.cc b/AMDiS/src/DOFMatrix.cc
index c7e77d59..c7631f5e 100644
--- a/AMDiS/src/DOFMatrix.cc
+++ b/AMDiS/src/DOFMatrix.cc
@@ -167,66 +167,51 @@ namespace AMDiS {
     return *this;
   }
 
-  void DOFMatrix::addElementMatrix(double sign, 
-				   const ElementMatrix& elMat, 
+  void DOFMatrix::addElementMatrix(const ElementMatrix& elMat, 
 				   const BoundaryType *bound,
 				   ElInfo* rowElInfo,
-				   ElInfo* colElInfo,
-				   bool add)
+				   ElInfo* colElInfo)
   {
     FUNCNAME("DOFMatrix::addElementMatrix()");
 
     TEST_EXIT_DBG(inserter)("DOFMatrix is not in insertion mode");
-    inserter_type &ins= *inserter;
 
     // === Get indices mapping from local to global matrix indices. ===
 
-    rowFESpace->getBasisFcts()->getLocalIndicesVec(rowElInfo->getElement(),
-						   rowFESpace->getAdmin(),
-						   &rowIndices);
+    rowFESpace->getBasisFcts()->getLocalIndices(rowElInfo->getElement(),
+						rowFESpace->getAdmin(),
+						rowIndices);
     if (rowFESpace == colFESpace) {
-      colIndices = rowIndices;
+      *inserter << element_matrix(elMat, rowIndices, rowIndices);
     } else {
       if (colElInfo) {
-	colFESpace->getBasisFcts()->getLocalIndicesVec(colElInfo->getElement(),
-						       colFESpace->getAdmin(),
-						       &colIndices);
+	colFESpace->getBasisFcts()->getLocalIndices(colElInfo->getElement(),
+						    colFESpace->getAdmin(),
+						    colIndices);
       } else {
 	// If there is no colElInfo pointer, use rowElInfo the get the indices.
-	colFESpace->getBasisFcts()->getLocalIndicesVec(rowElInfo->getElement(),
-						       colFESpace->getAdmin(),
-						       &colIndices);
+	colFESpace->getBasisFcts()->getLocalIndices(rowElInfo->getElement(),
+						    colFESpace->getAdmin(),
+						    colIndices);
       }
-    }
 
-    // === Add element matrix to the global matrix using the indices mapping. ===
+      *inserter << element_matrix(elMat, rowIndices, colIndices);
+    }
 
-    for (int i = 0; i < nRow; i++)  {   // for all rows of element matrix
-      DegreeOfFreedom row = rowIndices[i];
 
+    for (int i = 0; i < nRow; i++)  {
       BoundaryCondition *condition = 
 	bound ? boundaryManager->getBoundaryCondition(bound[i]) : NULL;
 
       if (condition && condition->isDirichlet()) {
 	if (condition->applyBoundaryCondition()) {
 #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
-	  if (rankDofs[row]) 
-	    applyDBCs.insert(static_cast<int>(row));
+	  if (rankDofs[rowIndices[i]]) 
+	    applyDBCs.insert(static_cast<int>(rowIndices[i]));
 #else
-	  applyDBCs.insert(static_cast<int>(row));
+	  applyDBCs.insert(static_cast<int>(rowIndices[i]));
 #endif
 	}
-      } else {
-
-	for (int j = 0; j < nCol; j++) {  // for all columns
-	  DegreeOfFreedom col = colIndices[j];
-	  double entry = elMat[i][j];
-  
-	  if (add)
-	    ins[row][col] += sign * entry;
-	  else
-	    ins[row][col] = sign * entry;	
-	}   
       }
     }
   }
@@ -251,7 +236,10 @@ namespace AMDiS {
       if ((*it)->getNeedDualTraverse() == false)
 	(*it)->getElementMatrix(elInfo,	elementMatrix, *factorIt ? **factorIt : 1.0);
 
-    addElementMatrix(factor, elementMatrix, bound, elInfo, NULL);   
+    if (factor != 1.0)
+      elementMatrix *= factor;
+
+    addElementMatrix(elementMatrix, bound, elInfo, NULL);   
   }
 
   void DOFMatrix::assemble(double factor, ElInfo *elInfo, const BoundaryType *bound,
@@ -263,7 +251,11 @@ namespace AMDiS {
 
       set_to_zero(elementMatrix);
       op->getElementMatrix(elInfo, elementMatrix, factor);
-      addElementMatrix(factor, elementMatrix, bound, elInfo, NULL);
+
+      if (factor != 1.0)
+	elementMatrix *= factor;
+
+      addElementMatrix(elementMatrix, bound, elInfo, NULL);
   }
 
   void DOFMatrix::assemble(double factor, 
@@ -292,7 +284,10 @@ namespace AMDiS {
       }      
     }
 
-    addElementMatrix(factor, elementMatrix, bound, rowElInfo, colElInfo);       
+    if (factor != 1.0)
+      elementMatrix *= factor;
+
+    addElementMatrix(elementMatrix, bound, rowElInfo, colElInfo);       
   }
 
   void DOFMatrix::assemble2(double factor, 
@@ -327,7 +322,10 @@ namespace AMDiS {
       }      
     }
 
-    addElementMatrix(factor, elementMatrix, bound, mainElInfo, NULL);       
+    if (factor != 1.0)
+      elementMatrix *= factor;
+
+    addElementMatrix(elementMatrix, bound, mainElInfo, NULL);       
   }
 
   void DOFMatrix::finishAssembling()
diff --git a/AMDiS/src/DOFMatrix.h b/AMDiS/src/DOFMatrix.h
index 5ae24aa9..2d67a90d 100644
--- a/AMDiS/src/DOFMatrix.h
+++ b/AMDiS/src/DOFMatrix.h
@@ -55,7 +55,7 @@ namespace AMDiS {
     typedef mtl::compressed2D<value_type>       base_matrix_type;
 
     /// Type of inserter for the base matrix;
-    typedef mtl::matrix::inserter<base_matrix_type>  inserter_type;
+    typedef mtl::matrix::inserter<base_matrix_type, mtl::operations::update_plus<value_type> >  inserter_type;
 
   private:
     /// Symbolic constant for an unused matrix entry
@@ -227,12 +227,10 @@ namespace AMDiS {
 		   Operator *op = NULL);
 
     /// Adds an element matrix to \ref matrix
-    void addElementMatrix(double sign, 
-			  const ElementMatrix& elMat, 
+    void addElementMatrix(const ElementMatrix& elMat, 
 			  const BoundaryType *bound,
 			  ElInfo* rowElInfo,
-			  ElInfo* colElInfo,
-			  bool add = true);
+			  ElInfo* colElInfo);
 
     /* \brief
      * That function must be called after the matrix assembling has been finished. 
@@ -391,8 +389,8 @@ namespace AMDiS {
 
       if (num_rows(matrix) != 0)
 	nnzPerRow = int(double(matrix.nnz()) / num_rows(matrix) * 1.2); 
-      if (nnzPerRow < 5) 
-	nnzPerRow= 5;      
+      if (nnzPerRow < 20) 
+	nnzPerRow = 20;
     }
 
     /// Returns \ref nnzPerRow.
@@ -541,10 +539,10 @@ namespace AMDiS {
     int nCol;
 
     /// Maps local row indices of an element to global matrix indices.
-    Vector<DegreeOfFreedom> rowIndices;
+    std::vector<DegreeOfFreedom> rowIndices;
 
     /// Maps local col indices of an element to global matrix indices.
-    Vector<DegreeOfFreedom> colIndices;
+    std::vector<DegreeOfFreedom> colIndices;
 
     /* \brief
      * A set of row indices. When assembling the DOF matrix, all rows, that
diff --git a/AMDiS/src/ProblemVec.cc b/AMDiS/src/ProblemVec.cc
index a2984375..4ebe67e8 100644
--- a/AMDiS/src/ProblemVec.cc
+++ b/AMDiS/src/ProblemVec.cc
@@ -640,26 +640,6 @@ namespace AMDiS {
     if (useGetBound)
       assembleFlag |= Mesh::FILL_BOUND;
 
-#if 0
-    for (int i = 0; i < nComponents; i++) {
-
-      for (int j = 0; j < nComponents; j++) {
-	if ((*systemMatrix)[i][j]) {
-	  DOFMatrix*                   dof_matrix= (*systemMatrix)[i][j];
-	  DOFMatrix::base_matrix_type& base_matrix= dof_matrix->getBaseMatrix();
-
-	  dof_matrix->calculateNnz();
-
-	  // Correct dimensionality of matrix
-	  base_matrix.change_dim(componentSpaces[i]->getAdmin()->getUsedSize(), 
-				 componentSpaces[j]->getAdmin()->getUsedSize());
-
-	  set_to_zero(base_matrix);
-	}
-      }
-    }
-#endif
-
     traverseInfo.updateStatus();
 
     // Used to calculate the overall number of non zero entries.
-- 
GitLab