From d2cd87005cfbfc8bf7c01ee3fd395903d235d5eb Mon Sep 17 00:00:00 2001 From: Peter Gottschling <peter.gottschling@simunova.com> Date: Tue, 28 Apr 2009 13:25:06 +0000 Subject: [PATCH] =?UTF-8?q?Gr=C3=B6=C3=9Fter=20Merge=20in=20der=20Geschich?= =?UTF-8?q?te=20von=20AMDiS.=20Mit=20Thomas'=20Beteiligung.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AMDiS/Makefile.in | 1 + AMDiS/aclocal.m4 | 34 +- AMDiS/autogen.sh | 47 ++ AMDiS/bin/Makefile.am | 52 +- AMDiS/bin/Makefile.in | 204 +----- AMDiS/configure | 208 ++++-- AMDiS/libtool | 47 +- AMDiS/src/AMDiS.h | 10 +- AMDiS/src/AMDiS_fwd.h | 82 +++ AMDiS/src/AdaptStationary.h | 5 +- AMDiS/src/BFGS_Precond.cc | 68 -- AMDiS/src/BFGS_Precond.h | 168 ----- AMDiS/src/BasisFunction.h | 7 +- AMDiS/src/BiCGSolver.h | 101 --- AMDiS/src/BiCGSolver.hh | 193 ------ AMDiS/src/BiCGStab.h | 104 --- AMDiS/src/BiCGStab.hh | 239 ------- AMDiS/src/BiCGStab2.h | 103 --- AMDiS/src/BiCGStab2.hh | 228 ------- AMDiS/src/BiCGStab_M.hh | 191 ------ AMDiS/src/Boundary.h | 110 ++++ AMDiS/src/BoundaryCondition.h | 27 +- AMDiS/src/BoundaryManager.h | 2 +- AMDiS/src/BoxSmoother.h | 3 + AMDiS/src/CGSolver.h | 114 ---- AMDiS/src/CGSolver.hh | 132 ---- AMDiS/src/CreatorInterface.h | 4 + AMDiS/src/CreatorMap.cc | 178 +----- AMDiS/src/CreatorMap.h | 25 +- AMDiS/src/DOFIndexed.cc | 93 ++- AMDiS/src/DOFIndexed.h | 12 +- AMDiS/src/DOFMatrix.cc | 700 ++++----------------- AMDiS/src/DOFMatrix.h | 308 ++++----- AMDiS/src/DOFVector.cc | 2 +- AMDiS/src/DOFVector.h | 34 +- AMDiS/src/DOFVector.hh | 454 +++++++------ AMDiS/src/DataCollector.cc | 3 +- AMDiS/src/DiagonalPreconditioner.cc | 59 -- AMDiS/src/DiagonalPreconditioner.h | 133 ---- AMDiS/src/DirichletBC.cc | 2 +- AMDiS/src/DirichletBC.h | 8 +- AMDiS/src/DualTraverse.h | 2 +- AMDiS/src/Estimator.h | 11 +- AMDiS/src/GMResSolver.h | 164 ----- AMDiS/src/GMResSolver.hh | 189 ------ AMDiS/src/GMResSolver2.h | 163 ----- AMDiS/src/GMResSolver2.hh | 191 ------ AMDiS/src/GSSmoother.cc | 9 +- AMDiS/src/ILUPreconditioner.cc | 314 --------- AMDiS/src/ILUPreconditioner.h | 181 ------ AMDiS/src/ILUTPreconditioner.cc | 247 -------- AMDiS/src/ILUTPreconditioner.h | 137 ---- AMDiS/src/ITL_OEMSolver.h | 141 +++++ AMDiS/src/ITL_Preconditioner.h | 177 ++++++ AMDiS/src/ITL_Solver.h | 180 ++++++ AMDiS/src/InterpolRestrictMatrix.cc | 23 +- AMDiS/src/InterpolRestrictMatrix.h | 6 +- AMDiS/src/JacobiSmoother.cc | 6 + AMDiS/src/LeafData.cc | 5 +- AMDiS/src/MatVecMultiplier.cc | 11 +- AMDiS/src/MultiGridPreconWrapper.cc | 4 + AMDiS/src/MultiGridPreconWrapper.h | 4 + AMDiS/src/MultiGridSolver.cc | 184 +++--- AMDiS/src/MultiGridSolver.h | 14 +- AMDiS/src/MultiGridSolverBase.h | 24 +- AMDiS/src/MultiGridSolverBase.hh | 4 + AMDiS/src/MultiGridWrapper.h | 5 + AMDiS/src/Newton.h | 5 +- AMDiS/src/NewtonS.h | 2 +- AMDiS/src/NonLinSolver.h | 22 +- AMDiS/src/NonLinSolver.hh | 2 +- AMDiS/src/NonLinUpdater.h | 4 +- AMDiS/src/ODirSolver.h | 101 --- AMDiS/src/ODirSolver.hh | 167 ----- AMDiS/src/OEMSolver.h | 236 ++++--- AMDiS/src/OEMSolver.hh | 109 ---- AMDiS/src/OResSolver.h | 101 --- AMDiS/src/OResSolver.hh | 160 ----- AMDiS/src/PeriodicBC.cc | 258 ++++++-- AMDiS/src/PeriodicBC.h | 7 +- AMDiS/src/Preconditioner.h | 299 --------- AMDiS/src/ProblemNonLin.cc | 8 + AMDiS/src/ProblemNonLin.h | 4 + AMDiS/src/ProblemScal.cc | 106 ++-- AMDiS/src/ProblemScal.h | 53 +- AMDiS/src/ProblemStatBase.h | 5 +- AMDiS/src/ProblemVec.cc | 127 ++-- AMDiS/src/ProblemVec.h | 61 +- AMDiS/src/QN_Precond.h | 26 - AMDiS/src/QN_Precond.hh | 141 ----- AMDiS/src/{BiCGStab_M.h => SolverMatrix.h} | 120 ++-- AMDiS/src/SparseVector.cc | 25 + AMDiS/src/StlVector.cc | 81 --- AMDiS/src/StlVector.h | 60 -- AMDiS/src/TFQMR.h | 115 ---- AMDiS/src/TFQMR.hh | 184 ------ AMDiS/src/UmfPackSolver.h | 103 ++- AMDiS/src/UmfPackSolver.hh | 222 ------- AMDiS/src/Utilities.h | 44 ++ AMDiS/src/V3Vector.cc | 173 ----- AMDiS/src/V3Vector.h | 117 ---- AMDiS/src/VecSymSolver.h | 103 --- AMDiS/src/VecSymSolver.hh | 443 ------------- 103 files changed, 2494 insertions(+), 8191 deletions(-) create mode 100755 AMDiS/autogen.sh create mode 100644 AMDiS/src/AMDiS_fwd.h delete mode 100755 AMDiS/src/BFGS_Precond.cc delete mode 100755 AMDiS/src/BFGS_Precond.h delete mode 100644 AMDiS/src/BiCGSolver.h delete mode 100644 AMDiS/src/BiCGSolver.hh delete mode 100644 AMDiS/src/BiCGStab.h delete mode 100644 AMDiS/src/BiCGStab.hh delete mode 100644 AMDiS/src/BiCGStab2.h delete mode 100644 AMDiS/src/BiCGStab2.hh delete mode 100644 AMDiS/src/BiCGStab_M.hh delete mode 100644 AMDiS/src/CGSolver.h delete mode 100644 AMDiS/src/CGSolver.hh delete mode 100644 AMDiS/src/DiagonalPreconditioner.cc delete mode 100644 AMDiS/src/DiagonalPreconditioner.h delete mode 100644 AMDiS/src/GMResSolver.h delete mode 100644 AMDiS/src/GMResSolver.hh delete mode 100644 AMDiS/src/GMResSolver2.h delete mode 100644 AMDiS/src/GMResSolver2.hh delete mode 100644 AMDiS/src/ILUPreconditioner.cc delete mode 100644 AMDiS/src/ILUPreconditioner.h delete mode 100644 AMDiS/src/ILUTPreconditioner.cc delete mode 100644 AMDiS/src/ILUTPreconditioner.h create mode 100644 AMDiS/src/ITL_OEMSolver.h create mode 100644 AMDiS/src/ITL_Preconditioner.h create mode 100644 AMDiS/src/ITL_Solver.h delete mode 100644 AMDiS/src/ODirSolver.h delete mode 100644 AMDiS/src/ODirSolver.hh delete mode 100644 AMDiS/src/OEMSolver.hh delete mode 100644 AMDiS/src/OResSolver.h delete mode 100644 AMDiS/src/OResSolver.hh delete mode 100644 AMDiS/src/Preconditioner.h delete mode 100755 AMDiS/src/QN_Precond.h delete mode 100755 AMDiS/src/QN_Precond.hh rename AMDiS/src/{BiCGStab_M.h => SolverMatrix.h} (53%) delete mode 100644 AMDiS/src/StlVector.cc delete mode 100644 AMDiS/src/StlVector.h delete mode 100644 AMDiS/src/TFQMR.h delete mode 100644 AMDiS/src/TFQMR.hh delete mode 100644 AMDiS/src/UmfPackSolver.hh create mode 100644 AMDiS/src/Utilities.h delete mode 100644 AMDiS/src/V3Vector.cc delete mode 100644 AMDiS/src/V3Vector.h delete mode 100644 AMDiS/src/VecSymSolver.h delete mode 100644 AMDiS/src/VecSymSolver.hh diff --git a/AMDiS/Makefile.in b/AMDiS/Makefile.in index a3d52949..2b28bece 100644 --- a/AMDiS/Makefile.in +++ b/AMDiS/Makefile.in @@ -139,6 +139,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ +SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ diff --git a/AMDiS/aclocal.m4 b/AMDiS/aclocal.m4 index c6b83dae..6cec4be8 100644 --- a/AMDiS/aclocal.m4 +++ b/AMDiS/aclocal.m4 @@ -1578,10 +1578,27 @@ linux*) # before this can be enabled. hardcode_into_libs=yes + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on @@ -4288,6 +4305,9 @@ CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) # Is the compiler the GNU C compiler? with_gcc=$_LT_AC_TAGVAR(GCC, $1) +gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` +gcc_ver=\`gcc -dumpversion\` + # An ERE matcher. EGREP=$lt_EGREP @@ -4421,11 +4441,11 @@ striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) +predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) +postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. @@ -4437,7 +4457,7 @@ postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) +compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method @@ -4517,7 +4537,7 @@ variables_saved_for_relink="$variables_saved_for_relink" link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) # Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec +sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec @@ -6353,6 +6373,7 @@ do done done done +IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris @@ -6385,6 +6406,7 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do done ]) SED=$lt_cv_path_SED +AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ]) diff --git a/AMDiS/autogen.sh b/AMDiS/autogen.sh new file mode 100755 index 00000000..701cc614 --- /dev/null +++ b/AMDiS/autogen.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +echo "--> Running aclocal" +aclocal +if test "$?" != "0" ; then + echo "*** aclocal failed" + exit 1 +fi + +if test "`grep AC_CONFIG_HEADER configure.ac`" != "" -o \ + "`grep AM_CONFIG_HEADER configure.ac`" != "" ; then + # if we use CONFIG_HEADER, then make sure to run autoheader + echo "--> Running autoheader" + autoheader + if test "$?" != "0" ; then + echo "*** autoheader failed" + exit 1 + fi +else + echo "--> autoheader not needed" +fi + +echo "--> Running autoconf" +autoconf +if test "$?" != "0" ; then + echo "*** autoconf failed" + exit 1 +fi + +echo "--> Running libtoolize" +libtoolize --automake --copy +if test "$?" != "0" ; then + echo "*** libtoolize failed" + exit 1 +fi + +echo "--> Running automake" +automake -a --copy --include-deps +if test "$?" != "0" ; then + echo "*** automake failed" + exit 1 +fi + +echo; +echo "Running ./configure $@" +echo; +./configure $@ diff --git a/AMDiS/bin/Makefile.am b/AMDiS/bin/Makefile.am index d996bb32..5f73591b 100644 --- a/AMDiS/bin/Makefile.am +++ b/AMDiS/bin/Makefile.am @@ -33,7 +33,7 @@ if USE_PARALLEL_AMDIS endif if ENABLE_UMFPACK - libamdis_la_CXXFLAGS += -DHAVE_UMFPACK=1 + libamdis_la_CXXFLAGS += -DHAVE_UMFPACK=1 -DMTL_HAS_UMFPACK AMDIS_INCLUDES += -I$(LIB_DIR)/UFconfig \ -I$(LIB_DIR)/AMD/Include \ -I$(LIB_DIR)/UMFPACK/Include @@ -52,12 +52,14 @@ if ENABLE_BOOST libamdis_la_CXXFLAGS += -DHAVE_BOOST=1 endif -INCLUDES = $(AMDIS_INCLUDES) $(PARALLEL_INCLUDES) +TEMPLATE_INCLUDES = -I../lib/mtl4 -I../lib/boost_1_34_1 + +INCLUDES = $(AMDIS_INCLUDES) $(PARALLEL_INCLUDES) $(TEMPLATE_INCLUDES) if AMDIS_DEBUG - libamdis_la_CXXFLAGS += -g -O0 -Wall -DDEBUG=1 $(OPENMP_FLAG) -ftemplate-depth-30 $(INCLUDES) #-pedantic + libamdis_la_CXXFLAGS += -g -O0 -Wall -DDEBUG=1 $(OPENMP_FLAG) $(INCLUDES) #-pedantic else - libamdis_la_CXXFLAGS += -O2 -Wall -DDEBUG=0 $(OPENMP_FLAG) -ftemplate-depth-30 $(INCLUDES) #-pedantic + libamdis_la_CXXFLAGS += -O2 -Wall -DDEBUG=0 -DNDEBUG $(OPENMP_FLAG) -ftemplate-depth-100 $(INCLUDES) #-pedantic endif @@ -65,14 +67,10 @@ libamdis_la_SOURCES = \ $(PARALLEL_AMDIS_SOURCES) \ $(SOURCE_DIR)/MultiGridPreconWrapper.h $(SOURCE_DIR)/MultiGridPreconWrapper.cc \ $(SOURCE_DIR)/LagrangeInterpolRestrict.h \ -$(SOURCE_DIR)/BiCGStab.h $(SOURCE_DIR)/BiCGStab.hh \ -$(SOURCE_DIR)/BiCGStab2.h $(SOURCE_DIR)/BiCGStab2.hh \ $(SOURCE_DIR)/InterpolRestrictMatrix.h $(SOURCE_DIR)/InterpolRestrictMatrix.cc \ $(SOURCE_DIR)/DOFIndexed.h $(SOURCE_DIR)/DOFIndexed.cc \ $(SOURCE_DIR)/GNUPlotWriter.h $(SOURCE_DIR)/GNUPlotWriter.cc \ $(SOURCE_DIR)/SmootherBase.h \ -$(SOURCE_DIR)/StlVector.h $(SOURCE_DIR)/StlVector.cc \ -$(SOURCE_DIR)/V3Vector.h $(SOURCE_DIR)/V3Vector.cc \ $(SOURCE_DIR)/GSSMoother.h $(SOURCE_DIR)/GSSmoother.cc \ $(SOURCE_DIR)/JacobiSMoother.h $(SOURCE_DIR)/JacobiSmoother.cc \ $(SOURCE_DIR)/SparseVector.h $(SOURCE_DIR)/SparseVector.hh $(SOURCE_DIR)/SparseVector.cc \ @@ -130,50 +128,22 @@ $(SOURCE_DIR)/AdaptStationary.h $(SOURCE_DIR)/AdaptStationary.cc \ $(SOURCE_DIR)/AdaptInstationary.h $(SOURCE_DIR)/AdaptInstationary.cc \ $(SOURCE_DIR)/QPsiPhi.h \ $(SOURCE_DIR)/BasisFunction.h \ -$(SOURCE_DIR)/BiCGSolver.h $(SOURCE_DIR)/BiCGSolver.hh \ $(SOURCE_DIR)/Boundary.h \ -$(SOURCE_DIR)/CGSolver.h $(SOURCE_DIR)/CGSolver.hh \ +$(SOURCE_DIR)/ITL_Solver.h \ $(SOURCE_DIR)/CoarseningManager.h \ $(SOURCE_DIR)/CoarseningManager1d.h $(SOURCE_DIR)/CoarseningManager2d.h $(SOURCE_DIR)/CoarseningManager3d.h \ $(SOURCE_DIR)/demangle.h \ -$(SOURCE_DIR)/DiagonalPreconditioner.h $(SOURCE_DIR)/DiagonalPreconditioner.cc \ -$(SOURCE_DIR)/ILUPreconditioner.h $(SOURCE_DIR)/ILUPreconditioner.cc \ -$(SOURCE_DIR)/ILUTPreconditioner.h $(SOURCE_DIR)/ILUTPreconditioner.cc \ -$(SOURCE_DIR)/QN_Precond.h $(SOURCE_DIR)/QN_Precond.hh \ -$(SOURCE_DIR)/BFGS_Precond.h $(SOURCE_DIR)/BFGS_Precond.cc \ -$(SOURCE_DIR)/DOFAdmin.h \ -$(SOURCE_DIR)/DOFIterator.h \ -$(SOURCE_DIR)/DOFMatrix.h \ -$(SOURCE_DIR)/DOFVector.h $(SOURCE_DIR)/DOFVector.hh $(SOURCE_DIR)/DOFVector.cc \ -$(SOURCE_DIR)/Element.h $(SOURCE_DIR)/ElementConnection.h \ -$(SOURCE_DIR)/ElInfo.h $(SOURCE_DIR)/ElInfo1d.h $(SOURCE_DIR)/ElInfo2d.h $(SOURCE_DIR)/ElInfo3d.h \ -$(SOURCE_DIR)/Error.h $(SOURCE_DIR)/Error.hh \ -$(SOURCE_DIR)/Estimator.h $(SOURCE_DIR)/Estimator.cc \ -$(SOURCE_DIR)/ResidualEstimator.h $(SOURCE_DIR)/ResidualEstimator.cc \ -$(SOURCE_DIR)/ResidualParallelEstimator.h $(SOURCE_DIR)/ResidualParallelEstimator.cc \ -$(SOURCE_DIR)/FiniteElemSpace.h \ -$(SOURCE_DIR)/FixVec.h $(SOURCE_DIR)/FixVec.hh \ -$(SOURCE_DIR)/FixVecConvert.h \ -$(SOURCE_DIR)/Flag.h \ -$(SOURCE_DIR)/Global.h \ -$(SOURCE_DIR)/GMResSolver.h $(SOURCE_DIR)/GMResSolver.hh \ -$(SOURCE_DIR)/GMResSolver2.h $(SOURCE_DIR)/GMResSolver2.hh \ -$(SOURCE_DIR)/TFQMR.h $(SOURCE_DIR)/TFQMR.hh \ -$(SOURCE_DIR)/VecSymSolver.h $(SOURCE_DIR)/VecSymSolver.hh \ -$(SOURCE_DIR)/UmfPackSolver.h $(SOURCE_DIR)/UmfPackSolver.hh \ -$(SOURCE_DIR)/PardisoSolver.h $(SOURCE_DIR)/PardisoSolver.hh $(SOURCE_DIR)/PardisoSolver.cc \ -$(SOURCE_DIR)/DuneSolver.h $(SOURCE_DIR)/DuneSolver.hh $(SOURCE_DIR)/DuneSolver.cc \ +$(SOURCE_DIR)/DOFAdmin.h $(SOURCE_DIR)/DOFIterator.h $(SOURCE_DIR)/DOFMatrix.h $(SOURCE_DIR)/DOFVector.h $(SOURCE_DIR)/DOFVector.hh $(SOURCE_DIR)/DOFVector.cc $(SOURCE_DIR)/Element.h $(SOURCE_DIR)/ElementConnection.h \ +$(SOURCE_DIR)/ElInfo.h $(SOURCE_DIR)/ElInfo1d.h $(SOURCE_DIR)/ElInfo2d.h $(SOURCE_DIR)/ElInfo3d.h $(SOURCE_DIR)/Error.h \ +$(SOURCE_DIR)/Error.hh $(SOURCE_DIR)/Estimator.h $(SOURCE_DIR)/Estimator.cc $(SOURCE_DIR)/FiniteElemSpace.h $(SOURCE_DIR)/FixVec.h $(SOURCE_DIR)/FixVec.hh $(SOURCE_DIR)/FixVecConvert.h $(SOURCE_DIR)/Flag.h $(SOURCE_DIR)/Global.h \ +$(SOURCE_DIR)/UmfPackSolver.h \ $(SOURCE_DIR)/UmfPackSolver.hh \ $(SOURCE_DIR)/Lagrange.h $(SOURCE_DIR)/Line.h \ $(SOURCE_DIR)/MacroElement.h $(SOURCE_DIR)/MacroWriter.h \ $(SOURCE_DIR)/Markings.h $(SOURCE_DIR)/Markings.hh \ $(SOURCE_DIR)/MemoryManager.h \ $(SOURCE_DIR)/Mesh.h \ -$(SOURCE_DIR)/ODirSolver.h $(SOURCE_DIR)/ODirSolver.hh \ -$(SOURCE_DIR)/OEMSolver.h $(SOURCE_DIR)/OEMSolver.hh \ -$(SOURCE_DIR)/OResSolver.h $(SOURCE_DIR)/OResSolver.hh \ $(SOURCE_DIR)/Parameters.h \ $(SOURCE_DIR)/Parametric.h \ -$(SOURCE_DIR)/Preconditioner.h \ $(SOURCE_DIR)/Quadrature.h \ $(SOURCE_DIR)/RCNeighbourList.h \ $(SOURCE_DIRe)/RefinementManager.h \ diff --git a/AMDiS/bin/Makefile.in b/AMDiS/bin/Makefile.in index 8eb9f3a3..9eef154d 100644 --- a/AMDiS/bin/Makefile.in +++ b/AMDiS/bin/Makefile.in @@ -37,7 +37,7 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @USE_PARALLEL_AMDIS_TRUE@am__append_1 = -DHAVE_PARALLEL_AMDIS=1 -@ENABLE_UMFPACK_TRUE@am__append_2 = -DHAVE_UMFPACK=1 +@ENABLE_UMFPACK_TRUE@am__append_2 = -DHAVE_UMFPACK=1 -DMTL_HAS_UMFPACK @ENABLE_UMFPACK_TRUE@am__append_3 = -I$(LIB_DIR)/UFconfig \ @ENABLE_UMFPACK_TRUE@ -I$(LIB_DIR)/AMD/Include \ @ENABLE_UMFPACK_TRUE@ -I$(LIB_DIR)/UMFPACK/Include @@ -46,8 +46,8 @@ host_triplet = @host@ @ENABLE_DUNE_TRUE@am__append_5 = -DHAVE_DUNE=1 @ENABLE_DUNE_TRUE@am__append_6 = -I$(DUNE_DIR) @ENABLE_BOOST_TRUE@am__append_7 = -DHAVE_BOOST=1 -@AMDIS_DEBUG_TRUE@am__append_8 = -g -O0 -Wall -DDEBUG=1 $(OPENMP_FLAG) -ftemplate-depth-30 $(INCLUDES) #-pedantic -@AMDIS_DEBUG_FALSE@am__append_9 = -O2 -Wall -DDEBUG=0 $(OPENMP_FLAG) -ftemplate-depth-30 $(INCLUDES) #-pedantic +@AMDIS_DEBUG_TRUE@am__append_8 = -g -O0 -Wall -DDEBUG=1 $(OPENMP_FLAG) $(INCLUDES) #-pedantic +@AMDIS_DEBUG_FALSE@am__append_9 = -O2 -Wall -DDEBUG=0 -DNDEBUG $(OPENMP_FLAG) -ftemplate-depth-100 $(INCLUDES) #-pedantic subdir = bin DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -84,15 +84,11 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ConditionalEstimator.h \ $(SOURCE_DIR)/MultiGridPreconWrapper.h \ $(SOURCE_DIR)/MultiGridPreconWrapper.cc \ $(SOURCE_DIR)/LagrangeInterpolRestrict.h \ - $(SOURCE_DIR)/BiCGStab.h $(SOURCE_DIR)/BiCGStab.hh \ - $(SOURCE_DIR)/BiCGStab2.h $(SOURCE_DIR)/BiCGStab2.hh \ $(SOURCE_DIR)/InterpolRestrictMatrix.h \ $(SOURCE_DIR)/InterpolRestrictMatrix.cc \ $(SOURCE_DIR)/DOFIndexed.h $(SOURCE_DIR)/DOFIndexed.cc \ $(SOURCE_DIR)/GNUPlotWriter.h $(SOURCE_DIR)/GNUPlotWriter.cc \ - $(SOURCE_DIR)/SmootherBase.h $(SOURCE_DIR)/StlVector.h \ - $(SOURCE_DIR)/StlVector.cc $(SOURCE_DIR)/V3Vector.h \ - $(SOURCE_DIR)/V3Vector.cc $(SOURCE_DIR)/GSSMoother.h \ + $(SOURCE_DIR)/SmootherBase.h $(SOURCE_DIR)/GSSMoother.h \ $(SOURCE_DIR)/GSSmoother.cc $(SOURCE_DIR)/JacobiSMoother.h \ $(SOURCE_DIR)/JacobiSmoother.cc $(SOURCE_DIR)/SparseVector.h \ $(SOURCE_DIR)/SparseVector.hh $(SOURCE_DIR)/SparseVector.cc \ @@ -160,53 +156,29 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ConditionalEstimator.h \ $(SOURCE_DIR)/AdaptStationary.cc \ $(SOURCE_DIR)/AdaptInstationary.h \ $(SOURCE_DIR)/AdaptInstationary.cc $(SOURCE_DIR)/QPsiPhi.h \ - $(SOURCE_DIR)/BasisFunction.h $(SOURCE_DIR)/BiCGSolver.h \ - $(SOURCE_DIR)/BiCGSolver.hh $(SOURCE_DIR)/Boundary.h \ - $(SOURCE_DIR)/CGSolver.h $(SOURCE_DIR)/CGSolver.hh \ - $(SOURCE_DIR)/CoarseningManager.h \ + $(SOURCE_DIR)/BasisFunction.h $(SOURCE_DIR)/Boundary.h \ + $(SOURCE_DIR)/ITL_Solver.h $(SOURCE_DIR)/CoarseningManager.h \ $(SOURCE_DIR)/CoarseningManager1d.h \ $(SOURCE_DIR)/CoarseningManager2d.h \ $(SOURCE_DIR)/CoarseningManager3d.h $(SOURCE_DIR)/demangle.h \ - $(SOURCE_DIR)/DiagonalPreconditioner.h \ - $(SOURCE_DIR)/DiagonalPreconditioner.cc \ - $(SOURCE_DIR)/ILUPreconditioner.h \ - $(SOURCE_DIR)/ILUPreconditioner.cc \ - $(SOURCE_DIR)/ILUTPreconditioner.h \ - $(SOURCE_DIR)/ILUTPreconditioner.cc $(SOURCE_DIR)/QN_Precond.h \ - $(SOURCE_DIR)/QN_Precond.hh $(SOURCE_DIR)/BFGS_Precond.h \ - $(SOURCE_DIR)/BFGS_Precond.cc $(SOURCE_DIR)/DOFAdmin.h \ - $(SOURCE_DIR)/DOFIterator.h $(SOURCE_DIR)/DOFMatrix.h \ - $(SOURCE_DIR)/DOFVector.h $(SOURCE_DIR)/DOFVector.hh \ - $(SOURCE_DIR)/DOFVector.cc $(SOURCE_DIR)/Element.h \ - $(SOURCE_DIR)/ElementConnection.h $(SOURCE_DIR)/ElInfo.h \ - $(SOURCE_DIR)/ElInfo1d.h $(SOURCE_DIR)/ElInfo2d.h \ - $(SOURCE_DIR)/ElInfo3d.h $(SOURCE_DIR)/Error.h \ - $(SOURCE_DIR)/Error.hh $(SOURCE_DIR)/Estimator.h \ - $(SOURCE_DIR)/Estimator.cc $(SOURCE_DIR)/ResidualEstimator.h \ - $(SOURCE_DIR)/ResidualEstimator.cc \ - $(SOURCE_DIR)/ResidualParallelEstimator.h \ - $(SOURCE_DIR)/ResidualParallelEstimator.cc \ + $(SOURCE_DIR)/DOFAdmin.h $(SOURCE_DIR)/DOFIterator.h \ + $(SOURCE_DIR)/DOFMatrix.h $(SOURCE_DIR)/DOFVector.h \ + $(SOURCE_DIR)/DOFVector.hh $(SOURCE_DIR)/DOFVector.cc \ + $(SOURCE_DIR)/Element.h $(SOURCE_DIR)/ElementConnection.h \ + $(SOURCE_DIR)/ElInfo.h $(SOURCE_DIR)/ElInfo1d.h \ + $(SOURCE_DIR)/ElInfo2d.h $(SOURCE_DIR)/ElInfo3d.h \ + $(SOURCE_DIR)/Error.h $(SOURCE_DIR)/Error.hh \ + $(SOURCE_DIR)/Estimator.h $(SOURCE_DIR)/Estimator.cc \ $(SOURCE_DIR)/FiniteElemSpace.h $(SOURCE_DIR)/FixVec.h \ $(SOURCE_DIR)/FixVec.hh $(SOURCE_DIR)/FixVecConvert.h \ $(SOURCE_DIR)/Flag.h $(SOURCE_DIR)/Global.h \ - $(SOURCE_DIR)/GMResSolver.h $(SOURCE_DIR)/GMResSolver.hh \ - $(SOURCE_DIR)/GMResSolver2.h $(SOURCE_DIR)/GMResSolver2.hh \ - $(SOURCE_DIR)/TFQMR.h $(SOURCE_DIR)/TFQMR.hh \ - $(SOURCE_DIR)/VecSymSolver.h $(SOURCE_DIR)/VecSymSolver.hh \ - $(SOURCE_DIR)/UmfPackSolver.h $(SOURCE_DIR)/UmfPackSolver.hh \ - $(SOURCE_DIR)/PardisoSolver.h $(SOURCE_DIR)/PardisoSolver.hh \ - $(SOURCE_DIR)/PardisoSolver.cc $(SOURCE_DIR)/DuneSolver.h \ - $(SOURCE_DIR)/DuneSolver.hh $(SOURCE_DIR)/DuneSolver.cc \ + $(SOURCE_DIR)/UmfPackSolver.h \ $(SOURCE_DIR)/UmfPackSolver.hh \ $(SOURCE_DIR)/Lagrange.h $(SOURCE_DIR)/Line.h \ $(SOURCE_DIR)/MacroElement.h $(SOURCE_DIR)/MacroWriter.h \ $(SOURCE_DIR)/Markings.h $(SOURCE_DIR)/Markings.hh \ $(SOURCE_DIR)/MemoryManager.h $(SOURCE_DIR)/Mesh.h \ - $(SOURCE_DIR)/ODirSolver.h $(SOURCE_DIR)/ODirSolver.hh \ - $(SOURCE_DIR)/OEMSolver.h $(SOURCE_DIR)/OEMSolver.hh \ - $(SOURCE_DIR)/OResSolver.h $(SOURCE_DIR)/OResSolver.hh \ $(SOURCE_DIR)/Parameters.h $(SOURCE_DIR)/Parametric.h \ - $(SOURCE_DIR)/Preconditioner.h $(SOURCE_DIR)/Quadrature.h \ - $(SOURCE_DIR)/RCNeighbourList.h \ + $(SOURCE_DIR)/Quadrature.h $(SOURCE_DIR)/RCNeighbourList.h \ $(SOURCE_DIRe)/RefinementManager.h \ $(SOURCE_DIR)/RefinementManager1d.h \ $(SOURCE_DIR)/RefinementManager2d.h \ @@ -270,7 +242,6 @@ am_libamdis_la_OBJECTS = $(am__objects_1) \ libamdis_la-MultiGridPreconWrapper.lo \ libamdis_la-InterpolRestrictMatrix.lo \ libamdis_la-DOFIndexed.lo libamdis_la-GNUPlotWriter.lo \ - libamdis_la-StlVector.lo libamdis_la-V3Vector.lo \ libamdis_la-GSSmoother.lo libamdis_la-JacobiSmoother.lo \ libamdis_la-SparseVector.lo libamdis_la-VertexVector.lo \ libamdis_la-PeriodicBC.lo libamdis_la-MultiGridSolver.lo \ @@ -294,18 +265,11 @@ am_libamdis_la_OBJECTS = $(am__objects_1) \ libamdis_la-ElementFileWriter.lo libamdis_la-ElInfo.lo \ libamdis_la-ElInfoStack.lo libamdis_la-Operator.lo \ libamdis_la-Mesh.lo libamdis_la-AdaptStationary.lo \ - libamdis_la-AdaptInstationary.lo \ - libamdis_la-DiagonalPreconditioner.lo \ - libamdis_la-ILUPreconditioner.lo \ - libamdis_la-ILUTPreconditioner.lo libamdis_la-BFGS_Precond.lo \ - libamdis_la-DOFVector.lo libamdis_la-Estimator.lo \ - libamdis_la-ResidualEstimator.lo \ - libamdis_la-ResidualParallelEstimator.lo \ - libamdis_la-PardisoSolver.lo libamdis_la-DuneSolver.lo \ - libamdis_la-ProblemInstat.lo libamdis_la-ProblemNonLin.lo \ - libamdis_la-NonLinUpdater.lo libamdis_la-QPsiPhi.lo \ - libamdis_la-BasisFunction.lo libamdis_la-Boundary.lo \ - libamdis_la-CoarseningManager.lo \ + libamdis_la-AdaptInstationary.lo libamdis_la-DOFVector.lo \ + libamdis_la-Estimator.lo libamdis_la-ProblemInstat.lo \ + libamdis_la-ProblemNonLin.lo libamdis_la-NonLinUpdater.lo \ + libamdis_la-QPsiPhi.lo libamdis_la-BasisFunction.lo \ + libamdis_la-Boundary.lo libamdis_la-CoarseningManager.lo \ libamdis_la-CoarseningManager1d.lo \ libamdis_la-CoarseningManager2d.lo \ libamdis_la-CoarseningManager3d.lo libamdis_la-demangle.lo \ @@ -435,6 +399,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ +SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -509,19 +474,16 @@ AMDIS_INCLUDES = -I$(SOURCE_DIR) $(am__append_3) $(am__append_6) libamdis_la_CXXFLAGS = $(am__append_1) $(am__append_2) $(am__append_4) \ $(am__append_5) $(am__append_7) $(am__append_8) \ $(am__append_9) -INCLUDES = $(AMDIS_INCLUDES) $(PARALLEL_INCLUDES) +TEMPLATE_INCLUDES = -I../lib/mtl4 -I../lib/boost_1_34_1 +INCLUDES = $(AMDIS_INCLUDES) $(PARALLEL_INCLUDES) $(TEMPLATE_INCLUDES) libamdis_la_SOURCES = \ $(PARALLEL_AMDIS_SOURCES) \ $(SOURCE_DIR)/MultiGridPreconWrapper.h $(SOURCE_DIR)/MultiGridPreconWrapper.cc \ $(SOURCE_DIR)/LagrangeInterpolRestrict.h \ -$(SOURCE_DIR)/BiCGStab.h $(SOURCE_DIR)/BiCGStab.hh \ -$(SOURCE_DIR)/BiCGStab2.h $(SOURCE_DIR)/BiCGStab2.hh \ $(SOURCE_DIR)/InterpolRestrictMatrix.h $(SOURCE_DIR)/InterpolRestrictMatrix.cc \ $(SOURCE_DIR)/DOFIndexed.h $(SOURCE_DIR)/DOFIndexed.cc \ $(SOURCE_DIR)/GNUPlotWriter.h $(SOURCE_DIR)/GNUPlotWriter.cc \ $(SOURCE_DIR)/SmootherBase.h \ -$(SOURCE_DIR)/StlVector.h $(SOURCE_DIR)/StlVector.cc \ -$(SOURCE_DIR)/V3Vector.h $(SOURCE_DIR)/V3Vector.cc \ $(SOURCE_DIR)/GSSMoother.h $(SOURCE_DIR)/GSSmoother.cc \ $(SOURCE_DIR)/JacobiSMoother.h $(SOURCE_DIR)/JacobiSmoother.cc \ $(SOURCE_DIR)/SparseVector.h $(SOURCE_DIR)/SparseVector.hh $(SOURCE_DIR)/SparseVector.cc \ @@ -579,50 +541,22 @@ $(SOURCE_DIR)/AdaptStationary.h $(SOURCE_DIR)/AdaptStationary.cc \ $(SOURCE_DIR)/AdaptInstationary.h $(SOURCE_DIR)/AdaptInstationary.cc \ $(SOURCE_DIR)/QPsiPhi.h \ $(SOURCE_DIR)/BasisFunction.h \ -$(SOURCE_DIR)/BiCGSolver.h $(SOURCE_DIR)/BiCGSolver.hh \ $(SOURCE_DIR)/Boundary.h \ -$(SOURCE_DIR)/CGSolver.h $(SOURCE_DIR)/CGSolver.hh \ +$(SOURCE_DIR)/ITL_Solver.h \ $(SOURCE_DIR)/CoarseningManager.h \ $(SOURCE_DIR)/CoarseningManager1d.h $(SOURCE_DIR)/CoarseningManager2d.h $(SOURCE_DIR)/CoarseningManager3d.h \ $(SOURCE_DIR)/demangle.h \ -$(SOURCE_DIR)/DiagonalPreconditioner.h $(SOURCE_DIR)/DiagonalPreconditioner.cc \ -$(SOURCE_DIR)/ILUPreconditioner.h $(SOURCE_DIR)/ILUPreconditioner.cc \ -$(SOURCE_DIR)/ILUTPreconditioner.h $(SOURCE_DIR)/ILUTPreconditioner.cc \ -$(SOURCE_DIR)/QN_Precond.h $(SOURCE_DIR)/QN_Precond.hh \ -$(SOURCE_DIR)/BFGS_Precond.h $(SOURCE_DIR)/BFGS_Precond.cc \ -$(SOURCE_DIR)/DOFAdmin.h \ -$(SOURCE_DIR)/DOFIterator.h \ -$(SOURCE_DIR)/DOFMatrix.h \ -$(SOURCE_DIR)/DOFVector.h $(SOURCE_DIR)/DOFVector.hh $(SOURCE_DIR)/DOFVector.cc \ -$(SOURCE_DIR)/Element.h $(SOURCE_DIR)/ElementConnection.h \ -$(SOURCE_DIR)/ElInfo.h $(SOURCE_DIR)/ElInfo1d.h $(SOURCE_DIR)/ElInfo2d.h $(SOURCE_DIR)/ElInfo3d.h \ -$(SOURCE_DIR)/Error.h $(SOURCE_DIR)/Error.hh \ -$(SOURCE_DIR)/Estimator.h $(SOURCE_DIR)/Estimator.cc \ -$(SOURCE_DIR)/ResidualEstimator.h $(SOURCE_DIR)/ResidualEstimator.cc \ -$(SOURCE_DIR)/ResidualParallelEstimator.h $(SOURCE_DIR)/ResidualParallelEstimator.cc \ -$(SOURCE_DIR)/FiniteElemSpace.h \ -$(SOURCE_DIR)/FixVec.h $(SOURCE_DIR)/FixVec.hh \ -$(SOURCE_DIR)/FixVecConvert.h \ -$(SOURCE_DIR)/Flag.h \ -$(SOURCE_DIR)/Global.h \ -$(SOURCE_DIR)/GMResSolver.h $(SOURCE_DIR)/GMResSolver.hh \ -$(SOURCE_DIR)/GMResSolver2.h $(SOURCE_DIR)/GMResSolver2.hh \ -$(SOURCE_DIR)/TFQMR.h $(SOURCE_DIR)/TFQMR.hh \ -$(SOURCE_DIR)/VecSymSolver.h $(SOURCE_DIR)/VecSymSolver.hh \ -$(SOURCE_DIR)/UmfPackSolver.h $(SOURCE_DIR)/UmfPackSolver.hh \ -$(SOURCE_DIR)/PardisoSolver.h $(SOURCE_DIR)/PardisoSolver.hh $(SOURCE_DIR)/PardisoSolver.cc \ -$(SOURCE_DIR)/DuneSolver.h $(SOURCE_DIR)/DuneSolver.hh $(SOURCE_DIR)/DuneSolver.cc \ +$(SOURCE_DIR)/DOFAdmin.h $(SOURCE_DIR)/DOFIterator.h $(SOURCE_DIR)/DOFMatrix.h $(SOURCE_DIR)/DOFVector.h $(SOURCE_DIR)/DOFVector.hh $(SOURCE_DIR)/DOFVector.cc $(SOURCE_DIR)/Element.h $(SOURCE_DIR)/ElementConnection.h \ +$(SOURCE_DIR)/ElInfo.h $(SOURCE_DIR)/ElInfo1d.h $(SOURCE_DIR)/ElInfo2d.h $(SOURCE_DIR)/ElInfo3d.h $(SOURCE_DIR)/Error.h \ +$(SOURCE_DIR)/Error.hh $(SOURCE_DIR)/Estimator.h $(SOURCE_DIR)/Estimator.cc $(SOURCE_DIR)/FiniteElemSpace.h $(SOURCE_DIR)/FixVec.h $(SOURCE_DIR)/FixVec.hh $(SOURCE_DIR)/FixVecConvert.h $(SOURCE_DIR)/Flag.h $(SOURCE_DIR)/Global.h \ +$(SOURCE_DIR)/UmfPackSolver.h \ $(SOURCE_DIR)/UmfPackSolver.hh \ $(SOURCE_DIR)/Lagrange.h $(SOURCE_DIR)/Line.h \ $(SOURCE_DIR)/MacroElement.h $(SOURCE_DIR)/MacroWriter.h \ $(SOURCE_DIR)/Markings.h $(SOURCE_DIR)/Markings.hh \ $(SOURCE_DIR)/MemoryManager.h \ $(SOURCE_DIR)/Mesh.h \ -$(SOURCE_DIR)/ODirSolver.h $(SOURCE_DIR)/ODirSolver.hh \ -$(SOURCE_DIR)/OEMSolver.h $(SOURCE_DIR)/OEMSolver.hh \ -$(SOURCE_DIR)/OResSolver.h $(SOURCE_DIR)/OResSolver.hh \ $(SOURCE_DIR)/Parameters.h \ $(SOURCE_DIR)/Parametric.h \ -$(SOURCE_DIR)/Preconditioner.h \ $(SOURCE_DIR)/Quadrature.h \ $(SOURCE_DIR)/RCNeighbourList.h \ $(SOURCE_DIRe)/RefinementManager.h \ @@ -791,7 +725,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-AdaptParaReal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-AdaptStationary.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Assembler.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-BFGS_Precond.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-BasisFunction.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Boundary.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-BoundaryManager.Plo@am__quote@ @@ -808,10 +741,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DOFMatrix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DOFVector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DataCollector.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DiagonalPreconditioner.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DirichletBC.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DualTraverse.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DuneSolver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ElInfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ElInfo1d.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ElInfo2d.Plo@am__quote@ @@ -828,8 +759,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-GNUPlotWriter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-GSSmoother.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Global.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ILUPreconditioner.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ILUTPreconditioner.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-InteriorBoundary.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-InterpolRestrictMatrix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-JacobiSmoother.Plo@am__quote@ @@ -855,7 +784,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ParallelProblem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Parameters.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Parametric.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-PardisoSolver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-PeriodicBC.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-PngWriter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ProblemInstat.Plo@am__quote@ @@ -874,14 +802,11 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-RefinementManager1d.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-RefinementManager2d.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-RefinementManager3d.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ResidualEstimator.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ResidualParallelEstimator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-RobinBC.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ScalableQuadrature.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-SecondOrderAssembler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-SparseVector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-StandardProblemIteration.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-StlVector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-SubAssembler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-SubElInfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-SurfaceQuadrature.Plo@am__quote@ @@ -890,7 +815,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Traverse.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-TraverseParallel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Triangle.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-V3Vector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ValueReader.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ValueWriter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-VertexVector.Plo@am__quote@ @@ -991,20 +915,6 @@ libamdis_la-GNUPlotWriter.lo: $(SOURCE_DIR)/GNUPlotWriter.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-GNUPlotWriter.lo `test -f '$(SOURCE_DIR)/GNUPlotWriter.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/GNUPlotWriter.cc -libamdis_la-StlVector.lo: $(SOURCE_DIR)/StlVector.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-StlVector.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-StlVector.Tpo" -c -o libamdis_la-StlVector.lo `test -f '$(SOURCE_DIR)/StlVector.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/StlVector.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-StlVector.Tpo" "$(DEPDIR)/libamdis_la-StlVector.Plo"; else rm -f "$(DEPDIR)/libamdis_la-StlVector.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/StlVector.cc' object='libamdis_la-StlVector.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-StlVector.lo `test -f '$(SOURCE_DIR)/StlVector.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/StlVector.cc - -libamdis_la-V3Vector.lo: $(SOURCE_DIR)/V3Vector.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-V3Vector.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-V3Vector.Tpo" -c -o libamdis_la-V3Vector.lo `test -f '$(SOURCE_DIR)/V3Vector.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/V3Vector.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-V3Vector.Tpo" "$(DEPDIR)/libamdis_la-V3Vector.Plo"; else rm -f "$(DEPDIR)/libamdis_la-V3Vector.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/V3Vector.cc' object='libamdis_la-V3Vector.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-V3Vector.lo `test -f '$(SOURCE_DIR)/V3Vector.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/V3Vector.cc - libamdis_la-GSSmoother.lo: $(SOURCE_DIR)/GSSmoother.cc @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-GSSmoother.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-GSSmoother.Tpo" -c -o libamdis_la-GSSmoother.lo `test -f '$(SOURCE_DIR)/GSSmoother.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/GSSmoother.cc; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-GSSmoother.Tpo" "$(DEPDIR)/libamdis_la-GSSmoother.Plo"; else rm -f "$(DEPDIR)/libamdis_la-GSSmoother.Tpo"; exit 1; fi @@ -1313,34 +1223,6 @@ libamdis_la-AdaptInstationary.lo: $(SOURCE_DIR)/AdaptInstationary.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-AdaptInstationary.lo `test -f '$(SOURCE_DIR)/AdaptInstationary.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/AdaptInstationary.cc -libamdis_la-DiagonalPreconditioner.lo: $(SOURCE_DIR)/DiagonalPreconditioner.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-DiagonalPreconditioner.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-DiagonalPreconditioner.Tpo" -c -o libamdis_la-DiagonalPreconditioner.lo `test -f '$(SOURCE_DIR)/DiagonalPreconditioner.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/DiagonalPreconditioner.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-DiagonalPreconditioner.Tpo" "$(DEPDIR)/libamdis_la-DiagonalPreconditioner.Plo"; else rm -f "$(DEPDIR)/libamdis_la-DiagonalPreconditioner.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/DiagonalPreconditioner.cc' object='libamdis_la-DiagonalPreconditioner.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-DiagonalPreconditioner.lo `test -f '$(SOURCE_DIR)/DiagonalPreconditioner.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/DiagonalPreconditioner.cc - -libamdis_la-ILUPreconditioner.lo: $(SOURCE_DIR)/ILUPreconditioner.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-ILUPreconditioner.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ILUPreconditioner.Tpo" -c -o libamdis_la-ILUPreconditioner.lo `test -f '$(SOURCE_DIR)/ILUPreconditioner.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ILUPreconditioner.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ILUPreconditioner.Tpo" "$(DEPDIR)/libamdis_la-ILUPreconditioner.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ILUPreconditioner.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/ILUPreconditioner.cc' object='libamdis_la-ILUPreconditioner.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-ILUPreconditioner.lo `test -f '$(SOURCE_DIR)/ILUPreconditioner.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ILUPreconditioner.cc - -libamdis_la-ILUTPreconditioner.lo: $(SOURCE_DIR)/ILUTPreconditioner.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-ILUTPreconditioner.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ILUTPreconditioner.Tpo" -c -o libamdis_la-ILUTPreconditioner.lo `test -f '$(SOURCE_DIR)/ILUTPreconditioner.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ILUTPreconditioner.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ILUTPreconditioner.Tpo" "$(DEPDIR)/libamdis_la-ILUTPreconditioner.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ILUTPreconditioner.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/ILUTPreconditioner.cc' object='libamdis_la-ILUTPreconditioner.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-ILUTPreconditioner.lo `test -f '$(SOURCE_DIR)/ILUTPreconditioner.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ILUTPreconditioner.cc - -libamdis_la-BFGS_Precond.lo: $(SOURCE_DIR)/BFGS_Precond.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-BFGS_Precond.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-BFGS_Precond.Tpo" -c -o libamdis_la-BFGS_Precond.lo `test -f '$(SOURCE_DIR)/BFGS_Precond.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/BFGS_Precond.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-BFGS_Precond.Tpo" "$(DEPDIR)/libamdis_la-BFGS_Precond.Plo"; else rm -f "$(DEPDIR)/libamdis_la-BFGS_Precond.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/BFGS_Precond.cc' object='libamdis_la-BFGS_Precond.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-BFGS_Precond.lo `test -f '$(SOURCE_DIR)/BFGS_Precond.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/BFGS_Precond.cc - libamdis_la-DOFVector.lo: $(SOURCE_DIR)/DOFVector.cc @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-DOFVector.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-DOFVector.Tpo" -c -o libamdis_la-DOFVector.lo `test -f '$(SOURCE_DIR)/DOFVector.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/DOFVector.cc; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-DOFVector.Tpo" "$(DEPDIR)/libamdis_la-DOFVector.Plo"; else rm -f "$(DEPDIR)/libamdis_la-DOFVector.Tpo"; exit 1; fi @@ -1355,34 +1237,6 @@ libamdis_la-Estimator.lo: $(SOURCE_DIR)/Estimator.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-Estimator.lo `test -f '$(SOURCE_DIR)/Estimator.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/Estimator.cc -libamdis_la-ResidualEstimator.lo: $(SOURCE_DIR)/ResidualEstimator.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-ResidualEstimator.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ResidualEstimator.Tpo" -c -o libamdis_la-ResidualEstimator.lo `test -f '$(SOURCE_DIR)/ResidualEstimator.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ResidualEstimator.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ResidualEstimator.Tpo" "$(DEPDIR)/libamdis_la-ResidualEstimator.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ResidualEstimator.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/ResidualEstimator.cc' object='libamdis_la-ResidualEstimator.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-ResidualEstimator.lo `test -f '$(SOURCE_DIR)/ResidualEstimator.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ResidualEstimator.cc - -libamdis_la-ResidualParallelEstimator.lo: $(SOURCE_DIR)/ResidualParallelEstimator.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-ResidualParallelEstimator.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ResidualParallelEstimator.Tpo" -c -o libamdis_la-ResidualParallelEstimator.lo `test -f '$(SOURCE_DIR)/ResidualParallelEstimator.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ResidualParallelEstimator.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ResidualParallelEstimator.Tpo" "$(DEPDIR)/libamdis_la-ResidualParallelEstimator.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ResidualParallelEstimator.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/ResidualParallelEstimator.cc' object='libamdis_la-ResidualParallelEstimator.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-ResidualParallelEstimator.lo `test -f '$(SOURCE_DIR)/ResidualParallelEstimator.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ResidualParallelEstimator.cc - -libamdis_la-PardisoSolver.lo: $(SOURCE_DIR)/PardisoSolver.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-PardisoSolver.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-PardisoSolver.Tpo" -c -o libamdis_la-PardisoSolver.lo `test -f '$(SOURCE_DIR)/PardisoSolver.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/PardisoSolver.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-PardisoSolver.Tpo" "$(DEPDIR)/libamdis_la-PardisoSolver.Plo"; else rm -f "$(DEPDIR)/libamdis_la-PardisoSolver.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/PardisoSolver.cc' object='libamdis_la-PardisoSolver.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-PardisoSolver.lo `test -f '$(SOURCE_DIR)/PardisoSolver.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/PardisoSolver.cc - -libamdis_la-DuneSolver.lo: $(SOURCE_DIR)/DuneSolver.cc -@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-DuneSolver.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-DuneSolver.Tpo" -c -o libamdis_la-DuneSolver.lo `test -f '$(SOURCE_DIR)/DuneSolver.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/DuneSolver.cc; \ -@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-DuneSolver.Tpo" "$(DEPDIR)/libamdis_la-DuneSolver.Plo"; else rm -f "$(DEPDIR)/libamdis_la-DuneSolver.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/DuneSolver.cc' object='libamdis_la-DuneSolver.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-DuneSolver.lo `test -f '$(SOURCE_DIR)/DuneSolver.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/DuneSolver.cc - libamdis_la-ProblemInstat.lo: $(SOURCE_DIR)/ProblemInstat.cc @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-ProblemInstat.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ProblemInstat.Tpo" -c -o libamdis_la-ProblemInstat.lo `test -f '$(SOURCE_DIR)/ProblemInstat.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ProblemInstat.cc; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ProblemInstat.Tpo" "$(DEPDIR)/libamdis_la-ProblemInstat.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ProblemInstat.Tpo"; exit 1; fi diff --git a/AMDiS/configure b/AMDiS/configure index 3ac06158..4ad0e601 100755 --- a/AMDiS/configure +++ b/AMDiS/configure @@ -462,7 +462,7 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT AMDIS_DEBUG_TRUE AMDIS_DEBUG_FALSE CXX CC AMDIS_INTEL_TRUE AMDIS_INTEL_FALSE AMDIS_OPENMP_TRUE AMDIS_OPENMP_FALSE OPENMP_FLAG MPI_DIR USE_PARALLEL_AMDIS_TRUE USE_PARALLEL_AMDIS_FALSE ENABLE_UMFPACK_TRUE ENABLE_UMFPACK_FALSE ENABLE_MKL_TRUE ENABLE_MKL_FALSE DUNE_DIR ENABLE_DUNE_TRUE ENABLE_DUNE_FALSE ENABLE_BOOST_TRUE ENABLE_BOOST_FALSE CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT AMDIS_DEBUG_TRUE AMDIS_DEBUG_FALSE CXX CC AMDIS_INTEL_TRUE AMDIS_INTEL_FALSE AMDIS_OPENMP_TRUE AMDIS_OPENMP_FALSE OPENMP_FLAG MPI_DIR USE_PARALLEL_AMDIS_TRUE USE_PARALLEL_AMDIS_FALSE ENABLE_UMFPACK_TRUE ENABLE_UMFPACK_FALSE ENABLE_MKL_TRUE ENABLE_MKL_FALSE DUNE_DIR ENABLE_DUNE_TRUE ENABLE_DUNE_FALSE ENABLE_BOOST_TRUE ENABLE_BOOST_FALSE CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -3909,6 +3909,7 @@ do done done done +IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris @@ -3943,6 +3944,7 @@ done fi SED=$lt_cv_path_SED + echo "$as_me:$LINENO: result: $SED" >&5 echo "${ECHO_T}$SED" >&6 @@ -4383,7 +4385,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4386 "configure"' > conftest.$ac_ext + echo '#line 4388 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -5518,7 +5520,7 @@ fi # Provide some information about the compiler. -echo "$as_me:5521:" \ +echo "$as_me:5523:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 @@ -6581,11 +6583,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6584: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6586: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6588: \$? = $ac_status" >&5 + echo "$as_me:6590: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -6849,11 +6851,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6852: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6854: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6856: \$? = $ac_status" >&5 + echo "$as_me:6858: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -6953,11 +6955,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6956: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6958: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:6960: \$? = $ac_status" >&5 + echo "$as_me:6962: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8418,10 +8420,31 @@ linux*) # before this can be enabled. hardcode_into_libs=yes + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 8427 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on @@ -9298,7 +9321,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 9301 "configure" +#line 9324 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9398,7 +9421,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 9401 "configure" +#line 9424 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9729,6 +9752,9 @@ CC=$lt_compiler # Is the compiler the GNU C compiler? with_gcc=$GCC +gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` +gcc_ver=\`gcc -dumpversion\` + # An ERE matcher. EGREP=$lt_EGREP @@ -9862,11 +9888,11 @@ striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=$lt_predep_objects +predep_objects=\`echo $lt_predep_objects | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=$lt_postdep_objects +postdep_objects=\`echo $lt_postdep_objects | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. @@ -9878,7 +9904,7 @@ postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path +compiler_lib_search_path=\`echo $lt_compiler_lib_search_path | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method @@ -9958,7 +9984,7 @@ variables_saved_for_relink="$variables_saved_for_relink" link_all_deplibs=$link_all_deplibs # Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec +sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec @@ -11738,11 +11764,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11741: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11767: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:11745: \$? = $ac_status" >&5 + echo "$as_me:11771: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -11842,11 +11868,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11845: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11871: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:11849: \$? = $ac_status" >&5 + echo "$as_me:11875: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12374,10 +12400,31 @@ linux*) # before this can be enabled. hardcode_into_libs=yes + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 12407 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on @@ -12761,6 +12808,9 @@ CC=$lt_compiler_CXX # Is the compiler the GNU C compiler? with_gcc=$GCC_CXX +gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` +gcc_ver=\`gcc -dumpversion\` + # An ERE matcher. EGREP=$lt_EGREP @@ -12894,11 +12944,11 @@ striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=$lt_predep_objects_CXX +predep_objects=\`echo $lt_predep_objects_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=$lt_postdep_objects_CXX +postdep_objects=\`echo $lt_postdep_objects_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. @@ -12910,7 +12960,7 @@ postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_CXX +compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method @@ -12990,7 +13040,7 @@ variables_saved_for_relink="$variables_saved_for_relink" link_all_deplibs=$link_all_deplibs_CXX # Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec +sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec @@ -13412,11 +13462,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13415: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13465: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13419: \$? = $ac_status" >&5 + echo "$as_me:13469: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -13516,11 +13566,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13519: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13569: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13523: \$? = $ac_status" >&5 + echo "$as_me:13573: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14961,10 +15011,31 @@ linux*) # before this can be enabled. hardcode_into_libs=yes + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 15018 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on @@ -15348,6 +15419,9 @@ CC=$lt_compiler_F77 # Is the compiler the GNU C compiler? with_gcc=$GCC_F77 +gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` +gcc_ver=\`gcc -dumpversion\` + # An ERE matcher. EGREP=$lt_EGREP @@ -15481,11 +15555,11 @@ striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=$lt_predep_objects_F77 +predep_objects=\`echo $lt_predep_objects_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=$lt_postdep_objects_F77 +postdep_objects=\`echo $lt_postdep_objects_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. @@ -15497,7 +15571,7 @@ postdeps=$lt_postdeps_F77 # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_F77 +compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method @@ -15577,7 +15651,7 @@ variables_saved_for_relink="$variables_saved_for_relink" link_all_deplibs=$link_all_deplibs_F77 # Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec +sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec @@ -15719,11 +15793,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15722: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15796: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15726: \$? = $ac_status" >&5 + echo "$as_me:15800: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15987,11 +16061,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15990: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16064: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15994: \$? = $ac_status" >&5 + echo "$as_me:16068: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16091,11 +16165,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16094: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16168: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16098: \$? = $ac_status" >&5 + echo "$as_me:16172: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17556,10 +17630,31 @@ linux*) # before this can be enabled. hardcode_into_libs=yes + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 17637 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on @@ -17943,6 +18038,9 @@ CC=$lt_compiler_GCJ # Is the compiler the GNU C compiler? with_gcc=$GCC_GCJ +gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` +gcc_ver=\`gcc -dumpversion\` + # An ERE matcher. EGREP=$lt_EGREP @@ -18076,11 +18174,11 @@ striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=$lt_predep_objects_GCJ +predep_objects=\`echo $lt_predep_objects_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=$lt_postdep_objects_GCJ +postdep_objects=\`echo $lt_postdep_objects_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. @@ -18092,7 +18190,7 @@ postdeps=$lt_postdeps_GCJ # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ +compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method @@ -18172,7 +18270,7 @@ variables_saved_for_relink="$variables_saved_for_relink" link_all_deplibs=$link_all_deplibs_GCJ # Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec +sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec @@ -18424,6 +18522,9 @@ CC=$lt_compiler_RC # Is the compiler the GNU C compiler? with_gcc=$GCC_RC +gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` +gcc_ver=\`gcc -dumpversion\` + # An ERE matcher. EGREP=$lt_EGREP @@ -18557,11 +18658,11 @@ striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=$lt_predep_objects_RC +predep_objects=\`echo $lt_predep_objects_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=$lt_postdep_objects_RC +postdep_objects=\`echo $lt_postdep_objects_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. @@ -18573,7 +18674,7 @@ postdeps=$lt_postdeps_RC # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_RC +compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method @@ -18653,7 +18754,7 @@ variables_saved_for_relink="$variables_saved_for_relink" link_all_deplibs=$link_all_deplibs_RC # Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec +sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec @@ -19567,6 +19668,7 @@ s,@host@,$host,;t t s,@host_cpu@,$host_cpu,;t t s,@host_vendor@,$host_vendor,;t t s,@host_os@,$host_os,;t t +s,@SED@,$SED,;t t s,@EGREP@,$EGREP,;t t s,@LN_S@,$LN_S,;t t s,@ECHO@,$ECHO,;t t diff --git a/AMDiS/libtool b/AMDiS/libtool index 41ace2e6..e7cf2e55 100755 --- a/AMDiS/libtool +++ b/AMDiS/libtool @@ -44,7 +44,7 @@ available_tags=" CXX F77" # ### BEGIN LIBTOOL CONFIG -# Libtool was configured on host NWRW15: +# Libtool was configured on host NWRW03: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -93,6 +93,9 @@ CC="gcc" # Is the compiler the GNU C compiler? with_gcc=yes +gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` +gcc_ver=`gcc -dumpversion` + # An ERE matcher. EGREP="grep -E" @@ -229,11 +232,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects="" +predep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects="" +postdep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place before the objects being linked to create a # shared library. @@ -245,7 +248,7 @@ postdeps="" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path="" +compiler_lib_search_path=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -325,10 +328,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/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/" +sys_lib_search_path_spec=`echo " /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/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-3.0.1 /usr/lib/qt-3.3/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" @@ -6760,7 +6763,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 NWRW15: +# Libtool was configured on host NWRW03: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -6809,6 +6812,9 @@ CC="g++" # Is the compiler the GNU C compiler? with_gcc=yes +gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` +gcc_ver=`gcc -dumpversion` + # An ERE matcher. EGREP="grep -E" @@ -6942,11 +6948,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o" +predep_objects=`echo "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o" +postdep_objects=`echo "/usr/lib/gcc/i386-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place before the objects being linked to create a # shared library. @@ -6958,7 +6964,7 @@ 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/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/../../.." +compiler_lib_search_path=`echo "-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/../../.." | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -7038,10 +7044,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/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/" +sys_lib_search_path_spec=`echo " /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/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-3.0.1 /usr/lib/qt-3.3/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" @@ -7065,7 +7071,7 @@ include_expsyms="" # ### BEGIN LIBTOOL TAG CONFIG: F77 -# Libtool was configured on host NWRW15: +# Libtool was configured on host NWRW03: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -7109,11 +7115,14 @@ LTCC="gcc" LTCFLAGS="-g -O2" # A language-specific compiler. -CC="g77" +CC="f95" # Is the compiler the GNU C compiler? with_gcc=yes +gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` +gcc_ver=`gcc -dumpversion` + # An ERE matcher. EGREP="grep -E" @@ -7250,11 +7259,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects="" +predep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects="" +postdep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place before the objects being linked to create a # shared library. @@ -7266,7 +7275,7 @@ postdeps="" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path="" +compiler_lib_search_path=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -7346,10 +7355,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/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/" +sys_lib_search_path_spec=`echo " /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/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-3.0.1 /usr/lib/qt-3.3/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" diff --git a/AMDiS/src/AMDiS.h b/AMDiS/src/AMDiS.h index 07ef0daf..d64d0761 100644 --- a/AMDiS/src/AMDiS.h +++ b/AMDiS/src/AMDiS.h @@ -6,13 +6,10 @@ #include "AdaptStationary.h" #include "Assembler.h" #include "BasisFunction.h" -#include "BiCGSolver.h" #include "Boundary.h" -#include "BiCGStab_M.h" #include "Boundary.h" #include "BoundaryCondition.h" #include "BoundaryManager.h" -#include "CGSolver.h" #include "CoarseningManager.h" #include "CoarseningManager1d.h" #include "CoarseningManager2d.h" @@ -25,7 +22,6 @@ #include "DOFIterator.h" #include "DOFMatrix.h" #include "DOFVector.h" -#include "DiagonalPreconditioner.h" #include "DirichletBC.h" #include "DualTraverse.h" #include "ElInfo.h" @@ -41,10 +37,11 @@ #include "FiniteElemSpace.h" #include "FixVec.h" #include "Flag.h" -#include "GMResSolver.h" #include "Global.h" #include "GridWriter.h" #include "InteriorBoundary.h" +#include "ITL_Preconditioner.h" +#include "ITL_Solver.h" #include "Lagrange.h" #include "LeafData.h" #include "Line.h" @@ -61,9 +58,7 @@ #include "NewtonS.h" #include "NonLinSolver.h" #include "NonLinUpdater.h" -#include "ODirSolver.h" #include "OEMSolver.h" -#include "OResSolver.h" #include "Operator.h" #include "Parameters.h" #include "Parametric.h" @@ -71,7 +66,6 @@ #include "PeriodicMap.h" #include "PeriodicBC.h" #include "PngWriter.h" -#include "Preconditioner.h" #include "ProblemScal.h" #include "ProblemVec.h" #include "ProblemInstat.h" diff --git a/AMDiS/src/AMDiS_fwd.h b/AMDiS/src/AMDiS_fwd.h new file mode 100644 index 00000000..f51a3fd8 --- /dev/null +++ b/AMDiS/src/AMDiS_fwd.h @@ -0,0 +1,82 @@ +// ============================================================================ +// == == +// == AMDiS - Adaptive multidimensional simulations == +// == == +// ============================================================================ +// == == +// == crystal growth group == +// == == +// == Stiftung caesar == +// == Ludwig-Erhard-Allee 2 == +// == 53175 Bonn == +// == germany == +// == == +// ============================================================================ +// == == +// == http://www.caesar.de/cg/AMDiS == +// == == +// ============================================================================ + +/** \file AMDiS_fwd.h */ + + +#ifndef AMDIS_AMDIS_FWD_INCLUDE +#define AMDIS_AMDIS_FWD_INCLUDE + +namespace AMDiS { + + class AdaptInfo; + class AdaptStationary; + class BasisFunction; + class BoundaryManager; + class CGSolver; + class CoarseningManager; + class DiagonalPreconditioner; + class DOFAdmin; + class DOFMatrix; + class Element; + class ElementMatrix; + class ElementVector; + class ElInfo; + class Estimator; + class FastQuadrature; + class FillInfo; + class FileWriterInterface; + class FiniteElemSpace; + class IdentityPreconditioner; + class InterpolRestrictMatrix; + class ITL_BasePreconditioner; + class LeafDataPeriodic; + class LevelAdmin; + class Marker; + class Mesh; + class MultiGridSortSolver; + class OEMSolver; + class Operator; + class ProblemInstat; + class ProblemIterationInterface; + class ProblemVec; + class PreconditionerScal; + class Quadrature; + class RCNeighbourList; + class RefinementManager; + class RobinBC; + class SystemVector; + class VertexVector; + + template<typename ReturnType, typename ArgumentType> class AbstractFunction; + template<typename VectorType> class MatVecMultiplier; + template<typename T> class DOFVectorBase; + template<typename T> class DOFVector; + template<typename T> class ITL_Preconditioner; + template<typename T> class Matrix; + template<typename T> class MatVecMultiplier; + template<typename T> class SolverMatrix; + template<typename T> class SparseVector; + template<typename T> class Vector; + + template <typename ITLSolver> class ITL_OEMSolver; + +} // namespace AMDiS + +#endif // AMDIS_AMDIS_FWD_INCLUDE diff --git a/AMDiS/src/AdaptStationary.h b/AMDiS/src/AdaptStationary.h index 8bf24778..c96204ee 100644 --- a/AMDiS/src/AdaptStationary.h +++ b/AMDiS/src/AdaptStationary.h @@ -34,13 +34,10 @@ #include "MemoryManager.h" #include "AdaptInfo.h" #include "AdaptBase.h" +#include "AMDiS_fwd.h" namespace AMDiS { - class Element; - template <typename T> class OEMSolver; - class ProblemIterationInterface; - // ============================================================================ // ===== class AdaptStationary ================================================ // ============================================================================ diff --git a/AMDiS/src/BFGS_Precond.cc b/AMDiS/src/BFGS_Precond.cc deleted file mode 100755 index 9ed4b20d..00000000 --- a/AMDiS/src/BFGS_Precond.cc +++ /dev/null @@ -1,68 +0,0 @@ -#include "BFGS_Precond.h" -#include "QN_Precond.h" -#include "FiniteElemSpace.h" -#include "DOFAdmin.h" -#include "DOFVector.h" -#include "DOFMatrix.h" -#include "DOFIterator.h" - -namespace AMDiS -{ - - void BFGS_Precond::addPair(DOFVector<double> *s, DOFVector<double> *y, - double sy) - { - FUNCNAME("BFGS_Preconditioner::addPair()"); - - if (!sy) - sy = *s * *y; - TEST_EXIT(sy > 0)("Vectors do not satisfy the curvature condition!\n"); - - BFGS_Vectors newPair(s->getFESpace()); - newPair.setVectors(s, y, sy); - - if (k < m) { - k++; - } else { - pairsVec.pop_back(); - } - - pairsVec.push_front(newPair); - - return; - } - - void BFGS_Precond::precon(DOFVector<double> *vec) - { - FUNCNAME("BFGS_Preconditioner::precon()"); - - int i = 0; - double beta; - double *alpha = GET_MEMORY(double, k); - - std::deque<BFGS_Vectors>::iterator pairsIterator(pairsVec.begin()); - - while (pairsIterator != pairsVec.end()) { - alpha[i] = pairsIterator->s * *vec; - alpha[i] /= pairsIterator->sy; - aXpY(-alpha[i], pairsIterator->y, *vec, bound); - ++i; - ++pairsIterator; - } - - diagPrecond(*matrix[row], vec, bound); - - while (pairsIterator != pairsVec.begin()) { - --pairsIterator; - --i; - beta = pairsIterator->y * *vec; - beta /= pairsIterator->sy; - aXpY(alpha[i]-beta, pairsIterator->s, *vec, bound); - } - - FREE_MEMORY(alpha, double, k); - - return; - } - -} diff --git a/AMDiS/src/BFGS_Precond.h b/AMDiS/src/BFGS_Precond.h deleted file mode 100755 index 56293303..00000000 --- a/AMDiS/src/BFGS_Precond.h +++ /dev/null @@ -1,168 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file BFGS_Precond.h */ - -#ifndef AMDIS_BFGS_PRECONDITIONER_H -#define AMDIS_BFGS_PRECONDITIONER_H - -#include "Parameters.h" -#include "Preconditioner.h" -#include "QN_Precond.h" - -namespace AMDiS -{ - - template<typename T> class DOFVector; - template<typename T> class OEMSolver; - - // ============================================================================ - // ===== class BFGS_Vectors =================================================== - // ============================================================================ - - // Auxiliar class por storing pairs of DOFVectors and their scalar products. - class BFGS_Vectors - { - public: - MEMORY_MANAGED(BFGS_Vectors); - - /** \brief - * Constructor. - */ - BFGS_Vectors(const FiniteElemSpace *fe_space) - : s(fe_space, "BFGS->s"), y(fe_space, "BFGS->y") - {}; - - inline void setVectors(DOFVector<double> *s_, DOFVector<double> *y_, - double sy_=0.0) - { - s = *s_; - y = *y_; - - if (!sy_) - sy = s * y; - else - sy = sy_; - - return; - }; - - private: - DOFVector<double> s, y; - double sy; - - friend class BFGS_Precond; - }; - - // ============================================================================ - // ===== class BFGS_Precond =================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * BFGS preconditioner. - */ - class BFGS_Precond : public PreconditionerScal - { - public: - MEMORY_MANAGED(BFGS_Precond); - - /** \brief - * Creator class used in the PreconditionerMap. - */ - class Creator : public PreconditionerScalCreator - { - public: - MEMORY_MANAGED(Creator); - - /** \brief - * Creates a new BFGS Preconditioner. - */ - PreconditionerScal *create() - { - return NEW BFGS_Precond(size, row); - }; - }; - - /** \brief - * Constructor. - */ - BFGS_Precond(int size_ = 1, int row_ = 0) : PreconditionerScal(size_, row_) { - k = 0; - - m = 2 * Global::getGeo(WORLD); - GET_PARAMETER(1, "preconditioner->max. number of pairs", "%d", &m); - m = std::max(0, std::min(m, 32)); - }; - - /** \brief - * Destructor. - */ - virtual ~BFGS_Precond() {}; - - /** \brief - * realisation of Preconditioner::init - */ - inline void init() - { - FUNCNAME("BFGS_Precond::init()"); - TEST_EXIT(matrix[row])("no matrix\n"); - }; - - /** \brief - * realisation of Preconditioner::precon - */ - void precon(DOFVector<double> *vec); - - /** \brief - * realisation of Preconditioner::exit - */ - inline void exit() {}; - - - /* ----- Specific functions ----- */ - - /** \brief - * add pair of vectors - */ - void addPair(DOFVector<double> *s, DOFVector<double> *y, double sy = 0.0); - - protected: - - /** \brief - * list of pairs - */ - std::deque<BFGS_Vectors> pairsVec; - - /** \brief - * maximal number of pairs - */ - int m; - - /** \brief - * actual number of pairs - */ - int k; - }; - -} - -#endif // AMDIS_BFGS_PRECONDITIONER_H diff --git a/AMDiS/src/BasisFunction.h b/AMDiS/src/BasisFunction.h index 62283a6a..24206efe 100644 --- a/AMDiS/src/BasisFunction.h +++ b/AMDiS/src/BasisFunction.h @@ -23,6 +23,7 @@ #define AMDIS_BASISFUNCTION_H #include <string> +#include "AMDiS_fwd.h" #include "Global.h" #include "Boundary.h" #include "MatrixVector.h" @@ -38,7 +39,7 @@ namespace AMDiS { class Quadrature; template <typename ReturnType, typename ArgumentType> class AbstractFunction; - template <typename T> class DOFVector; + // template <typename T> class DOFVector; template <typename T> class DOFIndexed; template <typename T> class DimVec; template <typename T> class DimMat; @@ -345,7 +346,7 @@ namespace AMDiS { * coefficient vector uh. */ double evalUh(const DimVec<double>& lambda, const double* uh) const; - + /** \brief * Evaluates elements value at barycentric coordinates lambda with local * coefficient vector uh. If val is not NULL the result will be stored @@ -354,7 +355,7 @@ namespace AMDiS { */ const WorldVector<double>& evalUh(const DimVec<double>& lambda, const WorldVector<double>* uh, WorldVector<double>* val) const; - + /** \brief * Evaluates the gradient at barycentric coordinates lambda. Lambda is the * Jacobian of the barycentric coordinates. uh is the local coefficient diff --git a/AMDiS/src/BiCGSolver.h b/AMDiS/src/BiCGSolver.h deleted file mode 100644 index e428ad4a..00000000 --- a/AMDiS/src/BiCGSolver.h +++ /dev/null @@ -1,101 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file BiCGSolver.h */ - -#ifndef AMDIS_BICGSOLVER_H -#define AMDIS_BICGSOLVER_H - -#include "OEMSolver.h" -#include "MemoryManager.h" -#include "CreatorInterface.h" - -namespace AMDiS { - - // ============================================================================ - // ===== class BiCGSolver ===================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Solves a linear system by a stabilized BiCG method and can be used for - * symmetric system matrices. - */ - template<typename VectorType> - class BiCGSolver : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(BiCGSolver<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new BiCGSolver object. - */ - OEMSolver<VectorType>* create() { - return NEW BiCGSolver<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - BiCGSolver(std::string name); - - /** \brief - * destructor - */ - ~BiCGSolver(); - - protected: - /** \brief - * realisation of OEMSolver::solveSystem - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b, bool reuseMatrix); - - /** \brief - * realisation of OEMSolver::init - */ - void init(); - - /** \brief - * realisation of OEMSolver::exit - */ - void exit(); - - private: - // pointer to memory needed for solveSystem - VectorType *rstar, *d, *s, *CAd, *h; - }; - -} - -#include "BiCGSolver.hh" - -#endif // AMDIS_BICGSOLVER_H diff --git a/AMDiS/src/BiCGSolver.hh b/AMDiS/src/BiCGSolver.hh deleted file mode 100644 index 14965297..00000000 --- a/AMDiS/src/BiCGSolver.hh +++ /dev/null @@ -1,193 +0,0 @@ -#include "Preconditioner.h" - -namespace AMDiS { - - template<typename VectorType> - BiCGSolver<VectorType>::BiCGSolver(std::string name) - : OEMSolver<VectorType>(name), - rstar(NULL), d(NULL), s(NULL), CAd(NULL), h(NULL) - { - } - - template<typename VectorType> - BiCGSolver<VectorType>::~BiCGSolver() - {} - - template<typename VectorType> - void BiCGSolver<VectorType>::init() - { - rstar = this->vectorCreator->create(); - d = this->vectorCreator->create(); - s = this->vectorCreator->create(); - CAd = this->vectorCreator->create(); - h = this->vectorCreator->create(); - } - - template<typename VectorType> - void BiCGSolver<VectorType>::exit() - { - this->vectorCreator->free(rstar); - this->vectorCreator->free(d); - this->vectorCreator->free(s); - this->vectorCreator->free(CAd); - this->vectorCreator->free(h); - } - - template<typename VectorType> - int BiCGSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, bool reuseMatrix) - { - FUNCNAME("BiCGSolver::solveSystem"); - VectorType *t = h; - - double res, old_res = -1.0; - double rh1, rh2, dad, alpha, ast, att, omega, beta; - int iter; - - const double TOL = 1.e-30; - - /*--------------------------------------------------------------------------*/ - /*--- Initalization ------------------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - if (norm(b) < TOL) - { - INFO(this->info,2)("b == 0, x = 0 is the solution of the linear system\n"); - set(*x, 0.0); - this->residual = 0.0; - return(0); - } - - // h = Ax - matVec->matVec(NoTranspose, *x, *h); - - // h -= b - *h -= *b; - - // rstar = h; - *rstar = *h; - - // preconditioning - if(this->leftPrecon) this->leftPrecon->precon(h); - if(this->rightPrecon) this->rightPrecon->precon(b); - - /*--------------------------------------------------------------------------*/ - /*--- check initial residual ---------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - res = norm(h); - - START_INFO(); - if (SOLVE_INFO(0, res, &old_res)) - return(0); - - // d = h - *d = *h; - - // rh1 = h*rstar - rh1 = *h * *rstar; - - /*--------------------------------------------------------------------------*/ - /*--- Iteration ----------------------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - for (iter = 1; iter <= this->max_iter; iter++) - { - /*--------------------------------------------------------------------------*/ - /*--- calculate CA.d and CA.d*rstar --------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - // CAd = Ad - matVec->matVec(NoTranspose, *d, *CAd); - - if(this->leftPrecon) this->leftPrecon->precon(CAd); - - // dad = CAd * rstar; - dad = *CAd * *rstar; - - if (abs(rh1) < TOL) { - BREAK_INFO("(h,r^*)_2 = 0", iter, res, &old_res); - return(iter); - } - if (abs(dad) < TOL) { - BREAK_INFO("(Ad,d^*)_2 = 0", iter, res, &old_res); - return(iter); - } - - /*-------------------------------------------------------------------------*/ - /*--- update s and t ----------------------------------------------------*/ - /*-------------------------------------------------------------------------*/ - - alpha = rh1/dad; - - // s = h - *s = *h; - - // s = -alpha CAd + s - axpy(-alpha, *CAd, *s); - - // t = As - matVec->matVec(NoTranspose, *s, *t); - - /*--------------------------------------------------------------------------*/ - /*--- calculate omega ----------------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - // ast = s*t - ast = *s * *t; - - // att = t*t - att = *t * *t; - - if (abs(ast) < TOL) { - INFO(this->info,2)("omega = 0"); - ast = ast > 0 ? TOL : -TOL; - } - - if (att < TOL) - { - INFO(this->info,2)("t = 0"); - att = TOL; - } - - omega= ast/att; - - /*--------------------------------------------------------------------------*/ - /*--- update x and calculate new h --------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - // x = -alpha d + x - axpy(-alpha, *d, *x); - - // x = -omega s + x - axpy(-omega, *s, *x); - - // h = s - omega * h - *h *= -omega; - *h += *s; - - res = norm(h); - if (SOLVE_INFO(iter, res, &old_res)) - return(iter); - - if (this->leftPrecon) this->leftPrecon->precon(t); - - // rh2 = h * rstar - rh2 = *h * *rstar; - - beta= (rh2/rh1)* (alpha/omega); - - // d = -omega CAd + d - axpy(-omega, *CAd, *d); - - // d = h + beta d - *d *= beta; - *d += *h; - - rh1 = rh2; - } - - return 0; // never reached ! - } - -} diff --git a/AMDiS/src/BiCGStab.h b/AMDiS/src/BiCGStab.h deleted file mode 100644 index e965c80d..00000000 --- a/AMDiS/src/BiCGStab.h +++ /dev/null @@ -1,104 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file BiCGStab.h */ - -#ifndef AMDIS_BiCGStab_H -#define AMDIS_BiCGStab_H - -#include "OEMSolver.h" -#include "MemoryManager.h" -#include "CreatorInterface.h" - -namespace AMDiS -{ - - // ============================================================================ - // ===== class BiCGStab ======================================================= - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Solves a linear system by the stabilized BiCG method. - * Can be used for general system matrices. - */ - template<typename VectorType> - class BiCGStab : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(BiCGStab<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new BiCGStab object. - */ - OEMSolver<VectorType>* create() - { - return NEW BiCGStab<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - BiCGStab(std::string name); - - /** \brief - * destructor - */ - ~BiCGStab(); - - protected: - /** \brief - * realisation of OEMSolver::solveSystem - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix); - - /** \brief - * realisation of OEMSolver::init - */ - void init(); - - /** \brief - * realisation of OEMSolver::exit - */ - void exit(); - - private: - // pointer to memory needed for solveSystem - VectorType *r, *rstar, *p, *v, *t, *xmin; - }; - -} - -#include "BiCGStab.hh" - -#endif // AMDIS_BiCGStab_H diff --git a/AMDiS/src/BiCGStab.hh b/AMDiS/src/BiCGStab.hh deleted file mode 100644 index 7479cfdf..00000000 --- a/AMDiS/src/BiCGStab.hh +++ /dev/null @@ -1,239 +0,0 @@ -#include "Preconditioner.h" - -namespace AMDiS -{ - - template<typename VectorType> - BiCGStab<VectorType>::BiCGStab(std::string name) - : OEMSolver<VectorType>(name), - r(NULL), - rstar(NULL), - p(NULL), - v(NULL), - t(NULL), - xmin(NULL) - {} - - template<typename VectorType> - BiCGStab<VectorType>::~BiCGStab() - {} - - template<typename VectorType> - void BiCGStab<VectorType>::init() - { - r = this->vectorCreator->create(); - rstar = this->vectorCreator->create(); - p = this->vectorCreator->create(); - v = this->vectorCreator->create(); - t = this->vectorCreator->create(); - xmin = this->vectorCreator->create(); - } - - template<typename VectorType> - void BiCGStab<VectorType>::exit() - { - this->vectorCreator->free(r); - this->vectorCreator->free(rstar); - this->vectorCreator->free(p); - this->vectorCreator->free(v); - this->vectorCreator->free(t); - this->vectorCreator->free(xmin); - } - - template<typename VectorType> - int BiCGStab<VectorType>::solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix) - { - FUNCNAME("BiCGStab::solveSystem"); - - double res, old_res = -1.0; - double rh1, rh2, dad, alpha, ast, att, omega, beta; - int iter; - - const double TOL = 1e-30; - - /*------------------------------------------------------------------------*/ - /*--- Initalization ----------------------------------------------------*/ - /*------------------------------------------------------------------------*/ - - *p = *b; - if (this->leftPrecon) - this->leftPrecon->precon(p); - double normB = norm(p); - - if (normB < TOL) { - INFO(this->info,2)("b == 0; x = 0 is the solution of the linear system\n"); - setValue(*x, 0.0); - this->residual = 0.0; - return(0); - } - - double save_tolerance = this->tolerance; - if (this->relative) - this->tolerance *= normB; - - *xmin = *x; - int imin = 0; - - // h = Ax - mv->matVec(NoTranspose, *x, *r); - - // h -= b - *r *= -1.0; - *r += *b; - - // preconditioning - if (this->leftPrecon) this->leftPrecon->precon(r); - - // rstar = h; - *rstar = *r; - - /*--- check initial residual -------------------------------------------*/ - - res = norm(r); - - START_INFO(); - if (SOLVE_INFO(0, res, &old_res)) { - if (this->relative) - this->tolerance = save_tolerance; - return(0); - } - - double normrmin = res; - - // d = h - *p = *r; - - // rh1 = h*rstar - rh1 = *r * *rstar; - - /*------------------------------------------------------------------------*/ - /*--- Iteration --------------------------------------------------------*/ - /*------------------------------------------------------------------------*/ - - for (iter = 1; iter <= this->max_iter; iter++) { - /*--- calculate CA.d and CA.d*rstar ----------------------------------*/ - - // CAd = Ad - mv->matVec(NoTranspose, *p, *v); - - if (this->leftPrecon) this->leftPrecon->precon(v); - - // dad = CAd * rstar; - dad = *v * *rstar; - - alpha = rh1/dad; - - if (abs(alpha) > 1e+6 * (res/norm(v))) { - BREAK_INFO("(Ad,d^*)_2 = 0", iter, res, &old_res); - break; - } - - /*--- update s and t ------------------------------------------------*/ - - // s = h - - // s = -alpha CAd + s - axpy(-alpha, *v, *r); - - // x = -alpha d + x - axpy(alpha, *p, *x); - - res = norm(r); - if (res <= this->tolerance) { - double red = res/old_res; - INFO(this->info,2)("%5d | %12.5e | %8.2e\n", iter, res, red); - INFO(this->info,6)("finished successfully with %d iterations\n", iter); - if (this->relative) - this->tolerance = save_tolerance; - return(iter); - } - - if (res < normrmin) { // update minimal norm quantities - normrmin = res; - *xmin = *x; - imin = iter; - } else if (res > normrmin * 1e+6) { - INFO(this->info,2)("Linear solver diverges.\n"); - INFO(this->info,2)("Current iteration: %d.\n", iter); - INFO(this->info,2)("Current residual: %e.\n", res); - break; - } - - // t = As - mv->matVec(NoTranspose, *r, *t); - - if (this->leftPrecon) - this->leftPrecon->precon(t); - - /*--- calculate omega ------------------------------------------------*/ - - // ast = s*t - ast = *r * *t; - - // att = t*t - att = *t * *t; - - omega = ast/att; - - if (abs(omega) <= 1e-6 * (res/norm(t))) { - BREAK_INFO("omega = 0", iter, res, &old_res); - break; - } - - /*--- update x and calculate new h ----------------------------------*/ - - // x = -omega s + x - axpy(omega, *r, *x); - - // h = s - omega * h - axpy(-omega, *t, *r); - - res = norm(r); - if (SOLVE_INFO(iter, res, &old_res) == 1) { - if (this->relative) - this->tolerance = save_tolerance; - return(iter); - } - - if (res < normrmin) { // update minimal norm quantities - normrmin = res; - *xmin = *x; - imin = iter; - } else if (res > normrmin * 1e+6) { - INFO(this->info,2)("Linear solver diverges.\n"); - INFO(this->info,2)("Current iteration: %d.\n", iter); - INFO(this->info,2)("Current residual: %e.\n", res); - break; - } - - // rh2 = h * rstar - rh2 = *r * *rstar; - - beta = (rh2/rh1) * (alpha/omega); - - // d = -omega CAd + d - axpy(-omega, *v, *p); - - // d = h + beta d - *p *= beta; - *p += *r; - - rh1 = rh2; - } - - // returned solution is first with minimal residual - *x = *xmin; - iter = imin; - this->residual = normrmin; - - if (this->relative) - this->tolerance = save_tolerance; - - INFO(this->info,2)("The minimal norm was %e; it was achieved in iteration %d.\n", - this->residual, iter); - - return(iter); - } - -} diff --git a/AMDiS/src/BiCGStab2.h b/AMDiS/src/BiCGStab2.h deleted file mode 100644 index 054a5bfc..00000000 --- a/AMDiS/src/BiCGStab2.h +++ /dev/null @@ -1,103 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file BiCGStab2.h */ - -#ifndef AMDIS_BiCGStab2_H -#define AMDIS_BiCGStab2_H - -#include "OEMSolver.h" -#include "MemoryManager.h" - -namespace AMDiS -{ - - // ============================================================================ - // ===== class BiCGStab2 ====================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Solves a linear system by the stabilized BiCG method. - * Can be used for general non-singular system matrices. - */ - template<typename VectorType> - class BiCGStab2 : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(BiCGStab2<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new BiCGStab2 object. - */ - OEMSolver<VectorType>* create() - { - return NEW BiCGStab2<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - BiCGStab2(std::string name); - - /** \brief - * destructor - */ - ~BiCGStab2(); - - protected: - /** \brief - * realisation of OEMSolver::solveSystem - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix); - - /** \brief - * realisation of OEMSolver::init - */ - void init(); - - /** \brief - * realisation of OEMSolver::exit - */ - void exit(); - - private: - // pointer to memory needed for solveSystem - VectorType *r, *rstar, *u, *v, *s, *w, *t, *xmin; - }; - -} - -#include "BiCGStab2.hh" - -#endif // AMDIS_BiCGStab2_H diff --git a/AMDiS/src/BiCGStab2.hh b/AMDiS/src/BiCGStab2.hh deleted file mode 100644 index e0bdedbc..00000000 --- a/AMDiS/src/BiCGStab2.hh +++ /dev/null @@ -1,228 +0,0 @@ -#include "Preconditioner.h" - -namespace AMDiS -{ - - template<typename VectorType> - BiCGStab2<VectorType>::BiCGStab2(std::string name) - : OEMSolver<VectorType>(name), - r(NULL), rstar(NULL), u(NULL), v(NULL), s(NULL), w(NULL), t(NULL), - xmin(NULL) - {} - - template<typename VectorType> - BiCGStab2<VectorType>::~BiCGStab2() - {} - - template<typename VectorType> - void BiCGStab2<VectorType>::init() - { - r = this->vectorCreator->create(); - rstar = this->vectorCreator->create(); - u = this->vectorCreator->create(); - v = this->vectorCreator->create(); - s = this->vectorCreator->create(); - w = this->vectorCreator->create(); - t = this->vectorCreator->create(); - xmin = this->vectorCreator->create(); - } - - template<typename VectorType> - void BiCGStab2<VectorType>::exit() - { - this->vectorCreator->free(r); - this->vectorCreator->free(rstar); - this->vectorCreator->free(u); - this->vectorCreator->free(v); - this->vectorCreator->free(s); - this->vectorCreator->free(w); - this->vectorCreator->free(t); - this->vectorCreator->free(xmin); - } - - template<typename VectorType> - int BiCGStab2<VectorType>::solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix) - { - FUNCNAME("BiCGStab2::solveSystem()"); - - double res, old_res = -1.0; - double rho0, alpha, omega1, omega2, rho1, beta, gamma, mu, nu, tau; - int iter; - - const double TOL = 1e-30; - - /*------------------------------------------------------------------------*/ - /*--- Initalization ----------------------------------------------------*/ - /*------------------------------------------------------------------------*/ - - *u = *b; - if (this->leftPrecon) - this->leftPrecon->precon(u); - double normB = norm(u); - - if (normB < TOL) { - INFO(this->info, 2)("b == 0; x = 0 is the solution of the linear system\n"); - setValue(*x, 0.0); - this->residual = 0.0; - return(0); - } - - double save_tolerance = this->tolerance; - if (this->relative) - this->tolerance *= normB; - - *xmin = *x; - int imin = 0; - - // r = b - Ax - mv->matVec(NoTranspose, *x, *r); - *r *= -1.0; - *r += *b; - - if (this->leftPrecon) - this->leftPrecon->precon(r); - - /*--- check initial residual -------------------------------------------*/ - - res = norm(r); - - START_INFO(); - if (SOLVE_INFO(0, res, &old_res)) { - if (this->relative) - this->tolerance = save_tolerance; - return(0); - } - - double normrmin = res; - - // setting for the method - *rstar = *r; - *rstar *= 1.0 / res; - - rho0 = 1.0; - alpha = 0.0; - omega2 = 1.0; - setValue(*u, 0.0); - - /*------------------------------------------------------------------------*/ - /*--- Iteration --------------------------------------------------------*/ - /*------------------------------------------------------------------------*/ - - for (iter = 1; iter <= this->max_iter; iter++) { - rho0 *= -omega2; - - /*--- even BiCG step -------------------------------------------------*/ - - // updating u - rho1 = *r * *rstar; - beta = alpha * rho1 / rho0; - rho0 = rho1; - *u *= -beta; - *u += *r; - - // computing v - mv->matVec(NoTranspose, *u, *v); - if (this->leftPrecon) - this->leftPrecon->precon(v); - - // Updating x and r - gamma = *v * *rstar; - alpha = rho0 / gamma; - axpy(alpha, *u, *x); - axpy(-alpha, *v, *r); - - // computing s - mv->matVec(NoTranspose, *r, *s); - if (this->leftPrecon) - this->leftPrecon->precon(s); - - /*--- odd BiCG step --------------------------------------------------*/ - - // updating v - rho1 = *s * *rstar; - beta = alpha * rho1 / rho0; - rho0 = rho1; - *v *= -beta; - *v += *s; - - // computing w - mv->matVec(NoTranspose, *v, *w); - if (this->leftPrecon) - this->leftPrecon->precon(w); - - // updating u, r and s - gamma = *w * *rstar; - alpha = rho0 / gamma; - *u *= -beta; - *u += *r; - axpy(-alpha, *v, *r); - axpy(-alpha, *w, *s); - - // computing t - mv->matVec(NoTranspose, *s, *t); - if (this->leftPrecon) - this->leftPrecon->precon(t); - - /*--- CGR(2) part ----------------------------------------------------*/ - - // computing constants - omega1 = *r * *s; - mu = *s * *s; - nu = *s * *t; - tau = *t * *t; - omega2 = *r * *t; - tau -= nu * nu / mu; - omega2 -= nu * omega1 / mu; - omega2 /= tau; - omega1 -= nu * omega2; - omega1 /= mu; - - // updating x - axpy(omega1, *r, *x); - axpy(omega2, *s, *x); - axpy(alpha, *u, *x); - - // updating r - axpy(-omega1, *s, *r); - axpy(-omega2, *t, *r); - /*--- checking accuracy ----------------------------------------------*/ - - res = norm(r); - if (SOLVE_INFO(iter, res, &old_res) == 1) { - if (this->relative) - this->tolerance = save_tolerance; - return(iter); - } - - // update minimal norm quantities - if (res < normrmin) { - normrmin = res; - *xmin = *x; - imin = iter; - } else if (res > normrmin * 1e+6) { - INFO(this->info,2)("Linear solver diverges.\n"); - INFO(this->info,2)("Current iteration: %d.\n", iter); - INFO(this->info,2)("Current residual: %e.\n", res); - break; - } - - // updating u - axpy(-omega1, *v, *u); - axpy(-omega2, *w, *u); - } - - // returned solution is first with minimal residual - *x = *xmin; - iter = imin; - this->residual = normrmin; - - if (this->relative) - this->tolerance = save_tolerance; - - INFO(this->info,2)("The minimal norm was %e; it was achieved in iteration %d.\n", - this->residual, iter); - - return(iter); - } -} diff --git a/AMDiS/src/BiCGStab_M.hh b/AMDiS/src/BiCGStab_M.hh deleted file mode 100644 index 57789557..00000000 --- a/AMDiS/src/BiCGStab_M.hh +++ /dev/null @@ -1,191 +0,0 @@ -namespace AMDiS { - - template<typename VectorType> - BiCGStab_M<VectorType>::BiCGStab_M(std::string name) : OEMSolver<VectorType>(name) {} - - template<typename VectorType> - BiCGStab_M<VectorType>::~BiCGStab_M() {} - - template<typename VectorType> - void BiCGStab_M<VectorType>::init() - { - r = this->vectorCreator->create(); - rt = this->vectorCreator->create(); - p = this->vectorCreator->create(); - v = this->vectorCreator->create(); - t = this->vectorCreator->create(); - ph = this->vectorCreator->create(); - sh = this->vectorCreator->create(); - xmin = this->vectorCreator->create(); - } - - template<typename VectorType> - void BiCGStab_M<VectorType>::exit() - { - this->vectorCreator->free(r); - this->vectorCreator->free(rt); - this->vectorCreator->free(p); - this->vectorCreator->free(v); - this->vectorCreator->free(t); - this->vectorCreator->free(ph); - this->vectorCreator->free(sh); - this->vectorCreator->free(xmin); - } - - template<typename VectorType> - int BiCGStab_M<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, bool reuseMatrix) - { - FUNCNAME("BiCGStab_M::solveSystem"); - double old_res = -1.0; - int iter, imin; - double n2b, normrmin, rho, rho1, omega, alpha = 0.0, beta, rtv; - - const double TOL_0 = 1e-30, TOL_INF = 1e+30; - - double save_tolerance = this->tolerance; - - // Check for all zero right hand side vector => all zero solution - n2b = norm(b); // norm of rhs vector b - if (n2b < TOL_0) - { - INFO(this->info,2)("b == 0, x = 0 is the solution of the linear system\n"); - set(*x, 0.0); // solution is all zeros - this->residual = 0.0; // residual is zero - return(0); // no iterations need to be performed - } - - if (this->relative) this->tolerance *= n2b; - - // Set up for the method - *xmin = *x; // iterate which has minimal residual so far - imin = 0; // iteration at which xmin was computed - matVec->matVec(NoTranspose, *x, *r); - *r *= -1.0; - *r += *b; // zero-th order residual - this->residual = norm(r); // norm of the residual - - START_INFO(); - if (SOLVE_INFO(0, this->residual, &old_res) == 1) - { - if (this->relative) this->tolerance = save_tolerance; - return(0); // initial guess is a good enough solution - } - - *rt = *r; // shadow residual - normrmin = this->residual; // norm of residual from xmin - rho = 1.0; - omega = 1.0; - - // Loop over maxit iterations (unless convergence or failure) - for (iter = 1; iter <= this->max_iter; iter++) - { - rho1 = rho; - rho = *r * *rt; - if (abs(rho) < TOL_0 || abs(rho) > TOL_INF) - { - BREAK_INFO("R and RT have become orthogonal", iter, this->residual, &old_res); - break; - } - - if (iter == 1) - *p = *r; - else - { - beta = (rho/rho1) * (alpha/omega); - if (abs(beta) < TOL_0 || abs(beta) > TOL_INF) - { - BREAK_INFO("beta has become too small or too large to continue " - "computing", iter, this->residual, &old_res); - break; - } - axpy(-omega, *v, *p); - *p *= beta; - *p += *r; - } - - *ph = *p; - if (this->leftPrecon) - this->leftPrecon->precon(ph); - - matVec->matVec(NoTranspose, *ph, *v); - - rtv = *v * *rt; - if (abs(rtv) < TOL_0 || abs(rtv) > TOL_INF) - { - BREAK_INFO("V and RT have become orthogonal", iter, this->residual, &old_res); - break; - } - - alpha = rho / rtv; - if (abs(alpha) > TOL_INF) - { - BREAK_INFO("alpha has become too large to continue computing", - iter, this->residual, &old_res); - break; - } - - axpy(alpha, *ph, *x); // form the "half" iterate - axpy(-alpha, *v, *r); // and its residual - this->residual = norm(r); - - if (this->residual < normrmin) // update minimal norm quantities - { - normrmin = this->residual; - *xmin = *x; - imin = iter; - } - - if (abs(alpha) < TOL_0) - { - BREAK_INFO("Stagnation of the method", iter, this->residual, &old_res); - break; // stagnation of the method - } - - *sh = *r; // residual associated with xhalf - if (this->leftPrecon) - this->leftPrecon->precon(sh); - matVec->matVec(NoTranspose, *sh, *t); - - omega = (*t * *r) / (*t * *t); - if (abs(omega) > TOL_INF) - { - BREAK_INFO("omega has become too large to continue computing", - iter, this->residual, &old_res); - break; - } - - axpy(omega, *sh, *x); // update x - axpy(-omega, *t, *r); - this->residual = norm(r); - if (SOLVE_INFO(iter, this->residual, &old_res) == 1) - { - if (this->relative) this->tolerance = save_tolerance; - return(iter); // check for convergence - } - - if (this->residual < normrmin) // update minimal norm quantities - { - normrmin = this->residual; - *xmin = *x; - imin = iter; - } - - if (abs(omega) < TOL_0) - { - BREAK_INFO("T and S have become orthogonal", iter, this->residual, &old_res); - break; // stagnation of the method - } - } // end for (iter = 1; iter <= this->max_iter; iter++) - - // returned solution is first with minimal residual - *x = *xmin; - iter = imin; - this->residual = normrmin; - - if (this->relative) this->tolerance = save_tolerance; - - return(iter); - } - -} diff --git a/AMDiS/src/Boundary.h b/AMDiS/src/Boundary.h index 9769aa1a..c5ef7f33 100644 --- a/AMDiS/src/Boundary.h +++ b/AMDiS/src/Boundary.h @@ -41,6 +41,116 @@ namespace AMDiS { /// Type specifier for the different boundary types typedef signed int BoundaryType; + // /** \ingroup Triangulation + // * \brief + // * Holds information about the type of boundary associated to an edge/face, + // * and how new vertices are projected to the boundary in the case of curved + // * boundaries. + // + // class Boundary + // { + // public: + // MEMORY_MANAGED(Boundary); + + // /** \brief + // * constructor + // + // Boundary(BoundaryType type=0) { + // bound = type; + // }; + + // /** \brief + // * copy constructor + // + // Boundary(const Boundary& old) { bound = old.getBound(); }; + + // /** \brief + // * destructor + // + // virtual ~Boundary() {}; + + // /** \brief + // * assignment operator + // + // Boundary& operator=(const Boundary& old) { + // if (this!=&old) bound = old.getBound(); + // return *this; + // }; + + // /** \brief + // * Returns + // * -true: if a new vertex should be projected to a curved boundary + // * -false: otherwise + // + // virtual bool interpolateBoundary() { return false; }; + + // /** \brief + // * Projection to the curved boundary + // + // virtual void interpolateBoundary(WorldVector<double>& ) {}; + + // /** \brief + // * Returns \ref bound + // + // inline const BoundaryType getBound() const { return bound; }; + + // /** \brief + // * Returns + // * -true: is \ref bound is INTERIOR + // * -false: otherwise + // + // inline const bool isInterior() const {return (bound == INTERIOR);}; + + // /** \brief + // * Returns + // * -true: is \ref bound is DIRICHLET + // * -false: otherwise + // + // inline const bool isDirichlet() const {return (bound == DIRICHLET);}; + + // /** \brief + // * Returns + // * -true: is \ref bound is NEUMANN + // * -false: otherwise + // + // inline const bool isNeumann() const {return (bound == NEUMANN);}; + + // /** \brief + // * Returns + // * -true: is \ref bound is ROBIN + // * -false: otherwise + // + // inline const bool isRobin() const {return (bound == ROBIN);}; + + // /** \brief + // * Returns the new value of \ref bound with respect to its old value and + // * the value of bound_. + // + // BoundaryType newVal(const BoundaryType bound_); + + // /** \brief + // * Returns the Boundary with given type from \ref boundaryMap. + // + // static Boundary* getBoundary(BoundaryType type); + + // /** \brief + // * Adds Boundary b to \ref boundaryMap. + // + // //static void addBoundary(Boundary *b); + + // protected: + // /** \brief + // * type of this boundary + // + // BoundaryType bound; + + // protected: + // /** \brief + // * stl map of all existing boundaries. + // + // static ::std::map<BoundaryType, Boundary*> boundaryMap; + // }; + BoundaryType newBound(BoundaryType oldBound, BoundaryType newBound); } diff --git a/AMDiS/src/BoundaryCondition.h b/AMDiS/src/BoundaryCondition.h index 3f9d85df..7f403143 100644 --- a/AMDiS/src/BoundaryCondition.h +++ b/AMDiS/src/BoundaryCondition.h @@ -24,10 +24,10 @@ #include "Boundary.h" #include "FiniteElemSpace.h" +#include "AMDiS_fwd.h" namespace AMDiS { - class DOFMatrix; template<typename T> class DOFVectorBase; class Estimator; class ElInfo; @@ -43,7 +43,7 @@ namespace AMDiS { * Sub class of BoundaryCondition. Local boundary conditions are filled * while mesh traversal. */ - class BoundaryCondition + class BoundaryCondition //: public BoundaryCondition { public: /** \brief @@ -56,30 +56,23 @@ namespace AMDiS { rowFESpace(rowFESpace_), colFESpace(colFESpace_) { - if (!colFESpace) - colFESpace = rowFESpace; + if(!colFESpace) colFESpace = rowFESpace; }; /** \brief * Returns \ref boundaryType. */ - inline BoundaryType getBoundaryType() { - return boundaryType; - }; + inline BoundaryType getBoundaryType() { return boundaryType; }; /** \brief * Returns \ref rowFESpace. */ - inline const FiniteElemSpace *getRowFESpace() { - return rowFESpace; - }; + inline const FiniteElemSpace *getRowFESpace() { return rowFESpace; }; /** \brief * Returns \ref rowFESpace. */ - inline const FiniteElemSpace *getColFESpace() { - return colFESpace; - }; + inline const FiniteElemSpace *getColFESpace() { return colFESpace; }; virtual void initMatrix(DOFMatrix*) {}; @@ -121,17 +114,13 @@ namespace AMDiS { */ virtual double boundResidual(ElInfo *elInfo, DOFMatrix *matrix, - const DOFVectorBase<double> *dv) { - return 0.0; - }; + const DOFVectorBase<double> *dv) { return 0.0; }; /** \brief * Returns whether the condition must be treated as dirichlet condition * while assemblage. */ - virtual bool isDirichlet() { - return false; - }; + virtual bool isDirichlet() { return false; }; protected: /** \brief diff --git a/AMDiS/src/BoundaryManager.h b/AMDiS/src/BoundaryManager.h index 78ab7c22..07e61713 100644 --- a/AMDiS/src/BoundaryManager.h +++ b/AMDiS/src/BoundaryManager.h @@ -24,12 +24,12 @@ #include <map> +#include "AMDiS_fwd.h" #include "Boundary.h" #include "BoundaryCondition.h" namespace AMDiS { - class DOFMatrix; class FiniteElemSpace; template<typename T> class Vector; template<typename T> class DOFVectorBase; diff --git a/AMDiS/src/BoxSmoother.h b/AMDiS/src/BoxSmoother.h index 19a6f500..52deed36 100644 --- a/AMDiS/src/BoxSmoother.h +++ b/AMDiS/src/BoxSmoother.h @@ -67,7 +67,9 @@ namespace AMDiS { const Vector< std::set<DegreeOfFreedom>*> &dofSet) { FUNCNAME("BoxSmoother::smooth()"); + ERROR_EXIT("Will be rewritten - Peter\n"); +#if 0 int i, j, k; // allocate memory @@ -211,6 +213,7 @@ namespace AMDiS { ++pos; } } +#endif }; protected: diff --git a/AMDiS/src/CGSolver.h b/AMDiS/src/CGSolver.h deleted file mode 100644 index f39a9690..00000000 --- a/AMDiS/src/CGSolver.h +++ /dev/null @@ -1,114 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file CGSolver.h */ - -#ifndef AMDIS_CGSOLVER_H -#define AMDIS_CGSOLVER_H - -namespace AMDiS { - - #include "OEMSolver.h" - #include "MemoryManager.h" - - // ============================================================================ - // ===== class CGSolver ======================================================= - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Solves a linear system by the conjugate gradient method and can be used for - * symmetric positive definite system matrices. - * - * The implementation is based on the following book: "Numerik linearer - * Gleichungssystene", 2. Auflage, Andreas Meister. The algorithm is described - * on page 124. The extension to the preconditioned cg method (pcg) is described - * on page 207 in the same book. We here use the same variable names, but without - * subscription. - */ - template<typename VectorType> - class CGSolver : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(CGSolver<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new CGSolver object. - */ - OEMSolver<VectorType>* create() { - return NEW CGSolver<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - CGSolver(std::string name); - - /** \brief - * destructor - */ - ~CGSolver(); - - protected: - /** \brief - * Implements OEMSolver<VectorType>::init(). - */ - void init() { - p = this->vectorCreator->create(); - r = this->vectorCreator->create(); - v = this->vectorCreator->create(); - z = this->vectorCreator->create(); - }; - - /** \brief - * Implements OEMSolver<VectorType>::exit(). - */ - void exit() { - this->vectorCreator->free(p); - this->vectorCreator->free(r); - this->vectorCreator->free(v); - this->vectorCreator->free(z); - }; - - /** \brief - * Implements OEMSolver<VectorType>::solve(). - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b, bool reuseMatrix); - - private: - VectorType *p, *r, *v, *z; - }; -} - -#include "CGSolver.hh" - -#endif // AMDIS_CGSOLVER_H diff --git a/AMDiS/src/CGSolver.hh b/AMDiS/src/CGSolver.hh deleted file mode 100644 index 7b1fa1e7..00000000 --- a/AMDiS/src/CGSolver.hh +++ /dev/null @@ -1,132 +0,0 @@ -#include "DOFVector.h" -#include "DOFMatrix.h" -#include "MatVecMultiplier.h" -#include "StlVector.h" -#include "V3Vector.h" - -namespace AMDiS { - - template<typename VectorType> - CGSolver<VectorType>::CGSolver(std::string name) - : OEMSolver<VectorType>(name) - {} - - template<typename VectorType> - CGSolver<VectorType>::~CGSolver() {} - - template<typename VectorType> - int CGSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, bool reuseMatrix) - { - FUNCNAME("CGSolver::solve()"); - - const double TOL = 1.e-30; - -// std::cout << "b: " << std::endl; -// print(b); - - // If norm of b is smaller than the tolarance, we can assume b to be zero. - // Hence, x = 0 is the solution of the linear system. - if (norm(b) < TOL) { - INFO(this->info,2)("b == 0, x = 0 is the solution of the linear system\n"); - setValue(*x, 0.0); - this->residual = 0.0; - - return(0); - } - -// std::cout << "x: " << std::endl; -// print(x); - - // p is temporaly used to calculate -x. - *p = *x; - *p *= -1.0; - - // r = b - Ax - matVec->matVec(NoTranspose, *p, *r); -// std::cout << "-Ax: " << std::endl; -// print(r); - *r += *b; - -// std::cout << "r: " << std::endl; -// print(r); - - *p = *r; - if (this->leftPrecon) { - this->leftPrecon->precon(p); - } - - // \alpha = (r,p)_2 - // without precondition, \alpha = (r,p)_2 = (r,r)_2 = \|r\|_2^2 -// std::cout << "Berechne Alpha: " << std::endl; -// std::cout << "r: " << std::endl; -// print(r); -// std::cout << "p: " << std::endl; -// print(p); - double alpha = *r * *p; -// std::cout << "alpha=" << alpha << std::endl; - - double alpha1, lambda, old_res = -1.0; - - START_INFO(); - // Test if x is already a solution of the lineas system. - if (SOLVE_INFO(0, sqrt(alpha), &old_res)) { - return(0); - } - - for (int iter = 1; iter <= this->max_iter; iter++) { - // std::cout << "---------------------------Ein Schritt---------------------------" << std::endl; - // v = Ap - matVec->matVec(NoTranspose, *p, *v); -// std::cout << "p: " << std::endl; -// print(p); -// std::cout << "Ap: " << std::endl; -// print(v); - - // \lambda = alpha / (v,p)_2 - lambda = *v * *p; - if (abs(lambda) < TOL) { - BREAK_INFO("(v,p)_2 = 0", iter, sqrt(alpha), &old_res); - return(iter); - } - lambda = alpha / lambda; - - // x = x + \lambda * p - axpy(lambda, *p, *x); - - // r = r - \lambda * v - axpy(-lambda, *v, *r); - - *z = *r; - if (this->leftPrecon) { - this->leftPrecon->precon(z); - } - - // \alpha_{m + 1} = (r,z)_2 - // without precondition, \alpha_{m + 1} = (r,z)_2 = (r,r)_2 = \|r\|_2^2 - alpha1 = *r * *z; - - // Check if x is a solution of the linear system. - if (SOLVE_INFO(iter, sqrt(alpha1), &old_res)) { - *p = *x; - *p *= -1.0; - - // r = b - Ax - matVec->matVec(NoTranspose, *p, *r); - *r += *b; - - return(iter); - } - - // p = z + (alpha_{m + 1} / alpha_{m}) * p - xpay(alpha1 / alpha, *z, *p); - - // Put the value of the alpha_{m + 1} variable to alpha_{m} variable - // for the next iteration. - alpha = alpha1; - } - - ERROR_EXIT("Should not be reached\n"); - return(0); - } -} diff --git a/AMDiS/src/CreatorInterface.h b/AMDiS/src/CreatorInterface.h index ea5e3a46..84cc948e 100644 --- a/AMDiS/src/CreatorInterface.h +++ b/AMDiS/src/CreatorInterface.h @@ -22,6 +22,8 @@ #ifndef AMDIS_CREATORINTERFACE_H #define AMDIS_CREATORINTERFACE_H +#include "DOFMatrix.h" + namespace AMDiS { /** \ingroup Common @@ -48,6 +50,8 @@ namespace AMDiS { */ virtual BaseClass* create() = 0; + virtual BaseClass* create(const DOFMatrix::base_matrix_type& A) { return 0; } + /** \brief * Can be implemented by sub classes. */ diff --git a/AMDiS/src/CreatorMap.cc b/AMDiS/src/CreatorMap.cc index d945a5dd..31c4206c 100644 --- a/AMDiS/src/CreatorMap.cc +++ b/AMDiS/src/CreatorMap.cc @@ -1,16 +1,13 @@ #include "CreatorMap.h" #include "OEMSolver.h" -#include "Preconditioner.h" -#include "DiagonalPreconditioner.h" -#include "ILUPreconditioner.h" -#include "ILUTPreconditioner.h" +#include "ITL_Solver.h" +#include "ITL_Preconditioner.h" #include "NonLinSolver.h" #include "MatrixVector.h" #include "SystemVector.h" #include "Estimator.h" -#include "ResidualEstimator.h" -#include "ResidualParallelEstimator.h" #include "RecoveryEstimator.h" +#include "ResidualEstimator.h" #include "LeafData.h" #include "SurfaceRegion_ED.h" #include "MultiGridWrapper.h" @@ -19,99 +16,66 @@ #include "GSSmoother.h" #include "JacobiSmoother.h" #include "ElementRegion_ED.h" -#include "BiCGStab.h" -#include "BiCGStab2.h" -#include "BFGS_Precond.h" #include "BoxSmoother.h" #include "MultiGridPreconWrapper.h" -#include "GMResSolver2.h" -#include "TFQMR.h" -#include "VecSymSolver.h" #include "UmfPackSolver.h" -#include "PardisoSolver.h" -#include "DuneSolver.h" namespace AMDiS { template<> - void CreatorMap<OEMSolver<DOFVector<double> > >::addDefaultCreators() + void CreatorMap<OEMSolver>::addDefaultCreators() { - OEMSolverCreator<DOFVector<double> > *creator; + OEMSolverCreator *creator; - creator = NEW BiCGSolver<DOFVector<double> >::Creator; - addCreator("bicgstab_albert", creator); - - creator = NEW CGSolver<DOFVector<double> >::Creator; + creator = NEW CGSolver::Creator; addCreator("cg", creator); - creator = NEW GMResSolver<DOFVector<double> >::Creator; - addCreator("gmres", creator); - - creator = NEW ODirSolver<DOFVector<double> >::Creator; - addCreator("odir", creator); + creator = NEW BiCGSolver::Creator; + addCreator("bicg", creator); - creator = NEW OResSolver<DOFVector<double> >::Creator; - addCreator("ores", creator); - - creator = NEW BiCGStab<DOFVector<double> >::Creator; + creator = NEW BiCGStab::Creator; addCreator("bicgstab", creator); - creator = NEW MultiGridWrapperScal::Creator; - addCreator("mg", creator); - - creator = NEW BiCGStab2<DOFVector<double> >::Creator; + creator = NEW BiCGStab2::Creator; addCreator("bicgstab2", creator); - // creator = NEW GMResSolver2<DOFVector<double> >::Creator; - // addCreator("gmres2", creator); - - creator = NEW TFQMR<DOFVector<double> >::Creator; - addCreator("tfqmr", creator); + creator = NEW BiCGStabEll::Creator; + addCreator("bicgstab_ell", creator); -#ifdef HAVE_DUNE - creator = NEW DuneSolver< DOFVector<double> >::Creator; - addCreator("dune", creator); +#ifdef HAVE_UMFPACK + creator = NEW UmfPackSolver::Creator; + addCreator("umfpack", creator); #endif } - - template<> - void CreatorMap<SmootherBase<DOFMatrix, - SparseVector<double>, - std::set<DegreeOfFreedom> > >::addDefaultCreators() - { - SmootherCreator<DOFMatrix, SparseVector<double>, std::set<DegreeOfFreedom> > *creator; - - creator = NEW GSSmoother<DOFMatrix, SparseVector<double>, std::set<DegreeOfFreedom> >::Creator; - addCreator("gs", creator); - - creator = NEW JacobiSmoother<DOFMatrix, SparseVector<double>, std::set<DegreeOfFreedom> >::Creator; - addCreator("j", creator); - } - - template<> - void CreatorMap<PreconditionerScal>::addDefaultCreators() + void CreatorMap<ITL_BasePreconditioner>::addDefaultCreators() { - CreatorInterface<PreconditionerScal> *creator; + CreatorInterface<ITL_BasePreconditioner> *creator; creator = NEW DiagonalPreconditioner::Creator; addCreator("diag", creator); + creator = NEW IdentityPreconditioner::Creator; + addCreator("no", creator); + creator = NEW ILUPreconditioner::Creator; addCreator("ilu", creator); - creator = NEW ILUTPreconditioner::Creator; - addCreator("ilut", creator); + creator = NEW ICPreconditioner::Creator; + addCreator("ic", creator); - creator = NEW BFGS_Precond::Creator; - addCreator("bfgs", creator); +#if 0 creator = NEW MGPreconWrapperScal::Creator; addCreator("mg", creator); +#endif } + + +#if 0 template<> void CreatorMap<NonLinSolver<DOFVector<double> > >::addDefaultCreators() { @@ -123,87 +87,10 @@ namespace AMDiS { creator = NEW NewtonS<DOFVector<double> >::Creator; addCreator("newton_fs", creator); } - - - template<> - void CreatorMap<OEMSolver<SystemVector> >::addDefaultCreators() - { - OEMSolverCreator<SystemVector> *creator; - - creator = NEW BiCGSolver<SystemVector>::Creator; - addCreator("bicgstab_albert", creator); - - creator = NEW CGSolver<SystemVector>::Creator; - addCreator("cg", creator); - - creator = NEW GMResSolver<SystemVector>::Creator; - addCreator("gmres", creator); - - creator = NEW ODirSolver<SystemVector>::Creator; - addCreator("odir", creator); - - creator = NEW OResSolver<SystemVector>::Creator; - addCreator("ores", creator); - - creator = NEW BiCGStab<SystemVector>::Creator; - addCreator("bicgstab", creator); - - creator = NEW BiCGStab2<SystemVector>::Creator; - addCreator("bicgstab2", creator); - - creator = NEW MultiGridWrapperVec::Creator; - addCreator("mg", creator); - - creator = NEW GMResSolver2<SystemVector>::Creator; - addCreator("gmres2", creator); - - creator = NEW TFQMR<SystemVector>::Creator; - addCreator("tfqmr", creator); - - creator = NEW VecSymSolver<SystemVector>::Creator; - addCreator("vecsym", creator); - -#ifdef HAVE_UMFPACK - creator = NEW UmfPackSolver<SystemVector>::Creator; - addCreator("umfpack", creator); -#endif - -#ifdef HAVE_MKL - creator = NEW PardisoSolver<SystemVector>::Creator; - addCreator("pardiso", creator); -#endif - -#ifdef HAVE_DUNE - creator = NEW DuneSolver<SystemVector>::Creator; - addCreator("dune", creator); #endif - } - - - template<> - void CreatorMap<SmootherBase<Matrix<DOFMatrix*>, - Vector<SparseVector<double>*>, - Vector< std::set<DegreeOfFreedom>*> > >::addDefaultCreators() - { - SmootherCreator<Matrix<DOFMatrix*>, - Vector<SparseVector<double>*>, - Vector< std::set<DegreeOfFreedom>*> > *creator; - - creator = NEW GSSmoother<Matrix<DOFMatrix*>, - Vector<SparseVector<double>*>, - Vector< std::set<DegreeOfFreedom>*> >::Creator; - addCreator("gs", creator); - - creator = NEW JacobiSmoother<Matrix<DOFMatrix*>, - Vector<SparseVector<double>*>, - Vector< std::set<DegreeOfFreedom>*> >::Creator; - addCreator("j", creator); - - creator = NEW BoxSmoother::Creator; - addCreator("box", creator); - } +#if 0 template<> void CreatorMap<NonLinSolver<SystemVector> >::addDefaultCreators() { @@ -215,7 +102,7 @@ namespace AMDiS { creator = NEW NewtonS<SystemVector>::Creator; addCreator("newton_fs", creator); } - +#endif template<> void CreatorMap<Estimator>::addDefaultCreators() @@ -225,16 +112,10 @@ namespace AMDiS { creator = NEW ResidualEstimator::Creator; addCreator("residual", creator); -#ifdef _OPENMP - creator = NEW ResidualParallelEstimator::Creator; - addCreator("residualparallel", creator); -#endif - creator = NEW RecoveryEstimator::Creator; addCreator("recovery", creator); } - template<> void CreatorMap<ElementData>::addDefaultCreators() { @@ -261,4 +142,5 @@ namespace AMDiS { creator = NEW ElementRegion_ED::Creator; addCreator("ElementRegion_ED", creator); } + } diff --git a/AMDiS/src/CreatorMap.h b/AMDiS/src/CreatorMap.h index 7807ddc8..d56e7da5 100644 --- a/AMDiS/src/CreatorMap.h +++ b/AMDiS/src/CreatorMap.h @@ -69,18 +69,19 @@ namespace AMDiS { static void addDefaultCreators(); - protected: - /** \brief - * Constructor is protected because derived maps should be singleton. - */ - static void init() { - if (!initialized) { - initialized = true; - NullCreator<BaseClass> *nullCreator = new NullCreator<BaseClass>; - addCreator("no", nullCreator); - addDefaultCreators(); - } - } + protected: + /** \brief + * Constructor is protected because derived maps should be singleton. + */ + static void init() { + if(!initialized) { + initialized = true; + NullCreator<BaseClass> *nullCreator = new NullCreator<BaseClass>; + // addCreator("no", nullCreator); + addCreator("0", nullCreator); + addDefaultCreators(); + } + }; protected: /** \brief diff --git a/AMDiS/src/DOFIndexed.cc b/AMDiS/src/DOFIndexed.cc index 07b8469e..1ebda059 100644 --- a/AMDiS/src/DOFIndexed.cc +++ b/AMDiS/src/DOFIndexed.cc @@ -1,15 +1,103 @@ #include "DOFIndexed.h" #include "DOFMatrix.h" +#include <boost/numeric/mtl/mtl.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + + +// Defining the interface for MTL4 +namespace mtl { + + // Let MTL4 know that DOFIndexed it is a column vector + namespace traits { + template <typename T> + struct category< AMDiS::DOFIndexed<T> > + { + typedef tag::dense_col_vector type; + }; + } + + namespace ashape { + template <typename T> + struct ashape< AMDiS::DOFIndexed<T> > + { + typedef cvec<typename ashape<T>::type> type; + }; + } + + // Modelling Collection and MutableCollection + template <typename T> + struct Collection< AMDiS::DOFIndexed<T> > + { + typedef T value_type; + typedef const T& const_reference; + typedef std::size_t size_type; + }; + + template <typename T> + struct MutableCollection< AMDiS::DOFIndexed<T> > + : public Collection< AMDiS::DOFIndexed<T> > + { + typedef T& reference; + }; + + +} // namespace mtl + + + namespace AMDiS { + // Some free functions used in MTL4 + + template <typename T> + inline std::size_t size(const AMDiS::DOFIndexed<T>& v) + { + return v.getSize(); + } + + template <typename T> + inline std::size_t num_rows(const AMDiS::DOFIndexed<T>& v) + { + return v.getSize(); + } + + template <typename T> + inline std::size_t num_cols(const AMDiS::DOFIndexed<T>& v) + { + return 1; + } + + + template <typename T> + inline void set_to_zero(AMDiS::DOFIndexed<T>& v) + { + using math::zero; + T ref, my_zero(zero(ref)); + + std::fill(v.begin(), v.end(), my_zero); + } + + + void mv(MatrixTranspose transpose, const DOFMatrix &a, - DOFIndexed<double> &x, + const DOFIndexed<double> &x, DOFIndexed<double> &result, bool add) { - FUNCNAME("DOFVector<T>::mv"); + FUNCNAME("DOFIndexed<T>::mv"); + + if (transpose == NoTranspose) + mult(a.getBaseMatrix(), x, result); + else if (transpose == Transpose) + mult(trans(const_cast<DOFMatrix::base_matrix_type&>(a.getBaseMatrix())), x, result); + else + ERROR_EXIT("transpose = %d\n", transpose); + +#if 0 int irow, jcol; double sum; @@ -36,6 +124,7 @@ namespace AMDiS { } else { ERROR_EXIT("transpose=%d\n", transpose); } +#endif } } diff --git a/AMDiS/src/DOFIndexed.h b/AMDiS/src/DOFIndexed.h index 6f62ded8..743e3e2f 100644 --- a/AMDiS/src/DOFIndexed.h +++ b/AMDiS/src/DOFIndexed.h @@ -25,15 +25,10 @@ #include <vector> #include "Global.h" #include "DOFIterator.h" +#include "AMDiS_fwd.h" namespace AMDiS { - class RCNeighbourList; - class FiniteElemSpace; - class DOFMatrix; - class ElInfo; - class Quadrature; - class FastQuadrature; // ============================================================================ // ===== class DOFIndexedBase ================================================= @@ -112,12 +107,13 @@ namespace AMDiS { virtual const T& operator[](DegreeOfFreedom i) const = 0; }; + void mv(MatrixTranspose transpose, const DOFMatrix &a, - DOFIndexed<double> &x, + const DOFIndexed<double> &x, DOFIndexed<double> &result, bool add = false); -} +} // namespace AMDiS #endif // AMDIS_DOFINDEXED_H diff --git a/AMDiS/src/DOFMatrix.cc b/AMDiS/src/DOFMatrix.cc index 4b44d3c5..843e42e5 100644 --- a/AMDiS/src/DOFMatrix.cc +++ b/AMDiS/src/DOFMatrix.cc @@ -15,16 +15,22 @@ #include "BoundaryManager.h" #include "ElementMatrix.h" #include "Assembler.h" +#include "Utilities.h" + +#include <boost/numeric/mtl/mtl.hpp> namespace AMDiS { + using namespace mtl; + DOFMatrix *DOFMatrix::traversePtr = NULL; DOFMatrix::DOFMatrix() - { - rowFESpace = NULL; - colFESpace = NULL; - } + : rowFESpace(NULL), + colFESpace(NULL), + elementMatrix(NULL), + inserter(NULL) + {} DOFMatrix::DOFMatrix(const FiniteElemSpace* rowFESpace_, const FiniteElemSpace* colFESpace_, @@ -32,7 +38,8 @@ namespace AMDiS { : rowFESpace(rowFESpace_), colFESpace(colFESpace_), name(name_), - coupleMatrix(false) + coupleMatrix(false), + inserter(NULL) { TEST_EXIT(rowFESpace)("no rowFESpace\n"); @@ -60,14 +67,14 @@ namespace AMDiS { *this = rhs; if (rowFESpace && rowFESpace->getAdmin()) (const_cast<DOFAdmin*>( rowFESpace->getAdmin()))->addDOFIndexed(this); + + TEST_EXIT(rhs.inserter == 0)("Cannot copy during insertion"); + inserter= 0; } DOFMatrix::~DOFMatrix() { FUNCNAME("DOFMatrix::~DOFMatrix()"); - - matrix.clear(); - if (rowFESpace && rowFESpace->getAdmin()) { (const_cast<DOFAdmin*>(rowFESpace->getAdmin()))->removeDOFIndexed(this); } @@ -77,65 +84,28 @@ namespace AMDiS { if (elementMatrix) DELETE elementMatrix; + if (inserter) delete inserter; } void DOFMatrix::print() const { FUNCNAME("DOFMatrix::print()"); - int sizeUsed = rowFESpace->getAdmin()->getUsedSize(); - - if (static_cast<int>(matrix.size()) < sizeUsed) { - WARNING("DOFMatrix not yet initialized\n"); - return; - } - - for (int i = 0; i < sizeUsed; i++) { - DOFMatrix::MatrixRow row = matrix[i]; - MSG("row %3d:",i); - int rowSize = static_cast<int>( row.size()); - for (int j = 0; j < rowSize; j++) { - int jcol = row[j].col; - if (entryUsed(i, j)) { - Msg::print(" (%3d,%20.17lf)", jcol, row[j].entry); - } - } - Msg::print("\n"); - } - } - - void DOFMatrix::printRow(int i) const - { - FUNCNAME("DOFMatrix::printRow()"); - - int sizeUsed = rowFESpace->getAdmin()->getUsedSize(); - - if (static_cast<int>(matrix.size()) < sizeUsed) { - WARNING("DOFMatrix not yet initialized\n"); - return; - } - - DOFMatrix::MatrixRow row = matrix[i]; - MSG("row %3d:",i); - int rowSize = static_cast<int>( row.size()); - for (int j = 0; j < rowSize; j++) { - int jcol = row[j].col; - if (entryUsed(i,j)) { - Msg::print(" (%3d,%20.17lf)", jcol, row[j].entry); - } - } - Msg::print("\n"); - } + using mtl::tag::major; using mtl::tag::nz; using mtl::begin; using mtl::end; + namespace traits= mtl::traits; + typedef base_matrix_type Matrix; - /****************************************************************************/ - /* clear: remove all entries from dof_matrix */ - /****************************************************************************/ + traits::row<Matrix>::type row(matrix); + traits::col<Matrix>::type col(matrix); + traits::const_value<Matrix>::type value(matrix); - void DOFMatrix::clear() - { - int mSize = static_cast<int>(matrix.size()); - for (int i = 0; i < mSize; i++) { - matrix[i].resize(0); + typedef traits::range_generator<major, Matrix>::type cursor_type; + typedef traits::range_generator<nz, cursor_type>::type icursor_type; + + 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) + Msg::print(" (%3d,%3d,%20.17lf)", row(*icursor), col(*icursor), value(*icursor)); + Msg::print("\n"); } } @@ -143,26 +113,24 @@ namespace AMDiS { { FUNCNAME("DOFMatrix::symmetric()"); - DegreeOfFreedom row, col; - double entry, tol = 1e-5; + double tol = 1e-5; - DOFMatrix::Iterator matrixRow(this, USED_DOFS); + using mtl::tag::major; using mtl::tag::nz; using mtl::begin; using mtl::end; + namespace traits= mtl::traits; + typedef base_matrix_type Matrix; - for (matrixRow.reset(); !matrixRow.end(); ++matrixRow) { - row = matrixRow.getDOFIndex(); - int rowSize = matrixRow->size(); - for (int i = 0; i < rowSize; i++) { - col = (*matrixRow)[i].col; - entry = (*matrixRow)[i].entry; - if (abs(entry - logAcc(col, row)) > tol) { - MSG("matrix[%d][%d] = %e, matrix[%d][%d] = %e\n", - row, col, entry, col, row, logAcc(col, row)); + traits::row<Matrix>::type row(matrix); + traits::col<Matrix>::type col(matrix); + traits::const_value<Matrix>::type value(matrix); + typedef traits::range_generator<major, Matrix>::type cursor_type; + typedef traits::range_generator<nz, cursor_type>::type icursor_type; + + 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) + // Compare each non-zero entry with its transposed + if (abs(value(*icursor) - matrix[col(*icursor)][row(*icursor)]) > tol) return false; - } - } - } - return true; } @@ -170,46 +138,7 @@ namespace AMDiS { { FUNCNAME("DOFMatrix::test()"); - int non_symmetric = 0, found = 0; - - /* test symmetry */ - for (int i = 0; i < static_cast<int>(matrix.size()); i++) { - double sum = 0.0; - DOFMatrix::MatrixRow *row = &matrix[i]; - for (int j = 0; j < static_cast<int>(row->size()); j++) { - int jcol = (*row)[j].col; - if (entryUsed(i, j)) { - found = 0; - if ((*row)[j].entry != (*row)[j].entry) { - MSG("mat[%d,%d]=%10.5e ???\n", i, jcol, (*row)[j].entry); - WAIT; - } - DOFMatrix::MatrixRow *row2 = &matrix[jcol]; - for (int k = 0; k < static_cast<int>(row->size()); k++) { - int kcol = (*row)[k].col; - if (entryUsed(jcol, k)) { - if (kcol == i) { - found = 1; - if (abs((*row2)[k].entry - (*row)[j].entry) > 1.E-5) { - non_symmetric = 1; - MSG("mat[%d,%d]=%10.5e != mat[%d,%d]=%10.5e\n", - i, jcol, (*row)[j].entry, jcol, i, (*row2)[k].entry); - } - row2 = NULL; - break; - } - } - } - if (!found) { - non_symmetric = 1; - MSG("mat[%d,%d] not found\n", jcol, i); - } - } - } - if (abs(sum) > 1.E-5) { - MSG("Zeilensumme[%d] = %10.5e\n", i, sum); - } - } + int non_symmetric = !symmetric(); if (non_symmetric) { MSG("matrix `%s' not symmetric.\n", name.data()); @@ -219,8 +148,11 @@ namespace AMDiS { } + // ok DOFMatrix& DOFMatrix::operator=(const DOFMatrix& rhs) { + TEST_EXIT(rhs.inserter == 0 && inserter == 0)("Cannot copy during insertion"); + rowFESpace = rhs.rowFESpace; colFESpace = rhs.colFESpace; operators = rhs.operators; @@ -249,198 +181,71 @@ namespace AMDiS { { FUNCNAME("DOFMatrix::addElementMatrix"); - DegreeOfFreedom row; + TEST_EXIT(inserter)("DOFMatrix is not in insertion mode"); + inserter_type &ins= *inserter; + + DegreeOfFreedom row, col; + double entry; - int nRow = elMat.rowIndices.getSize(); - int nCol = elMat.colIndices.getSize(); + int n_row = elMat.rowIndices.getSize(); + int n_col = elMat.colIndices.getSize(); - for (int i = 0; i < nRow; i++) { // for all rows of element matrix + for (int i = 0; i < n_row; i++) { // for all rows of element matrix row = elMat.rowIndices[i]; + BoundaryCondition *condition = bound ? boundaryManager->getBoundaryCondition(bound[i]) : NULL; if (condition && condition->isDirichlet()) { - applyDBCs.insert(static_cast<int>(row)); - } else { - for (int j = 0; j < nCol; j++) { // for all columns - addSparseDOFEntry(sign, row, elMat.colIndices[j], - elMat[i][j], add); - } - } + if (!coupleMatrix) + ins[row][row]= 1.0; + } else + for (int j = 0; j < n_col; j++) { // for all columns + col = elMat.colIndices[j]; + entry = elMat[i][j]; + if (add) + ins[row][col]+= sign * entry; + else + ins[row][col]= sign * entry; + } } } double DOFMatrix::logAcc(DegreeOfFreedom a,DegreeOfFreedom b) const { - int j; - - for (j = 0; j < static_cast<int>(matrix[a].size()); j++) - if (b == matrix[a][j].col) - break; - - return (j == static_cast<int>(matrix[a].size())) ? 0.0 : matrix[a][j].entry; - } - - void DOFMatrix::changeColOfEntry(DegreeOfFreedom a, - DegreeOfFreedom b, - DegreeOfFreedom c) - { - int j; - - for (j = 0; j<static_cast<int>(matrix[a].size());j++) - if (b == matrix[a][j].col) - break; - - if (j != static_cast<int>(matrix[a].size())) - matrix[a][j].col = c; + return matrix[a][b]; } - void DOFMatrix::addSparseDOFEntry(double sign, int irow, - int jcol, double entry, - bool add) - { - FUNCNAME("DOFMatrix::addSparseDOFEntry()"); - - MatrixRow *row = &(matrix[irow]); - - if (add && !entry) - return; - - int freeCol = -1; - int rowSize = static_cast<int>(row->size()); - - TEST_EXIT_DBG(jcol >= 0 && - jcol < colFESpace->getAdmin()->getUsedSize()) - ("Column index %d out of range 0-%d\n", jcol, colFESpace->getAdmin()->getUsedSize() - 1); - - // first entry is diagonal entry - if ((rowSize == 0) && (colFESpace == rowFESpace)) { - MatEntry newEntry = {irow, 0.0}; - row->push_back(newEntry); - rowSize = 1; - } - - int i; - // search jcol - for (i = 0; i < rowSize; i++) { - // jcol found ? - if ((*row)[i].col == jcol) { - break; - } - // remember free entry - if ((*row)[i].col == UNUSED_ENTRY) { - freeCol = i; - } - // no more entries - if ((*row)[i].col == NO_MORE_ENTRIES) { - freeCol = i; - if (rowSize > i+1) { - (*row)[i + 1].entry = NO_MORE_ENTRIES; - } - break; - } - } - - // jcol found? - if (i < rowSize) { - if (!add) { - (*row)[i].entry = 0.0; - } - - (*row)[i].entry += sign * entry; - } else { - if (freeCol == -1) { - MatEntry newEntry = {jcol, sign * entry}; - row->push_back(newEntry); - } else { - (*row)[freeCol].col = jcol; - if (!add) - (*row)[freeCol].entry = 0.0; - (*row)[freeCol].entry += sign * entry; - } - } - } - - void DOFMatrix::addMatEntry(int row, MatEntry entry) + void DOFMatrix::freeDOFContent(int index) { - matrix[row].push_back(entry); - } + using mtl::tag::major; using mtl::tag::nz; using mtl::begin; using mtl::end; + namespace traits= mtl::traits; + typedef base_matrix_type Matrix; - void DOFMatrix::addMatEntry(int row, DegreeOfFreedom col, double value) - { - MatEntry entry; - entry.col = col; - entry.entry = value; - matrix[row].push_back(entry); - } + traits::row<Matrix>::type row(matrix); + traits::col<Matrix>::type col(matrix); - void DOFMatrix::addRow(std::vector<MatEntry> row) - { - matrix.push_back(row); - } - - void DOFMatrix::compressDOFIndexed(int first, int last, - std::vector<DegreeOfFreedom> &newDOF) - { - for (int i = first; i <= last; i++) { - if (newDOF[i] >= 0) { - matrix[newDOF[i]].swap(matrix[i]); - matrix[i].resize(0); - } - } - int usedSize = rowFESpace->getAdmin()->getUsedSize(); - for (int i = 0; i < usedSize; i++) { - std::vector<MatEntry> *row = reinterpret_cast<std::vector<MatEntry>*>(&(matrix[i])); - int rowSize = static_cast<int>(row->size()); - for (int j = 0; j < rowSize; j++) { - int col = (*row)[j].col; - if (entryUsed(i, j)) - (*row)[j].col = newDOF[col]; - } - } - } + typedef traits::range_generator<major, Matrix>::type cursor_type; + typedef traits::range_generator<nz, cursor_type>::type icursor_type; + + cursor_type cursor = begin<major>(matrix); + // Jump directly to corresponding row or column + cursor+= index; - void DOFMatrix::freeDOFContent(int index) - { - int col = 0; - - if (0 < matrix[index].size()) { - int nRows = matrix.size(); - - // for all columns in this row - int size = static_cast<int>(matrix[index].size()); - for (int i = 0; i < size; i++) { - // if entry is used - if (entryUsed(index, i)) { - // get column of this entry - col = matrix[index][i].col; - if ((col != index) && (col < nRows)) { // remove symmetric entry if exists - int colsize = static_cast<int>(matrix[col].size()); - for (int j = 0; j < colsize; j++) { - int col2 = matrix[col][j].col; - if (col2 == index) { - matrix[col][j].col = DOFMatrix::UNUSED_ENTRY; - } else if (col2 == DOFMatrix::NO_MORE_ENTRIES) { - break; - } - } - } - } else if (col == DOFMatrix::NO_MORE_ENTRIES) { - break; - } - } - matrix[index].resize(0); + // Requires structural symmetry !!! + for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor) { + int my_row= row(*icursor), my_col= col(*icursor); + // Not very efficient (but general) + matrix.lvalue(my_row, my_col) = 0.0; // Need to call crop somewhere !!!! Peter + matrix.lvalue(my_col, my_row) = 0.0; } } - + // Should work as before void DOFMatrix::assemble(double factor, ElInfo *elInfo, const BoundaryType *bound) { FUNCNAME("DOFMatrix::assemble()"); - if (operators.size() == 0) - return; - operators[0]->getAssembler(omp_get_thread_num())-> initElementMatrix(elementMatrix, elInfo); @@ -476,7 +281,7 @@ namespace AMDiS { { FUNCNAME("DOFMatrix::assemble()"); - if (!op && operators.size() == 0) { + if(!op && operators.size() == 0) { return; } @@ -516,7 +321,7 @@ namespace AMDiS { operat->getAssembler(omp_get_thread_num())-> initElementMatrix(elementMatrix, mainElInfo); - if (op) { + if(op) { ERROR_EXIT("TODO"); // op->getElementMatrix(rowElInfo, colElInfo, // smallElInfo, largeElInfo, @@ -524,7 +329,7 @@ namespace AMDiS { } else { std::vector<Operator*>::iterator it; std::vector<double*>::iterator factorIt; - for (it = operators.begin(), factorIt = operatorFactor.begin(); + for(it = operators.begin(), factorIt = operatorFactor.begin(); it != operators.end(); ++it, ++factorIt) { if ((*it)->getNeedDualTraverse()) { @@ -549,6 +354,7 @@ namespace AMDiS { } } + // Should work as before Flag DOFMatrix::getAssembleFlag() { Flag fillFlag(0); @@ -560,133 +366,26 @@ namespace AMDiS { return fillFlag; } - void DOFMatrix::mm(MatrixTranspose aTranspose, - DOFMatrix& a, - MatrixTranspose bTranspose, - DOFMatrix& b) - { - FUNCNAME("DOFMatrix::mm()"); - - WARNING("implementation not finished!!!\n"); - - TEST_EXIT_DBG(a.getColFESpace() == b.getRowFESpace()) - ("a.colFESpace != b.rowFESpace\n"); - TEST_EXIT_DBG(rowFESpace == a.getRowFESpace()) - ("rowFESpace != a.rowFESpace\n"); - TEST_EXIT_DBG(colFESpace == b.getColFESpace()) - ("colFESpace != b.colFESpace\n"); - - clear(); - - int i, j; - - if (aTranspose == NoTranspose && bTranspose == NoTranspose) { - int cols = b.getColFESpace()->getAdmin()->getUsedSize(); - DOFMatrix::Iterator rowIterator(this, USED_DOFS); - - // for every row ... - for(rowIterator.reset(); !rowIterator.end(); ++rowIterator) { - int rowIndex = rowIterator.getDOFIndex(); - // and every column of result - for(i=0; i < cols; i++) { - double entry = 0.0; - // for every entry in a[i] ... - for(j=0; j < static_cast<int>( a[rowIndex].size()); j++) { - int logIndex = a[rowIndex][j].col; - int physIndex = b.logToPhysIndex(logIndex, i); - if(physIndex != -1) { - entry += a[rowIndex][j].entry * b[logIndex][physIndex].entry; - } - } - if (entry != 0.0) { - addSparseDOFEntry(1.0, rowIndex, i, entry); - } - } - } - } else if(aTranspose == Transpose && bTranspose == NoTranspose) { - DOFMatrix::Iterator aIterator(&a, USED_DOFS); - DOFMatrix::Iterator bIterator(&b, USED_DOFS); - for(aIterator.reset(), bIterator.reset(); - !aIterator.end(); - ++aIterator, ++bIterator) - { - std::vector<MatEntry>::const_iterator aRowIt; - std::vector<MatEntry>::const_iterator bRowIt; - for(aRowIt = aIterator->begin(); aRowIt != aIterator->end(); ++aRowIt) { - int aCol = aRowIt->col; - if(aCol == UNUSED_ENTRY) continue; - if(aCol == NO_MORE_ENTRIES) break; - for(bRowIt = bIterator->begin(); bRowIt !=bIterator->end(); ++bRowIt) { - int bCol = bRowIt->col; - if(bCol == UNUSED_ENTRY) continue; - if(bCol == NO_MORE_ENTRIES) break; - - double entry = aRowIt->entry * bRowIt->entry; - - if (entry != 0.0) { - addSparseDOFEntry(1.0, aCol, bCol, entry); - } - } - } - } - } else if(aTranspose == NoTranspose && bTranspose == Transpose) { - ERROR_EXIT("not yet\n"); - } else if(aTranspose == Transpose && bTranspose == Transpose) { - ERROR_EXIT("not yet\n"); - } - } - void DOFMatrix::axpy(double a, const DOFMatrix& x, const DOFMatrix& y) { - FUNCNAME("DOFMatrix::axpy()"); - - TEST_EXIT_DBG(x.getRowFESpace() == y.getRowFESpace() && - rowFESpace == x.getRowFESpace()) + FUNCNAME("DOFMatrix::axpy"); + TEST_EXIT(x.getRowFESpace() == y.getRowFESpace() && + rowFESpace == x.getRowFESpace()) ("row fe-spaces not equal\n"); - TEST_EXIT_DBG(x.getColFESpace() == y.getColFESpace() && - colFESpace == x.getColFESpace()) + TEST_EXIT(x.getColFESpace() == y.getColFESpace() && + colFESpace == x.getColFESpace()) ("col fe-spaces not equal\n"); - - DOFMatrix::Iterator rowIterator(this, USED_DOFS); - DOFMatrix::Iterator xIterator(const_cast<DOFMatrix*>(&x), USED_DOFS); - DOFMatrix::Iterator yIterator(const_cast<DOFMatrix*>(&y), USED_DOFS); - - int i, rowIndex, colIndex; - - for(rowIterator.reset(), xIterator.reset(), yIterator.reset(); - !rowIterator.end(); - ++rowIterator, ++xIterator, ++yIterator) - { - rowIndex = rowIterator.getDOFIndex(); - // add x contributions to this row - for(i=0; i < static_cast<int>((*xIterator).size()); i++) { - colIndex = (*xIterator)[i].col; - if (colIndex >= 0) { - addSparseDOFEntry(a, rowIndex, colIndex, (*xIterator)[i].entry); - } - } - // add y contributions to this row - for(i=0; i < static_cast<int>((*yIterator).size()); i++) { - colIndex = (*yIterator)[i].col; - if (colIndex >= 0) { - addSparseDOFEntry(1.0, rowIndex, colIndex, (*yIterator)[i].entry); - } - } - } + + matrix+= a * x.matrix + y.matrix; + } + void DOFMatrix::scal(double b) { - DOFMatrix::Iterator rowIterator(this, USED_DOFS); - for (rowIterator.reset(); !rowIterator.end(); ++rowIterator) { - for (int i = 0; i < static_cast<int>((*rowIterator).size()); i++) { - if ((*rowIterator)[i].col >= 0) { - (*rowIterator)[i].entry *= b; - } - } - } + matrix*= b; } void DOFMatrix::addOperator(Operator *op, double* factor, double* estFactor) @@ -698,63 +397,33 @@ namespace AMDiS { void DOFMatrix::copy(const DOFMatrix& rhs) { - clear(); - DOFMatrix::Iterator rhsIterator(const_cast<DOFMatrix*>(&rhs), USED_DOFS); - DOFMatrix::Iterator thisIterator(this, USED_DOFS); - std::vector<MatEntry>::const_iterator colIt; - std::vector<MatEntry>::const_iterator colBegin; - std::vector<MatEntry>::const_iterator colEnd; - for(rhsIterator.reset(), thisIterator.reset(); - !rhsIterator.end(); - ++rhsIterator, ++thisIterator) - { - colBegin = rhsIterator->begin(); - colEnd = rhsIterator->end(); - for(colIt = colBegin; colIt != colEnd; ++colIt) { - MatEntry matEntry; - matEntry.col = colIt->col; - matEntry.entry = colIt->entry; - thisIterator->push_back(matEntry); - } - } + matrix= rhs.matrix; } void DOFMatrix::removeRowsWithDBC(std::set<int> *rows) - { - for (std::set<int>::iterator it = rows->begin(); - it != rows->end(); - ++it) { - if (coupleMatrix) { - matrix[*it].resize(0); - } else { - matrix[*it].resize(1); - matrix[*it][0].col = *it; - matrix[*it][0].entry = 1.0; - } - } + { + ERROR_EXIT("TODO: removeRowsWithDBC"); - rows->clear(); - } +// for (std::set<int>::iterator it = rows->begin(); +// it != rows->end(); +// ++it) { +// if (coupleMatrix) { +// matrix[*it].resize(0); +// } else { +// matrix[*it].resize(1); +// matrix[*it][0].col = *it; +// matrix[*it][0].entry = 1.0; +// } +// } - int DOFMatrix::getNumCols() const { - int max = 0; - int rowSize = static_cast<int>(matrix.size()); - for (int i = 0; i < rowSize; i++) { - int colSize = static_cast<int>(matrix[i].size()); - for (int j = 0; j < colSize; j++) { - if (matrix[i][j].col > max) { - max = matrix[i][j].col; - } - } - } - - // Add one to the maximum value, because the indeces start with 0. - return max + 1; +// rows->clear(); } - void DOFMatrix::createPictureFile(const char* filename, int dim) { + TEST_EXIT(0)("Not yet re-implemented."); + +#if 0 png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); @@ -811,139 +480,14 @@ namespace AMDiS { png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); +#endif } int DOFMatrix::memsize() { - int sizeDOFMatrix = sizeof(DOFMatrix); - int sizeMatrix = sizeof(std::vector<MatrixRow>); - for (int i = 0; i < static_cast<int>(matrix.size()); i++) { - sizeMatrix += sizeof(MatrixRow) + matrix[i].size() * sizeof(MatEntry); - } - - return sizeDOFMatrix + sizeMatrix; - } - - - double norm(std::vector<MatEntry> *row) - { - double result = 0.0; - std::vector<MatEntry>::iterator it; - for (it = row->begin(); it < row->end(); ++it) { - result += (*it).entry * (*it).entry; - } - - return(sqrt(result)); - } - - double min(std::vector<MatEntry> *row) - { - double result = 0.0; - if (row->size() > 0) { - result = (*row)[0].entry; - } - - std::vector<MatEntry>::iterator it; - for (it = row->begin(); it < row->end(); ++it) { - if ((*it).entry < result) { - result = (*it).entry; - } - } - - return(result); + return (num_rows(matrix) + matrix.nnz()) * sizeof(base_matrix_type::size_type) + + matrix.nnz() * sizeof(base_matrix_type::value_type); } - double max(std::vector<MatEntry> *row) - { - double result = 0.0; - if (row->size() > 0) { - result = (*row)[0].entry; - } - - std::vector<MatEntry>::iterator it; - for (it = row->begin(); it < row->end(); ++it) { - if ((*it).entry > result) { - result = (*it).entry; - } - } - - return(result); - } - - void addDOFMatrix(DOFMatrix *result, const DOFMatrix *a, const DOFMatrix *b) - { - result->clear(); - - DOFMatrix::Iterator resultIterator(result, USED_DOFS); - DOFMatrix::Iterator aIterator(const_cast<DOFMatrix*>(a), USED_DOFS); - DOFMatrix::Iterator bIterator(const_cast<DOFMatrix*>(b), USED_DOFS); - - for (resultIterator.reset(), aIterator.reset(); - !aIterator.end(); - ++resultIterator, ++aIterator) { - - *resultIterator = *aIterator; - } - - for (resultIterator.reset(), bIterator.reset(); - !bIterator.end(); - ++resultIterator, ++bIterator) { - std::vector<MatEntry>::iterator resultRowIt; - std::vector<MatEntry>::const_iterator bRowIt; - - for (bRowIt = bIterator->begin(); - bRowIt != bIterator->end(); - ++bRowIt) { - bool added = false; - for (resultRowIt = resultIterator->begin(); - resultRowIt != resultIterator->end(); - ++resultRowIt) { - if (bRowIt->col == resultRowIt->col) { - resultRowIt->entry += bRowIt->entry; - - added = true; - break; - } - } - - if (!added) { - resultIterator->push_back(*bRowIt); - } - } - } - } - - void addDOFMatrix(DOFMatrix *result, const DOFMatrix *a) - { - DOFMatrix::Iterator resultIterator(result, USED_DOFS); - DOFMatrix::Iterator aIterator(const_cast<DOFMatrix*>(a), USED_DOFS); - - for (resultIterator.reset(), aIterator.reset(); - !aIterator.end(); - ++resultIterator, ++aIterator) { - std::vector<MatEntry>::iterator resultRowIt; - std::vector<MatEntry>::const_iterator aRowIt; - - for (aRowIt = aIterator->begin(); - aRowIt != aIterator->end(); - ++aRowIt) { - bool added = false; - for (resultRowIt = resultIterator->begin(); - resultRowIt != resultIterator->end(); - ++resultRowIt) { - if (aRowIt->col == resultRowIt->col) { - resultRowIt->entry += aRowIt->entry; - - added = true; - break; - } - } - - if (!added) { - resultIterator->push_back(*aRowIt); - } - } - } - } } diff --git a/AMDiS/src/DOFMatrix.h b/AMDiS/src/DOFMatrix.h index 49d5ea3c..5321efc2 100644 --- a/AMDiS/src/DOFMatrix.h +++ b/AMDiS/src/DOFMatrix.h @@ -30,7 +30,9 @@ #include <set> #include <memory> #include <list> +#include <boost/numeric/mtl/mtl.hpp> +#include "AMDiS_fwd.h" #include "Global.h" #include "Flag.h" #include "RCNeighbourList.h" @@ -47,20 +49,6 @@ namespace AMDiS { - // ============================================================================ - // ===== forward declarations ================================================= - // ============================================================================ - - class Mesh; - class FiniteElemSpace; - class ElInfo; - class BasisFunction; - class FillInfo; - class Operator; - class ElementMatrix; - class BoundaryManager; - - template<typename T> class DOFVector; // =========================================================================== // ===== struct MatEntry ===================================================== @@ -168,16 +156,25 @@ namespace AMDiS { /** \ingroup DOFAdministration * \brief * A DOFMatrix is a sparse matrix representation for matrices that work - * on DOFVectors. Every row of a matrix is realized as a vector of MatEntry - * objects. Each entry consists of a column DOF index and the corresponding - * double matrix entry. Unused entries are marked with a negative column index. + * on DOFVectors. The underlying matrix type + * is a CRS matrix of double. */ - class DOFMatrix : public DOFIndexed< std::vector<MatEntry> >, + class DOFMatrix : public DOFIndexed<bool>, public Serializable { public: MEMORY_MANAGED(DOFMatrix); + /// Type of scalars in the underlying matrix + typedef double value_type; + + /// Type of underlying matrix + typedef mtl::compressed2D<value_type> base_matrix_type; + + /// Type of inserter for the base matrix; + typedef mtl::matrix::inserter<base_matrix_type> inserter_type; + + private: /** \ingroup DOFAdministration * \brief * Alias for DOFIterator< std::vector<MatEntry<T> > >. So one can access an @@ -237,45 +234,38 @@ namespace AMDiS { void copy(const DOFMatrix& rhs); - /** \brief - * Returns an iterator to the begin of matrix rows (\ref matrix.begin()) - */ - std::vector< std::vector<MatEntry> >::iterator begin() { - return matrix.begin(); + /// Access underlying matrix directly + base_matrix_type& getBaseMatrix() + { + return matrix; } - /** \brief - * Returns an iterator to the end of matrix rows (\ref matrix.end()) - */ - std::vector< std::vector<MatEntry> >::iterator end() { - return matrix.end(); + /// Access underlying matrix directly (const) + const base_matrix_type& getBaseMatrix() const + { + return matrix; } + + // Only to get rid of the abstract functions, I hope they are not used + std::vector<bool>::iterator begin() {ERROR_EXIT("Shouldn't be used, only fake."); std::vector<bool> v; return v.begin();} + std::vector<bool>::iterator end() {ERROR_EXIT("Shouldn't be used, only fake."); std::vector<bool> v; return v.end();} +#if 1 + + bool dummy; // Must be deleted later + bool& operator[](int i) {ERROR_EXIT("Shouldn't be used, only fake."); return dummy;} + const bool& operator[](int i) const {ERROR_EXIT("Shouldn't be used, only fake."); return dummy;} +#endif /** \brief - * Used by DOFAdmin to compress the DOFMatrix + * DOFMatrix does not need to be compressed before assembling, when using MTL4. */ - virtual void compressDOFIndexed(int first, int last, - std::vector<DegreeOfFreedom> &newDOF); + void compressDOFIndexed(int first, int last, std::vector<DegreeOfFreedom> &newDOF) {} /** \brief * Implements DOFIndexedBase::freeDOFContent() */ virtual void freeDOFContent(int index); - /** \brief - * Returns whether entry matrix[a][b] is used - */ - inline bool entryUsed(DegreeOfFreedom a, int b) const { - return (((matrix[a])[b]).col >= 0); - } - - /** \brief - * Returns true if matrix[a][b] has entry \ref NO_MORE_ENTRIES - */ - inline bool noMoreEntries(DegreeOfFreedom a, int b) const { - return (NO_MORE_ENTRIES == ((matrix[a])[b]).col); - } - /** \brief * Returns \ref coupleMatrix. */ @@ -290,13 +280,7 @@ namespace AMDiS { coupleMatrix = c; } - /** \brief - * Matrix-matrix multiplication. - */ - void mm(MatrixTranspose aTranspose, DOFMatrix& a, - MatrixTranspose bTranspose, DOFMatrix& b); - - /** \brief + /** \brief * a*x + y */ void axpy(double a, const DOFMatrix& x, const DOFMatrix& y); @@ -392,24 +376,30 @@ namespace AMDiS { */ void finishAssembling(); - /// Returns \ref matrix - std::vector< std::vector<MatEntry> >& getMatrix() { - return matrix; - } - - /// - void setMatrix(std::vector< std::vector<MatEntry> > m) { - matrix = m; - } + /** \brief + * Enable insertion for assembly. You can optionally give an upper limit for + * entries per row (per column for CCS matrices). Choosing this parameter + * too small can induce perceivable overhead for compressed matrices. Thus, + * it's better to choose a bit too large than too small. + */ + void startInsertion(int nnz_per_row= 10) + { + if (inserter) + delete inserter, inserter= 0; - /// Returns \ref matrix[n] - const std::vector<MatEntry>& getRow(int n) const { - return matrix[n]; + inserter= new inserter_type(matrix, nnz_per_row); } - /// Returns \ref matrix[n] - std::vector<MatEntry>& getRow(int n) { - return matrix[n]; + /** \brief + * Finishes insertion. For compressed matrix types, this is where the + * compression happens. + */ + void finishInsertion() + { + TEST_EXIT(inserter)("Inserter wasn't used or is already finished."); + + delete inserter; + inserter= 0; } /** \brief @@ -437,7 +427,7 @@ namespace AMDiS { /// Returns number of rows (\ref matrix.size()) inline int getSize() const { - return matrix.size(); + return num_rows(matrix); } /** \brief @@ -448,6 +438,8 @@ namespace AMDiS { return rowFESpace->getAdmin()->getUsedSize(); } + + // Only fake, shouldn't be called /** \brief * Returns number of cols. For that, the function iteratos over all * rows and searchs for the entry with the highest col number. @@ -461,45 +453,9 @@ namespace AMDiS { /// Resizes \ref matrix to n rows inline void resize(int n) { - TEST_EXIT_DBG(n >= 0)("Can't resize DOFMatrix to negative size\n"); - matrix.resize(n); - } - - /// Returns \ref matrix[i] which is the i-th row - inline const std::vector<MatEntry>& operator[](int i) const { - TEST_EXIT_DBG((i >= 0) && (i < (static_cast<int>(matrix.size())))) - ("Illegal matrix index %d.\n",i); - return matrix[i]; - } - - /// Returns \ref matrix[i] which is the i-th row - inline std::vector<MatEntry>& operator[](int i) { - TEST_EXIT_DBG((i >= 0) && (i < (static_cast<int>(matrix.size())))) - ("Illegal vector index %d.\n", i); - return matrix[i]; - } - - /// Access to \ref matrix[a][b].entry - inline double physAcc(DegreeOfFreedom a, DegreeOfFreedom b) const { - return matrix[a][b].entry; - } - - /// Access to \ref matrix[a][b].col - inline DegreeOfFreedom physToLogIndex(DegreeOfFreedom a, - DegreeOfFreedom b) const - { - return matrix[a][b].col; - } - - /// Returns physical column index of logical index b in row a - inline DegreeOfFreedom logToPhysIndex(DegreeOfFreedom a, DegreeOfFreedom b) const - { - int size = static_cast<int>(matrix[a].size()); - for (int j = 0; j < size; j++) - if (b == matrix[a][j].col) - return j; - - return -1; + TEST_EXIT_DBG(n >= 0)("Can't resize DOFMatrix to negative size\n"); + // matrix.change_dim(n, n); + //WARNING("Obsolete function without effect -- Peter\n"); } /// Returns value at logical indices a,b @@ -508,14 +464,6 @@ namespace AMDiS { /// Changes col at logical indices a,b to c void changeColOfEntry(DegreeOfFreedom a, DegreeOfFreedom b, DegreeOfFreedom c); - /// Changes col of \ref matrix[a][b] to c - inline void changePhysColOfEntry(DegreeOfFreedom a, - DegreeOfFreedom b, - DegreeOfFreedom c) - { - matrix[a][b].col = c; - } - /** \brief * Creates an entry with logical indices irow, icol if there is no entry * yet. Than sign * entry is added to the value at this logical indices @@ -524,18 +472,6 @@ namespace AMDiS { int irow, int jcol, double entry, bool add = true); - inline double *hasSparseDOFEntry(int irow, int jcol) { - std::vector<MatEntry>::iterator it; - std::vector<MatEntry>::iterator end = matrix[irow].end(); - for (it = matrix[irow].begin(); it != end; ++it) { - if (it->col == NO_MORE_ENTRIES) - return NULL; - if (it->col == jcol) - return &(it->entry); - } - return NULL; - } - void addMatEntry(int row, MatEntry entry); void addMatEntry(int row, int DegreeOfFreedom, double value); @@ -547,11 +483,11 @@ namespace AMDiS { /// Prints \ref matrix to stdout void print() const; - /// Prints a row of \ref matrix to stdout - void printRow(int i) const; - /// Removes all matrix entries - void clear(); + void clear() + { + set_to_zero(matrix); + } /// Test whether \ref matrix is symmetric. Exits if not. void test(); @@ -584,28 +520,77 @@ namespace AMDiS { void createPictureFile(const char* filename, int dim); - void serialize(std::ostream &out) + private: + template <typename T> + void s_write(::std::ostream &out, const T& value) { - unsigned int matrixSize = matrix.size(); - unsigned int vecSize = 0; - - out.write(reinterpret_cast<const char*>(&matrixSize), sizeof(unsigned int)); - for(unsigned int i = 0; i < matrixSize; i++) { - vecSize = matrix[i].size(); - out.write(reinterpret_cast<const char*>(&vecSize), sizeof(unsigned int)); - out.write(reinterpret_cast<const char*>(&(matrix[i][0])), vecSize * sizeof(MatEntry)); - } + out.write(reinterpret_cast<const char*>(&value), sizeof value); + } + + public: + void serialize(::std::ostream &out) + { + using namespace mtl; + + typedef traits::range_generator<tag::major, base_matrix_type>::type c_type; + typedef traits::range_generator<tag::nz, c_type>::type ic_type; + + typedef Collection<base_matrix_type>::size_type size_type; + typedef Collection<base_matrix_type>::value_type value_type; + + traits::row<base_matrix_type>::type row(matrix); + traits::col<base_matrix_type>::type col(matrix); + traits::const_value<base_matrix_type>::type value(matrix); + + size_type rows= num_rows(matrix), cols= num_cols(matrix), total= matrix.nnz(); + s_write(out, rows); + s_write(out, cols); + s_write(out, total); + + for (c_type cursor(mtl::begin<tag::major>(matrix)), cend(mtl::end<tag::major>(matrix)); + cursor != cend; ++cursor) + for (ic_type icursor(mtl::begin<tag::nz>(cursor)), icend(mtl::end<tag::nz>(cursor)); + icursor != icend; ++icursor) { + size_type my_row= row(*icursor), my_col= col(*icursor); + value_type my_value= value(*icursor); + s_write(out, my_row); + s_write(out, my_col); + s_write(out, my_value); + } } - void deserialize(std::istream &in) { - unsigned int matrixSize, vecSize; + private: + template <typename T> + void s_read(::std::istream &in, T& value) + { + in.read(reinterpret_cast<char*>(&value), sizeof value); + } - in.read(reinterpret_cast<char*>(&matrixSize), sizeof(unsigned int)); - matrix.resize(matrixSize); - for(unsigned int i = 0; i < matrixSize; i++) { - in.read(reinterpret_cast<char*>(&vecSize), sizeof(unsigned int)); - matrix[i].resize(vecSize); - in.read(reinterpret_cast<char*>(&(matrix[i][0])), vecSize * sizeof(MatEntry)); + public: + void deserialize(::std::istream &in) + { + using namespace mtl; + + typedef Collection<base_matrix_type>::size_type size_type; + typedef Collection<base_matrix_type>::value_type value_type; + + size_type rows, cols, total; + s_read(in, rows); + s_read(in, cols); + s_read(in, total); + + // Prepare matrix insertion + clear(); + // matrix.change_dim(rows, cols) // do we want this? + inserter_type ins(matrix); + + for (size_type i= 0; i < total; ++i) { + size_type my_row, my_col; + value_type my_value; + s_read(in, my_row); + s_read(in, my_col); + s_read(in, my_value); + ins(my_row, my_col) << my_value; } } @@ -635,8 +620,8 @@ namespace AMDiS { /// Name of the DOFMatrix std::string name; - /// Sparse matrix stored in an STL vector of MatrixRow objects - std::vector<MatrixRow> matrix; + /// Sparse matrix, type is a template parameter by default compressed2D<double> + base_matrix_type matrix; /// Used while mesh traversal static DOFMatrix *traversePtr; @@ -673,6 +658,9 @@ namespace AMDiS { AO *applicationOrdering; #endif + /// Inserter object: implemented as pointer, allocated and deallocated as needed + inserter_type *inserter; + friend class DOFAdmin; friend class DOFVector<double>; friend class DOFVector<unsigned char>; @@ -680,24 +668,6 @@ namespace AMDiS { friend class DOFVector<WorldVector<double> >; }; - - inline DegreeOfFreedom logToPhysIndex(DOFMatrix *m, - DegreeOfFreedom a, DegreeOfFreedom b) - { - return m->logToPhysIndex(a, b); - } - - double norm(std::vector<MatEntry> *row); - - double min(std::vector<MatEntry> *row); - - double max(std::vector<MatEntry> *row); - - /// Addes two matrices. The result matrix is overwritten. - void addDOFMatrix(DOFMatrix *result, const DOFMatrix *a, const DOFMatrix *b); - - /// Addes matrix a to matrix result. - void addDOFMatrix(DOFMatrix *result, const DOFMatrix *a); } #endif // AMDIS_DOFMATRIX_H diff --git a/AMDiS/src/DOFVector.cc b/AMDiS/src/DOFVector.cc index d6742ffe..51be6625 100644 --- a/AMDiS/src/DOFVector.cc +++ b/AMDiS/src/DOFVector.cc @@ -605,7 +605,7 @@ namespace AMDiS { for (int i = 0; i < numBasFcts; i++) { if (vec[myLocalIndices[i]] == nul) { coords = basFcts->getCoords(i); - vec[myLocalIndices[i]] += vBasFcts->evalUh(*coords, vLocalCoeffs,NULL) * factor; + vec[myLocalIndices[i]] += vBasFcts->evalUh(*coords, vLocalCoeffs, NULL) * factor; } } elInfo = stack.traverseNext(elInfo); diff --git a/AMDiS/src/DOFVector.h b/AMDiS/src/DOFVector.h index ebd581b0..f56e7889 100644 --- a/AMDiS/src/DOFVector.h +++ b/AMDiS/src/DOFVector.h @@ -30,6 +30,7 @@ #include <memory> #include <list> +#include "AMDiS_fwd.h" #include "FixVec.h" #include "Global.h" #include "Flag.h" @@ -54,23 +55,6 @@ namespace AMDiS { // ===== forward declarations ================================================ // =========================================================================== - class Mesh; - class FiniteElemSpace; - class ElInfo; - class DOFAdmin; - class BasisFunction; - class FillInfo; - class Quadrature; - class FastQuadrature; - class DOFMatrix; - class MultiGridSortSolver; - class Operator; - class ElementVector; - class BoundaryManager; - - template<typename ResultType, typename ArgumentType> class AbstractFunction; - - template<typename T> class DOFVectorBase : public DOFIndexed<T> { @@ -345,6 +329,7 @@ namespace AMDiS { */ DOFVector() : DOFVectorBase<T>(), + //elementVector(NULL), feSpace(NULL), coarsenOperation(NO_OPERATION) {} @@ -395,7 +380,6 @@ namespace AMDiS { */ virtual void compressDOFIndexed(int first, int last, std::vector<DegreeOfFreedom> &newDof); - /** \brief * Sets \ref coarsenOperation to op */ @@ -469,10 +453,6 @@ namespace AMDiS { return vec[i]; } - inline int getSize() { - return vec.size(); - } - /** \brief * Returns \ref vec[i] */ @@ -594,7 +574,7 @@ namespace AMDiS { /// Used by interpol while mesh traversal static int interpolFct(ElInfo* elinfo); - + /// Prints \ref vec to stdout void print() const; @@ -626,9 +606,7 @@ namespace AMDiS { WorldVector<DOFVector<T>*> *getGradient(WorldVector<DOFVector<T>*> *grad) const; - DOFVector<WorldVector<T> >* - - getRecoveryGradient(DOFVector<WorldVector<T> >*) const; + DOFVector<WorldVector<T> >* getRecoveryGradient(DOFVector<WorldVector<T> >*) const; #ifdef HAVE_PARALLEL_AMDIS /// Sets the petsc application ordering object to map dof indices. @@ -748,6 +726,10 @@ namespace AMDiS { return DOFVector<DegreeOfFreedom>::operator[](i); } + const DegreeOfFreedom& operator[](DegreeOfFreedom i) const { + return DOFVector<DegreeOfFreedom>::operator[](i); + } + /// Implements DOFIndexedBase::getSize() int getSize() const { return DOFVector<DegreeOfFreedom>::getSize(); diff --git a/AMDiS/src/DOFVector.hh b/AMDiS/src/DOFVector.hh index d476dd76..233c6769 100644 --- a/AMDiS/src/DOFVector.hh +++ b/AMDiS/src/DOFVector.hh @@ -20,12 +20,60 @@ #include "Parameters.h" #include "Traverse.h" +#include <boost/numeric/mtl/mtl.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + + +// Defining the interface for MTL4 +namespace mtl { + + // Let MTL4 know that DOFVector it is a column vector + namespace traits { + template <typename T> + struct category< AMDiS::DOFVector<T> > + { + typedef tag::dense_col_vector type; + }; + } + + namespace ashape { + template <typename T> + struct ashape< AMDiS::DOFVector<T> > + { + typedef cvec<typename ashape<T>::type> type; + }; + } + + // Modelling Collection and MutableCollection + template <typename T> + struct Collection< AMDiS::DOFVector<T> > + { + typedef T value_type; + typedef const T& const_reference; + typedef std::size_t size_type; + }; + + template <typename T> + struct MutableCollection< AMDiS::DOFVector<T> > + : public Collection< AMDiS::DOFVector<T> > + { + typedef T& reference; + }; + + +} // namespace mtl + + + namespace AMDiS { template<typename T> DOFVectorBase<T>::DOFVectorBase(const FiniteElemSpace *f, std::string n) : feSpace(f), name(n), + elementVector(NULL), boundaryManager(NULL) { nBasFcts = feSpace->getBasisFcts()->getNumber(); @@ -63,6 +111,7 @@ namespace AMDiS { template<typename T> DOFVector<T>::DOFVector(const FiniteElemSpace* f, std::string n) : DOFVectorBase<T>(f, n), + //elementVector(NULL), coarsenOperation(NO_OPERATION) { init(f, n); @@ -77,7 +126,7 @@ namespace AMDiS { { name = n; feSpace = f; - if (feSpace && feSpace->getAdmin()) { + if(feSpace && feSpace->getAdmin()) { (feSpace->getAdmin())->addDOFIndexed(this); } this->boundaryManager = NEW BoundaryManager(f); @@ -86,7 +135,7 @@ namespace AMDiS { template<typename T> DOFVector<T>::~DOFVector() { - if (feSpace && feSpace->getAdmin()) { + if(feSpace && feSpace->getAdmin()) { (feSpace->getAdmin())->removeDOFIndexed(this); } @@ -348,7 +397,21 @@ namespace AMDiS { a.getSize(), a.getRowFESpace()->getAdmin()->getUsedSize()); } - ysize = y.getSize(); + // Create MTL vector as wrapper of y + mtl::vector::dense_vector<double> yy(y.getSize(), &y[0]); + DOFMatrix::base_matrix_type& A= a.getBaseMatrix(); + + if (transpose == NoTranspose) + yy= alpha*A*x + beta*yy; + else if (transpose == Transpose) + yy= alpha*trans(A)*x + beta*yy; + else + ERROR_EXIT("transpose=%d\n", transpose); + + +#if 0 + + //ysize = y.getSize(); typename DOFVector<T>::Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(&y), FREE_DOFS); for (vecIterator.reset(); !vecIterator.end(); ++vecIterator) { @@ -402,6 +465,8 @@ namespace AMDiS { else { ERROR_EXIT("transpose=%d\n", transpose); } +#endif + } template<typename T> @@ -481,7 +546,7 @@ namespace AMDiS { template<typename T> void DOFVector<T>::interpol(AbstractFunction<T, WorldVector<double> > *fct) { - FUNCNAME("DOFVector<T>::interpol()"); + FUNCNAME("interpol"); TEST_EXIT_DBG(fct)("no function to interpolate\n"); @@ -871,22 +936,26 @@ namespace AMDiS { T operator*(DOFVector<T>& x, DOFVector<T>& y) { FUNCNAME("DOFVector<T>::operator*(DOFVector<T>& x, DOFVector<T>& y)"); + T dot; + const DOFAdmin *admin = NULL; - TEST_EXIT_DBG(x.getFESpace() && y.getFESpace()) + TEST_EXIT(x.getFESpace() && y.getFESpace()) ("feSpace is NULL: %8X, %8X\n", x.getFESpace(), y.getFESpace()); - TEST_EXIT_DBG(x.getFESpace()->getAdmin() && - (x.getFESpace()->getAdmin() == y.getFESpace()->getAdmin())) + TEST_EXIT((admin = x.getFESpace()->getAdmin()) && (admin == y.getFESpace()->getAdmin())) ("no admin or different admins: %8X, %8X\n", x.getFESpace()->getAdmin(), y.getFESpace()->getAdmin()); - TEST_EXIT_DBG(x.getSize() == y.getSize())("different sizes\n"); + TEST_EXIT(x.getSize() == y.getSize())("different sizes\n"); + + dot = 0; - T dot = 0; typename DOFVector<T>::Iterator xIterator(dynamic_cast<DOFIndexed<T>*>(&x), USED_DOFS); typename DOFVector<T>::Iterator yIterator(dynamic_cast<DOFIndexed<T>*>(&y), USED_DOFS); - for (xIterator.reset(), yIterator.reset(); !xIterator.end(); - ++xIterator, ++yIterator) { - dot += (*xIterator) * (*yIterator); - } + for (xIterator.reset(), yIterator.reset(); + !xIterator.end(); + ++xIterator, ++yIterator) + { + dot += (*xIterator) * (*yIterator); + }; return(dot); } @@ -898,94 +967,34 @@ namespace AMDiS { DOFVector<T> &result, bool add) { + // Unfortunately needed + using namespace mtl; + FUNCNAME("DOFVector<T>::mv()"); - TEST_EXIT_DBG(a.getRowFESpace() && a.getColFESpace() && x.getFESpace() && result.getFESpace()) + TEST_EXIT(a.getRowFESpace() && a.getColFESpace() && x.getFESpace() && result.getFESpace()) ("getFESpace() is NULL: %8X, %8X, %8X, %8X\n", a.getRowFESpace(), a.getColFESpace(), x.getFESpace(), result.getFESpace()); - - TEST_EXIT_DBG((a.getRowFESpace()->getAdmin() && a.getColFESpace()->getAdmin()) && - (((transpose == NoTranspose) && - (a.getColFESpace()->getAdmin() == x.getFESpace()->getAdmin()) && - (a.getRowFESpace()->getAdmin() == result.getFESpace()->getAdmin())) || - ((transpose == Transpose) && - (a.getRowFESpace()->getAdmin() == x.getFESpace()->getAdmin()) && - (a.getColFESpace()->getAdmin() == result.getFESpace()->getAdmin())))) + + const DOFAdmin *rowAdmin = a.getRowFESpace()->getAdmin(); + const DOFAdmin *colAdmin = a.getColFESpace()->getAdmin(); + + TEST_EXIT((rowAdmin && colAdmin) && + (((transpose == NoTranspose) && (colAdmin == x.getFESpace()->getAdmin()) && + (rowAdmin == result.getFESpace()->getAdmin()))|| + ((transpose == Transpose) && (rowAdmin == x.getFESpace()->getAdmin()) && + (colAdmin == result.getFESpace()->getAdmin())))) ("no admin or different admins: %8X, %8X, %8X, %8X\n", a.getRowFESpace()->getAdmin(), a.getColFESpace()->getAdmin(), x.getFESpace()->getAdmin(), result.getFESpace()->getAdmin()); - - if (transpose == NoTranspose) { - TEST_EXIT_DBG(static_cast<int>(x.getSize()) >= a.getColFESpace()->getAdmin()->getUsedSize()) - ("x.size = %d too small: admin->sizeUsed = %d\n", - x.getSize(), a.getColFESpace()->getAdmin()->getUsedSize()); - TEST_EXIT_DBG(static_cast<int>( result.getSize()) >= a.getRowFESpace()->getAdmin()->getUsedSize()) - ("size = %d too small: admin->sizeUsed = %d\n", - result.getSize(), a.getRowFESpace()->getAdmin()->getUsedSize()); - TEST_EXIT_DBG(static_cast<int>( a.getSize()) >= a.getRowFESpace()->getAdmin()->getUsedSize()) - ("a.size = %d too small: admin->sizeUsed = %d\n", - a.getSize(), a.getRowFESpace()->getAdmin()->getUsedSize()); - - - typename DOFVector<T>::Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(&result), USED_DOFS); - DOFMatrix::Iterator rowIterator(const_cast<DOFMatrix*>(&a), USED_DOFS); - for (vecIterator.reset(), rowIterator.reset(); !rowIterator.end(); - ++rowIterator, ++vecIterator) { - - double sum = 0; - if (!add) - *vecIterator = 0.0; - for (std::vector<MatEntry>::iterator colIterator = rowIterator->begin(); - colIterator != rowIterator->end(); - colIterator++) { - - int jcol = colIterator->col; - if (jcol >= 0) { // entry used? - sum += (static_cast<double>(colIterator->entry)) * x[jcol]; - } else { - if (jcol == DOFMatrix::NO_MORE_ENTRIES) - break; - } - } - *vecIterator += sum; - } - } else if (transpose == Transpose) { - TEST_EXIT_DBG(static_cast<int>(x.getSize()) >= a.getRowFESpace()->getAdmin()->getUsedSize()) - ("x.size = %d too small: admin->sizeUsed = %d\n", - x.getSize(), a.getRowFESpace()->getAdmin()->getUsedSize()); - TEST_EXIT_DBG(static_cast<int>( result.getSize()) >= a.getColFESpace()->getAdmin()->getUsedSize()) - ("size = %d too small: admin->sizeUsed = %d\n", - result.getSize(), a.getColFESpace()->getAdmin()->getUsedSize()); - TEST_EXIT_DBG(static_cast<int>( a.getSize()) >= a.getRowFESpace()->getAdmin()->getUsedSize()) - ("a.size = %d too small: admin->sizeUsed = %d\n", - a.getSize(), a.getRowFESpace()->getAdmin()->getUsedSize()); - - if (!add) { - typename DOFVector<T>::Iterator vecIterator(dynamic_cast<DOFIndexed<T>*>(&result), USED_DOFS); - for (vecIterator.reset(); !vecIterator.end(); ++vecIterator) { - *vecIterator = 0; - } - } - typename DOFVector<T>::Iterator xIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(&x)), USED_DOFS); - DOFMatrix::Iterator rowIterator(const_cast<DOFMatrix*>(&a), USED_DOFS); - for (xIterator.reset(), rowIterator.reset(); !rowIterator.end(); - ++rowIterator, ++xIterator) { - T ax = (*xIterator); - for (std::vector<MatEntry>::iterator colIterator = rowIterator->begin(); - colIterator != rowIterator->end(); - colIterator++) { - int jcol = colIterator->col; - if (jcol >= 0) // entry used? - result[jcol] += (static_cast<double>(colIterator->entry)) * ax; - else - if (jcol == DOFMatrix::NO_MORE_ENTRIES) break; - } - } - } else { + if (transpose == NoTranspose) + mult(a.getBaseMatrix(), x, result); + else if (transpose == Transpose) + mult(trans(const_cast<DOFMatrix::base_matrix_type&>(a.getBaseMatrix())), x, result); + else ERROR_EXIT("transpose = %d\n", transpose); - } } template<typename T> @@ -995,26 +1004,43 @@ namespace AMDiS { { FUNCNAME("DOFVector<T>::axpy()"); - TEST_EXIT_DBG(x.getFESpace() && y.getFESpace()) + TEST_EXIT(x.getFESpace() && y.getFESpace()) ("feSpace is NULL: %8X, %8X\n", x.getFESpace(), y.getFESpace()); - TEST_EXIT_DBG(x.getFESpace()->getAdmin() && - (x.getFESpace()->getAdmin() == y.getFESpace()->getAdmin())) + const DOFAdmin *admin = x.getFESpace()->getAdmin(); + + TEST_EXIT((admin) && (admin == y.getFESpace()->getAdmin())) ("no admin or different admins: %8X, %8X\n", x.getFESpace()->getAdmin(), y.getFESpace()->getAdmin()); - TEST_EXIT_DBG(static_cast<int>(x.getSize()) >= x.getFESpace()->getAdmin()->getUsedSize()) + TEST_EXIT(static_cast<int>(x.getSize()) >= admin->getUsedSize()) ("size = %d too small: admin->size = %d\n", x.getSize(), - x.getFESpace()->getAdmin()->getUsedSize()); - TEST_EXIT_DBG(static_cast<int>(y.getSize()) >= x.getFESpace()->getAdmin()->getUsedSize()) + admin->getUsedSize()); + TEST_EXIT(static_cast<int>(y.getSize()) >= admin->getUsedSize()) ("y.size = %d too small: admin->size = %d\n", y.getSize(), - x.getFESpace()->getAdmin()->getUsedSize()); - - typename DOFVector<T>::Iterator xIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&x)), USED_DOFS); - typename DOFVector<T>::Iterator yIterator(dynamic_cast<DOFIndexed<T>*>(&y), USED_DOFS); - for (xIterator.reset(), yIterator.reset(); !xIterator.end(); - ++xIterator, ++yIterator) { - *yIterator += alpha * (*xIterator); - } + admin->getUsedSize()); + + // This is the old implementation of the mv-multiplication. It have been changed + // because of the OpenMP-parallelization: +// typename DOFVector<T>::Iterator xIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&x)), USED_DOFS); +// typename DOFVector<T>::Iterator yIterator(dynamic_cast<DOFIndexed<T>*>(&y), USED_DOFS); +// for(xIterator.reset(), yIterator.reset(); +// !xIterator.end(); +// ++xIterator, ++yIterator) +// { +// *yIterator += alpha * (*xIterator); +// }; + + int i; + int maxI = y.getSize(); + +#ifdef _OPENMP +#pragma omp parallel for schedule(dynamic, 25000) default(shared) private(i) +#endif + for (i = 0; i < maxI; i++) { + if (!admin->isDOFFree(i)) { + y[i] += alpha * x[i]; + } + } } template<typename T> @@ -1046,26 +1072,43 @@ namespace AMDiS { { FUNCNAME("DOFVector<T>::xpay()"); - TEST_EXIT_DBG(x.getFESpace() && y.getFESpace()) + TEST_EXIT(x.getFESpace() && y.getFESpace()) ("feSpace is NULL: %8X, %8X\n", x.getFESpace(), y.getFESpace()); - TEST_EXIT_DBG(x.getFESpace()->getAdmin() && - (x.getFESpace()->getAdmin() == y.getFESpace()->getAdmin())) + const DOFAdmin *admin = x.getFESpace()->getAdmin(); + + TEST_EXIT(admin && (admin == y.getFESpace()->getAdmin())) ("no admin or different admins: %8X, %8X\n", x.getFESpace()->getAdmin(), y.getFESpace()->getAdmin()); - TEST_EXIT_DBG(static_cast<int>(x.getSize()) >= x.getFESpace()->getAdmin()->getUsedSize()) + TEST_EXIT(static_cast<int>(x.getSize()) >= admin->getUsedSize()) ("size = %d too small: admin->size = %d\n", x.getSize(), - x.getFESpace()->getAdmin()->getUsedSize()); - TEST_EXIT_DBG(static_cast<int>(y.getSize()) >= x.getFESpace()->getAdmin()->getUsedSize()) + admin->getUsedSize()); + TEST_EXIT(static_cast<int>(y.getSize()) >= admin->getUsedSize()) ("y.size = %d too small: admin->size = %d\n", y.getSize(), - x.getFESpace()->getAdmin()->getUsedSize()); - - typename DOFVector<T>::Iterator xIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&x)), USED_DOFS); - typename DOFVector<T>::Iterator yIterator(dynamic_cast<DOFIndexed<T>*>(&y), USED_DOFS); - for (xIterator.reset(), yIterator.reset(); !xIterator.end(); - ++xIterator, ++yIterator) { - *yIterator = alpha *(*yIterator)+ (*xIterator); - } + admin->getUsedSize()); + + // This is the old implementation of the mv-multiplication. It have been changed + // because of the OpenMP-parallelization: + // typename DOFVector<T>::Iterator xIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&x)), USED_DOFS); + // typename DOFVector<T>::Iterator yIterator(dynamic_cast<DOFIndexed<T>*>(&y), USED_DOFS); + // for(xIterator.reset(), yIterator.reset(); + // !xIterator.end(); + // ++xIterator, ++yIterator) + // { + // *yIterator = alpha *(*yIterator)+ (*xIterator); + // }; + + int i; + int maxI = y.getSize(); + +#ifdef _OPENMP +#pragma omp parallel for schedule(dynamic, 25000) default(shared) private(i) +#endif + for (i = 0; i < maxI; i++) { + if (!admin->isDOFFree(i)) { + y[i] = alpha * y[i] + x[i]; + } + } } template<typename T> @@ -1075,10 +1118,12 @@ namespace AMDiS { { typename DOFVector<T>::Iterator vIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&v)), USED_DOFS); typename DOFVector<T>::Iterator rIterator(dynamic_cast<DOFIndexed<T>*>(&result), USED_DOFS); - for (vIterator.reset(), rIterator.reset(); !vIterator.end(); - ++vIterator, ++rIterator) { - *rIterator = scal * (*vIterator); - } + for(vIterator.reset(), rIterator.reset(); + !vIterator.end(); + ++vIterator, ++rIterator) + { + *rIterator = scal * (*vIterator); + }; return result; } @@ -1090,10 +1135,12 @@ namespace AMDiS { { typename DOFVector<T>::Iterator vIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&v)), USED_DOFS); typename DOFVector<T>::Iterator rIterator(dynamic_cast<DOFIndexed<T>*>(&result), USED_DOFS); - for (vIterator.reset(), rIterator.reset(); !vIterator.end(); - ++vIterator, ++rIterator) { - *rIterator = (*vIterator) + scal; - } + for(vIterator.reset(), rIterator.reset(); + !vIterator.end(); + ++vIterator, ++rIterator) + { + *rIterator = (*vIterator) + scal; + }; return result; } @@ -1105,124 +1152,135 @@ namespace AMDiS { typename DOFVector<T>::Iterator v1Iterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&v1)), USED_DOFS); typename DOFVector<T>::Iterator v2Iterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&v2)), USED_DOFS); typename DOFVector<T>::Iterator rIterator(dynamic_cast<DOFIndexed<T>*>(&result), USED_DOFS); - for (v1Iterator.reset(), v2Iterator.reset(), rIterator.reset(); !v1Iterator.end(); - ++v1Iterator, ++v2Iterator, ++rIterator) { - *rIterator = (*v1Iterator) + (*v2Iterator); - } + for(v1Iterator.reset(), v2Iterator.reset(), rIterator.reset(); + !v1Iterator.end(); + ++v1Iterator, ++v2Iterator, ++rIterator) + { + *rIterator = (*v1Iterator) + (*v2Iterator); + }; return result; + } template<typename T> - inline const DOFVector<T>& mod(const DOFVector<T>& v, - DOFVector<T>& result) + const T *DOFVectorBase<T>::getLocalVector(const Element *el, T *d) const { - typename DOFVector<T>::Iterator vIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&v)), USED_DOFS); - typename DOFVector<T>::Iterator rIterator(dynamic_cast<DOFIndexed<T>*>(&result), USED_DOFS); + static T* localVec = NULL; + const DOFAdmin* admin = feSpace->getAdmin(); - for (vIterator.reset(), rIterator.reset(); !vIterator.end(); - ++vIterator, ++rIterator) { - *rIterator = fmod((*vIterator), 1.0); - } + int i; + int nBasFcts = feSpace->getBasisFcts()->getNumber(); - return result; - } + T *result; + + if(d) { + result = d; + } else { + if(localVec) delete [] localVec; + localVec = new T[nBasFcts]; + result = localVec; + } - template<typename T> - inline const DOFVector<T>& Tanh(const DOFVector<T>& v, - DOFVector<T>& result) - { - typename DOFVector<T>::Iterator vIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&v)), USED_DOFS); - typename DOFVector<T>::Iterator rIterator(dynamic_cast<DOFIndexed<T>*>(&result), USED_DOFS); + const DegreeOfFreedom *localIndices = + feSpace->getBasisFcts()->getLocalIndices(el, admin, NULL); - double eps; - GET_PARAMETER(1, "vecphase->epsilon", "%f", &eps); - for (vIterator.reset(), rIterator.reset(); - !vIterator.end(); - ++vIterator, ++rIterator) { - *rIterator = 0.5 * (1.0 - tanh(3.0 * (*vIterator) / eps)); + for(i = 0; i < nBasFcts; i++) { + result[i] = (*this)[localIndices[i]]; } return result; } - template<typename T> - const T *DOFVectorBase<T>::getVecAtQPs(const ElInfo *elInfo, - const Quadrature *quad, + const T *DOFVectorBase<T>::getVecAtQPs(const ElInfo *elInfo, + const Quadrature *quad, const FastQuadrature *quadFast, - T *vecAtQPs) const + T *vecAtQPs) const { FUNCNAME("DOFVector<T>::getVecAtQPs()"); - TEST_EXIT_DBG(quad || quadFast)("neither quad nor quadFast defined\n"); + TEST_EXIT(quad || quadFast)("neither quad nor quadFast defined\n"); - if (quad && quadFast) { - TEST_EXIT_DBG(quad == quadFast->getQuadrature()) - ("quad != quadFast->quadrature\n"); + if(quad && quadFast) { + TEST_EXIT(quad == quadFast->getQuadrature()) + ("quad != quadFast->quadrature\n"); } - TEST_EXIT_DBG(!quadFast || quadFast->getBasisFunctions() == feSpace->getBasisFcts()) + TEST_EXIT(!quadFast || quadFast->getBasisFunctions() == feSpace->getBasisFcts()) ("invalid basis functions"); + Element *el = elInfo->getElement(); + + const Quadrature *quadrature = quadFast ? quadFast->getQuadrature() : quad; + const BasisFunction *basFcts = feSpace->getBasisFcts(); - int nPoints = quadFast ? quadFast->getQuadrature()->getNumPoints() : quad->getNumPoints(); + + int numPoints = quadrature->getNumPoints(); + int nBasFcts = basFcts->getNumber(); + int i, j; + static T *localvec = NULL; + T *result; if (vecAtQPs) { result = vecAtQPs; } else { - if (localvec) - delete [] localvec; - localvec = new T[nPoints]; - for (int i = 0; i < nPoints; i++) { + if(localvec) delete [] localvec; + localvec = new T[numPoints]; + for(i = 0; i < numPoints; i++) { localvec[i] = 0.0; } result = localvec; } - - T *localVec = localVectors[omp_get_thread_num()]; - getLocalVector(elInfo->getElement(), localVec); - - for (int i = 0; i < nPoints; i++) { - result[i] = 0.0; - for (int j = 0; j < nBasFcts; j++) { - result[i] += localVec[j] * + + const T *localVec = getLocalVector(el, NULL); + + for(i = 0; i < numPoints; i++) { + for(result[i] = j = 0; j < nBasFcts; j++) { + result[i] += localVec[j] * (quadFast ? (quadFast->getPhi(i, j)) : ((*(basFcts->getPhi(j)))(quad->getLambda(i)))); } } - + return const_cast<const T*>(result); } - template<typename T> - const T *DOFVectorBase<T>::getLocalVector(const Element *el, T *d) const + + + + // Some free functions used in MTL4 + + template <typename T> + inline std::size_t size(const AMDiS::DOFVector<T>& v) { - static T* localVec = NULL; - T *result; - if (d) { - result = d; - } else { - if (localVec) - delete [] localVec; - localVec = new T[nBasFcts]; - result = localVec; - } - - DegreeOfFreedom *myLocalIndices = localIndices[omp_get_thread_num()]; - feSpace->getBasisFcts()->getLocalIndices(el, feSpace->getAdmin(), - myLocalIndices); + return v.getSize(); + } - for (int i = 0; i < nBasFcts; i++) { - result[i] = (*this)[myLocalIndices[i]]; - } - - return result; + template <typename T> + inline std::size_t num_rows(const AMDiS::DOFVector<T>& v) + { + return v.getSize(); + } + + template <typename T> + inline std::size_t num_cols(const AMDiS::DOFVector<T>& v) + { + return 1; + } + + + template <typename T> + inline void set_to_zero(AMDiS::DOFVector<T>& v) + { + using math::zero; + T ref, my_zero(zero(ref)); + + std::fill(v.begin(), v.end(), my_zero); } - // integral u^2(1-u)^2 template<typename T> double DOFVector<T>::DoubleWell(Quadrature* q) const { diff --git a/AMDiS/src/DataCollector.cc b/AMDiS/src/DataCollector.cc index b5bb4c6e..c711e9d8 100644 --- a/AMDiS/src/DataCollector.cc +++ b/AMDiS/src/DataCollector.cc @@ -17,7 +17,7 @@ namespace AMDiS { TEST_EXIT(feSpace)("no feSpace\n"); TEST_EXIT(values)("no value Vector\n"); - + // === get mesh === mesh_ = feSpace->getMesh(); @@ -25,6 +25,7 @@ namespace AMDiS { localAdmin_ = const_cast<DOFAdmin*>(feSpace->getAdmin()); // === create vertex info vector === vertexInfos_ = NEW DOFVector< std::list<VertexInfo> >(feSpace, "vertex infos"); + interpPointInd_ = NEW DOFVector<int>(feSpace, "interpolation point indices"); interpPointCoords_ = NEW DOFVector< std::list<WorldVector<double> > >(feSpace, "interpolation point coordinates"); dofCoords_ = NEW DOFVector< std::list<WorldVector<double> > >(feSpace, "dof coords"); diff --git a/AMDiS/src/DiagonalPreconditioner.cc b/AMDiS/src/DiagonalPreconditioner.cc deleted file mode 100644 index 7a260aae..00000000 --- a/AMDiS/src/DiagonalPreconditioner.cc +++ /dev/null @@ -1,59 +0,0 @@ -#include "DiagonalPreconditioner.h" -#include "FiniteElemSpace.h" -#include "DOFAdmin.h" -#include "DOFVector.h" -#include "DOFMatrix.h" -#include "DOFIterator.h" - -namespace AMDiS { - - void DiagonalPreconditioner::precon(DOFVector<double>* x) - { - FUNCNAME("DiagonalPreconditioner::precon()"); - - TEST_EXIT_DBG(matrix[row])("no matrix\n"); - TEST_EXIT_DBG(x)("no solution vector\n"); - - DOFMatrix::Iterator rowIterator((*matrix[row]), USED_DOFS); - DOFVector<double>::Iterator vecIterator(x, USED_DOFS); - - if (bound) { - ERROR_EXIT("not up to date\n"); - DOFVector<BoundaryType>::Iterator bIterator(const_cast<DOFVector<BoundaryType>*>(bound), USED_DOFS); - for (vecIterator.reset(), rowIterator.reset(), bIterator.reset(); - !vecIterator.end(); ++vecIterator, ++bIterator, ++rowIterator) { - // only non-dirichlet nodes will be preconditioned - if ((*bIterator) <= 0 && rowIterator->size() != 0) { - (*vecIterator) /= (*rowIterator)[0].entry; - } - } - } else { - for (vecIterator.reset(), rowIterator.reset(); - !vecIterator.end(); - ++vecIterator, ++rowIterator) { - if (rowIterator->size() != 0) { - (*vecIterator) /= (*rowIterator)[0].entry; - } - } - } - } - - void DiagonalPreconditionerStd::precon(std::vector<double>* x) - { - FUNCNAME("DiagonalPreconditionerStd::precon()"); - - TEST_EXIT_DBG(x)("no solution vector\n"); - TEST_EXIT_DBG(x->size() == matrix->size())("solution vector and matrix have different size\n"); - - std::vector<double>::iterator vecIt; - std::vector< std::vector<MatEntry> >::iterator matrixIt; - - for (vecIt = x->begin(), matrixIt = matrix->begin(); - vecIt < x->end(); - ++vecIt, ++matrixIt) { - if (matrixIt->size() != 0) { - (*vecIt) /= (*matrixIt)[0].entry; - } - } - } -} diff --git a/AMDiS/src/DiagonalPreconditioner.h b/AMDiS/src/DiagonalPreconditioner.h deleted file mode 100644 index 77819b73..00000000 --- a/AMDiS/src/DiagonalPreconditioner.h +++ /dev/null @@ -1,133 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file DiagonalPreconditioner.h */ - -#ifndef AMDIS_DIAGONAL_PRECONDITIONER_H -#define AMDIS_DIAGONAL_PRECONDITIONER_H - -#include <vector> -#include "Preconditioner.h" -#include "MemoryManager.h" -#include "CreatorInterface.h" - -namespace AMDiS { - - template<typename T> class DOFVector; - template<typename T> class OEMSolver; - - // ============================================================================ - // ===== class DiagonalPreconditioner ========================================= - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * diagonal preconditioner. Implements the singleton design pattern to allow - * only one instance of this class. - */ - class DiagonalPreconditioner : public PreconditionerScal - { - public: - MEMORY_MANAGED(DiagonalPreconditioner); - - /** \brief - * Creator class used in the PreconditionerMap. - */ - class Creator : public PreconditionerScalCreator - { - public: - MEMORY_MANAGED(Creator); - - /** \brief - * Creates a DiagonalPreconditioner. - */ - PreconditionerScal *create() { - return NEW DiagonalPreconditioner(size, row); - }; - }; - - /** \brief - * Constructor. - */ - DiagonalPreconditioner(int size = 1, int row = 0) - : PreconditionerScal(size, row) - {}; - - /** \brief - * Destructor. - */ - virtual ~DiagonalPreconditioner() {}; - - /** \brief - * realisation of Preconditioner::init - */ - inline void init() { - FUNCNAME("DiagonalPreconditioner::init"); - TEST_EXIT(matrix[row])("no matrix\n"); - }; - - /** \brief - * realisation of Preconditioner::precon - */ - void precon(DOFVector<double> *x); - - /** \brief - * realisation of Preconditioner::exit - */ - inline void exit() {}; - }; - - - class DiagonalPreconditionerStd : public PreconditionerScalStd - { - public: - MEMORY_MANAGED(DiagonalPreconditionerStd); - - /** \brief - * Constructor. - */ - DiagonalPreconditionerStd() - {}; - - /** \brief - * Destructor. - */ - virtual ~DiagonalPreconditionerStd() {}; - - /** \brief - * realisation of Preconditioner::init - */ - inline void init() {}; - - /** \brief - * Realisation of Preconditioner::precon - */ - void precon(std::vector<double>* x); - - /** \brief - * realisation of Preconditioner::exit - */ - inline void exit() {}; - }; - -} - -#endif // AMDIS_DIAGONAL_PRECONDITIONER_H diff --git a/AMDiS/src/DirichletBC.cc b/AMDiS/src/DirichletBC.cc index 705a8829..15652327 100644 --- a/AMDiS/src/DirichletBC.cc +++ b/AMDiS/src/DirichletBC.cc @@ -15,7 +15,7 @@ namespace AMDiS { dofVec(NULL) { worldCoords.resize(omp_get_overall_max_threads()); - }; + } DirichletBC::DirichletBC(BoundaryType type, DOFVectorBase<double> *vec) diff --git a/AMDiS/src/DirichletBC.h b/AMDiS/src/DirichletBC.h index 5dfee096..d02d07fb 100644 --- a/AMDiS/src/DirichletBC.h +++ b/AMDiS/src/DirichletBC.h @@ -84,13 +84,9 @@ namespace AMDiS { */ double boundResidual(ElInfo*, DOFMatrix *, - const DOFVectorBase<double>*) { - return 0.0; - }; + const DOFVectorBase<double>*) { return 0.0; }; - bool isDirichlet() { - return true; - }; + bool isDirichlet() { return true; }; inline AbstractFunction<double, WorldVector<double> > *getF() { return f; diff --git a/AMDiS/src/DualTraverse.h b/AMDiS/src/DualTraverse.h index 05d7e78d..91a93e55 100644 --- a/AMDiS/src/DualTraverse.h +++ b/AMDiS/src/DualTraverse.h @@ -42,7 +42,7 @@ namespace AMDiS { basisFcts(NULL) {} - ~DualTraverse() {} + virtual ~DualTraverse() {} /// Start dual traversal bool traverseFirst(Mesh *mesh1, diff --git a/AMDiS/src/Estimator.h b/AMDiS/src/Estimator.h index 883eb5c9..de271ea1 100755 --- a/AMDiS/src/Estimator.h +++ b/AMDiS/src/Estimator.h @@ -26,6 +26,7 @@ #ifndef AMDIS_ESTIMATOR_H #define AMDIS_ESTIMATOR_H +#include "AMDiS_fwd.h" #include "Flag.h" #include "Global.h" #include "FixVec.h" @@ -34,16 +35,6 @@ namespace AMDiS { - class ElInfo; - class Quadrature; - class FastQuadrature; - class BasisFunction; - - class ProblemInstat; - template<typename T> class DOFVector; - class RobinBC; - class DOFMatrix; - // ============================================================================ // ===== class Estimator ====================================================== // ============================================================================ diff --git a/AMDiS/src/GMResSolver.h b/AMDiS/src/GMResSolver.h deleted file mode 100644 index 9a03ed34..00000000 --- a/AMDiS/src/GMResSolver.h +++ /dev/null @@ -1,164 +0,0 @@ -// ============================================================================ -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file GMResSolver.h */ - -#ifndef AMDIS_GMRESSOLVER_H -#define AMDIS_GMRESSOLVER_H - -#include <vector> -#include "OEMSolver.h" -#include "MemoryManager.h" - -namespace AMDiS { - - // ============================================================================ - // ===== class GMResSolver =================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Solves a linear system by the restarted GMRES(m) method (Generalized Minimal - * Residual) for general nonsymmetric system matrices. - * - * The implementation is based on the following book: "Numerik linearer - * Gleichungssystene", 2. Auflage, Andreas Meister. The algorithm is described - * on pages 150 and 154 (for the restarted version). The extension to the - * preconditioned GMRES(m) is based on the description in the book "Iterative - * Methods for Sparse Linear Systems", second edition, Yousef Saad, on page 268. - * - * The orthogonal system is build using the modified Gram Schmidt (MGS) method. - * The least square problem is solved using Givens transformations. - * - */ - template<typename VectorType> - class GMResSolver : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(GMResSolver<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new GMResSolver object. - */ - OEMSolver<VectorType>* create() { - return NEW GMResSolver<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - GMResSolver(std::string name); - - /** \brief - * destructor - */ - ~GMResSolver(); - - protected: - /** \brief - * realisation of OEMSolver::solveSystem - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix); - - /** \brief - * realisation of OEMSolver::init - */ - void init(); - - /** \brief - * realisation of OEMSolver::exit - */ - void exit(); - - /** \brief - * One run of the GMRES(m) method. Is called from solveSystem(). - */ - int gmres(MatVecMultiplier<VectorType> *mv, - VectorType *x, - VectorType *b); - - private: - /** \brief - * Stores the tolerance boundary for numerical computations. - */ - double TOL_; - - /** \brief - * The parameter m of GMRES(m), i.e. the number of iterations before a restart of - * the algorithm is forced. - */ - int restart_; - - /** \brief - * Stores intermediate results in the orthogonalization step. - */ - VectorType *w_; - - - VectorType *z_; - - VectorType *r_; - - /** \brief - * Pointers to the vectors of the orthogonal system. - */ - VectorType **v; - - /** \brief - * Stores the gamma values for Givens transformations. - */ - std::vector<double> gamma; - - /** \brief - * Stores the c values for Givens transformations. - */ - std::vector<double> c; - - /** \brief - * Stores the s values for Givens transformations. - */ - std::vector<double> s; - - std::vector<double> y_; - - /** \brief - * H-Matrix computed in the GMRES algorithm. - */ - std::vector< std::vector<double> > h; - }; - - -} - -#include "GMResSolver.hh" - -#endif // AMDIS_GMRESSOLVER_H diff --git a/AMDiS/src/GMResSolver.hh b/AMDiS/src/GMResSolver.hh deleted file mode 100644 index cf442a3e..00000000 --- a/AMDiS/src/GMResSolver.hh +++ /dev/null @@ -1,189 +0,0 @@ -#include "GMResSolver.h" -#include "Preconditioner.h" - -namespace AMDiS { - - template<typename VectorType> - GMResSolver<VectorType>::GMResSolver(std::string name) - : OEMSolver<VectorType>(name), - TOL_(1.e-25), - restart_(0), - w_(NULL) - { - FUNCNAME("GMResSolver::GMResSolver()"); - GET_PARAMETER(0, name + "->restart", "%d", &restart_); - TEST_EXIT(restart_)("restart not set\n"); - } - - template<typename VectorType> - GMResSolver<VectorType>::~GMResSolver() - {} - - template<typename VectorType> - void GMResSolver<VectorType>::init() - { - // Create a new vector w. - w_ = this->vectorCreator->create(); - z_ = this->vectorCreator->create(); - r_ = this->vectorCreator->create(); - - // Get memory for the vector pointers and create the pointers afterwards. - v = GET_MEMORY(VectorType*, restart_ + 1); - for (int i = 0; i <= restart_; i++) { - v[i] = this->vectorCreator->create(); - } - - // Resize all fields to the corresponding size. - gamma.resize(restart_ + 1); - c.resize(restart_); - s.resize(restart_); - - y_.resize(restart_); - - h.resize(restart_ + 1); - for (int i = 0; i <= restart_; i++) { - h[i].resize(restart_); - } - } - - template<typename VectorType> - void GMResSolver<VectorType>::exit() - { - // Empty used memory. - if (w_) { - this->vectorCreator->free(w_); - this->vectorCreator->free(z_); - this->vectorCreator->free(r_); - - for (int i = 0; i <= restart_; i++) { - this->vectorCreator->free(v[i]); - } - } - } - - - template<typename VectorType> - int GMResSolver<VectorType>::gmres(MatVecMultiplier<VectorType> *matVec, - VectorType *x, - VectorType *b) - { - FUNCNAME("GMResSolver::gmres()"); - - // r_0 = b - Ax, where r_0 is already stored as the first vector in the - // matrix V. - matVec->matVec(NoTranspose, *x, *v[0]); - xpay(-1.0, *b, *v[0]); - - // Left preconditioning, if required. - if (this->leftPrecon) { - this->leftPrecon->precon(v[0]); - } - - // Compute the norm of r_0 = v_0. - gamma[0] = norm(v[0]); - - // Normalize v_0. - *v[0] *= (1 / gamma[0]); - - // If the norm of gamma_0 is less than the tolerance bounday, x is already - // a good solution for Ax = b. - if (gamma[0] < this->tolerance) { - this->residual = gamma[0]; - return(0); - } - - // Main loop of the GMRES algorithm. - for (int j = 0; j < restart_; j++) { - // w_j = A * v_j; - matVec->matVec(NoTranspose, *v[j], *w_); - - // Preconditioning of w_j - if (this->leftPrecon) { - this->leftPrecon->precon(w_); - } - - // w_j = A * v_j - \sum(h_ij * v_i) - for (int i = 0; i <= j; i++) { - // h_ij = (v_i, A * v_j)_2 - h[i][j] = *w_ * (*v[i]); - - // Update w_j - axpy(-h[i][j], *v[i], *w_); - } - - // h_{j + 1}{j} = \| w_j \|_2 - h[j + 1][j] = norm(w_); - - // Compute h_ij and h_{i + 1}{j} using parameters of the Givens rotation. - for (int i = 0; i < j; i++) { - double t1 = c[i] * h[i][j] + s[i] * h[i + 1][j]; - double t2 = -s[i] * h[i][j] + c[i] * h[i + 1][j]; - h[i][j] = t1; - h[i + 1][j] = t2; - } - - // Compute new beta - double beta = sqrt(h[j][j] * h[j][j] + h[j + 1][j] * h[j + 1][j]); - // Update s_j and c_j - s[j] = h[j + 1][j] / beta; - c[j] = h[j][j] / beta; - // h_jj = beta - h[j][j] = beta; - - // Update gammas - gamma[j + 1] = -s[j] * gamma[j]; - gamma[j] *= c[j]; - - // Set v_{j + 1} to w_j and normalize it. - *v[j + 1] = *w_; - *v[j + 1] *= 1 / h[j + 1][j]; - } - - // Compute the solution. - for (int i = restart_ - 1; i >= 0; i--) { - for (int k = i + 1; k < restart_; k++) { - gamma[i] -= h[i][k] * gamma[k]; - } - gamma[i] /= h[i][i]; - axpy(gamma[i], *v[i], *x); - } - - // Update the new residual. - this->residual = abs(gamma[restart_]); - - return restart_; - } - - - template<typename VectorType> - int GMResSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, bool reuseMatrix) - { - FUNCNAME("GMResSolver::solveSystem()"); - - double old_res = -1.0; - - // If norm of b is smaller than the tolarance, we can assume b to be zero. - // Hence, x = 0 is the solution of the linear system. - if (norm(b) < TOL_) { - INFO(this->info, 2)("b == 0, x = 0 is the solution of the linear system\n"); - setValue(*x, 0.0); - this->residual = 0.0; - return(0); - } - - START_INFO(); - for (int iter = 0; iter <= this->max_iter; iter++) { - // Solve Ax=b using GMRES(m). - int k = gmres(matVec, x, b); - // Check the new residual. - if (SOLVE_INFO(iter, this->residual, &old_res)) - return(iter); - TEST_EXIT(k != 0)("this must not happen\n"); - } - - ERROR_EXIT("Should not be reached\n"); - return(0); - } - -} diff --git a/AMDiS/src/GMResSolver2.h b/AMDiS/src/GMResSolver2.h deleted file mode 100644 index 6e820643..00000000 --- a/AMDiS/src/GMResSolver2.h +++ /dev/null @@ -1,163 +0,0 @@ -// ============================================================================ -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file GMResSolver2.h */ - -#ifndef AMDIS_GMRESSOLVER2_H -#define AMDIS_GMRESSOLVER2_H - -#include "OEMSolver.h" -#include "MemoryManager.h" - -namespace AMDiS { - - // ============================================================================ - // ===== class GMResSolver2 =================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Solves a linear system by the restarted GMRES(m) method (Generalized Minimal - * Residual) for general nonsymmetric system matrices. - * - * The implementation is based on the following book: "Numerik linearer - * Gleichungssystene", 2. Auflage, Andreas Meister. The algorithm is described - * on pages 150 and 154 (for the restarted version). The extension to the - * preconditioned GMRES(m) is based on the description in the book "Iterative - * Methods for Sparse Linear Systems", second edition, Yousef Saad, on page 268. - * - * The orthogonal system is build using the modified Gram Schmidt (MGS) method. - * The least square problem is solved using Givens transformations. - * - */ - template<typename VectorType> - class GMResSolver2 : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(GMResSolver2<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new GMResSolver object. - */ - OEMSolver<VectorType>* create() { - return NEW GMResSolver2<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - GMResSolver2(std::string name); - - /** \brief - * destructor - */ - ~GMResSolver2(); - - protected: - /** \brief - * realisation of OEMSolver::solveSystem - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix); - - /** \brief - * realisation of OEMSolver::init - */ - void init(); - - /** \brief - * realisation of OEMSolver::exit - */ - void exit(); - - /** \brief - * One run of the GMRES(m) method. Is called from solveSystem(). - */ - int gmres(MatVecMultiplier<VectorType> *mv, - VectorType *x, - VectorType *b); - - private: - /** \brief - * Stores the tolerance boundary for numerical computations. - */ - double TOL_; - - /** \brief - * The parameter m of GMRES(m), i.e. the number of iterations before a restart of - * the algorithm is forced. - */ - int restart_; - - /** \brief - * Stores intermediate results in the orthogonalization step. - */ - VectorType *w_; - - - VectorType *z_; - - VectorType *r_; - - /** \brief - * Pointers to the vectors of the orthogonal system. - */ - VectorType **v; - - /** \brief - * Stores the gamma values for Givens transformations. - */ - vector<double> gamma; - - /** \brief - * Stores the c values for Givens transformations. - */ - vector<double> c; - - /** \brief - * Stores the s values for Givens transformations. - */ - vector<double> s; - - vector<double> y_; - - /** \brief - * H-Matrix computed in the GMRES algorithm. - */ - vector< vector<double> > h; - }; - - -} - -#include "GMResSolver2.hh" - -#endif // AMDIS_GMRESSOLVER2_H diff --git a/AMDiS/src/GMResSolver2.hh b/AMDiS/src/GMResSolver2.hh deleted file mode 100644 index 63fb90c2..00000000 --- a/AMDiS/src/GMResSolver2.hh +++ /dev/null @@ -1,191 +0,0 @@ -#include "GMResSolver2.h" -#include "Preconditioner.h" - -namespace AMDiS { - - template<typename VectorType> - GMResSolver2<VectorType>::GMResSolver2(std::string name) - : OEMSolver<VectorType>(name), - TOL_(1.e-25), - restart_(0), - w_(NULL) - { - FUNCNAME("GMResSolver2::GMResSolver2()"); - GET_PARAMETER(0, name + "->restart", "%d", &restart_); - TEST_EXIT(restart_)("restart not set\n"); - } - - template<typename VectorType> - GMResSolver2<VectorType>::~GMResSolver2() - {} - - template<typename VectorType> - void GMResSolver2<VectorType>::init() - { - // Create a new vector w. - w_ = this->vectorCreator->create(); - z_ = this->vectorCreator->create(); - r_ = this->vectorCreator->create(); - - // Get memory for the vector pointers and create the pointers afterwards. - v = GET_MEMORY(VectorType*, restart_ + 1); - for (int i = 0; i <= restart_; i++) { - v[i] = this->vectorCreator->create(); - } - - // Resize all fields to the corresponding size. - gamma.resize(restart_ + 1); - c.resize(restart_); - s.resize(restart_); - - y_.resize(restart_); - - h.resize(restart_ + 1); - for (int i = 0; i <= restart_; i++) { - h[i].resize(restart_); - } - } - - template<typename VectorType> - void GMResSolver2<VectorType>::exit() - { - // Empty used memory. - if (w_) { - this->vectorCreator->free(w_); - this->vectorCreator->free(z_); - this->vectorCreator->free(r_); - - for (int i = 0; i <= restart_; i++) { - this->vectorCreator->free(v[i]); - } - } - } - - - template<typename VectorType> - int GMResSolver2<VectorType>::gmres(MatVecMultiplier<VectorType> *matVec, - VectorType *x, - VectorType *b) - { - FUNCNAME("GMResSolver2::gmres()"); - - // r_0 = b - Ax, where r_0 is already stored as the first vector in the - // matrix V. - matVec->matVec(NoTranspose, *x, *v[0]); - xpay(-1.0, *b, *v[0]); - - // Left preconditioning, if required. - if (this->leftPrecon) { - this->leftPrecon->precon(v[0]); - } - - // Compute the norm of r_0 = v_0. - gamma[0] = norm(v[0]); - - // Normalize v_0. - *v[0] *= (1 / gamma[0]); - - // If the norm of gamma_0 is less than the tolerance bounday, x is already - // a good solution for Ax = b. - if (gamma[0] < this->tolerance) { - this->residual = gamma[0]; - return(0); - } - - // Main loop of the GMRES algorithm. - for (int j = 0; j < restart_; j++) { - // w_j = A * v_j; - matVec->matVec(NoTranspose, *v[j], *w_); - - // Preconditioning of w_j - if (this->leftPrecon) { - this->leftPrecon->precon(w_); - } - - // w_j = A * v_j - \sum(h_ij * v_i) - for (int i = 0; i <= j; i++) { - // h_ij = (v_i, A * v_j)_2 - h[i][j] = *w_ * (*v[i]); - - // Update w_j - axpy(-h[i][j], *v[i], *w_); - } - - // h_{j + 1}{j} = \| w_j \|_2 - h[j + 1][j] = norm(w_); - - // Compute h_ij and h_{i + 1}{j} using parameters of the Givens rotation. - for (int i = 0; i < j; i++) { - double t1 = c[i] * h[i][j] + s[i] * h[i + 1][j]; - double t2 = -s[i] * h[i][j] + c[i] * h[i + 1][j]; - h[i][j] = t1; - h[i + 1][j] = t2; - } - - // Compute new beta - double beta = sqrt(h[j][j] * h[j][j] + h[j + 1][j] * h[j + 1][j]); - // Update s_j and c_j - s[j] = h[j + 1][j] / beta; - c[j] = h[j][j] / beta; - // h_jj = beta - h[j][j] = beta; - - // Update gammas - gamma[j + 1] = -s[j] * gamma[j]; - gamma[j] *= c[j]; - - // Set v_{j + 1} to w_j and normalize it. - *v[j + 1] = *w_; - *v[j + 1] *= 1 / h[j + 1][j]; - } - - // Compute the solution. - for (int i = restart_ - 1; i >= 0; i--) { - for (int k = i + 1; k < restart_; k++) { - gamma[i] -= h[i][k] * gamma[k]; - } - gamma[i] /= h[i][i]; - axpy(gamma[i], *v[i], *x); - } - - // Update the new residual. - this->residual = abs(gamma[restart_]); - - return restart_; - } - - - template<typename VectorType> - int GMResSolver2<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, - bool reuseMatrix) - { - FUNCNAME("GMResSolver2::solveSystem()"); - - double old_res = -1.0; - - // If norm of b is smaller than the tolarance, we can assume b to be zero. - // Hence, x = 0 is the solution of the linear system. - if (norm(b) < TOL_) { - INFO(this->info, 2)("b == 0, x = 0 is the solution of the linear system\n"); - setValue(*x, 0.0); - this->residual = 0.0; - return(0); - } - - START_INFO(); - for (int iter = 0; iter <= this->max_iter; iter++) { - // Solve Ax=b using GMRES(m). - int k = gmres(matVec, x, b); - // Check the new residual. - if (SOLVE_INFO(iter, this->residual, &old_res)) - return(iter); - TEST_EXIT(k != 0)("this must not happen\n"); - } - - ERROR_EXIT("Should not be reached\n"); - return(0); - } - -} - diff --git a/AMDiS/src/GSSmoother.cc b/AMDiS/src/GSSmoother.cc index b87d7198..2f26b126 100755 --- a/AMDiS/src/GSSmoother.cc +++ b/AMDiS/src/GSSmoother.cc @@ -16,6 +16,9 @@ namespace AMDiS { int iterations, const std::set<DegreeOfFreedom> &dofSet) { + ERROR_EXIT("Will be rewritten - Peter\n"); + +#if 0 int i, j, rowNumber, colNumber, numCols; double entry, diagEntry = 0.0; @@ -83,6 +86,7 @@ namespace AMDiS { // (*solution)[rowNumber] += (1.0 - omega_) * oldSolution; // } // } +#endif } template<> @@ -95,6 +99,9 @@ namespace AMDiS { int iterations, const Vector< std::set<DegreeOfFreedom>*> &dofSet) { + ERROR_EXIT("Will be rewritten - Peter\n"); + +#if 0 int numComponents = s->getSize(); int i, j, k, l; int rowNumber, colNumber, numCols; @@ -143,6 +150,6 @@ namespace AMDiS { } } } +#endif } - } diff --git a/AMDiS/src/ILUPreconditioner.cc b/AMDiS/src/ILUPreconditioner.cc deleted file mode 100644 index 34c7a12a..00000000 --- a/AMDiS/src/ILUPreconditioner.cc +++ /dev/null @@ -1,314 +0,0 @@ -#include <iostream> -#include <sstream> -#include <vector> - -#include "ILUPreconditioner.h" -#include "DOFVector.h" -#include "DOFMatrix.h" -#include "DOFIterator.h" -#include "MatVecMultiplier.h" -#include "StlVector.h" - -namespace AMDiS { - - void ILUPreconditioner::init() - { - FUNCNAME("ILUPreconditioner::init()"); - - clock_t first = clock(); - - ilu_.resize(matrix.getSize()); - - for (int i = 0; i < matrix.getSize(); i++) { - if ((*matrix[i])) { - ilu_[i] = NEW DOFMatrix((*(*matrix[i]))); - } - } - - - DOFMatrix *ilu = ilu_[row]; - - int matrixSize = ilu->getRowFESpace()->getAdmin()->getUsedSize(); - - // Sort all rows corresponding to their position in the matrix. - diag_.resize(matrixSize); - for (int i = 0; i < matrixSize; i++) { - diag_[i] = (*ilu)[i][0].entry; - sort((*ilu)[i].begin(), (*ilu)[i].end(), CmpMatEntryCol()); - } - - // For i = 1, ..., n - 1, Do - for (int i = 1; i < matrixSize; i++) { - - // For k = 0, ..., i - 1 and for (i,k) \in NZ(ilu), Do - for (int col1 = 0; col1 < static_cast<int>((*ilu)[i].size()); col1++) { - // k is the logical index of the col1-th column in the i-th row. - int k = (*ilu)[i][col1].col; - if ((k < i) && // due to the condition that k goes up to i - 1 - (k >= 0) && // the entry is valid - ((*ilu)[i][col1].entry != 0.0)) { // the entry is non-zero, hence in NZ(ilu) - // Compute a_ik = a_ik / a_kk - (*ilu)[i][col1].entry = (*ilu)[i][col1].entry / diag_[k]; - - // For j = k + 1, ..., n - 1 and for (i,j) \in NZ(ilu), Do - for (int col2 = col1 + 1; col2 < static_cast<int>((*ilu)[i].size()); col2++) { - // j is the logical index of the col2-th column in the i-th row. - int j = (*ilu)[i][col2].col; - - // Because the rows are sorted, we start at position col1 + 1, and all non-valid - // entries have col < 0, we do not need to check for non-valid entries. - if ((*ilu)[i][col2].entry != 0.0) { - int physKJ = (*ilu).logToPhysIndex(k, j); - // If physKJ is negativ, the corresponding entry is zero and we do not need - // to compute the new element. - if (physKJ >= 0) { - // Compute a_ij = a_ij - a_ik * a_kj - (*ilu)[i][col2].entry = (*ilu)[i][col2].entry - ((*ilu)[i][col1].entry * (*ilu)[k][physKJ].entry); - // Do not forgett to update the diagonal entries, if we have computed on - // a diagonal element. - if (i == j) { - diag_[i] = (*ilu)[i][col2].entry; - } - } - } - } - } - } - } - - MSG("preconditioning of the coefficient matrix needed %.5f seconds\n", - TIME_USED(first,clock())); - } - - void ILUPreconditioner::exit() - { - for (int i = 0; i < ilu_.getSize(); i++) { - if ((*matrix[i])) { - DELETE ilu_[i]; - } - } - } - - void ILUPreconditioner::precon(DOFVector<double>* x) - { - DOFMatrix *ilu = ilu_[row]; - - // The solution of P * x = b must be calculated in the - // following. Note that the vector b is stored in x to - // saving space. - // We solve the equation with forward and backward substitution - // of the factorization P = L * U. - - DOFVector<double>::Iterator itx(x, USED_DOFS); - - // Forward substitution: L * y = b - // We use x to save the new results of y. Note that all diagonal - // elements of L are 1, hence we do not need to devide the term - // by the diagonal elements. - int i = 0; - for (itx.reset(); !itx.end(); ++itx, ++i) { - // y_i = b_i - // Must not be assigned directly, since x = b and y will take - // the results of y. - - std::vector<MatEntry> *m = &(*ilu)[i]; - - // y_i = b_i - \sum_{1}^{i-1} ( l_{i,k} * y_k ) - for (int col = 0; col < static_cast<int>((*m).size()); col++) { - int k = (*m)[col].col; - if (k >= 0) { - if (k < i) { - (*itx) -= (*m)[col].entry * (*x)[k]; - } else { - // If for an entry k < i does not hold, it will be also false - // for all other elements in th column, because the columns - // are sorted. - break; - } - } - } - } - - - // Backward substitution: R * x = y - do { - itx--; - i--; - - std::vector<MatEntry> *m = &(*ilu)[i]; - - // x_i = y_i - \sum_{i + 1}^(n} ( r_{i,k} * x_k ) - // The sum is build backwards, since the directon of calculation does not - // matter for the result, but we can break the search if k > i does not - // hold (the cols of ilu_ are sorted!) and so make the calculation faster. - for (int col = static_cast<int>((*m).size()) - 1; col >= 0; col--) { - int k = (*m)[col].col; - if (k > i) { - (*itx) -= (*m)[col].entry * (*x)[k]; - } else { - break; - } - } - - // x_i = x_i / r_{i,i} - (*itx) /= diag_[i]; - - } while (!itx.begin()); - } - - - - - - - - - - ///////////////////////////// - - void ILUPreconditionerStd::init() - { - FUNCNAME("ILUPreconditionerStd::init()"); - - clock_t first = clock(); - - ilu_ = *matrix; - - int matrixSize = ilu_.size(); - -// ilu_.resize(matrixSize); - -// for (int i = 0; i < matrixSize; i++) { -// ilu_[i] = (*matrix -// } - - std::vector< std::vector<MatEntry> > *ilu = &ilu_; - - - - // Sort all rows corresponding to their position in the matrix. - diag_.resize(matrixSize); - for (int i = 0; i < matrixSize; i++) { - diag_[i] = (*ilu)[i][0].entry; - sort((*ilu)[i].begin(), (*ilu)[i].end(), CmpMatEntryCol()); - } - - // For i = 1, ..., n - 1, Do - for (int i = 1; i < matrixSize; i++) { - - // For k = 0, ..., i - 1 and for (i,k) \in NZ(ilu), Do - for (int col1 = 0; col1 < static_cast<int>((*ilu)[i].size()); col1++) { - // k is the logical index of the col1-th column in the i-th row. - int k = (*ilu)[i][col1].col; - if ((k < i) && // due to the condition that k goes up to i - 1 - (k >= 0) && // the entry is valid - ((*ilu)[i][col1].entry != 0.0)) { // the entry is non-zero, hence in NZ(ilu) - // Compute a_ik = a_ik / a_kk - (*ilu)[i][col1].entry = (*ilu)[i][col1].entry / diag_[k]; - - // For j = k + 1, ..., n - 1 and for (i,j) \in NZ(ilu), Do - for (int col2 = col1 + 1; col2 < static_cast<int>((*ilu)[i].size()); col2++) { - // j is the logical index of the col2-th column in the i-th row. - int j = (*ilu)[i][col2].col; - - // Because the rows are sorted, we start at position col1 + 1, and all non-valid - // entries have col < 0, we do not need to check for non-valid entries. - if ((*ilu)[i][col2].entry != 0.0) { - // int physKJ = (*ilu).logToPhysIndex(k, j); - int physKJ = logToPhysIndex(ilu, k, j); - - // If physKJ is negativ, the corresponding entry is zero and we do not need - // to compute the new element. - if (physKJ >= 0) { - // Compute a_ij = a_ij - a_ik * a_kj - (*ilu)[i][col2].entry = (*ilu)[i][col2].entry - ((*ilu)[i][col1].entry * (*ilu)[k][physKJ].entry); - // Do not forgett to update the diagonal entries, if we have computed on - // a diagonal element. - if (i == j) { - diag_[i] = (*ilu)[i][col2].entry; - } - } - } - } - } - } - } - - MSG("preconditioning of the coefficient matrix needed %.5f seconds\n", - TIME_USED(first,clock())); - } - - void ILUPreconditionerStd::exit() - { - } - - void ILUPreconditionerStd::precon(std::vector<double> *x) - { - std::vector< std::vector<MatEntry> > *ilu = &ilu_; - - // The solution of P * x = b must be calculated in the - // following. Note that the vector b is stored in x to - // saving space. - // We solve the equation with forward and backward substitution - // of the factorization P = L * U. - - // DOFVector<double>::Iterator itx(x, USED_DOFS); - - std::vector<double>::iterator itx; - - // Forward substitution: L * y = b - // We use x to save the new results of y. Note that all diagonal - // elements of L are 1, hence we do not need to devide the term - // by the diagonal elements. - int i = 0; - for (itx = x->begin(); itx != x->end(); ++itx, ++i) { - // y_i = b_i - // Must not be assigned directly, since x = b and y will take - // the results of y. - - std::vector<MatEntry> *m = &(*ilu)[i]; - - // y_i = b_i - \sum_{1}^{i-1} ( l_{i,k} * y_k ) - for (int col = 0; col < static_cast<int>((*m).size()); col++) { - int k = (*m)[col].col; - if (k >= 0) { - if (k < i) { - (*itx) -= (*m)[col].entry * (*x)[k]; - } else { - // If for an entry k < i does not hold, it will be also false - // for all other elements in th column, because the columns - // are sorted. - break; - } - } - } - } - - - // Backward substitution: R * x = y - do { - itx--; - i--; - - std::vector<MatEntry> *m = &(*ilu)[i]; - - // x_i = y_i - \sum_{i + 1}^(n} ( r_{i,k} * x_k ) - // The sum is build backwards, since the directon of calculation does not - // matter for the result, but we can break the search if k > i does not - // hold (the cols of ilu_ are sorted!) and so make the calculation faster. - for (int col = static_cast<int>((*m).size()) - 1; col >= 0; col--) { - int k = (*m)[col].col; - if (k > i) { - (*itx) -= (*m)[col].entry * (*x)[k]; - } else { - break; - } - } - - // x_i = x_i / r_{i,i} - (*itx) /= diag_[i]; - - } while (itx != x->begin()); - } - -} diff --git a/AMDiS/src/ILUPreconditioner.h b/AMDiS/src/ILUPreconditioner.h deleted file mode 100644 index 104001aa..00000000 --- a/AMDiS/src/ILUPreconditioner.h +++ /dev/null @@ -1,181 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file ILUPreconditioner.h */ - -#ifndef AMDIS_ILU_PRECONDITIONER_H -#define AMDIS_ILU_PRECONDITIONER_H - -#include <vector> -#include "Preconditioner.h" -#include "MemoryManager.h" -#include "CreatorInterface.h" -#include "DOFMatrix.h" - -namespace AMDiS { - - template<typename T> class DOFVector; - template<typename T> class OEMSolver; - - // ============================================================================ - // ===== class ILUPreconditioner ============================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * ILU (Incomplete LU factorization) preconditioner. - * - * The preconditioner is implemented following the book "Iterative Methods for - * Sparce Linear Systems", second edition, Yousef Saad. The preconditioner is - * described in chapter 10.3 (algorithm 10.4). - */ - class ILUPreconditioner : public PreconditionerScal - { - public: - MEMORY_MANAGED(ILUPreconditioner); - - /** \brief - * Creater class used in PreconditionerMap. - */ - class Creator : public PreconditionerScalCreator - { - public: - MEMORY_MANAGED(Creator); - - /** \brief - * Creates an ILUPreconditioner. - */ - PreconditionerScal *create() { - return NEW ILUPreconditioner(size, row); - }; - }; - - /** \brief - * Constructor. - */ - ILUPreconditioner(int size = 1, int row = 0) - : PreconditionerScal(size, row) - {}; - - /** \brief - * Destructor. - */ - virtual ~ILUPreconditioner() {}; - - /** \brief - * Realisation of Preconditioner::init - * - * In the initalization phase the incomplete LU factorization - * of the coefficent matrix is calculated. - */ - void init(); - - /** \brief - * Realisation of Preconditioner::exit - */ - void exit(); - - /** \brief - * Realisation of Preconditioner::precon - */ - void precon(DOFVector<double>* x); - - private: - /** \brief - * This matrix stores the incomplete LU factorization - * of the coefficient matrix. - */ - // DOFMatrix *ilu_; - Vector<DOFMatrix*> ilu_; - - /** \brief - * Here we store the diagonal elements of ilu_ matrix. This - * allows faster computations. - */ - std::vector<double> diag_; - }; - - - - - - - - - - - - - - - - - class ILUPreconditionerStd : public PreconditionerScalStd - { - public: - MEMORY_MANAGED(ILUPreconditionerStd); - - - /** \brief - * Constructor. - */ - ILUPreconditionerStd() {}; - - /** \brief - * Destructor. - */ - virtual ~ILUPreconditionerStd() {}; - - /** \brief - * Realisation of Preconditioner::init - * - * In the initalization phase the incomplete LU factorization - * of the coefficent matrix is calculated. - */ - void init(); - - /** \brief - * Realisation of Preconditioner::exit - */ - void exit(); - - /** \brief - * Realisation of Preconditioner::precon - */ - void precon(std::vector<double>* x); - - private: - /** \brief - * This matrix stores the incomplete LU factorization - * of the coefficient matrix. - */ - std::vector< std::vector<MatEntry> > ilu_; - - /** \brief - * Here we store the diagonal elements of ilu_ matrix. This - * allows faster computations. - */ - std::vector<double> diag_; - }; - -} - -#endif // AMDIS_ILU_PRECONDITIONER_H diff --git a/AMDiS/src/ILUTPreconditioner.cc b/AMDiS/src/ILUTPreconditioner.cc deleted file mode 100644 index 04f966b1..00000000 --- a/AMDiS/src/ILUTPreconditioner.cc +++ /dev/null @@ -1,247 +0,0 @@ -#include <vector> -#include "ILUTPreconditioner.h" -#include "DOFVector.h" -#include "DOFMatrix.h" -#include "DOFIterator.h" -#include "MatVecMultiplier.h" - -namespace AMDiS { - - void ILUTPreconditioner::init() - { - FUNCNAME("ILUTPreconditioner::init()"); - - TEST_EXIT(matrix[row])("no matrix\n"); - - clock_t first = clock(); - - // Make a copy of the system matrix. - ilu_ = (*(*matrix[row])); - - int matrixSize = ilu_.getRowFESpace()->getAdmin()->getUsedSize(); - - diag_.resize(matrixSize); - - // For i = 1, ..., n, Do - for (int i = 0; i < matrixSize; i++) { - // We do not make a real copy of the row, but instead w is a pointer to - // the current row. - std::vector<MatEntry> *w = &(ilu_[i]); - - - // Calculate tau_i by calculating the 2-norm of the current row and - // multiplying the result with the parameter tau. - double taui = 0.0; - for (int col1 = 0; col1 < static_cast<int>((*w).size()); col1++) { - taui += (*w)[col1].entry * (*w)[col1].entry; - } - taui = sqrt(taui) * tau_; - - - // For k = 1, ..., i - 1 and when w_k not= 0, Do - for (int col1 = 0; col1 < static_cast<int>((*w).size()); col1++) { - // Pointer to the w_ik element - MatEntry *w_k = &((*w)[col1]); - - // Get the logical index k of the current element of row w. - int k = (*w_k).col; - - if ((k < i) && // must be smaller than i due to the loop condition - (k >= 0) && // must be a valid entry - ((*w_k).entry != 0.0)) { // must be non zero due to the loop condition - - // w_k := w_k / a_kk (note that the diagonal elements are always stored in the first entry of a row) - (*w_k).entry /= (*(*matrix[row]))[k][0].entry; - - // Dropping rule to w_k - // It is checked if the absolute value of w_k is smaller than tau_i - if (fabs((*w_k).entry) < taui) { - // Do not delete the element yet but set it to zero, so it will be deleted - // when the second dropping rule will be applied. - (*w_k).entry = 0.0; - } else { - // w := w - w_k * u_k* - // To compute the result, all elements of u_k are multiplied with w_k. Then - // we check if there is an element in w with the same column index. If yes, - // the result of the multiplication is substracted from the corresponding - // element in w. Otherwise, a new element in w with the negative value of - // the multiplication is created. - for (int col2 = 0; col2 < static_cast<int>(ilu_[k].size()); col2++) { - - // Pointer to the current element of row u_k* - MatEntry *u_kj = &ilu_[k][col2]; - - // We are in the k-th row of matrix ilu_. The row is devided into L and - // U factorization. Hence, all elements of U in ilu_ must have a column - // index that is greater than k. - if (((*u_kj).col > k) && // must be a U element - ((*u_kj).entry != 0.0)) { // must be non zero - - // w_k * u_kj - double v = (*w_k).entry * (*u_kj).entry; - - // search for the physical index of the j-th column in row w. - int index = -1; - for (int z = 0; z < static_cast<int>((*w).size()); z++) { - if ((*w)[z].col == (*u_kj).col) { - index = z; - break; - } - } - - if (index >= 0) { - // If there is a j-th column in row w, make the substraction. - (*w)[index].entry -= v; - } else { - // Otherwise, if the absolut value of the result of the multiplication - // is greater than the relative tolerance, create a new element in w. - if (fabs(v) > taui) { - MatEntry newEntry = {(*u_kj).col, -v}; - (*w).push_back(newEntry); - } - } - } - - } - } - } - } - - // Apply second dropping rule. - // First, remove all elements which absolut value is smaller than tau_i. - (*w).erase(remove_if((*w).begin(), (*w).end(), MatEntryValueLess(taui)), - (*w).end()); - - // Calculate the number of elements in the L-part of the current row. - int nL = 0; - for (int k = 1; k < static_cast<int>((*w).size()); k++) { - if ((*w)[k].col < i) { - nL++; - } - } - // Calculate the number of elements in the U-part of the current row. - int nU = (*w).size() - nL - 1; - - // Now we check, if there are more elements in L- and U-parts of the row - // than we should store. If it is so, the final number of elements is - // reduced to p. - if (nL > p_) { - nL = p_; - } - if (nU > p_) { - nU = p_; - } - - // First, we sort the row in such a way that the first element will stay to be - // the diagonal element, then all the elements of the L-part follows and after - // them all the elements of the U-part. Because we are in the i-th row, elements - // of L must have a column index smaller than i. - // itMiddle is then an iterator to the first element of the U-part. - std::vector<MatEntry>::iterator itMiddle = - partition((*w).begin() + 1, (*w).end(), MatEntryColLess(i)); - - // If there are elements in the L-part: - if (nL > 0) { - // Search for the nL largest elements in the L-part of the row. - nth_element((*w).begin() + 1, - (*w).begin() + 1 + nL, - itMiddle - 1, - CmpMatEntryAbsValueGreater()); - - // Delete all the elements that do not belong to the nL largest elements - // in the L-part. - itMiddle = (*w).erase((*w).begin() + nL + 1, itMiddle); - } - - // If there are elements in the U-part: - if (nU > 0) { - // Search for the nU largest elements in the U-part of the row. - nth_element(itMiddle, - itMiddle + nU, - (*w).end(), - CmpMatEntryAbsValueGreater()); - - // Delete all the elements that do not belong to the nU largest elements - // in the L-part. - (*w).erase(itMiddle + nU, (*w).end()); - } - - // Store the diagonal element and sort the line. - diag_[i] = (*w)[0].entry; - sort((*w).begin(), (*w).end(), CmpMatEntryCol()); - } - - - MSG("preconditioning of the coefficient matrix needed %.5f seconds\n", - TIME_USED(first,clock())); - } - - - void ILUTPreconditioner::exit() - { - ilu_.clear(); - } - - void ILUTPreconditioner::precon(DOFVector<double>* x) - { - // The solution of P * x = b must be calculated in the - // following. Note that the vector b is stored in x to - // saving space. - // We solve the equation with forward and backward substitution - // of the factorization P = L * U. - - DOFVector<double>::Iterator itx(x, USED_DOFS); - - // Forward substitution: L * y = b - // We use x to save the new results of y. Note that all diagonal - // elements of L are 1, hence we do not need to devide the term - // by the diagonal elements. - int i = 0; - for (itx.reset(); !itx.end(); ++itx, ++i) - { - // y_i = b_i - // Must not be assigned directly, since x = b and y will take - // the results of y. - - // y_i = b_i - \sum_{1}^{i-1} ( l_{i,k} * y_k ) - for (int col = 0; col < static_cast<int>(ilu_[i].size()); col++) { - int k = ilu_[i][col].col; - if (k >= 0) { - if (k < i) { - (*itx) -= ilu_[i][col].entry * (*x)[k]; - } else { - // If for an entry k < i does not hold, it will be also false - // for all other elements in th column, because the columns - // are sorted. - break; - } - } - } - } - - - // Backward substitution: R * x = y - do { - itx--; - i--; - - // x_i = y_i - \sum_{i + 1}^(n} ( r_{i,k} * x_k ) - // The sum is build backwards, since the directon of calculation does not - // matter for the result, but we can break the search if k > i does not - // hold (the cols of ilu_ are sorted!) and so make the calculation faster. - for (int col = static_cast<int>(ilu_[i].size()) - 1; col >= 0; col--) { - int k = ilu_[i][col].col; - if (k > i) { - (*itx) -= ilu_[i][col].entry * (*x)[k]; - } else { - break; - } - } - - // x_i = x_i / r_{i,i} - (*itx) /= diag_[i]; - - } while (!itx.begin()); - } - -} diff --git a/AMDiS/src/ILUTPreconditioner.h b/AMDiS/src/ILUTPreconditioner.h deleted file mode 100644 index 32916824..00000000 --- a/AMDiS/src/ILUTPreconditioner.h +++ /dev/null @@ -1,137 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file ILUTPreconditioner.h */ - -#ifndef AMDIS_ILUT_PRECONDITIONER_H -#define AMDIS_ILUT_PRECONDITIONER_H - -#include <vector> -#include "Preconditioner.h" -#include "MemoryManager.h" -#include "CreatorInterface.h" -#include "DOFMatrix.h" -#include "Parameters.h" - -namespace AMDiS { - - template<typename T> class DOFVector; - template<typename T> class OEMSolver; - - // ============================================================================ - // ===== class ILUTPreconditioner ============================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * ILUT (Incomplete LU factorization with Threshold) preconditioner. - * - * The preconditioner is implemented following the book "Iterative Methods for - * Sparce Linear Systems", second edition, Yousef Saad. The preconditioner is - * described in chapter 10.4 (algorithm 10.6). - * We have changed the dropping rules of the original algorithm to that the - * absolut values of w_k are checked. - */ - class ILUTPreconditioner : public PreconditionerScal - { - public: - MEMORY_MANAGED(ILUTPreconditioner); - - /** \brief - * Creater class used in PreconditionerMap. - */ - class Creator : public PreconditionerScalCreator - { - public: - MEMORY_MANAGED(Creator); - - /** \brief - * Creates an ILUPreconditioner. - */ - PreconditionerScal *create() { - return NEW ILUTPreconditioner(this->name_, size, row); - }; - }; - - /** \brief - * Constructor. - */ - ILUTPreconditioner(std::string name, int size = 1, int row = 0) - : PreconditionerScal(size, row), - name_(name), - tau_(0.0001), - p_(8) - { - GET_PARAMETER(0, name + "->tau", "%f", &tau_); - GET_PARAMETER(0, name + "->p", "%d", &p_); - }; - - /** \brief - * Destructor. - */ - virtual ~ILUTPreconditioner() {}; - - /** \brief - * Realisation of Preconditioner::init - * - */ - void init(); - - /** \brief - * Realisation of Preconditioner::exit - */ - void exit(); - - /** \brief - * Realisation of Preconditioner::precon - */ - void precon(DOFVector<double>* x); - - private: - std::string name_; - - /** \brief - * This matrix stores the incomplete LU factorization - * of the coefficient matrix. - */ - DOFMatrix ilu_; - - /** \brief - * Here we store the diagonal elements of ilu_ matrix. This - * allows faster computations. - */ - std::vector<double> diag_; - - /** \brief - * Stores the threshold factor for the preconditioning process. - */ - double tau_; - - /** \brief - * Stores the number of entries that are finally stored in each row - * of L and U. Hence, the total number of elements in each row of ilu_ - * is 2p + 1 (the diagonal element is always stored). - */ - int p_; - }; -} - -#endif // AMDIS_ILUT_PRECONDITIONER_H diff --git a/AMDiS/src/ITL_OEMSolver.h b/AMDiS/src/ITL_OEMSolver.h new file mode 100644 index 00000000..3dc952eb --- /dev/null +++ b/AMDiS/src/ITL_OEMSolver.h @@ -0,0 +1,141 @@ +// ============================================================================ +// == == +// == AMDiS - Adaptive multidimensional simulations == +// == == +// ============================================================================ +// == == +// == crystal growth group == +// == == +// == Stiftung caesar == +// == Ludwig-Erhard-Allee 2 == +// == 53175 Bonn == +// == germany == +// == == +// ============================================================================ +// == == +// == http://www.caesar.de/cg/AMDiS == +// == == +// ============================================================================ + +/** \file ITL_OEMSolver.h */ + + +#ifndef AMDIS_ITL_OEM_SOLVER_H +#define AMDIS_ITL_OEM_SOLVER_H + +#include "OEMSolver.h" +#include "ITL_Preconditioner.h" +#include "SolverMatrix.h" +#include "DOFVector.h" +#include "SystemVector.h" +#include "DOFMatrix.h" +#include "Parameters.h" + +#include <boost/numeric/itl/itl.hpp> +#include <boost/numeric/mtl/mtl.hpp> + +namespace AMDiS { + + + /** + * \ingroup Solver + * + *\brief + * Template for using solvers from ITL in AMDiS. + */ + template <typename ITLSolver> + class ITL_OEMSolver : public OEMSolver + { + typedef ITL_Preconditioner<itl::pc::identity<DOFMatrix> > id_t; + + public: + /// The constructor reads needed parameters and sets solvers \ref name. + ITL_OEMSolver(::std::string name) : OEMSolver(name) {} + + ~ITL_OEMSolver() {} + + + /// Solves the system iteratively + // This function is virtual because derived class calls solver with parameter + virtual int solveSystem(const DOFMatrix::base_matrix_type& A, + mtl::dense_vector<value_type>& x, + const mtl::dense_vector<value_type>& b) + { + itl::cyclic_iteration<value_type> iter(b, this->max_iter, this->relative, + this->tolerance, this->print_cycle); + return ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter); + } + + + /// Creator class used in the OEMSolverMap. + class Creator : public OEMSolverCreator + { + public: + MEMORY_MANAGED(Creator); + + virtual ~Creator() {} + + /// Returns a new CGSolver object. + OEMSolver* create() { + return NEW ITL_OEMSolver<ITLSolver>(this->name); + } + }; + + }; + + + /** + * \ingroup Solver + * + *\brief + * Template for using solvers from ITL that have one run-time parameter in AMDiS. + */ + template <typename ITLSolver> + class ITL_OEMSolver_para + : public OEMSolver // ITL_OEMSolver<ITLSolver> + { + typedef DOFMatrix::value_type value_type; + public: + /// The constructor reads needed parameters and sets solvers \ref name. + ITL_OEMSolver_para(::std::string name) + : OEMSolver(name), para(1) + { + GET_PARAMETER(0, name + "->para", "%d", ¶); + } + + ~ITL_OEMSolver_para() {} + + /// Set parameter of iterative solver + void setPara(int p) { para= p; } + + /// Solves the system iteratively + int solveSystem(const DOFMatrix::base_matrix_type& A, + mtl::dense_vector<value_type>& x, + const mtl::dense_vector<value_type>& b) + { + itl::cyclic_iteration<value_type> iter(b, this->max_iter, this->relative, + this->tolerance, this->print_cycle); + return ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter, para); + } + + class Creator : public OEMSolverCreator + { + public: + MEMORY_MANAGED(Creator); + + virtual ~Creator() {} + + /// Returns a new CGSolver object. + OEMSolver* create() { + return NEW ITL_OEMSolver_para<ITLSolver>(this->name); + } + }; + + private: + int para; + }; + + +} // namespace AMDiS + +#endif // AMDIS_ITL_OEM_SOLVER_H diff --git a/AMDiS/src/ITL_Preconditioner.h b/AMDiS/src/ITL_Preconditioner.h new file mode 100644 index 00000000..0352c0e2 --- /dev/null +++ b/AMDiS/src/ITL_Preconditioner.h @@ -0,0 +1,177 @@ +// ============================================================================ +// == == +// == AMDiS - Adaptive multidimensional simulations == +// == == +// ============================================================================ +// == == +// == crystal growth group == +// == == +// == Stiftung caesar == +// == Ludwig-Erhard-Allee 2 == +// == 53175 Bonn == +// == germany == +// == == +// ============================================================================ +// == == +// == http://www.caesar.de/cg/AMDiS == +// == == +// ============================================================================ + +/** \file ITL_Preconditioner.h */ + +#ifndef AMDIS_ITL_PRECONDITIONER_H +#define AMDIS_ITL_PRECONDITIONER_H + +#include "DOFMatrix.h" +#include "CreatorInterface.h" + +#include <boost/numeric/itl/itl.hpp> +#include <boost/numeric/itl/pc/ilu_0.hpp> +#include <boost/numeric/itl/pc/ic_0.hpp> + +namespace AMDiS { + + // ============================================================================ + // ===== class ITL_Preconditioner ============================================== + // ============================================================================ + + + /** + * \ingroup Solver + * + * \brief Common base class for wrappers to use ITL preconditioners in AMDiS. + */ + class ITL_BasePreconditioner + { + public: + typedef DOFMatrix::value_type value_type; + + virtual ~ITL_BasePreconditioner() {} + + virtual mtl::dense_vector<value_type> + member_solve(const mtl::dense_vector<value_type>& vin) const = 0; + + virtual mtl::dense_vector<value_type> + member_adjoint_solve(const mtl::dense_vector<value_type>& vin) const = 0; + }; + + inline mtl::dense_vector<DOFMatrix::value_type> + solve(const ITL_BasePreconditioner& P, const mtl::dense_vector<DOFMatrix::value_type>& vin) + { + return P.member_solve(vin); + } + + inline mtl::dense_vector<DOFMatrix::value_type> + adjoint_solve(const ITL_BasePreconditioner& P, const mtl::dense_vector<DOFMatrix::value_type>& vin) + { + return P.member_adjoint_solve(vin); + } + + /** + * \ingroup Solver + * + * \brief Wrapper for using ITL preconditioners in AMDiS. + */ + template <typename Preconditioner> + class ITL_Preconditioner : public ITL_BasePreconditioner + { + typedef DOFMatrix::value_type value_type; + public: + ITL_Preconditioner(const DOFMatrix::base_matrix_type& A) : precon(A) {} + + mtl::dense_vector<value_type> + member_solve(const mtl::dense_vector<value_type>& vin) const + { + return solve(precon, vin); + } + + mtl::dense_vector<value_type> + member_adjoint_solve(const mtl::dense_vector<value_type>& vin) const + { + return adjoint_solve(precon, vin); + } + + /// Creator class used in the OEMSolverMap. + class Creator : public CreatorInterface<ITL_BasePreconditioner> + { + public: + MEMORY_MANAGED(Creator); + + virtual ~Creator() {}; + + /** \brief + * Creates an ITL preconditioner + */ + ITL_BasePreconditioner *create(const DOFMatrix::base_matrix_type& A) { + return NEW ITL_Preconditioner<Preconditioner>(A); + } + + ITL_BasePreconditioner *create() { + ERROR_EXIT("Must not be called! Only defined to avoid abstract function."); return 0; + } + }; + + private: + Preconditioner precon; + }; + + + // ============================================================================ + // ===== class DiagonalPreconditioner ========================================= + // ============================================================================ + + /** + * \ingroup Solver + * + * \brief + * Diagonal preconditioner. + */ + class DiagonalPreconditioner + : public ITL_Preconditioner<itl::pc::diagonal<DOFMatrix::base_matrix_type> > + { + typedef ITL_Preconditioner<itl::pc::diagonal<DOFMatrix::base_matrix_type> > base; + + DiagonalPreconditioner(const DOFMatrix::base_matrix_type& A) : base(A) {} + }; + + /** + * \ingroup Solver + * + * \brief + * Identity preconditioner. Behaves like no preconditioning. + */ + class IdentityPreconditioner + : public ITL_Preconditioner<itl::pc::identity<DOFMatrix::base_matrix_type> > + { + typedef ITL_Preconditioner<itl::pc::identity<DOFMatrix::base_matrix_type> > base; + + IdentityPreconditioner(const DOFMatrix::base_matrix_type& A) : base(A) {} + }; + + + // ============================================================================ + // ===== class ILUPreconditioner ============================================== + // ============================================================================ + + /** + * \ingroup Solver + * + * \brief + * ILU (Incomplete LU factorization) preconditioner. + * + * The preconditioner is used from ITL. It corresponds for instance to "Iterative Methods for + * Sparce Linear Systems", second edition, Yousef Saad. The preconditioner is + * described in chapter 10.3 (algorithm 10.4). + */ + class ILUPreconditioner + : public ITL_Preconditioner< itl::pc::ilu_0<DOFMatrix::base_matrix_type> > + {}; + + class ICPreconditioner + : public ITL_Preconditioner< itl::pc::ic_0<DOFMatrix::base_matrix_type> > + {}; + + +} // namespace AMDiS + +#endif // AMDIS_ITL_PRECONDITIONER_H diff --git a/AMDiS/src/ITL_Solver.h b/AMDiS/src/ITL_Solver.h new file mode 100644 index 00000000..3043d36b --- /dev/null +++ b/AMDiS/src/ITL_Solver.h @@ -0,0 +1,180 @@ +// ============================================================================ +// == == +// == AMDiS - Adaptive multidimensional simulations == +// == == +// ============================================================================ +// == == +// == crystal growth group == +// == == +// == Stiftung caesar == +// == Ludwig-Erhard-Allee 2 == +// == 53175 Bonn == +// == germany == +// == == +// ============================================================================ +// == == +// == http://www.caesar.de/cg/AMDiS == +// == == +// ============================================================================ + +/** \file ITL_Preconditioner.h */ + +#ifndef AMDIS_ITL_SOLVER_H +#define AMDIS_ITL_SOLVER_H + +#include "ITL_OEMSolver.h" +#include <boost/numeric/itl/krylov/cg.hpp> +#include <boost/numeric/itl/krylov/bicg.hpp> +#include <boost/numeric/itl/krylov/bicgstab.hpp> +#include <boost/numeric/itl/krylov/bicgstab_2.hpp> +#include <boost/numeric/itl/krylov/bicgstab_ell.hpp> + +namespace AMDiS { + + // ============================================================================ + // ===== class CGSolver ======================================================= + // ============================================================================ + + /// Helper class to establish a type from a function + class cg_solver_type + { + public: + template < class LO, class X, class B, class L, class R, class I > + int operator()(const LO& A, X& x, const B& b, const L& l, const R& r, I& iter) + { return itl::cg(A, x, b, l, r, iter); } + }; + + + /** + * \ingroup Solver + * + * \brief + * Solves a linear system by the conjugate gradient method and can be used for + * symmetric positive definite system matrices. + */ + class CGSolver : public ITL_OEMSolver<cg_solver_type> + { + public: + /// The constructor reads required parameters and sets solvers \ref name. + CGSolver(std::string name) : ITL_OEMSolver<cg_solver_type>(name) {} + }; + + + // ============================================================================ + // ===== class BiCGSolver ===================================================== + // ============================================================================ + + /// Helper class to establish a type from a function + class bicg_solver_type + { + public: + template < class LO, class X, class B, class L, class R, class I > + int operator()(const LO& A, X& x, const B& b, const L& l, const R&, I& iter) + { return itl::bicg(A, x, b, l, iter); } + }; + + /** + * \ingroup Solver + * + * \brief + * Solves a linear system by a stabilized BiCG method and can be used for + * system matrices. + */ + class BiCGSolver : public ITL_OEMSolver<bicg_solver_type> + { + public: + /// The constructor reads required parameters and sets solvers \ref name. + BiCGSolver(::std::string name) : ITL_OEMSolver<bicg_solver_type>(name) {} + }; + + + // ============================================================================ + // ===== class BiCGStab ======================================================= + // ============================================================================ + + /// Helper class to establish a type from a function + class bicgstab_type + { + public: + template < class LinOp, class X, class B, class L, class R, class I > + int operator()(const LinOp& A, X& x, const B& b, const L& l, const R&, I& iter) + { return itl::bicgstab(A, x, b, l, iter); } + }; + + + /** + * \ingroup Solver + * + * \brief + * Solves a linear system by a stabilized BiCG method and can be used for + * system matrices. + */ + class BiCGStab : public ITL_OEMSolver<bicgstab_type> + { + public: + /// The constructor reads required parameters and sets solvers \ref name. + BiCGStab(::std::string name) : ITL_OEMSolver<bicgstab_type>(name) {} + }; + + + // ============================================================================ + // ===== class BiCGStab2 ====================================================== + // ============================================================================ + + /// Helper class to establish a type from a function + class bicgstab2_type + { + public: + template < class LinOp, class X, class B, class L, class R, class I > + int operator()(const LinOp& A, X& x, const B& b, const L& l, const R&, I& iter) + { return itl::bicgstab_2(A, x, b, l, iter); } + }; + + + /** + * \ingroup Solver + * + * \brief + * Solves a linear system by a stabilized BiCG method and can be used for + * system matrices. + */ + class BiCGStab2 : public ITL_OEMSolver<bicgstab2_type> + { + public: + /// The constructor reads required parameters and sets solvers \ref name. + BiCGStab2(::std::string name) : ITL_OEMSolver<bicgstab2_type>(name) {} + }; + + + // ============================================================================ + // ===== class BiCGStabEll ====================================================== + // ============================================================================ + + /// Helper class to establish a type from a function + class bicgstab_ell_type + { + public: + template < class LinOp, class X, class B, class L, class R, class I > + int operator()(const LinOp& A, X& x, const B& b, const L& l, const R& r, I& iter, int ell) + { return itl::bicgstab_ell(A, x, b, l, r, iter, ell); } + }; + + /** + * \ingroup Solver + * + * \brief + * Solves a linear system by a stabilized BiCG method and can be used for + * system matrices. + */ + class BiCGStabEll : public ITL_OEMSolver_para<bicgstab_ell_type> + { + public: + /// The constructor reads required parameters and sets solvers \ref name. + BiCGStabEll(::std::string name) : ITL_OEMSolver_para<bicgstab_ell_type>(name) {} + }; + + +} // namespace AMDiS + +#endif // AMDIS_ITL_SOLVER + diff --git a/AMDiS/src/InterpolRestrictMatrix.cc b/AMDiS/src/InterpolRestrictMatrix.cc index ce924771..e1f2de8a 100644 --- a/AMDiS/src/InterpolRestrictMatrix.cc +++ b/AMDiS/src/InterpolRestrictMatrix.cc @@ -142,12 +142,30 @@ namespace AMDiS { } } + // Disabled for the moment + + void InterpolRestrictMatrix::mv(DOFVectorBase<double> *src, + DOFVectorBase<double> *dest, + int coarseLevel) + {ERROR_EXIT("Will be rewritten - Peter\n");} + + void InterpolRestrictMatrix::assembleDOFMatrix(DOFMatrix *dest, + int coarseLevel) + {ERROR_EXIT("Will be rewritten - Peter\n");} + + void InterpolRestrictMatrix::print() + {ERROR_EXIT("Will be rewritten - Peter\n");} + + +#if 0 + + void InterpolRestrictMatrix::mv(DOFVectorBase<double> *src, DOFVectorBase<double> *dest, int coarseLevel) { FUNCNAME("InterpolRestrictMatrix::mv()"); - + if(!initialized_) { initialized_ = true; fillMemory(); @@ -544,4 +562,5 @@ namespace AMDiS { } } } -} +#endif +} // namespace AMDiS diff --git a/AMDiS/src/InterpolRestrictMatrix.h b/AMDiS/src/InterpolRestrictMatrix.h index d45ec5ee..3e7c84b2 100644 --- a/AMDiS/src/InterpolRestrictMatrix.h +++ b/AMDiS/src/InterpolRestrictMatrix.h @@ -4,15 +4,13 @@ #include <map> #include <vector> #include <string> + +#include "AMDiS_fwd.h" #include "Global.h" #include "MemoryManager.h" namespace AMDiS { - class DOFMatrix; - class Element; - template<typename T> class DOFVectorBase; - /** \brief * Defines the data structure for a general interpolation or restriction matrix. * Both can be used to map vectors from a fine mesh to a coarser mesh and vice diff --git a/AMDiS/src/JacobiSmoother.cc b/AMDiS/src/JacobiSmoother.cc index 8a4e5a64..0aeed6a4 100755 --- a/AMDiS/src/JacobiSmoother.cc +++ b/AMDiS/src/JacobiSmoother.cc @@ -16,6 +16,9 @@ namespace AMDiS { int iterations, const std::set<DegreeOfFreedom> &dofSet) { + ERROR_EXIT("Will be rewritten - Peter\n"); + +#if 0 int i, j, rowNumber, colNumber, numCols; double entry, diagEntry = 0.0; @@ -52,6 +55,7 @@ namespace AMDiS { (*solution)[rowNumber] += (1.0 - omega_) * oldSolution[rowNumber]; } } +#endif } template<> @@ -66,6 +70,7 @@ namespace AMDiS { { ERROR_EXIT("not yet (still gs)\n"); +#if 0 int numComponents = s->getSize(); int i, j, k, l; int rowNumber, colNumber, numCols; @@ -114,6 +119,7 @@ namespace AMDiS { } } } +#endif } } diff --git a/AMDiS/src/LeafData.cc b/AMDiS/src/LeafData.cc index 25d7e32b..4a78281e 100644 --- a/AMDiS/src/LeafData.cc +++ b/AMDiS/src/LeafData.cc @@ -32,7 +32,10 @@ namespace AMDiS { int elTypeParent) { - bool test = otherChild->deleteElementData(ESTIMATABLE); +#ifndef NDEBUG + bool test = +#endif + otherChild->deleteElementData(ESTIMATABLE); TEST_EXIT_DBG(test)("couldn't delete LeafDataEstimatable at otherChild"); parent->setElementData(NEW LeafDataEstimatable(parent->getElementData())); diff --git a/AMDiS/src/MatVecMultiplier.cc b/AMDiS/src/MatVecMultiplier.cc index d670b60b..741e8753 100644 --- a/AMDiS/src/MatVecMultiplier.cc +++ b/AMDiS/src/MatVecMultiplier.cc @@ -8,7 +8,8 @@ #include "DOFVector.h" #include "MatrixVector.h" #include "SystemVector.h" -#include "V3Vector.h" + +// These sources are rather suspicious -- Peter namespace AMDiS { @@ -69,6 +70,9 @@ namespace AMDiS { template<> void MassLumpingMatVec<DOFMatrix, DOFVector<double> >::calcMassLumpingMatrix(DOFMatrix *m) { + ERROR_EXIT("Will be rewritten (if any needs it) - Peter\n"); + +#if 0 // create new or clear old matrix if (!matrix) { matrix = NEW DOFMatrix(m->getRowFESpace(), @@ -110,11 +114,15 @@ namespace AMDiS { (*rowIt2)[0].col = rowIt2.getDOFIndex(); (*rowIt2)[0].entry = 1.0 / rowSum; } +#endif } template<> void MassLumpingMatVec<Matrix<DOFMatrix*>, SystemVector>::calcMassLumpingMatrix(Matrix<DOFMatrix*> *m) { + ERROR_EXIT("Will be rewritten (if any needs it) - Peter\n"); + +#if 0 int numComponents = m->getNumRows(); // create new or clear old matrix if(!matrix) { @@ -163,6 +171,7 @@ namespace AMDiS { (*rowIt2)[0].entry = 1.0 / rowSum; } } +#endif } diff --git a/AMDiS/src/MultiGridPreconWrapper.cc b/AMDiS/src/MultiGridPreconWrapper.cc index bdddb726..42ef2f8e 100644 --- a/AMDiS/src/MultiGridPreconWrapper.cc +++ b/AMDiS/src/MultiGridPreconWrapper.cc @@ -1,3 +1,5 @@ +#if 0 + #include "MultiGridPreconWrapper.h" #include "MultiGridSolver.h" #include "DOFVector.h" @@ -43,3 +45,5 @@ namespace AMDiS { } } + +#endif diff --git a/AMDiS/src/MultiGridPreconWrapper.h b/AMDiS/src/MultiGridPreconWrapper.h index 3dfb38d0..961c75d0 100644 --- a/AMDiS/src/MultiGridPreconWrapper.h +++ b/AMDiS/src/MultiGridPreconWrapper.h @@ -22,6 +22,8 @@ #ifndef AMDIS_MULTIGRIDPRECONWRAPPER_H #define AMDIS_MULTIGRIDPRECONWRAPPER_H +#if 0 + #include "Preconditioner.h" #include "MemoryManager.h" @@ -93,3 +95,5 @@ namespace AMDiS { } #endif + +#endif diff --git a/AMDiS/src/MultiGridSolver.cc b/AMDiS/src/MultiGridSolver.cc index a58e7d69..8a56fd7c 100644 --- a/AMDiS/src/MultiGridSolver.cc +++ b/AMDiS/src/MultiGridSolver.cc @@ -1,3 +1,5 @@ +#if 0 + #include "MultiGridSolver.h" #include "FiniteElemSpace.h" #include "DOFVector.h" @@ -14,11 +16,47 @@ #include "InterpolRestrictMatrix.h" #include "LagrangeInterpolRestrict.h" #include "DirichletBC.h" -#include "OpenMP.h" namespace AMDiS { - MultiGridSolverScal::MultiGridSolverScal(const std::string &name) + + MultiGridSolverScal::MultiGridSolverScal(const ::std::string &name) + : MultiGridSolverBase<DOFMatrix, DOFVector<double> >(name) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::initMaxLevel() {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::initMultiGrid(bool initMG) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::exitMultiGrid() {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::smooth(int level, int steps) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::prolongate(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::restrict(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::computeResidual(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::computeRHS(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::computeCorrection(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::fixSolution(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::exactSolve(int level) {ERROR_EXIT("Will be rewritten - Peter\n");} + bool MultiGridSolverScal::toleranceReached(double tol) {ERROR_EXIT("Will be rewritten - Peter\n"); return true; } + void MultiGridSolverScal::initFullMultiGrid() {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverScal::fmgInterpol(int level) {ERROR_EXIT("Will be rewritten - Peter\n");} + MultiGridSolverVec::MultiGridSolverVec(const ::std::string &name) + : MultiGridSolverBase<Matrix<DOFMatrix*>, SystemVector>(name) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::initMaxLevel() {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::initMultiGrid(bool initMG) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::exitMultiGrid() {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::smooth(int level, int steps) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::prolongate(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::restrict(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::computeResidual(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::computeRHS(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::computeCorrection(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::fixSolution(int level, int coarseLevel) {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::exactSolve(int level) {ERROR_EXIT("Will be rewritten - Peter\n");} + bool MultiGridSolverVec::toleranceReached(double tol) {ERROR_EXIT("Will be rewritten - Peter\n"); return true; } + void MultiGridSolverVec::initFullMultiGrid() {ERROR_EXIT("Will be rewritten - Peter\n");} + void MultiGridSolverVec::fmgInterpol(int level) {ERROR_EXIT("Will be rewritten - Peter\n");} + + +#if 0 + + MultiGridSolverScal::MultiGridSolverScal(const ::std::string &name) : MultiGridSolverBase<DOFMatrix, DOFVector<double> >(name), sparseResidual_(NULL), denseResidual_(NULL), @@ -39,11 +77,11 @@ namespace AMDiS { GET_PARAMETER(0, name_ + "->use galerkin operator", "%d", &galerkin_); // Create smoother - std::string smootherType("gs"); + ::std::string smootherType("gs"); GET_PARAMETER(0, name_ + "->smoother", &smootherType); - SmootherCreator<DOFMatrix, SparseVector<double>, std::set<DegreeOfFreedom> > *smootherCreator = - dynamic_cast<SmootherCreator<DOFMatrix, SparseVector<double>, std::set<DegreeOfFreedom> >*>( - CreatorMap<SmootherBase<DOFMatrix, SparseVector<double>, std::set<DegreeOfFreedom> > >::getCreator(smootherType)); + SmootherCreator<DOFMatrix, SparseVector<double>, ::std::set<DegreeOfFreedom> > *smootherCreator = + dynamic_cast<SmootherCreator<DOFMatrix, SparseVector<double>, ::std::set<DegreeOfFreedom> >*>( + CreatorMap<SmootherBase<DOFMatrix, SparseVector<double>, ::std::set<DegreeOfFreedom> > >::getCreator(smootherType)); if (smootherCreator && !smootherCreator->isNullCreator()) { smootherCreator->setName(name_ + "->smoother"); @@ -120,8 +158,7 @@ namespace AMDiS { } } - int error = mesh->queryCoarseDOFs(); - TEST_EXIT(error)("preserve coarse dofs not set in mesh\n"); + TEST_EXIT(mesh->queryCoarseDOFs())("preserve coarse dofs not set in mesh\n"); const BasisFunction *basFcts = feSpace->getBasisFcts(); int numDOFs = basFcts->getNumber(); @@ -150,17 +187,14 @@ namespace AMDiS { int level; // Iterators for all operators of the system matrix. - std::vector<Operator*>::iterator it; - std::vector<Operator*>::iterator opBegin = systemMatrix_->getOperatorsBegin(); - std::vector<Operator*>::iterator opEnd = systemMatrix_->getOperatorsEnd(); - - std::vector<double*>::iterator factorIt; - std::vector<double*>::iterator factorBegin = systemMatrix_->getOperatorFactorBegin(); + ::std::vector<Operator*>::iterator it; + ::std::vector<Operator*>::iterator opBegin = systemMatrix_->getOperatorsBegin(); + ::std::vector<Operator*>::iterator opEnd = systemMatrix_->getOperatorsEnd(); + ::std::vector<double*>::iterator factorIt; + ::std::vector<double*>::iterator factorBegin = systemMatrix_->getOperatorFactorBegin(); ElementMatrix *elementMatrix = NULL; - ERROR_EXIT("Initialize elementMatrix with a non NULL value!\n"); - - BoundaryType *bound = GET_MEMORY(BoundaryType, numDOFs); + const BoundaryType *bound; TraverseStack stack; @@ -193,8 +227,8 @@ namespace AMDiS { element = elInfo->getElement(); level = elInfo->getLevel(); basFcts->getLocalIndices(element, admin, dofs); - basFcts->getBound(elInfo, bound); - (*opBegin)->getAssembler(omp_get_thread_num())->initElementMatrix(elementMatrix, elInfo); + bound = basFcts->getBound(elInfo, NULL); + elementMatrix = (*opBegin)->getAssembler()->initElementMatrix(elementMatrix, elInfo); bool levelUsed = isMGLevel_[level]; @@ -277,8 +311,6 @@ namespace AMDiS { } // if-else element is leaf elInfo = stack.traverseNext(elInfo); } // while elInfo - - FREE_MEMORY(bound, BoundaryType, numDOFs); if (!galerkin_) { // Fill boundary conditions @@ -324,7 +356,7 @@ namespace AMDiS { DOFMatrix *fineMatrix = levels_[maxLevel_].matrix_; for (level = maxLevel_ - 1; level >= minLevel_; level--) { - std::map< std::pair<int, int>, bool> visited; + ::std::map< ::std::pair<int, int>, bool> visited; coarseMatrix = isMGLevel_[level] ? @@ -360,7 +392,7 @@ namespace AMDiS { for (int i = 0; i < dim + 1; i++) { for (int j = 0; j < dim + 1; j++) { - if(visited[std::pair<int, int>(fineDOFs[i], fineDOFs[j])] == false) + if(visited[::std::pair<int, int>(fineDOFs[i], fineDOFs[j])] == false) coarseMatrix->addSparseDOFEntry(1.0, parentDOFs[i], parentDOFs[j], @@ -371,7 +403,7 @@ namespace AMDiS { for (int i = 0; i < dim + 1; i++) { for (int j = 0; j < dim + 1; j++) { - if(visited[std::pair<int, int>(fineDOFs[i], fineDOFs[j])] == false) + if(visited[::std::pair<int, int>(fineDOFs[i], fineDOFs[j])] == false) coarseMatrix->addSparseDOFEntry(1.0, parentDOFs[i], parentDOFs[j], @@ -382,7 +414,7 @@ namespace AMDiS { for (int i = 0; i < dim + 1; i++) { for (int j = 0; j < 2; j++) { - if(visited[std::pair<int, int>(fineDOFs[i], fineDOFs[dim + 1])] == false) { + if(visited[::std::pair<int, int>(fineDOFs[i], fineDOFs[dim + 1])] == false) { coarseMatrix->addSparseDOFEntry(0.5, parentDOFs[i], parentDOFs[j], @@ -398,7 +430,7 @@ namespace AMDiS { } } - if (visited[std::pair<int, int>(fineDOFs[dim + 1], fineDOFs[dim + 1])] == false) { + if (visited[::std::pair<int, int>(fineDOFs[dim + 1], fineDOFs[dim + 1])] == false) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { coarseMatrix->addSparseDOFEntry(0.25, @@ -412,8 +444,8 @@ namespace AMDiS { for (int i = 0; i < dim + 2; i++) { for (int j = 0; j < dim + 2; j++) { - visited[std::pair<int, int>(fineDOFs[i], fineDOFs[j])] = true; - visited[std::pair<int, int>(fineDOFs[j], fineDOFs[i])] = true; + visited[::std::pair<int, int>(fineDOFs[i], fineDOFs[j])] = true; + visited[::std::pair<int, int>(fineDOFs[j], fineDOFs[i])] = true; } } } @@ -429,7 +461,7 @@ namespace AMDiS { for (int i = 0; i < dim + 1; i++) { for (int j = 0; j < dim + 1; j++) { - if (!visited[std::pair<int, int>(parentDOFs[i], parentDOFs[j])]) { + if (!visited[::std::pair<int, int>(parentDOFs[i], parentDOFs[j])]) { coarseMatrix->addSparseDOFEntry(1.0, parentDOFs[i], parentDOFs[j], @@ -550,8 +582,8 @@ namespace AMDiS { levels_[coarseLevel].oldSolution_->copy(*(levels_[level].solution_), levels_[level].nearestNeighbourDOFs_); - std::vector<Element*>::iterator elIt, elBegin, elEnd; - std::vector<int>::iterator typeIt; + ::std::vector<Element*>::iterator elIt, elBegin, elEnd; + ::std::vector<int>::iterator typeIt; for (int i = level; i > coarseLevel; i--) { elBegin = levels_[i-1].elements_.begin(); @@ -827,7 +859,7 @@ namespace AMDiS { // =============================================================================== // =============================================================================== - MultiGridSolverVec::MultiGridSolverVec(const std::string &name) + MultiGridSolverVec::MultiGridSolverVec(const ::std::string &name) : MultiGridSolverBase<Matrix<DOFMatrix*>, SystemVector>(name), sparseResidual_(NULL), denseResidual_(NULL), @@ -850,14 +882,14 @@ namespace AMDiS { GET_PARAMETER(0, name_ + "->use galerkin operator", "%d", &galerkin_); // Create smoother - std::string smootherType("gs"); + ::std::string smootherType("gs"); GET_PARAMETER(0, name_ + "->smoother", &smootherType); if(smootherType == "box") { boxSmoothing_ = true; } - SmootherCreator<Matrix<DOFMatrix*>, Vector<SparseVector<double>*>, Vector< std::set<DegreeOfFreedom>*> > *smootherCreator = - dynamic_cast<SmootherCreator<Matrix<DOFMatrix*>, Vector<SparseVector<double>*>, Vector< std::set<DegreeOfFreedom>*> >*>( - CreatorMap<SmootherBase<Matrix<DOFMatrix*>, Vector<SparseVector<double>*>, Vector< std::set<DegreeOfFreedom>*> > >::getCreator(smootherType) + SmootherCreator<Matrix<DOFMatrix*>, Vector<SparseVector<double>*>, Vector< ::std::set<DegreeOfFreedom>*> > *smootherCreator = + dynamic_cast<SmootherCreator<Matrix<DOFMatrix*>, Vector<SparseVector<double>*>, Vector< ::std::set<DegreeOfFreedom>*> >*>( + CreatorMap<SmootherBase<Matrix<DOFMatrix*>, Vector<SparseVector<double>*>, Vector< ::std::set<DegreeOfFreedom>*> > >::getCreator(smootherType) ); if(smootherCreator && !smootherCreator->isNullCreator()) { smootherCreator->setName(name_ + "->smoother"); @@ -871,7 +903,7 @@ namespace AMDiS { void MultiGridSolverVec::initMaxLevel() { int comp, numComps = solution_->getNumVectors(); - std::set<Mesh*> meshes; + ::std::set<Mesh*> meshes; for(comp = 0; comp < numComps; comp++) { Mesh *mesh = solution_->getDOFVector(comp)->getFESpace()->getMesh(); if(find(meshes.begin(), meshes.end(), mesh) == meshes.end()) { @@ -904,7 +936,7 @@ namespace AMDiS { // Get fe spaces and create residual vectors sparseResidual_ = NEW Vector<SparseVector<double>*>(numComponents_); - std::vector<FiniteElemSpace*> feSpaces(numComponents_); + ::std::vector<FiniteElemSpace*> feSpaces(numComponents_); for (int i = 0; i < numComponents_; i++) { feSpaces[i] = const_cast<FiniteElemSpace*> (solution_->getDOFVector(i)->getFESpace()); @@ -924,8 +956,9 @@ namespace AMDiS { Mesh *mesh = feSpaces[0]->getMesh(); int dim = mesh->getDim(); - int error = mesh->queryCoarseDOFs(); - TEST_EXIT(error)("preserve coarse dofs not set in mesh\n"); + TEST_EXIT(mesh->queryCoarseDOFs()) + ("preserve coarse dofs not set in mesh\n"); + // Check which level is a multigrid level and set the corresponding field // to true. @@ -958,7 +991,7 @@ namespace AMDiS { levels_[i].components_.resize(numComponents_); levels_[i].levelDOFs_.resize(numComponents_); - std::map<FiniteElemSpace*, FESpaceData*> feSpaceData; + ::std::map<FiniteElemSpace*, FESpaceData*> feSpaceData; MeshData *meshData = NEW MeshData; levels_[i].solution_ = NEW Vector<SparseVector<double>*>(numComponents_); @@ -1053,17 +1086,16 @@ namespace AMDiS { elInfo = stack.traverseNext(elInfo); } - BoundaryType *bound = GET_MEMORY(BoundaryType, numDOFs); - for (int col = 0; col < numComponents_; col++) { DOFMatrix *dofMatrix = (*systemMatrix_)[row][col]; - if (dofMatrix) { - std::vector<Operator*>::iterator it; - std::vector<Operator*>::iterator opBegin = dofMatrix->getOperatorsBegin(); - std::vector<Operator*>::iterator opEnd = dofMatrix->getOperatorsEnd(); - std::vector<double*>::iterator factorIt; - std::vector<double*>::iterator factorBegin = dofMatrix->getOperatorFactorBegin(); + if(dofMatrix) { + ::std::vector<Operator*>::iterator it; + ::std::vector<Operator*>::iterator opBegin = dofMatrix->getOperatorsBegin(); + ::std::vector<Operator*>::iterator opEnd = dofMatrix->getOperatorsEnd(); + ::std::vector<double*>::iterator factorIt; + ::std::vector<double*>::iterator factorBegin = dofMatrix->getOperatorFactorBegin(); ElementMatrix *elementMatrix = NULL; + const BoundaryType *bound; // assemble level matrices and create dof sets elInfo = stack.traverseFirst(mesh, -1, @@ -1077,8 +1109,8 @@ namespace AMDiS { element = elInfo->getElement(); level = elInfo->getLevel(); basFcts->getLocalIndices(element, admin, dofs); - basFcts->getBound(elInfo, bound); - (*opBegin)->getAssembler(omp_get_thread_num())->initElementMatrix(elementMatrix, elInfo); + bound = basFcts->getBound(elInfo, NULL); + elementMatrix = (*opBegin)->getAssembler()->initElementMatrix(elementMatrix, elInfo); bool levelUsed = isMGLevel_[level]; if (levelUsed) { @@ -1169,7 +1201,6 @@ namespace AMDiS { } } - FREE_MEMORY(bound, BoundaryType, numDOFs); FREE_MEMORY(dofs, DegreeOfFreedom, numDOFs); } @@ -1210,7 +1241,7 @@ namespace AMDiS { for (level = maxLevel_ - 1; level >= 0; level--) { if (level >= minLevel_) { - std::map< std::pair<int, int>, bool> visited; + ::std::map< ::std::pair<int, int>, bool> visited; coarseMatrix = isMGLevel_[level] ? (*(levels_[level].matrix_))[row][col] : @@ -1244,7 +1275,7 @@ namespace AMDiS { for (int i = 0; i < dim + 1; i++) { for(int j = 0; j < dim + 1; j++) { - if (visited[std::pair<int, int>(fineDOFs[i], fineDOFs[j])] == false) { + if (visited[::std::pair<int, int>(fineDOFs[i], fineDOFs[j])] == false) { coarseMatrix->addSparseDOFEntry(1.0, parentDOFs[i], parentDOFs[j], @@ -1256,7 +1287,7 @@ namespace AMDiS { for (int i = 0; i < dim + 1; i++) { for (int j = 0; j < dim + 1; j++) { - if (visited[std::pair<int, int>(fineDOFs[i], fineDOFs[j])] == false) { + if (visited[::std::pair<int, int>(fineDOFs[i], fineDOFs[j])] == false) { coarseMatrix->addSparseDOFEntry(1.0, parentDOFs[i], parentDOFs[j], @@ -1268,7 +1299,7 @@ namespace AMDiS { for (int i = 0; i < dim + 1; i++) { for (int j = 0; j < 2; j++) { - if (visited[std::pair<int, int>(fineDOFs[i], fineDOFs[dim + 1])] == false) { + if (visited[::std::pair<int, int>(fineDOFs[i], fineDOFs[dim + 1])] == false) { coarseMatrix->addSparseDOFEntry(0.5, parentDOFs[i], parentDOFs[j], @@ -1284,7 +1315,7 @@ namespace AMDiS { } } - if (visited[std::pair<int, int>(fineDOFs[dim + 1], fineDOFs[dim + 1])] == false) { + if (visited[::std::pair<int, int>(fineDOFs[dim + 1], fineDOFs[dim + 1])] == false) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { coarseMatrix->addSparseDOFEntry(0.25, @@ -1298,8 +1329,8 @@ namespace AMDiS { for (int i = 0; i < dim + 2; i++) { for (int j = 0; j < dim + 2; j++) { - visited[std::pair<int, int>(fineDOFs[i], fineDOFs[j])] = true; - visited[std::pair<int, int>(fineDOFs[j], fineDOFs[i])] = true; + visited[::std::pair<int, int>(fineDOFs[i], fineDOFs[j])] = true; + visited[::std::pair<int, int>(fineDOFs[j], fineDOFs[i])] = true; } } } @@ -1316,7 +1347,7 @@ namespace AMDiS { for (int i = 0; i < dim + 1; i++) { for (int j = 0; j < dim + 1; j++) { - if (!visited[std::pair<int, int>(parentDOFs[i], parentDOFs[j])]) { + if (!visited[::std::pair<int, int>(parentDOFs[i], parentDOFs[j])]) { coarseMatrix->addSparseDOFEntry(1.0, parentDOFs[i], parentDOFs[j], @@ -1342,7 +1373,7 @@ namespace AMDiS { if (boxSmoothing_) { boxDOFs_.resize(numComponents_); for (int i = 0; i < numComponents_; i++) { - boxDOFs_[i] = new std::set<DegreeOfFreedom>; + boxDOFs_[i] = new ::std::set<DegreeOfFreedom>; } } @@ -1385,15 +1416,15 @@ namespace AMDiS { { int numLevels = maxLevel_ + 1; - std::set<FESpaceData*> deletedFESpaceData; - std::set<MeshData*> deletedMeshData; + ::std::set<FESpaceData*> deletedFESpaceData; + ::std::set<MeshData*> deletedMeshData; for (int i = 0; i < numLevels; i++) { if (isMGLevel_[i]) { for (int j = 0; j < numComponents_; j++) { if (levels_[i].components_[j].meshData_) { - std::set<MeshData*>::iterator it; - it = std::find(deletedMeshData.begin(), + ::std::set<MeshData*>::iterator it; + it = ::std::find(deletedMeshData.begin(), deletedMeshData.end(), levels_[i].components_[j].meshData_); if (it == deletedMeshData.end()) { @@ -1403,8 +1434,8 @@ namespace AMDiS { } } if (levels_[i].components_[j].feSpaceData_) { - std::set<FESpaceData*>::iterator it; - it = std::find(deletedFESpaceData.begin(), + ::std::set<FESpaceData*>::iterator it; + it = ::std::find(deletedFESpaceData.begin(), deletedFESpaceData.end(), levels_[i].components_[j].feSpaceData_); if (it == deletedFESpaceData.end()) { @@ -1454,7 +1485,7 @@ namespace AMDiS { { if (boxSmoothing_) { for (int iteration = 0; iteration < steps; iteration++) { - std::vector<Element*>::iterator elIt, elBegin, elEnd; + ::std::vector<Element*>::iterator elIt, elBegin, elEnd; elBegin = levels_[level].elements_.begin(); elEnd = levels_[level].elements_.end(); for (elIt = elBegin; elIt != elEnd; ++elIt) { @@ -1518,8 +1549,8 @@ namespace AMDiS { void MultiGridSolverVec::restrict(int level, int coarseLevel) { - std::vector<Element*>::iterator elIt, elBegin, elEnd; - std::vector<int>::iterator typeIt; + ::std::vector<Element*>::iterator elIt, elBegin, elEnd; + ::std::vector<int>::iterator typeIt; for (int comp = 0; comp < numComponents_; comp++) { (*(levels_[coarseLevel].oldSolution_))[comp]-> @@ -1568,7 +1599,7 @@ namespace AMDiS { { DOFMatrix *matrix; SparseVector<double> *res, *sol, *rhs; - std::set<DegreeOfFreedom> *dofSet; + ::std::set<DegreeOfFreedom> *dofSet; for (int i = 0; i < numComponents_; i++) { res = (*sparseResidual_)[i]; res->clear(); @@ -1590,7 +1621,7 @@ namespace AMDiS { { DOFMatrix *matrix; SparseVector<double> *oldSol, *rhs, *res; - std::set<DegreeOfFreedom> *dofSet; + ::std::set<DegreeOfFreedom> *dofSet; for (int i = 0; i < numComponents_; i++) { rhs = (*(levels_[coarseLevel].rhs_))[i]; rhs->clear(); @@ -1613,7 +1644,7 @@ namespace AMDiS { void MultiGridSolverVec::computeCorrection(int level, int coarseLevel) { SparseVector<double> *res, *sol, *oldSol; - std::set<DegreeOfFreedom> *dofSet; + ::std::set<DegreeOfFreedom> *dofSet; for (int comp = 0; comp < numComponents_; comp++) { dofSet = &(levels_[coarseLevel].components_[comp].feSpaceData_->fineDOFs_); sol = (*(levels_[coarseLevel].solution_))[comp]; @@ -1628,7 +1659,7 @@ namespace AMDiS { void MultiGridSolverVec::fixSolution(int level, int coarseLevel) { SparseVector<double> *fineSol, *coarseSol, *res; - std::set<DegreeOfFreedom> *dofSet; + ::std::set<DegreeOfFreedom> *dofSet; for (int comp = 0; comp < numComponents_; comp++) { fineSol = (*(levels_[level].solution_))[comp]; coarseSol = (*(levels_[coarseLevel].solution_))[comp]; @@ -1654,7 +1685,7 @@ namespace AMDiS { FUNCNAME("MultiGridSolverVec::toleranceReached()"); SparseVector<double> *sol; - std::set<DegreeOfFreedom> *dofSet; + ::std::set<DegreeOfFreedom> *dofSet; for (int level = minLevel_; level < maxLevel_ + 1; level++) { if (isMGLevel_[level]) { for (int i = 0; i < numComponents_; i++) { @@ -1693,5 +1724,8 @@ namespace AMDiS { ERROR_EXIT("not yet\n"); } +#endif } + +#endif diff --git a/AMDiS/src/MultiGridSolver.h b/AMDiS/src/MultiGridSolver.h index 40f84def..2e2de061 100644 --- a/AMDiS/src/MultiGridSolver.h +++ b/AMDiS/src/MultiGridSolver.h @@ -22,6 +22,9 @@ #ifndef AMDIS_MULTIGRIDSOLVER_H #define AMDIS_MULTIGRIDSOLVER_H +#if 0 + +#include "AMDiS_fwd.h" #include "MultiGridSolverBase.h" #include <vector> #include "Global.h" @@ -33,15 +36,6 @@ namespace AMDiS { - class DOFMatrix; - template<typename T> class DOFVector; - template<typename T> class SparseVector; - class LevelAdmin; - class FiniteElemSpace; - class DOFAdmin; - class RCNeighbourList; - class InterpolRestrictMatrix; - /** \brief * Implementation of the multigrid solver base class for scalar problems. */ @@ -633,3 +627,5 @@ namespace AMDiS { } #endif + +#endif diff --git a/AMDiS/src/MultiGridSolverBase.h b/AMDiS/src/MultiGridSolverBase.h index 8480db2f..5294b3f4 100755 --- a/AMDiS/src/MultiGridSolverBase.h +++ b/AMDiS/src/MultiGridSolverBase.h @@ -22,8 +22,8 @@ #ifndef AMDIS_MULTIGRIDSOLVERBASE_H #define AMDIS_MULTIGRIDSOLVERBASE_H -#include "InterpolRestrictMatrix.h" -#include "LagrangeInterpolRestrict.h" +#if 0 + #include <string> namespace AMDiS { @@ -35,12 +35,12 @@ namespace AMDiS { /** \brief * Constructor, reads all multigrid parameters from the init file. */ - MultiGridSolverBase(const std::string &name); + MultiGridSolverBase(const ::std::string &name) ; /** \brief * Destructor */ - virtual ~MultiGridSolverBase() {} + virtual ~MultiGridSolverBase() {}; /** \brief * Abstract function for solving an equation using multigrid method. @@ -107,7 +107,7 @@ namespace AMDiS { /** \brief * Name of the problem, corresponding to the name in the init file. */ - std::string name_; + ::std::string name_; /** \brief * Tolerance for the computation. The multigrid method finished, if the @@ -147,21 +147,11 @@ namespace AMDiS { * zero value. */ int fmg_; - - /** \brief - * interpolMatrices[n][m] stores the interpolation matrix for - * n-dimensional elements and m-dimensional basis functions. - */ - InterpolRestrictMatrix *interpolMatrices[3][4]; - - /** \brief - * interpolMatrices[n][m] stores the restriction matrix for - * n-dimensional elements and m-dimensional basis functions. - */ - InterpolRestrictMatrix *restrictMatrices[3][4]; }; } #include "MultiGridSolverBase.hh" #endif + +#endif diff --git a/AMDiS/src/MultiGridSolverBase.hh b/AMDiS/src/MultiGridSolverBase.hh index c4ff0c2f..77b9d9aa 100644 --- a/AMDiS/src/MultiGridSolverBase.hh +++ b/AMDiS/src/MultiGridSolverBase.hh @@ -1,3 +1,5 @@ +#if 0 + #include "Global.h" #include "Parameters.h" @@ -136,3 +138,5 @@ namespace AMDiS { } } + +#endif diff --git a/AMDiS/src/MultiGridWrapper.h b/AMDiS/src/MultiGridWrapper.h index a0f6dcf1..272cc2e1 100644 --- a/AMDiS/src/MultiGridWrapper.h +++ b/AMDiS/src/MultiGridWrapper.h @@ -22,6 +22,8 @@ #ifndef AMDIS_MULTIGRIDWRAPPER_H #define AMDIS_MULTIGRIDWRAPPER_H +#if 0 + #include "MultiGridSolver.h" #include "MatVecMultiplier.h" #include "OEMSolver.h" @@ -29,6 +31,7 @@ namespace AMDiS { + /** \brief * Wrapper to make the multigrid solver accessible as a normal scal solver. */ @@ -144,3 +147,5 @@ namespace AMDiS { } #endif + +#endif diff --git a/AMDiS/src/Newton.h b/AMDiS/src/Newton.h index d1bcc75f..1b6b1e25 100644 --- a/AMDiS/src/Newton.h +++ b/AMDiS/src/Newton.h @@ -25,13 +25,12 @@ #include "MemoryManager.h" #include "CreatorInterface.h" #include "NonLinSolver.h" +#include "AMDiS_fwd.h" namespace AMDiS { class FiniteElemSpace; - template<typename VectorType> class OEMSolver; - // ============================================================================ // ===== class Newton ========================================================= // ============================================================================ @@ -71,7 +70,7 @@ namespace AMDiS { * Calls constructor of base class NonLinSolver */ Newton(const std::string& name_, - OEMSolver<VectorType> *linSolver_, + OEMSolver *linSolver_, NonLinUpdater<VectorType> *updater) : NonLinSolver<VectorType>(name_, linSolver_, updater) {}; diff --git a/AMDiS/src/NewtonS.h b/AMDiS/src/NewtonS.h index db7661f5..6f7a2019 100644 --- a/AMDiS/src/NewtonS.h +++ b/AMDiS/src/NewtonS.h @@ -66,7 +66,7 @@ namespace AMDiS { * Calls constructor of base class NonLinSolver */ NewtonS(const std::string& name_, - OEMSolver<VectorType> *linSolver_, + OEMSolver *linSolver_, NonLinUpdater<VectorType> *updater) : NonLinSolver<VectorType>(name_, linSolver_, updater), b(NULL), diff --git a/AMDiS/src/NonLinSolver.h b/AMDiS/src/NonLinSolver.h index ca729bd2..9e87bd32 100644 --- a/AMDiS/src/NonLinSolver.h +++ b/AMDiS/src/NonLinSolver.h @@ -22,14 +22,17 @@ #ifndef AMDIS_NONLINSOLVER_H #define AMDIS_NONLINSOLVER_H +#if 0 + #include <string> #include "Global.h" #include "CreatorInterface.h" +#include "AMDiS_fwd.h" +#include "OEMSolver.h" namespace AMDiS { - template<typename VectorType> class OEMSolver; template<typename VectorType> class NonLinUpdater; // ============================================================================ @@ -53,7 +56,7 @@ namespace AMDiS { * \param name name of this solver */ NonLinSolver(const std::string &name_, - OEMSolver<VectorType> *linSolver_, + OEMSolver *linSolver_, NonLinUpdater<VectorType> *updater); /** \brief @@ -88,7 +91,7 @@ namespace AMDiS { vectorCreator = creator; }; - inline OEMSolver<VectorType> *getLinearSolver() { return linSolver; }; + inline OEMSolver *getLinearSolver() { return linSolver; }; inline void setNonLinUpdater(NonLinUpdater<VectorType> *up) { nonLinUpdater = up; @@ -124,12 +127,14 @@ namespace AMDiS { { FUNCNAME("NonLinSolver::solveLinearSystem()"); TEST_EXIT(linSolver)("no solver\n"); - return linSolver->solve(matVec, x, fh, lPrecon, rPrecon); + ERROR_EXIT("Not yet re-implemented!\n"); + return -1; + // return linSolver->solve(matVec, x, fh, lPrecon, rPrecon); }; protected: std::string name; /**< \brief name of the solver */ - OEMSolver<VectorType> *linSolver; /**< \brief linear solver*/ + OEMSolver *linSolver; /**< \brief linear solver*/ NonLinUpdater<VectorType> *nonLinUpdater; /**< \brief non linear updater */ double tolerance; /**< \brief solver tolerance */ int maxIter; /**< \brief maximal # of iterations */ @@ -156,7 +161,7 @@ namespace AMDiS { void setName(std::string name_) { name = name_; }; - void setLinearSolver(OEMSolver<VectorType> *solver) { linearSolver = solver; }; + void setLinearSolver(OEMSolver *solver) { linearSolver = solver; }; void setNonLinUpdater(NonLinUpdater<VectorType> *updater) { nonLinUpdater = updater; @@ -164,7 +169,7 @@ namespace AMDiS { protected: std::string name; - OEMSolver<VectorType> *linearSolver; + OEMSolver *linearSolver; NonLinUpdater<VectorType> *nonLinUpdater; }; @@ -174,5 +179,8 @@ namespace AMDiS { #include "Newton.h" #include "NewtonS.h" + +#endif + #endif // AMDIS_NONLINSOLVER_H diff --git a/AMDiS/src/NonLinSolver.hh b/AMDiS/src/NonLinSolver.hh index 6dfb84a9..7bfb4e34 100644 --- a/AMDiS/src/NonLinSolver.hh +++ b/AMDiS/src/NonLinSolver.hh @@ -5,7 +5,7 @@ namespace AMDiS { template<typename VectorType> NonLinSolver<VectorType>::NonLinSolver(const std::string& name_, - OEMSolver<VectorType> *solver, + OEMSolver *solver, NonLinUpdater<VectorType> *updater) : name(name_), linSolver(solver), diff --git a/AMDiS/src/NonLinUpdater.h b/AMDiS/src/NonLinUpdater.h index bffe7026..5ee90dbe 100644 --- a/AMDiS/src/NonLinUpdater.h +++ b/AMDiS/src/NonLinUpdater.h @@ -22,15 +22,13 @@ #ifndef AMDIS_NONLINAPDATOR_H #define AMDIS_NONLINAPDATOR_H +#include "AMDiS_fwd.h" #include "MemoryManager.h" #include "SystemVector.h" #include "MatrixVector.h" namespace AMDiS { - class DOFMatrix; - template<typename T> class DOFVector; - // ========================================================================= // ===== class NonLinUpdater =============================================== // ========================================================================= diff --git a/AMDiS/src/ODirSolver.h b/AMDiS/src/ODirSolver.h deleted file mode 100644 index 15ba9c97..00000000 --- a/AMDiS/src/ODirSolver.h +++ /dev/null @@ -1,101 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file ODirSolver.h */ - -#ifndef AMDIS_ODIRSOLVER_H -#define AMDIS_ODIRSOLVER_H - -#include "OEMSolver.h" -#include "MemoryManager.h" - -namespace AMDiS { - - // ============================================================================ - // ===== class BiCGSolver ===================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Solves a linear system by the method of orthogonal directions and can be - * used for symmetric positive system matrices. - */ - template<typename VectorType> - class ODirSolver : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(ODirSolver<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new ODirSolver object. - */ - OEMSolver<VectorType>* create() { - return NEW ODirSolver<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - ODirSolver(std::string name); - - /** \brief - * destructor - */ - ~ODirSolver(); - - protected: - /** \brief - * realisation of OEMSolver::solveSystem - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix); - - /** \brief - * realisation of OEMSolver::init - */ - void init(); - - /** \brief - * realisation of OEMSolver::exit - */ - void exit(); - - private: - // pointer to memory needed for solveSystem - VectorType *Ad, *d, *d_old, *r, *h; - }; - -} - -#include "ODirSolver.hh" - -#endif // AMDIS_ODIR_SOLVER_H diff --git a/AMDiS/src/ODirSolver.hh b/AMDiS/src/ODirSolver.hh deleted file mode 100644 index 11fcdaa2..00000000 --- a/AMDiS/src/ODirSolver.hh +++ /dev/null @@ -1,167 +0,0 @@ -#include "Preconditioner.h" - -namespace AMDiS { - - template<typename VectorType> - ODirSolver<VectorType>::ODirSolver(std::string name) - : OEMSolver<VectorType>(name), - Ad(NULL), d(NULL), d_old(NULL), r(NULL), h(NULL) - { - } - - template<typename VectorType> - ODirSolver<VectorType>::~ODirSolver() - {} - - template<typename VectorType> - void ODirSolver<VectorType>::init() - { - Ad = this->vectorCreator->create(); - d = this->vectorCreator->create(); - d_old = this->vectorCreator->create(); - r = this->vectorCreator->create(); - h = this->vectorCreator->create(); - } - - template<typename VectorType> - void ODirSolver<VectorType>::exit() - { - this->vectorCreator->free(Ad); - this->vectorCreator->free(d); - this->vectorCreator->free(d_old); - this->vectorCreator->free(r); - this->vectorCreator->free(h); - } - - template<typename VectorType> - int ODirSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, bool reuseMatrix) - { - FUNCNAME("ODirSolver::solveSystem"); - - double res, old_res = -1.0; - double dad, dad_old, rd, alpha, gamma, sigma; - int iter; - VectorType *swap = NULL; - const double TOL = 1.e-30; - - /*--------------------------------------------------------------------------*/ - /*--- Initalization ------------------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - if (norm(b) < TOL) - { - INFO(this->info,2)("b == 0, x = 0 is the solution of the linear system\n"); - set(*x, 0.0); - return(0); - } - - // r = Ax - matVec->matVec(NoTranspose, *x, *r); - - // r = -b + r - *r -= *b; - - // h = r - *h = *r; - - if (this->leftPrecon) { - this->leftPrecon->precon(h); - } - - // d = h - *d = *h; - - // d_old = 0; - set(*d_old, 0.0); - - dad_old = 1.0; - - /*--------------------------------------------------------------------------*/ - /*--- check initial residual ---------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - res = norm(r); - - START_INFO(); - if (SOLVE_INFO(0, res, &old_res)) - return(0); - - /*--------------------------------------------------------------------------*/ - /*--- Iteration ----------------------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - for (iter = 1; iter <= this->max_iter; iter++) - { - /*--------------------------------------------------------------------------*/ - /*--- calculate r.d, A.d and d.A.d ---------------------------------------*/ - /*--------------------------------------------------------------------------*/ - // rd = r*d - rd = *r * *d; - - // Ad = A*d - matVec->matVec(NoTranspose, *d, *Ad); - - // dad = d*Ad - dad = *d * *Ad; - - if (abs(dad) < TOL) - { - BREAK_INFO("(Ad,d)_2 = 0", iter, res, &old_res); - return(iter); - } - - /*--------------------------------------------------------------------------*/ - /*--- update x and calculate new r --------------------------------------*/ - /*--------------------------------------------------------------------------*/ - alpha = rd/dad; - - // x = -alpha d + x - axpy(-alpha, *d, *x); - - // r = -alpha Ad + r - axpy(-alpha, *Ad, *r); - - res = norm(r); - if (SOLVE_INFO(iter, res, &old_res)) - return(iter); - - // h = Ad - *h = *Ad; - - if (this->leftPrecon) this->leftPrecon->precon(h); - - /*--------------------------------------------------------------------------*/ - /*--- calculate gamma and sigma ------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - // gamma = h*Ad/dad - gamma = (*h * *Ad)/dad; - sigma = dad/dad_old; - - /*--------------------------------------------------------------------------*/ - /*--- compute new d and save old values ----------------------------------*/ - /*--------------------------------------------------------------------------*/ - - // swap d and d_old - //swap(*d, *d_old); - swap = d; - d = d_old; - d_old = swap; - - // d = -sigma * d - *d *= -sigma; - - // d = -gamma d_old + d - axpy(-gamma, *d_old, *d); - - // d = h + d - *d += *h; - - dad_old= dad; - } - - return 0; // never reached ! - } - -} diff --git a/AMDiS/src/OEMSolver.h b/AMDiS/src/OEMSolver.h index 3830691c..c338e76e 100644 --- a/AMDiS/src/OEMSolver.h +++ b/AMDiS/src/OEMSolver.h @@ -31,100 +31,128 @@ #ifndef AMDIS_OEM_SOLVER_H #define AMDIS_OEM_SOLVER_H -// ============================================================================ -// ===== includes ============================================================= -// ============================================================================ - #include "Global.h" +#include "AMDiS_fwd.h" +#include "Parameters.h" +#include "SolverMatrix.h" +#include "DOFVector.h" +#include "SystemVector.h" +#include "DOFMatrix.h" +#include "ITL_Preconditioner.h" namespace AMDiS { - // ============================================================================ - // ===== forward declarations ================================================= - // ============================================================================ - - template<typename VectorType> class Preconditioner; - template<typename VectorType> class CreatorInterface; - template<typename VectorType> class MatVecMultiplier; - - // ============================================================================ - // ===== definitions ========================================================== - // ============================================================================ - - /** \brief prints information before solving the system */ -#define START_INFO() this->start_info(funcName) - - /** \brief prints information after solving the system */ -#define BREAK_INFO(st,it,res,ores) \ - this->break_info(funcName,st,it,res,ores) - - /** \brief prints information while solving the system */ -#define SOLVE_INFO(it,res,ores) \ - this->solve_info(funcName,it,res,ores) - - - // ============================================================================ - // ===== class OEMSolver ====================================================== - // ============================================================================ - /** * \ingroup Solver * *\brief * Solver for linear equation systems. - * Virtual base class for OEM solvers. */ - template<typename VectorType> class OEMSolver { public: + + typedef DOFMatrix::base_matrix_type matrix_type; + typedef DOFMatrix::value_type value_type; + /** \brief * The constructor reads needed parameters and sets solvers \ref name. */ - OEMSolver(std::string name); - - /** \brief - * Virtual destructor because OEMSolver is pure virtual. - */ - virtual ~OEMSolver(); - - void initParameters(); + OEMSolver(std::string str) + : name(str), + tolerance(0), + relative(0), + max_iter(1000), + info(0), + residual(0), + print_cycle(100), + leftPrecon(NULL), + rightPrecon(NULL) + {} /** \brief - * Solves the linear system. + * */ - int solve(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, - Preconditioner<VectorType> *lPrecon = NULL, - Preconditioner<VectorType> *rPrecon = NULL, - bool reuseMatrix = false) + virtual ~OEMSolver() { - FUNCNAME("OEMSolver::solve()"); - TEST_EXIT(mv)("no matVec\n"); - TEST_EXIT(vectorCreator)("no vectorCreator\n"); - - leftPrecon = lPrecon; - rightPrecon = rPrecon; - - init(); + if (leftPrecon) delete leftPrecon; + if (rightPrecon) delete rightPrecon; + } - if (leftPrecon) - leftPrecon->init(); + void initParameters() + { + FUNCNAME("OEMSolver::initParameters()"); - if (rightPrecon) - rightPrecon->init(); + GET_PARAMETER(0, name + "->tolerance", "%f", &tolerance); + GET_PARAMETER(0, name + "->relative tolerance", "%f", &relative); + GET_PARAMETER(0, name + "->max iteration", "%d", &max_iter); + GET_PARAMETER(0, name + "->print cycle", "%d", &print_cycle); + GET_PARAMETER(0, name + "->info", "%d", &info); + } - int iter = solveSystem(mv, x, b, reuseMatrix); + /** Set left Preconditioner + * + * It is assumed that the solver owns the preconditioner from this call. + * That means that the preconditioner is deleted by the solver when not needed. + */ + void setLeftPrecon(ITL_BasePreconditioner* p) + { + if (leftPrecon) delete leftPrecon; + leftPrecon= p; + } - if (leftPrecon) - leftPrecon->exit(); + /** Set right Preconditioner + * + * It is assumed that the solver owns the preconditioner from this call. + * That means that the preconditioner is deleted by the solver when not needed. + */ + void setRightPrecon(ITL_BasePreconditioner* p) + { + if (rightPrecon) delete rightPrecon; + rightPrecon= p; + } - if (rightPrecon) - rightPrecon->exit(); + /// Linear System to be solved in the derived class + virtual int solveSystem(const DOFMatrix::base_matrix_type& A, + mtl::dense_vector<value_type>& x, + const mtl::dense_vector<value_type>& b) = 0; + - exit(); + /// Solve a linear system for a scalar problem. + int solveSystem(const SolverMatrix<DOFMatrix>& A, + DOFVector<double>& x, + DOFVector<double>& b) + { + mtl::dense_vector<value_type> xx(x.getUsedSize(), &x[0]), + bb(b.getUsedSize(), &b[0]); + return solveSystem(A.getMatrix(), xx, bb); + } - return iter; + /// Solve a linear system for a vectorial problem. + int solveSystem(const SolverMatrix<Matrix<DOFMatrix*> >& A, + SystemVector& x, + SystemVector& b) + { + int ns= x.getSize(), // Number of systems. + size= x.getUsedSize(); // Size of all DOFVectors + + // Copy vectors + mtl::dense_vector<value_type> xx(size), bb(size); + for (int i = 0, counter = 0; i < ns; i++) { + DOFVector<double>::Iterator it(b.getDOFVector(i), USED_DOFS); + for (it.reset(); !it.end(); ++it) + bb[counter++] = *it; + } + + // Solver on DOFVector for single system + int r= solveSystem(A.getMatrix(), xx, bb); + + for (int i = 0, counter = 0; i < ns; i++) { + DOFVector<double>::Iterator it(x.getDOFVector(i), USED_DOFS); + for (it.reset(); !it.end(); ++it) + *it = xx[counter++]; + } + return r; } // ===== getting-methods ====================================================== @@ -196,52 +224,9 @@ namespace AMDiS { inline void setInfo(int i) { info = i; } - - inline void setVectorCreator(CreatorInterface<VectorType> *creator) { - vectorCreator = creator; - } - - inline CreatorInterface<VectorType>* getVectorCreator() { - return vectorCreator; - } /** \} */ - protected: - /** \brief - * To be overloaded by concrete solvers. - */ - virtual void init() = 0; - - /** \brief - * To be overloaded by concrete solvers. - */ - virtual void exit() = 0; - - /** \brief - * To be overloaded by concrete solvers. - */ - virtual int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, - VectorType *b, - bool reuseMatrix) = 0; - - - /** \brief - * Prints start information. Uses \ref START_INFO. - */ - void start_info(const char *); - - /** \brief - * Prints break information. Uses \ref BREAK_INFO. - */ - void break_info(const char *, const char *, int, double, double *); - - /** \brief - * Prints solve information. Uses \ref SOLVE_INFO. - */ - int solve_info(const char *, int, double, double *); - protected: /** \brief * solvers name. @@ -249,14 +234,14 @@ namespace AMDiS { std::string name; /** \brief - * solver tolerance. Set in OEMSolver's constructor. + * Solver tolerance |r|. Set in OEMSolver's constructor. */ double tolerance; /** \brief - * solver relative. Set in OEMSolver's constructor. + * Relative solver tolerance |r|/|r0|. Set in OEMSolver's constructor. */ - bool relative; + double relative; /** \brief * maximal number of iterations. Set in OEMSolver's constructor. @@ -273,12 +258,12 @@ namespace AMDiS { */ double residual; - Preconditioner<VectorType> *leftPrecon; - - Preconditioner<VectorType> *rightPrecon; + /// Print cycle, after how many iterations the residuum norm is logged. + int print_cycle; - CreatorInterface<VectorType> *vectorCreator; + ITL_BasePreconditioner *leftPrecon; + ITL_BasePreconditioner *rightPrecon; }; // ============================================================================ @@ -291,8 +276,7 @@ namespace AMDiS { * \brief * Interface for creators of concrete OEMSolvers. */ - template<typename T> - class OEMSolverCreator : public CreatorInterface<OEMSolver<T> > + class OEMSolverCreator : public CreatorInterface<OEMSolver> { public: virtual ~OEMSolverCreator() {} @@ -300,8 +284,8 @@ namespace AMDiS { /** \brief * Sets \ref problem */ - void setName(std::string name_) { - name = name_; + void setName(std::string str) { + name = str; } protected: @@ -313,14 +297,6 @@ namespace AMDiS { }; } -#include "OEMSolver.hh" - -#include "Preconditioner.h" -#include "BiCGSolver.h" -#include "BiCGStab_M.h" -#include "CGSolver.h" -#include "GMResSolver.h" -#include "ODirSolver.h" -#include "OResSolver.h" +#include "ITL_Solver.h" #endif // AMDIS_OEM_SOLVER_H diff --git a/AMDiS/src/OEMSolver.hh b/AMDiS/src/OEMSolver.hh deleted file mode 100644 index aa2d25f0..00000000 --- a/AMDiS/src/OEMSolver.hh +++ /dev/null @@ -1,109 +0,0 @@ -#include "CreatorInterface.h" -#include "Parameters.h" -#include "Preconditioner.h" -#include "CreatorMap.h" -#include "MatVecMultiplier.h" - -namespace AMDiS { - - template<typename VectorType> - OEMSolver<VectorType>::OEMSolver(std::string name_) - : name(name_), - tolerance(1.e-8), - relative(false), - max_iter(1000), - info(0), - residual(0), - leftPrecon(NULL), - rightPrecon(NULL), - vectorCreator(NULL) - { - FUNCNAME("OEMSolver::OEMSolver"); - } - - - template<typename VectorType> - void OEMSolver<VectorType>::initParameters() - { - FUNCNAME("OEMSolver::initParameters()"); - - GET_PARAMETER(0, name + "->tolerance", "%f", &tolerance); - GET_PARAMETER(0, name + "->relative", "%d", &relative); - GET_PARAMETER(0, name + "->max iteration", "%d", &max_iter); - GET_PARAMETER(0, name + "->info", "%d", &info); - } - - template<typename VectorType> - OEMSolver<VectorType>::~OEMSolver() - { - FUNCNAME("OEMSolver::~OEMSolver"); - - if (vectorCreator) - DELETE vectorCreator; - } - - - template<typename VectorType> - void OEMSolver<VectorType>::start_info(const char *funcName) - { - info = info > 10 ? 10 : info; - - INFO(info,6)("with tolerance %e\n", tolerance); - PRINT_INFO(info,6)("\n"); - INFO(info,2)("iter. | residual | red.\n"); - return; - } - - template<typename VectorType> - void OEMSolver<VectorType>::break_info(const char *funcName, - const char *reason, - int iter, - double res, - double *ores) - { - if (ores && *ores > 0) { - INFO(info,2)("%5d | %12.5e | %8.2e\n", iter, res, res / (*ores)); - } else { - INFO(info,2)("%5d | %12.5e |\n", iter, res); - } - INFO(info,2)("stop due to: %s\n", reason); - - residual = res; - } - - template<typename VectorType> - int OEMSolver<VectorType>::solve_info(const char * funcName, int iter, - double res, double *ores) - { - static int step[11] = {0, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1}; - - if (res <= tolerance || (info && (iter%step[info] == 0)) || iter == max_iter) { - if (ores) { - if (*ores > 0.0) { - double red = res/(*ores); - INFO(info,2)("%5d | %12.5e | %8.2e\n", iter, res, red); - } else { - INFO(info,2)("%5d | %12.5e | --------\n", iter, res); - } - *ores = res; - } else { - INFO(info,2)("%5d | %12.5e |\n", iter, res); - } - } - - residual = res; - - if (iter == max_iter && res > tolerance) { - INFO(info,1)("tolerance %e not reached after %d iterations\n", tolerance, iter); - return(2); - } - - if (res <= tolerance) { - INFO(info,6)("finished successfully with %d iterations\n"); - return(1); - } - - return 0; - } - -} diff --git a/AMDiS/src/OResSolver.h b/AMDiS/src/OResSolver.h deleted file mode 100644 index 8d731b37..00000000 --- a/AMDiS/src/OResSolver.h +++ /dev/null @@ -1,101 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file OResSolver.h */ - -#ifndef AMDIS_ORESSOLVER_H -#define AMDIS_ORESSOLVER_H - -#include "OEMSolver.h" -#include "MemoryManager.h" - -namespace AMDiS { - - // ============================================================================ - // ===== class OResSolver ===================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Solves a linear system by the method of orthogonal residuals and can be used - * for symmetric system matrices. - */ - template<typename VectorType> - class OResSolver : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(OResSolver<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new OResSolver object. - */ - OEMSolver<VectorType>* create() { - return NEW OResSolver<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - OResSolver(std::string name); - - /** \brief - * destructor - */ - ~OResSolver(); - - protected: - /** \brief - * realisation of OEMSolver::solveSystem - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix); - - /** \brief - * realisation of OEMSolver::init - */ - void init(); - - /** \brief - * realisation of OEMSolver::exit - */ - void exit(); - - private: - // pointer to memory needed for solveSystem - VectorType *Ad, *d, *d_old, *r, *h, *Ad_old, *Ah; - }; - -} - -#include "OResSolver.hh" - -#endif // AMDIS_ORESSOLVER_H diff --git a/AMDiS/src/OResSolver.hh b/AMDiS/src/OResSolver.hh deleted file mode 100644 index 74e95865..00000000 --- a/AMDiS/src/OResSolver.hh +++ /dev/null @@ -1,160 +0,0 @@ -#include "Preconditioner.h" - -namespace AMDiS { - - template<typename VectorType> - OResSolver<VectorType>::OResSolver(std::string name) - : OEMSolver<VectorType>(name), - Ad(NULL), d(NULL), d_old(NULL), r(NULL), h(NULL), Ad_old(NULL), Ah(NULL) - { - } - - template<typename VectorType> - OResSolver<VectorType>::~OResSolver() - {} - - template<typename VectorType> - void OResSolver<VectorType>::init() - { - Ad = this->vectorCreator->create(); - d = this->vectorCreator->create(); - d_old = this->vectorCreator->create(); - r = this->vectorCreator->create(); - h = this->vectorCreator->create(); - Ad_old = this->vectorCreator->create(); - Ah = this->vectorCreator->create(); - } - - template<typename T> - void OResSolver<T>::exit() - { - this->vectorCreator->free(Ad); - this->vectorCreator->free(d); - this->vectorCreator->free(d_old); - this->vectorCreator->free(r); - this->vectorCreator->free(h); - this->vectorCreator->free(Ad_old); - this->vectorCreator->free(Ah); - } - - template<typename VectorType> - int OResSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, - bool reuseMatrix) - { - FUNCNAME("OResSolver::solveSystem"); - - double alpha, gamma, sigma; - double daad, daad_old, rad, res, old_res = -1.0; - int iter; //, dim2; - VectorType *swap = NULL; - - /*--------------------------------------------------------------------------*/ - /*--- Initalization ------------------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - // r = Ax - matVec->matVec(NoTranspose, *x, *r); - - // r = - b + r - *r -= *b; - - // h = r - *h = *r; - - if (this->leftPrecon) this->leftPrecon->precon(h); - - // d = h - *d = *h; - - /*--- d_old = 0 and Ad_old = 0 ---------------*/ - set(*d_old, 0.0); - set(*Ad_old, 0.0); - - // Ad = A*d - matVec->matVec(NoTranspose, *d, *Ad); - - daad_old = 1.0; - - /*--------------------------------------------------------------------------*/ - /*--- check initial residual ---------------------------------------------*/ - /*--------------------------------------------------------------------------*/ - - res = norm(r); - - START_INFO(); - if (SOLVE_INFO(0, res, &old_res)) - return(0); - - for (iter = 1; iter <= this->max_iter; iter++) { - /*--- compute r.Ad and d.A.A.d ---------------------------------------------*/ - // rad = r * Ad - rad = *r * *Ad; - - // daad = Ad * Ad - daad = *Ad * *Ad; - - if (daad <= 1.e-30) { - BREAK_INFO("(Ad,d)_2 = 0", iter, res, &old_res); - return(iter); - } - - /*--- update u and r ------------------------------------------------------*/ - - alpha= rad/daad; - - // x = -alpha d + x - axpy(-alpha, *d, *x); - - // r = - alpha Ad + r - axpy(-alpha, *Ad, *r); - - res = norm(r); - - if (SOLVE_INFO(iter, res, &old_res)) - return(iter); - - // h = Ad - *h = *Ad; - - if (this->leftPrecon) this->leftPrecon->precon(h); - - // Ah = A * h - matVec->matVec(NoTranspose, *h, *Ah); - - // gamma = Ah * Ad / daad - gamma = (*Ah * *Ad)/daad; - sigma = daad/daad_old; - - /*--- compute new d.Ad, save old values! ----------------------------------*/ - // swap d and d_old - swap = d_old; - d_old = d; - d = swap; - - // swap Ad_old and Ad - swap = Ad_old; - Ad_old = Ad; - Ad = swap; - - /*--- d,Ad *= -sigma --------------*/ - *d *= -sigma; - *Ad *= -sigma; - - /*--- d,Ad -= gamma*d_old,Ad_old --*/ - axpy(-gamma, *d_old, *d); - axpy(-gamma, *Ad_old, *Ad); - - // d = h + d - *d += *h; - - // Ad = Ah + Ad - *Ad += *Ah; - - daad_old = daad; - } - - return 0; // never reached ! - } - -} diff --git a/AMDiS/src/PeriodicBC.cc b/AMDiS/src/PeriodicBC.cc index 1c70953d..17e0622e 100644 --- a/AMDiS/src/PeriodicBC.cc +++ b/AMDiS/src/PeriodicBC.cc @@ -9,15 +9,15 @@ namespace AMDiS { - std::vector<PeriodicDOFMapping*> PeriodicDOFMapping::mappings_; + ::std::vector<PeriodicDOFMapping*> PeriodicDOFMapping::mappings_; PeriodicDOFMapping* PeriodicDOFMapping::providePeriodicDOFMapping(const BasisFunction *basFcts) { - std::vector<PeriodicDOFMapping*>::iterator it; - std::vector<PeriodicDOFMapping*>::iterator end = mappings_.end(); - for (it = mappings_.begin(); it != end; ++it) { - if ((*it)->basFcts_ == basFcts) { + ::std::vector<PeriodicDOFMapping*>::iterator it; + ::std::vector<PeriodicDOFMapping*>::iterator end = mappings_.end(); + for(it = mappings_.begin(); it != end; ++it) { + if((*it)->basFcts_ == basFcts) { return *it; } } @@ -32,9 +32,9 @@ namespace AMDiS { { FUNCNAME("PeriodicDOFMapping::PeriodicDOFMapping()"); TEST_EXIT(basFcts_->getDim() > 1)("dim == 1\n"); - int num = basFcts_->getNumber(); + int i, num = basFcts_->getNumber(); DimVec<double> *lambda; - for (int i = 0; i < num; i++) { + for(i = 0; i < num; i++) { lambda = basFcts_->getCoords(i); indexOfCoords_[*lambda] = i; } @@ -42,9 +42,9 @@ namespace AMDiS { PeriodicDOFMapping::~PeriodicDOFMapping() { - std::map<DimVec<int>, DegreeOfFreedom*, DimVecLess<int> >::iterator it; - for (it = dofPermutation_.begin(); it != dofPermutation_.end(); ++it) { - if (it->second) { + ::std::map<DimVec<int>, DegreeOfFreedom*, DimVecLess<int> >::iterator it; + for(it = dofPermutation_.begin(); it != dofPermutation_.end(); ++it) { + if(it->second) { FREE_MEMORY(it->second, DegreeOfFreedom, basFcts_->getNumber()); } } @@ -55,17 +55,20 @@ namespace AMDiS { { FUNCNAME("PeriodicDOFMapping::getDOFPermutation()"); - if (dofPermutation_[vertexPermutation] == NULL) { + if(dofPermutation_[vertexPermutation] == NULL) { + //MSG("new dof permutation needed\n"); + + int i, j; int dim = basFcts_->getDim(); int num = basFcts_->getNumber(); int sum = 0; - for (int i = 0; i < dim + 1; i++) { + for(i = 0; i < dim + 1; i++) { sum += i - vertexPermutation[i]; - TEST_EXIT_DBG(vertexPermutation[i] < dim + 1) + TEST_EXIT(vertexPermutation[i] < dim + 1) ("invalid vertexPermuation\n"); } - TEST_EXIT_DBG(sum == 0)("invalid vertexPermutation\n"); + TEST_EXIT(sum == 0)("invalid vertexPermutation\n"); // create dof permutation DimVec<double> *lambda; @@ -73,15 +76,28 @@ namespace AMDiS { DegreeOfFreedom *mapping = GET_MEMORY(DegreeOfFreedom, num); - for (int i = 0; i < num; i++) { + for(i = 0; i < num; i++) { lambda = basFcts_->getCoords(i); - for (int j = 0; j < dim + 1; j++) { + for(j = 0; j < dim + 1; j++) { newLambda[vertexPermutation[j]] = (*lambda)[j]; } mapping[i] = indexOfCoords_[newLambda]; } dofPermutation_[vertexPermutation] = mapping; + + // MSG("vertex permutation: "); + // for(i = 0; i < dim+1; i++) { + // MSG("%d ", vertexPermutation[i]); + // } + // MSG("\n"); + + // MSG("dof permutation: "); + // for(i = 0; i < num; i++) { + // MSG("%d ", dofPermutation_[vertexPermutation][i]); + // } + // MSG("\n"); + // WAIT; } return dofPermutation_[vertexPermutation]; @@ -92,7 +108,7 @@ namespace AMDiS { : BoundaryCondition(type, rowFESpace_, NULL), masterMatrix_(NULL) { - if (rowFESpace->getMesh()->getDim() > 1) { + if(rowFESpace->getMesh()->getDim() > 1) { periodicDOFMapping_ = PeriodicDOFMapping::providePeriodicDOFMapping(rowFESpace_->getBasisFcts()); } else { @@ -107,17 +123,25 @@ namespace AMDiS { { FUNCNAME("PeriodicBC::initMatrix()"); - if (!masterMatrix_) { + // MSG("begin initMatrix...\n"); + + if(!masterMatrix_) { masterMatrix_ = matrix; + Mesh *mesh = matrix->getRowFESpace()->getMesh(); + associated_ = mesh->getPeriodicAssociations()[boundaryType]; - TEST_EXIT(associated_) - ("no associations for periodic boundary condition %d\n", boundaryType); + TEST_EXIT(associated_)("no associations for periodic boundary condition %d\n", + boundaryType); + + const BasisFunction *basFcts = rowFESpace->getBasisFcts(); + int num = basFcts->getNumber(); - neighIndices_ = GET_MEMORY(DegreeOfFreedom, - rowFESpace->getBasisFcts()->getNumber()); + neighIndices_ = GET_MEMORY(DegreeOfFreedom, num); } + + //MSG("end initMatrix...\n"); } void PeriodicBC::fillBoundaryCondition(DOFMatrix *matrix, @@ -126,24 +150,33 @@ namespace AMDiS { const BoundaryType *localBound, int nBasFcts) { - if (matrix == masterMatrix_) { + if(matrix == masterMatrix_) { + int dim = rowFESpace->getMesh()->getDim(); - - if (dim > 1) { + if(dim > 1) { + int i, j; DOFAdmin *admin = rowFESpace->getAdmin(); + FixVec<int, WORLD> elFace(dim, NO_INIT); FixVec<int, WORLD> neighFace(dim, NO_INIT); DimVec<int> vertexPermutation(dim, NO_INIT); + const BasisFunction *basFcts = rowFESpace->getBasisFcts(); int num = basFcts->getNumber(); + Element *element = elInfo->getElement(); + DimVec<DegreeOfFreedom> periodicDOFs(dim-1, NO_INIT); + int vertex, index, side; + GeoIndex sideGeoIndex = INDEX_OF_DIM(dim-1, dim); - for (side = 0; side < dim + 1; side++) { - if (elInfo->getBoundary(sideGeoIndex, side) == boundaryType) { - for (vertex = 0; vertex < dim; vertex++) { + for(side = 0; side < dim + 1; side++) { + + if(elInfo->getBoundary(sideGeoIndex, side) == boundaryType) { + + for(vertex = 0; vertex < dim; vertex++) { index = element->getVertexOfPosition(sideGeoIndex, side, vertex); @@ -151,36 +184,34 @@ namespace AMDiS { } Element *neigh = elInfo->getNeighbour(side); + basFcts->getLocalIndices(neigh, admin, neighIndices_); - int oppVertex = 0; - for (int i = 0; i < dim + 1; i++) { + int oppVertex = 0; + for(i = 0; i < dim + 1; i++) { // get vertex permutation - if (i == side) { + if(i == side) { vertexPermutation[i] = 0; } else { DegreeOfFreedom periodicDOF = periodicDOFs[element->getPositionOfVertex(side, i)]; - int j; - for (j = 0; j < dim + 1; j++) { - if (neigh->getDOF(j, 0) == periodicDOF) - break; + for(j = 0; j < dim + 1; j++) { + if(neigh->getDOF(j, 0) == periodicDOF) break; } vertexPermutation[i] = j; } oppVertex += i - vertexPermutation[i]; } - vertexPermutation[side] = oppVertex; // get DOF permutation const DegreeOfFreedom *dofPermutation = periodicDOFMapping_->getDOFPermutation(vertexPermutation); - + // set associated dofs - for (int i = 0; i < num; i++) { - if ((*(basFcts->getCoords(i)))[side] == 0) { + for(i = 0; i < num; i++) { + if((*(basFcts->getCoords(i)))[side] == 0) { (*associated_)[dofIndices[i]] = neighIndices_[dofPermutation[i]]; } } @@ -194,38 +225,134 @@ namespace AMDiS { { FUNCNAME("PeriodicBC::exitMatrix()"); - TEST_EXIT_DBG(matrix)("no matrix\n"); + TEST_EXIT(matrix)("no matrix\n"); - if (matrix == masterMatrix_) { - FREE_MEMORY(neighIndices_, DegreeOfFreedom, - rowFESpace->getBasisFcts()->getNumber()); + if(matrix == masterMatrix_) { + const BasisFunction *basFcts = rowFESpace->getBasisFcts(); + int num = basFcts->getNumber(); + FREE_MEMORY(neighIndices_, DegreeOfFreedom, num); masterMatrix_ = NULL; } - - std::vector< std::vector<MatEntry> >::iterator rowIt; - std::vector< std::vector<MatEntry> >::iterator rowEnd = matrix->end(); + // ---------- different assemblage style -------- + + // DOFMatrix::Iterator matrixRow(matrix, USED_DOFS); + // for(matrixRow.reset(); !matrixRow.end(); ++matrixRow) { + // row = matrixRow.getDOFIndex(); + + // rowSize = matrixRow->size(); + // newRow = ((*associated_)[row] == -1) ? row : (*associated_)[row]; + + // if(row < newRow) { + // for(i = 0; i < rowSize; i++) { + // col = (*matrixRow)[i].col; + // if(col == DOFMatrix::NO_MORE_ENTRIES) break; + // if(col == DOFMatrix::UNUSED_ENTRY) continue; + // newCol = ((*associated_)[col] == -1) ? col : (*associated_)[col]; + // if(col < newCol) { + // entry = (*matrixRow)[i].entry; + // (*matrixRow)[i].col = DOFMatrix::UNUSED_ENTRY; + // (*matrixRow)[i].entry = 0.0; + // matrix->addSparseDOFEntry(1.0, row, newCol, entry, true); + // } + // } + // rowSize = matrixRow->size(); + // for(i = 0; i < rowSize; i++) { + // col = (*matrixRow)[i].col; + // if(col == DOFMatrix::NO_MORE_ENTRIES) break; + // if(col == DOFMatrix::UNUSED_ENTRY) continue; + // entry = (*matrixRow)[i].entry; + // matrix->addSparseDOFEntry(1.0, newRow, col, entry, true); + // } + // matrixRow->resize(2); + // (*matrixRow)[0].col = row; + // (*matrixRow)[0].entry = 100.0;1.0; + // (*matrixRow)[1].col = newRow; + // (*matrixRow)[1].entry = -100.0;-1.0; + // } + // } + + + // --- method 2 --- + + // for(matrixRow.reset(); !matrixRow.end(); ++matrixRow) { + // row = matrixRow.getDOFIndex(); + // newRow = ((*associated_)[row] == -1) ? row : (*associated_)[row]; + // if(row < newRow) { + // // remember old row matrix[row] + // ::std::vector<MatEntry> oldMatrixRow = *matrixRow; + // // add new row to old row + // ::std::vector<MatEntry> &newMatrixRow = matrix->getRow(newRow); + // rowSize = newMatrixRow.size(); + // for(i = 0; i < rowSize; i++) { + // col = newMatrixRow[i].col; + // if(col == DOFMatrix::NO_MORE_ENTRIES) break; + // if(col == DOFMatrix::UNUSED_ENTRY) continue; + // newCol = ((*associated_)[col] == -1) ? col : (*associated_)[col]; + // entry = newMatrixRow[i].entry; + // matrix->addSparseDOFEntry(1.0, row, newCol, entry, true); + // } + // // add old row to new row + // rowSize = oldMatrixRow.size(); + // for(i = 0; i < rowSize; i++) { + // col = oldMatrixRow[i].col; + // if(col == DOFMatrix::NO_MORE_ENTRIES) break; + // if(col == DOFMatrix::UNUSED_ENTRY) continue; + // newCol = ((*associated_)[col] == -1) ? col : (*associated_)[col]; + // entry = oldMatrixRow[i].entry; + // matrix->addSparseDOFEntry(1.0, newRow, newCol, entry, true); + // } + // } + // } + + + // DOFVector<DegreeOfFreedom>::Iterator rowIt(associated_, USED_DOFS); + // DOFVector<DegreeOfFreedom>::Iterator colIt(associated_, USED_DOFS); + + + // Mesh *mesh = matrix->getRowFESpace()->getMesh(); + + using namespace mtl; + + // Compute reorder matrix (newRow and newCol yields transposed!!!) + matrix::traits::reorder<>::type R= matrix::reorder(*associated_); + DOFMatrix::base_matrix_type &A= matrix->getBaseMatrix(), B, D, E, TR; + + A*= 0.5; + // Half of entries with decreased row index + half of the strict lower origing + B= strict_upper(R) * A + strict_lower(A); + // Add half of entries with same row and decreased column index + half of increased columns + // Remark regarding column permutation: trans(strict_upper(trans(X))) == strict_lower(X) + // B+= bands(trans(R), 0, 1) * (A * strict_lower(R) + lower(A)); -> make this work one day!!! + TR= trans(R); + D= bands(TR, 0, 1); + E= A * strict_lower(R) + lower(A); + B+= D * E; + swap(A, B); + +#if 0 // The matrix operations above should be identical with the code below + + ::std::vector< ::std::vector<MatEntry> >::iterator rowIt; + ::std::vector< ::std::vector<MatEntry> >::iterator rowEnd = matrix->end(); int colIndex, rowSize; int row, col, newRow, newCol; double entry, *newEntryPtr; - for (rowIt = matrix->begin(), row = 0; rowIt != rowEnd; ++rowIt, ++row) { + for(rowIt = matrix->begin(), row = 0; rowIt != rowEnd; ++rowIt, ++row) { rowSize = static_cast<int>(rowIt->size()); newRow = (*associated_)[row]; - for (colIndex = 0; colIndex < rowSize; colIndex++) { + for(colIndex = 0; colIndex < rowSize; colIndex++) { col = (*rowIt)[colIndex].col; - if (col == DOFMatrix::UNUSED_ENTRY) - continue; - if (col == DOFMatrix::NO_MORE_ENTRIES) - break; + if(col == DOFMatrix::UNUSED_ENTRY) continue; + if(col == DOFMatrix::NO_MORE_ENTRIES) break; newCol = (*associated_)[col]; newEntryPtr = matrix->hasSparseDOFEntry(newRow, newCol); - if ((row < newRow) || - ((row == newRow) && (col < newCol)) || - !newEntryPtr) + if((row < newRow) || + ((row == newRow) && (col < newCol)) || + !newEntryPtr) { - if (!newEntryPtr) { + if(!newEntryPtr) { entry = 0.5 * (*rowIt)[colIndex].entry; (*rowIt)[colIndex].entry = entry; matrix->addSparseDOFEntry(1.0, newRow, newCol, entry, false); @@ -236,6 +363,9 @@ namespace AMDiS { } } } +#endif + + //MSG("end exitMatrix...\n"); } void PeriodicBC::exitVector(DOFVectorBase<double>* vector) @@ -252,17 +382,29 @@ namespace AMDiS { Mesh *mesh = vector->getFESpace()->getMesh(); VertexVector *associated_ = mesh->getPeriodicAssociations()[boundaryType]; - for (vecIt.reset(); !vecIt.end(); ++vecIt) { + for(vecIt.reset(); !vecIt.end(); ++vecIt) { dof = vecIt.getDOFIndex(); newDOF = (*associated_)[dof]; - if (dof < newDOF) { + if(dof < newDOF) { + // ---------- different assemblage style -------- + // (*vector)[newDOF] += (*vector)[dof]; + // (*vector)[dof] = 0.0; + + + // --- method 2 ---- + // //entry = (*vector)[dof]; + // (*vector)[dof] += (*vector)[newDOF]; + // (*vector)[newDOF] = (*vector)[dof]; + entry = ((*vector)[dof] + (*vector)[newDOF]) * 0.5; (*vector)[dof] = entry; (*vector)[newDOF] = entry; } } + + //MSG("end exitVector...\n"); } } diff --git a/AMDiS/src/PeriodicBC.h b/AMDiS/src/PeriodicBC.h index bdbbe143..baa592d6 100644 --- a/AMDiS/src/PeriodicBC.h +++ b/AMDiS/src/PeriodicBC.h @@ -22,6 +22,7 @@ #ifndef AMDIS_PERIODICBC_H #define AMDIS_PERIODICBC_H +#include "AMDiS_fwd.h" #include "BoundaryCondition.h" #include "MemoryManager.h" #include "FixVec.h" @@ -30,12 +31,6 @@ namespace AMDiS { - class ElInfo; - class DOFMatrix; - class BasisFunction; - class VertexVector; - class LeafDataPeriodic; - template<typename T> class DimVecLess { diff --git a/AMDiS/src/Preconditioner.h b/AMDiS/src/Preconditioner.h deleted file mode 100644 index 32fe39ee..00000000 --- a/AMDiS/src/Preconditioner.h +++ /dev/null @@ -1,299 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file Preconditioner.h */ - -#ifndef AMDIS_PRECONDITIONER_H -#define AMDIS_PRECONDITIONER_H - -#include <vector> - -#include "DOFVector.h" -#include "MatrixVector.h" -#include "SystemVector.h" -#include <string> - -namespace AMDiS { - - // ============================================================================ - // ===== class Preconditioner ================================================= - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Pure virtual base class for all preconditioners. - * A Preconditioner is used by an OEMSolver before solving the linear system to - * reduce the number of needed iterations. - */ - template<typename Vector> - class Preconditioner - { - public: - /** \brief - * Destructor. - */ - virtual ~Preconditioner() {}; - - /** \brief - * Initialisation of the preconditioner - */ - virtual void init() = 0; - - /** \brief - * Precondition function which should be implemented. - */ - virtual void precon(Vector *x) = 0; - - /** \brief - * Frees needed memory. - */ - virtual void exit() = 0; - }; - - // ============================================================================ - // ===== class PreconditionerScal ============================================= - // ============================================================================ - - /** - * \ingroup Solver - * - * Base class for DOFVector preconditioners. - */ - class PreconditionerScal : public Preconditioner<DOFVector<double> > - { - public: - /** \brife - * Constructor. - */ - PreconditionerScal(int numSystems = 1, int r = 0) - : matrix(numSystems), - bound(NULL), - row(r) - { - TEST_EXIT(r < numSystems)("r must be smaller than numSystems\n"); - matrix.set(NULL); - }; - - /** \brief - * Sets \ref matrix. - */ - inline void setMatrix(DOFMatrix **m, int system = 0) { - TEST_EXIT(system < matrix.getSize())("invalid system number\n"); - matrix[system] = m; - }; - - /** \brief - * Sets \ref bound. - */ - inline void setBound(DOFVector<BoundaryType> *b) { - bound = b; - }; - - protected: - /** \brief - * Matrix used for preconditioning. - */ - Vector<DOFMatrix**> matrix; - - /** \brief - * Boundary vector - */ - DOFVector<BoundaryType> *bound; - - /** \brief - * Row of the component in vector valued problems. - */ - int row; - }; - - - - // ============================================================================ - // ===== class PreconditionerScalStd ========================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * Base class for DOFVector preconditioners. - */ - class PreconditionerScalStd : public Preconditioner< std::vector<double> > - { - public: - /** \brife - * Constructor. - */ - PreconditionerScalStd() - {}; - - /** \brief - * Sets \ref matrix. - */ - inline void setMatrix(std::vector< std::vector<MatEntry> > *m) { - matrix = m; - }; - - protected: - /** \brief - * Matrix used for preconditioning. - */ - - std::vector< std::vector<MatEntry> > *matrix; - }; - - - // ============================================================================ - // ===== PreconditionerScalCreator ============================================ - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Interface for creators of concrete scalar preconditioners. - */ - class PreconditionerScalCreator - : public CreatorInterface<PreconditionerScal> - { - public: - PreconditionerScalCreator() - : size(1), row(0) - {}; - - virtual ~PreconditionerScalCreator() {}; - - /** \brief - * Sets \ref problem - */ - void setSizeAndRow(int size_, int row_) { - size = size_; - row = row_; - }; - - /** \brief - * Sets \ref problem - */ - void setName(std::string name) { - name_ = name; - }; - - protected: - int size; - int row; - - std::string name_; - }; - - - - // ============================================================================ - // ===== class PreconditionerVec ============================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - * Base class for vector valued preconditioners. - */ - class PreconditionerVec : public Preconditioner<SystemVector> - { - public: - MEMORY_MANAGED(PreconditionerVec); - - /** \brief - * Constructor. - */ - PreconditionerVec(int numSystems) - : scalPrecons(numSystems) - { - scalPrecons.set(NULL); - }; - - /** \brief - * Destructor. - */ - virtual ~PreconditionerVec() {}; - - /** \brief - * Initialisation of the preconditioner - */ - virtual void init() { - int i; - int size = scalPrecons.getSize(); - -#ifdef _OPENMP -#pragma omp parallel for num_threads(min(size, omp_get_max_threads())) -#endif - for (i = 0; i < size; i++) { - scalPrecons[i]->init(); - } - }; - - /** \brief - * Preconditioning method - */ - virtual void precon(SystemVector *x) { - int i; - int size = scalPrecons.getSize(); -#ifdef _OPENMP -#pragma omp parallel for num_threads(min(size, omp_get_max_threads())) -#endif - for (i = 0; i < size; i++) { - scalPrecons[i]->precon(x->getDOFVector(i)); - } - }; - - /** \brief - * Frees needed memory. - */ - virtual void exit() { - int size = scalPrecons.getSize(); - for (int i = 0; i < size; i++) { - scalPrecons[i]->exit(); - } - }; - - /** \brief - * Sets scalar preconditioner for system i. - */ - inline void setScalarPrecon(int i, PreconditionerScal *p) { - scalPrecons[i] = p; - }; - - /** \brief - * Gets i-th scalar preconditioner. - */ - inline PreconditionerScal *getScalarPrecon(int i) { - return scalPrecons[i]; - }; - - protected: - /** \brief - * Scalar Preconditioners. - */ - Vector<PreconditionerScal*> scalPrecons; - }; - -} - -#endif // AMDIS_PRECONDITIONER_H - diff --git a/AMDiS/src/ProblemNonLin.cc b/AMDiS/src/ProblemNonLin.cc index 2c0e672a..6840800d 100644 --- a/AMDiS/src/ProblemNonLin.cc +++ b/AMDiS/src/ProblemNonLin.cc @@ -5,6 +5,7 @@ #include "Traverse.h" #include "AdaptInfo.h" +#if 0 namespace AMDiS { void ProblemNonLinScal::initialize(Flag initFlag, @@ -56,6 +57,7 @@ namespace AMDiS { void ProblemNonLinScal::createNonLinSolver() { // create non-linear solver +#if 0 std::string nonLinSolverType("no"); GET_PARAMETER(0, name + "->nonlin solver", &nonLinSolverType); @@ -68,13 +70,16 @@ namespace AMDiS { nonLinSolverCreator->setNonLinUpdater(updater_); nonLinSolver_ = nonLinSolverCreator->create(); nonLinSolver_->setVectorCreator(NEW DOFVector<double>::Creator(feSpace)); +#endif } void ProblemNonLinScal::solve(AdaptInfo *adaptInfo) { +#if 0 TEST_EXIT(nonLinSolver_)("no non-linear solver!\n"); int iter = nonLinSolver_->solve(matVec, solution, rhs, leftPrecon, rightPrecon); adaptInfo->setSolverIterations(iter); +#endif } @@ -145,6 +150,7 @@ namespace AMDiS { void ProblemNonLinVec::createNonLinSolver() { +#if 0 // create non-linear solver std::string nonLinSolverType("no"); @@ -160,6 +166,7 @@ namespace AMDiS { nonLinSolver_->setVectorCreator(NEW SystemVector::Creator("temp", componentSpaces, nComponents)); +#endif } @@ -206,3 +213,4 @@ namespace AMDiS { } } +#endif diff --git a/AMDiS/src/ProblemNonLin.h b/AMDiS/src/ProblemNonLin.h index 2c2c8b49..14045706 100644 --- a/AMDiS/src/ProblemNonLin.h +++ b/AMDiS/src/ProblemNonLin.h @@ -30,6 +30,8 @@ #include "SystemVector.h" #include "MatrixVector.h" +#if 0 + namespace AMDiS { template<typename Vector> class NonLinSolver; @@ -267,5 +269,7 @@ namespace AMDiS { } +#endif + #endif diff --git a/AMDiS/src/ProblemScal.cc b/AMDiS/src/ProblemScal.cc index 08603d8b..84fdbb30 100644 --- a/AMDiS/src/ProblemScal.cc +++ b/AMDiS/src/ProblemScal.cc @@ -11,7 +11,6 @@ #include "FiniteElemSpace.h" #include "Estimator.h" #include "OEMSolver.h" -#include "Preconditioner.h" #include "MatVecMultiplier.h" #include "DOFVector.h" #include "Marker.h" @@ -24,6 +23,7 @@ #include "PeriodicBC.h" #include "ValueReader.h" #include "ElementFileWriter.h" +#include "ProblemVec.h" namespace AMDiS { @@ -47,10 +47,6 @@ namespace AMDiS { DELETE marker; if (solver) DELETE solver; - if (leftPrecon) - DELETE leftPrecon; - if (rightPrecon) - DELETE rightPrecon; if (mesh) DELETE mesh; @@ -195,7 +191,6 @@ namespace AMDiS { } } - void ProblemScal::setMeshFromProblemVec(ProblemVec* pv, int i) { mesh = pv->getMesh(i); @@ -203,7 +198,6 @@ namespace AMDiS { refinementManager = pv->getRefinementManager(i); } - Flag ProblemScal::markElements(AdaptInfo *adaptInfo) { if (marker) @@ -214,13 +208,11 @@ namespace AMDiS { return 0; } - Flag ProblemScal::refineMesh(AdaptInfo *adaptInfo) { return refinementManager->refineMesh(mesh); } - Flag ProblemScal::coarsenMesh(AdaptInfo *adaptInfo) { if (adaptInfo->isCoarseningAllowed(0)) { @@ -244,7 +236,10 @@ namespace AMDiS { #endif clock_t first = clock(); - int iter = solver->solve(matVec, solution, rhs, leftPrecon, rightPrecon); + + SolverMatrix<DOFMatrix> solverMatrix; + solverMatrix.setMatrix(*systemMatrix); + int iter = solver->solveSystem(solverMatrix, *solution, *rhs); #ifdef _OPENMP INFO(info, 8)("solution of discrete system needed %.5f seconds system time / %.5f seconds wallclock time\n", @@ -271,13 +266,13 @@ namespace AMDiS { if (mesh) { WARNING("mesh already created\n"); } else { - if (initFlag.isSet(CREATE_MESH) || + if(initFlag.isSet(CREATE_MESH) || ((!adoptFlag.isSet(INIT_MESH))&& (initFlag.isSet(INIT_SYSTEM)||initFlag.isSet(INIT_FE_SPACE)))) { createMesh(); } - if (adoptProblem && + if(adoptProblem && (adoptFlag.isSet(INIT_MESH) || adoptFlag.isSet(INIT_SYSTEM) || adoptFlag.isSet(INIT_FE_SPACE))) { @@ -299,6 +294,7 @@ namespace AMDiS { (initFlag.isSet(INIT_SYSTEM) && !adoptFlag.isSet(INIT_FE_SPACE))) { createFESpace(); } + if (adoptProblem && (adoptFlag.isSet(INIT_FE_SPACE) || adoptFlag.isSet(INIT_SYSTEM))) { TEST_EXIT(!feSpace)("feSpace already created"); @@ -358,10 +354,10 @@ namespace AMDiS { if (marker) { WARNING("marker already created\n"); } else { - if (initFlag.isSet(INIT_MARKER)) { + if(initFlag.isSet(INIT_MARKER)) { createMarker(); } - if (adoptProblem && adoptFlag.isSet(INIT_MARKER)) { + if(adoptProblem && adoptFlag.isSet(INIT_MARKER)) { TEST_EXIT(!marker)("marker already created\n"); marker = adoptProblem->getMarker(); } @@ -371,7 +367,7 @@ namespace AMDiS { WARNING("no marker created\n"); // === create file writer === - if (initFlag.isSet(INIT_FILEWRITER)) { + if(initFlag.isSet(INIT_FILEWRITER)) { createFileWriter(); } @@ -418,7 +414,7 @@ namespace AMDiS { mesh->getMacroFileInfo()); mesh->clearMacroFileInfo(); } - + // === do global refinements === if (initFlag.isSet(INIT_GLOBAL_REFINES)) { int globalRefinements = 0; @@ -466,50 +462,12 @@ namespace AMDiS { // === create solver === std::string solverType("no"); GET_PARAMETER(0, name + "->solver", &solverType); - OEMSolverCreator<DOFVector<double> > *solverCreator = - dynamic_cast<OEMSolverCreator<DOFVector<double> >*>(CreatorMap<OEMSolver<DOFVector<double> > >::getCreator(solverType)); + OEMSolverCreator *solverCreator = + dynamic_cast<OEMSolverCreator*>(CreatorMap<OEMSolver>::getCreator(solverType)); TEST_EXIT(solverCreator)("no solver type\n"); solverCreator->setName(name + "->solver"); solver = solverCreator->create(); solver->initParameters(); - - // === create preconditioners === - std::string preconType("no"); - Preconditioner<DOFVector<double> > *precon; - GET_PARAMETER(0, name + "->solver->left precon", &preconType); - CreatorInterface<PreconditionerScal> *preconCreator = - CreatorMap<PreconditionerScal>::getCreator(preconType); - - if (!preconCreator->isNullCreator()) { - dynamic_cast<PreconditionerScalCreator*>(preconCreator)->setSizeAndRow(1, 0); - dynamic_cast<PreconditionerScalCreator*>(preconCreator)->setName(name + "->solver->left precon"); - } - - precon = preconCreator->create(); - - if (precon) { - dynamic_cast<PreconditionerScal*>(precon)->setMatrix(&systemMatrix); - leftPrecon = precon; - } - - preconType.assign("no"); - GET_PARAMETER(0, name + "->solver->right precon", &preconType); - preconCreator = CreatorMap<PreconditionerScal>::getCreator(preconType); - - if (!preconCreator->isNullCreator()) { - dynamic_cast<PreconditionerScalCreator*>(preconCreator)->setSizeAndRow(1, 0); - dynamic_cast<PreconditionerScalCreator*>(preconCreator)->setName(name + "->solver->left precon"); - } - - precon = preconCreator->create(); - if (precon) { - dynamic_cast<PreconditionerScal*>(precon)->setMatrix(&systemMatrix); - rightPrecon = precon; - } - - // === create vector creator === - solver->setVectorCreator(new DOFVector<double>::Creator(feSpace)); - } void ProblemScal::createEstimator() @@ -599,9 +557,24 @@ namespace AMDiS { if (useGetBound) assembleFlag |= Mesh::FILL_BOUND; - systemMatrix->clear(); + // systemMatrix->clear(); rhs->set(0.0); + DOFMatrix::base_matrix_type& base_matrix= systemMatrix->getBaseMatrix(); + + int nnz_per_row= 0; + if (num_rows(base_matrix) != 0) + nnz_per_row= int(double(base_matrix.nnz()) / num_rows(base_matrix) * 1.2); + if (nnz_per_row < 5) + nnz_per_row= 5; + + // Correct dimensionality of matrix + base_matrix.change_dim(feSpace->getAdmin()->getUsedSize(), + feSpace->getAdmin()->getUsedSize()); + + // Reuse old sparsity information (if available) or default + systemMatrix->startInsertion(nnz_per_row); + // fill boundary conditions if (systemMatrix->getBoundaryManager()) systemMatrix->getBoundaryManager()->initMatrix(systemMatrix); @@ -648,6 +621,7 @@ namespace AMDiS { solution->getBoundaryManager()->exitVector(solution); INFO(info, 8)("buildAfterCoarsen needed %.5f seconds\n", TIME_USED(first,clock())); + systemMatrix->finishInsertion(); #ifdef HAVE_PARALLEL_AMDIS // PetscErrorCode ierr; @@ -656,6 +630,7 @@ namespace AMDiS { // ierr = MatCreate(PETSC_COMM_WORLD, &A); CHKERRQ(ierr); #endif + createPrecon(); } void ProblemScal::writeResidualMesh(AdaptInfo *adaptInfo, const std::string name) @@ -676,6 +651,23 @@ namespace AMDiS { fw.writeFiles(adaptInfo, true); } + void ProblemScal::createPrecon() + { + ::std::string preconType("no"); + GET_PARAMETER(0, name + "->solver->left precon", &preconType); + + CreatorInterface<ITL_BasePreconditioner> *preconCreator = + CreatorMap<ITL_BasePreconditioner>::getCreator(preconType); + + solver->setLeftPrecon( preconCreator->create(systemMatrix->getBaseMatrix()) ); + + preconType= "no"; + GET_PARAMETER(0, name + "->solver->right precon", &preconType); + + preconCreator = CreatorMap<ITL_BasePreconditioner>::getCreator(preconType); + solver->setRightPrecon( preconCreator->create(systemMatrix->getBaseMatrix()) ); + } + void ProblemScal::serialize(std::ostream &out) { FUNCNAME("ProblemScal::serialize()"); diff --git a/AMDiS/src/ProblemScal.h b/AMDiS/src/ProblemScal.h index 3b6cd776..4efc76a2 100644 --- a/AMDiS/src/ProblemScal.h +++ b/AMDiS/src/ProblemScal.h @@ -24,6 +24,7 @@ #include <list> +#include "AMDiS_fwd.h" #include "Global.h" #include "ProblemStatBase.h" #include "MemoryManager.h" @@ -31,7 +32,6 @@ #include "FixVec.h" #include "Boundary.h" #include "StandardProblemIteration.h" -#include "ProblemVec.h" #ifdef HAVE_PARALLEL_AMDIS #include "petscao.h" @@ -39,20 +39,7 @@ namespace AMDiS { - class Operator; - class DOFMatrix; - class FiniteElemSpace; - class Estimator; - template<typename T> class OEMSolver; - template<typename T> class Preconditioner; - template<typename T> class MatVecMultiplier; - template<typename T> class DOFVector; - class Marker; - class AdaptInfo; - class ElInfo; - class FileWriterInterface; - class RefinementManager; - class CoarseningManager; + class ProblemScal : public ProblemStatBase, public StandardProblemIteration @@ -73,8 +60,6 @@ namespace AMDiS { rhs(NULL), systemMatrix(NULL), matVec(NULL), - leftPrecon(NULL), - rightPrecon(NULL), useGetBound(true), refinementManager(NULL), coarseningManager(NULL), @@ -155,6 +140,8 @@ namespace AMDiS { */ virtual void buildBeforeCoarsen(AdaptInfo *adaptInfo, Flag) {} + void createPrecon(); + /** \brief * Implementation of ProblemStatBase::buildAfterCoarsen(). * Assembles \ref A and \ref rhs. @@ -268,7 +255,7 @@ namespace AMDiS { } /// Returns \ref solver. - inline OEMSolver<DOFVector<double> >* getSolver() { + inline OEMSolver* getSolver() { return solver; } @@ -287,16 +274,6 @@ namespace AMDiS { return useGetBound; } - /// Returns \ref leftPrecon. - inline Preconditioner<DOFVector<double> > *getLeftPrecon() { - return leftPrecon; - } - - /// Returns \ref rightPrecon. - inline Preconditioner<DOFVector<double> > *getRightPrecon() { - return rightPrecon; - } - /// inline CoarseningManager *getCoarseningManager() { return coarseningManager; @@ -324,20 +301,10 @@ namespace AMDiS { } /// Sets \ref solver. - inline void setSolver(OEMSolver<DOFVector<double> >* sol) { + inline void setSolver(OEMSolver* sol) { solver = sol; } - /// Sets \ref leftPrecon. - inline void setLeftPrecon(Preconditioner<DOFVector<double> > *p) { - leftPrecon = p; - } - - /// Sets \ref rightPrecon. - inline void setRightPrecon(Preconditioner<DOFVector<double> > *p) { - rightPrecon = p; - } - /// Sets \ref marker. inline void setMarker(Marker *m) { marker = m; @@ -374,7 +341,7 @@ namespace AMDiS { Estimator *estimator; /// Linear solver of this problem. Used in \ref solve(). - OEMSolver<DOFVector<double> > *solver; + OEMSolver *solver; /// DOFVector storing the calculated solution of the problem. DOFVector<double> *solution; @@ -388,12 +355,6 @@ namespace AMDiS { /// Matrix-vector multiplication MatVecMultiplier<DOFVector<double> > *matVec; - /// Left preconditioner. Used in \ref solver. - Preconditioner<DOFVector<double> > *leftPrecon; - - /// Right preconditioner. Used in \ref solver. - Preconditioner<DOFVector<double> > *rightPrecon; - /// Determines whether domain boundaries should be considered at assembling. bool useGetBound; diff --git a/AMDiS/src/ProblemStatBase.h b/AMDiS/src/ProblemStatBase.h index 12d9633c..4d5f704e 100644 --- a/AMDiS/src/ProblemStatBase.h +++ b/AMDiS/src/ProblemStatBase.h @@ -44,7 +44,7 @@ namespace AMDiS { const Flag INIT_ADAPT = 0X80L; const Flag INIT_FILEWRITER = 0X100L; const Flag INIT_GLOBAL_REFINES = 0X1000L; - + // For time dependent problems const Flag INIT_INITIAL_PROBLEM = 0X200L; const Flag INIT_UH_OLD = 0X400L; @@ -58,8 +58,7 @@ namespace AMDiS { const Flag INIT_ALL = INIT_FE_SPACE | INIT_MESH | CREATE_MESH | INIT_SYSTEM | INIT_SOLVER | INIT_ESTIMATOR | INIT_MARKER | INIT_ADAPT | INIT_FILEWRITER | INIT_INITIAL_PROBLEM | - INIT_UH_OLD | INIT_UPDATER | INIT_NONLIN_SOLVER | - INIT_GLOBAL_REFINES ; + INIT_UH_OLD | INIT_UPDATER | INIT_NONLIN_SOLVER ; const Flag MESH_REFINED = 1; const Flag MESH_COARSENED = 2; diff --git a/AMDiS/src/ProblemVec.cc b/AMDiS/src/ProblemVec.cc index 51e6c431..0467afe8 100644 --- a/AMDiS/src/ProblemVec.cc +++ b/AMDiS/src/ProblemVec.cc @@ -17,7 +17,6 @@ #include "DualTraverse.h" #include "Mesh.h" #include "OEMSolver.h" -#include "Preconditioner.h" #include "MatVecMultiplier.h" #include "DirichletBC.h" #include "RobinBC.h" @@ -353,73 +352,12 @@ namespace AMDiS { // === create solver === std::string solverType("no"); GET_PARAMETER(0, name + "->solver", &solverType); - OEMSolverCreator<SystemVector> *solverCreator = - dynamic_cast<OEMSolverCreator<SystemVector>*>( - CreatorMap<OEMSolver<SystemVector> > - ::getCreator(solverType) - ); + OEMSolverCreator *solverCreator = + dynamic_cast<OEMSolverCreator*>(CreatorMap<OEMSolver>::getCreator(solverType)); TEST_EXIT(solverCreator)("no solver type\n"); solverCreator->setName(name + "->solver"); solver = solverCreator->create(); solver->initParameters(); - - // === create preconditioners === - std::string preconType("no"); - - PreconditionerScal *scalPrecon; - PreconditionerVec *vecPrecon = NEW PreconditionerVec(nComponents); - - GET_PARAMETER(0, name + "->solver->left precon", &preconType); - CreatorInterface<PreconditionerScal> *preconCreator = - CreatorMap<PreconditionerScal>::getCreator(preconType); - - if (!preconCreator->isNullCreator()) { - dynamic_cast<PreconditionerScalCreator*>(preconCreator)-> - setName(name + "->solver->left precon"); - - for (int i = 0; i < nComponents; i++) { - dynamic_cast<PreconditionerScalCreator*>(preconCreator)-> - setSizeAndRow(nComponents, i); - - scalPrecon = preconCreator->create(); - for (int j = 0; j < nComponents; j++) { - scalPrecon->setMatrix(&(*systemMatrix)[i][j], j); - } - vecPrecon->setScalarPrecon(i, scalPrecon); - } - leftPrecon = vecPrecon; - } - - - vecPrecon = NEW PreconditionerVec(nComponents); - - GET_PARAMETER(0, name + "->solver->right precon", &preconType); - preconCreator = - CreatorMap<PreconditionerScal>::getCreator(preconType); - - if (!preconCreator->isNullCreator()) { - dynamic_cast<PreconditionerScalCreator*>(preconCreator)-> - setName(name + "->solver->left precon"); - - - for (int i = 0; i < nComponents; i++) { - dynamic_cast<PreconditionerScalCreator*>(preconCreator)-> - setSizeAndRow(nComponents, i); - - scalPrecon = preconCreator->create(); - for (int j = 0; j < nComponents; j++) { - scalPrecon->setMatrix(&(*systemMatrix)[i][j], j); - } - vecPrecon->setScalarPrecon(i, scalPrecon); - } - rightPrecon = vecPrecon; - } - - - // === create vector creator === - solver->setVectorCreator(NEW SystemVector::Creator("temp", - componentSpaces, - nComponents)); } void ProblemVec::createEstimator() @@ -565,8 +503,8 @@ namespace AMDiS { #endif clock_t first = clock(); - int iter = solver->solve(matVec, solution, rhs, leftPrecon, rightPrecon, fixedMatrix); - + int iter = solver->solveSystem(solverMatrix, *solution, *rhs); + #ifdef _OPENMP INFO(info, 8)("solution of discrete system needed %.5f seconds system time / %.5f seconds wallclock time\n", TIME_USED(first, clock()), omp_get_wtime() - wtime); @@ -731,11 +669,21 @@ namespace AMDiS { rhs->getDOFVector(i)->set(0.0); for (int j = 0; j < nComponents; j++) { if ((*systemMatrix)[i][j]) { - // The matrix should not be deleted, if it was assembled before - // and it is marked to be assembled only once. - if (!(assembleMatrixOnlyOnce[i][j] && assembledMatrix[i][j]) && asmMatrix) { - (*systemMatrix)[i][j]->clear(); - } + DOFMatrix* dof_matrix= (*systemMatrix)[i][j]; + DOFMatrix::base_matrix_type& base_matrix= dof_matrix->getBaseMatrix(); + + int nnz_per_row= 0; + if (num_rows(base_matrix) != 0) + nnz_per_row= int(double(base_matrix.nnz()) / num_rows(base_matrix) * 1.2); + if (nnz_per_row < 5) + nnz_per_row= 5; + + // Correct dimensionality of matrix + base_matrix.change_dim(componentSpaces[i]->getAdmin()->getUsedSize(), + componentSpaces[j]->getAdmin()->getUsedSize()); + + // Reuse old sparsity information (if available) or default + dof_matrix->startInsertion(nnz_per_row); } } } @@ -854,6 +802,15 @@ namespace AMDiS { assembleFlag); } + // Finish insertion + for (int i = 0; i < nComponents; i++) + for (int j = 0; j < nComponents; j++) + if ((*systemMatrix)[i][j]) + (*systemMatrix)[i][j]->finishInsertion(); + + solverMatrix.setMatrix(*systemMatrix); + createPrecon(); + #ifdef _OPENMP INFO(info, 8)("buildAfterCoarsen needed %.5f seconds system time / %.5f seconds wallclock time\n", TIME_USED(first, clock()), omp_get_wtime() - wtime); @@ -863,6 +820,24 @@ namespace AMDiS { #endif } + void ProblemVec::createPrecon() + { + ::std::string preconType("no"); + GET_PARAMETER(0, name + "->solver->left precon", &preconType); + + CreatorInterface<ITL_BasePreconditioner> *preconCreator = + CreatorMap<ITL_BasePreconditioner>::getCreator(preconType); + + solver->setLeftPrecon( preconCreator->create(solverMatrix.getMatrix()) ); + + preconType= "no"; + GET_PARAMETER(0, name + "->solver->right precon", &preconType); + + preconCreator = CreatorMap<ITL_BasePreconditioner>::getCreator(preconType); + solver->setRightPrecon( preconCreator->create(solverMatrix.getMatrix()) ); + } + + void ProblemVec::writeFiles(AdaptInfo *adaptInfo, bool force) { FUNCNAME("ProblemVec::writeFiles()"); @@ -965,10 +940,8 @@ namespace AMDiS { (*systemMatrix)[system][i]->getBoundaryManager()->addBoundaryCondition(dirichlet); } } - if (rhs) rhs->getDOFVector(system)->getBoundaryManager()->addBoundaryCondition(dirichlet); - if (solution) solution->getDOFVector(system)->getBoundaryManager()->addBoundaryCondition(dirichlet); } @@ -1052,6 +1025,10 @@ namespace AMDiS { // values have to be set to zero. *tmpMatrix = *matrix; tmpMatrix->clear(); + + tmpMatrix->getBaseMatrix().change_dim(matrix->getRowFESpace()->getAdmin()->getUsedSize(), + matrix->getColFESpace()->getAdmin()->getUsedSize()); + tmpMatrix->startInsertion(); } if (vector) { @@ -1097,6 +1074,8 @@ namespace AMDiS { elInfo = stack.traverseNext(elInfo); } + tmpMatrix->finishInsertion(); + // After mesh traverse, all thread have to added their private matrices and // vectors to the global public matrix and public vector. Therefore, this is // a critical section, which is allowed to be executed by on thread only at @@ -1107,7 +1086,7 @@ namespace AMDiS { #pragma omp critical #endif { - addDOFMatrix(matrix, tmpMatrix); + matrix->getBaseMatrix() += tmpMatrix->getBaseMatrix(); // Remove rows corresponding to DOFs on a Dirichlet boundary. matrix->removeRowsWithDBC(tmpMatrix->getApplyDBCs()); diff --git a/AMDiS/src/ProblemVec.h b/AMDiS/src/ProblemVec.h index de21bbd3..e1cae1eb 100644 --- a/AMDiS/src/ProblemVec.h +++ b/AMDiS/src/ProblemVec.h @@ -25,6 +25,7 @@ #include <vector> #include <list> +#include "AMDiS_fwd.h" #include "ProblemStatBase.h" #include "Parameters.h" #include "Boundary.h" @@ -32,26 +33,11 @@ #include "StandardProblemIteration.h" #include "ElementFileWriter.h" #include "ComponentTraverseInfo.h" +#include "AbstractFunction.h" +#include "SolverMatrix.h" namespace AMDiS { - template<typename t1, typename t2> class AbstractFunction; - class Operator; - class SystemVector; - class DOFMatrix; - class FiniteElemSpace; - class Estimator; - class Marker; - class AdaptStationary; - class AdaptInfo; - class FileWriterInterface; - class CoarseningManager; - class RefinementManager; - class Mesh; - template<typename T> class OEMSolver; - template<typename T> class Preconditioner; - template<typename T> class MatVecMultiplier; - class ProblemVec : public ProblemStatBase, public StandardProblemIteration { @@ -71,8 +57,6 @@ namespace AMDiS { rhs(NULL), systemMatrix(NULL), matVec(NULL), - leftPrecon(NULL), - rightPrecon(NULL), useGetBound(true), info(10), allowFirstRef(false), @@ -80,7 +64,6 @@ namespace AMDiS { { GET_PARAMETER(0, name + "->components", "%d", &nComponents); TEST_EXIT(nComponents > 0)("components not set!\n"); - estimator.resize(nComponents, NULL); marker.resize(nComponents, NULL); @@ -182,6 +165,9 @@ namespace AMDiS { bool assembleMatrix = true, bool assembleVector = true); + void createPrecon(); + + /** \brief * Determines the execution order of the single adaption steps. If adapt is * true, mesh adaption will be performed. This allows to avoid mesh adaption, @@ -352,7 +338,7 @@ namespace AMDiS { } /// Returns \ref solver. - inline OEMSolver<SystemVector>* getSolver() { + inline OEMSolver* getSolver() { return solver; } @@ -376,16 +362,6 @@ namespace AMDiS { return useGetBound; } - /// Returns \ref leftPrecon. - inline Preconditioner<SystemVector> *getLeftPrecon() { - return leftPrecon; - } - - /// Returns \ref rightPrecon. - inline Preconditioner<SystemVector> *getRightPrecon() { - return rightPrecon; - } - /** \} */ // ===== setting-methods ====================================================== @@ -415,20 +391,10 @@ namespace AMDiS { } /// Sets \ref solver. - inline void setSolver(OEMSolver<SystemVector>* sol) { + inline void setSolver(OEMSolver* sol) { solver = sol; } - /// Sets \ref leftPrecon. - inline void setLeftPrecon(Preconditioner<SystemVector> *p) { - leftPrecon = p; - } - - /// Sets \ref rightPrecon. - inline void setRightPrecon(Preconditioner<SystemVector> *p) { - rightPrecon = p; - } - /// inline void setAssembleMatrixOnlyOnce(int i, int j, bool value = true) { assembleMatrixOnlyOnce[i][j] = value; @@ -520,7 +486,7 @@ namespace AMDiS { std::vector<Estimator*> estimator; /// Linear solver of this problem. Used in \ref solve(). - OEMSolver<SystemVector> *solver; + OEMSolver *solver; /// System vector storing the calculated solution of the problem. SystemVector *solution; @@ -531,6 +497,9 @@ namespace AMDiS { /// System matrix Matrix<DOFMatrix*> *systemMatrix; + /// Composed system matrix + SolverMatrix<Matrix<DOFMatrix*> > solverMatrix; + /** \brief * Some DOFMatrices of the systemMatrix may be assembled only once (for * example if they are independent of the time or older solutions). If @@ -551,12 +520,6 @@ namespace AMDiS { /// Matrix-vector multiplication MatVecMultiplier<SystemVector> *matVec; - /// Left preconditioner. Used in \ref solver. - Preconditioner<SystemVector> *leftPrecon; - - /// Right preconditioner. Used in \ref solver. - Preconditioner<SystemVector> *rightPrecon; - /// Determines whether domain boundaries should be considered at assembling. bool useGetBound; diff --git a/AMDiS/src/QN_Precond.h b/AMDiS/src/QN_Precond.h deleted file mode 100755 index edc038d0..00000000 --- a/AMDiS/src/QN_Precond.h +++ /dev/null @@ -1,26 +0,0 @@ -/** \file QN_Precond.h */ - -#ifndef QN_PRECOND_H -#define QN_PRECOND_H - -#include "DOFVector.h" - -namespace AMDiS -{ - - template<typename T> - void diagPrecond(const DOFMatrix *A, DOFVector<T>* vec, - DOFVector<BoundaryType> *bound = NULL); - - template<typename T> - void aXpY(double a, const DOFVector<T>& x, DOFVector<T>& y, - DOFVector<BoundaryType> *bound = NULL); - - template<typename T> - void XpaY(double a, const DOFVector<T>& x, DOFVector<T>& y, - DOFVector<BoundaryType> *bound = NULL); - -} - -#include "QN_Precond.hh" -#endif // QN_PRECOND_H diff --git a/AMDiS/src/QN_Precond.hh b/AMDiS/src/QN_Precond.hh deleted file mode 100755 index 5bb4a35e..00000000 --- a/AMDiS/src/QN_Precond.hh +++ /dev/null @@ -1,141 +0,0 @@ -#include "DOFVector.h" - -namespace AMDiS -{ - - template<typename T> - void diagPrecond(DOFMatrix *A, DOFVector<T> *vec, - DOFVector<BoundaryType> *bound) - { - FUNCNAME("QN_Precond::diagPrecond()"); - - TEST(A)("No matrix; doing nothing\n"); - - DOFMatrix::Iterator rowIterator(A, USED_DOFS); - typename DOFVector<T>::Iterator vecIterator(vec, USED_DOFS); - - if (bound) { - DOFVector<BoundaryType>::Iterator - bIterator(const_cast<DOFVector<BoundaryType>*>(bound), USED_DOFS); - - for (vecIterator.reset(), rowIterator.reset(), bIterator.reset(); - !vecIterator.end(); ++vecIterator, ++bIterator, ++rowIterator) - { - // only non-dirichlet nodes will be preconditioned - if ((*bIterator) <= 0 && rowIterator->size() != 0) - (*vecIterator) *= (1.0 / (*rowIterator)[0].entry); - } - } else { - for (vecIterator.reset(), rowIterator.reset(); !vecIterator.end(); - ++vecIterator, ++rowIterator) - { - if (rowIterator->size() != 0) - (*vecIterator) *= (1.0 / (*rowIterator)[0].entry); - } - } - - return; - } - - template<typename T> - void aXpY(double alpha, const DOFVector<T>& x, DOFVector<T>& y, - DOFVector<BoundaryType> *bound) - { - FUNCNAME("QN_Precond::aXpY()"); - const DOFAdmin *admin; - - TEST_EXIT(x.getFESpace() && y.getFESpace()) - ("feSpace is NULL: %8X, %8X\n", x.getFESpace(), y.getFESpace()); - TEST_EXIT((admin = x.getFESpace()->getAdmin()) && - (admin == y.getFESpace()->getAdmin())) - ("no admin or different admins: %8X, %8X\n", - x.getFESpace()->getAdmin(), y.getFESpace()->getAdmin()); - TEST_EXIT(static_cast<int>(x.getSize()) >= admin->getUsedSize()) - ("size = %d too small: admin->size = %d\n", x.getSize(), - admin->getUsedSize()); - TEST_EXIT(static_cast<int>(y.getSize()) >= admin->getUsedSize()) - ("y.size = %d too small: admin->size = %d\n", y.getSize(), - admin->getUsedSize()); - - typename DOFVector<T>::Iterator - xIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&x)), - USED_DOFS); - typename DOFVector<T>::Iterator yIterator(dynamic_cast<DOFIndexed<T>*>(&y), - USED_DOFS); - - if (bound) { - DOFVector<BoundaryType>::Iterator - bIterator(const_cast<DOFVector<BoundaryType>*>(bound), USED_DOFS); - - for (xIterator.reset(), yIterator.reset(), bIterator.reset(); - !xIterator.end(); - ++xIterator, ++yIterator, ++bIterator) - { - // only non-dirichlet nodes will be updated - if ((*bIterator) <= 0 ) - *yIterator += alpha * (*xIterator); - } - } else { - for (xIterator.reset(), yIterator.reset(); !xIterator.end(); - ++xIterator, ++yIterator) - { - *yIterator += alpha * (*xIterator); - } - } - - return; - } - - template<typename T> - void XpaY(double alpha, const DOFVector<T>& x, DOFVector<T>& y, - DOFVector<BoundaryType> *bound) - { - FUNCNAME("QN_Precond::aXpY()"); - const DOFAdmin *admin; - - TEST_EXIT(x.getFESpace() && y.getFESpace()) - ("feSpace is NULL: %8X, %8X\n", x.getFESpace(), y.getFESpace()); - TEST_EXIT((admin = x.getFESpace()->getAdmin()) && - (admin == y.getFESpace()->getAdmin())) - ("no admin or different admins: %8X, %8X\n", - x.getFESpace()->getAdmin(), y.getFESpace()->getAdmin()); - TEST_EXIT(static_cast<int>(x.getSize()) >= admin->getUsedSize()) - ("size = %d too small: admin->size = %d\n", x.getSize(), - admin->getUsedSize()); - TEST_EXIT(static_cast<int>(y.getSize()) >= admin->getUsedSize()) - ("y.size = %d too small: admin->size = %d\n", y.getSize(), - admin->getUsedSize()); - - typename DOFVector<T>::Iterator - xIterator(dynamic_cast<DOFIndexed<T>*>(const_cast<DOFVector<T>*>(&x)), - USED_DOFS); - typename DOFVector<T>::Iterator yIterator(dynamic_cast<DOFIndexed<T>*>(&y), - USED_DOFS); - - if (bound) { - DOFVector<BoundaryType>::Iterator - bIterator(const_cast<DOFVector<BoundaryType>*>(bound), USED_DOFS); - - for (xIterator.reset(), yIterator.reset(), bIterator.reset(); - !xIterator.end(); - ++xIterator, ++yIterator, ++bIterator) - { - // only non-dirichlet nodes will be updated - if ((*bIterator) <= 0 ) { - *yIterator *= alpha; - *yIterator += *xIterator; - } - } - } else { - for (xIterator.reset(), yIterator.reset(); !xIterator.end(); - ++xIterator, ++yIterator) - { - *yIterator *= alpha; - *yIterator += *xIterator; - } - } - - return; - } - -} diff --git a/AMDiS/src/BiCGStab_M.h b/AMDiS/src/SolverMatrix.h similarity index 53% rename from AMDiS/src/BiCGStab_M.h rename to AMDiS/src/SolverMatrix.h index c9f36d0f..0c4d23b8 100644 --- a/AMDiS/src/BiCGStab_M.h +++ b/AMDiS/src/SolverMatrix.h @@ -17,82 +17,74 @@ // == == // ============================================================================ -/** \file BiCGStab_M.h */ +/** \file SolverMatrix.h */ + +#ifndef AMDIS_SOLVERMATRIX_H +#define AMDIS_SOLVERMATRIX_H + + +#include "DOFMatrix.h" -#ifndef BICGStab_M_H -#define BICGStab_M_H namespace AMDiS { // ============================================================================ - // ===== class BiCGStab_M ===================================================== + // ===== class SolverMatrix =================================================== // ============================================================================ /** - * \ingroup Solver - * - * \brief - * Solves a linear system by a stabilized BiCG method. - * Can be used for general matrices. + * \brief Helper class to provide complete matrix for ITL solvers and preconditioners */ - template<typename VectorType> - class BiCGStab_M : public OEMSolver<VectorType> + + // General case undefined ! + template <typename Matrix> + class SolverMatrix { }; + + + // DOFMatrix, i.e. ScalarProblem + template <> + class SolverMatrix<DOFMatrix> { - public: - MEMORY_MANAGED(BiCGStab_M<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new BiCGStab_M object. - */ - OEMSolver<VectorType>* create() + public : + SolverMatrix() : matrix(0) {} + + void setMatrix(const DOFMatrix& A) { - return NEW BiCGStab_M<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - BiCGStab_M(std::string name); - - /** \brief - * destructor - */ - ~BiCGStab_M(); - - protected: - /** \brief - * Implements OEMSolver<VectorType>::init(). - */ - void init(); - - /** \brief - * Implements OEMSolver<VectorType>::exit(). - */ - void exit(); - - /** \brief - * Implements OEMSolver<VectorType>::solve(). - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b, bool reuseMatrix); - - private: - // Pointers to memory needed for solveSystem - VectorType *r, *rt, *p, *v, *t, *ph, *sh, *xmin; + matrix= &A.getBaseMatrix(); + } + + const DOFMatrix::base_matrix_type& getMatrix() const { return *matrix; } + + private: + const DOFMatrix::base_matrix_type* matrix; }; -} -#include "BiCGStab_M.hh" + // VectorProblem + template <> + class SolverMatrix<Matrix<DOFMatrix*> > + { + public : + void setMatrix(const Matrix<DOFMatrix*>& A) + { + int ns = A.getSize(), size = A[0][0]->getFESpace()->getAdmin()->getUsedSize(), + new_size = ns * size; + matrix.change_dim(new_size, new_size); + DOFMatrix::inserter_type ins(matrix); + for (int rb= 0; rb < ns; ++rb) + for (int cb= 0; cb < ns; ++cb) + if (A[rb][cb]) + ins[rb * size][cb * size] << A[rb][cb]->getBaseMatrix(); + } + + const DOFMatrix::base_matrix_type& getMatrix() const { return matrix; } + + private: + DOFMatrix::base_matrix_type matrix; + }; + + + +} // namespace AMDiS -#endif // BICGStab_M_H +#endif // AMDIS_SOLVERMATRIX_H diff --git a/AMDiS/src/SparseVector.cc b/AMDiS/src/SparseVector.cc index 0435130b..5e144280 100644 --- a/AMDiS/src/SparseVector.cc +++ b/AMDiS/src/SparseVector.cc @@ -2,6 +2,8 @@ #include "DOFVector.h" #include "FiniteElemSpace.h" +#include <boost/numeric/mtl/mtl.hpp> + namespace AMDiS { template<> @@ -43,6 +45,28 @@ namespace AMDiS { std::set<DegreeOfFreedom> &dofSet, bool add) { + using namespace mtl; + using mtl::tag::nz; using mtl::begin; using mtl::end; + namespace traits= mtl::traits; + typedef DOFMatrix::base_matrix_type Matrix; + Matrix &matrix= a.getBaseMatrix(); + + traits::row<Matrix>::type row(matrix); + traits::col<Matrix>::type col(matrix); + traits::const_value<Matrix>::type value(matrix); + + typedef traits::range_generator<tag::row, Matrix>::type cursor_type; + typedef traits::range_generator<nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::row>(matrix), cend = end<tag::row>(matrix); cursor != cend; ++cursor) { + icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); + double sum= add ? result[row(*icursor)] : 0.0; + for (; icursor != icend; ++icursor) + sum+= value(*icursor) * const_cast<SparseVector<double>&>(x)[col(*icursor)]; + result[row(*icursor)]= sum; + } + +#if 0 //DOFMatrix::Iterator matIt(const_cast<DOFMatrix*>(&a), USED_DOFS); std::vector<MatEntry>::iterator rowIt, rowEnd; @@ -62,6 +86,7 @@ namespace AMDiS { result[row] += rowIt->entry * const_cast<SparseVector<double>&>(x)[col]; } } +#endif } template<> diff --git a/AMDiS/src/StlVector.cc b/AMDiS/src/StlVector.cc deleted file mode 100644 index f971f29f..00000000 --- a/AMDiS/src/StlVector.cc +++ /dev/null @@ -1,81 +0,0 @@ -#include <vector> -#include <math.h> -#include "StlVector.h" - -namespace AMDiS { - - double norm(std::vector<double> *vec) { - double v = 0; - for (int i = 0; i < static_cast<int>(vec->size()); i++) { - v += (*vec)[i] * (*vec)[i]; - } - return sqrt(v); - } - - void setValue(std::vector<double>& x, double value) { - for (int i = 0; i < static_cast<int>(x.size()); i++) { - x[i] = value; - } - } - - const std::vector<double>& operator*=(std::vector<double>& x, double scal) { - for (int i = 0; i < static_cast<int>(x.size()); i++) { - x[i] *= scal; - } - - return x; - } - - const std::vector<double>& operator+=(std::vector<double>& x1, - const std::vector<double>& x2) { - for (int i = 0; i < static_cast<int>(x1.size()); i++) { - x1[i] += x2[i]; - } - - return x1; - } - - double operator*(std::vector<double>& x1, std::vector<double>& x2) { - double result = 0.0; - - for (int i = 0; i < static_cast<int>(x1.size()); i++) { - result += x1[i] * x2[i]; - } - - return result; - } - - void axpy(double alpha, const std::vector<double>& x, std::vector<double>& y) { - for (int i = 0; i < static_cast<int>(y.size()); i++) { - y[i] += alpha * x[i]; - } - } - - void xpay(double alpha, const std::vector<double>& x, std::vector<double>& y) { - for (int i = 0; i < static_cast<int>(y.size()); i++) { - y[i] = alpha * y[i] + x[i]; - } - } - - int logToPhysIndex(std::vector< std::vector<MatEntry> > *matrix, int a, int b) - { - int j; - - for (j = 0; j < static_cast<int>((*matrix)[a].size()); j++) - if (b == (*matrix)[a][j].col) - break; - - return (j == static_cast<int>((*matrix)[a].size())) ? -1 : j; - } - - void print(std::vector<double> *vec) - { - std::cout << "["; - - for (int i = 0; i < static_cast<int>(vec->size()); i++) { - std::cout << (*vec)[i] << " , "; - } - - std::cout << "]" << std::endl; - } -} diff --git a/AMDiS/src/StlVector.h b/AMDiS/src/StlVector.h deleted file mode 100644 index 7dde8302..00000000 --- a/AMDiS/src/StlVector.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef AMDIS_STLVECTOR_H -#define AMDIS_STLVECTOR_H - -#include <vector> -#include "CreatorInterface.h" -#include "MemoryManager.h" -#include "DOFMatrix.h" - -namespace AMDiS { - - class StlVectorCreator : public CreatorInterface< std::vector<double> > { - public: - MEMORY_MANAGED(StlVectorCreator); - - StlVectorCreator(int size) - : size_(size) - {}; - - virtual ~StlVectorCreator() {}; - - std::vector<double> *create() { - std::vector<double> *vec = new std::vector<double>(size_, 0.0); - - return vec; - }; - - void free(std::vector<double> *vec) { - delete vec; - }; - - private: - int size_; - }; - - double norm(std::vector<double> *vec); - - inline int size(std::vector<double> *vec) - { - return vec->size(); - } - - void setValue(std::vector<double>& x, double value); - - const std::vector<double>& operator*=(std::vector<double>& x, double scal); - - const std::vector<double>& operator+=(std::vector<double>& x1, - const std::vector<double>& x2); - - double operator*(std::vector<double>& x1, std::vector<double>& x2); - - void axpy(double alpha, const std::vector<double>& x, std::vector<double>& y); - - void xpay(double alpha, const std::vector<double>& x, std::vector<double>& y); - - int logToPhysIndex(std::vector< std::vector<MatEntry> > *m, int a, int b); - - void print(std::vector<double> *vec); -} - -#endif diff --git a/AMDiS/src/TFQMR.h b/AMDiS/src/TFQMR.h deleted file mode 100644 index e127e267..00000000 --- a/AMDiS/src/TFQMR.h +++ /dev/null @@ -1,115 +0,0 @@ -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file TFQMR.h */ - -#ifndef AMDIS_TFQMR_H -#define AMDIS_TFQMR_H - -#include "OEMSolver.h" -#include "MemoryManager.h" - -namespace AMDiS { - - // ============================================================================ - // ===== class TFQMR ========================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - */ - template<typename VectorType> - class TFQMR : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(GMResSolver2<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new TFQMR object. - */ - OEMSolver<VectorType>* create() { - return NEW TFQMR<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - TFQMR(std::string name); - - /** \brief - * destructor - */ - ~TFQMR(); - - protected: - /** \brief - * realisation of OEMSolver::solveSystem - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix); - - /** \brief - * realisation of OEMSolver::init - */ - void init(); - - /** \brief - * realisation of OEMSolver::exit - */ - void exit(); - - private: - /** \brief - * Stores the tolerance boundary for numerical computations. - */ - double TOL_; - - VectorType *r0_; - - /** \brief - * Stores intermediate results in the orthogonalization step. - */ - VectorType *w_; - - /** \brief - * Pointers to the vectors of the orthogonal system. - */ - VectorType *y1_, *y2_; - - VectorType *v_, *d_, *tmp_; - - }; - - -} - -#include "TFQMR.hh" - -#endif // AMDIS_TFQMR_H diff --git a/AMDiS/src/TFQMR.hh b/AMDiS/src/TFQMR.hh deleted file mode 100644 index d2ae5e92..00000000 --- a/AMDiS/src/TFQMR.hh +++ /dev/null @@ -1,184 +0,0 @@ -#include "TFQMR.h" -#include "Preconditioner.h" - -namespace AMDiS { - - template<typename VectorType> - TFQMR<VectorType>::TFQMR(std::string name) - : OEMSolver<VectorType>(name), - TOL_(1.e-25) - { - FUNCNAME("TFQMR::TFQMR()"); - } - - template<typename VectorType> - TFQMR<VectorType>::~TFQMR() - {} - - template<typename VectorType> - void TFQMR<VectorType>::init() - { - r0_ = this->vectorCreator->create(); - w_ = this->vectorCreator->create(); - y1_ = this->vectorCreator->create(); - y2_ = this->vectorCreator->create(); - v_ = this->vectorCreator->create(); - d_ = this->vectorCreator->create(); - tmp_ = this->vectorCreator->create(); - } - - template<typename VectorType> - void TFQMR<VectorType>::exit() - { - if (r0_) { - this->vectorCreator->free(r0_); - this->vectorCreator->free(w_); - this->vectorCreator->free(y1_); - this->vectorCreator->free(y2_); - this->vectorCreator->free(v_); - this->vectorCreator->free(d_); - this->vectorCreator->free(tmp_); - } - } - - template<typename VectorType> - int TFQMR<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, - VectorType *b, - bool reuseMatrix) - { - DOFMatrix *m = (dynamic_cast<StandardMatVec<DOFMatrix, VectorType> *>(matVec))->getMatrix(); - - matVec->matVec(NoTranspose, *x, *r0_); - xpay(-1.0, *b, *r0_); - double tau = norm(r0_); - std::cout << "NORM: " << tau << std::endl; - - for (int iter = 0; iter < 1000; iter++) { - for (int i = 0; i < x->getSize(); i++) { - (*y1_)[i] = (*b)[i]; - - for (int j = 0; j < static_cast<int>((*m)[i].size()); j++) { - MatEntry a = (*m)[i][j]; - - if (a.col != i) { - (*y1_)[i] -= (*x)[i] * a.entry; - } - } - - (*y1_)[i] /= (*m)[i][0].entry; - } - - *x = *y1_; - } - - matVec->matVec(NoTranspose, *x, *r0_); - xpay(-1.0, *b, *r0_); - tau = norm(r0_); - std::cout << "NORM: " << tau << std::endl; - - return 1000; - } - - // template<typename VectorType> -// int TFQMR<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, -// VectorType *x, -// VectorType *b) -// { -// FUNCNAME("TFQMR::solveSystem()"); - -// double old_res = -1.0; - -// // If norm of b is smaller than the tolarance, we can assume b to be zero. -// // Hence, x = 0 is the solution of the linear system. -// if (norm(b) < TOL_) { -// INFO(this->info, 2)("b == 0, x = 0 is the solution of the linear system\n"); -// set(*x, 0.0); -// this->residual = 0.0; -// return(0); -// } - -// // r_0 = b - Ax, where r_0 is already stored as the first vector in the -// // matrix V. -// matVec->matVec(NoTranspose, *x, *r0_); -// xpay(-1.0, *b, *r0_); - -// if (this->leftPrecon) -// this->leftPrecon->precon(r0_); - -// *y1_ = *r0_; -// *w_ = *r0_; -// double tau = norm(r0_); - -// if (tau < this->tolerance) { -// this->residual = tau; -// return(0); -// } - -// matVec->matVec(NoTranspose, *y1_, *v_); -// d_->set(0.0); -// double eta = 0.0; -// double theta = 0.0; -// double rho1 = tau * tau; -// double rho2 = 0.0; -// double alpha = 0.0; -// double beta = 0.0; -// double c = 0.0; - -// START_INFO(); -// for (int j = 1; j <= this->max_iter; j++) { -// rho2 = *v_ * *r0_; -// alpha = rho1 / rho2; -// *y2_ = *y1_; -// axpy(-alpha, *v_, *y2_); - -// for (int m = 2 * j - 1; m <= 2 * j; m++) { -// matVec->matVec(NoTranspose, *y1_, *tmp_); -// axpy(-alpha, *tmp_, *w_); - -// if (this->leftPrecon) -// this->leftPrecon->precon(w_); - -// xpay(theta * theta * eta / alpha, *y1_, *d_); - - -// theta = norm(w_) / tau; -// c = 1 / sqrt(theta * theta + 1); -// eta = c * c * alpha; -// axpy(eta, *d_, *x); -// tau = tau * theta * c; -// this->residual = sqrt(m + 1) * tau; -// *y1_ = *y2_; -// } - -// if (SOLVE_INFO(j - 1, this->residual, &old_res)) -// return(j - 1); - -// rho2 = *w_ * *r0_; -// beta = rho2 / rho1; -// *y1_ = *w_; -// axpy(beta, *y2_, *y1_); - - -// matVec->matVec(NoTranspose, *y2_, *tmp_); - -// if (this->leftPrecon) -// this->leftPrecon->precon(tmp_); - -// xpay(beta, *tmp_, *v_); - -// matVec->matVec(NoTranspose, *y1_, *tmp_); - -// if (this->leftPrecon) -// this->leftPrecon->precon(tmp_); - - -// xpay(beta, *tmp_, *v_); - -// rho1 = rho2; -// } - -// return 0; -// } - -} diff --git a/AMDiS/src/UmfPackSolver.h b/AMDiS/src/UmfPackSolver.h index 6bc57c89..893ca76a 100644 --- a/AMDiS/src/UmfPackSolver.h +++ b/AMDiS/src/UmfPackSolver.h @@ -22,11 +22,13 @@ #ifndef AMDIS_UMFPACKSOLVER_H #define AMDIS_UMFPACKSOLVER_H -#ifdef HAVE_UMFPACK +#if defined HAVE_UMFPACK && defined MTL_HAS_UMFPACK #include "OEMSolver.h" #include "MemoryManager.h" +#include <boost/numeric/mtl/interface/umfpack_solve.hpp> + namespace AMDiS { // ============================================================================ @@ -42,16 +44,14 @@ namespace AMDiS { * * This is a direct solver for large sparse matrices. */ - template<typename VectorType> - class UmfPackSolver : public OEMSolver<VectorType> + + class UmfPackSolver : public OEMSolver { public: - MEMORY_MANAGED(UmfPackSolver<VectorType>); + MEMORY_MANAGED(UmfPackSolver); - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> + /// Creator class used in the OEMSolverMap. + class Creator : public OEMSolverCreator { public: MEMORY_MANAGED(Creator); @@ -61,78 +61,45 @@ namespace AMDiS { /** \brief * Returns a new UmfPackSolver object. */ - OEMSolver<VectorType>* create() { - return NEW UmfPackSolver<VectorType>(this->name); + OEMSolver* create() { + return NEW UmfPackSolver(this->name); }; }; - /** \brief - * constructor - */ - UmfPackSolver(std::string name); - - /** \brief - * destructor - */ - ~UmfPackSolver(); - protected: - /** \brief - * Implements OEMSolver<VectorType>::init(). - */ - void init() { - p = this->vectorCreator->create(); - r = this->vectorCreator->create(); + /// Constructor + UmfPackSolver(::std::string name) + : OEMSolver(name), + solver(0) + { + GET_PARAMETER(0, name + "->store symbolic", "%d", &store_symbolic); + // GET_PARAMETER(0, name + "->multiple rhs", "%d", &multipleRhs); } - /** \brief - * Implements OEMSolver<VectorType>::exit(). - */ - void exit() { - this->vectorCreator->free(p); - this->vectorCreator->free(r); + /// Destructor + ~UmfPackSolver() { if (solver) delete solver;} + + /// Solves the system directly + int solveSystem(const DOFMatrix::base_matrix_type& A, + mtl::dense_vector<value_type>& x, + const mtl::dense_vector<value_type>& b) + { + if (!solver) + solver= new mtl::matrix::umfpack::solver<matrix_type>(A); + else if (store_symbolic) + solver->update_numeric(); + else + solver->update(); + return (*solver)(x, b); } - - /** \brief - * Implements OEMSolver<VectorType>::solve(). - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b, bool reuseMatrix); + private: - /** \brief - * These vectors are justed to calculate the final residual of the solution. - */ - VectorType *r, *p; - - /** \brief - * Stores the result of umfpack_di_symbolic (the symbolic analysis which is needed - * for the numeric factorization). - */ - void *symbolic_; - - /** \brief - * Stores the result of umfpack_di_numeric, if multiple right hand sides will occure. - */ - void *numeric; - - /** \brief - * If the symbolic analysis should be done only once (for example, if the matrices - * to solve have all the same pattern because of no adaptivity), this variable - * is one, otherwise 0 and the symbolic analysis will be performed at every call - * of solveSystem(). - */ - int storeSymbolic_; - - /** \brief - * If not zero, Umfpack is prepared to solve multiple following systems with equal - * system matrix but different right hand side vectors. - */ - int multipleRhs; + mtl::matrix::umfpack::solver<matrix_type> *solver; + int store_symbolic; }; } -#include "UmfPackSolver.hh" - #endif // HAVE_UMFPACK #endif // AMDIS_UMFPACKSOLVER_H diff --git a/AMDiS/src/UmfPackSolver.hh b/AMDiS/src/UmfPackSolver.hh deleted file mode 100644 index 9762b0fa..00000000 --- a/AMDiS/src/UmfPackSolver.hh +++ /dev/null @@ -1,222 +0,0 @@ -#include <vector> - -#include "UmfPackSolver.h" -#include "DOFMatrix.h" -#include "MatVecMultiplier.h" - -#include "umfpack.h" - - -namespace AMDiS { - - template<typename VectorType> - UmfPackSolver<VectorType>::UmfPackSolver(std::string name) - : OEMSolver<VectorType>(name), - symbolic_(NULL), - storeSymbolic_(0), - multipleRhs(0) - { - GET_PARAMETER(0, name + "->store symbolic", "%d", &storeSymbolic_); - GET_PARAMETER(0, name + "->multiple rhs", "%d", &multipleRhs); - } - - template<typename VectorType> - UmfPackSolver<VectorType>::~UmfPackSolver() - { - if (storeSymbolic_ && (symbolic_ != NULL)) { - umfpack_di_free_symbolic(&symbolic_); - } - } - - template<typename VectorType> - int UmfPackSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, - bool reuseMatrix) - { - FUNCNAME("UmfPackSolver::solveSystem()"); - - TEST_EXIT(x->getSize() == b->getSize())("Vectors x and b must have the same size!"); - - // Extract the matrix of DOF-matrices. - StandardMatVec<Matrix<DOFMatrix*>, SystemVector> *stdMatVec = - dynamic_cast<StandardMatVec<Matrix<DOFMatrix*>, SystemVector> *>(matVec); - Matrix<DOFMatrix*> *m = stdMatVec->getMatrix(); - - // Number of systems. - int nComponents = m->getSize(); - - // Calculate size of the new composed matrix. - int newMatrixSize = 0; - std::vector<int> matricesSize(nComponents); - - for (int i = 0; i < nComponents; i++) { - for (int j = 0; j < nComponents; j++) { - if ((*m)[i][j]) { - matricesSize[i] = ((*m)[i][j])->getFESpace()->getAdmin()->getUsedSize(); - newMatrixSize += matricesSize[i]; - break; - } - } - } - - // int newMatrixSize = ((*m)[0][0])->getFESpace()->getAdmin()->getUsedSize() * nComponents; - - // The new matrix has to be stored in compressed col format, therefore - // the cols are collected. - std::vector< std::vector< MatEntry > > cols(newMatrixSize, std::vector<MatEntry>(0)); - - // Counter for the number of non-zero elements in the new matrix. - int nElements = 0; - - for (int stencilRow = 0, shiftRow = 0; stencilRow < nComponents; stencilRow++) { - - int shiftCol = 0; - - for (int stencilCol = 0; stencilCol < nComponents; stencilCol++) { - - if (!(*m)[stencilRow][stencilCol]) { - shiftCol += matricesSize[stencilCol]; - continue; - } - - DOFMatrix::Iterator matrixRow((*m)[stencilRow][stencilCol], USED_DOFS); - int rowIndex = 0; - for (matrixRow.reset(); !matrixRow.end(); matrixRow++, rowIndex++) { - for (int i = 0; i < static_cast<int>((*matrixRow).size()); i++) { - if ((*matrixRow)[i].col >= 0) { - MatEntry me; - me.entry = (*matrixRow)[i].entry; - // The col field is used to store the row number of the new element. - me.col = rowIndex + shiftRow; - - // And save the new element in the corresponding column. - cols[(*matrixRow)[i].col + shiftCol].push_back(me); - - nElements++; - } - - } - } - - - shiftCol += matricesSize[stencilCol]; - } - - shiftRow += matricesSize[stencilRow]; - } - - - // Data fields for UMFPack. - int *Ap = (int*)malloc(sizeof(int) * (newMatrixSize + 1)); - int *Ai = (int*)malloc(sizeof(int) * nElements); - double *Ax = (double*)malloc(sizeof(double) * nElements); - double *bvec = (double*)malloc(sizeof(double) * newMatrixSize); - double *xvec = (double*)malloc(sizeof(double) * newMatrixSize); - - // Resort the right hand side of the linear system. - for (int i = 0, counter = 0; i < b->getSize(); i++) { - DOFVector<double>::Iterator it(b->getDOFVector(i), USED_DOFS); - - for (it.reset(); !it.end(); ++it) { - bvec[counter++] = *it; - } - } - - - // Create fields Ap, Ai and Ax. - int elCounter = 0; - Ap[0] = 0; - for (int i = 0; i < newMatrixSize; i++) { - Ap[i + 1] = Ap[i] + cols[i].size(); - - // The cols has to be sorted for using them in UMFPack. - sort(cols[i].begin(), cols[i].end(), CmpMatEntryCol()); - - for (int j = 0; j < static_cast<int>(cols[i].size()); j++) { - Ai[elCounter] = cols[i][j].col; - Ax[elCounter] = cols[i][j].entry; - - elCounter++; - } - } - - - double Control[UMFPACK_CONTROL]; - double Info[UMFPACK_INFO]; - int status = 0; - - MSG("solving system with UMFPack ...\n"); - - // Use default setings. - umfpack_di_defaults(Control); - - // Run UMFPack. - if (!(storeSymbolic_) || - (storeSymbolic_ && (symbolic_ == NULL))) { - - status = umfpack_di_symbolic(newMatrixSize, newMatrixSize, Ap, Ai, Ax, - &symbolic_, Control, Info); - if (!status == UMFPACK_OK) { - ERROR_EXIT("UMFPACK Error in function umfpack_di_symbolic"); - } - } - - if (!((multipleRhs != 0) && (reuseMatrix))) { - // With multiple rhs are allowed, but not this time, free the matrix - // factorization of last solution step, - if ((multipleRhs != 0) && !reuseMatrix) { - umfpack_di_free_numeric(&numeric); - } - - status = umfpack_di_numeric(Ap, Ai, Ax, symbolic_, &numeric, Control, Info); - if (!status == UMFPACK_OK) { - ERROR_EXIT("UMFPACK Error in function umfpack_di_numeric"); - } - } - - status = umfpack_di_solve(UMFPACK_A, Ap, Ai, Ax, xvec, bvec, numeric, Control, Info); - if (!status == UMFPACK_OK) { - ERROR_EXIT("UMFPACK Error in function umfpack_di_solve"); - } - - if (!storeSymbolic_) { - umfpack_di_free_symbolic(&symbolic_); - } - if (multipleRhs == 0) { - umfpack_di_free_numeric(&numeric); - } - - - // Copy and resort solution. - for (int i = 0, counter = 0; i < x->getSize(); i++) { - DOFVector<double>::Iterator it(x->getDOFVector(i), USED_DOFS); - - for (it.reset(); !it.end(); it++) { - *it = xvec[counter++]; - } - } - - free(Ap); - free(Ai); - free(Ax); - free(bvec); - free(xvec); - - // Calculate and print the residual. - *p = *x; - *p *= -1.0; - matVec->matVec(NoTranspose, *p, *r); - *r += *b; - - this->residual = norm(r); - - MSG("Residual: %e\n", this->residual); - - if (this->residual > this->tolerance) { - ERROR_EXIT("UMFPACK could not solve the system!\n"); - } - - return(1); - } -} - diff --git a/AMDiS/src/Utilities.h b/AMDiS/src/Utilities.h new file mode 100644 index 00000000..143704eb --- /dev/null +++ b/AMDiS/src/Utilities.h @@ -0,0 +1,44 @@ +// ============================================================================ +// == == +// == AMDiS - Adaptive multidimensional simulations == +// == == +// ============================================================================ +// == == +// == crystal growth group == +// == == +// == Stiftung caesar == +// == Ludwig-Erhard-Allee 2 == +// == 53175 Bonn == +// == germany == +// == == +// ============================================================================ +// == == +// == http://www.caesar.de/cg/AMDiS == +// == == +// ============================================================================ + +/** \file Utilities.h */ + +#ifndef AMDIS_UTILITIES_H +#define AMDIS_UTILITIES_H + +#include <vector> +#include <algorithm> + + + +template <typename T> +std::vector<T> inline invert_reorder(const std::vector<T>& v) +{ + T my_max= *std::max_element(v.begin(), v.end()) + 1; + std::vector<T> u(my_max, T(-1)); + for (int i= 0; i < v.size(); i++) + if (v[i] >= 0) { + assert(u[v[i]] == -1); // check double insertion + u[v[i]]= T(i); + } + assert(find(u.begin(), u.end(), T(-1)) == u.end()); // check if all entries are set + return u; +} + +#endif // AMDIS_UTILITIES_H diff --git a/AMDiS/src/V3Vector.cc b/AMDiS/src/V3Vector.cc deleted file mode 100644 index 5f67a62b..00000000 --- a/AMDiS/src/V3Vector.cc +++ /dev/null @@ -1,173 +0,0 @@ -#include "V3Vector.h" -#include "StlVector.h" - -namespace AMDiS { - - M33::M33() - { - data.resize(9); - for (int i = 0; i < 9; i++) { - data[i] = 0.0; - } - }; - - M33::~M33() - {}; - - void M33::set(int row, int col, double value) - { - data[row * 3 + col] = value; - }; - - void M33::print() - { - std::cout << "["; - - for (int i = 0; i < 9; i++) { - std::cout << data[i] << ","; - } - - std::cout << "]" << std::endl; - }; - -/* double norm(std::vector<V3> *v) { - double result = 0.0; - - std::vector<V3>::iterator it; - - for (it = v->begin(); it < v->end(); ++it) { - result += (*it)[0] * (*it)[0] + (*it)[1] * (*it)[1] + (*it)[2] * (*it)[2]; - } - - return(sqrt(result)); - }; - - void setValue(std::vector<V3>& v, double value) - { - std::vector<V3>::iterator it; - - for (it = v.begin(); it < v.end(); ++it) { - (*it)[0] = value; - (*it)[1] = value; - (*it)[2] = value; - }; - }; - - const V3& operator += (V3& x1, const V3 x2) - { - x1[0] += x2[0]; - x1[1] += x2[1]; - x1[2] += x2[2]; - - return(x1); - } - - const std::vector<V3>& operator*=(std::vector<V3>& x, double scal) - { - std::vector<V3>::iterator it; - - for (it = x.begin(); it < x.end(); ++it) { - (*it)[0] *= scal; - (*it)[1] *= scal; - (*it)[2] *= scal; - } - - return(x); - }; - - const std::vector<V3>& operator+=(std::vector<V3>& x1, - const std::vector<V3>& x2) - { - std::vector<V3>::iterator it1; - std::vector<V3>::const_iterator it2; - - for (it1 = x1.begin(), it2 = x2.begin(); - it1 < x1.end(); - ++it1, ++it2) { - (*it1)[0] += (*it2)[0]; - (*it1)[1] += (*it2)[1]; - (*it1)[2] += (*it2)[2]; - }; - - return(x1); - }; - - double operator*(std::vector<V3>& x1, std::vector<V3>& x2) - { - double result = 0.0; - - std::vector<V3>::iterator it1, it2; - - for (it1 = x1.begin(), it2 = x2.begin(); - it1 < x1.end(); - ++it1, ++it2) { - result += (*it1)[0] * (*it2)[0] + - (*it1)[1] * (*it2)[1] + - (*it1)[2] * (*it2)[2]; - } - - return(result); - }; - - - void axpy(double alpha, const std::vector<V3>& x, std::vector<V3>& y) - { - std::vector<V3>::const_iterator it1; - std::vector<V3>::iterator it2; - - for (it1 = x.begin(), it2 = y.begin(); - it1 < x.end(); - ++it1, ++it2) { - (*it2)[0] += alpha * (*it1)[0]; - (*it2)[1] += alpha * (*it1)[1]; - (*it2)[2] += alpha * (*it1)[2]; - } - }; - - void xpay(double alpha, const std::vector<V3>& x, std::vector<V3>& y) - { - std::vector<V3>::const_iterator it1; - std::vector<V3>::iterator it2; - - for (it1 = x.begin(), it2 = y.begin(); - it1 < x.end(); - ++it1, ++it2) { - (*it2)[0] = alpha * (*it2)[0] + (*it1)[0]; - (*it2)[1] = alpha * (*it2)[1] + (*it1)[1]; - (*it2)[2] = alpha * (*it2)[2] + (*it1)[2]; - } - }; - - V3 mult(M33 mat, V3 vec) - { - V3 result(3); - - result[0] = mat[0] * vec[0] + mat[1] * vec[1] + mat[2] * vec[2]; - result[1] = mat[3] * vec[0] + mat[4] * vec[1] + mat[5] * vec[2]; - result[2] = mat[6] * vec[0] + mat[7] * vec[1] + mat[8] * vec[2]; - -// std::cout << "------------------------" << std::endl; -// std::cout << "M = "; -// mat.print(); -// std::cout << "v = "; -// print(&vec); -// std::cout << "r = "; -// print(&result); - - return(result); - }; - - void print(std::vector<V3> *v) - { - std::vector<V3>::const_iterator it; - - std::cout << "["; - - for (it = v->begin(); it < v->end(); ++it) { - std::cout << "(" << (*it)[0] << "," << (*it)[1] << "," << (*it)[2] << ") "; - } - - std::cout << "]" << std::endl; - }; -*/ -} diff --git a/AMDiS/src/V3Vector.h b/AMDiS/src/V3Vector.h deleted file mode 100644 index 601eab4a..00000000 --- a/AMDiS/src/V3Vector.h +++ /dev/null @@ -1,117 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file V3Vector.h */ - -#ifndef AMDIS_V3VECTOR_H -#define AMDIS_V3VECTOR_H - -#include <vector> -#include "Global.h" -#include "MemoryManager.h" -#include "CreatorInterface.h" - -namespace AMDiS { - - class M33 { - public: - M33(); - - ~M33(); - - void set(int row, int col, double value); - - bool operator==(const M33 &a) const { - return data == a.getData(); - }; - - bool operator!=(const M33 &a) const { - return data != a.getData(); - }; - - std::vector<double> getData() const { - return data; - }; - - inline double operator[](int i) const { - return(data[i]); - } - - void print(); - - private: - std::vector<double> data; - }; - - struct MatEntry33 - { - DegreeOfFreedom col; - - M33 entry; - }; -/* - typedef std::vector<double> V3; - - class V3Creator : public CreatorInterface< std::vector<V3> > { - public: - MEMORY_MANAGED(V3Creator); - - V3Creator(int size) - : size_(size) - {}; - - virtual ~V3Creator() {}; - - std::vector<V3> *create() { - std::vector<V3> *vec = new std::vector<V3>(size_, V3(3)); - - return vec; - }; - - void free(std::vector<V3> *vec) { - delete vec; - }; - - private: - int size_; - }; - - double norm(std::vector<V3> *v); - - void setValue(std::vector<V3>& v, double value); - - const V3& operator += (V3& x1, const V3 x2); - - const std::vector<V3>& operator*=(std::vector<V3>& x, double scal); - - const std::vector<V3>& operator+=(std::vector<V3>& x1, - const std::vector<V3>& x2); - - double operator*(std::vector<V3>& x1, std::vector<V3>& x2); - - void axpy(double alpha, const std::vector<V3>& x, std::vector<V3>& y); - - void xpay(double alpha, const std::vector<V3>& x, std::vector<V3>& y); - - V3 mult(M33 mat, V3 vec); - - void print(std::vector<V3> *v);*/ -} - -#endif diff --git a/AMDiS/src/VecSymSolver.h b/AMDiS/src/VecSymSolver.h deleted file mode 100644 index 130d50b3..00000000 --- a/AMDiS/src/VecSymSolver.h +++ /dev/null @@ -1,103 +0,0 @@ -// ============================================================================ -// == == -// == AMDiS - Adaptive multidimensional simulations == -// == == -// ============================================================================ -// == == -// == crystal growth group == -// == == -// == Stiftung caesar == -// == Ludwig-Erhard-Allee 2 == -// == 53175 Bonn == -// == germany == -// == == -// ============================================================================ -// == == -// == http://www.caesar.de/cg/AMDiS == -// == == -// ============================================================================ - -/** \file VecSymSolver.h */ - -#ifndef AMDIS_VECSYMSOLVER_H -#define AMDIS_VECSYMSOLVER_H - -#include "OEMSolver.h" -#include "MemoryManager.h" -#include "V3Vector.h" - -namespace AMDiS { - - // ============================================================================ - // ===== class VecSymSolver =================================================== - // ============================================================================ - - /** - * \ingroup Solver - * - * \brief - */ - template<typename VectorType> - class VecSymSolver : public OEMSolver<VectorType> - { - public: - MEMORY_MANAGED(VecSymSolver<VectorType>); - - /** \brief - * Creator class used in the OEMSolverMap. - */ - class Creator : public OEMSolverCreator<VectorType> - { - public: - MEMORY_MANAGED(Creator); - - virtual ~Creator() {}; - - /** \brief - * Returns a new CGSolver object. - */ - OEMSolver<VectorType>* create() { - return NEW VecSymSolver<VectorType>(this->name); - }; - }; - - /** \brief - * constructor - */ - VecSymSolver(std::string name); - - /** \brief - * destructor - */ - ~VecSymSolver(); - protected: - /** \brief - * Implements OEMSolver<VectorType>::init(). - */ - void init() { - p = this->vectorCreator->create(); - r = this->vectorCreator->create(); - }; - - /** \brief - * Implements OEMSolver<VectorType>::exit(). - */ - void exit() { - this->vectorCreator->free(p); - }; - - /** \brief - * Implements OEMSolver<VectorType>::solve(). - */ - int solveSystem(MatVecMultiplier<VectorType> *mv, - VectorType *x, VectorType *b, bool reuseMatrix); - - private: - VectorType *r, *p; - }; -} - -#include "VecSymSolver.hh" - -#endif // AMDIS_VECSYMSOLVER_H - diff --git a/AMDiS/src/VecSymSolver.hh b/AMDiS/src/VecSymSolver.hh deleted file mode 100644 index 76a1cd6f..00000000 --- a/AMDiS/src/VecSymSolver.hh +++ /dev/null @@ -1,443 +0,0 @@ -//#include <fstream> - -#include <vector> - -#include "VecSymSolver.h" -#include "DOFMatrix.h" -#include "DiagonalPreconditioner.h" -#include "ILUPreconditioner.h" -#include "MatVecMultiplier.h" - -namespace AMDiS { - - template<typename VectorType> - VecSymSolver<VectorType>::VecSymSolver(std::string name) - : OEMSolver<VectorType>(name) - {} - - template<typename VectorType> - VecSymSolver<VectorType>::~VecSymSolver() {} - -/* template<typename VectorType> - int VecSymSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b) - { - FUNCNAME("VecSymSolver::solveSystem()"); - - StandardMatVec<Matrix<DOFMatrix*>, SystemVector> *stdMatVec = - dynamic_cast<StandardMatVec<Matrix<DOFMatrix*>, SystemVector> *>(matVec); - - Matrix<DOFMatrix*> *m = stdMatVec->getMatrix(); - - DOFMatrix* dofm = (*m)[0][0]; - - int nComponents = m->getSize(); - int oneMatrixSize = dofm->getFESpace()->getAdmin()->getUsedSize(); - int bigMatrixSize = oneMatrixSize; - - std::vector< std::vector< MatEntry33 > > newm; - newm.resize(bigMatrixSize); - - std::vector<V3> xvec(bigMatrixSize); - std::vector<V3> bvec(bigMatrixSize); - for (int i = 0; i < bigMatrixSize; i++) { - xvec[i].resize(3); - bvec[i].resize(3); - } - - for (int stencilRow = 0; stencilRow < nComponents; stencilRow++) { - for (int stencilCol = 0; stencilCol < nComponents; stencilCol++) { - - if (!(*m)[stencilRow][stencilCol]) { -// std::cout << "Matrix " << stencilRow << "-" << stencilCol << " ist 0!" << std::endl; - continue; - } else { - (*m)[stencilRow][stencilCol]->print(); - - if ((*m)[stencilRow][stencilCol]->symmetric()) { - std::cout << "Matrix " << stencilRow << "-" << stencilCol << " ist symmetrisch!" << std::endl; - } else { - std::cout << "Matrix " << stencilRow << "-" << stencilCol << " ist nicht symmetrisch!" << std::endl; - } - }; - - DOFMatrix::Iterator matrixRow((*m)[stencilRow][stencilCol], USED_DOFS); - int rowIndex = 0; - for (matrixRow.reset(); !matrixRow.end(); ++matrixRow, rowIndex++) { - for (int i = 0; i < static_cast<int>((*matrixRow).size()); i++) { - if ((*matrixRow)[i].col >= 0) { - MatEntry33 *newMe = NULL; - -// if ((stencilRow == 0) && (stencilCol == 0) && -// (rowIndex == 0) && ((*matrixRow)[i].col == 0)) { -// std::cout << "Dich habe ich: " << (*matrixRow)[i].entry << std::endl; -// } - - for (int j = 0; j < static_cast<int>(newm[rowIndex].size()); j++) { - if (newm[rowIndex][j].col == (*matrixRow)[i].col) { - newMe = &(newm[rowIndex][j]); - } - } - - if (newMe == NULL) { -// if ((rowIndex == 0) && ((*matrixRow)[i].col == 0)) { -// std::cout << "0-Matrix neu anlegen!" << std::endl; -// }; - - MatEntry33 newMe; - newMe.col = (*matrixRow)[i].col; - newMe.entry.set(stencilRow, stencilCol, (*matrixRow)[i].entry); - newm[rowIndex].push_back(newMe); - -// if ((rowIndex == 0) && ((*matrixRow)[i].col == 0)) { -// std::cout << "0-Matrix: " << std::endl; -// newMe.entry.print(); -// } - - } else { - newMe->entry.set(stencilRow, stencilCol, (*matrixRow)[i].entry); - -// if ((rowIndex == 0) && ((*matrixRow)[i].col == 0)) { -// std::cout << "0-Matrix: " << std::endl; -// newMe->entry.print(); -// } - } - - } - } - } - - } - } - - - for (int i = 0; i < static_cast<int>(newm.size()); i++) { - - for (int j = 0; j < static_cast<int>(newm[j].size()); j++) { - if (newm[i][j].col == i) { - MatEntry33 tmp = newm[i][0]; - newm[i][0] = newm[i][j]; - newm[i][j] = tmp; - - break; - } - } - } - - - std::cout << "Gesuchter Vektor ist: " << std::endl; - - for (int i = 0; i < x->getSize(); i++) { - DOFVector<double>::Iterator it(x->getDOFVector(i), USED_DOFS); - - int counter = 0; - for (it.reset(); !it.end(); it++, counter++) { - std::cout << (*it) << std::endl; - - xvec[counter][i] = *it; - } - } - - std::cout << "Rechte Seite ist: " << std::endl; - - for (int i = 0; i < b->getSize(); i++) { - DOFVector<double>::Iterator it(b->getDOFVector(i), USED_DOFS); - - int counter = 0; - for (it.reset(); !it.end(); it++, counter++) { - std::cout << (*it) << std::endl; - - bvec[counter][i] = *it; - } - } - - - bool isSym = true; - - for (int i = 0; i < static_cast<int>(newm.size()); i++) { - -// std::cout << "Zeile " << i << ": " << std::endl; - - for (int j = 0; j < static_cast<int>(newm[i].size()); j++) { - int col = newm[i][j].col; - -// std::cout << col << ": [ "; -// for (int k = 0; k < 9; k++) { -// std::cout << newm[i][j].entry[k] << " "; -// } -// std::cout << "], "; - - if (col != i) { - for (int k = 0; k < static_cast<int>(newm[col].size()); k++) { - if (newm[col][k].col == i) { - if (newm[i][j].entry != newm[col][k].entry) { - isSym = false; - } - } - } - } - } - -// std::cout << std::endl; - } - - if (isSym) { - std::cout << "Gesamtmatrix ist symmetrisch!" << std::endl; - } else { - std::cout << "Gesamtmatrix ist nicht symmetrisch!" << std::endl; - } - - CGSolver< std::vector<V3> > solver2(this->name); - solver2.initParameters(); - solver2.setVectorCreator(NEW V3Creator(bigMatrixSize)); - - StandardMatVec< std::vector< std::vector<MatEntry33> >, std::vector<V3> > mv(&newm); - - *p = *x; - *p *= -1.0; - matVec->matVec(NoTranspose, *p, *r); - *r += *b; - - std::cout << "Checking res 1: " << norm(r) << std::endl; - - solver2.solve(&mv, &xvec, &bvec); - - for (int i = 0; i < x->getSize(); i++) { - DOFVector<double>::Iterator it(x->getDOFVector(i), USED_DOFS); - - int counter = 0; - for (it.reset(); !it.end(); it++, counter++) { - *it = xvec[counter][i]; - } - } - - *p = *x; - *p *= -1.0; - matVec->matVec(NoTranspose, *p, *r); - *r += *b; - - std::cout << "Checking res 2: " << norm(r) << std::endl; - - ERROR_EXIT("na, dass wars wohl!\n"); - - return(0); - } -*/ - - - template<typename VectorType> - int VecSymSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *b, bool reuseMatrix) - { - FUNCNAME("VecSymSolver::solveSystem()"); - - StandardMatVec<Matrix<DOFMatrix*>, SystemVector> *stdMatVec = - dynamic_cast<StandardMatVec<Matrix<DOFMatrix*>, SystemVector> *>(matVec); - - Matrix<DOFMatrix*> *m = stdMatVec->getMatrix(); - - DOFMatrix* dofm = (*m)[0][0]; - - int nComponents = m->getSize(); - int oneMatrixSize = dofm->getFESpace()->getAdmin()->getUsedSize(); - int bigMatrixSize = oneMatrixSize * nComponents; - - std::vector< std::vector< MatEntry > > newm(bigMatrixSize, std::vector<MatEntry>(0)); - std::vector<double> xvec(bigMatrixSize); - std::vector<double> bvec(bigMatrixSize); - - int nElements = 0; - - for (int stencilRow = 0; stencilRow < nComponents; stencilRow++) { - for (int stencilCol = 0; stencilCol < nComponents; stencilCol++) { - - if (!(*m)[stencilRow][stencilCol]) { - continue; - } - - // std::cout << "------------------------------" << std::endl; - // std::cout << "Matrix " << stencilRow << " - " << stencilCol << std::endl; - - // (*m)[stencilRow][stencilCol]->print(); - - DOFMatrix::Iterator matrixRow((*m)[stencilRow][stencilCol], USED_DOFS); - int rowIndex = 0; - for (matrixRow.reset(); !matrixRow.end(); matrixRow++, rowIndex++) { - for (int i = 0; i < static_cast<int>((*matrixRow).size()); i++) { - if ((*matrixRow)[i].col >= 0) { - MatEntry newMe; - newMe.entry = (*matrixRow)[i].entry; - newMe.col = ((*matrixRow)[i].col * nComponents) + stencilCol; - - newm[(rowIndex * nComponents) + stencilRow].push_back(newMe); - - nElements++; - } - } - } - -// if ((*m)[stencilRow][stencilCol]->symmetric()) { -// std::cout << "Matrix " << stencilRow << "-" << stencilCol << " ist symmetrisch!" << std::endl; -// } else { -// std::cout << "Matrix " << stencilRow << "-" << stencilCol << " ist nicht symmetrisch!" << std::endl; -// } - - - } - } - - - for (int i = 0; i < static_cast<int>(newm.size()); i++) { - for (int j = 0; j < static_cast<int>(newm[i].size()); j++) { - if (newm[i][j].col == i) { - MatEntry tmp = newm[i][0]; - newm[i][0] = newm[i][j]; - newm[i][j] = tmp; - - break; - } - } - } - -// std::cout << "-------------------------------" << std::endl; -// for (int i = 0; i < static_cast<int>(newm.size()); i++) { -// std::cout << "row : " << i << std::endl; -// for (int j = 0; j < static_cast<int>(newm[i].size()); j++) { -// std::cout << " ( " << newm[i][j].col << ", " << newm[i][j].entry << ")"; -// } -// std::cout << std::endl; -// } - - for (int i = 0; i < x->getSize(); i++) { - DOFVector<double>::Iterator it(x->getDOFVector(i), USED_DOFS); - - int counter = 0; - for (it.reset(); !it.end(); it++, counter++) { - xvec[counter * nComponents + i] = *it; - } - } - - for (int i = 0; i < b->getSize(); i++) { - DOFVector<double>::Iterator it(b->getDOFVector(i), USED_DOFS); - - int counter = 0; - for (it.reset(); !it.end(); it++, counter++) { - bvec[counter * nComponents + i] = *it; - } - } - - /* ======= CHOLMOD ========= - std::fstream file; - - file.open("matrix.m", fstream::out); - file << newm.size() << " " << newm.size() << " " << nElements << std::endl; - for (int i = 0; i < static_cast<int>(newm.size()); i++) { - for (int j = 0; j < static_cast<int>(newm[i].size()); j++) { - file << i + 1 << " " << newm[i][j].col + 1 << " " << newm[i][j].entry << std::endl; - } - } - file.close(); - - file.open("vector.m", fstream::out); - file << bvec.size() << " 1" << std::endl; - for (int i = 0; i < static_cast<int>(bvec.size()); i++) { - file << bvec[i] << std::endl; - } - file.close(); - */ - - bool isSym = true; - - for (int i = 0; i < static_cast<int>(newm.size()); i++) { - for (int j = 0; j < static_cast<int>(newm[i].size()); j++) { - int col = newm[i][j].col; - - if (col != i) { - for (int k = 0; k < static_cast<int>(newm[col].size()); k++) { - if (newm[col][k].col == i) { - if (newm[i][j].entry != newm[col][k].entry) { - isSym = false; - } - } - } - } - } - } - - if (isSym) { - std::cout << "Matrix is symmetrisch!" << std::endl; - } else { - std::cout << "Matrix ist nicht symmetrisch!" << std::endl; - } - - - - /* ======= CHOLMOD ========= - - double one [2] = {1,0}, m1 [2] = {-1,0}; - cholmod_sparse *A; - cholmod_dense *ch_b; - cholmod_dense *ch_x; - cholmod_dense *ch_r; - cholmod_common c; - cholmod_factor *L; - cholmod_start(&c); - - FILE *f = fopen("matrix.m", "r"); - A = cholmod_read_sparse(f, &c); - fclose(f); - - f = fopen("vector.m", "r"); - ch_b = cholmod_read_dense(f, &c); - fclose(f); - - L = cholmod_analyze(A, &c); - cholmod_factorize(A, L, &c); - - ch_x = cholmod_solve(CHOLMOD_A, L, ch_b, &c); - ch_r = cholmod_copy_dense(ch_b, &c); - cholmod_sdmult (A, 0, m1, one, ch_x, ch_r, &c) ; - std::cout << "NORM: " << cholmod_norm_dense(ch_r, 2, &c) << std::endl; - - cholmod_finish(&c); - */ - - //GMResSolver2< std::vector<double> > solver2(this->name); - //CGSolver< std::vector<double> > solver2(this->name); - // BiCGStab< std::vector<double> > solver2(this->name); - - // solver2.initParameters(); - // solver2.setVectorCreator(NEW StlVectorCreator(bigMatrixSize)); - - // StandardMatVec< std::vector< std::vector<MatEntry> >, std::vector<double> > mv(&newm); - - // ILUPreconditionerStd ilu; - // ilu.setMatrix(&newm); - - // DiagonalPreconditionerStd diag; - // diag.setMatrix(&newm); - - // solver2.solve(&mv, &xvec, &bvec, &diag); - - for (int i = 0; i < x->getSize(); i++) { - DOFVector<double>::Iterator it(x->getDOFVector(i), USED_DOFS); - - int counter = 0; - for (it.reset(); !it.end(); it++, counter++) { - *it = xvec[counter * nComponents + i]; - } - } - - *p = *x; - *p *= -1.0; - matVec->matVec(NoTranspose, *p, *r); - *r += *b; - - std::cout << "NORM: " << norm(r) << std::endl; - - // ERROR_EXIT("DA\n"); - - return(1); - } - -} -- GitLab