From a07b559f285eb18e1d43ad6d90c42f0a677df32e Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Fri, 12 Jun 2009 08:43:03 +0000 Subject: [PATCH] Work on pdd, code refactoring. --- AMDiS/libtool | 64 +++---- AMDiS/src/AMDiS_fwd.h | 4 + AMDiS/src/DOFAdmin.cc | 13 +- AMDiS/src/DOFAdmin.h | 23 ++- AMDiS/src/MacroElement.h | 55 ++++-- AMDiS/src/MacroWriter.h | 59 ++----- AMDiS/src/Marker.h | 176 ++++++------------ AMDiS/src/MatrixVector.h | 274 +++++++++++++++-------------- AMDiS/src/Mesh.cc | 2 +- AMDiS/src/MeshStructure.h | 52 +++--- AMDiS/src/MeshStructure_ED.h | 34 ++-- AMDiS/src/MpCCIAdapter.h | 6 +- AMDiS/src/Newton.h | 47 ++--- AMDiS/src/NonLinSolver.h | 86 +++++---- AMDiS/src/NonLinUpdater.h | 59 ++----- AMDiS/src/OEMSolver.h | 31 ++-- AMDiS/src/OpenMP.h | 18 +- AMDiS/src/Operator.h | 160 ++++++++--------- AMDiS/src/ParallelDomainProblem.cc | 140 ++++++++++++--- AMDiS/src/ParallelDomainProblem.h | 23 ++- AMDiS/src/RefinementManager.cc | 4 +- AMDiS/src/RefinementManager2d.cc | 6 +- 22 files changed, 663 insertions(+), 673 deletions(-) diff --git a/AMDiS/libtool b/AMDiS/libtool index 41ace2e6..bd275226 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 p1d062: # 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=" /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=" /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/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/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 p1d062: # 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/mpiCC" # 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/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/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=" /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=" /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/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib " +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/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 p1d062: # 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=" /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=" /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/octave-2.9.9 /usr/lib/qt-3.3/lib " +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/AMDiS_fwd.h b/AMDiS/src/AMDiS_fwd.h index 2e1440a0..1f64ae99 100644 --- a/AMDiS/src/AMDiS_fwd.h +++ b/AMDiS/src/AMDiS_fwd.h @@ -62,7 +62,10 @@ namespace AMDiS { class Parametric; class PeriodicBC; class ProblemInstat; + class ProblemInstatScal; + class ProblemInstatVec; class ProblemIterationInterface; + class ProblemScal; class ProblemStatBase; class ProblemTimeInterface; class ProblemVec; @@ -77,6 +80,7 @@ namespace AMDiS { class RCNeighbourList; class RefinementManager; class RobinBC; + class SMIAdapter; class SystemVector; class TraverseStack; class VertexInfo; diff --git a/AMDiS/src/DOFAdmin.cc b/AMDiS/src/DOFAdmin.cc index ff965f38..4aad64e9 100755 --- a/AMDiS/src/DOFAdmin.cc +++ b/AMDiS/src/DOFAdmin.cc @@ -160,9 +160,9 @@ namespace AMDiS { FUNCNAME("DOFAdmin::enlargeDOFLists()"); int old = size; - if (minsize > 0) { - if (old > minsize) return; - } + if (minsize > 0) + if (old > minsize) + return; int newval = max(minsize, static_cast<int>((dofFree.size() + sizeIncrement))); @@ -177,9 +177,7 @@ namespace AMDiS { // but DOFVectors<int> don't have to be changed std::list<DOFIndexedBase*>::iterator di; - std::list<DOFIndexedBase*>::iterator end = dofIndexedList.end(); - - for (di = dofIndexedList.begin(); di != end; ++di) + for (di = dofIndexedList.begin(); di != dofIndexedList.end(); ++di) if ((*di)->getSize() < newval) (*di)->resize(newval); } @@ -194,9 +192,8 @@ namespace AMDiS { #pragma omp critical (dofIndexAccess) #endif { - if (dofIndexed->getSize() < size) { + if (dofIndexed->getSize() < size) dofIndexed->resize(size); - } dofIndexedList.push_back(dofIndexed); } diff --git a/AMDiS/src/DOFAdmin.h b/AMDiS/src/DOFAdmin.h index ebae4d01..0e3f2402 100644 --- a/AMDiS/src/DOFAdmin.h +++ b/AMDiS/src/DOFAdmin.h @@ -175,7 +175,8 @@ namespace AMDiS { } /// Returns \ref mesh - inline const Mesh* getMesh() const { + inline const Mesh* getMesh() const + { return mesh; } @@ -196,6 +197,26 @@ namespace AMDiS { { dofFree[i] = b; } + + /// Sets \ref usedSize. + inline void setUsedSize(int i) + { + sizeUsed = i; + } + + /// Sets \ref usedCount. + inline void setUsedCount(int i) + { + usedCount = i; + } + + /// Sets \ref firstHole + inline void setFirstHole(int i) + { + TEST_EXIT_DBG(!dofFree[i])("There is no hole!\n"); + + firstHole = i; + } /** \} */ diff --git a/AMDiS/src/MacroElement.h b/AMDiS/src/MacroElement.h index 1a570508..8a14e0f7 100644 --- a/AMDiS/src/MacroElement.h +++ b/AMDiS/src/MacroElement.h @@ -56,47 +56,56 @@ namespace AMDiS { */ /// Returns \ref index. - inline int getIndex() const { + inline int getIndex() const + { return index; } /// Returns ref projection[i]. - inline Projection *getProjection(int i) const { + inline Projection *getProjection(int i) const + { return projection[i]; } /// Returns \ref el - inline Element* getElement() const { + inline Element* getElement() const + { return element; } /// Returns the i-th neighbour of this MacroElement \ref neighbour[i] - inline MacroElement* getNeighbour(int i) const { + inline MacroElement* getNeighbour(int i) const + { return neighbour[i]; } /// Returns the i-th opp-vertex of this MacroElement \ref oppVertex[i] - inline char getOppVertex(int i) const { + inline char getOppVertex(int i) const + { return oppVertex[i]; } /// Returns \ref coord[i] - inline WorldVector<double>& getCoord(int i) { + inline WorldVector<double>& getCoord(int i) + { return coord[i]; } /// Returns \ref coord - inline FixVec<WorldVector<double>, VERTEX>& getCoord() { + inline FixVec<WorldVector<double>, VERTEX>& getCoord() + { return coord; } /// Returns \ref boundary[i] - inline BoundaryType getBoundary(int i) const { + inline BoundaryType getBoundary(int i) const + { return boundary[i]; } /// Returns \ref elType - inline unsigned char getElType() const { + inline unsigned char getElType() const + { return elType; } @@ -107,12 +116,14 @@ namespace AMDiS { */ /// Sets \ref index - inline void setIndex(int n) { + inline void setIndex(int n) + { index = n ; } /// Sets \ref element if not yet set. - inline void setElement(Element* element_) { + inline void setElement(Element* element_) + { if (!element) { element = element_; } else { @@ -122,33 +133,38 @@ namespace AMDiS { } /// Sets \ref elType - inline void setElType(unsigned char typ) { + inline void setElType(unsigned char typ) + { elType = typ; } - /// Sets \ref projection[i] = p. - inline void setProjection(int i, Projection *p) { + inline void setProjection(int i, Projection *p) + { projection[i] = p; } /// Sets the i-th Neighbour to n - inline void setNeighbour(int i, MacroElement *n) { + inline void setNeighbour(int i, MacroElement *n) + { neighbour[i] = n; } /// Sets the i-th opp vertex to c - inline void setOppVertex(int i, char c) { + inline void setOppVertex(int i, char c) + { oppVertex[i] = c; } /// Sets \ref boundary[i] to b - inline void setBoundary(int i, BoundaryType b) { + inline void setBoundary(int i, BoundaryType b) + { boundary[i] = b; } /// - inline void setCoord(int i, const WorldVector<double> c) { + inline void setCoord(int i, const WorldVector<double> c) + { coord[i] = c; } @@ -162,7 +178,8 @@ namespace AMDiS { void deserialize(std::istream &in); /// - inline void writeNeighboursTo(std::vector<int> *indices) { + inline void writeNeighboursTo(std::vector<int> *indices) + { deserializedNeighbourIndices_ = indices; } diff --git a/AMDiS/src/MacroWriter.h b/AMDiS/src/MacroWriter.h index 0c952be6..96858673 100644 --- a/AMDiS/src/MacroWriter.h +++ b/AMDiS/src/MacroWriter.h @@ -46,20 +46,14 @@ namespace AMDiS { class MacroWriter { public: - /** \brief - * Stores a list of vertex infos for each dof. - */ + /// Stores a list of vertex infos for each dof. static DOFVector< std::list<VertexInfo> > *vertexInfos; - /** \brief - * List that stores an ElementInfo for each element. - */ + /// List that stores an ElementInfo for each element. static std::list<ElementInfo> elements; public: - /** \brief - * Writes the leaf elements of a Mesh as a macro triangulation to a file. - */ + /// Writes the leaf elements of a Mesh as a macro triangulation to a file. static int writeMacro(DataCollector *dc, const char *name, double time = 0.0, @@ -67,57 +61,36 @@ namespace AMDiS { Flag traverseFlag = Mesh::CALL_LEAF_EL, bool (*writeElem)(ElInfo*) = NULL); - /** \brief - * Init \ref periodicFile for the next macro to be written. - */ - static void writePeriodicFile(DataCollector *dc, - const std::string filename); + /// Init \ref periodicFile for the next macro to be written. + static void writePeriodicFile(DataCollector *dc, const std::string filename); protected: - /** \brief - * Mesh that should be written - */ + /// Mesh that should be written static Mesh *mesh; - /** \brief - * File to which the mesh should be written - */ + /// File to which the mesh should be written static FILE *macroFile; - /** \brief - * File in which the periodic infos are stored. - */ + /// File in which the periodic infos are stored. static FILE *periodicFile; - /** \brief - * vertex pre-dofs - */ + /// vertex pre-dofs static int n0; - /** \brief - * Number of vertices. - */ + /// Number of vertices. static int nv; - /** \brief - * Number of elements. - */ + /// Number of elements. static int ne; - /** \brief - * Number of connections. - */ + /// Number of connections. static int nc; - /** \brief - * Dimension of \ref mesh - */ + /// Dimension of \ref mesh static int dim; - /** \brief - * Maps internal element indices to global output indices. - */ + /// Maps internal element indices to global output indices. static std::map<int, int> outputIndices; /** \brief @@ -126,9 +99,7 @@ namespace AMDiS { */ static std::vector<DimVec<bool> > periodicConnections; - /** \brief - * - */ + /// static bool (*writeElement)(ElInfo*); }; diff --git a/AMDiS/src/Marker.h b/AMDiS/src/Marker.h index 1eb21849..a80ee7f5 100644 --- a/AMDiS/src/Marker.h +++ b/AMDiS/src/Marker.h @@ -41,14 +41,10 @@ namespace AMDiS { class Marker { public: - /** \brief - * Constructor. - */ + /// Constructor. Marker() {} - /** \brief - * Constructor. - */ + /// Constructor. Marker(std::string name_, int row_) : name(name_), row(row_), @@ -62,9 +58,7 @@ namespace AMDiS { GET_PARAMETER(0, name + "->max refinement level", "%d", &maxRefineLevel); } - /** \brief - * destructor - */ + /// destructor virtual ~Marker() {} /** \brief @@ -72,7 +66,8 @@ namespace AMDiS { * is marked only if the new mark is bigger than the old one. The return * value specifies whether the element has been marked, or not. */ - inline void setMark(Element *el, char newMark) { + inline void setMark(Element *el, char newMark) + { char oldMark = el->getMark(); if (!maximumMarking || (newMark > oldMark)) { @@ -94,50 +89,39 @@ namespace AMDiS { } } - /** \brief - * Can be used by sub classes. Called before traversal. - */ + /// Can be used by sub classes. Called before traversal. virtual void initMarking(AdaptInfo *adaptInfo, Mesh *mesh); - /** \brief - * Can be used by sub classes. Called after traversal. - */ + /// Can be used by sub classes. Called after traversal. virtual void finishMarking(AdaptInfo *adaptInfo); - /** \brief - * Marks one element. - */ + /// Marks one element. virtual void markElement(AdaptInfo *adaptInfo, ElInfo *elInfo); - /** \brief - * Marking of the mesh. - */ + /// Marking of the mesh. virtual Flag markMesh(AdaptInfo *adaptInfo, Mesh *mesh); - /** \brief - * Sets \ref maximumMarking. - */ - inline void setMaximumMarking(bool maxMark) { + /// Sets \ref maximumMarking. + inline void setMaximumMarking(bool maxMark) + { maximumMarking = maxMark; } - inline int getElMarkRefine() { + inline int getElMarkRefine() + { return elMarkRefine; } - inline int getElMarkCoarsen() { + inline int getElMarkCoarsen() + { return elMarkCoarsen; } - /** \brief - * Creates a scalr marker depending on the strategy set in parameters. - */ + /// Creates a scalr marker depending on the strategy set in parameters. static Marker *createMarker(std::string name, int row_); protected: - /** \brief - * Name of the scalar marker. - */ + /// Name of the scalar marker. std::string name; /** \brief @@ -146,14 +130,10 @@ namespace AMDiS { */ int row; - /** \brief - * estimation sum - */ + /// estimation sum double estSum; - /** \brief - * estmation maximum - */ + /// estmation maximum double estMax; /** \brief @@ -174,35 +154,22 @@ namespace AMDiS { */ double markCLimit; - /** \brief - * power in estimator norm - */ + /// power in estimator norm double p; - /** \brief - * Info level. - */ + /// Info level. int info; - /** \brief - * Counter for elements marked for refinement - */ + /// Counter for elements marked for refinement int elMarkRefine; - /** \brief - * Counter for elements marked for coarsening - */ + /// Counter for elements marked for coarsening int elMarkCoarsen; - /** \brief - * Maximal depth for element refinement. - */ + /// Maximal depth for element refinement. int maxRefineLevel; }; - // =========================================================================== - // ===== class GRMarker ====================================================== - // =========================================================================== /** * \ingroup Adaption @@ -213,26 +180,20 @@ namespace AMDiS { class GRMarker : public Marker { public: - /** \brief - * Constructor. - */ + /// Constructor. GRMarker(std::string name_, int row_) : Marker(name_, row_) {} - /** \brief - * Implementation of Marker::markElement(). - */ - virtual void markElement(AdaptInfo *adaptInfo, ElInfo *elInfo) { + /// Implementation of Marker::markElement(). + virtual void markElement(AdaptInfo *adaptInfo, ElInfo *elInfo) + { Element *el = elInfo->getElement(); - if(adaptInfo->isRefinementAllowed(row == -1 ? 0 : row)) + if (adaptInfo->isRefinementAllowed(row == -1 ? 0 : row)) setMark(el, adaptInfo->getRefineBisections(row == -1 ? 0 : row)); } }; - // =========================================================================== - // ===== class MSMarker ====================================================== - // =========================================================================== /** * \ingroup Adaption @@ -243,9 +204,7 @@ namespace AMDiS { class MSMarker : public Marker { public: - /** \brief - * Constructor. - */ + /// Constructor. MSMarker(std::string name_, int row_) : Marker(name_, row_), MSGamma(0.5), @@ -255,10 +214,9 @@ namespace AMDiS { GET_PARAMETER(0, name + "->MSGammaC", "%f", &MSGammaC); } - /** \brief - * Implementation of MarkScal::initMarking(). - */ - virtual void initMarking(AdaptInfo *adaptInfo, Mesh *mesh) { + /// Implementation of MarkScal::initMarking(). + virtual void initMarking(AdaptInfo *adaptInfo, Mesh *mesh) + { Marker::initMarking(adaptInfo, mesh); double MSGammaP = pow(MSGamma, p); @@ -269,20 +227,13 @@ namespace AMDiS { } protected: - /** \brief - * Marking parameter. - */ + /// Marking parameter. double MSGamma; - /** \brief - * Marking parameter. - */ + /// Marking parameter. double MSGammaC; }; - // =========================================================================== - // ===== class ESMarker ====================================================== - // =========================================================================== /** * \ingroup Adaption @@ -293,9 +244,7 @@ namespace AMDiS { class ESMarker : public Marker { public: - /** \brief - * Constructor. - */ + /// Constructor. ESMarker(std::string name_, int row_) : Marker(name_, row_), ESTheta(0.9), @@ -305,26 +254,17 @@ namespace AMDiS { GET_PARAMETER(0, name + "->ESThetaC", "%f", &ESThetaC); } - /** \brief - * Implementation of MarkScal::initMarking(). - */ + /// Implementation of MarkScal::initMarking(). virtual void initMarking(AdaptInfo *adaptInfo, Mesh *mesh); protected: - /** \brief - * Marking parameter. - */ + /// Marking parameter. double ESTheta; - /** \brief - * Marking parameter. - */ + /// Marking parameter. double ESThetaC; }; - // =========================================================================== - // ===== class GERSMarker ==================================================== - // =========================================================================== /** * \ingroup Adaption @@ -335,9 +275,7 @@ namespace AMDiS { class GERSMarker : public Marker { public: - /** \brief - * Constructor. - */ + /// Constructor. GERSMarker(std::string name_, int row_) : Marker(name_, row_), oldErrSum(0.0), @@ -350,46 +288,30 @@ namespace AMDiS { GET_PARAMETER(0, name + "->GERSThetaC", "%f", &GERSThetaC); } - /** \brief - * Implementation of Marker::markMesh(). - */ + /// Implementation of Marker::markMesh(). virtual Flag markMesh(AdaptInfo *adaptInfo, Mesh *mesh); protected: - /** \brief - * Refinement marking function. - */ + /// Refinement marking function. void markElementForRefinement(AdaptInfo *adaptInfo, ElInfo *elInfo); - /** \brief - * Coarsening marking function. - */ + /// Coarsening marking function. void markElementForCoarsening(AdaptInfo *adaptInfo, ElInfo *elInfo); protected: - /** \brief - * Marking parameter. - */ + /// Marking parameter. double GERSSum; - /** \brief - * Marking parameter. - */ + /// Marking parameter. double oldErrSum; - /** \brief - * Marking parameter. - */ + /// Marking parameter. double GERSThetaStar; - /** \brief - * Marking parameter. - */ + /// Marking parameter. double GERSNu; - /** \brief - * Marking parameter. - */ + /// Marking parameter. double GERSThetaC; }; diff --git a/AMDiS/src/MatrixVector.h b/AMDiS/src/MatrixVector.h index 7fa10120..42f2068b 100644 --- a/AMDiS/src/MatrixVector.h +++ b/AMDiS/src/MatrixVector.h @@ -44,12 +44,14 @@ namespace AMDiS { valArray = new T[size]; } - inline bool used() const { + inline bool used() const + { return (valArray != NULL); } /// Change the size of the vector to newSize. - inline void resize(int newSize) { + inline void resize(int newSize) + { if (size != newSize) { if (valArray) delete [] valArray; @@ -67,12 +69,14 @@ namespace AMDiS { } /// Destructor. - virtual ~Vector() { + virtual ~Vector() + { delete [] valArray; } /// Assignement operator - inline const Vector<T>& operator=(const Vector<T>& rhs) { + inline const Vector<T>& operator=(const Vector<T>& rhs) + { TEST_EXIT_DBG(rhs.size == size)("invalid size\n"); T *rhsIt, *thisIt; for (rhsIt = rhs.begin(), thisIt = this->begin(); @@ -85,124 +89,138 @@ namespace AMDiS { } /// Assignement operator - inline const Vector<T>& operator=(const T& scal) { + inline const Vector<T>& operator=(const T& scal) + { T *thisIt; - for(thisIt = this->begin(); - thisIt != this->end(); - ++thisIt) - { - *thisIt = scal; - } + for (thisIt = this->begin(); + thisIt != this->end(); + ++thisIt) + *thisIt = scal; + return *this; } /// Assignement operator - inline const Vector<T>& operator=(const T* vec) { + inline const Vector<T>& operator=(const T* vec) + { T *thisIt; const T *vecIt; - for(thisIt = this->begin(), vecIt = &vec[0]; - thisIt != this->end(); - ++thisIt, ++vecIt) - { - *thisIt = *vecIt; - } + for (thisIt = this->begin(), vecIt = &vec[0]; + thisIt != this->end(); + ++thisIt, ++vecIt) + *thisIt = *vecIt; + return *this; } /// Sets all entries to scal. - inline const Vector<T>& set(const T& scal) { + inline const Vector<T>& set(const T& scal) + { return *this = scal; } /// Sets all entries. - inline const Vector<T>& setValues(const T* values) { + inline const Vector<T>& setValues(const T* values) + { T *thisIt; const T *valuesIt; - for(thisIt = this->begin(), valuesIt = values; - thisIt != this->end(); - ++thisIt, ++valuesIt) - { - *thisIt = *valuesIt; - } + for (thisIt = this->begin(), valuesIt = values; + thisIt != this->end(); + ++thisIt, ++valuesIt) + *thisIt = *valuesIt; + return *this; } /// Sets all entries. - inline void fill(const T value) { - for (T *thisIt = this->begin(); thisIt != this->end(); thisIt++) { + inline void fill(const T value) + { + for (T *thisIt = this->begin(); thisIt != this->end(); thisIt++) *thisIt = value; - } } /// Comparison operator. - inline bool operator==(const Vector<T>& rhs) const { - if(size != rhs.size) return false; + inline bool operator==(const Vector<T>& rhs) const + { + if (size != rhs.size) + return false; + T *rhsIt, *thisIt; - for(rhsIt = rhs.begin(), thisIt = this->begin(); - rhsIt != rhs.end(); - ++rhsIt, ++thisIt) - { - if(*thisIt != *rhsIt) return false; - } + for (rhsIt = rhs.begin(), thisIt = this->begin(); + rhsIt != rhs.end(); + ++rhsIt, ++thisIt) + if(*thisIt != *rhsIt) + return false; + return true; } /// Comparison operator. - inline bool operator!=(const Vector<T>& rhs) const { + inline bool operator!=(const Vector<T>& rhs) const + { return !(*this==rhs); } /// Access to the i-th vector element. - inline T& operator[](int i) { + inline T& operator[](int i) + { TEST_EXIT_DBG(i < size && i >= 0)("invalid index\n"); return valArray[i]; } /// Access to the i-th vector element for const vectors. - inline const T& operator[] (int i) const { + inline const T& operator[] (int i) const + { TEST_EXIT_DBG(i < size && i >= 0)("invalid index\n"); return valArray[i]; } /// Returns pointer to the first vector element. - inline T *begin() const { + inline T *begin() const + { return valArray; } /// Returns pointer after the last vector element. - inline T *end() const { + inline T *end() const + { return valArray + size; } /// Returns \ref size. - virtual int getSize() const { + virtual int getSize() const + { return size; } /// Returns \ref valArray as T-array - inline T *getValArray() { + inline T *getValArray() + { return valArray; } - void print() const { + void print() const + { std::cout << this->size << " vector: " << std::endl; - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) std::cout << this->valArray[i] << " "; - } std::cout << std::endl; } - void serialize(std::ostream &out) { + void serialize(std::ostream &out) + { out.write(reinterpret_cast<const char*>(&size), sizeof(int)); out.write(reinterpret_cast<const char*>(valArray), size * sizeof(T)); } - void deserialize(std::istream &in) { + void deserialize(std::istream &in) + { in.read(reinterpret_cast<char*>(&size), sizeof(int)); in.read(reinterpret_cast<char*>(valArray), size * sizeof(T)); } - std::string getTypeName() const { + std::string getTypeName() const + { return "Vector"; } @@ -228,7 +246,8 @@ namespace AMDiS { {} /// Changes the size of the matrix to newRows x newCols. - inline void resize(int newRows, int newCols) { + inline void resize(int newRows, int newCols) + { if ((newRows != rows) || (newCols != cols)) { Vector<T>::resize(newRows * newCols); rows = newRows; @@ -237,58 +256,67 @@ namespace AMDiS { } /// Assignement operator. - inline const Matrix<T>& operator=(const T& scal) { + inline const Matrix<T>& operator=(const T& scal) + { return static_cast<const Matrix<T>&>(Vector<T>::operator=(scal)); } /// - inline bool operator==(const Matrix<T>& rhs) const { + inline bool operator==(const Matrix<T>& rhs) const + { if (rows != rhs.getNumRows()) return false; if (cols != rhs.getNumCols()) return false; return Vector<T>::operator == (rhs); } /// Comparison operator. - inline bool operator!=(const Matrix<T>& rhs) const { + inline bool operator!=(const Matrix<T>& rhs) const + { return !(*this == rhs); } /// Acces to i-th matrix row. - inline T *operator[](int i) { + inline T *operator[](int i) + { return this->valArray + cols * i; } /// Acces to i-th matrix row for constant matrices. - inline const T *operator[](int i) const { + inline const T *operator[](int i) const + { return this->valArray + cols * i; } /// Returns \ref rows. - inline int getNumRows() const { + inline int getNumRows() const + { return rows; } /// Return \ref cols. - inline int getNumCols() const { + inline int getNumCols() const + { return cols; } /// Returns \ref rows. - inline int getSize() const { + inline int getSize() const + { return rows; } /// Returns pointer after the last vector element. - inline T *end() const { + inline T *end() const + { return this->valArray + (cols * rows); } - void print() const { + void print() const + { std::cout << this->rows << " x " << this->cols << " matrix: " << std::endl; for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { + for (int j = 0; j < cols; j++) std::cout << this->valArray[i * cols + j] << " "; - } std::cout << std::endl; } } @@ -314,16 +342,13 @@ namespace AMDiS { resultIt != result.end(); ++resultIt) { *resultIt = 0; - for (vIt = v.begin(); vIt != v.end(); ++vIt, ++mIt) { + for (vIt = v.begin(); vIt != v.end(); ++vIt, ++mIt) *resultIt += *mIt * *vIt; - } } return result; - }; + } - /** \brief - * Computes x(Ay)^T, with x and y vectors, and A a matrix. - */ + /// Computes x(Ay)^T, with x and y vectors, and A a matrix. template<typename T> inline T xAy(const Vector<T>& x, const Matrix<T>& a, const Vector<T>& y) { @@ -336,36 +361,30 @@ namespace AMDiS { for (aIt = a.begin(), xIt = x.begin(); aIt != a.end(); ++xIt) { tmp = 0; - for (yIt = y.begin(); yIt != y.end(); ++yIt, ++aIt) { + for (yIt = y.begin(); yIt != y.end(); ++yIt, ++aIt) tmp += *aIt * *yIt; - } result += *xIt * tmp; } return result; } - /** \brief - * Matrix vector multiplication. - */ + /// Matrix vector multiplication. template<typename T> - inline const Vector<T>& operator*=(const Vector<T>& v, const Matrix<T>& m) { + inline const Vector<T>& operator*=(const Vector<T>& v, const Matrix<T>& m) + { return mv(m, v, v); - }; + } - /** \brief - * Matrix vector multiplication. - */ + /// Matrix vector multiplication. template<typename T> - inline Vector<T> operator*(const Matrix<T>& m, const Vector<T>& v) { + inline Vector<T> operator*(const Matrix<T>& m, const Vector<T>& v) + { Vector<T> result(v.getSize()); return mv(m, v, result); - }; - + } - /** \brief - * Scalar product. - */ + /// Scalar product. template<typename T> inline double operator*(const Vector<T>& v1, const Vector<T>& v2) { @@ -374,16 +393,13 @@ namespace AMDiS { T *v1It, *v2It; for (v1It = v1.begin(), v2It = v2.begin(); v1It != v1.end(); - ++v1It, ++v2It) { + ++v1It, ++v2It) result += *v1It * *v2It; - } return result; - }; + } - /** \brief - * Vector addition. - */ + /// Vector addition. template<typename T> inline const Vector<T>& add(const Vector<T>& v1, const Vector<T>& v2, Vector<T>& result) { @@ -393,16 +409,12 @@ namespace AMDiS { for (v1It = v1.begin(), v2It = v2.begin(), resultIt = result.begin(); v1It != v1.end(); ++v1It, ++v2It, ++resultIt) - { - *resultIt = *v1It + *v2It; - } + *resultIt = *v1It + *v2It; return result; - }; + } - /** \brief - * scalar * vector - */ + /// scalar * vector template<typename T> inline const Vector<T>& mult(const T& scal, const Vector<T>& v, @@ -413,16 +425,13 @@ namespace AMDiS { T *vIt, *resultIt; for (vIt = v.begin(), resultIt = result.begin(); vIt != v.end(); - ++vIt, ++resultIt) { + ++vIt, ++resultIt) *resultIt = scal * *vIt; - } return result; - }; + } - /** \brief - * vector + scalar - */ + /// vector + scalar template<typename T> inline const Vector<T>& add(const Vector<T>& v, const T& scal, Vector<T>& result) { @@ -431,16 +440,12 @@ namespace AMDiS { for (vIt = v.begin(), resultIt = result.begin(); vIt != v.end(); ++vIt, ++resultIt) - { - *resultIt = *vIt + scal; - } + *resultIt = *vIt + scal; return result; - }; + } - /** \brief - * y = a * x + y. - */ + /// y = a * x + y. template<typename T> inline const Vector<T>& axpy(const T& a, const Vector<T> &x, @@ -450,65 +455,70 @@ namespace AMDiS { T *xIt, *yIt; for (xIt = x.begin(), yIt = y.begin(); xIt != x.end(); - ++xIt, ++yIt) { + ++xIt, ++yIt) *yIt += a * *xIt; - } return y; - }; + } template<typename T> - inline const Vector<T>& operator*=(Vector<T>& v, const T& scal) { + inline const Vector<T>& operator*=(Vector<T>& v, const T& scal) + { return mult(scal, v, v); - }; + } template<typename T> - inline Vector<T> operator*(const Vector<T>& v, const T& scal) { + inline Vector<T> operator*(const Vector<T>& v, const T& scal) + { Vector<T> result = v; result *= scal; return result; - }; + } template<typename T> - inline const Vector<T>& operator+(const Vector<T>& v1, const T& scal) { + inline const Vector<T>& operator+(const Vector<T>& v1, const T& scal) + { Vector<T> result(v1.getSize()); return add(v1, scal, result); - }; + } template<typename T> - inline const Vector<T>& operator+=(Vector<T>& v1, const Vector<T>& v2) { + inline const Vector<T>& operator+=(Vector<T>& v1, const Vector<T>& v2) + { return add(v1, v2, v1); - }; + } template<typename T> - inline Vector<T> operator+(const Vector<T>& v1, const Vector<T>& v2) { + inline Vector<T> operator+(const Vector<T>& v1, const Vector<T>& v2) + { Vector<T> result = v1; result += v2; return result; - }; + } template<typename T> - const Vector<T>& operator-=(Vector<T>& v1, const Vector<T>& v2){ + const Vector<T>& operator-=(Vector<T>& v1, const Vector<T>& v2) + { return axpy(-1.0, v2, v1); - }; + } template<typename T> - Vector<T> operator-(const Vector<T>& v1, const Vector<T>& v2){ + Vector<T> operator-(const Vector<T>& v1, const Vector<T>& v2) + { Vector<T> result = v1; result -= v2; return result; - }; + } template<typename T> inline double norm(const Vector<T> *v) { T *vIt; double result = 0; - for (vIt = v->begin(); vIt != v->end(); ++vIt) { + for (vIt = v->begin(); vIt != v->end(); ++vIt) result += *vIt * *vIt; - } return sqrt(result); - }; + } template<typename T> void vectorProduct(const Vector<T>& x, @@ -520,7 +530,7 @@ namespace AMDiS { z[0] = x[1] * y[2] - x[2] * y[1]; z[1] = x[2] * y[0] - x[0] * y[2]; z[2] = x[0] * y[1] - x[1] * y[0]; - }; + } } diff --git a/AMDiS/src/Mesh.cc b/AMDiS/src/Mesh.cc index c804268c..57c15af7 100644 --- a/AMDiS/src/Mesh.cc +++ b/AMDiS/src/Mesh.cc @@ -503,7 +503,7 @@ namespace AMDiS { for (int j = 0; j < n; j++) dof[n0 + j] = const_cast<DOFAdmin*>(localAdmin)->getDOFIndex(); } - + return dof; } diff --git a/AMDiS/src/MeshStructure.h b/AMDiS/src/MeshStructure.h index f96f163e..39c6a17d 100644 --- a/AMDiS/src/MeshStructure.h +++ b/AMDiS/src/MeshStructure.h @@ -24,7 +24,8 @@ #include <vector> #include "AMDiS_fwd.h" -#include <Global.h> +#include "Global.h" + namespace AMDiS { class MeshStructure @@ -40,12 +41,11 @@ namespace AMDiS { void clear(); - /** \brief - * Creates a mesh structure code from a Mesh object by traversing it in preorder. - */ + /// Creates a mesh structure code from a Mesh object by traversing it in preorder. void init(Mesh *mesh); - void init(const std::vector<unsigned long int>& code, int numElements) { + void init(const std::vector<unsigned long int>& code, int numElements) + { code_ = code; numElements_ = numElements; reset(); @@ -53,10 +53,10 @@ namespace AMDiS { void reset(); - inline void commit() { - if (pos_ > 0) { + inline void commit() + { + if (pos_ > 0) code_.push_back(currentCode_); - } reset(); } @@ -66,7 +66,8 @@ namespace AMDiS { bool nextElement(MeshStructure *insert = NULL); - inline bool isLeafElement() { + inline bool isLeafElement() + { return (currentCode_ & 1) == 0; } @@ -74,7 +75,8 @@ namespace AMDiS { * Merges a mesh structure code with its own mesh structure code. The * result overwrites the own mesh structure code. */ - void merge(MeshStructure *structure) { + void merge(MeshStructure *structure) + { MeshStructure temp(*this); merge(&temp, structure, this); } @@ -91,37 +93,37 @@ namespace AMDiS { bool checkPartition = false, bool debugMode = false); - /** \brief - * Prints the mesh structure code. - */ - void print() { + /// Prints the mesh structure code. + void print() + { FUNCNAME("MeshStructure::print()"); reset(); bool cont = true; while (cont) { - if (isLeafElement()) { + if (isLeafElement()) MSG("0"); - } else { + else MSG("1"); - } + cont = nextElement(); } MSG("\n"); } - /** \brief - * Returns the mesh structure code. - */ - inline const std::vector<unsigned long int>& getCode() { + /// Returns the mesh structure code. + inline const std::vector<unsigned long int>& getCode() + { return code_; } - inline int getNumElements() { + inline int getNumElements() + { return numElements_; } - inline int getCurrentElement() { + inline int getCurrentElement() + { return currentElement_; } @@ -132,9 +134,7 @@ namespace AMDiS { */ void insertElement(bool isLeaf); - /** \brief - * Merges two mesh structure codes to one structure code. - */ + /// Merges two mesh structure codes to one structure code. void merge(MeshStructure *structure1, MeshStructure *structure2, MeshStructure *result); diff --git a/AMDiS/src/MeshStructure_ED.h b/AMDiS/src/MeshStructure_ED.h index 54413b68..8c811d34 100644 --- a/AMDiS/src/MeshStructure_ED.h +++ b/AMDiS/src/MeshStructure_ED.h @@ -37,11 +37,12 @@ namespace AMDiS { MeshStructure_ED(ElementData *decorated = NULL) : ElementData(decorated), structure_(NULL) - {}; + {} - virtual ~MeshStructure_ED() { + virtual ~MeshStructure_ED() + { delete structure_; - }; + } virtual bool refineElementData(Element* parent, Element* child1, @@ -59,7 +60,7 @@ namespace AMDiS { structure_->nextElement(); - if(!structure_->isLeafElement()) { + if (!structure_->isLeafElement()) { MeshStructure *structure1 = new MeshStructure(); structure_->skipBranch(structure1); structure1->commit(); @@ -70,7 +71,7 @@ namespace AMDiS { structure_->nextElement(); } - if(!structure_->isLeafElement()) { + if (!structure_->isLeafElement()) { MeshStructure *structure2 = new MeshStructure(); structure_->skipBranch(structure2); structure2->commit(); @@ -82,22 +83,27 @@ namespace AMDiS { return true; }; - virtual const int getTypeID() const { + virtual const int getTypeID() const + { return MESH_STRUCTURE; - }; + } - virtual bool isOfType(int typeID) const { - if(typeID == MESH_STRUCTURE) return true; + virtual bool isOfType(int typeID) const + { + if (typeID == MESH_STRUCTURE) + return true; return false; - }; + } - inline void setStructure(MeshStructure *structure) { + inline void setStructure(MeshStructure *structure) + { structure_ = structure; - }; + } - inline MeshStructure *getStructure() { + inline MeshStructure *getStructure() + { return structure_; - }; + } protected: MeshStructure *structure_; diff --git a/AMDiS/src/MpCCIAdapter.h b/AMDiS/src/MpCCIAdapter.h index e92012a6..2cd241dd 100644 --- a/AMDiS/src/MpCCIAdapter.h +++ b/AMDiS/src/MpCCIAdapter.h @@ -23,16 +23,12 @@ #define AMDIS_MPCCIADAPTER_H #include <map> +#include "AMDiS_fwd.h" #include "cci.h" #include "cci_const.h" namespace AMDiS { - class SMIAdapter; - class FiniteElemSpace; - class ElInfo; - template<typename T> class DOFVector; - class MpCCIAdapter { public: diff --git a/AMDiS/src/Newton.h b/AMDiS/src/Newton.h index 8f3b5740..5410da8b 100644 --- a/AMDiS/src/Newton.h +++ b/AMDiS/src/Newton.h @@ -41,54 +41,41 @@ namespace AMDiS { class Newton : public NonLinSolver<VectorType> { public: - /** \brief - * Creator class used in the NonLinSolverMap. - */ + /// Creator class used in the NonLinSolverMap. class Creator : public NonLinSolverCreator<VectorType> { public: - virtual ~Creator() {}; + virtual ~Creator() {} - /** \brief - * Returns a new Newton object. - */ - NonLinSolver<VectorType>* create() { + /// Returns a new Newton object. + NonLinSolver<VectorType>* create() + { return new Newton(this->name, this->linearSolver, this->nonLinUpdater); - }; + } }; - /** \brief - * Calls constructor of base class NonLinSolver - */ + /// Calls constructor of base class NonLinSolver Newton(const std::string& name_, OEMSolver *linSolver_, NonLinUpdater<VectorType> *updater) : NonLinSolver<VectorType>(name_, linSolver_, updater) - {}; + {} private: - /** \brief - * realisation of NonLinSolver::init - */ + /// realisation of NonLinSolver::init void init(); - /** \brief - * realisation of NonLinSolver::nlsolve - */ - int nlsolve(MatVecMultiplier<VectorType> *matVec, - VectorType *x, VectorType *rhs, - Preconditioner<VectorType> *lPrecon = NULL, - Preconditioner<VectorType> *rPrecon = NULL); - - /** \brief - * realisation of NonLinSolver::exit - */ + /// realisation of NonLinSolver::nlsolve + int nlsolve(MatVecMultiplier<VectorType> *matVec, + VectorType *x, VectorType *rhs, + Preconditioner<VectorType> *lPrecon = NULL, + Preconditioner<VectorType> *rPrecon = NULL); + + /// realisation of NonLinSolver::exit void exit(); private: - /** \brief - * internal used data - */ + /// internal used data VectorType *b; }; diff --git a/AMDiS/src/NonLinSolver.h b/AMDiS/src/NonLinSolver.h index 9e87bd32..631a9e4a 100644 --- a/AMDiS/src/NonLinSolver.h +++ b/AMDiS/src/NonLinSolver.h @@ -35,10 +35,6 @@ namespace AMDiS { template<typename VectorType> class NonLinUpdater; - // ============================================================================ - // ===== class NonLinSolver =================================================== - // ============================================================================ - /** * \ingroup Solver * @@ -59,14 +55,10 @@ namespace AMDiS { OEMSolver *linSolver_, NonLinUpdater<VectorType> *updater); - /** \brief - * destructor - */ - virtual ~NonLinSolver() {}; + /// destructor + virtual ~NonLinSolver() {} - /** \brief - * solves the non linear system. Uses sub class methods - */ + /// solves the non linear system. Uses sub class methods inline int solve(MatVecMultiplier<VectorType> *matVec, VectorType *x, VectorType *rhs, Preconditioner<VectorType> *lPrecon = NULL, @@ -77,47 +69,50 @@ namespace AMDiS { int result = nlsolve(matVec, x, rhs, lPrecon, rPrecon); exit(); return result; - }; + } - inline void setTolerance(double tol) { + inline void setTolerance(double tol) + { tolerance = tol; - }; + } - inline double getTolerance() { + inline double getTolerance() + { return tolerance; - }; + } - inline void setVectorCreator(CreatorInterface<VectorType> *creator) { + inline void setVectorCreator(CreatorInterface<VectorType> *creator) + { vectorCreator = creator; - }; + } - inline OEMSolver *getLinearSolver() { return linSolver; }; + inline OEMSolver *getLinearSolver() + { + return linSolver; + } - inline void setNonLinUpdater(NonLinUpdater<VectorType> *up) { + inline void setNonLinUpdater(NonLinUpdater<VectorType> *up) + { nonLinUpdater = up; - }; + } - inline NonLinUpdater<VectorType> *getNonLinUpdater() { + inline NonLinUpdater<VectorType> *getNonLinUpdater() + { return nonLinUpdater; - }; + } protected: - /** \brief - * Allocates needed memory. Must be overriden in sub classes. - */ + /// Allocates needed memory. Must be overriden in sub classes. virtual void init() = 0; - /** \brief - * Solves the non linear system. Must be overriden in sub classes. - */ + /// Solves the non linear system. Must be overriden in sub classes. + virtual int nlsolve(MatVecMultiplier<VectorType> *matVec, VectorType *x, VectorType *rhs, Preconditioner<VectorType> *lPrecon = NULL, Preconditioner<VectorType> *rPrecon = NULL) = 0; - /** \brief - * Frees needed memory. Must be overriden in sub classes. - */ + /// Frees needed memory. Must be overriden in sub classes. virtual void exit() = 0; virtual int solveLinearSystem(MatVecMultiplier<VectorType> *matVec, @@ -129,8 +124,7 @@ namespace AMDiS { TEST_EXIT(linSolver)("no solver\n"); ERROR_EXIT("Not yet re-implemented!\n"); return -1; - // return linSolver->solve(matVec, x, fh, lPrecon, rPrecon); - }; + } protected: std::string name; /**< \brief name of the solver */ @@ -146,26 +140,28 @@ namespace AMDiS { CreatorInterface<VectorType> *vectorCreator; }; - // ============================================================================ - // ===== class NonLinSolverCreator ============================================ - // ============================================================================ - /** \brief - * Interface for creators of concrete NonLinSolvers. - */ + /// Interface for creators of concrete NonLinSolvers. template<typename VectorType> class NonLinSolverCreator : public CreatorInterface<NonLinSolver<VectorType> > { public: - virtual ~NonLinSolverCreator() {}; + virtual ~NonLinSolverCreator() {} - void setName(std::string name_) { name = name_; }; + void setName(std::string name_) + { + name = name_; + } - void setLinearSolver(OEMSolver *solver) { linearSolver = solver; }; + void setLinearSolver(OEMSolver *solver) + { + linearSolver = solver; + } - void setNonLinUpdater(NonLinUpdater<VectorType> *updater) { + void setNonLinUpdater(NonLinUpdater<VectorType> *updater) + { nonLinUpdater = updater; - }; + } protected: std::string name; diff --git a/AMDiS/src/NonLinUpdater.h b/AMDiS/src/NonLinUpdater.h index ceeabb82..4f415440 100644 --- a/AMDiS/src/NonLinUpdater.h +++ b/AMDiS/src/NonLinUpdater.h @@ -28,10 +28,6 @@ namespace AMDiS { - // ========================================================================= - // ===== class NonLinUpdater =============================================== - // ========================================================================= - /** \brief * Used in non linear solvers for matrix and vector assemblage. * Base class for NonLinUpdaterScal and NonLinUpdaterVec. @@ -40,72 +36,47 @@ namespace AMDiS { class NonLinUpdater { public: - virtual ~NonLinUpdater() {}; + virtual ~NonLinUpdater() {} - /** \brief - * Pure virtual update function. - */ + /// Pure virtual update function. virtual void update(bool updateDF, Vector *F) = 0; }; - // ========================================================================= - // ===== class NonLinUpdaterScal =========================================== - // ========================================================================= - /** \brief - * NonLinUpdater for scalar problems. - */ + /// NonLinUpdater for scalar problems. class NonLinUpdaterScal : public NonLinUpdater<DOFVector<double> > { public: - /** \brief - * Constructor. - */ - NonLinUpdaterScal(DOFMatrix *m) : df(m) {}; + /// Constructor. + NonLinUpdaterScal(DOFMatrix *m) : df(m) {} - virtual ~NonLinUpdaterScal() {}; + virtual ~NonLinUpdaterScal() {} - /** \brief - * Implementation of NonLinUpdater::update(). - */ + /// Implementation of NonLinUpdater::update(). virtual void update(bool updateDF, DOFVector<double> *F); protected: - /** \brief - * Matrix to be updated. - */ + /// Matrix to be updated. DOFMatrix *df; }; - // ========================================================================= - // ===== class NonLinUpdaterVec ============================================ - // ========================================================================= - /** \brief - * NonLinUpdater for vector valued problems. - */ + /// NonLinUpdater for vector valued problems. class NonLinUpdaterVec : public NonLinUpdater<SystemVector> { public: - /** \brief - * Constructor. - */ - NonLinUpdaterVec(Matrix<DOFMatrix*> *m) : df(m) {}; + /// Constructor. + NonLinUpdaterVec(Matrix<DOFMatrix*> *m) : df(m) {} - virtual ~NonLinUpdaterVec() {}; + virtual ~NonLinUpdaterVec() {} - /** \brief - * Implementation of NonLinUpdater::update(). - */ - virtual void update(bool updateDF, - SystemVector *F); + /// Implementation of NonLinUpdater::update(). + virtual void update(bool updateDF, SystemVector *F); protected: - /** \brief - * Matrix to be updated. - */ + /// Matrix to be updated. Matrix<DOFMatrix*> *df; }; diff --git a/AMDiS/src/OEMSolver.h b/AMDiS/src/OEMSolver.h index 55175d2c..381d937f 100644 --- a/AMDiS/src/OEMSolver.h +++ b/AMDiS/src/OEMSolver.h @@ -68,9 +68,7 @@ namespace AMDiS { rightPrecon(NULL) {} - /** \brief - * - */ + /// virtual ~OEMSolver() { if (leftPrecon) delete leftPrecon; @@ -182,22 +180,26 @@ namespace AMDiS { */ /// Returns solvers \ref name. - inline const std::string& getName() { + inline const std::string& getName() + { return name; } /// Returns \ref tolerance - inline double getTolerance() { + inline double getTolerance() + { return tolerance; } /// Returns \ref max_iter - inline int getMaxIterations() { + inline int getMaxIterations() + { return max_iter; } /// Returns \ref residual - inline double getResidual() { + inline double getResidual() + { return residual; } @@ -208,22 +210,26 @@ namespace AMDiS { */ /// Sets \ref tolerance - inline void setTolerance(double tol) { + inline void setTolerance(double tol) + { tolerance = tol; } /// Sets \ref relative - inline void setRelative(bool rel) { + inline void setRelative(bool rel) + { relative = rel; } /// Sets \ref max_iter - inline void setMaxIterations(int i) { + inline void setMaxIterations(int i) + { max_iter = i; } /// Sets \ref info - inline void setInfo(int i) { + inline void setInfo(int i) + { info = i; } @@ -268,7 +274,8 @@ namespace AMDiS { virtual ~OEMSolverCreator() {} /// Sets \ref problem - void setName(std::string str) { + void setName(std::string str) + { name = str; } diff --git a/AMDiS/src/OpenMP.h b/AMDiS/src/OpenMP.h index 799c157d..3486fac9 100644 --- a/AMDiS/src/OpenMP.h +++ b/AMDiS/src/OpenMP.h @@ -8,7 +8,8 @@ const bool amdisHaveOpenMP = true; -inline int omp_get_overall_max_threads() { +inline int omp_get_overall_max_threads() +{ return std::max(omp_get_max_threads(), omp_get_num_threads()); } @@ -16,23 +17,28 @@ inline int omp_get_overall_max_threads() { const bool amdisHaveOpenMP = false; -inline int omp_get_max_threads() { +inline int omp_get_max_threads() +{ return 1; } -inline int omp_get_num_procs() { +inline int omp_get_num_procs() +{ return 1; } -inline int omp_get_num_threads() { +inline int omp_get_num_threads() +{ return 1; } -inline int omp_get_thread_num() { +inline int omp_get_thread_num() +{ return 0; } -inline int omp_get_overall_max_threads() { +inline int omp_get_overall_max_threads() +{ return 1; } diff --git a/AMDiS/src/Operator.h b/AMDiS/src/Operator.h index ae1c4b1f..5d4cd455 100644 --- a/AMDiS/src/Operator.h +++ b/AMDiS/src/Operator.h @@ -77,7 +77,8 @@ namespace AMDiS { {} /// Returs \auxFESpaces, the list of all aux fe spaces the operator makes use off. - std::vector<const FiniteElemSpace*>& getAuxFESpaces() { + std::vector<const FiniteElemSpace*>& getAuxFESpaces() + { return auxFESpaces; } @@ -85,7 +86,8 @@ namespace AMDiS { void setSymmetric(bool symm); /// Returns true, if the term is piecewise constant, returns false otherwise - inline bool isPWConst() { + inline bool isPWConst() + { return (degree == 0); } @@ -93,7 +95,8 @@ namespace AMDiS { bool isSymmetric(); /// Returns \ref degree. - inline int getDegree() { + inline int getDegree() + { return degree; } @@ -281,9 +284,8 @@ namespace AMDiS { if (D2UhAtQP) { for (int iq = 0; iq < nPoints; iq++) { double resultQP = 0.0; - for (int i = 0; i < dow; i++) { + for (int i = 0; i < dow; i++) resultQP += D2UhAtQP[iq][i][i]; - } result[iq] += factor * resultQP; } } @@ -294,10 +296,9 @@ namespace AMDiS { const WorldVector<double> *grdUhAtQP, WorldVector<double> *result) const { - if (grdUhAtQP) { + if (grdUhAtQP) for (int iq = 0; iq < nPoints; iq++) result[iq] += grdUhAtQP[iq]; - } } }; @@ -329,9 +330,7 @@ namespace AMDiS { setSymmetric(true); } - /** \brief - * Implements SecondOrderTerm::getLALt(). - */ + /// Implements SecondOrderTerm::getLALt(). inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const { const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda(); @@ -339,10 +338,7 @@ namespace AMDiS { l1lt(Lambda, *(LALt[iq]), (*factor)); } - - /** \brief - * Implenetation of SecondOrderTerm::eval(). - */ + /// Implenetation of SecondOrderTerm::eval(). void eval(int nPoints, const double *, const WorldVector<double> *, @@ -363,24 +359,18 @@ namespace AMDiS { } } - /** \brief - * Implenetation of SecondOrderTerm::weakEval(). - */ + /// Implenetation of SecondOrderTerm::weakEval(). void weakEval(int nPoints, const WorldVector<double> *grdUhAtQP, WorldVector<double> *result) const { - if (grdUhAtQP) { - for (int iq = 0; iq < nPoints; iq++) { + if (grdUhAtQP) + for (int iq = 0; iq < nPoints; iq++) axpy(*factor, grdUhAtQP[iq], result[iq]); - } - } } private: - /** \brief - * Pointer to the factor. - */ + /// Pointer to the factor. double *factor; }; @@ -476,11 +466,10 @@ namespace AMDiS { /** \brief * Implements SecondOrderTerm::getLALt(). */ - inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const{ - const DimVec<WorldVector<double> >& Lambda = elInfo->getGrdLambda(); - //double det = elInfo->getDet(); - int iq; - for(iq = 0; iq < nPoints; iq++) + inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const + { + const DimVec<WorldVector<double> >& Lambda = elInfo->getGrdLambda(); + for (int iq = 0; iq < nPoints; iq++) lalt(Lambda, matrix, *(LALt[iq]), symmetric, 1.0); } @@ -547,8 +536,7 @@ namespace AMDiS { inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const { const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda(); - int iq; - for(iq = 0; iq < nPoints; iq++) + for (int iq = 0; iq < nPoints; iq++) lalt_kl(Lambda, xi, xj, *(LALt[iq]), (*factor)); } @@ -562,12 +550,9 @@ namespace AMDiS { double *result, double fac) const { - int iq; - if(D2UhAtQP) { - for(iq = 0; iq < nPoints; iq++) { + if (D2UhAtQP) + for (int iq = 0; iq < nPoints; iq++) result[iq] += (*factor) * D2UhAtQP[iq][xi][xj] * fac; - } - } } /** \brief @@ -577,12 +562,9 @@ namespace AMDiS { const WorldVector<double> *grdUhAtQP, WorldVector<double> *result) const { - if(grdUhAtQP) { - int iq; - for(iq = 0; iq < nPoints; iq++) { + if (grdUhAtQP) + for (int iq = 0; iq < nPoints; iq++) result[iq][xi] += (*factor) * grdUhAtQP[iq][xj]; - } - } } private: @@ -1423,9 +1405,8 @@ namespace AMDiS { { const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda(); - for (int iq = 0; iq < nPoints; iq++) { + for (int iq = 0; iq < nPoints; iq++) l1(Lambda, Lb[iq], 1.0); - } } }; @@ -1459,9 +1440,8 @@ namespace AMDiS { { const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda(); - for (int iq = 0; iq < nPoints; iq++) { + for (int iq = 0; iq < nPoints; iq++) l1(Lambda, Lb[iq], (*factor)); - } } private: @@ -1494,9 +1474,8 @@ namespace AMDiS { { const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda(); - for (int iq = 0; iq < nPoints; iq++) { + for (int iq = 0; iq < nPoints; iq++) lb(Lambda, b, Lb[iq], 1.0); - } } /** \brief @@ -1509,11 +1488,9 @@ namespace AMDiS { double *result, double factor) const { - if (grdUhAtQP) { - for(int iq = 0; iq < nPoints; iq++) { + if (grdUhAtQP) + for(int iq = 0; iq < nPoints; iq++) result[iq] += b * grdUhAtQP[iq] * factor; - } - } } protected: @@ -2070,9 +2047,8 @@ namespace AMDiS { /// Implements ZeroOrderTerm::getC(). inline void getC(const ElInfo *, int nPoints, std::vector<double> &C) const { - for (int iq = 0; iq < nPoints; iq++) { + for (int iq = 0; iq < nPoints; iq++) C[iq] += factor; - } } /** \brief @@ -2085,9 +2061,8 @@ namespace AMDiS { double *result, double fac) const { - for (int iq = 0; iq < nPoints; iq++) { + for (int iq = 0; iq < nPoints; iq++) result[iq] += fac * factor * uhAtQP[iq]; - } } protected: @@ -3394,14 +3369,16 @@ namespace AMDiS { /** \brief * Sets \ref optimized. */ - inline void useOptimizedAssembler(bool opt) { + inline void useOptimizedAssembler(bool opt) + { optimized = opt; } /** \brief * Returns \ref optimized. */ - inline bool isOptimized() { + inline bool isOptimized() + { return optimized; } @@ -3458,17 +3435,20 @@ namespace AMDiS { void finishAssembling(); /// Returns \ref rowFESpace. - inline const FiniteElemSpace *getRowFESpace() { + inline const FiniteElemSpace *getRowFESpace() + { return rowFESpace; } /// Returns \ref colFESpace. - inline const FiniteElemSpace *getColFESpace() { + inline const FiniteElemSpace *getColFESpace() + { return colFESpace; } /// Returns \ref auxFESpaces. - inline std::vector<const FiniteElemSpace*> getAuxFESpaces() { + inline std::vector<const FiniteElemSpace*> getAuxFESpaces() + { return auxFESpaces; } @@ -3480,7 +3460,8 @@ namespace AMDiS { /** \brief * Returns \ref uhOld. */ - inline const DOFVectorBase<double> *getUhOld() { + inline const DOFVectorBase<double> *getUhOld() + { return uhOld; } @@ -3491,32 +3472,38 @@ namespace AMDiS { void setAssembler(int rank, Assembler *ass); /// Returns whether this is a matrix operator. - inline const bool isMatrixOperator() { + inline const bool isMatrixOperator() + { return type.isSet(MATRIX_OPERATOR); } /// Returns whether this is a vector operator - inline const bool isVectorOperator() { + inline const bool isVectorOperator() + { return type.isSet(VECTOR_OPERATOR); } /// Sets \ref fillFlag, the flag used for this Operator while mesh traversal. - inline void setFillFlag(Flag f) { + inline void setFillFlag(Flag f) + { fillFlag = f; } /// Sets \ref needDualTraverse. - void setNeedDualTraverse(bool b) { + void setNeedDualTraverse(bool b) + { needDualTraverse = b; } /// Returns \ref fillFlag - inline Flag getFillFlag() { + inline Flag getFillFlag() + { return fillFlag; } /// Returns \ref needDualTraverse - bool getNeedDualTraverse() { + bool getNeedDualTraverse() + { return needDualTraverse; } @@ -3544,9 +3531,8 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = zeroOrder[myRank].begin(); termIt != zeroOrder[myRank].end(); - ++termIt) { + ++termIt) (*termIt)->eval(nPoints, uhAtQP, grdUhAtQP, D2UhAtQP, result, factor); - } } @@ -3565,9 +3551,8 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = firstOrderGrdPsi[myRank].begin(); termIt != firstOrderGrdPsi[myRank].end(); - ++termIt) { + ++termIt) (*termIt)->eval(nPoints, uhAtQP, grdUhAtQP, D2UhAtQP, result, factor); - } } /** \brief @@ -3585,9 +3570,8 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = firstOrderGrdPhi[myRank].begin(); termIt != firstOrderGrdPhi[myRank].end(); - ++termIt) { + ++termIt) (*termIt)->eval(nPoints, uhAtQP, grdUhAtQP, D2UhAtQP, result, factor); - } } @@ -3606,9 +3590,8 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = secondOrder[myRank].begin(); termIt != secondOrder[myRank].end(); - ++termIt) { + ++termIt) (*termIt)->eval(nPoints, uhAtQP, grdUhAtQP, D2UhAtQP, result, factor); - } } /** \brief @@ -3623,9 +3606,8 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = secondOrder[myRank].begin(); termIt != secondOrder[myRank].end(); - ++termIt) { + ++termIt) static_cast<SecondOrderTerm*>(*termIt)->weakEval(nPoints, grdUhAtQP, result); - } } /** \brief @@ -3639,9 +3621,8 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = secondOrder[myRank].begin(); termIt != secondOrder[myRank].end(); - ++termIt) { + ++termIt) static_cast<SecondOrderTerm*>(*termIt)->getLALt(elInfo, nPoints, LALt); - } } /** \brief @@ -3655,9 +3636,8 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = firstOrderGrdPsi[myRank].begin(); termIt != firstOrderGrdPsi[myRank].end(); - ++termIt) { + ++termIt) static_cast<FirstOrderTerm*>(*termIt)->getLb(elInfo, nPoints, Lb); - } } /** \brief @@ -3671,9 +3651,8 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = firstOrderGrdPhi[myRank].begin(); termIt != firstOrderGrdPhi[myRank].end(); - ++termIt) { + ++termIt) static_cast<FirstOrderTerm*>(*termIt)->getLb(elInfo, nPoints, Lb); - } } /** \brief @@ -3687,13 +3666,13 @@ namespace AMDiS { std::vector<OperatorTerm*>::const_iterator termIt; for (termIt = zeroOrder[myRank].begin(); termIt != zeroOrder[myRank].end(); - ++termIt) { + ++termIt) static_cast<ZeroOrderTerm*>(*termIt)->getC(elInfo, nPoints, c); - } } /// Returns true, if there are second order terms. Returns false otherwise. - inline bool secondOrderTerms() { + inline bool secondOrderTerms() + { return secondOrder[omp_get_thread_num()].size() != 0; } @@ -3701,7 +3680,8 @@ namespace AMDiS { * Returns true, if there are first order terms (grdPsi). * Returns false otherwise. */ - inline bool firstOrderTermsGrdPsi() { + inline bool firstOrderTermsGrdPsi() + { return firstOrderGrdPsi[omp_get_thread_num()].size() != 0; } @@ -3709,7 +3689,8 @@ namespace AMDiS { * Returns true, if there are first order terms (grdPhi). * Returns false otherwise. */ - inline bool firstOrderTermsGrdPhi() { + inline bool firstOrderTermsGrdPhi() + { return firstOrderGrdPhi[omp_get_thread_num()].size() != 0; } @@ -3717,7 +3698,8 @@ namespace AMDiS { * Returns true, if there are zero order terms. * Returns false otherwise. */ - inline bool zeroOrderTerms() { + inline bool zeroOrderTerms() + { return zeroOrder[omp_get_thread_num()].size() != 0; } diff --git a/AMDiS/src/ParallelDomainProblem.cc b/AMDiS/src/ParallelDomainProblem.cc index 828190a2..b77bdd56 100644 --- a/AMDiS/src/ParallelDomainProblem.cc +++ b/AMDiS/src/ParallelDomainProblem.cc @@ -19,11 +19,13 @@ namespace AMDiS { ParallelDomainProblemBase::ParallelDomainProblemBase(const std::string& name, ProblemIterationInterface *iIF, ProblemTimeInterface *tIF, - FiniteElemSpace *fe) + FiniteElemSpace *fe, + RefinementManager *refineManager) : iterationIF(iIF), timeIF(tIF), feSpace(fe), mesh(fe->getMesh()), + refinementManager(refineManager), initialPartitionMesh(true), nRankDOFs(0) { @@ -48,14 +50,23 @@ namespace AMDiS { // === Create new global and local DOF numbering. === + // Set of all DOFs of the rank. + std::vector<const DegreeOfFreedom*> rankDOFs; + // Set of all interior boundary DOFs in ranks partition which are owned by + // another rank. + std::map<const DegreeOfFreedom*, int> boundaryDOFs; + // Number of DOFs in ranks partition that are owned by the rank. int nRankDOFs = 0; + // Number of DOFs in ranks partition that are at an interior boundary and are + // owned by other ranks. int nOverallDOFs = 0; - createLocalGlobalNumbering(nRankDOFs, nOverallDOFs); + + createLocalGlobalNumbering(rankDOFs, boundaryDOFs, nRankDOFs, nOverallDOFs); // === Create interior boundary information === - createInteriorBoundaryInfo(); + createInteriorBoundaryInfo(rankDOFs, boundaryDOFs); // === Remove all macro elements that are not part of the rank partition. === @@ -67,13 +78,27 @@ namespace AMDiS { int nAdmins = mesh->getNumberOfDOFAdmin(); for (int i = 0; i < nAdmins; i++) { - for (int j = 0; j < mesh->getDOFAdmin(i).getSize(); j++) - const_cast<DOFAdmin&>(mesh->getDOFAdmin(i)).setDOFFree(j, true); + DOFAdmin& admin = const_cast<DOFAdmin&>(mesh->getDOFAdmin(i)); + + for (int j = 0; j < admin.getSize(); j++) + admin.setDOFFree(j, true); for (int j = 0; j < static_cast<int>(mapLocalGlobalDOFs.size()); j++) - const_cast<DOFAdmin&>(mesh->getDOFAdmin(i)).setDOFFree(j, false); + admin.setDOFFree(j, false); + + admin.setUsedSize(mapLocalGlobalDOFs.size() - 1); + admin.setUsedCount(mapLocalGlobalDOFs.size()); + admin.setFirstHole(mapLocalGlobalDOFs.size()); } + /// === Global refinements. === + + refinementManager->globalRefine(mesh, 1); + + updateLocalGlobalNumbering(nRankDOFs, nOverallDOFs); + + exit(0); + /// === Create petsc matrix. === int ierr; @@ -248,14 +273,14 @@ namespace AMDiS { } - void ParallelDomainProblemBase::createInteriorBoundaryInfo() + void ParallelDomainProblemBase::createInteriorBoundaryInfo(std::vector<const DegreeOfFreedom*>& rankDOFs, + std::map<const DegreeOfFreedom*, int>& boundaryDOFs) { TraverseStack stack; ElInfo *elInfo = stack.traverseFirst(mesh, -1, Mesh::CALL_LEAF_EL | Mesh::FILL_NEIGH); while (elInfo) { Element *element = elInfo->getElement(); - // Hidde elements which are not part of ranks partition. PartitionElementData *partitionData = dynamic_cast<PartitionElementData*>(element->getElementData(PARTITION_ED)); if (partitionData->getPartitionStatus() == IN) { @@ -266,14 +291,46 @@ namespace AMDiS { PartitionElementData *neighbourPartitionData = dynamic_cast<PartitionElementData*>(elInfo->getNeighbour(i)->getElementData(PARTITION_ED)); if (neighbourPartitionData->getPartitionStatus() == OUT) { - AtomicBoundary& bound = interiorBoundary. - getNewAtomicBoundary(partitionVec[elInfo->getNeighbour(i)->getIndex()]); - bound.rankObject.el = element; - bound.rankObject.subObjAtBoundary = EDGE; - bound.rankObject.ithObjAtBoundary = i; - bound.neighbourObject.el = elInfo->getNeighbour(i); - bound.neighbourObject.subObjAtBoundary = EDGE; - bound.neighbourObject.ithObjAtBoundary = -1; + // We have found an element that is at an interior boundary. + + // === Find out, if the boundary part of the element corresponds to the + // rank or to the rank "on the other side" of the interoir boundary. === + + const DegreeOfFreedom* boundDOF1 = NULL; + const DegreeOfFreedom* boundDOF2 = NULL; + + switch (i) { + case 0: + boundDOF1 = element->getDOF(1); + boundDOF2 = element->getDOF(2); + break; + case 1: + boundDOF1 = element->getDOF(0); + boundDOF2 = element->getDOF(2); + break; + case 2: + boundDOF1 = element->getDOF(0); + boundDOF2 = element->getDOF(1); + break; + default: + ERROR_EXIT("Should never happen!\n"); + } + + bool isRankDOF1 = (find(rankDOFs.begin(), rankDOFs.end(), boundDOF1) != rankDOFs.end()); + bool isRankDOF2 = (find(rankDOFs.begin(), rankDOFs.end(), boundDOF2) != rankDOFs.end()); + bool ranksBoundary = isRankDOF1 || isRankDOF2; + + /// === And add the part of the interior boundary. === + + AtomicBoundary& bound = + interiorBoundary.getNewAtomicBoundary(ranksBoundary ? mpiRank : + partitionVec[elInfo->getNeighbour(i)->getIndex()]); + bound.rankObject.el = element; + bound.rankObject.subObjAtBoundary = EDGE; + bound.rankObject.ithObjAtBoundary = i; + bound.neighbourObject.el = elInfo->getNeighbour(i); + bound.neighbourObject.subObjAtBoundary = EDGE; + bound.neighbourObject.ithObjAtBoundary = -1; } } } @@ -300,18 +357,15 @@ namespace AMDiS { } - void ParallelDomainProblemBase::createLocalGlobalNumbering(int& nRankDOFs, + void ParallelDomainProblemBase::createLocalGlobalNumbering(std::vector<const DegreeOfFreedom*>& rankDOFs, + std::map<const DegreeOfFreedom*, int>& boundaryDOFs, + int& nRankDOFs, int& nOverallDOFs) { /// === Get rank information about DOFs. === // Stores to each DOF pointer the set of ranks the DOF is part of. std::map<const DegreeOfFreedom*, std::set<int> > partitionDOFs; - // Set of all DOFs of the rank. - std::vector<const DegreeOfFreedom*> rankDOFs; - // Set of all interior boundary DOFs in ranks partition which are owned by - // another rank. - std::map<const DegreeOfFreedom*, int> boundaryDOFs; createDOFMemberInfo(partitionDOFs, rankDOFs, boundaryDOFs); @@ -470,6 +524,40 @@ namespace AMDiS { } + void ParallelDomainProblemBase::updateLocalGlobalNumbering(int& nRankDOFs, + int& nOverallDOFs) + { + std::set<const DegreeOfFreedom*> rankDOFs; + std::set<const DegreeOfFreedom*> boundaryDOFs; + + + /// === Get all DOFs in ranks partition. === + + TraverseStack stack; + ElInfo *elInfo = stack.traverseFirst(mesh, -1, Mesh::CALL_LEAF_EL); + while (elInfo) { + Element *element = elInfo->getElement(); + + for (int i = 0; i < 3; i++) + rankDOFs.insert(element->getDOF(i)); + + elInfo = stack.traverseNext(elInfo); + } + + + // === Traverse on interior boundaries and move all not ranked owned DOFs from + // rankDOFs to boundaryDOFs === // + + for (std::map<int, std::vector<AtomicBoundary> >::iterator it = + interiorBoundary.boundary.begin(); + it != interiorBoundary.boundary.end(); + ++it) { + for (int i = 0; i < it->second.size(); i++) { + + } + } + } + void ParallelDomainProblemBase::createDOFMemberInfo( std::map<const DegreeOfFreedom*, std::set<int> >& partitionDOFs, @@ -533,7 +621,11 @@ namespace AMDiS { ParallelDomainProblemScal::ParallelDomainProblemScal(const std::string& name, ProblemScal *problem, ProblemInstatScal *problemInstat) - : ParallelDomainProblemBase(name, problem, problemInstat, problem->getFESpace()), + : ParallelDomainProblemBase(name, + problem, + problemInstat, + problem->getFESpace(), + problem->getRefinementManager()), probScal(problem) { } @@ -564,8 +656,8 @@ namespace AMDiS { // if (toDo.isSet(ESTIMATE)) // iterationIF->getProblem()->estimate(adaptInfo); - return flag; + return flag; } } diff --git a/AMDiS/src/ParallelDomainProblem.h b/AMDiS/src/ParallelDomainProblem.h index 41a4ebf8..ee2b9c24 100644 --- a/AMDiS/src/ParallelDomainProblem.h +++ b/AMDiS/src/ParallelDomainProblem.h @@ -31,6 +31,8 @@ #include "FiniteElemSpace.h" #include "AdaptInfo.h" #include "InteriorBoundary.h" +#include "AMDiS_fwd.h" + #include "petsc.h" #include "petscsys.h" #include "petscao.h" @@ -38,12 +40,7 @@ namespace AMDiS { - class ProblemScal; - class ProblemInstatScal; class ParMetisPartitioner; - class Mesh; - class DOFMatrix; - template<typename T> class DOFVector; class ParallelDomainProblemBase : public ProblemIterationInterface, public ProblemTimeInterface @@ -52,7 +49,8 @@ namespace AMDiS { ParallelDomainProblemBase(const std::string& name, ProblemIterationInterface *iterationIF, ProblemTimeInterface *timeIF, - FiniteElemSpace *feSpace); + FiniteElemSpace *feSpace, + RefinementManager *refineManager); virtual ~ParallelDomainProblemBase() {} @@ -126,12 +124,18 @@ namespace AMDiS { * Determine the interior boundaries, i.e. boundaries between ranks, and store * all information about them in \ref interiorBoundary. */ - void createInteriorBoundaryInfo(); + void createInteriorBoundaryInfo(std::vector<const DegreeOfFreedom*>& rankDOFs, + std::map<const DegreeOfFreedom*, int>& boundaryDOFs); /// Removes all macro elements from the mesh that are not part of ranks partition. void removeMacroElements(); - void createLocalGlobalNumbering(int& nRankDOFs, int& nOverallDOFs); + void createLocalGlobalNumbering(std::vector<const DegreeOfFreedom*>& rankDOFs, + std::map<const DegreeOfFreedom*, int>& boundaryDOFs, + int& nRankDOFs, + int& nOverallDOFs); + + void updateLocalGlobalNumbering(int& nRankDOFs, int& nOverallDOFs); /** \brief * This function traverses the whole mesh, i.e. before it is really partitioned, @@ -177,6 +181,9 @@ namespace AMDiS { /// Mesh of the problem. Mesh *mesh; + /// Refinement manager for the mesh. + RefinementManager *refinementManager; + /// Pointer to the paritioner which is used to devide a mesh into partitions. ParMetisPartitioner *partitioner; diff --git a/AMDiS/src/RefinementManager.cc b/AMDiS/src/RefinementManager.cc index a5fed07c..0dc3649f 100644 --- a/AMDiS/src/RefinementManager.cc +++ b/AMDiS/src/RefinementManager.cc @@ -59,8 +59,8 @@ namespace AMDiS { Mesh::CALL_LEAF_EL | Mesh::FILL_NEIGH | Mesh::FILL_BOUND); while (elInfo) { if (elInfo->getElement()->getMark() > 0) { - doMoreRecursiveRefine = doMoreRecursiveRefine || - (elInfo->getElement()->getMark() > 1); + doMoreRecursiveRefine = + doMoreRecursiveRefine || (elInfo->getElement()->getMark() > 1); elInfo = refineFunction(elInfo); } elInfo = stack->traverseNext(elInfo); diff --git a/AMDiS/src/RefinementManager2d.cc b/AMDiS/src/RefinementManager2d.cc index 945e819f..382331c9 100644 --- a/AMDiS/src/RefinementManager2d.cc +++ b/AMDiS/src/RefinementManager2d.cc @@ -229,9 +229,8 @@ namespace AMDiS { 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++) { + for(it = admin->beginDOFIndexed(); it != end; it++) (*it)->refineInterpol(*refineList, n_neigh); - } } @@ -251,9 +250,8 @@ namespace AMDiS { mesh->freeDOF(const_cast<int*>( el->getDOF(node+2)), EDGE); } - if (mesh->getNumberOfDOFs(EDGE) || mesh->getNumberOfDOFs(CENTER)) { + if (mesh->getNumberOfDOFs(EDGE) || mesh->getNumberOfDOFs(CENTER)) refineList->removeDOFParents(n_neigh); - } } return dof[0][0]; -- GitLab