From 173ee4217e7763198226733c80b7fee47043fb23 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Wed, 9 Feb 2011 08:07:56 +0000 Subject: [PATCH] Code revision in mesh refinement and coarsening. --- AMDiS/libtool | 64 +++++------ AMDiS/src/CoarseningManager.h | 12 +- AMDiS/src/CoarseningManager1d.h | 3 +- AMDiS/src/CoarseningManager2d.cc | 33 +++--- AMDiS/src/CoarseningManager2d.h | 6 +- AMDiS/src/CoarseningManager3d.cc | 109 +++++++++--------- AMDiS/src/CoarseningManager3d.h | 10 +- AMDiS/src/RCNeighbourList.cc | 68 ++++++----- AMDiS/src/RCNeighbourList.h | 31 ++--- AMDiS/src/RefinementManager.cc | 1 - AMDiS/src/RefinementManager2d.cc | 39 +++---- AMDiS/src/RefinementManager2d.h | 4 +- AMDiS/src/RefinementManager3d.cc | 160 ++++++++++++-------------- AMDiS/src/RefinementManager3d.h | 18 ++- AMDiS/src/parallel/MeshDistributor.cc | 2 +- 15 files changed, 266 insertions(+), 294 deletions(-) diff --git a/AMDiS/libtool b/AMDiS/libtool index 6a7f3c76..ace48e58 100755 --- a/AMDiS/libtool +++ b/AMDiS/libtool @@ -30,10 +30,10 @@ # the same distribution terms that you use for the rest of that program. # A sed program that does not truncate output. -SED="/bin/sed" +SED="/usr/bin/sed" # Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="/bin/sed -e 1s/^X//" +Xsed="/usr/bin/sed -e 1s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. @@ -44,7 +44,7 @@ available_tags=" CXX F77" # ### BEGIN LIBTOOL CONFIG -# Libtool was configured on host NWRW15: +# Libtool was configured on host p1q024: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -66,12 +66,12 @@ fast_install=yes # The host system. host_alias= -host=i686-pc-linux-gnu +host=x86_64-unknown-linux-gnu host_os=linux-gnu # The build system. build_alias= -build=i686-pc-linux-gnu +build=x86_64-unknown-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. @@ -82,13 +82,13 @@ AR="ar" AR_FLAGS="cru" # A C compiler. -LTCC="gcc" +LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" # LTCC compiler flags. LTCFLAGS="-g -O2" # A language-specific compiler. -CC="gcc" +CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" # Is the compiler the GNU C compiler? with_gcc=yes @@ -97,7 +97,7 @@ with_gcc=yes EGREP="grep -E" # The linker used to build libraries. -LD="/usr/bin/ld" +LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64" # Whether we need hard or soft links. LN_S="ln -s" @@ -171,7 +171,7 @@ dlopen_self=unknown dlopen_self_static=unknown # Compiler flag to prevent dynamic linking. -link_static_flag="-static" +link_static_flag="" # Compiler flag to turn off builtin functions. no_builtin_flag=" -fno-builtin" @@ -325,10 +325,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=" /u/witkowski/local/lib/i386-redhat-linux/4.1.2/ /u/witkowski/local/lib/ /u/witkowski/local/intel/mkl/10.0.1.014/lib/32/i386-redhat-linux/4.1.2/ /u/witkowski/local/intel/mkl/10.0.1.014/lib/32/ /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=" /fastfs/wir/local/lib/x86_64-suse-linux/4.1.2/ /fastfs/wir/local/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/ /usr/lib/gcc/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/ /lib/x86_64-suse-linux/4.1.2/ /lib/../lib64/ /usr/lib/x86_64-suse-linux/4.1.2/ /usr/lib/../lib64/ /fastfs/wir/local/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../ /lib/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/mysql /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib /usr/lib/xulrunner-1.9.2 " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" @@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` # End: # ### BEGIN LIBTOOL TAG CONFIG: CXX -# Libtool was configured on host NWRW15: +# Libtool was configured on host p1q024: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -6782,12 +6782,12 @@ fast_install=yes # The host system. host_alias= -host=i686-pc-linux-gnu +host=x86_64-unknown-linux-gnu host_os=linux-gnu # The build system. build_alias= -build=i686-pc-linux-gnu +build=x86_64-unknown-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. @@ -6798,13 +6798,13 @@ AR="ar" AR_FLAGS="cru" # A C compiler. -LTCC="gcc" +LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" # LTCC compiler flags. LTCFLAGS="-g -O2" # A language-specific compiler. -CC="g++" +CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicxx" # Is the compiler the GNU C compiler? with_gcc=yes @@ -6813,7 +6813,7 @@ with_gcc=yes EGREP="grep -E" # The linker used to build libraries. -LD="/usr/bin/ld" +LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64" # Whether we need hard or soft links. LN_S="ln -s" @@ -6887,7 +6887,7 @@ dlopen_self=unknown dlopen_self_static=unknown # Compiler flag to prevent dynamic linking. -link_static_flag="-static" +link_static_flag="" # Compiler flag to turn off builtin functions. no_builtin_flag=" -fno-builtin" @@ -6942,11 +6942,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o" +predep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbeginS.o" # 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="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o" # Dependencies to place before the objects being linked to create a # shared library. @@ -6954,11 +6954,11 @@ predeps="" # Dependencies to place after the objects being linked to create a # shared library. -postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s" +postdeps="-lmpi_cxx -lmpi -lopen-rte -lopen-pal -libverbs -lrt -lnuma -ldl -lnsl -lutil -ldl -lstdc++ -lm -lgcc_s -lpthread -lc -lgcc_s" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path="-L/u/witkowski/local/lib -L/u/witkowski/local/intel/mkl/10.0.1.014/lib/32 -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="-L/usr/lib64 -L/licsoft/libraries/openmpi/1.2.6/64bit/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/fastfs/wir/local/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.." # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -7038,10 +7038,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=" /u/witkowski/local/lib/i386-redhat-linux/4.1.2/ /u/witkowski/local/lib/ /u/witkowski/local/intel/mkl/10.0.1.014/lib/32/i386-redhat-linux/4.1.2/ /u/witkowski/local/intel/mkl/10.0.1.014/lib/32/ /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=" /fastfs/wir/local/lib/x86_64-suse-linux/4.1.2/ /fastfs/wir/local/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/ /usr/lib/gcc/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/ /lib/x86_64-suse-linux/4.1.2/ /lib/../lib64/ /usr/lib/x86_64-suse-linux/4.1.2/ /usr/lib/../lib64/ /fastfs/wir/local/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../ /lib/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/mysql /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib /usr/lib/xulrunner-1.9.2 " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" @@ -7065,7 +7065,7 @@ include_expsyms="" # ### BEGIN LIBTOOL TAG CONFIG: F77 -# Libtool was configured on host NWRW15: +# Libtool was configured on host p1q024: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -7087,12 +7087,12 @@ fast_install=yes # The host system. host_alias= -host=i686-pc-linux-gnu +host=x86_64-unknown-linux-gnu host_os=linux-gnu # The build system. build_alias= -build=i686-pc-linux-gnu +build=x86_64-unknown-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. @@ -7103,7 +7103,7 @@ AR="ar" AR_FLAGS="cru" # A C compiler. -LTCC="gcc" +LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" # LTCC compiler flags. LTCFLAGS="-g -O2" @@ -7112,13 +7112,13 @@ LTCFLAGS="-g -O2" CC="g77" # Is the compiler the GNU C compiler? -with_gcc=yes +with_gcc= # An ERE matcher. EGREP="grep -E" # The linker used to build libraries. -LD="/usr/bin/ld" +LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64" # Whether we need hard or soft links. LN_S="ln -s" @@ -7346,10 +7346,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=" /u/witkowski/local/lib/i386-redhat-linux/3.4.6/ /u/witkowski/local/lib/ /u/witkowski/local/intel/mkl/10.0.1.014/lib/32/i386-redhat-linux/3.4.6/ /u/witkowski/local/intel/mkl/10.0.1.014/lib/32/ /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=" /fastfs/wir/local/lib/x86_64-suse-linux/3.3.5/ /fastfs/wir/local/lib/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/ /usr/lib/gcc/x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../ /lib/x86_64-suse-linux/3.3.5/ /lib/ /usr/lib/x86_64-suse-linux/3.3.5/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/mysql /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib /usr/lib/xulrunner-1.9.2 " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" diff --git a/AMDiS/src/CoarseningManager.h b/AMDiS/src/CoarseningManager.h index c472dd7f..373092cc 100644 --- a/AMDiS/src/CoarseningManager.h +++ b/AMDiS/src/CoarseningManager.h @@ -72,16 +72,8 @@ namespace AMDiS { protected: - /** \brief - * If the mesh is coarsened by non recurisive traversal, this method - * spezifies - * how one element of the mesh is coarsened. The method can be overriden - * by sub classes, if used. - */ - virtual int coarsenFunction(ElInfo *) - { - return 0; - } + /// Defines the way how one element of the mesh is coarsen. + virtual void coarsenFunction(ElInfo *) {} /** \brief * Propagate coarsening information over the whole hierarchy diff --git a/AMDiS/src/CoarseningManager1d.h b/AMDiS/src/CoarseningManager1d.h index 2997739c..1fa47be2 100644 --- a/AMDiS/src/CoarseningManager1d.h +++ b/AMDiS/src/CoarseningManager1d.h @@ -50,11 +50,10 @@ namespace AMDiS { protected: /// Not needed in this sub class - int coarsenFunction(ElInfo *) + void coarsenFunction(ElInfo *) { FUNCNAME("CoarseningManager1d::coarsenFunction"); ERROR_EXIT("not used for dim = 1"); - return 0; } /// Needed instead of coarsenFunction in 1d. diff --git a/AMDiS/src/CoarseningManager2d.cc b/AMDiS/src/CoarseningManager2d.cc index 17250d23..f3419ca6 100644 --- a/AMDiS/src/CoarseningManager2d.cc +++ b/AMDiS/src/CoarseningManager2d.cc @@ -73,14 +73,14 @@ namespace AMDiS { /* of data (if possible) and finally coarsen the patch elements */ /****************************************************************************/ - void CoarseningManager2d::coarsenPatch(RCNeighbourList *coarsenList, + void CoarseningManager2d::coarsenPatch(RCNeighbourList &coarsenList, int n_neigh, int bound) { Triangle *el = - dynamic_cast<Triangle*>(const_cast<Element*>(coarsenList->getElement(0))); + dynamic_cast<Triangle*>(const_cast<Element*>(coarsenList.getElement(0))); Triangle *neigh = - dynamic_cast<Triangle*>(const_cast<Element*>(coarsenList->getElement(1))); + dynamic_cast<Triangle*>(const_cast<Element*>(coarsenList.getElement(1))); DegreeOfFreedom *dof[3]; dof[0] = const_cast<int*>(el->getChild(0)->getDof(2)); @@ -103,7 +103,7 @@ namespace AMDiS { } if (mesh->getNumberOfDofs(EDGE) || mesh->getNumberOfDofs(CENTER)) - coarsenList->addDOFParents(n_neigh); + coarsenList.addDOFParents(n_neigh); // restrict dof vectors to the parents on the patch @@ -112,7 +112,7 @@ namespace AMDiS { DOFAdmin* admin = const_cast<DOFAdmin*>(&mesh->getDofAdmin(iadmin)); for (std::list<DOFIndexedBase*>::iterator it = admin->beginDOFIndexed(); it != admin->endDOFIndexed(); ++it) - (*it)->coarseRestrict(*coarsenList, n_neigh); + (*it)->coarseRestrict(coarsenList, n_neigh); } coarsenTriangle(el); @@ -133,7 +133,7 @@ namespace AMDiS { } - int CoarseningManager2d::coarsenFunction(ElInfo *el_info) + void CoarseningManager2d::coarsenFunction(ElInfo *el_info) { Triangle *el = dynamic_cast<Triangle*>(const_cast<Element*>(el_info->getElement())); DegreeOfFreedom *edge[2]; @@ -143,20 +143,20 @@ namespace AMDiS { coarse_list.setCoarseningManager(this); if (el->getMark() >= 0) - return 0; // el must not be coarsend, return + return; // el must not be coarsend, return if (!(el->getChild(0))) - return 0; // single leaves don't get coarsened + return; // single leaves don't get coarsened if (el->getChild(0)->getMark() >= 0 || el->getChild(1)->getMark() >= 0) { // one of the children must not be coarsend; return :( el->setMark(0); - return 0; + return; } if (!el->getChild(0)->isLeaf() || !el->getChild(1)->isLeaf()) { // one of the children is not a leaf element; try again later on doMore = true; - return 0; + return; } // give the refinement edge the right orientation @@ -186,15 +186,12 @@ namespace AMDiS { if (coarse_list.doCoarsePatch(n_neigh)) { int n_neigh_periodic; DegreeOfFreedom *next_edge[2]; - RCNeighbourList *periodicList; + RCNeighbourList periodicList; while (edge[0] != NULL) { - periodicList = coarse_list.periodicSplit(edge, - next_edge, - &n_neigh, - &n_neigh_periodic); - - TEST_EXIT_DBG(periodicList)("periodicList = NULL\n"); + coarse_list.periodicSplit(edge, next_edge, + &n_neigh, &n_neigh_periodic, + periodicList); coarsenPatch(periodicList, n_neigh_periodic, bound); @@ -202,8 +199,6 @@ namespace AMDiS { edge[1] = next_edge[1]; } } - - return 0; } } diff --git a/AMDiS/src/CoarseningManager2d.h b/AMDiS/src/CoarseningManager2d.h index 1a9c0707..593f1b04 100644 --- a/AMDiS/src/CoarseningManager2d.h +++ b/AMDiS/src/CoarseningManager2d.h @@ -44,8 +44,8 @@ namespace AMDiS { virtual ~CoarseningManager2d() {} protected: - /// Implements CoarseningManager::coarsenFunction - virtual int coarsenFunction(ElInfo *el_info); + /// Implements \ref CoarseningManager::coarsenFunction + void coarsenFunction(ElInfo *el_info); /** \brief * Coarsens a single Triangle of the coarsening patch. DOFs @@ -59,7 +59,7 @@ namespace AMDiS { * First rebuild the DOFs on the parents then do restriction * of data (if possible) and finally coarsen the patch elements */ - void coarsenPatch(RCNeighbourList *coarsenList, int n_neigh, int bound); + void coarsenPatch(RCNeighbourList &coarsenList, int n_neigh, int bound); }; diff --git a/AMDiS/src/CoarseningManager3d.cc b/AMDiS/src/CoarseningManager3d.cc index e5a370e0..bbf40633 100644 --- a/AMDiS/src/CoarseningManager3d.cc +++ b/AMDiS/src/CoarseningManager3d.cc @@ -22,39 +22,39 @@ namespace AMDiS { - int CoarseningManager3d::coarsenFunction(ElInfo *el_info) + void CoarseningManager3d::coarsenFunction(ElInfo *el_info) { Tetrahedron *el = dynamic_cast<Tetrahedron*>(const_cast<Element*>(el_info->getElement())); - DegreeOfFreedom *edge[2]; - int n_neigh, bound = 0; - ElInfo *elinfo = el_info; - RCNeighbourList *coarsenList; - if (el->getMark() >= 0) - return 0; // el must not be coarsend, return :-( + return; // el must not be coarsend, return :-( + if (el->isLeaf()) - return 0; // single leaves don't get coarsened + return; // single leaves don't get coarsened - if (el->getChild(0)->getMark() >= 0 || el->getChild(1)->getMark() >= 0) { + if (el->getChild(0)->getMark() >= 0 || el->getChild(1)->getMark() >= 0) { // one of the children must not be coarsend; return :-( el->setMark(0); - return 0; + return; } if (!(el->getChild(0)->isLeaf()) || !(el->getChild(1)->isLeaf())) { // one of the children is not a leaf element; try again later on doMore = true; - return 0; + return; } + DegreeOfFreedom *edge[2]; + int n_neigh, bound = 0; + ElInfo *elinfo = el_info; + /****************************************************************************/ /* get a list for storing all elements at the coarsening edge and fill it */ /****************************************************************************/ - coarsenList = new RCNeighbourList(mesh->getMaxEdgeNeigh()); - coarsenList->setCoarseningManager(this); + RCNeighbourList coarsenList(mesh->getMaxEdgeNeigh()); + coarsenList.setCoarseningManager(this); /****************************************************************************/ /* give the refinement edge the right orientation */ @@ -68,17 +68,17 @@ namespace AMDiS { edge[0] = const_cast<int*>(el->getDof(1)); } - coarsenList->setElement(0, el, true); + coarsenList.setElement(0, el, true); n_neigh = 1; - coarsenList->setOppVertex(0,0,0); - coarsenList->setElType(0, el_info->getType()); + coarsenList.setOppVertex(0, 0, 0); + coarsenList.setElType(0, el_info->getType()); bound = false; if (getCoarsenPatch(elinfo, edge, 0, coarsenList, &n_neigh)) { getCoarsenPatch(elinfo, edge, 1, coarsenList, &n_neigh); bound = true; } - coarsenList->getNeighOnPatch(n_neigh, bound); + coarsenList.fillNeighbourRelations(n_neigh, bound); /****************************************************************************/ /* check wether we can coarsen the patch or not */ @@ -88,18 +88,15 @@ namespace AMDiS { // === check for periodic boundary ========================================== // ========================================================================== - if (coarsenList->doCoarsePatch(n_neigh)) { + if (coarsenList.doCoarsePatch(n_neigh)) { int n_neigh_periodic; DegreeOfFreedom *next_edge[2]; - RCNeighbourList *periodicList; + RCNeighbourList periodicList; while (edge[0] != NULL) { - periodicList = coarsenList->periodicSplit(edge, - next_edge, - &n_neigh, - &n_neigh_periodic); - - TEST_EXIT_DBG(periodicList)("periodicList = NULL\n"); + coarsenList.periodicSplit(edge, next_edge, + &n_neigh, &n_neigh_periodic, + periodicList); coarsenPatch(periodicList, n_neigh_periodic, bound); @@ -107,10 +104,6 @@ namespace AMDiS { edge[1] = next_edge[1]; } } - - delete coarsenList; - - return 0; } /*****************************************************************************/ @@ -120,18 +113,18 @@ namespace AMDiS { /* is part of the domains boundary */ /*****************************************************************************/ - void CoarseningManager3d::coarsenTetrahedron(RCNeighbourList *coarsenList, + void CoarseningManager3d::coarsenTetrahedron(RCNeighbourList &coarsenList, int index) { Tetrahedron *el = - dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList->getElement(index))); + dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList.getElement(index))); Tetrahedron *child[2]; Tetrahedron *neigh; int dir, el_type, i, node, opp_v; child[0] = dynamic_cast<Tetrahedron*>(const_cast<Element*>(el->getChild(0))); child[1] = dynamic_cast<Tetrahedron*>(const_cast<Element*>(el->getChild(1))); - el_type = coarsenList->getType(index); + el_type = coarsenList.getType(index); /****************************************************************************/ /* Information about patch neighbours is still valid! But edge and face */ @@ -140,10 +133,10 @@ namespace AMDiS { for (dir = 0; dir < 2; dir++) { neigh = - dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList->getNeighbourElement(index, dir))); - opp_v = coarsenList->getOppVertex(index, dir); + dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList.getNeighbourElement(index, dir))); + opp_v = coarsenList.getOppVertex(index, dir); - if (!neigh || neigh->isLeaf()) { + if (!neigh || neigh->isLeaf()) { /****************************************************************************/ /* boundary face or neigh has been coarsend: free the dof's in the face */ /****************************************************************************/ @@ -215,7 +208,7 @@ namespace AMDiS { bool CoarseningManager3d::getCoarsenPatch(ElInfo *el_info, DegreeOfFreedom *edge[2], int dir, - RCNeighbourList *coarsenList, + RCNeighbourList &coarsenList, int *n_neigh) { FUNCNAME("CoarseningManager3d::getCoarsenPatch"); @@ -231,13 +224,14 @@ namespace AMDiS { {0,1}}; el = dynamic_cast<Tetrahedron*>(const_cast<Element*>(el_info->getElement())); - neigh = dynamic_cast<Tetrahedron*>(const_cast<Element*>(el_info->getNeighbour(3 - dir))); + neigh = + dynamic_cast<Tetrahedron*>(const_cast<Element*>(el_info->getNeighbour(3 - dir))); if (neigh == NULL) return true; - opp_v = el_info->getOppVertex(3-dir); + opp_v = el_info->getOppVertex(3 - dir); - neigh_info = stack->traverseNeighbour3d(el_info, 3-dir); + neigh_info = stack->traverseNeighbour3d(el_info, 3 - dir); TEST_EXIT_DBG(neigh == neigh_info->getElement()) ("neigh %d and neigh_info->el %d are not identical\n", neigh->getIndex(), neigh_info->getElement()->getIndex()); @@ -245,9 +239,9 @@ namespace AMDiS { /* we have to go back to the starting element via opp_v values */ /* correct information is produce by get_neigh_on_patch() */ /****************************************************************************/ - coarsenList->setOppVertex(*n_neigh, 0, opp_v); - coarsenList->setElement(*n_neigh, neigh); - coarsenList->setElType(*n_neigh, neigh_info->getType()); + coarsenList.setOppVertex(*n_neigh, 0, opp_v); + coarsenList.setElement(*n_neigh, neigh); + coarsenList.setElType(*n_neigh, neigh_info->getType()); int n_vertices = mesh->getGeo(VERTEX); @@ -273,7 +267,7 @@ namespace AMDiS { neigh->getDof(1,0), neigh->getDof(2,0), neigh->getDof(3,0)); } edge_no = Tetrahedron::edgeOfDofs[j][k]; - coarsenList->setCoarsePatch(*n_neigh, edge_no == 0); + coarsenList.setCoarsePatch(*n_neigh, edge_no == 0); /****************************************************************************/ /* get the direction of the next neighbour */ @@ -287,7 +281,8 @@ namespace AMDiS { ++*n_neigh; opp_v = neigh_info->getOppVertex(i); - neigh = dynamic_cast<Tetrahedron*>(const_cast<Element*>(neigh_info->getNeighbour(i))); + neigh = + dynamic_cast<Tetrahedron*>(const_cast<Element*>(neigh_info->getNeighbour(i))); if (neigh) { neigh_info = stack->traverseNeighbour3d(neigh_info, i); TEST_EXIT_DBG(neigh == neigh_info->getElement()) @@ -297,9 +292,9 @@ namespace AMDiS { /* we have to go back to the starting element via opp_v values */ /* correct information is produce by get_neigh_on_patch() */ /****************************************************************************/ - coarsenList->setOppVertex(*n_neigh, 0, opp_v); - coarsenList->setElement(*n_neigh, neigh); - coarsenList->setElType(*n_neigh, neigh_info->getType()); + coarsenList.setOppVertex(*n_neigh, 0, opp_v); + coarsenList.setElement(*n_neigh, neigh); + coarsenList.setElType(*n_neigh, neigh_info->getType()); } else { break; } @@ -313,13 +308,13 @@ namespace AMDiS { /****************************************************************************/ i = *n_neigh - 1; - opp_v = coarsenList->getOppVertex(i, 0); + opp_v = coarsenList.getOppVertex(i, 0); do { TEST_EXIT_DBG(neigh_info->getNeighbour(opp_v) && i > 0) ("while looping back domains boundary was reached or i == 0\n"); - opp_v = coarsenList->getOppVertex(i--, 0); + opp_v = coarsenList.getOppVertex(i--, 0); neigh_info = stack->traverseNeighbour3d(neigh_info, opp_v); - } while(neigh_info->getElement() != el); + } while (neigh_info->getElement() != el); return true; } @@ -329,14 +324,14 @@ namespace AMDiS { /* of data (if possible) and finally coarsen the patch elements */ /****************************************************************************/ - void CoarseningManager3d::coarsenPatch(RCNeighbourList *coarsenList, + void CoarseningManager3d::coarsenPatch(RCNeighbourList &coarsenList, int n_neigh, int bound) { FUNCNAME("CoarseningManager3d::coarsenPatch()"); Tetrahedron *el = - dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList->getElement(0))); + dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList.getElement(0))); DegreeOfFreedom *dof = NULL; TEST_EXIT_DBG(el)("No element!\n"); @@ -354,7 +349,7 @@ namespace AMDiS { mesh->getNumberOfDofs(FACE) || mesh->getNumberOfDofs(CENTER)) { for (int i = 0; i < n_neigh; i++) - coarsenList->addDOFParent(i, dof); + coarsenList.addDOFParent(i, dof); } @@ -366,7 +361,7 @@ namespace AMDiS { DOFAdmin* admin = const_cast<DOFAdmin*>(&mesh->getDofAdmin(iadmin)); std::list<DOFIndexedBase*>::iterator end = admin->endDOFIndexed(); for (it = admin->beginDOFIndexed(); it != end; ++it) - (*it)->coarseRestrict(*coarsenList, n_neigh); + (*it)->coarseRestrict(coarsenList, n_neigh); } // === And now start to coarsen the patch: remove dof's of the coarsening edge. === @@ -380,11 +375,11 @@ namespace AMDiS { mesh->freeDof(const_cast<int*>(el->getChild(1)->getDof(node)), EDGE); } - if (coarsenList->getElement(0)->isNewCoordSet()) - coarsenList->getElement(0)->eraseNewCoord(); + if (coarsenList.getElement(0)->isNewCoordSet()) + coarsenList.getElement(0)->eraseNewCoord(); for (int i = 0; i < n_neigh; i++) { - coarsenList->getElement(i)->setNewCoord(NULL); + coarsenList.getElement(i)->setNewCoord(NULL); coarsenTetrahedron(coarsenList, i); } diff --git a/AMDiS/src/CoarseningManager3d.h b/AMDiS/src/CoarseningManager3d.h index 56d37304..5b70c65c 100644 --- a/AMDiS/src/CoarseningManager3d.h +++ b/AMDiS/src/CoarseningManager3d.h @@ -43,8 +43,8 @@ namespace AMDiS { virtual ~CoarseningManager3d() {} protected: - /// Implements CoarseningManager::coarsenFunction - int coarsenFunction(ElInfo *el_info); + /// Implements \ref CoarseningManager::coarsenFunction + void coarsenFunction(ElInfo *el_info); /** \brief * Coarsens a single Tetrahedron of the coarsening patch. DOFs @@ -52,7 +52,7 @@ namespace AMDiS { * at the boundary or the coarsening patch still belong to * the parent. Do not remove them form the mesh!!! */ - void coarsenTetrahedron(RCNeighbourList *coarsenList, int index); + void coarsenTetrahedron(RCNeighbourList &coarsenList, int index); /** \brief * Gets the patch for coarsening starting on element @@ -65,13 +65,13 @@ namespace AMDiS { * the starting element before we return */ bool getCoarsenPatch(ElInfo* el_info, DegreeOfFreedom *edge[2], - int dir, RCNeighbourList* coarsenList, int *n_neigh); + int dir, RCNeighbourList &coarsenList, int *n_neigh); /** \brief * First rebuild the DOFs on the parents then do restriction * of data (if possible) and finally coarsen the patch elements */ - void coarsenPatch(RCNeighbourList *coarsenList, int n_neigh, int bound); + void coarsenPatch(RCNeighbourList &coarsenList, int n_neigh, int bound); }; diff --git a/AMDiS/src/RCNeighbourList.cc b/AMDiS/src/RCNeighbourList.cc index bc883250..e91f8904 100644 --- a/AMDiS/src/RCNeighbourList.cc +++ b/AMDiS/src/RCNeighbourList.cc @@ -33,12 +33,13 @@ namespace AMDiS { rclist[i] = new RCListElement; } + RCNeighbourList::~RCNeighbourList() { - for (int i = 0; i < static_cast<int>(rclist.size()); i++) - delete rclist[i]; + clearList(); } + /****************************************************************************/ /* do_coarse_patch: if patch can be coarsend return true, else false and */ /* reset the element marks */ @@ -108,26 +109,26 @@ namespace AMDiS { } - void RCNeighbourList::getNeighOnPatch(int n_neigh, int bound) + void RCNeighbourList::fillNeighbourRelations(int n_neigh, int bound) { FUNCNAME("RCNeighbourList::getNeighOnPatch()"); for (int i = 0; i < n_neigh; i++) { Element *el = rclist[i]->el; - Element *neigh = NULL; - rclist[i]->no = i; + rclist[i]->ith = i; for (int dir = 0; dir < 2; dir++) { int j = 0; for (; j < n_neigh; j++) { - if ((neigh = rclist[j]->el) == el) + Element *neigh = rclist[j]->el; + if (neigh == el) continue; int k = 0; for (; k < 2; k++) { - if (neigh->getDof(2+k) == el->getDof(3-dir)) { + if (neigh->getDof(2 + k) == el->getDof(3 - dir)) { rclist[i]->neigh[dir] = rclist[j]; - rclist[i]->oppVertex[dir] = 3-k; + rclist[i]->oppVertex[dir] = 3 - k; break; } } @@ -144,6 +145,7 @@ namespace AMDiS { } } + void RCNeighbourList::addDOFParent(int elIndex, DegreeOfFreedom* dof) // 3d { Element *el = rclist[elIndex]->el; @@ -164,16 +166,16 @@ namespace AMDiS { /* and now those handed on by the children */ /****************************************************************************/ - el->setDof(node + 1, const_cast<int*>( el->getFirstChild()->getDof(node))); - el->setDof(node + 2, const_cast<int*>( el->getFirstChild()->getDof(node + 1))); - el->setDof(node + 5, const_cast<int*>( el->getFirstChild()->getDof(node + 3))); + el->setDof(node + 1, const_cast<int*>(el->getFirstChild()->getDof(node))); + el->setDof(node + 2, const_cast<int*>(el->getFirstChild()->getDof(node + 1))); + el->setDof(node + 5, const_cast<int*>(el->getFirstChild()->getDof(node + 3))); if (coarse_list->elType) { - el->setDof(node + 3, const_cast<int*>( el->getSecondChild()->getDof(node))); - el->setDof(node + 4, const_cast<int*>( el->getSecondChild()->getDof(node + 1))); + el->setDof(node + 3, const_cast<int*>(el->getSecondChild()->getDof(node))); + el->setDof(node + 4, const_cast<int*>(el->getSecondChild()->getDof(node + 1))); } else { - el->setDof(node + 3, const_cast<int*>( el->getSecondChild()->getDof(node + 1))); - el->setDof(node + 4, const_cast<int*>( el->getSecondChild()->getDof(node))); + el->setDof(node + 3, const_cast<int*>(el->getSecondChild()->getDof(node + 1))); + el->setDof(node + 4, const_cast<int*>(el->getSecondChild()->getDof(node))); } } @@ -220,6 +222,7 @@ namespace AMDiS { } } + void RCNeighbourList::addDOFParents(int n_neigh) // 2d { Mesh *coarse_mesh = coarseningManager->getMesh(); @@ -311,16 +314,17 @@ namespace AMDiS { } - RCNeighbourList *RCNeighbourList::periodicSplit(DegreeOfFreedom *edge[2], - DegreeOfFreedom *nextEdge[2], - int *n_neigh, - int *n_neigh_periodic) + void RCNeighbourList::periodicSplit(DegreeOfFreedom *edge[2], + DegreeOfFreedom *nextEdge[2], + int *n_neigh, + int *n_neigh_periodic, + RCNeighbourList &periodicList) { - RCNeighbourList *periodicList = NULL; *n_neigh_periodic = 0; int count = 0; int n_neigh_old = *n_neigh; bool secondPart = false; + bool firstSplit = true; nextEdge[0] = NULL; nextEdge[1] = NULL; @@ -343,10 +347,11 @@ namespace AMDiS { (*n_neigh)--; (*n_neigh_periodic)++; - if (!periodicList) { - periodicList = new RCNeighbourList; - insertIt = periodicList->rclist.end(); - periodicList->coarseningManager = coarseningManager; + if (firstSplit) { + periodicList.clearList(); + insertIt = periodicList.rclist.end(); + periodicList.coarseningManager = coarseningManager; + firstSplit = false; } else { if (edge[0]) { TEST_EXIT_DBG((dof0 == edge[0] && dof1 == edge[1]) || @@ -356,11 +361,11 @@ namespace AMDiS { } if (secondPart) { - insertIt = periodicList->rclist.begin(); + insertIt = periodicList.rclist.begin(); secondPart = false; } - insertIt = periodicList->rclist.insert(insertIt, *it); + insertIt = periodicList.rclist.insert(insertIt, *it); ++insertIt; it = rclist.erase(it); @@ -369,9 +374,16 @@ namespace AMDiS { } for (int i = 0; i < *n_neigh_periodic; i++) - periodicList->rclist[i]->no = i; + periodicList.rclist[i]->ith = i; + } + + + void RCNeighbourList::clearList() + { + for (unsigned int i = 0; i < rclist.size(); i++) + delete rclist[i]; - return periodicList; + rclist.clear(); } } diff --git a/AMDiS/src/RCNeighbourList.h b/AMDiS/src/RCNeighbourList.h index 174c84a5..2f5d6b64 100644 --- a/AMDiS/src/RCNeighbourList.h +++ b/AMDiS/src/RCNeighbourList.h @@ -77,11 +77,11 @@ namespace AMDiS { /** \brief * If \ref rclist[i].neigh[j] is not a NULL pointer - * \ref rclist[i].neigh[j]->no will be returned. Otherwise the return value is -1 + * \ref rclist[i].neigh[j]->ith will be returned. Otherwise the return value is -1 */ inline int getNeighbourNr(int i, int j) const { - return (rclist[i]->neigh[j])?rclist[i]->neigh[j]->no:-1; + return rclist[i]->neigh[j] ? rclist[i]->neigh[j]->ith : -1; } /** \brief @@ -91,7 +91,7 @@ namespace AMDiS { */ inline Element* getNeighbourElement(int i, int j) const { - return rclist[i]->neigh[j]? rclist[i]->neigh[j]->el : NULL; + return rclist[i]->neigh[j] ? rclist[i]->neigh[j]->el : NULL; } /// Returns \ref rclist[i].el @@ -99,6 +99,7 @@ namespace AMDiS { { if (static_cast<int>(rclist.size()) <= i) return NULL; + return rclist[i]->el; } @@ -107,6 +108,7 @@ namespace AMDiS { { rclist[i]->el = const_cast<Element*>(el); rclist[i]->flag = cp; + return el; } @@ -125,7 +127,7 @@ namespace AMDiS { virtual bool doCoarsePatch(int n_neigh); /// Sets \ref rclist[i].oppVertex[j] = k - inline void setOppVertex(int i,int j,int k) + inline void setOppVertex(int i, int j, int k) { rclist[i]->oppVertex[j] = k; } @@ -137,7 +139,7 @@ namespace AMDiS { } /// Sets \ref rclist[i].elType = t - inline void setElType(int i,unsigned char t) + inline void setElType(int i, unsigned char t) { rclist[i]->elType = t; } @@ -149,10 +151,10 @@ namespace AMDiS { } /** \brief - * Fills \ref rclist[i].neigh and \ref rclist[i].oppVertex infos ( 0 <= i + * Fills \ref rclist[i].neigh and \ref rclist[i].oppVertex infos (0 <= i * < n_neigh) */ - void getNeighOnPatch(int n_neigh, int bound); + void fillNeighbourRelations(int n_neigh, int bound); /** \brief * Adds those dof's on the parent that are handed on by the @@ -172,10 +174,13 @@ namespace AMDiS { /// Removes DOFs during refinement (2d) void removeDOFParents(int n_neigh); - RCNeighbourList *periodicSplit(DegreeOfFreedom *edge[2], - DegreeOfFreedom *nextEdge[2], - int *n_neigh, - int *n_neigh_periodic); + void periodicSplit(DegreeOfFreedom *edge[2], + DegreeOfFreedom *nextEdge[2], + int *n_neigh, + int *n_neigh_periodic, + RCNeighbourList &periodicList); + + void clearList(); protected: /// Information about one Element of the patch @@ -185,8 +190,8 @@ namespace AMDiS { /// Pointer to the Element Element* el; - /// This is the no-th entry in the RCNeighbourList - int no; + /// This is the i-th entry in the RCNeighbourList + int ith; /** \brief * Only used in the coarsening module: flag is true if the coarsening diff --git a/AMDiS/src/RefinementManager.cc b/AMDiS/src/RefinementManager.cc index a48a57d5..15274006 100644 --- a/AMDiS/src/RefinementManager.cc +++ b/AMDiS/src/RefinementManager.cc @@ -26,7 +26,6 @@ namespace AMDiS { bool RefinementManager::doMoreRecursiveRefine = false; int RefinementManager::callRefineInterpol = 0; - RCNeighbourList* RefinementManager3d::refList = NULL; Flag RefinementManager::globalRefine(Mesh *aMesh, int mark) diff --git a/AMDiS/src/RefinementManager2d.cc b/AMDiS/src/RefinementManager2d.cc index 601a67cf..d79501b5 100644 --- a/AMDiS/src/RefinementManager2d.cc +++ b/AMDiS/src/RefinementManager2d.cc @@ -37,8 +37,8 @@ namespace AMDiS { bool bound = false; DegreeOfFreedom *edge[2]; - RCNeighbourList* refineList = new RCNeighbourList(2); - refineList->setElement(0, elInfo->getElement()); + RCNeighbourList refineList(2); + refineList.setElement(0, elInfo->getElement()); int n_neigh = 1; if (elInfo->getProjection(0) && @@ -71,25 +71,21 @@ namespace AMDiS { DegreeOfFreedom lastNewDOF = -1; DegreeOfFreedom firstNewDOF = -1; - RCNeighbourList *periodicList; - std::map<int, VertexVector*>::iterator it; - std::map<int, VertexVector*>::iterator end = mesh->getPeriodicAssociations().end(); + RCNeighbourList periodicList; while (edge[0] != NULL) { - periodicList = refineList->periodicSplit(edge, next_edge, - &n_neigh, &n_neigh_periodic); - - TEST_EXIT_DBG(periodicList)("periodicList = NULL\n"); + refineList.periodicSplit(edge, next_edge, + &n_neigh, &n_neigh_periodic, + periodicList); newDOF = refinePatch(edge, periodicList, n_neigh_periodic, bound); - delete periodicList; - if (firstNewDOF == -1) firstNewDOF = newDOF; if (lastNewDOF != -1) { - for (it = mesh->getPeriodicAssociations().begin(); it != end; ++it) { + for (std::map<int, VertexVector*>::iterator it = mesh->getPeriodicAssociations().begin(); + it != mesh->getPeriodicAssociations().end(); ++it) { if (it->second) { if (((*(it->second))[edge[0][0]] == last_edge[0][0] && (*(it->second))[edge[1][0]] == last_edge[1][0]) || @@ -111,7 +107,8 @@ namespace AMDiS { } if (lastNewDOF != firstNewDOF) { - for (it = mesh->getPeriodicAssociations().begin(); it != end; ++it) { + for (std::map<int, VertexVector*>::iterator it = mesh->getPeriodicAssociations().begin(); + it != mesh->getPeriodicAssociations().end(); ++it) { if (it->second) { if (((*(it->second))[first_edge[0][0]] == last_edge[0][0] && (*(it->second))[first_edge[1][0]] == last_edge[1][0]) || @@ -124,8 +121,6 @@ namespace AMDiS { } } - delete refineList; - return elInfo; } @@ -176,15 +171,15 @@ namespace AMDiS { DegreeOfFreedom RefinementManager2d::refinePatch(DegreeOfFreedom *edge[2], - RCNeighbourList* refineList, + RCNeighbourList &refineList, int n_neigh, bool bound) { FUNCNAME("RefinementManager2d::refinePatch()"); DegreeOfFreedom *dof[3] = {NULL, NULL, NULL}; Triangle *el = - dynamic_cast<Triangle*>(const_cast<Element*>(refineList->getElement(0))); + dynamic_cast<Triangle*>(const_cast<Element*>(refineList.getElement(0))); Triangle *neigh = - dynamic_cast<Triangle*>(const_cast<Element*>(refineList->getElement(1))); + dynamic_cast<Triangle*>(const_cast<Element*>(refineList.getElement(1))); // === There is one new vertex in the refinement edge. === @@ -224,7 +219,7 @@ namespace AMDiS { std::list<DOFIndexedBase*>::iterator end = admin->endDOFIndexed(); for (std::list<DOFIndexedBase*>::iterator it = admin->beginDOFIndexed(); it != end; it++) - (*it)->refineInterpol(*refineList, n_neigh); + (*it)->refineInterpol(refineList, n_neigh); } @@ -240,7 +235,7 @@ namespace AMDiS { mesh->freeDof(const_cast<int*>(el->getDof(node+2)), EDGE); } if (mesh->getNumberOfDofs(EDGE) || mesh->getNumberOfDofs(CENTER)) - refineList->removeDOFParents(n_neigh); + refineList.removeDOFParents(n_neigh); } return dof[0][0]; @@ -323,7 +318,7 @@ namespace AMDiS { void RefinementManager2d::getRefinePatch(ElInfo **elInfo, DegreeOfFreedom *edge[2], - int dir, RCNeighbourList* refineList, + int dir, RCNeighbourList &refineList, int *n_neigh) { FUNCNAME("RefinementManager2d::getRefinePatch()"); @@ -355,7 +350,7 @@ namespace AMDiS { ("invalid traverse_neighbour1\n"); } - if (refineList->setElement(1, (*elInfo)->getNeighbour(2))) { + if (refineList.setElement(1, (*elInfo)->getNeighbour(2))) { TEST_EXIT_DBG((*elInfo)->getOppVertex(2) == 2) ("no compatible ref. edge after recursive refinement of neighbour\n"); *n_neigh = 2; diff --git a/AMDiS/src/RefinementManager2d.h b/AMDiS/src/RefinementManager2d.h index 3ce0cd83..c0c76484 100644 --- a/AMDiS/src/RefinementManager2d.h +++ b/AMDiS/src/RefinementManager2d.h @@ -56,11 +56,11 @@ namespace AMDiS { * looping around the refinement edge, otherwise 0 */ void getRefinePatch(ElInfo **elInfo, DegreeOfFreedom *edge[2], int dir, - RCNeighbourList* refineList, int *n_neigh); + RCNeighbourList &refineList, int *n_neigh); /// Refines all elements in the patch. DegreeOfFreedom refinePatch(DegreeOfFreedom *edge[2], - RCNeighbourList* refineList, + RCNeighbourList &refineList, int n_neigh, bool bound); /// Implements RefinementManager::refineFunction. diff --git a/AMDiS/src/RefinementManager3d.cc b/AMDiS/src/RefinementManager3d.cc index e3cde25c..df8d3441 100644 --- a/AMDiS/src/RefinementManager3d.cc +++ b/AMDiS/src/RefinementManager3d.cc @@ -29,15 +29,15 @@ namespace AMDiS { - void RefinementManager3d::bisectTetrahedron(RCNeighbourList* ref_list, + void RefinementManager3d::bisectTetrahedron(RCNeighbourList& refineList, int index, DegreeOfFreedom* dof[3], DegreeOfFreedom *edge[2]) { Tetrahedron *el = - dynamic_cast<Tetrahedron*>(const_cast<Element*>(ref_list->getElement(index))); + dynamic_cast<Tetrahedron*>(const_cast<Element*>(refineList.getElement(index))); Tetrahedron *child[2]; - int el_type = ref_list->getType(index); + int el_type = refineList.getType(index); child[0] = dynamic_cast<Tetrahedron*>(mesh->createNewElement(el)); child[1] = dynamic_cast<Tetrahedron*>(mesh->createNewElement(el)); @@ -146,26 +146,26 @@ namespace AMDiS { } if (mesh->getNumberOfDofs(EDGE) || mesh->getNumberOfDofs(FACE)) - fillPatchConnectivity(ref_list, index); + fillPatchConnectivity(refineList, index); } - void RefinementManager3d::fillPatchConnectivity(RCNeighbourList* ref_list, + void RefinementManager3d::fillPatchConnectivity(RCNeighbourList &refineList, int index) { FUNCNAME("RefinementManager3d::fillPatchConnectivity"); - Element *el = ref_list->getElement(index), *neigh; - int el_type = ref_list->getType(index); + Element *el = refineList.getElement(index); + int el_type = refineList.getType(index); int n_type = 0; - int dir, adjc, i, j, i_neigh, j_neigh; + int dir, adjc, i_neigh, j_neigh; int node0, node1, oppVertex = 0; for (dir = 0; dir < 2; dir++) { - neigh = ref_list->getNeighbourElement(index, dir); + Element *neigh = refineList.getNeighbourElement(index, dir); if (neigh) { - n_type = ref_list->getType(ref_list->getNeighbourNr(index, dir)); - oppVertex = ref_list->getOppVertex(index, dir); + n_type = refineList.getType(refineList.getNeighbourNr(index, dir)); + oppVertex = refineList.getOppVertex(index, dir); } if (!neigh || neigh->isLeaf()) { @@ -197,19 +197,15 @@ namespace AMDiS { /****************************************************************************/ if (el->getDof(0) == neigh->getDof(0)) { - /****************************************************************************/ - /* same position at refinement edge */ - /****************************************************************************/ + // Same position at refinement edge. adjc = 0; } else { - /****************************************************************************/ - /* different position at refinement edge */ - /****************************************************************************/ + // Different position at refinement edge. adjc = 1; } - for (i = 0; i < 2; i++) { - j = Tetrahedron::adjacentChild[adjc][i]; + for (int i = 0; i < 2; i++) { + int j = Tetrahedron::adjacentChild[adjc][i]; i_neigh = Tetrahedron::nChildFace[el_type][i][dir]; j_neigh = Tetrahedron::nChildFace[n_type][j][oppVertex - 2]; @@ -248,7 +244,7 @@ namespace AMDiS { } - int RefinementManager3d::newCoordsFct(ElInfo *el_info) + void RefinementManager3d::newCoordsFct(ElInfo *el_info, RCNeighbourList &refineList) { FUNCNAME("RefinementManager3d::newCoordsFct()"); @@ -274,38 +270,33 @@ namespace AMDiS { /* now, information should be passed on to patch neighbours... */ /* get the refinement patch */ /****************************************************************************/ - refList->setElement(0, el); - refList->setElType(0, el_info->getType()); + refineList.setElement(0, el); + refineList.setElType(0, el_info->getType()); int n_neigh = 1; for (int i = 0; i < 2; i++) edge[i] = const_cast<int*>(el_info->getElement()->getDof(i)); - if (getRefinePatch(&elinfo, edge, 0, refList, &n_neigh)) { + if (getRefinePatch(&elinfo, edge, 0, refineList, &n_neigh)) { // Domain's boundary was reached while looping around the refinement edge. - getRefinePatch(&elinfo, edge, 1, refList, &n_neigh); + getRefinePatch(&elinfo, edge, 1, refineList, &n_neigh); } for (int i = 1; i < n_neigh; i++) { /* start with 1, as list[0]=el */ - TEST(!refList->getElement(i)->isNewCoordSet()) - ("non-nil new_coord in el %d ref_list[%d] el %d (n_neigh=%d)\n", - el->getIndex(), i, refList->getElement(i)->getIndex(), n_neigh); + TEST(!refineList.getElement(i)->isNewCoordSet()) + ("non-nil new_coord in el %d refineList[%d] el %d (n_neigh=%d)\n", + el->getIndex(), i, refineList.getElement(i)->getIndex(), n_neigh); - refList->getElement(i)->setNewCoord(el->getNewCoord()); + refineList.getElement(i)->setNewCoord(el->getNewCoord()); } } - - return 0; } void RefinementManager3d::setNewCoords(int macroEl) { - if (refList) - delete refList; - - refList = new RCNeighbourList(mesh->getMaxEdgeNeigh()); + RCNeighbourList refineList(mesh->getMaxEdgeNeigh()); ElInfo *elInfo; if (macroEl == -1) @@ -321,18 +312,18 @@ namespace AMDiS { while (elInfo) { - newCoordsFct(elInfo); + newCoordsFct(elInfo, refineList); elInfo = stack->traverseNext(elInfo); } } DegreeOfFreedom RefinementManager3d::refinePatch(DegreeOfFreedom *edge[2], - RCNeighbourList* refineList, + RCNeighbourList &refineList, int n_neigh, bool bound) { Tetrahedron *el = - dynamic_cast<Tetrahedron*>(const_cast<Element*>(refineList->getElement(0))); + dynamic_cast<Tetrahedron*>(const_cast<Element*>(refineList.getElement(0))); /* first element in the list */ DegreeOfFreedom *dof[3] = {NULL, NULL, NULL}; @@ -354,14 +345,12 @@ namespace AMDiS { /****************************************************************************/ /* if there are functions to interpolate data to the finer grid, do so */ /****************************************************************************/ - int iadmin; - int nrAdmin = mesh->getNumberOfDOFAdmin(); - for (iadmin = 0; iadmin < nrAdmin; iadmin++) { + for (int iadmin = 0; iadmin < mesh->getNumberOfDOFAdmin(); iadmin++) { std::list<DOFIndexedBase*>::iterator it; DOFAdmin* admin = const_cast<DOFAdmin*>(&mesh->getDofAdmin(iadmin)); std::list<DOFIndexedBase*>::iterator end = admin->endDOFIndexed(); for (it = admin->beginDOFIndexed(); it != end; it++) - (*it)->refineInterpol(*refineList, n_neigh); + (*it)->refineInterpol(refineList, n_neigh); } if (!mesh->queryCoarseDOFs()) { @@ -374,7 +363,7 @@ namespace AMDiS { /* remove dof of the midpoint of the common refinement edge */ /****************************************************************************/ - el = dynamic_cast<Tetrahedron*>(const_cast<Element*>(refineList->getElement(0))); + el = dynamic_cast<Tetrahedron*>(const_cast<Element*>(refineList.getElement(0))); mesh->freeDof(const_cast<int*>(el->getDof(mesh->getNode(EDGE))), EDGE); } @@ -382,7 +371,7 @@ namespace AMDiS { mesh->getNumberOfDofs(FACE) || mesh->getNumberOfDofs(CENTER)) { for (int i = 0; i < n_neigh; i++) - refineList->removeDOFParent(i); + refineList.removeDOFParent(i); } } @@ -407,7 +396,7 @@ namespace AMDiS { int RefinementManager3d::getRefinePatch(ElInfo **el_info, DegreeOfFreedom *edge[2], int direction, - RCNeighbourList* refineList, + RCNeighbourList &refineList, int *n_neigh) { FUNCNAME("RefinementManager3d::getRefinePatch()"); @@ -548,12 +537,12 @@ namespace AMDiS { TEST_EXIT_DBG(*n_neigh < mesh->getMaxEdgeNeigh()) ("too many neighbours %d in refine patch\n", *n_neigh); - refineList->setElement(*n_neigh, neigh); - refineList->setElType(*n_neigh, neighElType); + refineList.setElement(*n_neigh, neigh); + refineList.setElType(*n_neigh, neighElType); // We have to go back to the starting element via oppVertex values. - refineList->setOppVertex(*n_neigh, 0, oppVertex); + refineList.setOppVertex(*n_neigh, 0, oppVertex); (*n_neigh)++; @@ -587,11 +576,11 @@ namespace AMDiS { // The domain's boundary is reached. Loop back to the starting el. int i = *n_neigh - 1; - oppVertex = refineList->getOppVertex(i, 0); + oppVertex = refineList.getOppVertex(i, 0); do { TEST_EXIT_DBG(neighInfo->getNeighbour(oppVertex) && i > 0) ("While looping back domains boundary was reached or i == 0\n"); - oppVertex = refineList->getOppVertex(i--, 0); + oppVertex = refineList.getOppVertex(i--, 0); int testIndex = neighInfo->getNeighbour(oppVertex)->getIndex(); neighInfo = stack->traverseNeighbour3d(neighInfo, oppVertex); @@ -618,7 +607,9 @@ namespace AMDiS { { FUNCNAME("RefinementManager3d::refineFunction()"); - if (el_info->getElement()->getMark() <= 0) + Element *el = el_info->getElement(); + + if (el->getMark() <= 0) return el_info; int bound = false; @@ -626,9 +617,9 @@ namespace AMDiS { // === Get memory for a list of all elements at the refinement edge. === - RCNeighbourList *ref_list = new RCNeighbourList(mesh->getMaxEdgeNeigh()); - ref_list->setElType(0, el_info->getType()); - ref_list->setElement(0, el_info->getElement()); + RCNeighbourList refineList(mesh->getMaxEdgeNeigh()); + refineList.setElType(0, el_info->getType()); + refineList.setElement(0, el); int n_neigh = 1; if (el_info->getProjection(0) && @@ -638,25 +629,25 @@ namespace AMDiS { // === Give the refinement edge the right orientation. === - if (el_info->getElement()->getDof(0, 0) < el_info->getElement()->getDof(1, 0)) { - edge[0] = const_cast<DegreeOfFreedom*>(el_info->getElement()->getDof(0)); - edge[1] = const_cast<DegreeOfFreedom*>(el_info->getElement()->getDof(1)); + if (el->getDof(0, 0) < el->getDof(1, 0)) { + edge[0] = const_cast<DegreeOfFreedom*>(el->getDof(0)); + edge[1] = const_cast<DegreeOfFreedom*>(el->getDof(1)); } else { - edge[1] = const_cast<DegreeOfFreedom*>(el_info->getElement()->getDof(0)); - edge[0] = const_cast<DegreeOfFreedom*>(el_info->getElement()->getDof(1)); + edge[1] = const_cast<DegreeOfFreedom*>(el->getDof(0)); + edge[0] = const_cast<DegreeOfFreedom*>(el->getDof(1)); } // === Traverse and refine the refinement patch. ==== - if (getRefinePatch(&el_info, edge, 0, ref_list, &n_neigh)) { + if (getRefinePatch(&el_info, edge, 0, refineList, &n_neigh)) { // Domain's boundary was reached while looping around the refinement edge - getRefinePatch(&el_info, edge, 1, ref_list, &n_neigh); + getRefinePatch(&el_info, edge, 1, refineList, &n_neigh); bound = true; } // fill neighbour information inside the patch in the refinement list - ref_list->getNeighOnPatch(n_neigh, bound); + refineList.fillNeighbourRelations(n_neigh, bound); // ============ Check for periodic boundary ============ @@ -666,41 +657,36 @@ namespace AMDiS { DegreeOfFreedom *last_edge[2] = {NULL, NULL}; int n_neigh_periodic; - DegreeOfFreedom newDOF = -1; - DegreeOfFreedom lastNewDOF = -1; - DegreeOfFreedom firstNewDOF = -1; + DegreeOfFreedom lastNewDof = -1; + DegreeOfFreedom firstNewDof = -1; - RCNeighbourList *periodicList; - std::map<int, VertexVector*>::iterator it; - std::map<int, VertexVector*>::iterator end = mesh->getPeriodicAssociations().end(); + RCNeighbourList periodicList; while (edge[0] != NULL) { - periodicList = ref_list->periodicSplit(edge, - next_edge, - &n_neigh, - &n_neigh_periodic); - - TEST_EXIT_DBG(periodicList)("periodicList = NULL\n"); + refineList.periodicSplit(edge, next_edge, + &n_neigh, &n_neigh_periodic, + periodicList); - newDOF = refinePatch(edge, periodicList, n_neigh_periodic, bound); + DegreeOfFreedom newDof = refinePatch(edge, periodicList, n_neigh_periodic, bound); - if (firstNewDOF == -1) - firstNewDOF = newDOF; + if (firstNewDof == -1) + firstNewDof = newDof; - if (lastNewDOF != -1) { - for (it = mesh->getPeriodicAssociations().begin(); it != end; ++it) { + if (lastNewDof != -1) { + for (std::map<int, VertexVector*>::iterator it = mesh->getPeriodicAssociations().begin(); + it != mesh->getPeriodicAssociations().end(); ++it) { if (it->second) { if (((*(it->second))[edge[0][0]] == last_edge[0][0] && (*(it->second))[edge[1][0]] == last_edge[1][0]) || ((*(it->second))[edge[0][0]] == last_edge[1][0] && (*(it->second))[edge[1][0]] == last_edge[0][0])) { - (*(it->second))[lastNewDOF] = newDOF; - (*(it->second))[newDOF] = lastNewDOF; + (*(it->second))[lastNewDof] = newDof; + (*(it->second))[newDof] = lastNewDof; } } } } - lastNewDOF = newDOF; + lastNewDof = newDof; last_edge[0] = edge[0]; last_edge[1] = edge[1]; @@ -709,15 +695,16 @@ namespace AMDiS { edge[1] = next_edge[1]; } - if (lastNewDOF != firstNewDOF) { - for (it = mesh->getPeriodicAssociations().begin(); it != end; ++it) { + if (lastNewDof != firstNewDof) { + for (std::map<int, VertexVector*>::iterator it = mesh->getPeriodicAssociations().begin(); + it != mesh->getPeriodicAssociations().end(); ++it) { if (it->second) { if (((*(it->second))[first_edge[0][0]] == last_edge[0][0] && (*(it->second))[first_edge[1][0]] == last_edge[1][0]) || ((*(it->second))[first_edge[0][0]] == last_edge[1][0] && (*(it->second))[first_edge[1][0]] == last_edge[0][0])) { - (*(it->second))[lastNewDOF] = firstNewDOF; - (*(it->second))[firstNewDOF] = lastNewDOF; + (*(it->second))[lastNewDof] = firstNewDof; + (*(it->second))[firstNewDof] = lastNewDof; } } } @@ -725,9 +712,6 @@ namespace AMDiS { stack->update(); - delete ref_list; - return el_info; } - } diff --git a/AMDiS/src/RefinementManager3d.h b/AMDiS/src/RefinementManager3d.h index 0815a4ce..57d4a968 100644 --- a/AMDiS/src/RefinementManager3d.h +++ b/AMDiS/src/RefinementManager3d.h @@ -42,14 +42,14 @@ namespace AMDiS { protected: /// Used by \ref setNewCoords - int newCoordsFct(ElInfo *el_info); + void newCoordsFct(ElInfo *el_info, RCNeighbourList &refineList); /// Implements RefinementManager::setNewCoords void setNewCoords(int macroEl = -1); /** \brief - * Gets the elements around the refinement edge with vertices node[0] and - * node[1]. Refines those elements at this edge that are not compatible + * Gets the elements around the refinement edge with vertices edge[0] and + * edge[1]. Refines those elements at this edge that are not compatible * devisible. The function returns 1 if the domain's boundary is reached * while looping around the refinement edge, otherwise 0. * @@ -59,26 +59,22 @@ namespace AMDiS { int getRefinePatch(ElInfo **el_info, DegreeOfFreedom *edge[2], int direction, - RCNeighbourList* refineList, + RCNeighbourList &refineList, int *n_neigh); /// Refines all elements in the patch. - DegreeOfFreedom refinePatch(DegreeOfFreedom *edge[2], RCNeighbourList* refineList, + DegreeOfFreedom refinePatch(DegreeOfFreedom *edge[2], RCNeighbourList &refineList, int n_neigh, bool bound); /// Implements RefinementManager::refineFunction. ElInfo* refineFunction(ElInfo* el_info); /// Refines one Tetrahedron. - void bisectTetrahedron(RCNeighbourList* refineList, int index, + void bisectTetrahedron(RCNeighbourList &refineList, int index, DegreeOfFreedom *dof[3], DegreeOfFreedom *edge[2]); /// Used by \ref bisectTetrahedron - void fillPatchConnectivity(RCNeighbourList* ref_list, int index); - - private: - /// Refinement patch - static RCNeighbourList* refList; + void fillPatchConnectivity(RCNeighbourList &refineList, int index); }; } diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc index 72a57542..d7acc49a 100644 --- a/AMDiS/src/parallel/MeshDistributor.cc +++ b/AMDiS/src/parallel/MeshDistributor.cc @@ -565,8 +565,8 @@ namespace AMDiS { } while (found); if (!el1.empty()) { + MSG("Unvalid 3D mesh with %d elements on this edge!\n", edgeEls.size()); meshIsValid = false; - break; } } -- GitLab