From 5f346ca04ada16259b783b65cc6ae374f43b4083 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Wed, 8 Apr 2009 09:20:53 +0000 Subject: [PATCH] * First bugfix in Traverse --- AMDiS/libtool | 64 +++--- AMDiS/src/Traverse.cc | 515 ++++++++++++++++++++++-------------------- AMDiS/src/Traverse.h | 140 +++++++++--- 3 files changed, 409 insertions(+), 310 deletions(-) diff --git a/AMDiS/libtool b/AMDiS/libtool index fcd0e2f7..41ace2e6 100755 --- a/AMDiS/libtool +++ b/AMDiS/libtool @@ -30,10 +30,10 @@ # the same distribution terms that you use for the rest of that program. # A sed program that does not truncate output. -SED="/usr/bin/sed" +SED="/bin/sed" # Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="/usr/bin/sed -e 1s/^X//" +Xsed="/bin/sed -e 1s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. @@ -44,7 +44,7 @@ available_tags=" CXX F77" # ### BEGIN LIBTOOL CONFIG -# Libtool was configured on host p2s256: +# Libtool was configured on host NWRW15: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -66,12 +66,12 @@ fast_install=yes # The host system. host_alias= -host=x86_64-unknown-linux-gnu +host=i686-pc-linux-gnu host_os=linux-gnu # The build system. build_alias= -build=x86_64-unknown-linux-gnu +build=i686-pc-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. @@ -82,13 +82,13 @@ AR="ar" AR_FLAGS="cru" # A C compiler. -LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" +LTCC="gcc" # LTCC compiler flags. LTCFLAGS="-g -O2" # A language-specific compiler. -CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" +CC="gcc" # Is the compiler the GNU C compiler? with_gcc=yes @@ -97,7 +97,7 @@ with_gcc=yes EGREP="grep -E" # The linker used to build libraries. -LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64" +LD="/usr/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" @@ -171,7 +171,7 @@ dlopen_self=unknown dlopen_self_static=unknown # Compiler flag to prevent dynamic linking. -link_static_flag="" +link_static_flag="-static" # Compiler flag to turn off builtin functions. no_builtin_flag=" -fno-builtin" @@ -325,10 +325,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=" /usr/lib64/gcc/x86_64-suse-linux/4.1.2/ /usr/lib/gcc/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/ /lib/x86_64-suse-linux/4.1.2/ /lib/../lib64/ /usr/lib/x86_64-suse-linux/4.1.2/ /usr/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../ /lib/ /usr/lib/" +sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" @@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` # End: # ### BEGIN LIBTOOL TAG CONFIG: CXX -# Libtool was configured on host p2s256: +# Libtool was configured on host NWRW15: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -6782,12 +6782,12 @@ fast_install=yes # The host system. host_alias= -host=x86_64-unknown-linux-gnu +host=i686-pc-linux-gnu host_os=linux-gnu # The build system. build_alias= -build=x86_64-unknown-linux-gnu +build=i686-pc-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. @@ -6798,13 +6798,13 @@ AR="ar" AR_FLAGS="cru" # A C compiler. -LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" +LTCC="gcc" # LTCC compiler flags. LTCFLAGS="-g -O2" # A language-specific compiler. -CC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpiCC" +CC="g++" # Is the compiler the GNU C compiler? with_gcc=yes @@ -6813,7 +6813,7 @@ with_gcc=yes EGREP="grep -E" # The linker used to build libraries. -LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64" +LD="/usr/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" @@ -6887,7 +6887,7 @@ dlopen_self=unknown dlopen_self_static=unknown # Compiler flag to prevent dynamic linking. -link_static_flag="" +link_static_flag="-static" # Compiler flag to turn off builtin functions. no_builtin_flag=" -fno-builtin" @@ -6942,11 +6942,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbeginS.o" +predep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o" # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o" +postdep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o" # Dependencies to place before the objects being linked to create a # shared library. @@ -6954,11 +6954,11 @@ predeps="" # Dependencies to place after the objects being linked to create a # shared library. -postdeps="-lmpi_cxx -lmpi -lopen-rte -lopen-pal -libverbs -lrt -lnuma -ldl -lnsl -lutil -ldl -lstdc++ -lm -lgcc_s -lpthread -lc -lgcc_s" +postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path="-L/usr/lib64 -L/licsoft/libraries/openmpi/1.2.6/64bit/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.." +compiler_lib_search_path="-L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.." # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -7038,10 +7038,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=" /usr/lib64/gcc/x86_64-suse-linux/4.1.2/ /usr/lib/gcc/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/ /lib/x86_64-suse-linux/4.1.2/ /lib/../lib64/ /usr/lib/x86_64-suse-linux/4.1.2/ /usr/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../ /lib/ /usr/lib/" +sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" @@ -7065,7 +7065,7 @@ include_expsyms="" # ### BEGIN LIBTOOL TAG CONFIG: F77 -# Libtool was configured on host p2s256: +# Libtool was configured on host NWRW15: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -7087,12 +7087,12 @@ fast_install=yes # The host system. host_alias= -host=x86_64-unknown-linux-gnu +host=i686-pc-linux-gnu host_os=linux-gnu # The build system. build_alias= -build=x86_64-unknown-linux-gnu +build=i686-pc-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. @@ -7103,7 +7103,7 @@ AR="ar" AR_FLAGS="cru" # A C compiler. -LTCC="/licsoft/libraries/openmpi/1.2.6/64bit/bin/mpicc" +LTCC="gcc" # LTCC compiler flags. LTCFLAGS="-g -O2" @@ -7112,13 +7112,13 @@ LTCFLAGS="-g -O2" CC="g77" # Is the compiler the GNU C compiler? -with_gcc= +with_gcc=yes # An ERE matcher. EGREP="grep -E" # The linker used to build libraries. -LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64" +LD="/usr/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" @@ -7346,10 +7346,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=" /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/ /usr/lib/gcc/x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../ /lib/x86_64-suse-linux/3.3.5/ /lib/ /usr/lib/x86_64-suse-linux/3.3.5/ /usr/lib/" +sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../ /lib/i386-redhat-linux/3.4.6/ /lib/ /usr/lib/i386-redhat-linux/3.4.6/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" diff --git a/AMDiS/src/Traverse.cc b/AMDiS/src/Traverse.cc index b767e0ae..b59f2448 100644 --- a/AMDiS/src/Traverse.cc +++ b/AMDiS/src/Traverse.cc @@ -30,16 +30,18 @@ namespace AMDiS { for (int i = 0; i < stack_size; i++) elinfo_stack[i]->setFillFlag(fill_flag & FILL_ANY); + elinfo_stack[0]->setMesh(mesh); elinfo_stack[1]->setMesh(mesh); - if (fill_flag.isSet(Mesh::CALL_LEAF_EL_LEVEL)) - TEST_EXIT_DBG(level >= 0)("invalid level: %d\n", level); + if (fill_flag.isSet(Mesh::CALL_LEAF_EL_LEVEL)) { + TEST_EXIT_DBG(level >= 0)("invalid level: %d\n", level); + } traverse_mel = NULL; stack_used = 0; - return traverseNext(NULL); + return(traverseNext(NULL)); } ElInfo* TraverseStack::traverseNext(ElInfo* elinfo_old) @@ -54,7 +56,8 @@ namespace AMDiS { elinfo_old = parametric->removeParametricInfo(elinfo_old); TEST_EXIT_DBG(elinfo_old == elinfo_stack[stack_used])("invalid old elinfo\n"); - } else { + } + else { TEST_EXIT_DBG(elinfo_old == NULL)("invalid old elinfo != nil\n"); } @@ -85,10 +88,210 @@ namespace AMDiS { elinfo->fillDetGrdLambda(); } - return elinfo; + return(elinfo); } + + /****************************************************************************/ + /* common (static) traversal routines for 2d and 3d */ + /* to be #included in traverse_r.c */ + /****************************************************************************/ + + /* traverse hierarchical mesh, call el_fct() for each/some element */ + + /****************************************************************************/ + /* recursive_traverse: */ + /* ------------------- */ + /* recursively traverse the mesh hierarchy tree */ + /* call the routine traverse_info->el_fct(el_info) with */ + /* - all tree leaves */ + /* - all tree leaves at a special level */ + /* - all tree elements in pre-/in-/post-order */ + /* depending on the traverse_info->level variable */ + /****************************************************************************/ + + int Traverse::recursive(ElInfoStack *elInfoStack) + { + FUNCNAME("Traverse::recursive()"); + + ElInfo *elinfo = elInfoStack->getCurrentElement(); + + Element *el = elinfo->getElement(); + int mg_level, sum = 0; + Parametric *parametric = mesh->getParametric(); + + if (flag.isSet(Mesh::CALL_LEAF_EL)) { + if (el->getFirstChild()) { + ElInfo* elinfo_new = elInfoStack->getNextElement(); + elinfo_new->fillElInfo(0, elinfo); + sum += recursive(elInfoStack); + elinfo_new->fillElInfo(1, elinfo); + sum += recursive(elInfoStack); + elInfoStack->getBackElement(); + } else { + if (el_fct != NULL) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + } + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } + + if (flag.isSet(Mesh::CALL_LEAF_EL_LEVEL)) { + if (el->getFirstChild()) { + if ((elinfo->getLevel() >= level)) { + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } + ElInfo* elinfo_new = elInfoStack->getNextElement(); + elinfo_new->fillElInfo(0, elinfo); + sum += recursive(elInfoStack); + elinfo->fillElInfo(1, elinfo); + sum += recursive(elInfoStack); + elInfoStack->getBackElement(); + } else { + if ((elinfo->getLevel() == level) && (el_fct!=NULL)) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + } + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } + + if (flag.isSet(Mesh::CALL_EL_LEVEL)) { + if (elinfo->getLevel() == level) { + if (NULL != el_fct) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + } else { + if (elinfo->getLevel() > level){ + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } else if (el->getFirstChild()) { + ElInfo* elinfo_new = elInfoStack->getNextElement(); + elinfo_new->fillElInfo(0, elinfo); + sum += recursive(elInfoStack); + elinfo_new->fillElInfo(1, elinfo); + sum += recursive(elInfoStack); + elInfoStack->getBackElement(); + } + } + + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } + + if (flag.isSet(Mesh::CALL_MG_LEVEL)) { + + mg_level = (elinfo->getLevel() + mesh->getDim() - 1) / mesh->getDim(); + + if (mg_level > level) { + return 0; + } + + if (!(el->getFirstChild())) { + if (el_fct != NULL) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } + + if ((mg_level == level) && ((elinfo->getLevel() % mesh->getDim()) == 0)) { + if (el_fct != NULL) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } + + ElInfo* elinfo_new = elInfoStack->getNextElement(); + + elinfo_new->fillElInfo(0, elinfo); + sum += recursive(elInfoStack); + + elinfo_new->fillElInfo(1, elinfo); + sum += recursive(elInfoStack); + + elInfoStack->getBackElement(); + + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } + + if (flag.isSet(Mesh::CALL_EVERY_EL_PREORDER)) { + if (el_fct != NULL) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + } + + if (el->getFirstChild()) { + ElInfo* elinfo_new = elInfoStack->getNextElement(); + + elinfo_new->fillElInfo(0, elinfo); + sum += recursive(elInfoStack); + + if (flag.isSet(Mesh::CALL_EVERY_EL_INORDER)) + if (el_fct!=NULL) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + elinfo_new->fillElInfo(1, elinfo); + sum += recursive(elInfoStack); + + elInfoStack->getBackElement(); + } else { + if (flag.isSet(Mesh::CALL_EVERY_EL_INORDER)) + if (el_fct != NULL) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + } + + if (flag.isSet(Mesh::CALL_EVERY_EL_POSTORDER)) + if (el_fct != NULL) { + if (parametric) + elinfo = parametric->addParametricInfo(elinfo); + elinfo->fillDetGrdLambda(); + sum += el_fct(elinfo); + if (parametric) + elinfo = parametric->removeParametricInfo(elinfo); + } + + return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + } + void TraverseStack::enlargeTraverseStack() { FUNCNAME("TraverseStack::enlargeTraverseStack()"); @@ -132,11 +335,8 @@ namespace AMDiS { if (stack_used == 0) { /* first call */ currentMacro = traverse_mesh->firstMacroElement(); - // Search for the first macro element that corresponds to the current thread. - // So increment as long as one of this condition does not hold and the - // current macro element is not the last one. - while ((*currentMacro)->getIndex() % maxThreads_ != myThreadId_ && - currentMacro != traverse_mesh->endOfMacroElements()) { + while (((*currentMacro)->getIndex() % maxThreads_ != myThreadId_) && + (currentMacro != traverse_mesh->endOfMacroElements())) { currentMacro++; } @@ -151,7 +351,7 @@ namespace AMDiS { el = elinfo_stack[stack_used]->getElement(); if ((el == NULL) || (el->getFirstChild() == NULL)) { - return elinfo_stack[stack_used]; + return (elinfo_stack[stack_used]); } } else { el = elinfo_stack[stack_used]->getElement(); @@ -161,16 +361,18 @@ namespace AMDiS { ((info_stack[stack_used] >= 2) || (el->getFirstChild() == NULL))) { stack_used--; el = elinfo_stack[stack_used]->getElement(); + + if (calcDisplacement) { + displacementStack.pop(); + } } /* goto next macro element */ if (stack_used < 1) { - // Again, search for the next macro element that corresponds to the - // current thread. do { currentMacro++; - } while (currentMacro != traverse_mesh->endOfMacroElements() && - (*currentMacro)->getIndex() % maxThreads_ != myThreadId_); + } while ((currentMacro != traverse_mesh->endOfMacroElements()) && + ((*currentMacro)->getIndex() % maxThreads_ != myThreadId_)); if (currentMacro == traverse_mesh->endOfMacroElements()) { return NULL; @@ -193,24 +395,31 @@ namespace AMDiS { if (stack_used >= stack_size - 1) enlargeTraverseStack(); - - int visitedChildren = info_stack[stack_used]; - if (visitedChildren == 0) { - el = const_cast<Element*>(el->getFirstChild()); - } else { - el = const_cast<Element*>(el->getSecondChild()); - } - + int i = info_stack[stack_used]; + el = const_cast<Element*>(((i == 0) ? el->getFirstChild() : el->getSecondChild())); info_stack[stack_used]++; - elinfo_stack[stack_used + 1]->fillElInfo(visitedChildren, - elinfo_stack[stack_used]); + elinfo_stack[stack_used + 1]->fillElInfo(i, elinfo_stack[stack_used]); stack_used++; + if (calcDisplacement) { + if (i == 0) { + displacementStack.push(displacementStack.top() * 2); + } else { + displacementStack.push(displacementStack.top() * 2 + 1); + } + } + + TEST_EXIT_DBG(stack_used < stack_size) ("stack_size=%d too small, level=(%d,%d)\n", - stack_size, elinfo_stack[stack_used]->getLevel()); + stack_size, elinfo_stack[stack_used]->getLevel()); + + info_stack[stack_used] = 0; } + if (calcDisplacement) { + } + return elinfo_stack[stack_used]; } @@ -676,18 +885,17 @@ namespace AMDiS { { FUNCNAME("TraverseStack::traverseNeighbour2d()"); - Element *el, *el2, *sav_el; + Triangle *el, *el2, *sav_el; ElInfo *old_elinfo, *elinfo, *elinfo2; int i, nb, opp_vertex, stack2_used; static int coarse_nb[3][3] = {{-2,-2,-2}, {2,-1,1}, {-1,2,0}}; /* father.neigh[coarse_nb[i][j]] == child[i-1].neigh[j] */ - int sav_index, sav_neighbour = neighbour; + int sav_index, sav_neighbour = neighbour; TEST_EXIT_DBG(stack_used > 0)("no current element"); - TEST_EXIT_DBG(traverse_fill_flag.isSet(Mesh::CALL_LEAF_EL)) - ("invalid traverse_fill_flag"); + TEST_EXIT_DBG(traverse_fill_flag.isSet(Mesh::CALL_LEAF_EL))("invalid traverse_fill_flag"); Parametric *parametric = traverse_mesh->getParametric(); @@ -697,7 +905,7 @@ namespace AMDiS { TEST_EXIT_DBG(elinfo_old == elinfo_stack[stack_used])("invalid old elinfo"); elinfo_stack[stack_used]->testFlag(Mesh::FILL_NEIGH); - el = elinfo_stack[stack_used]->getElement(); + el = dynamic_cast<Triangle*>(const_cast<Element*>( elinfo_stack[stack_used]->getElement())); sav_index = el->getIndex(); sav_el = el; @@ -713,10 +921,10 @@ namespace AMDiS { /* save information about current element and its position in the tree */ save_traverse_mel = traverse_mel; - save_stack_used = stack_used; - for (i = 0; i<=stack_used; i++) + save_stack_used = stack_used; + for (i=0; i<=stack_used; i++) save_info_stack[i] = info_stack[i]; - for (i = 0; i<=stack_used; i++) + for (i=0; i<=stack_used; i++) (*(save_elinfo_stack[i])) = (*(elinfo_stack[i])); old_elinfo = save_elinfo_stack[stack_used]; opp_vertex = old_elinfo->getOppVertex(neighbour); @@ -754,7 +962,7 @@ namespace AMDiS { stack2_used = 1; } elinfo2 = save_elinfo_stack[stack2_used]; - el2 = elinfo2->getElement(); + el2 = dynamic_cast<Triangle*>(const_cast<Element*>( elinfo2->getElement())); i = traverse_mel->getOppVertex(nb); traverse_mel = traverse_mel->getNeighbour(nb); @@ -773,17 +981,17 @@ namespace AMDiS { stack2_used++; /* go down one level in OLD hierarchy */ } elinfo2 = save_elinfo_stack[stack2_used]; - el2 = elinfo2->getElement(); + el2 = dynamic_cast<Triangle*>(const_cast<Element*>( elinfo2->getElement())); - if (stack_used >= stack_size - 1) { + if (stack_used >= stack_size-1) { enlargeTraverseStack(); } i = 2 - info_stack[stack_used]; - info_stack[stack_used] = i + 1; - elinfo_stack[stack_used + 1]->fillElInfo(i, elinfo_stack[stack_used]); + info_stack[stack_used] = i+1; + elinfo_stack[stack_used+1]->fillElInfo(i, elinfo_stack[stack_used]); stack_used++; - nb = 1 - i; + nb = 1-i; } /****************************************************************************/ @@ -793,15 +1001,15 @@ namespace AMDiS { /****************************************************************************/ elinfo = elinfo_stack[stack_used]; - el = elinfo->getElement(); + el = dynamic_cast<Triangle*>(const_cast<Element*>( elinfo->getElement())); while (el->getFirstChild()) { if (nb < 2) { /* go down one level in hierarchy */ - if (stack_used >= stack_size - 1) + if (stack_used >= stack_size-1) enlargeTraverseStack(); - elinfo_stack[stack_used + 1]->fillElInfo(1 - nb, elinfo_stack[stack_used]); - info_stack[stack_used] = 2 - nb; + elinfo_stack[stack_used+1]->fillElInfo(1-nb, elinfo_stack[stack_used]); + info_stack[stack_used] = 2-nb; stack_used++; nb = 2; } @@ -812,24 +1020,25 @@ namespace AMDiS { /* use child i, neighbour of el2->child[nb-1] */ i = 2 - save_info_stack[stack2_used]; TEST_EXIT_DBG(i < 2)("invalid OLD refinement?"); - info_stack[stack_used] = i + 1; - elinfo_stack[stack_used + 1]->fillElInfo(i, elinfo_stack[stack_used]); + info_stack[stack_used] = i+1; + elinfo_stack[stack_used+1]->fillElInfo(i, elinfo_stack[stack_used]); stack_used++; nb = i; elinfo = elinfo_stack[stack_used]; - el = elinfo->getElement(); + el = dynamic_cast<Triangle*>(const_cast<Element*>( elinfo->getElement())); stack2_used++; if (save_stack_used > stack2_used) { stack2_used++; /* go down one level in OLD hierarchy */ } elinfo2 = save_elinfo_stack[stack2_used]; - el2 = elinfo2->getElement(); + el2 = dynamic_cast<Triangle*>(const_cast<Element*>( elinfo2->getElement())); - } else { /* now we're done... */ + } + else { /* now we're done... */ elinfo = elinfo_stack[stack_used]; - el = elinfo->getElement(); + el = dynamic_cast<Triangle*>(const_cast<Element*>( elinfo->getElement())); } } @@ -841,7 +1050,7 @@ namespace AMDiS { sav_neighbour, sav_index, sav_el); MSG(" got element %d at %8X with opp_vertex %d neigh %d\n", elinfo->getElement()->getIndex(), elinfo->getElement(), opp_vertex, - elinfo->getNeighbour(opp_vertex)?elinfo->getNeighbour(opp_vertex)->getIndex() : -1); + elinfo->getNeighbour(opp_vertex)?elinfo->getNeighbour(opp_vertex)->getIndex():-1); TEST_EXIT_DBG(elinfo->getNeighbour(opp_vertex) == old_elinfo->getElement()) ("didn't succeed !?!?!?"); } @@ -865,7 +1074,7 @@ namespace AMDiS { elinfo->fillDetGrdLambda(); } - return elinfo; + return(elinfo); } void TraverseStack::update() @@ -888,208 +1097,18 @@ namespace AMDiS { for (int i = 1; i <= levelDif; i++) { upperElInfo->getSubElementCoords(coords, - elinfo_stack[stack_used - levelDif + i]-> - getIChild()); + elinfo_stack[stack_used - levelDif + i]->getIChild()); } } - - /****************************************************************************/ - /* common (static) traversal routines for 2d and 3d */ - /* to be #included in traverse_r.c */ - /****************************************************************************/ - - /* traverse hierarchical mesh, call el_fct() for each/some element */ - - /****************************************************************************/ - /* recursive_traverse: */ - /* ------------------- */ - /* recursively traverse the mesh hierarchy tree */ - /* call the routine traverse_info->el_fct(el_info) with */ - /* - all tree leaves */ - /* - all tree leaves at a special level */ - /* - all tree elements in pre-/in-/post-order */ - /* depending on the traverse_info->level variable */ - /****************************************************************************/ - int Traverse::recursive(ElInfoStack *elInfoStack) + void TraverseStack::startDisplacementCalculation(int level) { - FUNCNAME("Traverse::recursive()"); - - ElInfo *elinfo = elInfoStack->getCurrentElement(); - - Element *el = elinfo->getElement(); - int mg_level, sum = 0; - Parametric *parametric = mesh->getParametric(); - - if (flag.isSet(Mesh::CALL_LEAF_EL)) { - if (el->getFirstChild()) { - ElInfo* elinfo_new = elInfoStack->getNextElement(); - elinfo_new->fillElInfo(0, elinfo); - sum += recursive(elInfoStack); - elinfo_new->fillElInfo(1, elinfo); - sum += recursive(elInfoStack); - elInfoStack->getBackElement(); - } else { - if (el_fct != NULL) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - } - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; - } - - if (flag.isSet(Mesh::CALL_LEAF_EL_LEVEL)) { - if (el->getFirstChild()) { - if ((elinfo->getLevel() >= level)) { - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; - } - ElInfo* elinfo_new = elInfoStack->getNextElement(); - elinfo_new->fillElInfo(0, elinfo); - sum += recursive(elInfoStack); - elinfo->fillElInfo(1, elinfo); - sum += recursive(elInfoStack); - elInfoStack->getBackElement(); - } else { - if ((elinfo->getLevel() == level) && (el_fct!=NULL)) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - } - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; - } - - if (flag.isSet(Mesh::CALL_EL_LEVEL)) { - if (elinfo->getLevel() == level) { - if (NULL != el_fct) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - } else { - if (elinfo->getLevel() > level){ - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; - } else if (el->getFirstChild()) { - ElInfo* elinfo_new = elInfoStack->getNextElement(); - elinfo_new->fillElInfo(0, elinfo); - sum += recursive(elInfoStack); - elinfo_new->fillElInfo(1, elinfo); - sum += recursive(elInfoStack); - elInfoStack->getBackElement(); - } - } - - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; - } - - if (flag.isSet(Mesh::CALL_MG_LEVEL)) { + calcDisplacement = true; - mg_level = (elinfo->getLevel() + mesh->getDim() - 1) / mesh->getDim(); - - if (mg_level > level) { - return 0; - } - - if (!(el->getFirstChild())) { - if (el_fct != NULL) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; - } - - if ((mg_level == level) && ((elinfo->getLevel() % mesh->getDim()) == 0)) { - if (el_fct != NULL) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; - } - - ElInfo* elinfo_new = elInfoStack->getNextElement(); - - elinfo_new->fillElInfo(0, elinfo); - sum += recursive(elInfoStack); - - elinfo_new->fillElInfo(1, elinfo); - sum += recursive(elInfoStack); - - elInfoStack->getBackElement(); - - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; + displacementStack.empty(); + for (int i = 0; i <= elinfo_stack[stack_used]->getLevel() - level; i++) { + displacementStack.push(0); } - - if (flag.isSet(Mesh::CALL_EVERY_EL_PREORDER)) { - if (el_fct != NULL) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - } - - if (el->getFirstChild()) { - ElInfo* elinfo_new = elInfoStack->getNextElement(); - - elinfo_new->fillElInfo(0, elinfo); - sum += recursive(elInfoStack); - - if (flag.isSet(Mesh::CALL_EVERY_EL_INORDER)) - if (el_fct!=NULL) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - elinfo_new->fillElInfo(1, elinfo); - sum += recursive(elInfoStack); - - elInfoStack->getBackElement(); - } else { - if (flag.isSet(Mesh::CALL_EVERY_EL_INORDER)) - if (el_fct != NULL) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - } - - if (flag.isSet(Mesh::CALL_EVERY_EL_POSTORDER)) - if (el_fct != NULL) { - if (parametric) - elinfo = parametric->addParametricInfo(elinfo); - elinfo->fillDetGrdLambda(); - sum += el_fct(elinfo); - if (parametric) - elinfo = parametric->removeParametricInfo(elinfo); - } - - return (flag.isSet(Mesh::FILL_ADD_ALL)) ? sum : 0; } } diff --git a/AMDiS/src/Traverse.h b/AMDiS/src/Traverse.h index a67ce02d..826c678d 100644 --- a/AMDiS/src/Traverse.h +++ b/AMDiS/src/Traverse.h @@ -71,9 +71,11 @@ namespace AMDiS { stack_size(0), stack_used(0), save_stack_used(0), + calcDisplacement(false), myThreadId_(0), maxThreads_(1) - {} + { + } /** \brief * Destructor @@ -103,44 +105,75 @@ namespace AMDiS { */ ElInfo* traverseNext(ElInfo* elinfo_old); - /// Returns the neighbour-th neighbour of elInfoOld + /** \brief + * Returns the neighbour-th neighbour of elInfoOld + */ ElInfo* traverseNeighbour(ElInfo* elInfoOld, int neighbour); - /// Returns the neighbour-th neighbour of elInfoOld + /** \brief + * Returns the neighbour-th neighbour of elInfoOld + */ ElInfo* traverseNeighbour3d(ElInfo* elInfoOld, int neighbour); - /// Returns the neighbour-th neighbour of elInfoOld + /** \brief + * Returns the neighbour-th neighbour of elInfoOld + */ ElInfo* traverseNeighbour2d(ElInfo* elInfoOld, int neighbour); - /// Not yet implemented + /** \brief + * Not yet implemented + */ ElInfo* traverseMultiGridLevel(); - /// Preorder traversal of all elements + /** \brief + * Preorder traversal of all elements + */ ElInfo* traverseEveryElementPreorder(); - /// Inorder traversal of all elements + /** \brief + * Inorder traversal of all elements + */ ElInfo* traverseEveryElementInorder(); - /// Postorder traversal of all elements + /** \brief + * Postorder traversal of all elements + */ ElInfo* traverseEveryElementPostorder(); - /// Only for 3d: Calls update of all ElInfo3d onjects in \ref elinfo_stack + /** \brief + * Only for 3d: Calls update of all ElInfo3d onjects in \ref elinfo_stack + */ void update(); - /// - void getCoordsInElem(const ElInfo *upperElInfo, DimMat<double> *coords); + void getCoordsInElem(const ElInfo *upperElInfo, + DimMat<double> *coords); - /// Is used for parallel mesh traverse. + /** \brief + * Starts the calculation of the displacement relative to given level. + */ + void startDisplacementCalculation(int level); + + /** \brief + * Stops the calculation of displacement information. + */ + void stopDisplacementCalculation() { + calcDisplacement = false; + } + + /** \brief + * Is used for parallel mesh traverse. + */ inline void setMyThreadId(int myThreadId) { myThreadId_ = myThreadId; } - /// Is used for parallel mesh traverse. + /** \brief + * Is used for parallel mesh traverse. + */ inline void setMaxThreads(int maxThreads) { maxThreads_ = maxThreads; } - /// int getStackData(std::vector<ElInfo*> &elInfos, std::vector<int> &infos) { elInfos = elinfo_stack; infos = info_stack; @@ -149,16 +182,24 @@ namespace AMDiS { } private: - /// Enlargement of the stack + /** \brief + * Enlargement of the stack + */ void enlargeTraverseStack(); - /// Used by \ref traverseFirst() \ref traverseNext() + /** \brief + * Used by \ref traverseFirst() \ref traverseNext() + */ ElInfo* traverseLeafElement(); - /// Used by \ref traverseFirst() \ref traverseNext() + /** \brief + * Used by \ref traverseFirst() \ref traverseNext() + */ ElInfo* traverseLeafElementLevel(); - /// Used by \ref traverseFirst() \ref traverseNext() + /** \brief + * Used by \ref traverseFirst() \ref traverseNext() + */ ElInfo* traverseElementLevel(); /** \brief @@ -180,10 +221,14 @@ namespace AMDiS { } private: - /// Iterator to the current MacroElement + /** \brief + * Iterator to the current MacroElement + */ std::deque<MacroElement*>::const_iterator currentMacro; - /// Mesh which is currently traversed + /** \brief + * Mesh which is currently traversed + */ Mesh* traverse_mesh; /** \brief @@ -198,16 +243,24 @@ namespace AMDiS { */ Flag traverse_fill_flag; - /// current macro element + /** \brief + * current macro element + */ const MacroElement *traverse_mel; - /// Current size of the stack + /** \brief + * Current size of the stack + */ int stack_size; - /// Used size of the stack + /** \brief + * Used size of the stack + */ int stack_used; - /// + /** \brief + * + */ std::vector<ElInfo*> elinfo_stack; /** \brief @@ -218,18 +271,41 @@ namespace AMDiS { * visited. */ std::vector<int> info_stack; - - /// + + /** \brief + * + */ const MacroElement *save_traverse_mel; - /// + /** \brief + * + */ std::vector<ElInfo*> save_elinfo_stack; - /// + /** \brief + * + */ std::vector<unsigned char> save_info_stack; - /// + /** \brief + * + */ int save_stack_used; + + /** \brief + * + */ + int id; + + /** \brief + * Stack for counting the deplacement information for dual traverse. + */ + std::stack<int> displacementStack; + + /** \brief + * True, if \ref displacementStack should be calculated. + */ + bool calcDisplacement; /** \brief * Is used for parallel mesh traverse. The thread with the id @@ -276,7 +352,9 @@ namespace AMDiS { TEST_EXIT(m)("No traverse without mesh!\n"); } - /// Performs the recursive traversal + /** \brief + * Performs the recursive traversal + */ int recursive(ElInfoStack*); private: @@ -288,6 +366,8 @@ namespace AMDiS { int (*el_fct)(ElInfo*); + int id; + Traverse(); Traverse(const Traverse&); -- GitLab