diff -Nru dune-common-2.2.1/am/checklog dune-common-2.5.2~20170808ga5c076ca/am/checklog --- dune-common-2.2.1/am/checklog 2011-08-12 17:28:43.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/checklog 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ -# -*- Makefile -*- -# $Id: checklog 6488 2011-08-12 17:28:43Z sander $ - -# -# check-log -# -# This file implements the build-rules needed by the automated tests. -# "make check-log" will build the whole package and run all tests. For -# each test a log file under $(topsrc_dir)/check-log is created which -# contains the name of the test and what kind of test it was (build, -# lib, run, ...). If a test fails this is logged, but all other tests -# are still run. -# -# make OPTIONS: -# LOG_TIMING - specific command to measure the time needed for each test -# example: "make LOG_TIMING='time -p' check-log" -# -# IMPLEMENTATION: check-log depends on different targets for different -# kinds of tests. These can run idividually by calling check-log-XXX. -# Possible variants are (in order of dependence) -# - libs (build all libraries) -# - build (build all applications and tests) -# - test (run each test from $(TESTS)) -# - sources (run sourcescheck in each directory) -# - headers (run headercheck for each header) -# - dir (create dir entries for database, no actual tests are run) -# - -LOG_FILE = $(top_srcdir)/check-log.log -LOG_DIR = $(top_srcdir)/check-log -LOG_STORE = $(SHELL) $(DUNE_COMMON_ROOT)/bin/check-log-store $(LOG_FILE) $(LOG_DIR) -LOG_TIMING = -LOG_SET_OPTIONS = \ - path=`test "$(subdir)" = "." && \ - echo "/@PACKAGE_NAME@" || echo "/@PACKAGE_NAME@/$(subdir)"`; \ - ppath=`dirname $$path`; \ - dir=`basename $$path` - -$(DUNE_COMMON_ROOT)/bin/check-log-store: $(DUNE_COMMON_ROOT)/bin/check-log-store.in - cd $(DUNE_COMMON_ROOT)/bin/ && $(MAKE) check-log-store - -check-log: $(DUNE_COMMON_ROOT)/bin/check-log-store -check-log: - rm -f $(LOG_FILE) - -check-log: check-log-libs -check-log: check-log-build -check-log: check-log-test -check-log: check-log-sources -check-log: check-log-headers -check-log: check-log-dir - -check-log-libs: check-log-libs-recursive -check-log-build: check-log-build-recursive -check-log-test: check-log-test-recursive -check-log-sources: check-log-sources-recursive -check-log-headers: check-log-headers-recursive -check-log-dir: check-log-dir-recursive - -check-log-headers-am: - $(LOG_SET_OPTIONS); \ - list=`echo $(headercheck_PATTERN)`; \ - test "$$list" != "$(headercheck_PATTERN)" || exit 0; \ - for f in $$list; do \ - echo "$(headercheck_IGNORE)" | tr ' ' '\n' | grep -q "$$f"; \ - if echo "$(headercheck_IGNORE)" | tr ' ' '\n' | grep -q "$$f"; then continue; fi; \ - $(LOG_TIMING) ($(MAKE) headercheck-am SILENT=0 HEADER=$$f; \ - $(MAKE) headercheck-am SILENT=0 HEADER=$$f NO_CONFIG_H=1) > $(LOG_FILE) 2>&1; \ - $(LOG_STORE) "headercheck" "$$f" "$$path"; \ - done - -check-log-sources-am: - $(LOG_SET_OPTIONS); \ - $(LOG_TIMING) $(MAKE) sourcescheck-am > $(LOG_FILE) 2>&1; \ - $(LOG_STORE) "sources" "Makefile.am" "$$path" - -check-log-libs-am: - $(LOG_SET_OPTIONS); \ - for lib in $(LTLIBRARIES); do \ - $(LOG_TIMING) ($(MAKE) $$lib) > $(LOG_FILE) 2>&1; \ - $(LOG_STORE) "lib" "$$lib" "$$path"; \ - done; - -check-log-build-am: - $(LOG_SET_OPTIONS); \ - for target in $(check_PROGRAMS) $(PROGRAMS); do \ - $(LOG_TIMING) ($(MAKE) $$target) > $(LOG_FILE) 2>&1; \ - $(LOG_STORE) "build" "$$target" "$$path"; \ - done; - -check-log-test-am: - @LOG () { \ - echo "$$1" > $(LOG_FILE).2; \ - cat $(LOG_FILE) >> $(LOG_FILE).2; \ - mv $(LOG_FILE).2 $(LOG_FILE); \ - }; \ - $(LOG_SET_OPTIONS); \ - for tst in $(TESTS); do \ - if test -f ./$$tst; then dir=./; \ - elif test -f $$tst; then dir=; \ - else dir="$(srcdir)/"; fi; \ - echo "TEST $${dir}$$tst"; \ - if $(LOG_TIMING) $(TESTS_ENVIRONMENT) $${dir}$$tst > $(LOG_FILE) 2>&1; then \ - case " $(XFAIL_TESTS) " in \ - *" $$tst "*) \ - LOG "ERROR: XPASS ($$tst)"; \ - $(LOG_STORE) "run" "$$tst" "$$path" 1 0; \ - ;; \ - *) \ - LOG "SUCCESS: PASS ($$tst)"; \ - $(LOG_STORE) "run" "$$tst" "$$path" 0 0; \ - ;; \ - esac; \ - elif test $$? -ne 77; then \ - case " $(XFAIL_TESTS) " in \ - *" $$tst "*) \ - LOG "SUCCESS: XFAIL ($$tst)"; \ - $(LOG_STORE) "run" "$$tst" "$$path" 0 0; \ - ;; \ - *) \ - LOG "ERROR: FAIL ($$tst)"; \ - $(LOG_STORE) "run" "$$tst" "$$path" 1 0; \ - ;; \ - esac; \ - else \ - LOG "WARNING: SKIP ($$tst)"; \ - $(LOG_STORE) "run" "$$tst" "$$path" 0 1; \ - fi; \ - done; - -check-log-dir-am: - $(LOG_SET_OPTIONS); \ - $(LOG_STORE) "dir" "$$dir" "$$ppath" - -check-log-libs-recursive \ -check-log-build-recursive \ -check-log-test-recursive \ -check-log-sources-recursive \ -check-log-headers-recursive \ -check-log-dir-recursive: - @set fnord $$MAKEFLAGS; amf=$$2; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -.PHONY: check-log \ - check-log-lib check-log-lib-am check-log-lib-recursive \ - check-log-build check-log-build-am check-log-build-recursive \ - check-log-test check-log-test-am check-log-test-recursive \ - check-log-sources check-log-sources-am check-log-sources-recursive \ - check-log-dir check-log-dir-am check-log-dir-recursive diff -Nru dune-common-2.2.1/am/documentation dune-common-2.5.2~20170808ga5c076ca/am/documentation --- dune-common-2.2.1/am/documentation 2010-02-12 00:36:10.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/documentation 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -# -*- Makefile -*- -# $Id: global-rules 5267 2008-09-10 10:45:42Z christi $ - -maintainer-clean-local: doc-clean-am - -### -# build doc / web-install recursively -doc-clean-am: clean-am doc-clean-documentation doc-clean-local -doc-am: doc-all-documentation doc-local -web-install-am: web-install-local - -doc-local: -doc-clean-local: -web-install-local: - -web-install: web-install-recursive -doc: doc-recursive -doc-clean: doc-clean-recursive - -web-install-recursive \ -doc-clean-recursive \ -doc-recursive: - @set fnord $$MAKEFLAGS; amf=$$2; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $(subdir)/$$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -install-data-local: install-documentation -uninstall-local: uninstall-documentation - -#### -# "implementations" - -doc-all-documentation: $(DOCFILES) - -doc-clean-documentation: - -test -z "$(DOCFILES)" || rm -f $(DOCFILES) - -install-documentation: $(DOCFILES) install-documentation-local - @$(NORMAL_INSTALL) - test -z "$(docdir)" || $(mkdir_p) "$(DESTDIR)$(docdir)" - @list='$(DOCFILES) $(DOCFILES_EXTRA)'; test -n "$(docdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ - done - -uninstall-documentation: uninstall-documentation-local - @$(NORMAL_UNINSTALL) - @list='$(DOCFILES) $(DOCFILES_EXTRA)'; test -n "$(docdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(docdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(docdir)" && rm -f $$files - -.PHONY: uninstall-documentation uninstall-documentation-local \ - install-documentation install-documentation-local \ - doc-clean-am doc-am web-install-am \ - doc-local doc-clean-local web-install-local \ - web-install doc doc-clean \ - web-install-recursive doc-clean-recursive doc-recursive diff -Nru dune-common-2.2.1/am/doxygen dune-common-2.5.2~20170808ga5c076ca/am/doxygen --- dune-common-2.2.1/am/doxygen 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/doxygen 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -# -*-makefile-automake-*- - -doxygendir = $(docdir)/doxygen - -#### -# doxygen style files -if DUNEWEB -if WML - -DUNEWEBDOXY = @DUNEWEBDIR@/doc/doxygen -# themeing doxygen -DOXYGENHEADER = doxy-header.html -DOXYGENFOOTER = doxy-footer.html - -doxy-header.html: BASEDIR=../../.. -doxy-footer.html: BASEDIR=../../.. -doxy-header.html: WMLOPTS= -doxy-footer.html: WMLOPTS= - -doxy-header.html: @DUNEWEBDIR@/doc/doxygen/doxy-header.wml - $(WMLCMD) -I @DUNEWEBDIR@/doc/doxygen/ @DUNEWEBDIR@/doc/doxygen/doxy-header.wml -o $(abs_builddir)/doxy-header.html - -doxy-footer.html: @DUNEWEBDIR@/doc/doxygen/doxy-footer.wml - $(WMLCMD) -I @DUNEWEBDIR@/doc/doxygen/ @DUNEWEBDIR@/doc/doxygen/doxy-footer.wml -o $(abs_builddir)/doxy-footer.html - -endif # WML -endif # DUNEWEB - -#### -# how to build doxygen documentation - -# EXTRAINSTALL in the html subdirectory -DOXYGENHTMLFILES = *.html *.css *.png *.gif -DOXYGENINSTALL = $(DOXYGENHTMLFILES) ../doxygen.log ../doxyerr.log - -if DOXYGEN -if BUILD_DOCS - # disable dependency tracking when working without doxygen/documentation - DOXYGENTAG = doxygen-tag -endif # BUILD_DOCS - -DUNEDOXYNIZE=@DUNE_COMMON_ROOT@/bin/dunedoxynize -$(srcdir)/Doxyfile.in: FORCE - if test -f $(srcdir)/Doxylocal && test $(srcdir)/Doxylocal -nt $(srcdir)/Doxyfile.in; then \ - cd $(top_srcdir) && $(DUNEDOXYNIZE); \ - fi - -# build doxygen when 'make doc' is called -# what files does the doxygen-generated stuff depend on (find-syntax) -DOXYGEN_DEPENDON = -name \*.cc -o -name \*.hh -o -name \*.png -o -name Doxyfile -o -name modules -# check dependency ourself to be robust -$(DOXYGENTAG): FORCE Doxyfile $(DOXYGENHEADER) $(DOXYGENFOOTER) - set -e; \ - if ! test -e "$(DOXYGENTAG)" || \ - test x"`find $(top_srcdir) \( $(DOXYGEN_DEPENDON) \) -a -cnewer $(DOXYGENTAG) -print`" != x; \ - then \ - echo Running doxygen. This may take a while... ; \ - $(DOXYGEN) Doxyfile > doxygen.log <&-; \ - touch $(DOXYGENTAG) ; \ - if test "$$DOXYQUIET" != "1" && test -f doxyerr.log; \ - then cat doxyerr.log; fi; \ - if test -x "$(DUNEWEBDOXY)/update-doxygen.css"; \ - then $(DUNEWEBDOXY)/update-doxygen.css $(abs_builddir)/html; fi; \ - fi -doc-doxygen: $(DOXYGENTAG) $(DOXYGENHEADER) $(DOXYGENFOOTER) -else -doc-doxygen: -endif # DOXYGEN -doc-local: doc-doxygen - -doxygen-html-install: - set -e; \ - OLDPWD=$$PWD; \ - dir=$(abs_srcdir); \ - if test -f $(abs_builddir)/$(DOXYGENTAG); then dir=$(abs_builddir); fi; \ - cd "$$dir/html/"; \ - list=`echo $(DOXYGENHTMLFILES)`; \ - cd "$$OLDPWD"; \ - for p in $$list; do \ - if test -f "$$dir/html/$$p"; then $(instcmd) $$dir/html/$$p $(instdir); fi; \ - done; - -#### -# how to store doxygen in the tarball -if BUILD_DOCS -if DOXYGEN -doxygen-dist-install: $(DOXYGENTAG) - set -e; mkdir $(distdir)/html; \ - $(MAKE) doxygen-html-install instcmd="cp -fp" instdir="$(distdir)/html" - set -e; dir=$(abs_srcdir); \ - if test -f $(abs_builddir)/$(DOXYGENTAG); then dir=$(abs_builddir); fi; \ - cp $$dir/$(DOXYGENTAG) $(distdir)/$(DOXYGENTAG) - -dist-hook: doxygen-dist-install - -#### -# how to install doxygen - -install-doxygen: $(DOXYGENTAG) - set -e; $(mkinstalldirs) $(DESTDIR)/$(doxygendir); \ - pwd; \ - $(MAKE) doxygen-html-install instcmd="$(install_sh_DATA)" instdir="$(DESTDIR)/$(doxygendir)" - -uninstall-doxygen: - rm -rf $(DESTDIR)/$(doxygendir) - -# add doxygen to documentation-installation -install-documentation-local: install-doxygen -uninstall-documentation-local: uninstall-doxygen - -endif # DOXYGEN -endif # BUILD_DOCS - -#### -# howto install doxygen in the web page -include $(top_srcdir)/am/webstuff -if DUNEWEB -# how to install the doxygen documentation for the web site -web-install-doxygen: - if test -d $(DUNEWEBDIR) && test -r $(DUNEWEBDIR)/Make.global ; then \ - pushd html; \ - $(MAKE) -f $(DUNEWEBDIR)/Make.global \ - EXTRAINSTALL="$(DOXYGENINSTALL)" CURDIR="$(CURDIR)/@DUNE_MOD_NAME@-html" install ; \ - popd; \ - fi -else -web-install-doxygen: -endif # DUNEWEB -web-install-local: web-install-doxygen - -#### -# how to clean the doxygen stuff -doc-clean-local: doxygen-doc-clean -dist-clean-local: doxygen-dist-clean - -doxygen-dist-clean: - rm -f doxygen.log doxyerr.log $(DOXYGENTAG) - -doxygen-doc-clean: - rm -rf html $(DOXYGENTAG) $(DOXYGENHEADER) $(DOXYGENFOOTER) *~ - rm -f doxyerr.log doxygen.log - test ! -f Doxylocal || rm -f Doxygen.in - -# nice trick from the GNU make infopage to force a rule to run -FORCE: diff -Nru dune-common-2.2.1/am/global-rules dune-common-2.5.2~20170808ga5c076ca/am/global-rules --- dune-common-2.2.1/am/global-rules 2009-12-14 19:51:06.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/global-rules 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -# -*- Makefile -*- -# $Id: global-rules 5784 2009-12-14 19:51:06Z christi $ - -# -# this file should be included into any Makefile.am so that we can -# easily introduce new global rules. DO NOT OVERUSE! -# - -# add "sourcescheck"-target testing if all source files are mentioned -include $(top_srcdir)/am/sourcescheck - -# check consistency of the headers (see FS#394) -include $(top_srcdir)/am/headercheck - -# add "check-log"-target to create automated build logs -include $(top_srcdir)/am/checklog - -# add "doc"-target to create and clean documentation -include $(top_srcdir)/am/documentation diff -Nru dune-common-2.2.1/am/headercheck dune-common-2.5.2~20170808ga5c076ca/am/headercheck --- dune-common-2.2.1/am/headercheck 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/headercheck 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -# -*- Makefile -*- -# $Id: sourcescheck 5183 2008-04-27 17:37:08Z christi $ - -headercheck_PATTERN = *.hh - -# set -# headercheck_IGNORE = foo.hh -# to ignore foo.hh - -hctest.o: hctest.cc - $(CXX) -I$(top_builddir) -I$(top_srcdir) -DHEADERCHECK \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) \ - $(DUNEMPICPPFLAGS) $(ALL_PKG_CPPFLAGS) -c -o $@ $< - -headercheck: - @if test "x$V" = "x"; then \ - SILENTSTR='V=$(AM_DEFAULT_VERBOSITY)' ; \ - fi; \ - if test "x$SILENT" = "x1"; then \ - SILENTSTR='V=0' ; \ - fi; \ - if test "x$SILENT" = "x0"; then \ - SILENTSTR='V=1' ; \ - fi; \ - if test x"$$HEADER" = "x"; then \ - $(MAKE) $$SILENTSTR $(AM_MAKEFLAGS) headercheck-recursive; \ - else \ - $(MAKE) $$SILENTSTR $(AM_MAKEFLAGS) headercheck-am; \ - fi - -headercheck-am: - @if test x"$$HEADER" != "x"; then \ - list="$$HEADER"; \ - else \ - pushd "$(srcdir)" > /dev/null; \ - list=`echo $(headercheck_PATTERN)`; \ - popd > /dev/null; \ - fi; \ - test -z "$$NO_CONFIG_H" && NO_CONFIG_H=0; \ - test "$$list" != "$(headercheck_PATTERN)" || exit 0; \ - for f in $$list; do \ - echo "$(headercheck_IGNORE)" | tr ' ' '\n' | grep -q "$$f"; \ - if echo "$(headercheck_IGNORE)" | tr ' ' '\n' | grep -q "$$f"; then continue; fi; \ - HEADER="$(subdir)/$$f"; \ - echo "checking $$HEADER"; \ - CCFILE=hctest.cc; \ - OFILE=hctest.o; \ - LOGFILE=hctest.log; \ - rm -f $$CCFILE; \ - test $$NO_CONFIG_H -ne 0 && echo " without config.h" \ - || echo "#include " > $$CCFILE; \ - echo "#include <$${HEADER}>" >> $$CCFILE; \ - echo "#include <$${HEADER}>" >> $$CCFILE; \ - echo "int main () { return 0; }" >> $$CCFILE; \ - make $$OFILE > $$LOGFILE 2>&1; \ - SUCCESS=$$?; \ - if ! (test $$SUCCESS -eq 0 && test -e $$OFILE); then \ - echo "Error in $$HEADER"; \ - test $V -ne 1 && echo "run with V=1 to show details" || cat $$LOGFILE; \ - fi; \ - warnings=`grep 'warning' $$LOGFILE`; \ - FOUNDWARNINGS=$$?; \ - if ( test $$FOUNDWARNINGS -eq 0 && test -e $$OFILE ); then \ - echo "Warnings in $$HEADER"; \ - test $V -ne 1 && echo "run with V=1 to show details" || cat $$LOGFILE; \ - fi; \ - rm -f $$OFILE; \ - rm -f $$CCFILE; \ - rm -f $$LOGFILE; \ - test $$SUCCESS -eq 0 || exit $$SUCCESS; \ - done - -headercheck-recursive: - @set fnord $$MAKEFLAGS; amf=$$2; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $(subdir)/$$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -.PHONY: headercheck headercheck-recursive headercheck-am - -# vim:set filetype=automake: diff -Nru dune-common-2.2.1/am/inkscape.am dune-common-2.5.2~20170808ga5c076ca/am/inkscape.am --- dune-common-2.2.1/am/inkscape.am 2006-01-16 15:04:26.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/inkscape.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -if INKSCAPE -.svg.png: - $(INKSCAPE) -e $@ $< -endif INKSCAPE diff -Nru dune-common-2.2.1/am/latex dune-common-2.5.2~20170808ga5c076ca/am/latex --- dune-common-2.2.1/am/latex 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/latex 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -# -*- makefile -*- -# $Id: latex 7077 2013-01-19 10:06:29Z mblatt $ - -# Rules for latex stuff - -# rerun TEX if log-file suggests that -.tex.dvi: - export TEXINPUTS=.:$(abs_builddir):${TEXINPUTS}:; \ - set -e; builddir=$$PWD; \ - pushd $(srcdir); $(TEX) -output-directory=$$builddir /dev/null ; do \ - pushd $(srcdir); $(TEX) -output-directory=$$builddir /dev/null \ - && grep '^\\citation{' *.aux > /dev/null; \ - then \ - BSTINPUTS=.:$(srcdir):${BSTINPUTS}: BIBINPUTS=.:$(srcdir):${BIBINPUTS}: $(BIBTEX) $* || exit $$?; \ - pushd $(srcdir); $(TEX) -output-directory=$$builddir /dev/null ; do \ - pushd $(srcdir); $(TEX) -output-directory=$$builddir header_CHECK.install -sourcescheck-am: - @echo $(sourcescheck_LIST) | tr ' ' '\n' | \ - grep '\.[hcm][hc4]$$' | sort | uniq > header_CHECK.install - @(ls $(srcdir); echo $(sourcescheck_DUMMY)) | \ - grep '\.[hcm][hc4]$$' | sort | uniq > header_CHECK.present - @RESULT=0; \ - if diff header_CHECK.* | grep ^[\<\>] -q; then \ - echo "==== WARNING ===="; \ - echo "Directory: $(srcdir)"; \ - echo "Files present but not installed:"; \ - diff -u header_CHECK.install header_CHECK.present | \ - grep -v ^+++ | grep ^+; \ - echo "Files listed for install but not present:"; \ - diff -u header_CHECK.install header_CHECK.present | \ - grep -v ^--- | grep ^-; \ - echo "==== END ===="; \ - RESULT=1; \ - fi; \ - rm -f header_CHECK.install header_CHECK.present; \ - exit $$RESULT - -sourcescheck-recursive: - @set fnord $$MAKEFLAGS; amf=$$2; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -.PHONY: sourcescheck sourcescheck-recursive sourcescheck-am diff -Nru dune-common-2.2.1/am/top-rules dune-common-2.5.2~20170808ga5c076ca/am/top-rules --- dune-common-2.2.1/am/top-rules 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/top-rules 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -# -*-makefile-*- - -ACLOCAL_AMFLAGS=@ACLOCAL_AMFLAGS@ -DUNECONTROL=@DUNE_COMMON_ROOT@/bin/dunecontrol - -sourcescheck_NOSOURCES = aclocal.m4 dependencies.m4 - -all-am: dependencies.m4 - -@DUNE_MOD_NAME@.m4: dune.module - cd $(srcdir) && $(DUNECONTROL) --only=@DUNE_MOD_NAME@ m4create - -moduledir = $(libdir)/dunecontrol/@DUNE_MOD_NAME@ -module_DATA = dune.module - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = @DUNE_MOD_NAME@.pc - -maintainer-clean-local: top-clean - -# we use LT_OUTPUT, thus we might have a config.lt file -- remove it! -distclean-libtool: - -rm -f libtool config.lt -.PHONY: distclean-libtool - -top-clean: - rm -f dependencies.m4 diff -Nru dune-common-2.2.1/am/webstuff dune-common-2.5.2~20170808ga5c076ca/am/webstuff --- dune-common-2.2.1/am/webstuff 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/am/webstuff 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -# -*- makefile -*- -# $Id: webstuff 7077 2013-01-19 10:06:29Z mblatt $ - -## rules to create HTML-pages from wml-files with additional magic to -## possibly use the layout of the Dune-homepage - -# if DUNEWEBDIR is set to the dune-web directory the layout and -# install-stuff from that place will be used - -# CURDIR should be defined in the same way as in dune-web - -#### -# how to run wml -if DUNEWEB -WMLCMD = cd $(DUNEWEBDIR) && @WML@ --nocd -DROOT=$(BASEDIR) -else -WMLCMD = cd $(DUNE_COMMON_ROOT)/doc && @WML@ --nocd -endif - -#### -# how to build html files -if WML -.wml.html: - if test "`dirname $<`" == "."; then \ - input="$(abs_srcdir)/$<"; else \ - input="$<"; fi; \ - $(WMLCMD) -I $(abs_srcdir) $$input -o $(abs_builddir)/$@ -endif - -#### -# howto install into the webpage -if DUNEWEB -web-install-default: doc - if test -d $(DUNEWEBDIR) && test -r $(DUNEWEBDIR)/Make.global ; then \ - for DIR in $(SUBDIRS) ; do \ - $(MAKE) -C $$DIR web-install || exit 1; \ - done ; \ - $(MAKE) -f $(DUNEWEBDIR)/Make.global \ - EXTRAINSTALL="$(EXTRAINSTALL)" CURDIR="$(CURDIR)" install ; \ - fi -else -web-install-default: -endif - -#### -# how to clean up -web-build: $(PAGES) -web-clean: - -test -z $(PAGES) || rm -f $(PAGES) - -doc-clean-local: web-clean -web-install-local: web-install-default -doc-local: web-build diff -Nru dune-common-2.2.1/bin/addsourcescheck dune-common-2.5.2~20170808ga5c076ca/bin/addsourcescheck --- dune-common-2.2.1/bin/addsourcescheck 2005-05-02 16:35:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/addsourcescheck 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -#!/bin/bash - -# -# patch the include statement into all Makefile.am files -# - -set -e - -# always start in $top_srcdir -if ! test -f configure.ac; then - echo "Wrong Directory" - echo "run from \$top_srcdir" - exit 1 -fi - -# list of files to patch -FILES=`find . -name Makefile.am` -# snippet to patch into Makefile.am -SNIP='include $(top_srcdir)/am/sourcescheck' -# create the grep regexp from the snip -REGEXP="^$(echo $SNIP | sed -e 's/[\$\/\(\)]/./g')\$" -# enable / disable verbose mode -VERBOSE=0 - -for f in $FILES; do - # only patch files that don't have the patch yet - if ! grep -q "$REGEXP" $f; then - echo patching $f - # normalize end of file - while test "$(tail -1 $f)" != ""; do - echo >> $f - done - echo $SNIP >> $f - else - if test x$VERBOSE = x1; then - echo $f already patched - fi - fi -done diff -Nru dune-common-2.2.1/bin/am2cmake.py dune-common-2.5.2~20170808ga5c076ca/bin/am2cmake.py --- dune-common-2.2.1/bin/am2cmake.py 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/am2cmake.py 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,594 @@ +#!/usr/bin/python +import sys +import re +import os +import fnmatch +import errno +from optparse import OptionParser +from pyparsing import * + +class rem_proc: + def __init__(self, name): + self.name=name + self.found=False + def parse(self,tokens): + self.found=True + def foreach_begin(self): + return "\nforeach(i ${"+self.name+"})\n" + + def foreach_end(self): + return "endforeach(i ${"+self.name+"})\n" + + def process_SUBDIRS(self): + return ''.join([self.foreach_begin(), + " if(${i} STREQUAL \"test\")\n", + " set(opt EXCLUDE_FROM_ALL)\n", + " endif(${i} STREQUAL \"test\")\n", + " add_subdirectory(${i} ${opt})\n", + " unset(opt)\n"+self.foreach_end()]) + + def process(self): + s="" + if self.found: + s= getattr(self, "process_%s" % self.name)() + return s + + + def process_TESTS(self): + return ''.join(['\n', + self.foreach_begin(), + " add_test(${i} ${i})\n", + self.foreach_end()]) + + def process_XFAIL_TESTS(self): + return ''.join(['\n#Set properties for failing tests\n', + 'set_tests_properties(\n', + ' ${XFAIL_TESTS} PROPERTIES\n', + ' WILL_FAIL true)']) + + def process_COMPILE_XFAIL_TESTS(self): + return ''.join(['# Add test for programs that should not compile', + '\nforeach(_TEST ${COMPILE_XFAIL_TESTS})\n' + ' add_test(NAME ${_TEST}', + ' COMMAND ${CMAKE_COMMAND} --build . --target ${_TEST} --config $)\n', + 'endforeach(_TEST)\n', + 'set_tests_properties(${COMPILE_XFAIL_TESTS}\n', + ' PROPERTIES WILL_FAIL true)']) + + +def parse_dependency(tokens): + tokens[0][0]='add_dependencies('+tokens[0][0]+' ' + tokens[0][-1]=tokens[0][-1]+')' + +def comment_lines(tokens): + tokens[0][0]='# The following lines are comment out as the translation is not clear. TODO review\n#\n# '+tokens[0][0] + if len(tokens[0])>0: + for i in range(1, len(tokens[0])): + if tokens[0][i] == '\n': + tokens[0][i]='\n#' + +def repl_gnudir(m): + #print "gnudir %s" % m + return "CMAKE_INSTALL_"+m.upper() + +def parse_sources(tokens): + target=re.sub('_$', '', tokens[0][0]) + tokens[0][0]='add_executable('+target+' ' + tokens[0][-1]=tokens[0][-1]+')' + +class installer: + def __init__(self, name): + self.name = name + self.found_dirs = set() + self.regex= re.compile(r'(?P\S+[^_])_'+self.name) + self.install_prefix = { + 'SCRIPTS': 'PROGRAMS', + 'DATA': 'FILES', + 'PROGRAMS': 'TARGETS', + 'LIBRARIES': 'TARGETS', + 'HEADERS': 'FILES', + 'check_PROGRAMS': '' + }[name] + def create_parser(self,lowercase_name,opt_ws,equals,value): + parser=Group(Combine(Optional(lowercase_name)+self.name)+Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + return parser + def parse(self,tokens): + #import pdb; pdb.set_trace() + m=self.regex.match(tokens[0][0]) + if m: + self.found_dirs.add(m.group('prefix')) + else: + self.found_dirs.add('') + + def process(self): + #import pdb; pdb.set_trace() + s="" + for i in self.found_dirs: + if i: + install_dir=i+'dir' + else: + install_dir=repl_gnudir({ + 'SCRIPTS': 'bindir', + 'DATA': 'datadir', + 'PROGRAMS': 'bindir', + 'LIBRARIES': 'libdir', + 'HEADERS': 'includedir' + }[self.name]) + if not (i == ""): + var=""+i+'_'+self.name + else: + var=self.name + if not (var.strip().startswith('noinst_') + or var.strip().startswith('check_') + or var.strip().startswith('dist_noinst_')): + s= s+"\ninstall("+self.install_prefix+" ${"+var+"} DESTINATION ${"+install_dir+"})" + return s + +class target_flags: + def __init__(self, suffix): + self.suffix=suffix + self.known_flags = { + 'ALBERTA_': ['add_dune_alberta_flags',''], + 'AM_': ['target_link_libraries', '${DUNE_LIBS}'], + 'ALUGRID_': ['add_dune_alugrid_flags',''], + 'UG_': ['add_dune_ug_flags', ''], + 'SUPERLU_': ['add_dune_superlu_flags', ''], + 'DUNEMPI': ['add_dune_mpi_flags', ''], + 'AMIRAMESH_': ['add_dune_amiramesh_flags',''], + 'GMP_': ['add_dune_gmp_flags',''], + 'GRAPE_': ['add_dune_grape_flags',''], + 'PARMETIS_': ['add_dune_parmetis_flags',''], + 'PETSC_': ['add_dune_petsc_flags',''], + 'PSURFACE_': ['add_dune_psurface_flags',''] + } + for i in range(1,9): + self.known_flags.update({ + 'ALBERTA'+str(i)+'D_' : ['add_dune_alberta_flags', ''+'GRIDDIM '+str(i)]}) + def parse(self, stri,loc,tokens): + #print 'target_flags' + #print self.suffix + #print tokens + if (self.suffix == 'CPPFLAGS' or self.suffix=='CXXFLAGS'): + line=''.join(tokens[0]) + s='' + for key, value in self.known_flags.items(): + if line.find(key)>-1: + s+='\n'+value[0]+'('+re.sub(r'set\((.*)_', '\\1',tokens[0][0])+value[1]+')' + tokens[0]=s + #print tokens + else: + comment_lines(tokens) + +class dir_parser: + def __init__(self): + self.has_doxygen=False + def parse_dir(self,stri,loc,tokens): + #import pdb; pdb.set_trace() + #print "parse_dir" + #print tokens + tokens[0][1]=''.join(tokens[0][1:]) + if tokens[0][1].find('doxygen')>-1: + self.has_doxygen=True + #print range(2, len(tokens[0])) + if len(tokens[0]) >=2: + for i in range(2, len(tokens[0])): + tokens[0].pop() + #print tokens + #print "str="+stri+" |" + #print "loc="+str(loc)+" |" + #print tokens[0][1] + #for i in range(0,len(tokens[0])): + + tokens[0][1]=re.sub(r'\$\{([a-z]+dir)\}(\S*)\)', (lambda m: "${"+repl_gnudir(m.group(1))+"}"+m.group(2)+')'), tokens[0][1]) + #print tokens[0][1] + tokens[0][1]=tokens[0][1].replace('${CMAKE_INSTALL_DATADIR}/doc', + '${CMAKE_INSTALL_DOCDIR}') + tokens[0][1]=tokens[0][1].replace('${CMAKE_INSTALL_DATAROOTDIR}/doc', + '${CMAKE_INSTALL_DOCDIR}') + #print tokens + + def process(self): + if self.has_doxygen: + return '\n\n# Create and install doxygen documentation\nadd_doxygen_target()\n' + else: + return '' + +def parse_include(tokens): + tokens[0][0]='# include not needed for CMake\n# '+tokens[0][0] + +def parse_if(tokens): + + expression = tokens[0][1]+' ' + tokens[0][0] ='if(' + tokens[0][2] =')\n' + tokens[0][len([0])-2] ='endif('+expression+')' + if tokens[0].elsestart : + tokens[0][4] ='else('+expression+')' + +def parse_assign(tokens): + tokens[0][0]='set('+tokens[0][0]+' ' + tokens[0][-1]=tokens[0][-1]+')' + +def parse_append(tokens): + tokens[0][0]='list(APPEND '+tokens[0][0]+' ' + tokens[0][-1]=tokens[0][-1]+')' + + +def parse_var(stri,loc,tokens): + #print "parse_var" + #print tokens + #print "str="+stri+" |" + #print "loc=%s|" % loc + tokens[0]='${'+tokens[0]+'}' + #print tokens + +def rename_var(tokens): + #print 'rename_var |%s|' % tokens[0] + #print tokens + name = re.sub('[ ]*([a-zA-Z0-9_])[ ]*[\n]?', '\\1', tokens[0]) + #print '|%s|' %name + tokens[0]={ + 'ALBERTA': 'ALBERTA_FOUND', + 'ALUGRID': 'ALUGRID_FOUND', + 'AMIRAMESH': 'AMIRAMESH_FOUND', + 'CONVERT': 'CONVERT_FOUND', + 'EIGEN': 'EIGEN_FOUND', + 'GLUT': 'GLUT_FOUND', + 'GMP': 'GMP_FOUND', + 'GRAPE': 'GRAPE_FOUND', + 'INKSCAPE': 'INKSCAPE_FOUND', + 'MPI': 'MPI_CXX_FOUND', + 'PARDISO': 'PARDISO_FOUND', + 'PETSC': 'PETSC_FOUND', + 'PSURFACE': 'PSURFACE_FOUND', + 'SUPERLU': 'SUPERLU_FOUND', + 'TEX4HT': 'TEX4HT_FOUND', + 'UG': 'UG_FOUND'}.setdefault(name, tokens[0]) + if name.startswith('HAVE_DUNE'): + tokens[0]=re.sub(r'have-(.*)$', '\\1', name.lower().replace('_','-'))+'_FOUND' + #print tokens[0] + +#print rename_var(['bla']) +#print rename_var(['UG']) +#print rename_var(['A']) +change_var2=1 + +def parse_var2(stri,loc,tokens): + if change_var2: + tokens[0]='${'+tokens[0]+'}' + else: + tokens[0][0]='@'+tokens[0][0]+'@' + +class is_present: + def __init__(self): + self.found=False + def parse(self,tokens): + self.found=True + +def repl_tabs(tokens): + for i in range(0, len(tokens)): + tokens[i]=tokens[i].replace('\t', ' ') + +def am_2_cmake_string(amstring): + ParserElement.setDefaultWhitespaceChars("") + word = Word(alphanums+"*:.-_=<>&!;,/") + ws=Word(' ') + opt_ws=Optional(ws) + varopen = Literal("$(")#.replaceWith("${") + varclose = Literal(")")#.replaceWith("}") + var = Combine(varopen.suppress() + Word(alphanums+"_-")+varclose.suppress()) + var.addParseAction(rename_var) + var.addParseAction(parse_var) + var2 = Combine(Literal("@").suppress() +Word(alphanums+"_-")+Literal("@").suppress()) + var2.setParseAction(parse_var2) + wordorvar = var|var2| word + qwordorvar=("\""+wordorvar+"\"")|wordorvar + NL = opt_ws.suppress() + Or(lineEnd,stringEnd) + #NL.setDebug() + multiple_words = wordorvar + ZeroOrMore( opt_ws + wordorvar) + qmultiple_words = ("\""+multiple_words+"\"")|multiple_words + word_line = qmultiple_words+ZeroOrMore(opt_ws+qmultiple_words) + comment = Group('#'+ restOfLine('commenttext')) + continuation = Suppress('\\')+LineEnd() + #continuation.setDebug() + equals = Literal("=").suppress() + value = ZeroOrMore(opt_ws + Optional(word_line) + opt_ws + continuation)+ opt_ws+ word_line + name = Word(alphanums+"_-") + beginif = Literal("if") + #beginif.setDebug() + lines = Forward() + ifexpression = restOfLine + NL + ifexpression.setParseAction(rename_var) + ifbody = Group(lines) + endif = Literal('endif')+restOfLine.suppress() + elsestatement = Forward() + elsestatement << (opt_ws+ Literal('else').setResultsName('elsestart') + NL + Group (lines)) + #endif.setDebug() + ifstatement =Forward() + ifstatement << Group(beginif + ifexpression + Group(lines) + Optional(elsestatement) + opt_ws + endif)#+ NL# +endif #+ NL + #ifstatement.setDebug() + ifstatement.setParseAction(parse_if) + + varAssign = Group(name + Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + varAssign.setParseAction(parse_assign) + + docsAssign = Group(Or(Literal("DOCFILES"), Literal("DOCFILES_EXTRA"))+ Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + docsAssign.setParseAction(parse_assign) + docs_present = is_present() + docsAssign.addParseAction(docs_present.parse) + varAddAssign = Group(name + Suppress(opt_ws) + Literal('+=').suppress() + Suppress(opt_ws) + Optional(value)) + varAddAssign.setParseAction(parse_append) + + # Grammar for dir. A parser is needed to convert the GNU autoconf dirs to + # CMAKE GNU dirs. + dir_name = Regex("[a-z0-9_-]+dir")#Word(srange("[a-z0-9_-]")) + dirAssign=Group(dir_name+Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + dirAssign.setParseAction(parse_assign) + dirParser = dir_parser() + dirAssign.addParseAction(dirParser.parse_dir) + #dirAssign.setDebug() + + lowercase_name_= Regex("[a-z0-9_-]+_") + + cppflagsAssign = Group(lowercase_name_+'CPPFLAGS' + Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + cppflagsAssign.addParseAction(parse_assign) + cppflags=target_flags('CPPFLAGS') + cppflagsAssign.addParseAction(cppflags.parse) + + cxxflagsAssign = Group(lowercase_name_+'CXXFLAGS' + Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + cxxflags=target_flags('CXXFLAGS') + cxxflagsAssign.addParseAction(parse_assign) + cxxflagsAssign.addParseAction(cxxflags.parse) + + ldflagsAssign = Group(lowercase_name_+'LDFLAGS' + Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + ldflagsAssign.addParseAction(parse_assign) + ldflags=target_flags('LDFLAGS') + ldflagsAssign.addParseAction(ldflags.parse) + + ldaddAssign = Group(lowercase_name_+'LDADD' + Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + ldaddAssign.addParseAction(parse_assign) + ldadd=target_flags('LDADD') + ldaddAssign.addParseAction(ldadd.parse) + + libsAssign = Group(lowercase_name_+'LIBS' + Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + libsAssign.addParseAction(parse_assign) + libs=target_flags('LIBS') + libsAssign.addParseAction(libs.parse) + + + + + # Process dir_SOURCES assignment + sourcesAssign = Group(lowercase_name_+Suppress(Literal("SOURCES"))+Suppress(opt_ws)+ equals + Suppress(opt_ws) + Optional(value)) + sourcesAssign.setParseAction(parse_sources) + + # Process _DATA assignment + data_install = installer("DATA") + dataAssign = data_install.create_parser(lowercase_name_, opt_ws, equals, value) + #dataAssign.setDebug() + dataAssign.addParseAction(data_install.parse) + dataAssign.addParseAction(parse_assign) + #dataAssign.addParseAction(lambda tokens: data_install.parse(tokens)) + + # Process check_Programs but never install them + check_programs = installer("check_PROGRAMS") + check_programsAssign = check_programs.create_parser(lowercase_name_, opt_ws, equals, value) + + # Process _PROGRAMS assignment + programs_install = installer("PROGRAMS") + programsAssign = programs_install.create_parser(lowercase_name_, opt_ws, equals, value) + programsAssign.addParseAction(programs_install.parse) + programsAssign.addParseAction(parse_assign) + + # Process _LIBRARIES assignment + libraries_install = installer("LIBRARIES") + librariesAssign = libraries_install.create_parser(lowercase_name_, opt_ws, equals, value) + librariesAssign.addParseAction(libraries_install.parse) + librariesAssign.addParseAction(parse_assign) + + # Process _SCRIPTS assignment + scripts_install = installer("SCRIPTS") + scriptsAssign = scripts_install.create_parser(lowercase_name_, opt_ws, equals, value) + scriptsAssign.addParseAction(scripts_install.parse) + scriptsAssign.addParseAction(parse_assign) + + # Process _HEADERS assignment + headers_install = installer("HEADERS") + headersAssign = headers_install.create_parser(lowercase_name_, opt_ws, equals, value) + headersAssign.addParseAction(headers_install.parse) + headersAssign.addParseAction(parse_assign) + + # SUBDIRS + subdirsAssign = Group(Combine(Literal("SUBDIRS"))+Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + subdirsAssign.setParseAction(parse_assign) + subdirs= rem_proc("SUBDIRS") + subdirsAssign.addParseAction(subdirs.parse) + + testsAssign = Group(Combine(Literal("TESTS"))+Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + #testsAssign.setDebug() + testsAssign.setParseAction(parse_assign) + tests=rem_proc("TESTS") + testsAssign.addParseAction(tests.parse) + + fail_testsAssign = Group(Combine(Literal("XFAIL_TESTS"))+Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + fail_testsAssign.setParseAction(parse_assign) + fail_tests=rem_proc("XFAIL_TESTS") + fail_testsAssign.addParseAction(fail_tests.parse) + + compile_fail_testsAssign = Group(Combine(Literal("COMPILE_XFAIL_TESTS"))+Suppress(opt_ws)+ equals + opt_ws + Optional(value)) + compile_fail_testsAssign.setParseAction(parse_assign) + compile_fail_tests=rem_proc("COMPILE_XFAIL_TESTS") + compile_fail_testsAssign.addParseAction(compile_fail_tests.parse) + + # Process include lines and just comment them out. + includeLine = opt_ws.suppress() + Group(Literal('include') + restOfLine ) + includeLine.setParseAction(parse_include) + #includeLine.setDebug() + rule_line = multiple_words+Combine(Optional(Literal("\\")),lineEnd) + dependency_rule= Group(opt_ws+word+opt_ws+Suppress(Literal(':'))+ opt_ws+multiple_words) + dependency_rule.setParseAction(parse_dependency) + + easy_rule = Group(opt_ws+word+opt_ws+Literal(':')+ opt_ws+Optional(word_line)+opt_ws+ + ZeroOrMore(Or(NL,continuation)+ws+Optional(word_line)+opt_ws)+NL) + easy_rule.setParseAction(comment_lines) + #easy_rule.setDebug() + + lines << ZeroOrMore(opt_ws+(dependency_rule+NL|easy_rule|(sourcesAssign|dataAssign|check_programsAssign|programsAssign|librariesAssign|scriptsAssign|headersAssign|subdirsAssign|compile_fail_testsAssign|fail_testsAssign|testsAssign|dirAssign|cppflagsAssign|cxxflagsAssign|ldaddAssign|ldflagsAssign|libsAssign|varAddAssign|docsAssign|varAssign|comment|ifstatement|includeLine|Empty())+NL)) + + s= ''.join(lines.parseString(amstring)._asStringList()) + #print s + s=s+data_install.process() + s=s+programs_install.process() + s=s+libraries_install.process() + s=s+scripts_install.process() + s=s+headers_install.process() + s=s+subdirs.process() + + s+=tests.process() + s+=fail_tests.process() + s+=compile_fail_tests.process() + s+=dirParser.process() + if tests.found or compile_fail_tests.found: + s+=''.join(['\n\n# We do not want want to build the tests during make all\n', + '# but just build them on demand\n', + 'add_directory_test_target(_test_target)\n', + 'add_dependencies(${_test_target} ${TESTS} ${COMPILE_XFAIL_TESTS})']) + if docs_present.found: + s=s+''.join(['\n# Install documentation', + '\n# We assume that ${DOCFILES} and ${DOCFILES_EXTRA} are targets\n', + 'install(TARGETS ${DOCFILES} ${DOCFILES_EXTRA} DESTINATION ${docdir})\n']) + + return s + +def init_cmake_module(module_name): + return''.join(['# set up project\n', + 'project("'+module_name+'" C CXX)\n\n#circumvent not building docs\nset(BUILD_DOCS 1)\n\n', + '# general stuff\n', + 'cmake_minimum_required(VERSION 2.8.12)\n\n', + '#find dune-common and set the module path\n', + 'find_package(dune-common)\n' + 'list(APPEND CMAKE_MODULE_PATH ${dune-common_MODULE_PATH}\n' + ' "${CMAKE_SOURCE_DIR}/cmake/modules")# make sure our own modules are found\n\n', + '#include the dune macros\n' + 'include(DuneMacros)\n\n', + '# start a dune project with information from dune.module\n', + 'dune_project()\n\n']) + +def finalize_cmake_module(module_name): + upper_name =re.sub('-(\S)', lambda m: m.group(1).capitalize(), + module_name.capitalize()) + name_wo_dasch=module_name.replace('-', '') + lines = ['\nadd_subdirectory(cmake/modules)\n', + '# finalize the dune project, e.g., generate config.h etc.\n' + 'finalize_dune_project(GENERATE_CONFIG_H_CMAKE)\n'] + return ''.join(lines) + +def create_cmake_dirs_and_file(dirname, module_name): + upper_name =re.sub('-(\S)', lambda m: m.group(1).capitalize(), + module_name.capitalize()) + print 'module_name %s' % module_name + print 'upper_name %s' % upper_name + dirs={'modules': os.path.join(dirname, 'cmake', 'modules')} + cdirs=[] + for dir in dirs.values(): + try: + print "Creating %s" % dir + os.makedirs(dir) + except OSError as exception: + if exception.errno != errno.EEXIST: + raise + text="message(AUTHOR_WARNING \"TODO: Implement module test.\")" + output=open(os.path.join(dirs['modules'], upper_name+'Macros.cmake'), 'w') + output.write(text) + output.close() + # CMakeLists.txt in module directory + # list files *.cmake + all_cmake_files=[] + for root, dirnames, filenames in os.walk(dirs['modules']): + all_cmake_files.extend(fnmatch.filter(filenames,'*.cmake')[:]) + lines=['set(modules \n ', '\n '.join(all_cmake_files), '\n)\n'] + output=open(os.path.join(dirs['modules'], 'CMakeLists.txt'), 'w') + lines.extend(['install(FILES "${modules}" DESTINATION ${DUNE_INSTALL_MODULEDIR})\n']) + output.write(''.join(lines)) + output.close() + + +def am_2_cmake(amfile, cmakefile, module_root=False): + output = open(cmakefile, 'w') + if module_root: + dirname=os.path.dirname(amfile) + dune_module_path = os.path.join(dirname, 'dune.module') + module_file = open(dune_module_path, 'r') + lines = module_file.readlines() + print ''.join(lines) + m=re.search(r'.*Module:[ \t]*(\S+)[ \t]*[\n]?.*', ''.join(lines)) + if not m: + raise Exception("Could not find module name in dune.module file.") + module_file.close() + module_name=m.group(1) + print 'Module name is %s'% module_name + output.write(init_cmake_module(module_name)) + create_cmake_dirs_and_file(dirname, module_name) + input = open(amfile, 'r') + lines = input.readlines() + str = ''.join(lines) + output.write(re.sub('\s+\n', '\n', am_2_cmake_string(str))) + input.close() + if module_root: + output.write(finalize_cmake_module(module_name)) + output.close() + +def am_2_cmake_dir(directory): + for root, dirnames, filenames in os.walk(directory): + for filename in fnmatch.filter(filenames, 'Makefile.am'): + print "root=%s" % root + print "filename=%s" % filename + amfile=os.path.join(root, filename) + cmfile=os.path.join(root, 'CMakeLists.txt') + is_module_root = len(fnmatch.filter(filenames, 'dune.module')) + + print ''.join(['Converting ', amfile, ' -> ', cmfile]) + print is_module_root + am_2_cmake(amfile, cmfile, is_module_root) + + # Add doxygen target + doxygendir=os.path.join(directory, 'doc', 'doxygen') + if os.path.isdir(doxygendir) and os.path.exists(os.path.join(doxygendir, 'Doxylocal')): + output=open(os.path.join(doxygendir, 'CMakeLists.txt'),'a') + output.write('\n'.join(['# Create Doxyfile.in and Doxyfile, and doxygen documentation', +'add_doxygen_target()'])) + output.close() + # Add directives to create CMake packe configuration files with autotools + output=open("Makefile.am", "a") + output.write('\n'.join(['', '# Generate package configuration files for finding', + '# installed modules with CMake', + 'include $(top_srcdir)/am/cmake-pkg-config\n'])) + output.close() + +def main(): + usage = "usage: am2cmake " + parser = OptionParser(usage=usage) + parser.add_option("-a", "--am-file", dest="amfile", + help="The Makefile.am", metavar="FILE") + parser.add_option("-c", "--cmake-file", + dest="cmakefile", + help="The CMake file") + parser.add_option("-d", "--directory", + dest="directory", + help="Root directory of dune-module") + (options, args) = parser.parse_args() + if not options.amfile and not options.directory: + parser.error("options -a or option -d has to be present") + if options.directory and (options.amfile or options.cmakefile): + parser.error("Cannot provide a directory and a CMake or am file.") + if not options.cmakefile and not options.directory: + options.cmakefile = options.amfile.replace('Makefile.am', 'CMakeLists.txt') + + #import pdb; pdb.set_trace() + if options.directory: + am_2_cmake_dir(options.directory) + else: + print ''.join([options.amfile, '->', options.cmakefile]) + am_2_cmake(options.amfile, options.cmakefile) +if __name__ == "__main__": + main() diff -Nru dune-common-2.2.1/bin/check-log-store.in dune-common-2.5.2~20170808ga5c076ca/bin/check-log-store.in --- dune-common-2.2.1/bin/check-log-store.in 2010-02-05 12:07:37.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/check-log-store.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -#!/bin/sh - -set -e - -# DB format -# -# - -# parameter: -# $(LOG_FILE) $(LOG_DIR) "build" "$$target" "$$path" - -host="@hostid@" -tag="@tag@" -revision="@revision@" - -logfile="$1" -logdir="$2" -mode="$3" -module="`basename $4`" -path="$5" -errors="$6" -warnings="$7" - -test -d $logdir || mkdir $logdir - -storelog=`tempfile -d $logdir` - -trap "rm -f $storelog" EXIT - -if true; then - echo "TAG: $tag" - echo "REVISION: $revision" - echo "HOST: $host" - echo "MODE: $mode" - echo "MODULE: $module" - echo "PATH: $path" - if test "x$errors" != x; then - echo "ERRORS: $errors" - fi - if test "x$warnings" != x; then - echo "WARNINGS: $warnings" - fi - echo "LOG:" - cat $logfile -fi > $storelog - -trap - EXIT diff -Nru dune-common-2.2.1/bin/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/bin/CMakeLists.txt --- dune-common-2.2.1/bin/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,8 @@ +install(PROGRAMS + am2cmake.py + dune-ctest + duneproject + dunecontrol + git-whitespace-hook + dune-remove-autotools + DESTINATION ${CMAKE_INSTALL_BINDIR}) diff -Nru dune-common-2.2.1/bin/dune-autogen dune-common-2.5.2~20170808ga5c076ca/bin/dune-autogen --- dune-common-2.2.1/bin/dune-autogen 2009-10-12 16:26:23.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/dune-autogen 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -#!/bin/bash -# $Id: autogen.sh 5054 2008-01-08 15:06:55Z christi $ - -# barf on errors -set -e - -usage () { - echo "Usage: dune-autogen DUNE_MODULE_PATH_LIST [options]" - echo " --ac=, --acversion=VERSION use a specific VERSION of autoconf" - echo " --am=, --amversion=VERSION use a specific VERSION of automake" - echo " -h, --help you already found this :-)" -} - -## get my name... -grep '^Module:' dune.module >/dev/null || echo "Parser Error: Module entry missing in dune.module" -name= -while read head name rest -do case "$head" in - Module:) break;; - Module:*) name="${head#Module:}"; break;; - esac - name= -done /dev/null; then - echo - echo "Error: Could not find autoconf$ACVERSION" - echo " Did you specify a wrong version?" - exit 1 - fi -fi -if test "x$AMVERSION" != "x"; then - echo "Forcing automake version «$AMVERSION»" - if ! which automake$AMVERSION > /dev/null; then - echo - echo "Error: Could not find automake$AMVERSION" - echo " Did you specify a wrong version?" - exit 1 - fi -fi - -## run autotools - -echo "--> dunedoxynize..." -dunedoxynize - -echo "--> libtoolize..." -# this script won't rewrite the files if they already exist. This is a -# PITA when you want to upgrade libtool, thus I'm setting --force -if [ x`type -t glibtoolize` = xfile ]; then - LIBTOOLIZE=glibtoolize -fi -${LIBTOOLIZE-libtoolize} --force - -# writing privat m4 file -echo -n "--> " -dunecontrol --only=$name m4create - -# prepare everything -echo "--> aclocal..." -rm -f aclocal.m4 -rm -rf autom4te.cache -aclocal$AMVERSION -I . $ACLOCAL_FLAGS - -# create a link to the dune-common am directory -if [ "$name" != "dune-common" ]; then - if [ -n "$am_dir" ] && [ -d $am_dir ]; then - echo "--> linking dune-common/am..." - rm -f am - ln -s $am_dir am - else - echo - echo "Error: Could not find dune-common/am!" - usage - exit 1 - fi -fi - -# applications should provide a config.h for now -echo "--> autoheader..." -autoheader$ACVERSION - -echo "--> automake..." -automake$AMVERSION -W all --add-missing - -echo "--> autoconf..." -autoconf$ACVERSION - -## tell the user what to do next -echo "Now run ./configure to setup $name" diff -Nru dune-common-2.2.1/bin/dunecontrol dune-common-2.5.2~20170808ga5c076ca/bin/dunecontrol --- dune-common-2.2.1/bin/dunecontrol 2013-02-26 12:26:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/dunecontrol 2017-08-08 08:39:46.000000000 +0000 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e @@ -6,11 +6,27 @@ ### ### check for environment variables ### +if test -z "$GREP"; then + GREP=grep +fi +if test -z "$SED"; then + SED=sed +fi -if test -z $MAKE; then +if test -z "$MAKE"; then MAKE=make fi +system_default_cmake="no" +if test -z "$CMAKE"; then + CMAKE=cmake + system_default_cmake="yes" +fi + +space=" " +tab=" " +BLANK="$space$tab" + ############################################### ### ### read lib @@ -45,7 +61,7 @@ fdir="`canonicalname \"$fdir\"`" echo "$fdir/$fname" fi - # if this is a directory, then create an absolute + # if this is a directory, then create an absolute # directory name and we are done if test -d "$file"; then (cd "$file"; pwd) @@ -58,7 +74,7 @@ echo Usage: canonicalpath path >&2 return 1 fi - dirname `canonicalname "$1"` + dirname "`canonicalname "$1"`" } checkdebug () { @@ -78,20 +94,9 @@ set -v fi -export PREFIX_DIR="`canonicalpath $0`/.." - -# create PKG_CONFIG_PATH for installed dune modules -if test -d "$PREFIX_DIR/lib/pkgconfig"; then - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX_DIR/lib/pkgconfig" -fi - -# Read the modules find part -. "$PREFIX_DIR/lib/dunemodules.lib" - -############################################### onbuildfailure() { - echo "Terminating $(basename $0) due to previous errors!" >&2 + echo "Terminating $(basename "$0") due to previous errors!" >&2 exit 1 } @@ -126,7 +131,7 @@ # disable usage of opts file if test "x$DUNE_OPTS_FILE" != "x"; then echo "WARNING: commandline parameters will overwrite setting in opts file \"$DUNE_OPTS_FILE\"" - fi + fi fi # skip command delimiter @@ -136,17 +141,18 @@ local runcommand=run_$command # build the modules - local path=$(eval "echo \$PATH_${module}") + local path="$(eval "echo \$PATH_${module}")" eval echo "--- calling $command for \$NAME_${module} ---" - trap onbuildfailure EXIT + trap onbuildfailure EXIT if ! ( set -e cd "$path" export module - eval_control $runcommand $path/$CONTROL + export ABS_BUILDDIR=$(abs_builddir $module $BUILDDIR) + eval_control $runcommand "$path/$CONTROL" ); then eval echo "--- Failed to build \$NAME_${module} ---"; exit 1; fi - trap onfailure EXIT - + trap onfailure EXIT + eval echo "--- \$NAME_${module} done ---" done } @@ -161,11 +167,33 @@ load_opts() { local command=$1 local COMMAND=$(echo $command | tr '[:lower:]' '[:upper:]') - CMD_FLAGS="$(eval echo \$${COMMAND}_FLAGS)" + CMD_FLAGS=$(eval echo \$${COMMAND}_FLAGS) local CMD_FLAGS_FROM_FILE="" - BUILDDIR=$DUNE_BUILDDIR + if test "$command" = "NONE"; then + BUILDDIR=$DUNE_BUILDDIR + if test "x$DUNE_OPTS_FILE" != "x"; then + if test -z "$BUILDDIR"; then + # no builddir set yet, use build dir from opts file if set + # Note: if --use-buiddir is used BUILDDIR will be set already + OPTS_FILE_BUILDDIR="$(eval BUILDDIR=""; . $DUNE_OPTS_FILE; eval echo \$BUILDDIR)" + if test -n "$OPTS_FILE_BUILDDIR"; then + BUILDDIR="$OPTS_FILE_BUILDDIR" + fi + fi + if test "$system_default_cmake" = "yes"; then + # We use cmake for building, but CMAKE is not yet set. + # Check the opts file for it + OPTS_FILE_CMAKE="$(eval CMAKE=""; . $DUNE_OPTS_FILE; eval echo \$CMAKE)" + if test -n "$OPTS_FILE_CMAKE"; then + CMAKE="$OPTS_FILE_CMAKE" + fi + fi + fi + fi if test "x$DUNE_OPTS_FILE" != "x"; then - BUILDDIR="$(eval BUILDDIR=""; . $DUNE_OPTS_FILE; eval echo \$BUILDDIR)" + if test "$command" = "configure"; then + CMAKE_FLAGS="$(. $DUNE_OPTS_FILE; eval echo \$CMAKE_FLAGS)" + fi CMD_FLAGS_FROM_FILE="$(eval ${COMMAND}_FLAGS=""; . $DUNE_OPTS_FILE; eval echo \$${COMMAND}_FLAGS)" fi if test -n "$CMD_FLAGS_FROM_FILE"; then @@ -174,8 +202,78 @@ elif test -n "$CMD_FLAGS"; then echo "----- using default flags \$${COMMAND}_FLAGS from environment -----" fi + + # if no build directory is set, use default "build-cmake" + if test -z "$BUILDDIR"; then + export BUILDDIR=build-cmake + fi } +module_la_libname() +{ + local m=$1 + local name="$(eval echo \$NAME_$m)" + echo "lib$(echo $name | sed 's/-//g').la" +} + +abs_builddir() +{ + local m=$1 + local builddir=$2 + local name="$(eval echo \$NAME_$m)" + local path="$(eval echo \$PATH_$m)" + case $BUILDDIR in + /*) + echo $builddir/$name + ;; + *) + echo $path/$builddir + ;; + esac +} + +# Uses the current compiler to extract information about the +# multiarch triplets and sets the export variable MULTIARCH_LIBDIR +# according to it. +# If no compiler is specified then cc or gcc is used. +extract_multiarch(){ + set +e #error in the multiarch detection should not be fatal. + local my_cxx_compiler + if test "x$MULTIARCH_LIBDIR" != "x"; then + return + fi + load_opts "cmake" + if test "x$my_cxx_compiler" == "x"; then + load_opts "configure" + fi + my_cxx_compiler=`echo $CMD_FLAGS | $GREP CXX | $SED "s/.*CXX=[\"']\{0,1\}\([^$BLANK'\"]*\)[\"']\{0,1\}.*/\1/"` + if test "x$my_cxx_compiler" == "x"; then + $(which cc &>/dev/null) + if test $? -eq "0"; then + my_cxx_compiler=cc + else + my_cxx_compiler=gcc + fi + fi + multiarch=$($my_cxx_compiler --print-multiarch 2>/dev/null) + if test $? -gt 0; then + for i in "target=" "Target:"; do + multiarch=$($my_cxx_compiler -v 2>&1| $GREP "$i" | $SED "s/.*$i[$BLANK]*\([a-z0-9_-]*\)/\1/" | $SED "s/-[a-z]*-linux-gnu/-linux-gnu/") + if test -n "$multiarch"; then break; fi + done + fi + set -e # set to old value. + export MULTIARCH_LIBDIR="lib/$multiarch" +} + +export PREFIX_DIR="`canonicalpath "$0"`/.." + +# Read the modules find part +. "$PREFIX_DIR/lib/dunemodules.lib" + +############################################### + + ############################################### ### ### Commands @@ -202,11 +300,11 @@ done } -# check wheteher the parameter is valid command or not +# check whether the parameter is valid command or not is_command() { eval ' case "$1" in - '`echo $COMMANDS | sed -e 's/ / | /g'`') + '`echo $COMMANDS | $SED -e 's/ / | /g'`') return 0 ;; *) @@ -216,18 +314,23 @@ } # list of all dunecontrol commands -COMMANDS="printdeps update autogen configure make all exec status svn" +COMMANDS="printdeps vcsetup update configure make all exec bexec status svn git" + +# list of dunecontrol commands for which the version check is skipped by default +COMMANDSTOSKIPVERSIONCHECK="update status svn git exec bexec" # help string for the commands printdeps_HELP="print recursive dependencies of a module" -update_HELP="updated all modules from the repository" -autogen_HELP="run the autogen.sh script for each module" -configure_HELP="run configure for each module" -make_HELP="run make for each module" -all_HELP="\trun 'autogen', 'configure' and 'make' command for each module" -exec_HELP="execute an arbitrary command in each module directory" +vcsetup_HELP="setup version control repository (Git etc.) or working copy (SVN)" +update_HELP="update all modules from their repositories" +configure_HELP="run cmake for each module" +make_HELP="build each module" +all_HELP="\trun 'vcsetup', 'configure' and 'make' command for each module" +exec_HELP="execute an arbitrary command in each module source directory" +bexec_HELP="execute an arbitrary command in each module build directory" status_HELP="show vc status for all modules" svn_HELP="\trun svn command for each svn managed module" +git_HELP="\trun git command for each git managed module" # # setup command proxies @@ -239,15 +342,34 @@ done # -# default implementations for commands... +# default implementations for commands... # these can be overwritten in the $CONTROL files # run_default_exec () { bash -c "eval $CMD_FLAGS"; } +run_default_bexec () { + if test -d "$ABS_BUILDDIR"; then + bash -c "cd \"$ABS_BUILDDIR\" && eval $CMD_FLAGS"; + else + eval echo "Build directory \\\"$ABS_BUILDDIR\\\" not found, skipping bexec for \$NAME_${module}" + fi +} + run_default_status () { local verbose=0 local update="" + local is_git="" + local is_svn="" + name="$(eval echo \$NAME_$module)" + + if test -d .git; then is_git=1; fi + if test -d .svn; then is_svn=1; fi + if test ! "$is_svn" -a ! "$is_git" ; then + echo "module $name not under known version control" + return + fi + for i in $CMD_FLAGS; do if eval test "x$i" = "x-v"; then verbose=1; fi if eval test "x$i" = "x-vv"; then verbose=2; fi @@ -262,16 +384,24 @@ fi if test $verbose -eq 1; then - svn status $update | grep -E "^M|^A|^D|^C|^U" + test "$is_svn" && svn status $update | $GREP -E "^M|^A|^D|^C|^U" + test "$is_git" && git status -uno elif test $verbose -eq 2; then - svn status $update + test "$is_svn" && svn status $update + test "$is_git" && git status fi - name="$(eval echo \$NAME_$module)" - changed=$(svn status | grep -E "^M|^A|^D" | wc -l) - collisions=$(svn status | grep -E "^C"| wc -l) - pending=$(svn status $update | grep -E "^...... \* " | wc -l) + if test "$is_svn" ; then + changed=$(svn status | $GREP -E "^M|^A|^D" | wc -l) + collisions=$(svn status | $GREP -E "^C"| wc -l) + pending=$(svn status $update | $GREP -E "^...... \* " | wc -l) + fi + if test "$is_git" ; then + changed=$(git status --porcelain | $GREP -E "^ *M|^ *A|^ *D|^ *R|^ *C" | wc -l) + collisions=$(git status --porcelain | $GREP -E "^ *U"| wc -l) + pending=$(git status | $GREP -E "^\# Your branch is ahead |^\# Your branch is behind " | wc -l) + fi color=$green text="no changes" if [ $changed -eq 0 ]; then @@ -304,18 +434,129 @@ echo -e "$color[$text]$reset $name" } -run_default_update () { - DUNELINK=0 - if test -L dune; then - rm dune - DUNELINK=1 +run_default_vcsetup() { + # load user options + if [ -n "$CMD_FLAGS" ]; then + eval "$CMD_FLAGS" + fi + + # Check for both a file and a directory to cope with Git submodules + if [ -d .git -o -f .git ] ; then + + # Read Whitespace-Hook setting from dune.module file + local SETUPGITHOOK="$($GREP -i "^[$BLANK]*Whitespace-Hook:" dune.module | cut -d ':' -f2 | eval $PARSER_TRIM | tr '[:upper:]' '[:lower:]')" + + if [ "x$SETUPGITHOOK" = "xyes" ]; then + # we have to install the Git whitespace hook + + # The current Git repository might be a submodule, so we have to start by + # determining the location of the commit hook + + if [ -f .git ] ; then + # submodule -> .git contains a pointer to the repository + GITHOOKPATH="$($SED 's/gitdir: //' < .git)/hooks/pre-commit" + else + # standard case, .git is the repository + GITHOOKPATH=.git/hooks/pre-commit + fi + + if [ -n "$DISABLEWHITESPACEHOOK" ] ; then + # the user doesn't want the Git whitespace hook - deinstall it if necessary and warn the user + echo "WARNING: The current module wants to install the DUNE whitespace hook, but you have disabled the hook in your options!" + echo "WARNING: You will have to make sure that your commits don't introduce any trailing whitespace or indentation with tabs!" + echo "WARNING: Otherwise, your commits might be rejected when trying to push them to an official repository!" + + if [ -e "$GITHOOKPATH" ]; then + # there is a pre-commit hook, check whether it is our whitespace hook + local HOOKTAG="$(eval head -n 2 \"$GITHOOKPATH\" | tail -n 1)" + if [ "x$HOOKTAG" = "x# dune-git-whitespace-hook" ]; then + echo "--> Removing DUNE whitespace hook as requested by the user" + rm "$GITHOOKPATH" + fi + fi + else + # standard handling of Git whitespace hook + if [ ! -e "$GITHOOKPATH" ]; then + # there is no hook yet, we can safely install ours + echo "--> Installing Git pre-commit hook to enforce whitespace policy" + cp -p "$PREFIX_DIR/bin/git-whitespace-hook" "$GITHOOKPATH" + else + # there is already a hook, check whether it is our whitespace hook + local HOOKTAG="$(eval head -n 2 \"$GITHOOKPATH\" | tail -n 1)" + if [ "x$HOOKTAG" = "x# dune-git-whitespace-hook" ]; then + if [ "$PREFIX_DIR/bin/git-whitespace-hook" -nt "$GITHOOKPATH" ]; then + echo "--> Updating Git pre-commit hook with newer version" + cp -p "$PREFIX_DIR/bin/git-whitespace-hook" "$GITHOOKPATH" + fi + else + echo "WARNING: Existing pre-commit hook found!" + echo "WARNING: Skipping installation of DUNE whitespace hook!" + echo "WARNING: If you want to contribute patches to DUNE, you should make sure to call the whitespace hook" + echo "WARNING: (dune-common/bin/git-whitespace-hook) from you custom pre-commit hook, otherwise your commits" + echo "WARNING: might contain trailing whitespace and will not apply cleanly to the official repositories!" + fi + fi + fi + fi + + # Apply git configuration settings + if [ -f .vcsetup/config ]; then + echo -n "--> Setting Git configuration entries... " + cat .vcsetup/config | while read; do + # Filter out comments + local COMMENT="$(echo $REPLY | $GREP '^#')" + if [ ! "x$COMMENT" = "x$REPLY" ]; then + # parse line into an array first to catch obvious syntax errors + # like 'option value; rm -rf /' + eval local GIT_ARGS=($REPLY) + git config "${GIT_ARGS[@]}" + fi + done + echo "done" + fi + + # Apply user supplied configuration settings + if [ -n "$GIT_CONFIG_FILE" ]; then + if [ -f "$GIT_CONFIG_FILE" ]; then + echo -n "--> Setting custom Git configuration entries from '$GIT_CONFIG_FILE'... " + cat "$GIT_CONFIG_FILE" | while read; do + # Filter out comments + local COMMENT="$(echo $REPLY | $GREP '^#')" + if [ ! "x$COMMENT" = "x$REPLY" ]; then + # parse line into an array first to catch obvious syntax errors + # like 'option value; rm -rf /' + eval local GIT_ARGS=($REPLY) + git config "${GIT_ARGS[@]}" + fi + done + echo "done" + else + echo "WARNING: custom Git config file '$GIT_CONFIG_FILE' not found!" + fi + fi + fi + + # Run custom setup scripts + if [ -d .git -o -f .git -o -d .svn -o -d CVS ]; then + if [ -d .vcsetup/run.d ]; then + for SCRIPT in .vcsetup/run.d/* ; do + if [ -x "$SCRIPT" ]; then + echo "--> Running $SCRIPT" + "$SCRIPT" + fi + done + fi + fi +} + +run_default_update () { if test -d .svn; then svn update elif test -d CVS; then cvs update -dP - elif test -d .git; then - if test -d ".git/svn" && test -n "`git svn find-rev HEAD`"; then + elif test -d .git || test -f .git; then + if test -d .git && test -d ".git/svn" && test -n "`git svn find-rev HEAD`"; then # If the current HEAD points to a SVN commit, update via git-svn git svn rebase else @@ -335,35 +576,12 @@ echo "WARNING: $module is not under a known version control system." echo " We support svn, git and cvs." fi - if test "$DUNELINK" != 0 && ! test -d dune; then - echo "WARNING: $module is using the deprecated dune symlink" - ln -s . dune - fi -} - -run_default_autogen () { - PARAMS="$CMD_FLAGS" - local M4_PATH="" - if test -f configure.ac && \ - ( test -d .svn || test -d .git || test -d CVS || test -f stamp-vc ); then - for m in $FOUND_MODULES; do - path=$(eval "echo \$PATH_$m") - MODULE_PATHS="$MODULE_PATHS$path " - done - if test -f autogen.sh; then - eval echo "WARNING: \$NAME_$module contains obsolete autogen.sh," \ - >&2 - echo " dune-autogen is used instead." >&2 - fi - eval "$PREFIX_DIR/bin/dune-autogen" "$MODULE_PATHS" "$PARAMS" || exit 1 - else - echo Skipping dune-autogen - fi } run_default_configure () { + extract_multiarch PARAMS="$CMD_FLAGS" - if test -x configure; then + ACLOCAL_FLAGS="-I ." if test -d "m4"; then ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I m4" @@ -372,57 +590,100 @@ # get dependencies & suggestions sort_modules $module for m in $MODULES; do + path="$(eval "echo \$PATH_$m")" + # Translate the configure PARMS to cmake + export PARAMS + export CMAKE_PARAMS + if test x$module = x$m; then continue; fi # skip myself - path=$(eval "echo \$PATH_$m") name=$(eval "echo \$NAME_$m") - if test -d "$path/m4"; then - ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $path/m4" - fi - if test -d "$path/share/aclocal"; then - ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $path/share/aclocal" + for dir in $path/m4 $path/share/dune/aclocal $path/share/aclocal; do + if test -d "$dir"; then + ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $dir" + fi + done + local m_ABS_BUILDDIR=$(abs_builddir $m $BUILDDIR) + if test -d "$m_ABS_BUILDDIR"; then + PARAMS="$PARAMS \"--with-$name=$m_ABS_BUILDDIR\"" + else + if test x$(eval echo \$INST_$m) != xyes; then + PARAMS="$PARAMS \"--with-$name=$path\"" + fi fi - if test -d "$path/$BUILDDIR"; then - PARAMS="$PARAMS \"--with-$name=$path/$BUILDDIR\"" + + if test -d "$m_ABS_BUILDDIR"; then + CMAKE_PARAMS="$CMAKE_PARAMS \"-D""$name""_DIR=$m_ABS_BUILDDIR\"" else - PARAMS="$PARAMS \"--with-$name=$path\"" + TMP_PARAMS="\"-D""$name""_DIR=$path\"" + for i in $MULTIARCH_LIBDIR lib lib64 lib32; do + if test -d "$path/$i/cmake/$name"; then + TMP_PARAMS="\"-D""$name""_DIR=$path/$i/cmake/$name\"" + break; + fi + done + CMAKE_PARAMS="$CMAKE_PARAMS $TMP_PARAMS" fi + done - if test "x$HAVE_duneweb" == "xyes"; then - PARAMS="$PARAMS \"--with-duneweb=$PATH_duneweb\"" - fi - PARAMS="$PARAMS ACLOCAL_AMFLAGS=\"$ACLOCAL_FLAGS\"" - echo ./configure "$PARAMS" - # create build directory of requested - if test -n "$BUILDDIR"; then - test -d "$BUILDDIR" || mkdir "$BUILDDIR" + + # we have to export the compiler and compiler flags + # such that they are honored by cmake. + flags="CXX CC CXXFLAGS CFLAGS CPPFLAGS LDFLAGS F77 FFLAGS FLIBS FC FCFLAGS FCLIBS LIBS" + for i in $flags; do + cflags=`echo "$PARAMS" | $GREP $i= | $SED -e "s/^\($i=\"[^\"]*\"\).*/\1/" -e "s/.*[$BLANK]\($i=\"[^\"]*\"\).*/\1/" -e "s/^\($i='[^']*'\).*/\1/" -e "s/.*[$BLANK]\($i='[^']*'\).*/\1/"` + if test -n "$cflags" && test "$PARAMS" != "$cflags" ; then + PREPARAMS="$PREPARAMS $cflags" + else + cflags=`echo "$PARAMS" | $GREP $i= | $SED -e "s/^\($i=[^$BLANK]*\).*/\1/" -e "s/.*[$BLANK]\($i=[^$BLANK]*\).*/\1/"` + if test -n "$cflags" && test "$PARAMS" != "$cflags" ; then + PREPARAMS="$PREPARAMS $cflags" + fi + fi + done + # MPI flags are special. find_package(MPI) does not honor MPICC, MPICXX + # Therefore we translate them to CMake variables and add them to CMAKE_FLAGS. Fortran is omitted. + for i in CC CXX; do + comp=`echo "$PARAMS" | $GREP MPI$i= | $SED -e "s/^\($i=\"[^\"]*\"\).*/\1/" -e "s/.*[$BLANK]\($i=\"[^\"]*\"\).*/\1/" -e "s/^\($i='[^']*'\).*/\1/" -e "s/.*[$BLANK]\($i='[^']*'\).*/\1/"` + if test -n "$comp" && test "$PARAMS" != "$comp" ; then + CMAKE_FLAGS="-DMPI_$(echo $i| $SED 's/^CC$/C/')""_COMPILER:FILEPATH=`which $comp` $CMAKE_FLAGS" + else + comp=`echo "$PARAMS" | $GREP MPI$i= | $SED -e "s/^MPI$i=\([^$BLANK]*\).*/\1/" -e "s/.*[$BLANK]MPI$i=\([^$BLANK]*\).*/\1/"` + if test -n "$comp" && test "$PARAMS" != "$comp" ; then + CMAKE_FLAGS="-DMPI_$(echo $i| $SED 's/^CC$/C/')""_COMPILER:FILEPATH=`which $comp` $CMAKE_FLAGS" + fi + fi + done + # create build directory if requested + test -d "$ABS_BUILDDIR" || mkdir -p "$ABS_BUILDDIR" SRCDIR="$PWD" - cd "$BUILDDIR" - eval "$SRCDIR/configure" "$PARAMS" || exit 1 - else - eval ./configure "$PARAMS" || exit 1 - fi - else - if test -f configure.in || test -f configure.ac; then - echo "ERROR: configure.[in|ac] found, but configure missing." >&2 - echo "Did you forget to run autoconf?" >&2 - echo "Perhaps you didn't update your project to" >&2 - echo "the latest buildsystem changes (FS#382)." >&2 - echo "If your project is under version control, please make sure" >&2 - echo "you have a file stamp-vc in you top_srcdir." >&2 - exit 1 - fi - fi + cd "$ABS_BUILDDIR" + # check for libtool libs, which might break modules depending on this module + libname=$(module_la_libname $module) + found_libs=$(find dune -name \*.la) # find intermediate libtool libs + if test -e lib; then + found_libs="$found_libs"$(find lib -name $libname) #find primary lib + fi + test -n "$found_libs" && \ + echo "ERROR: your build directory $ABS_BUILDDIR contains libtool built libraries $found_libs, please cleanup" && \ + exit 1 + echo "$PREPARAMS $CMAKE -DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS \"$SRCDIR\"" + eval $PREPARAMS $CMAKE "-DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS \"$SRCDIR\"" || exit 1 } run_default_make () { - test ! -d "$BUILDDIR" || cd "$BUILDDIR" + test ! -d "$ABS_BUILDDIR" || cd "$ABS_BUILDDIR" PARAMS="$CMD_FLAGS" - echo make "$PARAMS" - eval $MAKE "$PARAMS" + echo "build directory: $BUILDDIR" + # prepend '--' to separate cmake and make parameters + if ! $(echo "$PARAMS" | grep -q -- '--'); then + PARAMS="-- $PARAMS" + fi + echo $CMAKE --build . "$PARAMS" + eval $CMAKE --build . "$PARAMS" } run_default_all () { - for cmd in autogen configure make; do + for cmd in vcsetup configure make; do eval echo "--- calling $cmd for \$NAME_${module} ---" load_opts $cmd run_$cmd @@ -436,19 +697,26 @@ fi } +run_default_git () { + if test -d .git; then + PARAMS="$CMD_FLAGS" + eval git "$PARAMS" + fi +} + ############################################### ### ### main ### onfailure() { - echo "Execution of $(basename $0) terminated due to errors!" >&2 + echo "Execution of $(basename "$0") terminated due to errors!" >&2 exit 1 } usage () { ( - echo "Usage: $(basename $0) [OPTIONS] COMMANDS [COMMAND-OPTIONS]" + echo "Usage: $(basename "$0") [OPTIONS] COMMANDS [COMMAND-OPTIONS]" echo "" echo " Execute COMMANDS for all Dune modules found. All entries in the" echo " DUNE_CONTROL_PATH variable are scanned recursively for Dune modules." @@ -456,21 +724,25 @@ echo " Dependencies are controlled by the $CONTROL files." echo "" echo "OPTIONS:" - echo " -h, --help show this help" - echo " --debug enable debug output of this script" - echo " --module=mod only apply the actions on module mod" - echo " and all modules it depends on" - echo " --only=mod only apply the actions on module mod" - echo " and not the modules it depends on" - echo " --current only apply the actions on the current module," - echo " the one whose source tree we are standing in" - echo " --resume resume a previous run (only consider the modules" - echo " not built successfully on the previous run)" - echo " --skipfirst skip the first module (use with --resume)" - echo " --opts=FILE load default options from FILE" - echo " (see dune-common/doc/example.opts)" + echo " -h, --help show this help" + echo " --debug enable debug output of this script" + echo " --module=mod apply the actions on module mod" + echo " and all modules it depends on" + echo " --only=mod only apply the actions on module mod" + echo " and not the modules it depends on" + echo " --current only apply the actions on the current module," + echo " i.e. the one whose source tree we are standing in," + echo " and not the modules it depends on" + echo " --current-dep apply the actions on the current module," + echo " and all modules it depends on" + echo " --resume resume a previous run (only consider the modules" + echo " not built successfully on the previous run)" + echo " --skipfirst skip the first module (use with --resume)" + echo " --opts=FILE load default options from FILE" echo " --builddir=NAME make out-of-source builds in a subdir NAME." - echo " This directory is created inside each module." + echo " This directory is created inside each module." + echo " If NAME is an absolute path, the build directory " + echo " is set to NAME/module-name for each module." echo " --[COMMAND]-opts=opts set options for COMMAND" echo " (this is mainly useful for the 'all' COMMAND)" echo "COMMANDS:" @@ -502,7 +774,7 @@ fi export MODULES= - RESUME="`cat $RESUME_FILE`" + RESUME="`cat "$RESUME_FILE"`" for a in $RESUME ; do export NAME_`fix_variable_name $a`="$a" fix_and_assign MODULE "$a" @@ -527,6 +799,15 @@ if test "x$SKIPFIRST" = "xyes" ; then export MODULES=`echo $MODULES " " | cut '--delimiter= ' --fields=2-` fi + # warn about superseeded modules: + if test -n "$superseded_modules"; then + # sort moules list and make it unique. + superseded_modules=$(echo $superseded_modules | tr ' ' '\n'| sort -u) + echo >&2 + echo "The following local modules do supersede the corresponding installed ones:" >&2 + echo "$superseded_modules" >&2 + echo >&2 + fi } # print the module list @@ -591,11 +872,11 @@ exit 1 fi ;; - -h|--help) + -h|--help) command=help break ;; - -p|--print) + -p|--print) command=print break ;; @@ -648,6 +929,18 @@ export SEARCH_MODULES="$SEARCH_MODULES $MODULE" export ONLY="$ONLY $MODULE" ;; + --current-dep) + while ! test -f $CONTROL; do + cd .. + if test "$OLDPWD" = "$PWD"; then + echo "You are not inside the source tree of a DUNE module." >&2 + exit -1 + fi + done; + parse_control $PWD/$CONTROL + fix_and_assign MODULE "$module" + export SEARCH_MODULES="$SEARCH_MODULES $MODULE" + ;; --resume) export RESUME_FLAG="yes" ;; @@ -672,6 +965,15 @@ shift done +extract_multiarch + +# create PKG_CONFIG_PATH for installed dune modules +for i in $MULTIARCH_LIBDIR lib64 lib32 lib; do + if test -d "$PREFIX_DIR/$i/pkgconfig"; then + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX_DIR/$i/pkgconfig" + fi +done + # we assume there should be a command... if test "x$command" = "x"; then usage @@ -692,7 +994,7 @@ create_module_list DUNE_CONTROL_PATH="" for mod in $MODULES; do - path=$(eval echo \$PATH_$mod) + path="$(eval echo \$PATH_$mod)" name=$(eval echo \$NAME_$mod) if test -f "$path/dune.module"; then export DUNE_CONTROL_PATH="$DUNE_CONTROL_PATH:$path/dune.module" @@ -707,7 +1009,7 @@ fi fi done - echo export DUNE_CONTROL_PATH=$(echo $DUNE_CONTROL_PATH | sed -e 's/^://') + echo export DUNE_CONTROL_PATH=$(echo $DUNE_CONTROL_PATH | $SED -e 's/^://') ;; printdeps) find_modules_in_path @@ -727,152 +1029,6 @@ echo " $mod (suggested)" done ;; - m4create) - find_modules_in_path - if test "x$SEARCH_MODULES" == "x"; then - echo "ERROR: m4create requires an explicit --module=... parameter" >&2 - exit 1 - fi - mainmod=`echo $SEARCH_MODULES` - eval mainmodpath=\$PATH_$mainmod - fname="$mainmodpath/dependencies.m4" - name=`eval echo \\${NAME_$mainmod}` - version=`eval echo \\${VERS_$mainmod}` - maintainer=`eval echo \\${MAIN_$mainmod}` - # get dependencies - eval deps=\$DEPS_$mainmod - #initially remove leading space - deps=`echo "$deps" | sed 's/^ *//'` - while test -n "$deps"; do - #the end of the name is marked either by space, opening paren - #or comma - depname="${deps%%[ (,]*}" - #remove the name and adjacent whitespace - deps=`echo "$deps" | sed 's/^[^ (,]* *//'` - #check whether there is a dependency version - case "$deps" in - '('*) deps="${deps#(}" - depver="${deps%%)*}" - deps="${deps#*)}" - ;; - *) depver= - ;; - esac - #remove any leading whitespace or commas for te next iteration - deps=`echo "$deps" | sed 's/^[, ]*//'` - - requires="$requires $depname $depver " - done - # get suggestions - eval sugs=\$SUGS_$mainmod - #initially remove leading space - sugs=`echo "$sugs" | sed 's/^ *//'` - while test -n "$sugs"; do - #the end of the name is marked either by space, opening paren - #or comma - sugsname="${sugs%%[ (,]*}" - #remove the name and adjacent whitespace - sugs=`echo "$sugs" | sed 's/^[^ (,]* *//'` - #check whether there is a dependency version - case "$sugs" in - '('*) sugs="${sugs#(}" - sugsver="${sugs%%)*}" - sugs="${sugs#*)}" - ;; - *) sugver= - ;; - esac - #remove any leading whitespace or commas for te next iteration - sugs=`echo "$sugs" | sed 's/^[, ]*//'` - - suggests="$suggests $sugsname" - suggestsall="$suggestsall $sugsname $sugsver " - done - # ensure a version number - if test "x$version" = "x"; then version="0.0"; fi - echo "writing $fname" - echo " for $name $version $maintainer" - echo " requires $requires" - echo " suggests $suggestsall" - AC_MACRO_DIR="." - test ! -d m4 || AC_MACRO_DIR=m4 - cat > $fname <> $fname <> $fname <> $fname <> $fname <> $fname < + +import errno +import glob +import os.path +import shutil +import subprocess +import sys +import xml.etree.ElementTree + +def printTest(test): + status = test.get("Status") + name = test.find("Name").text + fullName = test.find("FullName").text + output = test.find("Results").find("Measurement").find("Value").text + + print("======================================================================") + print("Name: {}".format(name)) + print("FullName: {}".format(fullName)) + print("Status: {}".format(status.upper())) + if output: + print("Output:") + for line in output.splitlines(): + print(" ", line) + print() + +def handleTest(test): + status = test.get("Status") + name = test.find("Path").text + if status == "passed": + passed = True + elif status == "notrun": + printTest(test) + passed = True + else: + printTest(test) + passed = False + return passed + +def findCTestOutput(): + files = glob.glob("Testing/*/Test.xml") + if len(files) != 1: + fn = files.join(", ") + raise Exception("Found multiple CTest output files: {}".format(files.join(", "))) + return files[0] + +def handleCTestOutput(): + path = findCTestOutput() + with open(path, "r", encoding="latin-1") as fh: + tree = xml.etree.ElementTree.parse(fh) + root = tree.getroot() + testing = root.find("Testing") + + passed = True + for test in testing.findall("Test"): + testPassed = handleTest(test) + passed = passed and testPassed + + return passed + +def runCTest(argv=[]): + cmd = ["ctest", + "--output-on-failure", + "--dashboard", "ExperimentalTest", + "--no-compress-output", + ] + cmd.extend(argv) + subprocess.call(cmd) + +def checkDirectory(): + if not os.path.exists("CMakeCache.txt"): + raise Exception("ERROR: dune-ctest must be run in a cmake build directory") + +def removeCTestOutput(): + try: + shutil.rmtree("Testing") + except OSError as e: + if e.errno != errno.ENOENT: + raise + +def main(): + try: + checkDirectory() + removeCTestOutput() + runCTest(argv=sys.argv[1:]) + passed = handleCTestOutput() + status = 0 if passed else 1 + sys.exit(status) + except Exception as e: + print("Internal error: {}".format(e)) + sys.exit(127) + +if __name__ == "__main__": + main() diff -Nru dune-common-2.2.1/bin/dunedoxynize dune-common-2.5.2~20170808ga5c076ca/bin/dunedoxynize --- dune-common-2.2.1/bin/dunedoxynize 2010-08-12 08:54:16.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/dunedoxynize 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ -#!/bin/sh - -if [ "x$DEBUG" = "xyes" ]; then - set -x -fi - -DOXYOUT=${1:-doc/doxygen/Doxyfile.in} -OUTDIR=`dirname "$DOXYOUT"` -DOXYDIR="doc/doxygen/" - -find_doxystyle() -{ - for i in `dirname $0`/../doc/doxygen/Doxystyle `dirname $0`/../share/dune-common/doc/doxygen/Doxystyle; do - if [ -f "$i" ]; then - export DOXYSTYLE=$i - return 0 - fi - done - return 1 -} - -test_doxylocal() -{ - while [ -n "$1" ]; do - if [ -f "$1/dune.module" ]; then - return 0 - fi - shift - done - return 1 -} - -parse_doxyfile() -{ - # Doxylocal is used _as is_ - if [ "$2" = "Doxylocal" ]; then - cat $1/$DOXYDIR/$2 - return - fi - - local FILE=$1/$DOXYDIR/$2 - local FOUND=0 - local line - - # find lines that match the pattern - set `grep -n '^ *\(INPUT\|EXAMPLE_PATH\|IMAGE_PATH\|PREDEFINED\|EXCLUDE\|EXAMPLE_PATTERNS\) *[+=]' $FILE | cut -d: -f1` - - # search lines in $@ and proceeding lines - grep -n . $FILE | - sed -e 's/\\/\\\\/g' | - while read line; do - if [ "${line%%:*}" -eq "${1:-0}" ]; then - FOUND=1 - # subst = by += if necessary - start="${line%%=*}" - case "$start" in - *+) ;; - *) line="$start+=${line#*=}" ;; - esac - shift - fi - if [ $FOUND -eq 1 ]; then - echo "$line" - else - continue - fi - # check for trailing '\' - case "$line" in - *\\) FOUND=1 ;; - *) FOUND=0 ;; - esac - done | sed -e 's/^[0-9]*://' -} - -parse_doxylocal() -{ - if echo $1 | grep -q "^/"; then - srcdir=$1/$DOXYDIR - top_srcdir=$1 - parse_doxyfile $1 $2 | sed -e "s!@\(abs_\)*srcdir@!$srcdir!" -e "s!@\(abs_\)*top_srcdir@!$top_srcdir!"; - else - parse_doxyfile $1 $2 - fi -} - -get_module_name() -{ - grep "^Module:" $1/dune.module | sed -e 's/^Module: *//' -} - -generate_doxyout() -{ - echo "Generating $DOXYOUT from " - echo " global style" - cat $DOXYSTYLE > $DOXYOUT - while [ -n "$1" ]; do - for DOXY in Doxylocal Doxyfile.in Doxyfile; do - if [ "$1/$DOXYDIR/$DOXY" -ef "$DOXYOUT" ]; then continue; fi - if [ -f "$1/$DOXYDIR/$DOXY" ]; then - echo " and `get_module_name $1` config" - parse_doxylocal $1 $DOXY >> $DOXYOUT - break - fi - done - shift - done - echo " ... done" -} - -generate_doxylocal() -{ - echo "Generating $DOXYOUT from " - for DOXY in Doxyfile.in Doxyfile; do - if [ -f "$1/$DOXYDIR/$DOXY" ]; then - echo " `get_module_name .` $DOXY" - parse_doxylocal . $DOXY > $DOXYOUT - break - fi - done - echo " ... done" -} - -# make sure we are in dune module -if ! [ -f dune.module ]; then - echo "Error: dunedoxynize must be called from the top_srcdir of your module" - exit 1 -fi - -# don't do anything if we have old style Doxyfile or Doxyfile.in, but no Doxylocal -if [ $# -eq 0 ] && ! [ -f "$DOXYDIR/Doxylocal" ]; then - for DOXY in Doxyfile.in Doxyfile; do - if [ -f "$DOXYDIR/$DOXY" ]; then - echo "Warning: module still uses handwritten $DOXY" - echo " You can transform it to an initial Doxylocal by calling" - echo " dune-common/bin/dunedoxynize doc/doxygen/Doxylocal ." - echo " in the top source directory of this module" - exit 0 - fi - done - exit 0 -fi - -# quit if your module doesn't have any documentation -if ! [ -d "$OUTDIR" ]; then - if [ $# -eq 0 ]; then - exit 0 - else - echo "Error: output directory $OUTDIR does not exist." - exit 0 - fi -fi - -# search for doxygen style -if ! find_doxystyle; then - echo "Error: dunedoxynize global style not found" - exit 1 -fi - -# drop the parameter of the output file -if [ $# -gt 0 ]; then - shift -fi - -# make sure that there is at least one Doxylocal file -if ! test_doxylocal "${@:-.}" && [ $# -gt 0 ]; then - echo "Error: you didn't supply any valid Doxylocal file" - exit 1 -fi - -if [ "`basename $DOXYOUT`" = "Doxylocal" ]; then - generate_doxylocal "${@:-.}" -else - generate_doxyout "${@:-.}" -fi diff -Nru dune-common-2.2.1/bin/duneproject dune-common-2.5.2~20170808ga5c076ca/bin/duneproject --- dune-common-2.2.1/bin/duneproject 2013-02-15 12:22:40.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/duneproject 2017-08-08 08:39:46.000000000 +0000 @@ -1,10 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash # # TODO: # -# * In case of an installed Dune, it should not be necessary to pass the -# dune-common dir to autogen.sh. # * Check module names entered as dependencies. set -e @@ -38,7 +36,7 @@ fdir="`canonicalname \"$fdir\"`" echo "$fdir/$fname" fi - # if this is a directory, then create an absolute + # if this is a directory, then create an absolute # directory name and we are done if test -d "$file"; then (cd "$file"; pwd) @@ -51,7 +49,7 @@ echo Usage: canonicalpath path >&2 return 1 fi - dirname $(canonicalname "$1") + dirname "$(canonicalname "$1")" } pkg_config_dependencies(){ @@ -79,6 +77,11 @@ fi done if [ "$found" = "0" ]; then + # Module not found in list, try pkg-config + pkg-config $module &> /dev/null + found=$? + fi + if [ "$found" = "0" ]; then echo "ERROR:">&2 echo "Module with name $dep was not found" >&2 echo "Did you forget to specify it's location" >&2 @@ -128,7 +131,7 @@ fi fi } - + echo echo == Dune project/module generator == echo @@ -140,10 +143,11 @@ ################## FIND AVAILABLE MODULES ################## -. $(canonicalpath $0)/../lib/dunemodules.lib +. "$(canonicalpath $0)/../lib/dunemodules.lib" -# create PKG_CONFIG_PATH for installed dune modules -export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(canonicalpath $0)/../lib/pkgconfig" +export PREFIX_DIR="`canonicalpath "$0"`/.." + +extract_multiarch_pkg_config_path # search for modules, both installed and src modules find_modules_in_path @@ -175,10 +179,15 @@ DEPENDENCIES="$2" VERSION="$3" MAINTAINER="$4" +ENABLE_ALL="$5" ################## READ OPTIONS ################## while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do + + # Track minimum CMake version + CMAKE_MINIMUM_REQUIRED=2.8.12 + while [ -z $PROJECT ]; do read -p "1) Name of your new Project? (e.g.: dune-grid): " PROJECT if echo "$MODULES" | grep -q ^$PROJECT$; then @@ -186,6 +195,9 @@ if test x$DELETE = xy -o x$DELETE = xY; then PROJECT="" fi + elif echo "$PROJECT" | grep -q "\."; then + echo "The Name contains a dot (.) which is not allowed." + PROJECT="" fi done MODULE="$PROJECT" @@ -194,12 +206,12 @@ while [ "$DEPOK" != 0 ]; do echo "2) Which modules should this module depend on?" - echo " Following modules are found:" + echo " The following modules have been found:" echo " $MODULES" # for i in $MODULES; do echo -n " $i"; done # echo "" while [ -z "$DEPENDENCIES" ]; do - read -p " Enter space separated list: " DEPENDENCIES + read -p " Enter space-separated list: " DEPENDENCIES done set +e modulesexist "$DEPENDENCIES" "$MODULES" @@ -213,14 +225,33 @@ while [ -z $VERSION ]; do read -p "3) Project/Module version? " VERSION done - while [ -z $MAINTAINER ]; do - read -p "4) Maintainers email address? " MAINTAINER + while [ -z "$MAINTAINER" ]; do + read -p "4) Maintainer's email address? " MAINTAINER done + while [ "$ENABLE_ALL" != "y" -a "$ENABLE_ALL" != "Y" -a "$ENABLE_ALL" != "n" -a "$ENABLE_ALL" != "N" ]; do + echo "5) Enable all available packages? Choose 'y' if you don't understand the question, but note that you need" + read -p " at least CMake 2.8.12 for this. You can check your version with 'cmake --version' [y/N]" ENABLE_ALL + done + + # canonicalize contents of ENABLE_ALL + ENABLE_ALL=$(tr '[:upper:]' '[:lower:]' <<< "$ENABLE_ALL") + + # set newer CMake minimum version if ENABLE_ALL is true + if [ 'y' == "$ENABLE_ALL" ] ; then + CMAKE_MINIMUM_REQUIRED=2.8.12 + fi echo echo "creating Project \"$PROJECT\", version $VERSION " echo "which depends on \"$DEPENDENCIES\"" echo "with maintainer \"$MAINTAINER\"" + if [ "y" == "$ENABLE_ALL" ] ; then + echo "and new, automatic external package handling based on dune_enable_all_packages()." + else + echo "and old external package handling (you need to manually add external dependencies to each target in CMakeLists.txt)." + fi + echo "Minimum required CMake version for building this project: ${CMAKE_MINIMUM_REQUIRED}" + echo read -p "Are these informations correct? [y/N] " DATACORRECT # reset data if necessary @@ -229,14 +260,18 @@ DEPENDENCIES="" VERSION="" MAINTAINER="" + ENABLE_ALL="" fi -done + + done + + echo echo "A sample code $MODULE.cc is generated in the \"$PROJECT\" directory." echo "Look at the README and dune.module files there." echo "Now you can run the dunecontrol script which will setup the new module." -echo "Sometimes you may have to tweak configure.ac a bit." +echo "Sometimes you may have to tweak CMakeLists.txt a bit." if test -d $PROJECT; then echo WARNING: @@ -261,12 +296,10 @@ Module: $MODULE Version: $VERSION Maintainer: $MAINTAINER -#depending on +#depending on Depends: $DEPENDENCIES C_DELIM -################## CONFIGURE.AC ################## - ## Create the parameters passed to DUNE_CHECK_ALL # save module list of dunemodules.inc @@ -305,47 +338,14 @@ echo "------------------------------------------" echo "writing initial files:" -# we need the module with _ instead of - to not confuse automake +# complete module name with _ instead of - to not confuse automake fix_and_assign CMODULE $MODULE -NAME=`echo $PROJECT | sed -e 's/dune[_-]//' | tr '-' '_'` - -################## CONFIGURE.AC ################## -echo "- $PROJECT/configure.ac" -cat > "$PROJECT/configure.ac" <= 1.5 - - autoconf >= 2.50 - - libtool + cmake >= ${CMAKE_MINIMUM_REQUIRED} Getting started --------------- -If these preliminaries are met, you should run +If these preliminaries are met, you should run dunecontrol all -which will find all installed dune modules as well as all dune modules -(not installed) which sources reside in a subdirectory of the current +which will find all installed dune modules as well as all dune modules +(not installed) which sources reside in a subdirectory of the current directory. Note that if dune is not installed properly you will either -have to add the directory where the dunecontrol script resides (probably +have to add the directory where the dunecontrol script resides (probably ./dune-common/bin) to your path or specify the relative path of the script. -On your project and all uninstalled DUNE source modules found the script -will then calls the GNU autoconf/automake to create a ./configure-script -and the Makefiles. Afterwards that configure script will be called and the -modules will be build using make all - -Most probably you'll have to provide additional information to dunecontrol -(e. g. compilers, configure options) and/or make options. +Most probably you'll have to provide additional information to dunecontrol +(e. g. compilers, configure options) and/or make options. The most convenient way is to use options files in this case. The files -defining three variables: +define four variables: -AUTOGEN_FLAGS flags passed to autogen -CONFIGURE_FLAGS flags passed to configure +CMAKE_FLAGS flags passed to cmake (during configure) MAKE_FLAGS flags passed to make An example options file might look like this: -#use this options to autogen, configure and make if no other options are given -AUTOGEN_FLAGS="--ac=2.50 --ac=1.8" #Forces automake 2,50 and autoconf 1.8 -CONFIGURE_FLAGS="CXX=g++-3.4 --prefix=/install/path" #force g++-3.4 as compiler +#use this options to configure and make if no other options are given +CMAKE_FLAGS=" \\ +-DCMAKE_CXX_COMPILER=g++-4.9 \\ +-DCMAKE_CXX_FLAGS='-Wall -pedantic' \\ +-DCMAKE_INSTALL_PREFIX=/install/path" #Force g++-4.9 and set compiler flags MAKE_FLAGS=install #Per default run make install instead of simply make -If you save this information into example.opts you can path the opts file to +If you save this information into example.opts you can pass the opts file to dunecontrol via the --opts option, e. g. dunecontrol --opts=example.opts all -To get a full list of available configure flags just run - - dunecontrol configure --help - -after running at least - dunecontrol autogen - More info --------- See dunecontrol --help - -for further options. +for further options. -The full build-system is described in the dune-common/doc/buildsystem (SVN version) or under share/doc/dune-common/buildsystem if you installed DUNE! - -\$Id: duneproject 7127 2013-02-15 12:22:40Z mblatt $ +The full build system is described in the dune-common/doc/buildsystem (Git version) or under share/doc/dune-common/buildsystem if you installed DUNE! R_DELIM -################## MAKEFILE.AM ################## -DISTCHECK_CONFIGURE_FLAGS= -for name in $DEPENDENCIES; do - capital=`echo $name | tr '[a-z-]' '[A-Z_]'` - DISTCHECK_CONFIGURE_FLAGS=$DISTCHECK_CONFIGURE_FLAGS"--with-${name}=\$(${capital}_ROOT) " -done -echo "- $PROJECT/Makefile.am" -cat> "$PROJECT/Makefile.am" << M_DELIM -# \$Id: duneproject 7127 2013-02-15 12:22:40Z mblatt $ - -# we need the module file to be able to build via dunecontrol -EXTRA_DIST=dune.module +################## CMakeLists.txt ################## +echo "- $PROJECT/CMakeLists.txt" +cat> "$PROJECT/CMakeLists.txt" << M_DELIM +cmake_minimum_required(VERSION ${CMAKE_MINIMUM_REQUIRED}) +project($PROJECT CXX) + +if(NOT (dune-common_DIR OR dune-common_ROOT OR + "\${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*")) + string(REPLACE \${CMAKE_PROJECT_NAME} dune-common dune-common_DIR + \${PROJECT_BINARY_DIR}) +endif() + +#find dune-common and set the module path +find_package(dune-common REQUIRED) +list(APPEND CMAKE_MODULE_PATH "\${PROJECT_SOURCE_DIR}/cmake/modules" + \${dune-common_MODULE_PATH}) -SUBDIRS = src m4 dune doc - -if BUILD_DOCS -# TODO: set up documentation tree automatically -#SUBDIRS += doc -endif - -# don't follow the full GNU-standard -# we need automake 1.5 -AUTOMAKE_OPTIONS = foreign 1.5 - -# pass most important options when "make distcheck" is used -DISTCHECK_CONFIGURE_FLAGS = $DISTCHECK_CONFIGURE_FLAGS CXX="\$(CXX)" CC="\$(CC)" - -include \$(top_srcdir)/am/top-rules -include \$(top_srcdir)/am/global-rules +#include the dune macros +include(DuneMacros) +# start a dune project with information from dune.module +dune_project() +M_DELIM +if [ 'y' == "$ENABLE_ALL" ] ; then +cat>> "$PROJECT/CMakeLists.txt" << M_DELIM +dune_enable_all_packages() M_DELIM +fi +cat>> "$PROJECT/CMakeLists.txt" << M_DELIM +add_subdirectory("src") +add_subdirectory("dune") +add_subdirectory("doc") +add_subdirectory("cmake/modules") -################## STAMP-VC ################## -echo "- $PROJECT/stamp-vc" -echo 'A stamp file to signify that this directory comes from a version control system, not an unpacked tarball' > $PROJECT/stamp-vc +# finalize the dune project, e.g. generating config.h etc. +finalize_dune_project(GENERATE_CONFIG_H_CMAKE) +M_DELIM ################## PROJECT.PC.IN ################## echo "- $PROJECT/$MODULE.pc.in" @@ -477,80 +461,95 @@ Description: $MODULE module URL: http://dune-project.org/ Requires: ${DEPENDENCIES} -Libs: -L${libdir} -Cflags: -I${includedir} +Libs: -L\${libdir} +Cflags: -I\${includedir} CC_DELIM echo " Please remember to update your $PROJECT/$MODULE.pc.in," echo " Description and URL are missing right now." -############################################################### -################## The source subdirectory #################### -############################################################### +################# config.h.cmake ##################### -mkdir "$PROJECT/src" +echo "- $PROJECT/config.h.cmake" +cat> "$PROJECT/config.h.cmake" < "$PROJECT/src/Makefile.am" << M_DELIM +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "@DUNE_MAINTAINER@" -SUBDIRS = +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@DUNE_MOD_NAME@" -noinst_PROGRAMS = ${CMODULE} +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "@DUNE_MOD_NAME@ @DUNE_MOD_VERSION@" -${CMODULE}_SOURCES = $CMODULE.cc - -${CMODULE}_CPPFLAGS = \$(AM_CPPFLAGS) \\ - \$(DUNEMPICPPFLAGS) \\ - \$(UG_CPPFLAGS) \\ - \$(AMIRAMESH_CPPFLAGS) \\ - \$(ALBERTA_CPPFLAGS) \\ - \$(ALUGRID_CPPFLAGS) -# The libraries have to be given in reverse order (most basic libraries -# last). Also, due to some misunderstanding, a lot of libraries include the -# -L option in LDFLAGS instead of LIBS -- so we have to include the LDFLAGS -# here as well. -${CMODULE}_LDADD = \\ - \$(DUNE_LDFLAGS) \$(DUNE_LIBS) \\ - \$(ALUGRID_LDFLAGS) \$(ALUGRID_LIBS) \\ - \$(ALBERTA_LDFLAGS) \$(ALBERTA_LIBS) \\ - \$(AMIRAMESH_LDFLAGS) \$(AMIRAMESH_LIBS) \\ - \$(UG_LDFLAGS) \$(UG_LIBS) \\ - \$(DUNEMPILIBS) \\ - \$(LDADD) -${CMODULE}_LDFLAGS = \$(AM_LDFLAGS) \\ - \$(DUNEMPILDFLAGS) \\ - \$(UG_LDFLAGS) \\ - \$(AMIRAMESH_LDFLAGS) \\ - \$(ALBERTA_LDFLAGS) \\ - \$(ALUGRID_LDFLAGS) \\ - \$(DUNE_LDFLAGS) - -# don't follow the full GNU-standard -# we need automake 1.5 -AUTOMAKE_OPTIONS = foreign 1.5 +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@DUNE_MOD_NAME@" -# pass most important options when "make distcheck" is used -DISTCHECK_CONFIGURE_FLAGS = $DISTCHECK_CONFIGURE_FLAGS CXX="\$(CXX)" CC="\$(CC)" +/* Define to the home page for this package. */ +#define PACKAGE_URL "@DUNE_MOD_URL@" -include \$(top_srcdir)/am/global-rules +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@DUNE_MOD_VERSION@" +/* end private */ + +/* Define to the version of $PROJECT */ +#define ${UNAME}_VERSION "@${UNAME}_VERSION@" + +/* Define to the major version of $PROJECT */ +#define ${UNAME}_VERSION_MAJOR @${UNAME}_VERSION_MAJOR@ + +/* Define to the minor version of $PROJECT */ +#define ${UNAME}_VERSION_MINOR @${UNAME}_VERSION_MINOR@ + +/* Define to the revision of $PROJECT */ +#define ${UNAME}_VERSION_REVISION @${UNAME}_VERSION_REVISION@ + +/* end $PROJECT + Everything below here will be overwritten +*/ +EOF +## done + +############################################################### +################## The source subdirectory #################### +############################################################### + +mkdir "$PROJECT/src" + +################## src/CMakeLists.txt ################## + +echo "- $PROJECT/src/CMakeLists.txt" +cat> "$PROJECT/src/CMakeLists.txt" << M_DELIM +add_executable("${MODULE}" ${MODULE}.cc) +target_link_dune_default_libraries("${MODULE}") M_DELIM ################## PROJECT.CC ################## -echo "- $PROJECT/src/$CMODULE.cc" -cat> "$PROJECT/src/$CMODULE.cc" << CC_DELIM +echo "- $PROJECT/src/$MODULE.cc" +cat> "$PROJECT/src/$MODULE.cc" << CC_DELIM +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + #ifdef HAVE_CONFIG_H -# include "config.h" +# include "config.h" #endif #include -#include"dune/common/mpihelper.hh" // An initializer of MPI -#include"dune/common/exceptions.hh" // We use exceptions +#include // An initializer of MPI +#include // We use exceptions int main(int argc, char** argv) { try{ - //Maybe initialize Mpi + // Maybe initialize MPI Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv); std::cout << "Hello World! This is ${PROJECT}." << std::endl; if(Dune::MPIHelper::isFake) @@ -569,44 +568,6 @@ } CC_DELIM -################## M4/MAKEFILE #################### -mkdir "$PROJECT/m4" -echo "- $PROJECT/m4/Makefile.am" -cat> "$PROJECT/m4/Makefile.am" << CC_DELIM -M4FILES = $MODULE.m4 - -aclocaldir = \$(datadir)/aclocal -aclocal_DATA = \$(M4FILES) - -EXTRA_DIST = \$(M4FILES) - -include \$(top_srcdir)/am/global-rules -CC_DELIM - -################## M4/PROJECT.M4 #################### -M4_MODULE=`echo $MODULE | tr '[a-z-]' '[A-Z_]'` -echo "- $PROJECT/m4/$MODULE.m4" -cat> "$PROJECT/m4/$MODULE.m4" << CC_DELIM -dnl -*- autoconf -*- -# Macros needed to find $MODULE and dependent libraries. They are called by -# the macros in \${top_src_dir}/dependencies.m4, which is generated by -# "dunecontrol autogen" - -# Additional checks needed to build $MODULE -# This macro should be invoked by every module which depends on $MODULE, as -# well as by $MODULE itself -AC_DEFUN([${M4_MODULE}_CHECKS]) - -# Additional checks needed to find $MODULE -# This macro should be invoked by every module which depends on $MODULE, but -# not by $MODULE itself -AC_DEFUN([${M4_MODULE}_CHECK_MODULE], -[ - DUNE_CHECK_MODULES([$MODULE],[$NAME/$NAME.hh]) -]) -CC_DELIM - - ################################################################ ################## The headers subdirectory #################### ################################################################ @@ -615,56 +576,41 @@ mkdir "$PROJECT/dune" mkdir "$PROJECT/dune/$NAME" -################## dune/Makefile.am #################### -echo "- $PROJECT/dune/Makefile.am" -cat> $PROJECT/dune/Makefile.am < $PROJECT/dune/CMakeLists.txt < $PROJECT/dune/$NAME/Makefile.am < $PROJECT/dune/$NAME/CMakeLists.txt < $PROJECT/dune/$NAME/$NAME.hh < "$PROJECT/doc/Makefile.am" << CC_DELIM - -SUBDIRS = doxygen -CURDIR = doc -BASEDIR = .. - -# add list of html files to generate from wml -PAGES= - -docdir=\$(datadir)/doc/${PROJECT} - -include \$(top_srcdir)/am/webstuff -include \$(top_srcdir)/am/global-rules +################## doc/CMakeLists.txt ################# +echo "- $PROJECT/doc/CMakeLists.txt" +cat> "$PROJECT/doc/CMakeLists.txt" << CC_DELIM +add_subdirectory("doxygen") CC_DELIM ############################################################### @@ -673,7 +619,6 @@ mkdir "$PROJECT/doc/doxygen" - #################### basic Doxylocal ########################## echo "- $PROJECT/doc/doxygen/Doxylocal" @@ -692,7 +637,7 @@ INPUT += @top_srcdir@/dune/ # see e.g. dune-grid for the examples of mainpage and modules -# INPUT += @srcdir@/mainpage \ +# INPUT += @srcdir@/mainpage \\ # @srcdir@/modules # The EXCLUDE tag can be used to specify files and/or directories that should @@ -712,25 +657,56 @@ # the \image command). # IMAGE_PATH += @top_srcdir@/dune/$NAME/pics +CC_DELIM + +################# doc/doxygen/CMakeLists.txt ##################### +echo "- $PROJECT/doc/doxygen/CMakeLists.txt" +cat> "$PROJECT/doc/doxygen/CMakeLists.txt" << CC_DELIM +# shortcut for creating the Doxyfile.in and Doxyfile +add_doxygen_target() CC_DELIM -################# doc/doxygen/Makefile.am ##################### +######################################################### +############### The cmake subdirectory ################## +######################################################### + +mkdir "$PROJECT/cmake" + +######################################################### +############### The cmake/modules subdirectory ########## +######################################################### + +mkdir "$PROJECT/cmake/modules" + +macroname="" +for i in $(echo $PROJECT| sed 's/-/ /g'); do + firstchar=$(echo $i | sed 's/\(.\).*/\1/') + macroname=$macroname$(echo $firstchar | tr '[a-z]' '[A-Z]')$(echo $i | sed 's/.\(.*\)/\1/') +done +macroname="$macroname""Macros.cmake" -echo "- $PROJECT/doc/doxygen/Makefile.am" -cat> "$PROJECT/doc/doxygen/Makefile.am" << CC_DELIM +################# cmake/modules/CMakeLists.txt ##################### -BASEDIR=../.. -CURDIR=doc/doxygen +echo "- $PROJECT/cmake/modules/CMakeLists.txt" +cat> "$PROJECT/cmake/modules/CMakeLists.txt" < "$PROJECT/cmake/modules/$macroname" </dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + + +# By default, we disallow trailing whitespace for the following files, but the check for C/C++ and CMake sources +# happens in the tab-in-indent check to avoid confusing users with duplicate error messages +TRAILING_WHITESPACE_DEFAULT='.*(dune.module|README|README.SVN|COPYING|INSTALL|TODO|\.pc\.in)$' + +# By default, we disallow tabs in indents and trailing whitespace in C/C++ and CMake source files +TAB_IN_INDENT_DEFAULT='.*(\.cpp|\.hpp|\.cc|\.hh|\.c|\.h|\.cmake|CMakeLists.txt|\.sh|\.py)$' + +# Get user preferences +TRAILING_WHITESPACE_FILES=$(git config hooks.whitespace.trailing) + +# Set default regex for disallowing trailing whitespace if the user did not set anything. +# We need to check the return value of git-config to distinguish the case +# when the user set an empty value +if [ $? -ne 0 ]; +then + TRAILING_WHITESPACE_FILES="$TRAILING_WHITESPACE_DEFAULT" +fi + + +TAB_IN_INDENT_FILES=$(git config hooks.whitespace.tabinindent) + +# Set default regex for disallowing tabs if the user did not set anything. +# We need to check the return value of git-config to distinguish the case +# when the user set an empty value +if [ $? -ne 0 ]; +then + TAB_IN_INDENT_FILES="$TAB_IN_INDENT_DEFAULT" +fi + + +# Unfortunately, we have to mess directly with the repository config file, +# as git won't honor a custom config file specified by GIT_CONFIG + +# backup repository-local user setting for core.whitespace +USER_WHITESPACE=$(git config --local --get core.whitespace) +if [ $? -ne 0 ]; +then + USER_HAS_CUSTOM_WHITESPACE=0 +else + USER_HAS_CUSTOM_WHITESPACE=1 +fi + +# Figure out how to call xargs to make sure it won't invoke its argument with +# an empty argument list. BSD xargs will not do that by default, while GNU xargs +# needs -r to do the same. So we start by checking whether xargs does the right +# thing without options. Now there could be other obscure versions of xargs out +# there (on clusters etc.) that behave in yet another way, so we try with -r as +# well. If that fails, we throw a big error message at the user. + +# In the following line, xargs should not call false, so the return value should be 0. +echo "" | xargs false + +if [ $? -ne 0 ]; then + # Let's try with -r + echo "" | xargs -r false + if [ $? -ne 0 ]; then + # Houston, we have a problem + if [ -z "$DUNE_WHITESPACE_IGNORE_XARGS" ]; then + echo "You seem to be lacking a version of xargs that is compatible to either BSD or GNU!" 1>&2 + echo "Please file a bug report at http://dune-project.org about this issue with your exact operating system type and version!" 1>&2 + echo "You can still use this hook by setting the environment variable DUNE_WHITESPACE_IGNORE_XARGS to 1, but please be aware" 1>&2 + echo "that the hook might create false positives." 1>&2 + echo "==============================================================" 1>&2 + echo "Aborting the commit..." 1>&2 + exit 99 + else + SILENTXARGS=xargs + fi + else + SILENTXARGS="xargs -r" + fi +else + SILENTXARGS=xargs +fi + + +fail=0 +done=0 + +do_cleanup() +{ + + if [ $done -ne 1 ]; + then + echo "Error while executing whitespace checking pre-commit hook!" 1>&2 + echo "There might still be whitespace errors in your commit!" 1>&2 + fi + + if [ $USER_HAS_CUSTOM_WHITESPACE -eq 1 ]; + then + git config --replace-all core.whitespace "$USER_WHITESPACE" + else + git config --unset core.whitespace + fi + + # be nice and let the commit go through if something went wrong along the + # way and we did not record a failure + exit $fail +} + +trap do_cleanup EXIT + +# set custom value +git config --replace-all core.whitespace trailing-space + +if [ -z "$TRAILING_WHITESPACE_FILES" ]; +then + git diff-index --check --cached $against -- + result=$? +else + git diff-index --cached --name-only $against | perl -ne "print if /$TRAILING_WHITESPACE_FILES/" | $SILENTXARGS git diff-index --check --cached $against -- + result=$? +fi + +if [ $result -ne 0 ]; +then + fail=1 +fi + +git config --replace-all core.whitespace trailing-space,tab-in-indent + +if [ -z "$TAB_IN_INDENT_FILES" ]; +then + git diff-index --check --cached $against -- + result=$? +else + git diff-index --cached --name-only $against | perl -ne "print if /$TAB_IN_INDENT_FILES/" | $SILENTXARGS git diff-index --check --cached $against -- + result=$? +fi + +if [ $result -ne 0 ]; +then + fail=1 +fi + +done=1 + +# trap will call the cleanup code diff -Nru dune-common-2.2.1/bin/Makefile.am dune-common-2.5.2~20170808ga5c076ca/bin/Makefile.am --- dune-common-2.2.1/bin/Makefile.am 2010-07-07 10:42:45.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -# $Id: Makefile.am 6064 2010-07-07 10:42:45Z mnolte $ - -# put scripts into dist-tarball -EXTRA_DIST = duneproject dunecontrol \ - dunedoxynize \ - mpi-config dune-autogen \ - xfail-compile-tests - -# ... and install some -bin_SCRIPTS = dunedoxynize duneproject dunecontrol mpi-config dune-autogen - -include $(top_srcdir)/am/global-rules diff -Nru dune-common-2.2.1/bin/mpi-config dune-common-2.5.2~20170808ga5c076ca/bin/mpi-config --- dune-common-2.2.1/bin/mpi-config 2010-07-07 09:40:04.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/mpi-config 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ -#!/bin/bash - -set -e - -canonicalname(){ - if test $# -ne 1; then - echo Usage: canonicalname path >&2 - return 1 - fi - name="$1" - while test -L "$name"; do - if ! test -e "$name"; then - echo $name: file not found >&2 - return 1 - fi - if newname="`readlink $name`"; then - name="$newname" - else - echo "$(dirname $name)/$(basename $name)" - fi - done - echo $name -} - -canonicalpath(){ - if test $# -ne 1; then - echo Usage: canonicalpath path >&2 - return 1 - fi - (cd $(dirname $(canonicalname $1)) && pwd) -} - -findm4dir() { - BINDIR="$(canonicalpath $0)" - # source-build - M4DIR="$BINDIR/../m4" - if test -f "$M4DIR/mpi-config.m4"; then - echo "$M4DIR" - return - fi - # installed - M4DIR="$BINDIR/../share/aclocal" - if test -f "$M4DIR/mpi-config.m4"; then - echo "$M4DIR" - return - fi - # downloaded - M4DIR="$BINDIR" - if test -f "$M4DIR/mpi-config.m4"; then - echo "$M4DIR" - return - fi - echo "ERROR: could not find mpi-config.m4! Incomplete installation?" >&2 - exit 1 -} - -version=0.1 -verbose=0 - -usage() -{ - cat <&2 -fi - -while test $# -gt 0 ; do - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case $1 in - --mpicc=*) - MPICC=$optarg - ;; - --version) - echo $version - exit 0 - ;; - --verbose) - verbose=1 - ;; - --disable-cxx) - disablecxx=yes - ;; - --mpiversion) - tasks="$tasks print_mpiversion" - ;; - --cflags) - tasks="$tasks print_cflags" - ;; - --ldflags) - tasks="$tasks print_ldflags" - ;; - --libs) - tasks="$tasks print_libs" - ;; - *) - usage 1 1>&2 - ;; - esac - shift -done - -if test x$MPICC = x ; then - MPICC=mpicc -fi - -# -# LIB -# -# load mpi-config.m4 -# - -# find m4 file -M4DIR=`findm4dir` - -eval "$( -m4 -I$M4DIR <&2 - return 1 - fi - file="$1" - if test ! -e "$file"; then - echo $file: file not found >&2 - return 1 - fi - # if this is a symlink, then follow the symlink - if test -L "$file"; then - fdir="`dirname \"$file\"`" - flink="`readlink \"$file\"`" - if test -e "$flink"; then - # these are absolute links, or links in the CWD - canonicalname "$flink" - else - canonicalname "$fdir/$flink" - fi - else - # if this is a file, then remember the filename and - # canonicalize the directory name - if test -f "$file"; then - fdir="`dirname \"$file\"`" - fname="`basename \"$file\"`" - fdir="`canonicalname \"$fdir\"`" - echo "$fdir/$fname" - fi - # if this is a directory, then create an absolute - # directory name and we are done - if test -d "$file"; then - (cd "$file"; pwd) - fi - fi -} - -canonicalpath(){ - if test $# -ne 1; then - echo Usage: canonicalpath path >&2 - return 1 - fi - dirname $(canonicalname "$1") -} - -checkdebug () { - while test $# -gt 0; do - if test x$1 = x--debug; then - echo yes - return - fi - shift - done - echo no -} - -DEBUG=`checkdebug $@` -if test "x$DEBUG" = "xyes"; then - set -x - set -v -fi - -export COMMAND_DIR="`canonicalpath $0`" - -# Read the modules find part -. "$COMMAND_DIR/dunemodules.inc" - -# -# test version checks -# - -test_version_check () { - if ! check_version "$1" "$2"; then - echo "ERROR: version does not match (found $1, required $2)" >&2 - #exit 1 - else - echo "OK: version does match (found $1, required $2)" >&2 - fi -} - -test_version_check "1.2.3" ">= 1.2.5 || < 1.2.4" -test_version_check "1.2.4" ">= 1.2.5 || < 1.2.4" -test_version_check "1.2.5" ">= 1.2.5 || < 1.2.4" -test_version_check "1.2" ">= 1.2.5 || < 1.2.4" - -test_version_check "1.2.3" ">= 1.2.5 && < 1.2.4" -test_version_check "1.2.4" "< 1.2.5 && >= 1.2.4" - -test_version_check "1.2.3" ">= 1.2" -test_version_check "1.2.3" "= 2.4.1" -test_version_check "1.2.3" "= 1.2.3" -test_version_check "1.2.3" "> 1.2" -test_version_check "1.2.3" "= 1.2" -test_version_check "1.2.3" "< 1.2" - -check_pattern() -{ - PATTERN=$PARSE_SUGDEP_PATTERN -} - -parse_version() -{ - local deps="$1" - local name="" - local dep="" - local xdeps="" - echo start: $deps - while test -n "$deps"; do - PATTERN=$PARSE_SUGDEP_PATTERN - name=`echo $deps | sed -e "s/$PATTERN/\1/"` - ver=`echo $deps | sed -e "s/$PATTERN/\2/" -e 's/[()]//g'` - xdeps=`echo $deps | sed -e "s/$PATTERN/\3/"` - if test "$deps" = "$xdeps"; then - echo Error parsing dependency string \"$1\" - exit 1 - fi - deps=$xdeps - echo $name version $ver ... $deps - done - echo done -} - -parse_version "dune-common (>= 1.2), dune-istl (<999)" -parse_version "alf (12) bart()c" -parse_version "a b () c" diff -Nru dune-common-2.2.1/bin/xfail-compile-tests dune-common-2.5.2~20170808ga5c076ca/bin/xfail-compile-tests --- dune-common-2.2.1/bin/xfail-compile-tests 2008-09-24 20:41:36.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/bin/xfail-compile-tests 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -#!/bin/bash - -make compile_XFAIL diff -Nru dune-common-2.2.1/cmake/modules/AddGMPFlags.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddGMPFlags.cmake --- dune-common-2.2.1/cmake/modules/AddGMPFlags.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddGMPFlags.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,28 @@ +# Defines the functions to use GMP +# +# .. cmake_function:: add_dune_gmp_flags +# +# .. cmake_param:: targets +# :positional: +# :single: +# :required: +# +# A list of targets to use GMP with. +# + + +function(add_dune_gmp_flags _targets) + if(GMP_FOUND) + foreach(_target ${_targets}) + target_link_libraries(${_target} ${GMP_LIBRARIES}) + set_property(TARGET ${_target} + APPEND_STRING + PROPERTY COMPILE_FLAGS "-DENABLE_GMP=1 ") + foreach(_path ${GMP_INCLUDE_DIRS}) + set_property(TARGET ${_target} + APPEND_STRING + PROPERTY COMPILE_FLAGS "-I${_path}") + endforeach(_path ${GMP_INCLUDE_DIRS}) + endforeach(_target ${_targets}) + endif(GMP_FOUND) +endfunction(add_dune_gmp_flags) diff -Nru dune-common-2.2.1/cmake/modules/AddMETISFlags.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddMETISFlags.cmake --- dune-common-2.2.1/cmake/modules/AddMETISFlags.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddMETISFlags.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,22 @@ +# Defines the functions to use METIS +# +# .. cmake_function:: add_dune_metis_flags +# +# .. cmake_param:: targets +# :positional: +# :single: +# :required: +# +# A list of targets to use METIS with. +# + + +function(add_dune_metis_flags _targets) + if(METIS_FOUND) + foreach(_target ${_targets}) + target_link_libraries(${_target} ${METIS_LIBRARY}) + endforeach(_target ${_targets}) + set_property(TARGET ${_targets} APPEND PROPERTY + INCLUDE_DIRECTORIES "${METIS_INCLUDE_DIRS}") + endif(METIS_FOUND) +endfunction(add_dune_metis_flags _targets) diff -Nru dune-common-2.2.1/cmake/modules/AddParMETISFlags.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddParMETISFlags.cmake --- dune-common-2.2.1/cmake/modules/AddParMETISFlags.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddParMETISFlags.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,29 @@ +# Defines the functions to use ParMETIS +# +# .. cmake_function:: add_dune_parmetis_flags +# +# .. cmake_param:: targets +# :positional: +# :single: +# :required: +# +# A list of targets to use ParMETIS with. +# + + +function(add_dune_parmetis_flags _targets) + if(PARMETIS_FOUND) + foreach(_target ${_targets}) + target_link_libraries(${_target} ${PARMETIS_LIBRARY} ${METIS_LIBRARY}) + GET_TARGET_PROPERTY(_props ${_target} INCLUDE_DIRECTORIES) + string(REPLACE "_props-NOTFOUND" "" _props "${_props}") + SET_TARGET_PROPERTIES(${_target} PROPERTIES INCLUDE_DIRECTORIES + "${_props};${PARMETIS_INCLUDE_DIRS}") + GET_TARGET_PROPERTY(_props ${_target} COMPILE_DEFINITIONS) + string(REPLACE "_props-NOTFOUND" "" _props "${_props}") + SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_DEFINITIONS + "${_props};ENABLE_PARMETIS") + endforeach(_target ${_targets}) + add_dune_mpi_flags(${_targets}) + endif(PARMETIS_FOUND) +endfunction(add_dune_parmetis_flags) diff -Nru dune-common-2.2.1/cmake/modules/AddPTScotchFlags.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddPTScotchFlags.cmake --- dune-common-2.2.1/cmake/modules/AddPTScotchFlags.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddPTScotchFlags.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,29 @@ +# Defines the functions to use PTScotch +# +# .. cmake_function:: add_dune_ptscotch_flags +# +# .. cmake_param:: targets +# :positional: +# :single: +# :required: +# +# A list of targets to use PTScotch with. +# + + +function(add_dune_ptscotch_flags _targets) + if(PTSCOTCH_FOUND) + foreach(_target ${_targets}) + target_link_libraries(${_target} ${PTSCOTCH_LIBRARY} ${SCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY}) + GET_TARGET_PROPERTY(_props ${_target} INCLUDE_DIRECTORIES) + string(REPLACE "_props-NOTFOUND" "" _props "${_props}") + SET_TARGET_PROPERTIES(${_target} PROPERTIES INCLUDE_DIRECTORIES + "${_props};${PTSCOTCH_INCLUDE_DIRS}") + GET_TARGET_PROPERTY(_props ${_target} COMPILE_DEFINITIONS) + string(REPLACE "_props-NOTFOUND" "" _props "${_props}") + SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_DEFINITIONS + "${_props};") + endforeach(_target ${_targets}) + add_dune_mpi_flags(${_targets}) + endif(PTSCOTCH_FOUND) +endfunction(add_dune_ptscotch_flags) diff -Nru dune-common-2.2.1/cmake/modules/AddSuiteSparseFlags.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddSuiteSparseFlags.cmake --- dune-common-2.2.1/cmake/modules/AddSuiteSparseFlags.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddSuiteSparseFlags.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,23 @@ +# Defines the functions to use SuiteSparse +# +# .. cmake_function:: add_dune_suitesparse_flags +# +# .. cmake_param:: targets +# :positional: +# :single: +# :required: +# +# A list of targets to use SuiteSparse with. +# + +function(add_dune_suitesparse_flags _targets) + if(SuiteSparse_FOUND) + foreach(_target ${_targets}) + target_link_libraries(${_target} ${SuiteSparse_DUNE_LIBRARIES}) + get_target_property(_props ${_target} COMPILE_FLAGS) + string(REPLACE "_props-NOTFOUND" "" _props "${_props}") + set_target_properties(${_target} PROPERTIES COMPILE_FLAGS + "${_props} ${SuiteSparse_DUNE_COMPILE_FLAGS} -DENABLE_SUITESPARSE=1") + endforeach(_target ${_targets}) + endif(SuiteSparse_FOUND) +endfunction(add_dune_suitesparse_flags) diff -Nru dune-common-2.2.1/cmake/modules/AddUMFPackFlags.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddUMFPackFlags.cmake --- dune-common-2.2.1/cmake/modules/AddUMFPackFlags.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddUMFPackFlags.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,24 @@ +# Defines the functions to use UMFPack +# +# .. cmake_function:: add_dune_umfpack_flags +# +# .. cmake_param:: targets +# :positional: +# :single: +# :required: +# +# A list of targets to use UMFPack with. +# + + +function(add_dune_umfpack_flags _targets) + if(UMFPACK_FOUND) + foreach(_target ${_targets}) + target_link_libraries(${_target} ${UMFPACK_DUNE_LIBRARIES}) + get_target_property(_props ${_target} COMPILE_FLAGS) + string(REPLACE "_props-NOTFOUND" "" _props "${_props}") + set_target_properties(${_target} PROPERTIES COMPILE_FLAGS + "${_props} ${UMFPACK_DUNE_COMPILE_FLAGS} -DENABLE_UMFPACK") + endforeach(_target ${_targets}) + endif(UMFPACK_FOUND) +endfunction(add_dune_umfpack_flags) diff -Nru dune-common-2.2.1/cmake/modules/AddVcFlags.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddVcFlags.cmake --- dune-common-2.2.1/cmake/modules/AddVcFlags.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/AddVcFlags.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,31 @@ +# Defines the functions to use Vc +# +# Vc is a library for high-level Vectorization support in C++ +# see https://github.com/VcDevel/Vc +# +# .. cmake_function:: add_dune_vc_flags +# +# .. cmake_param:: targets +# :positional: +# :single: +# :required: +# +# A list of targets to use VC with. +# + +function(add_dune_vc_flags _targets) + if(Vc_FOUND) + foreach(_target ${_targets}) + target_link_libraries(${_target} ${Vc_LIBRARIES}) + target_compile_options(${_target} PUBLIC ${Vc_ALL_FLAGS}) + target_include_directories(${_target} SYSTEM PUBLIC ${Vc_INCLUDE_DIR}) + endforeach(_target ${_targets}) + endif(Vc_FOUND) +endfunction(add_dune_vc_flags) + +if(Vc_FOUND) + dune_register_package_flags(COMPILE_OPTIONS "${Vc_ALL_FLAGS}" + LIBRARIES "${Vc_LIBRARIES}" + INCLUDE_DIRS "${Vc_INCLUDE_DIR}") +endif(Vc_FOUND) +set(HAVE_VC ${Vc_FOUND}) diff -Nru dune-common-2.2.1/cmake/modules/CheckCXXFeatures.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/CheckCXXFeatures.cmake --- dune-common-2.2.1/cmake/modules/CheckCXXFeatures.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/CheckCXXFeatures.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,408 @@ +# .. cmake_module:: +# +# Module that checks for supported C++14, C++11 and non-standard features. +# +# The behaviour of this module can be modified by the following variable: +# +# :ref:`DISABLE_CXX_VERSION_CHECK` +# Disable checking for std=c++11 (c++14, c++1y) +# +# This module internally sets the following variables, which are then +# exported into the config.h of the current dune module. +# +# :code:`HAS_ATTRIBUTE_UNUSED` +# True if attribute unused is supported +# +# :code:`HAS_ATTRIBUTE_DEPRECATED` +# True if attribute deprecated is supported +# +# :code:`HAS_ATTRIBUTE_DEPRECATED_MSG` +# True if attribute deprecated("msg") is supported +# +# .. cmake_variable:: DISABLE_CXX_VERSION_CHECK +# +# You may set this variable to TRUE to disable checking for +# std=c++11 (c++14, c++1y). For more details, check :ref:`CheckCXXFeatures`. +# + + +include(CMakePushCheckState) +include(CheckCXXCompilerFlag) +include(CheckCXXSourceCompiles) + +# C++ standard versions that this test knows about +set(CXX_VERSIONS 17 14 11) + + +# Compile tests for the different standard revisions; these test both the compiler +# and the associated library to avoid problems like using a C++14 user-installed +# compiler together with a non C++14-compliant stdlib from the system compiler. + +# we need to escape semicolons in the tests to be able to stick them into a list +string(REPLACE ";" "\;" cxx_17_test + " + #include + + // nested namespaces are a C++17 compiler feature + namespace A::B { + using T = int; + } + + int main() { + // std::void_t is a C++17 library feature + return not std::is_same >{}; + } + ") + +string(REPLACE ";" "\;" cxx_14_test + " + #include + + int main() { + // lambdas with auto parameters are C++14 - so this checks the compiler + auto l = [](auto x) { return x; }; + // std::make_unique() is a C++14 library feature - this checks whether the + // compiler uses a C++14 compliant library. + auto v = std::make_unique(l(0)); + return *v; + } + ") + +string(REPLACE ";" "\;" cxx_11_test + " + #include + + int main() { + // this checks both the compiler (by using auto) and the library (by using + // std::make_shared() for C++11 compliance at GCC 4.4 level. + auto v = std::make_shared(0); + return *v; + } + ") + +# build a list out of the pre-escaped tests +set(CXX_VERSIONS_TEST "${cxx_17_test}" "${cxx_14_test}" "${cxx_11_test}") + +# these are appended to "-std=c++" and tried in this order +# note the escaped semicolons; that's necessary to create a nested list +set(CXX_VERSIONS_FLAGS "17\;1z" "14\;1y" "11\;0x") + +# by default, we enable C++14 for now, but not C++17 +# The user can override this choice by explicitly setting this variable +set(CXX_MAX_STANDARD 14 CACHE STRING "highest version of the C++ standard to enable") + + +function(dune_require_cxx_standard) + include(CMakeParseArguments) + + cmake_parse_arguments("" "" "MODULE;VERSION" "" ${ARGN}) + + if(_UNPARSED_ARGUMENTS) + message(WARNING "Unknown arguments in call to dune_require_cxx_standard(${ARGN})") + endif() + + if(${_VERSION} GREATER ${CXX_MAX_SUPPORTED_STANDARD}) + + if(NOT _MODULE) + set(_MODULE "This module") + endif() + + if(${_VERSION} GREATER ${CXX_MAX_STANDARD}) + message(FATAL_ERROR "\ +${_MODULE} requires compiler support for C++${_VERSION}, but the build system is currently \ +set up to not allow newer language standards than C++${CXX_MAX_STANDARD}. Try setting the \ +CMake variable CXX_MAX_STANDARD to at least ${_VERSION}." + ) + else() + message(FATAL_ERROR " +${_MODULE} requires compiler support for C++${_VERSION}, but your compiler only supports \ +C++${CXX_MAX_SUPPORTED_STANDARD}." + ) + endif() + endif() +endfunction() + + +# try to enable all of the C++ standards that we know about, in descending order +if(NOT DISABLE_CXX_VERSION_CHECK) + + foreach(version ${CXX_VERSIONS}) + + # skip versions that are newer than allowed + if(NOT(version GREATER CXX_MAX_STANDARD)) + + list(FIND CXX_VERSIONS ${version} version_index) + list(GET CXX_VERSIONS_FLAGS ${version_index} version_flags) + + # First try whether the compiler accepts one of the command line flags for this standard + foreach(flag ${version_flags}) + + set(cxx_std_flag_works "cxx_std_flag_${flag}") + check_cxx_compiler_flag("-std=c++${flag}" ${cxx_std_flag_works}) + + if(${cxx_std_flag_works}) + set(cxx_std_flag "-std=c++${flag}") + break() + endif() + + endforeach() + + # and if it did, run the compile test + if(cxx_std_flag) + + list(GET CXX_VERSIONS_TEST ${version_index} version_test) + set(test_compiler_output "compiler_supports_cxx${version}") + + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${cxx_std_flag}") + check_cxx_source_compiles("${version_test}" ${test_compiler_output}) + cmake_pop_check_state() + + if(${test_compiler_output}) + set(CXX_MAX_SUPPORTED_STANDARD ${version}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_std_flag} ") + break() + else() + # Wipe the variable, as this version of the standard doesn't seem to work + unset(cxx_std_flag) + endif() + + endif() + endif() + endforeach() + + if(NOT DEFINED CXX_MAX_SUPPORTED_STANDARD) + # Let's just assume every compiler at least claims C++03 compliance by now + message(WARNING "\ +Unable to determine C++ standard support for your compiler, falling back to C++03. \ +If you know that your compiler supports a newer version of the standard, please set the CMake \ +variable DISABLE_CXX_VERSION_CHECK to true and the CMake variable CXX_MAX_SUPPORTED_STANDARD \ +to the highest version of the standard supported by your compiler (e.g. 14). If your compiler \ +needs custom flags to switch to that standard version, you have to manually add them to \ +CMAKE_CXX_FLAGS." + ) + set(CXX_MAX_SUPPORTED_STANDARD 3) + endif() + +endif() + +# make sure we have at least C++11 +dune_require_cxx_standard(MODULE "DUNE" VERSION 11) + +# perform tests + +# __attribute__((unused)) +check_cxx_source_compiles(" + int main(void) + { + int __attribute__((unused)) foo; + return 0; + }; +" HAS_ATTRIBUTE_UNUSED +) + +# __attribute__((deprecated)) +check_cxx_source_compiles(" +#define DEP __attribute__((deprecated)) + class bar + { + bar() DEP; + }; + + class peng { } DEP; + + template + class t_bar + { + t_bar() DEP; + }; + + template + class t_peng { + t_peng() {}; + } DEP; + + void foo() DEP; + + void foo() {} + + int main(void) + { + return 0; + }; +" HAS_ATTRIBUTE_DEPRECATED +) + +# __attribute__((deprecated("msg"))) +check_cxx_source_compiles(" +#define DEP __attribute__((deprecated(\"message\"))) + class bar { + bar() DEP; + }; + + class peng { } DEP; + + template + class t_bar + { + t_bar() DEP; + }; + + template + class t_peng + { + t_peng() {}; + } DEP; + + void foo() DEP; + + void foo() {} + + int main(void) + { + return 0; + }; +" HAS_ATTRIBUTE_DEPRECATED_MSG +) + +# full support for is_indexable (checking whether a type supports operator[]) +check_cxx_source_compiles(" + #include + #include + #include + + template + typename std::add_rvalue_reference::type declval(); + + namespace detail { + + template + struct _is_indexable + : public std::false_type + {}; + + template + struct _is_indexable()[declval()]) > 0),int>::type> + : public std::true_type + {}; + + } + + template + struct is_indexable + : public detail::_is_indexable + {}; + + struct foo_type {}; + + int main() + { + double x; + std::array y; + double z[5]; + foo_type f; + + static_assert(not is_indexable::value,\"scalar type\"); + static_assert(is_indexable::value,\"indexable class\"); + static_assert(is_indexable::value,\"array\"); + static_assert(not is_indexable::value,\"not indexable class\"); + static_assert(not is_indexable::value,\"custom index type\"); + + return 0; + } +" HAVE_IS_INDEXABLE_SUPPORT + ) + + +# find the threading library +# Use a copy FindThreads from CMake 3.1 due to its support of pthread +if(NOT DEFINED THREADS_PREFER_PTHREAD_FLAG) + set(THREADS_PREFER_PTHREAD_FLAG 1) +endif() +if(${CMAKE_VERSION} VERSION_LESS "3.1") + find_package(ThreadsCMake31) +else() + find_package(Threads) +endif() + +# see whether threading needs -no-as-needed +if(EXISTS /etc/dpkg/origins/ubuntu) + set(NO_AS_NEEDED "-Wl,-no-as-needed ") +else(EXISTS /etc/dpkg/origins/ubuntu) + set(NO_AS_NEEDED "") +endif(EXISTS /etc/dpkg/origins/ubuntu) + +set(STDTHREAD_LINK_FLAGS "${NO_AS_NEEDED}${CMAKE_THREAD_LIBS_INIT}" + CACHE STRING "Linker flags needed to get working C++11 threads support. On Ubuntu it may be necessary to include -Wl,-no-as-needed (see FS#1650).") + +# set linker flags +# +# in all implementations I know it is sufficient to set the linker flags when +# linking the final executable, so this should work. In cmake, this appears +# to only work when building the project however, not for later config tests +# (contrary to CMAKE_CXX_FLAGS). Luckily, later tests don't seem to use any +# threading... (except for our own sanity check) +if(NOT STDTHREAD_LINK_FLAGS STREQUAL "") + #set(vars CMAKE_EXE_LINKER_FLAGS ${CMAKE_CONFIGURATION_TYPES}) + # CMAKE_CONFIGURATION_TYPES seems to be empty. Use the configurations from + # adding -std=c++11 above instead. + set(vars CMAKE_EXE_LINKER_FLAGS DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) + string(REPLACE ";" ";CMAKE_EXE_LINKER_FLAGS_" vars "${vars}") + string(TOUPPER "${vars}" vars) + foreach(var ${vars}) + if(NOT var STREQUAL "") + set(${var} "${${var}} ${STDTHREAD_LINK_FLAGS}") + endif() + endforeach(var ${vars}) +endif(NOT STDTHREAD_LINK_FLAGS STREQUAL "") + +include(CheckCXXSourceRuns) +# check that the found configuration works +if(CMAKE_CROSSCOMPILING) + message(WARNING "Crosscompiling, cannot run test program to see whether " + "std::thread works. Assuming that the found configuration does indeed " + "work.") +endif(CMAKE_CROSSCOMPILING) + +if(NOT DEFINED STDTHREAD_WORKS) + if(NOT CMAKE_CROSSCOMPILING) + # The value is not in the cache, so run check + cmake_push_check_state() + # tests seem to ignore CMAKE_EXE_LINKER_FLAGS + set(CMAKE_REQUIRED_LIBRARIES "${STDTHREAD_LINK_FLAGS} ${CMAKE_REQUIRED_LIBRARIES}") + check_cxx_source_runs(" + #include + + void dummy() {} + + int main() { + std::thread t(dummy); + t.join(); + } + " STDTHREAD_WORKS) + cmake_pop_check_state() + endif(NOT CMAKE_CROSSCOMPILING) + # put the found value into the cache. Put it there even if we're + # cross-compiling, so the user can find it. Use FORCE: + # check_cxx_source_runs() already puts the value in the cache but without + # documentation; also the "if(NOT DEFINED STDTHREAD_WORKS)" will prevent us + # from overwriting a value set by the user. + set(STDTHREAD_WORKS "${STDTHREAD_WORKS}" + CACHE BOOL "Whether std::thread works." FORCE) +endif(NOT DEFINED STDTHREAD_WORKS) + +if(NOT STDTHREAD_WORKS) + # Working C++11 threading support is required for dune. In particular to + # make things like lazyly initialized caches thread safe + # (e.g. QuadratureRules::rule(), which needs std::call_once()). If we don't + # include the correct options during linking, there will be very funny + # errors at runtime, ranging from segfaults to + # + # terminate called after throwing an instance of 'std::system_error' + # what(): Unknown error 18446744073709551615 + message(FATAL_ERROR "Your system does not seem to have a working " + "implementation of std::thread. If it does, please set the linker flags " + "required to get std::thread working in the cache variable " + "STDTHREAD_LINK_FLAGS. If you think this test is wrong, set the cache " + "variable STDTHREAD_WORKS.") +endif(NOT STDTHREAD_WORKS) diff -Nru dune-common-2.2.1/cmake/modules/CheckForPthreads.c dune-common-2.5.2~20170808ga5c076ca/cmake/modules/CheckForPthreads.c --- dune-common-2.2.1/cmake/modules/CheckForPthreads.c 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/CheckForPthreads.c 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,41 @@ +// file copied from CMake 3.2.1, +// remove together with FindThreadsCMake31.cmake + +#include +#include +#include + +void* runner(void*); + +int res = 0; +#ifdef __CLASSIC_C__ +int main(){ + int ac; + char*av[]; +#else +int main(int ac, char*av[]){ +#endif + pthread_t tid[2]; + pthread_create(&tid[0], 0, runner, (void*)1); + pthread_create(&tid[1], 0, runner, (void*)2); + +#if defined(__BEOS__) && !defined(__ZETA__) // (no usleep on BeOS 5.) + usleep(1); // for strange behavior on single-processor sun +#endif + + pthread_join(tid[0], 0); + pthread_join(tid[1], 0); + if(ac > 1000){return *av[0];} + return res; +} + +void* runner(void* args) +{ + int cc; + for ( cc = 0; cc < 10; cc ++ ) + { + printf("%d CC: %d\n", (int)args, cc); + } + res ++; + return 0; +} diff -Nru dune-common-2.2.1/cmake/modules/CMakeBuiltinFunctionsDocumentation.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/CMakeBuiltinFunctionsDocumentation.cmake --- dune-common-2.2.1/cmake/modules/CMakeBuiltinFunctionsDocumentation.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/CMakeBuiltinFunctionsDocumentation.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,83 @@ +# This modules contains only documentation for CMake builtins. +# This is necessary to have an complete API documentation. +# +# .. cmake_function:: add_subdirectory +# +# .. cmake_param:: dir +# :single: +# :positional: +# :required: +# +# The :code:`CMakeLists.txt` file from this subdirectory +# will be executed next. +# +# .. cmake_param:: EXCLUDE_FROM_ALL +# :option: +# +# Whether targets added in this subdirectory should be built +# during :code:`make all`. +# +# This is a cmake builtin command. +# For detailed information, check the cmake documentation: +# +# :: +# +# cmake --help-command add_subdirectory +# +# .. cmake_function:: install +# +# Define installation rules to customize the behaviour of :code:`make install`. +# +# This is a cmake builtin command. +# For detailed information, check the cmake documentation: +# +# :: +# +# cmake --help-command install +# +# .. cmake_function:: add_executable +# +# Adds an executable to the project. +# +# This is a cmake builtin command. +# For detailed information, check the cmake documentation: +# +# :: +# +# cmake --help-command add_executable +# +# .. cmake_variable:: CMAKE__COMPILER +# +# Set the compiler for the language LANG. +# LANG is in our case out of C, CXX. +# +# This is a cmake builtin variable. +# For detailed information, check the cmake documentation: +# +# :: +# +# cmake --help-variable CMAKE_\_COMPILER +# +# .. cmake_variable:: CMAKE__FLAGS +# +# Set the compile flags for the language LANG. +# LANG is in our case out of C, CXX. +# +# This is a cmake builtin variable. +# For detailed information, check the cmake documentation: +# +# :: +# +# cmake --help-variable CMAKE_\_FLAGS +# +# .. cmake_function:: find_package +# +# Look for an external package. +# +# This is a cmake builtin command. +# For detailed information, check the cmake documentation: +# +# :: +# +# cmake --help-command find_package +# diff -Nru dune-common-2.2.1/cmake/modules/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/cmake/modules/CMakeLists.txt --- dune-common-2.2.1/cmake/modules/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,47 @@ +install(FILES + AddGMPFlags.cmake + AddMETISFlags.cmake + AddParMETISFlags.cmake + AddPTScotchFlags.cmake + AddSuiteSparseFlags.cmake + AddUMFPackFlags.cmake + AddVcFlags.cmake + CheckCXXFeatures.cmake + CheckForPthreads.c + CMakeBuiltinFunctionsDocumentation.cmake + DuneCommonMacros.cmake + DuneCxaDemangle.cmake + DuneDoc.cmake + DuneDoxygen.cmake + DuneEnableAllPackages.cmake + DuneExecuteProcess.cmake + DuneMacros.cmake + DuneMPI.cmake + DunePathHelper.cmake + DunePkgConfig.cmake + DunePythonCommonMacros.cmake + DunePythonFindPackage.cmake + DunePythonInstallPackage.cmake + DunePythonRequireVersion.cmake + DunePythonTestCommand.cmake + DunePythonVirtualenv.cmake + DuneSphinxCMakeDoc.cmake + DuneStreams.cmake + DuneSymlinkOrCopy.cmake + DuneTestMacros.cmake + FindGMP.cmake + FindInkscape.cmake + FindMETIS.cmake + FindMProtect.cmake + FindParMETIS.cmake + FindPTScotch.cmake + FindSphinx.cmake + FindSuiteSparse.cmake + FindThreadsCMake31.cmake + FindUMFPack.cmake + Headercheck.cmake + LanguageSupport.cmake + OverloadCompilerFlags.cmake + UseInkscape.cmake + UseLATEX.cmake + DESTINATION ${DUNE_INSTALL_MODULEDIR}) diff -Nru dune-common-2.2.1/cmake/modules/DuneCommonMacros.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneCommonMacros.cmake --- dune-common-2.2.1/cmake/modules/DuneCommonMacros.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneCommonMacros.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,37 @@ +# .. cmake_module:: +# +# This modules content is executed whenever a module required or suggests dune-common! +# + +# enforce C++-14 +dune_require_cxx_standard(MODULE "dune-common" VERSION 14) + +include(DuneStreams) +dune_set_minimal_debug_level() + +if(Fortran_Works) + # search for lapack + find_package(LAPACK) + set(HAVE_LAPACK ${LAPACK_FOUND}) + if(${HAVE_LAPACK}) + dune_register_package_flags(LIBRARIES "${LAPACK_LIBRARIES}") + endif(${HAVE_LAPACK}) + set(HAVE_BLAS ${BLAS_FOUND}) +else(Fortran_Works) + set(HAVE_LAPACK Off) + set(HAVE_BLAS Off) +endif(Fortran_Works) + +find_package(GMP) +include(AddGMPFlags) +find_package(Inkscape) +include(UseInkscape) +include(FindMProtect) + +# try to find the Vc library +find_package(Vc) +include(AddVcFlags) +set_package_info("Vc" "C++ Vectorization library" "https://github.com/VcDevel/Vc") + +# Run the python extension of the Dune cmake build system +include(DunePythonCommonMacros) diff -Nru dune-common-2.2.1/cmake/modules/DuneCxaDemangle.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneCxaDemangle.cmake --- dune-common-2.2.1/cmake/modules/DuneCxaDemangle.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneCxaDemangle.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,17 @@ +# This Module checks whether the compiler supports the +# abi::__cxa_demangle function required to +# make the type names returned by typeid() human-readable +# +# It sets the a variable :code:`HAVE_CXA_DEMANGLE` with the result. +# + +include(CheckCXXSourceCompiles) + +CHECK_CXX_SOURCE_COMPILES("#include +#include +int main(void){ + int foobar = 0; + const char *foo = typeid(foobar).name(); + int status; + char *demangled = abi::__cxa_demangle( foo, 0, 0, &status ); +}" HAVE_CXA_DEMANGLE) diff -Nru dune-common-2.2.1/cmake/modules/DuneDoc.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneDoc.cmake --- dune-common-2.2.1/cmake/modules/DuneDoc.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneDoc.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,161 @@ +# +# Module that provides a custom target make doc at the top level +# directory and utility macros for creating install directives +# that make sure that the files to be installed are previously +# generated even if make doc was not called. +# +# All documentation (Latex, Doxygen) will be generated during +# make doc. +# It provides the following macros: +# +# .. cmake_function:: dune_add_latex_document +# +# .. cmake_brief:: +# +# build a pdf document through the Dune build system. +# +# .. cmake_param:: texfile +# :single: +# :required: +# :positional: +# +# The texfile to compile into a pdf. +# +# .. note:: +# +# This function will be rewritten for Dune 3.0 as it currently +# shadows all options provided by the base implementation +# :code:`add_latex_document`. +# +# .. cmake_function:: create_doc_install +# +# .. cmake_brief:: +# +# creates a target for creating and installing a file +# to a given directory. +# +# .. cmake_param:: filename +# :single: +# :required: +# :positional: +# +# The name of the file to be installed. +# +# .. cmake_param:: targetdir +# :single: +# :required: +# :positional: +# +# The directory into which the beforementioned file will be installed. +# +# .. cmake_param:: dependency +# :single: +# :required: +# :positional: +# +# A target that gets called to create the file that will be installed. +# +# .. note:: +# +# This macro is needed, as we cannot add dependencies to the install +# target. See https://gitlab.kitware.com/cmake/cmake/issues/8438 +# and https://gitlab.dune-project.org/core/dune-common/issues/36 +# + +find_package(LATEX) +find_program(IMAGEMAGICK_CONVERT convert + DOC "The convert program that comes with ImageMagick (available at http://www.imagemagick.org)." + ) +set(LATEX_USABLE TRUE) + +# UseLATEX.cmake does only work in out-of-source builds +if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + message(WARNING "In-source detected, disabling LaTeX documentation. Use an out-of-source build to generate documentation.") + set(LATEX_USABLE FALSE) +endif() +# check needed LaTeX executables +if(NOT LATEX_COMPILER) + message(WARNING " Need latex to create documentation!") + set(LATEX_USABLE FALSE) +endif() +if(NOT BIBTEX_COMPILER) + message(WARNING " Need bibtex to create documentation!") + set(LATEX_USABLE FALSE) +endif() +if(NOT MAKEINDEX_COMPILER) + message(WARNING " Need makeindex to create documentation!") + set(LATEX_USABLE FALSE) +endif() +if(NOT IMAGEMAGICK_CONVERT) + message(WARNING " Need imagemagick to create latex documentation!") + set(LATEX_USABLE FALSE) +endif() +if(LATEX_USABLE) + include(UseLATEX) +endif() + +add_custom_target(doc) + +# add the Sphinx-generated build system documentation +include(DuneSphinxCMakeDoc) +# Support building documentation with doxygen. +include(DuneDoxygen) + +macro(create_doc_install filename targetdir dependency) + dune_module_path(MODULE dune-common RESULT scriptdir SCRIPT_DIR) + get_filename_component(targetfile ${filename} NAME) + set(install_command ${CMAKE_COMMAND} -D FILES=${filename} -D DIR=${CMAKE_INSTALL_PREFIX}/${targetdir} -P ${scriptdir}/InstallFile.cmake) + # create a custom target for the installation + add_custom_target(install_${targetfile} ${install_command} + COMMENT "Installing ${filename} to ${targetdir}" + DEPENDS ${dependency}) + # When installing, call cmake install with the above install target and add the file to install_manifest.txt + install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --target install_${targetfile} ) + LIST(APPEND CMAKE_INSTALL_MANIFEST_FILES ${CMAKE_INSTALL_PREFIX}/${targetdir}/${targetfile})") +endmacro(create_doc_install) + + +macro(dune_add_latex_document tex_file) + set(latex_arguments "${ARGN}") + # replace old DEFAULT_SAFEPDF by FORCE_DVI and emit warning + # this compatibility code can be removed after Dune 3.0 + list(FIND latex_arguments DEFAULT_SAFEPDF position_safepdf) + if(NOT position_safepdf EQUAL -1) + list(REMOVE_AT latex_arguments ${position_safepdf}) + list(APPEND latex_arguments FORCE_DVI) + message(WARNING "dune_add_latex_document's argument DEFAULT_SAFEPDF is deprecated, use FORCE_DVI instead") + endif() + # replace old DEFAULT_PDF and emit warning + # this compatibility code can be removed after Dune 3.0 + list(FIND latex_arguments DEFAULT_PDF position_defaultpdf) + if(NOT position_defaultpdf EQUAL -1) + list(REMOVE_AT latex_arguments ${position_defaultpdf}) + message(WARNING "dune_add_latex_document's argument DEFAULT_PDF is deprecated, just drop it") + endif() + # remove old argument FATHER_TARGET which is dropped and handled by an automatism now + # this compatibility code can be removed after Dune 3.0 + list(FIND latex_arguments FATHER_TARGET position_fathertarget) + if(NOT position_fathertarget EQUAL -1) + list(REMOVE_AT latex_arguments ${position_fathertarget}) + # father has an according argument trailing which is removed, too + list(REMOVE_AT latex_arguments ${position_fathertarget}) + message(WARNING "dune_add_latex_document's argument FATHER_TARGET is deprecated, this is handled automatically now") + endif() + + if(LATEX_USABLE) + # add rule to create latex document + add_latex_document(${tex_file} ${latex_arguments} + EXCLUDE_FROM_ALL + EXCLUDE_FROM_DEFAULTS) + # add tependency for target doc, but first construct document's target name + string(REGEX REPLACE "(.+).tex" "\\1" tex_file_base_name ${tex_file}) + list(FIND latex_arguments FORCE_DVI has_forcedvi) + if(has_forcedvi EQUAL -1) + add_dependencies(doc "${tex_file_base_name}") + else() + add_dependencies(doc "${tex_file_base_name}_safepdf") + endif() + else() + message(WARNING "Not adding rule to create ${file} as LaTeX is not usable!") + endif() +endmacro(dune_add_latex_document tex_file) diff -Nru dune-common-2.2.1/cmake/modules/DuneDoxygen.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneDoxygen.cmake --- dune-common-2.2.1/cmake/modules/DuneDoxygen.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneDoxygen.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,119 @@ +# Module for building documentation using doxygen. +# +# .. cmake_function:: add_doxygen_target +# +# .. cmake_param:: TARGET +# :single: +# +# The suffix to add to the target name, default to the module name. +# +# .. cmake_param:: DEPENDS +# :multi: +# +# A list of further dependencies of the doxygen documentation. +# Might include :code:`mainpage.txt`. +# +# .. cmake_param:: OUTPUT +# :single: +# +# Name of the output target, necessary if you don't generate html. +# +# This macro creates a target for building (:code:`doxygen_${ProjectName}`) and installing +# (:code:`doxygen_install_${ProjectName}`) the generated doxygen documentation. +# The documentation is built during the top-level :code:`make doc` call. We have added a dependency +# that makes sure it is built before running :code:`make install`. +# + +find_package(Doxygen) +include(CMakeParseArguments) + +# Set DOT_TRUE for the Doxyfile generation. +if (NOT DOXYGEN_DOT_FOUND) + set(DOT_TRUE '\#') +endif() + +add_custom_target(doxygen_install) + +# +# prepare_doxyfile() +# This functions adds the necessary routines for the generation of the +# Doxyfile[.in] files needed to doxygen. +macro(prepare_doxyfile) + message(STATUS "using ${DOXYSTYLE_FILE} to create doxystyle file") + + # check whether module has a Doxylocal file + find_file(_DOXYLOCAL Doxylocal PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH) + + if(_DOXYLOCAL) + set(make_doxyfile_command ${CMAKE_COMMAND} -D DOT_TRUE=${DOT_TRUE} -D DUNE_MOD_NAME=${ProjectName} -D DUNE_MOD_VERSION=${ProjectVersion} -D DOXYSTYLE=${DOXYSTYLE_FILE} -D DOXYLOCAL=${CMAKE_CURRENT_SOURCE_DIR}/Doxylocal -D abs_top_srcdir=${CMAKE_SOURCE_DIR} -D srcdir=${CMAKE_CURRENT_SOURCE_DIR} -D top_srcdir=${CMAKE_SOURCE_DIR} -P ${scriptdir}/CreateDoxyFile.cmake) + add_custom_command(OUTPUT Doxyfile.in Doxyfile + COMMAND ${make_doxyfile_command} + COMMENT "Creating Doxyfile.in" + DEPENDS ${DOXYSTYLE_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxylocal) + else() + set(make_doxyfile_command ${CMAKE_COMMAND} -D DOT_TRUE=${DOT_TRUE} -D DUNE_MOD_NAME=${ProjectName} -D DUNE_MOD_VERSION=${DUNE_MOD_VERSION} -D DOXYSTYLE=${DOXYSTYLE_FILE} -D abs_top_srcdir=${CMAKE_SOURCE_DIR} -D top_srcdir=${CMAKE_SOURCE_DIR} -P ${scriptdir}/CreateDoxyFile.cmake) + add_custom_command(OUTPUT Doxyfile.in Doxyfile + COMMAND ${make_doxyfile_command} + COMMENT "Creating Doxyfile.in" + DEPENDS ${DOXYSTYLE_FILE}) + endif() + add_custom_target(doxyfile DEPENDS Doxyfile.in Doxyfile) +endmacro(prepare_doxyfile) + +macro(add_doxygen_target) + set(options ) + set(oneValueArgs TARGET OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(DOXYGEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + # default target name is the module name + if(NOT DOXYGEN_TARGET) + set(DOXYGEN_TARGET ${ProjectName}) + endif() + + # default output is html + if(NOT DOXYGEN_OUTPUT) + set(DOXYGEN_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html") + endif() + + dune_module_path(MODULE dune-common RESULT scriptdir SCRIPT_DIR) + if("${CMAKE_PROJECT_NAME}" STREQUAL "dune-common") + set(DOXYSTYLE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Doxystyle) + endif() + message(STATUS "Using scripts from ${scriptdir} for creating doxygen stuff.") + + if(DOXYGEN_FOUND) + prepare_doxyfile() + # custom command that executes doxygen + add_custom_command(OUTPUT ${DOXYGEN_OUTPUT} + COMMAND ${CMAKE_COMMAND} -D DOXYGEN_EXECUTABLE=${DOXYGEN_EXECUTABLE} -P ${scriptdir}/RunDoxygen.cmake + COMMENT "Running doxygen documentation. This may take a while" + DEPENDS Doxyfile.in ${DOXYGEN_DEPENDS}) + # Create a target for building the doxygen documentation of a module, + # that is run during make doc + add_custom_target(doxygen_${DOXYGEN_TARGET} + DEPENDS ${DOXYGEN_OUTPUT}) + add_dependencies(doc doxygen_${DOXYGEN_TARGET}) + endif() + + # Use a cmake call to install the doxygen documentation and create a + # target for it + include(GNUInstallDirs) + # When installing call cmake install with the above install target + install(CODE + "execute_process(COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target doxygen_${ProjectName} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + file(GLOB doxygenfiles + GLOB ${CMAKE_CURRENT_BINARY_DIR}/html/*.html + ${CMAKE_CURRENT_BINARY_DIR}/html/*.js + ${CMAKE_CURRENT_BINARY_DIR}/html/*.png + ${CMAKE_CURRENT_BINARY_DIR}/html/*.css + ${CMAKE_CURRENT_BINARY_DIR}/html/*.gif) + set(doxygenfiles \"\${doxygenfiles}\") + foreach(_file \${doxygenfiles}) + get_filename_component(_basename \${_file} NAME) + LIST(APPEND CMAKE_INSTALL_MANIFEST_FILES ${CMAKE_INSTALL_FULL_DOCDIR}/doxygen/\${_basename}) + endforeach() + file(INSTALL \${doxygenfiles} DESTINATION ${CMAKE_INSTALL_FULL_DOCDIR}/doxygen) + message(STATUS \"Installed doxygen into ${CMAKE_INSTALL_FULL_DOCDIR}/doxygen\")") +endmacro(add_doxygen_target) diff -Nru dune-common-2.2.1/cmake/modules/DuneEnableAllPackages.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneEnableAllPackages.cmake --- dune-common-2.2.1/cmake/modules/DuneEnableAllPackages.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneEnableAllPackages.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,368 @@ +# Implementation of a simplified CMake build system. +# +# .. cmake_function:: dune_enable_all_packages +# +# .. cmake_brief:: +# +# Previously, the DUNE build system relied on the user to choose and add the compile and link flags +# necessary to build an executable. While this offers full control to the user, it +# is an error-prone procedure. +# +# Alternatively, users may use this function to simply add the compile flags for all +# found external modules to all executables in a DUNE module. Likewise, all found libraries are +# linked to all targets. +# +# .. cmake_param:: INCLUDE_DIRS +# :multi: +# +# A list of include directories, that should be added to all targets. +# In a standard Dune module, it is not necessary to specify anything. +# +# .. cmake_param:: COMPILE_DEFINITIONS +# :multi: +# +# A list of compile definitions, that should be added to all targets. +# In a standard Dune module, it is not necessary to specify anything. +# +# .. cmake_param:: COMPILE_OPTIONS +# :multi: +# +# A list of non-definition compile options, that should be added to all targets. +# In a standard Dune module, it is not necessary to specify anything. +# +# .. cmake_param:: MODULE_LIBRARIES +# :multi: +# +# If your module contains libraries as well as programs and if the programs should automatically +# link to those libraries, you *MUST* list these libraries in :code:`MODULE_LIBRARIES`. Those libraries will be +# automatically created by :ref:`dune_enable_all_packages` (which internally calls :ref:`dune_add_library`) and placed +# in the lib/ directory. The order of the libraries matters: if one library depends on another one, it must +# be listed after its dependency. This special handling of the libraries is due to the way newer CMake +# versions handle linking (in particular CMP022 and CMP038). You can later add source files to the library +# anywhere in the source tree by calling :ref:`dune_library_add_sources`. +# +# .. warning:: +# The library feature requires CMake 3.1+. If you use the feature with older versions, CMake +# will emit a fatal error. Moreover, it will issue a warning if the :code:`cmake_minimum_required` +# version is older than 3.1. +# +# .. cmake_param:: VERBOSE +# :option: +# +# If this option is set, the set of compile flags, linked libraries and include directories +# that is in use for all targets in the module is printed upon configuration. +# +# .. cmake_param:: APPEND +# :option: +# +# If this option is set, the definitions, flags and directories specified in this function are +# appended to the global collection of flags instead of being prepended. Only use it, if you know +# what you are doing. +# +# Adds all flags and all libraries to all executables that are subsequently added in the directory +# from where this function is called and from all its subdirectories (recursively). +# If used, this function *MUST* be called in the top level CMakeLists.txt BEFORE adding any subdirectories! +# You can optionally add additional include dirs and compile definitions that will also be applied to +# all targets in the module. +# +# .. note:: +# If you want to use :code:`dune_enable_all_packages` with an older version of CMake and your DUNE module +# creates its own library, you have to manually create the library in the top-level CMakeLists.txt +# file using :ref:`dune_add_library` (with all sources listed within that call), use +# :ref:`dune_target_enable_all_packages` to add all packages to the library and finally list that library +# under :code:`LIBRARIES` in the call to :ref:`dune_register_package_flags`. See dune-pdelab for an example of +# how to do this correctly. +# +# While :ref:`dune_enable_all_packages` defines the user interface for this feature, developers might +# also be interested in the following related functions: +# +# * :ref:`dune_target_enable_all_packages` +# * :ref:`dune_register_package_flags` +# * :ref:`dune_library_add_sources` +# +# .. cmake_function:: dune_target_enable_all_packages +# +# .. cmake_param:: TARGETS +# :multi: +# +# A list of targets to add all flags etc. too. +# +# Adds all currently registered package flags (see :ref:`dune_register_package_flags`) to the given targets. +# This function is mainly intended to help write DUNE modules that want to use :ref:`dune_enable_all_packages` and +# define their own libraries, but need to be compatible with CMake < 3.1 +# +# .. cmake_function:: dune_register_package_flags +# +# .. cmake_param:: INCLUDE_DIRS +# :multi: +# +# The list of include directories needed by the external package. +# +# .. cmake_param:: COMPILE_DEFINITIONS +# :multi: +# +# The list of compile definitions needed by the external package. +# +# .. cmake_param:: COMPILE_OPTIONS +# :multi: +# +# The list of compile options needed by the external package. +# +# .. cmake_param:: LIBRARIES +# :multi: +# +# The list of libraries that the external package should link to. +# The order of the input is preserved in the output. +# +# .. cmake_param:: APPEND +# :option: +# +# If this option is set, the definitions, flags and directories specified in this function are +# appended to the global collection of flags instead of being prepended. Only use it, if you know +# what you are doing. +# +# To correctly implement the automatic handling of external libraries, the compile flags, include paths and link +# flags of all found packages must be registered with this function. This function is only necessary for people that +# want to write their own :code:`FindFooBar` CMake modules to link against additional libraries which are not supported by +# the DUNE core modules. Call this function at the end of every find module. If you are using an external FindFoo +# module which you cannot alter, call it after the call to :code:`find_package(foo)`. +# +# .. cmake_function:: dune_library_add_sources +# +# .. cmake_param:: module_library +# :single: +# :positional: +# +# The name of the module library target. +# +# .. cmake_param: SOURCES +# :multi: +# :required: +# +# The source files to add to the DUNE module library :code:`module_library`. +# That library must have been created by an earlier call to :ref:`dune_enable_all_packages` +# in the current DUNE module. +# +# Register sources for module exported library. +# + +function(dune_register_package_flags) + include(CMakeParseArguments) + set(OPTIONS APPEND) + set(SINGLEARGS) + set(MULTIARGS COMPILE_DEFINITIONS COMPILE_OPTIONS INCLUDE_DIRS LIBRARIES) + cmake_parse_arguments(REGISTRY "${OPTIONS}" "${SINGLEARGS}" "${MULTIARGS}" ${ARGN}) + + if(REGISTRY_UNPARSED_ARGUMENTS) + message(WARNING "Unrecognized arguments for dune_register_package_flags!") + endif() + + if(REGISTRY_APPEND) + set_property(GLOBAL APPEND PROPERTY ALL_PKG_INCS "${REGISTRY_INCLUDE_DIRS}") + set_property(GLOBAL APPEND PROPERTY ALL_PKG_LIBS "${REGISTRY_LIBRARIES}") + set_property(GLOBAL APPEND PROPERTY ALL_PKG_DEFS "${REGISTRY_COMPILE_DEFINITIONS}") + set_property(GLOBAL APPEND PROPERTY ALL_PKG_OPTS "${REGISTRY_COMPILE_OPTIONS}") + else(REGISTRY_APPEND) + get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS) + get_property(all_libs GLOBAL PROPERTY ALL_PKG_LIBS) + get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS) + get_property(all_opts GLOBAL PROPERTY ALL_PKG_OPTS) + set_property(GLOBAL PROPERTY ALL_PKG_INCS "${REGISTRY_INCLUDE_DIRS}" "${all_incs}") + set_property(GLOBAL PROPERTY ALL_PKG_LIBS "${REGISTRY_LIBRARIES}" "${all_libs}") + set_property(GLOBAL PROPERTY ALL_PKG_DEFS "${REGISTRY_COMPILE_DEFINITIONS}" "${all_defs}") + set_property(GLOBAL PROPERTY ALL_PKG_OPTS "${REGISTRY_COMPILE_OPTIONS}" "${all_opts}") + endif(REGISTRY_APPEND) +endfunction(dune_register_package_flags) + + +function(dune_enable_all_packages) + include(CMakeParseArguments) + set(OPTIONS APPEND VERBOSE) + set(SINGLEARGS) + set(MULTIARGS COMPILE_DEFINITIONS COMPILE_OPTIONS INCLUDE_DIRS MODULE_LIBRARIES) + cmake_parse_arguments(DUNE_ENABLE_ALL_PACKAGES "${OPTIONS}" "${SINGLEARGS}" "${MULTIARGS}" ${ARGN}) + + if(DUNE_ENABLE_ALL_PACKAGES_UNPARSED_ARGUMENTS) + message(WARNING "Unrecognized arguments for dune_enable_all_packages!") + endif() + + # handle additional include dirs specified in dune_enable_all_packages + if(DUNE_ENABLE_ALL_PACKAGES_INCLUDE_DIRS) + if(DUNE_ENABLE_ALL_PACKAGES_APPEND) + set_property(GLOBAL APPEND PROPERTY ALL_PKG_INCS "${DUNE_ENABLE_ALL_PACKAGES_INCLUDE_DIRS}") + else(DUNE_ENABLE_ALL_PACKAGES_APPEND) + get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS) + set_property(GLOBAL PROPERTY ALL_PKG_INCS "${DUNE_ENABLE_ALL_PACKAGES_INCLUDE_DIRS}" "${all_incs}") + endif(DUNE_ENABLE_ALL_PACKAGES_APPEND) + endif(DUNE_ENABLE_ALL_PACKAGES_INCLUDE_DIRS) + + # add include dirs to all targets in module + get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS) + include_directories(${all_incs}) + # verbose output of include dirs + if(DUNE_ENABLE_ALL_PACKAGES_VERBOSE) + message("Include directories for this project: ${all_incs}") + endif(DUNE_ENABLE_ALL_PACKAGES_VERBOSE) + + # handle additional compile definitions specified in dune_enable_all_packages + if(DUNE_ENABLE_ALL_PACKAGES_COMPILE_DEFINITIONS) + if(DUNE_ENABLE_ALL_PACKAGES_APPEND) + set_property(GLOBAL APPEND PROPERTY ALL_PKG_DEFS "${DUNE_ENABLE_ALL_PACKAGES_COMPILE_DEFINITIONS}") + else(DUNE_ENABLE_ALL_PACKAGES_APPEND) + get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS) + set_property(GLOBAL PROPERTY ALL_PKG_DEFS "${DUNE_ENABLE_ALL_PACKAGES_COMPILE_DEFINITIONS}" "${all_defs}") + endif(DUNE_ENABLE_ALL_PACKAGES_APPEND) + endif(DUNE_ENABLE_ALL_PACKAGES_COMPILE_DEFINITIONS) + + # add compile definitions to all targets in module + get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS) + # We have to do this in a loop because add_definitions() is kind of broken: even though it is supposed + # to be *the* function for adding compile definitions, it does not prepend "-D" (as opposed to + # target_compile_definitions(), which does). Well, whatever... + foreach(_definition ${all_defs}) + if(_definition) + add_definitions("-D${_definition}") + endif() + endforeach() + # verbose output of compile definitions + if(DUNE_ENABLE_ALL_PACKAGES_VERBOSE) + message("Compile definitions for this project: ${all_defs}") + endif(DUNE_ENABLE_ALL_PACKAGES_VERBOSE) + + # handle additional compile options specified in dune_enable_all_packages + if(DUNE_ENABLE_ALL_PACKAGES_COMPILE_OPTIONS) + if(DUNE_ENABLE_ALL_PACKAGES_APPEND) + set_property(GLOBAL APPEND PROPERTY ALL_PKG_OPTS "${DUNE_ENABLE_ALL_PACKAGES_COMPILE_OPTIONS}") + else(DUNE_ENABLE_ALL_PACKAGES_APPEND) + get_property(all_opts GLOBAL PROPERTY ALL_PKG_OPTS) + set_property(GLOBAL PROPERTY ALL_PKG_OPTS "${DUNE_ENABLE_ALL_PACKAGES_COMPILE_OPTIONS}" "${all_opts}") + endif(DUNE_ENABLE_ALL_PACKAGES_APPEND) + endif(DUNE_ENABLE_ALL_PACKAGES_COMPILE_OPTIONS) + + # add compile options to all targets in module + get_property(all_opts GLOBAL PROPERTY ALL_PKG_OPTS) + add_compile_options(${all_opts}) + # verbose output of compile definitions + if(DUNE_ENABLE_ALL_PACKAGES_VERBOSE) + message("Compile options for this project: ${all_opts}") + endif(DUNE_ENABLE_ALL_PACKAGES_VERBOSE) + + # handle libraries + # this is a little tricky because the libraries defined within the current module require special + # handling to avoid tripping over CMake policies CMP022 and CMP038 + + # first add all libraries of upstream Dune modules and of external dependencies + get_property(all_libs GLOBAL PROPERTY ALL_PKG_LIBS) + link_libraries(${DUNE_LIBS} ${all_libs}) + + # now we have to do a little dance: Newer versions of CMake complain if a target links to itself, + # so we have to create all targets for libraries inside the module before adding them to the set + # of default libraries to link to. That works because calling link_libraries does not affect targets + # which already exist. + # Moroever, CMake generates a warning when creating a library without any source files, and the linker + # does the same if we add an empty dummy file. We work around that problem by autogenerating a library-specific + # stub source file with two functions ${lib_name}_version() and ${lib_name}_version_string() and add that + # as an initial source file. + # After creating the library with dune_add_library(), we add it to all future targets with a call to + # link_libraries(). The user can then add the real source files by calling dune_library_add_sources() + # throughout the module. + + if(DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES) + + # This only works for CMAKE 3.1+ because target_sources() - which we use to add sources to the + # libraries after creating them - was added in that version + if (CMAKE_VERSION VERSION_LESS 3.1.0) + message(FATAL_ERROR "dune_enable_all_packages() only supports MODULE_LIBRARIES for CMake 3.1+") + elseif(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.1.0) + message(WARNING +"You are using dune_enable_all_packages() with the MODULE_LIBRARIES feature. +This requires at least CMake 3.1, but your Dune module only requires ${CMAKE_MINIMUM_REQUIRED_VERSION}. +Update the cmake_minimum_required() call in your main CMakeLists.txt file to get rid of this warning.") + endif() + + # make sure the /lib directory exists - we need it to create the stub source file in there + file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/lib") + # figure out the location of the stub source template + dune_module_path(MODULE dune-common RESULT script_dir SCRIPT_DIR) + foreach(module_lib ${DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES}) + # create the stub source file in the output directory (using a c++ compatible name)... + string(REGEX REPLACE "[^a-zA-Z0-9]" "_" module_lib_mangled ${module_lib}) + configure_file("${script_dir}/module_library.cc.in" "${PROJECT_BINARY_DIR}/lib/lib${module_lib}_stub.cc") + + # ...and create the library... + dune_add_library(${module_lib} SOURCES "${PROJECT_BINARY_DIR}/lib/lib${module_lib}_stub.cc") + # ...and add it to all future targets in the module + link_libraries(${module_lib}) + endforeach(module_lib ${DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES}) + + # export the DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES variable to the parent scope + # this is required to make dune_library_add_sources() work (see further down) + set( + DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES + ${DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES} + PARENT_SCOPE + ) + endif(DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES) + + if(DUNE_ENABLE_ALL_PACKAGES_VERBOSE) + get_property(all_libs GLOBAL PROPERTY ALL_PKG_LIBS) + message("Libraries for this project: ${all_libs}") + endif(DUNE_ENABLE_ALL_PACKAGES_VERBOSE) + +endfunction(dune_enable_all_packages) + + +function(dune_target_enable_all_packages) + foreach(_target ${ARGN}) + + get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS) + target_include_directories(${_target} PUBLIC ${all_incs}) + + get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS) + target_compile_definitions(${_target} PUBLIC ${all_defs}) + + get_property(all_opts GLOBAL PROPERTY ALL_PKG_OPTS) + target_compile_options(${_target} PUBLIC ${all_opts}) + + get_property(all_libs GLOBAL PROPERTY ALL_PKG_LIBS) + target_link_libraries(${_target} PUBLIC ${DUNE_LIBS} ${all_libs}) + + endforeach() +endfunction(dune_target_enable_all_packages) + + +function(dune_library_add_sources lib) + + # This only works for CMAKE 3.1+ because target_sources() - which we use to add sources to the + # libraries after creating them - was added in that version + if (CMAKE_VERSION VERSION_LESS 3.1.0) + message(FATAL_ERROR "dune_library_add_sources() requires CMake 3.1+") + endif() + + if (NOT (DEFINED DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES)) + message(FATAL_ERROR "You must call dune_enable_all_packages with the MODULE_LIBRARIES option before calling dune_library_add_sources") + endif() + + # This looks weird, but seems to be the most practical way to check for list membership, + # as list(FIND ...) does not work reliably in a macro... + if (NOT (";${DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES};" MATCHES ";${lib};")) + message(FATAL_ERROR +"Attempt to add sources to library ${lib}, which has not been defined in dune_enable_all_packages. +List of libraries defined in dune_enable_all_packages: ${DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES}") + endif() + + include(CMakeParseArguments) + cmake_parse_arguments(DUNE_LIBRARY_ADD_SOURCES "" "" "SOURCES" ${ARGN}) + + if(DUNE_LIBRARY_ADD_SOURCES_UNPARSED_ARGUMENTS) + message(WARNING "Unrecognized arguments for dune_library_add_sources!") + endif() + + foreach(source ${DUNE_LIBRARY_ADD_SOURCES_SOURCES}) + if(IS_ABSOLUTE ${source}) + target_sources(${lib} PRIVATE ${source}) + else() + target_sources(${lib} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${source}) + endif() + endforeach() +endfunction() diff -Nru dune-common-2.2.1/cmake/modules/DuneExecuteProcess.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneExecuteProcess.cmake --- dune-common-2.2.1/cmake/modules/DuneExecuteProcess.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneExecuteProcess.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,58 @@ +# An error checking wrapper around the cmake command execute_process +# +# .. cmake_command:: dune_execute_process +# +# .. cmake_param:: ERROR_MESSAGE +# :single: +# +# Error message to show if command exited with non-zero exit code. +# This also implies abortion of the current cmake run with a fatal error. +# Note, that if this is omitted, no return code checking is done. +# +# A thin wrapper around the cmake command :code:`execute_process`, that +# exits on non-zero exit codes. All arguments are forwarded to the actual +# cmake command. +# + +function(dune_execute_process) + include(CMakeParseArguments) + cmake_parse_arguments(EXECUTE "" "ERROR_MESSAGE;RESULT_VARIABLE;OUTPUT_VARIABLE;ERROR_VARIABLE" "" ${ARGN}) + + # Decide whether stdout and stderr have to be split + if(EXECUTE_OUTPUT_VARIABLE AND EXECUTE_ERROR_VARIABLE) + set(SPLIT_ERROR TRUE) + set(ERRLOGVAR errlog) + else() + set(SPLIT_ERROR FALSE) + set(ERRLOGVAR log) + endif() + + # Call the original cmake function + execute_process(${EXECUTE_UNPARSED_ARGUMENTS} + RESULT_VARIABLE retcode + OUTPUT_VARIABLE log + ERROR_VARIABLE ${ERRLOGVAR} + ) + + # Issue an error if requested! + if(EXECUTE_ERROR_MESSAGE) + if(NOT "${retcode}" STREQUAL "0") + cmake_parse_arguments(ERR "" "" "COMMAND" ${EXECUTE_UNPARSED_ARGUMENTS}) + if(SPLIT_ERROR) + set(log "stdout:\n${log}\n\nstderr:\b${errlog}") + endif() + message(FATAL_ERROR "${EXECUTE_ERROR_MESSAGE}\nRun command:${ERR_COMMAND}\nReturn code: ${retcode}\nDetailed log:\n${log}") + endif() + endif() + + # Propagate logs back to the calling scope + if(EXECUTE_RESULT_VARIABLE) + set(${EXECUTE_RESULT_VARIABLE} ${retcode} PARENT_SCOPE) + endif() + if(EXECUTE_OUTPUT_VARIABLE) + set(${EXECUTE_OUTPUT_VARIABLE} ${log} PARENT_SCOPE) + endif() + if(EXECUTE_ERROR_VARIABLE) + set(${EXECUTE_ERROR_VARIABLE} ${${ERROR_VARIABLE}} PARENT_SCOPE) + endif() +endfunction() diff -Nru dune-common-2.2.1/cmake/modules/DuneMacros.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneMacros.cmake --- dune-common-2.2.1/cmake/modules/DuneMacros.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneMacros.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,1264 @@ +# Core DUNE module for CMake. +# +# Documentation of the public API defined in this module: +# +# .. cmake_function:: dune_project +# +# Initialize a Dune module. This function needs to be run from every +# top-level CMakeLists.txt file. It sets up the module, defines basic +# variables and manages depedencies. Don't forget to call +# :ref:`finalize_dune_project` afterwards. +# +# .. cmake_function:: finalize_dune_project +# +# Finalize a Dune module. This function needs to be run at the end of +# every top-level CMakeLists.txt file. Among other things it creates +# the cmake package configuration files. Modules can add additional +# entries to these files by setting the variable @${ProjectName}_INIT. +# +# .. cmake_function:: dune_add_library +# +# .. cmake_brief:: +# +# Add a library to a Dune module! +# +# .. cmake_param:: basename +# :single: +# :required: +# :positional: +# +# The basename for the library. On Unix this created :code:`lib.so` +# and :code:`lib.a` +# +# .. cmake_param:: NO_EXPORT +# :option: +# +# If omitted the library is exported for usage in other modules. +# +# .. cmake_param:: ADD_LIBS +# :multi: +# +# A list of libraries that should be incorporated into this library. +# +# .. cmake_param:: APPEND +# :option: +# +# Whether the library should be appended to the +# exported libraries. If there a DUNE module must +# make several libraries available, then first one +# must not use this option but the others have to +# use it. Otherwise only the last library will be +# exported as the others will be overwritten. +# +# .. cmake_param:: OBJECT +# :option: +# +# .. note:: +# This feature will very likely vanish in Dune 3.0 +# +# .. cmake_param:: SOURCES +# :multi: +# :required: +# +# The source files from which to build the library. +# +# .. cmake_param:: COMPILE_FLAGS +# :single: +# +# Any additional compile flags for building the library. +# +# .. cmake_function:: dune_target_link_libraries +# +# .. cmake_param:: BASENAME +# +# .. cmake_param:: LIBRARIES +# +# Link libraries to the static and shared version of +# library BASENAME +# +# +# .. cmake_function:: add_dune_all_flags +# +# .. cmake_param:: targets +# :single: +# :required: +# :positional: +# +# The targets to add the flags of all external libraries to. +# +# This function is superseded by :ref:`dune_target_enable_all_packages`. +# +# Documentation of internal macros in this module: +# +# dune_module_to_uppercase(upper_name module_name) +# +# Converts a module name given by module_name into an uppercase string +# upper_name where all dashes (-) are replaced by underscores (_) +# Example: dune-common -> DUNE_COMMON +# +# dune_module_information(MODULE_DIR [QUIET]) +# +# Parse ${MODULE_DIR}/dune.module and provide that information. +# If the second argument is QUIET no status message is printed. +# +# dune_create_dependency_tree() +# +# Creates the dependency tree of the module. +# +# dune_module_to_macro(_macro_name, _dune_module) +# +# Converts a module name given by _dune_module into a string _macro_name +# where all dashes (-) are removed and letters after a dash are capitalized +# Example: dune-grid-howto -> DuneGridHowto +# +# _macro_name: variable where the name will be stored. +# _dune_module: the name of the dune module. +# +# dune_regenerate_config_cmake() +# +# Creates a new config_collected.h.cmake file in ${CMAKE_CURRENT_BINARY_DIR} that +# consists of entries from ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake +# and includes non-private entries from the config.h.cmake files +# of all dependent modules. +# Finally config.h is created from config_collected.h.cmake. +# + +# Make CMake use rpath on OS X +if(POLICY CMP0042) + # this policy only needed for CMake older then 3.0 + cmake_policy(SET CMP0042 NEW) +endif() + +enable_language(C) # Enable C to skip CXX bindings for some tests. + +include(FeatureSummary) +include(DuneEnableAllPackages) +include(DuneTestMacros) +include(OverloadCompilerFlags) +include(DuneSymlinkOrCopy) +include(DunePathHelper) +include(DuneExecuteProcess) + +# Converts a module name given by _module into an uppercase string +# _upper where all dashes (-) are replaced by underscores (_) +# Example: dune-common -> DUNE_COMMON +macro(dune_module_to_uppercase _upper _module) + string(TOUPPER "${_module}" ${_upper}) + string(REPLACE "-" "_" ${_upper} "${${_upper}}") +endmacro(dune_module_to_uppercase _upper _module) + +macro(find_dune_package module) + include(CMakeParseArguments) + cmake_parse_arguments(DUNE_FIND "REQUIRED" "VERSION" "" ${ARGN}) + if(DUNE_FIND_REQUIRED) + set(required REQUIRED) + set_package_properties(${module} PROPERTIES TYPE REQUIRED) + else() + unset(required) + set_package_properties(${module} PROPERTIES TYPE OPTIONAL) + endif() + if(DUNE_FIND_VERSION MATCHES "(>=|=|<=).*") + string(REGEX REPLACE "(>=|=|<=)(.*)" "\\1" DUNE_FIND_VERSION_OP ${DUNE_FIND_VERSION}) + string(REGEX REPLACE "(>=|=|<=)(.*)" "\\2" DUNE_FIND_VERSION_NUMBER ${DUNE_FIND_VERSION}) + string(STRIP ${DUNE_FIND_VERSION_NUMBER} DUNE_FIND_VERSION_NUMBER) + extract_major_minor_version("${DUNE_FIND_VERSION_NUMBER}" DUNE_FIND_VERSION) + set(DUNE_FIND_VERSION_STRING "${DUNE_FIND_VERSION_MAJOR}.${DUNE_FIND_VERSION_MINOR}.${DUNE_FIND_VERSION_REVISION}") + else() + set(DUNE_FIND_VERSION_STRING "0.0.0") + endif() + if(NOT ${module}_FOUND) + if(NOT (${module}_DIR OR ${module}_ROOT OR + "${CMAKE_PREFIX_PATH}" MATCHES ".*${module}.*")) + string(REPLACE ${ProjectName} ${module} ${module}_DIR + ${PROJECT_BINARY_DIR}) + endif() + find_package(${module} NO_CMAKE_PACKAGE_REGISTRY) + endif() + if(NOT ${module}_FOUND) + message(STATUS "No full CMake package configuration support available." + " Falling back to pkg-config.") + # use pkg-config + find_package(PkgConfig) + if(NOT PKG_CONFIG_FOUND AND required) + message(FATAL_ERROR "Could not find module ${module}. We tried to use" + "pkg-config but could not find it. ") + endif() + pkg_check_modules (${module} ${required} ${module}${DUNE_FIND_VERSION}) + set(${module}_FAKE_CMAKE_PKGCONFIG TRUE) + endif() + if(${module}_FAKE_CMAKE_PKGCONFIG) + # compute the path to the libraries + if(${module}_LIBRARIES) + unset(_module_lib) + foreach(lib ${${module}_LIBRARIES}) + foreach(libdir ${${module}_LIBRARY_DIRS}) + if(EXISTS ${libdir}/lib${lib}.a) + set(_module_lib ${libdir}/lib${lib}.a) + set(_module_lib_static "STATIC") + endif() + if(EXISTS ${libdir}/lib${lib}.so) + set(_module_lib ${libdir}/lib${lib}.so) + set(_module_lib_static "") + endif() + if(_module_lib) + #import library + add_library(${lib} ${_module_lib_static} IMPORTED) + set_property(TARGET ${lib} APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) + set_target_properties(${lib} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX" + IMPORTED_LOCATION_NOCONFIG "${_module_lib}") + break() + endif() + endforeach() + endforeach() + endif() + if(NOT ${module}_MODULE_PATH) + if(${module}_INCLUDE_DIRS) + list(GET ${module}_INCLUDE_DIRS 0 _dir) + if(EXISTS ${_dir}/../share/dune/cmake/modules) + set(${module}_MODULE_PATH ${_dir}/../share/dune/cmake/modules) + endif() + endif() + endif() + unset(${module}_FAKE_CMAKE_PKGCONFIG) + endif() + if(${module}_FOUND) + # parse other module's dune.module file to generate variables for config.h + unset(${module}_dune_module) + foreach(_dune_module_file + ${${module}_PREFIX}/dune.module + ${${module}_PREFIX}/lib/dunecontrol/${module}/dune.module + ${${module}_PREFIX}/lib64/dunecontrol/${module}/dune.module) + if(EXISTS ${_dune_module_file}) + get_filename_component(_dune_module_file_path ${_dune_module_file} PATH) + dune_module_information(${_dune_module_file_path})# QUIET) + set(${module}_dune_module 1) + set(DUNE_FIND_MOD_VERSION_STRING "${DUNE_VERSION_MAJOR}.${DUNE_VERSION_MINOR}.${DUNE_VERSION_REVISION}") + # check whether dependency mathes version requirement + unset(module_version_wrong) + if(DUNE_FIND_VERSION_OP MATCHES ">=") + if(NOT (DUNE_FIND_MOD_VERSION_STRING VERSION_EQUAL DUNE_FIND_VERSION_STRING OR + DUNE_FIND_MOD_VERSION_STRING VERSION_GREATER DUNE_FIND_VERSION_STRING)) + set(module_version_wrong 1) + endif() + elseif(DUNE_FIND_VERSION_OP MATCHES "<=") + if(NOT (DUNE_FIND_MOD_VERSION_STRING VERSION_EQUAL DUNE_FIND_VERSION_STRING OR + DUNE_FIND_MOD_VERSION_STRING VERSION_LESS DUNE_FIND_VERSION_STRING)) + set(module_version_wrong 1) + endif() + elseif(DUNE_FIND_VERSION_OP MATCHES "=" AND + NOT (DUNE_FIND_MOD_VERSION_STRING VERSION_EQUAL DUNE_FIND_VERSION_STRING)) + set(module_version_wrong 1) + endif() + endif() + endforeach() + if(NOT ${module}_dune_module) + message(FATAL_ERROR "Could not find dune.module file for module ${module} " + "in ${${module}_PREFIX}, ${${module}_PREFIX}/lib/dunecontrol/${module}/, " + "${${module}_PREFIX}/lib64/dunecontrol/${module}/dune.module") + endif() + if(module_version_wrong) + message(FATAL_ERROR "Could not find requested version of module ${module}. " + "Requested version was ${DUNE_FIND_VERSION}, found version is ${DUNE_FIND_MOD_VERSION_STRING}") + endif() + else(${module}_FOUND) + if(required) + message(FATAL_ERROR "Could not find required module ${module}.") + endif() + endif() + set(DUNE_${module}_FOUND ${${module}_FOUND}) +endmacro(find_dune_package module) + +macro(extract_line HEADER OUTPUT FILE_NAME) + set(REGEX "^${HEADER}[ ]*[^\\n]+") + file(STRINGS "${FILE_NAME}" OUTPUT1 REGEX "${REGEX}") + if(OUTPUT1) + set(REGEX "^[ ]*${HEADER}[ ]*(.+)[ ]*$") + string(REGEX REPLACE ${REGEX} "\\1" ${OUTPUT} "${OUTPUT1}") + else(OUTPUT1) + set(OUTPUT OUTPUT-NOTFOUND) + endif() +endmacro(extract_line) + +# +# split list of modules, potentially with version information +# into list of modules and list of versions +# +macro(split_module_version STRING MODULES VERSIONS) + set(REGEX "[a-zA-Z0-9-]+[ ]*(\\([ ]*([^ ]+)?[ ]*[^ ]+[ ]*\\))?") + string(REGEX MATCHALL "${REGEX}" matches "${STRING}") + set(${MODULES} "") + set(${VERSIONS} "") + foreach(i ${matches}) + string(REGEX REPLACE "^([a-zA-Z0-9-]+).*$" "\\1" mod ${i}) + string(REGEX MATCH "\\([ ]*(([^ ]+)?[ ]*[^ ]+)[ ]*\\)" have_version + ${i}) + if(have_version) + string(REGEX REPLACE "^\\([ ]*([^ ]*[ ]*[^ ]+)[ ]*\\)$" "\\1" + version ${have_version}) + else() + set(version " ") # Mark as no version requested. + # Having a space is mandatory as we will append it to a list + # and an empty string will not be treated as entry we append to it. + endif() + list(APPEND ${MODULES} ${mod}) + list(APPEND ${VERSIONS} ${version}) + endforeach() +endmacro(split_module_version) + +# +# Convert a string with spaces in a list which is a string with semicolon +# +function(convert_deps_to_list var) + string(REGEX REPLACE "([a-zA-Z0-9\\)]) ([a-zA-Z0-9])" "\\1;\\2" ${var} ${${var}}) + set(${var} ${${var}} PARENT_SCOPE) +endfunction(convert_deps_to_list var) + +# +# extracts major, minor, and revision from version string +# +function(extract_major_minor_version version_string varname) + string(REGEX REPLACE "([0-9]+).*" "\\1" ${varname}_MAJOR "${version_string}") + string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" ${varname}_MINOR "${version_string}") + string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" ${varname}_REVISION "${version_string}") + set(${varname}_MAJOR "${${varname}_MAJOR}" PARENT_SCOPE) # make variable accessible in parent scope + + # remove false matches in version string and export to parent scop + string(REGEX MATCH "[^0-9]" NON_NUMBER_CHARACTER "${${varname}_MINOR}") + if(NON_NUMBER_CHARACTER) + set(${varname}_MINOR "0" PARENT_SCOPE) + else() + set(${varname}_MINOR ${${varname}_MINOR} PARENT_SCOPE) + endif() + string(REGEX MATCH "[^0-9]" NON_NUMBER_CHARACTER "${${varname}_REVISION}") + if(NON_NUMBER_CHARACTER) + set(${varname}_REVISION "0" PARENT_SCOPE) + else() + set(${varname}_REVISION ${${varname}_REVISION} PARENT_SCOPE) + endif() +endfunction(extract_major_minor_version version_string varname) + +# add dune-common version from dune.module to config.h +# optional second argument is verbosity +macro(dune_module_information MODULE_DIR) + # find version strings + extract_line("Version:" MODULE_LINE "${MODULE_DIR}/dune.module") + if(NOT MODULE_LINE MATCHES ".+") + message(FATAL_ERROR "${MODULE_DIR}/dune.module is missing a version.") + endif() + + string(REGEX REPLACE ".*Version:[ ]*([^ \n]+).*" "\\1" DUNE_MOD_VERSION "${MODULE_LINE}") + extract_major_minor_version("${DUNE_MOD_VERSION}" DUNE_VERSION) + + # find strings for module name, maintainer + # 1. Check for line starting with Module + extract_line("Module:" DUNE_MOD_NAME "${MODULE_DIR}/dune.module") + if(NOT DUNE_MOD_NAME) + message(FATAL_ERROR "${MODULE_DIR}/dune.module is missing a module name.") + endif() + + # 2. Check for line starting with Maintainer + extract_line("Maintainer:" DUNE_MAINTAINER "${MODULE_DIR}/dune.module") + if(NOT DUNE_MAINTAINER) + message(FATAL_ERROR "${MODULE_DIR}/dune.module is missing a maintainer.") + endif() + + # 3. Check for line starting with Depends + extract_line("Depends:" ${DUNE_MOD_NAME}_DEPENDS "${MODULE_DIR}/dune.module") + if(${DUNE_MOD_NAME}_DEPENDS) + split_module_version(${${DUNE_MOD_NAME}_DEPENDS} ${DUNE_MOD_NAME}_DEPENDS_MODULE ${DUNE_MOD_NAME}_DEPENDS_VERSION) + foreach(_mod ${${DUNE_MOD_NAME}_DEPENDS}) + set(${_mod}_REQUIRED REQUIRED) + endforeach() + convert_deps_to_list(${DUNE_MOD_NAME}_DEPENDS) + if(NOT ("${ARGV1}" STREQUAL QUIET)) + message(STATUS "Dependencies for ${DUNE_MOD_NAME}: ${${DUNE_MOD_NAME}_DEPENDS}") + endif() + endif() + + # 4. Check for line starting with Suggests + extract_line("Suggests:" ${DUNE_MOD_NAME}_SUGGESTS "${MODULE_DIR}/dune.module") + if(${DUNE_MOD_NAME}_SUGGESTS) + split_module_version(${${DUNE_MOD_NAME}_SUGGESTS} ${DUNE_MOD_NAME}_SUGGESTS_MODULE ${DUNE_MOD_NAME}_SUGGESTS_VERSION) + convert_deps_to_list(${DUNE_MOD_NAME}_SUGGESTS) + if(NOT ("${ARGV1}" STREQUAL QUIET)) + message(STATUS "Suggestions for ${DUNE_MOD_NAME}: ${${DUNE_MOD_NAME}_SUGGESTS}") + endif() + endif() + + dune_module_to_uppercase(DUNE_MOD_NAME_UPPERCASE ${DUNE_MOD_NAME}) + + # set module version + set(${DUNE_MOD_NAME_UPPERCASE}_VERSION "${DUNE_MOD_VERSION}") + set(${DUNE_MOD_NAME_UPPERCASE}_VERSION_MAJOR "${DUNE_VERSION_MAJOR}") + set(${DUNE_MOD_NAME_UPPERCASE}_VERSION_MINOR "${DUNE_VERSION_MINOR}") + set(${DUNE_MOD_NAME_UPPERCASE}_VERSION_REVISION "${DUNE_VERSION_REVISION}") + + # configure CPack + set(CPACK_PACKAGE_NAME "${DUNE_MOD_NAME}") + set(CPACK_PACKAGE_VERSION "${DUNE_VERSION_MAJOR}.${DUNE_VERSION_MINOR}.${DUNE_VERSION_REVISION}") + set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") + set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}" "\\\\.svn" "\\\\.git" ".*/*\\\\.gitignore") +endmacro(dune_module_information) + +macro(dune_process_dependency_leafs modules versions is_required next_level_deps + next_level_sugs) + # modules, and versions are not real variables, make them one + set(mmodules ${modules}) + set(mversions ${versions}) + list(LENGTH mmodules mlength) + list(LENGTH mversions vlength) + if(NOT mlength EQUAL vlength) + message(STATUS "mmodules=${mmodules} modules=${modules}") + message(STATUS "mversions=${mversions} versions=${mversions}") + message(FATAL_ERROR "List of modules and versions do not have the same length!") + endif() + if(mlength GREATER 0) + math(EXPR length "${mlength}-1") + foreach(i RANGE 0 ${length}) + list(GET mmodules ${i} _mod) + list(GET mversions ${i} _ver) + find_dune_package(${_mod} ${is_required} VERSION "${_ver}") + set(${_mod}_SEARCHED ON) + if(NOT "${is_required}" STREQUAL "") + set(${_mod}_REQUIRED ON) + set(${next_level_deps} ${${_mod}_DEPENDS} ${${next_level_deps}}) + else(NOT "${is_required}" STREQUAL "") + set(${next_level_sugs} ${${_mod}_DEPENDS} ${${next_level_sugs}}) + endif() + set(${next_level_sugs} ${${_mod}_SUGGESTS} ${${next_level_sugs}}) + endforeach() + endif() + if(${next_level_sugs}) + list(REMOVE_DUPLICATES ${next_level_sugs}) + endif() + if(${next_level_deps}) + list(REMOVE_DUPLICATES ${next_level_deps}) + endif() +endmacro(dune_process_dependency_leafs) + +function(remove_processed_modules modules versions is_required) + list(LENGTH ${modules} mlength) + if(mlength GREATER 0) + math(EXPR length "${mlength}-1") + foreach(i RANGE ${length} 0 -1) + list(GET ${modules} ${i} _mod) + if(${_mod}_SEARCHED) + list(REMOVE_AT ${modules} ${i}) + list(REMOVE_AT ${versions} ${i}) + if(is_required AND NOT ${_mod}_REQUIRED AND NOT ${_mod}_FOUND) + message(FATAL_ERROR "Required module ${_mod} not found!") + endif() + endif() + endforeach() + endif() + set(${modules} ${${modules}} PARENT_SCOPE) + set(${versions} ${${versions}} PARENT_SCOPE) +endfunction(remove_processed_modules modules versions is_required) + +macro(dune_create_dependency_leafs depends depends_versions suggests suggests_versions) + set(deps "") + set(sugs "") + #Process dependencies + if(NOT "${depends}" STREQUAL "") + dune_process_dependency_leafs("${depends}" "${depends_versions}" REQUIRED deps sugs) + endif() + # Process suggestions + if(NOT "${suggests}" STREQUAL "") + dune_process_dependency_leafs("${suggests}" "${suggests_versions}" "" deps sugs) + endif() + split_module_version("${deps}" next_mod_depends next_depends_versions) + split_module_version("${sugs}" next_mod_suggests next_suggests_versions) + set(ALL_DEPENDENCIES ${ALL_DEPENDENCIES} ${next_mod_depends} ${next_mod_suggests}) + # Move to next level + if(next_mod_suggests OR next_mod_depends) + dune_create_dependency_leafs("${next_mod_depends}" "${next_depends_versions}" + "${next_mod_suggests}" "${next_suggests_versions}") + endif() +endmacro(dune_create_dependency_leafs) + +macro(dune_create_dependency_tree) + if(dune-common_MODULE_PATH) + list(REMOVE_ITEM CMAKE_MODULE_PATH "${dune-common_MODULE_PATH}") + endif() + list(FIND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules start) + set(ALL_DEPENDENCIES "") + if(${ProjectName}_DEPENDS_MODULE OR ${ProjectName}_SUGGESTS_MODULE) + set(ALL_DEPENDENCIES ${${ProjectName}_DEPENDS_MODULE} ${${ProjectName}_SUGGESTS_MODULE}) + dune_create_dependency_leafs("${${ProjectName}_DEPENDS_MODULE}" "${${ProjectName}_DEPENDS_VERSION}" + "${${ProjectName}_SUGGESTS_MODULE}" "${${ProjectName}_SUGGESTS_VERSION}") + endif() + set(_my_path "") + if(ALL_DEPENDENCIES) + # Reverse the order of the modules and remove duplicates + # At end of this clause we have have a list modules + # where for each entry all dependencies are before the + # module in the list. + set(NEW_ALL_DEPS "") + list(LENGTH ALL_DEPENDENCIES length) + if(length GREATER 0) + math(EXPR length "${length}-1") + list(GET ALL_DEPENDENCIES ${length} _mod) + set(${_mod}_cmake_path_processed 1) + set(_my_path ${${_mod}_MODULE_PATH}) + list(APPEND NEW_ALL_DEPS ${_mod}) + if(length GREATER 0) + math(EXPR length "${length}-1") + foreach(i RANGE ${length} 0 -1) + list(GET ALL_DEPENDENCIES ${i} _mod) + if(NOT ${_mod}_cmake_path_processed) + set(${_mod}_cmake_path_processed 1) + if(${_mod}_MODULE_PATH) + list(INSERT _my_path 0 ${${_mod}_MODULE_PATH}) + endif() + list(APPEND NEW_ALL_DEPS ${_mod}) + endif() + endforeach() + endif() + list(LENGTH CMAKE_MODULE_PATH length) + math(EXPR length "${length}-1") + if(start EQUAL -1) + list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules ${_my_path}) + else() + if(start EQUAL ${length}) + list(APPEND CMAKE_MODULE_PATH ${_my_path}) + else() + if(_my_path) + list(INSERT CMAKE_MODULE_PATH ${start} ${_my_path}) + endif() + endif() + endif() + endif() + set(ALL_DEPENDENCIES ${NEW_ALL_DEPS}) + endif() +endmacro(dune_create_dependency_tree) + +# Converts a module name given by _dune_module into a string _macro_name +# where all dashes (-) are removed and letters after a dash are capitalized +# Example: dune-grid-howto -> DuneGridHowto +macro(dune_module_to_macro _macro_name _dune_module) + set(${_macro_name} "") + set(_rest "${_dune_module}") + string(FIND "${_rest}" "-" _found) + while(_found GREATER -1) + string(REGEX REPLACE "([^-]*)-.*" "\\1" _first_part + "${_rest}") + string(REGEX REPLACE "[^-]*-(.*)" "\\1" _rest + "${_rest}") + string(SUBSTRING "${_first_part}" 0 1 _first_letter) + string(SUBSTRING "${_first_part}" 1 -1 _rest_first_part) + string(TOUPPER "${_first_letter}" _first_letter) + set(${_macro_name} "${${_macro_name}}${_first_letter}${_rest_first_part}") + string(FIND "${_rest}" "-" _found) + endwhile() + string(LENGTH "${_rest}" _length) + string(SUBSTRING "${_rest}" 0 1 _first_letter) + string(SUBSTRING "${_rest}" 1 -1 _rest) + string(TOUPPER "${_first_letter}" _first_letter) + set(${_macro_name} "${${_macro_name}}${_first_letter}${_rest}") +endmacro(dune_module_to_macro _macro_name _dune_module) + +macro(dune_process_dependency_macros) + foreach(_mod ${ALL_DEPENDENCIES} ${ProjectName}) + if(NOT ${_mod}_PROCESSED) + # module not processed yet + set(${_mod}_PROCESSED ${_mod}) + # Search for a cmake files containing tests and directives + # specific to this module + dune_module_to_macro(_cmake_mod_name "${_mod}") + set(_macro "${_cmake_mod_name}Macros") + set(_mod_cmake _mod_cmake-NOTFOUND) # Prevent false positives due to caching + find_file(_mod_cmake + ${_macro}.cmake + ${CMAKE_MODULE_PATH} + NO_DEFAULT_PATH) + if(_mod_cmake) + message(STATUS "Performing tests specific to ${_mod} from file ${_mod_cmake}.") + include(${_mod_cmake}) + endif() + dune_module_to_uppercase(_upper_case "${_mod}") + if(${_mod}_INCLUDE_DIRS) + message(STATUS "Setting ${_mod}_INCLUDE_DIRS=${${_mod}_INCLUDE_DIRS}") + include_directories("${${_mod}_INCLUDE_DIRS}") + endif() + if(${_mod}_LIBRARIES) + message(STATUS "Setting ${_mod}_LIBRARIES=${${_mod}_LIBRARIES}") + foreach(_lib ${${_mod}_LIBRARIES}) + list(INSERT DUNE_DEFAULT_LIBS 0 "${_lib}") + list(INSERT DUNE_LIBS 0 "${_lib}") + endforeach() + endif() + + # register dune module + dune_register_package_flags(INCLUDE_DIRS "${${_mod}_INCLUDE_DIRS}") + endif() + endforeach() +endmacro(dune_process_dependency_macros) + +# macro that should be called near the begin of the top level CMakeLists.txt. +# Namely it sets up the module, defines basic variables and manages +# depedencies. +# Don't forget to call finalize_dune_project afterwards. +macro(dune_project) + # check whether a compiler name instead of compiler path is given, this causes serious problems with older cmake versions. + # Unfortunately those errors only surface on a second run, when the build directory already exists. The compiler + # variable is then (for obscure reasons) expanded to ${CMAKE_BINARY_DIR}/... + if((${CMAKE_CXX_COMPILER} MATCHES "${CMAKE_BINARY_DIR}.*") AND (${CMAKE_VERSION} VERSION_LESS "3.0")) + message(FATAL_ERROR "You need to specify an absolute path to your compiler instead of just the compiler name. cmake >= 3.0 fixes this issue.") + endif() + + # check if CXX flag overloading has been enabled (see OverloadCompilerFlags.cmake) + initialize_compiler_script() + + # extract information from dune.module + dune_module_information(${CMAKE_SOURCE_DIR}) + set(ProjectName "${DUNE_MOD_NAME}") + set(ProjectVersion "${DUNE_MOD_VERSION}") + set(ProjectVersionString "${DUNE_VERSION_MAJOR}.${DUNE_VERSION_MINOR}.${DUNE_VERSION_REVISION}") + set(ProjectVersionMajor "${DUNE_VERSION_MAJOR}") + set(ProjectVersionMinor "${DUNE_VERSION_MINOR}") + set(ProjectVersionRevision "${DUNE_VERSION_REVISION}") + set(ProjectMaintainerEmail "${DUNE_MAINTAINER}") + + # check whether this module has been explicitly disabled through the cmake flags. + # If so, stop the build. This is necessary because dunecontrol does not parse + # the given CMake flags for a disabled Dune modules. + if(CMAKE_DISABLE_FIND_PACKAGE_${ProjectName}) + message("Module ${ProjectName} has been explicitly disabled through the cmake flags. Skipping build.") + return() + endif() + + define_property(GLOBAL PROPERTY DUNE_MODULE_LIBRARIES + BRIEF_DOCS "List of libraries of the module. DO NOT EDIT!" + FULL_DOCS "List of libraries of the module. Used to generate CMake's package configuration files. DO NOT EDIT!") + dune_create_dependency_tree() + + # assert the project names matches + if(NOT (ProjectName STREQUAL CMAKE_PROJECT_NAME)) + message(FATAL_ERROR "Module name from dune.module does not match the name given in CMakeLists.txt.") + endif() + + # optional Fortran support + include(LanguageSupport) + workaround_9220(Fortran Fortran_Works) + if(Fortran_Works) + enable_language(Fortran OPTIONAL) + if(NOT CMAKE_Fortran_COMPILER) + set(Fortran_Works OFF) + endif() + endif() + + option(DUNE_USE_ONLY_STATIC_LIBS "If set to ON, we will force static linkage everywhere" OFF) + if(DUNE_USE_ONLY_STATIC_LIBS) + if(BUILD_SHARED_LIBS) + message(FATAL_ERROR "Your requesting to use only static libraries " + "(DUNE_USE_ONLY_STATIC_LIBS==True) while at same time requesting to " + "build shared libraries (BUILD_SHARED_LIBS==True). This is a " + "contradiction!") + endif() + endif() + option(DUNE_BUILD_BOTH_LIBS "If set to ON, shared and static libs will be built" + ${_default_enable_static}) + + # As default request position independent code if shared libraries are built + # This should allow DUNE modules to use CMake's object libraries. + # This can be overwritten for targets by setting the target property + # POSITION_INDEPENDENT_CODE to false/OFF + if(BUILD_SHARED_LIBS) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + endif() + + if(DUNE_USE_ONLY_STATIC_LIBS) + # Use only static libraries. + # We do this by overriding the library suffixes. + set( BLA_STATIC 1) + set( _dune_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() + if(APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + endif() + endif() + + # check for C++ features, set compiler flags for C++14 or C++11 mode + include(CheckCXXFeatures) + include(DuneCxaDemangle) + + # set include path and link path for the current project. + include_directories("${CMAKE_BINARY_DIR}") + include_directories("${CMAKE_SOURCE_DIR}") + include_directories("${CMAKE_CURRENT_BINARY_DIR}") + include_directories("${CMAKE_CURRENT_SOURCE_DIR}") + add_definitions(-DHAVE_CONFIG_H) + + # Search for MPI and set the relevant variables. + include(DuneMPI) + + # Make calling fortran routines from C/C++ possible + if(Fortran_Works) + include(FortranCInterface) + FortranCInterface_VERIFY(CXX) + # Write FC.h header containing information about + # how to call fortran routined. + # It will be included in config.h + FortranCInterface_HEADER(FC.h MACRO_NAMESPACE "FC_") + else() + # Write empty FC.h header + # Make sure to only write this file once, otherwise every cmake run + # will trigger a full rebuild of the whole project. + unset(_FC_H CACHE) + find_file(_FC_H NAME FC.h PATHS "${CMAKE_BINARY_DIR}" NO_DEFAULT_PATH) + if(NOT _FC_H) + file(WRITE "${CMAKE_BINARY_DIR}/FC.h" "") + endif() + endif() + + # Create custom target for building the documentation + # and provide macros for installing the docs and force + # building them before. + include(DuneDoc) + + # activate pkg-config + include(DunePkgConfig) + + # Process the macros provided by the dependencies and ourself + dune_process_dependency_macros() + + include(GNUInstallDirs) + # Set variable where the cmake modules will be installed. + # Thus the user can override it and for example install + # directly into the CMake installation. We use a cache variable + # that is overridden by a local variable of the same name if + # the user does not explicitely set a value for it. Thus the value + # will automatically change if the user changes CMAKE_INSTALL_DATAROOTDIR + # or CMAKE_INSTALL_PREFIX + if(NOT DUNE_INSTALL_MODULEDIR) + set(DUNE_INSTALL_MODULEDIR "" + CACHE PATH + "Installation directory for CMake modules. Default is \${CMAKE_INSTALL_DATAROOTDIR}/dune/cmake/modules when not set explicitely") + set(DUNE_INSTALL_MODULEDIR ${CMAKE_INSTALL_DATAROOTDIR}/dune/cmake/modules) + endif() + if(NOT DUNE_INSTALL_NONOBJECTLIBDIR) + set(DUNE_INSTALL_NONOBJECTLIBDIR "" + CACHE PATH + "Installation directory for libraries that are not architecture dependent. Default is lib when not set explicitely") + set(DUNE_INSTALL_NONOBJECTLIBDIR lib) + endif() + # set up make headercheck + include(Headercheck) + setup_headercheck() + +endmacro(dune_project) + +# create a new config.h file and overwrite the existing one +macro(dune_regenerate_config_cmake) + set(CONFIG_H_CMAKE_FILE "${CMAKE_BINARY_DIR}/config_collected.h.cmake") + if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake) + file(READ ${CMAKE_SOURCE_DIR}/config.h.cmake _file) + string(REGEX MATCH + "/[\\*/][ ]*begin[ ]+${ProjectName}.*\\/[/\\*][ ]*end[ ]*${ProjectName}[^\\*]*\\*/" + _myfile "${_file}") + endif() + # overwrite file with new content + file(WRITE ${CONFIG_H_CMAKE_FILE} "/* config.h. Generated from config_collected.h.cmake by CMake. + It was generated from config_collected.h.cmake which in turn is generated automatically + from the config.h.cmake files of modules this module depends on. */" + ) + + # define that we found this module + set(${ProjectName}_FOUND 1) + foreach(_dep ${ProjectName} ${ALL_DEPENDENCIES}) + dune_module_to_uppercase(upper ${_dep}) + set(HAVE_${upper} ${${_dep}_FOUND}) + file(APPEND ${CONFIG_H_CMAKE_FILE} + "\n\n/* Define to 1 if you have module ${_dep} available */ +#cmakedefine01 HAVE_${upper}\n") + endforeach() + + # add previous module specific section + foreach(_dep ${ALL_DEPENDENCIES}) + foreach(_mod_conf_file ${${_dep}_PREFIX}/config.h.cmake + ${${_dep}_PREFIX}/share/${_dep}/config.h.cmake) + if(EXISTS ${_mod_conf_file}) + file(READ "${_mod_conf_file}" _file) + string(REGEX REPLACE + ".*/\\*[ ]*begin[ ]+${_dep}[^\\*]*\\*/(.*)/[/\\*][ ]*end[ ]*${_dep}[^\\*]*\\*/" "\\1" + _tfile "${_file}") + # strip the private section + string(REGEX REPLACE "(.*)/[\\*][ ]*begin private.*/[\\*][ ]*end[ ]*private[^\\*]\\*/(.*)" "\\1\\2" _ttfile "${_tfile}") + + # extract the bottom section + string(REGEX MATCH "/[\\*][ ]*begin bottom.*/[\\*][ ]*end[ ]*bottom[^\\*]\\*/" _tbottom "${_ttfile}") + string(REGEX REPLACE ".*/\\*[ ]*begin[ ]+bottom[^\\*]*\\*/(.*)/[/\\*][ ]*end[ ]*bottom[^\\*]*\\*/" "\\1" ${_dep}_CONFIG_H_BOTTOM "${_tbottom}" ) + string(REGEX REPLACE "(.*)/[\\*][ ]*begin bottom.*/[\\*][ ]*end[ ]*bottom[^\\*]\\*/(.*)" "\\1\\2" _file "${_ttfile}") + + # append bottom section + if(${_dep}_CONFIG_H_BOTTOM) + set(CONFIG_H_BOTTOM "${CONFIG_H_BOTTOM} ${${_dep}_CONFIG_H_BOTTOM}") + endif() + + file(APPEND ${CONFIG_H_CMAKE_FILE} "${_file}") + endif() + endforeach() + endforeach() + # parse again dune.module file of current module to set PACKAGE_* variables + dune_module_information(${CMAKE_SOURCE_DIR} QUIET) + file(APPEND ${CONFIG_H_CMAKE_FILE} "\n${_myfile}") + # append CONFIG_H_BOTTOM section at the end if found + if(CONFIG_H_BOTTOM) + file(APPEND ${CONFIG_H_CMAKE_FILE} "${CONFIG_H_BOTTOM}") + endif() +endmacro(dune_regenerate_config_cmake) + +# macro that should be called at the end of the top level CMakeLists.txt. +# Namely it creates config.h and the cmake-config files, +# some install directives and exports the module. +macro(finalize_dune_project) + if(DUNE_SYMLINK_TO_SOURCE_TREE) + dune_symlink_to_source_tree() + endif() + + #configure all headerchecks + finalize_headercheck() + + #create cmake-config files for installation tree + include(CMakePackageConfigHelpers) + include(GNUInstallDirs) + set(DOXYSTYLE_DIR ${CMAKE_INSTALL_DATAROOTDIR}/dune-common/doc/doxygen/) + set(SCRIPT_DIR ${CMAKE_INSTALL_DATAROOTDIR}/dune/cmake/scripts) + # Set the location where the doc sources are installed. + # Needed by custom package configuration + # file section of dune-grid. + set(DUNE_MODULE_SRC_DOCDIR "\${${ProjectName}_PREFIX}/${CMAKE_INSTALL_DOCDIR}") + + if(NOT EXISTS ${PROJECT_SOURCE_DIR}/cmake/pkg/${ProjectName}-config.cmake.in) + # Generate a standard cmake package configuration file + file(WRITE ${PROJECT_BINARY_DIR}/CMakeFiles/${ProjectName}-config.cmake.in +"if(NOT ${ProjectName}_FOUND) +# Whether this module is installed or not +set(${ProjectName}_INSTALLED @MODULE_INSTALLED@) + +# Settings specific to the module +@${ProjectName}_INIT@ +# Package initialization +@PACKAGE_INIT@ + +#report other information +set_and_check(${ProjectName}_PREFIX \"\${PACKAGE_PREFIX_DIR}\") +set_and_check(${ProjectName}_INCLUDE_DIRS \"@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@\") +set(${ProjectName}_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\") +set(${ProjectName}_CXX_FLAGS_DEBUG \"${CMAKE_CXX_FLAGS_DEBUG}\") +set(${ProjectName}_CXX_FLAGS_MINSIZEREL \"${CMAKE_CXX_FLAGS_MINSIZEREL}\") +set(${ProjectName}_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE}\") +set(${ProjectName}_CXX_FLAGS_RELWITHDEBINFO \"${CMAKE_CXX_FLAGS_RELWITHDEBINFO}\") +set(${ProjectName}_DEPENDS \"@${ProjectName}_DEPENDS@\") +set(${ProjectName}_SUGGESTS \"@${ProjectName}_SUGGESTS@\") +set(${ProjectName}_MODULE_PATH \"@PACKAGE_DUNE_INSTALL_MODULEDIR@\") +set(${ProjectName}_LIBRARIES \"@DUNE_MODULE_LIBRARIES@\") + +# Lines that are set by the CMake build system via the variable DUNE_CUSTOM_PKG_CONFIG_SECTION +${DUNE_CUSTOM_PKG_CONFIG_SECTION} + +#import the target +if(${ProjectName}_LIBRARIES) + get_filename_component(_dir \"\${CMAKE_CURRENT_LIST_FILE}\" PATH) + include(\"\${_dir}/${ProjectName}-targets.cmake\") +endif() +endif()") + set(CONFIG_SOURCE_FILE ${PROJECT_BINARY_DIR}/CMakeFiles/${ProjectName}-config.cmake.in) + else() + set(CONFIG_SOURCE_FILE ${PROJECT_SOURCE_DIR}/cmake/pkg/${ProjectName}-config.cmake.in) + endif() + get_property(DUNE_MODULE_LIBRARIES GLOBAL PROPERTY DUNE_MODULE_LIBRARIES) + + # compute under which libdir the package configuration files are to be installed. + # If the module installs an object library we use CMAKE_INSTALL_LIBDIR + # to capture the multiarch triplet of Debian/Ubuntu. + # Otherwise we fall back to DUNE_INSTALL_NONOBJECTLIB which is lib + # if not set otherwise. + get_property(DUNE_MODULE_LIBRARIES GLOBAL PROPERTY DUNE_MODULE_LIBRARIES) + if(DUNE_MODULE_LIBRARIES) + set(DUNE_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) + else() + set(DUNE_INSTALL_LIBDIR ${DUNE_INSTALL_NONOBJECTLIBDIR}) + endif() + + # Set the location of the doc file source. Needed by custom package configuration + # file section of dune-grid. + set(DUNE_MODULE_SRC_DOCDIR "${PROJECT_SOURCE_DIR}/doc") + set(MODULE_INSTALLED ON) + + configure_package_config_file(${CONFIG_SOURCE_FILE} + ${PROJECT_BINARY_DIR}/cmake/pkg/${ProjectName}-config.cmake + INSTALL_DESTINATION ${DUNE_INSTALL_LIBDIR}/cmake/${ProjectName} + PATH_VARS CMAKE_INSTALL_DATAROOTDIR DUNE_INSTALL_MODULEDIR CMAKE_INSTALL_INCLUDEDIR + DOXYSTYLE_DIR SCRIPT_DIR) + + + #create cmake-config files for build tree + set(PACKAGE_CMAKE_INSTALL_INCLUDEDIR ${PROJECT_SOURCE_DIR}) + set(PACKAGE_CMAKE_INSTALL_DATAROOTDIR ${PROJECT_BINARY_DIR}) + set(PACKAGE_DOXYSTYLE_DIR ${PROJECT_SOURCE_DIR}/doc/doxygen) + set(PACKAGE_SCRIPT_DIR ${PROJECT_SOURCE_DIR}/cmake/scripts) + set(PACKAGE_DUNE_INSTALL_MODULEDIR ${PROJECT_SOURCE_DIR}/cmake/modules) + set(PACKAGE_PREFIX_DIR ${PROJECT_BINARY_DIR}) + set(PACKAGE_INIT "# Set prefix to source dir +set(PACKAGE_PREFIX_DIR ${PROJECT_SOURCE_DIR}) +macro(set_and_check _var _file) + set(\${_var} \"\${_file}\") + if(NOT EXISTS \"\${_file}\") + message(FATAL_ERROR \"File or directory \${_file} referenced by variable \${_var} does not exist !\") + endif() +endmacro()") + set(MODULE_INSTALLED OFF) + configure_file( + ${CONFIG_SOURCE_FILE} + ${PROJECT_BINARY_DIR}/${ProjectName}-config.cmake @ONLY) + + if(NOT EXISTS ${PROJECT_SOURCE_DIR}/${ProjectName}-config-version.cmake.in) + file(WRITE ${PROJECT_BINARY_DIR}/CMakeFiles/${ProjectName}-config-version.cmake.in +"set(PACKAGE_VERSION \"${ProjectVersionString}\") + +if(\"\${PACKAGE_FIND_VERSION_MAJOR}\" EQUAL \"${ProjectVersionMajor}\" AND + \"\${PACKAGE_FIND_VERSION_MINOR}\" EQUAL \"${ProjectVersionMinor}\") + set (PACKAGE_VERSION_COMPATIBLE 1) # compatible with newer + if (\"\${PACKAGE_FIND_VERSION}\" VERSION_EQUAL \"${ProjectVersionString}\") + set(PACKAGE_VERSION_EXACT 1) #exact match for this version + endif() +endif() +") + set(CONFIG_VERSION_FILE ${PROJECT_BINARY_DIR}/CMakeFiles/${ProjectName}-config-version.cmake.in) + else() + set(CONFIG_VERSION_FILE ${PROJECT_SOURCE_DIR}/${ProjectName}-config-version.cmake.in) + endif() + configure_file( + ${CONFIG_VERSION_FILE} + ${PROJECT_BINARY_DIR}/${ProjectName}-config-version.cmake @ONLY) + + # install dune.module file + install(FILES dune.module DESTINATION ${DUNE_INSTALL_NONOBJECTLIBDIR}/dunecontrol/${ProjectName}) + + # install cmake-config files + install(FILES ${PROJECT_BINARY_DIR}/cmake/pkg/${ProjectName}-config.cmake + ${PROJECT_BINARY_DIR}/${ProjectName}-config-version.cmake + DESTINATION ${DUNE_INSTALL_LIBDIR}/cmake/${ProjectName}) + + # install config.h + if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake) + install(FILES config.h.cmake DESTINATION share/${ProjectName}) + endif() + + # install pkg-config files + create_and_install_pkconfig(${DUNE_INSTALL_LIBDIR}) + + if("${ARGC}" EQUAL "1") + message(STATUS "Adding custom target for config.h generation") + dune_regenerate_config_cmake() + # add a target to generate config.h.cmake + add_custom_target(OUTPUT config_collected.h.cmake + COMMAND dune_regenerate_config_cmake()) + # actually write the config.h file to disk + # using generated file + configure_file(${CMAKE_CURRENT_BINARY_DIR}/config_collected.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/config.h) + else() + message(STATUS "Not adding custom target for config.h generation") + # actually write the config.h file to disk + configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) + endif() + + include(CPack) + + feature_summary(WHAT ALL) + + # check if CXX flag overloading has been enabled + # and write compiler script (see OverloadCompilerFlags.cmake) + finalize_compiler_script() +endmacro(finalize_dune_project) + +macro(target_link_dune_default_libraries _target) + foreach(_lib ${DUNE_DEFAULT_LIBS}) + target_link_libraries(${_target} ${_lib}) + endforeach() +endmacro(target_link_dune_default_libraries) + +function(dune_expand_object_libraries _SOURCES_var _ADD_LIBS_var _COMPILE_FLAGS_var) + set(_new_SOURCES "") + set(_new_ADD_LIBS "${${_ADD_LIBS_var}}") + set(_new_COMPILE_FLAGS "${${_COMPILE_FLAGS_var}}") + set(_regex "_DUNE_TARGET_OBJECTS:([a-zA-Z0-9_-]+)_") + foreach(_source ${${_SOURCES_var}}) + string(REGEX MATCH ${_regex} _matched "${_source}") + if(_matched) + string(REGEX REPLACE "${_regex}" "\\1" _basename "${_source}") + foreach(var _SOURCES _ADD_LIBS _COMPILE_FLAGS) + get_property(_prop GLOBAL PROPERTY DUNE_LIB_${_basename}${var}) + list(APPEND _new${var} "${_prop}") + endforeach() + else() + list(APPEND _new_SOURCES "${_source}") + endif() + endforeach() + + foreach(var _SOURCES _ADD_LIBS _COMPILE_FLAGS) + set(${${var}_var} "${_new${var}}" PARENT_SCOPE) + endforeach() +endfunction(dune_expand_object_libraries) + +# Creates shared and static libraries with the same basename. +# More docu can be found at the top of this file. +macro(dune_add_library basename) + include(CMakeParseArguments) + cmake_parse_arguments(DUNE_LIB ";APPEND;NO_EXPORT;OBJECT" "COMPILE_FLAGS" + "ADD_LIBS;SOURCES" ${ARGN}) + if(DUNE_LIB_OBJECT) + if(DUNE_LIB_${basename}_SOURCES) + message(FATAL_ERROR "There is already a library with the name ${basename}, " + "but only one is allowed!") + else() + foreach(source ${DUNE_LIB_UNPARSED_ARGUMENTS}) + list(APPEND full_path_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source}) + endforeach() + # register sources, libs and flags for building the library later + define_property(GLOBAL PROPERTY DUNE_LIB_${basename}_SOURCES + BRIEF_DOCS "Convenience property with sources for library ${basename}. DO NOT EDIT!" + FULL_DOCS "Convenience property with sources for library ${basename}. DO NOT EDIT!") + set_property(GLOBAL PROPERTY DUNE_LIB_${basename}_SOURCES + "${full_path_sources}") + define_property(GLOBAL PROPERTY DUNE_LIB_${basename}_ADD_LIBS + BRIEF_DOCS "Convenience property with libraries for library ${basename}. DO NOT EDIT!" + FULL_DOCS "Convenience property with libraries for library ${basename}. DO NOT EDIT!") + set_property(GLOBAL PROPERTY DUNE_LIB_${basename}_ADD_LIBS + "${DUNE_LIB_ADD_LIBS}") + define_property(GLOBAL PROPERTY DUNE_LIB_${basename}_COMPILE_FLAGS + BRIEF_DOCS "Convenience property with compile flags for library ${basename}. DO NOT EDIT!" + FULL_DOCS "Convenience property with compile flags for library ${basename}. DO NOT EDIT!") + set_property(GLOBAL PROPERTY DUNE_LIB_${basename}_COMPILE_FLAGS + "${DUNE_LIB_COMPILE_FLAGS}") + endif() + else(DUNE_LIB_OBJECT) + list(APPEND DUNE_LIB_SOURCES ${DUNE_LIB_UNPARSED_ARGUMENTS}) + dune_expand_object_libraries(DUNE_LIB_SOURCES DUNE_LIB_ADD_LIBS DUNE_LIB_COMPILE_FLAGS) + #create lib + add_library(${basename} ${DUNE_LIB_SOURCES}) + get_property(_prop GLOBAL PROPERTY DUNE_MODULE_LIBRARIES) + set_property(GLOBAL PROPERTY DUNE_MODULE_LIBRARIES ${_prop} ${basename}) + # link with specified libraries. + if(DUNE_LIB_ADD_LIBS) + dune_target_link_libraries(${basename} "${DUNE_LIB_ADD_LIBS}") + endif() + if(DUNE_LIB_COMPILE_FLAGS) + set_property(${basename} APPEND_STRING COMPILE_FLAGS + "${DUNE_LIB_COMPILE_FLAGS}") + endif() + # Build library in ${PROJECT_BINARY_DIR}/lib + set_target_properties(${basename} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") + + set(_created_libs ${basename}) + + if(DUNE_BUILD_BOTH_LIBS) + if(BUILD_SHARED_LIBS) + #create static lib + add_library(${basename}-static STATIC ${DUNE_LIB_SOURCES}) + # make sure both libs have the same name. + set_target_properties(${basename}-static PROPERTIES + OUTPUT_NAME ${basename} + ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") + list(APPEND _created_libs ${basename}-static) + # link with specified libraries. + if(DUNE_LIB_ADD_LIBS) + dune_target_link_libraries(${basename}-static "${DUNE_LIB_ADD_LIBS}") + endif() + if(DUNE_LIB_COMPILE_FLAGS) + set_property(${basename}-static APPEND_STRING COMPILE_FLAGS + "${DUNE_LIB_COMPILE_FLAGS}") + endif() + else() + #create shared libs + add_library(${basename}-shared SHARED ${DUNE_LIB_SOURCES}) + set_target_properties(${basename}-shared PROPERTIES + OUTPUT_NAME ${basename} + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") + # link with specified libraries. + if(DUNE_LIB_ADD_LIBS) + dune_target_link_libraries(${basename}-shared "${DUNE_LIB_ADD_LIBS}") + endif() + if(DUNE_LIB_COMPILE_FLAGS) + set_property(${basename}-shared APPEND_STRING COMPILE_FLAGS + "${DUNE_LIB_COMPILE_FLAGS}") + endif() + list(APPEND _created_libs ${basename}-shared) + endif() + endif() + + if(NOT DUNE_LIB_NO_EXPORT) + # The follwing allows for adding multiple libs in the same + # directory or below with passing the APPEND keyword. + # If there are additional calls to dune_add_library in other + # modules then you have to use APPEND or otherwise only the + # last lib will get exported as a target. + if(NOT _MODULE_EXPORT_USED) + set(_MODULE_EXPORT_USED ON) + set(_append "") + else() + set(_append APPEND) + endif() + # Allow to explicitly pass APPEND + if(DUNE_LIB_APPEND) + set(_append APPEND) + endif() + + # install targets to use the libraries in other modules. + install(TARGETS ${_created_libs} + EXPORT ${ProjectName}-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(EXPORT ${ProjectName}-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${ProjectName}) + + # export libraries for use in build tree + export(TARGETS ${_created_libs} ${_append} + FILE ${PROJECT_BINARY_DIR}/${ProjectName}-targets.cmake) + endif() + endif() +endmacro(dune_add_library basename sources) + +macro(replace_properties_for_one) + get_property(properties ${option_command} ${_target} + PROPERTY ${REPLACE_PROPERTY}) + if(NOT properties) + # property not set. set it directly + foreach(i RANGE 0 ${hlength}) + math(EXPR idx "(2 * ${i}) + 1") + list(GET REPLACE_UNPARSED_ARGUMENTS ${idx} repl) + list(APPEND replacement ${repl}) + endforeach() + list(REMOVE_DUPLICATES replacement) + set_property(${option_command} ${_target} ${REPLACE_APPEND} + ${REPLACE_APPEND_STRING} PROPERTY ${REPLACE_PROPERTY} ${replacement}) + else() + foreach(prop ${properties}) + set(matched FALSE) + foreach(i RANGE 0 ${hlength}) + math(EXPR regexi "2 * ${i}") + math(EXPR repli "${regexi} +1") + list(GET REPLACE_UNPARSED_ARGUMENTS ${regexi} regex) + list(GET REPLACE_UNPARSED_ARGUMENTS ${repli} replacement) + string(REGEX MATCH ${regex} match ${prop}) + + if(match) + list(APPEND new_props ${replacement}) + set(matched TRUE) + endif() + endforeach() + + if(NOT matched) + list(APPEND new_props ${prop}) + endif() + endforeach() + list(REMOVE_DUPLICATES new_props) + set_property(${option_command} ${_target} + PROPERTY ${REPLACE_PROPERTY} ${new_props}) + endif() + get_property(properties ${option_command} ${_target} PROPERTY ${REPLACE_PROPERTY}) +endmacro(replace_properties_for_one) + +function(dune_target_link_libraries basename libraries) + target_link_libraries(${basename} ${libraries}) + if(DUNE_BUILD_BOTH_LIBS) + if(BUILD_SHARED_LIBS) + target_link_libraries(${basename}-static ${libraries}) + else() + target_link_libraries(${basename}-shared ${libraries}) + endif() + endif() +endfunction(dune_target_link_libraries basename libraries) + +function(replace_properties) + include(CMakeParseArguments) + set(_first_opts "GLOBAL;DIRECTORY;TARGET;SOURCE;CACHE") + cmake_parse_arguments(REPLACE "GLOBAL" + "DIRECTORY;PROPERTY" "TARGET;SOURCE;TEST;CACHE" ${ARGN}) + + set(MY_DIRECTORY TRUE) + foreach(i ${_first_opts}) + if(REPLACE_${i}) + set(MY_DIRECTORY FALSE) + endif() + endforeach() + if(NOT MY_DIRECTORY) + list(FIND REPLACE_UNPARSED_ARGUMENTS DIRECTORY _found) + if(_found GREATER -1) + list(REMOVE_AT REPLACE_UNPARSED_ARGUMENTS ${_found}) + set(MY_DIRECTORY TRUE) + set(REPLACE_DIRECTORY "") + endif() + endif() + + # setup options + if(REPLACE_GLOBAL) + set(option_command GLOBAL) + elseif(MY_DIRECTORY) + set(option_command DIRECTORY) + elseif(REPLACE_DIRECTORY) + set(option_command DIRECTORY) + set(option_arg ${REPLACE_DIRECTORY}) + elseif(REPLACE_TARGET) + set(option_command TARGET) + set(option_arg ${REPLACE_TARGET}) + elseif(REPLACE_SOURCE) + set(option_command SOURCE) + set(option_arg ${REPLACE_SOURCE}) + elseif(REPLACE_TEST) + set(option_command TEST) + set(option_arg${REPLACE_TEST}) + elseif(REPLACE_CACHE) + set(option_command CACHE) + set(option_arg ${REPLACE_CACHE}) + endif() + + if(NOT (REPLACE_CACHE OR REPLACE_TEST OR REPLACE_SOURCE + OR REPLACE_TARGET OR REPLACE_DIRECTORY OR REPLACE_GLOBAL + OR MY_DIRECTORY)) + message(ERROR "One of GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, or CACHE" + " has to be present") + endif() + + list(LENGTH REPLACE_UNPARSED_ARGUMENTS length) +# if(NOT (REPLACE_GLOBAL AND REPLACE_TARGET AND +# REPLACE_SOURCE AND REPLACE + math(EXPR mlength "${length} % 2 ") + math(EXPR hlength "${length} / 2 - 1") + + if(NOT ${mlength} EQUAL 0) + message(ERROR "You need to specify pairs consisting of a regular expression and a replacement string.") + endif() + + if(NOT length GREATER 0) + message(ERROR "You need to specify at least on pair consisting of a regular expression +and a replacement string. ${REPLACE_UNPARSED_ARGUMENTS}") + endif() + + foreach(_target ${option_arg}) + replace_properties_for_one() + endforeach() + + list(LENGTH option_arg _length) + if(_length EQUAL 0) + replace_properties_for_one() + endif() +endfunction(replace_properties) + +macro(add_dune_all_flags targets) + get_property(incs GLOBAL PROPERTY ALL_PKG_INCS) + get_property(defs GLOBAL PROPERTY ALL_PKG_DEFS) + get_property(libs GLOBAL PROPERTY ALL_PKG_LIBS) + foreach(target ${targets}) + set_property(TARGET ${target} APPEND PROPERTY INCLUDE_DIRECTORIES ${incs}) + set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS ${defs}) + target_link_libraries(${target} ${DUNE_LIBS} ${libs}) + endforeach() +endmacro(add_dune_all_flags targets) diff -Nru dune-common-2.2.1/cmake/modules/DuneMPI.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneMPI.cmake --- dune-common-2.2.1/cmake/modules/DuneMPI.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneMPI.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,66 @@ +# Searches for MPI and thread support and sets the following +# DUNE specific flags: +# +# MPI_DUNE_COMPILE_FLAGS Compiler flags for MPI applications. +# MPI_DUNE_INCLUDE_PATH Include path for MPI applications. +# MPI_DUNE_LINK_FLAGS Linker flags for MPI applications. +# MPI_DUNE_LIBRARIES Libraries for MPI applications. +# +# The DUNE way to compile MPI applications is to use the CXX +# compiler with MPI flags usually used for C. CXX bindings +# are deactivated to prevent ABI problems. +# +# .. cmake_function:: add_dune_mpi_flags +# +# .. cmake_param:: targets +# :single: +# :required: +# :positional: +# +# The target list to add the MPI flags to. +# + + +find_package(MPI) +find_package(Threads) + +if(MPI_C_FOUND) + set(HAVE_MPI ${MPI_C_FOUND}) + # We do not support the CXX bindings of MPI + set(MPI_DUNE_COMPILE_FLAGS ${MPI_C_COMPILE_FLAGS} CACHE STRING + "Compile flags used by DUNE when compiling MPI programs") + set(MPI_DUNE_INCLUDE_PATH ${MPI_C_INCLUDE_PATH} CACHE STRING + "Include path used by DUNE when compiling MPI programs") + # There seems to be no target specific include path, use the global one. + include_directories(${MPI_DUNE_INCLUDE_PATH}) + set(MPI_DUNE_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING + "Linker flags used by DUNE when compiling MPI programs") + set(MPI_DUNE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${MPI_C_LIBRARIES} CACHE STRING + "Libraries used by DUNE when linking MPI programs") + + # TODO check on where to position this exactly, doesn't look completely thought through + dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_MPI=1;MPICH_SKIP_MPICXX;MPIPP_H" + INCLUDE_DIRS "${MPI_DUNE_INCLUDE_PATH}" + LIBRARIES "${MPI_DUNE_LIBRARIES}") +endif(MPI_C_FOUND) + +# adds MPI flags to the targets +function(add_dune_mpi_flags) + cmake_parse_arguments(ADD_MPI "SOURCE_ONLY;OBJECT" "" "" ${ARGN}) + if(ADD_MPI_SOURCE_ONLY) + set(_prefix SOURCE) + else() + set(_prefix TARGET) + endif() + if(MPI_C_FOUND) + set_property(${_prefix} ${ADD_MPI_UNPARSED_ARGUMENTS} APPEND PROPERTY COMPILE_FLAGS ${MPI_DUNE_COMPILE_FLAGS}) + set_property(${_prefix} ${ADD_MPI_UNPARSED_ARGUMENTS} APPEND PROPERTY COMPILE_DEFINITIONS ENABLE_MPI=1 + MPICH_SKIP_MPICXX MPIPP_H) + if(NOT (ADD_MPI_SOURCE_ONLY OR ADD_MPI_OBJECT)) + set_property(${_prefix} ${ADD_MPI_UNPARSED_ARGUMENTS} APPEND_STRING PROPERTY LINK_FLAGS ${MPI_DUNE_LINK_FLAGS}) + foreach(target ${ADD_MPI_UNPARSED_ARGUMENTS}) + target_link_libraries(${target} ${MPI_DUNE_LIBRARIES}) + endforeach(target ${ADD_MPI_UNPARSED_ARGUMENTS}) + endif(NOT (ADD_MPI_SOURCE_ONLY OR ADD_MPI_OBJECT)) + endif(MPI_C_FOUND) +endfunction(add_dune_mpi_flags) diff -Nru dune-common-2.2.1/cmake/modules/DunePathHelper.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePathHelper.cmake --- dune-common-2.2.1/cmake/modules/DunePathHelper.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePathHelper.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,101 @@ +# Some helper functions for people developing the CMake build system +# to get quick and easy access to path variables of Dune modules. +# +# .. cmake_function:: dune_module_path +# +# .. cmake_param:: MODULE +# :single: +# :required: +# +# The name of the module. +# +# .. cmake_param:: RESULT +# :single: +# :required: +# +# The name of the variable to export the result. +# +# .. cmake_param:: CMAKE_MODULES +# :option: +# +# Set to return the path to cmake modules +# +# .. cmake_param:: BUILD_DIR +# :option: +# +# Set to return the path to the build directory +# +# .. cmake_param:: SOURCE_DIR +# :option: +# +# Set to return the include path of the module +# +# .. cmake_param:: SCRIPT_DIR +# :option: +# +# Set to return the CMake script dir +# +# +# Returns the specified path of the given module. This differs +# whether it is called from the actual module, or from a module +# requiring or suggesting this module. One and only one type of path +# may be requested. +# + +function(dune_module_path) + # Parse Arguments + set(OPTION CMAKE_MODULES BUILD_DIR SOURCE_DIR SCRIPT_DIR) + set(SINGLE MODULE RESULT) + set(MULTI) + include(CMakeParseArguments) + cmake_parse_arguments(PATH "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN}) + if(PATH_UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments in dune_module_path: This often indicates typos!") + endif() + + # Check whether one and only one path type was set. + set(OPTION_FOUND 0) + foreach(opt ${OPTION}) + if(${PATH_${opt}}) + if(OPTION_FOUND) + message(FATAL_ERROR "Cannot request two different paths from dune_module_path") + else() + set(OPTION_FOUND 1) + endif() + endif() + endforeach() + if(NOT OPTION_FOUND) + message(FATAL_ERROR "Cannot determine type of requested path!") + endif() + + # Set the requested paths for the cmake module path + if(PATH_CMAKE_MODULES) + set(IF_CURRENT_MOD ${CMAKE_SOURCE_DIR}/cmake/modules) + set(IF_NOT_CURRENT_MOD ${${PATH_MODULE}_MODULE_PATH}) + endif() + + # Set the requested paths for the cmake script path + if(PATH_SCRIPT_DIR) + set(IF_CURRENT_MOD ${CMAKE_SOURCE_DIR}/cmake/scripts) + set(IF_NOT_CURRENT_MOD ${${PATH_MODULE}_SCRIPT_DIR}) + endif() + + # Set the requested paths for the build directory + if(PATH_BUILD_DIR) + set(IF_CURRENT_MOD ${CMAKE_BINARY_DIR}) + set(IF_NOT_CURRENT_MOD ${${PATH_MODULE}_DIR}) + endif() + + # Set the requested paths for the include directory + if(PATH_SOURCE_DIR) + set(IF_CURRENT_MOD ${CMAKE_SOURCE_DIR}) + set(IF_NOT_CURRENT_MOD ${${PATH_MODULE}_PREFIX}) + endif() + + # Now set the path in the outer scope! + if(CMAKE_PROJECT_NAME STREQUAL ${PATH_MODULE}) + set(${PATH_RESULT} ${IF_CURRENT_MOD} PARENT_SCOPE) + else() + set(${PATH_RESULT} ${IF_NOT_CURRENT_MOD} PARENT_SCOPE) + endif() +endfunction() diff -Nru dune-common-2.2.1/cmake/modules/DunePkgConfig.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePkgConfig.cmake --- dune-common-2.2.1/cmake/modules/DunePkgConfig.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePkgConfig.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,43 @@ +# searches for pkg-config, creates the +# file .pc from .pc.in, +# and adds installation directives. +# + +find_package(PkgConfig) + +function(create_and_install_pkconfig installlibdir) + # set some variables that are used in the pkg-config file + include(GNUInstallDirs) + set( prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix "\${prefix}") + set(libdir "\${exec_prefix}/${installlibdir}") + set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + set(PACKAGE_NAME ${ProjectName}) + set(VERSION ${ProjectVersion}) + set(CC ${CMAKE_C_COMPILER}) + set(CXX "${CMAKE_CXX_COMPILER} ${CXX_STD11_FLAGS}") + + if(DUNE_DEPENDS) + foreach(_DUNE_DEPEND ${DUNE_DEPENDS}) + string(REGEX REPLACE "\\(" "" REQF1 ${_DUNE_DEPEND}) + string(REGEX REPLACE "\\)" "" LR ${REQF1}) + if(REQUIRES) + set(REQUIRES "${REQUIRES} ${LR}") + else() + set(REQUIRES ${LR}) + endif(REQUIRES) + endforeach(_DUNE_DEPEND ${DUNE_DEPENDS}) + endif(DUNE_DEPENDS) + + #create pkg-config file + configure_file( + ${PROJECT_SOURCE_DIR}/${ProjectName}.pc.in + ${PROJECT_BINARY_DIR}/${ProjectName}.pc + @ONLY + ) + + # install pkgconfig file + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ProjectName}.pc + DESTINATION ${installlibdir}/pkgconfig) + +endfunction(create_and_install_pkconfig) diff -Nru dune-common-2.2.1/cmake/modules/DunePythonCommonMacros.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonCommonMacros.cmake --- dune-common-2.2.1/cmake/modules/DunePythonCommonMacros.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonCommonMacros.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,160 @@ +# The python extension of the Dune cmake build system +# +# .. cmake_module:: +# +# This module is the main entry point for the python extension of the Dune cmake +# build system. It handles the detection of the python installation, defines installation +# rules for python packages in Dune modules and provides virtual environments to +# run python code from cmake. +# +# If you want to use Dune modules that provide Python functionality, you should be aware +# of some facts: +# +# * CMake looks for your python interpreter during configure. If you want to have it +# work with a virtual environment, you should activate your virtualenv before configure. +# * Each module has an additional target :code:`make install_python`, that installs python packages +# defined in the Dune module. You can customize the install location with +# :ref:`DUNE_PYTHON_INSTALL_LOCATION`. This is also included in :code:`make install`. +# * There is additional functionality, that automatically sets up a virtual environment +# at configure time, you can read more at :ref:`DunePythonVirtualenv`. +# +# After the module :code:`DunePythonCommonMacros` is run (which happens automatically when +# configuring dune-common) the following python-related variables will be set and available +# for use in downstream modules: +# +# * All variables set by :code:`FindPythonInterp.cmake` and :code:`FindPythonLibs.cmake` +# * :code:`DUNE_PYTHON_SYSTEM_IS_VIRTUALENV`: True if the given system interpreter resides in +# virtual environment. +# +# For documentation on how to customize the build process, check the input variable +# reference for any variables prefixed with :code:`DUNE_PYTHON`. To learn how to write build +# system code for Dune modules shipping python, have a look at the command reference for +# commands prefixed :code:`dune_python`. +# +# .. cmake_variable:: DUNE_PYTHON_INSTALL_LOCATION +# +# This variable can be used to control where Dune should install python +# packages. Possible values are: +# +# * :code:`user`: installs into the users home directory through :code:`pip --user`. Note, that +# this is incompatible with using virtual environments (as per pip docs). +# * :code:`system`: into the standard paths of the interpreter which was found +# by cmake. +# * :code:`none`: Never install any python packages. +# +# The default value in use depends on the system interpreter to run in a virtual environment +# or not: If it does, :code:`system` is the default, if it does not :code:`none` is the default. +# This rather unintuitive default originates from the strong belief, that installing +# python packages into the system locations at :code:`/usr/...` should be discouraged. +# +# .. cmake_variable:: DUNE_PYTHON_VIRTUALENV_SETUP +# +# Set this variable to allow the Dune build system to set up a virtualenv at +# configure time. Such virtual environment is very useful, whenever python code +# is to be run at configure time, i.e. to implement code generation in Python or +# to use Python wrappers in testing. Some downstream modules will *require* you +# to set this variable. When setting this variable, you allow the Dune buildsystem +# to install packages through :code:`pip` into a virtualenv, that resides in a cmake +# build directory. For all the information on this virtualenv, see :ref:`DunePythonVirtualenv`. +# +# .. cmake_function:: dune_python_require_virtualenv_setup +# +# Call this function from a downstream module, if that module relies on the +# the presence of the configure time virtualenv described in :ref:`DunePythonVirtualenv`. +# + +# Include all the other parts of the python extension to avoid that users need +# to explicitly include parts of our build system. +include(DunePythonFindPackage) +include(DunePythonInstallPackage) +include(DunePythonRequireVersion) +include(DunePythonTestCommand) + +# Update the list of valid python versions, the shipped CMake modules tend to outdate... +# Mention all those not present in CMake 2.8.12 +set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6) + +# Find the Python Interpreter +set(_VERSION_STRING "") +if(DUNE_PYTHON_FORCE_PYTHON2 AND DUNE_PYTHON_FORCE_PYTHON3) + message(FATAL_ERROR "Cannot enforce both python2 *and* python3") +endif() +if(DUNE_PYTHON_FORCE_PYTHON2) + set(_VERSION_STRING "2") +endif() +if(DUNE_PYTHON_FORCE_PYTHON3) + set(_VERSION_STRING "3") +endif() +find_package(PythonInterp ${_VERSION_STRING}) + +# Find the Python libraries +find_package(PythonLibs) + +# Determine whether the given interpreter is running inside a virtualenv +if(PYTHONINTERP_FOUND) + include(DuneExecuteProcess) + include(DunePathHelper) + dune_module_path(MODULE dune-common + RESULT scriptdir + SCRIPT_DIR) + + dune_execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${scriptdir}/envdetect.py" + RESULT_VARIABLE DUNE_PYTHON_SYSTEM_IS_VIRTUALENV + ) +endif() + +# Determine where to install python packages +if(NOT DUNE_PYTHON_INSTALL_LOCATION) + if(DUNE_PYTHON_SYSTEM_IS_VIRTUALENV) + set(DUNE_PYTHON_INSTALL_LOCATION "system") + else() + set(DUNE_PYTHON_INSTALL_LOCATION "none") + endif() +endif() +if(NOT(("${DUNE_PYTHON_INSTALL_LOCATION}" STREQUAL "user") OR + ("${DUNE_PYTHON_INSTALL_LOCATION}" STREQUAL "system") OR + ("${DUNE_PYTHON_INSTALL_LOCATION}" STREQUAL "none"))) + message(FATAL_ERROR "DUNE_PYTHON_INSTALL_LOCATION must be user|system|none.") +endif() +if(("${DUNE_PYTHON_INSTALL_LOCATION}" STREQUAL "user") AND + DUNE_PYTHON_SYSTEM_IS_VIRTUALENV) + message(FATAL_ERROR "Specifying 'user' as install location is incomaptible with using virtual environments (as per pip docs)") +endif() + +# Check presence of python packages required by the buildsystem +dune_python_find_package(PACKAGE pip) + +# Add python related meta targets +add_custom_target(test_python) +add_custom_target(install_python) + +# Set the path to a Dune wheelhouse that is to be used during installation +# NB: Right now, the same logic is used to retrieve the location of the +# wheelhouse (which means that you have to use the same CMAKE_INSTALL_PREFIX +# when *using* installed modules, you used when *installing* them. +# TODO: Replace this with a better mechanism (like writing the location into +# dune-commons package config file) +set(DUNE_PYTHON_WHEELHOUSE ${CMAKE_INSTALL_PREFIX}/share/dune/wheelhouse) + +# Have make install do the same as make install_python +install(CODE "set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) + set(DUNE_PYTHON_WHEELHOUSE ${DUNE_PYTHON_WHEELHOUSE}) + include(DuneExecuteProcess) + dune_execute_process(COMMAND \"${CMAKE_COMMAND}\" --build . --target install_python --config $) + ") + +# Implement a check for the presence of the virtualenv +function(dune_python_require_virtualenv_setup) + if(NOT DUNE_PYTHON_VIRTUALENV_SETUP) + message(FATAL_ERROR "\n + ${CMAKE_PROJECT_NAME} relies on a configure-time virtual environment being + set up by the Dune python build system. You have to set the CMake variable + DUNE_PYTHON_VIRTUALENV_SETUP to allow that.\n + ") + endif() +endfunction() + +# If requested, switch into DunePythonVirtualenv.cmake and setup the virtualenv. +if(DUNE_PYTHON_VIRTUALENV_SETUP) + include(DunePythonVirtualenv) +endif() diff -Nru dune-common-2.2.1/cmake/modules/DunePythonFindPackage.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonFindPackage.cmake --- dune-common-2.2.1/cmake/modules/DunePythonFindPackage.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonFindPackage.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,116 @@ +# This module provides functions to check for the existence of python packages on the host system. +# +# .. cmake_function:: dune_python_find_package +# +# .. cmake_param:: PACKAGE +# :required: +# :single: +# +# The package name to look for. +# +# .. cmake_param: RESULT +# :single: +# +# The variable to store the result of the check in +# in the calling scope. Defaults to :code:`DUNE_PYTHON__FOUND` +# Note that the package name is case sensitive and will +# usually be lowercase. +# +# .. cmake_param:: REQUIRED +# :option: +# +# If set, the function will error out if the package is not +# found. +# +# .. cmake_param:: VERSION +# :single: +# +# The minimum version of the package that is required. +# +# .. cmake_param:: EXACT +# :option: +# +# Whether the given version requirement has to be matched exactly. +# +# .. cmake_param:: INTERPRETER +# :single: +# +# The python interpreter, whose paths are searched for the package. +# Defaults to :code:`${PYTHON_EXECUTABLE}`, might differ when dealing with +# the configure-time virtualenv set up with :ref:`DUNE_PYTHON_VIRTUALENV_SETUP`. +# +# Find a given python package on the system. +# + +function(dune_python_find_package) + # Parse Arguments + set(OPTION REQUIRED EXACT) + set(SINGLE PACKAGE RESULT VERSION INTERPRETER) + set(MULTI) + include(CMakeParseArguments) + cmake_parse_arguments(PYPACKAGE "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN}) + if(PYCHECK_UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments in dune_python_find_package: This often indicates typos!") + endif() + + # Do error checking on input and apply defaults + if(NOT PYPACKAGE_RESULT) + set(PYPACKAGE_RESULT DUNE_PYTHON_${PYPACKAGE_PACKAGE}_FOUND) + endif() + if(NOT PYPACKAGE_INTERPRETER) + set(PYPACKAGE_INTERPRETER "${PYTHON_EXECUTABLE}") + endif() + if(PYPACKAGE_EXACT AND NOT PYPACKAGE_VERSION) + message(FATAL_ERROR "dune_python_find_package: EXACT given, but no VERSION specified.") + endif() + + # Do the actual check + execute_process(COMMAND "${PYPACKAGE_INTERPRETER}" -c "import ${PYPACKAGE_PACKAGE}" + RESULT_VARIABLE PYPACKAGE_RETURN + ERROR_QUIET) + + # Perform additional checks + if(PYPACKAGE_RETURN STREQUAL "0") + include(DunePathHelper) + dune_module_path(MODULE dune-common + RESULT scriptdir + SCRIPT_DIR) + + # Check the found version of the given python package + # We cannot use find_package_handle_standard_args for that, as it is too + # closely tied to using find_package(), which we cannot use for variable package + # name... + execute_process(COMMAND "${PYPACKAGE_INTERPRETER}" "${scriptdir}/pyversion.py" "${PYPACKAGE_PACKAGE}" + RESULT_VARIABLE retcode + OUTPUT_VARIABLE VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_QUIET + ) + + set(${PYPACKAGE_RESULT} TRUE) + if("${retcode}" STREQUAL "0") + if(("${VERSION_STRING}" VERSION_LESS "${PYPACKAGE_VERSION}") OR + (PYPACKAGE_EXACT AND NOT ("${VERSION_STRING}" VERSION_EQUAL "${PYPACKAGE_VERSION}"))) + set(PYPACKAGE_RESULT FALSE) + endif() + else() + set(VERSION_STRING "unknown version") + if(PYPACKAGE_VERSION) + set(${PYPACKAGE_RESULT} FALSE) + endif() + endif() + else() + set(${PYPACKAGE_RESULT} FALSE) + if(PYPACKAGE_REQUIRED) + message(FATAL_ERROR "The python package ${PYCHECK_PACKAGE} could not be found! (for interpreter ${PYPACKAGE_INTERPRETER})") + endif() + endif() + + # Set the result variable and print the result + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(${PYPACKAGE_PACKAGE}_${PYPACKAGE_INTERPRETER} + "Failed to find the python package ${PYPACKAGE_PACKAGE} with interpreter ${PYPACKAGE_INTERPRETER}." + ${PYPACKAGE_RESULT} + ) + set(${PYPACKAGE_RESULT} ${${PYPACKAGE_RESULT}} PARENT_SCOPE) +endfunction() diff -Nru dune-common-2.2.1/cmake/modules/DunePythonInstallPackage.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonInstallPackage.cmake --- dune-common-2.2.1/cmake/modules/DunePythonInstallPackage.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonInstallPackage.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,141 @@ +# This cmake module provides infrastructure for cmake installation rules concerning python packages. +# +# .. cmake_function:: dune_python_install_package +# +# .. cmake_param:: PATH +# :required: +# :single: +# +# Relative path to the given python package source code. +# +# .. cmake_param:: ADDITIONAL_PIP_PARAMS +# :multi: +# :argname: param +# +# Parameters to add to any :code:`pip install` call (appended). +# +# This function installs the python package located at the given path. It +# +# * installs it to the location specified with :ref:`DUNE_PYTHON_INSTALL_LOCATION` during +# :code:`make install_python` and during :code:`make install`. +# * installs a wheel into the Dune wheelhouse during :code:`make install`. +# This is necessary for mixing installed and non-installed Dune modules. +# +# The package at the given location is expected to be a pip-installable package. +# +# .. cmake_variable:: DUNE_PYTHON_INSTALL_EDITABLE +# +# Set this variable to have all installations of python packages use +# :code:`pip --editable`. +# + +function(dune_python_install_package) + # Parse Arguments + set(OPTION) + set(SINGLE PATH) + set(MULTI ADDITIONAL_PIP_PARAMS) + include(CMakeParseArguments) + cmake_parse_arguments(PYINST "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN}) + if(PYINST_UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments in dune_python_install_package: This often indicates typos!") + endif() + + # Check for the presence of the pip package + if(NOT DUNE_PYTHON_pip_FOUND) + message(FATAL_ERROR "dune_python_install_package: Requested installations, but pip was not found!") + endif() + + set(PYINST_FULLPATH ${CMAKE_CURRENT_SOURCE_DIR}/${PYINST_PATH}) + if(EXISTS ${PYINST_FULLPATH}/setup.py.in) + configure_file(${PYINST_PATH}/setup.py.in ${PYINST_PATH}/setup.py) + set(PYINST_FULLPATH ${CMAKE_CURRENT_BINARY_DIR}/${PYINST_PATH}) + set(PYINST_PUREPYTHON FALSE) + elseif(EXISTS ${PYINST_FULLPATH}/setup.py) + set(PYINST_PUREPYTHON TRUE) + else() + message(FATAL_ERROR "dune_python_install_package: Requested installations, but neither setup.py nor setup.py.in found!") + endif() + + # Find out whether we should install in editable mode + set(INSTALL_EDITABLE ${DUNE_PYTHON_INSTALL_EDITABLE}) + + # Construct the wheel house installation option string + set(WHEEL_OPTION "") + if(IS_DIRECTORY ${DUNE_PYTHON_WHEELHOUSE}) + set(WHEEL_OPTION "--find-links=${DUNE_PYTHON_WHEELHOUSE}") + # + # The following line is a bummer! + # We cannot have editable packages once we start using global installations! + # This is related to the nightmare that is https://github.com/pypa/pip/issues/3 + # + set(INSTALL_EDITABLE FALSE) + endif() + + # Construct the editable option string + set(EDIT_OPTION "") + if(INSTALL_EDITABLE) + set(EDIT_OPTION "-e") + endif() + + # Construct the installation location option string + set(INSTALL_OPTION "") + if("${DUNE_PYTHON_INSTALL_LOCATION}" STREQUAL "user") + set(INSTALL_OPTION "--user") + endif() + + set(INSTALL_CMDLINE -m pip install + "${INSTALL_OPTION}" "${WHEEL_OPTION}" "${EDIT_OPTION}" ${PYINST_ADDITIONAL_PIP_PARAMS} + "${PYINST_FULLPATH}") + + + # + # If requested, install into the configure-time Dune virtualenv + # + + if(PYINST_PUREPYTHON AND DUNE_PYTHON_VIRTUALENV_SETUP) + message("-- Installing python package at ${CMAKE_CURRENT_SOURCE_DIR}/${PYINST_PATH} into the virtualenv...") + dune_execute_process(COMMAND "${DUNE_PYTHON_VIRTUALENV_EXECUTABLE}" "${INSTALL_CMDLINE}" + ERROR_MESSAGE "dune_python_install_package: Error installing into virtualenv!") + endif() + + # + # Now define rules for `make install_python`. + # + + # Leave this function if no installation rules are required + if("${DUNE_PYTHON_INSTALL_LOCATION}" STREQUAL "none") + return() + endif() + + dune_module_path(MODULE dune-common + RESULT scriptdir + SCRIPT_DIR) + + # Determine a target name for installing this package + string(REPLACE "/" "_" targetname "install_python_${CMAKE_CURRENT_SOURCE_DIR}_${PYINST_PATH}") + + # Add a custom target that globally installs this package if requested + add_custom_target(${targetname} + COMMAND ${PYTHON_EXECUTABLE} ${INSTALL_CMDLINE} + COMMENT "Installing the python package at ${PYINST_FULLPATH}" + ) + + add_dependencies(install_python ${targetname}) + + # Define rules for `make install` that install a wheel into a central wheelhouse + # + # NB: This is necessary, to allow mixing installed and non-installed modules + # with python packages. The wheelhouse will allow to install any missing + # python packages into a virtual environment. + # + + # Construct the wheel installation commandline + set(WHEEL_COMMAND ${PYTHON_EXECUTABLE} -m pip wheel -w ${DUNE_PYTHON_WHEELHOUSE} ${PYINST_FULLPATH}) + + # Add the installation rule + install(CODE "message(\"Installing wheel for python package at ${PYINST_FULLPATH}...\") + dune_execute_process(COMMAND ${WHEEL_COMMAND} + ERROR_MESSAGE \"Error installing wheel for python package at ${PYINST_FULLPATH}\" + )" + ) +endfunction() diff -Nru dune-common-2.2.1/cmake/modules/DunePythonRequireVersion.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonRequireVersion.cmake --- dune-common-2.2.1/cmake/modules/DunePythonRequireVersion.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonRequireVersion.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,78 @@ +# This module provides functions to implement constraints on the version of the python interpreter. +# +# .. cmake_function:: dune_python_require_version +# +# .. cmake_param:: version +# :positional: +# :single: +# :required: +# +# The minimum required version. +# +# Error out, if the python interpreter found by cmake is older than the given version. +# Python2 and Python3 versions are not compared to each other, so you can call this +# macro multiple times to enforce minimal versions on a python2 and python3 interpreter +# independently. +# +# .. cmake_function:: dune_python_force_version +# +# .. cmake_param:: version +# :positional: +# :single: +# :required: +# +# The major python version: 2 or 3 +# +# Enforce the major version of the python interpreter to be either 2 or 3. +# +# .. note:: +# +# This is the developer-facing interface to enforce a major python version. +# A user can set the input variable :ref:`DUNE_PYTHON_FORCE_PYTHON2` or +# :ref:`DUNE_PYTHON_FORCE_PYTHON3` to achieve the same result for a given build only. +# +# .. cmake_variable:: DUNE_PYTHON_FORCE_PYTHON2 +# +# Set this variable to TRUE to force usage of a python2 interpreter. This is +# the *user-facing* interface, developers of Dune modules, may force the python +# major version through :ref:`dune_python_force_version`. +# +# .. note:: +# This does not check for the interpreter requirements of your python packages. +# If you set it and one of your packages requires python3, you will get an error. +# +# +# .. cmake_variable:: DUNE_PYTHON_FORCE_PYTHON3 +# +# Set this variable to TRUE to force usage of a python3 interpreter. This is +# the *user-facing* interface, developers of Dune modules, may force the python +# major version through :ref:`dune_python_force_version`. +# +# .. note:: +# This does not check for the interpreter requirements of your python packages. +# If you set it and one of your packages requires python2, you will get an error. +# + + +function(dune_python_require_version) + string(REPLACE "." ";" versionlist ${ARGV0}) + list(GET versionlist 0 major) + if("${major}" STREQUAL "2") + # This is a python2 requirement. + if("${PYTHON_VERSION_MAJOR}" STREQUAL "2" AND PYTHON_VERSION_STRING VERSION_LESS ${ARGV0}) + message(FATAL_ERROR "${CMAKE_PROJECT_NAME} requires at least python ${ARGV0}") + endif() + else() + # This is a python3 requirement. + if("${PYTHON_VERSION_MAJOR}" STREQUAL "3" AND PYTHON_VERSION_STRING VERSION_LESS ${ARGV0}) + message(FATAL_ERROR "${CMAKE_PROJECT_NAME} requires at least python ${ARGV0}") + endif() + endif() +endfunction() + + +function(dune_python_force_version) + if(NOT "${PYTHON_VERSION_MAJOR}" STREQUAL "${ARGV0}") + message(FATAL_ERROR "${CMAKE_PROJECT_NAME} requires python ${ARGV0}!") + endif() +endfunction() diff -Nru dune-common-2.2.1/cmake/modules/DunePythonTestCommand.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonTestCommand.cmake --- dune-common-2.2.1/cmake/modules/DunePythonTestCommand.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonTestCommand.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,78 @@ +# Wrap python testing commands into the CMake build system +# +# .. cmake_function:: dune_python_add_test +# +# .. cmake_param:: COMMAND +# :multi: +# :required: +# +# The command to run. It will be executed during :code:`make test_python` +# and during `ctest`. +# +# .. note:: +# +# If your testing command involces an invocation of the python +# interpreter you should use :code:`${PYTHON_EXECUTABLE}` for that. +# Also calling python executables through :code:`-m` is generally to +# be favored, e.g. :code:`${PYTHON_EXECUTABLE} -m pytest` instead of +# :code:`py.test`. +# +# .. cmake_param:: WORKING_DIRECTORY +# :single: +# :argname: dir +# +# The working directory of the command. Defaults to +# the current build directory. +# +# .. cmake_param:: NAME +# :single: +# +# A name to identify this test in ctest. Names must be unique throughout +# the project. If omitted, defaults to mangling of the command. +# +# Integrates a python testing framework command into the Dune +# build system. Added commands are run, when the target +# :code:`test_python` is built and during :code:`ctest`. +# + +function(dune_python_add_test) + # Parse Arguments + set(OPTION) + set(SINGLE WORKING_DIRECTORY NAME) + set(MULTI COMMAND) + include(CMakeParseArguments) + cmake_parse_arguments(PYTEST "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN}) + if(PYTEST_UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments in dune_python_add_test: This often indicates typos!") + endif() + + # Apply defaults + if(NOT PYTEST_WORKING_DIRECTORY) + set(PYTEST_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() + if(NOT PYTEST_COMMAND) + message(FATAL_ERROR "dune_python_add_test: no COMMAND to execute specified!") + endif() + if(NOT PYTEST_NAME) + set(commandstr "") + foreach(comm ${PYTEST_COMMAND}) + set(commandstr "${commandstr}_${comm}") + endforeach() + set(commandstr "${commandstr}_${PYTEST_WORKING_DIRECTORY}") + string(REPLACE "/" "_" PYTEST_NAME ${commandstr}) + endif() + + # Actually run the command + add_custom_target(target_${PYTEST_NAME} + COMMAND ${PYTEST_COMMAND} + WORKING_DIRECTORY ${PYTEST_WORKING_DIRECTORY}) + + # Build this during make test_python + add_dependencies(test_python target_${PYTEST_NAME}) + + # Also build this during ctest + _add_test(NAME ${PYTEST_NAME} + COMMAND ${PYTEST_COMMAND} + WORKING_DIRECTORY ${PYTEST_WORKING_DIRECTORY} + ) +endfunction() diff -Nru dune-common-2.2.1/cmake/modules/DunePythonVirtualenv.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonVirtualenv.cmake --- dune-common-2.2.1/cmake/modules/DunePythonVirtualenv.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DunePythonVirtualenv.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,151 @@ +# Manage the creation of a configure-time virtual environment +# +# .. cmake_module:: +# +# This module manages the creation of virtual python environment during +# configuration. Execution of this module must be explicitly enabled by +# setting the variable :ref:`DUNE_PYTHON_VIRTUALENV_SETUP`. Note that some +# downstream modules will require you to set this variable. The purpose +# of this virtual environment is to be able to run python code from cmake +# in situations such as python-based code generation, running postprocessing +# in python during testing etc. +# +# Although designed for internal use, this virtualenv can also be manually +# inspected. A symlink to the activation script is placed in the top level +# build directory of all Dune modules in the stack. To directly execute a +# command in the virtualenv, you can use the script :code:`run-in-dune-env `, +# which is also placed into every build directory. +# +# All packages installed with :ref:`dune_python_install_package` are automatically +# installed into the virtualenv. +# +# After execution of this module, the following are available for use in +# downstream modules: +# +# * :code:`DUNE_PYTHON_VIRTUALENV_PATH` The path of the virtual environment +# * :code:`DUNE_PYTHON_VIRTUALENV_EXECUTABLE` The python interpreter in the virtual environment +# +# The created virtualenv resides in the first non-installed Dune module of +# the module stack (if no installation is performed: dune-common). Be aware +# that mixing installed and non-installed modules may result in a situation, +# where multiple such environments are created, although only one should. +# This is a known issue for now, a proper solution would offload the positioning +# of the environment to a tool with a broader scope, such as dunecontrol. +# +# .. cmake_variable:: DUNE_PYTHON_ALLOW_GET_PIP +# +# Set this variable to allow the Dune build system to download :code:`get-pip.py` +# from https://bootstrap.pypa.io/get-pip.py at configure time and execute it +# to install pip into the freshly set up virtual environment. This step became +# necessary because of a debian bug: +# https://bugs.launchpad.net/debian/+source/python3.4/+bug/1290847 +# +# If you do not want the Dune build system to download :code:`get-pip.py`, you can +# manually activate the virtual environment (sourcing the activate script +# symlinked into the build directories), install pip through your favorite +# method and reconfigure. +# + +# First, we look through the dependency tree of this module for a build directory +# that already contains a virtual environment. +set(DUNE_PYTHON_VIRTUALENV_PATH) +foreach(mod ${ALL_DEPENDENCIES}) + if(IS_DIRECTORY ${${mod}_DIR}/dune-env) + set(DUNE_PYTHON_VIRTUALENV_PATH ${${mod}_DIR}/dune-env) + endif() + # check in the current build directory - this might be a reconfigure + if(IS_DIRECTORY ${CMAKE_BINARY_DIR}/dune-env) + set(DUNE_PYTHON_VIRTUALENV_PATH ${CMAKE_BINARY_DIR}/dune-env) + endif() +endforeach() + +# If it does not yet exist, set it up! +if(NOT DUNE_PYTHON_VIRTUALENV_PATH) + # Check for presence of the virtualenv/venv package + dune_python_find_package(PACKAGE virtualenv) + dune_python_find_package(PACKAGE venv) + if(NOT(DUNE_PYTHON_virtualenv_FOUND OR DUNE_PYTHON_venv_FOUND)) + message(FATAL_ERROR "One of the python packages virtualenv/venv is needed on the host system!") + endif() + + # Set some options depending on which virtualenv package is used + if(DUNE_PYTHON_virtualenv_FOUND) + set(VIRTUALENV_PACKAGE_NAME virtualenv) + set(NOPIP_OPTION --no-pip) + endif() + if(DUNE_PYTHON_venv_FOUND) + set(VIRTUALENV_PACKAGE_NAME venv) + set(NOPIP_OPTION --without-pip) + endif() + + # Set up the env itself + message("-- Building a virtual env in ${CMAKE_BINARY_DIR}/dune-env...") + dune_execute_process(COMMAND ${PYTHON_EXECUTABLE} + -m ${VIRTUALENV_PACKAGE_NAME} + ${NOPIP_OPTION} + ${CMAKE_BINARY_DIR}/dune-env + ERROR_MESSAGE "Fatal error when setting up a virtualenv." + ) + + # And set the path to it + set(DUNE_PYTHON_VIRTUALENV_PATH ${CMAKE_BINARY_DIR}/dune-env) +endif() + +# Also store the virtual env interpreter directly +set(DUNE_PYTHON_VIRTUALENV_EXECUTABLE ${DUNE_PYTHON_VIRTUALENV_PATH}/bin/python) + +# Write a symlink for activation of the environment into all the +# build directories of the Dune stack +dune_execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${DUNE_PYTHON_VIRTUALENV_PATH}/bin/activate ${CMAKE_BINARY_DIR}/activate) + +# Also write a small wrapper script 'run-in-dune-env' into the build directory +# This is necessary to execute installed python scripts (the bin path of a virtualenv +# is *not* in the sys path, so a simple `python scriptname` does not work. +if(UNIX) + find_package(UnixCommands QUIET) + dune_module_path(MODULE dune-common + RESULT scriptdir + SCRIPT_DIR) + configure_file(${scriptdir}/run-in-dune-env.sh.in + ${CMAKE_BINARY_DIR}/run-in-dune-env + @ONLY) +else() + message(WARNING "Writing script 'run-in-dune-env' not implemented on your platform!") +endif() + +# We previously omitted pip from the env, because of this Debian bug: +# https://bugs.launchpad.net/debian/+source/python3.4/+bug/1290847 +# We now, need to install pip. Easiest way is to download the get-pip +# script. We ask users for permission to do so, or we allow them to +# set it up themselves. +dune_python_find_package(PACKAGE pip + RESULT pippresent + INTERPRETER ${DUNE_PYTHON_VIRTUALENV_EXECUTABLE} + ) +if(NOT pippresent) + if(DUNE_PYTHON_ALLOW_GET_PIP) + # Fetch the get-pip.py script + message("-- Installing pip using https://bootstrap.pypa.io/get-pip.py...") + file(DOWNLOAD https://bootstrap.pypa.io/get-pip.py ${CMAKE_CURRENT_BINARY_DIR}/get-pip.py) + + # Verify that the script was successfully fetched + file(READ ${CMAKE_CURRENT_BINARY_DIR}/get-pip.py verify LIMIT 1) + if(NOT verify) + message(FATAL_ERROR " + Fetching get-pip.py failed. This often happens when CMake is built from source without SSL/TLS support. + Consider using a different cmake version or fall back to manually installing pip into the virtualenv. + ") + endif() + + # Execute the script + dune_execute_process(COMMAND ${DUNE_PYTHON_VIRTUALENV_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/get-pip.py + ERROR_MESSAGE "Fatal error when installing pip into the virtualenv." + ) + else() + message(FATAL_ERROR "dune-common set up a virtualenv, but needs pip to be installed into it. + You can either install it yourself manually activating the virtualenv with + the activate script in your build directory ${CMAKE_BINARY_DIR} or you set + the CMake variable DUNE_PYTHON_ALLOW_GET_PIP to allow Dune to use get-pip.py + from https://bootstrap.pypa.io/get-pip.py") + endif() +endif() \ No newline at end of file diff -Nru dune-common-2.2.1/cmake/modules/DuneSphinxCMakeDoc.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneSphinxCMakeDoc.cmake --- dune-common-2.2.1/cmake/modules/DuneSphinxCMakeDoc.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneSphinxCMakeDoc.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,179 @@ +# Module to generate CMake API documentation with Sphinx +# +# .. cmake_function:: dune_cmake_sphinx_doc +# +# .. cmake_brief:: +# +# Generate the documentation that you are just browsing!!! +# +# .. cmake_param:: BUILDTYPE +# :multi: +# +# Set the type of build that is requested. By default, "html" is chosen. +# The list of available build types: +# +# * `html` +# +# .. cmake_param:: SPHINX_CONF +# :single: +# :argname: conf +# +# A template for a conf file to be passed to :code:`sphinx-build`. +# The real configuration file will be generated through CMakes +# :code:`configure_file` mechanism. A reasonable default file is +# provided by dune-common. Only use this if you want to create +# custom documentation. +# +# .. cmake_param:: RST_SOURCES +# :multi: +# :argname: src +# +# A list of rst sources, that should be configured into the build tree +# (using :code:`configure_file`). If omitted, this defaults to +# :code:`index.rst` and :code:`contents.rst` with suitable content. +# Only use this if you want to create custom documentation. +# +# .. cmake_param:: MODULE_ONLY +# :option: +# +# Only document CMake functionality from the current Dune module. +# +# Generate a documentation for the CMake API. A set of cmake +# modules defined by the parameters and all functions and macros +# there in are automatically generated. The top level directory +# of the documentation is the current build directory (aka the +# directory that this function is called from) +# +# There are some assumptions on how the documentation in +# the CMake modules is written: +# +# * At the beginning of each CMake module there is a comment block that is written in restructured text. +# The first two characters of each line (the comment character +# and a blank) are ignored. Any resulting content of lines most form valid rst. +# * TODO document more +# + +find_package(Sphinx) + + +function(dune_cmake_sphinx_doc) + # Only proceed if Sphinx was found on the system + if(NOT SPHINX_FOUND) + message("-- Skipping building CMake API documentation (Sphinx was not found!)") + return() + endif() + + # Only proceed if the python interpreter was found by cmake + if(NOT PYTHONINTERP_FOUND) + message("-- Skipping building CMake API documentation (Python interpreter was not found!)") + return() + endif() + + # Parse Arguments + set(OPTION MODULE_ONLY) + set(SINGLE SPHINX_CONF) + set(MULTI BUILDTYPE RST_SOURCES) + include(CMakeParseArguments) + cmake_parse_arguments(SPHINX_CMAKE "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN}) + if(SPHINX_CMAKE_UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments in dune_cmake_sphinx_doc: This often indicates typos!") + endif() + + # Apply defaults + if(NOT SPHINX_CMAKE_BUILDTYPE) + set(SPHINX_CMAKE_BUILDTYPE html) + endif() + + # Extract the script directory from dune-common + dune_module_path(MODULE dune-common RESULT DUNE_SPHINX_EXT_PATH SCRIPT_DIR) + + # Find the configuration file template. + if(NOT SPHINX_CMAKE_SPHINX_CONF) + set(SPHINX_CMAKE_SPHINX_CONF ${DUNE_SPHINX_EXT_PATH}/conf.py.in) + endif() + + # Apply defaults to the rst sources that are not module dependent. + if(NOT SPHINX_CMAKE_RST_SOURCES) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/contents.rst "") + set(SPHINX_CMAKE_RST_SOURCES ${DUNE_SPHINX_EXT_PATH}/index.rst.in ${CMAKE_CURRENT_BINARY_DIR}/contents.rst) + endif() + + # Write the conf.py, which sets up Sphinx into the build directory + configure_file(${SPHINX_CMAKE_SPHINX_CONF} ${CMAKE_CURRENT_BINARY_DIR}/conf.py) + + # Check whether we need to look through all dependencies + set(DOC_CMAKE_MODULES) + if(NOT SPHINX_CMAKE_MODULE_ONLY) + set(DOC_CMAKE_MODULES ${ALL_DEPENDENCIES}) + endif() + + # Now treat the module dependent rst sources. + set(CMAKE_DOC_DEPENDENCIES "") + set(${CMAKE_PROJECT_NAME}_PREFIX ${CMAKE_SOURCE_DIR}) + foreach(dep ${DOC_CMAKE_MODULES} ${CMAKE_PROJECT_NAME}) + # Look for a build system documentation exported by the module dep + set(RSTFILE "") + # check in the correct path for non-installed modules + if(EXISTS ${${dep}_PREFIX}/doc/buildsystem/${dep}.rst) + set(RSTFILE ${${dep}_PREFIX}/doc/buildsystem/${dep}.rst) + endif() + # now check for the correct path taking into account installed ones + if(EXISTS ${${dep}_PREFIX}/share/doc/${dep}/${dep}.rst) + set(RSTFILE ${${dep}_PREFIX}/share/doc/${dep}/${dep}.rst) + endif() + # Now process the file, if we have found one + if(RSTFILE) + # add it to index.rst then. + set(CMAKE_DOC_DEPENDENCIES "${CMAKE_DOC_DEPENDENCIES} ${dep}\n") + # ... and copy the rst file to the current build. + configure_file(${RSTFILE} ${CMAKE_CURRENT_BINARY_DIR}/${dep}.rst) + endif() + endforeach() + + # Write the non-module dependent rst source files from templates + foreach(rstin ${SPHINX_CMAKE_RST_SOURCES}) + get_filename_component(rst ${rstin} NAME_WE) + configure_file(${rstin} ${CMAKE_CURRENT_BINARY_DIR}/${rst}.rst) + endforeach() + + # Generate the list of modules by looking through the module paths + # of all dependencies for files matching *.cmake + set(SPHINX_DOC_MODULE_LIST) + set(${CMAKE_PROJECT_NAME}_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) + foreach(dep ${DOC_CMAKE_MODULES} ${CMAKE_PROJECT_NAME}) + file(GLOB modules "${${dep}_MODULE_PATH}/*.cmake") + set(SPHINX_DOC_MODULE_LIST ${SPHINX_DOC_MODULE_LIST} ${modules}) + endforeach() + + # Initialize a variable that collects all dependencies of the documentation + set(DOC_DEPENDENCIES) + + # Generate the rst files for all cmake modules + foreach(module ${SPHINX_DOC_MODULE_LIST}) + get_filename_component(modname ${module} NAME) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/modules/${modname} + COMMAND ${PYTHON_EXECUTABLE} ${DUNE_SPHINX_EXT_PATH}/extract_cmake_data.py + --module=${module} + --builddir=${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${module} + COMMENT "Extracting CMake API documentation from ${modname}" + ) + set(DOC_DEPENDENCIES ${DOC_DEPENDENCIES} ${CMAKE_CURRENT_BINARY_DIR}/modules/${modname}) + endforeach() + + # Call Sphinx once for each requested build type + foreach(type ${SPHINX_CMAKE_BUILDTYPE}) + # Call the sphinx executable + add_custom_target(sphinx_${type} + COMMAND ${SPHINX_EXECUTABLE} + -b ${type} + -w ${CMAKE_BINARY_DIR}/SphinxError.log + -c ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/${type} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${DOC_DEPENDENCIES} + ) + add_dependencies(doc sphinx_${type}) + endforeach() +endfunction() diff -Nru dune-common-2.2.1/cmake/modules/DuneStreams.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneStreams.cmake --- dune-common-2.2.1/cmake/modules/DuneStreams.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneStreams.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,27 @@ +# This Module configures the DUNE debug streams. +# +# .. cmake_variable:: MINIMAL_DEBUG_LEVEL +# +# This variable configures the Dune debug streams. +# Standard debug streams with level below :code:`MINIMAL_DEBUG_LEVEL` will +# collapse to doing nothing if output is requested. Possible values are +# :code:`vverb`, :code:`verb`, :code:`info`, :code:`warn` and :code:`grave`. +# Deafults to :code:`warn`. +# + +macro(dune_set_minimal_debug_level) +set(MINIMAL_DEBUG_LEVEL ON CACHE STRING "set the MINIMAL_DEBUG_LEVEL. Standard debug streams with level below MINIMAL_DEBUG_LEVEL will collapse to doing nothing if output is requested. (default=warn)") +set_property(CACHE MINIMAL_DEBUG_LEVEL PROPERTY STRINGS + "grave" "warn" "info" "verb" "vverb") +if(MINIMAL_DEBUG_LEVEL MATCHES "grave") + set(DUNE_MINIMAL_DEBUG_LEVEL 5) +elseif(MINIMAL_DEBUG_LEVEL MATCHES "info") + set(DUNE_MINIMAL_DEBUG_LEVEL 3) +elseif(MINIMAL_DEBUG_LEVEL MATCHES "verb") + set(DUNE_MINIMAL_DEBUG_LEVEL 2) +elseif(MINIMAL_DEBUG_LEVEL MATCHES "vverb") + set(DUNE_MINIMAL_DEBUG_LEVEL 1) +else() + set(DUNE_MINIMAL_DEBUG_LEVEL 4) +endif() +endmacro(dune_set_minimal_debug_level) diff -Nru dune-common-2.2.1/cmake/modules/DuneSymlinkOrCopy.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneSymlinkOrCopy.cmake --- dune-common-2.2.1/cmake/modules/DuneSymlinkOrCopy.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneSymlinkOrCopy.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,174 @@ +# This module provides convenience macros to provide files from the source tree in the build tree. +# +# It provides the following macros: +# +# dune_add_copy_command(filename) +# +# This macro adds a file-copy command. +# The file_name is the name of a file that exists +# in the source tree. This file will be copied +# to the build tree when executing this command. +# Notice that this does not create a top-level +# target. In order to do this you have to additionally +# call add_custom_target(...) with dependency +# on the file. +# +# dune_add_copy_target(target_name file_name) +# +# This macro adds a file-copy target under given target_name. +# The file_name is the name of a file that exists +# in the source tree. This file will be copied +# to the build tree. +# +# dune_add_copy_dependency(target file_name) +# +# This macro adds a copy-dependecy to a target +# The file_name is the name of a file that exists +# in the source tree. This file will be copied +# to the build tree. +# +# +# .. cmake_function:: dune_add_copy_command +# +# .. cmake_param:: filename +# :positional: +# :single: +# :required: +# +# TODO DOC ME! +# +# .. cmake_function:: dune_add_copy_target +# +# .. cmake_param:: target_name +# :positional: +# :single: +# :required: +# +# .. cmake_param:: filename +# :positional: +# :single: +# :required: +# +# TODO DOC ME! +# +# .. cmake_function:: dune_add_copy_dependency +# +# .. cmake_param:: target +# :positional: +# :single: +# :required: +# +# .. cmake_param:: filename +# :positional: +# :single: +# :required: +# +# TODO DOC ME! +# +# .. cmake_function:: dune_symlink_to_source_tree +# +# .. cmake_param:: NAME +# :single: +# +# The name of the symlink, defaults to :code:`src_dir`. +# +# This function will place a symlink into every subdirectory +# of the build tree, that allows to jump to the corresponding +# source directory. Call this from your top-level :code:`CMakeLists.txt` +# to enable it for a given module. To enable it for all modules, +# set the variable :ref:`DUNE_SYMLINK_TO_SOURCE_TREE` instead. +# If used on Windows systems, a warning is issued. +# +# .. cmake_variable:: DUNE_SYMLINK_TO_SOURCE_TREE +# +# If this variable is set to TRUE, the functionality of +# :ref:`dune_symlink_to_source_tree` is enabled in all modules. +# This will place symlinks to the corresponding source directory +# in every subdirectory of the build directory. +# +# .. cmake_function:: dune_symlink_to_source_files +# +# .. cmake_param:: FILES +# :multi: +# :required: +# +# The list of files to symlink. +# +# Create symlinks in the current build directory, which +# point to files in the source directory. This is usually +# used for grid and ini files and the like. On Windows systems, +# a warning is issued and copying is used as a fallback to +# symlinking. +# + +macro(dune_add_copy_command file_name) + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${file_name}" + COMMAND ${CMAKE_COMMAND} + ARGS -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}" "${file_name}" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}" + ) +endmacro(dune_add_copy_command file_name) + +macro(dune_add_copy_target target_name file_name) + dune_add_copy_command(${file_name}) + add_custom_target("${target_name}" ALL DEPENDS "${file_name}") +endmacro(dune_add_copy_target target_name file_name) + +macro(dune_add_copy_dependency target file_name) + message(STATUS "Adding copy-to-build-dir dependency for ${file_name} to target ${target}") + dune_add_copy_target("${target}_copy_${file_name}" "${file_name}") + add_dependencies(${target} "${target}_copy_${file_name}") +endmacro(dune_add_copy_dependency) + +function(dune_symlink_to_source_tree) + # parse arguments + include(CMakeParseArguments) + cmake_parse_arguments(ARG "" "NAME" "" ${ARGN}) + if(NOT ARG_NAME) + set(ARG_NAME "src_dir") + endif() + + # check for Windows to issue a warning + if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + if(NOT DEFINED DUNE_WINDOWS_SYMLINK_WARNING) + message(WARNING "Your module wanted to create symlinks, but you cannot do that on your platform.") + set(DUNE_WINDOWS_SYMLINK_WARNING) + endif() + else() + # get a list of all files in the current source directory and below. + file(GLOB_RECURSE files RELATIVE ${CMAKE_SOURCE_DIR} "*CMakeLists.txt") + + # iterate over all files, extract the directory name and write a symlink in the corresponding build directory + foreach(f ${files}) + get_filename_component(dir ${f} DIRECTORY) + if(NOT "${CMAKE_SOURCE_DIR}/${dir}" MATCHES "${CMAKE_BINARY_DIR}/*") + execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_SOURCE_DIR}/${dir}" "${CMAKE_BINARY_DIR}/${dir}/${ARG_NAME}") + endif(NOT "${CMAKE_SOURCE_DIR}/${dir}" MATCHES "${CMAKE_BINARY_DIR}/*") + endforeach() + endif() +endfunction(dune_symlink_to_source_tree) + +function(dune_symlink_to_source_files) + # parse arguments + include(CMakeParseArguments) + cmake_parse_arguments(ARG "" "" "FILES" ${ARGN}) + if(ARG_UNPARSED_ARGUMENTS) + message(WARNING "You are using dune_symlink_to_source_files without named arguments (or have typos in your named arguments)!") + endif() + + # create symlinks for all given files + foreach(f ${ARG_FILES}) + # check for Windows to issue a warning + if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + if(NOT DEFINED DUNE_WINDOWS_SYMLINK_WARNING) + message(WARNING "Your module wanted to create symlinks, but you cannot do that on your platform.") + set(DUNE_WINDOWS_SYMLINK_WARNING) + endif() + dune_add_copy_command(${f}) + else() + # create symlink + execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/${f}") + endif() + endforeach() +endfunction(dune_symlink_to_source_files) diff -Nru dune-common-2.2.1/cmake/modules/DuneTestMacros.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneTestMacros.cmake --- dune-common-2.2.1/cmake/modules/DuneTestMacros.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/DuneTestMacros.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,322 @@ +# Module that provides tools for testing the Dune way. +# +# Note that "the Dune way" of doing this has changed after +# the 2.4 release. See the build system documentation for details. +# +# .. cmake_function:: dune_add_test +# +# .. cmake_brief:: +# +# Adds a test to the Dune testing suite! +# +# .. cmake_param:: NAME +# :single: +# +# The name of the test that should be added. If an executable +# is also added (by specifying SOURCES), the executable is also +# named accordingly. If omitted, the name will be deduced from +# the (single) sources parameter or from the given target. Note +# that this requires you to take care, that you only use a target +# or source file for but one such test. +# +# .. cmake_param:: SOURCES +# :multi: +# +# The source files that this test depends on. These are the +# sources that will be passed to :ref:`add_executable`. +# +# You *must* specify either :code:`SOURCES` or :code:`TARGET`. +# +# .. cmake_param:: TARGET +# :single: +# +# An executable target which should be used for the test. Use +# this option over the :code:`SOURCES` parameter if you want to +# reuse already added targets. +# +# You *must* specify either :code:`SOURCES` or :code:`TARGET`. +# +# .. cmake_param:: COMPILE_DEFINITIONS +# :multi: +# :argname: def +# +# A set of compile definitions to add to the target. +# Only definitions beyond the application of :ref:`add_dune_all_flags` +# have to be stated. +# This is only used, if :code:`dune_add_test` adds the executable itself. +# +# .. cmake_param:: COMPILE_FLAGS +# :multi: +# :argname: flag +# +# A set of non-definition compile flags to add to the target. +# Only flags beyond the application of :ref:`add_dune_all_flags` +# have to be stated. +# This is only used, if :code:`dune_add_test` adds the executable itself. +# +# .. cmake_param:: LINK_LIBRARIES +# :multi: +# :argname: lib +# +# A list of libraries to link the target to. +# Only libraries beyond the application of :ref:`add_dune_all_flags` +# have to be stated. +# This is only used, if :code:`dune_add_test` adds the executable itself. +# +# .. cmake_param:: EXPECT_COMPILE_FAIL +# :option: +# +# If given, the test is expected to not compile successfully! +# +# .. cmake_param:: EXPECT_FAIL +# :option: +# +# If given, this test is expected to compile, but fail to run. +# +# .. cmake_param:: CMD_ARGS +# :multi: +# :argname: arg +# +# Command line arguments that should be passed to this test. +# +# .. cmake_param:: MPI_RANKS +# :multi: +# :argname: ranks +# +# The numbers of cores that this test should be executed with. +# Note that one test (in the ctest sense) is created for each number +# given here. Any number exceeding the user-specified processor maximum +# :ref:`DUNE_MAX_TEST_CORES` will be ignored. Tests with a +# processor number :code:`n` higher than one will have the suffix +# :code:`-mpi-n` appended to their name. You need to specify the +# TIMEOUT option when specifying the MPI_RANKS option. +# +# .. cmake_param:: CMAKE_GUARD +# :multi: +# :argname: condition +# +# A number of conditions that CMake should evaluate before adding this +# test. If one of the conditions fails, the test should be shown +# as skipped in the test summary. Use this feature instead of guarding +# the call to :code:`dune_add_test` with an :code:`if` clause. +# +# The passed condition can be a complex expression like +# `( A OR B ) AND ( C OR D )`. Mind the spaces around the parentheses. +# +# Example: Write CMAKE_GUARD dune-foo_FOUND if you want your test to only +# build and run when the dune-foo module is present. +# +# .. cmake_param:: COMMAND +# :multi: +# :argname: cmd +# +# You may specify the COMMAND option to give the exact command line to be +# executed when running the test. This defaults to the name of the executable +# added by dune_add_test for this test. Note that if you specify both CMD_ARGS +# and COMMAND, the given CMD_ARGS will be put behind your COMMAND. If you use +# this in combination with the MPI_RANKS parameter, the call to mpi will still be +# wrapped around the given commands. +# +# .. cmake_param:: COMPILE_ONLY +# :option: +# +# Set if the given test should only be compiled during :code:`make build_tests`, +# but not run during :code:`make test`. This is useful if you compile the same +# executable twice, but with different compile flags, where you want to assure that +# it compiles with both sets of flags, but you already know they will produce the +# same result. +# +# .. cmake_param:: TIMEOUT +# :single: +# +# If set, the test will time out after the given number of seconds. This supersedes +# any timeout setting in ctest (see `cmake --help-property TIMEOUT`). If you +# specify the MPI_RANKS option, you need to specify a TIMEOUT. +# +# This function defines the Dune way of adding a test to the testing suite. +# You may either add the executable yourself through :ref:`add_executable` +# and pass it to the :code:`TARGET` option, or you may rely on :ref:`dune_add_test` +# to do so. +# +# .. cmake_variable:: DUNE_REENABLE_ADD_TEST +# +# You may set this variable to True either through your opts file or in your module +# (before the call to :code:`include(DuneMacros)`) to suppress the error that is thrown if +# :code:`add_test` is used. You should only do that if you have proper reason to do so. +# +# .. cmake_variable:: DUNE_MAX_TEST_CORES +# +# You may set this variable to give an upperbound to the number of processors, that +# a single test may use. Defaults to 2, when MPI is found and to 1 otherwise. +# +# .. cmake_variable:: DUNE_BUILD_TESTS_ON_MAKE_ALL +# +# You may set this variable through your opts file or on a per module level (in the toplevel +# :code:`CMakeLists.txt` before :code:`include(DuneMacros)`) to have the Dune build system +# build all tests during `make all`. Note, that this may take quite some time for some modules. +# If not in use, you have to build tests through the target :code:`build_tests`. +# + +# enable the testing suite on the CMake side. +enable_testing() +include(CTest) + +# Introduce a target that triggers the building of all tests +add_custom_target(build_tests) + +# Set the default on the variable DUNE_MAX_TEST_CORES +if(NOT DUNE_MAX_TEST_CORES) + set(DUNE_MAX_TEST_CORES 2) +endif() + +function(dune_add_test) + include(CMakeParseArguments) + set(OPTIONS EXPECT_COMPILE_FAIL EXPECT_FAIL SKIP_ON_77 COMPILE_ONLY) + set(SINGLEARGS NAME TARGET TIMEOUT) + set(MULTIARGS SOURCES COMPILE_DEFINITIONS COMPILE_FLAGS LINK_LIBRARIES CMD_ARGS MPI_RANKS COMMAND CMAKE_GUARD) + cmake_parse_arguments(ADDTEST "${OPTIONS}" "${SINGLEARGS}" "${MULTIARGS}" ${ARGN}) + + # Check whether the parser produced any errors + if(ADDTEST_UNPARSED_ARGUMENTS) + message(WARNING "Unrecognized arguments ('${ADDTEST_UNPARSED_ARGUMENTS}') for dune_add_test!") + endif() + + # Check input for validity and apply defaults + if(NOT ADDTEST_SOURCES AND NOT ADDTEST_TARGET) + message(FATAL_ERROR "You need to specify either the SOURCES or the TARGET option for dune_add_test!") + endif() + if(ADDTEST_SOURCES AND ADDTEST_TARGET) + message(FATAL_ERROR "You cannot specify both SOURCES and TARGET for dune_add_test") + endif() + if(NOT ADDTEST_NAME) + # try deducing the test name from the executable name + if(ADDTEST_TARGET) + set(ADDTEST_NAME ${ADDTEST_TARGET}) + endif() + # try deducing the test name form the source name + if(ADDTEST_SOURCES) + # deducing a name is only possible with a single source argument + list(LENGTH ADDTEST_SOURCES len) + if(NOT len STREQUAL "1") + message(FATAL_ERROR "Cannot deduce test name from multiple sources!") + endif() + # strip file extension + get_filename_component(ADDTEST_NAME ${ADDTEST_SOURCES} NAME_WE) + endif() + endif() + if(NOT ADDTEST_COMMAND) + set(ADDTEST_COMMAND ${ADDTEST_NAME}) + endif() + if(ADDTEST_MPI_RANKS AND (NOT ADDTEST_TIMEOUT)) + message(FATAL_ERROR "dune_add_test: You need to specify the TIMEOUT parameter if using the MPI_RANKS parameter.") + endif() + if(NOT ADDTEST_MPI_RANKS) + set(ADDTEST_MPI_RANKS 1) + endif() + if(NOT ADDTEST_TIMEOUT) + set(ADDTEST_TIMEOUT 300) + endif() + foreach(num ${ADDTEST_MPI_RANKS}) + if(NOT "${num}" MATCHES "[1-9][0-9]*") + message(FATAL_ERROR "${num} was given to the MPI_RANKS arugment of dune_add_test, but it does not seem like a correct processor number") + endif() + endforeach() + if(ADDTEST_SKIP_ON_77) + message(WARNING "The SKIP_ON_77 option for dune_add_test is obsolete, it is now enabled by default.") + endif() + + # Discard all parallel tests if MPI was not found + if(NOT MPI_FOUND) + set(DUNE_MAX_TEST_CORES 1) + endif() + + # Find out whether this test should be a dummy + set(DOSOMETHING TRUE) + set(FAILED_CONDITION_PRINTING "") + foreach(condition ${ADDTEST_CMAKE_GUARD}) + separate_arguments(condition) + if(NOT (${condition})) + set(DOSOMETHING FALSE) + set(FAILED_CONDITION_PRINTING "${FAILED_CONDITION_PRINTING}std::cout << \" ${condition}\" << std::endl;\n") + endif() + endforeach() + + # If we do nothing, switch the sources for a dummy source + if(NOT DOSOMETHING) + dune_module_path(MODULE dune-common RESULT scriptdir SCRIPT_DIR) + set(ADDTEST_TARGET) + set(dummymain ${CMAKE_CURRENT_BINARY_DIR}/main77_${ADDTEST_NAME}.cc) + configure_file(${scriptdir}/main77.cc.in ${dummymain}) + set(ADDTEST_SOURCES ${dummymain}) + endif() + + # Add the executable if it is not already present + if(ADDTEST_SOURCES) + add_executable(${ADDTEST_NAME} ${ADDTEST_SOURCES}) + # add all flags to the target! + add_dune_all_flags(${ADDTEST_NAME}) + # This is just a placeholder + target_compile_definitions(${ADDTEST_NAME} PUBLIC ${ADDTEST_COMPILE_DEFINITIONS}) + target_compile_options(${ADDTEST_NAME} PUBLIC ${ADDTEST_COMPILE_FLAGS}) + target_link_libraries(${ADDTEST_NAME} ${ADDTEST_LINK_LIBRARIES}) + set(ADDTEST_TARGET ${ADDTEST_NAME}) + endif() + + # Make sure to exclude the target from all, even when it is user-provided + if(DUNE_BUILD_TESTS_ON_MAKE_ALL AND (NOT ADDTEST_EXPECT_COMPILE_FAIL)) + set_property(TARGET ${ADDTEST_TARGET} PROPERTY EXCLUDE_FROM_ALL 0) + else() + set_property(TARGET ${ADDTEST_TARGET} PROPERTY EXCLUDE_FROM_ALL 1) + endif() + + # Have the given target depend on build_tests in order to trigger the build correctly + if(NOT ADDTEST_EXPECT_COMPILE_FAIL) + add_dependencies(build_tests ${ADDTEST_TARGET}) + endif() + + # Process the EXPECT_COMPILE_FAIL option + if(ADDTEST_EXPECT_COMPILE_FAIL) + set(ADDTEST_COMMAND ${CMAKE_COMMAND} --build . --target ${ADDTEST_TARGET} --config $) + endif() + + # Add one test for each specified processor number + foreach(procnum ${ADDTEST_MPI_RANKS}) + if((NOT "${procnum}" GREATER "${DUNE_MAX_TEST_CORES}") AND (NOT ADDTEST_COMPILE_ONLY)) + if(NOT ${procnum} STREQUAL "1") + set(ACTUAL_TESTCOMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${procnum} ${ADDTEST_COMMAND} ${MPIEXEC_POSTFLAGS}) + set(ACTUAL_NAME "${ADDTEST_NAME}-mpi-${procnum}") + else() + set(ACTUAL_TESTCOMMAND ${ADDTEST_COMMAND}) + set(ACTUAL_NAME ${ADDTEST_NAME}) + endif() + + # Now add the actual test + _add_test(NAME ${ACTUAL_NAME} + COMMAND ${ACTUAL_TESTCOMMAND} ${ADDTEST_CMD_ARGS} + ) + + # Define the number of processors (ctest will coordinate this with the -j option) + set_tests_properties(${ACTUAL_NAME} PROPERTIES PROCESSORS ${procnum}) + # Apply the timeout (which was defaulted to 5 minutes if not specified) + set_tests_properties(${ACTUAL_NAME} PROPERTIES TIMEOUT ${ADDTEST_TIMEOUT}) + # Process the EXPECT_FAIL option + if(ADDTEST_EXPECT_COMPILE_FAIL OR ADDTEST_EXPECT_FAIL) + set_tests_properties(${ACTUAL_NAME} PROPERTIES WILL_FAIL true) + endif() + # Skip the test if the return code is 77! + set_tests_properties(${ACTUAL_NAME} PROPERTIES SKIP_RETURN_CODE 77) + endif() + endforeach() +endfunction() + +macro(add_directory_test_target) + message(FATAL_ERROR "The function add_directory_test_target has been removed alongside all testing magic in dune-common. Check dune_add_test for the new way!") +endmacro() + +macro(add_test) + if(NOT DUNE_REENABLE_ADD_TEST) + message(SEND_ERROR "Please use dune_add_test instead of add_test! If you need add_test in a downstream project, set the variable DUNE_REENABLE_ADD_TEST to True in that project to suppress this error.") + else() + _add_test(${ARGN}) + endif() +endmacro() diff -Nru dune-common-2.2.1/cmake/modules/FindGMP.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindGMP.cmake --- dune-common-2.2.1/cmake/modules/FindGMP.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindGMP.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,103 @@ +# .. cmake_module:: +# +# Find the GNU MP Bignum (GMP) library +# +# You may set the following variables to modify the +# behaviour of this module: +# +# :ref:`GMP_ROOT` +# Path list to search for GMP +# +# Sets the following variables: +# +# :code:`GMP_FOUND` +# True if the GMP library was found. +# +# .. cmake_variable:: GMP_ROOT +# +# You may set this variable to have :ref:`FindGMP` look +# for the gmp package in the given path before inspecting +# system paths. +# + + +# search for location of header gmpxx.h", only at positions given by the user +find_path(GMP_INCLUDE_DIR + NAMES "gmpxx.h" + PATHS ${GMP_PREFIX} ${GMP_ROOT} + PATH_SUFFIXES include + NO_DEFAULT_PATH) +# try default paths now +find_path(GMP_INCLUDE_DIR + NAMES "gmpxx.h") + +# check if header is accepted +include(CMakePushCheckState) +cmake_push_check_state() +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMP_INCLUDE_DIR}) +include(CheckIncludeFileCXX) +check_include_file_cxx("gmpxx.h" GMP_HEADER_WORKS) + +# look for library gmp, only at positions given by the user +find_library(GMP_LIB gmp + PATHS ${GMP_PREFIX} ${GMP_ROOT} + PATH_SUFFIXES lib lib64 + NO_DEFAULT_PATH + DOC "GNU GMP library") +# try default paths now +find_library(GMP_LIB gmp) + +# look for library gmpxx, only at positions given by the user +find_library(GMPXX_LIB gmpxx + PATHS ${GMP_PREFIX} ${GMP_ROOT} + PATH_SUFFIXES lib lib64 + NO_DEFAULT_PATH + DOC "GNU GMPXX library") +# try default paths now +find_library(GMPXX_LIB gmpxx) + +# check if library works +if(GMP_LIB AND GMPXX_LIB) + include(CheckSymbolExists) + check_library_exists(${GMP_LIB} __gmpz_abs "" GMPXX_LIB_WORKS) +endif(GMP_LIB AND GMPXX_LIB) +cmake_pop_check_state() + +# behave like a CMake module is supposed to behave +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "GMP" + DEFAULT_MSG + GMP_INCLUDE_DIR GMP_LIB GMPXX_LIB GMP_HEADER_WORKS GMPXX_LIB_WORKS +) + +mark_as_advanced(GMP_LIB GMPXX_LIB GMP_INCLUDE_DIR) + +# if both headers and library are found, store results +if(GMP_FOUND) + set(GMP_INCLUDE_DIRS ${GMP_INCLUDE_DIR}) + set(GMP_LIBRARIES ${GMP_LIB} ${GMPXX_LIB}) + set(GMP_COMPILE_FLAGS "-DENABLE_GMP=1") + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determing location of GMP succeeded:\n" + "Include directory: ${GMP_INCLUDE_DIRS}\n" + "Library directory: ${GMP_LIBRARIES}\n\n") +else(GMP_FOUND) + # log errornous result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determing location of GMP failed:\n" + "Include directory: ${GMP_INCLUDE_DIR}\n" + "gmp library directory: ${GMP_LIB}\n" + "gmpx library directory: ${GMPXX_LIB}\n\n") +endif(GMP_FOUND) + +# set HAVE_GMP for config.h +set(HAVE_GMP ${GMP_FOUND}) + +# register all GMP related flags +if(HAVE_GMP) + dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_GMP=1" + LIBRARIES "${GMP_LIB};${GMPXX_LIB}" + INCLUDE_DIRS "${GMP_INCLUDE_DIR}") +endif() diff -Nru dune-common-2.2.1/cmake/modules/FindInkscape.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindInkscape.cmake --- dune-common-2.2.1/cmake/modules/FindInkscape.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindInkscape.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,19 @@ +# .. cmake_module:: +# +# Module that checks for inkscape +# +# Sets the following variables +# +# :code:`INKSCAPE_FOUND` +# Whether inkscape was found +# +# :code:`INKSCAPE` +# Path to inkscape to generate .png's form .svg's +# + +find_program(INKSCAPE inkscape DOC "Path to inkscape to generate png files from svg files") +find_program(CONVERT convert DOC "Path to convert program") +if(INKSCAPE) + set(INKSCAPE_FOUND True) +endif(INKSCAPE) + diff -Nru dune-common-2.2.1/cmake/modules/FindMETIS.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindMETIS.cmake --- dune-common-2.2.1/cmake/modules/FindMETIS.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindMETIS.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,149 @@ +# .. cmake_module:: +# +# Find the METIS library +# +# You may set the following variables to modify the +# behaviour of this module: +# +# :ref:`METIS_ROOT` +# Prefix, where METIS is installed +# +# :ref:`METIS_LIB_NAME` +# Name of the METIS library (default: metis) +# +# :ref:`METIS_LIBRARY` +# Full path to the METIS library +# +# Sets the following variables: +# +# :code:`METIS_FOUND` +# True if the METIS library was found. +# +# :code:`METIS_LIBRARY` +# Full path to the METIS library +# +# :code:`METIS_LIBRARIES` +# List of libraries needed for linking with METIS +# +# .. cmake_variable:: METIS_ROOT +# +# You may set this variable to have :ref:`FindMETIS` look +# for the METIS library and includes in the given path +# before inspecting default system paths. +# +# .. cmake_variable:: METIS_LIB_NAME +# +# You may set this variable to specify the name of the METIS +# library that :ref:`FindMETIS` looks for. +# +# .. cmake_variable:: METIS_LIBRARY +# +# You may set this variable to specify the full path to the METIS +# library, that should be used by :ref:`FindMETIS`. +# + + +# search metis header +find_path(METIS_INCLUDE_DIR metis.h + PATHS ${METIS_DIR} ${METIS_ROOT} + PATH_SUFFIXES metis include include/metis Lib METISLib + NO_DEFAULT_PATH + DOC "Include directory of metis") +find_path(METIS_INCLUDE_DIR metis.h + PATH_SUFFIXES metis include include/metis Lib METISLib) + +set(METIS_LIBRARY METIS_LIBRARY-NOTFOUND CACHE FILEPATH "Full path of the METIS library") + +# check metis header +include(CMakePushCheckState) +cmake_push_check_state() # Save variables +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${METIS_INCLUDE_DIR}) +check_include_file(metis.h METIS_FOUND) + +# search metis library +if(NOT METIS_LIB_NAME) + set(METIS_LIB_NAME metis) +endif(NOT METIS_LIB_NAME) + +find_library(METIS_LIBRARY ${METIS_LIB_NAME} + PATHS ${METIS_DIR} ${METIS_ROOT} + PATH_SUFFIXES lib + NO_DEFAULT_PATH) +find_library(METIS_LIBRARY ${METIS_LIB_NAME} + PATH_SUFFIXES lib +) + +# we need to check whether we need to link m, copy the lazy solution from FindBLAS and FindLAPACK here. +if(METIS_LIBRARY AND NOT WIN32) + set(_METIS_LM_LIBRARY "-lm") +endif() + +# check metis library +if(METIS_LIBRARY) + set(_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") # do a backup + list(APPEND CMAKE_REQUIRED_LIBRARIES ${METIS_LIBRARY} ${_METIS_LM_LIBRARY}) + include(CheckFunctionExists) + check_function_exists(METIS_PartGraphKway HAVE_METIS_PARTGRAPHKWAY) + + if(NOT HAVE_METIS_PARTGRAPHKWAY) + # Maybe we are using static scotch libraries. In this case we need to link + # the other scotch libraries too. Let's make a best effort. + # Get the path where METIS_LIBRARY resides + get_filename_component(_lib_root ${METIS_LIBRARY} DIRECTORY) + # Search for additional libs only in this directory. + # Otherwise we might find incompatible ones, e.g. for int instead of long + find_library(SCOTCH_LIBRARY scotch PATHS ${_lib_root} "The Scotch library." NO_DEFAULT_PATH) + find_library(SCOTCHERR_LIBRARY scotcherr PATHS ${_lib_root} "The Scotch error library." + NO_DEFAULT_PATH) + if(SCOTCH_LIBRARY AND SCOTCHERR_LIBRARY) + set(_METIS_SCOTCH_LIBRARIES ${SCOTCH_LIBRARY} ${SCOTCHERR_LIBRARY} ${STDTHREAD_LINK_FLAGS} ) + set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES} ${METIS_LIBRARY} ${_METIS_SCOTCH_LIBRARIES} ${_METIS_LM_LIBRARY}) + # unset HAVE_METIS_PARTGRAPHKWAY to force another + # run of check_function_exists(METIS_PartGraphKway + unset(HAVE_METIS_PARTGRAPHKWAY CACHE) + check_function_exists(METIS_PartGraphKway HAVE_METIS_PARTGRAPHKWAY) + endif() + endif() + set(CMAKE_REQUIRED_LIBRARIES "${_CMAKE_REQUIRED_LIBRARIES}") +endif(METIS_LIBRARY) + +# behave like a CMake module is supposed to behave +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "METIS" + DEFAULT_MSG + METIS_INCLUDE_DIR + METIS_LIBRARY + HAVE_METIS_PARTGRAPHKWAY +) + +cmake_pop_check_state() + +mark_as_advanced(METIS_INCLUDE_DIR METIS_LIBRARIES METIS_LIB_NAME) + +# if both headers and library are found, store results +if(METIS_FOUND) + set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR}) + # We need to cache METIS_LIBRARIES as for subsequent runs + # The scotch stuff will not be set again!!! + set(METIS_LIBRARIES ${METIS_LIBRARY} ${_METIS_SCOTCH_LIBRARIES} ${_METIS_LM_LIBRARY} + CACHE STRING "List of all libraries needed to link to METIS") + set(HAVE_METIS ${METIS_FOUND}) + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determing location of METIS succeeded:\n" + "Include directory: ${METIS_INCLUDE_DIRS}\n" + "Library directory: ${METIS_LIBRARIES}\n\n") +else(METIS_FOUND) + # log errornous result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determing location of METIS failed:\n" + "Include directory: ${METIS_INCLUDE_DIRS}\n" + "Library directory: ${METIS_LIBRARIES}\n\n") +endif(METIS_FOUND) + +# register all METIS related flags +if(METIS_FOUND) + dune_register_package_flags(LIBRARIES "${METIS_LIBRARIES}" + INCLUDE_DIRS "${METIS_INCLUDE_DIRS}") +endif() diff -Nru dune-common-2.2.1/cmake/modules/FindMProtect.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindMProtect.cmake --- dune-common-2.2.1/cmake/modules/FindMProtect.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindMProtect.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,18 @@ +# .. cmake_module:: +# +# Module that detects mprotect support +# +# Sets the following variables: +# +# * :code:`HAVE_SYS_MMAN_H` +# * :code:`HAVE_MPROTECT` +# + +include(CheckIncludeFile) +check_include_file("sys/mman.h" HAVE_SYS_MMAN_H) +include(CheckCSourceCompiles) +check_c_source_compiles(" +#include +int main(void){ + mprotect(0,0,PROT_NONE); +}" HAVE_MPROTECT) diff -Nru dune-common-2.2.1/cmake/modules/FindParMETIS.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindParMETIS.cmake --- dune-common-2.2.1/cmake/modules/FindParMETIS.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindParMETIS.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,161 @@ +# .. cmake_module:: +# +# Module that checks whether ParMETIS is available. +# +# You may set the following variables to configure this modules behaviour: +# +# :ref:`PARMETIS_ROOT` +# Prefix where ParMETIS is installed. +# +# :ref:`METIS_LIB_NAME` +# Name of the METIS library (default: metis). +# +# :ref:`PARMETIS_LIB_NAME` +# Name of the ParMETIS library (default: parmetis). +# +# :ref:`METIS_LIBRARY` +# Full path of the METIS library. +# +# :ref:`PARMETIS_LIBRARY` +# Full path of the ParMETIS library +# +# Sets the following variables: +# +# :code:`PARMETIS_FOUND` +# True if ParMETIS was found. +# +# :code:`METIS_LIBRARY` +# Full path of the METIS library. +# +# :code:`PARMETIS_LIBRARY` +# Full path of the ParMETIS library. +# +# :code:`PARMETIS_LIBRARIES` +# List of all libraries needed for linking with ParMETIS, +# +# .. cmake_variable:: PARMETIS_ROOT +# +# You may set this variable to have :ref:`FindParMETIS` look +# for the ParMETIS library and includes in the given path +# before inspecting default system paths. +# +# .. cmake_variable:: PARMETIS_LIB_NAME +# +# You may set this variable to specify the name of the ParMETIS +# library that :ref:`FindParMETIS` looks for. +# +# .. cmake_variable:: PARMETIS_LIBRARY +# +# You may set this variable to specify the full path to the ParMETIS +# library, that should be used by :ref:`FindParMETIS`. +# + + +find_path(PARMETIS_INCLUDE_DIR parmetis.h + PATHS ${PARMETIS_DIR} ${PARMETIS_ROOT} + PATH_SUFFIXES include parmetis + NO_DEFAULT_PATH + DOC "Include directory of ParMETIS") +find_path(PARMETIS_INCLUDE_DIR parmetis.h + PATH_SUFFIXES include parmetis) + +set(METIS_LIB_NAME metis + CACHE STRING "Name of the METIS library (default: metis).") +set(PARMETIS_LIB_NAME parmetis + CACHE STRING "Name of the ParMETIS library (default: parmetis).") +set(METIS_LIBRARY METIS_LIBRARY-NOTFOUND + CACHE FILEPATH "Full path of the METIS library") +set(PARMETIS_LIBRARY ParMETIS_LIBRARY-NOTFOUND + CACHE FILEPATH "Full path of the ParMETIS library") + +# check METIS and ParMETIS headers +include(CMakePushCheckState) +cmake_push_check_state() # Save variables +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${MPI_DUNE_INCLUDE_PATH} ${PARMETIS_INCLUDE_DIR}) +set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${MPI_DUNE_COMPILE_FLAGS}") +check_include_file(metis.h METIS_FOUND) +check_include_file(parmetis.h PARMETIS_FOUND) + +if(PARMETIS_FOUND) + set(ParMETIS_INCLUDE_PATH ${CMAKE_REQUIRED_INCLUDES}) + set(ParMETIS_COMPILE_FLAGS "${CMAKE_REQUIRED_FLAGS} -DENABLE_PARMETIS=1") + + # search METIS library + find_library(METIS_LIBRARY metis + PATHS ${PARMETIS_DIR} ${PARMETIS_ROOT} + PATH_SUFFIXES lib + NO_DEFAULT_PATH) + find_library(METIS_LIBRARY metis) + + # search ParMETIS library + find_library(PARMETIS_LIBRARY parmetis + PATHS ${PARMETIS_DIR} ${PARMETIS_ROOT} + PATH_SUFFIXES lib + NO_DEFAULT_PATH) + find_library(PARMETIS_LIBRARY parmetis) + + set(_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") # do a backup + # check ParMETIS library + if(PARMETIS_LIBRARY) + set(_PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARIES} ${MPI_DUNE_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${_PARMETIS_LIBRARIES} ${_CMAKE_REQUIRED_LIBRARIES}) + include(CheckFunctionExists) + check_function_exists(parmetis_v3_partkway HAVE_PARMETIS) + if(NOT HAVE_PARMETIS) + # Maybe we are using static scotch libraries. In this case we need to link + # the other scotch libraries too. Let's make a best effort. + # Get the path where ParMETIS_LIBRARY resides + get_filename_component(_lib_root ${METIS_LIBRARY} DIRECTORY) + # Search for additional libs only in this directory. + # Otherwise we might find incompatible ones, e.g. for int instead of long + find_library(PTSCOTCH_LIBRARY ptscotch PATHS ${_lib_root} "The PT-Scotch library." + NO_DEFAULT_PATH) + find_library(PTSCOTCHERR_LIBRARY ptscotcherr PATHS ${_lib_root} "The Scotch error library." + NO_DEFAULT_PATH) + if(PTSCOTCH_LIBRARY AND PTSCOTCHERR_LIBRARY) + set(_PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${PTSCOTCH_LIBRARY} + ${PTSCOTCHERR_LIBRARY} ${METIS_LIBRARIES} ${MPI_DUNE_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${_PARMETIS_LIBRARIES} + ${_CMAKE_REQUIRED_LIBRARIES}) + unset(HAVE_PARMETIS CACHE) + check_function_exists(parmetis_v3_partkway HAVE_PARMETIS) + endif() + endif() + endif(PARMETIS_LIBRARY) + set(CMAKE_REQUIRED_LIBRARIES "${_CMAKE_REQUIRED_LIBRARIES}") # get backup +endif(PARMETIS_FOUND) + +# behave like a CMake module is supposed to behave +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "ParMETIS" + DEFAULT_MSG + PARMETIS_INCLUDE_DIR + PARMETIS_LIBRARY + HAVE_PARMETIS +) + +mark_as_advanced(PARMETIS_INCLUDE_DIR METIS_LIBRARY PARMETIS_LIBRARY METIS_LIB_NAME PARMETIS_LIB_NAME) + +#restore old values +cmake_pop_check_state() + +if(PARMETIS_FOUND) + set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR}) + set(PARMETIS_LIBRARIES "${_PARMETIS_LIBRARIES}" + CACHE FILEPATH "ParMETIS libraries needed for linking") + set(PARMETIS_LINK_FLAGS "${DUNE_MPI_LINK_FLAGS}" + CACHE STRING "ParMETIS link flags") + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determing location of ParMETIS succeeded:\n" + "Include directory: ${PARMETIS_INCLUDE_DIRS}\n" + "Library directory: ${PARMETIS_LIBRARIES}\n\n") +endif(PARMETIS_FOUND) + +# register all ParMETIS related flags +if(PARMETIS_FOUND) + dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_PARMETIS=1" + LIBRARIES "${PARMETIS_LIBRARIES}" + INCLUDE_DIRS "${PARMETIS_INCLUDE_DIRS}") +endif() diff -Nru dune-common-2.2.1/cmake/modules/FindPTScotch.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindPTScotch.cmake --- dune-common-2.2.1/cmake/modules/FindPTScotch.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindPTScotch.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,110 @@ +# .. cmake_module:: +# +# Module that checks whether PT-Scotch is available. +# +# You may set the following variables to customize this modules behaviour: +# +# :ref:`PTSCOTCH_ROOT` +# Prefix where PT-Scotch is installed. +# +# :ref:`PTSCOTCH_SUFFIX` +# Scotch might be compiled using different +# integer sizes (int32, int64, long). When +# this is is set the headers and libaries +# are search under the suffix +# :code:`include/scotch-${PTSCOTCH_SUFFIX}`, and +# :code:`lib/scotch-${PTSCOTCH_SUFFIX}`, respectively. +# +# This module sets the following variables: +# +# :code:`PTSCOTCH_FOUND` +# True if PT-Scotch was found. +# +# :code:`PTSCOTCH_INCLUDE_DIRS` +# All include directories needed to compile PT-Scotch programs. +# +# :code:`PTSCOTCH_LIBRARIES` +# All libraries needed to link PT-Scotch programs. +# +# :code:`PTSCOTCH_FOUND` +# True if PT-Scotch was found. +# +# .. cmake_variable:: PTSCOTCH_ROOT +# +# You may set this variable to have :ref:`FindPTScotch` look +# for the PTScotch package in the given path before inspecting +# system paths. +# +# .. cmake_variable:: PTSCOTCH_SUFFIX +# +# PTScotch might be compiled using different +# integer sizes (int32, int64, long). When +# this is is set the headers and libaries +# are search under the suffix +# :code:`include/scotch-${PTSCOTCH_SUFFIX}`, and +# :code:`lib/scotch-${PTSCOTCH_SUFFIX}`, respectively. +# + +include(DuneMPI) +macro(_search_pt_lib libvar libname doc) + find_library(${libvar} ${libname} + PATHS ${PTSCOTCH_ROOT} ${PTSCOTCH_ROOT}/lib PATH_SUFFIXES ${PATH_SUFFIXES} + NO_DEFAULT_PATH + DOC "${doc}") + find_library(${libvar} ${libname}) +endmacro(_search_pt_lib) + +if(PTSCOTCH_SUFFIX) + set(PATH_SUFFIXES "scotch-${PTSCOTCH_SUFFIX}") +else(PTSCOTCH_SUFFIX) + set(PATH_SUFFIXES "scotch") +endif(PTSCOTCH_SUFFIX) + +include(CMakePushCheckState) +cmake_push_check_state() # Save variables +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${MPI_DUNE_INCLUDE_PATH}) +set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${MPI_DUNE_COMPILE_FLAGS}") + +find_path(PTSCOTCH_INCLUDE_DIR ptscotch.h + PATHS ${PTSCOTCH_ROOT} ${PTSCOTCH_ROOT}/include + PATH_SUFFIXES ${PATH_SUFFIXES} + NO_DEFAULT_PATH + DOC "Include directory of PT-Scotch") +find_path(PTSCOTCH_INCLUDE_DIR ptscotch.h + PATH_SUFFIXES ${PATH_SUFFIXES}) + +_search_pt_lib(PTSCOTCH_LIBRARY ptscotch "The main PT-Scotch library.") +_search_pt_lib(SCOTCH_LIBRARY scotch "The Scotch library.") +_search_pt_lib(PTSCOTCHERR_LIBRARY ptscotcherr "The PT-Scotch error library.") + +# behave like a CMake module is supposed to behave +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "PTScotch" + DEFAULT_MSG + PTSCOTCH_INCLUDE_DIR + PTSCOTCH_LIBRARY + SCOTCH_LIBRARY + PTSCOTCHERR_LIBRARY +) +#restore old values +cmake_pop_check_state() + +if(PTSCOTCH_FOUND) + set(PTSCOTCH_INCLUDE_DIRS ${PTSCOTCH_INCLUDE_DIR}) + set(PTSCOTCH_LIBRARIES ${PTSCOTCH_LIBRARY} ${SCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY} ${MPI_DUNE_LIBRARIES} + CACHE FILEPATH "All libraries needed to link programs using PT-Scotch") + set(PTSCOCH_LINK_FLAGS "${DUNE_MPI_LINK_FLAGS}" + CACHE STRING "PT-Scotch link flags") + set(HAVE_PTSCOTCH 1) + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determing location of PT-Scotch succeeded:\n" + "Include directory: ${PTSCOTCH_INCLUDE_DIRS}\n" + "Library directory: ${PTSCOTCH_LIBRARIES}\n\n") + + dune_register_package_flags(LIBRARIES "${PTSCOTCH_LIBRARIES}" + INCLUDE_DIRS "${PTSCOTCH_INCLUDE_DIRS}") +endif(PTSCOTCH_FOUND) + +mark_as_advanced(PTSCOTCH_INCLUDE_DIR PTSCOTCH_LIBRARIES HAVE_PTSCOTCH) diff -Nru dune-common-2.2.1/cmake/modules/FindSphinx.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindSphinx.cmake --- dune-common-2.2.1/cmake/modules/FindSphinx.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindSphinx.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,41 @@ +# .. cmake_module:: +# +# Find Sphinx - the python documentation tool +# +# You may set the following variables to modify the +# behaviour of this module: +# +# :ref:`SPHINX_ROOT` +# the path to look for sphinx with the highest priority +# +# The following variables are set by this module: +# +# :code:`SPHINX_FOUND` +# whether Sphinx was found +# +# :code:`SPHINX_EXECUTABLE` +# the path to the sphinx-build executable +# +# .. cmake_variable:: SPHINX_ROOT +# +# You may set this variable to have :ref:`FindSphinx` look +# for the :code:`sphinx-build` executable in the given path +# before inspecting system paths. +# + +#TODO export version. + +find_program(SPHINX_EXECUTABLE + NAMES sphinx-build + PATHS ${SPHINX_ROOT} + NO_DEFAULT_PATH) + +find_program(SPHINX_EXECUTABLE + NAMES sphinx-build) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "Sphinx" + DEFAULT_MSG + SPHINX_EXECUTABLE +) diff -Nru dune-common-2.2.1/cmake/modules/FindSuiteSparse.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindSuiteSparse.cmake --- dune-common-2.2.1/cmake/modules/FindSuiteSparse.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindSuiteSparse.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,281 @@ +# .. cmake_module:: +# +# Find the SuiteSparse libraries like UMFPACK or SPQR. +# +# Example which tries to find Suite Sparse's UMFPack component: +# +# :code:`find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK)` +# +# `OPTIONAL_COMPONENTS` +# A list of components. Components are: +# AMD, BTF, CAMD, CCOLAMD, CHOLMOD, COLAMD, CXSPARSE, +# KLU, LDL, RBIO, SPQR, UMFPACK +# +# :ref:`SuiteSparse_ROOT` +# Path list to search for SuiteSparse +# +# Sets the following variables: +# +# :code:`SuiteSparse_FOUND` +# True if SuiteSparse was found. +# +# :code:`SuiteSparse_INCLUDE_DIRS` +# Path to the SuiteSparse include dirs. +# +# :code:`SuiteSparse_LIBRARIES` +# Name of the SuiteSparse libraries. +# +# :code:`SuiteSparse__FOUND` +# Whether was found as part of SuiteSparse. +# +# .. cmake_variable:: SuiteSparse_ROOT +# +# You may set this variable to have :ref:`FindSuiteSparse` look +# for SuiteSparse in the given path before inspecting +# system paths. +# + +find_package(BLAS QUIET) + +# look for desired componenents +set(SUITESPARSE_COMPONENTS ${SuiteSparse_FIND_COMPONENTS}) + +# resolve inter-component dependencies +list(FIND SUITESPARSE_COMPONENTS "UMFPACK" WILL_USE_UMFPACK) +if(NOT WILL_USE_UMFPACK EQUAL -1) + list(APPEND SUITESPARSE_COMPONENTS AMD CHOLMOD) +endif() +list(FIND SUITESPARSE_COMPONENTS "CHOLMOD" WILL_USE_CHOLMOD) +if(NOT WILL_USE_CHOLMOD EQUAL -1) + list(APPEND SUITESPARSE_COMPONENTS AMD CAMD COLAMD CCOLAMD) +endif() + +if(SUITESPARSE_COMPONENTS) + list(REMOVE_DUPLICATES SUITESPARSE_COMPONENTS) +endif() + +# find SuiteSparse config: +# look for library at positions given by the user +find_library(SUITESPARSE_CONFIG_LIB + NAMES "suitesparseconfig" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "lib" "lib32" "lib64" "Lib" + NO_DEFAULT_PATH +) +# now also include the default paths +find_library(SUITESPARSE_CONFIG_LIB + NAMES "suitesparseconfig" + PATH_SUFFIXES "lib" "lib32" "lib64" "Lib" +) + +#look for header files at positions given by the user +find_path(SUITESPARSE_INCLUDE_DIR + NAMES "SuiteSparse_config.h" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include" + NO_DEFAULT_PATH +) +#now also look for default paths +find_path(SUITESPARSE_INCLUDE_DIR + NAMES "SuiteSparse_config.h" + PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include" +) + +foreach(_component ${SUITESPARSE_COMPONENTS}) + string(TOLOWER ${_component} _componentLower) + + #look for library at positions given by the user + find_library(${_component}_LIBRARY + NAMES "${_componentLower}" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "lib" "lib32" "lib64" "${_component}" "${_component}/Lib" + NO_DEFAULT_PATH + ) + #now also include the default paths + find_library(${_component}_LIBRARY + NAMES "${_componentLower}" + PATH_SUFFIXES "lib" "lib32" "lib64" "${_component}" "${_component}/Lib" + ) + + #look for header files at positions given by the user + find_path(${_component}_INCLUDE_DIR + NAMES "${_componentLower}.h" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "${_componentLower}" "include/${_componentLower}" "suitesparse" "include" "src" "${_component}" "${_component}/Include" + NO_DEFAULT_PATH + ) + #now also look for default paths + find_path(${_component}_INCLUDE_DIR + NAMES "${_componentLower}.h" + PATH_SUFFIXES "${_componentLower}" "include/${_componentLower}" "suitesparse" "include" "${_component}" "${_component}/Include" + ) +endforeach() + +# SPQR has different header file name SuiteSparseQR.hpp +#look for header files at positions given by the user +find_path(SPQR_INCLUDE_DIR + NAMES "SuiteSparseQR.hpp" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "spqr" "include/spqr" "suitesparse" "include" "src" "SPQR" "SPQR/Include" + NO_DEFAULT_PATH +) +#now also look for default paths +find_path(SPQR_INCLUDE_DIR + NAMES "SuiteSparseQR.hpp" + PATH_SUFFIXES "spqr" "include/spqr" "suitesparse" "include" "SPQR" "SPQR/Include" +) + +# resolve inter-modular dependencies + +# CHOLMOD requires AMD, COLAMD; CAMD and CCOLAMD are optional +if(CHOLMOD_LIBRARY) + if(NOT (AMD_LIBRARY AND COLAMD_LIBRARY)) + message(WARNING "CHOLMOD requires AMD and COLAMD which were not found, skipping the test.") + set(SuiteSparse_CHOLMOD_FOUND "CHOLMOD requires AMD and COLAMD-NOTFOUND") + endif() + + list(APPEND CHOLMOD_LIBRARY ${AMD_LIBRARY} ${COLAMD_LIBRARY}) + if(CAMD_LIBRARY) + list(APPEND CHOLMOD_LIBRARY ${CAMD_LIBRARY}) + endif() + if(CCOLAMD_LIBRARY) + list(APPEND CHOLMOD_LIBRARY ${CCOLAMD_LIBRARY}) + endif() + list(REVERSE CHOLMOD_LIBRARY) + # remove duplicates + list(REMOVE_DUPLICATES CHOLMOD_LIBRARY) + list(REVERSE CHOLMOD_LIBRARY) +endif() + +# UMFPack requires AMD, can depend on CHOLMOD +if(UMFPACK_LIBRARY) + # check wether cholmod was found + if(CHOLMOD_LIBRARY) + list(APPEND UMFPACK_LIBRARY ${CHOLMOD_LIBRARY}) + else() + list(APPEND UMFPACK_LIBRARY ${AMD_LIBRARY}) + endif() + list(REVERSE UMFPACK_LIBRARY) + # remove duplicates + list(REMOVE_DUPLICATES UMFPACK_LIBRARY) + list(REVERSE UMFPACK_LIBRARY) +endif() + +# check wether everything was found +foreach(_component ${SUITESPARSE_COMPONENTS}) + # variable used for component handling + if(${_component}_LIBRARY AND ${_component}_INCLUDE_DIR) + set(SuiteSparse_${_component}_FOUND TRUE) + else() + set(SuiteSparse_${_component}_FOUND FALSE) + endif() + set(HAVE_SUITESPARSE_${_component} ${SuiteSparse_${_component}_FOUND}) + if(SuiteSparse_${_component}_FOUND) + list(APPEND SUITESPARSE_INCLUDE_DIR "${${_component}_INCLUDE_DIR}") + list(APPEND SUITESPARSE_LIBRARY "${${_component}_LIBRARY}") + endif() + + mark_as_advanced( + HAVE_SUITESPARSE_${_component} + SuiteSparse_${_component}_FOUND + ${_component}_INCLUDE_DIR + ${_component}_LIBRARY) +endforeach() + +# check version, for SPQR we need at least SuiteSparse 4.3 +if(SuiteSparse_SPQR_FOUND) + include(CheckCSourceCompiles) + include(CMakePushCheckState) + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SUITESPARSE_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SUITESPARSE_LIBRARY}) + # check whether version is at least 4.3 + check_c_source_compiles(" + #include + int main(void) + { + #ifndef SUITESPARSE_HAS_VERSION_FUNCTION + #error SuiteSparse <= 4.2.0 too old, required version 4.3 or newer for SPQR. + #endif + #if SUITESPARSE_VERSION <= 4003 + #error SuiteSparse too old, required version 4.3 or newer for SPQR. + #endif + return 0; + }" + SUITESPARSE_MIN_VERSION_4_3) + + if(NOT SUITESPARSE_MIN_VERSION_4_3) + set(SuiteSparse_SPQR_FOUND FALSE) + set(HAVE_SUITESPARSE_SPQR FALSE) + endif() + cmake_pop_check_state() +endif() + +list(APPEND SUITESPARSE_LIBRARY ${SUITESPARSE_CONFIG_LIB}) + +# make them unique +if(SUITESPARSE_INCLUDE_DIR) + list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIR) +endif() +if(SUITESPARSE_LIBRARY) + list(REVERSE SUITESPARSE_LIBRARY) + list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY) + list(REVERSE SUITESPARSE_LIBRARY) +endif() + +# behave like a CMake module is supposed to behave +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "SuiteSparse" + FOUND_VAR SuiteSparse_FOUND + REQUIRED_VARS + BLAS_FOUND + SUITESPARSE_INCLUDE_DIR + SUITESPARSE_LIBRARY + HANDLE_COMPONENTS +) + +mark_as_advanced( + SUITESPARSE_INCLUDE_DIR + SUITESPARSE_LIBRARY + SUITESPARSE_CONFIG_LIB + SUITESPARSE_MIN_VERSION_4_3 + WILL_USE_CHOLMOD + WILL_USE_UMFPACK) + +# if both headers and library are found, store results +if(SuiteSparse_FOUND) + set(SuiteSparse_LIBRARIES ${SUITESPARSE_LIBRARY}) + set(SuiteSparse_INCLUDE_DIRS ${SUITESPARSE_INCLUDE_DIR}) + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining location of SuiteSparse succeeded:\n" + "Include directory: ${SuiteSparse_INCLUDE_DIRS}\n" + "Library directory: ${SuiteSparse_LIBRARIES}\n\n") + set(SuiteSparse_COMPILER_FLAGS) + foreach(dir ${SuiteSparse_INCLUDE_DIRS}) + set(SuiteSparse_COMPILER_FLAGS "${SuiteSparse_COMPILER_FLAGS} -I${dir}/") + endforeach() + set(SuiteSparse_DUNE_COMPILE_FLAGS ${SuiteSparse_COMPILER_FLAGS} + CACHE STRING "Compile Flags used by DUNE when compiling with SuiteSparse programs") + set(SuiteSparse_DUNE_LIBRARIES ${BLAS_LIBRARIES} ${SuiteSparse_LIBRARIES} + CACHE STRING "Libraries used by DUNE when linking SuiteSparse programs") +else() + # log errornous result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKES_FILES_DIRECTORY}/CMakeError.log + "Determing location of SuiteSparse failed:\n" + "Include directory: ${SuiteSparse_INCLUDE_DIRS}\n" + "Library directory: ${SuiteSparse_LIBRARIES}\n\n") +endif() + +#set HAVE_SUITESPARSE for config.h +set(HAVE_SUITESPARSE ${SuiteSparse_FOUND}) +set(HAVE_UMFPACK ${SuiteSparse_UMFPACK_FOUND}) + +# register all SuiteSparse related flags +if(SuiteSparse_FOUND) + dune_register_package_flags( + COMPILE_DEFINITIONS "ENABLE_SUITESPARSE=1" + LIBRARIES "${SuiteSparse_LIBRARIES}" + INCLUDE_DIRS "${SuiteSparse_INCLUDE_DIRS}") +endif() diff -Nru dune-common-2.2.1/cmake/modules/FindThreadsCMake31.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindThreadsCMake31.cmake --- dune-common-2.2.1/cmake/modules/FindThreadsCMake31.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindThreadsCMake31.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,257 @@ +# .. cmake_module:: +# +# This module determines the thread library of the system. +# +# This file is a modified copy from CMake 3.1. Do not edit this +# file. Remove this file once we rely on at least CMake 3.1. +# +# The following variables are set +# +# :code:`CMAKE_THREAD_LIBS_INIT` +# the thread library +# +# :code:`CMAKE_USE_SPROC_INIT` +# are we using sproc? +# +# :code:`CMAKE_USE_WIN32_THREADS_INIT` +# using WIN32 threads? +# +# :code:`CMAKE_USE_PTHREADS_INIT` +# are we using pthreads +# +# :code:`CMAKE_HP_PTHREADS_INIT` +# are we using hp pthreads +# +# .. cmake_variable:: CMAKE_THREAD_PREFER_PTHREAD +# +# For systems with multiple thread libraries, caller can set this +# variable to prefer pthread. Modifies the behaviour of :ref:`FindThreadsCMake31`. +# +# .. cmake_variable:: THREADS_PREFER_PTHREAD_FLAG +# +# If the use of the -pthread compiler and linker flag is preferred then the +# caller can set this variable. Modifies the behaviour of :ref:`FindThreadsCMake31`. +# + +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2015 Kitware, Inc. +# Copyright 2011-2014 Rolf Eike Beer +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the names of Kitware, Inc., the Insight Software Consortium, +# nor the names of their contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ------------------------------------------------------------------------------ +# +# The above copyright and license notice applies to distributions of +# CMake in source and binary form. Some source files contain additional +# notices of original copyright by their contributors; see each source +# for details. Third-party software packages supplied with CMake under +# compatible licenses provide their own copyright notices documented in +# corresponding subdirectories. +# +# ------------------------------------------------------------------------------ +# +# CMake was initially developed by Kitware with the following sponsorship: +# +# * National Library of Medicine at the National Institutes of Health +# as part of the Insight Segmentation and Registration Toolkit (ITK). +# +# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel +# Visualization Initiative. +# +# * National Alliance for Medical Image Computing (NAMIC) is funded by the +# National Institutes of Health through the NIH Roadmap for Medical Research, +# Grant U54 EB005149. +# +# * Kitware, Inc. + +include (CheckIncludeFiles) +include (CheckLibraryExists) +include (CheckSymbolExists) +set(Threads_FOUND FALSE) +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY}) + +# Do we have sproc? +if(CMAKE_SYSTEM_NAME MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD) + CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H) +endif() + +# Internal helper macro. +# Do NOT even think about using it outside of this file! +macro(_check_threads_lib LIBNAME FUNCNAME VARNAME) + if(NOT Threads_FOUND) + CHECK_LIBRARY_EXISTS(${LIBNAME} ${FUNCNAME} "" ${VARNAME}) + if(${VARNAME}) + set(CMAKE_THREAD_LIBS_INIT "-l${LIBNAME}") + set(CMAKE_HAVE_THREADS_LIBRARY 1) + set(Threads_FOUND TRUE) + endif() + endif () +endmacro() + +# Internal helper macro. +# Do NOT even think about using it outside of this file! +macro(_check_pthreads_flag) + if(NOT Threads_FOUND) + # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread + if(NOT DEFINED THREADS_HAVE_PTHREAD_ARG) + message(STATUS "Check if compiler accepts -pthread") + try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c + CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread + COMPILE_OUTPUT_VARIABLE OUTPUT) + + if(THREADS_HAVE_PTHREAD_ARG) + if(THREADS_PTHREAD_ARG STREQUAL "2") + set(Threads_FOUND TRUE) + message(STATUS "Check if compiler accepts -pthread - yes") + else() + message(STATUS "Check if compiler accepts -pthread - no") + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if compiler accepts -pthread returned ${THREADS_PTHREAD_ARG} instead of 2. The compiler had the following output:\n${OUTPUT}\n\n") + endif() + else() + message(STATUS "Check if compiler accepts -pthread - no") + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n") + endif() + + endif() + + if(THREADS_HAVE_PTHREAD_ARG) + set(Threads_FOUND TRUE) + set(CMAKE_THREAD_LIBS_INIT "-pthread") + endif() + endif() +endmacro() + +if(CMAKE_HAVE_SPROC_H AND NOT CMAKE_THREAD_PREFER_PTHREAD) + # We have sproc + set(CMAKE_USE_SPROC_INIT 1) +else() + # Do we have pthreads? + CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H) + if(CMAKE_HAVE_PTHREAD_H) + + # + # We have pthread.h + # Let's check for the library now. + # + set(CMAKE_HAVE_THREADS_LIBRARY) + if(NOT THREADS_HAVE_PTHREAD_ARG) + # Check if pthread functions are in normal C library + CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE) + if(CMAKE_HAVE_LIBC_CREATE) + set(CMAKE_THREAD_LIBS_INIT "") + set(CMAKE_HAVE_THREADS_LIBRARY 1) + set(Threads_FOUND TRUE) + else() + + # Check for -pthread first if enabled. This is the recommended + # way, but not backwards compatible as one must also pass -pthread + # as compiler flag then. + if (THREADS_PREFER_PTHREAD_FLAG) + _check_pthreads_flag() + endif () + + _check_threads_lib(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE) + _check_threads_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE) + if(CMAKE_SYSTEM_NAME MATCHES "SunOS") + # On sun also check for -lthread + _check_threads_lib(thread thr_create CMAKE_HAVE_THR_CREATE) + endif() + endif() + endif() + + _check_pthreads_flag() + endif() +endif() + +if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE) + set(CMAKE_USE_PTHREADS_INIT 1) + set(Threads_FOUND TRUE) +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Windows") + set(CMAKE_USE_WIN32_THREADS_INIT 1) + set(Threads_FOUND TRUE) +endif() + +if(CMAKE_USE_PTHREADS_INIT) + if(CMAKE_SYSTEM_NAME MATCHES "HP-UX") + # Use libcma if it exists and can be used. It provides more + # symbols than the plain pthread library. CMA threads + # have actually been deprecated: + # http://docs.hp.com/en/B3920-90091/ch12s03.html#d0e11395 + # http://docs.hp.com/en/947/d8.html + # but we need to maintain compatibility here. + # The CMAKE_HP_PTHREADS setting actually indicates whether CMA threads + # are available. + CHECK_LIBRARY_EXISTS(cma pthread_attr_create "" CMAKE_HAVE_HP_CMA) + if(CMAKE_HAVE_HP_CMA) + set(CMAKE_THREAD_LIBS_INIT "-lcma") + set(CMAKE_HP_PTHREADS_INIT 1) + set(Threads_FOUND TRUE) + endif() + set(CMAKE_USE_PTHREADS_INIT 1) + endif() + + if(CMAKE_SYSTEM MATCHES "OSF1-V") + set(CMAKE_USE_PTHREADS_INIT 0) + set(CMAKE_THREAD_LIBS_INIT ) + endif() + + if(CMAKE_SYSTEM MATCHES "CYGWIN_NT") + set(CMAKE_USE_PTHREADS_INIT 1) + set(Threads_FOUND TRUE) + set(CMAKE_THREAD_LIBS_INIT ) + set(CMAKE_USE_WIN32_THREADS_INIT 0) + endif() +endif() + +set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND) + +# if(THREADS_FOUND AND NOT TARGET Threads::Threads) +# add_library(Threads::Threads INTERFACE IMPORTED) +# +# if(THREADS_HAVE_PTHREAD_ARG) +# set_property(TARGET Threads::Threads PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread") +# endif() +# +# if(CMAKE_THREAD_LIBS_INIT) +# set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") +# endif() +# endif() diff -Nru dune-common-2.2.1/cmake/modules/FindUMFPack.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindUMFPack.cmake --- dune-common-2.2.1/cmake/modules/FindUMFPack.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/FindUMFPack.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,83 @@ +# .. cmake_module:: +# +# Find the UMFPack library +# +# .. deprecated:: 3.0 +# Use :code:`find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK)` instead +# +# You may set the following variables to modify the +# behaviour of this module: +# +# :ref:`UMFPACK_ROOT` +# Path list to search for UMFPack. +# +# Sets the following variables: +# +# :code:`UMFPACK_FOUND` +# True if the GMP library was found. +# +# :code:`UMFPACK_INCLUDE_DIRS` +# List of include directories with the UMFPack headers +# +# :code:`UMFPACK_LIBRARIES` +# List of libraries to link with UMFPack. +# +# .. cmake_variable:: UMFPACK_ROOT +# +# You may set this variable to have :ref:`FindUMFPack` look +# for the UMFPack package in the given path before inspecting +# system paths. +# + +find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK) + +# use find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK) instead +message(WARNING "find_package(UMFPack) is deprecated, please use FindSuiteSparse instead") + +set(UMFPACK_INCLUDE_DIRS ${SuiteSparse_INCLUDE_DIRS}) +set(UMFPACK_LIBRARIES ${SuiteSparse_LIBRARIES}) + +# behave like a CMake module is supposed to behave +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "UMFPack" + DEFAULT_MSG + UMFPACK_INCLUDE_DIRS + UMFPACK_LIBRARIES +) + +mark_as_advanced(UMFPACK_INCLUDE_DIRS UMFPACK_LIBRARIES) + +# if both headers and library are found, store results +if(UMFPACK_FOUND) + foreach( dir ${UMFPACK_INCLUDE_DIR} ) + list( APPEND UMFPACK_INCLUDE_FLAGS "-I${dir}/ " ) + endforeach() + set(UMFPACK_LIBRARIES ${UMFPACK_LIBRARIES}) + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining location of UMFPack succeeded:\n" + "Include directory: ${UMFPACK_INCLUDE_DIRS}\n" + "Library directory: ${UMFPACK_LIBRARIES}\n\n") + set(UMFPACK_DUNE_COMPILE_FLAGS "${UMFPACK_INCLUDE_FLAGS}" + CACHE STRING "Compile Flags used by DUNE when compiling with UMFPack programs") + set(UMFPACK_DUNE_LIBRARIES ${UMFPACK_LIBRARIES} ${BLAS_LIBRARIES} ${AMD_LIBRARY} + CACHE STRING "Libraries used by DUNE when linking UMFPack programs") +else(UMFPACK_FOUND) + # log errornous result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKES_FILES_DIRECTORY}/CMakeError.log + "Determing location of UMFPack failed:\n" + "Include directory: ${UMFPACK_INCLUDE_DIRS}\n" + "Library directory: ${UMFPACK_LIBRARIES}\n\n") +endif(UMFPACK_FOUND) + +#set HAVE_UMFPACK for config.h +set(HAVE_UMFPACK ${UMFPACK_FOUND}) +set(HAVE_SUITESPARSE_UMFPACK ${UMFPACK_FOUND}) + +# register all umfpack related flags +if(UMFPACK_FOUND) + dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_UMFPACK=1" + LIBRARIES "${UMFPACK_LIBRARIES}" + INCLUDE_DIRS "${UMFPACK_INCLUDE_DIRS}") +endif() diff -Nru dune-common-2.2.1/cmake/modules/Headercheck.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/Headercheck.cmake --- dune-common-2.2.1/cmake/modules/Headercheck.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/Headercheck.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,82 @@ +# .. cmake_variable:: ENABLE_HEADERCHECK +# +# Set this variable to TRUE if you want to use the CMake +# reimplementation of the old autotools feaure :code:`make headercheck`. +# There has been a couple of issues with this implementation in +# the past, so it was deactivated by default. +# + +# sets up a global property with the names of all header files +# in the module and a global target depending on all checks +macro(setup_headercheck) + #glob for headers + file(GLOB_RECURSE all_headers "*.hh") + # strip hidden files + string(REGEX REPLACE "[^;]*/\\.[^;]*\\.hh;?" "" headers "${all_headers}") + set_property(GLOBAL PROPERTY headercheck_list ${headers}) + + #define headercheck target + dune_module_path(MODULE dune-common RESULT scriptdir SCRIPT_DIR) + add_custom_target(headercheck ${CMAKE_COMMAND} -P ${scriptdir}/FinalizeHeadercheck.cmake -DENABLE_HEADERCHECK=${ENABLE_HEADERCHECK} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endmacro(setup_headercheck) + +# these macros are used to exclude headers from make headercheck +# call this from a CMakeLists.txt file with a list of headers in that directory +macro(exclude_from_headercheck) + #make this robust to argument being passed with or without "" + string(REGEX REPLACE "[\ \n]+([^\ ])" ";\\1" list ${ARGV0}) + set(list "${list};${ARGV}") + get_property(headerlist GLOBAL PROPERTY headercheck_list) + foreach(item ${list}) + list(REMOVE_ITEM headerlist "${CMAKE_CURRENT_SOURCE_DIR}/${item}") + endforeach() + set_property(GLOBAL PROPERTY headercheck_list ${headerlist}) +endmacro(exclude_from_headercheck) + +macro(exclude_dir_from_headercheck) + file(GLOB list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.hh") + exclude_from_headercheck(${list}) +endmacro(exclude_dir_from_headercheck) + +macro(exclude_all_but_from_headercheck) + file(GLOB excllist RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.hh") + #make this robust to argument being passed with or without "" + string(REGEX REPLACE "[\ \n]+([^\ \n])" ";\\1" list ${ARGV0}) + set(list "${list};${ARGV}") + foreach(item ${list}) + list(REMOVE_ITEM excllist ${item}) + endforeach() + exclude_from_headercheck(${excllist}) +endmacro(exclude_all_but_from_headercheck) + +# configure all headerchecks +macro(finalize_headercheck) + if(ENABLE_HEADERCHECK) + get_property(headerlist GLOBAL PROPERTY headercheck_list) + foreach(header ${headerlist}) + #do some name conversion + string(REGEX REPLACE ".*/([^/]*)" "\\1" simple ${header}) + string(REPLACE ${PROJECT_SOURCE_DIR} "" rel ${header}) + string(REGEX REPLACE "(.*)/[^/]*" "\\1" relpath ${rel}) + string(REGEX REPLACE "/" "_" targname ${rel}) + + #generate the headercheck .cc file + file(WRITE ${CMAKE_BINARY_DIR}/headercheck/${rel}.cc "#ifdef HAVE_CONFIG_H\n#include\n#endif\n#include<${simple}>\n#include<${simple}>\nint main(){return 0;}") + + # add target for the check of current header, this is implemented as a library + # to prevent CMake from automatically trying to link the target, functionality + # of macro try_compile() is unfortunately not availbale due to it not being scriptable. + add_library(headercheck_${targname} STATIC EXCLUDE_FROM_ALL + ${CMAKE_BINARY_DIR}/headercheck/${rel}.cc) + add_dependencies(headercheck headercheck_${targname}) + + #add PKG_ALL_FLAGS and the directory where the header is located + set_property(TARGET headercheck_${targname} + APPEND_STRING PROPERTY COMPILE_FLAGS "-DHEADERCHECK -I${PROJECT_SOURCE_DIR}${relpath} -I${CMAKE_BINARY_DIR}") + set_property(TARGET headercheck_${targname} PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/headercheck/${relpath}") + add_dune_all_flags(headercheck_${targname}) + unset(headercheck_${targname}_LIB_DEPENDS CACHE) + endforeach(header ${headerlist}) + endif() +endmacro(finalize_headercheck) diff -Nru dune-common-2.2.1/cmake/modules/LanguageSupport.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/LanguageSupport.cmake --- dune-common-2.2.1/cmake/modules/LanguageSupport.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/LanguageSupport.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,66 @@ +# cmake/modules/language_support.cmake +# +# Temporary additional general language support is contained within this +# file. + +# This additional function definition is needed to provide a workaround for +# CMake bug 9220. + +# On debian testing (cmake 2.6.2), I get return code zero when calling +# cmake the first time, but cmake crashes when running a second time +# as follows: +# +# -- The Fortran compiler identification is unknown +# CMake Error at /usr/share/cmake-2.6/Modules/CMakeFortranInformation.cmake:7 (GET_FILENAME_COMPONENT): +# get_filename_component called with incorrect number of arguments +# Call Stack (most recent call first): +# CMakeLists.txt:3 (enable_language) +# +# My workaround is to invoke cmake twice. If both return codes are zero, +# it is safe to invoke ENABLE_LANGUAGE(Fortran OPTIONAL) + +function(workaround_9220 language language_works) + #message("DEBUG: language = ${language}") + set(text + "project(test NONE) + cmake_minimum_required(VERSION 2.8.0) + set (CMAKE_Fortran_FLAGS \"${CMAKE_Fortran_FLAGS}\") + set (CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}\") + enable_language(${language} OPTIONAL) + ") + file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/language_tests/${language}) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}) + file(WRITE ${CMAKE_BINARY_DIR}/language_tests/${language}/CMakeLists.txt + ${text}) + execute_process( + COMMAND ${CMAKE_COMMAND} . -G "${CMAKE_GENERATOR}" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language} + RESULT_VARIABLE return_code + OUTPUT_QUIET + ERROR_QUIET + ) + + if(return_code EQUAL 0) + # Second run + execute_process ( + COMMAND ${CMAKE_COMMAND} . + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language} + RESULT_VARIABLE return_code + OUTPUT_QUIET + ERROR_QUIET + ) + if(return_code EQUAL 0) + set(${language_works} ON PARENT_SCOPE) + else(return_code EQUAL 0) + set(${language_works} OFF PARENT_SCOPE) + endif(return_code EQUAL 0) + else(return_code EQUAL 0) + set(${language_works} OFF PARENT_SCOPE) + endif(return_code EQUAL 0) +endfunction(workaround_9220) + +# Temporary tests of the above function. +#workaround_9220(CXX CXX_language_works) +#message("CXX_language_works = ${CXX_language_works}") +#workaround_9220(CXXp CXXp_language_works) +#message("CXXp_language_works = ${CXXp_language_works}") diff -Nru dune-common-2.2.1/cmake/modules/OverloadCompilerFlags.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/OverloadCompilerFlags.cmake --- dune-common-2.2.1/cmake/modules/OverloadCompilerFlags.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/OverloadCompilerFlags.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,142 @@ +# check whether the user wants to overload compile flags upon calling make +# +# Provides the following macros: +# +# initialize_compiler_script() : needs to be called before further flags are added to CMAKE_CXX_FLAGS +# finalize_compiler_script() : needs to be called at the end of the cmake macros, e.g. in finalize_dune_project +# +# Those two macro calls are hooked into dune_project/finalize_dune_project. +# +# .. cmake_variable:: ALLOW_CXXFLAGS_OVERWRITE +# +# Setting this option will allow you to overload preprocessor definitions from +# the command line, as it was possible naturally with the autotools build system. +# This feature only works with a :code:`Unix Makefiles` based generator. You can +# use it as: +# +# :code:`make CXXFLAGS="your flags" GRIDTYPE="grid type"` +# +# :code:`GRIDTYPE` can be anything defined in :code:`config.h` via the :ref:`dune_define_gridtype` macro from dune-grid. +# Furthermore any CPP variable of the form :code:`-DVAR=VALUE` can be overloaded on the command line. +# +# .. note:: +# If you don't know what this is or what it's good for, don't use it. +# + +option(ALLOW_CXXFLAGS_OVERWRITE OFF) +option(ALLOW_CFLAGS_OVERWRITE OFF) + +set(CXX_COMPILER_SCRIPT "${CMAKE_BINARY_DIR}/CXX_compiler.sh" ) +set(C_COMPILER_SCRIPT "${CMAKE_BINARY_DIR}/C_compiler.sh" ) + +macro(find_extended_unix_commands) + include(FindUnixCommands) + set(FLAGSNAMES "ALLOW_CXXFLAGS_OVERWRITE and/or ALLOW_CFLAGS_OVERWRITE") + find_program (GREP_PROGRAM grep) + if(NOT GREP_PROGRAM) + message( SEND_ERROR "grep not found, please disable ${FLAGSNAMES}") + endif() + find_program (SED_PROGRAM sed) + if(NOT SED_PROGRAM) + message( SEND_ERROR "sed not found, please disable ${FLAGSNAMES}") + endif() + find_program (CUT_PROGRAM cut) + if(NOT CUT_PROGRAM) + message( SEND_ERROR "cut not found, please disable ${FLAGSNAMES}") + endif() + find_program (ENV_PROGRAM env) + if(NOT ENV_PROGRAM) + message( SEND_ERROR "env not found, please disable ${FLAGSNAMES}") + endif() + find_program (ECHO_PROGRAM echo) + if(NOT ECHO_PROGRAM) + message( SEND_ERROR "echo not found, please disable ${FLAGSNAMES}") + endif() + find_program (CHMOD_PROGRAM chmod) + if(NOT CHMOD_PROGRAM) + message( SEND_ERROR "chmod not found, please disable ${FLAGSNAMES}") + endif() + mark_as_advanced(GREP_PROGRAM) + mark_as_advanced(SED_PROGRAM) + mark_as_advanced(CUT_PROGRAM) + mark_as_advanced(ENV_PROGRAM) + mark_as_advanced(ECHO_PROGRAM) + mark_as_advanced(CHMOD_PROGRAM) +endmacro(find_extended_unix_commands) + +# init compiler script and store CXX flags +macro(initialize_compiler_script) + if(ALLOW_CXXFLAGS_OVERWRITE AND (${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*")) + # check for unix commands necessary + find_extended_unix_commands() + # set CXXFLAGS as environment variable + set( DEFAULT_CXXFLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "default CXX flags") + set( CMAKE_CXX_FLAGS "" ) + set( DEFAULT_CXX_COMPILER ${CMAKE_CXX_COMPILER} ) + set( CXX_COMPILER_SCRIPT_FILE "#!${BASH}\nexec ${CMAKE_CXX_COMPILER} \"\$@\"") + file(WRITE ${CXX_COMPILER_SCRIPT} "${CXX_COMPILER_SCRIPT_FILE}") + execute_process(COMMAND ${CHMOD_PROGRAM} 755 ${CXX_COMPILER_SCRIPT}) + set(CMAKE_CXX_COMPILER ${CXX_COMPILER_SCRIPT}) + endif() + if(ALLOW_CFLAGS_OVERWRITE AND (${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*")) + # check for unix commands necessary + find_extended_unix_commands() + # set CFLAGS as environment variable + set( DEFAULT_CFLAGS ${CMAKE_C_FLAGS} CACHE STRING "default C flags") + set( CMAKE_C_FLAGS "" ) + set( DEFAULT_C_COMPILER ${CMAKE_C_COMPILER} ) + set( C_COMPILER_SCRIPT_FILE "#!${BASH}\nexec ${CMAKE_C_COMPILER} \"\$@\"") + file(WRITE ${C_COMPILER_SCRIPT} "${C_COMPILER_SCRIPT_FILE}") + execute_process(COMMAND ${CHMOD_PROGRAM} 755 ${C_COMPILER_SCRIPT}) + set(CMAKE_C_COMPILER ${C_COMPILER_SCRIPT}) + endif() +endmacro() + +# finalize compiler script and write it +macro(finalize_compiler_script) + if(${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*") + # check CXX compiler + if((ALLOW_CXXFLAGS_OVERWRITE)) + set(COMPILERS "CXX") + endif() + # check C compiler + if((ALLOW_CFLAGS_OVERWRITE)) + set(COMPILERS ${COMPILERS} "C") + endif() + + # for the found compilers for flag overloading generate compiler script + foreach(COMP ${COMPILERS}) + set( COMPILER_SCRIPT_FILE "#!${BASH}\nSED=${SED_PROGRAM}\nGREP=${GREP_PROGRAM}") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nCUT=${CUT_PROGRAM}\nENV=${ENV_PROGRAM}\nECHO=${ECHO_PROGRAM}") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n# store flags\nFLAGS=\"\$@\"") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nMAKE_EXECUTABLE_NEW=0\n") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nif [ \"\$${COMP}FLAGS\" == \"\" ]; then\n # default ${COMP} flags\n ${COMP}FLAGS=\"${DEFAULT_CXXFLAGS}\"\nfi\n") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nif [ \"\$EXTRA_${COMP}FLAGS\" != \"\" ]; then\n # extra ${COMP} flags\n ${COMP}FLAGS=\"$${COMP}FLAGS $EXTRA_${COMP}FLAGS\"\nfi\n") + # only for CXX we need to scan config.h for GRIDTYPE + if( ${COMP} STREQUAL "CXX" ) + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nGRIDS=\nCONFIG_H=${CMAKE_BINARY_DIR}/config.h") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nif [ \"\$GRIDTYPE\" != \"\" ]; then") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n GRIDS=`\$GREP \"defined USED_[A-Z_]*_GRIDTYPE\" \$CONFIG_H | \$SED 's/\\(.*defined USED\\_\\)\\(.*\\)\\(\\_GRIDTYPE*\\)/\\2/g'`\nfi\n") + endif() + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nOLDFLAGS=\$FLAGS\nFLAGS=") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nfor FLAG in \$OLDFLAGS; do") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n NEWFLAG=\$FLAG\n VARNAME=`\$ECHO \$FLAG | \$GREP \"\\-D\" | \$SED 's/-D//g'`") + # only for CXX we have GRIDTYPE + if( ${COMP} STREQUAL "CXX" ) + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n for GRID in \$GRIDS; do\n if [ \"\$VARNAME\" == \"\$GRID\" ]; then\n NEWFLAG=\"-D\$GRIDTYPE\"\n break\n fi\n done") + endif() + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n VARNAME=`\$ECHO \$VARNAME | \$GREP \"=\" | \$CUT -d \"=\" -f 1`") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n if [ \"\$VARNAME\" != \"\" ]; then\n VAR=`\$ENV | \$GREP \$VARNAME`\n if [ \"\$VAR\" != \"\" ]; then") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n # add variable from environment to flags list\n NEWFLAG=\"-D\$VARNAME=\${!VARNAME}\"\n fi\n fi") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n FLAGS=\"\$FLAGS \$NEWFLAG\"\ndone") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n\$ECHO \"${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS\"") + set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nexec ${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS") + message("-- Generating ${COMP} compiler script for ${COMP}FLAGS overloading on command line") + if( ${COMP} STREQUAL "CXX" ) + file(WRITE ${CXX_COMPILER_SCRIPT} "${COMPILER_SCRIPT_FILE}") + else() + file(WRITE ${C_COMPILER_SCRIPT} "${COMPILER_SCRIPT_FILE}") + endif() + endforeach() + endif() +endmacro() diff -Nru dune-common-2.2.1/cmake/modules/UseInkscape.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/UseInkscape.cmake --- dune-common-2.2.1/cmake/modules/UseInkscape.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/UseInkscape.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,72 @@ +# Module that provides conversion routines using inkscape +# +# .. cmake_function:: inkscape_generate_png_from_svg +# +# .. cmake_param:: OUTPUT_DIR +# :single: +# +# The output directory for the generated png files. +# Defaults to the current build directory. +# +# .. cmake_param:: pngfiles +# :single: +# :positional: +# :required: +# +# The files that should be converted. +# +# .. cmake_param:: DPI +# :single: +# +# dpi value for the generated image (default: 90) +# +# TODO Switch to named arguments! +# + +include(CMakeParseArguments) + +function(inkscape_generate_png_from_svg) + if(NOT INKSCAPE) + return() + endif(NOT INKSCAPE) + cmake_parse_arguments(INKSCAPE "" "OUTPUT_DIR;DPI" "" ${ARGN}) + if(NOT INKSCAPE_OUTPUT_DIR) + set(INKSCAPE_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif(NOT INKSCAPE_OUTPUT_DIR) + if(NOT INKSCAPE_DPI) + set(INKSCAPE_DPI 90) + endif(NOT INKSCAPE_DPI) + + foreach(pic ${INKSCAPE_UNPARSED_ARGUMENTS}) + string(REGEX REPLACE "\\.[a-zA-Z]+" ".svg" input ${pic}) + add_custom_command(OUTPUT ${pic} + COMMAND ${INKSCAPE} --export-dpi=${INKSCAPE_DPI} -e ${pic} ${CMAKE_CURRENT_SOURCE_DIR}/${input} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${input} + COMMENT "Generating ${INKSCAPE_OUTPUT_DIR}/${pic} from ${CMAKE_CURRENT_SOURCE_DIR}/${input}" + WORKING_DIRECTORY ${INKSCAPE_OUTPUT_DIR}) + endforeach(pic) +endfunction(inkscape_generate_png_from_svg) + +function(inkscape_generate_eps_from_svg) + cmake_parse_arguments(INKSCAPE "" "INPUT_DIR;OUTPUT_DIR;DPI" "" ${ARGN}) + if(NOT INKSCAPE_INPUT_DIR) + set(INKSCAPE_INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + endif(NOT INKSCAPE_INPUT_DIR) + if(NOT INKSCAPE_INPUT_DIR) + set(INKSCAPE_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif(NOT INKSCAPE_INPUT_DIR) + + foreach(_pic ${INKSCAPE_UNPARSED_ARGUMENTS}) + string(REGEX REPLACE "\\.[a-zA-Z]+" ".png" input "${_pic}") + string(REGEX REPLACE "\\.[a-zA-Z]+" ".svg" svginput "${_pic}") + + add_custom_target(${input} + COMMAND ${INKSCAPE} --export-dpi=${INKSCAPE_DPI} -e ${input} ${CMAKE_CURRENT_SOURCE_DIR}/${svginput} + COMMENT "Generating ${INKSCAPE_OUTPUT_DIR}/${svginput} from ${CMAKE_CURRENT_SOURCE_DIR}/${input}") + add_custom_command(OUTPUT ${_pic} + COMMAND ${CONVERT} ${INKSCAPE_OUTPUT_DIR}/${input} EPS:${_pic} + DEPENDS ${input} + COMMENT "Converting ${INKSCAPE_OUTPUT_DIR}/${input} to ${INKSCAPE_OUTPUT_DIR}/${_pic}" + WORKING_DIRECTORY ${INKSCAPE_OUTPUT_DIR}) + endforeach(_pic ${INKSCAPE_UNPARSED_ARGUMENTS}) +endfunction(inkscape_generate_eps_from_svg) diff -Nru dune-common-2.2.1/cmake/modules/UseLATEX.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/modules/UseLATEX.cmake --- dune-common-2.2.1/cmake/modules/UseLATEX.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/modules/UseLATEX.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,1602 @@ +# File: UseLATEX.cmake +# CMAKE commands to actually use the LaTeX compiler +# Version: 2.3.0 +# Author: Kenneth Moreland +# +# Copyright 2004, 2015 Sandia Corporation. +# Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive +# license for use of this work by or on behalf of the U.S. Government. +# +# This software is released under the BSD 3-Clause License. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +# The following function is defined: +# +# add_latex_document( +# [BIBFILES ] +# [INPUTS ] +# [IMAGE_DIRS] +# [IMAGES] +# [CONFIGURE] +# [DEPENDS] +# [MULTIBIB_NEWCITES] +# [USE_BIBLATEX] +# [USE_INDEX] +# [INDEX_NAMES ] +# [USE_GLOSSARY] [USE_NOMENCL] +# [FORCE_PDF] [FORCE_DVI] [FORCE_HTML] +# [TARGET_NAME] +# [EXCLUDE_FROM_ALL] +# [EXCLUDE_FROM_DEFAULTS]) +# Adds targets that compile . The latex output is placed +# in LATEX_OUTPUT_PATH or CMAKE_CURRENT_BINARY_DIR if the former is +# not set. The latex program is picky about where files are located, +# so all input files are copied from the source directory to the +# output directory. This includes the target tex file, any tex file +# listed with the INPUTS option, the bibliography files listed with +# the BIBFILES option, and any .cls, .bst, and .clo files found in +# the current source directory. Images found in the IMAGE_DIRS +# directories or listed by IMAGES are also copied to the output +# directory and converted to an appropriate format if necessary. Any +# tex files also listed with the CONFIGURE option are also processed +# with the CMake CONFIGURE_FILE command (with the @ONLY flag). Any +# file listed in CONFIGURE but not the target tex file or listed with +# INPUTS has no effect. DEPENDS can be used to specify generated files +# that are needed to compile the latex target. +# +# The following targets are made. The name prefix is based off of the +# base name of the tex file unless TARGET_NAME is specified. If +# TARGET_NAME is specified, then that name is used for the targets. +# +# name_dvi: Makes .dvi +# name_pdf: Makes .pdf using pdflatex. +# name_safepdf: Makes .pdf using ps2pdf. If using the +# default program arguments, this will ensure all fonts +# are embedded and no lossy compression has been +# performed on images. +# name_ps: Makes .ps +# name_html: Makes .html +# name_auxclean: Deletes .aux and other auxiliary files. +# This is sometimes necessary if a LaTeX error occurs +# and writes a bad aux file. Unlike the regular clean +# target, it does not delete other input files, such as +# converted images, to save time on the rebuild. +# +# Unless the EXCLUDE_FROM_ALL option is given, one of these targets +# is added to the ALL target and built by default. Which target is +# determined by the LATEX_DEFAULT_BUILD CMake variable. See the +# documentation of that variable for more details. +# +# Unless the EXCLUDE_FROM_DEFAULTS option is given, all these targets +# are added as dependencies to targets named dvi, pdf, safepdf, ps, +# html, and auxclean, respectively. +# +# USE_BIBLATEX enables the use of biblatex/biber as an alternative to +# bibtex. Bibtex remains the default if USE_BIBLATEX is not +# specified. +# +# If the argument USE_INDEX is given, then commands to build an index +# are made. If the argument INDEX_NAMES is given, an index file is +# generated for each name in this list. See the LaTeX package multind +# for more information about how to generate multiple indices. +# +# If the argument USE_GLOSSARY is given, then commands to +# build a glossary are made. If the argument MULTIBIB_NEWCITES is +# given, then additional bibtex calls are added to the build to +# support the extra auxiliary files created with the \newcite command +# in the multibib package. +# +# History: +# +# 2.3.0 Add USE_BIBLATEX option to support the biblatex package, which +# requires using the program biber as a replacement for bibtex +# (thanks to David Tracey). +# +# 2.2.1 Add STRINGS property to LATEX_DEFAULT_BUILD to make it easier to +# select the default build in the CMake GUI. +# +# 2.2.0 Add TARGET_NAME option. +# +# 2.1.1 Support for finding bmp, ppm, and other image files. +# +# 2.1.0 Fix an error where the pdf target and others were defined multiple +# times if UseLATEX.cmake was included multiple times. +# +# Added INDEX_NAMES option to support multiple indexes in a single +# document from the multind package (thanks to Dan Lipsa). +# +# 2.0.0 First major revision of UseLATEX.cmake updates to more recent features +# of CMake and some non-backward compatible changes. +# +# Changed all function and macro names to lower case. CMake's identifiers +# are case insensitive, but the convention moved from all upper case to +# all lower case somewhere around the release of CMake 2. (The original +# version of UseLATEX.cmake predates that.) +# +# Remove condition matching in if statements. They are no longer necessary +# and are even discouraged (because else clauses get confusing). +# +# Use "new" features available in CMake such as list and argument parsing. +# +# Remove some code that has been deprecated for a while. +# +# Mark variables for compiler and converter executables as advanced to +# match the more conventional CMake behavior. +# +# Changed how default builds are specified and add the ability to force +# a particular build. +# +# Made the base targets (pdf, dvi, etc.) global. add_latex_document +# always mangles its target names and these base targets depend on +# the targets with mangled names. +# +# 1.10.5 Fix for Window's convert check (thanks to Martin Baute). +# +# 1.10.4 Copy font files to binary directory for packages that come with +# their own fonts. +# +# 1.10.3 Check for Windows version of convert being used instead of +# ImageMagick's version (thanks to Martin Baute). +# +# 1.10.2 Use htlatex as a fallback when latex2html is not available (thanks +# to Tomasz Grzegurzko). +# +# 1.10.1 Make convert program mandatory only if actually used (thanks to +# Julien Schueller). +# +# 1.10.0 Added NO_DEFAULT and DEFAULT_PS options. +# Fixed issue with cleaning files for LaTeX documents originating in +# a subdirectory. +# +# 1.9.6 Fixed problem with LATEX_SMALL_IMAGES. +# Strengthened check to make sure the output directory does not contain +# the source files. +# +# 1.9.5 Add support for image types not directly supported by either latex +# or pdflatex. (Thanks to Jorge Gerardo Pena Pastor for SVG support.) +# +# 1.9.4 Fix issues with filenames containing multiple periods. +# +# 1.9.3 Hide some variables that are now cached but should not show up in +# the ccmake list of variables. +# +# 1.9.2 Changed MACRO declarations to FUNCTION declarations. The better +# FUNCTION scoping will hopefully avoid some common but subtle bugs. +# This implicitly increases the minimum CMake version to 4.6 (although +# I honestly only test it with the latest 4.8 version). +# +# Since we are updating the minimum CMake version, I'm going to start +# using the builtin LIST commands that are now available. +# +# Favor using pdftops from the Poppler package to convert from pdf to +# eps. It does a much better job than ImageMagick or ghostscript. +# +# 1.9.1 Fixed typo that caused the LATEX_SMALL_IMAGES option to fail to +# activate. +# +# 1.9.0 Add support for the multibib package (thanks to Antonio LaTorre). +# +# 1.8.2 Fix corner case when an argument name was also a variable containing +# the text of an argument. In this case, the CMake IF was matching +# the argument text with the contents of the variable with the same +# argument name. +# +# 1.8.1 Fix problem where ps2pdf was not getting the appropriate arguments. +# +# 1.8.0 Add support for synctex. +# +# 1.7.7 Support calling xindy when making glossaries. +# +# Improved make clean support. +# +# 1.7.6 Add support for the nomencl package (thanks to Myles English). +# +# 1.7.5 Fix issue with bibfiles being copied two different ways, which causes +# Problems with dependencies (thanks to Edwin van Leeuwen). +# +# 1.7.4 Added the DEFAULT_SAFEPDF option (thanks to Raymond Wan). +# +# Added warnings when image directories are not found (and were +# probably not given relative to the source directory). +# +# 1.7.3 Fix some issues with interactions between makeglossaries and bibtex +# (thanks to Mark de Wever). +# +# 1.7.2 Use ps2pdf to convert eps to pdf to get around the problem with +# ImageMagick dropping the bounding box (thanks to Lukasz Lis). +# +# 1.7.1 Fixed some dependency issues. +# +# 1.7.0 Added DEPENDS options (thanks to Theodore Papadopoulo). +# +# 1.6.1 Ported the makeglossaries command to CMake and embedded the port +# into UseLATEX.cmake. +# +# 1.6.0 Allow the use of the makeglossaries command. Thanks to Oystein +# S. Haaland for the patch. +# +# 1.5.0 Allow any type of file in the INPUTS lists, not just tex file +# (suggested by Eric Noulard). As a consequence, the ability to +# specify tex files without the .tex extension is removed. The removed +# function is of dubious value anyway. +# +# When copying input files, skip over any file that exists in the +# binary directory but does not exist in the source directory with the +# assumption that these files were added by some other mechanism. I +# find this useful when creating large documents with multiple +# chapters that I want to build separately (for speed) as I work on +# them. I use the same boilerplate as the starting point for all +# and just copy it with different configurations. This was what the +# separate ADD_LATEX_DOCUMENT method was supposed to originally be for. +# Since its external use is pretty much deprecated, I removed that +# documentation. +# +# 1.4.1 Copy .sty files along with the other class and package files. +# +# 1.4.0 Added a MANGLE_TARGET_NAMES option that will mangle the target names. +# +# Fixed problem with copying bib files that became apparent with +# CMake 2.4. +# +# 1.3.0 Added a LATEX_OUTPUT_PATH variable that allows you or the user to +# specify where the built latex documents to go. This is especially +# handy if you want to do in-source builds. +# +# Removed the ADD_LATEX_IMAGES macro and absorbed the functionality +# into ADD_LATEX_DOCUMENT. The old interface was always kind of +# clunky anyway since you had to specify the image directory in both +# places. It also made supporting LATEX_OUTPUT_PATH problematic. +# +# Added support for jpeg files. +# +# 1.2.0 Changed the configuration options yet again. Removed the NO_CONFIGURE +# Replaced it with a CONFIGURE option that lists input files for which +# configure should be run. +# +# The pdf target no longer depends on the dvi target. This allows you +# to build latex documents that require pdflatex. Also added an option +# to make the pdf target the default one. +# +# 1.1.1 Added the NO_CONFIGURE option. The @ character can be used when +# specifying table column separators. If two or more are used, then +# will incorrectly substitute them. +# +# 1.1.0 Added ability include multiple bib files. Added ability to do copy +# sub-tex files for multipart tex files. +# +# 1.0.0 If both ps and pdf type images exist, just copy the one that +# matches the current render mode. Replaced a bunch of STRING +# commands with GET_FILENAME_COMPONENT commands that were made to do +# the desired function. +# +# 0.4.0 First version posted to CMake Wiki. +# + +if(__USE_LATEX_INCLUDED) + return() +endif() +set(__USE_LATEX_INCLUDED TRUE) + +############################################################################# +# Find the location of myself while originally executing. If you do this +# inside of a macro, it will recode where the macro was invoked. +############################################################################# +set(LATEX_USE_LATEX_LOCATION ${CMAKE_CURRENT_LIST_FILE} + CACHE INTERNAL "Location of UseLATEX.cmake file." FORCE + ) + +############################################################################# +# Generic helper functions +############################################################################# + +include(CMakeParseArguments) + +function(latex_list_contains var value) + set(input_list ${ARGN}) + list(FIND input_list "${value}" index) + if(index GREATER -1) + set(${var} TRUE PARENT_SCOPE) + else() + set(${var} PARENT_SCOPE) + endif() +endfunction(latex_list_contains) + +# Match the contents of a file to a regular expression. +function(latex_file_match variable filename regexp default) + # The FILE STRINGS command would be a bit better, but I'm not totally sure + # the match will always be to a whole line, and I don't want to break things. + file(READ ${filename} file_contents) + string(REGEX MATCHALL "${regexp}" + match_result ${file_contents} + ) + if(match_result) + set(${variable} "${match_result}" PARENT_SCOPE) + else() + set(${variable} "${default}" PARENT_SCOPE) + endif() +endfunction(latex_file_match) + +# A version of GET_FILENAME_COMPONENT that treats extensions after the last +# period rather than the first. To the best of my knowledge, all filenames +# typically used by LaTeX, including image files, have small extensions +# after the last dot. +function(latex_get_filename_component varname filename type) + set(result) + if("${type}" STREQUAL "NAME_WE") + get_filename_component(name ${filename} NAME) + string(REGEX REPLACE "\\.[^.]*\$" "" result "${name}") + elseif("${type}" STREQUAL "EXT") + get_filename_component(name ${filename} NAME) + string(REGEX MATCH "\\.[^.]*\$" result "${name}") + else() + get_filename_component(result ${filename} ${type}) + endif() + set(${varname} "${result}" PARENT_SCOPE) +endfunction(latex_get_filename_component) + +############################################################################# +# Functions that perform processing during a LaTeX build. +############################################################################# +function(latex_makeglossaries) + # This is really a bare bones port of the makeglossaries perl script into + # CMake scripting. + message("**************************** In makeglossaries") + if(NOT LATEX_TARGET) + message(SEND_ERROR "Need to define LATEX_TARGET") + endif() + + set(aux_file ${LATEX_TARGET}.aux) + + if(NOT EXISTS ${aux_file}) + message(SEND_ERROR "${aux_file} does not exist. Run latex on your target file.") + endif() + + latex_file_match(newglossary_lines ${aux_file} + "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" + "@newglossary{main}{glg}{gls}{glo}" + ) + + latex_file_match(istfile_line ${aux_file} + "@istfilename[ \t]*{([^}]*)}" + "@istfilename{${LATEX_TARGET}.ist}" + ) + string(REGEX REPLACE "@istfilename[ \t]*{([^}]*)}" "\\1" + istfile ${istfile_line} + ) + + string(REGEX MATCH ".*\\.xdy" use_xindy "${istfile}") + if(use_xindy) + message("*************** Using xindy") + if(NOT XINDY_COMPILER) + message(SEND_ERROR "Need to define XINDY_COMPILER") + endif() + else() + message("*************** Using makeindex") + if(NOT MAKEINDEX_COMPILER) + message(SEND_ERROR "Need to define MAKEINDEX_COMPILER") + endif() + endif() + + foreach(newglossary ${newglossary_lines}) + string(REGEX REPLACE + "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" + "\\1" glossary_name ${newglossary} + ) + string(REGEX REPLACE + "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" + "${LATEX_TARGET}.\\2" glossary_log ${newglossary} + ) + string(REGEX REPLACE + "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" + "${LATEX_TARGET}.\\3" glossary_out ${newglossary} + ) + string(REGEX REPLACE + "@newglossary[ \t]*{([^}]*)}{([^}]*)}{([^}]*)}{([^}]*)}" + "${LATEX_TARGET}.\\4" glossary_in ${newglossary} + ) + + if(use_xindy) + latex_file_match(xdylanguage_line ${aux_file} + "@xdylanguage[ \t]*{${glossary_name}}{([^}]*)}" + "@xdylanguage{${glossary_name}}{english}" + ) + string(REGEX REPLACE + "@xdylanguage[ \t]*{${glossary_name}}{([^}]*)}" + "\\1" + language + ${xdylanguage_line} + ) + # What crazy person makes a LaTeX index generator that uses different + # identifiers for language than babel (or at least does not support + # the old ones)? + if(${language} STREQUAL "frenchb") + set(language "french") + elseif(${language} MATCHES "^n?germanb?$") + set(language "german") + elseif(${language} STREQUAL "magyar") + set(language "hungarian") + elseif(${language} STREQUAL "lsorbian") + set(language "lower-sorbian") + elseif(${language} STREQUAL "norsk") + set(language "norwegian") + elseif(${language} STREQUAL "portuges") + set(language "portuguese") + elseif(${language} STREQUAL "russianb") + set(language "russian") + elseif(${language} STREQUAL "slovene") + set(language "slovenian") + elseif(${language} STREQUAL "ukraineb") + set(language "ukrainian") + elseif(${language} STREQUAL "usorbian") + set(language "upper-sorbian") + endif() + if(language) + set(language_flags "-L ${language}") + else() + set(language_flags "") + endif() + + latex_file_match(codepage_line ${aux_file} + "@gls@codepage[ \t]*{${glossary_name}}{([^}]*)}" + "@gls@codepage{${glossary_name}}{utf}" + ) + string(REGEX REPLACE + "@gls@codepage[ \t]*{${glossary_name}}{([^}]*)}" + "\\1" + codepage + ${codepage_line} + ) + if(codepage) + set(codepage_flags "-C ${codepage}") + else() + # Ideally, we would check that the language is compatible with the + # default codepage, but I'm hoping that distributions will be smart + # enough to specify their own codepage. I know, it's asking a lot. + set(codepage_flags "") + endif() + + message("${XINDY_COMPILER} ${MAKEGLOSSARIES_COMPILER_FLAGS} ${language_flags} ${codepage_flags} -I xindy -M ${glossary_name} -t ${glossary_log} -o ${glossary_out} ${glossary_in}" + ) + exec_program(${XINDY_COMPILER} + ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS} + ${language_flags} + ${codepage_flags} + -I xindy + -M ${glossary_name} + -t ${glossary_log} + -o ${glossary_out} + ${glossary_in} + OUTPUT_VARIABLE xindy_output + ) + message("${xindy_output}") + + # So, it is possible (perhaps common?) for aux files to specify a + # language and codepage that are incompatible with each other. Check + # for that condition, and if it happens run again with the default + # codepage. + if("${xindy_output}" MATCHES "^Cannot locate xindy module for language (.+) in codepage (.+)\\.$") + message("*************** Retrying xindy with default codepage.") + exec_program(${XINDY_COMPILER} + ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS} + ${language_flags} + -I xindy + -M ${glossary_name} + -t ${glossary_log} + -o ${glossary_out} + ${glossary_in} + ) + endif() + + else() + message("${MAKEINDEX_COMPILER} ${MAKEGLOSSARIES_COMPILER_FLAGS} -s ${istfile} -t ${glossary_log} -o ${glossary_out} ${glossary_in}") + exec_program(${MAKEINDEX_COMPILER} ARGS ${MAKEGLOSSARIES_COMPILER_FLAGS} + -s ${istfile} -t ${glossary_log} -o ${glossary_out} ${glossary_in} + ) + endif() + + endforeach(newglossary) +endfunction(latex_makeglossaries) + +function(latex_makenomenclature) + message("**************************** In makenomenclature") + if(NOT LATEX_TARGET) + message(SEND_ERROR "Need to define LATEX_TARGET") + endif() + + if(NOT MAKEINDEX_COMPILER) + message(SEND_ERROR "Need to define MAKEINDEX_COMPILER") + endif() + + set(nomencl_out ${LATEX_TARGET}.nls) + set(nomencl_in ${LATEX_TARGET}.nlo) + + exec_program(${MAKEINDEX_COMPILER} ARGS ${MAKENOMENCLATURE_COMPILER_FLAGS} + ${nomencl_in} -s "nomencl.ist" -o ${nomencl_out} + ) +endfunction(latex_makenomenclature) + +function(latex_correct_synctex) + message("**************************** In correct SyncTeX") + if(NOT LATEX_TARGET) + message(SEND_ERROR "Need to define LATEX_TARGET") + endif() + + if(NOT GZIP) + message(SEND_ERROR "Need to define GZIP") + endif() + + if(NOT LATEX_SOURCE_DIRECTORY) + message(SEND_ERROR "Need to define LATEX_SOURCE_DIRECTORY") + endif() + + if(NOT LATEX_BINARY_DIRECTORY) + message(SEND_ERROR "Need to define LATEX_BINARY_DIRECTORY") + endif() + + set(synctex_file ${LATEX_BINARY_DIRECTORY}/${LATEX_TARGET}.synctex) + set(synctex_file_gz ${synctex_file}.gz) + + if(EXISTS ${synctex_file_gz}) + + message("Making backup of synctex file.") + configure_file(${synctex_file_gz} ${synctex_file}.bak.gz COPYONLY) + + message("Uncompressing synctex file.") + exec_program(${GZIP} + ARGS --decompress ${synctex_file_gz} + ) + + message("Reading synctex file.") + file(READ ${synctex_file} synctex_data) + + message("Replacing relative with absolute paths.") + string(REGEX REPLACE + "(Input:[0-9]+:)([^/\n][^\n]*)" + "\\1${LATEX_SOURCE_DIRECTORY}/\\2" + synctex_data + "${synctex_data}" + ) + + message("Writing synctex file.") + file(WRITE ${synctex_file} "${synctex_data}") + + message("Compressing synctex file.") + exec_program(${GZIP} + ARGS ${synctex_file} + ) + + else() + + message(SEND_ERROR "File ${synctex_file_gz} not found. Perhaps synctex is not supported by your LaTeX compiler.") + + endif() + +endfunction(latex_correct_synctex) + +############################################################################# +# Helper functions for establishing LaTeX build. +############################################################################# + +function(latex_needit VAR NAME) + if(NOT ${VAR}) + message(SEND_ERROR "I need the ${NAME} command.") + endif() +endfunction(latex_needit) + +function(latex_wantit VAR NAME) + if(NOT ${VAR}) + message(STATUS "I could not find the ${NAME} command.") + endif() +endfunction(latex_wantit) + +function(latex_setup_variables) + set(LATEX_OUTPUT_PATH "${LATEX_OUTPUT_PATH}" + CACHE PATH "If non empty, specifies the location to place LaTeX output." + ) + + find_package(LATEX) + + find_program(XINDY_COMPILER + NAME xindy + PATHS ${MIKTEX_BINARY_PATH} /usr/bin + ) + + find_package(UnixCommands) + + find_program(PDFTOPS_CONVERTER + NAMES pdftops + DOC "The pdf to ps converter program from the Poppler package." + ) + + mark_as_advanced( + LATEX_COMPILER + PDFLATEX_COMPILER + BIBTEX_COMPILER + BIBER_COMPILER + MAKEINDEX_COMPILER + XINDY_COMPILER + DVIPS_CONVERTER + PS2PDF_CONVERTER + PDFTOPS_CONVERTER + LATEX2HTML_CONVERTER + ) + + latex_needit(LATEX_COMPILER latex) + latex_wantit(PDFLATEX_COMPILER pdflatex) + latex_needit(BIBTEX_COMPILER bibtex) + latex_wantit(BIBER_COMPILER biber) + latex_needit(MAKEINDEX_COMPILER makeindex) + latex_wantit(DVIPS_CONVERTER dvips) + latex_wantit(PS2PDF_CONVERTER ps2pdf) + latex_wantit(PDFTOPS_CONVERTER pdftops) + # MiKTeX calls latex2html htlatex + if(NOT ${LATEX2HTML_CONVERTER}) + find_program(HTLATEX_CONVERTER + NAMES htlatex + PATHS ${MIKTEX_BINARY_PATH} + /usr/bin + ) + mark_as_advanced(HTLATEX_CONVERTER) + if(HTLATEX_CONVERTER) + set(USING_HTLATEX TRUE CACHE INTERNAL "True when using MiKTeX htlatex instead of latex2html" FORCE) + set(LATEX2HTML_CONVERTER ${HTLATEX_CONVERTER} + CACHE FILEPATH "htlatex taking the place of latex2html" FORCE) + else() + set(USING_HTLATEX FALSE CACHE INTERNAL "True when using MiKTeX htlatex instead of latex2html" FORCE) + endif() + endif() + latex_wantit(LATEX2HTML_CONVERTER latex2html) + + set(LATEX_COMPILER_FLAGS "-interaction=nonstopmode" + CACHE STRING "Flags passed to latex.") + set(PDFLATEX_COMPILER_FLAGS ${LATEX_COMPILER_FLAGS} + CACHE STRING "Flags passed to pdflatex.") + set(LATEX_SYNCTEX_FLAGS "-synctex=1" + CACHE STRING "latex/pdflatex flags used to create synctex file.") + set(BIBTEX_COMPILER_FLAGS "" + CACHE STRING "Flags passed to bibtex.") + set(BIBER_COMPILER_FLAGS "" + CACHE STRING "Flags passed to biber.") + set(MAKEINDEX_COMPILER_FLAGS "" + CACHE STRING "Flags passed to makeindex.") + set(MAKEGLOSSARIES_COMPILER_FLAGS "" + CACHE STRING "Flags passed to makeglossaries.") + set(MAKENOMENCLATURE_COMPILER_FLAGS "" + CACHE STRING "Flags passed to makenomenclature.") + set(DVIPS_CONVERTER_FLAGS "-Ppdf -G0 -t letter" + CACHE STRING "Flags passed to dvips.") + set(PS2PDF_CONVERTER_FLAGS "-dMaxSubsetPct=100 -dCompatibilityLevel=1.3 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dMonoImageFilter=/FlateEncode" + CACHE STRING "Flags passed to ps2pdf.") + set(PDFTOPS_CONVERTER_FLAGS -r 600 + CACHE STRING "Flags passed to pdftops.") + set(LATEX2HTML_CONVERTER_FLAGS "" + CACHE STRING "Flags passed to latex2html.") + mark_as_advanced( + LATEX_COMPILER_FLAGS + PDFLATEX_COMPILER_FLAGS + LATEX_SYNCTEX_FLAGS + BIBTEX_COMPILER_FLAGS + BIBER_COMPILER_FLAGS + MAKEINDEX_COMPILER_FLAGS + MAKEGLOSSARIES_COMPILER_FLAGS + MAKENOMENCLATURE_COMPILER_FLAGS + DVIPS_CONVERTER_FLAGS + PS2PDF_CONVERTER_FLAGS + PDFTOPS_CONVERTER_FLAGS + LATEX2HTML_CONVERTER_FLAGS + ) + separate_arguments(LATEX_COMPILER_FLAGS) + separate_arguments(PDFLATEX_COMPILER_FLAGS) + separate_arguments(LATEX_SYNCTEX_FLAGS) + separate_arguments(BIBTEX_COMPILER_FLAGS) + separate_arguments(BIBER_COMPILER_FLAGS) + separate_arguments(MAKEINDEX_COMPILER_FLAGS) + separate_arguments(MAKEGLOSSARIES_COMPILER_FLAGS) + separate_arguments(MAKENOMENCLATURE_COMPILER_FLAGS) + separate_arguments(DVIPS_CONVERTER_FLAGS) + separate_arguments(PS2PDF_CONVERTER_FLAGS) + separate_arguments(PDFTOPS_CONVERTER_FLAGS) + separate_arguments(LATEX2HTML_CONVERTER_FLAGS) + + find_program(IMAGEMAGICK_CONVERT convert + DOC "The convert program that comes with ImageMagick (available at http://www.imagemagick.org)." + ) + mark_as_advanced(IMAGEMAGICK_CONVERT) + + if(DEFINED ENV{LATEX_DEFAULT_BUILD}) + set(default_build $ENV{LATEX_DEFAULT_BUILD}) + else() + set(default_build pdf) + endif() + + set(LATEX_DEFAULT_BUILD "${default_build}" CACHE STRING + "Choose the default type of LaTeX build. Valid options are pdf, dvi, ps, safepdf, html" + ) + set_property(CACHE LATEX_DEFAULT_BUILD + PROPERTY STRINGS pdf dvi ps safepdf html + ) + + option(LATEX_USE_SYNCTEX + "If on, have LaTeX generate a synctex file, which WYSIWYG editors can use to correlate output files like dvi and pdf with the lines of LaTeX source that generates them. In addition to adding the LATEX_SYNCTEX_FLAGS to the command line, this option also adds build commands that \"corrects\" the resulting synctex file to point to the original LaTeX files rather than those generated by UseLATEX.cmake." + OFF + ) + + option(LATEX_SMALL_IMAGES + "If on, the raster images will be converted to 1/6 the original size. This is because papers usually require 600 dpi images whereas most monitors only require at most 96 dpi. Thus, smaller images make smaller files for web distribution and can make it faster to read dvi files." + OFF) + if(LATEX_SMALL_IMAGES) + set(LATEX_RASTER_SCALE 16 PARENT_SCOPE) + set(LATEX_OPPOSITE_RASTER_SCALE 100 PARENT_SCOPE) + else() + set(LATEX_RASTER_SCALE 100 PARENT_SCOPE) + set(LATEX_OPPOSITE_RASTER_SCALE 16 PARENT_SCOPE) + endif() + + # Just holds extensions for known image types. They should all be lower case. + # For historical reasons, these are all declared in the global scope. + set(LATEX_DVI_VECTOR_IMAGE_EXTENSIONS .eps CACHE INTERNAL "") + set(LATEX_DVI_RASTER_IMAGE_EXTENSIONS CACHE INTERNAL "") + set(LATEX_DVI_IMAGE_EXTENSIONS + ${LATEX_DVI_VECTOR_IMAGE_EXTENSIONS} + ${LATEX_DVI_RASTER_IMAGE_EXTENSIONS} + CACHE INTERNAL "" + ) + + set(LATEX_PDF_VECTOR_IMAGE_EXTENSIONS .pdf CACHE INTERNAL "") + set(LATEX_PDF_RASTER_IMAGE_EXTENSIONS .jpeg .jpg .png CACHE INTERNAL "") + set(LATEX_PDF_IMAGE_EXTENSIONS + ${LATEX_PDF_VECTOR_IMAGE_EXTENSIONS} + ${LATEX_PDF_RASTER_IMAGE_EXTENSIONS} + CACHE INTERNAL "" + ) + + set(LATEX_OTHER_VECTOR_IMAGE_EXTENSIONS .ai .dot .svg CACHE INTERNAL "") + set(LATEX_OTHER_RASTER_IMAGE_EXTENSIONS + .bmp .bmp2 .bmp3 .dcm .dcx .ico .gif .pict .ppm .tif .tiff + CACHE INTERNAL "") + set(LATEX_OTHER_IMAGE_EXTENSIONS + ${LATEX_OTHER_VECTOR_IMAGE_EXTENSIONS} + ${LATEX_OTHER_RASTER_IMAGE_EXTENSIONS} + CACHE INTERNAL "" + ) + + set(LATEX_VECTOR_IMAGE_EXTENSIONS + ${LATEX_DVI_VECTOR_IMAGE_EXTENSIONS} + ${LATEX_PDF_VECTOR_IMAGE_EXTENSIONS} + ${LATEX_OTHER_VECTOR_IMAGE_EXTENSIONS} + CACHE INTERNAL "" + ) + set(LATEX_RASTER_IMAGE_EXTENSIONS + ${LATEX_DVI_RASTER_IMAGE_EXTENSIONS} + ${LATEX_PDF_RASTER_IMAGE_EXTENSIONS} + ${LATEX_OTHER_RASTER_IMAGE_EXTENSIONS} + CACHE INTERNAL "" + ) + set(LATEX_IMAGE_EXTENSIONS + ${LATEX_DVI_IMAGE_EXTENSIONS} + ${LATEX_PDF_IMAGE_EXTENSIONS} + ${LATEX_OTHER_IMAGE_EXTENSIONS} + CACHE INTERNAL "" + ) +endfunction(latex_setup_variables) + +function(latex_setup_targets) + if(NOT TARGET pdf) + add_custom_target(pdf) + endif() + if(NOT TARGET dvi) + add_custom_target(dvi) + endif() + if(NOT TARGET ps) + add_custom_target(ps) + endif() + if(NOT TARGET safepdf) + add_custom_target(safepdf) + endif() + if(NOT TARGET html) + add_custom_target(html) + endif() + if(NOT TARGET auxclean) + add_custom_target(auxclean) + endif() +endfunction(latex_setup_targets) + +function(latex_get_output_path var) + set(latex_output_path) + if(LATEX_OUTPUT_PATH) + get_filename_component( + LATEX_OUTPUT_PATH_FULL "${LATEX_OUTPUT_PATH}" ABSOLUTE + ) + if("${LATEX_OUTPUT_PATH_FULL}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + message(SEND_ERROR "You cannot set LATEX_OUTPUT_PATH to the same directory that contains LaTeX input files.") + else() + set(latex_output_path "${LATEX_OUTPUT_PATH_FULL}") + endif() + else() + if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + message(SEND_ERROR "LaTeX files must be built out of source or you must set LATEX_OUTPUT_PATH.") + else() + set(latex_output_path "${CMAKE_CURRENT_BINARY_DIR}") + endif() + endif() + set(${var} ${latex_output_path} PARENT_SCOPE) +endfunction(latex_get_output_path) + +function(latex_add_convert_command + output_path + input_path + output_extension + input_extension + flags + ) + set(require_imagemagick_convert TRUE) + set(convert_flags "") + if(${input_extension} STREQUAL ".eps" AND ${output_extension} STREQUAL ".pdf") + # ImageMagick has broken eps to pdf conversion + # use ps2pdf instead + if(PS2PDF_CONVERTER) + set(require_imagemagick_convert FALSE) + set(converter ${PS2PDF_CONVERTER}) + set(convert_flags -dEPSCrop ${PS2PDF_CONVERTER_FLAGS}) + else() + message(SEND_ERROR "Using postscript files with pdflatex requires ps2pdf for conversion.") + endif() + elseif(${input_extension} STREQUAL ".pdf" AND ${output_extension} STREQUAL ".eps") + # ImageMagick can also be sketchy on pdf to eps conversion. Not good with + # color spaces and tends to unnecessarily rasterize. + # use pdftops instead + if(PDFTOPS_CONVERTER) + set(require_imagemagick_convert FALSE) + set(converter ${PDFTOPS_CONVERTER}) + set(convert_flags -eps ${PDFTOPS_CONVERTER_FLAGS}) + else() + message(STATUS "Consider getting pdftops from Poppler to convert PDF images to EPS images.") + set(convert_flags ${flags}) + endif() + else() + set(convert_flags ${flags}) + endif() + + if(require_imagemagick_convert) + if(IMAGEMAGICK_CONVERT) + string(TOLOWER ${IMAGEMAGICK_CONVERT} IMAGEMAGICK_CONVERT_LOWERCASE) + if(${IMAGEMAGICK_CONVERT_LOWERCASE} MATCHES "system32[/\\\\]convert\\.exe") + message(SEND_ERROR "IMAGEMAGICK_CONVERT set to Window's convert.exe for changing file systems rather than ImageMagick's convert for changing image formats. Please make sure ImageMagick is installed (available at http://www.imagemagick.org) and its convert program is used for IMAGEMAGICK_CONVERT. (It is helpful if ImageMagick's path is before the Windows system paths.)") + else() + set(converter ${IMAGEMAGICK_CONVERT}) + endif() + else() + message(SEND_ERROR "Could not find convert program. Please download ImageMagick from http://www.imagemagick.org and install.") + endif() + endif() + + add_custom_command(OUTPUT ${output_path} + COMMAND ${converter} + ARGS ${convert_flags} ${input_path} ${output_path} + DEPENDS ${input_path} + ) +endfunction(latex_add_convert_command) + +# Makes custom commands to convert a file to a particular type. +function(latex_convert_image + output_files_var + input_file + output_extension + convert_flags + output_extensions + other_files + ) + set(output_file_list) + set(input_dir ${CMAKE_CURRENT_SOURCE_DIR}) + latex_get_output_path(output_dir) + + latex_get_filename_component(extension "${input_file}" EXT) + + # Check input filename for potential problems with LaTeX. + latex_get_filename_component(name "${input_file}" NAME_WE) + if(name MATCHES ".*\\..*") + string(REPLACE "." "-" suggested_name "${name}") + set(suggested_name "${suggested_name}${extension}") + message(WARNING "Some LaTeX distributions have problems with image file names with multiple extensions. Consider changing ${name}${extension} to something like ${suggested_name}.") + endif() + + string(REGEX REPLACE "\\.[^.]*\$" ${output_extension} output_file + "${input_file}") + + latex_list_contains(is_type ${extension} ${output_extensions}) + if(is_type) + if(convert_flags) + latex_add_convert_command(${output_dir}/${output_file} + ${input_dir}/${input_file} ${output_extension} ${extension} + "${convert_flags}") + set(output_file_list ${output_dir}/${output_file}) + else() + # As a shortcut, we can just copy the file. + add_custom_command(OUTPUT ${output_dir}/${input_file} + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${input_dir}/${input_file} ${output_dir}/${input_file} + DEPENDS ${input_dir}/${input_file} + ) + set(output_file_list ${output_dir}/${input_file}) + endif() + else() + set(do_convert TRUE) + # Check to see if there is another input file of the appropriate type. + foreach(valid_extension ${output_extensions}) + string(REGEX REPLACE "\\.[^.]*\$" ${output_extension} try_file + "${input_file}") + latex_list_contains(has_native_file "${try_file}" ${other_files}) + if(has_native_file) + set(do_convert FALSE) + endif() + endforeach(valid_extension) + + # If we still need to convert, do it. + if(do_convert) + latex_add_convert_command(${output_dir}/${output_file} + ${input_dir}/${input_file} ${output_extension} ${extension} + "${convert_flags}") + set(output_file_list ${output_dir}/${output_file}) + endif() + endif() + + set(${output_files_var} ${output_file_list} PARENT_SCOPE) +endfunction(latex_convert_image) + +# Adds custom commands to process the given files for dvi and pdf builds. +# Adds the output files to the given variables (does not replace). +function(latex_process_images dvi_outputs_var pdf_outputs_var) + latex_get_output_path(output_dir) + set(dvi_outputs) + set(pdf_outputs) + foreach(file ${ARGN}) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + latex_get_filename_component(extension "${file}" EXT) + set(convert_flags) + + # Check to see if we need to downsample the image. + latex_list_contains(is_raster "${extension}" + ${LATEX_RASTER_IMAGE_EXTENSIONS}) + if(LATEX_SMALL_IMAGES) + if(is_raster) + set(convert_flags -resize ${LATEX_RASTER_SCALE}%) + endif() + endif() + + # Make sure the output directory exists. + latex_get_filename_component(path "${output_dir}/${file}" PATH) + make_directory("${path}") + + # Do conversions for dvi. + latex_convert_image(output_files "${file}" .eps "${convert_flags}" + "${LATEX_DVI_IMAGE_EXTENSIONS}" "${ARGN}") + list(APPEND dvi_outputs ${output_files}) + + # Do conversions for pdf. + if(is_raster) + latex_convert_image(output_files "${file}" .png "${convert_flags}" + "${LATEX_PDF_IMAGE_EXTENSIONS}" "${ARGN}") + list(APPEND pdf_outputs ${output_files}) + else() + latex_convert_image(output_files "${file}" .pdf "${convert_flags}" + "${LATEX_PDF_IMAGE_EXTENSIONS}" "${ARGN}") + list(APPEND pdf_outputs ${output_files}) + endif() + else() + message(WARNING "Could not find file ${CMAKE_CURRENT_SOURCE_DIR}/${file}. Are you sure you gave relative paths to IMAGES?") + endif() + endforeach(file) + + set(${dvi_outputs_var} ${dvi_outputs} PARENT_SCOPE) + set(${pdf_outputs_var} ${pdf_outputs} PARENT_SCOPE) +endfunction(latex_process_images) + +function(latex_copy_globbed_files pattern dest) + file(GLOB file_list ${pattern}) + foreach(in_file ${file_list}) + latex_get_filename_component(out_file ${in_file} NAME) + configure_file(${in_file} ${dest}/${out_file} COPYONLY) + endforeach(in_file) +endfunction(latex_copy_globbed_files) + +function(latex_copy_input_file file) + latex_get_output_path(output_dir) + + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + latex_get_filename_component(path ${file} PATH) + file(MAKE_DIRECTORY ${output_dir}/${path}) + + latex_list_contains(use_config ${file} ${LATEX_CONFIGURE}) + if(use_config) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${file} + ${output_dir}/${file} + @ONLY + ) + add_custom_command(OUTPUT ${output_dir}/${file} + COMMAND ${CMAKE_COMMAND} + ARGS ${CMAKE_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} + ) + else() + add_custom_command(OUTPUT ${output_dir}/${file} + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${output_dir}/${file} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} + ) + endif() + else() + if(EXISTS ${output_dir}/${file}) + # Special case: output exists but input does not. Assume that it was + # created elsewhere and skip the input file copy. + else() + message("Could not find input file ${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif() + endif() +endfunction(latex_copy_input_file) + +############################################################################# +# Commands provided by the UseLATEX.cmake "package" +############################################################################# + +function(latex_usage command message) + message(SEND_ERROR + "${message}\n Usage: ${command}(\n [BIBFILES ...]\n [INPUTS ...]\n [IMAGE_DIRS ...]\n [IMAGES \n [CONFIGURE ...]\n [DEPENDS ...]\n [MULTIBIB_NEWCITES] \n [USE_BIBLATEX] [USE_INDEX] [USE_GLOSSARY] [USE_NOMENCL]\n [FORCE_PDF] [FORCE_DVI] [FORCE_HTML]\n [TARGET_NAME] \n [EXCLUDE_FROM_ALL]\n [EXCLUDE_FROM_DEFAULTS])" + ) +endfunction(latex_usage command message) + +# Parses arguments to add_latex_document and ADD_LATEX_TARGETS and sets the +# variables LATEX_TARGET, LATEX_IMAGE_DIR, LATEX_BIBFILES, LATEX_DEPENDS, and +# LATEX_INPUTS. +function(parse_add_latex_arguments command latex_main_input) + set(options + USE_BIBLATEX + USE_INDEX + USE_GLOSSARY + USE_NOMENCL + FORCE_PDF + FORCE_DVI + FORCE_HTML + EXCLUDE_FROM_ALL + EXCLUDE_FROM_DEFAULTS + # Deprecated options + USE_GLOSSARIES + DEFAULT_PDF + DEFAULT_SAFEPDF + DEFAULT_PS + NO_DEFAULT + MANGLE_TARGET_NAMES + ) + set(oneValueArgs + TARGET_NAME + ) + set(multiValueArgs + BIBFILES + MULTIBIB_NEWCITES + INPUTS + IMAGE_DIRS + IMAGES + CONFIGURE + DEPENDS + INDEX_NAMES + ) + cmake_parse_arguments( + LATEX "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Handle invalid and deprecated arguments + if(LATEX_UNPARSED_ARGUMENTS) + latex_usage(${command} "Invalid or deprecated arguments: ${LATEX_UNPARSED_ARGUMENTS}") + endif() + if(LATEX_USE_GLOSSARIES) + latex_usage(${command} "USE_GLOSSARIES option removed in version 1.6.1. Use USE_GLOSSARY instead.") + endif() + if(LATEX_DEFAULT_PDF) + latex_usage(${command} "DEFAULT_PDF option removed in version 2.0. Use FORCE_PDF option or LATEX_DEFAULT_BUILD CMake variable instead.") + endif() + if(LATEX_DEFAULT_SAFEPDF) + latex_usage(${command} "DEFAULT_SAFEPDF option removed in version 2.0. Use LATEX_DEFAULT_BUILD CMake variable instead.") + endif() + if(LATEX_DEFAULT_DVI) + latex_usage(${command} "DEFAULT_DVI option removed in version 2.0. Use FORCE_DVI option or LATEX_DEFAULT_BUILD CMake variable instead.") + endif() + if(LATEX_NO_DEFAULT) + latex_usage(${command} "NO_DEFAULT option removed in version 2.0. Use EXCLUDE_FROM_ALL instead.") + endif() + if(LATEX_MANGLE_TARGET_NAMES) + latex_usage(${command} "MANGLE_TARGET_NAMES option removed in version 2.0. All LaTeX targets use mangled names now.") + endif() + + # Capture the first argument, which is the main LaTeX input. + latex_get_filename_component(latex_target ${latex_main_input} NAME_WE) + set(LATEX_MAIN_INPUT ${latex_main_input} PARENT_SCOPE) + set(LATEX_TARGET ${latex_target} PARENT_SCOPE) + + # Propagate the result variables to the caller + foreach(arg_name ${options} ${oneValueArgs} ${multiValueArgs}) + set(var_name LATEX_${arg_name}) + set(${var_name} ${${var_name}} PARENT_SCOPE) + endforeach(arg_name) +endfunction(parse_add_latex_arguments) + +function(add_latex_targets_internal) + if(LATEX_USE_SYNCTEX) + set(synctex_flags ${LATEX_SYNCTEX_FLAGS}) + else() + set(synctex_flags) + endif() + + # The commands to run LaTeX. They are repeated multiple times. + set(latex_build_command + ${LATEX_COMPILER} ${LATEX_COMPILER_FLAGS} ${synctex_flags} ${LATEX_MAIN_INPUT} + ) + set(pdflatex_build_command + ${PDFLATEX_COMPILER} ${PDFLATEX_COMPILER_FLAGS} ${synctex_flags} ${LATEX_MAIN_INPUT} + ) + + if(NOT LATEX_TARGET_NAME) + set(LATEX_TARGET_NAME ${LATEX_TARGET}) + endif() + + # Set up target names. + set(dvi_target ${LATEX_TARGET_NAME}_dvi) + set(pdf_target ${LATEX_TARGET_NAME}_pdf) + set(ps_target ${LATEX_TARGET_NAME}_ps) + set(safepdf_target ${LATEX_TARGET_NAME}_safepdf) + set(html_target ${LATEX_TARGET_NAME}_html) + set(auxclean_target ${LATEX_TARGET_NAME}_auxclean) + + # Probably not all of these will be generated, but they could be. + # Note that the aux file is added later. + set(auxiliary_clean_files + ${output_dir}/${LATEX_TARGET}.aux + ${output_dir}/${LATEX_TARGET}.bbl + ${output_dir}/${LATEX_TARGET}.blg + ${output_dir}/${LATEX_TARGET}-blx.bib + ${output_dir}/${LATEX_TARGET}.glg + ${output_dir}/${LATEX_TARGET}.glo + ${output_dir}/${LATEX_TARGET}.gls + ${output_dir}/${LATEX_TARGET}.idx + ${output_dir}/${LATEX_TARGET}.ilg + ${output_dir}/${LATEX_TARGET}.ind + ${output_dir}/${LATEX_TARGET}.ist + ${output_dir}/${LATEX_TARGET}.log + ${output_dir}/${LATEX_TARGET}.out + ${output_dir}/${LATEX_TARGET}.toc + ${output_dir}/${LATEX_TARGET}.lof + ${output_dir}/${LATEX_TARGET}.xdy + ${output_dir}/${LATEX_TARGET}.synctex.gz + ${output_dir}/${LATEX_TARGET}.synctex.bak.gz + ${output_dir}/${LATEX_TARGET}.dvi + ${output_dir}/${LATEX_TARGET}.ps + ${output_dir}/${LATEX_TARGET}.pdf + ) + + set(image_list ${LATEX_IMAGES}) + + # For each directory in LATEX_IMAGE_DIRS, glob all the image files and + # place them in LATEX_IMAGES. + foreach(dir ${LATEX_IMAGE_DIRS}) + if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}) + message(WARNING "Image directory ${CMAKE_CURRENT_SOURCE_DIR}/${dir} does not exist. Are you sure you gave relative directories to IMAGE_DIRS?") + endif() + foreach(extension ${LATEX_IMAGE_EXTENSIONS}) + file(GLOB files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*${extension}) + foreach(file ${files}) + latex_get_filename_component(filename ${file} NAME) + list(APPEND image_list ${dir}/${filename}) + endforeach(file) + endforeach(extension) + endforeach(dir) + + latex_process_images(dvi_images pdf_images ${image_list}) + + set(make_dvi_command + ${CMAKE_COMMAND} -E chdir ${output_dir} + ${latex_build_command}) + set(make_pdf_command + ${CMAKE_COMMAND} -E chdir ${output_dir} + ${pdflatex_build_command} + ) + + set(make_dvi_depends ${LATEX_DEPENDS} ${dvi_images}) + set(make_pdf_depends ${LATEX_DEPENDS} ${pdf_images}) + foreach(input ${LATEX_MAIN_INPUT} ${LATEX_INPUTS}) + list(APPEND make_dvi_depends ${output_dir}/${input}) + list(APPEND make_pdf_depends ${output_dir}/${input}) + if(${input} MATCHES "\\.tex$") + # Dependent .tex files might have their own .aux files created. Make + # sure these get cleaned as well. This might replicate the cleaning + # of the main .aux file, which is OK. + string(REGEX REPLACE "\\.tex$" "" input_we ${input}) + list(APPEND auxiliary_clean_files + ${output_dir}/${input_we}.aux + ${output_dir}/${input}.aux + ) + endif() + endforeach(input) + + if(LATEX_USE_GLOSSARY) + foreach(dummy 0 1) # Repeat these commands twice. + set(make_dvi_command ${make_dvi_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${CMAKE_COMMAND} + -D LATEX_BUILD_COMMAND=makeglossaries + -D LATEX_TARGET=${LATEX_TARGET} + -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER} + -D XINDY_COMPILER=${XINDY_COMPILER} + -D MAKEGLOSSARIES_COMPILER_FLAGS=${MAKEGLOSSARIES_COMPILER_FLAGS} + -P ${LATEX_USE_LATEX_LOCATION} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${latex_build_command} + ) + set(make_pdf_command ${make_pdf_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${CMAKE_COMMAND} + -D LATEX_BUILD_COMMAND=makeglossaries + -D LATEX_TARGET=${LATEX_TARGET} + -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER} + -D XINDY_COMPILER=${XINDY_COMPILER} + -D MAKEGLOSSARIES_COMPILER_FLAGS=${MAKEGLOSSARIES_COMPILER_FLAGS} + -P ${LATEX_USE_LATEX_LOCATION} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${pdflatex_build_command} + ) + endforeach(dummy) + endif() + + if(LATEX_USE_NOMENCL) + foreach(dummy 0 1) # Repeat these commands twice. + set(make_dvi_command ${make_dvi_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${CMAKE_COMMAND} + -D LATEX_BUILD_COMMAND=makenomenclature + -D LATEX_TARGET=${LATEX_TARGET} + -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER} + -D MAKENOMENCLATURE_COMPILER_FLAGS=${MAKENOMENCLATURE_COMPILER_FLAGS} + -P ${LATEX_USE_LATEX_LOCATION} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${latex_build_command} + ) + set(make_pdf_command ${make_pdf_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${CMAKE_COMMAND} + -D LATEX_BUILD_COMMAND=makenomenclature + -D LATEX_TARGET=${LATEX_TARGET} + -D MAKEINDEX_COMPILER=${MAKEINDEX_COMPILER} + -D MAKENOMENCLATURE_COMPILER_FLAGS=${MAKENOMENCLATURE_COMPILER_FLAGS} + -P ${LATEX_USE_LATEX_LOCATION} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${pdflatex_build_command} + ) + endforeach(dummy) + endif() + + if(LATEX_BIBFILES) + if(LATEX_USE_BIBLATEX) + if(NOT BIBER_COMPILER) + message(SEND_ERROR "I need the biber command.") + endif() + set(bib_compiler ${BIBER_COMPILER}) + set(bib_compiler_flags ${BIBER_COMPILER_FLAGS}) + else() + set(bib_compiler ${BIBTEX_COMPILER}) + set(bib_compiler_flags ${BIBTEX_COMPILER_FLAGS}) + endif() + if(LATEX_MULTIBIB_NEWCITES) + foreach (multibib_auxfile ${LATEX_MULTIBIB_NEWCITES}) + latex_get_filename_component(multibib_target ${multibib_auxfile} NAME_WE) + set(make_dvi_command ${make_dvi_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${bib_compiler} ${bib_compiler_flags} ${multibib_target}) + set(make_pdf_command ${make_pdf_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${bib_compiler} ${bib_compiler_flags} ${multibib_target}) + set(auxiliary_clean_files ${auxiliary_clean_files} + ${output_dir}/${multibib_target}.aux) + endforeach (multibib_auxfile ${LATEX_MULTIBIB_NEWCITES}) + else() + set(make_dvi_command ${make_dvi_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${bib_compiler} ${bib_compiler_flags} ${LATEX_TARGET}) + set(make_pdf_command ${make_pdf_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${bib_compiler} ${bib_compiler_flags} ${LATEX_TARGET}) + endif() + + foreach (bibfile ${LATEX_BIBFILES}) + list(APPEND make_dvi_depends ${output_dir}/${bibfile}) + list(APPEND make_pdf_depends ${output_dir}/${bibfile}) + endforeach (bibfile ${LATEX_BIBFILES}) + else() + if(LATEX_MULTIBIB_NEWCITES) + message(WARNING "MULTIBIB_NEWCITES has no effect without BIBFILES option.") + endif() + endif() + + if(LATEX_USE_INDEX) + if(LATEX_INDEX_NAMES) + set(INDEX_NAMES ${LATEX_INDEX_NAMES}) + else() + set(INDEX_NAMES ${LATEX_TARGET}) + endif() + foreach(idx_name ${INDEX_NAMES}) + set(make_dvi_command ${make_dvi_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${latex_build_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${MAKEINDEX_COMPILER} ${MAKEINDEX_COMPILER_FLAGS} ${idx_name}.idx) + set(make_pdf_command ${make_pdf_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${pdflatex_build_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${MAKEINDEX_COMPILER} ${MAKEINDEX_COMPILER_FLAGS} ${idx_name}.idx) + set(auxiliary_clean_files ${auxiliary_clean_files} + ${output_dir}/${idx_name}.idx + ${output_dir}/${idx_name}.ilg + ${output_dir}/${idx_name}.ind) + endforeach() + else() + if(LATEX_INDEX_NAMES) + message(WARNING "INDEX_NAMES has no effect without USE_INDEX option.") + endif() + endif() + + set(make_dvi_command ${make_dvi_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${latex_build_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${latex_build_command}) + set(make_pdf_command ${make_pdf_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${pdflatex_build_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${pdflatex_build_command}) + + # Need to run one more time to remove biblatex' warning + # about page breaks that have changed. + if(LATEX_USE_BIBLATEX) + set(make_dvi_command ${make_dvi_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${latex_build_command}) + set(make_pdf_command ${make_pdf_command} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${pdflatex_build_command}) + endif() + + if(LATEX_USE_SYNCTEX) + if(NOT GZIP) + message(SEND_ERROR "UseLATEX.cmake: USE_SYNTEX option requires gzip program. Set GZIP variable.") + endif() + set(make_dvi_command ${make_dvi_command} + COMMAND ${CMAKE_COMMAND} + -D LATEX_BUILD_COMMAND=correct_synctex + -D LATEX_TARGET=${LATEX_TARGET} + -D GZIP=${GZIP} + -D "LATEX_SOURCE_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}" + -D "LATEX_BINARY_DIRECTORY=${output_dir}" + -P ${LATEX_USE_LATEX_LOCATION} + ) + set(make_pdf_command ${make_pdf_command} + COMMAND ${CMAKE_COMMAND} + -D LATEX_BUILD_COMMAND=correct_synctex + -D LATEX_TARGET=${LATEX_TARGET} + -D GZIP=${GZIP} + -D "LATEX_SOURCE_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}" + -D "LATEX_BINARY_DIRECTORY=${output_dir}" + -P ${LATEX_USE_LATEX_LOCATION} + ) + endif() + + # Capture the default build. + string(TOLOWER "${LATEX_DEFAULT_BUILD}" default_build) + + if((NOT LATEX_FORCE_PDF) AND (NOT LATEX_FORCE_DVI) AND (NOT LATEX_FORCE_HTML)) + set(no_force TRUE) + endif() + + # Add commands and targets for building pdf outputs (with pdflatex). + if(LATEX_FORCE_PDF OR no_force) + if(LATEX_FORCE_PDF) + set(default_build pdf) + endif() + + if(PDFLATEX_COMPILER) + add_custom_command(OUTPUT ${output_dir}/${LATEX_TARGET}.pdf + COMMAND ${make_pdf_command} + DEPENDS ${make_pdf_depends} + ) + add_custom_target(${pdf_target} DEPENDS ${output_dir}/${LATEX_TARGET}.pdf) + if(NOT LATEX_EXCLUDE_FROM_DEFAULTS) + add_dependencies(pdf ${pdf_target}) + endif() + endif() + endif() + + # Add commands and targets for building dvi outputs. + if(LATEX_FORCE_DVI OR LATEX_FORCE_HTML OR no_force) + if(LATEX_FORCE_DVI) + if((NOT default_build STREQUAL dvi) AND + (NOT default_build STREQUAL ps) AND + (NOT default_build STREQUAL safepdf)) + set(default_build dvi) + endif() + endif() + + add_custom_command(OUTPUT ${output_dir}/${LATEX_TARGET}.dvi + COMMAND ${make_dvi_command} + DEPENDS ${make_dvi_depends} + ) + add_custom_target(${dvi_target} DEPENDS ${output_dir}/${LATEX_TARGET}.dvi) + if(NOT LATEX_EXCLUDE_FROM_DEFAULTS) + add_dependencies(dvi ${dvi_target}) + endif() + + if(DVIPS_CONVERTER) + add_custom_command(OUTPUT ${output_dir}/${LATEX_TARGET}.ps + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${DVIPS_CONVERTER} ${DVIPS_CONVERTER_FLAGS} -o ${LATEX_TARGET}.ps ${LATEX_TARGET}.dvi + DEPENDS ${output_dir}/${LATEX_TARGET}.dvi) + add_custom_target(${ps_target} DEPENDS ${output_dir}/${LATEX_TARGET}.ps) + if(NOT LATEX_EXCLUDE_FROM_DEFAULTS) + add_dependencies(ps ${ps_target}) + endif() + if(PS2PDF_CONVERTER) + # Since both the pdf and safepdf targets have the same output, we + # cannot properly do the dependencies for both. When selecting safepdf, + # simply force a recompile every time. + add_custom_target(${safepdf_target} + ${CMAKE_COMMAND} -E chdir ${output_dir} + ${PS2PDF_CONVERTER} ${PS2PDF_CONVERTER_FLAGS} ${LATEX_TARGET}.ps ${LATEX_TARGET}.pdf + DEPENDS ${ps_target} + ) + if(NOT LATEX_EXCLUDE_FROM_DEFAULTS) + add_dependencies(safepdf ${safepdf_target}) + endif() + endif() + endif() + endif() + + if(LATEX_FORCE_HTML OR no_force) + if (LATEX_FORCE_HTML) + set(default_build html) + endif() + + if(LATEX2HTML_CONVERTER) + if(USING_HTLATEX) + # htlatex places the output in a different location + set(HTML_OUTPUT "${output_dir}/${LATEX_TARGET}.html") + else() + set(HTML_OUTPUT "${output_dir}/${LATEX_TARGET}/${LATEX_TARGET}.html") + endif() + add_custom_command(OUTPUT ${HTML_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E chdir ${output_dir} + ${LATEX2HTML_CONVERTER} ${LATEX2HTML_CONVERTER_FLAGS} ${LATEX_MAIN_INPUT} + DEPENDS ${output_dir}/${LATEX_TARGET}.tex + ) + add_custom_target(${html_target} DEPENDS ${HTML_OUTPUT} ${dvi_target}) + if(NOT LATEX_EXCLUDE_FROM_DEFAULTS) + add_dependencies(html ${html_target}) + endif() + endif() + endif() + + # Set default targets. + if("${default_build}" STREQUAL "pdf") + add_custom_target(${LATEX_TARGET_NAME} DEPENDS ${pdf_target}) + elseif("${default_build}" STREQUAL "dvi") + add_custom_target(${LATEX_TARGET_NAME} DEPENDS ${dvi_target}) + elseif("${default_build}" STREQUAL "ps") + add_custom_target(${LATEX_TARGET_NAME} DEPENDS ${ps_target}) + elseif("${default_build}" STREQUAL "safepdf") + add_custom_target(${LATEX_TARGET_NAME} DEPENDS ${safepdf_target}) + elseif("${default_build}" STREQUAL "html") + add_custom_target(${LATEX_TARGET_NAME} DEPENDS ${html_target}) + else() + message(SEND_ERROR "LATEX_DEFAULT_BUILD set to an invalid value. See the documentation for that variable.") + endif() + + if(NOT LATEX_EXCLUDE_FROM_ALL) + add_custom_target(_${LATEX_TARGET_NAME} ALL DEPENDS ${LATEX_TARGET_NAME}) + endif() + + set_directory_properties(. + ADDITIONAL_MAKE_CLEAN_FILES "${auxiliary_clean_files}" + ) + + add_custom_target(${auxclean_target} + COMMENT "Cleaning auxiliary LaTeX files." + COMMAND ${CMAKE_COMMAND} -E remove ${auxiliary_clean_files} + ) + add_dependencies(auxclean ${auxclean_target}) +endfunction(add_latex_targets_internal) + +function(add_latex_targets latex_main_input) + latex_get_output_path(output_dir) + parse_add_latex_arguments(ADD_LATEX_TARGETS ${latex_main_input} ${ARGN}) + + add_latex_targets_internal() +endfunction(add_latex_targets) + +function(add_latex_document latex_main_input) + latex_get_output_path(output_dir) + if(output_dir) + parse_add_latex_arguments(add_latex_document ${latex_main_input} ${ARGN}) + + latex_copy_input_file(${LATEX_MAIN_INPUT}) + + foreach (bib_file ${LATEX_BIBFILES}) + latex_copy_input_file(${bib_file}) + endforeach (bib_file) + + foreach (input ${LATEX_INPUTS}) + latex_copy_input_file(${input}) + endforeach(input) + + latex_copy_globbed_files(${CMAKE_CURRENT_SOURCE_DIR}/*.cls ${output_dir}) + latex_copy_globbed_files(${CMAKE_CURRENT_SOURCE_DIR}/*.bst ${output_dir}) + latex_copy_globbed_files(${CMAKE_CURRENT_SOURCE_DIR}/*.clo ${output_dir}) + latex_copy_globbed_files(${CMAKE_CURRENT_SOURCE_DIR}/*.sty ${output_dir}) + latex_copy_globbed_files(${CMAKE_CURRENT_SOURCE_DIR}/*.ist ${output_dir}) + latex_copy_globbed_files(${CMAKE_CURRENT_SOURCE_DIR}/*.fd ${output_dir}) + + add_latex_targets_internal() + endif() +endfunction(add_latex_document) + +############################################################################# +# Actually do stuff +############################################################################# + +if(LATEX_BUILD_COMMAND) + set(command_handled) + + if("${LATEX_BUILD_COMMAND}" STREQUAL makeglossaries) + latex_makeglossaries() + set(command_handled TRUE) + endif() + + if("${LATEX_BUILD_COMMAND}" STREQUAL makenomenclature) + latex_makenomenclature() + set(command_handled TRUE) + endif() + + if("${LATEX_BUILD_COMMAND}" STREQUAL correct_synctex) + latex_correct_synctex() + set(command_handled TRUE) + endif() + + if(NOT command_handled) + message(SEND_ERROR "Unknown command: ${LATEX_BUILD_COMMAND}") + endif() + +else() + # Must be part of the actual configure (included from CMakeLists.txt). + latex_setup_variables() + latex_setup_targets() +endif() diff -Nru dune-common-2.2.1/cmake/pkg/dune-common-config.cmake.in dune-common-2.5.2~20170808ga5c076ca/cmake/pkg/dune-common-config.cmake.in --- dune-common-2.2.1/cmake/pkg/dune-common-config.cmake.in 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/pkg/dune-common-config.cmake.in 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,22 @@ +if(NOT @DUNE_MOD_NAME@_FOUND) +@PACKAGE_INIT@ + +#import the target +get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) +include("${_dir}/@DUNE_MOD_NAME@-targets.cmake") + +#report other information +set_and_check(@DUNE_MOD_NAME@_PREFIX "${PACKAGE_PREFIX_DIR}") +set_and_check(@DUNE_MOD_NAME@_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set(@DUNE_MOD_NAME@_CXX_FLAGS "@CMAKE_CXX_FLAGS@") +set(@DUNE_MOD_NAME@_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@") +set(@DUNE_MOD_NAME@_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@") +set(@DUNE_MOD_NAME@_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@") +set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@") +set(@DUNE_MOD_NAME@_LIBRARIES "dunecommon") +set_and_check(@DUNE_MOD_NAME@_SCRIPT_DIR "@PACKAGE_SCRIPT_DIR@") +set_and_check(DOXYSTYLE_FILE "@PACKAGE_DOXYSTYLE_DIR@/Doxystyle") +set(@DUNE_MOD_NAME@_DEPENDS "@DUNE_DEPENDS@") +set(@DUNE_MOD_NAME@_SUGGESTS "@DUNE_SUGGESTS@") +set_and_check(@DUNE_MOD_NAME@_MODULE_PATH "@PACKAGE_DUNE_INSTALL_MODULEDIR@") +endif(NOT @DUNE_MOD_NAME@_FOUND) diff -Nru dune-common-2.2.1/cmake/scripts/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/CMakeLists.txt --- dune-common-2.2.1/cmake/scripts/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,14 @@ +install(FILES + conf.py.in + CreateDoxyFile.cmake + envdetect.py + extract_cmake_data.py + FinalizeHeadercheck.cmake + index.rst.in + InstallFile.cmake + main77.cc.in + pyversion.py + run-in-dune-env.sh.in + RunDoxygen.cmake + sphinx_cmake_dune.py + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dune/cmake/scripts) diff -Nru dune-common-2.2.1/cmake/scripts/conf.py.in dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/conf.py.in --- dune-common-2.2.1/cmake/scripts/conf.py.in 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/conf.py.in 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,5 @@ +import sys + +sys.path.append('@DUNE_SPHINX_EXT_PATH@') + +extensions = ['sphinx_cmake_dune'] diff -Nru dune-common-2.2.1/cmake/scripts/CreateDoxyFile.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/CreateDoxyFile.cmake --- dune-common-2.2.1/cmake/scripts/CreateDoxyFile.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/CreateDoxyFile.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,15 @@ +# For now we just support appending Doxyfile and Doxylocal +file(READ ${DOXYSTYLE} file_contents) +file(WRITE Doxyfile.in ${file_contents}) +if(DOXYLOCAL) + file(READ ${DOXYLOCAL} file_contents) +endif() +file(APPEND Doxyfile.in ${file_contents}) + +# configure_file does not work as it insists an existing input file, which in our +# needs to be generated first. +# Therefore we read the Doxyfile.in and replace the variables using string(CONFIGURE) +# and then write the file. +file(READ Doxyfile.in file_contents) +string(CONFIGURE ${file_contents} output) +file(WRITE Doxyfile ${output}) diff -Nru dune-common-2.2.1/cmake/scripts/envdetect.py dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/envdetect.py --- dune-common-2.2.1/cmake/scripts/envdetect.py 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/envdetect.py 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,22 @@ +# A python script that determines whether the current interpreter is +# running inside a virtual environment. For discussion of the implemented +# methods, see http://stackoverflow.com/questions/1871549 +# +# Meant to be run from DunePythonCommonMacros.cmake. For that reason, it +# exits with either 1 or 0, where 1 indicates that the interpreter +# runs inside a virtualenv +# + +import sys + +# If sys.real_prefix exists, this is a virtualenv set up with the virtualenv package +real_prefix = hasattr(sys, 'real_prefix') +if real_prefix: + sys.exit(1) + +# If a virtualenv is set up with pyvenv, we check for equality of base_prefix and prefix +if hasattr(sys, 'base_prefix'): + sys.exit(sys.prefix != sys.base_prefix) + +# If none of the above conditions triggered, this is probably no virtualenv interpreter +sys.exit(0) \ No newline at end of file diff -Nru dune-common-2.2.1/cmake/scripts/extract_cmake_data.py dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/extract_cmake_data.py --- dune-common-2.2.1/cmake/scripts/extract_cmake_data.py 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/extract_cmake_data.py 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,104 @@ +#!/usr/bin/env python + +""" This script will parse a cmake module and extract some + rst documentation from it. This might not be as elegant as + writing a Sphinx domain or using a custom extension with + cmake related directives, but it provides a straightforward + working way. + + This is used by dune-common to generate the build system documentation. + Users do not want to use this!!! +""" +from __future__ import print_function + +import argparse +import os +import re + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument('-b', '--builddir', help='The directory where to place the produced output', required=True) + parser.add_argument('-m', '--module', help='The module to parse', required=True) + return vars(parser.parse_args()) + +def write_line(f, line): + if len(line) > 2: + f.write(line[2:]) + else: + f.write('\n') + +def read_module(args=get_args()): + modname = os.path.splitext(os.path.basename(args['module']))[0] + modpath = os.path.join(args['builddir'], 'modules') + if not os.path.exists(modpath): + os.makedirs(modpath) + modfile = os.path.join(modpath, modname + '.rst') + with open(args['module'], 'r') as i: +# mod = open(modfile, 'w') +# # Write the first block into the module rst file +# mod.write(".. _" + modname + ":\n\n") +# mod.write(modname + "\n") +# mod.write("="*len(modname) + "\n\n") + +# listHeader = False + o = None + + for l in i: + if not l.startswith('#'): + return + if l.startswith('# .. cmake_function'): + if o: + o.close() + cmdpath = os.path.join(args['builddir'], 'commands') + if not os.path.exists(cmdpath): + os.makedirs(cmdpath) + try: + cmd = re.findall(r'# .. cmake_function:: (.*)', l)[0] + except IndexError as e: + print("CMake doc syntax error in {}: cannot parse function on line {}".format(args['module'], l)) + raise e + cmdfile = os.path.join(cmdpath, cmd + ".rst") +# if not listHeader: +# mod.write("\nThis module defines the following functions or macros:\n\n") +# listHeader = True +# mod.write("* :ref:`{}`\n".format(cmd)) + o = open(cmdfile, 'w') + o.write(".. _" + cmd + ":\n\n") + o.write(cmd + "\n") + o.write("="*len(cmd) + "\n\n") + write_line(o, l) + elif l.startswith('# .. cmake_variable'): + if o: + o.close() + varpath = os.path.join(args['builddir'], 'variables') + if not os.path.exists(varpath): + os.makedirs(varpath) + try: + var = re.findall(r'# .. cmake_variable:: (.*)', l)[0] + except IndexError as e: + print("CMake doc syntax error in {}: cannot parse variable on line".format(args['module'], l)) + raise e + varfile = os.path.join(varpath, var + ".rst") + o = open(varfile, 'w') + o.write(".. _" + var + ":\n\n") + o.write(var + "\n") + o.write("="*len(var) + "\n\n") + write_line(o, l) + elif l.startswith('# .. cmake_module'): + if o: + o.close() + modpath = os.path.join(args['builddir'], 'modules') + if not os.path.exists(modpath): + os.makedirs(modpath) + modfile = os.path.join(modpath, modname + ".rst") + o = open(modfile, 'w') + o.write(".. _" + modname + ":\n\n") + o.write(modname + "\n") + o.write("="*len(modname) + "\n\n") + write_line(o, l) + else: + if o: + write_line(o, l) + +# Parse the given arguments +read_module() diff -Nru dune-common-2.2.1/cmake/scripts/FinalizeHeadercheck.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/FinalizeHeadercheck.cmake --- dune-common-2.2.1/cmake/scripts/FinalizeHeadercheck.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/FinalizeHeadercheck.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,13 @@ +# this is script is called at the end of all header checks +if(ENABLE_HEADERCHECK) + message("Headerchecks finished! Rerun CMake if a new file has not been checked!") +else() + message("The headercheck feature is currently disabled. You can enable it by adding ENABLE_HEADERCHECK=1 to your cmake flags.") +endif() + +#message("Running make clean on headercheck targets...") +#this cleans the build directory from pollution through headerchecks but prevents caching... :/ +#file(GLOB_RECURSE list "./CMakeFiles/headercheck_*/cmake_clean.cmake") +#foreach(item ${list}) + # execute_process(COMMAND ${CMAKE_COMMAND} -P ${item}) +#endforeach() \ No newline at end of file diff -Nru dune-common-2.2.1/cmake/scripts/index.rst.in dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/index.rst.in --- dune-common-2.2.1/cmake/scripts/index.rst.in 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/index.rst.in 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,41 @@ +.. title:: @CMAKE_PROJECT_NAME@ CMake reference + +.. role:: cmake(code) + :language: cmake + +Introduction +============ +.. toctree:: + :maxdepth: 2 + +@CMAKE_DOC_DEPENDENCIES@ + +.. _variableref: + +Input Variable reference +======================== +.. toctree:: + :maxdepth: 1 + :glob: + + variables/* + +.. _commandref: + +Command reference +================= +.. toctree:: + :maxdepth: 1 + :glob: + + commands/* + +.. _moduleref: + +Module reference +================ +.. toctree:: + :maxdepth: 1 + :glob: + + modules/* diff -Nru dune-common-2.2.1/cmake/scripts/InstallFile.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/InstallFile.cmake --- dune-common-2.2.1/cmake/scripts/InstallFile.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/InstallFile.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,6 @@ + +# Somehow variable list get destroyed when calling cmake (; is replaced with +# whitespace character. Undo this change +string(REGEX REPLACE "([a-zA-Z0-9]) ([/a-zA-Z0-9])" "\\1;\\2" files "${FILES}") +file(INSTALL ${files} DESTINATION ${DIR}) + diff -Nru dune-common-2.2.1/cmake/scripts/main77.cc.in dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/main77.cc.in --- dune-common-2.2.1/cmake/scripts/main77.cc.in 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/main77.cc.in 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,8 @@ +#include + +int main() +{ + std::cout << "This test was skipped because it failed the following CMake Conditions:" << std::endl; + ${FAILED_CONDITION_PRINTING} + return 77; +} diff -Nru dune-common-2.2.1/cmake/scripts/module_library.cc.in dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/module_library.cc.in --- dune-common-2.2.1/cmake/scripts/module_library.cc.in 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/module_library.cc.in 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,11 @@ +#include + +std::size_t ${module_lib_mangled}_version() +{ + return ${ProjectVersionMajor} * 10000 + ${ProjectVersionMinor} * 100 + ${ProjectVersionRevision}; +} + +std::string ${module_lib_mangled}_version_string() +{ + return "${ProjectVersion}"; +} diff -Nru dune-common-2.2.1/cmake/scripts/pyversion.py dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/pyversion.py --- dune-common-2.2.1/cmake/scripts/pyversion.py 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/pyversion.py 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,31 @@ +# This python script tries to figure out the version of a given python +# package. This is only intended to be used from DunePythonFindPackage.cmake +# +# There is no unified way of specifying the version of a python package. This +# script implements some methods. For discussion on the implemented methods see +# http://stackoverflow.com/questions/20180543 +# + +import sys + +# Load the module passed as argument (this avoids the need for a template +# to be configured to put the package name inhere) +modstr = sys.argv[1] +module = __import__(modstr) + +# The most common mechanism is module.__version__ +if hasattr(module, '__version__'): + sys.stdout.write(module.__version__) + sys.exit(0) + +# Alternative implementation: through pip (pip itself implement pip.__version__, +# so we never get here, when checking the version of pip itself), only works if +# package name and distribution name are the same +import pip +for package in pip.get_installed_distributions(): + if package.project_name == modstr and package.has_version(): + sys.stdout.write(package.version) + sys.exit(0) + +# Give up on this one +sys.exit(1) \ No newline at end of file diff -Nru dune-common-2.2.1/cmake/scripts/RunDoxygen.cmake dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/RunDoxygen.cmake --- dune-common-2.2.1/cmake/scripts/RunDoxygen.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/RunDoxygen.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,3 @@ +execute_process(COMMAND + ${DOXYGEN_EXECUTABLE} Doxyfile OUTPUT_FILE doxygen.log ERROR_FILE doxygen.log + TIMEOUT 300) diff -Nru dune-common-2.2.1/cmake/scripts/run-in-dune-env.sh.in dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/run-in-dune-env.sh.in --- dune-common-2.2.1/cmake/scripts/run-in-dune-env.sh.in 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/run-in-dune-env.sh.in 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,4 @@ +#!@BASH@ + +source @DUNE_PYTHON_VIRTUALENV_PATH@/bin/activate +"$@" diff -Nru dune-common-2.2.1/cmake/scripts/sphinx_cmake_dune.py dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/sphinx_cmake_dune.py --- dune-common-2.2.1/cmake/scripts/sphinx_cmake_dune.py 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/cmake/scripts/sphinx_cmake_dune.py 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,170 @@ +""" A cmake extension for Sphinx + +tailored for the Dune project. +This is used during `make doc` to build the +build system documentation. +""" + +from docutils import nodes +from docutils.parsers.rst import Directive +from itertools import chain + +class CMakeParamNode(nodes.Element): + pass + +class CMakeBriefNode(nodes.Element): + pass + +class CMakeFunction(Directive): + # We do require the name to be an argument + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = False + has_content = True + + def run(self): + env = self.state.document.settings.env + + # Parse the content of the directive recursively + node = nodes.Element() + node.document = self.state.document + self.state.nested_parse(self.content, self.content_offset, node) + + brief_nodes = [] + output_nodes = [] + required_params = {} + optional_params = {} + + for child in node: + if isinstance(child, CMakeParamNode): + if child["required"]: + required_params[child["name"]] = child + else: + optional_params[child["name"]] = child + elif isinstance(child, CMakeBriefNode): + par = nodes.paragraph() + self.state.nested_parse(child['content'], self.content_offset, par) + brief_nodes.append(par) + else: + output_nodes.append(child) + + # Build the content of the box + sl = [self.arguments[0] + '(\n'] + for rp, paramnode in required_params.items(): + if paramnode["multi"]: + sl.append(" "*(len(self.arguments[0])+2) + paramnode['name'] + ' ' + paramnode['argname'] + '1 [' + paramnode['argname'] + '2 ...]\n') + if paramnode["single"]: + sl.append(" "*(len(self.arguments[0])+2) + paramnode['name'] + ' ' + paramnode['argname'] + '\n') + if paramnode["option"]: + sl.append(" "*(len(self.arguments[0])+2) + paramnode['name'] + '\n') + + for op, paramnode in optional_params.items(): + if paramnode["multi"]: + sl.append(' '*(len(self.arguments[0])+1) + '[' + paramnode['name'] + ' ' + paramnode['argname'] + '1 [' + paramnode['argname'] + '2 ...]' + ']\n') + if paramnode["single"]: + sl.append(" "*(len(self.arguments[0])+1) + '['+ paramnode['name'] + ' ' + paramnode['argname'] + ']\n') + if paramnode["option"]: + sl.append(" "*(len(self.arguments[0])+1) + '['+ paramnode['name'] + ']\n') + + sl.append(")\n") + lb = nodes.literal_block(''.join(sl), ''.join(sl)) + brief_nodes.append(lb) + + dl = nodes.definition_list() + for param, paramnode in chain(required_params.items(), optional_params.items()): + dli = nodes.definition_list_item() + dl += dli + + dlit = nodes.term(text=param) + dli += dlit + + dlic = nodes.definition() + dli += dlic + self.state.nested_parse(paramnode['content'], self.content_offset, dlic) + + # add the parameter list to the output + brief_nodes.append(dl) + + return brief_nodes + output_nodes + +class CMakeBrief(Directive): + required_arguments = 0 + optional_arguments = 0 + final_argument_whitespace = False + has_content = True + + def run(self): + node = CMakeBriefNode() + node['content'] = self.content + return [node] + +class CMakeParam(Directive): + # We do require the name to be an argument + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = False + option_spec = {'argname' : lambda s: s, + 'multi': lambda s: True, + 'option': lambda s: True, + 'positional' : lambda s: True, + 'required': lambda s: True, + 'single': lambda s: True + } + has_content = True + + def run(self): + node = CMakeParamNode() + # set defaults: + node['name'] = self.arguments[0] + node['single'] = self.options.get('single', False) + node['multi'] = self.options.get('multi', False) + node['option'] = self.options.get('option', False) + node['positional'] = self.options.get('positional', False) + node['required'] = self.options.get('required', False) + node['argname'] = self.options.get('argname', self.arguments[0].lower() if self.arguments[0].lower()[-1:] != 's' else self.arguments[0].lower()[:-1]) + node['content'] = self.content + if node['positional']: + node['argname'] = '' + return [node] + + +class CMakeVariable(Directive): + # We do require the name to be an argument + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = False + option_spec = {'argname' : lambda s: s, + 'multi': lambda s: True, + 'option': lambda s: True, + 'positional' : lambda s: True, + 'required': lambda s: True, + 'single': lambda s: True + } + has_content = True + + def run(self): + node = nodes.paragraph() + self.state.nested_parse(self.content, self.content_offset, node) + return [node] + +class CMakeModule(Directive): + required_arguments = 0 + optional_arguments = 0 + final_argument_whitespace = False + has_content = True + + def run(self): + node = nodes.paragraph() + self.state.nested_parse(self.content, self.content_offset, node) + return [node] + +def setup(app): + app.add_node(CMakeBriefNode) + app.add_node(CMakeParamNode) + app.add_directive('cmake_module', CMakeModule) + app.add_directive('cmake_brief', CMakeBrief) + app.add_directive('cmake_function', CMakeFunction) + app.add_directive('cmake_param', CMakeParam) + app.add_directive('cmake_variable', CMakeVariable) + + return {'version': '0.1'} diff -Nru dune-common-2.2.1/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/CMakeLists.txt --- dune-common-2.2.1/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,29 @@ +# set up project +project("dune-common" C CXX) + +# general stuff +cmake_minimum_required(VERSION 2.8.12) + +# make sure our own modules are found +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules") + +# set the script dir for the macros. +set(DUNE_COMMON_SCRIPT_DIR "${PROJECT_SOURCE_DIR}/cmake/scripts") + +#include the dune macros +include(DuneMacros) + +# start a dune project with information from dune.module +dune_project() + +# add subdirectories to execute CMakeLists.txt there +add_subdirectory("lib") +add_subdirectory("share") +add_subdirectory("dune") +add_subdirectory("bin") +add_subdirectory("doc") +add_subdirectory("cmake/modules") +add_subdirectory("cmake/scripts") + +# finalize the dune project, e.g. generating config.h etc. +finalize_dune_project() diff -Nru dune-common-2.2.1/config.h.cmake dune-common-2.5.2~20170808ga5c076ca/config.h.cmake --- dune-common-2.2.1/config.h.cmake 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/config.h.cmake 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,157 @@ +/* config.h. Generated from config.h.cmake by CMake. */ + +/* begin dune-common */ + +/* Define to the version of dune-common */ +#define DUNE_COMMON_VERSION "${DUNE_COMMON_VERSION}" + +/* Define to the major version of dune-common */ +#define DUNE_COMMON_VERSION_MAJOR ${DUNE_COMMON_VERSION_MAJOR} + +/* Define to the minor version of dune-common */ +#define DUNE_COMMON_VERSION_MINOR ${DUNE_COMMON_VERSION_MINOR} + +/* Define to the revision of dune-common */ +#define DUNE_COMMON_VERSION_REVISION ${DUNE_COMMON_VERSION_REVISION} + +/* Standard debug streams with a level below will collapse to doing nothing */ +#define DUNE_MINIMAL_DEBUG_LEVEL ${DUNE_MINIMAL_DEBUG_LEVEL} + +/* does the compiler support __attribute__((deprecated))? */ +#cmakedefine HAS_ATTRIBUTE_DEPRECATED 1 + +/* does the compiler support __attribute__((deprecated("message"))? */ +#cmakedefine HAS_ATTRIBUTE_DEPRECATED_MSG 1 + +/* does the compiler support __attribute__((unused))? */ +#cmakedefine HAS_ATTRIBUTE_UNUSED 1 + +/* Define if you have a BLAS library. */ +#cmakedefine HAVE_BLAS 1 + +/* does the compiler support abi::__cxa_demangle */ +#cmakedefine HAVE_CXA_DEMANGLE 1 + +/* Define if you have LAPACK library. */ +#cmakedefine HAVE_LAPACK 1 + +/* Define to 1 if you have the header file. */ +// Not used! #cmakedefine01 HAVE_MALLOC_H + +/* Define if you have the MPI library. */ +#cmakedefine HAVE_MPI ENABLE_MPI + +/* Define if you have the GNU GMP library. The value should be ENABLE_GMP + to facilitate activating and deactivating GMP using compile flags. */ +#cmakedefine HAVE_GMP ENABLE_GMP + +/* Define to 1 if you have the Vc library. */ +#cmakedefine HAVE_VC 1 + +/* Define to 1 if you have the symbol mprotect. */ +#cmakedefine HAVE_MPROTECT 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 + +/* Define to 1 if you have . */ +#cmakedefine HAVE_SYS_MMAN_H 1 + +/* begin private */ + +/* Name of package */ +#define PACKAGE "dune-common" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "@DUNE_MAINTAINER@" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@DUNE_MOD_NAME@" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "@DUNE_MOD_NAME@ @DUNE_MOD_VERSION@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@DUNE_MOD_NAME@" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "@DUNE_MOD_URL@" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@DUNE_MOD_VERSION@" + +/* Version number of package */ +#define VERSION "@DUNE_MOD_VERSION@" + +/* end private */ + +/* old feature support macros which were tested until 2.4, kept around for one more release */ +/* As these are now always supported due to the new compiler requirements, they are directly */ +/* defined without an explicit test. */ +#define HAVE_NULLPTR 1 +#define HAVE_CONSTEXPR 1 +#define HAVE_RANGE_BASED_FOR 1 +#define HAVE_NOEXCEPT_SPECIFIER 1 +#define HAVE_STD_DECLVAL 1 +#define HAVE_KEYWORD_FINAL 1 +#define MPI_2 1 + +/* Define to 1 if the compiler properly supports testing for operator[] */ +#cmakedefine HAVE_IS_INDEXABLE_SUPPORT 1 + +/* Define to ENABLE_UMFPACK if the UMFPack library is available */ +#cmakedefine HAVE_UMFPACK ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse library is available */ +#cmakedefine HAVE_SUITESPARSE ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's AMD library is available */ +#cmakedefine HAVE_SUITESPARSE_AMD ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's BTF library is available */ +#cmakedefine HAVE_SUITESPARSE_BTF ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's CAMD library is available */ +#cmakedefine HAVE_SUITESPARSE_CAMD ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's CCOLAMD library is available */ +#cmakedefine HAVE_SUITESPARSE_CCOLAMD ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's CHOLMOD library is available */ +#cmakedefine HAVE_SUITESPARSE_CHOLMOD ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's COLAMD library is available */ +#cmakedefine HAVE_SUITESPARSE_COLAMD ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's CXSPARSE library is available */ +#cmakedefine HAVE_SUITESPARSE_CXSPARSE ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's KLU library is available */ +#cmakedefine HAVE_SUITESPARSE_KLU ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's LDL library is available */ +#cmakedefine HAVE_SUITESPARSE_LDL ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's RBIO library is available */ +#cmakedefine HAVE_SUITESPARSE_RBIO ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's SPQR library is available + and if it's version is at least 4.3 */ +#cmakedefine HAVE_SUITESPARSE_SPQR ENABLE_SUITESPARSE + +/* Define to ENABLE_SUITESPARSE if the SuiteSparse's UMFPACK library is available */ +#cmakedefine HAVE_SUITESPARSE_UMFPACK ENABLE_SUITESPARSE + +/* Define to ENABLE_PARMETIS if you have the Parmetis library. + This is only true if MPI was found + by configure _and_ if the application uses the PARMETIS_CPPFLAGS */ +#cmakedefine HAVE_PARMETIS ENABLE_PARMETIS + +/* Define to 1 if PT-Scotch is available */ +#cmakedefine HAVE_PTSCOTCH 1 + +/* Include always useful headers */ +#include "FC.h" +#define FC_FUNC FC_GLOBAL_ + +/* end dune-common */ diff -Nru dune-common-2.2.1/configure.ac dune-common-2.5.2~20170808ga5c076ca/configure.ac --- dune-common-2.2.1/configure.ac 2013-02-15 12:22:40.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/configure.ac 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -#! /bin/bash -# $Id: configure.ac 7127 2013-02-15 12:22:40Z mblatt $ -# Process this file with autoconf to produce a configure script. - -DUNE_AC_INIT # gets module version from dune.module file -AM_INIT_AUTOMAKE -AC_CONFIG_SRCDIR([dune/common/stdstreams.cc]) -AC_CONFIG_HEADERS([config.h]) - -# add configure flags needed to create log files for dune-autobuild -DUNE_AUTOBUILD_FLAGS -# check all dune dependecies and prerequisits -DUNE_CHECK_ALL - -# preset variable to path such that #include works -AC_SUBST([DUNE_COMMON_ROOT], '$(abs_top_srcdir)') -AC_SUBST([DUNE_COMMON_BIN], '$(abs_top_srcdir)/bin/') -AC_SUBST([AM_CPPFLAGS], '-I$(top_srcdir)') -AC_SUBST([AM_LDFLAGS], '$(DUNE_LDFLAGS)') -AC_SUBST([LDADD], '$(top_builddir)/lib/libdunecommon.la') - -# write output -AC_CONFIG_FILES([Makefile - lib/Makefile - bin/Makefile - dune/Makefile - dune/common/Makefile - dune/common/test/Makefile - dune/common/parallel/Makefile - dune/common/parallel/test/Makefile - doc/Makefile - doc/doxygen/Makefile - doc/doxygen/Doxyfile - doc/buildsystem/Makefile - m4/Makefile - am/Makefile - bin/check-log-store - dune-common.pc]) -AC_OUTPUT - -# make scripts executable -chmod +x bin/check-log-store - -# print results -DUNE_SUMMARY_ALL diff -Nru dune-common-2.2.1/CONTRIBUTING.md dune-common-2.5.2~20170808ga5c076ca/CONTRIBUTING.md --- dune-common-2.2.1/CONTRIBUTING.md 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/CONTRIBUTING.md 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,70 @@ +Contributing to the Dune Core Modules +===================================== + +You've squashed an annoying bug or implemented a nifty new feature in DUNE? +And you're willing to share your improvements with the community? This page +explains how to get those changes to us and what to take care of. + +Take a look at the DUNE coding style +------------------------------------ + +Your work will enjoy much smoother sailing if you take a look at the Coding +Style and try to stick to it with your changes. We understand that everyone +has their personal preferences and that there is no such thing as the *right* +coding style (in the end, it's a matter of taste), but DUNE is a pretty large +project, and a consistent way of doing things really helps a lot when trying +to find your way around a body of code as big as DUNE. + +Make sure to install the Whitespace Hook before starting to work, because +our repositories enforce certain rules about whitespace and will not accept +commits that violate those rules. And a developer will be much more motivated +to merge your patch if doing so does not involve fixing a bunch of tab-based +indentations that you inadvertently added as part of your changes + +Use Git to your advantage +------------------------- + +We know, Git can be a bit daunting at first, but trust us, it's really worth +investing half an hour to learn the basics! Even though you don't have any +commit rights to the DUNE repositories, Git still allows you to create local +commits on your machine, avoiding the usual ugly business of creating backup +copies, copying around code in files, commenting and uncommenting variants etc. +And when you're done and send the changes to us, we can simply import those +commits into our repositories. That saves a lot of time and when your changes +can be applied in five minutes using two or three commands, chances are a +developer will much more easily find the time to do so. Git is really popular, +so there are tons of tutorials all over the web. Here are some pointers: + +* http://try.github.io/ is a very quick, hands-down introduction + to Git that allows you to try out Git directly in your browser. + Requires a GitHub account to continue at some point, though. +* http://git-scm.com/book is a very well-written and detailed resource + for all things Git. Chapter 2 is a great introduction to Git that also explains + a little bit how Git works, which really helps to reduce the number of + *WTF just happened?* moments. ;-) +* http://eagain.net/articles/git-for-computer-scientists/ is a short and + sweet explanation of what Git does at a fundamental level - just the thing for + scientists! ;-) +* http://git-scm.com/doc/ext is a collection of both introductory and + more in-depth Git resources. + +Whatever you do, make sure to set your Git identity so that the commits tell us who authored them! + +Getting the changes to us +------------------------- + +You should get your changes to us in the following way: +* Get an account for [our GitLab instance](http://gitlab.dune-project.org). +* Fork the core module that you want to contribute to, just + as you would do on GitHub. +* Push your changes to your fork on some branch. +* Open a merge request using the branch you pushed your changes + to as the source branch and the master of the core module repository + as the target branch. GitLab will usually ask you about opening + a merge request if you browse it right after pushing to some branch. +* Follow the discussion on the merge request to see what improvements + should be done to the branch before merging. + +If you have any questions or complaints about this workflow of +contributing to Dune, please rant on the +[dune-devel mailing list](mailto:dune-devel@lists.dune-project.org). diff -Nru dune-common-2.2.1/COPYING dune-common-2.5.2~20170808ga5c076ca/COPYING --- dune-common-2.2.1/COPYING 2013-02-26 12:26:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/COPYING 2017-08-08 08:39:46.000000000 +0000 @@ -1,40 +1,61 @@ Copyright holders: +================== +2015--2016 Marco Agnese +2015 Martin Alkämper 2003--2010 Peter Bastian -2004--2012 Markus Blatt -2011 Ansgar Burchardt +2004--2016 Markus Blatt +2013 Andreas Buhr +2011--2016 Ansgar Burchardt 2004--2005 Adrian Burri -2006--2012 Andreas Dedner +2014 Benjamin Bykowski (may appear in the logs as "Convex Function") +2014 Marco Cecchetti +2006--2016 Andreas Dedner 2003 Marc Droske -2003--2012 Christian Engwer -2004--2012 Jorrit Fahlke +2003--2016 Christian Engwer +2004--2016 Jorrit Fahlke +2016 Thomas Fetzer 2008--2013 Bernd Flemisch -2005--2010 Carsten Gräser -2010--2012 Christoph Grüninger +2013--2014 Christoph Gersbacher +2015 Stefan Girke +2005--2016 Carsten Gräser +2015--2016 Felix Gruber +2010--2016 Christoph Grüninger 2006 Bernhard Haasdonk +2015 Claus-Justus Heine +2015--2016 René Heß 2012--2013 Olaf Ippisch +2013--2016 Dominic Kempf 2009 Leonard Kern +2013 Torbjörn Klatt +2003--2015 Robert Klöfkorn 2005--2007 Sreejith Pulloor Kuttanikkad -2003--2012 Robert Klöfkorn -2010--2011 Andreas Lauser +2012--2016 Arne Morten Kvarving +2010--2014 Andreas Lauser +2016 Tobias Leibner +2015 Lars Lubkoll +2012--2016 Tobias Malkmus 2007--2011 Sven Marnach -2012 Tobias Malkmus -2010 Rene Milk -2011--2012 Steffen Müthing +2010--2016 Rene Milk +2011--2016 Steffen Müthing 2003--2006 Thimo Neubauer 2011 Rebecca Neumann -2008--2012 Martin Nolte +2008--2016 Martin Nolte +2014 Andreas Nüßing 2004--2005 Mario Ohlberger -2008--2012 Elias Pipping +2014 Steffen Persvold +2008--2016 Elias Pipping 2011 Dan Popovic 2009 Atgeirr Rasmussen -2003--2012 Oliver Sander -2006--2011 Uli Sack +2006--2014 Uli Sack +2003--2016 Oliver Sander 2006 Klaus Schneider 2004 Roland Schulz -2009--2012 BÃ¥rd Skaflestad +2015 Nicolas Schwenck +2016 Linus Seelinger +2009--2014 BÃ¥rd Skaflestad 2012 Matthias Wohlmuth -2011 Jonathan Youett +2011--2016 Jonathan Youett The DUNE library and headers are licensed under version 2 of the GNU @@ -56,16 +77,16 @@ reasons why the executable file might be covered by the GNU General Public License. - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -114,8 +135,8 @@ The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE + + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -169,7 +190,7 @@ License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -227,7 +248,7 @@ access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -284,7 +305,7 @@ This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -314,7 +335,7 @@ of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -336,9 +357,9 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it diff -Nru dune-common-2.2.1/debian/changelog dune-common-2.5.2~20170808ga5c076ca/debian/changelog --- dune-common-2.2.1/debian/changelog 2013-05-12 16:30:59.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/changelog 2017-08-11 11:40:15.000000000 +0000 @@ -1,3 +1,225 @@ +dune-common (2.5.2~20170808ga5c076ca-0~ubuntu14.04~ab1) trusty; urgency=medium + + * New upstream snapshot. + * Use g++-7. The default compiler on Ubuntu 14.04 is too old. + * Restore libdune-common-dbg. + + -- Ansgar Burchardt Fri, 11 Aug 2017 13:40:15 +0200 + +dune-common (2.5.1-1) unstable; urgency=medium + + * New upstream release. + * Build-Depend on texlive-pictures instead of pgf. (Closes: #867073) + * debian/copyright: Update URLs. + * Bumped Standards-Version to 4.0.0 (no changes). + + -- Ansgar Burchardt Tue, 18 Jul 2017 11:53:29 +0200 + +dune-common (2.5.1~rc1-1) experimental; urgency=medium + + * New upstream release candidate. + * No longer build manual -dbg package. Use the automatically generated + -dbgsym package instead. + * dune-debian.mk: do not limit number of MPI ranks to number of cores + when running tests. (Closes: #850229) + + -- Ansgar Burchardt Sat, 17 Jun 2017 15:48:18 +0200 + +dune-common (2.5.0-1) unstable; urgency=medium + + * New upstream release. + + -- Ansgar Burchardt Sun, 18 Dec 2016 12:58:14 +0100 + +dune-common (2.5.0~rc2-2) unstable; urgency=medium + + * Add Breaks+Replaces: libdune-functions-dev (<< 2.5.0~) + (Closes: #847142) + + -- Ansgar Burchardt Mon, 05 Dec 2016 23:41:24 +0100 + +dune-common (2.5.0~rc2-1) unstable; urgency=medium + + * Upload to unstable. + * New upstream release candidate. + * dune-debian.mk: Restore variable for configure options. + + -- Ansgar Burchardt Mon, 05 Dec 2016 23:09:55 +0100 + +dune-common (2.5.0~rc1-3) experimental; urgency=medium + + * Call dh_sphinxdoc only when building arch-indep packages. + + -- Ansgar Burchardt Tue, 22 Nov 2016 21:12:02 +0100 + +dune-common (2.5.0~rc1-2) experimental; urgency=medium + + * Patch: Add correct offset for end of chunk + This should fix the build failure on 32bit architectures. + + 0001-Add-correct-offset-for-end-of-chunk.patch + * Use dh_sphinxdoc. + + -- Ansgar Burchardt Tue, 22 Nov 2016 20:21:37 +0100 + +dune-common (2.5.0~rc1-1) experimental; urgency=medium + + * New upstream release candidate. + * Switch to CMake. + * dune-debian.mk: Simplify running tests. + * Bumped Standards-Version to 3.9.8 (no changes). + + -- Ansgar Burchardt Mon, 21 Nov 2016 20:37:38 +0100 + +dune-common (2.4.1-1) unstable; urgency=medium + + * New upstream release. + * Mark libdune-common-dev as Multi-Arch: same. + + -- Ansgar Burchardt Mon, 29 Feb 2016 10:19:18 +0100 + +dune-common (2.4.1~rc2-1) experimental; urgency=medium + + * New upstream release candidate. + + -- Ansgar Burchardt Sun, 28 Feb 2016 13:18:16 +0100 + +dune-common (2.4.0-1) unstable; urgency=medium + + * New upstream release. + + -- Ansgar Burchardt Fri, 25 Sep 2015 22:29:28 +0200 + +dune-common (2.4~20150912rc3-1) unstable; urgency=medium + + * New upstream release candidate. + * dune-debian.mk: Add options to enable UMFPack support. + + -- Ansgar Burchardt Sun, 13 Sep 2015 13:38:49 +0200 + +dune-common (2.4~20150825rc2-1) experimental; urgency=medium + + * New upstream release candidate. + * Move shared library into -dev package and provide a virtual package + that changes with the upstream version for shlib dependencies. See + also https://lists.debian.org/debian-devel/2015/07/msg00115.html + * libdune-common-dev: Add -doc package as a suggested package. + + -- Ansgar Burchardt Fri, 04 Sep 2015 14:24:36 +0200 + +dune-common (2.4~20150717rc1-1) experimental; urgency=medium + + * New upstream release candidate. + + -- Ansgar Burchardt Fri, 17 Jul 2015 20:45:00 +0200 + +dune-common (2.4~20150617g6f17141-1) experimental; urgency=medium + + * New upstream snapshot. + * get-orig-source: Use commit date instead of current date. + + -- Ansgar Burchardt Fri, 19 Jun 2015 23:11:40 +0200 + +dune-common (2.4~20150521g15491c4-1) experimental; urgency=medium + + * New upstream snapshot. + + -- Ansgar Burchardt Thu, 21 May 2015 21:46:50 +0200 + +dune-common (2.4~20150505g1ce8697-1) experimental; urgency=medium + + * New upstream snapshot. + * Change shared library package name to libdune-common-2.4git. + * Update debian/copyright for new upstream snapshot. + * Add Build-Depends-Indep: graphviz for "dot". + * dune-debian.mk: Continue to use autotools for now. + * Bumped Standards-Version to 3.9.6 (no changes). + + -- Ansgar Burchardt Tue, 05 May 2015 21:53:57 +0200 + +dune-common (2.3.1-1) unstable; urgency=medium + + * New upstream release. + * Install bash completion for dunecontrol. + + -- Ansgar Burchardt Tue, 17 Jun 2014 19:46:31 +0200 + +dune-common (2.3.1~rc1-1) experimental; urgency=medium + + * New upstream release candidate. + * Change shared library package name to libdune-common-2.3.1. + * dune-debian.mk: Enable support for UG. + + -- Ansgar Burchardt Tue, 10 Jun 2014 19:54:09 +0200 + +dune-common (2.3.0-1) unstable; urgency=medium + + * New upstream release. + * Change shared library package name to libdune-common-2.3.0. + + -- Ansgar Burchardt Fri, 14 Feb 2014 09:12:40 +0100 + +dune-common (2.3~20140122g7a7cf2b-1) experimental; urgency=medium + + * New upstream snapshot. + + -- Ansgar Burchardt Wed, 22 Jan 2014 23:10:56 +0100 + +dune-common (2.3~20140117beta2-1) experimental; urgency=medium + + * New upstream snapshot. + * Remove patches that should be obsoleted by upstream changes. + * dune-debian.mk: Remove obsolete --enable-fieldvector-size-is-method flag. + * libdune-common-dev.install: Install /usr/lib/*/cmake. + * Backport 073167e61070a5e952c738c02d85c3f946717e40 ([dune-autogen] + Prevents overriding am_dir with installed modules) from master branch. + + New patch: 0001-dune-autogen-Prevents-overriding-am_dir-with-install.patch + + -- Ansgar Burchardt Mon, 20 Jan 2014 13:42:47 +0100 + +dune-common (2.3~20140111beta1-1) experimental; urgency=medium + + * New upstream snapshot. + * Rename git-whitespace-hook to dune-git-whitespace-hook. + * Install cmake modules. Note that it is still not possible to use + cmake with the Debian packages. + * debian/control: Remove ${shlibs:Depends} from -dev and -dbg package. + * debian/dune-debian.mk: Use default compression for binary packages. + + -- Ansgar Burchardt Wed, 15 Jan 2014 13:33:04 +0100 + +dune-common (2.3~20140103g107b57a-1) experimental; urgency=medium + + * New upstream snapshot. + * Install man page using dh_installman as "make install" is not called + for the doc subdirectory and thus dh_install cannot find usr/share/man. + * debian/dune-debian.mk: Restore --without-parmetis. + + -- Ansgar Burchardt Fri, 03 Jan 2014 00:40:13 +0100 + +dune-common (2.3~20131227g6c02812-1) experimental; urgency=medium + + * New upstream snapshot. + * Add Build-Depends on texlive-latex-extra (for subfigure.sty). + * Change shared library package name to libdune-common-2.3svn. + * Patch dunecontrol to skip directories starting with a dot when + looking for dune.module. + + new patch: skip-dirs-starting-with-dot.patch + * Install dune_cxa_demangle.m4. + + new patch: 0001-Install-dune_cxa_demangle.m4.patch + * debian/dune-debian.mk: Do not pass --without-parmetis to configure + as doing so triggers a bug causing the configure script to abort, cf. + + * debian/control: Use canonical Vcs-* URIs. + * debian/control: Drop pre-depends on dpkg (>= 1.15.6) which is + already satisfied in Debian 6. + * debian/rules: Install am2cmake.py as dune-am2cmake. + * libdune-common-dev: Add dependency on python and python-pyparsing + for am2cmake.py. + * libdune-common-dev: Include man page for dunecontrol. + * Bumped Standards-Version to 3.9.5 (no changes). + + -- Ansgar Burchardt Wed, 01 Jan 2014 19:40:32 +0100 + dune-common (2.2.1-2) unstable; urgency=low * Upload to unstable. diff -Nru dune-common-2.2.1/debian/clean dune-common-2.5.2~20170808ga5c076ca/debian/clean --- dune-common-2.2.1/debian/clean 2011-12-20 22:21:08.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/clean 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -doc/buildsystem/buildsystem.pdf diff -Nru dune-common-2.2.1/debian/control dune-common-2.5.2~20170808ga5c076ca/debian/control --- dune-common-2.2.1/debian/control 2013-05-12 16:30:35.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/control 2017-08-11 11:40:15.000000000 +0000 @@ -1,23 +1,29 @@ Source: dune-common Section: libs Priority: optional -Standards-Version: 3.9.4 +Standards-Version: 4.0.0 Maintainer: Debian Science Maintainers Uploaders: Ansgar Burchardt , Oliver Sander -Vcs-Browser: http://git.debian.org/?p=debian-science/packages/dune-common.git -Vcs-Git: git://git.debian.org/debian-science/packages/dune-common.git +Vcs-Browser: https://anonscm.debian.org/cgit/debian-science/packages/dune-common.git +Vcs-Git: https://anonscm.debian.org/git/debian-science/packages/dune-common.git Homepage: http://www.dune-project.org/ Build-Depends: debhelper (>= 9), - automake, autoconf, gfortran, libtool, mpi-default-bin, mpi-default-dev, pkg-config -Build-Depends-Indep: doxygen, ghostscript, texlive-latex-recommended, pgf + g++-7, + cmake, gfortran, mpi-default-bin, mpi-default-dev, pkg-config, python3 +Build-Depends-Indep: doxygen, ghostscript, graphviz, imagemagick, texlive-latex-extra, texlive-latex-recommended, texlive-pictures, python3-sphinx Package: libdune-common-dev Section: libdevel Architecture: any -Depends: ${misc:Depends}, ${shlibs:Depends}, libdune-common-2.2.1 (= ${binary:Version}) -Pre-Depends: dpkg (>= 1.15.6) -Recommends: automake, autoconf, libtool, pkg-config -Suggests: libdune-common-dbg (= ${binary:Version}) +Multi-Arch: same +Depends: ${misc:Depends}, ${shlibs:Depends}, + g++-7, + pkg-config, python, python-pyparsing +Breaks: libdune-functions-dev (<< 2.5.0~) +Replaces: libdune-functions-dev (<< 2.5.0~) +Recommends: cmake, python3 +Suggests: libdune-common-doc (= ${source:Version}) +Provides: ${dune:shared-library} Description: toolbox for solving PDEs -- basic classes (development files) DUNE, the Distributed and Unified Numerics Environment is a modular toolbox for solving partial differential equations (PDEs) with grid-based methods. @@ -28,37 +34,17 @@ Package: libdune-common-dbg Section: debug -Priority: extra -Architecture: any -Multi-Arch: same -Depends: ${misc:Depends}, ${shlibs:Depends}, libdune-common-2.2.1 (= ${binary:Version}) -Pre-Depends: dpkg (>= 1.15.6) -Description: toolbox for solving PDEs -- basic classes (debug symbols) - DUNE, the Distributed and Unified Numerics Environment is a modular toolbox - for solving partial differential equations (PDEs) with grid-based methods. - It supports the easy implementation of methods like Finite Elements (FE), - Finite Volumes (FV), and also Finite Differences (FD). - . - This package contains the debug symbols for the basic classes. - -Package: libdune-common-2.2.1 Architecture: any Multi-Arch: same -Depends: ${misc:Depends}, ${shlibs:Depends} -Pre-Depends: ${misc:Pre-Depends}, dpkg (>= 1.15.6) -Description: toolbox for solving PDEs -- basic classes (library) - DUNE, the Distributed and Unified Numerics Environment is a modular toolbox - for solving partial differential equations (PDEs) with grid-based methods. - It supports the easy implementation of methods like Finite Elements (FE), - Finite Volumes (FV), and also Finite Differences (FD). - . - This package contains the library for the basic classes. +Depends: ${misc:Depends}, libdune-common-dev (= ${binary:Version}) +Description: debug symbols for libdune-common-dev Package: libdune-common-doc Section: doc Architecture: all -Depends: ${misc:Depends} -Pre-Depends: dpkg (>= 1.15.6) +Multi-Arch: foreign +Depends: ${misc:Depends}, ${sphinxdoc:Depends} +Built-Using: ${dune:doc:Built-Using} Description: toolbox for solving PDEs -- basic classes (documentation) DUNE, the Distributed and Unified Numerics Environment is a modular toolbox for solving partial differential equations (PDEs) with grid-based methods. diff -Nru dune-common-2.2.1/debian/copyright dune-common-2.5.2~20170808ga5c076ca/debian/copyright --- dune-common-2.2.1/debian/copyright 2013-03-01 22:24:02.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/copyright 2017-08-07 13:07:26.000000000 +0000 @@ -1,79 +1,119 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: dune-common -Source: http://www.dune-project.org/downloadsvn.html +Source: https://www.dune-project.org/dev/downloadgit/ Files: * Copyright: - 2003-2010 Peter Bastian - 2004-2012 Markus Blatt - 2011 Ansgar Burchardt - 2004-2005 Adrian Burri - 2006-2012 Andreas Dedner - 2003 Marc Droske - 2003-2012 Christian Engwer - 2004-2012 Jorrit Fahlke - 2008-2013 Bernd Flemisch - 2005-2010 Carsten Gräser - 2010-2012 Christoph Grüninger - 2006 Bernhard Haasdonk - 2012-2013 Olaf Ippisch - 2009 Leonard Kern - 2005-2007 Sreejith Pulloor Kuttanikkad - 2003-2012 Robert Klöfkorn - 2010-2011 Andreas Lauser - 2007-2011 Sven Marnach - 2012 Tobias Malkmus - 2010 Rene Milk - 2011-2012 Steffen Müthing - 2003-2006 Thimo Neubauer - 2011 Rebecca Neumann - 2008-2012 Martin Nolte - 2004-2005 Mario Ohlberger - 2008-2012 Elias Pipping - 2011 Dan Popovic - 2009 Atgeirr Rasmussen - 2003-2012 Oliver Sander - 2006-2011 Uli Sack - 2006 Klaus Schneider - 2004 Roland Schulz - 2009-2012 BÃ¥rd Skaflestad - 2012 Matthias Wohlmuth - 2011 Jonathan Youett + 2015--2016 Marco Agnese + 2015 Martin Alkämper + 2003--2010 Peter Bastian + 2004--2016 Markus Blatt + 2013 Andreas Buhr + 2011--2016 Ansgar Burchardt + 2004--2005 Adrian Burri + 2014 Benjamin Bykowski + 2014 Marco Cecchetti + 2006--2016 Andreas Dedner + 2003 Marc Droske + 2003--2016 Christian Engwer + 2004--2016 Jorrit Fahlke + 2016 Thomas Fetzer + 2008--2013 Bernd Flemisch + 2013--2014 Christoph Gersbacher + 2015 Stefan Girke + 2005--2016 Carsten Gräser + 2015--2016 Felix Gruber + 2010--2016 Christoph Grüninger + 2006 Bernhard Haasdonk + 2015 Claus-Justus Heine + 2015--2016 René Heß + 2012--2013 Olaf Ippisch + 2013--2016 Dominic Kempf + 2009 Leonard Kern + 2013 Torbjörn Klatt + 2003--2015 Robert Klöfkorn + 2005--2007 Sreejith Pulloor Kuttanikkad + 2012--2016 Arne Morten Kvarving + 2010--2014 Andreas Lauser + 2016 Tobias Leibner + 2015 Lars Lubkoll + 2012--2016 Tobias Malkmus + 2007--2011 Sven Marnach + 2010--2016 Rene Milk + 2011--2016 Steffen Müthing + 2003--2006 Thimo Neubauer + 2011 Rebecca Neumann + 2008--2016 Martin Nolte + 2014 Andreas Nüßing + 2004--2005 Mario Ohlberger + 2014 Steffen Persvold + 2008--2016 Elias Pipping + 2011 Dan Popovic + 2009 Atgeirr Rasmussen + 2006--2014 Uli Sack + 2003--2016 Oliver Sander + 2006 Klaus Schneider + 2004 Roland Schulz + 2015 Nicolas Schwenck + 2016 Linus Seelinger + 2009--2014 BÃ¥rd Skaflestad + 2012 Matthias Wohlmuth + 2011--2016 Jonathan Youett License: GPL-2 with DUNE exception -Files: dune/common/exprtmpl.hh -Copyright: 2005, Christian Engwer -License: LGPL-2.1 -Comment: Oversight from relicensing, see also - - -Files: m4/acx_blas.m4 m4/acx_lapack.m4 m4/acx_mpi.m4 m4/acx_pthread.m4 -Copyright: 2001-2005, Steven G. Johnson -License: GPL-2+ with Autoconf Macro exception -Comment: see older autoconf-archive packages - -Files: m4/ax_boost_base.m4 +Files: cmake/modules/CheckForPthreads.c cmake/modules/FindThreadsCMake31.cmake Copyright: - 2008, Thomas Porschberg - 2009, Peter Adolphs -License: GNU-All-Permissive-License - -Files: m4/ax_check_gl.m4 m4/ax_lang_compiler_ms.m4 -Copyright: 2004, Braden McDaniel -License: GNU-All-Permissive-License -Comment: see older autoconf-archive packages + 2002-2015 Kitware, Inc. + 2011-2014 Rolf Eike Beer +License: BSD-3-clause + CMake - Cross Platform Makefile Generator + Copyright 2000-2015 Kitware, Inc. + Copyright 2000-2011 Insight Software Consortium + All rights reserved. + . + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + . + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + . + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + . + * Neither the names of Kitware, Inc., the Insight Software Consortium, + nor the names of their contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Files: cmake/modules/UseLATEX.cmake +Copyright: 2004-2015, Sandia Corporation +License: other + Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + license for use of this work by or on behalf of the + U.S. Government. Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. -Files: m4/immdx_lib_metis.m4 -Copyright: 2003, Ben Bergen +Files: doc/dunecontrol.1 +Copyright: 2013-2015, Oliver Sander License: GNU-All-Permissive-License -Comment: see older autoconf-archive packages - -Files: m4/shared_ptr.m4 -Copyright: 2009, Sun Microsystems -License: SUN-All-Permissive-License Files: debian/* -Copyright: 2011-2012, Ansgar Burchardt +Copyright: 2011-2015, Ansgar Burchardt License: GPL-2 with DUNE exception License: GPL-2 with DUNE exception @@ -100,50 +140,7 @@ On Debian systems, the full text of the GNU General Public License version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. -License: GPL-2+ with Autoconf Macro exception - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - . - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - Public License for more details. - . - You should have received a copy of the GNU General Public License along - with this program. If not, see . - . - As a special exception, the respective Autoconf Macro's copyright owner - gives unlimited permission to copy, distribute and modify the configure - scripts that are the output of Autoconf when processing the Macro. You - need not follow the terms of the GNU General Public License when using - or distributing such scripts, even though portions of the text of the - Macro appear in them. The GNU General Public License (GPL) does govern - all other use of the material that constitutes the Autoconf Macro. - . - This special exception to the GPL applies to versions of the Autoconf - Macro released by the Autoconf Archive. When you make and distribute a - modified version of the Autoconf Macro, you may extend this special - exception to the GPL to apply to your modified version as well. - . - On Debian systems, the full text of the GNU General Public License version 2 - can be found in the file `/usr/share/common-licenses/GPL-2'. - -License: LGPL-2.1 - This file is part of DUNE, a Distributed and Unified Numerics Environment. - It is distributed under the terms of the GNU Lesser General Public License - version 2.1. - . - On Debian systems, the full text of the GNU Lesser General Public License - version 2.1 can be found in the file `/usr/share/common-licenses/LGPL-2.1'. - License: GNU-All-Permissive-License Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. - -License: SUN-All-Permissive-License - This file is free software; Sun Microsystems gives unlimited permission to - copy and/or distribute it, with or without modifications, as long as this - notice is preserved. diff -Nru dune-common-2.2.1/debian/dune-debian.mk dune-common-2.5.2~20170808ga5c076ca/debian/dune-debian.mk --- dune-common-2.2.1/debian/dune-debian.mk 2012-03-17 13:27:37.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/dune-debian.mk 2017-08-11 09:27:37.000000000 +0000 @@ -1,36 +1,30 @@ +include /usr/share/dpkg/pkg-info.mk -DUNE_DEBIAN_DUNECONTROL ?= /usr/bin/dunecontrol -DUNE_DEBIAN_CONFIGURE_FLAGS ?= \ - --enable-parallel \ - --enable-shared \ - --enable-fieldvector-size-is-method \ - --with-alberta=/usr \ - --with-gmp \ - --without-grape \ - --without-metis \ - --without-parmetis \ - --with-superlu \ - --without-ug \ - --without-x +DUNE_CTEST ?= /usr/bin/dune-ctest + +DUNE_DEBIAN_CMAKE_FLAGS = -DBUILD_SHARED_LIBS=1 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 + +DUNE_DEBIAN_SHLIB = $(subst ~,.,lib$(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM)) + +DUNE_DOC_BUILT_USING_PACKAGES = doxygen +DUNE_DOC_BUILT_USING = $(shell dpkg-query -f '$${source:Package} (= $${source:Version})' -W $(DUNE_DOC_BUILT_USING_PACKAGES)) override_dh_auto_configure: - $(DUNE_DEBIAN_DUNECONTROL) autogen - dh_auto_configure -- $(DUNE_DEBIAN_CONFIGURE_FLAGS) + dh_auto_configure -- $(DUNE_DEBIAN_CMAKE_FLAGS) + +# OpenMPI looks for a rsh program, even when it only starts local processes. +export OMPI_MCA_plm_rsh_agent=/bin/false + +# Don't limit number of MPI ranks to number of cores (when running tests), +# see https://bugs.debian.org/850229 +export OMPI_MCA_rmaps_base_oversubscribe=1 override_dh_auto_test: - # OpenMPI expects rsh/ssh to be in PATH even when it only starts local processes: - mkdir debian/tmp-test - ln -s /bin/false debian/tmp-test/ssh - ln -s /bin/false debian/tmp-test/rsh - PATH=$(CURDIR)/debian/tmp-test:$$PATH dh_auto_test - rm -rf debian/tmp-test - -override_dh_builddeb: - dh_builddeb -- -Zxz - -override_dh_clean: - dh_clean - find . -name Makefile.in -delete - rm -f aclocal.m4 config.guess config.h.in config.sub configure dependencies.m4 depcomp install-sh ltmain.sh missing - rm -rf doc/doxygen/Doxyfile.in doc/doxygen/doxyerr.log doc/doxygen/doxygen-tag doc/doxygen/doxygen.log doc/doxygen/html - rm -rf debian/tmp-test + dh_auto_build -- build_tests + cd build; PATH=$(CURDIR)/debian/tmp-test:$$PATH $(DUNE_CTEST) + +override_dh_gencontrol: + dh_gencontrol -- -Vdune:shared-library='$(DUNE_DEBIAN_SHLIB)' -Vdune:doc:Built-Using='$(DUNE_DOC_BUILT_USING)' + +override_dh_makeshlibs: + dh_makeshlibs --version-info='$(DUNE_DEBIAN_SHLIB)' diff -Nru dune-common-2.2.1/debian/get-orig-source dune-common-2.5.2~20170808ga5c076ca/debian/get-orig-source --- dune-common-2.2.1/debian/get-orig-source 2012-03-17 12:24:38.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/get-orig-source 2017-08-07 13:07:26.000000000 +0000 @@ -13,20 +13,64 @@ echo "usage: get-orig-source [options...] [] [] module: name of dune module (eg. dune-common) version: upstream version number - tree: branch (default: trunk) + tree: branch (default: master) rev: revision number options: - --snapshot: SVN revision is appended to the version number + --snapshot: date and Git revision is appended to the version number --dch: run dch to update version number - -d : create orig tarball in directory " + -d : create orig tarball in directory + + environment: + DUNE_SOURCE path to DUNE repositories" exit 1 } +safe-rm() { + local -a args + args=(--verbose) + while [[ $# -gt 0 ]]; do + case "${1}" in + -*) args+=("${1}"); shift ;; + *) break ;; + esac + done + + local path + local n d r + for path in "$@"; do + r="${path}" + d="." + while [[ ${r} =~ .*/.* ]]; do + n="${r%%/*}" + r="${r#*/}" + if [[ $n == "" ]]; then + d="" + continue + fi + d="${d}/${n}" + if [[ -L "${d}" ]]; then + echo "safe-rm: ${d} is a symbolic link (while removing ${path})" >&2 + exit 1 + fi + done + done + + rm "${args[@]}" "${@}" +} + if [[ $# -lt 2 ]]; then usage fi +if [[ -z "${DUNE_SOURCE:-}" ]]; then + echo "DUNE_SOURCE is not set" >&2 + echo "----------------------" >&2 + echo "Please set DUNE_SOURCE to a directory containing" >&2 + echo "checkouts of the DUNE modules to avoid cloning them." >&2 + exit 1 +fi + snapshot= dch= dir=. @@ -42,16 +86,24 @@ module="$1" version="$2" -branch="${3:-trunk}" -rev="${4:-}" +branch="${3:-master}" +if [[ -d "${DUNE_SOURCE}/${module}.git" ]]; then + GIT_DIR="${DUNE_SOURCE}/${module}.git" +elif [[ -d "${DUNE_SOURCE}/${module}/.git" ]]; then + GIT_DIR="${DUNE_SOURCE}/${module}/.git" +else + echo "Could not find Git repository for ${module} in ${DUNE_SOURCE}" >&2 + exit 1 +fi -url="https://svn.dune-project.org/svn/$module/$branch" +export GIT_DIR if [[ $snapshot ]]; then - if [[ -z $rev ]]; then - rev="$(svn info "$url" | awk '/^Last Changed Rev:/ { print $4 }')" - fi - version="${version}svn$rev" + rev="$(git rev-parse --short ${branch})" + date=$(git log -1 --pretty="format:%ci" ${branch}) + date=${date%% *} + date=${date//-/} + version="${version}${date}g${rev}" fi origdir="$module-$version.orig" @@ -62,16 +114,20 @@ exit 1 fi -svn export ${rev:+-r $rev} "$url" "$origdir" +mkdir "${origdir}" +git archive --format=tar ${branch} | tar -C "${origdir}" -x cd "$origdir" case "$module" in dune-grid) - find doc/grids/amiramesh -name "[a-z]*.am" -delete + safe-rm -r doc/grids/amiramesh + ;; + dune-uggrid) + safe-rm -r doc ;; esac cd .. -tar c "$origdir" | xz > "$tarball" +tar --owner=root --group=root -c "$origdir" | xz -9 > "$tarball" rm -rf "$origdir" if [[ $dch ]]; then diff -Nru dune-common-2.2.1/debian/libdune-common-2.2.1.install dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-2.2.1.install --- dune-common-2.2.1/debian/libdune-common-2.2.1.install 2011-12-20 22:21:08.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-2.2.1.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/lib/*/libdunecommon-*.so diff -Nru dune-common-2.2.1/debian/libdune-common-2.2.1.lintian-overrides dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-2.2.1.lintian-overrides --- dune-common-2.2.1/debian/libdune-common-2.2.1.lintian-overrides 2013-03-01 22:48:58.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-2.2.1.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -# I prefer libdune-common as the module is named dune-common upstream. -# -- ansgar 2012-03-01 -libdune-common-2.2.1: package-name-doesnt-match-sonames libdunecommon-2.2.1 diff -Nru dune-common-2.2.1/debian/libdune-common-dev.install dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-dev.install --- dune-common-2.2.1/debian/libdune-common-dev.install 2012-06-01 17:20:17.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-dev.install 2017-08-07 13:07:26.000000000 +0000 @@ -1,11 +1,8 @@ usr/bin usr/include -usr/lib/*/dunecontrol usr/lib -usr/lib/*/dunemodules.lib usr/lib -usr/lib/*/libdunecommon.a -usr/lib/*/libdunecommon.so -usr/lib/*/pkgconfig +usr/lib +usr/share/bash-completion usr/share/dune-common -usr/share/aclocal usr/share/dune +usr/share/dune debian/dune-debian.mk usr/share/dune diff -Nru dune-common-2.2.1/debian/libdune-common-dev.lintian-overrides dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-dev.lintian-overrides --- dune-common-2.2.1/debian/libdune-common-dev.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-dev.lintian-overrides 2017-08-07 13:07:26.000000000 +0000 @@ -0,0 +1,6 @@ +# We don't build a separate shared library package. +# See also https://lists.debian.org/debian-devel/2015/07/msg00115.html +libdune-common-dev: non-dev-pkg-with-shlib-symlink * +libdune-common-dev: package-name-doesnt-match-sonames * +# ABI is too unstable to warrant extra work with a symbols file +libdune-common-dev: no-symbols-control-file diff -Nru dune-common-2.2.1/debian/libdune-common-dev.manpages dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-dev.manpages --- dune-common-2.2.1/debian/libdune-common-dev.manpages 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-dev.manpages 2017-08-07 13:07:26.000000000 +0000 @@ -0,0 +1 @@ +doc/dunecontrol.1 diff -Nru dune-common-2.2.1/debian/libdune-common-doc.install dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-doc.install --- dune-common-2.2.1/debian/libdune-common-doc.install 2011-12-21 00:22:38.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-doc.install 2017-08-07 13:07:26.000000000 +0000 @@ -1 +1,2 @@ usr/share/doc/dune-common/* usr/share/doc/libdune-common-doc +build/doc/buildsystem/html usr/share/doc/libdune-common-doc/buildsystem diff -Nru dune-common-2.2.1/debian/libdune-common-doc.lintian-overrides dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-doc.lintian-overrides --- dune-common-2.2.1/debian/libdune-common-doc.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/libdune-common-doc.lintian-overrides 2017-08-07 14:41:18.000000000 +0000 @@ -0,0 +1,2 @@ +# see doxygen's /usr/share/doc/doxygen/README.jquery +libdune-common-doc: embedded-javascript-library usr/share/doc/libdune-common-doc/doxygen/jquery.js please use libjs-jquery diff -Nru dune-common-2.2.1/debian/patches/aclocal.patch dune-common-2.5.2~20170808ga5c076ca/debian/patches/aclocal.patch --- dune-common-2.2.1/debian/patches/aclocal.patch 2013-03-02 01:18:05.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/patches/aclocal.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ ---- a/bin/dune-autogen -+++ b/bin/dune-autogen -@@ -36,6 +36,10 @@ - ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $LIBTOOL_prefix/share/aclocal" - fi - -+if test -d "/usr/share/dune/aclocal"; then -+ ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I /usr/share/dune/aclocal" -+fi -+ - for OPT in "$@"; do - set +e - # stolen from configure... ---- a/bin/dunecontrol -+++ b/bin/dunecontrol -@@ -368,6 +368,9 @@ - if test -d "m4"; then - ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I m4" - fi -+ if test -d "/usr/share/dune/aclocal"; then -+ ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I /usr/share/dune/aclocal" -+ fi - MY_MODULES= - # get dependencies & suggestions - sort_modules $module diff -Nru dune-common-2.2.1/debian/patches/dune-autogen.patch dune-common-2.5.2~20170808ga5c076ca/debian/patches/dune-autogen.patch --- dune-common-2.2.1/debian/patches/dune-autogen.patch 2012-06-01 17:21:12.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/patches/dune-autogen.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ ---- dune-common.orig/bin/dune-autogen -+++ dune-common/bin/dune-autogen -@@ -27,7 +27,7 @@ - rm -f $name.m4 - - # add current dir to PATH --PATH=`dirname $0`:$PATH -+#PATH=`dirname $0`:$PATH - - # guess libtool prefix - if test -n "$LIBTOOLIZE"; then -@@ -125,6 +125,7 @@ - - # create a link to the dune-common am directory - if [ "$name" != "dune-common" ]; then -+ : ${am_dir:=/usr/share/dune-common/am} - if [ -n "$am_dir" ] && [ -d $am_dir ]; then - echo "--> linking dune-common/am..." - rm -f am diff -Nru dune-common-2.2.1/debian/patches/fix-PARSER_TRIM.diff dune-common-2.5.2~20170808ga5c076ca/debian/patches/fix-PARSER_TRIM.diff --- dune-common-2.2.1/debian/patches/fix-PARSER_TRIM.diff 2013-03-02 00:18:53.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/patches/fix-PARSER_TRIM.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ ---- a/lib/dunemodules.lib -+++ b/lib/dunemodules.lib -@@ -43,7 +43,7 @@ - # paramters: - # $1 file to read - # --PARSER_TRIM="awk '{gsub(/^[[:space:]]+| +$/,\"\");printf(\"%s\", \$0);}'" -+PARSER_TRIM="awk '{gsub(/^[ \\t]+|[ \\t]+$/,\"\");printf(\"%s\", \$0);}'" - parse_control() { - # check file existence - if test ! -f "$1" -o "$(basename $1)" != "$CONTROL"; then diff -Nru dune-common-2.2.1/debian/patches/rename-git-whitespace-hook.patch dune-common-2.5.2~20170808ga5c076ca/debian/patches/rename-git-whitespace-hook.patch --- dune-common-2.2.1/debian/patches/rename-git-whitespace-hook.patch 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/patches/rename-git-whitespace-hook.patch 2017-08-07 13:07:26.000000000 +0000 @@ -0,0 +1,40 @@ +From: Ansgar Burchardt +Subject: Rename git-whitespace-hook to dune-git-whitespace-hook. + +The name git-whitespace-hook is a bit too generic for a DUNE-specific +tool. + +--- a/bin/dunecontrol ++++ b/bin/dunecontrol +@@ -476,17 +476,28 @@ + fi + else + # standard handling of Git whitespace hook ++ for f in dune-git-whitespace-hook git-whitespace-hook; do ++ f="${PREFIX_DIR}/bin/${f}" ++ if [ -e "${f}" ]; then ++ git_whitespace_hook="${f}" ++ break ++ fi ++ done ++ if [ -z "${git_whitespace_hook:-}" ]; then ++ echo "Did not find git-whitespace-hook." >&2 ++ exit 1 ++ fi + if [ ! -e "$GITHOOKPATH" ]; then + # there is no hook yet, we can safely install ours + echo "--> Installing Git pre-commit hook to enforce whitespace policy" +- cp -p "$PREFIX_DIR/bin/git-whitespace-hook" "$GITHOOKPATH" ++ cp -p "${git_whitespace_hook}" "$GITHOOKPATH" + else + # there is already a hook, check whether it is our whitespace hook + local HOOKTAG="$(eval head -n 2 \"$GITHOOKPATH\" | tail -n 1)" + if [ "x$HOOKTAG" = "x# dune-git-whitespace-hook" ]; then +- if [ "$PREFIX_DIR/bin/git-whitespace-hook" -nt "$GITHOOKPATH" ]; then ++ if [ "${git_whitespace_hook}" -nt "$GITHOOKPATH" ]; then + echo "--> Updating Git pre-commit hook with newer version" +- cp -p "$PREFIX_DIR/bin/git-whitespace-hook" "$GITHOOKPATH" ++ cp -p "${git_whitespace_hook}" "$GITHOOKPATH" + fi + else + echo "WARNING: Existing pre-commit hook found!" diff -Nru dune-common-2.2.1/debian/patches/series dune-common-2.5.2~20170808ga5c076ca/debian/patches/series --- dune-common-2.2.1/debian/patches/series 2013-03-02 00:06:41.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/patches/series 2017-08-11 09:33:50.000000000 +0000 @@ -1,4 +1,3 @@ soname.patch -dune-autogen.patch -aclocal.patch -fix-PARSER_TRIM.diff +skip-dirs-starting-with-dot.patch +rename-git-whitespace-hook.patch diff -Nru dune-common-2.2.1/debian/patches/skip-dirs-starting-with-dot.patch dune-common-2.5.2~20170808ga5c076ca/debian/patches/skip-dirs-starting-with-dot.patch --- dune-common-2.2.1/debian/patches/skip-dirs-starting-with-dot.patch 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/debian/patches/skip-dirs-starting-with-dot.patch 2017-08-07 13:07:26.000000000 +0000 @@ -0,0 +1,13 @@ +From: Ansgar Burchardt +Subject: skip directories starting with a dot when looking for dune.module +--- a/lib/dunemodules.lib ++++ b/lib/dunemodules.lib +@@ -250,7 +250,7 @@ + while read m; do + test -n "$m" && parse_control "$m" + done < dune-foo.cc -doc -\end{lstlisting} - -You can now call \dunecontrol for your new project, as you would for any other \dune module. If you have a \texttt{config.opts}\xspace -file configured to your needs (see e.g. the ``Installation Notes'' on -\url{http://www.dune-project.org}), a simple call of - -\begin{lstlisting}[language=make] -./dune-common/bin/dunecontrol --module=dune-foo --opts=config.opts all -\end{lstlisting} -should call \autogen, \configure and \make for your -project and all modules your project depends on first. - -\begin{remark} -Always call \dunecontrol from the directory containing \dunecommon. -\end{remark} - -You can now simply run - -\begin{lstlisting}[language=make] -./dune-foo/src/dune-foo -\end{lstlisting} -which should produce something like - -\begin{lstlisting}[language=make] -Hello World! This is dune-foo. -This is a sequential program. -\end{lstlisting} - -If you want your \dune module to be usable by other people your -design should follow a certain structure. A good way to indicate that -your module is set up like the other \dune modules is by naming it -with the prefix \texttt{dune-}\xspace. Since your module should be -concerned with a certain topic, you should give it a meaningful name -(e.g. \dunegrid is about grids). You will also see that there are -subfolders \texttt{doc/}\xspace, \texttt{foo/}\xspace and -\texttt{src/}\xspace in \texttt{dune-foo/}\xspace. -\texttt{foo/}\xspace will contain any headers that are of interest to -other users (like the subfolder \texttt{common/}\xspace in -\dunecommon, \texttt{grid/}\xspace in \dunegrid, etc.). Other users -will have to include those files if they want to work with them. Let's -say your project provides some interface implementation in a file -\texttt{foo.hh}\xspace. \duneproject already put this an example file -into the subfolder \texttt{dune/foo/}. - -\begin{lstlisting}[language=make] -dune-foo/ --> configure.ac --> doc/ - -> doxygen/ - -> Doxylocal - -> Makefile.am - -> Makefile.am --> dune.module --> dune/ - -> foo/ - -> foo.hh - -> Makefile.am - -> Makefile.am --> Makefile.am --> README --> src/ - -> dune_foo.cc -\end{lstlisting} - -After running -\begin{lstlisting}[language=make] -make doc -\end{lstlisting} -in \texttt{dune-foo} you should now find a -\texttt{html} \texttt{doxygen} documentation which can be read by opening -\texttt{dune-foo/doc/doxygen/html/index.html}. - -\section{Dune module guidelines}\label{section::dune_module_guidelines} -\label{guidelines} - -A \dune module should comply with the following rules: -\begin{itemize} -\item Documentation is located under \texttt{doc/} and gets - web-installed under \texttt{BASEDIR/doc/}. -\item \automake includes are located in \dunecommon. To use them, you - will have to make a symbolic link to \texttt{dune-common/am/} (see - \ref{am_includes}). The symlink creation should be handled by the - \autogen (see~\ref{autogen}). -\item The \texttt{am/} directory does not get included in the tarball. -\item Additional configure tests are located in the \texttt{m4/} - directory. You should at least provide the macros \texttt{\emph{MODULE}\_CHECKS} - and \texttt{\emph{MODULE}\_CHECK\_MODULE}, in order to setup and - find your module (see~\ref{m4files}). -\item Header files should be accessible via \verb!#include !, - otherwise they cannot be used by other \dune modules. In order to work - with a freshly checkout version of your module you will usually need - to create a local symbolic link \texttt{dune -> - \textit{module-directory/}}. This link gets created by the - \texttt{DUNE\_SYMLINK} command in your \configureac. When running - \texttt{make install} all header files should be installed into - \texttt{\textit{prefix}/include/dune/}. -\end{itemize} - -\section{The Structure of \dune} -\dune consists of several independent modules: -\begin{itemize} -\item \dunecommon -\item \dunegrid -\item \duneistl -\item \dunegridhowto -\item \dunegriddevhowto -\end{itemize} - -Single modules can depend on other modules and so the \dune modules -form a dependency graph. The build system has to track and resolve -these inter-module dependencies. - -The build system is structured as follows: -\begin{itemize} -\item Each module is built using the GNU AutoTools. -\item Each module has a set of modules it depends on, these modules - have to be built before building the module itself. -\item Each module has a file \dunemodule which holds dependencies and - other information regarding the module. -\item The modules can be built in the appropriate order using the - \dunecontrol script (shipped with \dunecommon) -\end{itemize} - -The reasons to use the GNU AutoTools for \dune were the following -\begin{itemize} -\item We need platform independent build. -\item Enabling or disabling of certain features depending on - features present on the system. -\item Creations of libraries on all platforms. -\item Easy creation of portable but flexible Makefiles. -\end{itemize} - -The reasons to add the \dunecontrol script and the \dunemodule -description files were -\begin{itemize} -\item One tool to setup all modules (the AutoTools can only work on one - module). -\item Automatic dependency tracking. -\item Automatic collection of command-line parameters (\configure needs - special command-line parameters for all modules it uses) -\end{itemize} - -\section{Building Single Modules Using the GNU AutoTools} - -Software is generally developed to be used on multiple -platforms. Since each of these platforms has different compilers, -different header files, there is a need to write makefiles and build -scripts that work on a variety of platforms. The Free -Software Foundation (FSF), faced with this problem, devised a -set of tools to generate makefiles and build scripts that work on a -variety of platforms. These are the GNU AutoTools. -If you have downloaded and built any GNU -software from source, you are familiar with the \configure script. The -\configure script runs a series of tests to get information about -your machine. - -The autotools simplify the generation of portable Makefiles and -configure scripts. - -\minisec{autoconf} - -\autoconf is used to create the \configure script. \configure is -created from \configureac, using a set of \texttt{m4} files. - -\begin{center} - \begin{tikzpicture}[scale=0.05,line width=1pt,rounded corners=8pt] - \draw (-2,2) node [anchor=south] {\configureac} - -- (-2,-2) -- (67.5,-2) -- (67.5,-6); - \draw (137,2) node [anchor=south] {\tt{}m4/*.m4} - -- (137,-2) -- (67.5,-2) -- (67.5,-6); - \draw[->] (67.5,-5.5) - -- (67.5,-10) node [anchor=west] {\textit{\autoconf}} - -- (67.5,-20) node [anchor=north] {\configure}; - \end{tikzpicture} -\end{center} - -How to write a \configureac for \dune is described in Sec.\,\ref{configure.ac}. - -\minisec{automake} - -\automake is used to create the \makefilein files (needed for -\configure) from \makefileam files, using a set of include files -located in a directory called \texttt{am}. These include files provide -additional features not provided by the standard \automake (see -Sec.\,\ref{am_includes}). The \texttt{am} directory is in the \dunecommon -module and each module intending to use one of these includes has to -have a symlink \texttt{am} that points to \texttt{dune-common/am}. -This link is usually created by \autogen (see Sec.\,\ref{autogen}). - -\begin{center} - \begin{tikzpicture}[scale=0.05,line width=1pt,rounded corners=8pt] - \draw (-2,2) node [anchor=south] {\makefileam} - -- (-2,-2) -- (67.5,-2) -- (67.5,-6); - \draw (137,2) node [anchor=south] {\tt{}am/*} - -- (137,-2) -- (67.5,-2) -- (67.5,-6); - \draw[->] (67.5,-5.5) - -- (67.5,-10) node [anchor=west] {\textit{\automake}} - -- (67.5,-20) node [anchor=north] {\texttt{Makefile.in}}; - \draw[dashed, ->] (67.5,-30) - -- (67.5,-37) node [anchor=west] {\textit{\configure}} - -- (67.5,-44) node [anchor=north] {\texttt{Makefile}}; - \end{tikzpicture} -\end{center} - -Information on writing a \makefileam is described in \ref{makefile.am} - -\minisec{libtool} -\libtool is a wrapper around the compiler and -linker. It offers a generic interface for creating static and shared -libraries, regardless of the platform it is running on. - -\libtool hides all the platform specific aspects of library creation -and library usage. When linking a library or an executable you (or -\automake) can call the compiler via \libtool. \libtool will then take -care of -\begin{itemize} -\item platform specific command-line parameters for the linker, -\item library dependencies. -\end{itemize} - -\minisec{configure} -\label{configure} -\configure will run the set of tests specified in your \configureac. -Using the results of these tests configure can check that all -necessary features (libraries, programs, etc.) are present and can activate -and deactivate certain features of the module depending on what is -available on your system. - -For example \configure in \dunegrid will search for the ALUGrid -library and enable or disable \texttt{Dune::ALU3dGrid}. -This is done by writing a preprocessor macro \verb!#define HAVE_ALUGRID! -in the \texttt{config.h} -header file. A header file can then use an \verb!#ifdef! statement to -disable parts of the code that do not work without a certain -feature. This can be used in the applications as well as in the headers -of a \dune module. - -The \texttt{config.h} file is created by \configure from a -\texttt{config.h.in} file, which is automatically created from the -list of tests used in the \configureac. - -\subsection{Makefile.am} -\label{makefile.am} - -\subsubsection{Overview} - -Let's start off with a simple program \executable{hello} built from -\texttt{hello.c}. As \automake is designed to build and install a -package it needs to know - -\begin{itemize} -\item what programs it should build, -\item where to put them when installing, -\item which sources to use. -\end{itemize} - -The core of a \makefileam thus looks like this: - -\begin{lstlisting}[language=make] -noinst_PROGRAMS = hello -hello_SOURCES = hello.c -\end{lstlisting} - -This would build \executable{hello} but not install it when \texttt{make - install} is called. Using \verb!bin_PROGRAMS! instead of -\verb!noinst_PROGRAMS! would install the \executable{hello}-binary into a -\texttt{\textit{prefix}/bin} directory. - -Building more programs with several source files works like this - -\begin{lstlisting}[language=make] -noinst_PROGRAMS = hello bye - -hello_SOURCES = common.c common.h hello.c -bye_SOURCES = common.c common.h bye.c parser.y lexer.l -\end{lstlisting} - -\automake has more integrated rules than the standard make, the example -above would automatically use yacc/lex to create -\texttt{parser.c/lexer.c} and build them into the {\em bye} binary. - -Make-Variables may be defined and used as usual: - -\begin{lstlisting}[language=make] -noinst_PROGRAMS = hello bye - -COMMON = common.c common.h - -hello_SOURCES = $(COMMON) hello.c -bye_SOURCES = $(COMMON) bye.c parser.y lexer.l -\end{lstlisting} - -Even normal make-rules may be used in a \makefileam. - -\minisec{Using flags} - -Compiler/linker/preprocessor-flags can be set either globally: - -\begin{lstlisting}[language=make] -noinst_PROGRAMS = hello bye - -AM_CPPFLAGS = -DDEBUG - -hello_SOURCES = hello.c -bye_SOURCES = bye.c -\end{lstlisting} - -or locally: - -\begin{lstlisting}[language=make] -noinst_PROGRAMS = hello bye - -hello_SOURCES = hello.c -hello_CPPFLAGS = -DHELLO - -bye_SOURCES = bye.c -bye_CPPFLAGS = -DBYE -\end{lstlisting} - -The local setting overrides the global one, thus - -\begin{lstlisting}[language=make] -hello_CPPFLAGS = $(AM_CPPFLAGS) -Dmyflags -\end{lstlisting} -%$\end{lstlisting} - -may be a good idea. - -It is even possible to compile the same sources with different flags: - -\begin{lstlisting}[language=make] -noinst_PROGRAMS = hello bye - -hello_SOURCES = generic-greeting.c -hello_CPPFLAGS = -DHELLO - -bye_SOURCES = generic-greeting.c -bye_CPPFLAGS = -DBYE -\end{lstlisting} - -Perhaps you're wondering why the above examples used -\texttt{AM\_CPPFLAGS} instead of normal \texttt{CPPFLAGS}? The -reason for this is that the variables \texttt{CFLAGS}, -\texttt{CPPFLAGS}, \texttt{CXXFLAGS} etc. are considered {\em user - variables} which may be set on the command line: - -\begin{lstlisting}[language=make] -make CXXFLAGS="-O2000" -\end{lstlisting} - -This would override any settings in Makefile.am which might be -necessary to build. Thus, if the variables should be set even if the -user wishes to modify the values, you should use the \texttt{AM\_*} -version. - -The real compile-command always uses both \texttt{AM\_\textit{VAR}} and -\texttt{\textit{VAR}} (or \texttt{\texttt{progname}\_\textit{VAR}} and -\texttt{\textit{VAR}}). Options that -autoconf finds are stored in the user variables (so that they may be -overridden). - -Besides the three types of variables mentioned so far (user-, automake- and -program-variables) there exists a fourth type by convention: variables of -dependent libraries. These variables have the form -\texttt{\textit{LIBRARY}\_\textit{VAR}} and contain flags necessary to build -programs or libraries which depend on that library. They are usually included -in \texttt{\textit{program}\_\textit{VAR}}, like this: -\begin{lstlisting}[language=make] -foo_CPPFLAGS = $(AM_CPPFLAGS) $(SUPERLU_CPPFLAGS) -\end{lstlisting} -If all programs build by the same makefile depend on a library, -\texttt{\textit{program}\_\textit{VAR}} can be included in -\texttt{AM\_\textit{VAR}} instead: -\begin{lstlisting}[language=make] -AM_CPPFLAGS = @AM_CPPFLAGS@ $(SUPERLU_CPPFLAGS) -\end{lstlisting} -%$\end{lstlisting} - -There are five classes of variables in automake-generated makefiles: -\begin{description} -\item[automake] Example: \texttt{AM\_CPPFLAGS}. These variables are usually - undefined by default and the developer may assign them default values in the - \texttt{Makefile.am}: - \begin{lstlisting}[language=make] -AM_CPPFLAGS = -DMY_DIR=`pwd` - \end{lstlisting} - {\bf Automake} variables are not automatically substituted by - \texttt{configure}, though it is common for the developer to - \lstinline[language=make]{AC_SUBST} them. In this case a different - technique must be used to assign values to them, or the substituted value - will be ignored. See the {\bf configure-substituted} class below. The - names of {\bf automake} variables begin with \texttt{AM\_} most of the time, - but there are some variables which don't have that prefix. These variables - give defaults for {\bf target-specific} variables. -\item[configure-substituted] Example: \lstinline[language=make]{srcdir}. - Anything can be made a {\bf configure-substituted} variable by calling - \lstinline[language=sh]{AC_SUBST} in \texttt{configure.ac}. Some - variables always substituted by autoconf\footnote{autoconf manual, section - ``Preset Output Variables''} or automake, others are only substituted when - certain autoconf macros are used. In Dune, it is quiet common to substitute - {\bf automake} variables: - \begin{lstlisting}[language=sh] -AC_SUBST(AM_CPPFLAGS, $DUNE_CPPFLAGS) - \end{lstlisting} - %$\end{lstlisting} - The value substituted by \texttt{configure} can be augmented in the - \texttt{Makefile.am} like this: - \begin{lstlisting}[language=make] -AM_CPPFLAGS = @AM_CPPFLAGS@ -DMY_DIR=`pwd` - \end{lstlisting} -\item[target-specific] Example: \texttt{\textit{target}\_CPPFLAGS}. The names - of these variables are of the form canonical target name followed by an - underscore followed some uppercase letters. If there is a {\bf automake} - variable corresponding to this {\bf target-specific} variable, the uppercase - letters at the end of the name usually correspond to the name of that {\bf - automake} variable. These variables provide target-specific information. - They are defined by the developer in the \texttt{Makefile.am} and are - documented in the automake manual. If there is corresponding a {\bf - automake} variable it provides a default which is used when the {\bf - target-specific} variable is not defined. Example definition: - \begin{lstlisting}[language=make] -false_SOURCES = true.c -false_CPPFLAGS = $(AM_CPPFLAGS) -DEXIT_CODE=1 - \end{lstlisting} - %$\end{lstlisting} - This example also shows how to include the value of the corresponding {\bf - automake} variable. -\item[user] Example: \texttt{CPPFLAGS}. These variables are for the user to - set on the make command line: - \begin{lstlisting}[language=sh] -make CPPFLAGS=-DNDEBUG - \end{lstlisting} - They usually augment some {\bf target-specific} or {\bf makefile-default} - variable in the build rules. Often these variables are {\em - precious}\footnote{autoconf manual, - \lstinline[language=sh]{AC_ARG_VAR}}, and the user can tell - \texttt{configure} what values these variables should have. These variables - are {\bf configure-substituted}. - - The developer should never set this - variables in the \texttt{Makefile.am}, because that would override the - user-provided values given to configure. Instead, \texttt{configure.ac} - must be tweaked to set a different default if the user does not give a value - to \texttt{configure}. -\item[external-library] Example: \texttt{\textit{LIB}CPPFLAGS}. These - variables contain settings needed when using external libraries in a - target. They should be included in the value for the corresponding {\bf - target-specific} variable - \begin{lstlisting}[language=make] -testprog_CPPFLAGS = $(AM_CPPFLAGS) $(SUPERLUCPPFLAGS) - \end{lstlisting} - or the {\bf makefile-default} variable - \begin{lstlisting}[language=make] -AM_CPPFLAGS = @AM_CPPFLAGS@ $(SUPERLUCPPFLAGS) - \end{lstlisting} - %$\end{lstlisting} - Values for these variables are determined by \texttt{configure}, thus they - are {\bf configure-substituted}. Usually, - \texttt{configure.ac} must call the right autoconf macro to determine these - variables. - - Note that the variable name with an underscore - \texttt{\textit{LIB}\_CPPFLAGS} is not recommended\footnote{Autoconf - manual, section ``Flag Variables Ordering''}, although this pattern is - common. -\end{description} - -Commonly used variables are: -\begin{description} -\item[preprocessor flags] These flags are passed in any build rule that calls - the preprocessor. If there is a {\bf target-specific} variable - \texttt{\textit{target}\_CPPFLAGS} defined, the flags are given by -\begin{lstlisting}[language=make] -$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(target_CPPFLAGS) $(CPPFLAGS) -\end{lstlisting} - %$\end{lstlisting} - otherwise -\begin{lstlisting}[language=make] -$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -\end{lstlisting} - %$\end{lstlisting} - is used. - \begin{description} - \item[\texttt{DEFS}] Class: {\bf configure-substituted}. Contains all the - preprocessor defines from \lstinline[language=sh]{AC_DEFINE} and friends. - If a \texttt{config.h} header is used, contains just the value - \texttt{-DHAVE\_CONFIG\_H} instead. - \item[\texttt{DEFAULT\_INCLUDES}] Class: {\bf configure-substituted}. This - variables contains a set of default include paths: \texttt{-I.}, - \texttt{-I\$(srcdir)}, and an path to the directory of \texttt{config.h}, - if that is used. - \item[\texttt{INCLUDES}] Class: {\bf automake}. This is an obsolete - alternative to \texttt{AM\_CPPFLAGS}. Use that instead. - \item[\texttt{\textit{target}\_CPPFLAGS}] Class: {\bf target-specific}. - Target-specific preprocessor flags. If this variable exists, it overrides - \texttt{AM\_CPPFLAGS} and causes the renaming of object - files\footnote{automake manual, ``Why are object files sometimes - renamed?''}. - \item[\texttt{AM\_CPPFLAGS}] Class: {\bf automake}. This is the makefile - default for any preprocessor flags. - \item[\texttt{CPPFLAGS}] Class: {\bf user}, {\bf configure-substituted}. - Flags given by the user, either to \texttt{configure} or when invoking - \texttt{make}. If the user didn't provide any value to - \texttt{configure}, it may contain debugging and optimization options per - default (like \texttt{-DNDEBUG}). The value of \texttt{CPPFLAGS} always - appears after the other preprocessor flags. - \item[\texttt{\textit{LIB}CPPFLAGS}] Class: {\bf external-library}. - Preprocessor flags when building with library \textit{LIB}. This variable - should be include in \texttt{\textit{target}\_CPPFLAGS} or - \texttt{AM\_CPPFLAGS} in the \texttt{Makefile.am}. - \end{description} - -\item[C-compiler flags] These flags are passed in any build rule that calls - the C compiler or the C linker. If there is a {\bf target-specific} - variable \texttt{\textit{target}\_CFLAGS} defined, the flags are given by -\begin{lstlisting}[language=make] -$(target_CFLAGS) $(CFLAGS) -\end{lstlisting} - otherwise -\begin{lstlisting}[language=make] -$(AM_CFLAGS) $(CFLAGS) -\end{lstlisting} - is used. - \begin{description} - \item[\texttt{\textit{target}\_CFLAGS}] Class: {\bf target-specific}. - Target-specific C compiler flags. If this variable exists, it overrides - \texttt{AM\_CFLAGS} and causes the renaming of object - files\footnote{automake manual, ``Why are object files sometimes - renamed?''}. - \item[\texttt{AM\_CFLAGS}] Class: {\bf automake}. This is the makefile - default for any C compiler flags. - \item[\texttt{CFLAGS}] Class: {\bf user}, {\bf configure-substituted}. - Flags given by the user, either to \texttt{configure} or when invoking - \texttt{make}. If the user didn't provide any value to - \texttt{configure}, it may contain debugging, optimization and warning - options per default (like \texttt{-g -O2 -Wall}). The value of - \texttt{CFLAGS} always appears after the other C compiler flags. - \end{description} - -\item[C++-compiler flags] These flags are passed in any build rule that calls - the C++ compiler or the C++ linker. If there is a {\bf target-specific} - variable \texttt{\textit{target}\_CXXFLAGS} defined, the flags are given by -\begin{lstlisting}[language=make] -$(target_CXXFLAGS) $(CXXFLAGS) -\end{lstlisting} - otherwise -\begin{lstlisting}[language=make] -$(AM_CXXFLAGS) $(CXXFLAGS) -\end{lstlisting} - is used. - \begin{description} - \item[\texttt{\textit{target}\_CXXFLAGS}] Class: {\bf target-specific}. - Target-specific C++ compiler flags. If this variable exists, it overrides - \texttt{AM\_CXXFLAGS} and causes the renaming of object - files\footnote{automake manual, ``Why are object files sometimes - renamed?''}. - \item[\texttt{AM\_CXXFLAGS}] Class: {\bf automake}. This is the makefile - default for any C++ compiler flags. - \item[\texttt{CXXFLAGS}] Class: {\bf user}, {\bf configure-substituted}. - Flags given by the user, either to \texttt{configure} or when invoking - \texttt{make}. If the user didn't provide any value to - \texttt{configure}, it may contain debugging, optimization and warning - options per default (like \texttt{-g -O2 -Wall}). The value of - \texttt{CXXFLAGS} always appears after the other C++ compiler flags. - \end{description} - -\item[linker flags] These flags are passed in any build rule that calls the - linker. If there is a {\bf target-specific} variable - \texttt{\textit{target}\_LDFLAGS} defined, the flags are given by -\begin{lstlisting}[language=make] -$(target_LDFLAGS) $(LDFLAGS) -\end{lstlisting} - otherwise -\begin{lstlisting}[language=make] -$(AM_LDFLAGS) $(LDFLAGS) -\end{lstlisting} - is used. These variables are inappropriate to pass any options or parameters - that specify libraries of object files, in particular \texttt{-L} or - \texttt{-l} or the libtool options \texttt{-dlopen} and \texttt{-dlpreopen}. - Use a variable from the {\em libraries to link to} set to do that. - \begin{description} - \item[\texttt{\textit{target}\_LDFLAGS}] Class: {\bf target-specific}. - Target-specific C++ compiler flags. If this variable exists, it overrides - \texttt{AM\_LDFLAGS}. The existence of this variable does {\em not} cause - renaming of object files\footnote{automake manual, ``Why are object files - sometimes renamed?''}. - \item[\texttt{AM\_LDFLAGS}] Class: {\bf automake}. This is the makefile - default for any linker flags. - \item[\texttt{LDFLAGS}] Class: {\bf user}, {\bf configure-substituted}. - Flags given by the user, either to \texttt{configure} or when invoking - \texttt{make}. If the user didn't provide any value to - \texttt{configure}, it may contain debugging, optimization and warning - options per default. The value of \texttt{LDFLAGS} always appears after - the other linker flags. - \item[\texttt{\textit{LIB}LDFLAGS}] Class: {\bf external-library}. Linker - flags needed when linking to library \textit{LIB}. This variable should - be include in \texttt{\textit{target}\_LDFLAGS} or \texttt{AM\_LDFLAGS} in - the \texttt{Makefile.am}. - \end{description} - -\item[libraries to link to] These variables are used to determine the - libraries and object files to link to. They are passed whenever the linker - is called. When - linking a program, extra libraries and objects to link to are given by - \begin{lstlisting}[language=make] -$(target_LDADD) $(LIBS) - \end{lstlisting} - If the {\bf target-specific} variable \texttt{\textit{target}\_LDADD} is not - defined, automake supplies - \begin{lstlisting}[language=make] -target_LDADD = $(LDADD) - \end{lstlisting} - %$\end{lstlisting} - When linking a library, extra libraries and objects to link to are given by - \begin{lstlisting}[language=make] -$(target_LIBADD) $(LIBS) - \end{lstlisting} - If the {\bf target-specific} variable \texttt{\textit{target}\_LIBADD} is - not defined, automake defines it empty - \begin{lstlisting}[language=make] -target_LIBADD = - \end{lstlisting} - Libraries and objects to link to must be given in reverse order: a library - or object file must come before the libraries or object files it depends on - on the linker command line. Thus the value of the \texttt{LIBS} variable is - included after the value of the \texttt{\textit{target}\_LDADD} or - \texttt{\textit{target}\_LIBADD} variable. - - In general, any linker flags and argument that specify libraries and object - files should be included in these variables, and nothing else. In - particular that means library and object file names, the options \texttt{-L} - and \texttt{-l}, and the libtool options \texttt{-dlopen} and - \texttt{-dlpreopen}. The option \texttt{-L} should come directly before any - \texttt{-l} options it sets the linker path for, otherwise a path set by - another \texttt{-L} option may take precedence, which may happen to contain - a library by the same name. - \begin{description} - \item[\texttt{\textit{target}\_LDADD}] Class: {\bf target-specific}. - Target-specific libraries and objects to link to {\em for programs}. If - this variable does not exist, it defaults to \texttt{\$(LDADD)}. - \item[\texttt{LDADD}] Class: {\bf automake}. Libraries and objects - to link to {\em for programs}. Default for - \texttt{\textit{target}\_LDADD}. - \item[\texttt{\textit{target}\_LIBADD}] Class: {\bf target-specific}. - Target-specific objects to link to {\em for libraries}. If the target is - a libtool library, then other libtool libraries may also be specified - here. This variable has no makefile-wide default, if it does not exist - the empty value is assumed. - \item[\texttt{LIBS}] Class: {\bf automake}, {\bf configure-substituted}. - Libraries discovered by configure. - \item[\texttt{\textit{LIB}LIBS}] Class: {\bf external-library}. Libraries - and object files needed to linking against library \textit{LIB}, including - that library itself. This variable should be include in - \texttt{\textit{target}\_LDADD}, \texttt{LDADD}, or - \texttt{\textit{target}\_LIBADD} in the \texttt{Makefile.am}. - \end{description} -\end{description} - -\minisec{Individual library variables} - -\begin{description} -\item[MPI] The \texttt{DUNE\_MPI} macro sets the following variables with the - help of the macros \texttt{MPI\_CONFIG} and \texttt{ACX\_MPI}: For - compilation with the MPI compiler \texttt{MPICC} and \texttt{MPILIBS}. - These are not used in \dune except that \texttt{MPICC} may be set on the - configure command line to select which MPI installation to use. For - compilation with the standard compiler it sets \texttt{DUNEMPICPPFLAGS}, - \texttt{DUNEMPILDFLAGS} and \texttt{DUNEMPILIBS}, and the deprecated - variables \texttt{MPI\_CPPFLAGS} and \texttt{MPI\_LDFLAGS} (note there is no - \texttt{MPI\_LIBS}). Unfortunately with most MPI implementations it is - impossible to obtain the linker flags separately from the libraries to link - to. Therefore, this macro stuffs everything into \texttt{DUNEMPILIBS}, - which has the advantage that it works and the disadvantage that users are - unable to overwrite the linker flags. If that is a problem users should set - these variables themselves on the configure command line. - - In addition, this macro substitutes \texttt{MPI\_VERSION} a text string - identifying the detected version of MPI. It defines the following - preprocessor defines: \texttt{MPI\_2}, defined if the detected MPI supports - the MPI-2 standard. \texttt{HAVE\_MPI}, 1 if MPI is detected and enabled. - It also defines the automake conditional \texttt{MPI}. -\item[\dune modules] For each \dune module there are the variables - \texttt{\textit{MODULE}\_CPPFLAGS}, \texttt{\textit{MODULE}\_LDFLAGS} and - \texttt{\textit{MODULE}\_LIBS}. They contain everything to use that module - with its most basic functionality. For instance, for \texttt{dune-grid} - they do not contain the stuff for MPI, Alberta, ALU Grid or UG, even if - those were detected. They do contain the stuff for \texttt{dune-common}, - possibly with duplicates removed, since that is absolutely required for the - operation of \texttt{dune-grid}. Example use: - \begin{lstlisting}[language=make] -foo_SOURCES = foo.cc -foo_CPPFLAGS = $(AM_CPPFLAGS) \ - $(UG_CPPFLAGS) \ - $(DUNE_GRID_CPPFLAGS) -foo_LDFLAGS = $(AM_LDFLAGS) \ - $(UG_LDFLAGS) \ - $(DUNE_GRID_LDFLAGS) -foo_LDADD = \ - $(DUNE_GRID_LIBS) \ - $(UG_LIBS) \ - $(LDADD) - \end{lstlisting} - %$\end{lstlisting} - Note that there are no such variables for the current module -- these - variables are used in the process of building the current module, so that - module is incomplete when detecting these variables. Note also that by - ``\dune module'' we mean a software package which uses the \dune - build system, not one of the official dune modules. -\item[Basic \dune] To use the basic functionality of all detected \dune - modules, the variables \texttt{DUNE\_CPPFLAGS}, \texttt{DUNE\_LDFLAGS} and - \texttt{DUNE\_LIBS} may be used. They collect the contents of all \dune - module variables, possibly with duplicates removed. -\item[Extended \dune] To use \dune with all functionality that requires - external libraries, the variables \texttt{ALL\_PKG\_CPPFLAGS}, - \texttt{ALL\_PKG\_LDFLAGS} and \texttt{ALL\_PKG\_LIBS} may be used. They - provide everything necessary to build with any external library detected by - configure. In the case of Alberta a choice must be made between 2D and 3D. - Here the \texttt{ALL\_PKG\_*} variables just follow the choice of the - corresponding \texttt{ALBERTA\_*} variables. -\end{description} - -\minisec{Conditional builds} - -Some parts of \dune only make sense if certain add-on packages were -found. autoconf therefore defines {\em conditionals} which automake can -use: - -\begin{lstlisting}[language=make] -if OPENGL - PROGS = hello glhello -else - PROGS = hello -endif - -hello_SOURCES = hello.c - -glhello_SOURCES = glhello.c hello.c -\end{lstlisting} - -This will only build the {\em glhello} program if OpenGL was found. An -important feature of these conditionals is that they work with any -make program, even those without a native {\em if} construct like GNU-make. - -\minisec{Default targets} - -An automake-generated Makefile does not only know the usual {\em all}, -{\em clean} and {\em install} targets but also -\begin{description} -\item [tags] travel recursively through the directories and create - TAGS-files which can be used in many editors to quickly find where - symbols/functions are defined (use emacs-format) -\item [ctags] the same as "tags" but uses the vi-format for the tags-files -\item [dist] create a distribution tarball -\item [check] run a set of regression tests -\item [distcheck] create a tarball and do a test-build if it really works -\end{description} - -\subsubsection{Building Documentation} -\label{am_includes} - -If you want to build documentation you might need additional make -rules. \dune offers a set of predefined rules to create certain kinds -of documentation. Therefor you have to include the appropriate rules -from the \texttt{am/} directory. These rules are stored in the -\texttt{dune-common/am/} directory. If you want to use these any of -these rules in your \dune module or application you will have to -create a symbolic link to \texttt{dune-common/am/}. The creation of -this link should be done by the \autogen script. - -The build system automatically gives you two targets related to the documentation: -\begin{description} - \item [doc] make the documentation, - \item [doc-clean] clean up all documentation-related stuff. -\end{description} - - -\minisec{doxygen} - -The source code documentation system \texttt{doxygen}\xspace is the -preferable way to document your source and header files. - -In order to build \texttt{doxygen} documentation you can include -\texttt{\$(top\_srcdir)/am/doxygen}. Additionally you have create a -file \texttt{Doxylocal} which contains your local \texttt{doxygen} -configuration. - -Your \texttt{doxygen} documentation should be located in the -subdirectory \texttt{doc/doxygen/}\xspace (see ``Coding Style'' in the -section ``Developing Dune'' on -\url{http://www.dune-project.org/} for details). \em After -running \duneproject the basic setup is already done\em. - -You should only have one \texttt{doxygen} directory and the files are -automatically installed into\\ -\texttt{\$prefix/share/doc/\$modulename/doxygen/}. If for any reason -you really have to change the installation path you can set the -variable \texttt{doxygendir} \em after \em including \texttt{am/doxygen}. - -The file \texttt{doc/doxygen/Doxylocal}\xspace contains the basic -information where header and source files are located in your -project. Usually you will not have to adjust this file, it is already -created by \duneproject. It only -contains the very basic information. During the \texttt{dune-autogen}\xspace -run the script \texttt{dunedoxynize}\xspace uses the information contained in -\texttt{Doxylocal}, merges them with the global \dune \texttt{doxygen}\xspace -styles and writes \texttt{Doxyfile.in}, which will be translated into a -full \texttt{Doxyfile}\xspace during the \configure run. For details about -the configuration of \texttt{doxygen}\xspace and about documenting your -source code we refer to the \texttt{doxygen}\xspace web-site -\url{http://www.doxygen.org/}. - -\minisec{html pages} -Webpages are created from wml sources, using the program \texttt{wml} -(\url{http://thewml.org/}).\\ -\texttt{\$(top\_srcdir)/am/webstuff} contains the necessary rules. - -Add all \texttt{html} files to the \texttt{PAGES} variable to build -and install them. - -\hspace*{-2ex}\begin{minipage}{\textwidth} -\begin{lst}[File Makefile.am] \mbox{} -\lstinputlisting[language=make]{../Makefile.am} -\end{lst} -\end{minipage} - -\minisec{\LaTeX documents} -In order to compile \LaTeX documents you can include -\texttt{\$(top\_srcdir)/am/latex}. This way you get rules for creation -of DVI files, PS files and PDF files. - -\minisec{SVG graphics} -SVG graphics can be converted to png, in order to include them into -the web page. This conversion can be done using inkscape -(\url{http://www.inkscape.org/}). -\texttt{\$(top\_srcdir)/am/inkscape.am} offers the necessary rules. - -\subsubsection{Automatic testing} - -Dune offers several special \make targets, which help you find problems -in your build system configuration, or in your code. - -\begin{description} -\item[check] You can define lists of regression tests in your - \makefileam. These are run when you call \texttt{make check}. -\item[distcheck] This target is already defined by automake. It - creates a tarball, unpacks it, tries to do an out-of-source build - and runs the regression tests against this build. -\item[sourcescheck] This target tries to make sure that you don't - forget to install any important headers or source files. -\item[headercheck] This target tries to make sure that your header - files can be parsed and are self-contained. -\end{description} - -\minisec{The check target} - -TODO\dots{} - -\minisec{The sourcescheck target} - -TODO\dots{} - -\minisec{The headercheck target} - -TODO\dots{} - -\subsection{configure.ac} -\label{configure.ac} - -\configureac is a normal text file that contains several \autoconf -macros. These macros are evaluated by the \texttt{m4} macro processor -and transformed into a shell script. - -\begin{lst}[File dune-common/configure.ac] \mbox{} -\lstinputlisting{../../configure.ac} -\end{lst} - -We offer a set of macros that can be used in your \configureac: - -\begin{itemize} -\item \texttt{DUNE\_CHECK\_ALL} - runs all checks usually needed by a {\em \dune module}. - It checks for all dependencies and suggestions and for their - prerequisites. - In order to make the dependencies known to \configure \autogen calls - \texttt{dunecontrol m4create} and write a file - \texttt{dependencies.m4}. -\item \texttt{DUNE\_SYMLINK} - creates symlink \texttt{\$(top\_srcdir)/dune} $\!\rightarrow$ - \texttt{\$(top\_srcdir)}. The programming guidelines (\ref{guidelines}) - require that the include statements be like \texttt{\#include - }. If your module has a directory structure - \texttt{\topsrc/foo}, you will need such a link. However, you are - encouraged to store the files directly in a directory structure - \texttt{\topsrc/dune/foo} in order to avoid any inconvenience when - copying the files. This will also eliminate the necessity for - \texttt{DUNE\_SYMLINK}. -\item \texttt{DUNE\_AUTOBUILD\_FLAGS} - adds configure flags needed to create log files for - \texttt{dune-autobuild}. If you want to add your module to the - \texttt{dune-autobuild} system, you have to call this macro. -\item \texttt{DUNE\_SUMMARY\_ALL} - prints information on the results of all major checks run by - \texttt{DUNE\_CHECK\_ALL}. -\end{itemize} - -\texttt{DUNE\_CHECK\_ALL} defines the following -variables that can be used in the \configure script or in the -\makefileam: - -\begin{itemize} -\item \texttt{DUNE\textit{\,MODULE\,}\_CPPFLAGS} -\item \texttt{DUNE\textit{\,MODULE\,}\_LDFLAGS} -\item \texttt{DUNE\textit{\,MODULE\,}\_LIBS} -\item \texttt{DUNE\textit{\,MODULE\,}ROOT} -\end{itemize} - -The last step to a complete \configureac is that you tell \autoconf -which files should be generated by \configure. Therefore you add an -\texttt{AC\_CONFIG\_FILES([\textit{WhiteSpaceSeparatedListOfFiles}])} -statement to your \configureac. The list of files should be the list -of files that are to be generated, not the input---i.e. you would -write -\begin{lstlisting}[language=make] -AC_CONFIG_FILES([Makefile doc/Makefile]) -\end{lstlisting} -instead of -\begin{lstlisting}[language=make] -AC_CONFIG_FILES([Makefile.in doc/Makefile.in]) -\end{lstlisting} -After you told \autoconf which files to create you have to actually -trigger their creation with command \texttt{AC\_OUTPUT}. - -\subsection{Using configuration information provided by configure} - -The \lstinline!./configure! script in the module produces a file -\lstinline!config.h!\ that contains information about the configuration -parameters, for example which of the optional grid implementations is -available and which dimension has been selected (if applicable). This -information can then be used at compile-time to include header files -or code that depend on optional packages. - -As an example, the macro \lstinline!HAVE_ARRAY!\ can be used to compile -code using C++11 arrays as in -\begin{lstlisting}[basicstyle=\ttfamily\scriptsize] -#ifdef HAVE_ARRAY -#include -std::array a = {1, 2, 3}; -#endif -\end{lstlisting} - -In some cases the macro \lstinline!HAVE_!\ is set to -\lstinline!ENABLE_!. In this case \lstinline!ENABLE_! is -supposed to be either \texttt{false} or \texttt{true}. It might be -undefined which is equivalent to \texttt{false}. Thus the correct usage -is \lstinline!#if HAVE_!\ instead of \lstinline!#ifdef HAVE_!. -The macro \lstinline!ENABLE_!\ is not intended for the user. It -is a trick to move the final definition of \lstinline!HAVE_!\ -to the command line. - -As an example, the macro \lstinline!HAVE_UG!\ can be used to compile -UG-specific code as in -\begin{lstlisting}[basicstyle=\ttfamily\scriptsize] -#if HAVE_UG -#include -#endif -\end{lstlisting} - -It is important that the file \lstinline!config.h! is the first -included header in your application! - - - - -\subsection{dune-autogen} -\label{autogen} - -The \autogen script is used to bring the freshly checked out module -into that state that you expect from a module received via the -tarball. That means it runs all necessary steps so that you can call -\configure to setup your module. In the case of \dune this means that -\autogen runs -\begin{itemize} -\item \texttt{libtoolize} (prepare the module for \libtool) -\item \texttt{dunecontrol m4create} (create an m4 file containing the - dependencies of this module) -\item \texttt{aclocal} (collect all \autoconf macros needed for this module) -\item \texttt{autoheader} (create the \texttt{config.h.in}) -\item \texttt{automake} (create the \makefilein) -\item \texttt{autoconf} (create \configure) -\end{itemize} - -If needed it will also create the symbolic link to the -\texttt{dune-common/am/} directory (see~\ref{am_includes}). - -\subsection{m4 files} -\label{m4files} - -\texttt{m4/} files contain macros which are then composed into -\configure and are run during execution of \configure. - -\minisec{private m4 macros} - -You can add new tests to configure by providing additional macro files -in the directory \texttt{module/m4/}. - -\minisec{dependencies.m4} - -\texttt{\topsrc/dependencies.m4} hold all information about the -dependencies and suggestions of this module. It is an automatically -generated file. It is generated by \texttt{dunecontrol m4create}. - -\minisec{m4 module checks} -For each dependencies of your module \texttt{\emph{MODULE}\_CHECKS} -and \texttt{\emph{MODULE}\_CHECK\_MODULE} is called. Last -\texttt{\emph{MODULE}\_CHECKS} is called for your module, in order to -check all prerequisites for your module. - -When you have to provide the two macros -\texttt{\emph{MODULE}\_CHECKS} and -\texttt{\emph{MODULE}\_CHECK\_MODULE} for your module these should be -written to a \texttt{m4/*.m4} file. - -Here follows an example for the module \texttt{dune-foo}: - -\begin{lstlisting} -dnl -*- autoconf -*- -# Macros needed to find dune-foo and dependent libraries. They are -# called by the macros in ${top_src_dir}/dependencies.m4, which is -# generated by "dunecontrol autogen" - -# Additional checks needed to build dune-foo -# This macro should be invoked by every module which depends on -# dune-foo, as well as by dune-foo itself -AC_DEFUN([DUNE_FOO_CHECKS]) - -# Additional checks needed to find dune-foo -# This macro should be invoked by every module which depends on dune-foo, but -# _not_ by dune-foo itself -AC_DEFUN([DUNE_FOO_CHECK_MODULE],[ - DUNE_CHECK_MODULES([dune-foo], dnl module name - [foo/foo.hh], dnl header file - [Dune::FooFnkt]) dnl symbol in libdunefoo -]) -\end{lstlisting} - -The first one calls all checks required to make use of -\texttt{dune-foo}. The dependency checks are not to be included, they -are run automatically. The second macro tells how to check for your -module. In case you are only writing an application and don't want to -make this module available to other modules, you can just leave it -empty. If you have to provide some way to find your module. The -easiest is to use the \texttt{DUNE\_CHECK\_MODULES} macro, which is -defined in \texttt{dune-common/m4/dune.m4}. - -\section{Building Sets of Modules Using \dunecontrol} -\label{dunecontrol} -\dunecontrol helps you building the different \dune modules in the -appropriate order. Each module has a \dunemodule file which contains -information on the module needed by \dunecontrol. - -\dunecontrol searches for \dunemodule files recursively from where you -are executing the program. For each \dune module found it will execute -a \dunecontrol command. All commands offered by \dunecontrol have a -default implementation. This default implementation can be overwritten -and extended in the \dunemodule file. - -The commands you are interested in right now are -\begin{itemize} -\item \texttt{autogen} runs \autogen for each module. A list of - directories containing \dunemodule files and the parameters given on - the command line are passed as parameters to \autogen. -\item \texttt{configure} runs \configure for each - module. \texttt{--with-dune-\textit{module}} parameters are created - for a set of known \dune modules. -\item \texttt{make} runs \make for each module. -\item \texttt{all} runs \autogen, \configure and \make for each module. -\end{itemize} - -In order to build \dune the first time you will need the \texttt{all} -command. In pseudo code \texttt{all} does the following: -\begin{lstlisting}[language=Perl] -foreach ($module in $Modules) { - foreach (command in {autogen,configure,make) { - run $command in $module - } -} -\end{lstlisting} - -This differs from calling -\begin{lstlisting} -dunecontrol autogen -dunecontrol configure -dunecontrol make -\end{lstlisting} -as it ensures that i.e. \dunecommon is fully built before \configure -is executed in \dunegrid. Otherwise \configure in \dunegrid would -complain that \texttt{libcommon.la} from \dunecommon is missing. - -Further more you can add parameters to the commands; these parameters -get passed on to the program being executed. Assuming you want to call -\texttt{make clean} in all \dune modules you can execute -\begin{lstlisting} -dunecontrol make clean -\end{lstlisting} - -\minisec{opts files} -You can also let \dunecontrol read the command parameters from a file. -For each command you can specify parameters. The parameters are stored -in a variable called \texttt{\textit{COMMAND}\,\_FLAGS} with -\texttt{\textit{COMMAND}} written in capital letters. - -\begin{lst}[File example.opts] \mbox{} -\lstinputlisting{../example.opts} -\end{lst} - -When you specify an opts file and command line parameters -\begin{lstlisting} -dunecontrol --opts=some.opts configure --with-foo=bar -\end{lstlisting} -\dunecontrol will ignore the parameters specified in the opts file and -you will get a warning. - -\minisec{environment variables} -You can further control the behavior of \dunecontrol by certain -environment variables. -\begin{itemize} -\item \texttt{DUNE\_CONTROL\_PATH} specifies the paths, where - \dunecontrol is searching for modules. All entries have to be colon - separated and should point to either a directory (which is search - recursively for \texttt{dune.module} files) or a directly - \texttt{dune.module} file. -\item \texttt{DUNE\_OPTS\_FILE} specifies the opts file that should be - read by \dunecontrol. This variable will be overwritten by the - \texttt{--opts=} option. -\item \texttt{MAKE} tells \dunecontrol which command to invoke for - 'make'. This can be useful for example, if you want to use - \texttt{\textit{gmake}} as a make drop-in. -\item \texttt{GREP} tells \dunecontrol which command to invoke for 'grep'. -\end{itemize} - -\minisec{opts file variables} -Certain aspects of the build system can be specified via additional -entries in the opts file: - -\begin{itemize} -\item \texttt{DUNE\_CONTROL\_PATH} -- see \emph{environment variables} -\item \texttt{RESUME\_FILE} -- see \emph{Resume build after error} - Section \ref{sec:timesaving} -\item \texttt{BUILDDIR} configure the modules to use out-of-source - build. The binaries are built in subdirectories of each module, - named according to the \texttt{BUILDDIR} variable. -\item \texttt{\textit{COMMAND}\,\_FLAGS}\\ the most important ones are: - \begin{itemize} - \item \texttt{AUTOGEN\_FLAGS} specifies options for the - \texttt{dune-autogen} script. This allows to set\\ - \texttt{--acversion=VERSION} or \texttt{--amversion=VERSION} to - force usage of a specific\\ \texttt{autoconf\$VERSION} or - \texttt{automake\$VERSION}. - \item \texttt{CONFIGURE\_FLAGS} specifies options you want to pass to - configure. For a list of possible parameters see - \texttt{./configure --help} (note that this command is only - available after running \texttt{dunecontrol autogen}). - \item \texttt{MAKE\_FLAGS} specifies options for the \texttt{make} - command, e.g. \texttt{-j4} to allow four concurrent build jobs. - \end{itemize} -\end{itemize} - -\subsection{dune.module}\label{subsec::dune.module} - -The \dunemodule file is split into two parts. First we have the -parameter section where you specify parameters describing the module. -Then we have the command section where you can overload the default -implementation of a command called via \dunecontrol. - -\begin{lst}[File dune.module] \mbox{} -\begin{lstlisting} -# parameters for dune control -Module: dune-grid -Version: 2.2-svn -Maintainer: dune@dune-project.org -Depends: dune-common (>= 2.2) dune-geometry (>= 2.2) -Extra-Suggests: UG Alberta Alu3d - -# overload the run_configure command -run_configure () { - # lets extend the parameter list $CMD_FLAGS - if test "x$HAVE_UG" == "xyes"; then - CMD_FLAGS="$CMD_FLAGS \"--with-ug=$PATH_UG\"" - fi - if test "x$HAVE_Alberta" == "xyes"; then - CMD_FLAGS="$CMD_FLAGS \"--with-alberta=$PATH_Alberta\"" - fi - if test "x$HAVE_Alu3d" == "xyes"; then - CMD_FLAGS="$CMD_FLAGS \"--with-alugrid=$PATH_Alu3d\"" - fi - # call the default implementation - run_default_configure -} -\end{lstlisting} -\end{lst} - -The parameter section will be parsed by \dunecontrol will effect -i.e. the order in which the modules are built. The parameters and -their values are separated by colon. Possible parameters are -\begin{itemize} -\item \texttt{Module} (\em required\em) is the name of the module. The - name is of the form \texttt{[a-zA-Z0-9\_-]+}. -\item \texttt{Version} (\em optional\em) is the module's version. -\item \texttt{Maintainer} (\em optional\em) is the email address of the - module's maintainer. -\item \texttt{Depends} (\em required\em) takes a space separated list - of required modules. This module is not functional without these - other modules. Checks whether the demanded version of the required - modules is provided. -\item \texttt{Suggests} (\em optional\em) takes a space separated list - of optional modules. This module is functional without these - other modules, but can offer further functionality if one or more of - the suggested modules are found. -\end{itemize} - -The command section lets you overload the default implementation -provided by \dunecontrol. For each command \dunecontrol call the -function \texttt{run\_\textit{command}}. The parameters from the -command line or the opts file are store in the variable -\texttt{\$CMD\_FLAGS}. If you just want to create additional parameters -you can add these to \texttt{\$CMD\_FLAGS} and then call the default -implementation of the command via -\texttt{run\_default\_\textit{command}}. - -\subsection{\dune-specific conditional builds} - -The \texttt{Suggests} parameter in the \texttt{dune.module} file, -see \ref{subsec::dune.module}, gives you the flexibility to optionally build -parts of your code depending on whether certain \dune or external modules are -installed or not. As an example, we show in this section a \dune module with suggestions -for the modules \texttt{dune-localfunctions} and \texttt{dune-pdelab}. -A subdirectory \texttt{my\_pdelab\_application} should only be built if these optional modules -are installed. We assume that your project is set up in the traditional -\texttt{automake} fashion, i.e. there is a \texttt{Makefile.am} in every subdirectory. - -Suppose your \texttt{dune.module} file has dependencies on \texttt{dune-localfunctions} -and \texttt{dune-pdelab} specified in the \texttt{Suggests} section: -\begin{lstlisting}[language=make] -# in the dune.module file -Module: my_application -Depends: dune-common dune-grid dune-istl -Suggests: dune-localfunctions dune-pdelab -\end{lstlisting} -There are three steps to take now: -\begin{enumerate} - \item Call \texttt{DUNE\_CHECK\_MODULES} from your local \texttt{\textit{MODULE}\_CHECK\_MODULE} - macro to implicitly define an \texttt{AM\_CONDITIONAL}. - \item This conditional can be used in any \texttt{Makefile.am} for optional builds. - \item The Makefile in any optional sub-directory to be build has to be - specified in \texttt{configure.ac} to be created. -\end{enumerate} - -\minisec{The automake conditional} -If you call the macro \texttt{DUNE\_CHECK\_MODULES} during your build process, -an \texttt{AM\_CONDITIONAL} named \texttt{HAVE\_\textit{SUGGESTEDMODULE}} is defined where -\texttt{\textit{SUGGESTEDMODULE}} is the name of the suggested module in upper case, and -with any \texttt{-} replaced by \texttt{\_}. For example, for \texttt{dune-pdelab} the -name would be \texttt{HAVE\_DUNE\_PDELAB}. \texttt{DUNE\_CHECK\_MODULES} -is defined in \texttt{dune-common/m4/dune.m4}, and it is documented there. -You should not call \texttt{DUNE\_CHECK\_MODULES} directly but in your local -\texttt{m4} file in your module where your module's checks are defined, -see section \ref{m4files}. For instance, if your module is \texttt{dune-foo}, -this call in a file \texttt{dune-foo/m4/dune-foo.m4} would be -\begin{lstlisting}[language=make] -AC_DEFUN([DUNE_FOO_CHECK_MODULE], -[ - DUNE_CHECK_MODULES([dune-foo], [foo/foo.hh]) -]) -\end{lstlisting} -This way, the requested \texttt{AM\_CONDITIONAL} is created implicitly. - -\minisec{The Makefile.am clause} -Having the \texttt{AM\_CONDITIONAL} named \texttt{HAVE\_DUNE\_PDELAB} -defined, you can use it in any \texttt{Makefile.am} of your project -to optionally build subdirectories or applications using \texttt{dune-pdelab}: -\begin{lstlisting}[language=make] -# build the directory my_pdelab_application if dune-pdelab is installed -SUBDIRS = appl1 appl2 -if HAVE_DUNE_PDELAB - SUBDIRS += my_pdelab_application -endif -\end{lstlisting} -Compare this \dune-specific conditional build to general conditional builds in -Section~\ref{makefile.am}. - -\minisec{The configure.ac entry} -Additionally, you have to specify in your \texttt{configure.ac} -(section \ref{configure.ac}) that the makefile in the directory -\texttt{my\_pdelab\_application} should be built: -\begin{lstlisting}[language=make] -AC_CONFIG_FILES([Makefile - ... - my_pdelab_application/Makefile - ... - dune-common.pc]) -AC_OUTPUT -\end{lstlisting} -Now, your project is prepared to build the subdirectory -\texttt{my\_pdelab\_application} if and only if your machine has a successfully -installed \texttt{dune-pdelab}. - -\subsection{Time savings using \dunecontrol} -\label{sec:timesaving} - -\dunecontrol can help working with a growing stack of depending \dune modules and -might save you time. - -\minisec{Narrow down \dune modules to apply actions to} -Often you don't want to let \dunecontrol apply actions for every module but only -the one you are working on. - -With the flag \texttt{--only=dune-foo} in -\begin{lstlisting}[language=make] -./dune-common/bin/dunecontrol --module=dune-foo --opts=config.opts configure -\end{lstlisting} -only the module \texttt{dune-foo} will be configured by \dunecontrol. - -Using the flag \texttt{--current} below a module's root directory \dunecontrol -applies actions only for this module. - -To apply the actions to a module and all modules it depends on, set the flag -\texttt{--module=dune-foo}. - -\minisec{Updates from revision control systems} -If modules are kept in a revision control system you need to stay up to -date and download the newest versions for your modules. The command \texttt{update} -as in -\begin{lstlisting}[language=make] -./dune-common/bin/dunecontrol update -\end{lstlisting} -makes \dunecontrol to update every module. Currently supported and automatically detected -revision control systems are the Concurrent Versions System (CVS), Apache -Subversion (SVN) and Git. - -\minisec{Execute commands for every module} -The \dunecontrol command \texttt{exec} allows to execute commands in the root -directory of every module. For example the -statement -\begin{lstlisting}[language=make,showstringspaces=false] -./dune-common/bin/dunecontrol exec "svn log -l10" -\end{lstlisting} -shows the last ten Subversion commit messages for all modules. If a module is -not under Subversion version control the command execution fails and \dunecontrol -stops. - -\minisec{Resume build after error} -\dunecontrol stops whenever an error occurs. But you can resume from the module which -failed. To enable this feature, you have to specify the path of a resume file in the -variable \texttt{RESUME\_FILE} of your options file and use the flag \texttt{--resume}. -If \dunecontrol fails it saves the name of the failing module in the specified file. -On the next run it recognizes the failed run and resumes from the failed module on. - -\dunecontrol skips the first module -- the one with the error in the last run -- after -resuming if the flag \texttt{--skipfirst} is given together with \texttt{--resume}. - -\minisec{Use configure caching} -\configure is run for every module thus many tests are unnecessarily run multiple times. -You can use \autoconf's ability to cache test results. If you add -\texttt{--cache-file=/tmp/dune-config.cache} to the \texttt{CONFIUGURE\_FLAGS} of -you options file the \configure cache is created. Be aware that the file persists -between \dunecontrol runs. If you encounter any problems, you want to change the -configuration or to rerun all checks, the cache file should be removed manually. - -\minisec{Faster module search} -If the environment variable \texttt{DUNE\_CONTROL\_PATH} is not set, \dunecontrol -recursively searches for \dune modules below the working directory. Depending on -your installation, this search may take quite a bit of time. It can be -avoided by including the paths to the \texttt{dune.module} files of all modules in -\texttt{DUNE\_CONTROL\_PATH}. - -This list of paths can actually be created on the fly by a command. -Let us assume all \dune modules are in one directory, which is the working directory -for \dunecontrol, too. By adding the line -\begin{lstlisting}[language=make,showstringspaces=false] -DUNE_CONTROL_PATH="`ls */dune.module | tr '\n' ':'`" -\end{lstlisting} -to your opts file, no search will be performed. Instead, only the faster, non-recursive -\texttt{ls} command is called. - -\section{Further documentation} - -\minisec{automake \& Makefile.am} -\url{http://www.gnu.org/software/automake/manual/}\\ -The \automake manual describes in detail how to write and maintain a -\makefileam and the usage of \automake. - -\minisec{autoconf \& configure.ac} -\url{http://www.gnu.org/software/autoconf/manual/}\\ -The \autoconf manual covers the usage of \autoconf and how to write -\configure.ac files (sometimes they are called \texttt{configure.in}). - -\minisec{Autoconf Macro Archive} -\url{http://autoconf-archive.cryp.to/}\\ -The Autoconf Macro Archive provides macros that can be integrated in -your \configureac in order to search for certain software. These -macros are useful to many software writers using the autoconf tool, but too -specific to be included into autoconf itself. - -\minisec{doxygen} -\url{http://www.doxygen.org/}\\ -The \texttt{doxygen} website offers documentation on how to document -your source code and also on the configuration parameters in your -\texttt{Doxylocal} file. - -\minisec{libtool} -\url{http://www.gnu.org/software/libtool/manual.html}\\ -The \libtool manual offers further information on the usage of -\libtool package and gives a good overview of the different -problems/aspects of creating portable libraries. - -\minisec{autobook} -\url{http://sources.redhat.com/autobook/}\\ -The autobook is a complete book describing the GNU toolchain -(\autoconf, \automake and \libtool). It contains many recipes on how -to use the autotools. The book is available as an online -version. - -\minisec{dune-project} -\url{http://www.dune-project.org/}\\ -The official homepage of \dune. - -\end{document} - -%%% Local IspellDict: "american" -%%% Local Variables: -%%% mode: latex -%%% TeX-master: t -%%% End: diff -Nru dune-common-2.2.1/doc/buildsystem/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/doc/buildsystem/CMakeLists.txt --- dune-common-2.2.1/doc/buildsystem/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/buildsystem/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,5 @@ +# Install the buildsystem documentation defined in dune-common +install(FILES dune-common.rst DESTINATION ${CMAKE_INSTALL_DOCDIR}) + +# Also always build the CMake API documentation in dune-common +dune_cmake_sphinx_doc() diff -Nru dune-common-2.2.1/doc/buildsystem/dune-common.rst dune-common-2.5.2~20170808ga5c076ca/doc/buildsystem/dune-common.rst --- dune-common-2.2.1/doc/buildsystem/dune-common.rst 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/buildsystem/dune-common.rst 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,421 @@ +=========== +dune-common +=========== + +.. _whatis: + +What is CMake anyway? +===================== + +CMake... + +- is an open source build system tool developed at KITware. +- offers a one-tool-solution to all building tasks, like configuring, building, linking, testing and packaging. +- is a build system generator: It supports a set of backends called *generators* +- is portable +- is controlled by ONE rather simple language + +Dune got support for CMake in version 2.3 alongside the old Autotools build system. It got the default in the +2.4 release. After that release, the Autotools build system will be removed from the master branch. + +You can install CMake through your favorite package manager or downloading source code from +`KITWare `_ +The minimum required version to build Dune with CMake is 2.8.12. + +.. _howtouse: + +How do I use Dune with CMake? +============================= + +As with the Autotools, the build process is controlled by the script :code:`dunecontrol`, located in :code:`dune-common/bin`. +There is a compatibility layer that will translate all the configure flags from your opts file into the corresponding +CMake flags. While this is a great tool to determine how to do the transition, in the long run you should switch to +a CMake-only approach. + +:code:`dunecontrol` will pickup the variable :code:`CMAKE_FLAGS` from your opts file and use it as command line options for +any call to CMake. There, you can define variables for the configure process with CMake's :code:`-D` option; just as +with the C pre-processor. + +The most important part of the configure flags is to tell the build system where to look for external libraries. +You can browse the :ref:`variableref` section of this documentation for a list of variables that are picked up +by the Dune CMake build system. + +.. _whatfiles: + +What files in a dune module belong to the CMake build system? +============================================================= + +Every directory in a project contains a file called :code:`CMakeLists.txt`, which is written in the CMake language. +You can think of these as a distributed configure script. Upon configure, the top-level :code:`CMakeLists.txt` is executed. +Whenever an :ref:`add_subdirectory` command is encountered, the :code:`CMakeLists.txt` file of that sub-directory is executed. +The top-level :code:`CMakeLists.txt` file is special, because it sets up the entire Dune module correctly. You should not delete the +auto-generated parts of it. + +Additionally, a Dune module can export some cmake modules. A cmake module is a file that contains one or +more build system macros meant for downstream use. If a module provides modules, they can be found in +the subfolder :code:`cmake/modules`. The module :code:`dune-foo/cmake/modules/DuneFooMacros.cmake` in a module +:code:`dune-foo` is special however: Its contents are always executed when configuring the module +:code:`dune-foo` or any other Dune module, that requires or suggests the module :code:`dune-foo`. +This is the perfect place to put your checks for external packages, see below. + +The file :code:`config.h.cmake` defines a template for the section of :code:`config.h`, that is generated by the module. + +.. _porting: + +How do I port an existing module? +================================= + +There is multiple approaches to this: + +- First, check :ref:`simplified` and decide whether such simple approach is sufficient for your project. +- There is the python script :code:`dune-common/bin/am2cmake.py`, which automatically generates :code:`CMakeLists.txt`'s + from its :code:`Makefile.am` counterparts. While this works fine, for many modules the resulting files look very + autotoolish and are often too complicated. +- Copy the top-level :code:`CMakeLists.txt` file from a freshly generated Dune module (you still need to adjust the + project name to have it match the module name) and write all other :code:`CMakeLists.txt` by hand. This sounds + cumbersome, but its actually not very much work if you read below advices and have the online documentation at hand. + +In order to write your own :code:`CMakeLists.txt` files you should be aware of the following basic commands of the CMake +language: + +- :ref:`add_subdirectory` for recursively adding subdirectories +- :ref:`add_executable` to add some executable programs +- :ref:`dune_add_test` to register tests to the test suite. +- :ref:`install` to mark files for installation. + +For further commands, browse this documentation. + +If your module requires any other packages than the dune modules listed in your :code:`dune.module` file, you should +also use the command :ref:`find_package` in the module :code:`dune-foo/cmake/modules/DuneFooMacros.cmake` +(as mentioned in :ref:`whatfiles`). How to do this with external packages not yet supported by Dune is +covered in :ref:`external` + +.. _flags: + +How do I modify the flags and linked libraries of a given target? +================================================================= + +Again, there are multiple ways to do this. The Dune build system offers macros to make this task as +easy as possible. For each external module, there is a macro :code:`add_dune_*_flags`. Those macros should +cover most flags. Example usage: + +.. code-block:: cmake + + add_executable(foo foo.cc) + add_dune_umfpack_flags(foo) + add_dune_mpi_flags(foo) + +There is also the macro :ref:`add_dune_all_flags`, which uses the same flag registry mechanism as the simplified +build system in section :ref:`simplified`. + +If you want to fully control the configuration of the targets, you can do so. Build system entities such +as targets, directories and tests do have so called properties in CMake. You can access and modify those +properties via the commands :code:`get_property` and :code:`set_property`. You can for example use those +to modify a targets :code:`COMPILE_DEFINITIONS` or :code:`INCLUDE_DIRECTORIES` property: + +.. code-block:: cmake + + add_executable(foo foo.cc) + set_property(TARGET foo APPEND PROPERTY COMPILE_DEFINITIONS ) + set_property(TARGET foo APPEND PROPERTY INCLUDE_DIRECTORIES ) + +For a full list of properties, check the manual: + +.. code-block:: bash + + cmake --help-property-list + +Manually linking libraries can be done through the :code:`target_link_libraries` command instead of manually +tweaking properties. + +.. _external: + +How do I link against external libraries, that are not checked for by Dune? +=========================================================================== + +While there might be many solutions that make your application work, there is only one clean solution to this: You have +to provide a find module for the package. A find module is a CMake module that follows a specific naming scheme: For +an external package called :code:`SomePackage` it is called :code:`FindSomePackage.cmake`. Note that CMake +treats package names case sensitive. If CMake encounters a :code:`find_package(SomePackage)` line, it searches +its module include paths for this find module. A good read to get started writing a find module is +`this page `_ in the CMake wiki. + +Depending on how common your external package is, you may not even need to write the find module on your own. +You can have a look at the list of find modules shipped by CMake or simply search the +internet for the module name and profit from other open-source project's work. + +It is considered good style to also provide a macro :code:`add_dune_somepackage_flags`. + +.. _outofsource: + +What is an out-of-source build? +=============================== + +An out-of-source build does leave the version-controlled source tree untouched and puts all files that are +generated by the build process into a different directory -- the build directory. The build directory does mirror +your source tree's structure as seen in the following. Assume the following source directory structure: + +:: + + dune-foo/ + CMakeLists.txt + dune/ + foo/ + CMakeLists.txt + src/ + CMakeLists.txt + +The generated build directory will have the following structure, where the directory :code:`build-cmake` +is a subdirectory of the source directory: + +:: + + build-cmake/ + Makefile + dune/ + foo/ + Makefile + src/ + Makefile + +Using the :code:`Unix Makefiles` generator, your Makefiles are generated in the build tree, so that is where you +have to call :code:`make`. There are multiple advantages with this approach, such as a clear separation between +version controlled and generated files and you can have multiple out-of-source builds with different configurations +at the same time. + +Out-of-source builds are the default with CMake. In-source builds are strongly discouraged. + +By default, a subfolder :code:`build-cmake` is generated within each dune module and is used as a build directory. +You can customize this folder through the :code:`--builddir` option of :code:`dunecontrol`. Give an absolute path to +the :code:`--builddir` option, you will get something like this: + +:: + + build/ + dune-common/ + Makefile + dune-foo/ + Makefile + +So, instead of one build directory in every dune module, you will be able to collect all build directories in one +directory. This makes it much easier to have multiple build directories and to remove build directories. + +.. _simplified: + +What is the new simplified build system and how do I use it? +============================================================ + +Dune offers a simplified build system, where all flags are added to all targets and all libraries are linked to all targets. You can enable the feature +by calling :ref:`dune_enable_all_packages` in the top-level :code:`CMakeLists.txt` file of your project, before you add any subdirectories. + +This will modify all targets in the directory of the :code:`CMakeLists.txt`, where you put this, and also in all +subdirectories. The compile flags for all found external packages are added to those targets and the target is +linked against all found external libraries. + +To use this while using custom external packages, you have to register your flags to the mechanism. +Also, some special care has to be given, if your module does build one or more library which targets within the module do link against. + +Carefully read the following documentation in those cases: + +* :ref:`dune_enable_all_packages` +* :ref:`dune_register_package_flags` +* :ref:`dune_library_add_sources` + +.. _compiler: + +How do I change my compiler and compiler flags? +=============================================== + +In general, there are multiple ways to do this: + +* Setting the CMake variables :ref:`CMAKE__COMPILER` (with :code:`LANG` being :code:`C` + or :code:`CXX` or :code:`Fortran`) from the opts file +* Setting those variables within the project with the :code:`set` command +* Setting the environment variables :code:`CC`, :code:`CXX`, :code:`FC` etc. + +The first option is the recommended way. Whenever you change your compiler, you should delete all build +directories. For some CMake versions, there is a known CMake bug, that requires you to give an absolute path +to your compiler, but Dune will issue a warning, if you violate that. + +You can modify your default compiler flags by setting the variables +:ref:`CMAKE__FLAGS` in your opts file (again with :code:`LANG` being :code:`C` or +:code:`CXX` or :code:`Fortran`). + +.. _symlink: + +How should I handle ini and grid files in an out-of-source-build setup? +======================================================================= + +Such files are under version control, but they are needed in the build directory. +There are some CMake functions targeting this issue: + +* :ref:`dune_symlink_to_source_tree` +* :ref:`dune_symlink_to_source_files` +* :ref:`dune_add_copy_command` +* :ref:`dune_add_copy_dependency` +* :ref:`dune_add_copy_target` + +The simplest way to solve the problem is to set the variable :ref:`DUNE_SYMLINK_TO_SOURCE_TREE` to your opts file. +This will execute :ref:`dune_symlink_to_source_tree` in your top-level :code:`CMakeLists.txt`. This will add a symlink +:code:`src_dir` to all subdirectories of the build directory, which points to the corresponding directory of the source +tree. This will only work on platforms that support symlinking. + +.. _ides: + +How do I use CMake with IDEs? +============================= + +As already said, CMake is merely a build system generator with multiple backends (called a generator). Using IDEs requires +a different generator. Check :code:`cmake --help` for a list of generators. You can then add the :code:`-G` to the :code:`CMAKE_FLAGS` in your opts file. +Note that the generator name has to match character by character, including case and spaces. + +To configure highlighting of CMake errors in Emacs' compilation mode, include +the following in your :code:`~./emacs` (see the `Emacs bug +`_): + +.. code-block:: elisp + + (setq compilation-error-regexp-alist-alist + `((cmake "^CMake \\(?:Error\\|\\(Warning\\)\\) at \\(.*\\):\\([1-9][0-9]*\\) ([^)]+):$" + 2 3 nil (1)) + (cmake-info "^ \\(?: \\*\\)?\\(.*\\):\\([1-9][0-9]*\\) ([^)]+)$" + 2 3 nil 0) + . ,compilation-error-regexp-alist-alist)) + +Then customize the option :code:`compilation-error-regexp-alist` and add the +two predefined symbols :code:`cmake` and :code:`cmake-info` to the list. + +.. _cxxflags: + +I usually modify my CXXFLAGS upon calling make. How can I do this in CMake? +=========================================================================== + +This violates the CMake philosophy and there is no clean solution to achieve it. The CMake-ish solution would be +to have for each configuration one out-of-source build. We have nevertheless implemented a workaround. It can be enable +by setting the variable :ref:`ALLOW_CXXFLAGS_OVERWRITE` in your opts file. You can then type: + +.. code-block:: bash + + make CXXFLAGS="" + +Furthermore any C pre-processor variable of the form :code:`-DVAR=` can be overloaded on the command line +and the grid type can be set via :code:`GRIDTYPE=""`. + +Note this only works with generators that are based on Makefiles and several Unix tools like bash must be +available. + +.. _test: + +How do I run the test suite from CMake? +======================================= + +The built-in target to run the tests is called :code:`test` instead of Autotools' :code:`check`. +It is a mere wrapper around CMake's own testing tool CTest. You can check :code:`ctest --help` +for a lot of useful options, such as choosing the set of tests to be run by matching regular expressions or +showing the output of failed tests. + +The test programs are not built automatically. You need to build them manually +before running them using :code:`make build_tests`. + +The Dune test suite also defines tests that run in parallel. You may set an upper bound to the number +of cores in use for a single test by setting :ref:`DUNE_MAX_TEST_CORES`. + +.. _disable: + +Can I disable an external dependency? +===================================== + +To disable an external dependency :code:`Foo`, add + +:: + + -DCMAKE_DISABLE_FIND_PACKAGE_Foo=TRUE + +to your opts file. The name of the dependency is case sensitive but there is no canonical naming +scheme. See the output of configure to get the right name. + +Make sure to not use cached configure results by deleting the cache file or the build directory, cf. +:ref:`troubleshoot`. + +.. _parallel: + +How do I switch between parallel and sequential builds? +======================================================= + +Dune builds with CMake are parallel if and only if MPI is found. To have a sequential build despite an +installed MPI library, you have to explicitly disable the corresponding find module by setting + +:: + + -DCMAKE_DISABLE_FIND_PACKAGE_MPI=TRUE + +in the :code:`CMAKE_FLAGS` of your opts file, as described in section :ref:`disable`. + +.. _headercheck: + +Why is it not possible anymore to do make headercheck? +====================================================== + +The headercheck feature has been disabled by default. You can enable it by setting the CMake variable :ref:`ENABLE_HEADERCHECK` +through your opts file. This step has been necessary, because of the large amount of additional file the headercheck adds to the +build directory. A better implementation has not been found yet, because it simply does not fit the CMake philosophy. + +.. _tarball: + +How do I create tarballs? +========================= + +CMake has a packaging tool CPack. This creates tarballs or binary packages. To build tarballs add +the variable :code:`CPACK_SET_DESTDIR` which must be set to :code:`true` for the configuration +of all modules. Inside the build directory run :code:`make package_source` and you'll find the +packages below :code:`/_CPack_Packages`. + +Note that an un-packed copy is located there which contains a :code:`dune.module` file. Delete the +subdirectory. Otherwise it is going to break your next :code:`dunecontrol` run, because the module +is defined multiple times. + +.. _dune-python: + +How does the Dune build system handle Python? +============================================= + +dune-common contains a build system extension to handle many python-related aspects. You can +read more on this in the module description :ref:`DunePythonCommonMacros` and the pieces of +documentation mentioned inthere. + +.. _troubleshoot: + +How do I troubleshoot? +====================== + +CMake caches aggressively which makes it bad at recognizing changed configurations. +To trigger a fresh run of configure, you can delete the :code:`CMakeCache.txt` file from +the build directory and maybe save some compilation time afterward. + +Whenever you experience any problems, your first step should be to delete all build directories. Nice trick: + +:: + + dunecontrol exec "rm -rf build-cmake" + +This will remove all build directories from all DUNE modules. + +Later on you can get an error log from the file :code:`CMakeError.log` in the :code:`CMakeFiles` +subdirectory of your build directory. This is what you should send to the mailing list alongside the +description of your setup and efforts to help us help you. + +Where can I get help? +===================== + +The CMake manual is available on the command line: + +* :code:`cmake --help-command-list` +* :code:`cmake --help-command ` +* :code:`cmake --help-property-list` +* :code:`cmake --help-property ` +* :code:`cmake --help-module-list` +* :code:`cmake --help-module ` + +To get help on which variables are picked up by CMake, there is a CMake wiki page collecting them. +Of course, there is also Google, StackOverflow and the CMake Mailing list (archive). +For problems specific to DUNE's build system, ask on our mailing lists. diff -Nru dune-common-2.2.1/doc/buildsystem/Makefile.am dune-common-2.5.2~20170808ga5c076ca/doc/buildsystem/Makefile.am --- dune-common-2.2.1/doc/buildsystem/Makefile.am 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/buildsystem/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -# $Id: Makefile.am 4499 2006-04-13 14:56:35Z christi $ - -# setting like in dune-web -CURDIR=doc/buildsystem -BASEDIR=../.. - -# install the html pages -docdir=$(datadir)/doc/dune-common/buildsystem -if BUILD_DOCS - DOCFILES=buildsystem.pdf - EXTRA_DIST=$(DOCFILES) - EXTRAINSTALL=$(DOCFILES) -endif - -# include predefined rules -include $(top_srcdir)/am/webstuff -include $(top_srcdir)/am/latex -include $(top_srcdir)/am/global-rules diff -Nru dune-common-2.2.1/doc/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/doc/CMakeLists.txt --- dune-common-2.2.1/doc/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,5 @@ +add_subdirectory("doxygen") +add_subdirectory("buildsystem") +add_subdirectory("comm") +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dunecontrol.1 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff -Nru dune-common-2.2.1/doc/comm/buildindexset.hh dune-common-2.5.2~20170808ga5c076ca/doc/comm/buildindexset.hh --- dune-common-2.2.1/doc/comm/buildindexset.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/buildindexset.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,54 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef BUILDINDEXSET_HH +#define BUILDINDEXSET_HH + + +#include +#include + +/** + * @brief Flag for marking the indices. + */ +enum Flag {owner, overlap}; + +// The type of local index we use +typedef Dune::ParallelLocalIndex LocalIndex; + +/** + * @brief Add indices to the example index set. + * @param indexSet The index set to build. + */ +template +void build(C& comm, Dune::ParallelIndexSet& indexSet) +{ + + + + + // The rank of our process + int rank=comm.rank(); + + // Indicate that we add or remove indices. + indexSet.beginResize(); + + if(rank==0) { + indexSet.add(0, LocalIndex(0,overlap,true)); + indexSet.add(2, LocalIndex(1,owner,true)); + indexSet.add(6, LocalIndex(2,owner,true)); + indexSet.add(3, LocalIndex(3,owner,true)); + indexSet.add(5, LocalIndex(4,owner,true)); + } + + if(rank==1) { + indexSet.add(0, LocalIndex(0,owner,true)); + indexSet.add(1, LocalIndex(1,owner,true)); + indexSet.add(7, LocalIndex(2,owner,true)); + indexSet.add(5, LocalIndex(3,overlap,true)); + indexSet.add(4, LocalIndex(4,owner,true)); + } + + // Modification is over + indexSet.endResize(); +} +#endif diff -Nru dune-common-2.2.1/doc/comm/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/doc/comm/CMakeLists.txt --- dune-common-2.2.1/doc/comm/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,17 @@ +add_executable(poosc08 "poosc08.cc") +target_link_libraries(poosc08 "dunecommon") + +add_executable(poosc08_test "poosc08_test.cc") +target_link_libraries(poosc08_test "dunecommon") + +add_executable(indexset "indexset.cc") +target_link_libraries(indexset "dunecommon") + +add_dune_mpi_flags("poosc08;poosc08_test;indexset") + +dune_add_latex_document(communication.tex + FORCE_DVI + BIBFILES communication.bib + INPUTS poosc08_test.cc + IMAGE_DIRS figures) +create_doc_install(${CMAKE_CURRENT_BINARY_DIR}/communication.pdf ${CMAKE_INSTALL_DOCDIR}/comm communication_safepdf) diff -Nru dune-common-2.2.1/doc/comm/communication.bib dune-common-2.5.2~20170808ga5c076ca/doc/comm/communication.bib --- dune-common-2.2.1/doc/comm/communication.bib 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/communication.bib 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,79 @@ +@InProceedings{ISTL, + author = {Markus Blatt and Peter Bastian}, + title = {The Iterative Solver Template Library}, + booktitle = {Applied Parallel Computing. State of the Art in Scientific Computing}, + editor = {Bo K\r{a}gstr\"om and Erik Elmroth and Jack Dongarra and Jerzy Wa\'sniewski}, + year = 2007, + volume = 4699, + series = {Lecture Notes in Computer Science}, + publisher = {Springer}, + pages = {666--675} +} + +@Article{dune08-1, + author = {Peter Bastian and Markus Blatt and Andreas Dedner and Christian Engwer and Robert Kl\"ofkorn and Mario Ohlberger and Oliver Sander}, + title = { A generic grid interface for parallel and adaptive scientific computing. Part I: abstract framework}, + journal = {Computing}, + year = 2008, + volume = 82, + number = {2--3}, + pages = {103--119} +} +@Article{dune08-2, + author = {Peter Bastian and Markus Blatt and Andreas Dedner and Christian Engwer and Robert Kl\"ofkorn and Ralf Kornhuber and Mario Ohlberger and Oliver Sander}, + title = { A generic grid interface for parallel and adaptive scientific computing. Part II: implementation and test in DUNE}, + journal = {Computing}, + year = 2008, + volume = 82, + number = {2--3} , + pages = {121--138} +} +@Article{ISTLParallel, + author = {Markus Blatt and Peter Bastian}, + title = {On the Generic Parallelisation of Iterative Solvers for + the Finite Element Method}, + journal = {Int. J. Computational Science and + Engineering}, + volume = {4}, + number = {1}, + pages = {56--69}, + year = 2008 +} + +@Misc{DuneWeb, + author = {DUNE}, + howpublished = {\texttt{http://www.dune-project.org/}} +} +@Misc{boost_mpi, + author = {D. Gregor and M. Troyer}, + title = {{B}oost.{M}{P}{I}}, + howpublished = {\texttt{http://www.boost.org/}}, + year = 2006 +} + +@PhdThesis{gerlach02:janus, + author = {Jens Gerlach}, + title = {Domain Engineering and Generic Programming for Parallel Scientific Computing}, + school = {TU Berlin}, + year = {2002} +} + +@InProceedings{giloi95:_promot, + author = {W.K. Giloi and M. Kessler and A. Schramm}, + title = {PROMOTER: A High Level, Object-Parallel Programming Language}, + booktitle = {Proceedings of the International Conference on High Performance Computing}, + year = {1995}, + address = {New Dehli, India}, + month = {December} +} + +@inproceedings{nolte00:_taco, + author = {J\"{o}rg Nolte and Mitsuhisa Sato and Yutaka Ishikawa}, + title = {TACO -- Dynamic Distributed Collections with Templates and Topologies}, + booktitle = {Euro-Par '00: Proceedings from the 6th International Euro-Par Conference on Parallel Processing}, + year = {2000}, + isbn = {3-540-67956-1}, + pages = {1071--1080}, + publisher = {Springer-Verlag}, + address = {London, UK}, + } \ No newline at end of file diff -Nru dune-common-2.2.1/doc/comm/communication.tex dune-common-2.5.2~20170808ga5c076ca/doc/comm/communication.tex --- dune-common-2.2.1/doc/comm/communication.tex 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/communication.tex 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,543 @@ +\documentclass[11pt]{article} +\usepackage{multicol} +\usepackage{ifthen} +%\usepackage{multitoc} +%\usepackage{german} +%\usepackage{bibgerm} +\usepackage{amsthm} +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{color} +\usepackage{hyperref} +\usepackage{psfrag} +\usepackage{subfigure} +\usepackage[dvips]{epsfig} +\usepackage[dvips]{graphicx} +\usepackage[a4paper,body={148mm,240mm,nohead}]{geometry} +\usepackage[ansinew]{inputenc} +\usepackage{listings} +\lstset{language=C++, basicstyle=\ttfamily, + stringstyle=\ttfamily, commentstyle=\it, extendedchars=true} + +\newif\ifpdf +\ifnum\ifx\pdfoutput\undefined0\else\pdfoutput\fi<1 +\pdffalse % we are not running PDFLaTeX +\else +\pdftrue % we are running PDFLaTeX +\fi + +\ifpdf +\usepackage[pdftex]{graphicx} +\else +\usepackage{graphicx} +\fi + +\ifpdf +\DeclareGraphicsExtensions{.pdf, .jpg, .tif} +\else +\DeclareGraphicsExtensions{.eps, .jpg} +\fi + +%\theoremstyle{plain} +\newtheorem{theorem}{Theorem}[section] +\newtheorem{lemma}[theorem]{Lemma} + +\theoremstyle{definition} +\newtheorem{definition}[theorem]{Definition} +\newtheorem{class}[theorem]{Class} +\newtheorem{algorithm}[theorem]{Algorithm} +\theoremstyle{remark} +\newtheorem{remark}[theorem]{Remark} + +\newcommand{\C}{\mathbb{C}} +\newcommand{\R}{\mathbb{R}} +\newcommand{\N}{\mathbb{N}} +\newcommand{\Z}{\mathbb{Z}} +\newcommand{\Q}{\mathbb{Q}} +\newcommand{\K}{\mathbb{K}} +\newcommand{\loc}{\mbox{loc}} + +\title{Communication within the Iterative Solver Template Library (ISTL)\thanks{Part of the + Distributed and Unified Numerics Environment (DUNE) which is + available from the site + \texttt{http://www.dune-project.org/}}} + +\author{% +Markus Blatt\\ +Interdisziplinäres Zentrum für Wissenschaftliches Rechnen,\\ +Universität Heidelberg, Im Neuenheimer Feld 368, D-69120 Heidelberg, \\ +email: \texttt{Markus.Blatt@iwr.uni-heidelberg.de}} + +\date{April 27, 2005} + +\begin{document} + +\maketitle + +\begin{abstract} + This document describes usage and interface of the classes meant for + setting up the communication within a parallel programm using + ISTL. As most of the communication in distributed programm occur in + the same pattern it is often more efficient (and of course more easy + for the programmer) to build the communication pattern once in the + programm and then use multiple times (e.~g. at each iteration step + of an iterative solver). +\end{abstract} + +\begin{multicols}{2} +{\small\tableofcontents} +\end{multicols} + + +\section{Introduction} +\label{sec:introduction} + +When using the data parallel programming model a set of processes +works collectively on the same set of finite data objects. These might +be elements of a finite element grid or vector entries in a linear algebra +computation. Each process works on different partitions of the global +data. Only for this partition it computes updated values. + +In large scale parallel codes it is advisable to store the data +partition in a local data structure directly in the local memory of +the process. Due to data dependencies the process needs to access data +in the partition of other processes, too. This can either be done by +communicating these values on demand between the processes whenever +they are accessed. This results in data structures that are aware of +the data distribution. Or by augmenting the partition of the process such +that it additionally includes the data values that the other values +depend on. Note that now the partitioning is not disjoint any more but +overlapping. Of course the values other processes compute for need to +be updated using communication at so called synchronisation points of +the algorithm + +In the latter case the data structures do not need to know anything +about the data distribution. +This demands more effort from the parallel algorithm designer to make +sure that the data used for computations is valid, i.e. contains an +updated value if another process computes the data for it. Still it allows +for fewer synchronisation points in the algorithms as even in collective +operations all input data may already be updated from other processes +due to a previous operation. Between the necessary synchronisation +points one can take advantage of the fast local memory +access. + +Consider representing a random access container $x$ on a set of +processes ${\cal P}=\{0, \ldots, P-1\}$. It is represented by individual +pieces $x^p$, where $x^p$ is the piece stored on +process $p$ of the $P$ processes participating in the +calculation. Although the global representation of the container is +not available on any process, a process $p$ needs to know how the +entries of its local piece $x^p$ correspond to the entries of the +global container $x$, which would be used in a sequential program. + +\section{Communication Software Components} +\label{sec:comm-softw-comp} + +From an abstract point of view a random access container $x: I +\rightarrow K$ provides a +mapping from an index set $I \subset \N_0$ onto a set of objects +$K$. Note that we do not require $I$ to be consecutive. The piece +$x_p$ of the container $x$ stored on process $p$ is a mapping $x_p:I_p +\rightarrow K$, where $I_p \subset I$. Due to efficiency the entries +of $x_p$ should be stored consecutively in memory. +This means that for the local computation the data must be addressable +by a consecutive index starting from $0$. + +When using adaptive +discretisation methods there might be the need to reorder the indices +after adding and/or deleting some of the discretisation +points. Therefore this index does not need to be persistent +and can easily be changed. We will call this index {\em\index{local index}local index}. + +For the communication phases of our algorithms these locally stored +entries must also be addressable by a global identifier. It is used to +store the received values at and to retrieve the values to be sent from the +correct local position in the consecutive memory chunk. To ease the +addition and removal of discretisation points this global identifier has +to be persistent but does not need to be consecutive. We +will call this global identifier {\em\index{global index}global index}. + +\subsection{ParallelIndexSet} + Let $I \subset \N_0$ be an arbitrary, not necessarily consecutive, + index set identifying all discretisation points of the computation. + Furthermore, let + $$({I}_p)_{p\in {\cal P}}, \quad + \bigcup\limits_{p \in {\cal P}} {I}_p = I$$ be an overlapping decomposition of the global index set + $I$ into the sets of indices ${I}_p$ corresponding to the + global indices of the values stored locally in the chunk of process $p$. + + Then the class + \begin{lstlisting}{} + template class ParallelIndexSet; + \end{lstlisting} + realises the one to one mapping + $$ + \gamma_p\::\: {I}_p \longrightarrow {I}^{\loc}_p := [0, n_p) + $$ + of the globally unique index onto the local index. + + The template parameter \lstinline!TG! is the type of the global + index and + \lstinline!TL! is the type of the local index. The only prerequisite + of \lstinline!TG! is that objects of this type are comparable using + the less-than-operator \lstinline! class ParallelLocalIndex; +\end{lstlisting} +as the type for the local index of class \lstinline!ParallelIndexSet!. +Here the template parameter \lstinline!TA! is the type of the +attributes used, e.g. an enumeration \lstinline!Flags! defined by +\begin{lstlisting} + enum Flags {owner, ghost}; +\end{lstlisting} +where +\lstinline!owner! marks the indices $k \in I_p$ owned by process +$p$ and \lstinline!ghost! the indices $k\not\in I_p$ owned +by other processes. + +As an example let us look at an array distributed between two +processes. In Figure \ref{fig:redistarray} one can see the array +$a$ as it appears in a sequential program. Below there are two +different distributions of that array. The local views $s_0$ and +$s_1$ are the parts process $0$ and $1$ store in the case that $a$ is +divided into two +blocks. The local views $t_0$ and $t_1$ are the parts of $a$ that +process $0$ and $1$ store in the case that $a$ is divided into 4 +blocks and process +$0$ stores the first and third block and process $1$ the second and +fourth block. The decompositions have an overlap of one and the indices have +the attributes \lstinline!owner! and \lstinline!ghost! visualised by +white and shaded cells, respectively. +The index sets $I_s$ and $I_t$ corresponding to the decompositions $s_p$ +and $t_p$, $p \in \{0,1\}$, are shown in Figure \ref{fig:redistindex} as sets of triples +$(g,l,a)$. Here $g$ is the global index, $l$ is the local index and +$a$ is the attribute (either o for \lstinline!owner! or {g} +for \lstinline!ghost!). +\begin{figure}%[b] + \centering + \psfrag{Is}{$I_s$} + \psfrag{It}{$I_t$} + \epsfig{file=figures/distindex.eps,width=.5\textwidth} + \caption{Index sets for array redistribution} + \label{fig:redistindex} +\end{figure} +\begin{figure*}%[b] + \centering + \psfrag{a0:}{$s_0$:} + \psfrag{a1:}{$s_1$:} + \psfrag{b0:}{$t_0$:} + \psfrag{b1:}{$t_1$:} + \epsfig{file=figures/distarray.eps,width=.9\textwidth} + \caption{Redistributed array} + \label{fig:redistarray} +\end{figure*} + +The following code snippet demonstrates how to set up the index set +$I_s$ on process $0$: +\lstinputlisting[linerange={53-57,59-61,67-67}]{poosc08_test.cc} +\subsection{Remote Indices} +\label{sec:remote-indices} + +To set up communication between the processes every process needs to +know which indices are also known to other processes and which +attributes are attached to them on the remote side. +There are scenarios where data is exchanged between different +index sets, e.g. if the data is agglomerated on lesser processes or +redistributed. Therefore communication is allowed to occur between different +decompositions of the same index set. + + +Let $I \subset \N$ be the global index set and +$$ +(I^s_p)_{p\in{\cal P}},\quad \bigcup_{p\in{\cal P}} I^s_p = I,\quad +\text{ and } \quad +(I^t_p)_{p\in{\cal P}}, \quad\bigcup_{p\in{\cal P}} I^t_p = I +$$ be two overlapping +decompositions of the same index set $I$. Then an instance of class +\lstinline!RemoteIndices! on process $p \in {\cal P}$ +stores the sets of triples +\begin{equation} + \label{eq:ri_s_set} + \begin{split} + r_{p \rightarrow q}^{s} = \{ (g,(l,a),b) \,|\, g \in I^s_q \wedge g \in I_p^t, +l=\gamma_p^s(g), a = \alpha_p^s(l), b = +\alpha_q^t(\gamma_q^t(g))\} +\end{split} +\end{equation} +and +\begin{equation} + \label{eq:ri_t_set} + \begin{split} + r_{p \rightarrow q}^{t} = \{ (g,(l,a),b) \,|\, g \in I^s_q \wedge g \in I_p^t, + l=\gamma_p^t(g), a = \alpha_p^t(l), b = + \alpha_p^s(\gamma_p^s(g))\}\,, + \end{split} +\end{equation} +for all $q\in{\cal P}$. +Here $\alpha^s_p$ and $\alpha^t_p$ denote the mapping of local +indices on process $p$ onto attributes for the index set $I^s_p$ and +$I^t_p$ as realised by \lstinline!ParallelLocalIndex!. +Note that the sets $r_{p \rightarrow q}^{s}$ and $r_{p \rightarrow + q}^{t}$ will only be nonempty if the processes $p$ and $q$ manage +overlapping index sets. + +For our example in Figure \ref{fig:redistarray} and Figure +\ref{fig:redistindex} the interface between $I_s$ and $I_t$ on process +$0$ is: +\begin{align*} + r_{0\rightarrow 0}^{s} = \{&(0,(0,o),o), (1,(1,o),o), (2,(2,o),o), + (3,(3,o),g), (5,(5,o),g), (6,(6,g),o)\}\\ + r_{0\rightarrow 0}^{t} = \{&(0,(0,o),o), (1,(1,o),o), (2,(2,o),o), + (3,(3,g),o), (5,(4,g),o), (6,(5,o),g)\}\\ + r_{0\rightarrow 1}^{s} = \{&(2(2,o),g), (3,(3,o),o), (4,(4,o),o), + (5,(5,o),o), (6,(6,g),g)\}\\ + r_{0\rightarrow 1}^{t} = \{&(5,(4,g),g), (6,(5,o),o), (7,(6,o),o), + (8,(7,o),o), (9,(8,g),o)\} +\end{align*} +This information can either be calculated automatically by +communicating all indices in a ring or set up by hand if the user has +this information available. Assuming that \lstinline!sis! is the index set +$I_s$ and \lstinline!tis! the index set $I_t$ set up as described in +the previous subsection and \lstinline!comm! is an MPI communicator +then the simple call +\lstinputlisting[linerange={83-84}]{poosc08_test.cc} +on all processes automatically calculates this information and +stores it in \lstinline!riRedist!. For a +parallel calculation on the local views $s_0$ and $s_1$ calling +\lstinputlisting[linerange={86-87}]{poosc08_test.cc} +on all processes builds the necessary information in \lstinline!riS!. + +\subsection{Communication Interface} +\label{sec:comm-interf} + +With the information provided by class \lstinline!RemoteIndices! the +user can set up arbitrary communication interfaces. These interfaces +are realised in \lstinline!template class Interface!, +where the template parameter \lstinline!T! is the custom type of the +\lstinline!ParallelIndexSet! representing the index sets. +Using the attributes attached to the indices by +\lstinline!ParallelLocalIndex! the user can select subsets of the +indices for exchanging data, e.g. send data from indices marked +as \lstinline!owner! to indices marked as \lstinline!ghost!. + +Basically the interface on process $p$ manages two sets for each +process $q$ it shares common indices with: + +$$ +i_{p\rightarrow q}^{s} = \{ l | (g,(l,a),b) \in r_{p\rightarrow q}^{s} | +a \in A_s \wedge b \in A_t\} +$$ +and +$$ +i_{p\rightarrow q}^{t} = \{ l | (g, (l,a), b) \in r_{p\rightarrow q}^{t} | +a \in A_t \wedge b \in A_s\}\,, +$$ +where $A_s$ and $A_t$ are the attributes marking the indices where the +source and target of the communication will be, respectively. + +In our example these sets on process $0$ will be stored for +communication if $A_s=\{o\}$ and $A_t=\{o, g\}$: +\begin{align*} + i_{0\rightarrow 0}^{s} = \{0, 1, 3, 5\}\quad & \quad + i_{0\rightarrow 0}^{t} = \{0, 1, 3, 4\}\\ + i_{0\rightarrow 1}^{s} = \{2, 3, 4, 5\}\quad & \quad + i_{0\rightarrow 1}^{t} = \{5, 6, 7, 8\}\,. +\end{align*} + +The following code snippet would build the interface above in +\lstinline!infRedist! as well as the interface \lstinline!infS! +to communicate between +indices marked as \lstinline!owner! and \lstinline!ghost! on the local +array views $s_0$ and $s_1$: +\lstinputlisting[linerange={89-97}]{poosc08_test.cc} + +\subsection{Communicator} +\label{sec:communicator} + +Using the classes from the previous sections all information about the +communication is available and we are set to communicate data values +of arbitrary +container types. The only prerequisite for the container type is that +its values are addressable via \lstinline!operator[](size_t index)!. +This should be safe to assume. + +An important feature of our communicators is that we are not only able to +send one data item per index, but also different numbers of data +elements (of the same type) for each index. This is +supported in a generic way by the traits class +\lstinline!template struct CommPolicy! +describing the container type \lstinline!V!. The +\lstinline!typedef IndexedType! is the atomic type to be communicated and +\lstinline!typedef IndexedTypeFlag! is either \lstinline!SizeOne! if +there is only one data item per index or \lstinline!VariableSize! if the +number of data items per index is variable. + +The default implementation works for all +array-like containers which provide only one data item per index. For all +other containers the user has to provide its own custom +specialisation. +%For the vector classes of ISTL (up to two block levels) +%those specialisations are already implemented. + +The class \lstinline!template class BufferedCommunicator! +performs the +actual communication. The template parameter \lstinline!T! describes +the type of the parallel index set. +It uses the information about the communication interface provided by +an object of class \lstinline!Interface! to set up communication +buffers for a container containing a specific data type. It is also +responsible for gathering the data before and scattering the data +after the communication step. The strict separation of the interface +description from the actual buffering and communication allows for +reusing the interface information with various different container and +data types. + +Before the communication can start one has to call the +\lstinline!build! method with the data source and target containers as +well as the communication interface as arguments. Assuming +\lstinline!s! and \lstinline!t! as arrays $s_i$ and $t_i$, +respectively, then +\lstinputlisting[linerange=103-106]{poosc08_test.cc} +demonstrates how to set up the communicator \lstinline!bCommRedist! for the array +redistribution and \lstinline!bComm! for a parallel calculation on the +local views $s_i$. The +\lstinline!build! function +calculates the size of the messages to send to other processes and +allocates buffers for the send and receive actions. The +representatives \lstinline!s! and \lstinline!t! are +needed to get the number of data values at each index in the case of +variable numbers of data items per index. Note that, due to the generic +programming techniques used, the compiler knows if the number of data +points is constant for each index and will apply a specialised +algorithm for calculating the message size without querying neither +\lstinline!s! nor \lstinline!t!. Clean up of allocated +resources is done either by calling the method \lstinline!free()! or +automatically in the destructor. + +The actual communication takes place if one of the methods +\lstinline!forward! +and \lstinline!backward! is called. In our case in +\lstinline!bCommRedist! the \lstinline!forward! method +sends data from the local views $s_i$ to the local views $t_i$ +according to the interface information and the \lstinline!backward! +method in the opposite direction. + +The following code snippet first redistributes the local views $s_i$ +of the global array to the local views $t_i$ and +performs some calculation on this representation. Afterwards the +result is communicated backwards. +\lstinputlisting[linerange=110-113]{poosc08_test.cc} + +Note that both methods have a different template parameter, either +\lstinline!CopyData! or \lstinline!AddData!. These are policies for +gathering and scattering the data items. The former just copies +the data from and to the location. The latter copies from the source +location but adds the received data items to the target +entries. Assuming our data is stored in simple C-arrays +\lstinline!AddData! could be implemented like this: + +\lstinputlisting[linerange=16-27]{poosc08_test.cc} + +Note that arbitrary +manipulations can be applied to the communicated data in both methods. + +For containers with multiple data items associated with one index +the methods \lstinline!gather! and \lstinline!scatter! must have an additional +integer argument specifying the sub-index. + +\section{Collective Communication} +\label{sec:collective-communication} + +While communicating entries of array-like structures is a prominent +task in scientific computing codes one must not neglect +collective communication operations, like gathering and scattering data + from and to all processes, respectively, or waiting for other processes. An +abstraction for these operations is crucial for decoupling the +communication from the parallel programming paradigm used. + +Therefore we designed +\lstinline!template class CollectiveCommunication! which provides +information of the underlying parallel programming paradigm as well as +the collective communication operations as known from MPI. See Table +\ref{tab:col-comm} for a list of all functions. + +\begin{table*}%[b] + \centering + \begin{tabular}{p{.5\textwidth}|p{.4\textwidth}} + Function&Description\\\hline\hline + \lstinline!int rank()!&Get the rank of the process\\ + \lstinline!int size()!&Get the number of processes\\ + \lstinline!template T sum (T& in)!& Compute global + sum\\ + \lstinline!template T prod (T& in)!&Compute global + product\\ + \lstinline!template T min (T& in)!&Compute global minimum\\ + \lstinline!template T max (T& in)!&Compute global + maximum\\ + \lstinline!void barrier()!& Wait for all processes.\\ + \lstinline!template int broadcast (T* inout, int len, int root)! +& Broadcast an array from root to all other processes\\ +\lstinline!template int gather (T* in, T* out, int len, int root)!& +Gather arrays at a root process\\ +\lstinline!template int allreduce(Type* in, Type* out, int len)!& +Combine values from all processes on all processes. Combine function +is given with \lstinline!BinaryFunction! + \end{tabular} + \caption{Collective Communication Functions} + \label{tab:col-comm} +\end{table*} + +Currently there is a default implementation for sequential programs +as well as a specialisation working with MPI. This approach allows for +running parallel programs sequentially without any parallel overhead +simply by choosing the sequential specialisation at compile time. +Note that the interface is far more convenient to use than the C++ +interface of MPI. The latter is a simple wrapper around the C +implementation without taking advantage of the power of generic programming. + + +The collective communication classes were developed before the release +of Boost.MPI \cite{boost_mpi}. In contrast to Boost.MPI it was never +meant as a full generic implementation of all MPI functions. Instead it +is restricted to the most basic subset of collective operations needed +to implement finite element methods and iterative solver using the +previously described components. This lean interface should make it +possible to easily port this approach to +thread based parallelisation as well as other parallelisation +paradigms. This would allow code to easily switch between different paradigms + + +\bibliographystyle{plainnat} +\bibliography{communication} +\end{document} +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: diff -Nru dune-common-2.2.1/doc/comm/figures/darray.eps dune-common-2.5.2~20170808ga5c076ca/doc/comm/figures/darray.eps --- dune-common-2.2.1/doc/comm/figures/darray.eps 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/figures/darray.eps 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,230 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: ../eps/darray.eps +%%Creator: fig2dev Version 3.2 Patchlevel 1 +%%CreationDate: Thu Mar 4 15:25:17 1999 +%%For: peter@speedo (Peter Bastian) +%%Orientation: Portrait +%%BoundingBox: 0 0 345 260 +%%Pages: 0 +%%BeginSetup +%%EndSetup +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +-130.0 296.0 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def +%%EndProlog + +$F2psBegin +10 setmiterlimit +n -1000 5689 m -1000 -1000 l 8527 -1000 l 8527 5689 l cp clip + 0.06299 0.06299 sc +% Polyline +7.500 slw +n 5265 3105 m 7515 3105 l 7515 3780 l 5265 3780 l cp gs col0 s gr +% Polyline +n 5670 3105 m 5670 3780 l gs col0 s gr +% Polyline +n 6120 3105 m 6120 3780 l gs col0 s gr +% Polyline +n 6570 3105 m 6570 3780 l gs col0 s gr +% Polyline +n 7020 3105 m 7020 3780 l gs col0 s gr +/Times-Roman ff 180.00 scf sf +5400 4050 m +gs 1 -1 sc (0) col0 sh gr +/Times-Roman ff 180.00 scf sf +6300 4050 m +gs 1 -1 sc (2) col0 sh gr +/Times-Roman ff 180.00 scf sf +6750 4050 m +gs 1 -1 sc (3) col0 sh gr +/Times-Roman ff 180.00 scf sf +7245 4050 m +gs 1 -1 sc (4) col0 sh gr +/Times-Roman ff 180.00 scf sf +5850 4050 m +gs 1 -1 sc (1) col0 sh gr +% Polyline +n 2340 3105 m 4590 3105 l 4590 3780 l 2340 3780 l cp gs col0 s gr +% Polyline +n 2745 3105 m 2745 3780 l gs col0 s gr +% Polyline +n 3195 3105 m 3195 3780 l gs col0 s gr +% Polyline +n 3645 3105 m 3645 3780 l gs col0 s gr +% Polyline +n 4095 3105 m 4095 3780 l gs col0 s gr +/Times-Roman ff 180.00 scf sf +2475 4050 m +gs 1 -1 sc (0) col0 sh gr +/Times-Roman ff 180.00 scf sf +3375 4050 m +gs 1 -1 sc (2) col0 sh gr +/Times-Roman ff 180.00 scf sf +3825 4050 m +gs 1 -1 sc (3) col0 sh gr +/Times-Roman ff 180.00 scf sf +4320 4050 m +gs 1 -1 sc (4) col0 sh gr +/Times-Roman ff 180.00 scf sf +2925 4050 m +gs 1 -1 sc (1) col0 sh gr +/Times-Roman ff 180.00 scf sf +2970 4320 m +gs 1 -1 sc (local indices) col0 sh gr +/Times-Roman ff 180.00 scf sf +2475 4635 m +gs 1 -1 sc (local array in processor 0) col0 sh gr +% Polyline +n 3150 1215 m 6750 1215 l 6750 1890 l 3150 1890 l cp gs col0 s gr +% Polyline +n 4950 1215 m 4950 1890 l gs col0 s gr +% Polyline +n 4050 1215 m 4050 1890 l gs col0 s gr +% Polyline +n 3600 1215 m 3600 1890 l gs col0 s gr +% Polyline +n 4500 1215 m 4500 1890 l gs col0 s gr +% Polyline +n 5850 1215 m 5850 1890 l gs col0 s gr +% Polyline +n 5400 1215 m 5400 1890 l gs col0 s gr +% Polyline +n 6300 1215 m 6300 1890 l gs col0 s gr +% Polyline +n 2520 3105 m 3375 1890 l gs col0 s gr +% Polyline +n 2970 3105 m 4230 1890 l gs col0 s gr +% Polyline +n 3375 3105 m 6030 1890 l gs col0 s gr +% Polyline +n 3825 3105 m 4725 1890 l gs col0 s gr +% Polyline +n 5490 3105 m 3465 1890 l gs col0 s gr +% Polyline +n 5850 3105 m 3870 1890 l gs col0 s gr +% Polyline +n 6345 3105 m 6525 1890 l gs col0 s gr +% Polyline +n 6795 3105 m 5625 1890 l gs col0 s gr +% Polyline +n 7290 3105 m 5175 1890 l gs col0 s gr +% Polyline +n 4320 3105 m 5535 1890 l gs col0 s gr +/Times-Roman ff 180.00 scf sf +3285 1035 m +gs 1 -1 sc (0) col0 sh gr +/Times-Roman ff 180.00 scf sf +3735 1035 m +gs 1 -1 sc (1) col0 sh gr +/Times-Roman ff 180.00 scf sf +4230 1035 m +gs 1 -1 sc (2) col0 sh gr +/Times-Roman ff 180.00 scf sf +4680 1035 m +gs 1 -1 sc (3) col0 sh gr +/Times-Roman ff 180.00 scf sf +5085 1035 m +gs 1 -1 sc (4) col0 sh gr +/Times-Roman ff 180.00 scf sf +5535 1035 m +gs 1 -1 sc (5) col0 sh gr +/Times-Roman ff 180.00 scf sf +5985 1035 m +gs 1 -1 sc (6) col0 sh gr +/Times-Roman ff 180.00 scf sf +6435 1035 m +gs 1 -1 sc (7) col0 sh gr +/Times-Roman ff 180.00 scf sf +5940 4320 m +gs 1 -1 sc (local indices) col0 sh gr +/Times-Roman ff 180.00 scf sf +5490 4635 m +gs 1 -1 sc (local array in processor 1) col0 sh gr +/Times-Roman ff 180.00 scf sf +3825 720 m +gs 1 -1 sc (global array with global indices) col0 sh gr +/Times-Italic ff 180.00 scf sf +2880 1665 m +gs 1 -1 sc (a:) col0 sh gr +/Times-Italic ff 180.00 scf sf +2070 3555 m +gs 1 -1 sc (a0:) col0 sh gr +/Times-Italic ff 180.00 scf sf +4995 3555 m +gs 1 -1 sc (a1:) col0 sh gr +$F2psEnd +rs diff -Nru dune-common-2.2.1/doc/comm/figures/distarray.eps dune-common-2.5.2~20170808ga5c076ca/doc/comm/figures/distarray.eps --- dune-common-2.2.1/doc/comm/figures/distarray.eps 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/figures/distarray.eps 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,1278 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: inkscape 0.44.1 +%%Pages: 1 +%%Orientation: Portrait +%%BoundingBox: -43 616 613 832 +%%HiResBoundingBox: -43.106274 616.19711 612.40005 831.58167 +%%DocumentMedia: plain 596 842 0 () () +%%EndComments +%%Page: 1 1 +0 842 translate +0.8 -0.8 scale +gsave [1 0 0 1 0 0] concat +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +130.75 35.229931 moveto +168.75 35.229931 lineto +168.75 70.229931 lineto +130.75 70.229931 lineto +130.75 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +170.25 35.229931 moveto +208.25 35.229931 lineto +208.25 70.229931 lineto +170.25 70.229931 lineto +170.25 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +565.25 35.229931 moveto +603.25 35.229931 lineto +603.25 70.229931 lineto +565.25 70.229931 lineto +565.25 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +525.75 35.229931 moveto +563.75 35.229931 lineto +563.75 70.229931 lineto +525.75 70.229931 lineto +525.75 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +486.25 35.229931 moveto +524.25 35.229931 lineto +524.25 70.229931 lineto +486.25 70.229931 lineto +486.25 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +446.75 35.229931 moveto +484.75 35.229931 lineto +484.75 70.229931 lineto +446.75 70.229931 lineto +446.75 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +407.25 35.229931 moveto +445.25 35.229931 lineto +445.25 70.229931 lineto +407.25 70.229931 lineto +407.25 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +367.75 35.229931 moveto +405.75 35.229931 lineto +405.75 70.229931 lineto +367.75 70.229931 lineto +367.75 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +328.25 35.229931 moveto +366.25 35.229931 lineto +366.25 70.229931 lineto +328.25 70.229931 lineto +328.25 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +288.75 35.229931 moveto +326.75 35.229931 lineto +326.75 70.229931 lineto +288.75 70.229931 lineto +288.75 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +249.25 35.229931 moveto +287.25 35.229931 lineto +287.25 70.229931 lineto +249.25 70.229931 lineto +249.25 35.229931 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +209.75 35.229931 moveto +247.75 35.229931 lineto +247.75 70.229931 lineto +209.75 70.229931 lineto +209.75 35.229931 lineto +closepath +stroke +gsave [1 0 0 1 90.45711 -21.76955] concat +gsave [1 0 0 -1 56 78.362183] concat +gsave +/newlatin1font {findfont dup length dict copy dup /Encoding ISOLatin1Encoding put definefont} def +/(BitstreamVeraSans-Roman-ISOLatin1) /(BitstreamVeraSans-Roman) newlatin1font +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(0) show +grestore +grestore +gsave [1 0 0 -1 95.71582 78.369019] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(1) show +grestore +grestore +gsave [1 0 0 -1 135.17871 78.461304] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(2) show +grestore +grestore +gsave [1 0 0 -1 174.25195 78.362183] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(3) show +grestore +grestore +gsave [1 0 0 -1 213.27051 78.369019] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(4) show +grestore +grestore +gsave [1 0 0 -1 253.06152 78.269897] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(5) show +grestore +grestore +gsave [1 0 0 -1 292.07324 78.362183] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(6) show +grestore +grestore +gsave [1 0 0 -1 331.74121 78.369019] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(7) show +grestore +grestore +gsave [1 0 0 -1 370.85547 78.362183] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(8) show +grestore +grestore +gsave [1 0 0 -1 410.23633 78.362183] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(9) show +grestore +grestore +gsave [1 0 0 -1 440.62109 78.362183] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(10) show +grestore +grestore +gsave [1 0 0 -1 480.33691 78.369019] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(11) show +grestore +grestore +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +644.59235 134.57874 moveto +682.59235 134.57874 lineto +682.59235 169.57874 lineto +644.59235 169.57874 lineto +644.59235 134.57874 lineto +closepath +stroke +gsave [1 0 0 -1 320.31937 23.521814] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(global array) show +grestore +grestore +gsave [1 0 0 -1 94.752312 53.220303] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(a:) show +grestore +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +54.781971 134.38783 moveto +92.781971 134.38783 lineto +92.781971 169.38783 lineto +54.781971 169.38783 lineto +54.781971 134.38783 lineto +closepath +stroke +gsave +0.79607844 0.79607844 0.79607844 setrgbcolor +newpath +291.03198 133.63783 moveto +330.53198 133.63783 lineto +330.53198 170.13783 lineto +291.03198 170.13783 lineto +291.03198 133.63783 lineto +closepath +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1 setlinewidth +0 setlinejoin +0 setlinecap +newpath +291.03198 133.63783 moveto +330.53198 133.63783 lineto +330.53198 170.13783 lineto +291.03198 170.13783 lineto +291.03198 133.63783 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +252.28197 134.38783 moveto +290.28197 134.38783 lineto +290.28197 169.38783 lineto +252.28197 169.38783 lineto +252.28197 134.38783 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +212.78197 134.38783 moveto +250.78197 134.38783 lineto +250.78197 169.38783 lineto +212.78197 169.38783 lineto +212.78197 134.38783 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +173.28197 134.38783 moveto +211.28197 134.38783 lineto +211.28197 169.38783 lineto +173.28197 169.38783 lineto +173.28197 134.38783 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +133.78197 134.38783 moveto +171.78197 134.38783 lineto +171.78197 169.38783 lineto +133.78197 169.38783 lineto +133.78197 134.38783 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +94.281967 134.38783 moveto +132.28197 134.38783 lineto +132.28197 169.38783 lineto +94.281967 169.38783 lineto +94.281967 134.38783 lineto +closepath +stroke +gsave [1.05799 0 0 1 -76.67982 40.7414] concat +gsave [1 0 0 -1 138.59293 118.27412] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(0) show +grestore +grestore +gsave [1 0 0 -1 176.39273 118.28096] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(1) show +grestore +grestore +gsave [1 0 0 -1 213.93961 118.37325] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(2) show +grestore +grestore +gsave [1 0 0 -1 251.09683 118.27412] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(3) show +grestore +grestore +gsave [1 0 0 -1 288.19937 118.28096] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(4) show +grestore +grestore +gsave [1 0 0 -1 326.07437 118.18184] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(5) show +grestore +grestore +gsave [1 0 0 -1 363.17007 118.27412] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(6) show +grestore +grestore +grestore +gsave +0.79607844 0.79607844 0.79607844 setrgbcolor +newpath +408.72391 134.59494 moveto +446.72391 134.59494 lineto +446.72391 169.59494 lineto +408.72391 169.59494 lineto +408.72391 134.59494 lineto +closepath +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +408.72391 134.59494 moveto +446.72391 134.59494 lineto +446.72391 169.59494 lineto +408.72391 169.59494 lineto +408.72391 134.59494 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +606.22388 134.59494 moveto +644.22388 134.59494 lineto +644.22388 169.59494 lineto +606.22388 169.59494 lineto +606.22388 134.59494 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +566.72388 134.59494 moveto +604.72388 134.59494 lineto +604.72388 169.59494 lineto +566.72388 169.59494 lineto +566.72388 134.59494 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +527.22388 134.59494 moveto +565.22388 134.59494 lineto +565.22388 169.59494 lineto +527.22388 169.59494 lineto +527.22388 134.59494 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +487.72391 134.59494 moveto +525.72391 134.59494 lineto +525.72391 169.59494 lineto +487.72391 169.59494 lineto +487.72391 134.59494 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +448.22391 134.59494 moveto +486.22391 134.59494 lineto +486.22391 169.59494 lineto +448.22391 169.59494 lineto +448.22391 134.59494 lineto +closepath +stroke +gsave [1 0 0 -1 421.10342 157.16211] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(5) show +grestore +grestore +gsave [1 0 0 -1 461.11514 157.25439] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(6) show +grestore +grestore +gsave [1 0 0 -1 501.78314 157.26123] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(7) show +grestore +grestore +gsave [1 0 0 -1 541.8974 157.25439] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(8) show +grestore +grestore +gsave [1 0 0 -1 582.27826 157.25439] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(9) show +grestore +grestore +gsave [1 0 0 -1 613.66302 157.25439] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(10) show +grestore +grestore +gsave [1 0 0 -1 654.37885 157.26123] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(11) show +grestore +grestore +gsave +0.79607844 0.79607844 0.79607844 setrgbcolor +newpath +292.38773 195.09746 moveto +330.38773 195.09746 lineto +330.38773 230.09746 lineto +292.38773 230.09746 lineto +292.38773 195.09746 lineto +closepath +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +292.38773 195.09746 moveto +330.38773 195.09746 lineto +330.38773 230.09746 lineto +292.38773 230.09746 lineto +292.38773 195.09746 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +252.88774 195.09746 moveto +290.88774 195.09746 lineto +290.88774 230.09746 lineto +252.88774 230.09746 lineto +252.88774 195.09746 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +213.38774 195.09746 moveto +251.38774 195.09746 lineto +251.38774 230.09746 lineto +213.38774 230.09746 lineto +213.38774 195.09746 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +173.88776 195.09746 moveto +211.88776 195.09746 lineto +211.88776 230.09746 lineto +173.88776 230.09746 lineto +173.88776 195.09746 lineto +closepath +stroke +gsave +0.79607844 0.79607844 0.79607844 setrgbcolor +newpath +134.38776 195.09746 moveto +172.38776 195.09746 lineto +172.38776 230.09746 lineto +134.38776 230.09746 lineto +134.38776 195.09746 lineto +closepath +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +134.38776 195.09746 moveto +172.38776 195.09746 lineto +172.38776 230.09746 lineto +134.38776 230.09746 lineto +134.38776 195.09746 lineto +closepath +stroke +gsave +0.79607844 0.79607844 0.79607844 setrgbcolor +newpath +94.887749 195.09746 moveto +132.88775 195.09746 lineto +132.88775 230.09746 lineto +94.887749 230.09746 lineto +94.887749 195.09746 lineto +closepath +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +94.887749 195.09746 moveto +132.88775 195.09746 lineto +132.88775 230.09746 lineto +94.887749 230.09746 lineto +94.887749 195.09746 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +55.387745 195.09746 moveto +93.387745 195.09746 lineto +93.387745 230.09746 lineto +55.387745 230.09746 lineto +55.387745 195.09746 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +15.887744 195.09746 moveto +53.887744 195.09746 lineto +53.887744 230.09746 lineto +15.887744 230.09746 lineto +15.887744 195.09746 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +-23.612255 195.09746 moveto +14.387745 195.09746 lineto +14.387745 230.09746 lineto +-23.612255 230.09746 lineto +-23.612255 195.09746 lineto +closepath +stroke +gsave [1.065237 0 0 1 -54.35452 -47.7132] concat +gsave [1 0 0 -1 41.012192 264.64523] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(0) show +grestore +grestore +gsave [1 0 0 -1 78.429184 264.65207] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(1) show +grestore +grestore +gsave [1 0 0 -1 115.59325 264.74435] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(2) show +grestore +grestore +gsave [1 0 0 -1 152.36766 264.64523] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(3) show +grestore +grestore +gsave [1 0 0 -1 189.52489 264.55295] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(5) show +grestore +grestore +gsave [1 0 0 -1 226.23778 264.64523] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(6) show +grestore +grestore +gsave [1 0 0 -1 263.60693 264.65207] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(7) show +grestore +grestore +gsave [1 0 0 -1 300.42236 264.64523] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(8) show +grestore +grestore +gsave [1 0 0 -1 337.50439 264.64523] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(9) show +grestore +grestore +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +726.75006 191.62869 moveto +764.75006 191.62869 lineto +764.75006 226.62869 lineto +726.75006 226.62869 lineto +726.75006 191.62869 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +687.25006 191.62869 moveto +725.25006 191.62869 lineto +725.25006 226.62869 lineto +687.25006 226.62869 lineto +687.25006 191.62869 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +647.75006 191.62869 moveto +685.75006 191.62869 lineto +685.75006 226.62869 lineto +647.75006 226.62869 lineto +647.75006 191.62869 lineto +closepath +stroke +gsave +0.79607844 0.79607844 0.79607844 setrgbcolor +newpath +608.25006 191.62869 moveto +646.25006 191.62869 lineto +646.25006 226.62869 lineto +608.25006 226.62869 lineto +608.25006 191.62869 lineto +closepath +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +608.25006 191.62869 moveto +646.25006 191.62869 lineto +646.25006 226.62869 lineto +608.25006 226.62869 lineto +608.25006 191.62869 lineto +closepath +stroke +gsave +0.79607844 0.79607844 0.79607844 setrgbcolor +newpath +568.75006 191.62869 moveto +606.75006 191.62869 lineto +606.75006 226.62869 lineto +568.75006 226.62869 lineto +568.75006 191.62869 lineto +closepath +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +568.75006 191.62869 moveto +606.75006 191.62869 lineto +606.75006 226.62869 lineto +568.75006 226.62869 lineto +568.75006 191.62869 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +529.25006 191.62869 moveto +567.25006 191.62869 lineto +567.25006 226.62869 lineto +529.25006 226.62869 lineto +529.25006 191.62869 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +489.75006 191.62869 moveto +527.75006 191.62869 lineto +527.75006 226.62869 lineto +489.75006 226.62869 lineto +489.75006 191.62869 lineto +closepath +stroke +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +450.25006 191.62869 moveto +488.25006 191.62869 lineto +488.25006 226.62869 lineto +450.25006 226.62869 lineto +450.25006 191.62869 lineto +closepath +stroke +gsave +0.79607844 0.79607844 0.79607844 setrgbcolor +newpath +410.75006 191.62869 moveto +448.75006 191.62869 lineto +448.75006 226.62869 lineto +410.75006 226.62869 lineto +410.75006 191.62869 lineto +closepath +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +410.75006 191.62869 moveto +448.75006 191.62869 lineto +448.75006 226.62869 lineto +410.75006 226.62869 lineto +410.75006 191.62869 lineto +closepath +stroke +gsave [1 0 0 1 244.4658 -120.5452] concat +gsave [1 0 0 -1 181.01933 335.45502] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(2) show +grestore +grestore +gsave [1 0 0 -1 221.09258 335.3559] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(3) show +grestore +grestore +gsave [1 0 0 -1 261.11115 335.36273] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(4) show +grestore +grestore +gsave [1 0 0 -1 301.90216 335.26361] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(5) show +grestore +grestore +gsave [1 0 0 -1 341.91388 335.3559] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(6) show +grestore +grestore +gsave [1 0 0 -1 382.34259 335.3559] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(8) show +grestore +grestore +gsave [1 0 0 -1 422.72345 335.3559] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(9) show +grestore +grestore +gsave [1 0 0 -1 454.10822 335.3559] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(10) show +grestore +grestore +gsave [1 0 0 -1 494.82404 335.36273] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(11) show +grestore +grestore +grestore +gsave [1 0 0 -1 22.627417 158.24216] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(a0:) show +grestore +grestore +gsave [1 0 0 -1 381.13055 161.07059] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(a1:) show +grestore +grestore +gsave [1 0 0 -1 -55.154327 213.39648] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(b0:) show +grestore +grestore +gsave [1 0 0 -1 381.83765 211.98228] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(b1:) show +grestore +grestore +gsave [1.03432 0 0 0.966819 0 0] concat +gsave [1 0 0 -1 317.21094 112.36991] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +13.535465 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(local views) show +grestore +grestore +grestore +0 0 0 setrgbcolor +[] 0 setdash +1 setlinewidth +0 setlinejoin +0 setlinecap +newpath +370 281.61579 moveto +370 126.86218 lineto +stroke +gsave [1 0 0 -1 143.62598 255.36218] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(P0) show +grestore +grestore +gsave [1 0 0 -1 578.62598 253.86218] concat +gsave +/(BitstreamVeraSans-Roman-ISOLatin1) findfont +14 scalefont +setfont +0 0 0 setrgbcolor +newpath +0 0 moveto +(P1) show +grestore +grestore +grestore +showpage +%%EOF diff -Nru dune-common-2.2.1/doc/comm/figures/distindex.eps dune-common-2.5.2~20170808ga5c076ca/doc/comm/figures/distindex.eps --- dune-common-2.2.1/doc/comm/figures/distindex.eps 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/figures/distindex.eps 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,4736 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: inkscape 0.44.1 +%%Pages: 1 +%%Orientation: Portrait +%%BoundingBox: -5 414 276 601 +%%HiResBoundingBox: -5.9999911 414 276 600.4 +%%DocumentMedia: plain 596 842 0 () () +%%EndComments +%%Page: 1 1 +0 842 translate +0.8 -0.8 scale +gsave [1 0 0 1 0 0] concat +gsave +0 0 0 setrgbcolor +newpath +11.34082 347.36218 moveto +10.730139 348.41037 10.276689 349.44715 9.9804688 350.47253 curveto +9.6842421 351.49793 9.5361303 352.53699 9.5361328 353.58972 curveto +9.5361303 354.64246 9.6842421 355.68608 9.9804688 356.72058 curveto +10.281247 357.75053 10.734697 358.78731 11.34082 359.83093 curveto +10.24707 359.83093 lineto +9.563474 358.75997 9.0507792 357.70723 8.7089844 356.67273 curveto +8.3717434 355.63823 8.2031238 354.61056 8.203125 353.58972 curveto +8.2031238 352.57345 8.3717434 351.55034 8.7089844 350.52039 curveto +9.0462219 349.49045 9.5589167 348.43771 10.24707 347.36218 curveto +11.34082 347.36218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +15.155273 356.82312 moveto +19.974609 356.82312 lineto +19.974609 357.98523 lineto +13.494141 357.98523 lineto +13.494141 356.82312 lineto +14.018228 356.2808 14.731443 355.55392 15.633789 354.64246 curveto +16.540686 353.72644 17.110347 353.13628 17.342773 352.87195 curveto +17.784825 352.37521 18.092442 351.95594 18.265625 351.61414 curveto +18.443353 351.26779 18.53222 350.92827 18.532227 350.59558 curveto +18.53222 350.05327 18.340814 349.61121 17.958008 349.26941 curveto +17.579747 348.92762 17.085282 348.75672 16.474609 348.75671 curveto +16.041663 348.75672 15.583656 348.83192 15.100586 348.9823 curveto +14.622068 349.1327 14.109373 349.36056 13.5625 349.66589 curveto +13.5625 348.27136 lineto +14.118488 348.04806 14.638019 347.87945 15.121094 347.7655 curveto +15.604164 347.65158 16.04622 347.59461 16.447266 347.5946 curveto +17.504552 347.59461 18.34765 347.85894 18.976562 348.38757 curveto +19.605462 348.91623 19.919914 349.62261 19.919922 350.50671 curveto +19.919914 350.92599 19.840162 351.32475 19.680664 351.703 curveto +19.525709 352.07671 19.240879 352.51876 18.826172 353.02917 curveto +18.712233 353.16134 18.349929 353.54415 17.739258 354.17761 curveto +17.128576 354.80652 16.267249 355.68836 15.155273 356.82312 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +23.023438 356.2489 moveto +24.46582 356.2489 lineto +24.46582 357.42468 lineto +23.344727 359.61218 lineto +22.462891 359.61218 lineto +23.023438 357.42468 lineto +23.023438 356.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +28.526367 356.82312 moveto +33.345703 356.82312 lineto +33.345703 357.98523 lineto +26.865234 357.98523 lineto +26.865234 356.82312 lineto +27.389321 356.2808 28.102537 355.55392 29.004883 354.64246 curveto +29.91178 353.72644 30.481441 353.13628 30.713867 352.87195 curveto +31.155919 352.37521 31.463536 351.95594 31.636719 351.61414 curveto +31.814447 351.26779 31.903314 350.92827 31.90332 350.59558 curveto +31.903314 350.05327 31.711908 349.61121 31.329102 349.26941 curveto +30.950841 348.92762 30.456376 348.75672 29.845703 348.75671 curveto +29.412757 348.75672 28.954749 348.83192 28.47168 348.9823 curveto +27.993162 349.1327 27.480467 349.36056 26.933594 349.66589 curveto +26.933594 348.27136 lineto +27.489582 348.04806 28.009112 347.87945 28.492188 347.7655 curveto +28.975257 347.65158 29.417314 347.59461 29.818359 347.5946 curveto +30.875646 347.59461 31.718744 347.85894 32.347656 348.38757 curveto +32.976555 348.91623 33.291008 349.62261 33.291016 350.50671 curveto +33.291008 350.92599 33.211256 351.32475 33.051758 351.703 curveto +32.896803 352.07671 32.611972 352.51876 32.197266 353.02917 curveto +32.083327 353.16134 31.721023 353.54415 31.110352 354.17761 curveto +30.49967 354.80652 29.638343 355.68836 28.526367 356.82312 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +36.394531 356.2489 moveto +37.836914 356.2489 lineto +37.836914 357.42468 lineto +36.71582 359.61218 lineto +35.833984 359.61218 lineto +36.394531 357.42468 lineto +36.394531 356.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +43.49707 351.21082 moveto +42.822588 351.21082 42.289385 351.47514 41.897461 352.00378 curveto +41.505532 352.52788 41.309568 353.24793 41.30957 354.16394 curveto +41.309568 355.07996 41.503253 355.80229 41.890625 356.33093 curveto +42.282549 356.85502 42.81803 357.11707 43.49707 357.11707 curveto +44.166987 357.11707 44.697911 356.85274 45.089844 356.3241 curveto +45.481765 355.79545 45.677728 355.0754 45.677734 354.16394 curveto +45.677728 353.25704 45.481765 352.53927 45.089844 352.01062 curveto +44.697911 351.47742 44.166987 351.21082 43.49707 351.21082 curveto +43.49707 350.14441 moveto +44.590815 350.14442 45.449864 350.49989 46.074219 351.21082 curveto +46.69856 351.92176 47.010734 352.90613 47.010742 354.16394 curveto +47.010734 355.4172 46.69856 356.40157 46.074219 357.11707 curveto +45.449864 357.828 44.590815 358.18347 43.49707 358.18347 curveto +42.39876 358.18347 41.537433 357.828 40.913086 357.11707 curveto +40.293293 356.40157 39.983398 355.4172 39.983398 354.16394 curveto +39.983398 352.90613 40.293293 351.92176 40.913086 351.21082 curveto +41.537433 350.49989 42.39876 350.14442 43.49707 350.14441 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +48.890625 347.36218 moveto +49.984375 347.36218 lineto +50.667966 348.43771 51.178382 349.49045 51.515625 350.52039 curveto +51.857418 351.55034 52.028316 352.57345 52.02832 353.58972 curveto +52.028316 354.61056 51.857418 355.63823 51.515625 356.67273 curveto +51.178382 357.70723 50.667966 358.75997 49.984375 359.83093 curveto +48.890625 359.83093 lineto +49.496743 358.78731 49.947914 357.75053 50.244141 356.72058 curveto +50.544919 355.68608 50.69531 354.64246 50.695312 353.58972 curveto +50.69531 352.53699 50.544919 351.49793 50.244141 350.47253 curveto +49.947914 349.44715 49.496743 348.41037 48.890625 347.36218 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +32.34082 327.36218 moveto +31.730139 328.41037 31.276689 329.44715 30.980469 330.47253 curveto +30.684242 331.49793 30.53613 332.53699 30.536133 333.58972 curveto +30.53613 334.64246 30.684242 335.68608 30.980469 336.72058 curveto +31.281247 337.75053 31.734697 338.78731 32.34082 339.83093 curveto +31.24707 339.83093 lineto +30.563474 338.75997 30.050779 337.70723 29.708984 336.67273 curveto +29.371743 335.63823 29.203124 334.61056 29.203125 333.58972 curveto +29.203124 332.57345 29.371743 331.55034 29.708984 330.52039 curveto +30.046222 329.49045 30.558917 328.43771 31.24707 327.36218 curveto +32.34082 327.36218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +37.918945 328.68835 moveto +37.208004 328.68836 36.672523 329.03927 36.3125 329.74109 curveto +35.957029 330.43836 35.779295 331.48882 35.779297 332.89246 curveto +35.779295 334.29155 35.957029 335.342 36.3125 336.04382 curveto +36.672523 336.74109 37.208004 337.08972 37.918945 337.08972 curveto +38.634435 337.08972 39.169916 336.74109 39.525391 336.04382 curveto +39.88541 335.342 40.065423 334.29155 40.06543 332.89246 curveto +40.065423 331.48882 39.88541 330.43836 39.525391 329.74109 curveto +39.169916 329.03927 38.634435 328.68836 37.918945 328.68835 curveto +37.918945 327.5946 moveto +39.06282 327.59461 39.93554 328.04806 40.537109 328.95496 curveto +41.143221 329.85731 41.446281 331.16981 41.446289 332.89246 curveto +41.446281 334.61056 41.143221 335.92306 40.537109 336.82996 curveto +39.93554 337.7323 39.06282 338.18347 37.918945 338.18347 curveto +36.775062 338.18347 35.900063 337.7323 35.293945 336.82996 curveto +34.692382 335.92306 34.391601 334.61056 34.391602 332.89246 curveto +34.391601 331.16981 34.692382 329.85731 35.293945 328.95496 curveto +35.900063 328.04806 36.775062 327.59461 37.918945 327.5946 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +44.023438 336.2489 moveto +45.46582 336.2489 lineto +45.46582 337.42468 lineto +44.344727 339.61218 lineto +43.462891 339.61218 lineto +44.023438 337.42468 lineto +44.023438 336.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +51.290039 328.68835 moveto +50.579098 328.68836 50.043617 329.03927 49.683594 329.74109 curveto +49.328123 330.43836 49.150388 331.48882 49.150391 332.89246 curveto +49.150388 334.29155 49.328123 335.342 49.683594 336.04382 curveto +50.043617 336.74109 50.579098 337.08972 51.290039 337.08972 curveto +52.005529 337.08972 52.54101 336.74109 52.896484 336.04382 curveto +53.256504 335.342 53.436517 334.29155 53.436523 332.89246 curveto +53.436517 331.48882 53.256504 330.43836 52.896484 329.74109 curveto +52.54101 329.03927 52.005529 328.68836 51.290039 328.68835 curveto +51.290039 327.5946 moveto +52.433914 327.59461 53.306634 328.04806 53.908203 328.95496 curveto +54.514315 329.85731 54.817375 331.16981 54.817383 332.89246 curveto +54.817375 334.61056 54.514315 335.92306 53.908203 336.82996 curveto +53.306634 337.7323 52.433914 338.18347 51.290039 338.18347 curveto +50.146156 338.18347 49.271156 337.7323 48.665039 336.82996 curveto +48.063475 335.92306 47.762694 334.61056 47.762695 332.89246 curveto +47.762694 331.16981 48.063475 329.85731 48.665039 328.95496 curveto +49.271156 328.04806 50.146156 327.59461 51.290039 327.5946 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +57.394531 336.2489 moveto +58.836914 336.2489 lineto +58.836914 337.42468 lineto +57.71582 339.61218 lineto +56.833984 339.61218 lineto +57.394531 337.42468 lineto +57.394531 336.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +64.49707 331.21082 moveto +63.822588 331.21082 63.289385 331.47514 62.897461 332.00378 curveto +62.505532 332.52788 62.309568 333.24793 62.30957 334.16394 curveto +62.309568 335.07996 62.503253 335.80229 62.890625 336.33093 curveto +63.282549 336.85502 63.81803 337.11707 64.49707 337.11707 curveto +65.166987 337.11707 65.697911 336.85274 66.089844 336.3241 curveto +66.481765 335.79545 66.677728 335.0754 66.677734 334.16394 curveto +66.677728 333.25704 66.481765 332.53927 66.089844 332.01062 curveto +65.697911 331.47742 65.166987 331.21082 64.49707 331.21082 curveto +64.49707 330.14441 moveto +65.590815 330.14442 66.449864 330.49989 67.074219 331.21082 curveto +67.69856 331.92176 68.010734 332.90613 68.010742 334.16394 curveto +68.010734 335.4172 67.69856 336.40157 67.074219 337.11707 curveto +66.449864 337.828 65.590815 338.18347 64.49707 338.18347 curveto +63.39876 338.18347 62.537433 337.828 61.913086 337.11707 curveto +61.293293 336.40157 60.983398 335.4172 60.983398 334.16394 curveto +60.983398 332.90613 61.293293 331.92176 61.913086 331.21082 curveto +62.537433 330.49989 63.39876 330.14442 64.49707 330.14441 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +69.890625 327.36218 moveto +70.984375 327.36218 lineto +71.667966 328.43771 72.178382 329.49045 72.515625 330.52039 curveto +72.857418 331.55034 73.028316 332.57345 73.02832 333.58972 curveto +73.028316 334.61056 72.857418 335.63823 72.515625 336.67273 curveto +72.178382 337.70723 71.667966 338.75997 70.984375 339.83093 curveto +69.890625 339.83093 lineto +70.496743 338.78731 70.947914 337.75053 71.244141 336.72058 curveto +71.544919 335.68608 71.69531 334.64246 71.695312 333.58972 curveto +71.69531 332.53699 71.544919 331.49793 71.244141 330.47253 curveto +70.947914 329.44715 70.496743 328.41037 69.890625 327.36218 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +77.683594 328.36218 moveto +77.072913 329.41037 76.619463 330.44715 76.323242 331.47253 curveto +76.027016 332.49793 75.878904 333.53699 75.878906 334.58972 curveto +75.878904 335.64246 76.027016 336.68608 76.323242 337.72058 curveto +76.62402 338.75053 77.07747 339.78731 77.683594 340.83093 curveto +76.589844 340.83093 lineto +75.906247 339.75997 75.393553 338.70723 75.051758 337.67273 curveto +74.714517 336.63823 74.545897 335.61056 74.545898 334.58972 curveto +74.545897 333.57345 74.714517 332.55034 75.051758 331.52039 curveto +75.388995 330.49045 75.90169 329.43771 76.589844 328.36218 curveto +77.683594 328.36218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +80.547852 337.82312 moveto +82.803711 337.82312 lineto +82.803711 330.03699 lineto +80.349609 330.52917 lineto +80.349609 329.27136 lineto +82.790039 328.77917 lineto +84.170898 328.77917 lineto +84.170898 337.82312 lineto +86.426758 337.82312 lineto +86.426758 338.98523 lineto +80.547852 338.98523 lineto +80.547852 337.82312 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +89.366211 337.2489 moveto +90.808594 337.2489 lineto +90.808594 338.42468 lineto +89.6875 340.61218 lineto +88.805664 340.61218 lineto +89.366211 338.42468 lineto +89.366211 337.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +93.918945 337.82312 moveto +96.174805 337.82312 lineto +96.174805 330.03699 lineto +93.720703 330.52917 lineto +93.720703 329.27136 lineto +96.161133 328.77917 lineto +97.541992 328.77917 lineto +97.541992 337.82312 lineto +99.797852 337.82312 lineto +99.797852 338.98523 lineto +93.918945 338.98523 lineto +93.918945 337.82312 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +102.7373 337.2489 moveto +104.17969 337.2489 lineto +104.17969 338.42468 lineto +103.05859 340.61218 lineto +102.17676 340.61218 lineto +102.7373 338.42468 lineto +102.7373 337.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +109.83984 332.21082 moveto +109.16536 332.21082 108.63216 332.47514 108.24023 333.00378 curveto +107.8483 333.52788 107.65234 334.24793 107.65234 335.16394 curveto +107.65234 336.07996 107.84603 336.80229 108.2334 337.33093 curveto +108.62532 337.85502 109.1608 338.11707 109.83984 338.11707 curveto +110.50976 338.11707 111.04068 337.85274 111.43262 337.3241 curveto +111.82454 336.79545 112.0205 336.0754 112.02051 335.16394 curveto +112.0205 334.25704 111.82454 333.53927 111.43262 333.01062 curveto +111.04068 332.47742 110.50976 332.21082 109.83984 332.21082 curveto +109.83984 331.14441 moveto +110.93359 331.14442 111.79264 331.49989 112.41699 332.21082 curveto +113.04133 332.92176 113.35351 333.90613 113.35352 335.16394 curveto +113.35351 336.4172 113.04133 337.40157 112.41699 338.11707 curveto +111.79264 338.828 110.93359 339.18347 109.83984 339.18347 curveto +108.74153 339.18347 107.88021 338.828 107.25586 338.11707 curveto +106.63607 337.40157 106.32617 336.4172 106.32617 335.16394 curveto +106.32617 333.90613 106.63607 332.92176 107.25586 332.21082 curveto +107.88021 331.49989 108.74153 331.14442 109.83984 331.14441 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +115.2334 328.36218 moveto +116.32715 328.36218 lineto +117.01074 329.43771 117.52116 330.49045 117.8584 331.52039 curveto +118.20019 332.55034 118.37109 333.57345 118.37109 334.58972 curveto +118.37109 335.61056 118.20019 336.63823 117.8584 337.67273 curveto +117.52116 338.70723 117.01074 339.75997 116.32715 340.83093 curveto +115.2334 340.83093 lineto +115.83952 339.78731 116.29069 338.75053 116.58691 337.72058 curveto +116.88769 336.68608 117.03808 335.64246 117.03809 334.58972 curveto +117.03808 333.53699 116.88769 332.49793 116.58691 331.47253 curveto +116.29069 330.44715 115.83952 329.41037 115.2334 328.36218 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +56.84082 347.36218 moveto +56.230139 348.41037 55.776689 349.44715 55.480469 350.47253 curveto +55.184242 351.49793 55.03613 352.53699 55.036133 353.58972 curveto +55.03613 354.64246 55.184242 355.68608 55.480469 356.72058 curveto +55.781247 357.75053 56.234697 358.78731 56.84082 359.83093 curveto +55.74707 359.83093 lineto +55.063474 358.75997 54.550779 357.70723 54.208984 356.67273 curveto +53.871743 355.63823 53.703124 354.61056 53.703125 353.58972 curveto +53.703124 352.57345 53.871743 351.55034 54.208984 350.52039 curveto +54.546222 349.49045 55.058917 348.43771 55.74707 347.36218 curveto +56.84082 347.36218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +63.649414 352.4823 moveto +64.310215 352.62358 64.825188 352.91753 65.194336 353.36414 curveto +65.568026 353.81075 65.754875 354.36219 65.754883 355.01843 curveto +65.754875 356.0256 65.408521 356.80489 64.71582 357.35632 curveto +64.023106 357.90776 63.038732 358.18347 61.762695 358.18347 curveto +61.334307 358.18347 60.89225 358.14018 60.436523 358.05359 curveto +59.98535 357.97156 59.518228 357.84623 59.035156 357.67761 curveto +59.035156 356.3446 lineto +59.417967 356.56791 59.837238 356.73653 60.292969 356.85046 curveto +60.748695 356.9644 61.224932 357.02136 61.72168 357.02136 curveto +62.58756 357.02136 63.246088 356.85047 63.697266 356.50867 curveto +64.152989 356.16687 64.380853 355.67013 64.380859 355.01843 curveto +64.380853 354.41687 64.168939 353.94747 63.745117 353.61023 curveto +63.325841 353.26844 62.74023 353.09754 61.988281 353.09753 curveto +60.798828 353.09753 lineto +60.798828 351.96277 lineto +62.042969 351.96277 lineto +62.722 351.96277 63.241531 351.82833 63.601562 351.55945 curveto +63.961583 351.28602 64.141595 350.89409 64.141602 350.38367 curveto +64.141595 349.85959 63.954747 349.45855 63.581055 349.18054 curveto +63.211909 348.898 62.680985 348.75672 61.988281 348.75671 curveto +61.610022 348.75672 61.204424 348.79774 60.771484 348.87976 curveto +60.338539 348.9618 59.862303 349.08941 59.342773 349.26257 curveto +59.342773 348.0321 lineto +59.86686 347.88628 60.356768 347.77691 60.8125 347.70398 curveto +61.272783 347.63107 61.705725 347.59461 62.111328 347.5946 curveto +63.1595 347.59461 63.988926 347.83387 64.599609 348.31238 curveto +65.210279 348.78635 65.515617 349.42892 65.515625 350.24011 curveto +65.515617 350.80522 65.353834 351.28374 65.030273 351.67566 curveto +64.706699 352.06303 64.246413 352.33191 63.649414 352.4823 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +68.523438 356.2489 moveto +69.96582 356.2489 lineto +69.96582 357.42468 lineto +68.844727 359.61218 lineto +67.962891 359.61218 lineto +68.523438 357.42468 lineto +68.523438 356.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +77.020508 352.4823 moveto +77.681309 352.62358 78.196282 352.91753 78.56543 353.36414 curveto +78.93912 353.81075 79.125969 354.36219 79.125977 355.01843 curveto +79.125969 356.0256 78.779615 356.80489 78.086914 357.35632 curveto +77.3942 357.90776 76.409826 358.18347 75.133789 358.18347 curveto +74.7054 358.18347 74.263343 358.14018 73.807617 358.05359 curveto +73.356443 357.97156 72.889321 357.84623 72.40625 357.67761 curveto +72.40625 356.3446 lineto +72.789061 356.56791 73.208331 356.73653 73.664062 356.85046 curveto +74.119789 356.9644 74.596025 357.02136 75.092773 357.02136 curveto +75.958654 357.02136 76.617182 356.85047 77.068359 356.50867 curveto +77.524082 356.16687 77.751947 355.67013 77.751953 355.01843 curveto +77.751947 354.41687 77.540033 353.94747 77.116211 353.61023 curveto +76.696935 353.26844 76.111323 353.09754 75.359375 353.09753 curveto +74.169922 353.09753 lineto +74.169922 351.96277 lineto +75.414062 351.96277 lineto +76.093094 351.96277 76.612625 351.82833 76.972656 351.55945 curveto +77.332676 351.28602 77.512689 350.89409 77.512695 350.38367 curveto +77.512689 349.85959 77.32584 349.45855 76.952148 349.18054 curveto +76.583003 348.898 76.052079 348.75672 75.359375 348.75671 curveto +74.981116 348.75672 74.575518 348.79774 74.142578 348.87976 curveto +73.709633 348.9618 73.233397 349.08941 72.713867 349.26257 curveto +72.713867 348.0321 lineto +73.237954 347.88628 73.727862 347.77691 74.183594 347.70398 curveto +74.643877 347.63107 75.076819 347.59461 75.482422 347.5946 curveto +76.530594 347.59461 77.36002 347.83387 77.970703 348.31238 curveto +78.581373 348.78635 78.886711 349.42892 78.886719 350.24011 curveto +78.886711 350.80522 78.724928 351.28374 78.401367 351.67566 curveto +78.077793 352.06303 77.617507 352.33191 77.020508 352.4823 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +81.894531 356.2489 moveto +83.336914 356.2489 lineto +83.336914 357.42468 lineto +82.21582 359.61218 lineto +81.333984 359.61218 lineto +81.894531 357.42468 lineto +81.894531 356.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +88.99707 351.21082 moveto +88.322588 351.21082 87.789385 351.47514 87.397461 352.00378 curveto +87.005532 352.52788 86.809568 353.24793 86.80957 354.16394 curveto +86.809568 355.07996 87.003253 355.80229 87.390625 356.33093 curveto +87.782549 356.85502 88.31803 357.11707 88.99707 357.11707 curveto +89.666987 357.11707 90.197911 356.85274 90.589844 356.3241 curveto +90.981765 355.79545 91.177728 355.0754 91.177734 354.16394 curveto +91.177728 353.25704 90.981765 352.53927 90.589844 352.01062 curveto +90.197911 351.47742 89.666987 351.21082 88.99707 351.21082 curveto +88.99707 350.14441 moveto +90.090815 350.14442 90.949864 350.49989 91.574219 351.21082 curveto +92.19856 351.92176 92.510734 352.90613 92.510742 354.16394 curveto +92.510734 355.4172 92.19856 356.40157 91.574219 357.11707 curveto +90.949864 357.828 90.090815 358.18347 88.99707 358.18347 curveto +87.89876 358.18347 87.037433 357.828 86.413086 357.11707 curveto +85.793293 356.40157 85.483398 355.4172 85.483398 354.16394 curveto +85.483398 352.90613 85.793293 351.92176 86.413086 351.21082 curveto +87.037433 350.49989 87.89876 350.14442 88.99707 350.14441 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +94.390625 347.36218 moveto +95.484375 347.36218 lineto +96.167966 348.43771 96.678382 349.49045 97.015625 350.52039 curveto +97.357418 351.55034 97.528316 352.57345 97.52832 353.58972 curveto +97.528316 354.61056 97.357418 355.63823 97.015625 356.67273 curveto +96.678382 357.70723 96.167966 358.75997 95.484375 359.83093 curveto +94.390625 359.83093 lineto +94.996743 358.78731 95.447914 357.75053 95.744141 356.72058 curveto +96.044919 355.68608 96.19531 354.64246 96.195312 353.58972 curveto +96.19531 352.53699 96.044919 351.49793 95.744141 350.47253 curveto +95.447914 349.44715 94.996743 348.41037 94.390625 347.36218 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +102.34082 348.36218 moveto +101.73014 349.41037 101.27669 350.44715 100.98047 351.47253 curveto +100.68424 352.49793 100.53613 353.53699 100.53613 354.58972 curveto +100.53613 355.64246 100.68424 356.68608 100.98047 357.72058 curveto +101.28125 358.75053 101.7347 359.78731 102.34082 360.83093 curveto +101.24707 360.83093 lineto +100.56347 359.75997 100.05078 358.70723 99.708984 357.67273 curveto +99.371743 356.63823 99.203124 355.61056 99.203125 354.58972 curveto +99.203124 353.57345 99.371743 352.55034 99.708984 351.52039 curveto +100.04622 350.49045 100.55892 349.43771 101.24707 348.36218 curveto +102.34082 348.36218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +108.75977 349.9823 moveto +105.27344 355.43054 lineto +108.75977 355.43054 lineto +108.75977 349.9823 lineto +108.39746 348.77917 moveto +110.13379 348.77917 lineto +110.13379 355.43054 lineto +111.58984 355.43054 lineto +111.58984 356.57898 lineto +110.13379 356.57898 lineto +110.13379 358.98523 lineto +108.75977 358.98523 lineto +108.75977 356.57898 lineto +104.15234 356.57898 lineto +104.15234 355.24597 lineto +108.39746 348.77917 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +114.02344 357.2489 moveto +115.46582 357.2489 lineto +115.46582 358.42468 lineto +114.34473 360.61218 lineto +113.46289 360.61218 lineto +114.02344 358.42468 lineto +114.02344 357.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +122.13086 349.9823 moveto +118.64453 355.43054 lineto +122.13086 355.43054 lineto +122.13086 349.9823 lineto +121.76855 348.77917 moveto +123.50488 348.77917 lineto +123.50488 355.43054 lineto +124.96094 355.43054 lineto +124.96094 356.57898 lineto +123.50488 356.57898 lineto +123.50488 358.98523 lineto +122.13086 358.98523 lineto +122.13086 356.57898 lineto +117.52344 356.57898 lineto +117.52344 355.24597 lineto +121.76855 348.77917 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +127.39453 357.2489 moveto +128.83691 357.2489 lineto +128.83691 358.42468 lineto +127.71582 360.61218 lineto +126.83398 360.61218 lineto +127.39453 358.42468 lineto +127.39453 357.2489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +134.49707 352.21082 moveto +133.82259 352.21082 133.28938 352.47514 132.89746 353.00378 curveto +132.50553 353.52788 132.30957 354.24793 132.30957 355.16394 curveto +132.30957 356.07996 132.50325 356.80229 132.89062 357.33093 curveto +133.28255 357.85502 133.81803 358.11707 134.49707 358.11707 curveto +135.16699 358.11707 135.69791 357.85274 136.08984 357.3241 curveto +136.48176 356.79545 136.67773 356.0754 136.67773 355.16394 curveto +136.67773 354.25704 136.48176 353.53927 136.08984 353.01062 curveto +135.69791 352.47742 135.16699 352.21082 134.49707 352.21082 curveto +134.49707 351.14441 moveto +135.59081 351.14442 136.44986 351.49989 137.07422 352.21082 curveto +137.69856 352.92176 138.01073 353.90613 138.01074 355.16394 curveto +138.01073 356.4172 137.69856 357.40157 137.07422 358.11707 curveto +136.44986 358.828 135.59081 359.18347 134.49707 359.18347 curveto +133.39876 359.18347 132.53743 358.828 131.91309 358.11707 curveto +131.29329 357.40157 130.9834 356.4172 130.9834 355.16394 curveto +130.9834 353.90613 131.29329 352.92176 131.91309 352.21082 curveto +132.53743 351.49989 133.39876 351.14442 134.49707 351.14441 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +139.89062 348.36218 moveto +140.98438 348.36218 lineto +141.66797 349.43771 142.17838 350.49045 142.51562 351.52039 curveto +142.85742 352.55034 143.02832 353.57345 143.02832 354.58972 curveto +143.02832 355.61056 142.85742 356.63823 142.51562 357.67273 curveto +142.17838 358.70723 141.66797 359.75997 140.98438 360.83093 curveto +139.89062 360.83093 lineto +140.49674 359.78731 140.94791 358.75053 141.24414 357.72058 curveto +141.54492 356.68608 141.69531 355.64246 141.69531 354.58972 curveto +141.69531 353.53699 141.54492 352.49793 141.24414 351.47253 curveto +140.94791 350.44715 140.49674 349.41037 139.89062 348.36218 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +27.34082 371.86218 moveto +26.730139 372.91037 26.276689 373.94715 25.980469 374.97253 curveto +25.684242 375.99793 25.53613 377.03699 25.536133 378.08972 curveto +25.53613 379.14246 25.684242 380.18608 25.980469 381.22058 curveto +26.281247 382.25053 26.734697 383.28731 27.34082 384.33093 curveto +26.24707 384.33093 lineto +25.563474 383.25997 25.050779 382.20723 24.708984 381.17273 curveto +24.371743 380.13823 24.203124 379.11056 24.203125 378.08972 curveto +24.203124 377.07345 24.371743 376.05034 24.708984 375.02039 curveto +25.046222 373.99045 25.558917 372.93771 26.24707 371.86218 curveto +27.34082 371.86218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +29.979492 372.27917 moveto +35.400391 372.27917 lineto +35.400391 373.44128 lineto +31.244141 373.44128 lineto +31.244141 375.94324 lineto +31.444658 375.87488 31.645179 375.82475 31.845703 375.79285 curveto +32.04622 375.7564 32.246741 375.73817 32.447266 375.73816 curveto +33.586583 375.73817 34.488926 376.05034 35.154297 376.67468 curveto +35.819654 377.29904 36.152336 378.14441 36.152344 379.21082 curveto +36.152336 380.30912 35.81054 381.16362 35.126953 381.77429 curveto +34.443353 382.38041 33.479487 382.68347 32.235352 382.68347 curveto +31.806963 382.68347 31.369463 382.64701 30.922852 382.5741 curveto +30.480792 382.50118 30.022785 382.39181 29.548828 382.24597 curveto +29.548828 380.85828 lineto +29.958983 381.08159 30.382811 381.24793 30.820312 381.3573 curveto +31.25781 381.46668 31.720374 381.52136 32.208008 381.52136 curveto +32.996415 381.52136 33.620763 381.31401 34.081055 380.89929 curveto +34.541335 380.48458 34.771478 379.92176 34.771484 379.21082 curveto +34.771478 378.49988 34.541335 377.93706 34.081055 377.52234 curveto +33.620763 377.10763 32.996415 376.90027 32.208008 376.90027 curveto +31.838864 376.90027 31.469724 376.94129 31.100586 377.02332 curveto +30.736 377.10535 30.362303 377.23296 29.979492 377.40613 curveto +29.979492 372.27917 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +39.023438 380.7489 moveto +40.46582 380.7489 lineto +40.46582 381.92468 lineto +39.344727 384.11218 lineto +38.462891 384.11218 lineto +39.023438 381.92468 lineto +39.023438 380.7489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +43.350586 372.27917 moveto +48.771484 372.27917 lineto +48.771484 373.44128 lineto +44.615234 373.44128 lineto +44.615234 375.94324 lineto +44.815752 375.87488 45.016273 375.82475 45.216797 375.79285 curveto +45.417314 375.7564 45.617835 375.73817 45.818359 375.73816 curveto +46.957677 375.73817 47.86002 376.05034 48.525391 376.67468 curveto +49.190748 377.29904 49.52343 378.14441 49.523438 379.21082 curveto +49.52343 380.30912 49.181633 381.16362 48.498047 381.77429 curveto +47.814447 382.38041 46.850581 382.68347 45.606445 382.68347 curveto +45.178057 382.68347 44.740557 382.64701 44.293945 382.5741 curveto +43.851886 382.50118 43.393879 382.39181 42.919922 382.24597 curveto +42.919922 380.85828 lineto +43.330077 381.08159 43.753904 381.24793 44.191406 381.3573 curveto +44.628903 381.46668 45.091468 381.52136 45.579102 381.52136 curveto +46.367508 381.52136 46.991857 381.31401 47.452148 380.89929 curveto +47.912429 380.48458 48.142572 379.92176 48.142578 379.21082 curveto +48.142572 378.49988 47.912429 377.93706 47.452148 377.52234 curveto +46.991857 377.10763 46.367508 376.90027 45.579102 376.90027 curveto +45.209958 376.90027 44.840817 376.94129 44.47168 377.02332 curveto +44.107094 377.10535 43.733397 377.23296 43.350586 377.40613 curveto +43.350586 372.27917 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +52.394531 380.7489 moveto +53.836914 380.7489 lineto +53.836914 381.92468 lineto +52.71582 384.11218 lineto +51.833984 384.11218 lineto +52.394531 381.92468 lineto +52.394531 380.7489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +59.49707 375.71082 moveto +58.822588 375.71082 58.289385 375.97514 57.897461 376.50378 curveto +57.505532 377.02788 57.309568 377.74793 57.30957 378.66394 curveto +57.309568 379.57996 57.503253 380.30229 57.890625 380.83093 curveto +58.282549 381.35502 58.81803 381.61707 59.49707 381.61707 curveto +60.166987 381.61707 60.697911 381.35274 61.089844 380.8241 curveto +61.481765 380.29545 61.677728 379.5754 61.677734 378.66394 curveto +61.677728 377.75704 61.481765 377.03927 61.089844 376.51062 curveto +60.697911 375.97742 60.166987 375.71082 59.49707 375.71082 curveto +59.49707 374.64441 moveto +60.590815 374.64442 61.449864 374.99989 62.074219 375.71082 curveto +62.69856 376.42176 63.010734 377.40613 63.010742 378.66394 curveto +63.010734 379.9172 62.69856 380.90157 62.074219 381.61707 curveto +61.449864 382.328 60.590815 382.68347 59.49707 382.68347 curveto +58.39876 382.68347 57.537433 382.328 56.913086 381.61707 curveto +56.293293 380.90157 55.983398 379.9172 55.983398 378.66394 curveto +55.983398 377.40613 56.293293 376.42176 56.913086 375.71082 curveto +57.537433 374.99989 58.39876 374.64442 59.49707 374.64441 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +64.890625 371.86218 moveto +65.984375 371.86218 lineto +66.667966 372.93771 67.178382 373.99045 67.515625 375.02039 curveto +67.857418 376.05034 68.028316 377.07345 68.02832 378.08972 curveto +68.028316 379.11056 67.857418 380.13823 67.515625 381.17273 curveto +67.178382 382.20723 66.667966 383.25997 65.984375 384.33093 curveto +64.890625 384.33093 lineto +65.496743 383.28731 65.947914 382.25053 66.244141 381.22058 curveto +66.544919 380.18608 66.69531 379.14246 66.695312 378.08972 curveto +66.69531 377.03699 66.544919 375.99793 66.244141 374.97253 curveto +65.947914 373.94715 65.496743 372.91037 64.890625 371.86218 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +75.84082 370.86218 moveto +75.230139 371.91037 74.776689 372.94715 74.480469 373.97253 curveto +74.184242 374.99793 74.03613 376.03699 74.036133 377.08972 curveto +74.03613 378.14246 74.184242 379.18608 74.480469 380.22058 curveto +74.781247 381.25053 75.234697 382.28731 75.84082 383.33093 curveto +74.74707 383.33093 lineto +74.063474 382.25997 73.550779 381.20723 73.208984 380.17273 curveto +72.871743 379.13823 72.703124 378.11056 72.703125 377.08972 curveto +72.703124 376.07345 72.871743 375.05034 73.208984 374.02039 curveto +73.546222 372.99045 74.058917 371.93771 74.74707 370.86218 curveto +75.84082 370.86218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +81.589844 375.83191 moveto +80.970048 375.83191 80.477861 376.04383 80.113281 376.46765 curveto +79.753252 376.89148 79.57324 377.47254 79.573242 378.21082 curveto +79.57324 378.94454 79.753252 379.5256 80.113281 379.95398 curveto +80.477861 380.37781 80.970048 380.58972 81.589844 380.58972 curveto +82.20963 380.58972 82.699539 380.37781 83.05957 379.95398 curveto +83.424147 379.5256 83.606439 378.94454 83.606445 378.21082 curveto +83.606439 377.47254 83.424147 376.89148 83.05957 376.46765 curveto +82.699539 376.04383 82.20963 375.83191 81.589844 375.83191 curveto +84.331055 371.50476 moveto +84.331055 372.76257 lineto +83.984694 372.59852 83.633782 372.47319 83.27832 372.3866 curveto +82.927403 372.30002 82.57877 372.25672 82.232422 372.25671 curveto +81.320959 372.25672 80.623694 372.56434 80.140625 373.17957 curveto +79.662107 373.79481 79.388669 374.72449 79.320312 375.96863 curveto +79.58919 375.57215 79.926429 375.26909 80.332031 375.05945 curveto +80.737626 374.84526 81.184241 374.73817 81.671875 374.73816 curveto +82.69726 374.73817 83.506178 375.05034 84.098633 375.67468 curveto +84.69563 376.29448 84.994133 377.13986 84.994141 378.21082 curveto +84.994133 379.25899 84.684237 380.09981 84.064453 380.73328 curveto +83.444655 381.36674 82.619786 381.68347 81.589844 381.68347 curveto +80.409502 381.68347 79.507159 381.2323 78.882812 380.32996 curveto +78.258462 379.42306 77.946288 378.11056 77.946289 376.39246 curveto +77.946288 374.77918 78.3291 373.49403 79.094727 372.53699 curveto +79.860349 371.57541 80.888017 371.09461 82.177734 371.0946 curveto +82.524083 371.09461 82.872715 371.12879 83.223633 371.19714 curveto +83.579095 371.26551 83.948235 371.36805 84.331055 371.50476 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +87.523438 379.7489 moveto +88.96582 379.7489 lineto +88.96582 380.92468 lineto +87.844727 383.11218 lineto +86.962891 383.11218 lineto +87.523438 380.92468 lineto +87.523438 379.7489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +94.960938 375.83191 moveto +94.341142 375.83191 93.848955 376.04383 93.484375 376.46765 curveto +93.124346 376.89148 92.944333 377.47254 92.944336 378.21082 curveto +92.944333 378.94454 93.124346 379.5256 93.484375 379.95398 curveto +93.848955 380.37781 94.341142 380.58972 94.960938 380.58972 curveto +95.580724 380.58972 96.070632 380.37781 96.430664 379.95398 curveto +96.795241 379.5256 96.977532 378.94454 96.977539 378.21082 curveto +96.977532 377.47254 96.795241 376.89148 96.430664 376.46765 curveto +96.070632 376.04383 95.580724 375.83191 94.960938 375.83191 curveto +97.702148 371.50476 moveto +97.702148 372.76257 lineto +97.355787 372.59852 97.004876 372.47319 96.649414 372.3866 curveto +96.298497 372.30002 95.949864 372.25672 95.603516 372.25671 curveto +94.692053 372.25672 93.994788 372.56434 93.511719 373.17957 curveto +93.0332 373.79481 92.759763 374.72449 92.691406 375.96863 curveto +92.960284 375.57215 93.297523 375.26909 93.703125 375.05945 curveto +94.10872 374.84526 94.555334 374.73817 95.042969 374.73816 curveto +96.068354 374.73817 96.877272 375.05034 97.469727 375.67468 curveto +98.066724 376.29448 98.365226 377.13986 98.365234 378.21082 curveto +98.365226 379.25899 98.055331 380.09981 97.435547 380.73328 curveto +96.815749 381.36674 95.99088 381.68347 94.960938 381.68347 curveto +93.780596 381.68347 92.878253 381.2323 92.253906 380.32996 curveto +91.629556 379.42306 91.317382 378.11056 91.317383 376.39246 curveto +91.317382 374.77918 91.700194 373.49403 92.46582 372.53699 curveto +93.231442 371.57541 94.259111 371.09461 95.548828 371.0946 curveto +95.895177 371.09461 96.243809 371.12879 96.594727 371.19714 curveto +96.950189 371.26551 97.319329 371.36805 97.702148 371.50476 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +100.89453 379.7489 moveto +102.33691 379.7489 lineto +102.33691 380.92468 lineto +101.21582 383.11218 lineto +100.33398 383.11218 lineto +100.89453 380.92468 lineto +100.89453 379.7489 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +110.06836 377.56824 moveto +110.06835 376.65678 109.87923 375.9504 109.50098 375.4491 curveto +109.12727 374.9478 108.60091 374.69715 107.92188 374.69714 curveto +107.24739 374.69715 106.72103 374.9478 106.34277 375.4491 curveto +105.96907 375.9504 105.78222 376.65678 105.78223 377.56824 curveto +105.78222 378.47514 105.96907 379.17924 106.34277 379.68054 curveto +106.72103 380.18185 107.24739 380.4325 107.92188 380.4325 curveto +108.60091 380.4325 109.12727 380.18185 109.50098 379.68054 curveto +109.87923 379.17924 110.06835 378.47514 110.06836 377.56824 curveto +111.32617 380.53503 moveto +111.32616 381.83842 111.03678 382.80684 110.45801 383.44031 curveto +109.87923 384.07833 108.99283 384.39734 107.79883 384.39734 curveto +107.35677 384.39734 106.93978 384.36316 106.54785 384.2948 curveto +106.15592 384.23099 105.77539 384.13073 105.40625 383.99402 curveto +105.40625 382.77039 lineto +105.77539 382.97091 106.13997 383.11902 106.5 383.21472 curveto +106.86002 383.31042 107.22688 383.35827 107.60059 383.35828 curveto +108.42545 383.35827 109.04296 383.1418 109.45312 382.70886 curveto +109.86328 382.28048 110.06835 381.63106 110.06836 380.76062 curveto +110.06836 380.13855 lineto +109.80859 380.58972 109.47591 380.92696 109.07031 381.15027 curveto +108.66471 381.37358 108.17936 381.48523 107.61426 381.48523 curveto +106.67545 381.48523 105.91894 381.12748 105.34473 380.41199 curveto +104.77051 379.69649 104.4834 378.74858 104.4834 377.56824 curveto +104.4834 376.38335 104.77051 375.43315 105.34473 374.71765 curveto +105.91894 374.00216 106.67545 373.64442 107.61426 373.64441 curveto +108.17936 373.64442 108.66471 373.75607 109.07031 373.97937 curveto +109.47591 374.20268 109.80859 374.53992 110.06836 374.99109 curveto +110.06836 373.82898 lineto +111.32617 373.82898 lineto +111.32617 380.53503 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +113.71875 370.86218 moveto +114.8125 370.86218 lineto +115.49609 371.93771 116.00651 372.99045 116.34375 374.02039 curveto +116.68554 375.05034 116.85644 376.07345 116.85645 377.08972 curveto +116.85644 378.11056 116.68554 379.13823 116.34375 380.17273 curveto +116.00651 381.20723 115.49609 382.25997 114.8125 383.33093 curveto +113.71875 383.33093 lineto +114.32487 382.28731 114.77604 381.25053 115.07227 380.22058 curveto +115.37304 379.18608 115.52343 378.14246 115.52344 377.08972 curveto +115.52343 376.03699 115.37304 374.99793 115.07227 373.97253 curveto +114.77604 372.94715 114.32487 371.91037 113.71875 370.86218 curveto +fill +grestore +gsave [1.04082 0 0 0.999696 -220.2817 5.106745] concat +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +349.5 351.36218 moveto +349.5 378.68618 319.484 400.86218 282.5 400.86218 curveto +245.516 400.86218 215.5 378.68618 215.5 351.36218 curveto +215.5 324.03818 245.516 301.86218 282.5 301.86218 curveto +319.484 301.86218 349.5 324.03818 349.5 351.36218 curveto +closepath +stroke +grestore +gsave +0 0 0 setrgbcolor +newpath +66.874023 311.95789 moveto +68.254883 311.95789 lineto +68.254883 322.16394 lineto +66.874023 322.16394 lineto +66.874023 311.95789 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +75.829102 314.73328 moveto +75.829102 315.92273 lineto +75.473627 315.74044 75.104487 315.60373 74.72168 315.51257 curveto +74.338862 315.42143 73.942378 315.37586 73.532227 315.37585 curveto +72.907874 315.37586 72.438474 315.47156 72.124023 315.66296 curveto +71.814125 315.85438 71.659178 316.14149 71.65918 316.52429 curveto +71.659178 316.81596 71.770831 317.04611 71.994141 317.21472 curveto +72.217445 317.37879 72.666338 317.53602 73.34082 317.6864 curveto +73.771484 317.7821 lineto +74.664709 317.97351 75.298171 318.24467 75.671875 318.59558 curveto +76.050124 318.94194 76.239251 319.42729 76.239258 320.05164 curveto +76.239251 320.76257 75.956699 321.3254 75.391602 321.74011 curveto +74.831049 322.15483 74.058589 322.36218 73.074219 322.36218 curveto +72.664059 322.36218 72.235674 322.32117 71.789062 322.23914 curveto +71.347003 322.16166 70.879882 322.04317 70.387695 321.88367 curveto +70.387695 320.58484 lineto +70.852538 320.82638 71.310545 321.00867 71.761719 321.13171 curveto +72.212888 321.2502 72.659502 321.30945 73.101562 321.30945 curveto +73.694006 321.30945 74.149735 321.20919 74.46875 321.00867 curveto +74.787755 320.80359 74.94726 320.51648 74.947266 320.14734 curveto +74.94726 319.80554 74.831049 319.5435 74.598633 319.36121 curveto +74.370763 319.17892 73.867183 319.00346 73.087891 318.83484 curveto +72.650391 318.7323 lineto +71.871092 318.56824 71.308267 318.31759 70.961914 317.98035 curveto +70.615559 317.63855 70.442382 317.17143 70.442383 316.57898 curveto +70.442382 315.85893 70.69759 315.30294 71.208008 314.91101 curveto +71.718422 314.51909 72.443031 314.32313 73.381836 314.32312 curveto +73.846675 314.32313 74.284175 314.35731 74.694336 314.42566 curveto +75.104487 314.49403 75.482742 314.59657 75.829102 314.73328 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +6.3125 439.27167 moveto +5.7018192 440.31985 5.2483691 441.35664 4.9521484 442.38202 curveto +4.6559218 443.40742 4.50781 444.44648 4.5078125 445.49921 curveto +4.50781 446.55194 4.6559218 447.59556 4.9521484 448.63007 curveto +5.2529264 449.66001 5.7063765 450.6968 6.3125 451.74042 curveto +5.21875 451.74042 lineto +4.5351537 450.66945 4.0224589 449.61672 3.6806641 448.58221 curveto +3.3434231 447.54771 3.1748035 446.52004 3.1748047 445.49921 curveto +3.1748035 444.48294 3.3434231 443.45982 3.6806641 442.42987 curveto +4.0179016 441.39993 4.5305964 440.3472 5.21875 439.27167 curveto +6.3125 439.27167 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +11.890625 440.59784 moveto +11.179684 440.59785 10.644203 440.94876 10.28418 441.65057 curveto +9.9287084 442.34785 9.7509743 443.3983 9.7509766 444.80194 curveto +9.7509743 446.20103 9.9287084 447.25149 10.28418 447.95331 curveto +10.644203 448.65057 11.179684 448.99921 11.890625 448.99921 curveto +12.606115 448.99921 13.141596 448.65057 13.49707 447.95331 curveto +13.85709 447.25149 14.037103 446.20103 14.037109 444.80194 curveto +14.037103 443.3983 13.85709 442.34785 13.49707 441.65057 curveto +13.141596 440.94876 12.606115 440.59785 11.890625 440.59784 curveto +11.890625 439.50409 moveto +13.0345 439.5041 13.90722 439.95755 14.508789 440.86444 curveto +15.114901 441.76679 15.417961 443.07929 15.417969 444.80194 curveto +15.417961 446.52004 15.114901 447.83254 14.508789 448.73944 curveto +13.90722 449.64178 13.0345 450.09296 11.890625 450.09296 curveto +10.746741 450.09296 9.8717424 449.64178 9.265625 448.73944 curveto +8.6640613 447.83254 8.3632803 446.52004 8.3632812 444.80194 curveto +8.3632803 443.07929 8.6640613 441.76679 9.265625 440.86444 curveto +9.8717424 439.95755 10.746741 439.5041 11.890625 439.50409 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +17.995117 448.15839 moveto +19.4375 448.15839 lineto +19.4375 449.33417 lineto +18.316406 451.52167 lineto +17.43457 451.52167 lineto +17.995117 449.33417 lineto +17.995117 448.15839 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +25.261719 440.59784 moveto +24.550778 440.59785 24.015296 440.94876 23.655273 441.65057 curveto +23.299802 442.34785 23.122068 443.3983 23.12207 444.80194 curveto +23.122068 446.20103 23.299802 447.25149 23.655273 447.95331 curveto +24.015296 448.65057 24.550778 448.99921 25.261719 448.99921 curveto +25.977208 448.99921 26.51269 448.65057 26.868164 447.95331 curveto +27.228184 447.25149 27.408197 446.20103 27.408203 444.80194 curveto +27.408197 443.3983 27.228184 442.34785 26.868164 441.65057 curveto +26.51269 440.94876 25.977208 440.59785 25.261719 440.59784 curveto +25.261719 439.50409 moveto +26.405593 439.5041 27.278314 439.95755 27.879883 440.86444 curveto +28.485995 441.76679 28.789055 443.07929 28.789062 444.80194 curveto +28.789055 446.52004 28.485995 447.83254 27.879883 448.73944 curveto +27.278314 449.64178 26.405593 450.09296 25.261719 450.09296 curveto +24.117835 450.09296 23.242836 449.64178 22.636719 448.73944 curveto +22.035155 447.83254 21.734374 446.52004 21.734375 444.80194 curveto +21.734374 443.07929 22.035155 441.76679 22.636719 440.86444 curveto +23.242836 439.95755 24.117835 439.5041 25.261719 439.50409 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +31.366211 448.15839 moveto +32.808594 448.15839 lineto +32.808594 449.33417 lineto +31.6875 451.52167 lineto +30.805664 451.52167 lineto +31.366211 449.33417 lineto +31.366211 448.15839 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +38.46875 443.1203 moveto +37.794267 443.12031 37.261065 443.38463 36.869141 443.91327 curveto +36.477211 444.43736 36.281248 445.15741 36.28125 446.07343 curveto +36.281248 446.98944 36.474933 447.71177 36.862305 448.24042 curveto +37.254229 448.76451 37.78971 449.02655 38.46875 449.02655 curveto +39.138667 449.02655 39.669591 448.76223 40.061523 448.23358 curveto +40.453444 447.70494 40.649408 446.98489 40.649414 446.07343 curveto +40.649408 445.16653 40.453444 444.44876 40.061523 443.9201 curveto +39.669591 443.38691 39.138667 443.12031 38.46875 443.1203 curveto +38.46875 442.05389 moveto +39.562495 442.0539 40.421543 442.40937 41.045898 443.1203 curveto +41.67024 443.83124 41.982414 444.81562 41.982422 446.07343 curveto +41.982414 447.32668 41.67024 448.31106 41.045898 449.02655 curveto +40.421543 449.73749 39.562495 450.09296 38.46875 450.09296 curveto +37.37044 450.09296 36.509112 449.73749 35.884766 449.02655 curveto +35.264973 448.31106 34.955077 447.32668 34.955078 446.07343 curveto +34.955077 444.81562 35.264973 443.83124 35.884766 443.1203 curveto +36.509112 442.40937 37.37044 442.0539 38.46875 442.05389 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +43.862305 439.27167 moveto +44.956055 439.27167 lineto +45.639646 440.3472 46.150062 441.39993 46.487305 442.42987 curveto +46.829097 443.45982 46.999996 444.48294 47 445.49921 curveto +46.999996 446.52004 46.829097 447.54771 46.487305 448.58221 curveto +46.150062 449.61672 45.639646 450.66945 44.956055 451.74042 curveto +43.862305 451.74042 lineto +44.468423 450.6968 44.919594 449.66001 45.21582 448.63007 curveto +45.516599 447.59556 45.666989 446.55194 45.666992 445.49921 curveto +45.666989 444.44648 45.516599 443.40742 45.21582 442.38202 curveto +44.919594 441.35664 44.468423 440.31985 43.862305 439.27167 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +51.951172 439.27167 moveto +51.340491 440.31985 50.887041 441.35664 50.59082 442.38202 curveto +50.294594 443.40742 50.146482 444.44648 50.146484 445.49921 curveto +50.146482 446.55194 50.294594 447.59556 50.59082 448.63007 curveto +50.891598 449.66001 51.345048 450.6968 51.951172 451.74042 curveto +50.857422 451.74042 lineto +50.173826 450.66945 49.661131 449.61672 49.319336 448.58221 curveto +48.982095 447.54771 48.813475 446.52004 48.813477 445.49921 curveto +48.813475 444.48294 48.982095 443.45982 49.319336 442.42987 curveto +49.656573 441.39993 50.169268 440.3472 50.857422 439.27167 curveto +51.951172 439.27167 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +54.81543 448.7326 moveto +57.071289 448.7326 lineto +57.071289 440.94647 lineto +54.617188 441.43866 lineto +54.617188 440.18085 lineto +57.057617 439.68866 lineto +58.438477 439.68866 lineto +58.438477 448.7326 lineto +60.694336 448.7326 lineto +60.694336 449.89471 lineto +54.81543 449.89471 lineto +54.81543 448.7326 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +63.633789 448.15839 moveto +65.076172 448.15839 lineto +65.076172 449.33417 lineto +63.955078 451.52167 lineto +63.073242 451.52167 lineto +63.633789 449.33417 lineto +63.633789 448.15839 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +68.186523 448.7326 moveto +70.442383 448.7326 lineto +70.442383 440.94647 lineto +67.988281 441.43866 lineto +67.988281 440.18085 lineto +70.428711 439.68866 lineto +71.80957 439.68866 lineto +71.80957 448.7326 lineto +74.06543 448.7326 lineto +74.06543 449.89471 lineto +68.186523 449.89471 lineto +68.186523 448.7326 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +77.004883 448.15839 moveto +78.447266 448.15839 lineto +78.447266 449.33417 lineto +77.326172 451.52167 lineto +76.444336 451.52167 lineto +77.004883 449.33417 lineto +77.004883 448.15839 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +84.107422 443.1203 moveto +83.432939 443.12031 82.899737 443.38463 82.507812 443.91327 curveto +82.115883 444.43736 81.91992 445.15741 81.919922 446.07343 curveto +81.91992 446.98944 82.113604 447.71177 82.500977 448.24042 curveto +82.892901 448.76451 83.428382 449.02655 84.107422 449.02655 curveto +84.777339 449.02655 85.308263 448.76223 85.700195 448.23358 curveto +86.092116 447.70494 86.288079 446.98489 86.288086 446.07343 curveto +86.288079 445.16653 86.092116 444.44876 85.700195 443.9201 curveto +85.308263 443.38691 84.777339 443.12031 84.107422 443.1203 curveto +84.107422 442.05389 moveto +85.201166 442.0539 86.060215 442.40937 86.68457 443.1203 curveto +87.308912 443.83124 87.621086 444.81562 87.621094 446.07343 curveto +87.621086 447.32668 87.308912 448.31106 86.68457 449.02655 curveto +86.060215 449.73749 85.201166 450.09296 84.107422 450.09296 curveto +83.009111 450.09296 82.147784 449.73749 81.523438 449.02655 curveto +80.903645 448.31106 80.593749 447.32668 80.59375 446.07343 curveto +80.593749 444.81562 80.903645 443.83124 81.523438 443.1203 curveto +82.147784 442.40937 83.009111 442.0539 84.107422 442.05389 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +89.500977 439.27167 moveto +90.594727 439.27167 lineto +91.278317 440.3472 91.788734 441.39993 92.125977 442.42987 curveto +92.467769 443.45982 92.638668 444.48294 92.638672 445.49921 curveto +92.638668 446.52004 92.467769 447.54771 92.125977 448.58221 curveto +91.788734 449.61672 91.278317 450.66945 90.594727 451.74042 curveto +89.500977 451.74042 lineto +90.107095 450.6968 90.558266 449.66001 90.854492 448.63007 curveto +91.155271 447.59556 91.305661 446.55194 91.305664 445.49921 curveto +91.305661 444.44648 91.155271 443.40742 90.854492 442.38202 curveto +90.558266 441.35664 90.107095 440.31985 89.500977 439.27167 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +51.951172 458.80682 moveto +51.340491 459.85501 50.887041 460.89179 50.59082 461.91718 curveto +50.294594 462.94257 50.146482 463.98163 50.146484 465.03436 curveto +50.146482 466.0871 50.294594 467.13072 50.59082 468.16522 curveto +50.891598 469.19517 51.345048 470.23195 51.951172 471.27557 curveto +50.857422 471.27557 lineto +50.173826 470.20461 49.661131 469.15188 49.319336 468.11737 curveto +48.982095 467.08287 48.813475 466.0552 48.813477 465.03436 curveto +48.813475 464.01809 48.982095 462.99498 49.319336 461.96503 curveto +49.656573 460.93509 50.169268 459.88235 50.857422 458.80682 curveto +51.951172 458.80682 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +54.589844 459.22382 moveto +60.010742 459.22382 lineto +60.010742 460.38593 lineto +55.854492 460.38593 lineto +55.854492 462.88788 lineto +56.05501 462.81953 56.255531 462.7694 56.456055 462.73749 curveto +56.656572 462.70104 56.857093 462.68281 57.057617 462.6828 curveto +58.196935 462.68281 59.099278 462.99498 59.764648 463.61932 curveto +60.430006 464.24368 60.762688 465.08905 60.762695 466.15546 curveto +60.762688 467.25377 60.420891 468.10826 59.737305 468.71893 curveto +59.053705 469.32505 58.089839 469.62811 56.845703 469.62811 curveto +56.417314 469.62811 55.979815 469.59165 55.533203 469.51874 curveto +55.091144 469.44582 54.633136 469.33645 54.15918 469.19061 curveto +54.15918 467.80292 lineto +54.569334 468.02623 54.993162 468.19257 55.430664 468.30194 curveto +55.868161 468.41132 56.330726 468.466 56.818359 468.466 curveto +57.606766 468.466 58.231115 468.25865 58.691406 467.84393 curveto +59.151687 467.42922 59.38183 466.8664 59.381836 466.15546 curveto +59.38183 465.44452 59.151687 464.8817 58.691406 464.46698 curveto +58.231115 464.05227 57.606766 463.84492 56.818359 463.84491 curveto +56.449215 463.84492 56.080075 463.88593 55.710938 463.96796 curveto +55.346352 464.04999 54.972654 464.1776 54.589844 464.35077 curveto +54.589844 459.22382 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +63.633789 467.69354 moveto +65.076172 467.69354 lineto +65.076172 468.86932 lineto +63.955078 471.05682 lineto +63.073242 471.05682 lineto +63.633789 468.86932 lineto +63.633789 467.69354 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +71.741211 460.42694 moveto +68.254883 465.87518 lineto +71.741211 465.87518 lineto +71.741211 460.42694 lineto +71.378906 459.22382 moveto +73.115234 459.22382 lineto +73.115234 465.87518 lineto +74.571289 465.87518 lineto +74.571289 467.02362 lineto +73.115234 467.02362 lineto +73.115234 469.42987 lineto +71.741211 469.42987 lineto +71.741211 467.02362 lineto +67.133789 467.02362 lineto +67.133789 465.69061 lineto +71.378906 459.22382 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +77.004883 467.69354 moveto +78.447266 467.69354 lineto +78.447266 468.86932 lineto +77.326172 471.05682 lineto +76.444336 471.05682 lineto +77.004883 468.86932 lineto +77.004883 467.69354 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +86.178711 465.51288 moveto +86.178705 464.60142 85.989577 463.89505 85.611328 463.39374 curveto +85.237625 462.89244 84.711258 462.64179 84.032227 462.64178 curveto +83.357744 462.64179 82.831377 462.89244 82.453125 463.39374 curveto +82.079425 463.89505 81.892576 464.60142 81.892578 465.51288 curveto +81.892576 466.41978 82.079425 467.12388 82.453125 467.62518 curveto +82.831377 468.12649 83.357744 468.37714 84.032227 468.37714 curveto +84.711258 468.37714 85.237625 468.12649 85.611328 467.62518 curveto +85.989577 467.12388 86.178705 466.41978 86.178711 465.51288 curveto +87.436523 468.47968 moveto +87.436516 469.78306 87.147128 470.75148 86.568359 471.38495 curveto +85.989577 472.02297 85.103185 472.34198 83.90918 472.34198 curveto +83.467119 472.34198 83.050127 472.3078 82.658203 472.23944 curveto +82.266274 472.17564 81.88574 472.07538 81.516602 471.93866 curveto +81.516602 470.71503 lineto +81.88574 470.91555 82.250323 471.06366 82.610352 471.15936 curveto +82.970374 471.25506 83.337236 471.30292 83.710938 471.30292 curveto +84.535803 471.30292 85.153315 471.08644 85.563477 470.6535 curveto +85.973627 470.22512 86.178705 469.5757 86.178711 468.70526 curveto +86.178711 468.08319 lineto +85.918939 468.53436 85.586257 468.8716 85.180664 469.09491 curveto +84.77506 469.31822 84.289709 469.42987 83.724609 469.42987 curveto +82.785804 469.42987 82.029295 469.07212 81.455078 468.35663 curveto +80.880858 467.64114 80.593749 466.69322 80.59375 465.51288 curveto +80.593749 464.32799 80.880858 463.37779 81.455078 462.66229 curveto +82.029295 461.94681 82.785804 461.58906 83.724609 461.58905 curveto +84.289709 461.58906 84.77506 461.70071 85.180664 461.92401 curveto +85.586257 462.14733 85.918939 462.48457 86.178711 462.93573 curveto +86.178711 461.77362 lineto +87.436523 461.77362 lineto +87.436523 468.47968 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +89.829102 458.80682 moveto +90.922852 458.80682 lineto +91.606442 459.88235 92.116859 460.93509 92.454102 461.96503 curveto +92.795894 462.99498 92.966793 464.01809 92.966797 465.03436 curveto +92.966793 466.0552 92.795894 467.08287 92.454102 468.11737 curveto +92.116859 469.15188 91.606442 470.20461 90.922852 471.27557 curveto +89.829102 471.27557 lineto +90.43522 470.23195 90.886391 469.19517 91.182617 468.16522 curveto +91.483396 467.13072 91.633786 466.0871 91.633789 465.03436 curveto +91.633786 463.98163 91.483396 462.94257 91.182617 461.91718 curveto +90.886391 460.89179 90.43522 459.85501 89.829102 458.80682 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +97.405273 439.73846 moveto +96.794593 440.78665 96.341143 441.82343 96.044922 442.84882 curveto +95.748695 443.87421 95.600583 444.91327 95.600586 445.966 curveto +95.600583 447.01874 95.748695 448.06236 96.044922 449.09686 curveto +96.3457 450.12681 96.79915 451.16359 97.405273 452.20721 curveto +96.311523 452.20721 lineto +95.627927 451.13625 95.115232 450.08352 94.773438 449.04901 curveto +94.436197 448.01451 94.267577 446.98684 94.267578 445.966 curveto +94.267577 444.94973 94.436197 443.92662 94.773438 442.89667 curveto +95.110675 441.86673 95.62337 440.81399 96.311523 439.73846 curveto +97.405273 439.73846 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +101.21973 449.1994 moveto +106.03906 449.1994 lineto +106.03906 450.36151 lineto +99.558594 450.36151 lineto +99.558594 449.1994 lineto +100.08268 448.65709 100.7959 447.9302 101.69824 447.01874 curveto +102.60514 446.10273 103.1748 445.51256 103.40723 445.24823 curveto +103.84928 444.75149 104.1569 444.33222 104.33008 443.99042 curveto +104.50781 443.64407 104.59667 443.30455 104.59668 442.97186 curveto +104.59667 442.42955 104.40527 441.9875 104.02246 441.64569 curveto +103.6442 441.3039 103.14973 441.133 102.53906 441.133 curveto +102.10612 441.133 101.64811 441.2082 101.16504 441.35858 curveto +100.68652 441.50898 100.17383 441.73685 99.626953 442.04218 curveto +99.626953 440.64764 lineto +100.18294 440.42435 100.70247 440.25573 101.18555 440.14178 curveto +101.66862 440.02786 102.11067 439.9709 102.51172 439.97089 curveto +103.56901 439.9709 104.4121 440.23522 105.04102 440.76385 curveto +105.66991 441.29251 105.98437 441.99889 105.98438 442.883 curveto +105.98437 443.30227 105.90462 443.70104 105.74512 444.07928 curveto +105.59016 444.45299 105.30533 444.89505 104.89062 445.40546 curveto +104.77669 445.53762 104.41438 445.92043 103.80371 446.55389 curveto +103.19303 447.1828 102.3317 448.06464 101.21973 449.1994 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +109.08789 448.62518 moveto +110.53027 448.62518 lineto +110.53027 449.80096 lineto +109.40918 451.98846 lineto +108.52734 451.98846 lineto +109.08789 449.80096 lineto +109.08789 448.62518 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +114.59082 449.1994 moveto +119.41016 449.1994 lineto +119.41016 450.36151 lineto +112.92969 450.36151 lineto +112.92969 449.1994 lineto +113.45377 448.65709 114.16699 447.9302 115.06934 447.01874 curveto +115.97623 446.10273 116.54589 445.51256 116.77832 445.24823 curveto +117.22037 444.75149 117.52799 444.33222 117.70117 443.99042 curveto +117.8789 443.64407 117.96777 443.30455 117.96777 442.97186 curveto +117.96777 442.42955 117.77636 441.9875 117.39355 441.64569 curveto +117.01529 441.3039 116.52083 441.133 115.91016 441.133 curveto +115.47721 441.133 115.0192 441.2082 114.53613 441.35858 curveto +114.05762 441.50898 113.54492 441.73685 112.99805 442.04218 curveto +112.99805 440.64764 lineto +113.55403 440.42435 114.07357 440.25573 114.55664 440.14178 curveto +115.03971 440.02786 115.48177 439.9709 115.88281 439.97089 curveto +116.9401 439.9709 117.7832 440.23522 118.41211 440.76385 curveto +119.04101 441.29251 119.35546 441.99889 119.35547 442.883 curveto +119.35546 443.30227 119.27571 443.70104 119.11621 444.07928 curveto +118.96126 444.45299 118.67643 444.89505 118.26172 445.40546 curveto +118.14778 445.53762 117.78548 445.92043 117.1748 446.55389 curveto +116.56412 447.1828 115.7028 448.06464 114.59082 449.1994 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +122.45898 448.62518 moveto +123.90137 448.62518 lineto +123.90137 449.80096 lineto +122.78027 451.98846 lineto +121.89844 451.98846 lineto +122.45898 449.80096 lineto +122.45898 448.62518 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +129.56152 443.5871 moveto +128.88704 443.5871 128.35384 443.85143 127.96191 444.38007 curveto +127.56998 444.90416 127.37402 445.62421 127.37402 446.54022 curveto +127.37402 447.45624 127.56771 448.17857 127.95508 448.70721 curveto +128.347 449.2313 128.88248 449.49335 129.56152 449.49335 curveto +130.23144 449.49335 130.76236 449.22903 131.1543 448.70038 curveto +131.54622 448.17173 131.74218 447.45168 131.74219 446.54022 curveto +131.74218 445.63333 131.54622 444.91555 131.1543 444.3869 curveto +130.76236 443.85371 130.23144 443.5871 129.56152 443.5871 curveto +129.56152 442.52069 moveto +130.65527 442.5207 131.51432 442.87617 132.13867 443.5871 curveto +132.76301 444.29804 133.07519 445.28241 133.0752 446.54022 curveto +133.07519 447.79348 132.76301 448.77785 132.13867 449.49335 curveto +131.51432 450.20428 130.65527 450.55975 129.56152 450.55975 curveto +128.46321 450.55975 127.60189 450.20428 126.97754 449.49335 curveto +126.35775 448.77785 126.04785 447.79348 126.04785 446.54022 curveto +126.04785 445.28241 126.35775 444.29804 126.97754 443.5871 curveto +127.60189 442.87617 128.46321 442.5207 129.56152 442.52069 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +134.95508 439.73846 moveto +136.04883 439.73846 lineto +136.73242 440.81399 137.24284 441.86673 137.58008 442.89667 curveto +137.92187 443.92662 138.09277 444.94973 138.09277 445.966 curveto +138.09277 446.98684 137.92187 448.01451 137.58008 449.04901 curveto +137.24284 450.08352 136.73242 451.13625 136.04883 452.20721 curveto +134.95508 452.20721 lineto +135.5612 451.16359 136.01237 450.12681 136.30859 449.09686 curveto +136.60937 448.06236 136.75976 447.01874 136.75977 445.966 curveto +136.75976 444.91327 136.60937 443.87421 136.30859 442.84882 curveto +136.01237 441.82343 135.5612 440.78665 134.95508 439.73846 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +5.1376953 458.27362 moveto +4.5270145 459.32181 4.0735644 460.35859 3.7773438 461.38397 curveto +3.4811171 462.40937 3.3330053 463.44843 3.3330078 464.50116 curveto +3.3330053 465.5539 3.4811171 466.59752 3.7773438 467.63202 curveto +4.0781217 468.66197 4.5315718 469.69875 5.1376953 470.74237 curveto +4.0439453 470.74237 lineto +3.360349 469.67141 2.8476542 468.61867 2.5058594 467.58417 curveto +2.1686184 466.54966 1.9999988 465.522 2 464.50116 curveto +1.9999988 463.48489 2.1686184 462.46178 2.5058594 461.43182 curveto +2.8430969 460.40188 3.3557917 459.34915 4.0439453 458.27362 curveto +5.1376953 458.27362 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +11.946289 463.39374 moveto +12.60709 463.53502 13.122063 463.82896 13.491211 464.27557 curveto +13.864901 464.72219 14.05175 465.27362 14.051758 465.92987 curveto +14.05175 466.93703 13.705396 467.71633 13.012695 468.26776 curveto +12.319981 468.81919 11.335607 469.09491 10.05957 469.09491 curveto +9.6311815 469.09491 9.1891247 469.05162 8.7333984 468.96503 curveto +8.2822245 468.883 7.8151026 468.75767 7.3320312 468.58905 curveto +7.3320312 467.25604 lineto +7.7148423 467.47935 8.1341127 467.64797 8.5898438 467.7619 curveto +9.0455701 467.87584 9.5218066 467.9328 10.018555 467.9328 curveto +10.884435 467.9328 11.542963 467.7619 11.994141 467.4201 curveto +12.449864 467.07831 12.677728 466.58157 12.677734 465.92987 curveto +12.677728 465.32831 12.465814 464.85891 12.041992 464.52167 curveto +11.622716 464.17988 11.037105 464.00898 10.285156 464.00897 curveto +9.0957031 464.00897 lineto +9.0957031 462.87421 lineto +10.339844 462.87421 lineto +11.018875 462.87421 11.538406 462.73977 11.898438 462.47089 curveto +12.258458 462.19746 12.43847 461.80553 12.438477 461.2951 curveto +12.43847 460.77102 12.251622 460.36998 11.87793 460.09198 curveto +11.508784 459.80944 10.97786 459.66816 10.285156 459.66815 curveto +9.9068974 459.66816 9.5012988 459.70918 9.0683594 459.7912 curveto +8.6354143 459.87324 8.1591778 460.00084 7.6396484 460.17401 curveto +7.6396484 458.94354 lineto +8.1637351 458.79772 8.6536434 458.68834 9.109375 458.61542 curveto +9.5696582 458.54251 10.0026 458.50605 10.408203 458.50604 curveto +11.456375 458.50605 12.285801 458.74531 12.896484 459.22382 curveto +13.507154 459.69778 13.812492 460.34036 13.8125 461.15155 curveto +13.812492 461.71666 13.650709 462.19518 13.327148 462.5871 curveto +13.003574 462.97447 12.543288 463.24335 11.946289 463.39374 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +16.820312 467.16034 moveto +18.262695 467.16034 lineto +18.262695 468.33612 lineto +17.141602 470.52362 lineto +16.259766 470.52362 lineto +16.820312 468.33612 lineto +16.820312 467.16034 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +25.317383 463.39374 moveto +25.978184 463.53502 26.493157 463.82896 26.862305 464.27557 curveto +27.235995 464.72219 27.422844 465.27362 27.422852 465.92987 curveto +27.422844 466.93703 27.07649 467.71633 26.383789 468.26776 curveto +25.691075 468.81919 24.706701 469.09491 23.430664 469.09491 curveto +23.002275 469.09491 22.560218 469.05162 22.104492 468.96503 curveto +21.653318 468.883 21.186196 468.75767 20.703125 468.58905 curveto +20.703125 467.25604 lineto +21.085936 467.47935 21.505206 467.64797 21.960938 467.7619 curveto +22.416664 467.87584 22.8929 467.9328 23.389648 467.9328 curveto +24.255529 467.9328 24.914057 467.7619 25.365234 467.4201 curveto +25.820957 467.07831 26.048822 466.58157 26.048828 465.92987 curveto +26.048822 465.32831 25.836908 464.85891 25.413086 464.52167 curveto +24.99381 464.17988 24.408198 464.00898 23.65625 464.00897 curveto +22.466797 464.00897 lineto +22.466797 462.87421 lineto +23.710938 462.87421 lineto +24.389969 462.87421 24.9095 462.73977 25.269531 462.47089 curveto +25.629551 462.19746 25.809564 461.80553 25.80957 461.2951 curveto +25.809564 460.77102 25.622715 460.36998 25.249023 460.09198 curveto +24.879878 459.80944 24.348954 459.66816 23.65625 459.66815 curveto +23.277991 459.66816 22.872393 459.70918 22.439453 459.7912 curveto +22.006508 459.87324 21.530272 460.00084 21.010742 460.17401 curveto +21.010742 458.94354 lineto +21.534829 458.79772 22.024737 458.68834 22.480469 458.61542 curveto +22.940752 458.54251 23.373694 458.50605 23.779297 458.50604 curveto +24.827469 458.50605 25.656895 458.74531 26.267578 459.22382 curveto +26.878248 459.69778 27.183586 460.34036 27.183594 461.15155 curveto +27.183586 461.71666 27.021803 462.19518 26.698242 462.5871 curveto +26.374668 462.97447 25.914382 463.24335 25.317383 463.39374 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +30.191406 467.16034 moveto +31.633789 467.16034 lineto +31.633789 468.33612 lineto +30.512695 470.52362 lineto +29.630859 470.52362 lineto +30.191406 468.33612 lineto +30.191406 467.16034 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +39.365234 464.97968 moveto +39.365228 464.06822 39.176101 463.36184 38.797852 462.86053 curveto +38.424148 462.35924 37.897782 462.10859 37.21875 462.10858 curveto +36.544267 462.10859 36.017901 462.35924 35.639648 462.86053 curveto +35.265948 463.36184 35.079099 464.06822 35.079102 464.97968 curveto +35.079099 465.88658 35.265948 466.59068 35.639648 467.09198 curveto +36.017901 467.59328 36.544267 467.84393 37.21875 467.84393 curveto +37.897782 467.84393 38.424148 467.59328 38.797852 467.09198 curveto +39.176101 466.59068 39.365228 465.88658 39.365234 464.97968 curveto +40.623047 467.94647 moveto +40.623039 469.24986 40.333652 470.21828 39.754883 470.85175 curveto +39.176101 471.48976 38.289708 471.80877 37.095703 471.80878 curveto +36.653642 471.80877 36.23665 471.77459 35.844727 471.70624 curveto +35.452797 471.64243 35.072264 471.54217 34.703125 471.40546 curveto +34.703125 470.18182 lineto +35.072264 470.38234 35.436847 470.53045 35.796875 470.62616 curveto +36.156898 470.72186 36.52376 470.76971 36.897461 470.76971 curveto +37.722326 470.76971 38.339838 470.55324 38.75 470.1203 curveto +39.16015 469.69191 39.365228 469.0425 39.365234 468.17206 curveto +39.365234 467.54999 lineto +39.105463 468.00116 38.772781 468.3384 38.367188 468.56171 curveto +37.961584 468.78501 37.476233 468.89667 36.911133 468.89667 curveto +35.972328 468.89667 35.215818 468.53892 34.641602 467.82343 curveto +34.067382 467.10793 33.780273 466.16002 33.780273 464.97968 curveto +33.780273 463.79478 34.067382 462.84459 34.641602 462.12909 curveto +35.215818 461.4136 35.972328 461.05586 36.911133 461.05585 curveto +37.476233 461.05586 37.961584 461.16751 38.367188 461.39081 curveto +38.772781 461.61412 39.105463 461.95136 39.365234 462.40253 curveto +39.365234 461.24042 lineto +40.623047 461.24042 lineto +40.623047 467.94647 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +43.015625 458.27362 moveto +44.109375 458.27362 lineto +44.792966 459.34915 45.303382 460.40188 45.640625 461.43182 curveto +45.982418 462.46178 46.153316 463.48489 46.15332 464.50116 curveto +46.153316 465.522 45.982418 466.54966 45.640625 467.58417 curveto +45.303382 468.61867 44.792966 469.67141 44.109375 470.74237 curveto +43.015625 470.74237 lineto +43.621743 469.69875 44.072914 468.66197 44.369141 467.63202 curveto +44.669919 466.59752 44.82031 465.5539 44.820312 464.50116 curveto +44.82031 463.44843 44.669919 462.40937 44.369141 461.38397 curveto +44.072914 460.35859 43.621743 459.32181 43.015625 458.27362 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +98.233398 458.80682 moveto +97.622718 459.85501 97.169268 460.89179 96.873047 461.91718 curveto +96.57682 462.94257 96.428708 463.98163 96.428711 465.03436 curveto +96.428708 466.0871 96.57682 467.13072 96.873047 468.16522 curveto +97.173825 469.19517 97.627275 470.23195 98.233398 471.27557 curveto +97.139648 471.27557 lineto +96.456052 470.20461 95.943357 469.15188 95.601562 468.11737 curveto +95.264322 467.08287 95.095702 466.0552 95.095703 465.03436 curveto +95.095702 464.01809 95.264322 462.99498 95.601562 461.96503 curveto +95.9388 460.93509 96.451495 459.88235 97.139648 458.80682 curveto +98.233398 458.80682 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +103.98242 463.77655 moveto +103.36263 463.77656 102.87044 463.98847 102.50586 464.41229 curveto +102.14583 464.83613 101.96582 465.41718 101.96582 466.15546 curveto +101.96582 466.88918 102.14583 467.47024 102.50586 467.89862 curveto +102.87044 468.32245 103.36263 468.53436 103.98242 468.53436 curveto +104.60221 468.53436 105.09212 468.32245 105.45215 467.89862 curveto +105.81673 467.47024 105.99902 466.88918 105.99902 466.15546 curveto +105.99902 465.41718 105.81673 464.83613 105.45215 464.41229 curveto +105.09212 463.98847 104.60221 463.77656 103.98242 463.77655 curveto +106.72363 459.4494 moveto +106.72363 460.70721 lineto +106.37727 460.54316 106.02636 460.41784 105.6709 460.33124 curveto +105.31998 460.24466 104.97135 460.20136 104.625 460.20135 curveto +103.71354 460.20136 103.01627 460.50898 102.5332 461.12421 curveto +102.05468 461.73945 101.78125 462.66914 101.71289 463.91327 curveto +101.98177 463.51679 102.31901 463.21373 102.72461 463.00409 curveto +103.1302 462.7899 103.57682 462.68281 104.06445 462.6828 curveto +105.08984 462.68281 105.89876 462.99498 106.49121 463.61932 curveto +107.08821 464.23912 107.38671 465.0845 107.38672 466.15546 curveto +107.38671 467.20364 107.07682 468.04446 106.45703 468.67792 curveto +105.83723 469.31138 105.01236 469.62811 103.98242 469.62811 curveto +102.80208 469.62811 101.89974 469.17694 101.27539 468.2746 curveto +100.65104 467.3677 100.33887 466.0552 100.33887 464.3371 curveto +100.33887 462.72382 100.72168 461.43867 101.4873 460.48163 curveto +102.25293 459.52005 103.2806 459.03926 104.57031 459.03925 curveto +104.91666 459.03926 105.26529 459.07344 105.61621 459.14178 curveto +105.97167 459.21015 106.34081 459.31269 106.72363 459.4494 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +109.91602 467.69354 moveto +111.3584 467.69354 lineto +111.3584 468.86932 lineto +110.2373 471.05682 lineto +109.35547 471.05682 lineto +109.91602 468.86932 lineto +109.91602 467.69354 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +114.24316 459.22382 moveto +119.66406 459.22382 lineto +119.66406 460.38593 lineto +115.50781 460.38593 lineto +115.50781 462.88788 lineto +115.70833 462.81953 115.90885 462.7694 116.10938 462.73749 curveto +116.30989 462.70104 116.51041 462.68281 116.71094 462.6828 curveto +117.85026 462.68281 118.7526 462.99498 119.41797 463.61932 curveto +120.08333 464.24368 120.41601 465.08905 120.41602 466.15546 curveto +120.41601 467.25377 120.07421 468.10826 119.39062 468.71893 curveto +118.70703 469.32505 117.74316 469.62811 116.49902 469.62811 curveto +116.07063 469.62811 115.63314 469.59165 115.18652 469.51874 curveto +114.74446 469.44582 114.28646 469.33645 113.8125 469.19061 curveto +113.8125 467.80292 lineto +114.22265 468.02623 114.64648 468.19257 115.08398 468.30194 curveto +115.52148 468.41132 115.98405 468.466 116.47168 468.466 curveto +117.26009 468.466 117.88443 468.25865 118.34473 467.84393 curveto +118.80501 467.42922 119.03515 466.8664 119.03516 466.15546 curveto +119.03515 465.44452 118.80501 464.8817 118.34473 464.46698 curveto +117.88443 464.05227 117.26009 463.84492 116.47168 463.84491 curveto +116.10254 463.84492 115.7334 463.88593 115.36426 463.96796 curveto +114.99967 464.04999 114.62597 464.1776 114.24316 464.35077 curveto +114.24316 459.22382 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +123.28711 467.69354 moveto +124.72949 467.69354 lineto +124.72949 468.86932 lineto +123.6084 471.05682 lineto +122.72656 471.05682 lineto +123.28711 468.86932 lineto +123.28711 467.69354 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +130.38965 462.65546 moveto +129.71517 462.65546 129.18196 462.91979 128.79004 463.44843 curveto +128.39811 463.97252 128.20215 464.69257 128.20215 465.60858 curveto +128.20215 466.5246 128.39583 467.24693 128.7832 467.77557 curveto +129.17513 468.29966 129.71061 468.56171 130.38965 468.56171 curveto +131.05957 468.56171 131.59049 468.29738 131.98242 467.76874 curveto +132.37434 467.24009 132.57031 466.52004 132.57031 465.60858 curveto +132.57031 464.70169 132.37434 463.98391 131.98242 463.45526 curveto +131.59049 462.92206 131.05957 462.65546 130.38965 462.65546 curveto +130.38965 461.58905 moveto +131.48339 461.58906 132.34244 461.94453 132.9668 462.65546 curveto +133.59114 463.3664 133.90331 464.35077 133.90332 465.60858 curveto +133.90331 466.86184 133.59114 467.84621 132.9668 468.56171 curveto +132.34244 469.27264 131.48339 469.62811 130.38965 469.62811 curveto +129.29134 469.62811 128.43001 469.27264 127.80566 468.56171 curveto +127.18587 467.84621 126.87598 466.86184 126.87598 465.60858 curveto +126.87598 464.35077 127.18587 463.3664 127.80566 462.65546 curveto +128.43001 461.94453 129.29134 461.58906 130.38965 461.58905 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +135.7832 458.80682 moveto +136.87695 458.80682 lineto +137.56054 459.88235 138.07096 460.93509 138.4082 461.96503 curveto +138.75 462.99498 138.92089 464.01809 138.9209 465.03436 curveto +138.92089 466.0552 138.75 467.08287 138.4082 468.11737 curveto +138.07096 469.15188 137.56054 470.20461 136.87695 471.27557 curveto +135.7832 471.27557 lineto +136.38932 470.23195 136.84049 469.19517 137.13672 468.16522 curveto +137.4375 467.13072 137.58789 466.0871 137.58789 465.03436 curveto +137.58789 463.98163 137.4375 462.94257 137.13672 461.91718 curveto +136.84049 460.89179 136.38932 459.85501 135.7832 458.80682 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +4.1689453 477.84198 moveto +3.5582645 478.89017 3.1048144 479.92695 2.8085938 480.95233 curveto +2.5123671 481.97773 2.3642553 483.01679 2.3642578 484.06952 curveto +2.3642553 485.12226 2.5123671 486.16588 2.8085938 487.20038 curveto +3.1093717 488.23033 3.5628218 489.26711 4.1689453 490.31073 curveto +3.0751953 490.31073 lineto +2.391599 489.23977 1.8789042 488.18703 1.5371094 487.15253 curveto +1.1998684 486.11802 1.0312488 485.09036 1.03125 484.06952 curveto +1.0312488 483.05325 1.1998684 482.03014 1.5371094 481.00018 curveto +1.8743469 479.97024 2.3870417 478.91751 3.0751953 477.84198 curveto +4.1689453 477.84198 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +6.4453125 478.25897 moveto +13.007812 478.25897 lineto +13.007812 478.84686 lineto +9.3027344 488.46503 lineto +7.8603516 488.46503 lineto +11.34668 479.42108 lineto +6.4453125 479.42108 lineto +6.4453125 478.25897 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +15.851562 486.7287 moveto +17.293945 486.7287 lineto +17.293945 487.90448 lineto +16.172852 490.09198 lineto +15.291016 490.09198 lineto +15.851562 487.90448 lineto +15.851562 486.7287 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +23.289062 482.81171 moveto +22.669267 482.81171 22.17708 483.02363 21.8125 483.44745 curveto +21.452471 483.87128 21.272458 484.45234 21.272461 485.19061 curveto +21.272458 485.92434 21.452471 486.50539 21.8125 486.93378 curveto +22.17708 487.35761 22.669267 487.56952 23.289062 487.56952 curveto +23.908849 487.56952 24.398757 487.35761 24.758789 486.93378 curveto +25.123366 486.50539 25.305657 485.92434 25.305664 485.19061 curveto +25.305657 484.45234 25.123366 483.87128 24.758789 483.44745 curveto +24.398757 483.02363 23.908849 482.81171 23.289062 482.81171 curveto +26.030273 478.48456 moveto +26.030273 479.74237 lineto +25.683912 479.57832 25.333001 479.45299 24.977539 479.36639 curveto +24.626622 479.27981 24.277989 479.23652 23.931641 479.23651 curveto +23.020178 479.23652 22.322913 479.54414 21.839844 480.15936 curveto +21.361325 480.7746 21.087888 481.70429 21.019531 482.94843 curveto +21.288409 482.55195 21.625648 482.24889 22.03125 482.03925 curveto +22.436845 481.82506 22.883459 481.71796 23.371094 481.71796 curveto +24.396479 481.71796 25.205397 482.03014 25.797852 482.65448 curveto +26.394849 483.27428 26.693351 484.11965 26.693359 485.19061 curveto +26.693351 486.23879 26.383456 487.07961 25.763672 487.71307 curveto +25.143874 488.34654 24.319005 488.66327 23.289062 488.66327 curveto +22.108721 488.66327 21.206378 488.2121 20.582031 487.30975 curveto +19.957681 486.40285 19.645507 485.09036 19.645508 483.37225 curveto +19.645507 481.75898 20.028319 480.47382 20.793945 479.51678 curveto +21.559567 478.55521 22.587236 478.07441 23.876953 478.0744 curveto +24.223302 478.07441 24.571934 478.10859 24.922852 478.17694 curveto +25.278314 478.24531 25.647454 478.34785 26.030273 478.48456 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +29.222656 486.7287 moveto +30.665039 486.7287 lineto +30.665039 487.90448 lineto +29.543945 490.09198 lineto +28.662109 490.09198 lineto +29.222656 487.90448 lineto +29.222656 486.7287 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +36.325195 481.69061 moveto +35.650713 481.69062 35.11751 481.95494 34.725586 482.48358 curveto +34.333657 483.00768 34.137693 483.72773 34.137695 484.64374 curveto +34.137693 485.55976 34.331378 486.28209 34.71875 486.81073 curveto +35.110674 487.33482 35.646155 487.59686 36.325195 487.59686 curveto +36.995112 487.59686 37.526036 487.33254 37.917969 486.80389 curveto +38.30989 486.27525 38.505853 485.5552 38.505859 484.64374 curveto +38.505853 483.73684 38.30989 483.01907 37.917969 482.49042 curveto +37.526036 481.95722 36.995112 481.69062 36.325195 481.69061 curveto +36.325195 480.62421 moveto +37.41894 480.62421 38.277989 480.97968 38.902344 481.69061 curveto +39.526685 482.40156 39.838859 483.38593 39.838867 484.64374 curveto +39.838859 485.897 39.526685 486.88137 38.902344 487.59686 curveto +38.277989 488.3078 37.41894 488.66327 36.325195 488.66327 curveto +35.226885 488.66327 34.365558 488.3078 33.741211 487.59686 curveto +33.121418 486.88137 32.811523 485.897 32.811523 484.64374 curveto +32.811523 483.38593 33.121418 482.40156 33.741211 481.69061 curveto +34.365558 480.97968 35.226885 480.62421 36.325195 480.62421 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +41.71875 477.84198 moveto +42.8125 477.84198 lineto +43.496091 478.91751 44.006507 479.97024 44.34375 481.00018 curveto +44.685543 482.03014 44.856441 483.05325 44.856445 484.06952 curveto +44.856441 485.09036 44.685543 486.11802 44.34375 487.15253 curveto +44.006507 488.18703 43.496091 489.23977 42.8125 490.31073 curveto +41.71875 490.31073 lineto +42.324868 489.26711 42.776039 488.23033 43.072266 487.20038 curveto +43.373044 486.16588 43.523435 485.12226 43.523438 484.06952 curveto +43.523435 483.01679 43.373044 481.97773 43.072266 480.95233 curveto +42.776039 479.92695 42.324868 478.89017 41.71875 477.84198 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +51.951172 478.34198 moveto +51.340491 479.39017 50.887041 480.42695 50.59082 481.45233 curveto +50.294594 482.47773 50.146482 483.51679 50.146484 484.56952 curveto +50.146482 485.62226 50.294594 486.66588 50.59082 487.70038 curveto +50.891598 488.73033 51.345048 489.76711 51.951172 490.81073 curveto +50.857422 490.81073 lineto +50.173826 489.73977 49.661131 488.68703 49.319336 487.65253 curveto +48.982095 486.61802 48.813475 485.59036 48.813477 484.56952 curveto +48.813475 483.55325 48.982095 482.53014 49.319336 481.50018 curveto +49.656573 480.47024 50.169268 479.41751 50.857422 478.34198 curveto +51.951172 478.34198 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +57.529297 484.11835 moveto +56.873043 484.11835 56.355791 484.29381 55.977539 484.64471 curveto +55.603839 484.99563 55.41699 485.4787 55.416992 486.09393 curveto +55.41699 486.70917 55.603839 487.19224 55.977539 487.54315 curveto +56.355791 487.89406 56.873043 488.06952 57.529297 488.06952 curveto +58.185542 488.06952 58.702794 487.89406 59.081055 487.54315 curveto +59.459304 487.18768 59.648431 486.70461 59.648438 486.09393 curveto +59.648431 485.4787 59.459304 484.99563 59.081055 484.64471 curveto +58.707351 484.29381 58.190099 484.11835 57.529297 484.11835 curveto +56.148438 483.53046 moveto +55.555987 483.38463 55.093422 483.10891 54.760742 482.70331 curveto +54.432616 482.29772 54.268553 481.80325 54.268555 481.21991 curveto +54.268553 480.40416 54.557941 479.75931 55.136719 479.28534 curveto +55.720049 478.81139 56.517575 478.57441 57.529297 478.5744 curveto +58.545567 478.57441 59.343093 478.81139 59.921875 479.28534 curveto +60.500644 479.75931 60.790031 480.40416 60.790039 481.21991 curveto +60.790031 481.80325 60.62369 482.29772 60.291016 482.70331 curveto +59.962884 483.10891 59.504876 483.38463 58.916992 483.53046 curveto +59.58235 483.68541 60.099602 483.98847 60.46875 484.43964 curveto +60.84244 484.89081 61.029289 485.44224 61.029297 486.09393 curveto +61.029289 487.08287 60.726229 487.84166 60.120117 488.3703 curveto +59.518548 488.89895 58.654942 489.16327 57.529297 489.16327 curveto +56.403643 489.16327 55.537758 488.89895 54.931641 488.3703 curveto +54.330077 487.84166 54.029296 487.08287 54.029297 486.09393 curveto +54.029296 485.44224 54.216145 484.89081 54.589844 484.43964 curveto +54.96354 483.98847 55.483071 483.68541 56.148438 483.53046 curveto +55.642578 481.34979 moveto +55.642576 481.87845 55.806638 482.29088 56.134766 482.5871 curveto +56.467445 482.88333 56.932288 483.03144 57.529297 483.03143 curveto +58.12174 483.03144 58.584304 482.88333 58.916992 482.5871 curveto +59.254226 482.29088 59.422845 481.87845 59.422852 481.34979 curveto +59.422845 480.82115 59.254226 480.40872 58.916992 480.11249 curveto +58.584304 479.81627 58.12174 479.66816 57.529297 479.66815 curveto +56.932288 479.66816 56.467445 479.81627 56.134766 480.11249 curveto +55.806638 480.40872 55.642576 480.82115 55.642578 481.34979 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +63.633789 487.2287 moveto +65.076172 487.2287 lineto +65.076172 488.40448 lineto +63.955078 490.59198 lineto +63.073242 490.59198 lineto +63.633789 488.40448 lineto +63.633789 487.2287 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +67.598633 478.75897 moveto +74.161133 478.75897 lineto +74.161133 479.34686 lineto +70.456055 488.96503 lineto +69.013672 488.96503 lineto +72.5 479.92108 lineto +67.598633 479.92108 lineto +67.598633 478.75897 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +77.004883 487.2287 moveto +78.447266 487.2287 lineto +78.447266 488.40448 lineto +77.326172 490.59198 lineto +76.444336 490.59198 lineto +77.004883 488.40448 lineto +77.004883 487.2287 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +84.107422 482.19061 moveto +83.432939 482.19062 82.899737 482.45494 82.507812 482.98358 curveto +82.115883 483.50768 81.91992 484.22773 81.919922 485.14374 curveto +81.91992 486.05976 82.113604 486.78209 82.500977 487.31073 curveto +82.892901 487.83482 83.428382 488.09686 84.107422 488.09686 curveto +84.777339 488.09686 85.308263 487.83254 85.700195 487.30389 curveto +86.092116 486.77525 86.288079 486.0552 86.288086 485.14374 curveto +86.288079 484.23684 86.092116 483.51907 85.700195 482.99042 curveto +85.308263 482.45722 84.777339 482.19062 84.107422 482.19061 curveto +84.107422 481.12421 moveto +85.201166 481.12421 86.060215 481.47968 86.68457 482.19061 curveto +87.308912 482.90156 87.621086 483.88593 87.621094 485.14374 curveto +87.621086 486.397 87.308912 487.38137 86.68457 488.09686 curveto +86.060215 488.8078 85.201166 489.16327 84.107422 489.16327 curveto +83.009111 489.16327 82.147784 488.8078 81.523438 488.09686 curveto +80.903645 487.38137 80.593749 486.397 80.59375 485.14374 curveto +80.593749 483.88593 80.903645 482.90156 81.523438 482.19061 curveto +82.147784 481.47968 83.009111 481.12421 84.107422 481.12421 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +89.500977 478.34198 moveto +90.594727 478.34198 lineto +91.278317 479.41751 91.788734 480.47024 92.125977 481.50018 curveto +92.467769 482.53014 92.638668 483.55325 92.638672 484.56952 curveto +92.638668 485.59036 92.467769 486.61802 92.125977 487.65253 curveto +91.788734 488.68703 91.278317 489.73977 90.594727 490.81073 curveto +89.500977 490.81073 lineto +90.107095 489.76711 90.558266 488.73033 90.854492 487.70038 curveto +91.155271 486.66588 91.305661 485.62226 91.305664 484.56952 curveto +91.305661 483.51679 91.155271 482.47773 90.854492 481.45233 curveto +90.558266 480.42695 90.107095 479.39017 89.500977 478.34198 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +96.905273 479.30878 moveto +96.294593 480.35696 95.841143 481.39375 95.544922 482.41913 curveto +95.248695 483.44453 95.100583 484.48359 95.100586 485.53632 curveto +95.100583 486.58905 95.248695 487.63267 95.544922 488.66718 curveto +95.8457 489.69712 96.29915 490.73391 96.905273 491.77753 curveto +95.811523 491.77753 lineto +95.127927 490.70656 94.615232 489.65383 94.273438 488.61932 curveto +93.936197 487.58482 93.767577 486.55715 93.767578 485.53632 curveto +93.767577 484.52005 93.936197 483.49693 94.273438 482.46698 curveto +94.610675 481.43704 95.12337 480.38431 95.811523 479.30878 curveto +96.905273 479.30878 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +99.571289 489.71991 moveto +99.571289 488.4621 lineto +99.917641 488.62616 100.26855 488.75149 100.62402 488.83807 curveto +100.97949 488.92466 101.32812 488.96796 101.66992 488.96796 curveto +102.58138 488.96796 103.27636 488.66262 103.75488 488.05194 curveto +104.23795 487.43671 104.51367 486.50474 104.58203 485.25604 curveto +104.3177 485.64797 103.98274 485.94875 103.57715 486.15839 curveto +103.17154 486.36803 102.72265 486.47284 102.23047 486.47284 curveto +101.20963 486.47284 100.40071 486.16523 99.803711 485.54999 curveto +99.211262 484.9302 98.915038 484.08482 98.915039 483.01385 curveto +98.915038 481.96569 99.224934 481.12487 99.844727 480.49139 curveto +100.46452 479.85794 101.28938 479.54121 102.31934 479.5412 curveto +103.49967 479.54121 104.39973 479.99466 105.01953 480.90155 curveto +105.64387 481.8039 105.95605 483.1164 105.95605 484.83905 curveto +105.95605 486.44778 105.57323 487.73293 104.80762 488.69452 curveto +104.04654 489.65155 103.02115 490.13007 101.73145 490.13007 curveto +101.38509 490.13007 101.03418 490.09589 100.67871 490.02753 curveto +100.32324 489.95917 99.9541 489.85663 99.571289 489.71991 curveto +102.31934 485.39276 moveto +102.93912 485.39277 103.42903 485.18085 103.78906 484.75702 curveto +104.15364 484.3332 104.33593 483.75214 104.33594 483.01385 curveto +104.33593 482.28014 104.15364 481.70136 103.78906 481.27753 curveto +103.42903 480.84915 102.93912 480.63496 102.31934 480.63495 curveto +101.69954 480.63496 101.20735 480.84915 100.84277 481.27753 curveto +100.48274 481.70136 100.30273 482.28014 100.30273 483.01385 curveto +100.30273 483.75214 100.48274 484.3332 100.84277 484.75702 curveto +101.20735 485.18085 101.69954 485.39277 102.31934 485.39276 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +108.58789 488.1955 moveto +110.03027 488.1955 lineto +110.03027 489.37128 lineto +108.90918 491.55878 lineto +108.02734 491.55878 lineto +108.58789 489.37128 lineto +108.58789 488.1955 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +115.85449 485.08514 moveto +115.19824 485.08515 114.68099 485.2606 114.30273 485.61151 curveto +113.92903 485.96243 113.74219 486.4455 113.74219 487.06073 curveto +113.74219 487.67597 113.92903 488.15904 114.30273 488.50995 curveto +114.68099 488.86086 115.19824 489.03632 115.85449 489.03632 curveto +116.51074 489.03632 117.02799 488.86086 117.40625 488.50995 curveto +117.7845 488.15448 117.97363 487.67141 117.97363 487.06073 curveto +117.97363 486.4455 117.7845 485.96243 117.40625 485.61151 curveto +117.03255 485.2606 116.51529 485.08515 115.85449 485.08514 curveto +114.47363 484.49725 moveto +113.88118 484.35143 113.41862 484.07571 113.08594 483.6701 curveto +112.75781 483.26451 112.59375 482.77005 112.59375 482.18671 curveto +112.59375 481.37096 112.88314 480.7261 113.46191 480.25214 curveto +114.04524 479.77819 114.84277 479.54121 115.85449 479.5412 curveto +116.87076 479.54121 117.66829 479.77819 118.24707 480.25214 curveto +118.82584 480.7261 119.11523 481.37096 119.11523 482.18671 curveto +119.11523 482.77005 118.94889 483.26451 118.61621 483.6701 curveto +118.28808 484.07571 117.83007 484.35143 117.24219 484.49725 curveto +117.90755 484.65221 118.4248 484.95527 118.79395 485.40643 curveto +119.16764 485.85761 119.35448 486.40904 119.35449 487.06073 curveto +119.35448 488.04966 119.05142 488.80845 118.44531 489.3371 curveto +117.84374 489.86574 116.98014 490.13007 115.85449 490.13007 curveto +114.72884 490.13007 113.86295 489.86574 113.25684 489.3371 curveto +112.65527 488.80845 112.35449 488.04966 112.35449 487.06073 curveto +112.35449 486.40904 112.54134 485.85761 112.91504 485.40643 curveto +113.28874 484.95527 113.80827 484.65221 114.47363 484.49725 curveto +113.96777 482.31659 moveto +113.96777 482.84524 114.13183 483.25768 114.45996 483.55389 curveto +114.79264 483.85012 115.25748 483.99824 115.85449 483.99823 curveto +116.44694 483.99824 116.9095 483.85012 117.24219 483.55389 curveto +117.57942 483.25768 117.74804 482.84524 117.74805 482.31659 curveto +117.74804 481.78795 117.57942 481.37552 117.24219 481.07928 curveto +116.9095 480.78307 116.44694 480.63496 115.85449 480.63495 curveto +115.25748 480.63496 114.79264 480.78307 114.45996 481.07928 curveto +114.13183 481.37552 113.96777 481.78795 113.96777 482.31659 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +121.95898 488.1955 moveto +123.40137 488.1955 lineto +123.40137 489.37128 lineto +122.28027 491.55878 lineto +121.39844 491.55878 lineto +121.95898 489.37128 lineto +121.95898 488.1955 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +131.13281 486.01483 moveto +131.13281 485.10338 130.94368 484.397 130.56543 483.89569 curveto +130.19173 483.3944 129.66536 483.14374 128.98633 483.14374 curveto +128.31185 483.14374 127.78548 483.3944 127.40723 483.89569 curveto +127.03353 484.397 126.84668 485.10338 126.84668 486.01483 curveto +126.84668 486.92174 127.03353 487.62584 127.40723 488.12714 curveto +127.78548 488.62844 128.31185 488.87909 128.98633 488.87909 curveto +129.66536 488.87909 130.19173 488.62844 130.56543 488.12714 curveto +130.94368 487.62584 131.13281 486.92174 131.13281 486.01483 curveto +132.39062 488.98163 moveto +132.39062 490.28501 132.10123 491.25344 131.52246 491.8869 curveto +130.94368 492.52492 130.05729 492.84393 128.86328 492.84393 curveto +128.42122 492.84393 128.00423 492.80975 127.6123 492.74139 curveto +127.22038 492.67759 126.83984 492.57733 126.4707 492.44061 curveto +126.4707 491.21698 lineto +126.83984 491.4175 127.20442 491.56561 127.56445 491.66132 curveto +127.92448 491.75702 128.29134 491.80487 128.66504 491.80487 curveto +129.4899 491.80487 130.10742 491.5884 130.51758 491.15546 curveto +130.92773 490.72707 131.13281 490.07766 131.13281 489.20721 curveto +131.13281 488.58514 lineto +130.87304 489.03632 130.54036 489.37356 130.13477 489.59686 curveto +129.72916 489.82017 129.24381 489.93182 128.67871 489.93182 curveto +127.73991 489.93182 126.9834 489.57408 126.40918 488.85858 curveto +125.83496 488.14309 125.54785 487.19517 125.54785 486.01483 curveto +125.54785 484.82994 125.83496 483.87975 126.40918 483.16425 curveto +126.9834 482.44876 127.73991 482.09101 128.67871 482.091 curveto +129.24381 482.09101 129.72916 482.20266 130.13477 482.42596 curveto +130.54036 482.64928 130.87304 482.98652 131.13281 483.43768 curveto +131.13281 482.27557 lineto +132.39062 482.27557 lineto +132.39062 488.98163 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +134.7832 479.30878 moveto +135.87695 479.30878 lineto +136.56054 480.38431 137.07096 481.43704 137.4082 482.46698 curveto +137.75 483.49693 137.92089 484.52005 137.9209 485.53632 curveto +137.92089 486.55715 137.75 487.58482 137.4082 488.61932 curveto +137.07096 489.65383 136.56054 490.70656 135.87695 491.77753 curveto +134.7832 491.77753 lineto +135.38932 490.73391 135.84049 489.69712 136.13672 488.66718 curveto +136.4375 487.63267 136.58789 486.58905 136.58789 485.53632 curveto +136.58789 484.48359 136.4375 483.44453 136.13672 482.41913 curveto +135.84049 481.39375 135.38932 480.35696 134.7832 479.30878 curveto +fill +grestore +gsave [1.209899 0 0 0.857509 -38.19343 49.51799] concat +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +154.5 482.61218 moveto +154.5 515.59418 125.716 542.36218 90.25 542.36218 curveto +54.784 542.36218 26 515.59418 26 482.61218 curveto +26 449.63018 54.784 422.86218 90.25 422.86218 curveto +125.716 422.86218 154.5 449.63018 154.5 482.61218 curveto +closepath +stroke +grestore +gsave +0 0 0 setrgbcolor +newpath +67.874023 420.15613 moveto +69.254883 420.15613 lineto +69.254883 430.36218 lineto +67.874023 430.36218 lineto +67.874023 420.15613 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +73.192383 420.5321 moveto +73.192383 422.70593 lineto +75.783203 422.70593 lineto +75.783203 423.68347 lineto +73.192383 423.68347 lineto +73.192383 427.83972 lineto +73.19238 428.46407 73.27669 428.86511 73.445312 429.04285 curveto +73.618487 429.22058 73.967119 429.30945 74.491211 429.30945 curveto +75.783203 429.30945 lineto +75.783203 430.36218 lineto +74.491211 430.36218 lineto +73.520505 430.36218 72.850584 430.18217 72.481445 429.82214 curveto +72.112303 429.45756 71.927733 428.79675 71.927734 427.83972 curveto +71.927734 423.68347 lineto +71.004883 423.68347 lineto +71.004883 422.70593 lineto +71.927734 422.70593 lineto +71.927734 420.5321 lineto +73.192383 420.5321 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +59.254883 524.79089 moveto +59.254883 528.62585 lineto +60.991211 528.62585 lineto +61.633784 528.62586 62.130528 528.45952 62.481445 528.12683 curveto +62.83235 527.79415 63.007806 527.3202 63.007812 526.70496 curveto +63.007806 526.09429 62.83235 525.62261 62.481445 525.28992 curveto +62.130528 524.95724 61.633784 524.7909 60.991211 524.79089 curveto +59.254883 524.79089 lineto +57.874023 523.65613 moveto +60.991211 523.65613 lineto +62.135086 523.65614 62.998691 523.9159 63.582031 524.43542 curveto +64.169914 524.95041 64.463859 525.70692 64.463867 526.70496 curveto +64.463859 527.71212 64.169914 528.47319 63.582031 528.98816 curveto +62.998691 529.50314 62.135086 529.76062 60.991211 529.76062 curveto +59.254883 529.76062 lineto +59.254883 533.86218 lineto +57.874023 533.86218 lineto +57.874023 523.65613 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +69.399414 524.56531 moveto +68.688473 524.56532 68.152992 524.91623 67.792969 525.61804 curveto +67.437498 526.31532 67.259763 527.36577 67.259766 528.76941 curveto +67.259763 530.1685 67.437498 531.21896 67.792969 531.92078 curveto +68.152992 532.61804 68.688473 532.96668 69.399414 532.96667 curveto +70.114904 532.96668 70.650385 532.61804 71.005859 531.92078 curveto +71.365879 531.21896 71.545892 530.1685 71.545898 528.76941 curveto +71.545892 527.36577 71.365879 526.31532 71.005859 525.61804 curveto +70.650385 524.91623 70.114904 524.56532 69.399414 524.56531 curveto +69.399414 523.47156 moveto +70.543289 523.47157 71.416009 523.92502 72.017578 524.83191 curveto +72.62369 525.73426 72.92675 527.04676 72.926758 528.76941 curveto +72.92675 530.48751 72.62369 531.80001 72.017578 532.70691 curveto +71.416009 533.60925 70.543289 534.06042 69.399414 534.06042 curveto +68.255531 534.06042 67.380531 533.60925 66.774414 532.70691 curveto +66.17285 531.80001 65.872069 530.48751 65.87207 528.76941 curveto +65.872069 527.04676 66.17285 525.73426 66.774414 524.83191 curveto +67.380531 523.92502 68.255531 523.47157 69.399414 523.47156 curveto +fill +grestore +gsave [1.063088 0 0 0.999533 -49.82231 5.914079] concat +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +349.5 351.36218 moveto +349.5 378.68618 319.484 400.86218 282.5 400.86218 curveto +245.516 400.86218 215.5 378.68618 215.5 351.36218 curveto +215.5 324.03818 245.516 301.86218 282.5 301.86218 curveto +319.484 301.86218 349.5 324.03818 349.5 351.36218 curveto +closepath +stroke +grestore +gsave +0 0 0 setrgbcolor +newpath +205.85547 329.61218 moveto +205.24479 330.66037 204.79134 331.69715 204.49512 332.72253 curveto +204.19889 333.74793 204.05078 334.78699 204.05078 335.83972 curveto +204.05078 336.89246 204.19889 337.93608 204.49512 338.97058 curveto +204.7959 340.00053 205.24935 341.03731 205.85547 342.08093 curveto +204.76172 342.08093 lineto +204.07812 341.00997 203.56543 339.95723 203.22363 338.92273 curveto +202.88639 337.88823 202.71777 336.86056 202.71777 335.83972 curveto +202.71777 334.82345 202.88639 333.80034 203.22363 332.77039 curveto +203.56087 331.74045 204.07357 330.68771 204.76172 329.61218 curveto +205.85547 329.61218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +208.49414 330.02917 moveto +213.91504 330.02917 lineto +213.91504 331.19128 lineto +209.75879 331.19128 lineto +209.75879 333.69324 lineto +209.95931 333.62488 210.15983 333.57475 210.36035 333.54285 curveto +210.56087 333.5064 210.76139 333.48817 210.96191 333.48816 curveto +212.10123 333.48817 213.00357 333.80034 213.66895 334.42468 curveto +214.3343 335.04904 214.66698 335.89441 214.66699 336.96082 curveto +214.66698 338.05912 214.32519 338.91362 213.6416 339.52429 curveto +212.958 340.13041 211.99414 340.43347 210.75 340.43347 curveto +210.32161 340.43347 209.88411 340.39701 209.4375 340.3241 curveto +208.99544 340.25118 208.53743 340.14181 208.06348 339.99597 curveto +208.06348 338.60828 lineto +208.47363 338.83159 208.89746 338.99793 209.33496 339.1073 curveto +209.77246 339.21668 210.23502 339.27136 210.72266 339.27136 curveto +211.51106 339.27136 212.13541 339.06401 212.5957 338.64929 curveto +213.05598 338.23458 213.28613 337.67176 213.28613 336.96082 curveto +213.28613 336.24988 213.05598 335.68706 212.5957 335.27234 curveto +212.13541 334.85763 211.51106 334.65027 210.72266 334.65027 curveto +210.35351 334.65027 209.98437 334.69129 209.61523 334.77332 curveto +209.25065 334.85535 208.87695 334.98296 208.49414 335.15613 curveto +208.49414 330.02917 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +217.53809 338.4989 moveto +218.98047 338.4989 lineto +218.98047 339.67468 lineto +217.85938 341.86218 lineto +216.97754 341.86218 lineto +217.53809 339.67468 lineto +217.53809 338.4989 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +224.80469 330.93835 moveto +224.09375 330.93836 223.55827 331.28927 223.19824 331.99109 curveto +222.84277 332.68836 222.66504 333.73882 222.66504 335.14246 curveto +222.66504 336.54155 222.84277 337.592 223.19824 338.29382 curveto +223.55827 338.99109 224.09375 339.33972 224.80469 339.33972 curveto +225.52018 339.33972 226.05566 338.99109 226.41113 338.29382 curveto +226.77115 337.592 226.95117 336.54155 226.95117 335.14246 curveto +226.95117 333.73882 226.77115 332.68836 226.41113 331.99109 curveto +226.05566 331.28927 225.52018 330.93836 224.80469 330.93835 curveto +224.80469 329.8446 moveto +225.94856 329.84461 226.82128 330.29806 227.42285 331.20496 curveto +228.02896 332.10731 228.33202 333.41981 228.33203 335.14246 curveto +228.33202 336.86056 228.02896 338.17306 227.42285 339.07996 curveto +226.82128 339.9823 225.94856 340.43347 224.80469 340.43347 curveto +223.6608 340.43347 222.7858 339.9823 222.17969 339.07996 curveto +221.57812 338.17306 221.27734 336.86056 221.27734 335.14246 curveto +221.27734 333.41981 221.57812 332.10731 222.17969 331.20496 curveto +222.7858 330.29806 223.6608 329.84461 224.80469 329.8446 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +230.90918 338.4989 moveto +232.35156 338.4989 lineto +232.35156 339.67468 lineto +231.23047 341.86218 lineto +230.34863 341.86218 lineto +230.90918 339.67468 lineto +230.90918 338.4989 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +240.08301 336.31824 moveto +240.083 335.40678 239.89387 334.7004 239.51562 334.1991 curveto +239.14192 333.6978 238.61556 333.44715 237.93652 333.44714 curveto +237.26204 333.44715 236.73567 333.6978 236.35742 334.1991 curveto +235.98372 334.7004 235.79687 335.40678 235.79688 336.31824 curveto +235.79687 337.22514 235.98372 337.92924 236.35742 338.43054 curveto +236.73567 338.93185 237.26204 339.1825 237.93652 339.1825 curveto +238.61556 339.1825 239.14192 338.93185 239.51562 338.43054 curveto +239.89387 337.92924 240.083 337.22514 240.08301 336.31824 curveto +241.34082 339.28503 moveto +241.34081 340.58842 241.05142 341.55684 240.47266 342.19031 curveto +239.89387 342.82833 239.00748 343.14734 237.81348 343.14734 curveto +237.37142 343.14734 236.95442 343.11316 236.5625 343.0448 curveto +236.17057 342.98099 235.79004 342.88073 235.4209 342.74402 curveto +235.4209 341.52039 lineto +235.79004 341.72091 236.15462 341.86902 236.51465 341.96472 curveto +236.87467 342.06042 237.24153 342.10827 237.61523 342.10828 curveto +238.4401 342.10827 239.05761 341.8918 239.46777 341.45886 curveto +239.87792 341.03048 240.083 340.38106 240.08301 339.51062 curveto +240.08301 338.88855 lineto +239.82324 339.33972 239.49055 339.67696 239.08496 339.90027 curveto +238.67936 340.12358 238.19401 340.23523 237.62891 340.23523 curveto +236.6901 340.23523 235.93359 339.87748 235.35938 339.16199 curveto +234.78516 338.44649 234.49805 337.49858 234.49805 336.31824 curveto +234.49805 335.13335 234.78516 334.18315 235.35938 333.46765 curveto +235.93359 332.75216 236.6901 332.39442 237.62891 332.39441 curveto +238.19401 332.39442 238.67936 332.50607 239.08496 332.72937 curveto +239.49055 332.95268 239.82324 333.28992 240.08301 333.74109 curveto +240.08301 332.57898 lineto +241.34082 332.57898 lineto +241.34082 339.28503 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +243.7334 329.61218 moveto +244.82715 329.61218 lineto +245.51074 330.68771 246.02116 331.74045 246.3584 332.77039 curveto +246.70019 333.80034 246.87109 334.82345 246.87109 335.83972 curveto +246.87109 336.86056 246.70019 337.88823 246.3584 338.92273 curveto +246.02116 339.95723 245.51074 341.00997 244.82715 342.08093 curveto +243.7334 342.08093 lineto +244.33952 341.03731 244.79069 340.00053 245.08691 338.97058 curveto +245.38769 337.93608 245.53808 336.89246 245.53809 335.83972 curveto +245.53808 334.78699 245.38769 333.74793 245.08691 332.72253 curveto +244.79069 331.69715 244.33952 330.66037 243.7334 329.61218 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +253.34082 328.61218 moveto +252.73014 329.66037 252.27669 330.69715 251.98047 331.72253 curveto +251.68424 332.74793 251.53613 333.78699 251.53613 334.83972 curveto +251.53613 335.89246 251.68424 336.93608 251.98047 337.97058 curveto +252.28125 339.00053 252.7347 340.03731 253.34082 341.08093 curveto +252.24707 341.08093 lineto +251.56347 340.00997 251.05078 338.95723 250.70898 337.92273 curveto +250.37174 336.88823 250.20312 335.86056 250.20312 334.83972 curveto +250.20312 333.82345 250.37174 332.80034 250.70898 331.77039 curveto +251.04622 330.74045 251.55892 329.68771 252.24707 328.61218 curveto +253.34082 328.61218 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +259.08984 333.58191 moveto +258.47005 333.58191 257.97786 333.79383 257.61328 334.21765 curveto +257.25325 334.64148 257.07324 335.22254 257.07324 335.96082 curveto +257.07324 336.69454 257.25325 337.2756 257.61328 337.70398 curveto +257.97786 338.12781 258.47005 338.33972 259.08984 338.33972 curveto +259.70963 338.33972 260.19954 338.12781 260.55957 337.70398 curveto +260.92415 337.2756 261.10644 336.69454 261.10645 335.96082 curveto +261.10644 335.22254 260.92415 334.64148 260.55957 334.21765 curveto +260.19954 333.79383 259.70963 333.58191 259.08984 333.58191 curveto +261.83105 329.25476 moveto +261.83105 330.51257 lineto +261.48469 330.34852 261.13378 330.22319 260.77832 330.1366 curveto +260.4274 330.05002 260.07877 330.00672 259.73242 330.00671 curveto +258.82096 330.00672 258.12369 330.31434 257.64062 330.92957 curveto +257.16211 331.54481 256.88867 332.47449 256.82031 333.71863 curveto +257.08919 333.32215 257.42643 333.01909 257.83203 332.80945 curveto +258.23763 332.59526 258.68424 332.48817 259.17188 332.48816 curveto +260.19726 332.48817 261.00618 332.80034 261.59863 333.42468 curveto +262.19563 334.04448 262.49413 334.88986 262.49414 335.96082 curveto +262.49413 337.00899 262.18424 337.84981 261.56445 338.48328 curveto +260.94465 339.11674 260.11979 339.43347 259.08984 339.43347 curveto +257.9095 339.43347 257.00716 338.9823 256.38281 338.07996 curveto +255.75846 337.17306 255.44629 335.86056 255.44629 334.14246 curveto +255.44629 332.52918 255.8291 331.24403 256.59473 330.28699 curveto +257.36035 329.32541 258.38802 328.84461 259.67773 328.8446 curveto +260.02408 328.84461 260.37272 328.87879 260.72363 328.94714 curveto +261.07909 329.01551 261.44824 329.11805 261.83105 329.25476 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +265.02344 337.4989 moveto +266.46582 337.4989 lineto +266.46582 338.67468 lineto +265.34473 340.86218 lineto +264.46289 340.86218 lineto +265.02344 338.67468 lineto +265.02344 337.4989 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +269.57617 338.07312 moveto +271.83203 338.07312 lineto +271.83203 330.28699 lineto +269.37793 330.77917 lineto +269.37793 329.52136 lineto +271.81836 329.02917 lineto +273.19922 329.02917 lineto +273.19922 338.07312 lineto +275.45508 338.07312 lineto +275.45508 339.23523 lineto +269.57617 339.23523 lineto +269.57617 338.07312 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +278.39453 337.4989 moveto +279.83691 337.4989 lineto +279.83691 338.67468 lineto +278.71582 340.86218 lineto +277.83398 340.86218 lineto +278.39453 338.67468 lineto +278.39453 337.4989 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +285.49707 332.46082 moveto +284.82259 332.46082 284.28938 332.72514 283.89746 333.25378 curveto +283.50553 333.77788 283.30957 334.49793 283.30957 335.41394 curveto +283.30957 336.32996 283.50325 337.05229 283.89062 337.58093 curveto +284.28255 338.10502 284.81803 338.36707 285.49707 338.36707 curveto +286.16699 338.36707 286.69791 338.10274 287.08984 337.5741 curveto +287.48176 337.04545 287.67773 336.3254 287.67773 335.41394 curveto +287.67773 334.50704 287.48176 333.78927 287.08984 333.26062 curveto +286.69791 332.72742 286.16699 332.46082 285.49707 332.46082 curveto +285.49707 331.39441 moveto +286.59081 331.39442 287.44986 331.74989 288.07422 332.46082 curveto +288.69856 333.17176 289.01073 334.15613 289.01074 335.41394 curveto +289.01073 336.6672 288.69856 337.65157 288.07422 338.36707 curveto +287.44986 339.078 286.59081 339.43347 285.49707 339.43347 curveto +284.39876 339.43347 283.53743 339.078 282.91309 338.36707 curveto +282.29329 337.65157 281.9834 336.6672 281.9834 335.41394 curveto +281.9834 334.15613 282.29329 333.17176 282.91309 332.46082 curveto +283.53743 331.74989 284.39876 331.39442 285.49707 331.39441 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +290.89062 328.61218 moveto +291.98438 328.61218 lineto +292.66797 329.68771 293.17838 330.74045 293.51562 331.77039 curveto +293.85742 332.80034 294.02832 333.82345 294.02832 334.83972 curveto +294.02832 335.86056 293.85742 336.88823 293.51562 337.92273 curveto +293.17838 338.95723 292.66797 340.00997 291.98438 341.08093 curveto +290.89062 341.08093 lineto +291.49674 340.03731 291.94791 339.00053 292.24414 337.97058 curveto +292.54492 336.93608 292.69531 335.89246 292.69531 334.83972 curveto +292.69531 333.78699 292.54492 332.74793 292.24414 331.72253 curveto +291.94791 330.69715 291.49674 329.66037 290.89062 328.61218 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +188.1377 350.98914 moveto +187.52701 352.03732 187.07356 353.07411 186.77734 354.09949 curveto +186.48112 355.12488 186.33301 356.16395 186.33301 357.21667 curveto +186.33301 358.26941 186.48112 359.31303 186.77734 360.34753 curveto +187.07812 361.37748 187.53157 362.41427 188.1377 363.45789 curveto +187.04395 363.45789 lineto +186.36035 362.38692 185.84765 361.33419 185.50586 360.29968 curveto +185.16862 359.26518 185 358.23751 185 357.21667 curveto +185 356.2004 185.16862 355.17729 185.50586 354.14734 curveto +185.8431 353.1174 186.35579 352.06467 187.04395 350.98914 curveto +188.1377 350.98914 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +190.41406 351.40613 moveto +196.97656 351.40613 lineto +196.97656 351.99402 lineto +193.27148 361.61218 lineto +191.8291 361.61218 lineto +195.31543 352.56824 lineto +190.41406 352.56824 lineto +190.41406 351.40613 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +199.82031 359.87585 moveto +201.2627 359.87585 lineto +201.2627 361.05164 lineto +200.1416 363.23914 lineto +199.25977 363.23914 lineto +199.82031 361.05164 lineto +199.82031 359.87585 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +205.32324 360.45007 moveto +210.14258 360.45007 lineto +210.14258 361.61218 lineto +203.66211 361.61218 lineto +203.66211 360.45007 lineto +204.1862 359.90776 204.89941 359.18087 205.80176 358.26941 curveto +206.70865 357.3534 207.27832 356.76323 207.51074 356.4989 curveto +207.95279 356.00216 208.26041 355.58289 208.43359 355.24109 curveto +208.61132 354.89474 208.70019 354.55522 208.7002 354.22253 curveto +208.70019 353.68022 208.50878 353.23817 208.12598 352.89636 curveto +207.74772 352.55457 207.25325 352.38368 206.64258 352.38367 curveto +206.20963 352.38368 205.75162 352.45887 205.26855 352.60925 curveto +204.79004 352.75965 204.27734 352.98752 203.73047 353.29285 curveto +203.73047 351.89832 lineto +204.28646 351.67502 204.80599 351.5064 205.28906 351.39246 curveto +205.77213 351.27853 206.21419 351.22157 206.61523 351.22156 curveto +207.67252 351.22157 208.51562 351.48589 209.14453 352.01453 curveto +209.77343 352.54318 210.08788 353.24956 210.08789 354.13367 curveto +210.08788 354.55294 210.00813 354.95171 209.84863 355.32996 curveto +209.69368 355.70366 209.40885 356.14572 208.99414 356.65613 curveto +208.8802 356.78829 208.5179 357.17111 207.90723 357.80457 curveto +207.29654 358.43347 206.43522 359.31531 205.32324 360.45007 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +213.19141 359.87585 moveto +214.63379 359.87585 lineto +214.63379 361.05164 lineto +213.5127 363.23914 lineto +212.63086 363.23914 lineto +213.19141 361.05164 lineto +213.19141 359.87585 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +220.29395 354.83777 moveto +219.61946 354.83778 219.08626 355.1021 218.69434 355.63074 curveto +218.30241 356.15483 218.10644 356.87488 218.10645 357.79089 curveto +218.10644 358.70691 218.30013 359.42924 218.6875 359.95789 curveto +219.07942 360.48198 219.61491 360.74402 220.29395 360.74402 curveto +220.96386 360.74402 221.49479 360.4797 221.88672 359.95105 curveto +222.27864 359.42241 222.4746 358.70235 222.47461 357.79089 curveto +222.4746 356.884 222.27864 356.16622 221.88672 355.63757 curveto +221.49479 355.10438 220.96386 354.83778 220.29395 354.83777 curveto +220.29395 353.77136 moveto +221.38769 353.77137 222.24674 354.12684 222.87109 354.83777 curveto +223.49544 355.54871 223.80761 356.53309 223.80762 357.79089 curveto +223.80761 359.04415 223.49544 360.02853 222.87109 360.74402 curveto +222.24674 361.45496 221.38769 361.81042 220.29395 361.81042 curveto +219.19563 361.81042 218.33431 361.45496 217.70996 360.74402 curveto +217.09017 360.02853 216.78027 359.04415 216.78027 357.79089 curveto +216.78027 356.53309 217.09017 355.54871 217.70996 354.83777 curveto +218.33431 354.12684 219.19563 353.77137 220.29395 353.77136 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +225.6875 350.98914 moveto +226.78125 350.98914 lineto +227.46484 352.06467 227.97526 353.1174 228.3125 354.14734 curveto +228.65429 355.17729 228.82519 356.2004 228.8252 357.21667 curveto +228.82519 358.23751 228.65429 359.26518 228.3125 360.29968 curveto +227.97526 361.33419 227.46484 362.38692 226.78125 363.45789 curveto +225.6875 363.45789 lineto +226.29362 362.41427 226.74479 361.37748 227.04102 360.34753 curveto +227.34179 359.31303 227.49218 358.26941 227.49219 357.21667 curveto +227.49218 356.16395 227.34179 355.12488 227.04102 354.09949 curveto +226.74479 353.07411 226.29362 352.03732 225.6875 350.98914 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +232.84082 350.48914 moveto +232.23014 351.53732 231.77669 352.57411 231.48047 353.59949 curveto +231.18424 354.62488 231.03613 355.66395 231.03613 356.71667 curveto +231.03613 357.76941 231.18424 358.81303 231.48047 359.84753 curveto +231.78125 360.87748 232.2347 361.91427 232.84082 362.95789 curveto +231.74707 362.95789 lineto +231.06347 361.88692 230.55078 360.83419 230.20898 359.79968 curveto +229.87174 358.76518 229.70312 357.73751 229.70312 356.71667 curveto +229.70312 355.7004 229.87174 354.67729 230.20898 353.64734 curveto +230.54622 352.6174 231.05892 351.56467 231.74707 350.48914 curveto +232.84082 350.48914 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +238.41895 356.2655 moveto +237.76269 356.26551 237.24544 356.44096 236.86719 356.79187 curveto +236.49349 357.14279 236.30664 357.62586 236.30664 358.24109 curveto +236.30664 358.85633 236.49349 359.3394 236.86719 359.69031 curveto +237.24544 360.04122 237.76269 360.21668 238.41895 360.21667 curveto +239.07519 360.21668 239.59244 360.04122 239.9707 359.69031 curveto +240.34895 359.33484 240.53808 358.85177 240.53809 358.24109 curveto +240.53808 357.62586 240.34895 357.14279 239.9707 356.79187 curveto +239.597 356.44096 239.07975 356.26551 238.41895 356.2655 curveto +237.03809 355.67761 moveto +236.44564 355.53178 235.98307 355.25607 235.65039 354.85046 curveto +235.32226 354.44487 235.1582 353.95041 235.1582 353.36707 curveto +235.1582 352.55132 235.44759 351.90646 236.02637 351.4325 curveto +236.6097 350.95855 237.40722 350.72157 238.41895 350.72156 curveto +239.43522 350.72157 240.23274 350.95855 240.81152 351.4325 curveto +241.39029 351.90646 241.67968 352.55132 241.67969 353.36707 curveto +241.67968 353.95041 241.51334 354.44487 241.18066 354.85046 curveto +240.85253 355.25607 240.39452 355.53178 239.80664 355.67761 curveto +240.472 355.83257 240.98925 356.13563 241.3584 356.58679 curveto +241.73209 357.03797 241.91894 357.5894 241.91895 358.24109 curveto +241.91894 359.23002 241.61588 359.98881 241.00977 360.51746 curveto +240.4082 361.0461 239.54459 361.31042 238.41895 361.31042 curveto +237.29329 361.31042 236.42741 361.0461 235.82129 360.51746 curveto +235.21973 359.98881 234.91894 359.23002 234.91895 358.24109 curveto +234.91894 357.5894 235.10579 357.03797 235.47949 356.58679 curveto +235.85319 356.13563 236.37272 355.83257 237.03809 355.67761 curveto +236.53223 353.49695 moveto +236.53222 354.0256 236.69629 354.43804 237.02441 354.73425 curveto +237.35709 355.03048 237.82194 355.17859 238.41895 355.17859 curveto +239.01139 355.17859 239.47395 355.03048 239.80664 354.73425 curveto +240.14387 354.43804 240.31249 354.0256 240.3125 353.49695 curveto +240.31249 352.96831 240.14387 352.55588 239.80664 352.25964 curveto +239.47395 351.96343 239.01139 351.81532 238.41895 351.81531 curveto +237.82194 351.81532 237.35709 351.96343 237.02441 352.25964 curveto +236.69629 352.55588 236.53222 352.96831 236.53223 353.49695 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +244.52344 359.37585 moveto +245.96582 359.37585 lineto +245.96582 360.55164 lineto +244.84473 362.73914 lineto +243.96289 362.73914 lineto +244.52344 360.55164 lineto +244.52344 359.37585 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +253.02051 355.60925 moveto +253.68131 355.75053 254.19628 356.04448 254.56543 356.49109 curveto +254.93912 356.93771 255.12597 357.48914 255.12598 358.14539 curveto +255.12597 359.15255 254.77961 359.93185 254.08691 360.48328 curveto +253.3942 361.03471 252.40983 361.31042 251.13379 361.31042 curveto +250.7054 361.31042 250.26334 361.26713 249.80762 361.18054 curveto +249.35644 361.09851 248.88932 360.97319 248.40625 360.80457 curveto +248.40625 359.47156 lineto +248.78906 359.69487 249.20833 359.86349 249.66406 359.97742 curveto +250.11979 360.09135 250.59603 360.14832 251.09277 360.14832 curveto +251.95865 360.14832 252.61718 359.97742 253.06836 359.63562 curveto +253.52408 359.29383 253.75195 358.79708 253.75195 358.14539 curveto +253.75195 357.54383 253.54003 357.07443 253.11621 356.73718 curveto +252.69693 356.39539 252.11132 356.22449 251.35938 356.22449 curveto +250.16992 356.22449 lineto +250.16992 355.08972 lineto +251.41406 355.08972 lineto +252.09309 355.08973 252.61262 354.95529 252.97266 354.6864 curveto +253.33268 354.41297 253.51269 354.02104 253.5127 353.51062 curveto +253.51269 352.98654 253.32584 352.5855 252.95215 352.3075 curveto +252.583 352.02495 252.05208 351.88368 251.35938 351.88367 curveto +250.98112 351.88368 250.57552 351.92469 250.14258 352.00671 curveto +249.70963 352.08875 249.2334 352.21636 248.71387 352.38953 curveto +248.71387 351.15906 lineto +249.23795 351.01323 249.72786 350.90386 250.18359 350.83093 curveto +250.64388 350.75803 251.07682 350.72157 251.48242 350.72156 curveto +252.53059 350.72157 253.36002 350.96083 253.9707 351.43933 curveto +254.58137 351.9133 254.88671 352.55588 254.88672 353.36707 curveto +254.88671 353.93218 254.72493 354.41069 254.40137 354.80261 curveto +254.07779 355.18999 253.61751 355.45887 253.02051 355.60925 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +257.89453 359.37585 moveto +259.33691 359.37585 lineto +259.33691 360.55164 lineto +258.21582 362.73914 lineto +257.33398 362.73914 lineto +257.89453 360.55164 lineto +257.89453 359.37585 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +264.99707 354.33777 moveto +264.32259 354.33778 263.78938 354.6021 263.39746 355.13074 curveto +263.00553 355.65483 262.80957 356.37488 262.80957 357.29089 curveto +262.80957 358.20691 263.00325 358.92924 263.39062 359.45789 curveto +263.78255 359.98198 264.31803 360.24402 264.99707 360.24402 curveto +265.66699 360.24402 266.19791 359.9797 266.58984 359.45105 curveto +266.98176 358.92241 267.17773 358.20235 267.17773 357.29089 curveto +267.17773 356.384 266.98176 355.66622 266.58984 355.13757 curveto +266.19791 354.60438 265.66699 354.33778 264.99707 354.33777 curveto +264.99707 353.27136 moveto +266.09081 353.27137 266.94986 353.62684 267.57422 354.33777 curveto +268.19856 355.04871 268.51073 356.03309 268.51074 357.29089 curveto +268.51073 358.54415 268.19856 359.52853 267.57422 360.24402 curveto +266.94986 360.95496 266.09081 361.31042 264.99707 361.31042 curveto +263.89876 361.31042 263.03743 360.95496 262.41309 360.24402 curveto +261.79329 359.52853 261.4834 358.54415 261.4834 357.29089 curveto +261.4834 356.03309 261.79329 355.04871 262.41309 354.33777 curveto +263.03743 353.62684 263.89876 353.27137 264.99707 353.27136 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +270.39062 350.48914 moveto +271.48438 350.48914 lineto +272.16797 351.56467 272.67838 352.6174 273.01562 353.64734 curveto +273.35742 354.67729 273.52832 355.7004 273.52832 356.71667 curveto +273.52832 357.73751 273.35742 358.76518 273.01562 359.79968 curveto +272.67838 360.83419 272.16797 361.88692 271.48438 362.95789 curveto +270.39062 362.95789 lineto +270.99674 361.91427 271.44791 360.87748 271.74414 359.84753 curveto +272.04492 358.81303 272.19531 357.76941 272.19531 356.71667 curveto +272.19531 355.66395 272.04492 354.62488 271.74414 353.59949 curveto +271.44791 352.57411 270.99674 351.53732 270.39062 350.48914 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +278.84082 350.64343 moveto +278.23014 351.69162 277.77669 352.7284 277.48047 353.75378 curveto +277.18424 354.77918 277.03613 355.81824 277.03613 356.87097 curveto +277.03613 357.92371 277.18424 358.96733 277.48047 360.00183 curveto +277.78125 361.03178 278.2347 362.06856 278.84082 363.11218 curveto +277.74707 363.11218 lineto +277.06347 362.04122 276.55078 360.98848 276.20898 359.95398 curveto +275.87174 358.91948 275.70312 357.89181 275.70312 356.87097 curveto +275.70312 355.8547 275.87174 354.83159 276.20898 353.80164 curveto +276.54622 352.7717 277.05892 351.71896 277.74707 350.64343 curveto +278.84082 350.64343 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +281.50684 361.05457 moveto +281.50684 359.79675 lineto +281.85319 359.96082 282.2041 360.08614 282.55957 360.17273 curveto +282.91504 360.25932 283.26367 360.30261 283.60547 360.30261 curveto +284.51692 360.30261 285.21191 359.99728 285.69043 359.3866 curveto +286.1735 358.77136 286.44921 357.8394 286.51758 356.5907 curveto +286.25325 356.98263 285.91829 357.28341 285.5127 357.49304 curveto +285.10709 357.70268 284.6582 357.8075 284.16602 357.8075 curveto +283.14518 357.8075 282.33626 357.49988 281.73926 356.88464 curveto +281.14681 356.26486 280.85059 355.41948 280.85059 354.34851 curveto +280.85059 353.30034 281.16048 352.45952 281.78027 351.82605 curveto +282.40006 351.1926 283.22493 350.87586 284.25488 350.87585 curveto +285.43522 350.87586 286.33528 351.32931 286.95508 352.23621 curveto +287.57942 353.13856 287.89159 354.45106 287.8916 356.17371 curveto +287.89159 357.78243 287.50878 359.06759 286.74316 360.02917 curveto +285.98209 360.98621 284.9567 361.46472 283.66699 361.46472 curveto +283.32063 361.46472 282.96972 361.43054 282.61426 361.36218 curveto +282.25879 361.29382 281.88965 361.19128 281.50684 361.05457 curveto +284.25488 356.72742 moveto +284.87467 356.72742 285.36458 356.51551 285.72461 356.09167 curveto +286.08919 355.66785 286.27148 355.0868 286.27148 354.34851 curveto +286.27148 353.61479 286.08919 353.03602 285.72461 352.61218 curveto +285.36458 352.18381 284.87467 351.96961 284.25488 351.9696 curveto +283.63509 351.96961 283.1429 352.18381 282.77832 352.61218 curveto +282.41829 353.03602 282.23828 353.61479 282.23828 354.34851 curveto +282.23828 355.0868 282.41829 355.66785 282.77832 356.09167 curveto +283.1429 356.51551 283.63509 356.72742 284.25488 356.72742 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +290.52344 359.53015 moveto +291.96582 359.53015 lineto +291.96582 360.70593 lineto +290.84473 362.89343 lineto +289.96289 362.89343 lineto +290.52344 360.70593 lineto +290.52344 359.53015 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +298.63086 352.26355 moveto +295.14453 357.71179 lineto +298.63086 357.71179 lineto +298.63086 352.26355 lineto +298.26855 351.06042 moveto +300.00488 351.06042 lineto +300.00488 357.71179 lineto +301.46094 357.71179 lineto +301.46094 358.86023 lineto +300.00488 358.86023 lineto +300.00488 361.26648 lineto +298.63086 361.26648 lineto +298.63086 358.86023 lineto +294.02344 358.86023 lineto +294.02344 357.52722 lineto +298.26855 351.06042 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +303.89453 359.53015 moveto +305.33691 359.53015 lineto +305.33691 360.70593 lineto +304.21582 362.89343 lineto +303.33398 362.89343 lineto +303.89453 360.70593 lineto +303.89453 359.53015 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +310.99707 354.49207 moveto +310.32259 354.49207 309.78938 354.75639 309.39746 355.28503 curveto +309.00553 355.80913 308.80957 356.52918 308.80957 357.44519 curveto +308.80957 358.36121 309.00325 359.08354 309.39062 359.61218 curveto +309.78255 360.13627 310.31803 360.39832 310.99707 360.39832 curveto +311.66699 360.39832 312.19791 360.13399 312.58984 359.60535 curveto +312.98176 359.0767 313.17773 358.35665 313.17773 357.44519 curveto +313.17773 356.53829 312.98176 355.82052 312.58984 355.29187 curveto +312.19791 354.75867 311.66699 354.49207 310.99707 354.49207 curveto +310.99707 353.42566 moveto +312.09081 353.42567 312.94986 353.78114 313.57422 354.49207 curveto +314.19856 355.20301 314.51073 356.18738 314.51074 357.44519 curveto +314.51073 358.69845 314.19856 359.68282 313.57422 360.39832 curveto +312.94986 361.10925 312.09081 361.46472 310.99707 361.46472 curveto +309.89876 361.46472 309.03743 361.10925 308.41309 360.39832 curveto +307.79329 359.68282 307.4834 358.69845 307.4834 357.44519 curveto +307.4834 356.18738 307.79329 355.20301 308.41309 354.49207 curveto +309.03743 353.78114 309.89876 353.42567 310.99707 353.42566 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +316.39062 350.64343 moveto +317.48438 350.64343 lineto +318.16797 351.71896 318.67838 352.7717 319.01562 353.80164 curveto +319.35742 354.83159 319.52832 355.8547 319.52832 356.87097 curveto +319.52832 357.89181 319.35742 358.91948 319.01562 359.95398 curveto +318.67838 360.98848 318.16797 362.04122 317.48438 363.11218 curveto +316.39062 363.11218 lineto +316.99674 362.06856 317.44791 361.03178 317.74414 360.00183 curveto +318.04492 358.96733 318.19531 357.92371 318.19531 356.87097 curveto +318.19531 355.81824 318.04492 354.77918 317.74414 353.75378 curveto +317.44791 352.7284 316.99674 351.69162 316.39062 350.64343 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +197.1377 371.14343 moveto +196.52701 372.19162 196.07356 373.2284 195.77734 374.25378 curveto +195.48112 375.27918 195.33301 376.31824 195.33301 377.37097 curveto +195.33301 378.42371 195.48112 379.46733 195.77734 380.50183 curveto +196.07812 381.53178 196.53157 382.56856 197.1377 383.61218 curveto +196.04395 383.61218 lineto +195.36035 382.54122 194.84765 381.48848 194.50586 380.45398 curveto +194.16862 379.41948 194 378.39181 194 377.37097 curveto +194 376.3547 194.16862 375.33159 194.50586 374.30164 curveto +194.8431 373.2717 195.35579 372.21896 196.04395 371.14343 curveto +197.1377 371.14343 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +200.00195 380.60437 moveto +202.25781 380.60437 lineto +202.25781 372.81824 lineto +199.80371 373.31042 lineto +199.80371 372.05261 lineto +202.24414 371.56042 lineto +203.625 371.56042 lineto +203.625 380.60437 lineto +205.88086 380.60437 lineto +205.88086 381.76648 lineto +200.00195 381.76648 lineto +200.00195 380.60437 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +211.62988 372.4696 moveto +210.91894 372.46961 210.38346 372.82052 210.02344 373.52234 curveto +209.66797 374.21961 209.49023 375.27007 209.49023 376.67371 curveto +209.49023 378.0728 209.66797 379.12325 210.02344 379.82507 curveto +210.38346 380.52234 210.91894 380.87097 211.62988 380.87097 curveto +212.34537 380.87097 212.88085 380.52234 213.23633 379.82507 curveto +213.59635 379.12325 213.77636 378.0728 213.77637 376.67371 curveto +213.77636 375.27007 213.59635 374.21961 213.23633 373.52234 curveto +212.88085 372.82052 212.34537 372.46961 211.62988 372.4696 curveto +211.62988 371.37585 moveto +212.77376 371.37586 213.64648 371.82931 214.24805 372.73621 curveto +214.85416 373.63856 215.15722 374.95106 215.15723 376.67371 curveto +215.15722 378.39181 214.85416 379.70431 214.24805 380.61121 curveto +213.64648 381.51355 212.77376 381.96472 211.62988 381.96472 curveto +210.486 381.96472 209.611 381.51355 209.00488 380.61121 curveto +208.40332 379.70431 208.10254 378.39181 208.10254 376.67371 curveto +208.10254 374.95106 208.40332 373.63856 209.00488 372.73621 curveto +209.611 371.82931 210.486 371.37586 211.62988 371.37585 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +217.73438 380.03015 moveto +219.17676 380.03015 lineto +219.17676 381.20593 lineto +218.05566 383.39343 lineto +217.17383 383.39343 lineto +217.73438 381.20593 lineto +217.73438 380.03015 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +222.06152 371.56042 moveto +227.48242 371.56042 lineto +227.48242 372.72253 lineto +223.32617 372.72253 lineto +223.32617 375.22449 lineto +223.52669 375.15613 223.72721 375.106 223.92773 375.0741 curveto +224.12825 375.03765 224.32877 375.01942 224.5293 375.01941 curveto +225.66861 375.01942 226.57096 375.33159 227.23633 375.95593 curveto +227.90169 376.58029 228.23437 377.42566 228.23438 378.49207 curveto +228.23437 379.59037 227.89257 380.44487 227.20898 381.05554 curveto +226.52538 381.66166 225.56152 381.96472 224.31738 381.96472 curveto +223.88899 381.96472 223.45149 381.92826 223.00488 381.85535 curveto +222.56282 381.78243 222.10482 381.67306 221.63086 381.52722 curveto +221.63086 380.13953 lineto +222.04101 380.36284 222.46484 380.52918 222.90234 380.63855 curveto +223.33984 380.74793 223.80241 380.80261 224.29004 380.80261 curveto +225.07845 380.80261 225.70279 380.59526 226.16309 380.18054 curveto +226.62337 379.76583 226.85351 379.20301 226.85352 378.49207 curveto +226.85351 377.78113 226.62337 377.21831 226.16309 376.80359 curveto +225.70279 376.38888 225.07845 376.18152 224.29004 376.18152 curveto +223.9209 376.18152 223.55175 376.22254 223.18262 376.30457 curveto +222.81803 376.3866 222.44433 376.51421 222.06152 376.68738 curveto +222.06152 371.56042 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +231.10547 380.03015 moveto +232.54785 380.03015 lineto +232.54785 381.20593 lineto +231.42676 383.39343 lineto +230.54492 383.39343 lineto +231.10547 381.20593 lineto +231.10547 380.03015 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +238.20801 374.99207 moveto +237.53353 374.99207 237.00032 375.25639 236.6084 375.78503 curveto +236.21647 376.30913 236.02051 377.02918 236.02051 377.94519 curveto +236.02051 378.86121 236.21419 379.58354 236.60156 380.11218 curveto +236.99349 380.63627 237.52897 380.89832 238.20801 380.89832 curveto +238.87792 380.89832 239.40885 380.63399 239.80078 380.10535 curveto +240.1927 379.5767 240.38867 378.85665 240.38867 377.94519 curveto +240.38867 377.03829 240.1927 376.32052 239.80078 375.79187 curveto +239.40885 375.25867 238.87792 374.99207 238.20801 374.99207 curveto +238.20801 373.92566 moveto +239.30175 373.92567 240.1608 374.28114 240.78516 374.99207 curveto +241.4095 375.70301 241.72167 376.68738 241.72168 377.94519 curveto +241.72167 379.19845 241.4095 380.18282 240.78516 380.89832 curveto +240.1608 381.60925 239.30175 381.96472 238.20801 381.96472 curveto +237.1097 381.96472 236.24837 381.60925 235.62402 380.89832 curveto +235.00423 380.18282 234.69434 379.19845 234.69434 377.94519 curveto +234.69434 376.68738 235.00423 375.70301 235.62402 374.99207 curveto +236.24837 374.28114 237.1097 373.92567 238.20801 373.92566 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +243.60156 371.14343 moveto +244.69531 371.14343 lineto +245.3789 372.21896 245.88932 373.2717 246.22656 374.30164 curveto +246.56836 375.33159 246.73925 376.3547 246.73926 377.37097 curveto +246.73925 378.39181 246.56836 379.41948 246.22656 380.45398 curveto +245.88932 381.48848 245.3789 382.54122 244.69531 383.61218 curveto +243.60156 383.61218 lineto +244.20768 382.56856 244.65885 381.53178 244.95508 380.50183 curveto +245.25586 379.46733 245.40625 378.42371 245.40625 377.37097 curveto +245.40625 376.31824 245.25586 375.27918 244.95508 374.25378 curveto +244.65885 373.2284 244.20768 372.19162 243.60156 371.14343 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +252.1377 371.98914 moveto +251.52701 373.03732 251.07356 374.07411 250.77734 375.09949 curveto +250.48112 376.12488 250.33301 377.16395 250.33301 378.21667 curveto +250.33301 379.26941 250.48112 380.31303 250.77734 381.34753 curveto +251.07812 382.37748 251.53157 383.41427 252.1377 384.45789 curveto +251.04395 384.45789 lineto +250.36035 383.38692 249.84765 382.33419 249.50586 381.29968 curveto +249.16862 380.26518 249 379.23751 249 378.21667 curveto +249 377.2004 249.16862 376.17729 249.50586 375.14734 curveto +249.8431 374.1174 250.35579 373.06467 251.04395 371.98914 curveto +252.1377 371.98914 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +255.00195 381.45007 moveto +257.25781 381.45007 lineto +257.25781 373.66394 lineto +254.80371 374.15613 lineto +254.80371 372.89832 lineto +257.24414 372.40613 lineto +258.625 372.40613 lineto +258.625 381.45007 lineto +260.88086 381.45007 lineto +260.88086 382.61218 lineto +255.00195 382.61218 lineto +255.00195 381.45007 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +263.91602 381.45007 moveto +266.17188 381.45007 lineto +266.17188 373.66394 lineto +263.71777 374.15613 lineto +263.71777 372.89832 lineto +266.1582 372.40613 lineto +267.53906 372.40613 lineto +267.53906 381.45007 lineto +269.79492 381.45007 lineto +269.79492 382.61218 lineto +263.91602 382.61218 lineto +263.91602 381.45007 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +272.73438 380.87585 moveto +274.17676 380.87585 lineto +274.17676 382.05164 lineto +273.05566 384.23914 lineto +272.17383 384.23914 lineto +272.73438 382.05164 lineto +272.73438 380.87585 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +280.17188 376.95886 moveto +279.55208 376.95887 279.05989 377.17078 278.69531 377.5946 curveto +278.33528 378.01844 278.15527 378.59949 278.15527 379.33777 curveto +278.15527 380.0715 278.33528 380.65255 278.69531 381.08093 curveto +279.05989 381.50476 279.55208 381.71668 280.17188 381.71667 curveto +280.79166 381.71668 281.28157 381.50476 281.6416 381.08093 curveto +282.00618 380.65255 282.18847 380.0715 282.18848 379.33777 curveto +282.18847 378.59949 282.00618 378.01844 281.6416 377.5946 curveto +281.28157 377.17078 280.79166 376.95887 280.17188 376.95886 curveto +282.91309 372.63171 moveto +282.91309 373.88953 lineto +282.56672 373.72547 282.21581 373.60015 281.86035 373.51355 curveto +281.50943 373.42697 281.1608 373.38368 280.81445 373.38367 curveto +279.90299 373.38368 279.20573 373.69129 278.72266 374.30652 curveto +278.24414 374.92176 277.9707 375.85145 277.90234 377.09558 curveto +278.17122 376.6991 278.50846 376.39604 278.91406 376.1864 curveto +279.31966 375.97222 279.76627 375.86512 280.25391 375.86511 curveto +281.27929 375.86512 282.08821 376.17729 282.68066 376.80164 curveto +283.27766 377.42143 283.57616 378.26681 283.57617 379.33777 curveto +283.57616 380.38595 283.26627 381.22677 282.64648 381.86023 curveto +282.02669 382.49369 281.20182 382.81042 280.17188 382.81042 curveto +278.99153 382.81042 278.08919 382.35925 277.46484 381.45691 curveto +276.84049 380.55001 276.52832 379.23751 276.52832 377.51941 curveto +276.52832 375.90613 276.91113 374.62098 277.67676 373.66394 curveto +278.44238 372.70236 279.47005 372.22157 280.75977 372.22156 curveto +281.10611 372.22157 281.45475 372.25575 281.80566 372.3241 curveto +282.16113 372.39247 282.53027 372.49501 282.91309 372.63171 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +286.10547 380.87585 moveto +287.54785 380.87585 lineto +287.54785 382.05164 lineto +286.42676 384.23914 lineto +285.54492 384.23914 lineto +286.10547 382.05164 lineto +286.10547 380.87585 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +293.20801 375.83777 moveto +292.53353 375.83778 292.00032 376.1021 291.6084 376.63074 curveto +291.21647 377.15483 291.02051 377.87488 291.02051 378.79089 curveto +291.02051 379.70691 291.21419 380.42924 291.60156 380.95789 curveto +291.99349 381.48198 292.52897 381.74402 293.20801 381.74402 curveto +293.87792 381.74402 294.40885 381.4797 294.80078 380.95105 curveto +295.1927 380.42241 295.38867 379.70235 295.38867 378.79089 curveto +295.38867 377.884 295.1927 377.16622 294.80078 376.63757 curveto +294.40885 376.10438 293.87792 375.83778 293.20801 375.83777 curveto +293.20801 374.77136 moveto +294.30175 374.77137 295.1608 375.12684 295.78516 375.83777 curveto +296.4095 376.54871 296.72167 377.53309 296.72168 378.79089 curveto +296.72167 380.04415 296.4095 381.02853 295.78516 381.74402 curveto +295.1608 382.45496 294.30175 382.81042 293.20801 382.81042 curveto +292.1097 382.81042 291.24837 382.45496 290.62402 381.74402 curveto +290.00423 381.02853 289.69434 380.04415 289.69434 378.79089 curveto +289.69434 377.53309 290.00423 376.54871 290.62402 375.83777 curveto +291.24837 375.12684 292.1097 374.77137 293.20801 374.77136 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +298.60156 371.98914 moveto +299.69531 371.98914 lineto +300.3789 373.06467 300.88932 374.1174 301.22656 375.14734 curveto +301.56836 376.17729 301.73925 377.2004 301.73926 378.21667 curveto +301.73925 379.23751 301.56836 380.26518 301.22656 381.29968 curveto +300.88932 382.33419 300.3789 383.38692 299.69531 384.45789 curveto +298.60156 384.45789 lineto +299.20768 383.41427 299.65885 382.37748 299.95508 381.34753 curveto +300.25586 380.31303 300.40625 379.26941 300.40625 378.21667 curveto +300.40625 377.16395 300.25586 376.12488 299.95508 375.09949 curveto +299.65885 374.07411 299.20768 373.03732 298.60156 371.98914 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +238.37402 312.40613 moveto +239.75488 312.40613 lineto +239.75488 322.61218 lineto +238.37402 322.61218 lineto +238.37402 312.40613 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +247.3291 315.18152 moveto +247.3291 316.37097 lineto +246.97363 316.18869 246.60449 316.05197 246.22168 315.96082 curveto +245.83886 315.86968 245.44238 315.8241 245.03223 315.8241 curveto +244.40787 315.8241 243.93847 315.91981 243.62402 316.11121 curveto +243.31413 316.30262 243.15918 316.58973 243.15918 316.97253 curveto +243.15918 317.26421 243.27083 317.49435 243.49414 317.66296 curveto +243.71745 317.82703 244.16634 317.98426 244.84082 318.13464 curveto +245.27148 318.23035 lineto +246.16471 318.42176 246.79817 318.69292 247.17188 319.04382 curveto +247.55012 319.39018 247.73925 319.87553 247.73926 320.49988 curveto +247.73925 321.21082 247.4567 321.77364 246.8916 322.18835 curveto +246.33105 322.60307 245.55859 322.81042 244.57422 322.81042 curveto +244.16406 322.81042 243.73567 322.76941 243.28906 322.68738 curveto +242.847 322.6099 242.37988 322.49141 241.8877 322.33191 curveto +241.8877 321.03308 lineto +242.35254 321.27462 242.81055 321.45691 243.26172 321.57996 curveto +243.71289 321.69845 244.1595 321.75769 244.60156 321.75769 curveto +245.19401 321.75769 245.64974 321.65743 245.96875 321.45691 curveto +246.28776 321.25183 246.44726 320.96472 246.44727 320.59558 curveto +246.44726 320.25379 246.33105 319.99174 246.09863 319.80945 curveto +245.87076 319.62716 245.36718 319.4517 244.58789 319.28308 curveto +244.15039 319.18054 lineto +243.37109 319.01648 242.80827 318.76583 242.46191 318.42859 curveto +242.11556 318.0868 241.94238 317.61967 241.94238 317.02722 curveto +241.94238 316.30718 242.19759 315.75119 242.70801 315.35925 curveto +243.21842 314.96733 243.94303 314.77137 244.88184 314.77136 curveto +245.34668 314.77137 245.78418 314.80555 246.19434 314.8739 curveto +246.60449 314.94227 246.98274 315.04481 247.3291 315.18152 curveto +fill +grestore +gsave [1 0 0 1 3.250285 1] concat +gsave +0 0 0 setrgbcolor +newpath +180.84082 436.23914 moveto +180.23014 437.28732 179.77669 438.32411 179.48047 439.34949 curveto +179.18424 440.37488 179.03613 441.41395 179.03613 442.46667 curveto +179.03613 443.51941 179.18424 444.56303 179.48047 445.59753 curveto +179.78125 446.62748 180.2347 447.66427 180.84082 448.70789 curveto +179.74707 448.70789 lineto +179.06347 447.63692 178.55078 446.58419 178.20898 445.54968 curveto +177.87174 444.51518 177.70312 443.48751 177.70312 442.46667 curveto +177.70312 441.4504 177.87174 440.42729 178.20898 439.39734 curveto +178.54622 438.3674 179.05892 437.31467 179.74707 436.23914 curveto +180.84082 436.23914 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +184.65527 445.70007 moveto +189.47461 445.70007 lineto +189.47461 446.86218 lineto +182.99414 446.86218 lineto +182.99414 445.70007 lineto +183.51823 445.15776 184.23144 444.43087 185.13379 443.51941 curveto +186.04069 442.6034 186.61035 442.01323 186.84277 441.7489 curveto +187.28483 441.25216 187.59244 440.83289 187.76562 440.49109 curveto +187.94335 440.14474 188.03222 439.80522 188.03223 439.47253 curveto +188.03222 438.93022 187.84081 438.48817 187.45801 438.14636 curveto +187.07975 437.80457 186.58528 437.63368 185.97461 437.63367 curveto +185.54166 437.63368 185.08366 437.70887 184.60059 437.85925 curveto +184.12207 438.00965 183.60937 438.23752 183.0625 438.54285 curveto +183.0625 437.14832 lineto +183.61849 436.92502 184.13802 436.7564 184.62109 436.64246 curveto +185.10416 436.52853 185.54622 436.47157 185.94727 436.47156 curveto +187.00455 436.47157 187.84765 436.73589 188.47656 437.26453 curveto +189.10546 437.79318 189.41991 438.49956 189.41992 439.38367 curveto +189.41991 439.80294 189.34016 440.20171 189.18066 440.57996 curveto +189.02571 440.95366 188.74088 441.39572 188.32617 441.90613 curveto +188.21223 442.03829 187.84993 442.42111 187.23926 443.05457 curveto +186.62858 443.68347 185.76725 444.56531 184.65527 445.70007 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +192.52344 445.12585 moveto +193.96582 445.12585 lineto +193.96582 446.30164 lineto +192.84473 448.48914 lineto +191.96289 448.48914 lineto +192.52344 446.30164 lineto +192.52344 445.12585 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +199.79004 437.56531 moveto +199.0791 437.56532 198.54362 437.91623 198.18359 438.61804 curveto +197.82812 439.31532 197.65039 440.36577 197.65039 441.76941 curveto +197.65039 443.1685 197.82812 444.21896 198.18359 444.92078 curveto +198.54362 445.61804 199.0791 445.96668 199.79004 445.96667 curveto +200.50553 445.96668 201.04101 445.61804 201.39648 444.92078 curveto +201.7565 444.21896 201.93652 443.1685 201.93652 441.76941 curveto +201.93652 440.36577 201.7565 439.31532 201.39648 438.61804 curveto +201.04101 437.91623 200.50553 437.56532 199.79004 437.56531 curveto +199.79004 436.47156 moveto +200.93391 436.47157 201.80663 436.92502 202.4082 437.83191 curveto +203.01432 438.73426 203.31737 440.04676 203.31738 441.76941 curveto +203.31737 443.48751 203.01432 444.80001 202.4082 445.70691 curveto +201.80663 446.60925 200.93391 447.06042 199.79004 447.06042 curveto +198.64616 447.06042 197.77116 446.60925 197.16504 445.70691 curveto +196.56348 444.80001 196.26269 443.48751 196.2627 441.76941 curveto +196.26269 440.04676 196.56348 438.73426 197.16504 437.83191 curveto +197.77116 436.92502 198.64616 436.47157 199.79004 436.47156 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +205.89453 445.12585 moveto +207.33691 445.12585 lineto +207.33691 446.30164 lineto +206.21582 448.48914 lineto +205.33398 448.48914 lineto +205.89453 446.30164 lineto +205.89453 445.12585 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +215.06836 442.94519 moveto +215.06835 442.03374 214.87923 441.32736 214.50098 440.82605 curveto +214.12727 440.32475 213.60091 440.0741 212.92188 440.0741 curveto +212.24739 440.0741 211.72103 440.32475 211.34277 440.82605 curveto +210.96907 441.32736 210.78222 442.03374 210.78223 442.94519 curveto +210.78222 443.85209 210.96907 444.5562 211.34277 445.0575 curveto +211.72103 445.5588 212.24739 445.80945 212.92188 445.80945 curveto +213.60091 445.80945 214.12727 445.5588 214.50098 445.0575 curveto +214.87923 444.5562 215.06835 443.85209 215.06836 442.94519 curveto +216.32617 445.91199 moveto +216.32616 447.21537 216.03678 448.1838 215.45801 448.81726 curveto +214.87923 449.45528 213.99283 449.77429 212.79883 449.77429 curveto +212.35677 449.77429 211.93978 449.74011 211.54785 449.67175 curveto +211.15592 449.60795 210.77539 449.50769 210.40625 449.37097 curveto +210.40625 448.14734 lineto +210.77539 448.34786 211.13997 448.49597 211.5 448.59167 curveto +211.86002 448.68738 212.22688 448.73523 212.60059 448.73523 curveto +213.42545 448.73523 214.04296 448.51876 214.45312 448.08582 curveto +214.86328 447.65743 215.06835 447.00802 215.06836 446.13757 curveto +215.06836 445.5155 lineto +214.80859 445.96668 214.47591 446.30391 214.07031 446.52722 curveto +213.66471 446.75053 213.17936 446.86218 212.61426 446.86218 curveto +211.67545 446.86218 210.91894 446.50444 210.34473 445.78894 curveto +209.77051 445.07345 209.4834 444.12553 209.4834 442.94519 curveto +209.4834 441.7603 209.77051 440.81011 210.34473 440.0946 curveto +210.91894 439.37912 211.67545 439.02137 212.61426 439.02136 curveto +213.17936 439.02137 213.66471 439.13302 214.07031 439.35632 curveto +214.47591 439.57964 214.80859 439.91688 215.06836 440.36804 curveto +215.06836 439.20593 lineto +216.32617 439.20593 lineto +216.32617 445.91199 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +218.71875 436.23914 moveto +219.8125 436.23914 lineto +220.49609 437.31467 221.00651 438.3674 221.34375 439.39734 curveto +221.68554 440.42729 221.85644 441.4504 221.85645 442.46667 curveto +221.85644 443.48751 221.68554 444.51518 221.34375 445.54968 curveto +221.00651 446.58419 220.49609 447.63692 219.8125 448.70789 curveto +218.71875 448.70789 lineto +219.32487 447.66427 219.77604 446.62748 220.07227 445.59753 curveto +220.37304 444.56303 220.52343 443.51941 220.52344 442.46667 curveto +220.52343 441.41395 220.37304 440.37488 220.07227 439.34949 curveto +219.77604 438.32411 219.32487 437.28732 218.71875 436.23914 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +228.53711 436.77234 moveto +227.92643 437.82053 227.47298 438.85731 227.17676 439.88269 curveto +226.88053 440.90809 226.73242 441.94715 226.73242 442.99988 curveto +226.73242 444.05262 226.88053 445.09623 227.17676 446.13074 curveto +227.47754 447.16069 227.93099 448.19747 228.53711 449.24109 curveto +227.44336 449.24109 lineto +226.75976 448.17012 226.24707 447.11739 225.90527 446.08289 curveto +225.56803 445.04838 225.39941 444.02071 225.39941 442.99988 curveto +225.39941 441.98361 225.56803 440.9605 225.90527 439.93054 curveto +226.24251 438.9006 226.75521 437.84787 227.44336 436.77234 curveto +228.53711 436.77234 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +235.3457 441.89246 moveto +236.0065 442.03374 236.52148 442.32768 236.89062 442.77429 curveto +237.26432 443.22091 237.45116 443.77234 237.45117 444.42859 curveto +237.45116 445.43575 237.10481 446.21505 236.41211 446.76648 curveto +235.71939 447.31791 234.73502 447.59363 233.45898 447.59363 curveto +233.0306 447.59363 232.58854 447.55033 232.13281 447.46375 curveto +231.68164 447.38171 231.21452 447.25639 230.73145 447.08777 curveto +230.73145 445.75476 lineto +231.11426 445.97807 231.53353 446.14669 231.98926 446.26062 curveto +232.44498 446.37455 232.92122 446.43152 233.41797 446.43152 curveto +234.28385 446.43152 234.94238 446.26062 235.39355 445.91882 curveto +235.84928 445.57703 236.07714 445.08028 236.07715 444.42859 curveto +236.07714 443.82703 235.86523 443.35763 235.44141 443.02039 curveto +235.02213 442.67859 234.43652 442.5077 233.68457 442.50769 curveto +232.49512 442.50769 lineto +232.49512 441.37292 lineto +233.73926 441.37292 lineto +234.41829 441.37293 234.93782 441.23849 235.29785 440.9696 curveto +235.65787 440.69617 235.83788 440.30425 235.83789 439.79382 curveto +235.83788 439.26974 235.65104 438.8687 235.27734 438.5907 curveto +234.9082 438.30816 234.37727 438.16688 233.68457 438.16687 curveto +233.30631 438.16688 232.90071 438.20789 232.46777 438.28992 curveto +232.03483 438.37196 231.55859 438.49956 231.03906 438.67273 curveto +231.03906 437.44226 lineto +231.56315 437.29644 232.05306 437.18706 232.50879 437.11414 curveto +232.96907 437.04123 233.40201 437.00477 233.80762 437.00476 curveto +234.85579 437.00477 235.68522 437.24403 236.2959 437.72253 curveto +236.90657 438.1965 237.21191 438.83908 237.21191 439.65027 curveto +237.21191 440.21538 237.05012 440.6939 236.72656 441.08582 curveto +236.40299 441.47319 235.9427 441.74207 235.3457 441.89246 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +240.21973 445.65906 moveto +241.66211 445.65906 lineto +241.66211 446.83484 lineto +240.54102 449.02234 lineto +239.65918 449.02234 lineto +240.21973 446.83484 lineto +240.21973 445.65906 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +244.77246 446.23328 moveto +247.02832 446.23328 lineto +247.02832 438.44714 lineto +244.57422 438.93933 lineto +244.57422 437.68152 lineto +247.01465 437.18933 lineto +248.39551 437.18933 lineto +248.39551 446.23328 lineto +250.65137 446.23328 lineto +250.65137 447.39539 lineto +244.77246 447.39539 lineto +244.77246 446.23328 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +253.59082 445.65906 moveto +255.0332 445.65906 lineto +255.0332 446.83484 lineto +253.91211 449.02234 lineto +253.03027 449.02234 lineto +253.59082 446.83484 lineto +253.59082 445.65906 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +260.69336 440.62097 moveto +260.01888 440.62098 259.48567 440.8853 259.09375 441.41394 curveto +258.70182 441.93803 258.50586 442.65809 258.50586 443.5741 curveto +258.50586 444.49012 258.69954 445.21245 259.08691 445.74109 curveto +259.47884 446.26518 260.01432 446.52722 260.69336 446.52722 curveto +261.36328 446.52722 261.8942 446.2629 262.28613 445.73425 curveto +262.67805 445.20561 262.87402 444.48556 262.87402 443.5741 curveto +262.87402 442.6672 262.67805 441.94943 262.28613 441.42078 curveto +261.8942 440.88758 261.36328 440.62098 260.69336 440.62097 curveto +260.69336 439.55457 moveto +261.7871 439.55457 262.64615 439.91004 263.27051 440.62097 curveto +263.89485 441.33192 264.20702 442.31629 264.20703 443.5741 curveto +264.20702 444.82735 263.89485 445.81173 263.27051 446.52722 curveto +262.64615 447.23816 261.7871 447.59363 260.69336 447.59363 curveto +259.59505 447.59363 258.73372 447.23816 258.10938 446.52722 curveto +257.48958 445.81173 257.17969 444.82735 257.17969 443.5741 curveto +257.17969 442.31629 257.48958 441.33192 258.10938 440.62097 curveto +258.73372 439.91004 259.59505 439.55457 260.69336 439.55457 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +266.08691 436.77234 moveto +267.18066 436.77234 lineto +267.86425 437.84787 268.37467 438.9006 268.71191 439.93054 curveto +269.05371 440.9605 269.22461 441.98361 269.22461 442.99988 curveto +269.22461 444.02071 269.05371 445.04838 268.71191 446.08289 curveto +268.37467 447.11739 267.86425 448.17012 267.18066 449.24109 curveto +266.08691 449.24109 lineto +266.69303 448.19747 267.1442 447.16069 267.44043 446.13074 curveto +267.74121 445.09623 267.8916 444.05262 267.8916 442.99988 curveto +267.8916 441.94715 267.74121 440.90809 267.44043 439.88269 curveto +267.1442 438.85731 266.69303 437.82053 266.08691 436.77234 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +275.5498 436.77234 moveto +274.93912 437.82053 274.48567 438.85731 274.18945 439.88269 curveto +273.89323 440.90809 273.74511 441.94715 273.74512 442.99988 curveto +273.74511 444.05262 273.89323 445.09623 274.18945 446.13074 curveto +274.49023 447.16069 274.94368 448.19747 275.5498 449.24109 curveto +274.45605 449.24109 lineto +273.77246 448.17012 273.25976 447.11739 272.91797 446.08289 curveto +272.58073 445.04838 272.41211 444.02071 272.41211 442.99988 curveto +272.41211 441.98361 272.58073 440.9605 272.91797 439.93054 curveto +273.25521 438.9006 273.7679 437.84787 274.45605 436.77234 curveto +275.5498 436.77234 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +281.96875 438.39246 moveto +278.48242 443.8407 lineto +281.96875 443.8407 lineto +281.96875 438.39246 lineto +281.60645 437.18933 moveto +283.34277 437.18933 lineto +283.34277 443.8407 lineto +284.79883 443.8407 lineto +284.79883 444.98914 lineto +283.34277 444.98914 lineto +283.34277 447.39539 lineto +281.96875 447.39539 lineto +281.96875 444.98914 lineto +277.36133 444.98914 lineto +277.36133 443.65613 lineto +281.60645 437.18933 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +287.23242 445.65906 moveto +288.6748 445.65906 lineto +288.6748 446.83484 lineto +287.55371 449.02234 lineto +286.67188 449.02234 lineto +287.23242 446.83484 lineto +287.23242 445.65906 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +292.73535 446.23328 moveto +297.55469 446.23328 lineto +297.55469 447.39539 lineto +291.07422 447.39539 lineto +291.07422 446.23328 lineto +291.59831 445.69096 292.31152 444.96407 293.21387 444.05261 curveto +294.12076 443.1366 294.69043 442.54643 294.92285 442.2821 curveto +295.3649 441.78537 295.67252 441.36609 295.8457 441.02429 curveto +296.02343 440.67794 296.1123 440.33843 296.1123 440.00574 curveto +296.1123 439.46343 295.92089 439.02137 295.53809 438.67957 curveto +295.15983 438.33778 294.66536 438.16688 294.05469 438.16687 curveto +293.62174 438.16688 293.16373 438.24207 292.68066 438.39246 curveto +292.20215 438.54286 291.68945 438.77072 291.14258 439.07605 curveto +291.14258 437.68152 lineto +291.69857 437.45822 292.2181 437.2896 292.70117 437.17566 curveto +293.18424 437.06174 293.6263 437.00477 294.02734 437.00476 curveto +295.08463 437.00477 295.92773 437.26909 296.55664 437.79773 curveto +297.18554 438.32638 297.49999 439.03276 297.5 439.91687 curveto +297.49999 440.33615 297.42024 440.73491 297.26074 441.11316 curveto +297.10579 441.48686 296.82096 441.92892 296.40625 442.43933 curveto +296.29231 442.5715 295.93001 442.95431 295.31934 443.58777 curveto +294.70865 444.21668 293.84733 445.09851 292.73535 446.23328 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +300.60352 445.65906 moveto +302.0459 445.65906 lineto +302.0459 446.83484 lineto +300.9248 449.02234 lineto +300.04297 449.02234 lineto +300.60352 446.83484 lineto +300.60352 445.65906 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +307.70605 440.62097 moveto +307.03157 440.62098 306.49837 440.8853 306.10645 441.41394 curveto +305.71452 441.93803 305.51855 442.65809 305.51855 443.5741 curveto +305.51855 444.49012 305.71224 445.21245 306.09961 445.74109 curveto +306.49153 446.26518 307.02701 446.52722 307.70605 446.52722 curveto +308.37597 446.52722 308.9069 446.2629 309.29883 445.73425 curveto +309.69075 445.20561 309.88671 444.48556 309.88672 443.5741 curveto +309.88671 442.6672 309.69075 441.94943 309.29883 441.42078 curveto +308.9069 440.88758 308.37597 440.62098 307.70605 440.62097 curveto +307.70605 439.55457 moveto +308.7998 439.55457 309.65885 439.91004 310.2832 440.62097 curveto +310.90754 441.33192 311.21972 442.31629 311.21973 443.5741 curveto +311.21972 444.82735 310.90754 445.81173 310.2832 446.52722 curveto +309.65885 447.23816 308.7998 447.59363 307.70605 447.59363 curveto +306.60774 447.59363 305.74642 447.23816 305.12207 446.52722 curveto +304.50228 445.81173 304.19238 444.82735 304.19238 443.5741 curveto +304.19238 442.31629 304.50228 441.33192 305.12207 440.62097 curveto +305.74642 439.91004 306.60774 439.55457 307.70605 439.55457 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +313.09961 436.77234 moveto +314.19336 436.77234 lineto +314.87695 437.84787 315.38737 438.9006 315.72461 439.93054 curveto +316.0664 440.9605 316.2373 441.98361 316.2373 442.99988 curveto +316.2373 444.02071 316.0664 445.04838 315.72461 446.08289 curveto +315.38737 447.11739 314.87695 448.17012 314.19336 449.24109 curveto +313.09961 449.24109 lineto +313.70573 448.19747 314.1569 447.16069 314.45312 446.13074 curveto +314.7539 445.09623 314.90429 444.05262 314.9043 442.99988 curveto +314.90429 441.94715 314.7539 440.90809 314.45312 439.88269 curveto +314.1569 438.85731 313.70573 437.82053 313.09961 436.77234 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +181.16895 456.3075 moveto +180.55826 457.35568 180.10481 458.39246 179.80859 459.41785 curveto +179.51237 460.44324 179.36426 461.48231 179.36426 462.53503 curveto +179.36426 463.58777 179.51237 464.63139 179.80859 465.66589 curveto +180.10937 466.69584 180.56282 467.73262 181.16895 468.77625 curveto +180.0752 468.77625 lineto +179.3916 467.70528 178.8789 466.65255 178.53711 465.61804 curveto +178.19987 464.58354 178.03125 463.55587 178.03125 462.53503 curveto +178.03125 461.51876 178.19987 460.49565 178.53711 459.4657 curveto +178.87435 458.43576 179.38704 457.38303 180.0752 456.3075 curveto +181.16895 456.3075 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +183.80762 456.72449 moveto +189.22852 456.72449 lineto +189.22852 457.8866 lineto +185.07227 457.8866 lineto +185.07227 460.38855 lineto +185.27278 460.3202 185.4733 460.27007 185.67383 460.23816 curveto +185.87435 460.20171 186.07487 460.18348 186.27539 460.18347 curveto +187.41471 460.18348 188.31705 460.49565 188.98242 461.12 curveto +189.64778 461.74435 189.98046 462.58973 189.98047 463.65613 curveto +189.98046 464.75444 189.63866 465.60893 188.95508 466.2196 curveto +188.27148 466.82572 187.30761 467.12878 186.06348 467.12878 curveto +185.63509 467.12878 185.19759 467.09233 184.75098 467.01941 curveto +184.30892 466.94649 183.85091 466.83712 183.37695 466.69128 curveto +183.37695 465.30359 lineto +183.78711 465.5269 184.21094 465.69324 184.64844 465.80261 curveto +185.08593 465.91199 185.5485 465.96668 186.03613 465.96667 curveto +186.82454 465.96668 187.44889 465.75932 187.90918 465.3446 curveto +188.36946 464.92989 188.5996 464.36707 188.59961 463.65613 curveto +188.5996 462.94519 188.36946 462.38237 187.90918 461.96765 curveto +187.44889 461.55294 186.82454 461.34559 186.03613 461.34558 curveto +185.66699 461.34559 185.29785 461.3866 184.92871 461.46863 curveto +184.56413 461.55066 184.19043 461.67827 183.80762 461.85144 curveto +183.80762 456.72449 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +192.85156 465.19421 moveto +194.29395 465.19421 lineto +194.29395 466.37 lineto +193.17285 468.5575 lineto +192.29102 468.5575 lineto +192.85156 466.37 lineto +192.85156 465.19421 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +201.34863 461.42761 moveto +202.00943 461.56889 202.52441 461.86284 202.89355 462.30945 curveto +203.26725 462.75607 203.45409 463.3075 203.4541 463.96375 curveto +203.45409 464.97091 203.10774 465.7502 202.41504 466.30164 curveto +201.72232 466.85307 200.73795 467.12878 199.46191 467.12878 curveto +199.03353 467.12878 198.59147 467.08549 198.13574 466.9989 curveto +197.68457 466.91687 197.21745 466.79154 196.73438 466.62292 curveto +196.73438 465.28992 lineto +197.11719 465.51323 197.53646 465.68185 197.99219 465.79578 curveto +198.44791 465.90971 198.92415 465.96668 199.4209 465.96667 curveto +200.28678 465.96668 200.94531 465.79578 201.39648 465.45398 curveto +201.85221 465.11218 202.08007 464.61544 202.08008 463.96375 curveto +202.08007 463.36219 201.86816 462.89279 201.44434 462.55554 curveto +201.02506 462.21375 200.43945 462.04285 199.6875 462.04285 curveto +198.49805 462.04285 lineto +198.49805 460.90808 lineto +199.74219 460.90808 lineto +200.42122 460.90809 200.94075 460.77365 201.30078 460.50476 curveto +201.6608 460.23133 201.84081 459.8394 201.84082 459.32898 curveto +201.84081 458.8049 201.65397 458.40386 201.28027 458.12585 curveto +200.91113 457.84331 200.3802 457.70204 199.6875 457.70203 curveto +199.30924 457.70204 198.90364 457.74305 198.4707 457.82507 curveto +198.03776 457.90711 197.56152 458.03472 197.04199 458.20789 curveto +197.04199 456.97742 lineto +197.56608 456.83159 198.05599 456.72222 198.51172 456.64929 curveto +198.972 456.57639 199.40494 456.53993 199.81055 456.53992 curveto +200.85872 456.53993 201.68815 456.77918 202.29883 457.25769 curveto +202.9095 457.73166 203.21484 458.37424 203.21484 459.18542 curveto +203.21484 459.75054 203.05305 460.22905 202.72949 460.62097 curveto +202.40592 461.00835 201.94563 461.27723 201.34863 461.42761 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +206.22266 465.19421 moveto +207.66504 465.19421 lineto +207.66504 466.37 lineto +206.54395 468.5575 lineto +205.66211 468.5575 lineto +206.22266 466.37 lineto +206.22266 465.19421 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +213.3252 460.15613 moveto +212.65071 460.15613 212.11751 460.42046 211.72559 460.9491 curveto +211.33366 461.47319 211.13769 462.19324 211.1377 463.10925 curveto +211.13769 464.02527 211.33138 464.7476 211.71875 465.27625 curveto +212.11067 465.80033 212.64616 466.06238 213.3252 466.06238 curveto +213.99511 466.06238 214.52604 465.79806 214.91797 465.26941 curveto +215.30989 464.74077 215.50585 464.02071 215.50586 463.10925 curveto +215.50585 462.20236 215.30989 461.48458 214.91797 460.95593 curveto +214.52604 460.42274 213.99511 460.15613 213.3252 460.15613 curveto +213.3252 459.08972 moveto +214.41894 459.08973 215.27799 459.4452 215.90234 460.15613 curveto +216.52669 460.86707 216.83886 461.85145 216.83887 463.10925 curveto +216.83886 464.36251 216.52669 465.34688 215.90234 466.06238 curveto +215.27799 466.77332 214.41894 467.12878 213.3252 467.12878 curveto +212.22688 467.12878 211.36556 466.77332 210.74121 466.06238 curveto +210.12142 465.34688 209.81152 464.36251 209.81152 463.10925 curveto +209.81152 461.85145 210.12142 460.86707 210.74121 460.15613 curveto +211.36556 459.4452 212.22688 459.08973 213.3252 459.08972 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +218.71875 456.3075 moveto +219.8125 456.3075 lineto +220.49609 457.38303 221.00651 458.43576 221.34375 459.4657 curveto +221.68554 460.49565 221.85644 461.51876 221.85645 462.53503 curveto +221.85644 463.55587 221.68554 464.58354 221.34375 465.61804 curveto +221.00651 466.65255 220.49609 467.70528 219.8125 468.77625 curveto +218.71875 468.77625 lineto +219.32487 467.73262 219.77604 466.69584 220.07227 465.66589 curveto +220.37304 464.63139 220.52343 463.58777 220.52344 462.53503 curveto +220.52343 461.48231 220.37304 460.44324 220.07227 459.41785 curveto +219.77604 458.39246 219.32487 457.35568 218.71875 456.3075 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +228.20898 455.77429 moveto +227.5983 456.82248 227.14485 457.85926 226.84863 458.88464 curveto +226.55241 459.91004 226.40429 460.9491 226.4043 462.00183 curveto +226.40429 463.05457 226.55241 464.09819 226.84863 465.13269 curveto +227.14941 466.16264 227.60286 467.19942 228.20898 468.24304 curveto +227.11523 468.24304 lineto +226.43164 467.17208 225.91894 466.11934 225.57715 465.08484 curveto +225.23991 464.05034 225.07129 463.02267 225.07129 462.00183 curveto +225.07129 460.98556 225.23991 459.96245 225.57715 458.9325 curveto +225.91439 457.90256 226.42708 456.84982 227.11523 455.77429 curveto +228.20898 455.77429 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +233.95801 460.74402 moveto +233.33821 460.74402 232.84603 460.95594 232.48145 461.37976 curveto +232.12142 461.80359 231.9414 462.38465 231.94141 463.12292 curveto +231.9414 463.85665 232.12142 464.43771 232.48145 464.86609 curveto +232.84603 465.28992 233.33821 465.50183 233.95801 465.50183 curveto +234.57779 465.50183 235.0677 465.28992 235.42773 464.86609 curveto +235.79231 464.43771 235.9746 463.85665 235.97461 463.12292 curveto +235.9746 462.38465 235.79231 461.80359 235.42773 461.37976 curveto +235.0677 460.95594 234.57779 460.74402 233.95801 460.74402 curveto +236.69922 456.41687 moveto +236.69922 457.67468 lineto +236.35286 457.51063 236.00195 457.3853 235.64648 457.29871 curveto +235.29557 457.21213 234.94693 457.16883 234.60059 457.16882 curveto +233.68912 457.16883 232.99186 457.47645 232.50879 458.09167 curveto +232.03027 458.70692 231.75683 459.6366 231.68848 460.88074 curveto +231.95735 460.48426 232.29459 460.1812 232.7002 459.97156 curveto +233.10579 459.75737 233.5524 459.65028 234.04004 459.65027 curveto +235.06542 459.65028 235.87434 459.96245 236.4668 460.58679 curveto +237.06379 461.20659 237.3623 462.05197 237.3623 463.12292 curveto +237.3623 464.1711 237.0524 465.01192 236.43262 465.64539 curveto +235.81282 466.27885 234.98795 466.59558 233.95801 466.59558 curveto +232.77767 466.59558 231.87532 466.14441 231.25098 465.24207 curveto +230.62663 464.33517 230.31445 463.02267 230.31445 461.30457 curveto +230.31445 459.69129 230.69726 458.40614 231.46289 457.4491 curveto +232.22851 456.48752 233.25618 456.00672 234.5459 456.00671 curveto +234.89225 456.00672 235.24088 456.0409 235.5918 456.10925 curveto +235.94726 456.17762 236.3164 456.28016 236.69922 456.41687 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +239.8916 464.66101 moveto +241.33398 464.66101 lineto +241.33398 465.83679 lineto +240.21289 468.02429 lineto +239.33105 468.02429 lineto +239.8916 465.83679 lineto +239.8916 464.66101 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +247.99902 457.39441 moveto +244.5127 462.84265 lineto +247.99902 462.84265 lineto +247.99902 457.39441 lineto +247.63672 456.19128 moveto +249.37305 456.19128 lineto +249.37305 462.84265 lineto +250.8291 462.84265 lineto +250.8291 463.99109 lineto +249.37305 463.99109 lineto +249.37305 466.39734 lineto +247.99902 466.39734 lineto +247.99902 463.99109 lineto +243.3916 463.99109 lineto +243.3916 462.65808 lineto +247.63672 456.19128 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +253.2627 464.66101 moveto +254.70508 464.66101 lineto +254.70508 465.83679 lineto +253.58398 468.02429 lineto +252.70215 468.02429 lineto +253.2627 465.83679 lineto +253.2627 464.66101 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +262.43652 462.48035 moveto +262.43652 461.56889 262.24739 460.86251 261.86914 460.36121 curveto +261.49544 459.85991 260.96907 459.60926 260.29004 459.60925 curveto +259.61556 459.60926 259.08919 459.85991 258.71094 460.36121 curveto +258.33724 460.86251 258.15039 461.56889 258.15039 462.48035 curveto +258.15039 463.38725 258.33724 464.09135 258.71094 464.59265 curveto +259.08919 465.09395 259.61556 465.34461 260.29004 465.3446 curveto +260.96907 465.34461 261.49544 465.09395 261.86914 464.59265 curveto +262.24739 464.09135 262.43652 463.38725 262.43652 462.48035 curveto +263.69434 465.44714 moveto +263.69433 466.75053 263.40494 467.71895 262.82617 468.35242 curveto +262.24739 468.99044 261.361 469.30945 260.16699 469.30945 curveto +259.72493 469.30945 259.30794 469.27527 258.91602 469.20691 curveto +258.52409 469.1431 258.14355 469.04284 257.77441 468.90613 curveto +257.77441 467.6825 lineto +258.14355 467.88301 258.50814 468.03113 258.86816 468.12683 curveto +259.22819 468.22253 259.59505 468.27038 259.96875 468.27039 curveto +260.79362 468.27038 261.41113 468.05391 261.82129 467.62097 curveto +262.23144 467.19259 262.43652 466.54317 262.43652 465.67273 curveto +262.43652 465.05066 lineto +262.17675 465.50183 261.84407 465.83907 261.43848 466.06238 curveto +261.03287 466.28569 260.54752 466.39734 259.98242 466.39734 curveto +259.04362 466.39734 258.28711 466.03959 257.71289 465.3241 curveto +257.13867 464.6086 256.85156 463.66069 256.85156 462.48035 curveto +256.85156 461.29546 257.13867 460.34526 257.71289 459.62976 curveto +258.28711 458.91427 259.04362 458.55653 259.98242 458.55652 curveto +260.54752 458.55653 261.03287 458.66818 261.43848 458.89148 curveto +261.84407 459.11479 262.17675 459.45203 262.43652 459.9032 curveto +262.43652 458.74109 lineto +263.69434 458.74109 lineto +263.69434 465.44714 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +266.08691 455.77429 moveto +267.18066 455.77429 lineto +267.86425 456.84982 268.37467 457.90256 268.71191 458.9325 curveto +269.05371 459.96245 269.22461 460.98556 269.22461 462.00183 curveto +269.22461 463.02267 269.05371 464.05034 268.71191 465.08484 curveto +268.37467 466.11934 267.86425 467.17208 267.18066 468.24304 curveto +266.08691 468.24304 lineto +266.69303 467.19942 267.1442 466.16264 267.44043 465.13269 curveto +267.74121 464.09819 267.8916 463.05457 267.8916 462.00183 curveto +267.8916 460.9491 267.74121 459.91004 267.44043 458.88464 curveto +267.1442 457.85926 266.69303 456.82248 266.08691 455.77429 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +275.57715 455.77429 moveto +274.96647 456.82248 274.51302 457.85926 274.2168 458.88464 curveto +273.92057 459.91004 273.77246 460.9491 273.77246 462.00183 curveto +273.77246 463.05457 273.92057 464.09819 274.2168 465.13269 curveto +274.51757 466.16264 274.97102 467.19942 275.57715 468.24304 curveto +274.4834 468.24304 lineto +273.7998 467.17208 273.28711 466.11934 272.94531 465.08484 curveto +272.60807 464.05034 272.43945 463.02267 272.43945 462.00183 curveto +272.43945 460.98556 272.60807 459.96245 272.94531 458.9325 curveto +273.28255 457.90256 273.79524 456.84982 274.4834 455.77429 curveto +275.57715 455.77429 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +281.15527 461.55066 moveto +280.49902 461.55066 279.98177 461.72612 279.60352 462.07703 curveto +279.22982 462.42794 279.04297 462.91101 279.04297 463.52625 curveto +279.04297 464.14148 279.22982 464.62455 279.60352 464.97546 curveto +279.98177 465.32638 280.49902 465.50183 281.15527 465.50183 curveto +281.81152 465.50183 282.32877 465.32638 282.70703 464.97546 curveto +283.08528 464.62 283.27441 464.13692 283.27441 463.52625 curveto +283.27441 462.91101 283.08528 462.42794 282.70703 462.07703 curveto +282.33333 461.72612 281.81608 461.55066 281.15527 461.55066 curveto +279.77441 460.96277 moveto +279.18196 460.81694 278.7194 460.54122 278.38672 460.13562 curveto +278.05859 459.73003 277.89453 459.23556 277.89453 458.65222 curveto +277.89453 457.83648 278.18392 457.19162 278.7627 456.71765 curveto +279.34603 456.2437 280.14355 456.00672 281.15527 456.00671 curveto +282.17154 456.00672 282.96907 456.2437 283.54785 456.71765 curveto +284.12662 457.19162 284.41601 457.83648 284.41602 458.65222 curveto +284.41601 459.23556 284.24967 459.73003 283.91699 460.13562 curveto +283.58886 460.54122 283.13085 460.81694 282.54297 460.96277 curveto +283.20833 461.11772 283.72558 461.42078 284.09473 461.87195 curveto +284.46842 462.32312 284.65527 462.87456 284.65527 463.52625 curveto +284.65527 464.51518 284.35221 465.27397 283.74609 465.80261 curveto +283.14452 466.33126 282.28092 466.59558 281.15527 466.59558 curveto +280.02962 466.59558 279.16373 466.33126 278.55762 465.80261 curveto +277.95605 465.27397 277.65527 464.51518 277.65527 463.52625 curveto +277.65527 462.87456 277.84212 462.32312 278.21582 461.87195 curveto +278.58952 461.42078 279.10905 461.11772 279.77441 460.96277 curveto +279.26855 458.7821 moveto +279.26855 459.31076 279.43261 459.72319 279.76074 460.01941 curveto +280.09342 460.31564 280.55826 460.46375 281.15527 460.46375 curveto +281.74772 460.46375 282.21028 460.31564 282.54297 460.01941 curveto +282.8802 459.72319 283.04882 459.31076 283.04883 458.7821 curveto +283.04882 458.25347 282.8802 457.84103 282.54297 457.5448 curveto +282.21028 457.24858 281.74772 457.10047 281.15527 457.10046 curveto +280.55826 457.10047 280.09342 457.24858 279.76074 457.5448 curveto +279.43261 457.84103 279.26855 458.25347 279.26855 458.7821 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +287.25977 464.66101 moveto +288.70215 464.66101 lineto +288.70215 465.83679 lineto +287.58105 468.02429 lineto +286.69922 468.02429 lineto +287.25977 465.83679 lineto +287.25977 464.66101 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +291.58691 456.19128 moveto +297.00781 456.19128 lineto +297.00781 457.35339 lineto +292.85156 457.35339 lineto +292.85156 459.85535 lineto +293.05208 459.78699 293.2526 459.73686 293.45312 459.70496 curveto +293.65364 459.6685 293.85416 459.65028 294.05469 459.65027 curveto +295.19401 459.65028 296.09635 459.96245 296.76172 460.58679 curveto +297.42708 461.21115 297.75976 462.05652 297.75977 463.12292 curveto +297.75976 464.22123 297.41796 465.07573 296.73438 465.6864 curveto +296.05078 466.29252 295.08691 466.59558 293.84277 466.59558 curveto +293.41438 466.59558 292.97689 466.55912 292.53027 466.48621 curveto +292.08821 466.41329 291.63021 466.30391 291.15625 466.15808 curveto +291.15625 464.77039 lineto +291.5664 464.99369 291.99023 465.16004 292.42773 465.26941 curveto +292.86523 465.37879 293.3278 465.43347 293.81543 465.43347 curveto +294.60384 465.43347 295.22818 465.22612 295.68848 464.8114 curveto +296.14876 464.39669 296.3789 463.83386 296.37891 463.12292 curveto +296.3789 462.41199 296.14876 461.84917 295.68848 461.43445 curveto +295.22818 461.01974 294.60384 460.81238 293.81543 460.81238 curveto +293.44629 460.81238 293.07715 460.8534 292.70801 460.93542 curveto +292.34342 461.01746 291.96972 461.14507 291.58691 461.31824 curveto +291.58691 456.19128 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +300.63086 464.66101 moveto +302.07324 464.66101 lineto +302.07324 465.83679 lineto +300.95215 468.02429 lineto +300.07031 468.02429 lineto +300.63086 465.83679 lineto +300.63086 464.66101 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +309.80469 462.48035 moveto +309.80468 461.56889 309.61555 460.86251 309.2373 460.36121 curveto +308.8636 459.85991 308.33723 459.60926 307.6582 459.60925 curveto +306.98372 459.60926 306.45735 459.85991 306.0791 460.36121 curveto +305.7054 460.86251 305.51855 461.56889 305.51855 462.48035 curveto +305.51855 463.38725 305.7054 464.09135 306.0791 464.59265 curveto +306.45735 465.09395 306.98372 465.34461 307.6582 465.3446 curveto +308.33723 465.34461 308.8636 465.09395 309.2373 464.59265 curveto +309.61555 464.09135 309.80468 463.38725 309.80469 462.48035 curveto +311.0625 465.44714 moveto +311.06249 466.75053 310.7731 467.71895 310.19434 468.35242 curveto +309.61555 468.99044 308.72916 469.30945 307.53516 469.30945 curveto +307.0931 469.30945 306.6761 469.27527 306.28418 469.20691 curveto +305.89225 469.1431 305.51172 469.04284 305.14258 468.90613 curveto +305.14258 467.6825 lineto +305.51172 467.88301 305.8763 468.03113 306.23633 468.12683 curveto +306.59635 468.22253 306.96321 468.27038 307.33691 468.27039 curveto +308.16178 468.27038 308.77929 468.05391 309.18945 467.62097 curveto +309.5996 467.19259 309.80468 466.54317 309.80469 465.67273 curveto +309.80469 465.05066 lineto +309.54492 465.50183 309.21223 465.83907 308.80664 466.06238 curveto +308.40104 466.28569 307.91569 466.39734 307.35059 466.39734 curveto +306.41178 466.39734 305.65527 466.03959 305.08105 465.3241 curveto +304.50683 464.6086 304.21973 463.66069 304.21973 462.48035 curveto +304.21973 461.29546 304.50683 460.34526 305.08105 459.62976 curveto +305.65527 458.91427 306.41178 458.55653 307.35059 458.55652 curveto +307.91569 458.55653 308.40104 458.66818 308.80664 458.89148 curveto +309.21223 459.11479 309.54492 459.45203 309.80469 459.9032 curveto +309.80469 458.74109 lineto +311.0625 458.74109 lineto +311.0625 465.44714 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +313.45508 455.77429 moveto +314.54883 455.77429 lineto +315.23242 456.84982 315.74284 457.90256 316.08008 458.9325 curveto +316.42187 459.96245 316.59277 460.98556 316.59277 462.00183 curveto +316.59277 463.02267 316.42187 464.05034 316.08008 465.08484 curveto +315.74284 466.11934 315.23242 467.17208 314.54883 468.24304 curveto +313.45508 468.24304 lineto +314.0612 467.19942 314.51237 466.16264 314.80859 465.13269 curveto +315.10937 464.09819 315.25976 463.05457 315.25977 462.00183 curveto +315.25976 460.9491 315.10937 459.91004 314.80859 458.88464 curveto +314.51237 457.85926 314.0612 456.82248 313.45508 455.77429 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +174.3125 475.84265 moveto +173.70182 476.89084 173.24837 477.92762 172.95215 478.953 curveto +172.65592 479.9784 172.50781 481.01746 172.50781 482.07019 curveto +172.50781 483.12293 172.65592 484.16655 172.95215 485.20105 curveto +173.25293 486.231 173.70638 487.26778 174.3125 488.3114 curveto +173.21875 488.3114 lineto +172.53515 487.24044 172.02246 486.1877 171.68066 485.1532 curveto +171.34342 484.1187 171.1748 483.09103 171.1748 482.07019 curveto +171.1748 481.05392 171.34342 480.03081 171.68066 479.00085 curveto +172.0179 477.97092 172.5306 476.91818 173.21875 475.84265 curveto +174.3125 475.84265 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +176.97852 486.25378 moveto +176.97852 484.99597 lineto +177.32487 485.16004 177.67578 485.28536 178.03125 485.37195 curveto +178.38672 485.45854 178.73535 485.50183 179.07715 485.50183 curveto +179.9886 485.50183 180.68359 485.19649 181.16211 484.58582 curveto +181.64518 483.97058 181.92089 483.03862 181.98926 481.78992 curveto +181.72493 482.18185 181.38997 482.48263 180.98438 482.69226 curveto +180.57877 482.9019 180.12988 483.00672 179.6377 483.00671 curveto +178.61686 483.00672 177.80794 482.6991 177.21094 482.08386 curveto +176.61849 481.46408 176.32226 480.6187 176.32227 479.54773 curveto +176.32226 478.49956 176.63216 477.65874 177.25195 477.02527 curveto +177.87174 476.39182 178.69661 476.07508 179.72656 476.07507 curveto +180.9069 476.07508 181.80696 476.52853 182.42676 477.43542 curveto +183.0511 478.33778 183.36327 479.65028 183.36328 481.37292 curveto +183.36327 482.98165 182.98046 484.26681 182.21484 485.22839 curveto +181.45377 486.18543 180.42838 486.66394 179.13867 486.66394 curveto +178.79231 486.66394 178.4414 486.62976 178.08594 486.5614 curveto +177.73047 486.49304 177.36133 486.3905 176.97852 486.25378 curveto +179.72656 481.92664 moveto +180.34635 481.92664 180.83626 481.71473 181.19629 481.29089 curveto +181.56087 480.86707 181.74316 480.28602 181.74316 479.54773 curveto +181.74316 478.81401 181.56087 478.23524 181.19629 477.8114 curveto +180.83626 477.38303 180.34635 477.16883 179.72656 477.16882 curveto +179.10677 477.16883 178.61458 477.38303 178.25 477.8114 curveto +177.88997 478.23524 177.70996 478.81401 177.70996 479.54773 curveto +177.70996 480.28602 177.88997 480.86707 178.25 481.29089 curveto +178.61458 481.71473 179.10677 481.92664 179.72656 481.92664 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +185.99512 484.72937 moveto +187.4375 484.72937 lineto +187.4375 485.90515 lineto +186.31641 488.09265 lineto +185.43457 488.09265 lineto +185.99512 485.90515 lineto +185.99512 484.72937 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +193.43262 480.81238 moveto +192.81282 480.81238 192.32063 481.0243 191.95605 481.44812 curveto +191.59603 481.87195 191.41601 482.45301 191.41602 483.19128 curveto +191.41601 483.92501 191.59603 484.50606 191.95605 484.93445 curveto +192.32063 485.35828 192.81282 485.57019 193.43262 485.57019 curveto +194.0524 485.57019 194.54231 485.35828 194.90234 484.93445 curveto +195.26692 484.50606 195.44921 483.92501 195.44922 483.19128 curveto +195.44921 482.45301 195.26692 481.87195 194.90234 481.44812 curveto +194.54231 481.0243 194.0524 480.81238 193.43262 480.81238 curveto +196.17383 476.48523 moveto +196.17383 477.74304 lineto +195.82747 477.57899 195.47656 477.45366 195.12109 477.36707 curveto +194.77018 477.28049 194.42154 477.23719 194.0752 477.23718 curveto +193.16373 477.23719 192.46647 477.54481 191.9834 478.16003 curveto +191.50488 478.77528 191.23144 479.70496 191.16309 480.9491 curveto +191.43196 480.55262 191.7692 480.24956 192.1748 480.03992 curveto +192.5804 479.82573 193.02701 479.71863 193.51465 479.71863 curveto +194.54003 479.71863 195.34895 480.03081 195.94141 480.65515 curveto +196.5384 481.27495 196.83691 482.12032 196.83691 483.19128 curveto +196.83691 484.23946 196.52701 485.08028 195.90723 485.71375 curveto +195.28743 486.34721 194.46256 486.66394 193.43262 486.66394 curveto +192.25228 486.66394 191.34993 486.21277 190.72559 485.31042 curveto +190.10124 484.40353 189.78906 483.09103 189.78906 481.37292 curveto +189.78906 479.75965 190.17187 478.4745 190.9375 477.51746 curveto +191.70312 476.55588 192.73079 476.07508 194.02051 476.07507 curveto +194.36686 476.07508 194.71549 476.10926 195.06641 476.17761 curveto +195.42187 476.24598 195.79101 476.34852 196.17383 476.48523 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +199.36621 484.72937 moveto +200.80859 484.72937 lineto +200.80859 485.90515 lineto +199.6875 488.09265 lineto +198.80566 488.09265 lineto +199.36621 485.90515 lineto +199.36621 484.72937 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +206.46875 479.69128 moveto +205.79427 479.69129 205.26106 479.95561 204.86914 480.48425 curveto +204.47721 481.00835 204.28125 481.7284 204.28125 482.64441 curveto +204.28125 483.56043 204.47493 484.28276 204.8623 484.8114 curveto +205.25423 485.33549 205.78971 485.59754 206.46875 485.59753 curveto +207.13867 485.59754 207.66959 485.33321 208.06152 484.80457 curveto +208.45344 484.27592 208.64941 483.55587 208.64941 482.64441 curveto +208.64941 481.73751 208.45344 481.01974 208.06152 480.49109 curveto +207.66959 479.95789 207.13867 479.69129 206.46875 479.69128 curveto +206.46875 478.62488 moveto +207.56249 478.62489 208.42154 478.98035 209.0459 479.69128 curveto +209.67024 480.40223 209.98241 481.3866 209.98242 482.64441 curveto +209.98241 483.89767 209.67024 484.88204 209.0459 485.59753 curveto +208.42154 486.30847 207.56249 486.66394 206.46875 486.66394 curveto +205.37044 486.66394 204.50911 486.30847 203.88477 485.59753 curveto +203.26497 484.88204 202.95508 483.89767 202.95508 482.64441 curveto +202.95508 481.3866 203.26497 480.40223 203.88477 479.69128 curveto +204.50911 478.98035 205.37044 478.62489 206.46875 478.62488 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +211.8623 475.84265 moveto +212.95605 475.84265 lineto +213.63965 476.91818 214.15006 477.97092 214.4873 479.00085 curveto +214.8291 480.03081 215 481.05392 215 482.07019 curveto +215 483.09103 214.8291 484.1187 214.4873 485.1532 curveto +214.15006 486.1877 213.63965 487.24044 212.95605 488.3114 curveto +211.8623 488.3114 lineto +212.46842 487.26778 212.91959 486.231 213.21582 485.20105 curveto +213.5166 484.16655 213.66699 483.12293 213.66699 482.07019 curveto +213.66699 481.01746 213.5166 479.9784 213.21582 478.953 curveto +212.91959 477.92762 212.46842 476.89084 211.8623 475.84265 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +222.12305 476.34265 moveto +221.51237 477.39084 221.05892 478.42762 220.7627 479.453 curveto +220.46647 480.4784 220.31836 481.51746 220.31836 482.57019 curveto +220.31836 483.62293 220.46647 484.66655 220.7627 485.70105 curveto +221.06347 486.731 221.51692 487.76778 222.12305 488.8114 curveto +221.0293 488.8114 lineto +220.3457 487.74044 219.83301 486.6877 219.49121 485.6532 curveto +219.15397 484.6187 218.98535 483.59103 218.98535 482.57019 curveto +218.98535 481.55392 219.15397 480.53081 219.49121 479.50085 curveto +219.82845 478.47092 220.34114 477.41818 221.0293 476.34265 curveto +222.12305 476.34265 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +224.9873 485.80359 moveto +227.24316 485.80359 lineto +227.24316 478.01746 lineto +224.78906 478.50964 lineto +224.78906 477.25183 lineto +227.22949 476.75964 lineto +228.61035 476.75964 lineto +228.61035 485.80359 lineto +230.86621 485.80359 lineto +230.86621 486.9657 lineto +224.9873 486.9657 lineto +224.9873 485.80359 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +236.61523 477.66882 moveto +235.90429 477.66883 235.36881 478.01974 235.00879 478.72156 curveto +234.65332 479.41883 234.47558 480.46929 234.47559 481.87292 curveto +234.47558 483.27202 234.65332 484.32247 235.00879 485.02429 curveto +235.36881 485.72156 235.90429 486.07019 236.61523 486.07019 curveto +237.33072 486.07019 237.86621 485.72156 238.22168 485.02429 curveto +238.5817 484.32247 238.76171 483.27202 238.76172 481.87292 curveto +238.76171 480.46929 238.5817 479.41883 238.22168 478.72156 curveto +237.86621 478.01974 237.33072 477.66883 236.61523 477.66882 curveto +236.61523 476.57507 moveto +237.75911 476.57508 238.63183 477.02853 239.2334 477.93542 curveto +239.83951 478.83778 240.14257 480.15028 240.14258 481.87292 curveto +240.14257 483.59103 239.83951 484.90353 239.2334 485.81042 curveto +238.63183 486.71277 237.75911 487.16394 236.61523 487.16394 curveto +235.47135 487.16394 234.59635 486.71277 233.99023 485.81042 curveto +233.38867 484.90353 233.08789 483.59103 233.08789 481.87292 curveto +233.08789 480.15028 233.38867 478.83778 233.99023 477.93542 curveto +234.59635 477.02853 235.47135 476.57508 236.61523 476.57507 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +242.71973 485.22937 moveto +244.16211 485.22937 lineto +244.16211 486.40515 lineto +243.04102 488.59265 lineto +242.15918 488.59265 lineto +242.71973 486.40515 lineto +242.71973 485.22937 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +246.68457 476.75964 moveto +253.24707 476.75964 lineto +253.24707 477.34753 lineto +249.54199 486.9657 lineto +248.09961 486.9657 lineto +251.58594 477.92175 lineto +246.68457 477.92175 lineto +246.68457 476.75964 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +256.09082 485.22937 moveto +257.5332 485.22937 lineto +257.5332 486.40515 lineto +256.41211 488.59265 lineto +255.53027 488.59265 lineto +256.09082 486.40515 lineto +256.09082 485.22937 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +263.19336 480.19128 moveto +262.51888 480.19129 261.98567 480.45561 261.59375 480.98425 curveto +261.20182 481.50835 261.00586 482.2284 261.00586 483.14441 curveto +261.00586 484.06043 261.19954 484.78276 261.58691 485.3114 curveto +261.97884 485.83549 262.51432 486.09754 263.19336 486.09753 curveto +263.86328 486.09754 264.3942 485.83321 264.78613 485.30457 curveto +265.17805 484.77592 265.37402 484.05587 265.37402 483.14441 curveto +265.37402 482.23751 265.17805 481.51974 264.78613 480.99109 curveto +264.3942 480.45789 263.86328 480.19129 263.19336 480.19128 curveto +263.19336 479.12488 moveto +264.2871 479.12489 265.14615 479.48035 265.77051 480.19128 curveto +266.39485 480.90223 266.70702 481.8866 266.70703 483.14441 curveto +266.70702 484.39767 266.39485 485.38204 265.77051 486.09753 curveto +265.14615 486.80847 264.2871 487.16394 263.19336 487.16394 curveto +262.09505 487.16394 261.23372 486.80847 260.60938 486.09753 curveto +259.98958 485.38204 259.67969 484.39767 259.67969 483.14441 curveto +259.67969 481.8866 259.98958 480.90223 260.60938 480.19128 curveto +261.23372 479.48035 262.09505 479.12489 263.19336 479.12488 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +268.58691 476.34265 moveto +269.68066 476.34265 lineto +270.36425 477.41818 270.87467 478.47092 271.21191 479.50085 curveto +271.55371 480.53081 271.72461 481.55392 271.72461 482.57019 curveto +271.72461 483.59103 271.55371 484.6187 271.21191 485.6532 curveto +270.87467 486.6877 270.36425 487.74044 269.68066 488.8114 curveto +268.58691 488.8114 lineto +269.19303 487.76778 269.6442 486.731 269.94043 485.70105 curveto +270.24121 484.66655 270.3916 483.62293 270.3916 482.57019 curveto +270.3916 481.51746 270.24121 480.4784 269.94043 479.453 curveto +269.6442 478.42762 269.19303 477.39084 268.58691 476.34265 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +276.49121 476.34265 moveto +275.88053 477.39084 275.42708 478.42762 275.13086 479.453 curveto +274.83463 480.4784 274.68652 481.51746 274.68652 482.57019 curveto +274.68652 483.62293 274.83463 484.66655 275.13086 485.70105 curveto +275.43164 486.731 275.88509 487.76778 276.49121 488.8114 curveto +275.39746 488.8114 lineto +274.71386 487.74044 274.20117 486.6877 273.85938 485.6532 curveto +273.52213 484.6187 273.35351 483.59103 273.35352 482.57019 curveto +273.35351 481.55392 273.52213 480.53081 273.85938 479.50085 curveto +274.19661 478.47092 274.70931 477.41818 275.39746 476.34265 curveto +276.49121 476.34265 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +279.35547 485.80359 moveto +281.61133 485.80359 lineto +281.61133 478.01746 lineto +279.15723 478.50964 lineto +279.15723 477.25183 lineto +281.59766 476.75964 lineto +282.97852 476.75964 lineto +282.97852 485.80359 lineto +285.23438 485.80359 lineto +285.23438 486.9657 lineto +279.35547 486.9657 lineto +279.35547 485.80359 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +288.26953 485.80359 moveto +290.52539 485.80359 lineto +290.52539 478.01746 lineto +288.07129 478.50964 lineto +288.07129 477.25183 lineto +290.51172 476.75964 lineto +291.89258 476.75964 lineto +291.89258 485.80359 lineto +294.14844 485.80359 lineto +294.14844 486.9657 lineto +288.26953 486.9657 lineto +288.26953 485.80359 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +297.08789 485.22937 moveto +298.53027 485.22937 lineto +298.53027 486.40515 lineto +297.40918 488.59265 lineto +296.52734 488.59265 lineto +297.08789 486.40515 lineto +297.08789 485.22937 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +304.35449 482.11902 moveto +303.69824 482.11902 303.18099 482.29448 302.80273 482.64539 curveto +302.42903 482.9963 302.24219 483.47937 302.24219 484.0946 curveto +302.24219 484.70984 302.42903 485.19291 302.80273 485.54382 curveto +303.18099 485.89474 303.69824 486.07019 304.35449 486.07019 curveto +305.01074 486.07019 305.52799 485.89474 305.90625 485.54382 curveto +306.2845 485.18836 306.47363 484.70528 306.47363 484.0946 curveto +306.47363 483.47937 306.2845 482.9963 305.90625 482.64539 curveto +305.53255 482.29448 305.01529 482.11902 304.35449 482.11902 curveto +302.97363 481.53113 moveto +302.38118 481.3853 301.91862 481.10958 301.58594 480.70398 curveto +301.25781 480.29839 301.09375 479.80392 301.09375 479.22058 curveto +301.09375 478.40483 301.38314 477.75998 301.96191 477.28601 curveto +302.54524 476.81206 303.34277 476.57508 304.35449 476.57507 curveto +305.37076 476.57508 306.16829 476.81206 306.74707 477.28601 curveto +307.32584 477.75998 307.61523 478.40483 307.61523 479.22058 curveto +307.61523 479.80392 307.44889 480.29839 307.11621 480.70398 curveto +306.78808 481.10958 306.33007 481.3853 305.74219 481.53113 curveto +306.40755 481.68608 306.9248 481.98914 307.29395 482.44031 curveto +307.66764 482.89148 307.85448 483.44292 307.85449 484.0946 curveto +307.85448 485.08354 307.55142 485.84233 306.94531 486.37097 curveto +306.34374 486.89962 305.48014 487.16394 304.35449 487.16394 curveto +303.22884 487.16394 302.36295 486.89962 301.75684 486.37097 curveto +301.15527 485.84233 300.85449 485.08354 300.85449 484.0946 curveto +300.85449 483.44292 301.04134 482.89148 301.41504 482.44031 curveto +301.78874 481.98914 302.30827 481.68608 302.97363 481.53113 curveto +302.46777 479.35046 moveto +302.46777 479.87912 302.63183 480.29155 302.95996 480.58777 curveto +303.29264 480.884 303.75748 481.03211 304.35449 481.0321 curveto +304.94694 481.03211 305.4095 480.884 305.74219 480.58777 curveto +306.07942 480.29155 306.24804 479.87912 306.24805 479.35046 curveto +306.24804 478.82183 306.07942 478.40939 305.74219 478.11316 curveto +305.4095 477.81694 304.94694 477.66883 304.35449 477.66882 curveto +303.75748 477.66883 303.29264 477.81694 302.95996 478.11316 curveto +302.63183 478.40939 302.46777 478.82183 302.46777 479.35046 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +310.45898 485.22937 moveto +311.90137 485.22937 lineto +311.90137 486.40515 lineto +310.78027 488.59265 lineto +309.89844 488.59265 lineto +310.45898 486.40515 lineto +310.45898 485.22937 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +317.56152 480.19128 moveto +316.88704 480.19129 316.35384 480.45561 315.96191 480.98425 curveto +315.56998 481.50835 315.37402 482.2284 315.37402 483.14441 curveto +315.37402 484.06043 315.56771 484.78276 315.95508 485.3114 curveto +316.347 485.83549 316.88248 486.09754 317.56152 486.09753 curveto +318.23144 486.09754 318.76236 485.83321 319.1543 485.30457 curveto +319.54622 484.77592 319.74218 484.05587 319.74219 483.14441 curveto +319.74218 482.23751 319.54622 481.51974 319.1543 480.99109 curveto +318.76236 480.45789 318.23144 480.19129 317.56152 480.19128 curveto +317.56152 479.12488 moveto +318.65527 479.12489 319.51432 479.48035 320.13867 480.19128 curveto +320.76301 480.90223 321.07519 481.8866 321.0752 483.14441 curveto +321.07519 484.39767 320.76301 485.38204 320.13867 486.09753 curveto +319.51432 486.80847 318.65527 487.16394 317.56152 487.16394 curveto +316.46321 487.16394 315.60189 486.80847 314.97754 486.09753 curveto +314.35775 485.38204 314.04785 484.39767 314.04785 483.14441 curveto +314.04785 481.8866 314.35775 480.90223 314.97754 480.19128 curveto +315.60189 479.48035 316.46321 479.12489 317.56152 479.12488 curveto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +322.95508 476.34265 moveto +324.04883 476.34265 lineto +324.73242 477.41818 325.24284 478.47092 325.58008 479.50085 curveto +325.92187 480.53081 326.09277 481.55392 326.09277 482.57019 curveto +326.09277 483.59103 325.92187 484.6187 325.58008 485.6532 curveto +325.24284 486.6877 324.73242 487.74044 324.04883 488.8114 curveto +322.95508 488.8114 lineto +323.5612 487.76778 324.01237 486.731 324.30859 485.70105 curveto +324.60937 484.66655 324.75976 483.62293 324.75977 482.57019 curveto +324.75976 481.51746 324.60937 480.4784 324.30859 479.453 curveto +324.01237 478.42762 323.5612 477.39084 322.95508 476.34265 curveto +fill +grestore +gsave [1.436848 0 0 0.806571 118.9493 72.56034] concat +0 0 0 setrgbcolor +[] 0 setdash +1.5 setlinewidth +0 setlinejoin +0 setlinecap +newpath +154.5 482.61218 moveto +154.5 515.59418 125.716 542.36218 90.25 542.36218 curveto +54.784 542.36218 26 515.59418 26 482.61218 curveto +26 449.63018 54.784 422.86218 90.25 422.86218 curveto +125.716 422.86218 154.5 449.63018 154.5 482.61218 curveto +closepath +stroke +grestore +gsave +0 0 0 setrgbcolor +newpath +244.37402 420.15613 moveto +245.75488 420.15613 lineto +245.75488 430.36218 lineto +244.37402 430.36218 lineto +244.37402 420.15613 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +249.69238 420.5321 moveto +249.69238 422.70593 lineto +252.2832 422.70593 lineto +252.2832 423.68347 lineto +249.69238 423.68347 lineto +249.69238 427.83972 lineto +249.69238 428.46407 249.77669 428.86511 249.94531 429.04285 curveto +250.11849 429.22058 250.46712 429.30945 250.99121 429.30945 curveto +252.2832 429.30945 lineto +252.2832 430.36218 lineto +250.99121 430.36218 lineto +250.0205 430.36218 249.35058 430.18217 248.98145 429.82214 curveto +248.6123 429.45756 248.42773 428.79675 248.42773 427.83972 curveto +248.42773 423.68347 lineto +247.50488 423.68347 lineto +247.50488 422.70593 lineto +248.42773 422.70593 lineto +248.42773 420.5321 lineto +249.69238 420.5321 lineto +fill +grestore +grestore +gsave +0 0 0 setrgbcolor +newpath +250.25488 525.79089 moveto +250.25488 529.62585 lineto +251.99121 529.62585 lineto +252.63378 529.62586 253.13053 529.45952 253.48145 529.12683 curveto +253.83235 528.79415 254.00781 528.3202 254.00781 527.70496 curveto +254.00781 527.09429 253.83235 526.62261 253.48145 526.28992 curveto +253.13053 525.95724 252.63378 525.7909 251.99121 525.79089 curveto +250.25488 525.79089 lineto +248.87402 524.65613 moveto +251.99121 524.65613 lineto +253.13509 524.65614 253.99869 524.9159 254.58203 525.43542 curveto +255.16991 525.95041 255.46386 526.70692 255.46387 527.70496 curveto +255.46386 528.71212 255.16991 529.47319 254.58203 529.98816 curveto +253.99869 530.50314 253.13509 530.76062 251.99121 530.76062 curveto +250.25488 530.76062 lineto +250.25488 534.86218 lineto +248.87402 534.86218 lineto +248.87402 524.65613 lineto +fill +grestore +gsave +0 0 0 setrgbcolor +newpath +257.68555 533.70007 moveto +259.94141 533.70007 lineto +259.94141 525.91394 lineto +257.4873 526.40613 lineto +257.4873 525.14832 lineto +259.92773 524.65613 lineto +261.30859 524.65613 lineto +261.30859 533.70007 lineto +263.56445 533.70007 lineto +263.56445 534.86218 lineto +257.68555 534.86218 lineto +257.68555 533.70007 lineto +fill +grestore +0 0 0 setrgbcolor +[] 0 setdash +1 setlinewidth +0 setlinejoin +0 setlinecap +newpath +155 302.36218 moveto +154.5 534.36218 lineto +stroke +grestore +showpage +%%EOF diff -Nru dune-common-2.2.1/doc/comm/indexset.cc dune-common-2.5.2~20170808ga5c076ca/doc/comm/indexset.cc --- dune-common-2.2.1/doc/comm/indexset.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/indexset.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,51 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#include + +#include +#include +#include +#include +#include "buildindexset.hh" +#include "reverse.hh" + +int main(int argc, char **argv) +{ + // This is a parallel programm so we need to + // initialize mpi first. + Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv); + + // The rank of our process + int rank = helper.rank(); + + // The type used as the global index + typedef int GlobalIndex; + + // The index set we use to identify the local indices with the globally + // unique ones + typedef Dune::ParallelIndexSet ParallelIndexSet; + + // The index set + ParallelIndexSet indexSet; + + build(helper, indexSet); + + // Print the index set + std::cout< +#include // We use exceptions +#include // An initializer of MPI +#include +#include + +enum Flags { owner, ghost }; + +struct Bla +{ + + /** @brief The local index. */ + size_t localIndex_; + + /** @brief An attribute for the index. */ + char attribute_; + + /** @brief True if the index is also known to other processors. */ + bool public_; + + /** + * @brief The state of the index. + * + * Has to be one of LocalIndexState! + * @see LocalIndexState. + */ + char state_; +}; + + +template +void buildBlockedIndexSet(T1& indexset, int N, const T2& comm) +{ + int rank=comm.rank(); + int size=comm.size(); + int localsize=N/size; + int bigger=N%size; + int start, end; + if(rank0) + indexset.add(gindex-1,LocalIndex(index++,ghost)); + + for(int i=start; i > IndexSet; + IndexSet blockedSet; + buildBlockedIndexSet(blockedSet, n, helper.getCollectiveCommunication()); + } + return 0; + } + catch (Dune::Exception &e) { + std::cerr << "Dune reported error: " << e << std::endl; + } + catch (...) { + std::cerr << "Unknown exception thrown!" << std::endl; + } +} diff -Nru dune-common-2.2.1/doc/comm/poosc08_test.cc dune-common-2.5.2~20170808ga5c076ca/doc/comm/poosc08_test.cc --- dune-common-2.2.1/doc/comm/poosc08_test.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/comm/poosc08_test.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,155 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include +#include // We use exceptions +#include // An initializer of MPI +#include +#include +#include +#include +#include +#include + +enum Flags { owner, ghost }; + +template +struct AddData { + typedef typename T::value_type IndexedType; + + static const IndexedType& gather(const T& v, int i){ + return v[i]; + } + + static void scatter(T& v, const IndexedType& item, int i){ + v[i]+=item; + } +}; + +template +struct CopyData { + typedef typename T::value_type IndexedType; + + static const IndexedType& gather(const T& v, int i){ + return v[i]; + } + + static void scatter(T& v, const IndexedType& item, int i){ + v[i]=item; + } +}; + + +template +void doCalculations(T&){} + +#if HAVE_MPI +void test() +{ + int rank; + MPI_Comm comm=(MPI_COMM_WORLD); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + using namespace Dune; + // shortcut for index set type + typedef ParallelLocalIndex LocalIndex; + typedef ParallelIndexSet PIndexSet; + PIndexSet sis; + sis.beginResize(); + if(rank==0) { + + sis.add(11, LocalIndex(0, ghost)); + for(int i=1; i<=6; i++) + sis.add(i-1, LocalIndex(i, owner, i<=1||i>5)); + sis.add(6, LocalIndex(7, ghost)); + }else{ + sis.add(5, LocalIndex(0, ghost)); + for(int i=1; i<=6; i++) + sis.add(5+i, LocalIndex(i, owner, i<=1||i>5)); + sis.add(0,LocalIndex(7, ghost)); + } + sis.endResize(); + + PIndexSet tis; + tis.beginResize(); + int l=0; + for(int i=0; i<2; ++i) + for(int j=0; j<5; ++j) { + int g=rank*3-1+i*6+j; + if(g<0||g>11) + continue; + Flags flag=(j>0&&j<4) ? owner : ghost; + tis.add(g, LocalIndex(l++, flag)); + } + tis.endResize(); + std::cout< riRedist(sis, tis, comm); + riRedist.rebuild(); + + std::vector v; + RemoteIndices riS(sis,sis, comm, v, true); + riS.rebuild(); + + std::cout<,EnumItem,Flags> ghostFlags; + EnumItem ownerFlags; + Combine, EnumItem > allFlags; + + Interface infRedist; + Interface infS; + + infRedist.build(riRedist, ownerFlags, allFlags); + infS.build(riS, ownerFlags, ghostFlags); + + std::cout<<"inf "< Container; + Container s(sis.size(),3), t(tis.size()); + + s[sis.size()-1]=-1; + + BufferedCommunicator bComm; + BufferedCommunicator bCommRedist; + bComm.build(s, s, infS); + //bCommRedist.build(s, t, infRedist); + for(std::size_t i=0; i >(s,s); + + for(std::size_t i=0; i >(s,t); + // calculate on the redistributed array + doCalculations(t); + bCommRedist.backward >(s,t); +} +#endif // HAVE_MPI + +int main(int argc, char** argv) +{ + try{ + using namespace Dune; +#if HAVE_MPI + //Maybe initialize Mpi + MPIHelper& helper = MPIHelper::instance(argc, argv); + std::cout << "Hello World! This is poosc08. rank=" < +void reverseLocalIndex(Dune::ParallelIndexSet& indexSet) +{ + // reverse the local indices + typedef typename Dune::ParallelIndexSet::iterator iterator; + + iterator end = indexSet.end(); + size_t maxLocal = 0; + + // find the maximal local index + for(iterator index = indexSet.begin(); index != end; ++index) { + // Get the local index + LocalIndex& local = index->local(); + maxLocal = std::max(maxLocal, local.local()); + } + + for(iterator index = indexSet.begin(); index != end; ++index) { + // Get the local index + LocalIndex& local = index->local(); + local = maxLocal--; + } + +} +#endif diff -Nru dune-common-2.2.1/doc/doxygen/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/CMakeLists.txt --- dune-common-2.2.1/doc/doxygen/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,4 @@ +# create Doxyfile.in and Doxyfile +add_doxygen_target() + +install(FILES Doxystyle DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dune-common/doc/doxygen) diff -Nru dune-common-2.2.1/doc/doxygen/Doxylocal dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/Doxylocal --- dune-common-2.2.1/doc/doxygen/Doxylocal 2011-03-28 12:28:55.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/Doxylocal 2017-08-08 08:39:46.000000000 +0000 @@ -1,7 +1,8 @@ # Where to search and which files to use -INPUT += @srcdir@/mainpage \ - @srcdir@/modules \ - @top_srcdir@/dune/common/modules \ +INPUT += @srcdir@/mainpage.txt \ + @srcdir@/modules.txt \ + @top_srcdir@/dune/common/modules.txt \ @top_srcdir@/dune/common -EXCLUDE += @top_srcdir@/dune/common/test +EXCLUDE += @top_srcdir@/dune/common/test \ + @top_srcdir@/dune/common/debugallocator.cc diff -Nru dune-common-2.2.1/doc/doxygen/Doxystyle dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/Doxystyle --- dune-common-2.2.1/doc/doxygen/Doxystyle 2013-02-26 12:26:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/Doxystyle 2017-08-08 08:39:46.000000000 +0000 @@ -13,9 +13,9 @@ FILE_PATTERNS = *.hh \ *.cc INPUT = -EXCLUDE = +EXCLUDE = -EXCLUDE_PATTERNS = */.svn/* */test/* +EXCLUDE_PATTERNS = */test/* # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. @@ -54,11 +54,10 @@ FULL_PATH_NAMES = NO # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems +# (but less readable) file names. This can be useful if your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. -@DUNEWEB_TRUE@SHORT_NAMES = NO -@DUNEWEB_FALSE@SHORT_NAMES = YES +SHORT_NAMES = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should @@ -107,14 +106,12 @@ # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. -SHOW_DIRECTORIES = YES - -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 3 HTML_OUTPUT = html -SEARCHENGINE = NO +SEARCHENGINE = YES GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES @@ -154,31 +151,29 @@ CLASS_GRAPH = YES COLLABORATION_GRAPH = NO GROUP_GRAPHS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES +INCLUDE_GRAPH = NO +INCLUDED_BY_GRAPH = NO GRAPHICAL_HIERARCHY = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = NO DOT_CLEANUP = NO -#################################################################### -# Header Footer and Stylesheet in use is controled by the Makefile # -# (christi 16. Jan 2006) # -#################################################################### +##################################################################### +# Header Footer and Stylesheet in use is controlled by the Makefile # +# (christi 16. Jan 2006) # +##################################################################### -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a # standard header. -@DUNEWEB_TRUE@HTML_HEADER = doxy-header.html -@DUNEWEB_FALSE@HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -@DUNEWEB_TRUE@HTML_FOOTER = doxy-footer.html -@DUNEWEB_FALSE@HTML_FOOTER = +HTML_FOOTER = ########################## DOXYGEN DOXYSTYLE EXTRACT_ALL = YES @@ -189,7 +184,7 @@ EXTRACT_ANON_NSPACES = NO HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO +HIDE_FRIEND_COMPOUNDS = YES HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = NO @@ -205,10 +200,9 @@ GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = +ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 -SHOW_DIRECTORIES = YES SHOW_FILES = YES SHOW_NAMESPACES = YES -FILE_VERSION_FILTER = -LAYOUT_FILE = +FILE_VERSION_FILTER = +LAYOUT_FILE = diff -Nru dune-common-2.2.1/doc/doxygen/mainpage dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/mainpage --- dune-common-2.2.1/doc/doxygen/mainpage 2006-09-13 08:51:49.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/mainpage 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -/** \mainpage dune-common Automatic Documentation - -\section intro Introduction - -Welcome to the %Dune documentation pages. This documentation has been -generated using Doxygen, a free source code documentation system for -documenting C/C++ code. - -\section mods Modules - -The best way to start is from the page \subpage modules which gives -you access to the documentation by category. - -*/ - -/** \page modules Modules -*/ diff -Nru dune-common-2.2.1/doc/doxygen/mainpage.txt dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/mainpage.txt --- dune-common-2.2.1/doc/doxygen/mainpage.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/mainpage.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,17 @@ +/** \mainpage dune-common Automatic Documentation + +\section intro Introduction + +Welcome to the %Dune documentation pages. This documentation has been +generated using Doxygen, a free source code documentation system for +documenting C/C++ code. + +\section mods Modules + +The best way to start is from the page \subpage modules which gives +you access to the documentation by category. + +*/ + +/** \page modules Modules +*/ diff -Nru dune-common-2.2.1/doc/doxygen/Makefile.am dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/Makefile.am --- dune-common-2.2.1/doc/doxygen/Makefile.am 2011-02-28 11:41:46.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -# $Id: Makefile.am 6360 2011-02-28 11:41:46Z sander $ - -doxydir = $(pkgdatadir)/doc/doxygen - -doxy_DATA = \ - Doxystyle - -# setting like in dune-web -BASEDIR=../.. -CURDIR=doc/doxygen -PAGES = - -# add some more stuff to install and tarball -DOCFILES = $(PAGES) -EXTRA_DIST = $(PAGES) Doxystyle - -include $(top_srcdir)/am/doxygen -include $(top_srcdir)/am/global-rules diff -Nru dune-common-2.2.1/doc/doxygen/modules dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/modules --- dune-common-2.2.1/doc/doxygen/modules 2009-05-13 19:12:28.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/modules 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -/** - @defgroup Common Common (foundation classes) -*/ diff -Nru dune-common-2.2.1/doc/doxygen/modules.txt dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/modules.txt --- dune-common-2.2.1/doc/doxygen/modules.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/doxygen/modules.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,66 @@ +/** + @defgroup Common Common + @brief foundation classes +*/ + +/** + @defgroup Allocators Allocators + @brief Implementations of the STL allocator concept + @ingroup Common +*/ + +/** + @defgroup Utilities Utilities + @brief Collection of helper classes, type traits, etc. + @ingroup Common +*/ + +/** + @defgroup Path Filesystem Paths + @brief Utilities for filesystem path management + @ingroup Utilities +*/ + +/** + @defgroup RangeUtilities Range Utilities + @brief Utilities for reduction like operations on ranges + + All these reduction operations work for appropriate ranges and scalar values + + @ingroup Utilities +*/ + +/** + @defgroup StringUtilities String Utilities + @brief Utility functions for std::string + @ingroup Utilities +*/ + +/** + @defgroup TupleUtilities Tuple Utilities + @brief Utility classes which can be used with std::tuple + @ingroup Utilities +*/ + +/** + @defgroup TypeUtilities Type Utilities + @brief Type traits, overload helpers, and other utilities for type computations + @ingroup Utilities +*/ + +/** + @defgroup HybridUtilities Hybrid Utilities + @brief Hybrid utility functions that work on homogeneous as well as heterogeneous containers + @ingroup Utilities +*/ + +/** + @defgroup Numbers Numbers + @brief Class implementing different number representations and helper functions + @ingroup Common +*/ + +/** + @defgroup FloatCmp FloatCmp + @ingroup Numbers +*/ diff -Nru dune-common-2.2.1/doc/dunecontrol.1 dune-common-2.5.2~20170808ga5c076ca/doc/dunecontrol.1 --- dune-common-2.2.1/doc/dunecontrol.1 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/dunecontrol.1 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,169 @@ +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH DUNECONTROL 1 "November 8, 2016" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +dunecontrol \- Control program for the Dune build system +.SH SYNOPSIS +.B dunecontrol +[\fIOPTIONS\fP] \fICOMMANDS\fP [\fICOMMAND-OPTIONS\fP] +.SH DESCRIPTION +.B dunecontrol +is the control program for the build system of the Dune libraries. + +The Dune libraries form a set of modules. Each can be built independently using CMake. +Additionally, though, there are dependencies between modules, +which are expected to form a directed acyclic graph. These dependencies are set in a +file called +.B dune.module +contained in the main directory of each Dune module. + +The +.B dunecontrol +program helps to build sets of inter-dependent modules. It allows to construct +the entire dependency graph and obtain information about it. Then it allows to run various build-related +commands for all modules. These are executed in the order mandated by the dependency graph. + +.SH COMMANDS +Colon-separated list of commands. Available commands are: +.HP +.B help +.IP +Show a help message and exit +.HP +.B print +.IP +Print the list of modules sorted according to their dependency relations +.HP +.B info +.IP +Same as `print', but including whether it is a dependency or suggestion +.HP +.B printdeps +.IP +Print recursive dependencies of a module +.HP +.B vcsetup +.IP +Setup version control repository (Git etc.) or working copy (SVN) +.HP +.B update +.IP +Update all modules from the repository from their respective version control systems +.HP +.B configure +.IP +Run cmake for each module +.HP +.B make +.IP +Run make for each module +.HP +.B all +.IP +Run the 'configure' and 'make' commands for each module +.HP +.B exec +.IP +Execute an arbitrary command in each module source directory +.HP +.B bexec +.IP +Execute an arbitrary command in each module build directory +.HP +.B status +.IP +Show version control status for each module +.HP +.B svn +.IP +Run svn command for each svn-managed module +.HP +.B git +.IP +Run git command for each git-managed module +.HP +.B export +.IP +Run eval `dunecontrol export` to save the list of dune.module files to the DUNE_CONTROL_PATH variable +.SH OPTIONS +.HP +\fB\-h\fP, \fB\-\-help\fP +.IP +Show this help +.HP +\fB--debug\fP +.IP +Run with debugging output enabled +.HP +\fB--module=\fP\fImod\fP +.IP +Apply the actions on module +.I mod +and all modules it depends on +.HP +\fB--only=\fP\fImod\fP +.IP +Only apply the actions on module +.I mod +, but not on the modules it depends on +.HP +\fB--current\fP +.IP +Only apply the actions on the current module, the one whose source tree we are in +.HP +\fB--current-dep\fP +.IP +Apply the actions on the current module, and all modules it depends on +.HP +\fB--resume\fP +.IP +Resume a previous run (only consider the modules not built successfully on the previous run) +.HP +\fB--skipfirst\fP +.IP +Skip the first module (use with --resume) +.HP +\fB--opts=\fP\fIfile\fP +.IP +Load default options from \fIfile\fP +.HP +\fB--builddir=\fP\fIname\fP +.IP +Make out-of-source builds in a subdir \fIname\fP. This directory is created inside each module. +.HP +\fB--[COMMAND]-opts=\fP\fIopts\fP +.IP +Set options for COMMAND (this is mainly useful for the 'all' COMMAND) + + +.SH ENVIRONMENT VARIABLES +.B dunecontrol +looks for Dune modules in all directories given in the +.B DUNE_CONTROL_PATH +variable, and additionally recursively in all subdirectories of those directories. +The default for the case that DUNE_CONTROL_PATH is empty is the current directory, +plus a system-wide installation in /usr. + +.SH AUTHOR +Dune was written by the Dune team (www.dune-project.org/people). +.PP +This manual page was written by Oliver Sander. + +.SH COPYRIGHT +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without any warranty. diff -Nru dune-common-2.2.1/doc/example.opts dune-common-2.5.2~20170808ga5c076ca/doc/example.opts --- dune-common-2.2.1/doc/example.opts 2006-07-12 09:53:37.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/example.opts 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -# use these options for configure if no options a provided on the cmdline -AUTOGEN_FLAGS="--ac=2.50 --am=-1.8" -CONFIGURE_FLAGS="CXX=g++-3.4 --prefix='/tmp/Hu Hu'" -MAKE_FLAGS=install diff -Nru dune-common-2.2.1/doc/Makefile.am dune-common-2.5.2~20170808ga5c076ca/doc/Makefile.am --- dune-common-2.2.1/doc/Makefile.am 2011-03-29 21:03:14.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/doc/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -# $Id: Makefile.am 6409 2011-03-29 21:03:14Z sander $ - -# also build these sub directories -SUBDIRS = doxygen buildsystem - -# setting like in dune-web -CURDIR=doc -# position of the web base directory, -# relative to $(CURDIR) -BASEDIR=.. -EXTRAINSTALL=example.opts - -# install the html pages -docdir=$(datadir)/doc/dune-common -DOCFILES = $(PAGES) -DOCFILES_EXTRA = example.opts - -EXTRA_DIST = $(PAGES) example.opts - -# include rules for wml -> html transformation -include $(top_srcdir)/am/webstuff - -# include further rules needed by Dune -include $(top_srcdir)/am/global-rules diff -Nru dune-common-2.2.1/dune/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/dune/CMakeLists.txt --- dune-common-2.2.1/dune/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1 @@ +add_subdirectory("common") diff -Nru dune-common-2.2.1/dune/common/alignment.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/alignment.hh --- dune-common-2.2.1/dune/common/alignment.hh 2012-02-29 10:11:31.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/alignment.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,90 +1,26 @@ -// $Id: alignment.hh 6574 2012-02-29 10:11:31Z sander $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_ALIGNMENT_HH #define DUNE_ALIGNMENT_HH -#include -#if HAVE_TYPE_TRAITS -#include -#elif HAVE_TR1_TYPE_TRAITS -#include -#endif + +#warning The header dune/common/alignment.hh is deprecated. Use alignof(T) instead of Dune::AlignmentOf::value. + +#include namespace Dune { - + /** @addtogroup Common * * @{ */ /** - * @file + * @file * @brief This file implements a template class to determine alignment * requirements of types at compile time. * @author Markus Blatt */ - namespace - { - - /** - * @brief Helper class to measure alignment requirement. - * @tparam T The type we want to measure the alignment requirement for. - */ - template - struct AlignmentStruct - { - char c; - T t; - void hack(); - }; - - /** - * @brief Helper class to measure alignment requirement. - * @tparam T The type we want to measure the alignment requirement for. - */ - template - struct AlignmentHelper - { - enum { N2 = sizeof(AlignmentStruct) - sizeof(T) - N }; - char padding1[N]; - T t; - char padding2[N2]; - }; - -#define ALIGNMENT_MODULO(a, b) (a % b == 0 ? \ - static_cast(b) : \ - static_cast(a % b)) -#define ALIGNMENT_MIN(a, b) (static_cast(a) < \ - static_cast(b) ? \ - static_cast(a) : \ - static_cast(b)) - /** @brief does the actual calculations. */ - template - struct AlignmentTester - { - typedef AlignmentStruct s; - typedef AlignmentHelper h; - typedef AlignmentTester next; - enum - { - a1 = ALIGNMENT_MODULO(N , sizeof(T)), - a2 = ALIGNMENT_MODULO(h::N2 , sizeof(T)), - a3 = ALIGNMENT_MODULO(sizeof(h), sizeof(T)), - a = sizeof(h) == sizeof(s) ? ALIGNMENT_MIN(a1, a2) : a3, - result = ALIGNMENT_MIN(a, next::result) - }; - }; - - /** @brief does the actual calculations. */ - template - struct AlignmentTester - { - enum - { - result = ALIGNMENT_MODULO(sizeof(AlignmentStruct), sizeof(T)) - }; - }; - } //end anonymous namespace - /** * @brief Calculates the alignment requirement of a type. * @@ -96,20 +32,14 @@ template struct AlignmentOf { - + enum - { - /** @brief The alignment requirement. */ -#ifdef HAVE_TYPE_TRAITS - value = std::alignment_of::value -#elif HAVE_TR1_TYPETRAITS - value = std::tr1::alignment_of::value -#else - value = AlignmentTester) - sizeof(T) -1>::result -#endif - }; + { + /** @brief The alignment requirement. */ + value = std::alignment_of::value + }; }; - + /** @} */ } #endif diff -Nru dune-common-2.2.1/dune/common/array.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/array.hh --- dune-common-2.2.1/dune/common/array.hh 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/array.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,256 +1,40 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_ARRAY_HH #define DUNE_ARRAY_HH /** \file \brief Fallback implementation of the std::array class (a static array) -*/ + */ -#include -#include -#include - -// Include system implementation of array class if present -#ifdef HAVE_ARRAY #include -#else -#include -#endif -#include "deprecated.hh" +#include +#include -namespace Dune +namespace Dune { /** @addtogroup Common - @{ - */ - -#ifdef HAVE_ARRAY - using std::array; -#else - - /** \brief Simple fixed size array class. This replaces std::array, - * if that is not available. - * + @{ */ - template - class array { - public: - - //! Remember the storage type - typedef T value_type; - - /** \brief Reference to an object */ - typedef value_type& reference; - - /** \brief Const reference to an object */ - typedef const value_type& const_reference; - - /** \brief Iterator type */ - typedef value_type* iterator; - - /** \brief Const iterator type */ - typedef const value_type* const_iterator; - - /** \brief Type used for array indices */ - typedef std::size_t size_type; - - /** \brief Difference type */ - typedef std::ptrdiff_t difference_type; - - /** \brief Reverse iterator type */ - typedef std::reverse_iterator reverse_iterator; - - /** \brief Const reverse iterator type */ - typedef std::reverse_iterator const_reverse_iterator; - - /** \brief Return array size */ - size_type size() const {return N;} - - //! Assign value to all entries - array& operator= (const T& t) - { - fill(t); - return (*this); - } - - //! \brief Assign value to all entries (according to C++0x the fill method is to be prefered) - void assign(const T& t) DUNE_DEPRECATED - { - fill(t); - } - - //! \brief Assign value to all entries (according to C++0x the fill method is to be prefered) - void fill(const T& t) - { - for (size_type i=0; i 0) ? N : 1]; - }; - - - - // Comparison Operators (see [lib.container.requirements]) - // ------------------------------------------------------- - - template< class T, size_t N > - inline bool operator< ( const array< T, N > &a, const array< T, N > &b ) - { - return std::lexicographical_compare( a.begin(), a.end(), b.begin(), b.end() ); - } - - template< class T, size_t N > - inline bool operator> ( const array< T, N > &a, const array< T, N > &b ) - { - return b < a; - } - - template< class T, size_t N > - inline bool operator<= ( const array< T, N > &a, const array< T, N > &b ) - { - return !(a > b); - } - - template< class T, size_t N > - inline bool operator>= ( const array< T, N > &a, const array< T, N > &b ) - { - return !(a < b); - } -#endif - - //! Output operator for array - template < class T, size_t N > - inline std::ostream& operator<< (std::ostream& s, const array& e) - { - if (N == 0) - { - s << "[]"; - return s; - } - - s << "["; - for (size_t i=0; i - array make_array(const T &t0) { - array result = { t0 }; - return result; - } - - template - array make_array(const T &t0, const T &t1) { - array result = { t0, t1 }; - return result; - } - - template - array make_array(const T &t0, const T &t1, const T &t2) { - array result = { t0, t1, t2 }; - return result; - } - - template - array make_array(const T &t0, const T &t1, const T &t2, const T &t3) { - array result = { t0, t1, t2, t3 }; - return result; - } - - template - array make_array(const T &t0, const T &t1, const T &t2, const T &t3, - const T &t4) - { - array result = { t0, t1, t2, t3, t4 }; - return result; - } - - template - array make_array(const T &t0, const T &t1, const T &t2, const T &t3, - const T &t4, const T &t5) - { - array result = { t0, t1, t2, t3, t4, t5 }; - return result; - } - - template - array make_array(const T &t0, const T &t1, const T &t2, const T &t3, - const T &t4, const T &t5, const T &t6) - { - array result = { t0, t1, t2, t3, t4, t5, t6 }; - return result; - } - - template - array make_array(const T &t0, const T &t1, const T &t2, const T &t3, - const T &t4, const T &t5, const T &t6, const T &t7) - { - array result = { t0, t1, t2, t3, t4, t5, t6, t7 }; - return result; - } - - template - array make_array(const T &t0, const T &t1, const T &t2, const T &t3, - const T &t4, const T &t5, const T &t6, const T &t7, - const T &t8) - { - array result = { t0, t1, t2, t3, t4, t5, t6, t7, t8 }; - return result; - } -#endif // !DOXYGEN + using Dune::Std::make_array; - //! create an initialize an array + //! Create an array and fill it with copies of the provided value. /** - * \note There are overloads for this method which take fewer arguments - * (minimum 1). The current maximum of 10 arguments is arbitrary and - * can be raised on demand. - * \note This method is Dune-specific and not part of any C++-standard. + * \note This method is Dune-specific and not part of any C++ standard. */ - template - array make_array(const T &t0, const T &t1, const T &t2, const T &t3, - const T &t4, const T &t5, const T &t6, const T &t7, - const T &t8, const T &t9) + template + std::array fill_array(const T& t) { - array result = { t0, t1, t2, t3, t4, t5, t6, t7, t8, t9 }; - return result; + std::array r; + r.fill(t); + return r; } /** @} */ diff -Nru dune-common-2.2.1/dune/common/arraylist.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/arraylist.hh --- dune-common-2.2.1/dune/common/arraylist.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/arraylist.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,34 +1,35 @@ -// $Id: arraylist.hh 6785 2012-05-31 22:07:47Z sander $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: -#ifndef DUNE_ARRAYLIST_HH -#define DUNE_ARRAYLIST_HH +#ifndef DUNE_COMMON_ARRAYLIST_HH +#define DUNE_COMMON_ARRAYLIST_HH -#include -#include -#include"shared_ptr.hh" -#include"array.hh" -#include"iteratorfacades.hh" +#include +#include +#include +#include +#include "iteratorfacades.hh" namespace Dune { // forward declaration template class ArrayListIterator; - + template class ConstArrayListIterator; - + /** - * @file + * @file * \brief Implements a random-access container that can efficiently change size (similar to std::deque) - * + * * This file implements the class ArrayList which behaves like - * dynamically growing array together with + * dynamically growing array together with * the class ArrayListIterator which is random access iterator as needed * by the stl for sorting and other algorithms. * @author Markus Blatt */ - /** + /** * @addtogroup Common * * @{ @@ -37,39 +38,39 @@ /** * @brief A dynamically growing random access list. * - * Internally the data is organised in a list of arrays of fixed size. - * Whenever the capacity of the array list is not sufficient a new - * Dune::array is allocated. In contrast to + * Internally the data is organised in a list of arrays of fixed size. + * Whenever the capacity of the array list is not sufficient a new + * std::array is allocated. In contrast to * std::vector this approach prevents data copying. On the outside * we provide the same interface as the stl random access containers. * * While the concept sounds quite similar to std::deque there are slight * but crucial differences: - * - In contrast to std:deque the actual implementation (a list of arrays) - * is known. While - * for std::deque there are at least two possible implementations + * - In contrast to std:deque the actual implementation (a list of arrays) + * is known. While + * for std::deque there are at least two possible implementations * (dynamic array or using a double linked list. * - In contrast to std:deque there is not insert which invalidates iterators * but our push_back method leaves all iterators valid. - * - Additional functionality lets one delete entries before and at an + * - Additional functionality lets one delete entries before and at an * iterator while moving the iterator to the next valid position. */ template > class ArrayList { - public: + public: /** * @brief The member type that is stored. * * Has to be assignable and has to have an empty constructor. */ typedef T MemberType; - + /** * @brief Value type for stl compliance. */ typedef T value_type; - + /** * @brief The type of a reference to the type we store. */ @@ -79,31 +80,31 @@ * @brief The type of a const reference to the type we store. */ typedef const T& const_reference; - + /** * @brief The type of a pointer to the type we store. */ typedef T* pointer; - + /** * @brief The type of a const pointer to the type we store. */ typedef const T* const_pointer; - - enum - { - /** - * @brief The number of elements in one chunk of the list. - * This has to be at least one. The default is 100. - */ - chunkSize_ = (N > 0)? N : 1 - }; - + + enum + { + /** + * @brief The number of elements in one chunk of the list. + * This has to be at least one. The default is 100. + */ + chunkSize_ = (N > 0) ? N : 1 + }; + /** * @brief A random access iterator. */ typedef ArrayListIterator iterator; - + /** * @brief A constant random access iterator. */ @@ -113,63 +114,63 @@ * @brief The size type. */ typedef std::size_t size_type; - + /** * @brief The difference type. */ typedef std::ptrdiff_t difference_type; - + /** * @brief Get an iterator that is positioned at the first element. * @return The iterator. */ iterator begin(); - + /** - * @brief Get a random access iterator that is positioned at the + * @brief Get a random access iterator that is positioned at the * first element. * @return The iterator. */ const_iterator begin() const; - + /** - * @brief Get a random access iterator positioned after the last + * @brief Get a random access iterator positioned after the last * element */ iterator end(); - + /** - * @brief Get a random access iterator positioned after the last + * @brief Get a random access iterator positioned after the last * element */ const_iterator end() const; - + /** * @brief Append an entry to the list. * @param entry The new entry. */ inline void push_back(const_reference entry); - + /** * @brief Get the element at specific position. * @param i The index of the position. * @return The element at that position. */ inline reference operator[](size_type i); - + /** * @brief Get the element at specific position. * @param i The index of the position. * @return The element at that position. */ inline const_reference operator[](size_type i) const; - + /** * @brief Get the number of elements in the list. * @return The number of elements. */ inline size_type size() const; - + /** * @brief Purge the list. * @@ -178,7 +179,7 @@ * increases. */ inline void purge(); - + /** * @brief Delete all entries from the list. */ @@ -187,35 +188,35 @@ * @brief Constructs an Array list with one chunk. */ ArrayList(); - + private: - + /** * @brief The allocators for the smart pointer. */ - typedef typename A::template rebind > >::other + typedef typename A::template rebind > >::other SmartPointerAllocator; - + /** * @brief The allocator for the fixed array. */ - typedef typename A::template rebind >::other - ArrayAllocator; + typedef typename A::template rebind >::other + ArrayAllocator; /** * @brief The iterator needs access to the private variables. */ friend class ArrayListIterator; friend class ConstArrayListIterator; - + /** @brief the data chunks of our list. */ - std::vector >, - SmartPointerAllocator> chunks_; - /** @brief The current data capacity. + std::vector >, + SmartPointerAllocator> chunks_; + /** @brief The current data capacity. * This is the capacity that the list could have theoretically * with this number of chunks. That is chunks * chunkSize. * In practice some of the chunks at the beginning might be empty - * (i.e. null pointers in the first start_/chunkSize chunks) + * (i.e. null pointers in the first start_/chunkSize chunks) * because of previous calls to eraseToHere. * start_+size_<=capacity_ holds. */ @@ -233,7 +234,7 @@ * @return The element at that position. */ inline reference elementAt(size_type i); - + /** * @brief Get the element at specific position. * @@ -244,81 +245,81 @@ */ inline const_reference elementAt(size_type i) const; }; - + /** * @brief A random access iterator for the Dune::ArrayList class. */ template class ArrayListIterator : public RandomAccessIteratorFacade, - typename A::value_type, - typename A::reference, - typename A::difference_type> + typename A::value_type, + typename A::reference, + typename A::difference_type> { - + friend class ArrayList; friend class ConstArrayListIterator; - public: + public: /** * @brief The member type. */ typedef typename A::value_type MemberType; - + typedef typename A::difference_type difference_type; - + typedef typename A::size_type size_type; - + typedef typename A::reference reference; - + typedef typename A::const_reference const_reference; - - enum - { - /** - * @brief The number of elements in one chunk of the list. - * - * This has to be at least one. The default is 100. - */ - chunkSize_ = (N > 0)? N : 1 - }; - + + enum + { + /** + * @brief The number of elements in one chunk of the list. + * + * This has to be at least one. The default is 100. + */ + chunkSize_ = (N > 0) ? N : 1 + }; + /** * @brief Comares two iterators. - * @return True if the iterators are for the same list and + * @return True if the iterators are for the same list and * at the position. */ - inline bool equals(const ArrayListIterator& other)const; - + inline bool equals(const ArrayListIterator& other) const; + /** * @brief Comares two iterators. - * @return True if the iterators are for the same list and + * @return True if the iterators are for the same list and * at the position. */ - inline bool equals(const ConstArrayListIterator& other)const; - + inline bool equals(const ConstArrayListIterator& other) const; + /** * @brief Increment the iterator. */ inline void increment(); - + /** * @brief decrement the iterator. */ inline void decrement(); - + /** * @brief Get the value of the list at an arbitrary position. - * @return The value at that postion. + * @return The value at that position. */ - inline reference elementAt(size_type i)const; - + inline reference elementAt(size_type i) const; + /** * @brief Access the element at the current position. * @return The element at the current position. */ - inline reference dereference()const; - + inline reference dereference() const; + /** * @brief Erase all entries before the current position * and the one at the current position. @@ -330,20 +331,20 @@ * @return An iterator to the first position after the deleted * ones or to the end if the list is empty. */ - inline void eraseToHere(); - + inline void eraseToHere(); + /** \todo Please doc me! */ inline size_type position(){return position_;} - + /** \todo Please doc me! */ inline void advance(difference_type n); - - /** \todo Please doc me! */ - inline difference_type distanceTo(const ArrayListIterator& other)const; - - /** \todo Please doc me! */ + + /** \todo Please doc me! */ + inline difference_type distanceTo(const ArrayListIterator& other) const; + + /** \todo Please doc me! */ inline ArrayListIterator& operator=(const ArrayListIterator& other); - + //! Standard constructor inline ArrayListIterator() : position_(0) {} @@ -355,9 +356,9 @@ * @param position The initial position of the iterator. */ inline ArrayListIterator(ArrayList& arrayList, size_type position); - + /** - * @brief The current postion. + * @brief The current position. */ size_type position_; /** @@ -365,50 +366,50 @@ */ ArrayList* list_; }; - + /** * @brief A constant random access iterator for the Dune::ArrayList class. */ template class ConstArrayListIterator - : public RandomAccessIteratorFacade, - const typename A::value_type, - typename A::const_reference, - typename A::difference_type> + : public RandomAccessIteratorFacade, + const typename A::value_type, + typename A::const_reference, + typename A::difference_type> { friend class ArrayList; friend class ArrayListIterator; - - public: + + public: /** * @brief The member type. */ typedef typename A::value_type MemberType; typedef typename A::difference_type difference_type; - + typedef typename A::size_type size_type; - + typedef typename A::reference reference; - + typedef typename A::const_reference const_reference; - enum - { - /** - * @brief The number of elements in one chunk of the list. - * - * This has to be at least one. The default is 100. - */ - chunkSize_ = (N > 0)? N : 1 - }; + enum + { + /** + * @brief The number of elements in one chunk of the list. + * + * This has to be at least one. The default is 100. + */ + chunkSize_ = (N > 0) ? N : 1 + }; /** * @brief Comares to iterators. - * @return true if the iterators are for the same list and + * @return true if the iterators are for the same list and * at the position. */ - inline bool equals(const ConstArrayListIterator& other)const; + inline bool equals(const ConstArrayListIterator& other) const; /** * @brief Increment the iterator. @@ -419,27 +420,27 @@ * @brief decrement the iterator. */ inline void decrement(); - + /** \todo Please doc me! */ inline void advance(difference_type n); /** \todo Please doc me! */ - inline difference_type distanceTo(const ConstArrayListIterator& other)const; + inline difference_type distanceTo(const ConstArrayListIterator& other) const; /** * @brief Get the value of the list at an arbitrary position. - * @return The value at that postion. + * @return The value at that position. */ - inline const_reference elementAt(size_type i)const; + inline const_reference elementAt(size_type i) const; /** * @brief Access the element at the current position. * @return The element at the current position. */ - inline const_reference dereference()const; + inline const_reference dereference() const; inline const ConstArrayListIterator& operator=(const ConstArrayListIterator& other); - + inline ConstArrayListIterator() : position_(0) {} @@ -455,7 +456,7 @@ inline ConstArrayListIterator(const ArrayList& arrayList, size_type position); /** - * @brief The current postion. + * @brief The current position. */ size_type position_; /** @@ -464,9 +465,9 @@ const ArrayList* list_; }; - + template - ArrayList::ArrayList() + ArrayList::ArrayList() : capacity_(0), size_(0), start_(0) { chunks_.reserve(100); @@ -491,10 +492,10 @@ { size_t index=start_+size_; if(index==capacity_) - { - chunks_.push_back(shared_ptr >(new array())); - capacity_ += chunkSize_; - } + { + chunks_.push_back(std::make_shared >()); + capacity_ += chunkSize_; + } elementAt(index)=entry; ++size_; } @@ -536,7 +537,7 @@ { return ConstArrayListIterator(*this, start_); } - + template ArrayListIterator ArrayList::end() { @@ -554,16 +555,13 @@ { // Distance to copy to the left. size_t distance = start_/chunkSize_; - if(distance>0){ + if(distance>0) { // Number of chunks with entries in it; size_t chunks = ((start_%chunkSize_ + size_)/chunkSize_ ); - - typedef typename std::vector > >::iterator iterator; // Copy chunks to the left. - std::copy(chunks_.begin()+distance, - chunks_.begin()+(distance+chunks), chunks_.begin()); + std::copy(chunks_.begin()+distance, + chunks_.begin()+(distance+chunks), chunks_.begin()); // Calculate new parameters start_ = start_ % chunkSize_; @@ -585,7 +583,7 @@ template - bool ArrayListIterator::equals(const ArrayListIterator& other)const + bool ArrayListIterator::equals(const ArrayListIterator& other) const { // Makes only sense if we reference a common list assert(list_==(other.list_)); @@ -594,7 +592,7 @@ template - bool ArrayListIterator::equals(const ConstArrayListIterator& other)const + bool ArrayListIterator::equals(const ConstArrayListIterator& other) const { // Makes only sense if we reference a common list assert(list_==(other.list_)); @@ -603,7 +601,7 @@ template - bool ConstArrayListIterator::equals(const ConstArrayListIterator& other)const + bool ConstArrayListIterator::equals(const ConstArrayListIterator& other) const { // Makes only sense if we reference a common list assert(list_==(other.list_)); @@ -615,7 +613,7 @@ { ++position_; } - + template void ConstArrayListIterator::increment() { @@ -623,41 +621,41 @@ } template - void ArrayListIterator::decrement() + void ArrayListIterator::decrement() { --position_; } template - void ConstArrayListIterator::decrement() + void ConstArrayListIterator::decrement() { --position_; } template - typename ArrayListIterator::reference ArrayListIterator::elementAt(size_type i) const + typename ArrayListIterator::reference ArrayListIterator::elementAt(size_type i) const { return list_->elementAt(i+position_); } template - typename ConstArrayListIterator::const_reference ConstArrayListIterator::elementAt(size_type i) const + typename ConstArrayListIterator::const_reference ConstArrayListIterator::elementAt(size_type i) const { return list_->elementAt(i+position_); } - + template typename ArrayListIterator::reference ArrayListIterator::dereference() const { return list_->elementAt(position_); } - + template typename ConstArrayListIterator::const_reference ConstArrayListIterator::dereference() const { return list_->elementAt(position_); } - + template typename ArrayListIterator::difference_type ArrayListIterator::distanceTo(const ArrayListIterator& other) const { @@ -698,13 +696,13 @@ size_t posChunkStart = position_ / chunkSize_; // number of chunks to deallocate size_t chunks = (position_ - list_->start_ + list_->start_ % chunkSize_) - / chunkSize_; + / chunkSize_; list_->start_ = position_; - + // Deallocate memory not needed any more. - for(size_t chunk=0; chunkchunks_[posChunkStart].reset(); + for(size_t chunk=0; chunkchunks_[posChunkStart].reset(); } // Capacity stays the same as the chunks before us @@ -713,14 +711,14 @@ } template - ArrayListIterator::ArrayListIterator(ArrayList& arrayList, size_type position) + ArrayListIterator::ArrayListIterator(ArrayList& arrayList, size_type position) : position_(position), list_(&arrayList) {} - + template - ConstArrayListIterator::ConstArrayListIterator(const ArrayList& arrayList, - size_type position) + ConstArrayListIterator::ConstArrayListIterator(const ArrayList& arrayList, + size_type position) : position_(position), list_(&arrayList) {} @@ -729,7 +727,7 @@ : position_(other.position_), list_(other.list_) {} - + /** @} */ } #endif diff -Nru dune-common-2.2.1/dune/common/bartonnackmanifcheck.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/bartonnackmanifcheck.hh --- dune-common-2.2.1/dune/common/bartonnackmanifcheck.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/bartonnackmanifcheck.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,14 +1,25 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: /** @file - @author Robert Kloefkorn - @brief Provides check for implementation of interface methods when using - static polymorphism, i.e. the Barton-Nackman trick. - - Use by invoking CHECK_INTERFACE_IMPLEMENTATION(asImp().methodToCheck()) - and for template methods double ( - CHECK_INTERFACE_IMPLEMENTATION((asImp().template methodToCheck ())). -**/ + @author Robert Kloefkorn + @brief Provides check for implementation of interface methods when using + static polymorphism, i.e. the Barton-Nackman trick. This is purely for + debugging purposes. To check the correct implementation of interface methods + (and pick up possible infinite loops) NDEBUG must be undefined and + DUNE_INTERFACECHECK has to be defined. -//- Dune includes + Use by invoking CHECK_INTERFACE_IMPLEMENTATION(asImp().methodToCheck()) + and for + template methods double (CHECK_INTERFACE_IMPLEMENTATION((asImp().template methodToCheck ())). + If either NDEBUG is defined or + DUNE_INTERFACECHECK is undefined the CHECK_INTERFACE_IMPLEMENTATION macro is empty. + + Note: adding the interface check to a method will cause the implementation of the + method to be called twice, so before use make sure + that this will not cause problems e.g. if internal counters are updated. + **/ + +//- Dune includes #include #ifdef CHECK_INTERFACE_IMPLEMENTATION @@ -18,8 +29,8 @@ #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION #endif -#ifdef NDEBUG -#define CHECK_INTERFACE_IMPLEMENTATION(dummy) +#if defined NDEBUG || !defined DUNE_INTERFACECHECK +#define CHECK_INTERFACE_IMPLEMENTATION(dummy) #else #define CHECK_INTERFACE_IMPLEMENTATION(__interface_method_to_call__) \ {\ @@ -40,11 +51,11 @@ #endif /** The macro CHECK_AND_CALL_INTERFACE_IMPLEMENTATION throws an exception, - if the interface method ist not implemented and just calls the method - otherwise. If NDEBUG is defined no - checking is done and the method is just called. -*/ -#ifdef NDEBUG + if the interface method ist not implemented and just calls the method + otherwise. If NDEBUG is defined no + checking is done and the method is just called. + */ +#if defined NDEBUG || !defined DUNE_INTERFACECHECK #define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__) \ (__interface_method_to_call__) #else diff -Nru dune-common-2.2.1/dune/common/bigunsignedint.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/bigunsignedint.hh --- dune-common-2.2.1/dune/common/bigunsignedint.hh 2010-11-29 23:40:59.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/bigunsignedint.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,33 +1,64 @@ -// $Id: bigunsignedint.hh 6280 2010-11-29 23:40:59Z dedner $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_BIGUNSIGNEDINT_HH #define DUNE_BIGUNSIGNEDINT_HH -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /** - * @file - * @brief Portable very large unsigned integers + * @file + * @brief Portable very large unsigned integers * @author Peter Bastian */ namespace Dune { - /** @addtogroup Common - * - * @{ - */ - #if HAVE_MPI template struct MPITraits; #endif + /** @addtogroup Numbers + * + * @{ + */ + + namespace { + + // numeric_limits_helper provides std::numeric_limits access to the internals + // of bigunsignedint. Previously, the correct specialization of std::numeric_limits + // was a friend of bigunsignedint, but that creates problems on recent versions + // of clang with the alternative libc++ library, because that library declares the + // base template of std::numeric_limits as a class and clang subsequently complains + // if the friend declaration uses 'struct'. Unfortunately, libstdc++ uses a struct, + // making it impossible to keep clang happy for both standard libraries. + // So we move the access helper functionality into a custom struct and simply let + // the numeric_limits specialization inherit from the helper. + + template + struct numeric_limits_helper + { + + protected: + + static std::uint16_t& digit(T& big_unsigned_int, std::size_t i) + { + return big_unsigned_int.digit[i]; + } + + }; + + } + /** - * @brief Portable very large unsigned integers + * @brief Portable very large unsigned integers * * Implements (arbitrarily) large unsigned integers to be used as global * ids in some grid managers. Size is a template parameter. @@ -39,88 +70,89 @@ class bigunsignedint { public: - // unsigned short is 16 bits wide, n is the number of digits needed - enum { bits=std::numeric_limits::digits, n=k/bits+(k%bits!=0), - hexdigits=4, bitmask=0xFFFF, compbitmask=0xFFFF0000, - overflowmask=0x1 }; + // unsigned short is 16 bits wide, n is the number of digits needed + enum { bits=std::numeric_limits::digits, n=k/bits+(k%bits!=0), + hexdigits=4, bitmask=0xFFFF, compbitmask=0xFFFF0000, + overflowmask=0x1 }; - //! Construct uninitialized - bigunsignedint (); + //! Construct uninitialized + bigunsignedint (); - //! Construct from signed int - bigunsignedint (int x); + //! Construct from signed int + template + bigunsignedint (Signed x, typename std::enable_if::value && std::is_signed::value>::type* = 0); - //! Construct from unsigned int - bigunsignedint (std::size_t x); + //! Construct from unsigned int + bigunsignedint (std::uintmax_t x); - //! Print number in hex notation - void print (std::ostream& s) const ; + //! Print number in hex notation + void print (std::ostream& s) const ; - //! add - bigunsignedint operator+ (const bigunsignedint& x) const; + //! add + bigunsignedint operator+ (const bigunsignedint& x) const; - //! subtract - bigunsignedint operator- (const bigunsignedint& x) const; + //! subtract + bigunsignedint operator- (const bigunsignedint& x) const; - //! multiply - bigunsignedint operator* (const bigunsignedint& x) const; + //! multiply + bigunsignedint operator* (const bigunsignedint& x) const; - //! prefix increment - bigunsignedint& operator++ (); + //! prefix increment + bigunsignedint& operator++ (); - //! divide - //! \warning This function is very slow and its usage should be - //! prevented if possible - bigunsignedint operator/ (const bigunsignedint& x) const; + //! divide + //! \warning This function is very slow and its usage should be + //! prevented if possible + bigunsignedint operator/ (const bigunsignedint& x) const; - //! modulo - //! \warning This function is very slow and its usage should be - //! prevented if possible - bigunsignedint operator% (const bigunsignedint& x) const; + //! modulo + //! \warning This function is very slow and its usage should be + //! prevented if possible + bigunsignedint operator% (const bigunsignedint& x) const; - //! bitwise and - bigunsignedint operator& (const bigunsignedint& x) const; + //! bitwise and + bigunsignedint operator& (const bigunsignedint& x) const; - //! bitwise exor - bigunsignedint operator^ (const bigunsignedint& x) const; + //! bitwise exor + bigunsignedint operator^ (const bigunsignedint& x) const; - //! bitwise or - bigunsignedint operator| (const bigunsignedint& x) const; + //! bitwise or + bigunsignedint operator| (const bigunsignedint& x) const; - //! bitwise komplement - bigunsignedint operator~ () const; + //! bitwise complement + bigunsignedint operator~ () const; - //! left shift1/ - bigunsignedint operator<< (int i) const; + //! left shift + bigunsignedint operator<< (int i) const; - //! right shift - bigunsignedint operator>> (int i) const; + //! right shift + bigunsignedint operator>> (int i) const; - //! less than - bool operator< (const bigunsignedint& x) const; + //! less than + bool operator< (const bigunsignedint& x) const; - //! less than or equal - bool operator<= (const bigunsignedint& x) const; + //! less than or equal + bool operator<= (const bigunsignedint& x) const; - //! greater than - bool operator> (const bigunsignedint& x) const; + //! greater than + bool operator> (const bigunsignedint& x) const; - //! greater or equal - bool operator>= (const bigunsignedint& x) const; + //! greater or equal + bool operator>= (const bigunsignedint& x) const; - //! equal - bool operator== (const bigunsignedint& x) const; + //! equal + bool operator== (const bigunsignedint& x) const; - //! not equal - bool operator!= (const bigunsignedint& x) const; + //! not equal + bool operator!= (const bigunsignedint& x) const; - //! export to other types -// operator unsigned int () const; - unsigned int touint() const; + //! export to other types + // operator unsigned int () const; + std::uint_least32_t touint() const; /** * @brief Convert to a double. * @@ -128,56 +160,63 @@ */ double todouble() const; - friend class bigunsignedint; - friend struct std::numeric_limits< bigunsignedint >; - + friend class bigunsignedint; + friend struct numeric_limits_helper< bigunsignedint >; + + inline friend std::size_t hash_value(const bigunsignedint& arg) + { + return hash_range(arg.digit,arg.digit + arg.n); + } + private: - unsigned short digit[n]; + std::uint16_t digit[n]; #if HAVE_MPI - friend class MPITraits >; + friend struct MPITraits >; #endif - inline void assign(std::size_t x); - - + inline void assign(std::uintmax_t x); + + } ; // Constructors template bigunsignedint::bigunsignedint () - { + { assign(0u); } template - bigunsignedint::bigunsignedint (int y) + template + bigunsignedint::bigunsignedint (Signed y, typename std::enable_if::value && std::is_signed::value>::type*) { - std::size_t x = std::abs(y); - assign(x); + if (y < 0) + DUNE_THROW(Dune::Exception, "Trying to construct a Dune::bigunsignedint from a negative integer: " << y); + assign(y); } template - bigunsignedint::bigunsignedint (std::size_t x) + bigunsignedint::bigunsignedint (std::uintmax_t x) { assign(x); } template - void bigunsignedint::assign(std::size_t x) + void bigunsignedint::assign(std::uintmax_t x) { - int no=std::min(static_cast(n), - static_cast(std::numeric_limits::digits/bits)); - - for(int i=0; i>bits; + static const int no=std::min(static_cast(n), + static_cast(std::numeric_limits::digits/bits)); + + for(int i=0; i>bits; } for (unsigned int i=no; i - inline unsigned int bigunsignedint::touint () const + inline std::uint_least32_t bigunsignedint::touint () const { - return (digit[1]< @@ -186,9 +225,9 @@ int firstInZeroRange=n; for(int i=n-1; i>=0; --i) if(digit[i]!=0) - break; + break; else - --firstInZeroRange; + --firstInZeroRange; int representableDigits=std::numeric_limits::digits/bits; int lastInRepresentableRange=0; if(representableDigits inline void bigunsignedint::print (std::ostream& s) const - { - bool leading=false; + { + bool leading=false; - // print from left to right - for (int i=n-1; i>=0; i--) - for (int d=hexdigits-1; d>=0; d--) - { - // extract one hex digit - int current = (digit[i]>>(d*4))&0xF; - if (current!=0) - { - // s.setf(std::ios::noshowbase); - s << std::hex << current; - leading = false; - } - else if (!leading) s << std::hex << current; - } - if (leading) s << "0"; - s << std::dec; + // print from left to right + for (int i=n-1; i>=0; i--) + for (int d=hexdigits-1; d>=0; d--) + { + // extract one hex digit + int current = (digit[i]>>(d*4))&0xF; + if (current!=0) + { + // s.setf(std::ios::noshowbase); + s << std::hex << current; + leading = false; + } + else if (!leading) s << std::hex << current; + } + if (leading) s << "0"; + s << std::dec; } template inline std::ostream& operator<< (std::ostream& s, const bigunsignedint& x) { - x.print(s); - return s; + x.print(s); + return s; } @@ -234,73 +273,76 @@ template inline bigunsignedint bigunsignedint::operator+ (const bigunsignedint& x) const { - bigunsignedint result; - int overflow=0; + bigunsignedint result; + std::uint_fast32_t overflow=0; - for (unsigned int i=0; i>bits)&overflowmask; - } - return result; + for (unsigned int i=0; i(digit[i]) + static_cast(x.digit[i]) + overflow; + result.digit[i] = sum&bitmask; + overflow = (sum>>bits)&overflowmask; + } + return result; } template inline bigunsignedint bigunsignedint::operator- (const bigunsignedint& x) const { - bigunsignedint result; - int overflow=0; + bigunsignedint result; + std::int_fast32_t overflow=0; - for (unsigned int i=0; i=0) - result.digit[i] = (unsigned short) diff; - else - { - result.digit[i] = (unsigned short) (diff+bitmask); - overflow = 1; - } - } - return result; + for (unsigned int i=0; i(digit[i]) - static_cast(x.digit[i]) - overflow; + if (diff>=0) + { + result.digit[i] = static_cast(diff); + overflow = 0; + } + else + { + result.digit[i] = static_cast(diff+bitmask+1); + overflow = 1; + } + } + return result; } template inline bigunsignedint bigunsignedint::operator* (const bigunsignedint& x) const { - bigunsignedint<2*k> finalproduct(0); + bigunsignedint<2*k> finalproduct(0); + + for (unsigned int m=0; m singleproduct(0); + std::uint_fast32_t overflow(0); + for (unsigned int i=0; i(digit[i])*static_cast(x.digit[m])+overflow; + singleproduct.digit[i+m] = static_cast(digitproduct&bitmask); + overflow = (digitproduct>>bits)&bitmask; + } + finalproduct = finalproduct+singleproduct; + } - for (unsigned int m=0; m singleproduct(0); - unsigned int overflow(0); - for (unsigned int i=0; i>bits)&bitmask; - } - finalproduct = finalproduct+singleproduct; - } - - bigunsignedint result; - for (unsigned int i=0; i result; + for (unsigned int i=0; i - inline bigunsignedint& bigunsignedint::operator++ () - { - int overflow=1; - - for (unsigned int i=0; i>bits)&overflowmask; - } - return *this; + inline bigunsignedint& bigunsignedint::operator++ () + { + std::uint_fast32_t overflow=1; + + for (unsigned int i=0; i(digit[i]) + overflow; + digit[i] = sum&bitmask; + overflow = (sum>>bits)&overflowmask; + } + return *this; } template @@ -309,234 +351,232 @@ if(x==0) DUNE_THROW(Dune::MathError, "division by zero!"); - // better slow than nothing - bigunsignedint temp(*this); - bigunsignedint result(0); - - while (temp>=x) - { - ++result; - temp = temp-x; - } + // better slow than nothing + bigunsignedint temp(*this); + bigunsignedint result(0); + + while (temp>=x) + { + ++result; + temp = temp-x; + } - return result; + return result; } template inline bigunsignedint bigunsignedint::operator% (const bigunsignedint& x) const { - // better slow than nothing - bigunsignedint temp(*this); - bigunsignedint result(0); - - while (temp>=x) - { - ++result; - temp = temp-x; - } + // better slow than nothing + bigunsignedint temp(*this); - return temp; + while (temp>=x) + { + temp = temp-x; + } + + return temp; } template inline bigunsignedint bigunsignedint::operator& (const bigunsignedint& x) const { - bigunsignedint result; - for (unsigned int i=0; i result; + for (unsigned int i=0; i inline bigunsignedint bigunsignedint::operator^ (const bigunsignedint& x) const { - bigunsignedint result; - for (unsigned int i=0; i result; + for (unsigned int i=0; i inline bigunsignedint bigunsignedint::operator| (const bigunsignedint& x) const { - bigunsignedint result; - for (unsigned int i=0; i result; + for (unsigned int i=0; i inline bigunsignedint bigunsignedint::operator~ () const { - bigunsignedint result; - for (unsigned int i=0; i result; + for (unsigned int i=0; i inline bigunsignedint bigunsignedint::operator<< (int shift) const { - bigunsignedint result(0); + bigunsignedint result(0); - // multiples of bits - int j=shift/bits; - for (int i=n-1-j; i>=0; i--) - result.digit[i+j] = digit[i]; - - // remainder - j=shift%bits; - for (int i=n-1; i>=0; i--) - { - unsigned int temp = result.digit[i]; - temp = temp<>bits; - if (i+1<(int)n) - result.digit[i+1] = result.digit[i+1]|temp; - } + // multiples of bits + int j=shift/bits; + for (int i=n-1-j; i>=0; i--) + result.digit[i+j] = digit[i]; + + // remainder + j=shift%bits; + for (int i=n-1; i>=0; i--) + { + unsigned int temp = result.digit[i]; + temp = temp<(temp&bitmask); + temp = temp>>bits; + if (i+1<(int)n) + result.digit[i+1] = result.digit[i+1]|temp; + } - return result; + return result; } template inline bigunsignedint bigunsignedint::operator>> (int shift) const { - bigunsignedint result(0); + bigunsignedint result(0); - // multiples of bits - int j=shift/bits; - for (unsigned int i=0; i>bits); - if (i>0) - result.digit[i-1] = result.digit[i-1] | (temp&bitmask); - } + // multiples of bits + int j=shift/bits; + for (unsigned int i=0; i((temp&compbitmask)>>bits); + if (i>0) + result.digit[i-1] = result.digit[i-1] | (temp&bitmask); + } - return result; + return result; } template inline bool bigunsignedint::operator!= (const bigunsignedint& x) const { - for (unsigned int i=0; i inline bool bigunsignedint::operator== (const bigunsignedint& x) const { - return !((*this)!=x); + return !((*this)!=x); } template inline bool bigunsignedint::operator< (const bigunsignedint& x) const { - for (int i=n-1; i>=0; i--) - if (digit[i]x.digit[i]) return false; - return false; + for (int i=n-1; i>=0; i--) + if (digit[i]x.digit[i]) return false; + return false; } template inline bool bigunsignedint::operator<= (const bigunsignedint& x) const { - for (int i=n-1; i>=0; i--) - if (digit[i]x.digit[i]) return false; - return true; + for (int i=n-1; i>=0; i--) + if (digit[i]x.digit[i]) return false; + return true; } template inline bool bigunsignedint::operator> (const bigunsignedint& x) const { - return !((*this)<=x); + return !((*this)<=x); } template inline bool bigunsignedint::operator>= (const bigunsignedint& x) const { - return !((*this) - inline bigunsignedint operator+ (const bigunsignedint& x, std::size_t y) + inline bigunsignedint operator+ (const bigunsignedint& x, std::uintmax_t y) { - bigunsignedint temp(y); - return x+temp; + bigunsignedint temp(y); + return x+temp; } template - inline bigunsignedint operator- (const bigunsignedint& x, std::size_t y) + inline bigunsignedint operator- (const bigunsignedint& x, std::uintmax_t y) { - bigunsignedint temp(y); - return x-temp; + bigunsignedint temp(y); + return x-temp; } template - inline bigunsignedint operator* (const bigunsignedint& x, std::size_t y) + inline bigunsignedint operator* (const bigunsignedint& x, std::uintmax_t y) { - bigunsignedint temp(y); - return x*temp; + bigunsignedint temp(y); + return x*temp; } template - inline bigunsignedint operator/ (const bigunsignedint& x, std::size_t y) + inline bigunsignedint operator/ (const bigunsignedint& x, std::uintmax_t y) { - bigunsignedint temp(y); - return x/temp; + bigunsignedint temp(y); + return x/temp; } template - inline bigunsignedint operator% (const bigunsignedint& x, std::size_t y) + inline bigunsignedint operator% (const bigunsignedint& x, std::uintmax_t y) { - bigunsignedint temp(y); - return x%temp; + bigunsignedint temp(y); + return x%temp; } template - inline bigunsignedint operator+ (std::size_t x, const bigunsignedint& y) + inline bigunsignedint operator+ (std::uintmax_t x, const bigunsignedint& y) { - bigunsignedint temp(x); - return temp+y; + bigunsignedint temp(x); + return temp+y; } template - inline bigunsignedint operator- (std::size_t x, const bigunsignedint& y) + inline bigunsignedint operator- (std::uintmax_t x, const bigunsignedint& y) { - bigunsignedint temp(x); - return temp-y; + bigunsignedint temp(x); + return temp-y; } template - inline bigunsignedint operator* (std::size_t x, const bigunsignedint& y) + inline bigunsignedint operator* (std::uintmax_t x, const bigunsignedint& y) { - bigunsignedint temp(x); - return temp*y; + bigunsignedint temp(x); + return temp*y; } template - inline bigunsignedint operator/ (std::size_t x, const bigunsignedint& y) + inline bigunsignedint operator/ (std::uintmax_t x, const bigunsignedint& y) { - bigunsignedint temp(x); - return temp/y; + bigunsignedint temp(x); + return temp/y; } template - inline bigunsignedint operator% (std::size_t x, const bigunsignedint& y) + inline bigunsignedint operator% (std::uintmax_t x, const bigunsignedint& y) { - bigunsignedint temp(x); - return temp%y; + bigunsignedint temp(x); + return temp%y; } @@ -547,10 +587,11 @@ { template struct numeric_limits > + : private Dune::numeric_limits_helper > // for access to internal state of bigunsignedint { public: static const bool is_specialized = true; - + static Dune::bigunsignedint min() { return static_cast >(0); @@ -560,18 +601,20 @@ { Dune::bigunsignedint max_; for(std::size_t i=0; i < Dune::bigunsignedint::n; ++i) - max_.digit[i]=std::numeric_limits::max(); + // access internal state via the helper base class + Dune::numeric_limits_helper >:: + digit(max_,i)=std::numeric_limits::max(); return max_; } - - + + static const int digits = Dune::bigunsignedint::bits * - Dune::bigunsignedint::n; + Dune::bigunsignedint::n; static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; static const int radix = 2; - + static Dune::bigunsignedint epsilon() { return static_cast >(0); @@ -581,37 +624,37 @@ { return static_cast >(0); } - + static const int min_exponent = 0; static const int min_exponent10 = 0; static const int max_exponent = 0; static const int max_exponent10 = 0; - + static const bool has_infinity = false; static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - + static const bool has_signaling_NaN = false; + static const float_denorm_style has_denorm = denorm_absent; static const bool has_denorm_loss = false; static Dune::bigunsignedint infinity() throw() - { - return static_cast >(0); + { + return static_cast >(0); } static Dune::bigunsignedint quiet_NaN() throw() - { - return static_cast >(0); + { + return static_cast >(0); } static Dune::bigunsignedint signaling_NaN() throw() - { - return static_cast >(0); + { + return static_cast >(0); } static Dune::bigunsignedint denorm_min() throw() - { - return static_cast >(0); + { + return static_cast >(0); } static const bool is_iec559 = false; @@ -623,7 +666,9 @@ static const float_round_style round_style = round_toward_zero; }; - + } +DUNE_DEFINE_HASH(DUNE_HASH_TEMPLATE_ARGS(int k),DUNE_HASH_TYPE(Dune::bigunsignedint)) + #endif diff -Nru dune-common-2.2.1/dune/common/binaryfunctions.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/binaryfunctions.hh --- dune-common-2.2.1/dune/common/binaryfunctions.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/binaryfunctions.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_BINARYFUNCTIONS_HH #define DUNE_BINARYFUNCTIONS_HH @@ -5,8 +7,8 @@ * \brief Various helper classes derived from from std::binary_function for * stl-style functional programming */ -#include -#include +#include +#include namespace Dune { @@ -19,7 +21,7 @@ return std::min(t1,t2); } }; - + template struct Max : std::binary_function diff -Nru dune-common-2.2.1/dune/common/bitsetvector.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/bitsetvector.hh --- dune-common-2.2.1/dune/common/bitsetvector.hh 2010-05-06 10:04:18.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/bitsetvector.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,602 +1,619 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_BLOCK_BITFIELD_HH #define DUNE_BLOCK_BITFIELD_HH /** \file \brief Efficient implementation of a dynamic array of static arrays of booleans -*/ + */ #include #include #include #include +#include #include #include namespace Dune { - template class BitSetVector; - template class BitSetVectorReference; + template class BitSetVector; + template class BitSetVectorReference; - /** - \brief A proxy class that acts as a const reference to a single - bitset in a BitSetVector. + /** + \brief A proxy class that acts as a const reference to a single + bitset in a BitSetVector. + + It contains a conversion to std::bitset and most of the + interface of const std::bitset. + + \warning As this is only a proxy class, you can not get the + address of the bitset. + */ + template + class BitSetVectorConstReference + { + protected: + + typedef Dune::BitSetVector BitSetVector; + friend class Dune::BitSetVector; + + BitSetVectorConstReference(const BitSetVector& blockBitField_, int block_number_) : + blockBitField(blockBitField_), + block_number(block_number_) + { + DUNE_ASSERT_BOUNDS(blockBitField_.size() > block_number_); + } - It contains a conversion to std::bitset and most of the - interface of const std::bitset. + //! hide assignment operator + BitSetVectorConstReference& operator=(const BitSetVectorConstReference & b); - \warning As this is only a proxy class, you can not get the - address of the bitset. - */ - template - class BitSetVectorConstReference + public: + + typedef std::bitset bitset; + + // bitset interface typedefs + typedef typename std::vector::const_reference reference; + typedef typename std::vector::const_reference const_reference; + typedef size_t size_type; + + //! Returns a copy of *this shifted left by n bits. + bitset operator<<(size_type n) const { - protected: + bitset b = *this; + b <<= n; + return b; + } - typedef Dune::BitSetVector BitSetVector; - friend class Dune::BitSetVector; - - BitSetVectorConstReference(const BitSetVector& blockBitField, int block_number) : - blockBitField(blockBitField), - block_number(block_number) - {}; - - //! hide assignment operator - BitSetVectorConstReference& operator=(const BitSetVectorConstReference & b); - - public: - - typedef std::bitset bitset; - - // bitset interface typedefs - typedef typename std::vector::const_reference reference; - typedef typename std::vector::const_reference const_reference; - typedef size_t size_type; - - //! Returns a copy of *this shifted left by n bits. - bitset operator<<(size_type n) const - { - bitset b = *this; - b <<= n; - return b; - } - - //! Returns a copy of *this shifted right by n bits. - bitset operator>>(size_type n) const - { - bitset b = *this; - b >>= n; - return b; - } - - //! Returns a copy of *this with all of its bits flipped. - bitset operator~() const - { - bitset b = *this; - b.flip(); - return b; - } - - //! Returns block_size. - size_type size() const - { - return block_size; - } - - //! Returns the number of bits that are set. - size_type count() const - { - size_type n = 0; - for(size_type i=0; i - bool equals(const BS & bs) const - { - bool eq = true; - for(int i=0; i>(size_type n) const + { + bitset b = *this; + b >>= n; + return b; + } - friend class BitSetVectorReference; - }; + //! Returns a copy of *this with all of its bits flipped. + bitset operator~() const + { + bitset b = *this; + b.flip(); + return b; + } - /** - \brief A proxy class that acts as a mutable reference to a - single bitset in a BitSetVector. + //! Returns block_size. + size_type size() const + { + return block_size; + } + + //! Returns the number of bits that are set. + size_type count() const + { + size_type n = 0; + for(size_type i=0; i - class BitSetVectorReference : public BitSetVectorConstReference + + friend std::ostream& operator<< (std::ostream& s, const BitSetVectorConstReference& v) { - protected: + s << "("; + for(int i=0; i BitSetVector; - friend class Dune::BitSetVector; + const_reference getBit(size_type i) const + { + return blockBitField.getBit(block_number,i); + } - typedef Dune::BitSetVectorConstReference BitSetVectorConstReference; - - BitSetVectorReference(BitSetVector& blockBitField, int block_number) : - BitSetVectorConstReference(blockBitField, block_number), - blockBitField(blockBitField) - {}; - - public: - typedef std::bitset bitset; - - //! bitset interface typedefs - //! \{ - //! A proxy class that acts as a reference to a single bit. - typedef typename std::vector::reference reference; - //! A proxy class that acts as a const reference to a single bit. - typedef typename std::vector::const_reference const_reference; - //! \} - - //! size_type typedef (an unsigned integral type) - typedef size_t size_type; - - //! Assignment from bool, sets each bit in the bitset to b - BitSetVectorReference& operator=(bool b) - { - for(int i=0; i>=(size_type n) - { - for (size_type i=0; iblock_number,i); - } - }; + template + bool equals(const BS & bs) const + { + bool eq = true; + for(int i=0; i - struct const_reference< BitSetVectorReference > + void operator & (); + + friend class BitSetVectorReference; + }; + + /** + \brief A proxy class that acts as a mutable reference to a + single bitset in a BitSetVector. + + It contains an assignment operator from std::bitset. It + inherits the const std::bitset interface provided by + BitSetVectorConstReference and adds most of the non-const + methods of std::bitset. + + \warning As this is only a proxy class, you can not get the + address of the bitset. + */ + template + class BitSetVectorReference : public BitSetVectorConstReference + { + protected: + + typedef Dune::BitSetVector BitSetVector; + friend class Dune::BitSetVector; + + typedef Dune::BitSetVectorConstReference BitSetVectorConstReference; + + BitSetVectorReference(BitSetVector& blockBitField_, int block_number_) : + BitSetVectorConstReference(blockBitField_, block_number_), + blockBitField(blockBitField_) + {} + + public: + typedef std::bitset bitset; + + //! bitset interface typedefs + //! \{ + //! A proxy class that acts as a reference to a single bit. + typedef typename std::vector::reference reference; + //! A proxy class that acts as a const reference to a single bit. + typedef typename std::vector::const_reference const_reference; + //! \} + + //! size_type typedef (an unsigned integral type) + typedef size_t size_type; + + //! Assignment from bool, sets each bit in the bitset to b + BitSetVectorReference& operator=(bool b) { - typedef BitSetVectorConstReference type; - }; - - template - struct const_reference< BitSetVectorConstReference > - { - typedef BitSetVectorConstReference type; - }; - - template - struct mutable_reference< BitSetVectorReference > + for(int i=0; i type; - }; + for(int i=0; i - struct mutable_reference< BitSetVectorConstReference > + //! Assignment from BitSetVectorConstReference + BitSetVectorReference& operator=(const BitSetVectorConstReference & b) { - typedef BitSetVectorReference type; - }; + for(int i=0; i > - class BitSetVector : private std::vector - { - /** \brief The implementation class: an unblocked bitfield */ - typedef std::vector BlocklessBaseClass; - - public: - //! container interface typedefs - //! \{ - - /** \brief Type of the values stored by the container */ - typedef std::bitset value_type; - - /** \brief Reference to a small block of bits */ - typedef BitSetVectorReference reference; - - /** \brief Const reference to a small block of bits */ - typedef BitSetVectorConstReference const_reference; - - /** \brief Pointer to a small block of bits */ - typedef BitSetVectorReference* pointer; - - /** \brief Const pointer to a small block of bits */ - typedef BitSetVectorConstReference* const_pointer; - - /** \brief size type */ - typedef typename std::vector::size_type size_type; - - /** \brief The type of the allocator */ - typedef Allocator allocator_type; - //! \} - - //! iterators - //! \{ - typedef Dune::GenericIterator, value_type, reference, std::ptrdiff_t, ForwardIteratorFacade> iterator; - typedef Dune::GenericIterator, const value_type, const_reference, std::ptrdiff_t, ForwardIteratorFacade> const_iterator; - //! \} - - //! Returns a iterator pointing to the beginning of the vector. - iterator begin(){ - return iterator(*this, 0); - } - - //! Returns a const_iterator pointing to the beginning of the vector. - const_iterator begin() const{ - return const_iterator(*this, 0); - } - - //! Returns an iterator pointing to the end of the vector. - iterator end(){ - return iterator(*this, size()); - } - - //! Returns a const_iterator pointing to the end of the vector. - const_iterator end() const{ - return const_iterator(*this, size()); - } - - //! Default constructor - BitSetVector() : - BlocklessBaseClass() - {} - - //! Construction from an unblocked bitfield - BitSetVector(const BlocklessBaseClass& blocklessBitField) : - BlocklessBaseClass(blocklessBitField) - { - if (blocklessBitField.size()%block_size != 0) - DUNE_THROW(RangeError, "Vector size is not a multiple of the block size!"); - } - - /** Constructor with a given length - \param n Number of blocks - */ - explicit BitSetVector(int n) : - BlocklessBaseClass(n*block_size) - {} - - //! Constructor which initializes the field with true or false - BitSetVector(int n, bool v) : - BlocklessBaseClass(n*block_size,v) - {} - - //! Erases all of the elements. - void clear() - { - BlocklessBaseClass::clear(); - } - - //! Resize field - void resize(int n, bool v = bool()) - { - BlocklessBaseClass::resize(n*block_size, v); - } - - /** \brief Return the number of blocks */ - size_type size() const - { - return BlocklessBaseClass::size()/block_size; - } - - //! Sets all entries to true - void setAll() { - this->assign(BlocklessBaseClass::size(), true); - } - - //! Sets all entries to false - void unsetAll() { - this->assign(BlocklessBaseClass::size(), false); - } - - /** \brief Return reference to i-th block */ - reference operator[](int i) - { - return reference(*this, i); - } - - /** \brief Return const reference to i-th block */ - const_reference operator[](int i) const - { - return const_reference(*this, i); - } - - /** \brief Return reference to last block */ - reference back() - { - return reference(*this, size()-1); - } - - /** \brief Return const reference to last block */ - const_reference back() const - { - return const_reference(*this, size()-1); - } - - //! Returns the number of bits that are set. - size_type count() const - { - return std::count(BlocklessBaseClass::begin(), BlocklessBaseClass::end(), true); - } - - //! Returns the number of set bits, while each block is masked with 1<::reference getBit(size_type i, size_type j) { - return BlocklessBaseClass::operator[](i*block_size+j); - } - - typename std::vector::const_reference getBit(size_type i, size_type j) const { - return BlocklessBaseClass::operator[](i*block_size+j); - } - - friend class BitSetVectorReference; - friend class BitSetVectorConstReference; - }; + //! Assignment from BitSetVectorReference + BitSetVectorReference& operator=(const BitSetVectorReference & b) + { + for(int i=0; i>=(size_type n) + { + for (size_type i=0; iblock_number,i); + } + }; + + /** + typetraits for BitSetVectorReference + */ + template + struct const_reference< BitSetVectorReference > + { + typedef BitSetVectorConstReference type; + }; + + template + struct const_reference< BitSetVectorConstReference > + { + typedef BitSetVectorConstReference type; + }; + + template + struct mutable_reference< BitSetVectorReference > + { + typedef BitSetVectorReference type; + }; + + template + struct mutable_reference< BitSetVectorConstReference > + { + typedef BitSetVectorReference type; + }; + + /** + \brief A dynamic %array of blocks of booleans + */ + template > + class BitSetVector : private std::vector + { + /** \brief The implementation class: an unblocked bitfield */ + typedef std::vector BlocklessBaseClass; + + public: + //! container interface typedefs + //! \{ + + /** \brief Type of the values stored by the container */ + typedef std::bitset value_type; + + /** \brief Reference to a small block of bits */ + typedef BitSetVectorReference reference; + + /** \brief Const reference to a small block of bits */ + typedef BitSetVectorConstReference const_reference; + + /** \brief Pointer to a small block of bits */ + typedef BitSetVectorReference* pointer; + + /** \brief Const pointer to a small block of bits */ + typedef BitSetVectorConstReference* const_pointer; + + /** \brief size type */ + typedef typename std::vector::size_type size_type; + + /** \brief The type of the allocator */ + typedef Allocator allocator_type; + //! \} + + //! iterators + //! \{ + typedef Dune::GenericIterator, value_type, reference, std::ptrdiff_t, ForwardIteratorFacade> iterator; + typedef Dune::GenericIterator, const value_type, const_reference, std::ptrdiff_t, ForwardIteratorFacade> const_iterator; + //! \} + + //! Returns a iterator pointing to the beginning of the vector. + iterator begin(){ + return iterator(*this, 0); + } + + //! Returns a const_iterator pointing to the beginning of the vector. + const_iterator begin() const { + return const_iterator(*this, 0); + } + + //! Returns an iterator pointing to the end of the vector. + iterator end(){ + return iterator(*this, size()); + } + + //! Returns a const_iterator pointing to the end of the vector. + const_iterator end() const { + return const_iterator(*this, size()); + } + + //! Default constructor + BitSetVector() : + BlocklessBaseClass() + {} + + //! Construction from an unblocked bitfield + BitSetVector(const BlocklessBaseClass& blocklessBitField) : + BlocklessBaseClass(blocklessBitField) + { + if (blocklessBitField.size()%block_size != 0) + DUNE_THROW(RangeError, "Vector size is not a multiple of the block size!"); + } + + /** Constructor with a given length + \param n Number of blocks + */ + explicit BitSetVector(int n) : + BlocklessBaseClass(n*block_size) + {} + + //! Constructor which initializes the field with true or false + BitSetVector(int n, bool v) : + BlocklessBaseClass(n*block_size,v) + {} + + //! Erases all of the elements. + void clear() + { + BlocklessBaseClass::clear(); + } + + //! Resize field + void resize(int n, bool v = bool()) + { + BlocklessBaseClass::resize(n*block_size, v); + } + + /** \brief Return the number of blocks */ + size_type size() const + { + return BlocklessBaseClass::size()/block_size; + } + + //! Sets all entries to true + void setAll() { + this->assign(BlocklessBaseClass::size(), true); + } + + //! Sets all entries to false + void unsetAll() { + this->assign(BlocklessBaseClass::size(), false); + } + + /** \brief Return reference to i-th block */ + reference operator[](int i) + { + return reference(*this, i); + } + + /** \brief Return const reference to i-th block */ + const_reference operator[](int i) const + { + return const_reference(*this, i); + } + + /** \brief Return reference to last block */ + reference back() + { + return reference(*this, size()-1); + } + + /** \brief Return const reference to last block */ + const_reference back() const + { + return const_reference(*this, size()-1); + } + + //! Returns the number of bits that are set. + size_type count() const + { + return std::count(BlocklessBaseClass::begin(), BlocklessBaseClass::end(), true); + } + + //! Returns the number of set bits, while each block is masked with 1<::reference getBit(size_type i, size_type j) { + DUNE_ASSERT_BOUNDS(j < block_size); + DUNE_ASSERT_BOUNDS(i < size()); + return BlocklessBaseClass::operator[](i*block_size+j); + } + + typename std::vector::const_reference getBit(size_type i, size_type j) const { + DUNE_ASSERT_BOUNDS(j < block_size); + DUNE_ASSERT_BOUNDS(i < size()); + return BlocklessBaseClass::operator[](i*block_size+j); + } + + friend class BitSetVectorReference; + friend class BitSetVectorConstReference; + }; } // namespace Dune diff -Nru dune-common-2.2.1/dune/common/boundschecking.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/boundschecking.hh --- dune-common-2.2.1/dune/common/boundschecking.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/boundschecking.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,41 @@ +#ifndef DUNE_BOUNDSCHECKING_HH +#define DUNE_BOUNDSCHECKING_HH + +#include + +/** + * \file + * \brief Macro for wrapping boundary checks + */ + +/** + * @addtogroup Common + * + * @{ + */ + +#ifndef DUNE_ASSERT_BOUNDS +#if defined(DUNE_CHECK_BOUNDS) || defined(DOXYGEN) + +/** + * \brief If `DUNE_CHECK_BOUNDS` is defined: check if condition + * \a cond holds; otherwise, do nothing. + * + * Meant to be used for conditions that assure writes and reads + * do not occur outside of memory limits or pre-defined patterns + * and related conditions. + */ +#define DUNE_ASSERT_BOUNDS(cond) \ + do { \ + if (!(cond)) \ + DUNE_THROW(Dune::RangeError, "Index out of bounds."); \ + } while (false) + +#else +#define DUNE_ASSERT_BOUNDS(cond) +#endif +#endif + +/* @} */ + +#endif // DUNE_BOUNDSCHECKING_HH diff -Nru dune-common-2.2.1/dune/common/classname.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/classname.hh --- dune-common-2.2.1/dune/common/classname.hh 2011-10-26 20:38:41.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/classname.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,8 +1,10 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_CLASSNAME_HH #define DUNE_CLASSNAME_HH /** \file - * \brief A free function to provide the demangled class name + * \brief A free function to provide the demangled class name * of a given object or type as a string */ @@ -10,46 +12,44 @@ #include #include -#if defined(__GNUC__) && ! defined(__clang__) +#if HAVE_CXA_DEMANGLE #include -#endif // #ifdef __GNUC__ +#endif // #if HAVE_CXA_DEMANGLE namespace Dune { - - /** \brief Provide the demangled class name of a given object as a string */ - template - std::string className ( T &t ) - { - std::string className = typeid( t ).name(); -#if defined(__GNUC__) && ! defined(__clang__) - int status; - char *demangled = abi::__cxa_demangle( className.c_str(), 0, 0, &status ); - if( demangled ) - { - className = demangled; - std::free( demangled ); - } -#endif // #ifdef __GNUC__ - return className; - } - /** \brief Provide the demangled class name of a type T as a string */ - template - std::string className () + /** \brief Provide the demangled class name of a type T as a string */ + template + std::string className () + { + typedef typename std::remove_reference::type TR; + std::string className = typeid( TR ).name(); +#if HAVE_CXA_DEMANGLE + int status; + char *demangled = abi::__cxa_demangle( className.c_str(), 0, 0, &status ); + if( demangled ) { - std::string className = typeid( T ).name(); -#if defined(__GNUC__) && ! defined(__clang__) - int status; - char *demangled = abi::__cxa_demangle( className.c_str(), 0, 0, &status ); - if( demangled ) - { - className = demangled; - std::free( demangled ); - } -#endif // #ifdef __GNUC__ - return className; + className = demangled; + std::free( demangled ); } - +#endif // #if HAVE_CXA_DEMANGLE + if (std::is_const::value) + className += " const"; + if (std::is_volatile::value) + className += " volatile"; + if (std::is_lvalue_reference::value) + className += "&"; + else if (std::is_rvalue_reference::value) + className += "&&"; + return className; + } + + /** \brief Provide the demangled class name of a given object as a string */ + template + std::string className ( T& ) + { + return className(); + } } // namespace Dune #endif // DUNE_CLASSNAME_HH diff -Nru dune-common-2.2.1/dune/common/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/dune/common/CMakeLists.txt --- dune-common-2.2.1/dune/common/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,113 @@ +add_subdirectory("parallel") +add_subdirectory("std") +add_subdirectory("test") + +#build the library dunecommon +if(LAPACK_FOUND) + set(_additional_libs ${LAPACK_LIBRARIES}) +elseif(BLAS_FOUND) + set(_additional_libs ${BLAS_LIBRARIES}) +endif(LAPACK_FOUND) + +dune_add_library("dunecommon" + debugallocator.cc + dynmatrixev.cc + exceptions.cc + fmatrixev.cc + ios_state.cc + parametertree.cc + parametertreeparser.cc + path.cc + stdstreams.cc + stdthread.cc + ADD_LIBS "${_additional_libs}") + +#install headers +install(FILES + alignment.hh + array.hh + arraylist.hh + bartonnackmanifcheck.hh + bigunsignedint.hh + binaryfunctions.hh + bitsetvector.hh + boundschecking.hh + classname.hh + concept.hh + conditional.hh + debugallocator.hh + debugstream.hh + deprecated.hh + densematrix.hh + densevector.hh + diagonalmatrix.hh + documentation.hh + dotproduct.hh + dynmatrix.hh + dynmatrixev.hh + dynvector.hh + enumset.hh + exceptions.hh + float_cmp.cc + float_cmp.hh + fmatrix.hh + fmatrixev.hh + forloop.hh + ftraits.hh + function.hh + fvector.hh + gcd.hh + genericiterator.hh + gmpfield.hh + hash.hh + hybridutilities.hh + identitymatrix.hh + indent.hh + indices.hh + interfaces.hh + ios_state.hh + iteratorfacades.hh + iteratorrange.hh + lcm.hh + lru.hh + mallocallocator.hh + math.hh + matvectraits.hh + nullptr.hh + overloadset.hh + parametertree.hh + parametertreeparser.hh + path.hh + poolallocator.hh + power.hh + precision.hh + propertymap.hh + promotiontraits.hh + proxymemberaccess.hh + rangeutilities.hh + reservedvector.hh + shared_ptr.hh + simd.hh + singleton.hh + sllist.hh + stdstreams.hh + stdthread.hh + streamoperators.hh + stringutility.hh + timer.hh + tuples.hh + tupleutility.hh + tuplevector.hh + typelist.hh + typetraits.hh + typeutilities.hh + unused.hh + version.hh + visibility.hh +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common) + +# Install some test headers, because they get used by tests in other modules +# We do this here as test will not be considered for make install +install(FILES test/iteratortest.hh + test/checkmatrixinterface.hh + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common/test) diff -Nru dune-common-2.2.1/dune/common/collectivecommunication.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/collectivecommunication.hh --- dune-common-2.2.1/dune/common/collectivecommunication.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/collectivecommunication.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,271 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -#ifndef DUNE_COLLECTIVECOMMUNICATION_HH -#define DUNE_COLLECTIVECOMMUNICATION_HH - -#include -#include -#include - -#include"exceptions.hh" - -/*! \defgroup ParallelCommunication Parallel Communication - \ingroup Common - - Dune offers an abstraction to the basic methods of parallel - communication. It allows to switch parallel features on and off, - without changing the code. - -*/ - -/*! - \file - \brief An abstraction to the basic methods of parallel communication, - following the message-passing paradigm. - \ingroup ParallelCommunication - */ - -namespace Dune -{ - - /* define some type that definitely differs from MPI_Comm */ - struct No_Comm {}; - - - /*! @brief Collective communication interface and sequential default implementation - - CollectiveCommunication offers an abstraction to the basic methods - of parallel communication, following the message-passing - paradigm. It allows to switch parallel features on and off, without - changing the code. Currently only MPI and sequential code are - supported. - - A CollectiveCommunication object is returned by all grids (also - the sequential ones) in order to allow code to be written in - a transparent way for sequential and parallel grids. - - This class provides a default implementation for sequential grids. - The number of processes involved is 1, any sum, maximum, etc. returns - just its input argument and so on. - - In specializations one can implement the real thing using appropriate - communication functions, e.g. there exists an implementation using - the Message Passing %Interface (MPI), see Dune::CollectiveCommunication. - - Moreover, the communication subsystem used by an implementation - is not visible in the interface, i.e. Dune grid implementations - are not restricted to MPI. - - \ingroup ParallelCommunication - */ - template - class CollectiveCommunication - { - public: - //! Construct default object - CollectiveCommunication() - {} - CollectiveCommunication (const C&) - {} - - //! Return rank, is between 0 and size()-1 - int rank () const - { - return 0; - } - - //! Number of processes in set, is greater than 0 - int size () const - { - return 1; - } - - /** @brief Compute the sum of the argument over all processes and - return the result in every process. Assumes that T has an operator+ - */ - template - T sum (T& in) const // MPI does not know about const :-( - { - return in; - } - - /** @brief Compute the sum over all processes for each component of an array and return the result - in every process. Assumes that T has an operator+ - */ - template - int sum (T* inout, int len) const - { - return 0; - } - - /** @brief Compute the product of the argument over all processes and - return the result in every process. Assumes that T has an operator* - */ - template - T prod (T& in) const // MPI does not know about const :-( - { - return in; - } - - /** @brief Compute the product over all processes - for each component of an array and return the result - in every process. Assumes that T has an operator* - */ - template - int prod (T* inout, int len) const - { - return 0; - } - - /** @brief Compute the minimum of the argument over all processes and - return the result in every process. Assumes that T has an operator< - */ - template - T min (T& in) const // MPI does not know about const :-( - { - return in; - } - - /** @brief Compute the minimum over all processes - for each component of an array and return the result - in every process. Assumes that T has an operator< - */ - template - int min (T* inout, int len) const - { - return 0; - } - - /** @brief Compute the maximum of the argument over all processes and - return the result in every process. Assumes that T has an operator< - */ - template - T max (T& in) const // MPI does not know about const :-( - { - return in; - } - - /** @brief Compute the maximum over all processes - for each component of an array and return the result - in every process. Assumes that T has an operator< - */ - template - int max (T* inout, int len) const - { - return 0; - } - - /** @brief Wait until all processes have arrived at this point in the program. - */ - int barrier () const - { - return 0; - } - - /** @brief Distribute an array from the process with rank root to all other processes - */ - template - int broadcast (T* inout, int len, int root) const - { - return 0; - } - - /** @brief Gather arrays on root task. - * - * Each process sends its in array of length len to the root process - * (including the root itself). In the root process these arrays are stored in rank - * order in the out array which must have size len * number of processes. - * @param[in] in The send buffer with the data to send. - * @param[out] out The buffer to store the received data in. Might have length zero on non-root - * tasks. - * @param[in] len The number of elements to send on each task. - * @param[out] root The root task that gathers the data. - */ - template - int gather (T* in, T* out, int len, int root) const // note out must have same size as in - { - for (int i=0; i - int scatter (T* send, T* recv, int len, int root) const // note out must have same size as in - { - for (int i=0; i - int allgather(T* sbuf, int count, T* rbuf) const - { - for(T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf) - *sbuf=*rbuf; - return 0; - } - - /** - * @brief Compute something over all processes - * for each component of an array and return the result - * in every process. - * - * The template parameter BinaryFunction is the type of - * the binary function to use for the computation - * - * @param inout The array to compute on. - * @param len The number of components in the array - */ - template - int allreduce(Type* inout, int len) const - { - return 0; - } - - /** - * @brief Compute something over all processes - * for each component of an array and return the result - * in every process. - * - * The template parameter BinaryFunction is the type of - * the binary function to use for the computation - * - * @param in The array to compute on. - * @param out The array to store the results in. - * @param len The number of components in the array - */ - template - void allreduce(Type* in, Type* out, int len) const - { - std::copy(in, in+len, out); - return; - } - - }; -} - -#endif diff -Nru dune-common-2.2.1/dune/common/concept.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/concept.hh --- dune-common-2.2.1/dune/common/concept.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/concept.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,318 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_CONCEPT_HH +#define DUNE_COMMON_CONCEPT_HH + +#include +#include +#include + +#include +#include +#include +#include + + + +namespace Dune { + + + +/** + * \brief Namespace for concepts + * + * This namespace contains helper functions for + * concept definitions and the concept definitions + * themselves. + */ +namespace Concept { + + + +/** + * \brief Base class for refined concepts. + * + * If a new concept should refine one or more existing concepts, + * this can be achieved by deriving the new concept from + * Refines where C1, ..., CN are the concepts + * to be refined. If you want to refine several concepts + * they should all be put in a single Refines<...> base + * class. + * + * \tparam BaseConcepts The list of concepts to be refined. + */ +template +struct Refines +{ + typedef TypeList BaseConceptList; +}; + + + +namespace Imp { + + // ############################################################################# + // # All functions following here are implementation details + // # for the models() function below. + // ############################################################################# + + // Forward declaration + template + constexpr bool models(); + + + + // Here is the implementation of the concept checking. + // The first two overloads do the magic for checking + // if the requirements of a concept are satisfied. + // The rest is just for checking base concepts in case + // of refinement. + + // This overload is present if type substitution for + // C::require(T...) is successful, i.e., if the T... + // matches the requirement of C. In this case this + // overload is selected because PriorityTag<1> + // is a better match for PrioriryTag<42> than + // PriorityTag<0> in the default overload. + template().require(std::declval()...), 0) =0> + constexpr std::true_type matchesRequirement(PriorityTag<1>) + { return {}; } + + // If the above overload is ruled out by SFINAE because + // the T... does not match the requirements of C, then + // this default overload drops in. + template + constexpr std::false_type matchesRequirement(PriorityTag<0>) + { return {}; } + + + + // An empty list C of concepts is always matched by T... + template + constexpr bool modelsConceptList(TypeList<>) + { return true; } + + // A nonempty list C0,..,CN of concepts is modeled + // by T... if it models the concept C0 + // and all concepts in the list C1,..,CN. + template + constexpr bool modelsConceptList(TypeList) + { return Imp::models() and modelsConceptList(TypeList()); } + + + + // If C is an unrefined concept, then T... models C + // if it matches the requirement of C. + template + constexpr bool modelsConcept(PriorityTag<0>) + { return matchesRequirement(PriorityTag<42>()); } + + // If C is a refined concept, then T... models C + // if it matches the requirement of C and of + // all base concepts. + // + // This overload is used if C::BaseConceptList exists + // due to its higher priority. + template + constexpr bool modelsConcept(PriorityTag<1>) + { return matchesRequirement(PriorityTag<42>()) and modelsConceptList(typename C::BaseConceptList()); } + + // This is the full concept check. It's defined here in the + // implementation namespace with 'constexpr bool' return type + // because we need a forward declaration in order to use it + // internally above. + // + // The actual interface function can then call this one and + // return the result as std::integral_constant which + // does not allow for a forward declaration because the return + // type is deduced. + template + constexpr bool models() + { + return modelsConcept(PriorityTag<42>()); + } + +} // namespace Dune::Concept::Imp + +} // namespace Dune::Concept + + + +/** + * \brief Check if concept is modeled by given types + * + * This will check if the given concept is modeled by the given + * list of types. This is true if the list of types models all + * the base concepts that are refined by the given concept + * and if it satisfies all additional requirements of the latter. + * + * Notice that a concept may be defined for a list of interacting types. + * The function will check if the given list of types matches the requirements + * on the whole list. It does not check if each individual type in the list + * satisfies the concept. + * + * This concept check mechanism is inspired by the concept checking + * facility in Eric Nieblers range-v3. For more information please + * refer to the libraries project page https://github.com/ericniebler/range-v3 + * or this blog entry: http://ericniebler.com/2013/11/23/concept-checking-in-c11. + * In fact the interface provided here is almost exactly the same as in range-v3. + * However the implementation differs, because range-v3 uses its own meta-programming + * library whereas our implementation is more straight forward. + * + * The result is returned as std::integral_constant which + * allows to nicely use this method with Hybrid::ifElse. + * + * \tparam C The concept to check + * \tparam T The list of type to check against the concept + * + */ +template +constexpr auto models() +{ + return Std::bool_constant()>(); +} + + + +namespace Concept { + +namespace Imp { + + // ############################################################################# + // # All functions following here are implementation details for the + // # for the tupleEntriesModel() function below. + // ############################################################################# + + template + struct TupleEntriesModelHelper + { + template + struct AccumulateFunctor + { + using type = typename std::integral_constant()>; + }; + using Result = typename ReduceTuple::type; + }; + +} // namespace Dune::Concept::Imp + + + +// ############################################################################# +// # The method tupleEntriesModel() does the actual check if the types in a tuple +// # model a concept using the implementation details above. +// ############################################################################# + +template +constexpr auto tupleEntriesModel() + -> typename Imp::TupleEntriesModelHelper::Result +{ + return {}; +} + +// ############################################################################# +// # The following require*() functions are just helpers that allow to +// # propagate a failed check as substitution failure. This is useful +// # inside of a concept definition. +// ############################################################################# + +// Helper function for use in concept definitions. +// If the passed value b is not true, the concept will to be satisfied. +template::type = 0> +constexpr bool requireTrue() +{ + return true; +} + +// Helper function for use in concept definitions. +template(), int>::type = 0> +constexpr bool requireConcept() +{ + return true; +} + +// Helper function for use in concept definitions. +// This allows to avoid using decltype +template(), int>::type = 0> +constexpr bool requireConcept(T&&... t) +{ + return true; +} + +// Helper function for use in concept definitions. +// This checks if the concept given as first type is modelled by all types in the tuple passed as argument +template(), int>::type = 0> +constexpr bool requireConceptForTupleEntries() +{ + return true; +} + +// Helper function for use in concept definitions. +// If the first passed type is not convertible to the second, the concept will not be satisfied. +template::value, int>::type = 0> +constexpr bool requireConvertible() +{ + return true; +} + +// Helper function for use in concept definitions. +// If passed argument is not convertible to the first passed type, the concept will not be satisfied. +template::value, int>::type = 0> +constexpr bool requireConvertible(const From&) +{ + return true; +} + +// Helper function for use in concept definitions. +// This will always evaluate to true. If just allow +// to turn a type into an expression. The failure happens +// already during substitution for the type argument. +template +constexpr bool requireType() +{ + return true; +} + +// Helper function for use in concept definitions. +// If first passed type is not a base class of second type, the concept will not be satisfied. +template::value, int>::type = 0> +constexpr bool requireBaseOf() +{ + return true; +} + +// Helper function for use in concept definitions. +// If first passed type is not a base class of first arguments type, the concept will not be satisfied. +template::value, int>::type = 0> +constexpr bool requireBaseOf(const Derived&) +{ + return true; +} + +// Helper function for use in concept definitions. +// If the passed types are not the same, the concept will not be satisfied. +template::value, int>::type = 0> +constexpr bool requireSameType() +{ + return true; +} + + + +} // namespace Dune::Concept + + + +} // namespace Dune + + + + +#endif // DUNE_COMMON_CONCEPT_HH diff -Nru dune-common-2.2.1/dune/common/conditional.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/conditional.hh --- dune-common-2.2.1/dune/common/conditional.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/conditional.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,33 @@ +#ifndef DUNE_COMMON_CONDITIONAL_HH +#define DUNE_COMMON_CONDITIONAL_HH + +namespace Dune +{ + + /** \brief conditional evaluate + + sometimes call immediate if, evaluates to + + \code + if (b) + return v1; + else + return v2; + \endcode + + In contrast to if-then-else the cond function can also be + evaluated for vector valued SIMD data types, see simd.hh. + + \param b boolean value + \param v1 value of b==true + \param v2 value of b==false + */ + template + const T1 cond(bool b, const T1 & v1, const T2 & v2) + { + return (b ? v1 : v2); + } + +} // end namespace Dune + +#endif // DUNE_COMMON_CONDITIONAL_HH diff -Nru dune-common-2.2.1/dune/common/debugallocator.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/debugallocator.cc --- dune-common-2.2.1/dune/common/debugallocator.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/debugallocator.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,31 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "debugallocator.hh" + +#include +#include +#include + +namespace Dune +{ + namespace DebugMemory + { + // system constant for page size + const std::ptrdiff_t page_size = sysconf(_SC_PAGESIZE); + + // implement member functions + void AllocationManager::allocation_error(const char* msg) + { + std::cerr << "Abort - Memory Corruption: " << msg << std::endl; + std::abort(); + } + + // global instance of AllocationManager + AllocationManager alloc_man; + + } // end namespace DebugMemory +} // end namespace Dune diff -Nru dune-common-2.2.1/dune/common/debugallocator.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/debugallocator.hh --- dune-common-2.2.1/dune/common/debugallocator.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/debugallocator.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,327 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_DEBUG_ALLOCATOR_HH +#define DUNE_DEBUG_ALLOCATOR_HH + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if HAVE_SYS_MMAN_H && HAVE_MPROTECT +#include +#else +enum DummyProtFlags { PROT_NONE, PROT_WRITE, PROT_READ }; +#endif + +#include "mallocallocator.hh" + +namespace Dune +{ + +#ifndef DOXYGEN // hide implementation details from doxygen + namespace DebugMemory + { + + extern const std::ptrdiff_t page_size; + + struct AllocationManager + { + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef void* pointer; + + protected: + static void allocation_error(const char* msg); + + struct AllocationInfo; + friend struct AllocationInfo; + +#define ALLOCATION_ASSERT(A) { if (!(A)) \ + { allocation_error("Assertion " # A " failed");\ + }\ +}; + + struct AllocationInfo + { + AllocationInfo(const std::type_info & t) : type(&t) {} + const std::type_info * type; + + pointer page_ptr; + pointer ptr; + size_type pages; + size_type capacity; + size_type size; + bool not_free; + }; + + typedef MallocAllocator Alloc; + typedef std::vector AllocationList; + AllocationList allocation_list; + + private: + void memprotect(void* from, difference_type len, int prot) + { +#if HAVE_SYS_MMAN_H && HAVE_MPROTECT + int result = mprotect(from, len, prot); + if (result == -1) + { + + std::cerr << "ERROR: (" << result << ": " << strerror(result) << ")" << std::endl; + std::cerr << " Failed to "; + if (prot == PROT_NONE) + std::cerr << "protect "; + else + std::cerr << "unprotect "; + std::cerr << "memory range: " + << from << ", " + << static_cast( + static_cast(from) + len) + << std::endl; + abort(); + } +#else + DUNE_UNUSED_PARAMETER(from); + DUNE_UNUSED_PARAMETER(len); + DUNE_UNUSED_PARAMETER(prot); + std::cerr << "WARNING: memory protection not available" << std::endl; +#endif + } + + public: + + ~AllocationManager () + { + AllocationList::iterator it; + bool error = false; + for (it=allocation_list.begin(); it!=allocation_list.end(); it++) + { + if (it->not_free) + { + std::cerr << "ERROR: found memory chunk still in use: " << + it->capacity << " bytes at " << it->ptr << std::endl; + error = true; + } + munmap(it->page_ptr, it->pages * page_size); + } + if (error) + allocation_error("lost allocations"); + } + + template + T* allocate(size_type n) throw(std::bad_alloc) + { + // setup chunk info + AllocationInfo ai(typeid(T)); + ai.size = n; + ai.capacity = n * sizeof(T); + ai.pages = (ai.capacity) / page_size + 2; + ai.not_free = true; + size_type overlap = ai.capacity % page_size; + ai.page_ptr = mmap(NULL, ai.pages * page_size, + PROT_READ | PROT_WRITE, +#ifdef __APPLE__ + MAP_ANON | MAP_PRIVATE, +#else + MAP_ANONYMOUS | MAP_PRIVATE, +#endif + -1, 0); + if (MAP_FAILED == ai.page_ptr) + { + throw std::bad_alloc(); + } + ai.ptr = static_cast(ai.page_ptr) + page_size - overlap; + // write protect memory behind the actual data + memprotect(static_cast(ai.page_ptr) + (ai.pages-1) * page_size, + page_size, + PROT_NONE); + // remember the chunk + allocation_list.push_back(ai); + // return the ptr + return static_cast(ai.ptr); + } + + template + void deallocate(T* ptr, size_type n = 0) throw() + { + // compute page address + void* page_ptr = + static_cast( + (char*)(ptr) - ((std::uintptr_t)(ptr) % page_size)); + // search list + AllocationList::iterator it; + unsigned int i = 0; + for (it=allocation_list.begin(); it!=allocation_list.end(); it++, i++) + { + if (it->page_ptr == page_ptr) + { + // std::cout << "found memory_block in allocation " << i << std::endl; + // sanity checks + if (n != 0) + ALLOCATION_ASSERT(n == it->size); + ALLOCATION_ASSERT(ptr == it->ptr); + ALLOCATION_ASSERT(true == it->not_free); + ALLOCATION_ASSERT(typeid(T) == *(it->type)); + // free memory + it->not_free = false; +#if DEBUG_ALLOCATOR_KEEP + // write protect old memory + memprotect(it->page_ptr, + (it->pages) * page_size, + PROT_NONE); +#else + // unprotect old memory + memprotect(it->page_ptr, + (it->pages) * page_size, + PROT_READ | PROT_WRITE); + munmap(it->page_ptr, it->pages * page_size); + // remove chunk info + allocation_list.erase(it); +#endif + return; + } + } + allocation_error("memory block not found"); + } + }; +#undef ALLOCATION_ASSERT + + extern AllocationManager alloc_man; + } // end namespace DebugMemory +#endif // DOXYGEN + + template + class DebugAllocator; + + // specialize for void + template <> + class DebugAllocator { + public: + typedef void* pointer; + typedef const void* const_pointer; + // reference to void members are impossible. + typedef void value_type; + template struct rebind { + typedef DebugAllocator other; + }; + }; + + // actual implementation + /** + @ingroup Allocators + @brief Allocators implementation which performs different kind of memory checks + + We check: + - access past the end + - only free memory which was allocated with this allocator + - list allocated memory chunks still in use upon destruction of the allocator + + When defining DEBUG_ALLOCATOR_KEEP to 1, we also check + - double free + - access after free + + When defining DEBUG_NEW_DELETE >= 1, we + - overload new/delte + - use the Debug memory management for new/delete + - DEBUG_NEW_DELETE > 2 gives extensive debug output + */ + template + class DebugAllocator { + public: + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T value_type; + template struct rebind { + typedef DebugAllocator other; + }; + + //! create a new DebugAllocator + DebugAllocator() throw() {} + //! copy construct from an other DebugAllocator, possibly for a different result type + template + DebugAllocator(const DebugAllocator&) throw() {} + //! cleanup this allocator + ~DebugAllocator() throw() {} + + pointer address(reference x) const + { + return &x; + } + const_pointer address(const_reference x) const + { + return &x; + } + + //! allocate n objects of type T + pointer allocate(size_type n, + DebugAllocator::const_pointer hint = 0) + { + DUNE_UNUSED_PARAMETER(hint); + return DebugMemory::alloc_man.allocate(n); + } + + //! deallocate n objects of type T at address p + void deallocate(pointer p, size_type n) + { + DebugMemory::alloc_man.deallocate(p,n); + } + + //! max size for allocate + size_type max_size() const throw() + { + return size_type(-1) / sizeof(T); + } + + //! copy-construct an object of type T (i.e. make a placement new on p) + void construct(pointer p, const T& val) + { + ::new((void*)p)T(val); + } + + //! construct an object of type T from variadic parameters + template + void construct(pointer p, _Args&&... __args) + { + ::new((void *)p)T(std::forward<_Args>(__args) ...); + } + + //! destroy an object of type T (i.e. call the destructor) + void destroy(pointer p) + { + p->~T(); + } + }; +} + +#ifdef DEBUG_NEW_DELETE +void * operator new(size_t size) +{ + // try to allocate size bytes + void *p = Dune::DebugMemory::alloc_man.allocate(size); +#if DEBUG_NEW_DELETE > 2 + std::cout << "NEW " << size + << " -> " << p + << std::endl; +#endif + return p; +} + +void operator delete(void * p) throw() +{ +#if DEBUG_NEW_DELETE > 2 + std::cout << "FREE " << p << std::endl; +#endif + Dune::DebugMemory::alloc_man.deallocate(static_cast(p)); +} + +#endif // DEBUG_NEW_DELETE + +#endif // DUNE_DEBUG_ALLOCATOR_HH diff -Nru dune-common-2.2.1/dune/common/debugstream.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/debugstream.hh --- dune-common-2.2.1/dune/common/debugstream.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/debugstream.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,4 +1,5 @@ -// $Id: debugstream.hh 6785 2012-05-31 22:07:47Z sander $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_DEBUGSTREAM_HH #define DUNE_DEBUGSTREAM_HH @@ -15,114 +16,114 @@ namespace Dune { /*! \defgroup DebugOut Debug output - \ingroup Common - - The debug output is implemented by instances of DebugStream which - provides the following features: + \ingroup Common - - output-syntax in the standard ostream-notation - - output can be totally deactivated depending on template parameters - - streams with active output can be deactivated during runtime - - redirecting to std::ostream or other DebugStream s during runtime - - stack oriented state + The debug output is implemented by instances of DebugStream which + provides the following features: - The Dune-components should use the streams explained in \ref StdStreams - for output so that applications may redirect the output globally. + - output-syntax in the standard ostream-notation + - output can be totally deactivated depending on template parameters + - streams with active output can be deactivated during runtime + - redirecting to std::ostream or other DebugStream s during runtime + - stack oriented state - Changes in runtime are provided by three sets of methods: + The Dune-components should use the streams explained in \ref StdStreams + for output so that applications may redirect the output globally. - - push()/pop() sets new activation flag or restore old setting - - attach()/detach() redirects output to a different std::ostream or restore old stream - - tie()/untie() redirects output through another DebugStream. If the state of the master stream changes (activation or output-stream) it is changed in the tied stream as well + Changes in runtime are provided by three sets of methods: - The first methods implement a full stack whereas tie() is a bit - different: though a tied stream may be (de)activated via - push()/pop() you cannot attach() or detach() an output. You'll need - to change the master stream instead. + - push()/pop() sets new activation flag or restore old setting + - attach()/detach() redirects output to a different std::ostream or restore old stream + - tie()/untie() redirects output through another DebugStream. If the state of the master stream changes (activation or output-stream) it is changed in the tied stream as well - \section DebugAppl Applications + The first methods implement a full stack whereas tie() is a bit + different: though a tied stream may be (de)activated via + push()/pop() you cannot attach() or detach() an output. You'll need + to change the master stream instead. - Applications using the Dune-library should create an independent set - of DebugStreams so that the debug levels can be changed separately. - Example: + \section DebugAppl Applications - \code - static const Dune::DebugLevel APPL_MINLEVEL = 3; + Applications using the Dune-library should create an independent set + of DebugStreams so that the debug levels can be changed separately. + Example: - Dune::DebugStream<1, APPL_MINLEVEL> myverbose; - Dune::DebugStream<2, APPL_MINLEVEL> myinfo; - Dune::DebugStream<3, APPL_MINLEVEL> mywarn; - \endcode + \code + static const Dune::DebugLevel APPL_MINLEVEL = 3; - This code creates three streams of which only the last one really - creates output. The output-routines of the other streams vanish in - optimized executables. + Dune::DebugStream<1, APPL_MINLEVEL> myverbose; + Dune::DebugStream<2, APPL_MINLEVEL> myinfo; + Dune::DebugStream<3, APPL_MINLEVEL> mywarn; + \endcode - You can use the common_bits-Template to switch to a policy using bitflags: + This code creates three streams of which only the last one really + creates output. The output-routines of the other streams vanish in + optimized executables. - \code - enum { APPL_CORE = 1, APPL_IO = 2, APPL_GRAPHICS = 4}; - - static const Dune::DebugLevel APPL_DEBUG_MASK = APPL_CORE | APPL_GRAPHICS; - static const Dune::DebugLevel APPL_ACTIVE_MASK = 0xff; - - Dune::DebugStream coreout; - Dune::DebugStream ioout; - Dune::DebugStream graphout; - \endcode + You can use the common_bits-Template to switch to a policy using bitflags: - Applications that wish to redirect the \ref StdStreams through their - private streams may use the tie()-mechanism: + \code + enum { APPL_CORE = 1, APPL_IO = 2, APPL_GRAPHICS = 4}; - \code - // initialize streams like above + static const Dune::DebugLevel APPL_DEBUG_MASK = APPL_CORE | APPL_GRAPHICS; + static const Dune::DebugLevel APPL_ACTIVE_MASK = 0xff; - Dune::dwarn.tie(coreout); + Dune::DebugStream coreout; + Dune::DebugStream ioout; + Dune::DebugStream graphout; + \endcode - // ... Dune-output to dwarn will be directed through coreout ... + Applications that wish to redirect the \ref StdStreams through their + private streams may use the tie()-mechanism: - Dune::dwarn.untie(); - \endcode + \code + // initialize streams like above - Keep in mind to untie() a stream before the tied stream is destructed. + Dune::dwarn.tie(coreout); - An alternative is to attach() an output stream defined by the application: + // ... Dune-output to dwarn will be directed through coreout ... - \code - std::ofstream mylog("application.log"); + Dune::dwarn.untie(); + \endcode - Dune::dwarn.attach(mylog); - \endcode - */ + Keep in mind to untie() a stream before the tied stream is destructed. + + An alternative is to attach() an output stream defined by the application: + + \code + std::ofstream mylog("application.log"); + + Dune::dwarn.attach(mylog); + \endcode + */ /** \addtogroup DebugOut \{ - */ - /*! \file + */ + /*! \file + + This file implements the class DebugStream to support output in a + variety of debug levels. Additionally, template parameters control + if the output operation is really performed so that unused debug + levels can be deactivated + + */ - This file implements the class DebugStream to support output in a - variety of debug levels. Additionally, template parameters control - if the output operation is really performed so that unused debug - levels can be deactivated - - */ - - - /*! \brief Type for debug levels. - - Only positive values allowed - */ + + /*! \brief Type for debug levels. + + Only positive values allowed + */ typedef unsigned int DebugLevel; - /*! + /*! - \brief Greater or equal template test. + \brief Greater or equal template test. - value is false if current is below the threshold, true otherwise - - This is the default struct to control the activation policy of - DebugStream and deactivates output below the threshold - */ + value is false if current is below the threshold, true otherwise + + This is the default struct to control the activation policy of + DebugStream and deactivates output below the threshold + */ template struct greater_or_equal { static const bool value = (current >= threshold); @@ -131,22 +132,22 @@ /*! \brief activate if current and mask have common bits switched on. - This template implements an alternative strategy to activate or - deactivate a DebugStream. Keep in mind to number your streams as - powers of two if using this template - */ + This template implements an alternative strategy to activate or + deactivate a DebugStream. Keep in mind to number your streams as + powers of two if using this template + */ template struct common_bits { enum {value = ((current & mask)!=0) }; }; - + //! \brief standard exception for the debugstream class DebugStreamError : public IOError {}; class StreamWrap { public: - StreamWrap(std::ostream& _out) : out(_out) { }; + StreamWrap(std::ostream& _out) : out(_out) { } std::ostream& out; StreamWrap *next; }; @@ -157,10 +158,10 @@ public: //! \brief current output stream and link to possibly pushed old output streams StreamWrap* current; - + //! \brief flag to switch output during runtime bool _active; - + //! \brief are we tied to another DebugStream? bool _tied; @@ -169,35 +170,35 @@ }; /*! - \brief Generic class to implement debug output streams - - The main function of a DebugStream is to provide output in a - standard ostream fashion that is fully deactivated if the level of - the stream does not meet the current requirements. More information in \ref DebugOut - - \param thislevel this level - \param dlevel level needed for any output to happen - \param alevel level needed to switch activation flag on - \param activator template describing the activation policy + \brief Generic class to implement debug output streams + + The main function of a DebugStream is to provide output in a + standard ostream fashion that is fully deactivated if the level of + the stream does not meet the current requirements. More information in \ref DebugOut + + \param thislevel this level + \param dlevel level needed for any output to happen + \param alevel level needed to switch activation flag on + \param activator template describing the activation policy - \todo Fix visibility of internal data + \todo Fix visibility of internal data */ - template class activator = greater_or_equal> + template class activator = greater_or_equal> class DebugStream : public DebugStreamState { public: /*! \brief Create a DebugStream and set initial output stream - during runtime another stream can be attach()ed, however the - initial stream may not be detach()ed. - */ + during runtime another stream can be attach()ed, however the + initial stream may not be detach()ed. + */ DebugStream(std::ostream& out = std::cerr) { // start a new list of streams current = new StreamWrap(out); current->next = 0; - + // check if we are above the default activation level _active = activator::value; @@ -206,20 +207,20 @@ // no child streams yet _tied_streams = 0; - }; + } /*! \brief Create a DebugStream and directly tie to another DebugStream - The fallback is used if a DebugStream constructed via this method - is untie()ed later. Otherwise the stream would be broken afterwards. - */ - DebugStream (DebugStreamState& master, - std::ostream& fallback = std::cerr) + The fallback is used if a DebugStream constructed via this method + is untie()ed later. Otherwise the stream would be broken afterwards. + */ + DebugStream (DebugStreamState& master, + std::ostream& fallback = std::cerr) { // start a new list of streams current = new StreamWrap(fallback); current->next = 0; - + // check if we are above the default activation level _active = activator::value; _tied_streams = 0; @@ -228,32 +229,33 @@ _tied = true; tiedstate = &master; tiedstate->_tied_streams++; - }; + } /*! \brief Destroy stream. - if other streams still tie() to this stream an exception will be - thrown. Otherwise the child streams would certainly break on the - next output - */ - ~DebugStream() { + if other streams still tie() to this stream an exception will be + thrown. Otherwise the child streams would certainly break on the + next output + */ + ~DebugStream() noexcept(false) + { // untie if (_tied) tiedstate->_tied_streams--; else { // check if somebody still ties to us... if (_tied_streams != 0) - DUNE_THROW(DebugStreamError, + DUNE_THROW(DebugStreamError, "There are streams still tied to this stream!"); - }; + } // remove ostream-stack while (current != 0) { StreamWrap *s = current; current = current->next; delete s; - }; - }; + } + } //! \brief Generic types are passed on to current output stream template @@ -265,16 +267,16 @@ current->out << data; } else { if (_active && tiedstate->_active) - tiedstate->current->out << data; - }; - }; + tiedstate->current->out << data; + } + } return *this; } /*! \brief explicit specialization so that enums can be printed - - Operators for built-in types follow special + + Operators for built-in types follow special rules (§11.2.3) so that enums won't fit into the generic method above. With an existing operator<< for int however the enum will be automatically casted. @@ -287,13 +289,13 @@ current->out << data; } else { if (_active && tiedstate->_active) - tiedstate->current->out << data; - }; - }; + tiedstate->current->out << data; + } + } return *this; } - + //! \brief pass on manipulators to underlying output stream DebugStream& operator<<(std::ostream& (*f)(std::ostream&)) { if (activator::value) { @@ -303,12 +305,12 @@ } else { if (_active && tiedstate->_active) f(tiedstate->current->out); - }; + } } return *this; - }; - + } + //! \brief pass on flush to underlying output stream DebugStream& flush() { if (activator::value) { @@ -318,12 +320,12 @@ } else { if (_active && tiedstate->_active) tiedstate->current->out.flush(); - }; + } } return *this; - }; - + } + //! \brief set activation flag and store old value void push(bool b) { // are we at all active? @@ -333,52 +335,52 @@ } else { // stay off _actstack.push(false); - }; - }; - + } + } + //! \brief restore previously set activation flag void pop() throw(DebugStreamError) { if (_actstack.empty()) DUNE_THROW(DebugStreamError, "No previous activation setting!"); - + _active = _actstack.top(); _actstack.pop(); - }; + } /*! \brief reports if this stream will produce output - a DebugStream that is deactivated because of its level will always - return false, otherwise the state of the internal activation is - returned - */ + a DebugStream that is deactivated because of its level will always + return false, otherwise the state of the internal activation is + returned + */ bool active() const { return activator::value && _active; - }; - - /*! \brief set output to a different stream. + } - Old stream data is stored - */ + /*! \brief set output to a different stream. + + Old stream data is stored + */ void attach(std::ostream& stream) { if (_tied) DUNE_THROW(DebugStreamError, "Cannot attach to a tied stream!"); StreamWrap* newcurr = new StreamWrap(stream); newcurr->next = current; - current = newcurr; - }; - + current = newcurr; + } + //! \brief detach current output stream and restore to previous stream void detach() throw(DebugStreamError) { if (current->next == 0) DUNE_THROW(DebugStreamError, "Cannot detach initial stream!"); if (_tied) DUNE_THROW(DebugStreamError, "Cannot detach a tied stream!"); - + StreamWrap* old = current; current = current->next; delete old; - }; + } // \brief Tie a stream to this one. void tie(DebugStreamState& to) throw(DebugStreamError) { @@ -389,11 +391,11 @@ _tied = true; tiedstate = &to; - + // tell master class tiedstate->_tied_streams++; - }; - + } + //! \brief Untie stream void untie() throw(DebugStreamError) { if(! _tied) @@ -402,18 +404,18 @@ tiedstate->_tied_streams--; _tied = false; tiedstate = 0; - }; + } private: //! \brief pointer to data of stream we're tied to DebugStreamState* tiedstate; /*! \brief Activation state history. - - store old activation settings so that the outside code doesn't - need to remember */ + + store old activation settings so that the outside code doesn't + need to remember */ std::stack _actstack; - }; + }; /** /} */ } diff -Nru dune-common-2.2.1/dune/common/densematrix.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/densematrix.hh --- dune-common-2.2.1/dune/common/densematrix.hh 2013-02-26 12:26:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/densematrix.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,25 +1,27 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: -// $Id: fmatrix.hh 6128 2010-09-08 13:50:00Z christi $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_DENSEMATRIX_HH #define DUNE_DENSEMATRIX_HH #include #include #include +#include #include -#include +#include #include #include #include -#include #include +#include +#include +#include namespace Dune { - + template class DenseMatrix; template @@ -30,8 +32,8 @@ }; /* - work around a problem of FieldMatrix/FieldVector, - there is no unique way to obtain the size of a class + work around a problem of FieldMatrix/FieldVector, + there is no unique way to obtain the size of a class */ template class FieldMatrix; template class FieldVector; @@ -49,59 +51,95 @@ static typename V::size_type size(const V & v) { return N; } }; } - -/** - @addtogroup DenseMatVec - @{ -*/ - -/*! \file - - \brief Implements a matrix constructed from a given type - representing a field and a compile-time given number of rows and columns. -*/ /** - \brief you have to specialize this function for any type T that should be assignable to a DenseMatrix - \tparam M Type of the matrix implementation class implementing the dense matrix - */ - template - void istl_assign_to_fmatrix(DenseMatrix& f, const T& t) - { - DUNE_THROW(NotImplemented, "You need to specialise the method istl_assign_to_fmatrix(DenseMatrix& f, const T& t) " - << "(with M being " << className() << ") " - << "for T == " << className() << "!"); - } + @addtogroup DenseMatVec + @{ + */ + + /*! \file + + \brief Implements a matrix constructed from a given type + representing a field and a compile-time given number of rows and columns. + */ + + - namespace + /** + \brief you have to specialize this structure for any type that should be assignable to a DenseMatrix + \tparam DenseMatrix Some type implementing the dense matrix interface + \tparam RHS Right hand side type + */ + template< class DenseMatrix, class RHS > + struct DenseMatrixAssigner; + +#ifndef DOXYGEN + namespace Impl { - template - struct DenseMatrixAssigner + + template< class DenseMatrix, class RHS, class = void > + class DenseMatrixAssigner + {}; + + template< class DenseMatrix, class RHS > + class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< Dune::IsNumber< RHS >::value > > { - template - static void assign(DenseMatrix& fm, const T& t) + public: + static void apply ( DenseMatrix &denseMatrix, const RHS &rhs ) { - istl_assign_to_fmatrix(fm, t); + typedef typename DenseMatrix::field_type field_type; + std::fill( denseMatrix.begin(), denseMatrix.end(), static_cast< field_type >( rhs ) ); } - }; - - template<> - struct DenseMatrixAssigner + template< class DenseMatrix, class RHS > + class DenseMatrixAssigner< DenseMatrix, RHS, std::enable_if_t< !std::is_same< typename RHS::const_iterator, void >::value > > { - template - static void assign(DenseMatrix& fm, const T& t) + public: + static void apply ( DenseMatrix &denseMatrix, const RHS &rhs ) { - fm = static_cast::value_type>(t); + DUNE_ASSERT_BOUNDS(rhs.N() == denseMatrix.N()); + DUNE_ASSERT_BOUNDS(rhs.M() == denseMatrix.M()); + typename DenseMatrix::iterator tIt = std::begin(denseMatrix); + typename RHS::const_iterator sIt = std::begin(rhs); + for(; sIt != std::end(rhs); ++tIt, ++sIt) + std::copy(std::begin(*sIt), std::end(*sIt), std::begin(*tIt)); } }; - } - + + } // namespace Impl + + + + template< class DenseMatrix, class RHS > + struct DenseMatrixAssigner + : public Impl::DenseMatrixAssigner< DenseMatrix, RHS > + {}; + + + namespace Impl + { + + template< class DenseMatrix, class RHS > + std::true_type hasDenseMatrixAssigner ( DenseMatrix &, const RHS &, decltype( Dune::DenseMatrixAssigner< DenseMatrix, RHS >::apply( std::declval< DenseMatrix & >(), std::declval< const RHS & >() ) ) * = nullptr ); + + std::false_type hasDenseMatrixAssigner ( ... ); + + } // namespace Impl + + template< class DenseMatrix, class RHS > + struct HasDenseMatrixAssigner + : public decltype( Impl::hasDenseMatrixAssigner( std::declval< DenseMatrix & >(), std::declval< const RHS & >() ) ) + {}; + +#endif // #ifndef DOXYGEN + + + /** @brief Error thrown if operations of a FieldMatrix fail. */ - class FMatrixError : public Exception {}; + class FMatrixError : public MathError {}; - /** + /** @brief A dense n x m matrix. Matrices represent linear maps from a vector space V to a vector space W. @@ -110,7 +148,7 @@ columns is given at compile time. \tparam MAT type of the matrix implementation - */ + */ template class DenseMatrix { @@ -119,7 +157,7 @@ // Curiously recurring template pattern MAT & asImp() { return static_cast(*this); } const MAT & asImp() const { return static_cast(*this); } - + public: //===== type definitions and constants @@ -137,7 +175,7 @@ //! The type used for the index access and size operation typedef typename Traits::size_type size_type; - + //! The type used to represent a row (must fulfill the Dune::DenseVector interface) typedef typename Traits::row_type row_type; @@ -154,40 +192,40 @@ }; //===== access to components - + //! random access row_reference operator[] ( size_type i ) { return asImp().mat_access(i); } - + const_row_reference operator[] ( size_type i ) const { return asImp().mat_access(i); } - + //! size method (number of rows) size_type size() const { return rows(); } - + //===== iterator interface to rows of the matrix //! Iterator class for sequential access - typedef DenseIterator Iterator; + typedef DenseIterator Iterator; //! typedef for stl compliant access typedef Iterator iterator; //! rename the iterators for easier access typedef Iterator RowIterator; //! rename the iterators for easier access - typedef typename row_type::Iterator ColIterator; + typedef typename std::remove_reference::type::Iterator ColIterator; //! begin iterator Iterator begin () { return Iterator(*this,0); } - + //! end iterator Iterator end () { @@ -209,20 +247,20 @@ } //! Iterator class for sequential access - typedef DenseIterator ConstIterator; + typedef DenseIterator ConstIterator; //! typedef for stl compliant access typedef ConstIterator const_iterator; //! rename the iterators for easier access typedef ConstIterator ConstRowIterator; //! rename the iterators for easier access - typedef typename row_type::ConstIterator ConstColIterator; + typedef typename std::remove_reference::type::ConstIterator ConstColIterator; //! begin iterator ConstIterator begin () const { return ConstIterator(*this,0); } - + //! end iterator ConstIterator end () const { @@ -235,7 +273,7 @@ { return ConstIterator(*this,rows()-1); } - + //! @returns an iterator that is positioned before //! the first entry of the vector. ConstIterator beforeBegin () const @@ -243,26 +281,22 @@ return ConstIterator(*this,-1); } - //===== assignment from scalar - DenseMatrix& operator= (const field_type& f) - { - for (size_type i=0; i - DenseMatrix& operator= (const T& t) + template< class RHS, class = std::enable_if_t< HasDenseMatrixAssigner< MAT, RHS >::value > > + DenseMatrix &operator= ( const RHS &rhs ) { - DenseMatrixAssigner::exists>::assign(*this, t); + DenseMatrixAssigner< MAT, RHS >::apply( asImp(), rhs ); return *this; } + //===== vector space arithmetic //! vector space addition template DenseMatrix& operator+= (const DenseMatrix& y) { + DUNE_ASSERT_BOUNDS(rows() == y.rows()); for (size_type i=0; i DenseMatrix& operator-= (const DenseMatrix& y) { + DUNE_ASSERT_BOUNDS(rows() == y.rows()); for (size_type i=0; i DenseMatrix &axpy (const field_type &k, const DenseMatrix &y ) { + DUNE_ASSERT_BOUNDS(rows() == y.rows()); for( size_type i = 0; i < rows(); ++i ) (*this)[ i ].axpy( k, y[ i ] ); return *this; @@ -306,6 +342,7 @@ template bool operator== (const DenseMatrix& y) const { + DUNE_ASSERT_BOUNDS(rows() == y.rows()); for (size_type i=0; i void mv (const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=M()) DUNE_THROW(FMatrixError,"Index out of range"); - if (y.N()!=N()) DUNE_THROW(FMatrixError,"Index out of range"); -#endif + DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y)); + DUNE_ASSERT_BOUNDS(x.N() == M()); + DUNE_ASSERT_BOUNDS(y.N() == N()); + + using field_type = typename FieldTraits::field_type; for (size_type i=0; i void mtv ( const X &x, Y &y ) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - //assert( &x != &y ); - //This assert did not work for me. Compile error: - // comparison between distinct pointer types ‘const - // Dune::FieldVector*’ and ‘Dune::FieldVector*’ lacks a cast - if( x.N() != N() ) - DUNE_THROW( FMatrixError, "Index out of range." ); - if( y.N() != M() ) - DUNE_THROW( FMatrixError, "Index out of range." ); -#endif - for( size_type i = 0; i < cols(); ++i ) + DUNE_ASSERT_BOUNDS((void*)(&x) != (void*)(&y)); + DUNE_ASSERT_BOUNDS(x.N() == N()); + DUNE_ASSERT_BOUNDS(y.N() == M()); + + using field_type = typename FieldTraits::field_type; + for(size_type i = 0; i < cols(); ++i) { - y[ i ] = 0; - for( size_type j = 0; j < rows(); ++j ) - y[ i ] += (*this)[ j ][ i ] * x[ j ]; + y[i] = field_type(0); + for(size_type j = 0; j < rows(); ++j) + y[i] += (*this)[j][i] * x[j]; } } @@ -363,12 +396,8 @@ template void umv (const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=M()) - DUNE_THROW(FMatrixError,"y += A x -- index out of range (sizes: x: " << x.N() << ", y: " << y.N() << ", A: " << this->N() << " x " << this->M() << ")" << std::endl); - if (y.N()!=N()) - DUNE_THROW(FMatrixError,"y += A x -- index out of range (sizes: x: " << x.N() << ", y: " << y.N() << ", A: " << this->N() << " x " << this->M() << ")" << std::endl); -#endif + DUNE_ASSERT_BOUNDS(x.N() == M()); + DUNE_ASSERT_BOUNDS(y.N() == N()); for (size_type i=0; i void umtv (const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); - if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); -#endif - + DUNE_ASSERT_BOUNDS(x.N() == N()); + DUNE_ASSERT_BOUNDS(y.N() == M()); for (size_type i=0; i void umhv (const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); - if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); -#endif - + DUNE_ASSERT_BOUNDS(x.N() == N()); + DUNE_ASSERT_BOUNDS(y.N() == M()); for (size_type i=0; i void mmv (const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); - if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); -#endif + DUNE_ASSERT_BOUNDS(x.N() == M()); + DUNE_ASSERT_BOUNDS(y.N() == N()); for (size_type i=0; i void mmtv (const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); - if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); -#endif - + DUNE_ASSERT_BOUNDS(x.N() == N()); + DUNE_ASSERT_BOUNDS(y.N() == M()); for (size_type i=0; i void mmhv (const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); - if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); -#endif - + DUNE_ASSERT_BOUNDS(x.N() == N()); + DUNE_ASSERT_BOUNDS(y.N() == M()); for (size_type i=0; i - void usmv (const field_type& alpha, const X& x, Y& y) const + void usmv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); - if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); -#endif + DUNE_ASSERT_BOUNDS(x.N() == M()); + DUNE_ASSERT_BOUNDS(y.N() == N()); for (size_type i=0; i - void usmtv (const field_type& alpha, const X& x, Y& y) const + void usmtv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); - if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); -#endif - + DUNE_ASSERT_BOUNDS(x.N() == N()); + DUNE_ASSERT_BOUNDS(y.N() == M()); for (size_type i=0; i - void usmhv (const field_type& alpha, const X& x, Y& y) const + void usmhv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const { -#ifdef DUNE_FMatrix_WITH_CHECKING - if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); - if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); -#endif - + DUNE_ASSERT_BOUNDS(x.N() == N()); + DUNE_ASSERT_BOUNDS(y.N() == M()); for (size_type i=0; i::real_type infinity_norm () const - { - if (size() == 0) - return 0.0; - - ConstIterator it = begin(); - typename remove_const< typename FieldTraits::real_type >::type max = it->one_norm(); - for (it = it + 1; it != end(); ++it) - max = std::max(max, it->one_norm()); - - return max; + template ::value, int>::type = 0> + typename FieldTraits::real_type infinity_norm() const { + using real_type = typename FieldTraits::real_type; + using std::max; + + real_type norm = 0; + for (auto const &x : *this) { + real_type const a = x.one_norm(); + norm = max(a, norm); + } + return norm; } //! simplified infinity norm (uses Manhattan norm for complex values) - typename FieldTraits::real_type infinity_norm_real () const - { - if (size() == 0) - return 0.0; + template ::value, int>::type = 0> + typename FieldTraits::real_type infinity_norm_real() const { + using real_type = typename FieldTraits::real_type; + using std::max; + + real_type norm = 0; + for (auto const &x : *this) { + real_type const a = x.one_norm_real(); + norm = max(a, norm); + } + return norm; + } - ConstIterator it = begin(); - typename remove_const< typename FieldTraits::real_type >::type max = it->one_norm_real(); - for (it = it + 1; it != end(); ++it) - max = std::max(max, it->one_norm_real()); + //! infinity norm (row sum norm, how to generalize for blocks?) + template ::value, int>::type = 0> + typename FieldTraits::real_type infinity_norm() const { + using real_type = typename FieldTraits::real_type; + using std::max; + + real_type norm = 0; + real_type isNaN = 1; + for (auto const &x : *this) { + real_type const a = x.one_norm(); + norm = max(a, norm); + isNaN += a; + } + isNaN /= isNaN; + return norm * isNaN; + } - return max; + //! simplified infinity norm (uses Manhattan norm for complex values) + template ::value, int>::type = 0> + typename FieldTraits::real_type infinity_norm_real() const { + using real_type = typename FieldTraits::real_type; + using std::max; + + real_type norm = 0; + real_type isNaN = 1; + for (auto const &x : *this) { + real_type const a = x.one_norm_real(); + norm = max(a, norm); + isNaN += a; + } + isNaN /= isNaN; + return norm * isNaN; } //===== solve @@ -545,14 +593,15 @@ */ void invert(); - //! calculates the determinant of this matrix + //! calculates the determinant of this matrix field_type determinant () const; //! Multiplies M from the left to this matrix template MAT& leftmultiply (const DenseMatrix& M) { - assert(M.rows() == M.cols() && M.rows() == rows()); + DUNE_ASSERT_BOUNDS(M.rows() == M.cols()); + DUNE_ASSERT_BOUNDS(M.rows() == rows()); MAT C(asImp()); for (size_type i=0; i MAT& rightmultiply (const DenseMatrix& M) { - assert(M.rows() == M.cols() && M.cols() == cols()); + DUNE_ASSERT_BOUNDS(M.rows() == M.cols()); + DUNE_ASSERT_BOUNDS(M.cols() == cols()); MAT C(asImp()); - + for (size_type i=0; i leftmultiplyany (const FieldMatrix& M) const { FieldMatrix C; - + for (size_type i=0; i rightmultiplyany (const FieldMatrix& M) const { FieldMatrix C; - + for (size_type i=0; i=rows()) DUNE_THROW(FMatrixError,"row index out of range"); - if (j<0 || j>=cols()) DUNE_THROW(FMatrixError,"column index out of range"); -#endif + DUNE_UNUSED_PARAMETER(i); + DUNE_UNUSED_PARAMETER(j); + DUNE_ASSERT_BOUNDS(i >= 0 && i < rows()); + DUNE_ASSERT_BOUNDS(j >= 0 && j < cols()); return true; } @@ -659,13 +709,13 @@ struct ElimPivot { ElimPivot(std::vector & pivot); - + void swap(int i, int j); - + template - void operator()(const T&, int k, int i) + void operator()(const T&, int, int) {} - + std::vector & pivot_; }; @@ -673,9 +723,9 @@ struct Elim { Elim(V& rhs); - + void swap(int i, int j); - + void operator()(const typename V::field_type& factor, int k, int i); V* rhs_; @@ -686,16 +736,16 @@ ElimDet(field_type& sign) : sign_(sign) { sign_ = 1; } - void swap(int i, int j) + void swap(int, int) { sign_ *= -1; } - void operator()(const field_type&, int k, int i) + void operator()(const field_type&, int, int) {} field_type& sign_; }; #endif // DOXYGEN - + template void luDecomposition(DenseMatrix& A, Func func) const; }; @@ -714,13 +764,13 @@ { pivot_[i]=j; } - + template template DenseMatrix::Elim::Elim(V& rhs) : rhs_(&rhs) {} - + template template void DenseMatrix::Elim::swap(int i, int j) @@ -740,16 +790,16 @@ inline void DenseMatrix::luDecomposition(DenseMatrix& A, Func func) const { typedef typename FieldTraits::real_type - real_type; + real_type; real_type norm = A.infinity_norm_real(); // for relative thresholds real_type pivthres = std::max( FMatrixPrecision< real_type >::absolute_limit(), norm * FMatrixPrecision< real_type >::pivoting_limit() ); real_type singthres = std::max( FMatrixPrecision< real_type >::absolute_limit(), norm * FMatrixPrecision< real_type >::singular_limit() ); - + // LU decomposition of A in A for (size_type i=0; i::real_type pivmax=fvmeta::absreal(A[i][i]); - + // pivoting ? if (pivmax::absolute_limit()) - DUNE_THROW(FMatrixError,"matrix is singular"); + DUNE_THROW(FMatrixError,"matrix is singular"); #endif x[0] = b[0]/(*this)[0][0]; } else if (rows()==2) { - + field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0]; #ifdef DUNE_FMatrix_WITH_CHECKING if (fvmeta::absreal(detinv)::absolute_limit()) DUNE_THROW(FMatrixError,"matrix is singular"); #endif detinv = 1.0/detinv; - + x[0] = detinv*((*this)[1][1]*b[0]-(*this)[0][1]*b[1]); x[1] = detinv*((*this)[0][0]*b[1]-(*this)[1][0]*b[0]); @@ -824,16 +874,16 @@ #endif x[0] = (b[0]*(*this)[1][1]*(*this)[2][2] - b[0]*(*this)[2][1]*(*this)[1][2] - - b[1] *(*this)[0][1]*(*this)[2][2] + b[1]*(*this)[2][1]*(*this)[0][2] - + b[2] *(*this)[0][1]*(*this)[1][2] - b[2]*(*this)[1][1]*(*this)[0][2]) / d; + - b[1] *(*this)[0][1]*(*this)[2][2] + b[1]*(*this)[2][1]*(*this)[0][2] + + b[2] *(*this)[0][1]*(*this)[1][2] - b[2]*(*this)[1][1]*(*this)[0][2]) / d; x[1] = ((*this)[0][0]*b[1]*(*this)[2][2] - (*this)[0][0]*b[2]*(*this)[1][2] - - (*this)[1][0] *b[0]*(*this)[2][2] + (*this)[1][0]*b[2]*(*this)[0][2] - + (*this)[2][0] *b[0]*(*this)[1][2] - (*this)[2][0]*b[1]*(*this)[0][2]) / d; + - (*this)[1][0] *b[0]*(*this)[2][2] + (*this)[1][0]*b[2]*(*this)[0][2] + + (*this)[2][0] *b[0]*(*this)[1][2] - (*this)[2][0]*b[1]*(*this)[0][2]) / d; x[2] = ((*this)[0][0]*(*this)[1][1]*b[2] - (*this)[0][0]*(*this)[2][1]*b[1] - - (*this)[1][0] *(*this)[0][1]*b[2] + (*this)[1][0]*(*this)[2][1]*b[0] - + (*this)[2][0] *(*this)[0][1]*b[1] - (*this)[2][0]*(*this)[1][1]*b[0]) / d; + - (*this)[1][0] *(*this)[0][1]*b[2] + (*this)[1][0]*(*this)[2][1]*b[0] + + (*this)[2][0] *(*this)[0][1]*b[1] - (*this)[2][0]*(*this)[1][1]*b[0]) / d; } else { @@ -842,16 +892,16 @@ rhs = b; // copy data Elim elim(rhs); MAT A(asImp()); - + luDecomposition(A, elim); - + // backsolve - for(int i=rows()-1; i>=0; i--){ + for(int i=rows()-1; i>=0; i--) { for (size_type j=i+1; j @@ -862,22 +912,22 @@ DUNE_THROW(FMatrixError, "Can't invert a " << rows() << "x" << cols() << " matrix!"); if (rows()==1) { - + #ifdef DUNE_FMatrix_WITH_CHECKING if (fvmeta::absreal((*this)[0][0])::absolute_limit()) - DUNE_THROW(FMatrixError,"matrix is singular"); + DUNE_THROW(FMatrixError,"matrix is singular"); #endif - (*this)[0][0] = 1.0/(*this)[0][0]; - + (*this)[0][0] = field_type( 1 ) / (*this)[0][0]; + } else if (rows()==2) { field_type detinv = (*this)[0][0]*(*this)[1][1]-(*this)[0][1]*(*this)[1][0]; #ifdef DUNE_FMatrix_WITH_CHECKING if (fvmeta::absreal(detinv)::absolute_limit()) - DUNE_THROW(FMatrixError,"matrix is singular"); + DUNE_THROW(FMatrixError,"matrix is singular"); #endif - detinv = 1.0/detinv; + detinv = field_type( 1 ) / detinv; field_type temp=(*this)[0][0]; (*this)[0][0] = (*this)[1][1]*detinv; @@ -886,37 +936,67 @@ (*this)[1][1] = temp*detinv; } + else if (rows()==3) + { + using K = field_type; + // code generated by maple + K t4 = (*this)[0][0] * (*this)[1][1]; + K t6 = (*this)[0][0] * (*this)[1][2]; + K t8 = (*this)[0][1] * (*this)[1][0]; + K t10 = (*this)[0][2] * (*this)[1][0]; + K t12 = (*this)[0][1] * (*this)[2][0]; + K t14 = (*this)[0][2] * (*this)[2][0]; + + K det = (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+ + t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]); + K t17 = K(1.0)/det; + + K matrix01 = (*this)[0][1]; + K matrix00 = (*this)[0][0]; + K matrix10 = (*this)[1][0]; + K matrix11 = (*this)[1][1]; + + (*this)[0][0] = ((*this)[1][1] * (*this)[2][2] - (*this)[1][2] * (*this)[2][1])*t17; + (*this)[0][1] = -((*this)[0][1] * (*this)[2][2] - (*this)[0][2] * (*this)[2][1])*t17; + (*this)[0][2] = (matrix01 * (*this)[1][2] - (*this)[0][2] * (*this)[1][1])*t17; + (*this)[1][0] = -((*this)[1][0] * (*this)[2][2] - (*this)[1][2] * (*this)[2][0])*t17; + (*this)[1][1] = (matrix00 * (*this)[2][2] - t14) * t17; + (*this)[1][2] = -(t6-t10) * t17; + (*this)[2][0] = (matrix10 * (*this)[2][1] - matrix11 * (*this)[2][0]) * t17; + (*this)[2][1] = -(matrix00 * (*this)[2][1] - t12) * t17; + (*this)[2][2] = (t4-t8) * t17; + } else { - + MAT A(asImp()); std::vector pivot(rows()); luDecomposition(A, ElimPivot(pivot)); DenseMatrix& L=A; DenseMatrix& U=A; - + // initialize inverse *this=field_type(); - + for(size_type i=0; i0;){ + for (size_type i=rows(); i>0;) { --i; - for (size_type k=0; k0; ){ + for(size_type i=rows(); i>0; ) { --i; if(i!=pivot[i]) for(size_type j=0; j inline typename DenseMatrix::field_type DenseMatrix::determinant() const @@ -936,21 +1016,21 @@ if (rows()==1) return (*this)[0][0]; - + if (rows()==2) - return (*this)[0][0]*(*this)[1][1] - (*this)[0][1]*(*this)[1][0]; + return (*this)[0][0]*(*this)[1][1] - (*this)[0][1]*(*this)[1][0]; if (rows()==3) { - // code generated by maple + // code generated by maple field_type t4 = (*this)[0][0] * (*this)[1][1]; field_type t6 = (*this)[0][0] * (*this)[1][2]; field_type t8 = (*this)[0][1] * (*this)[1][0]; field_type t10 = (*this)[0][2] * (*this)[1][0]; field_type t12 = (*this)[0][1] * (*this)[2][0]; field_type t14 = (*this)[0][2] * (*this)[2][0]; - + return (t4*(*this)[2][2]-t6*(*this)[2][1]-t8*(*this)[2][2]+ - t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]); + t10*(*this)[2][1]+t12*(*this)[1][2]-t14*(*this)[1][1]); } @@ -972,153 +1052,15 @@ #endif // DOXYGEN namespace DenseMatrixHelp { -#if 0 - //! invert scalar without changing the original matrix - template - static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) - { - inverse[0][0] = 1.0/matrix[0][0]; - return matrix[0][0]; - } - - //! invert scalar without changing the original matrix - template - static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) - { - return invertMatrix(matrix,inverse); - } - - - //! invert 2x2 Matrix without changing the original matrix - template - static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) - { - // code generated by maple - field_type det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]); - field_type det_1 = 1.0/det; - inverse[0][0] = matrix[1][1] * det_1; - inverse[0][1] = - matrix[0][1] * det_1; - inverse[1][0] = - matrix[1][0] * det_1; - inverse[1][1] = matrix[0][0] * det_1; - return det; - } - - //! invert 2x2 Matrix without changing the original matrix - //! return transposed matrix - template - static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) - { - // code generated by maple - field_type det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]); - field_type det_1 = 1.0/det; - inverse[0][0] = matrix[1][1] * det_1; - inverse[1][0] = - matrix[0][1] * det_1; - inverse[0][1] = - matrix[1][0] * det_1; - inverse[1][1] = matrix[0][0] * det_1; - return det; - } - - //! invert 3x3 Matrix without changing the original matrix - template - static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) - { - // code generated by maple - field_type t4 = matrix[0][0] * matrix[1][1]; - field_type t6 = matrix[0][0] * matrix[1][2]; - field_type t8 = matrix[0][1] * matrix[1][0]; - field_type t10 = matrix[0][2] * matrix[1][0]; - field_type t12 = matrix[0][1] * matrix[2][0]; - field_type t14 = matrix[0][2] * matrix[2][0]; - - field_type det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+ - t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]); - field_type t17 = 1.0/det; - - inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17; - inverse[0][1] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17; - inverse[0][2] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17; - inverse[1][0] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17; - inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17; - inverse[1][2] = -(t6-t10) * t17; - inverse[2][0] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17; - inverse[2][1] = -(matrix[0][0] * matrix[2][1] - t12) * t17; - inverse[2][2] = (t4-t8) * t17; - - return det; - } - - //! invert 3x3 Matrix without changing the original matrix - template - static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) - { - // code generated by maple - field_type t4 = matrix[0][0] * matrix[1][1]; - field_type t6 = matrix[0][0] * matrix[1][2]; - field_type t8 = matrix[0][1] * matrix[1][0]; - field_type t10 = matrix[0][2] * matrix[1][0]; - field_type t12 = matrix[0][1] * matrix[2][0]; - field_type t14 = matrix[0][2] * matrix[2][0]; - - field_type det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+ - t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]); - field_type t17 = 1.0/det; - - inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17; - inverse[1][0] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17; - inverse[2][0] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17; - inverse[0][1] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17; - inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17; - inverse[2][1] = -(t6-t10) * t17; - inverse[0][2] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17; - inverse[1][2] = -(matrix[0][0] * matrix[2][1] - t12) * t17; - inverse[2][2] = (t4-t8) * t17; - - return det; - } - - //! calculates ret = A * B - template< class K, int m, int n, int p > - static inline void multMatrix ( const FieldMatrix< K, m, n > &A, - const FieldMatrix< K, n, p > &B, - FieldMatrix< K, m, p > &ret ) - { - typedef typename FieldMatrix< K, m, p > :: size_type size_type; - for( size_type i = 0; i < m; ++i ) - { - for( size_type j = 0; j < p; ++j ) - { - ret[ i ][ j ] = K( 0 ); - for( size_type k = 0; k < n; ++k ) - ret[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ]; - } - } - } - - //! calculates ret= A_t*A - template - static inline void multTransposedMatrix(const FieldMatrix &matrix, FieldMatrix& ret) - { - typedef typename FieldMatrix::size_type size_type; - - for(size_type i=0; i - static inline void multAssign(const DenseMatrix &matrix, const DenseVector & x, DenseVector & ret) + static inline void multAssign(const DenseMatrix &matrix, const DenseVector & x, DenseVector & ret) { - assert(x.size() == matrix.cols()); - assert(ret.size() == matrix.rows()); + DUNE_ASSERT_BOUNDS(x.size() == matrix.cols()); + DUNE_ASSERT_BOUNDS(ret.size() == matrix.rows()); typedef typename DenseMatrix::size_type size_type; - + for(size_type i=0; i - static inline void multAssignTransposed( const FieldMatrix &matrix, const FieldVector & x, FieldVector & ret) + static inline void multAssignTransposed( const FieldMatrix &matrix, const FieldVector & x, FieldVector & ret) { typedef typename FieldMatrix::size_type size_type; - + for(size_type i=0; i - static inline FieldVector mult(const FieldMatrix &matrix, const FieldVector & x) + static inline FieldVector mult(const FieldMatrix &matrix, const FieldVector & x) { FieldVector ret; multAssign(matrix,x,ret); return ret; } - //! calculates ret = matrix^T * x + //! calculates ret = matrix^T * x template - static inline FieldVector multTransposed(const FieldMatrix &matrix, const FieldVector & x) + static inline FieldVector multTransposed(const FieldMatrix &matrix, const FieldVector & x) { FieldVector ret; multAssignTransposed( matrix, x, ret ); - return ret; + return ret; } #endif - } // end namespace DenseMatrixHelp + } // end namespace DenseMatrixHelp /** \brief Sends the matrix to an output stream */ template @@ -1174,7 +1116,7 @@ return s; } -/** @} end documentation */ + /** @} end documentation */ } // end namespace Dune diff -Nru dune-common-2.2.1/dune/common/densevector.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/densevector.hh --- dune-common-2.2.1/dune/common/densevector.hh 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/densevector.hh 2017-08-08 08:39:46.000000000 +0000 @@ -4,11 +4,14 @@ #define DUNE_DENSEVECTOR_HH #include +#include #include "genericiterator.hh" #include "ftraits.hh" #include "matvectraits.hh" - +#include "promotiontraits.hh" +#include "dotproduct.hh" +#include "boundschecking.hh" namespace Dune { @@ -22,87 +25,91 @@ typedef typename FieldTraits< typename DenseMatVecTraits::value_type >::real_type real_type; }; -/** @defgroup DenseMatVec Dense Matrix and Vector Template Library - @ingroup Common - @{ -*/ - -/*! \file - * \brief Implements the dense vector interface, with an exchangeable storage class - */ + /** @defgroup DenseMatVec Dense Matrix and Vector Template Library + @ingroup Common + @{ + */ + + /*! \file + * \brief Implements the dense vector interface, with an exchangeable storage class + */ namespace fvmeta { /** \private \memberof Dune::DenseVector - */ + */ template inline typename FieldTraits::real_type absreal (const K& k) { - return std::abs(k); + using std::abs; + return abs(k); } /** \private \memberof Dune::DenseVector - */ + */ template inline typename FieldTraits::real_type absreal (const std::complex& c) { - return std::abs(c.real()) + std::abs(c.imag()); + using std::abs; + return abs(c.real()) + abs(c.imag()); } /** \private \memberof Dune::DenseVector - */ + */ template inline typename FieldTraits::real_type abs2 (const K& k) { return k*k; } - + /** \private \memberof Dune::DenseVector - */ + */ template inline typename FieldTraits::real_type abs2 (const std::complex& c) { return c.real()*c.real() + c.imag()*c.imag(); } - + /** \private \memberof Dune::DenseVector - */ + */ template::is_integer> struct Sqrt { static inline typename FieldTraits::real_type sqrt (const K& k) { - return std::sqrt(k); + using std::sqrt; + return sqrt(k); } }; - + /** \private \memberof Dune::DenseVector - */ + */ template struct Sqrt { static inline typename FieldTraits::real_type sqrt (const K& k) { - return typename FieldTraits::real_type(std::sqrt(double(k))); + using std::sqrt; + return typename FieldTraits::real_type(sqrt(double(k))); } }; - + /** \private \memberof Dune::DenseVector - */ + */ template inline typename FieldTraits::real_type sqrt (const K& k) { @@ -113,17 +120,19 @@ /*! \brief Generic iterator class for dense vector and matrix implementations - provides sequential access to DenseVector, FieldVector and FieldMatrix + provides sequential access to DenseVector, FieldVector and FieldMatrix */ - template - class DenseIterator : - public Dune::RandomAccessIteratorFacade,T, T&, std::ptrdiff_t> + template + class DenseIterator : + public Dune::RandomAccessIteratorFacade,T, R, std::ptrdiff_t> { - friend class DenseIterator::type, typename remove_const::type >; - friend class DenseIterator::type, const typename remove_const::type >; - + friend class DenseIterator::type, typename std::remove_const::type, typename mutable_reference::type >; + friend class DenseIterator::type, const typename std::remove_const::type, typename const_reference::type >; + + typedef DenseIterator::type, typename std::remove_const::type, typename mutable_reference::type > MutableIterator; + typedef DenseIterator::type, const typename std::remove_const::type, typename const_reference::type > ConstIterator; public: - + /** * @brief The type of the difference between two positions. */ @@ -133,72 +142,76 @@ * @brief The type to index the underlying container. */ typedef typename C::size_type SizeType; - + // Constructors needed by the base iterators. DenseIterator() : container_(0), position_() {} - + DenseIterator(C& cont, SizeType pos) : container_(&cont), position_(pos) {} - - DenseIterator(const DenseIterator::type, typename remove_const::type >& other) + + DenseIterator(const MutableIterator & other) + : container_(other.container_), position_(other.position_) + {} + + DenseIterator(const ConstIterator & other) : container_(other.container_), position_(other.position_) {} - + // Methods needed by the forward iterator - bool equals(const DenseIterator::type,typename remove_const::type>& other) const + bool equals(const MutableIterator &other) const { return position_ == other.position_ && container_ == other.container_; } - - - bool equals(const DenseIterator::type,const typename remove_const::type>& other) const + + + bool equals(const ConstIterator & other) const { return position_ == other.position_ && container_ == other.container_; } - - T& dereference() const{ + + R dereference() const { return container_->operator[](position_); } - + void increment(){ ++position_; } - + // Additional function needed by BidirectionalIterator void decrement(){ --position_; } - + // Additional function needed by RandomAccessIterator - T& elementAt(DifferenceType i)const{ + R elementAt(DifferenceType i) const { return container_->operator[](position_+i); } - + void advance(DifferenceType n){ position_=position_+n; } - - DifferenceType distanceTo(DenseIterator::type,const typename remove_const::type> other)const + + DifferenceType distanceTo(DenseIterator::type,const typename std::remove_const::type> other) const { assert(other.container_==container_); - return other.position_ - position_; + return static_cast< DifferenceType >( other.position_ ) - static_cast< DifferenceType >( position_ ); } - - DifferenceType distanceTo(DenseIterator::type, typename remove_const::type> other)const + + DifferenceType distanceTo(DenseIterator::type, typename std::remove_const::type> other) const { assert(other.container_==container_); - return other.position_ - position_; + return static_cast< DifferenceType >( other.position_ ) - static_cast< DifferenceType >( position_ ); } - + //! return index SizeType index () const { return this->position_; } - + private: C *container_; SizeType position_; @@ -226,7 +239,14 @@ // Curiously recurring template pattern V & asImp() { return static_cast(*this); } const V & asImp() const { return static_cast(*this); } - + + // prohibit copying + DenseVector ( const DenseVector & ); + + protected: + // construction allowed to derived classes only + constexpr DenseVector () {} + public: //===== type definitions and constants @@ -237,14 +257,14 @@ typedef typename Traits::value_type value_type; //! export the type representing the field - typedef typename Traits::value_type field_type; + typedef typename FieldTraits< value_type >::field_type field_type; //! export the type representing the components typedef typename Traits::value_type block_type; //! The type used for the index access and size operation typedef typename Traits::size_type size_type; - + //! We are at the leaf of the block recursion enum { //! The number of block levels we contain @@ -257,7 +277,7 @@ { for (size_type i=0; i Iterator; //! typedef for stl compliant access typedef Iterator iterator; - + //! begin iterator Iterator begin () { @@ -352,14 +372,14 @@ { return ConstIterator(*this,std::min(i,size())); } - + //===== vector space arithmetic //! vector space addition template derived_type& operator+= (const DenseVector& y) { - assert(y.size() == size()); + DUNE_ASSERT_BOUNDS(y.size() == size()); for (size_type i=0; i derived_type& operator-= (const DenseVector& y) { - assert(y.size() == size()); + DUNE_ASSERT_BOUNDS(y.size() == size()); for (size_type i=0; i + typename std::enable_if< + std::is_convertible::value, + derived_type + >::type& + operator+= (const ValueType& kk) { + const value_type& k = kk; for (size_type i=0; i + typename std::enable_if< + std::is_convertible::value, + derived_type + >::type& + operator-= (const ValueType& kk) { + const value_type& k = kk; for (size_type i=0; i + typename std::enable_if< + std::is_convertible::value, + derived_type + >::type& + operator*= (const FieldType& kk) { + const field_type& k = kk; for (size_type i=0; i + typename std::enable_if< + std::is_convertible::value, + derived_type + >::type& + operator/= (const FieldType& kk) { + const field_type& k = kk; for (size_type i=0; i bool operator== (const DenseVector& y) const { - assert(y.size() == size()); + DUNE_ASSERT_BOUNDS(y.size() == size()); for (size_type i=0; i - derived_type& axpy (const value_type& a, const DenseVector& y) + derived_type& axpy (const field_type& a, const DenseVector& y) { - assert(y.size() == size()); + DUNE_ASSERT_BOUNDS(y.size() == size()); for (size_type i=0; i + typename PromotionTraits::field_type>::PromotedType operator* (const DenseVector& y) const { + typedef typename PromotionTraits::field_type>::PromotedType PromotedType; + PromotedType result(0); + assert(y.size() == size()); + for (size_type i=0; i - value_type operator* (const DenseVector& y) const - { + /** + * @brief vector dot product \f$\left (x^H \cdot y \right)\f$ which corresponds to Petsc's VecDot + * + * http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecDot.html + * @param y other vector + * @return + */ + template + typename PromotionTraits::field_type>::PromotedType dot(const DenseVector& y) const { + typedef typename PromotionTraits::field_type>::PromotedType PromotedType; + PromotedType result(0); assert(y.size() == size()); - value_type result( 0 ); - for (size_type i=0; i::real_type one_norm() const { + using std::abs; typename FieldTraits::real_type result( 0 ); for (size_type i=0; i::real_type infinity_norm () const - { - if (size() == 0) - return 0.0; - - ConstIterator it = begin(); - typename FieldTraits::real_type max = std::abs(*it); - for (it = it + 1; it != end(); ++it) - max = std::max(max, std::abs(*it)); - - return max; + template ::value, int>::type = 0> + typename FieldTraits::real_type infinity_norm() const { + using real_type = typename FieldTraits::real_type; + using std::abs; + using std::max; + + real_type norm = 0; + for (auto const &x : *this) { + real_type const a = abs(x); + norm = max(a, norm); + } + return norm; } //! simplified infinity norm (uses Manhattan norm for complex values) - typename FieldTraits::real_type infinity_norm_real () const - { - if (size() == 0) - return 0.0; + template ::value, int>::type = 0> + typename FieldTraits::real_type infinity_norm_real() const { + using real_type = typename FieldTraits::real_type; + using std::max; + + real_type norm = 0; + for (auto const &x : *this) { + real_type const a = fvmeta::absreal(x); + norm = max(a, norm); + } + return norm; + } - ConstIterator it = begin(); - typename FieldTraits::real_type max = fvmeta::absreal(*it); - for (it = it + 1; it != end(); ++it) - max = std::max(max, fvmeta::absreal(*it)); + //! infinity norm (maximum of absolute values of entries) + template ::value, int>::type = 0> + typename FieldTraits::real_type infinity_norm() const { + using real_type = typename FieldTraits::real_type; + using std::abs; + using std::max; + + real_type norm = 0; + real_type isNaN = 1; + for (auto const &x : *this) { + real_type const a = abs(x); + norm = max(a, norm); + isNaN += a; + } + isNaN /= isNaN; + return norm * isNaN; + } - return max; + //! simplified infinity norm (uses Manhattan norm for complex values) + template ::value, int>::type = 0> + typename FieldTraits::real_type infinity_norm_real() const { + using real_type = typename FieldTraits::real_type; + using std::max; + + real_type norm = 0; + real_type isNaN = 1; + for (auto const &x : *this) { + real_type const a = fvmeta::absreal(x); + norm = max(a, norm); + isNaN += a; + } + isNaN /= isNaN; + return norm * isNaN; } //===== sizes diff -Nru dune-common-2.2.1/dune/common/deprecated.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/deprecated.hh --- dune-common-2.2.1/dune/common/deprecated.hh 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/deprecated.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_DEPRECATED_HH #define DUNE_DEPRECATED_HH @@ -12,7 +14,7 @@ //! Mark some entity as deprecated /** * \code -#include + *#include * \endcode * * This is a preprocessor define which can be used to mark functions, @@ -20,7 +22,7 @@ * deprecated, users are advised to migrate to the new interface, since it * will probably be removed in the next release of Dune. * - * DUNE_DEPRECATED currently works with g++ only. For other compilers it will + * DUNE_DEPRECATED currently works with g++ and clang++. For other compilers it will * be defined empty. This way the user will not get any deprecation warning, * but at least his code still compiles (well, until the next Dune release, * that is). @@ -28,21 +30,21 @@ * Here are some examples how to mark different stuff deprecated: * - Classes * \code -class DUNE_DEPRECATED Class {}; // 1) -class Class {} DUNE_DEPRECATED; // 2) + class DUNE_DEPRECATED Class {}; // 1) + class Class {} DUNE_DEPRECATED; // 2) * \endcode * Both forms do not work properly with g++-4.1: no deprecation warning * will be given, although the code still compiles. 1) should be preferred * over 2) since 2) does not work with clang++-1.1 (again, no warning given - * but code still compiles) + * but code still compiles, works with clang++-3.1) * - Template classes * \code -template -class DUNE_DEPRECATED Class {}; // 1) -template -class Class {} DUNE_DEPRECATED; // 2) + template + class DUNE_DEPRECATED Class {}; // 1) + template + class Class {} DUNE_DEPRECATED; // 2) * \endcode - * This works works with g++-4.3, g++-4.4 and g++-4.5 only, g++-4.1 and + * This works works with g++ >=4.3 only; g++-4.1 and * clang++ compile the code without warning in both cases. Furthermore, * the warning is only triggered when copying an object of that template * class, neither making a typedef nor simply creating such an object emit @@ -50,33 +52,34 @@ * marked deprecated as well, if possible. * - Member constants * \code -template struct Class { - static const int c0 DUNE_DEPRECATED = 0; - static const int DUNE_DEPRECATED c1 = 1; -}; + template struct Class { + static const int c0 DUNE_DEPRECATED = 0; + static const int DUNE_DEPRECATED c1 = 1; + }; * \endcode - * Works with g++-4.1, g++-4.3, g++-4.4, g++-4.5. No warning but clean - * compile with clang++-1.1. + * Works with g++-4.1, g++ >=4.3 and clang++3.1. + * No warning but clean compile with clang++-1.1. * - Member enumerators * \code -template struct Class { - enum enumeration { enumerator = 0 }; -}; + template struct Class { + enum enumeration { enumerator = 0 }; + }; * \endcode * No form of deprecation is known that does not trigger an error on most * compilers. * - Member functions * \code -template struct Class { - void frob() DUNE_DEPRECATED {} -}; -template struct Class { - void DUNE_DEPRECATED frob() {} -}; -template struct Class { - DUNE_DEPRECATED void frob() {} -}; + template struct Class { + void frob() DUNE_DEPRECATED {} + }; // 1) + template struct Class { + void DUNE_DEPRECATED frob() {} + }; // 2) + template struct Class { + DUNE_DEPRECATED void frob() {} + }; // 3) * \endcode + * With g++ only 2) emits a warning for templated member functions. */ #define DUNE_DEPRECATED #else // defined(HAS_ATTRIBUTE_DEPRECATED) @@ -87,7 +90,7 @@ //! Mark some entity as deprecated /** * \code -#include + *#include * \endcode * * This is a preprocessor define which can be used to mark functions, @@ -105,8 +108,8 @@ * Here are some examples how to mark different stuff deprecated: * - Classes * \code -class DUNE_DEPRECATED_MSG("In the future, please use 'Glass'") Class {}; // 1) -class Class {} DUNE_DEPRECATED("In the future, please use 'Glass'"); // 2) + class DUNE_DEPRECATED_MSG("In the future, please use 'Glass'") Class {}; // 1) + class Class {} DUNE_DEPRECATED_MSG("In the future, please use 'Glass'"); // 2) * \endcode * For both forms, deprecation warnings and the additional hint "In * the future, please use 'Glass'" will be printed on compilers @@ -119,10 +122,10 @@ * (again, no warning will be given but code still compiles) * - Template classes * \code -template -class DUNE_DEPRECATED_MSG("In the future, please use 'Glass'") Class {}; // 1) -template -class Class {} DUNE_DEPRECATED_MSG("In the future, please use 'Glass'"); // 2) + template + class DUNE_DEPRECATED_MSG("In the future, please use 'Glass'") Class {}; // 1) + template + class Class {} DUNE_DEPRECATED_MSG("In the future, please use 'Glass'"); // 2) * \endcode * This works works with g++ >= 4.5, clang++ until at least version * 1.1 will compile the code without warning in both cases. @@ -133,38 +136,86 @@ * deprecated as well, if possible. * - Member constants * \code -template struct Class { - static const int c0 DUNE_DEPRECATED_MSG("c2 is the new hype") = 0; - static const int DUNE_DEPRECATED_MSG("c2 is the new hype") c1 = 1; -}; + template struct Class { + static const int c0 DUNE_DEPRECATED_MSG("c2 is the new hype") = 0; + static const int DUNE_DEPRECATED_MSG("c2 is the new hype") c1 = 1; + }; * \endcode * Works without printing the hint on g++-4.1, g++-4.3, g++-4.4 and - * fully on g++ >= 4.5. No warning but clean compile with - * clang++-1.1. + * fully on g++ >= 4.5. Works for clang++-3.1. + * No warning but clean compile with clang++-1.1. * - Member enumerators * \code -template struct Class { - enum enumeration { enumerator = 0 }; -}; + template struct Class { + enum enumeration { enumerator = 0 }; + }; * \endcode * No form of deprecation is known that does not trigger an error on most * compilers. * - Member functions * \code -template struct Class { - void frob() DUNE_DEPRECATED_MSG("frogs() are beautiful from now on") {} -}; -template struct Class { - void DUNE_DEPRECATED_MSG("frogs() are beautiful from now on") frob() {} -}; -template struct Class { - DUNE_DEPRECATED_MSG("frogs() are beautiful from now on") void frob() {} -}; + template struct Class { + void frob() DUNE_DEPRECATED_MSG("use frog") {} + }; // 1) + template struct Class { + void DUNE_DEPRECATED_MSG("use frog") frob() {} + }; // 2) + template struct Class { + DUNE_DEPRECATED_MSG("use frog") void frob() {} + }; // 3) * \endcode + * With g++ only 2) emits a warning for templated member functions. */ #define DUNE_DEPRECATED_MSG(text) DUNE_DEPRECATED #else // defined(HAS_ATTRIBUTE_DEPRECATED_MSG) -#define DUNE_DEPRECATED_MSG(text) __attribute__((deprecated(#text))) +#define DUNE_DEPRECATED_MSG(text) __attribute__((deprecated(# text))) +#endif + +#ifdef DOXYGEN +/** + * \brief Ignore deprecation warnings (start) + * + * This macro can be used together with `DUNE_NO_DEPRECATED_END` to mark a + * block in which deprecation warnings are ignored. This can be useful for + * implementations of deprecated methods that call other deprecated methods + * or for testing deprecated methods in the testsuite. + * + * \code + DUNE_NO_DEPRECATED_BEGIN + some_deprecated_function(); + another_deprecated_function(); + DUNE_NO_DEPRECATED_END + * \endcode + * + * \warning This macro must always be used together with `DUNE_NO_DEPRECATED_END` + */ +#define DUNE_NO_DEPRECATED_BEGIN ... +/** + * \brief Ignore deprecation warnings (end) + * + * \warning This macro must always be used together with `DUNE_NO_DEPRECATED_BEGIN` + */ +#define DUNE_NO_DEPRECATED_END ... +#else +# if defined __clang__ +# define DUNE_NO_DEPRECATED_BEGIN \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +# define DUNE_NO_DEPRECATED_END _Pragma("clang diagnostic pop") +# elif defined __INTEL_COMPILER +# define DUNE_NO_DEPRECATED_BEGIN \ + _Pragma("warning push") \ + _Pragma("warning(disable:1478)") +# define DUNE_NO_DEPRECATED_END _Pragma("warning pop") +# elif defined __GNUC__ +# define DUNE_NO_DEPRECATED_BEGIN \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +# define DUNE_NO_DEPRECATED_END _Pragma("GCC diagnostic pop") +# else +# define DUNE_NO_DEPRECATED_BEGIN /* Noop. */ +# define DUNE_NO_DEPRECATED_END /* Noop. */ +# endif #endif //! @} diff -Nru dune-common-2.2.1/dune/common/diagonalmatrix.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/diagonalmatrix.hh --- dune-common-2.2.1/dune/common/diagonalmatrix.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/diagonalmatrix.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,1093 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_DIAGONAL_MATRIX_HH +#define DUNE_DIAGONAL_MATRIX_HH + +/*! \file + \brief This file implements a quadratic diagonal matrix of fixed size. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Dune { + + template< class K, int n > class DiagonalRowVectorConst; + template< class K, int n > class DiagonalRowVector; + template< class DiagonalMatrixType > class DiagonalMatrixWrapper; + template< class C, class T, class R> class ContainerWrapperIterator; + + /** + @addtogroup DenseMatVec + @{ + */ + + /** + *@brief A diagonal matrix of static size. + * + * This is meant to be a replacement of FieldMatrix for the case that + * it is a diagonal matrix. + * + * \tparam K Type used for scalars + * \tparam n Matrix size + */ + template + class DiagonalMatrix + { + typedef DiagonalMatrixWrapper< DiagonalMatrix > WrapperType; + + public: + //===== type definitions and constants + + //! export the type representing the field + typedef K value_type; + typedef value_type field_type; + + //! export the type representing the components + typedef K block_type; + + //! The type used for the index access and size operations. + typedef std::size_t size_type; + + //! We are at the leaf of the block recursion + enum { + //! The number of block levels we contain. This is 1. + blocklevel = 1 + }; + + //! Each row is implemented by a field vector + typedef DiagonalRowVector row_type; + typedef row_type reference; + typedef row_type row_reference; + typedef DiagonalRowVectorConst const_row_type; + typedef const_row_type const_reference; + typedef const_row_type const_row_reference; + + //! export size + enum { + //! The number of rows + rows = n, + //! The number of columns + cols = n + }; + + //==== size + + size_type size () const + { + return rows; + } + + //===== constructors + + //! Default constructor + DiagonalMatrix () {} + + //! Constructor initializing the whole matrix with a scalar + DiagonalMatrix (const K& k) + : diag_(k) + {} + + //! Constructor initializing the diagonal with a vector + DiagonalMatrix (const FieldVector& diag) + : diag_(diag) + {} + + /** \brief Construct diagonal matrix from an initializer list + * + * The elements of the list are copied into the diagonal elements of the matrix. + * If the initializer list is shorter than the matrix diagonal (which has n elements), + * the remaining matrix diagonal elements are left uninitialized. If the initializer + * list is longer, than only the first n elements will be copied into the matrix + * diagonal. + */ + DiagonalMatrix (std::initializer_list const &l) + { + std::copy_n(l.begin(), std::min(static_cast(rows), + l.size()), + diag_.begin()); + } + + /** \brief Assignment from a scalar */ + DiagonalMatrix& operator= (const K& k) + { + diag_ = k; + return *this; + } + + /** \brief Check if matrix is the same object as the other matrix */ + bool identical(const DiagonalMatrix& other) const + { + return (this==&other); + } + + //===== iterator interface to rows of the matrix + //! Iterator class for sequential access + typedef ContainerWrapperIterator Iterator; + //! typedef for stl compliant access + typedef Iterator iterator; + //! rename the iterators for easier access + typedef Iterator RowIterator; + //! rename the iterators for easier access + typedef typename row_type::Iterator ColIterator; + + //! begin iterator + Iterator begin () + { + return Iterator(WrapperType(this),0); + } + + //! end iterator + Iterator end () + { + return Iterator(WrapperType(this),n); + } + + //! @returns an iterator that is positioned before + //! the end iterator of the rows, i.e. at the last row. + Iterator beforeEnd () + { + return Iterator(WrapperType(this),n-1); + } + + //! @returns an iterator that is positioned before + //! the first row of the matrix. + Iterator beforeBegin () + { + return Iterator(WrapperType(this),-1); + } + + + //! Iterator class for sequential access + typedef ContainerWrapperIterator ConstIterator; + //! typedef for stl compliant access + typedef ConstIterator const_iterator; + //! rename the iterators for easier access + typedef ConstIterator ConstRowIterator; + //! rename the iterators for easier access + typedef typename const_row_type::ConstIterator ConstColIterator; + + //! begin iterator + ConstIterator begin () const + { + return ConstIterator(WrapperType(this),0); + } + + //! end iterator + ConstIterator end () const + { + return ConstIterator(WrapperType(this),n); + } + + //! @returns an iterator that is positioned before + //! the end iterator of the rows. i.e. at the last row. + ConstIterator beforeEnd() const + { + return ConstIterator(WrapperType(this),n-1); + } + + //! @returns an iterator that is positioned before + //! the first row of the matrix. + ConstIterator beforeBegin () const + { + return ConstIterator(WrapperType(this),-1); + } + + + + //===== vector space arithmetic + + //! vector space addition + DiagonalMatrix& operator+= (const DiagonalMatrix& y) + { + diag_ += y.diag_; + return *this; + } + + //! vector space subtraction + DiagonalMatrix& operator-= (const DiagonalMatrix& y) + { + diag_ -= y.diag_; + return *this; + } + + //! vector space multiplication with scalar + DiagonalMatrix& operator+= (const K& k) + { + diag_ += k; + return *this; + } + + //! vector space division by scalar + DiagonalMatrix& operator-= (const K& k) + { + diag_ -= k; + return *this; + } + + //! vector space multiplication with scalar + DiagonalMatrix& operator*= (const K& k) + { + diag_ *= k; + return *this; + } + + //! vector space division by scalar + DiagonalMatrix& operator/= (const K& k) + { + diag_ /= k; + return *this; + } + + //===== comparison ops + + //! comparison operator + bool operator==(const DiagonalMatrix& other) const + { + return diag_==other.diagonal(); + } + + //! incomparison operator + bool operator!=(const DiagonalMatrix& other) const + { + return diag_!=other.diagonal(); + } + + + //===== linear maps + + //! y = A x + template + void mv (const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void mtv (const X& x, Y& y) const + { + mv(x, y); + } + + //! y += A x + template + void umv (const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void umtv (const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void umhv (const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void mmv (const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void mmtv (const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void mmhv (const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void usmv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void usmtv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void usmhv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const + { +#ifdef DUNE_FMatrix_WITH_CHECKING + if (x.N()!=N()) DUNE_THROW(FMatrixError,"index out of range"); + if (y.N()!=M()) DUNE_THROW(FMatrixError,"index out of range"); +#endif + for (size_type i=0; i + void solve (V& x, const V& b) const + { + for (int i=0; i= 0 && i < n); + DUNE_ASSERT_BOUNDS(j >= 0 && j < n); + return i==j; + } + + + + //! Sends the matrix to an output stream + friend std::ostream& operator<< (std::ostream& s, const DiagonalMatrix& a) + { + for (size_type i=0; i(&diag_[i]), i); + } + + //! Return const_reference object as row replacement + const_reference operator[](size_type i) const + { + return const_reference(const_cast(&diag_[i]), i); + } + + //! Get const reference to diagonal entry + const K& diagonal(size_type i) const + { + return diag_[i]; + } + + //! Get reference to diagonal entry + K& diagonal(size_type i) + { + return diag_[i]; + } + + //! Get const reference to diagonal vector + const FieldVector& diagonal() const + { + return diag_; + } + + //! Get reference to diagonal vector + FieldVector& diagonal() + { + return diag_; + } + + private: + + // the data, a FieldVector storing the diagonal + FieldVector diag_; + }; + +#ifndef DOXYGEN // hide specialization + /** \brief Special type for 1x1 matrices + */ + template< class K > + class DiagonalMatrix : public FieldMatrix + { + typedef FieldMatrix Base; + public: + //! The type used for index access and size operations + typedef typename Base::size_type size_type; + + //! We are at the leaf of the block recursion + enum { + //! The number of block levels we contain. + //! This is always one for this type. + blocklevel = 1 + }; + + typedef typename Base::row_type row_type; + + typedef typename Base::row_reference row_reference; + typedef typename Base::const_row_reference const_row_reference; + + //! export size + enum { + //! \brief The number of rows. + //! This is always one for this type. + rows = 1, + //! \brief The number of columns. + //! This is always one for this type. + cols = 1 + }; + + + //! Default Constructor + DiagonalMatrix() + {} + + //! Constructor initializing the whole matrix with a scalar + DiagonalMatrix(const K& scalar) + { + (*this)[0][0] = scalar; + } + + //! Get const reference to diagonal entry + const K& diagonal(size_type) const + { + return (*this)[0][0]; + } + + //! Get reference to diagonal entry + K& diagonal(size_type) + { + return (*this)[0][0]; + } + + //! Get const reference to diagonal vector + const FieldVector& diagonal() const + { + return (*this)[0]; + } + + //! Get reference to diagonal vector + FieldVector& diagonal() + { + return (*this)[0]; + } + + }; +#endif + + + template + class DiagonalMatrixWrapper + { + typedef typename DiagonalMatrixType::reference reference; + typedef typename DiagonalMatrixType::const_reference const_reference; + typedef typename DiagonalMatrixType::field_type K; + typedef DiagonalRowVector row_type; + typedef std::size_t size_type; + typedef DiagonalMatrixWrapper< DiagonalMatrixType> MyType; + + friend class ContainerWrapperIterator; + friend class ContainerWrapperIterator; + + public: + + DiagonalMatrixWrapper() : + mat_(0) + {} + + DiagonalMatrixWrapper(const DiagonalMatrixType* mat) : + mat_(const_cast(mat)) + {} + + size_type realIndex(int i) const + { + return i; + } + + row_type* pointer(int i) const + { + row_ = row_type(&(mat_->diagonal(i)), i); + return &row_; + } + + bool identical(const DiagonalMatrixWrapper& other) const + { + return mat_==other.mat_; + } + + private: + + mutable DiagonalMatrixType* mat_; + mutable row_type row_; + }; + + /** \brief + * + */ + template< class K, int n > + class DiagonalRowVectorConst + { + template + friend class DiagonalMatrixWrapper; + friend class ContainerWrapperIterator, const K, const K&>; + + public: + // remember size of vector + enum { dimension = n }; + + // standard constructor and everything is sufficient ... + + //===== type definitions and constants + + //! export the type representing the field + typedef K field_type; + + //! export the type representing the components + typedef K block_type; + + //! The type used for the index access and size operation + typedef std::size_t size_type; + + //! We are at the leaf of the block recursion + enum { + //! The number of block levels we contain + blocklevel = 1 + }; + + //! export size + enum { + //! The size of this vector. + size = n + }; + + //! Constructor making uninitialized vector + DiagonalRowVectorConst() : + p_(0), + row_(0) + {} + + //! Constructor making vector with identical coordinates + explicit DiagonalRowVectorConst (K* p, int col) : + p_(p), + row_(col) + {} + + //===== access to components + + //! same for read only access + const K& operator[] (size_type i) const + { + DUNE_UNUSED_PARAMETER(i); + DUNE_ASSERT_BOUNDS(i == row_); + return *p_; + } + + // check if row is identical to other row (not only identical values) + // since this is a proxy class we need to check equality of the stored pointer + bool identical(const DiagonalRowVectorConst& other) const + { + return ((p_ == other.p_)and (row_ == other.row_)); + } + + //! ConstIterator class for sequential access + typedef ContainerWrapperIterator, const K, const K&> ConstIterator; + //! typedef for stl compliant access + typedef ConstIterator const_iterator; + + //! begin ConstIterator + ConstIterator begin () const + { + return ConstIterator(*this,0); + } + + //! end ConstIterator + ConstIterator end () const + { + return ConstIterator(*this,1); + } + + //! @returns an iterator that is positioned before + //! the end iterator of the rows. i.e. at the row. + ConstIterator beforeEnd() const + { + return ConstIterator(*this,0); + } + + //! @returns an iterator that is positioned before + //! the first row of the matrix. + ConstIterator beforeBegin () const + { + return ConstIterator(*this,-1); + } + + //! Binary vector comparison + bool operator== (const DiagonalRowVectorConst& y) const + { + return ((p_==y.p_)and (row_==y.row_)); + } + + //===== sizes + + //! number of blocks in the vector (are of size 1 here) + size_type N () const + { + return n; + } + + //! dimension of the vector space + size_type dim () const + { + return n; + } + + //! index of this row in surrounding matrix + size_type rowIndex() const + { + return row_; + } + + //! the diagonal value + const K& diagonal() const + { + return *p_; + } + + protected: + + size_type realIndex(int i) const + { + return rowIndex(); + } + + K* pointer(size_type i) const + { + return const_cast(p_); + } + + DiagonalRowVectorConst* operator&() + { + return this; + } + + // the data, very simply a pointer to the diagonal value and the row number + K* p_; + size_type row_; + }; + + template< class K, int n > + class DiagonalRowVector : public DiagonalRowVectorConst + { + template + friend class DiagonalMatrixWrapper; + friend class ContainerWrapperIterator, K, K&>; + + public: + // standard constructor and everything is sufficient ... + + //===== type definitions and constants + + //! export the type representing the field + typedef K field_type; + + //! export the type representing the components + typedef K block_type; + + //! The type used for the index access and size operation + typedef std::size_t size_type; + + //! Constructor making uninitialized vector + DiagonalRowVector() : DiagonalRowVectorConst() + {} + + //! Constructor making vector with identical coordinates + explicit DiagonalRowVector (K* p, int col) : DiagonalRowVectorConst(p, col) + {} + + //===== assignment from scalar + //! Assignment operator for scalar + DiagonalRowVector& operator= (const K& k) + { + *p_ = k; + return *this; + } + + //===== access to components + + //! random access + K& operator[] (size_type i) + { + DUNE_UNUSED_PARAMETER(i); + DUNE_ASSERT_BOUNDS(i == row_); + return *p_; + } + + //! Iterator class for sequential access + typedef ContainerWrapperIterator, K, K&> Iterator; + //! typedef for stl compliant access + typedef Iterator iterator; + + //! begin iterator + Iterator begin () + { + return Iterator(*this, 0); + } + + //! end iterator + Iterator end () + { + return Iterator(*this, 1); + } + + //! @returns an iterator that is positioned before + //! the end iterator of the rows, i.e. at the last row. + Iterator beforeEnd () + { + return Iterator(*this, 0); + } + + //! @returns an iterator that is positioned before + //! the first row of the matrix. + Iterator beforeBegin () + { + return Iterator(*this, -1); + } + + //! ConstIterator class for sequential access + typedef ContainerWrapperIterator, const K, const K&> ConstIterator; + //! typedef for stl compliant access + typedef ConstIterator const_iterator; + + using DiagonalRowVectorConst::identical; + using DiagonalRowVectorConst::operator[]; + using DiagonalRowVectorConst::operator==; + using DiagonalRowVectorConst::begin; + using DiagonalRowVectorConst::end; + using DiagonalRowVectorConst::beforeEnd; + using DiagonalRowVectorConst::beforeBegin; + using DiagonalRowVectorConst::N; + using DiagonalRowVectorConst::dim; + using DiagonalRowVectorConst::rowIndex; + using DiagonalRowVectorConst::diagonal; + + protected: + + DiagonalRowVector* operator&() + { + return this; + } + + private: + + using DiagonalRowVectorConst::p_; + using DiagonalRowVectorConst::row_; + }; + + + // implement type traits + template + struct const_reference< DiagonalRowVector > + { + typedef DiagonalRowVectorConst type; + }; + + template + struct const_reference< DiagonalRowVectorConst > + { + typedef DiagonalRowVectorConst type; + }; + + template + struct mutable_reference< DiagonalRowVector > + { + typedef DiagonalRowVector type; + }; + + template + struct mutable_reference< DiagonalRowVectorConst > + { + typedef DiagonalRowVector type; + }; + + + + /** \brief Iterator class for sparse vector-like containers + * + * This class provides an iterator for sparse vector like containers. + * It contains a ContainerWrapper that must provide the translation + * from the position in the underlying container to the index + * in the sparse container. + * + * The ContainerWrapper must be default and copy-constructable. + * Furthermore it must provide the methods: + * + * bool identical(other) - check if this is identical to other (same container, not only equal) + * T* pointer(position) - get pointer to data at position in underlying container + * size_t realIndex(position) - get index in sparse container for position in underlying container + * + * Notice that the iterator stores a ContainerWrapper. + * This allows one to use proxy classes as underlying container + * and as returned reference type. + * + * \tparam CW The container wrapper class + * \tparam T The contained type + * \tparam R The reference type returned by dereference + */ + template + class ContainerWrapperIterator : public BidirectionalIteratorFacade,T, R, int> + { + typedef typename std::remove_const::type NonConstCW; + + friend class ContainerWrapperIterator::type, typename mutable_reference::type>; + friend class ContainerWrapperIterator::type, typename const_reference::type>; + + typedef ContainerWrapperIterator::type, typename mutable_reference::type> MyType; + typedef ContainerWrapperIterator::type, typename const_reference::type> MyConstType; + + public: + + // Constructors needed by the facade iterators. + ContainerWrapperIterator() : + containerWrapper_(), + position_(0) + {} + + ContainerWrapperIterator(CW containerWrapper, int position) : + containerWrapper_(containerWrapper), + position_(position) + {} + + template + ContainerWrapperIterator(OtherContainerWrapperIteratorType& other) : + containerWrapper_(other.containerWrapper_), + position_(other.position_) + {} + + ContainerWrapperIterator(const MyType& other) : + containerWrapper_(other.containerWrapper_), + position_(other.position_) + {} + + ContainerWrapperIterator(const MyConstType& other) : + containerWrapper_(other.containerWrapper_), + position_(other.position_) + {} + + template + ContainerWrapperIterator& operator=(OtherContainerWrapperIteratorType& other) + { + containerWrapper_ = other.containerWrapper_; + position_ = other.position_; + return *this; + } + + // This operator is needed since we can not get the address of the + // temporary object returned by dereference + T* operator->() const + { + return containerWrapper_.pointer(position_); + } + + // Methods needed by the forward iterator + bool equals(const MyType& other) const + { + return position_ == other.position_ && containerWrapper_.identical(other.containerWrapper_); + } + + bool equals(const MyConstType& other) const + { + return position_ == other.position_ && containerWrapper_.identical(other.containerWrapper_); + } + + R dereference() const + { + return *containerWrapper_.pointer(position_); + } + + void increment() + { + ++position_; + } + + // Additional function needed by BidirectionalIterator + void decrement() + { + --position_; + } + + // Additional function needed by RandomAccessIterator + R elementAt(int i) const + { + return *containerWrapper_.pointer(position_+i); + } + + void advance(int n) + { + position_=position_+n; + } + + template + std::ptrdiff_t distanceTo(OtherContainerWrapperIteratorType& other) const + { + assert(containerWrapper_.identical(other)); + return other.position_ - position_; + } + + std::ptrdiff_t index() const + { + return containerWrapper_.realIndex(position_); + } + + private: + NonConstCW containerWrapper_; + size_t position_; + }; + + template + struct DenseMatrixAssigner> { + static void apply(DenseMatrix& denseMatrix, + DiagonalMatrix const& rhs) { + DUNE_ASSERT_BOUNDS(denseMatrix.M() == N); + DUNE_ASSERT_BOUNDS(denseMatrix.N() == N); + denseMatrix = field(0); + for (int i = 0; i < N; ++i) + denseMatrix[i][i] = rhs.diagonal()[i]; + } + }; + /* @} */ +} // end namespace +#endif diff -Nru dune-common-2.2.1/dune/common/documentation.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/documentation.hh --- dune-common-2.2.1/dune/common/documentation.hh 2010-12-21 13:55:28.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/documentation.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,47 +1,49 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_DOCUMENTATION_HH #define DUNE_COMMON_DOCUMENTATION_HH /** \file \brief Documentation related stuff -*/ + */ namespace Dune { - //! Dummy struct used for documentation purposes /** + * \brief Dummy struct used for documentation purposes + * * This struct can be used for documenting interfaces. One example would * be: * \code -// Traits class that determines some property for some other type T -template -class SomeTraits { - dune_static_assert(AlwaysFalse::value, - "Sorry, SomeTraits must be specialized for all types"); -public: - // The type of some property of T - typedef ImplementationDefined type; -}; -#ifndef DOXYGEN -template<> -struct SomeTraits - typedef ... type; -}; -// ... -#endif // DOXYGEN + * // Traits class that determines some property for some other type T + * template + * class SomeTraits { + * static_assert(Std::to_false_type::value, + * "Sorry, SomeTraits must be specialized for all types"); + * public: + * // The type of some property of T + * typedef ImplementationDefined type; + * }; + * #ifndef DOXYGEN + * template<> + * struct SomeTraits + * typedef ... type; + * }; + * // ... + * #endif // DOXYGEN * \endcode * * \sa implementationDefined */ struct ImplementationDefined {}; - //! Dummy integral value used for documentation purposes /** + * \brief Dummy integral value used for documentation purposes + * * \var Dune::implementationDefined * \code -#include + * #include * \endcode * * \sa ImplementationDefined diff -Nru dune-common-2.2.1/dune/common/dotproduct.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/dotproduct.hh --- dune-common-2.2.1/dune/common/dotproduct.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/dotproduct.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,99 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_DOTPRODUCT_HH +#define DUNE_DOTPRODUCT_HH + +#include "ftraits.hh" +#include "typetraits.hh" + +namespace Dune { + /** + * @file + * @brief Provides the functions dot(a,b) := \f$a^H \cdot b \f$ and dotT(a,b) := \f$a^T \cdot b \f$ + * + * The provided dot products dot,dotT are used to compute (indefinite) dot products for fundamental types as well as DUNE vector types, such as DenseVector, FieldVector, ISTLVector. + * Note that the definition of dot(a,b) conjugates the first argument. This agrees with the behaviour of Matlab and Petsc, but not with BLAS. + * @author Jö Fahlke, Matthias Wohlmuth + */ + + /** @addtogroup Common + * + * @{ + */ + + template + struct AlwaysVoid { typedef void type; }; + + template + struct IsVector : std::false_type {}; + + template + struct IsVector::type> + : std::true_type {}; + + /** @brief computes the dot product for fundamental data types according to Petsc's VectDot function: dot(a,b) := std::conj(a)*b + * + * @see http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecDot.html#VecDot + * @param a + * @param b + * @return conj(a)*b + */ + template + auto + dot(const A & a, const B & b) -> typename std::enable_if::value && !std::is_same::field_type,typename FieldTraits::real_type> ::value, decltype(conj(a)*b)>::type + { + return conj(a)*b; + } + + /** + * @brief computes the dot product for fundamental data types according to Petsc's VectDot function: dot(a,b) := std::conj(a)*b + * + * Specialization for real first arguments which replaces conj(a) by a. + * @see http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecTDot.html#VecTDot + * @param a + * @param b + * @return a*b (which is the same as conj(a)*b in this case) + */ + // fundamental type with A being a real type + template + auto + dot(const A & a, const B & b) -> typename std::enable_if::value && std::is_same::field_type,typename FieldTraits::real_type>::value, decltype(a*b)>::type + { + return a*b; + } + + /** + * @brief computes the dot product for various dune vector types according to Petsc's VectDot function: dot(a,b) := std::conj(a)*b + * + * Specialization for real first arguments which replaces conj(a) by a. + * @see http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecTDot.html#VecTDot + * @param a + * @param b + * @return dot(a,b) + */ + template + auto + dot(const A & a, const B & b) -> typename std::enable_if::value, decltype(a.dot(b))>::type + { + return a.dot(b); + } + /** @} */ + + /** + * @brief Computes an indefinite vector dot product for fundamental data types according to Petsc's VectTDot function: dotT(a,b) := a*b + * @see http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecTDot.html#VecTDot + * @param a + * @param b + * @return a*b + */ + template + auto + dotT(const A & a, const B & b) -> decltype(a*b) + { + return a*b; + } + + /** @} */ +} // end namespace DUNE + +#endif // DUNE_DOTPRODUCT_HH diff -Nru dune-common-2.2.1/dune/common/dynmatrixev.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/dynmatrixev.cc --- dune-common-2.2.1/dune/common/dynmatrixev.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/dynmatrixev.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,154 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_FMATRIXEIGENVALUES_EXT_CC +#define DUNE_FMATRIXEIGENVALUES_EXT_CC + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include + +#if HAVE_LAPACK + +// nonsymmetric matrices +#define DGEEV_FORTRAN FC_FUNC (dgeev, DGEEV) + +// dsyev declaration (in liblapack) +extern "C" { + + /* + * + ** purpose + ** ======= + ** + ** xgeev computes for an N-by-N BASE DATA TYPE nonsymmetric matrix A, the + ** eigenvalues and, optionally, the left and/or right eigenvectors. + ** + ** The right eigenvector v(j) of A satisfies + ** A * v(j) = lambda(j) * v(j) + ** where lambda(j) is its eigenvalue. + ** The left eigenvector u(j) of A satisfies + ** u(j)**T * A = lambda(j) * u(j)**T + ** where u(j)**T denotes the transpose of u(j). + ** + ** The computed eigenvectors are normalized to have Euclidean norm + ** equal to 1 and largest component real. + ** + ** arguments + ** ========= + ** + ** jobvl (input) char + ** = 'n': left eigenvectors of a are not computed; + ** = 'v': left eigenvectors of a are computed. + ** + ** jobvr (input) char + ** = 'n': right eigenvectors of a are not computed; + ** = 'v': right eigenvectors of a are computed. + ** + ** n (input) long int + ** the order of the matrix v. v >= 0. + ** + ** a (input/output) BASE DATA TYPE array, dimension (lda,n) + ** on entry, the n-by-n matrix a. + ** on exit, a has been overwritten. + ** + ** lda (input) long int + ** the leading dimension of the array a. lda >= max(1,n). + ** + ** wr (output) BASE DATA TYPE array, dimension (n) + ** wi (output) BASE DATA TYPE array, dimension (n) + ** wr and wi contain the real and imaginary parts, + ** respectively, of the computed eigenvalues. complex + ** conjugate pairs of eigenvalues appear consecutively + ** with the eigenvalue having the positive imaginary part + ** first. + ** + ** vl (output) COMPLEX DATA TYPE array, dimension (ldvl,n) + ** if jobvl = 'v', the left eigenvectors u(j) are stored one + ** after another in the columns of vl, in the same order + ** as their eigenvalues. + ** if jobvl = 'n', vl is not referenced. + ** if the j-th eigenvalue is real, then u(j) = vl(:,j), + ** the j-th column of vl. + ** if the j-th and (j+1)-st eigenvalues form a complex + ** conjugate pair, then u(j) = vl(:,j) + i*vl(:,j+1) and + ** u(j+1) = vl(:,j) - i*vl(:,j+1). + ** + ** ldvl (input) long int + ** the leading dimension of the array vl. ldvl >= 1; if + ** jobvl = 'v', ldvl >= n. + ** + ** vr (output) COMPLEX DATA TYPE array, dimension (ldvr,n) + ** if jobvr = 'v', the right eigenvectors v(j) are stored one + ** after another in the columns of vr, in the same order + ** as their eigenvalues. + ** if jobvr = 'n', vr is not referenced. + ** if the j-th eigenvalue is real, then v(j) = vr(:,j), + ** the j-th column of vr. + ** if the j-th and (j+1)-st eigenvalues form a complex + ** conjugate pair, then v(j) = vr(:,j) + i*vr(:,j+1) and + ** v(j+1) = vr(:,j) - i*vr(:,j+1). + ** + ** ldvr (input) long int + ** the leading dimension of the array vr. ldvr >= 1; if + ** jobvr = 'v', ldvr >= n. + ** + ** work (workspace/output) BASE DATA TYPE array, dimension (max(1,lwork)) + ** on exit, if info = 0, work(1) returns the optimal lwork. + ** + ** lwork (input) long int + ** the dimension of the array work. lwork >= max(1,3*n), and + ** if jobvl = 'v' or jobvr = 'v', lwork >= 4*n. for good + ** performance, lwork must generally be larger. + ** + ** if lwork = -1, then a workspace query is assumed; the routine + ** only calculates the optimal size of the work array, returns + ** this value as the first entry of the work array, and no error + ** message related to lwork is issued by xerbla. + ** + ** info (output) long int + ** = 0: successful exit + ** < 0: if info = -i, the i-th argument had an illegal value. + ** > 0: if info = i, the qr algorithm failed to compute all the + ** eigenvalues, and no eigenvectors have been computed; + ** elements i+1:n of wr and wi contain eigenvalues which + ** have converged. + ** + **/ + + extern void DGEEV_FORTRAN(const char* jobvl, const char* jobvr, const long + int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, + const long int* ldvl, double* vr, const long int* ldvr, double* work, + const long int* lwork, const long int* info); + +} // end extern C +#endif + +namespace Dune { + + namespace DynamicMatrixHelp { + + void eigenValuesNonsymLapackCall( + const char* jobvl, const char* jobvr, const long + int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, + const long int* ldvl, double* vr, const long int* ldvr, double* work, + const long int* lwork, const long int* info) + { +#if HAVE_LAPACK + // call LAPACK dgeev + DGEEV_FORTRAN(jobvl, jobvr, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, + work, lwork, info); +#else + DUNE_THROW(NotImplemented,"eigenValuesNonsymLapackCall: LAPACK not found!"); +#endif + } + + } // end namespace FMatrixHelp + +} // end namespace Dune +#endif diff -Nru dune-common-2.2.1/dune/common/dynmatrixev.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/dynmatrixev.hh --- dune-common-2.2.1/dune/common/dynmatrixev.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/dynmatrixev.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,91 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_DYNMATRIXEIGENVALUES_HH +#define DUNE_DYNMATRIXEIGENVALUES_HH + +#include + +#include + +#include "dynmatrix.hh" + +/*! + \file + \brief utility functions to compute eigenvalues for + dense matrices. + \addtogroup DenseMatVec + @{ + */ + +namespace Dune { + + namespace DynamicMatrixHelp { + + // defined in fmatrixev_ext.cpp + extern void eigenValuesNonsymLapackCall( + const char* jobvl, const char* jobvr, const long + int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, + const long int* ldvl, double* vr, const long int* ldvr, double* work, + const long int* lwork, const long int* info); + + /** \brief calculates the eigenvalues of a symmetric field matrix + \param[in] matrix matrix eigenvalues are calculated for + \param[out] eigenValues FieldVector that contains eigenvalues in + ascending order + + \note LAPACK::dgeev is used to calculate the eigen values + */ + template + static void eigenValuesNonSym(const DynamicMatrix& matrix, + DynamicVector& eigenValues) + { + { + const long int N = matrix.rows(); + const char jobvl = 'n'; + const char jobvr = 'n'; + + + // matrix to put into dgeev + std::unique_ptr matrixVector = Std::make_unique(N*N); + + // copy matrix + int row = 0; + for(int i=0; i eigenR = Std::make_unique(N); + std::unique_ptr eigenI = Std::make_unique(N); + std::unique_ptr work = Std::make_unique(3*N); + + // return value information + long int info = 0; + long int lwork = 3*N; + + // call LAPACK routine (see fmatrixev_ext.cc) + eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, &matrixVector[0], &N, + &eigenR[0], &eigenI[0], 0, &N, 0, &N, &work[0], + &lwork, &info); + + if( info != 0 ) + { + std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl; + DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!"); + } + + eigenValues.resize(N); + for (int i=0; i(eigenR[i], eigenI[i]); + } + } + + } + +} +/** @} */ +#endif diff -Nru dune-common-2.2.1/dune/common/dynmatrix.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/dynmatrix.hh --- dune-common-2.2.1/dune/common/dynmatrix.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/dynmatrix.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,30 +1,30 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: -// $Id: fmatrix.hh 6181 2010-10-13 18:53:40Z christi $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_DYNMATRIX_HH #define DUNE_DYNMATRIX_HH #include #include #include +#include -#include +#include #include #include #include -#include +#include namespace Dune { - -/** - @addtogroup DenseMatVec - @{ -*/ - -/*! \file - * \brief This file implements a dense matrix with dynamic numbers of rows and columns. - */ + + /** + @addtogroup DenseMatVec + @{ + */ + + /*! \file + * \brief This file implements a dense matrix with dynamic numbers of rows and columns. + */ template< class K > class DynamicMatrix; @@ -42,7 +42,7 @@ typedef K value_type; typedef typename container_type::size_type size_type; }; - + template< class K > struct FieldTraits< DynamicMatrix > { @@ -63,7 +63,7 @@ typedef typename Base::size_type size_type; typedef typename Base::value_type value_type; typedef typename Base::row_type row_type; - + //===== constructors //! \brief Default constructor DynamicMatrix () {} @@ -73,27 +73,76 @@ _data(r, row_type(c, v) ) {} + /** \brief Constructor initializing the matrix from a list of vector + */ + DynamicMatrix (std::initializer_list> const &ll) + : _data(ll) + {} + + + template ::value && HasDenseMatrixAssigner::value>> + DynamicMatrix(T const& rhs) + { + *this = rhs; + } + //==== resize related methods + /** + * \brief resize matrix to r × c + * + * Resize the matrix to r × c, using v + * as the value of all entries. + * + * \warning All previous entries are lost, even when the matrix + * was not actually resized. + * + * \param r number of rows + * \param c number of columns + * \param v value of matrix entries + */ void resize (size_type r, size_type c, value_type v = value_type() ) { _data.resize(0); _data.resize(r, row_type(c, v) ); } - + //===== assignment - using Base::operator=; - + // General assignment with resizing + template ::value>> + DynamicMatrix& operator=(T const& rhs) { + _data.resize(rhs.N()); + std::fill(_data.begin(), _data.end(), row_type(rhs.M(), K(0))); + Base::operator=(rhs); + return *this; + } + + // Specialisation: scalar assignment (no resizing) + template ::value>> + DynamicMatrix& operator=(T scalar) { + std::fill(_data.begin(), _data.end(), scalar); + return *this; + } + // make this thing a matrix size_type mat_rows() const { return _data.size(); } size_type mat_cols() const { assert(this->rows()); return _data.front().size(); } - row_type & mat_access(size_type i) { return _data[i]; } - const row_type & mat_access(size_type i) const { return _data[i]; } + row_type & mat_access(size_type i) { + DUNE_ASSERT_BOUNDS(i < _data.size()); + return _data[i]; + } + const row_type & mat_access(size_type i) const { + DUNE_ASSERT_BOUNDS(i < _data.size()); + return _data[i]; + } }; -/** @} end documentation */ + /** @} end documentation */ } // end namespace diff -Nru dune-common-2.2.1/dune/common/dynvector.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/dynvector.hh --- dune-common-2.2.1/dune/common/dynvector.hh 2010-10-13 07:39:23.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/dynvector.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,14 +1,18 @@ -// $Id: fvector.hh 6105 2010-08-25 16:06:36Z christi $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_DYNVECTOR_HH #define DUNE_DYNVECTOR_HH -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "boundschecking.hh" #include "exceptions.hh" #include "genericiterator.hh" @@ -17,65 +21,115 @@ namespace Dune { -/** @addtogroup DenseMatVec - @{ -*/ - -/*! \file - * \brief This file implements a dense vector with a dynamic size. -*/ - - template< class K > class DynamicVector; - template< class K > - struct DenseMatVecTraits< DynamicVector > + /** @addtogroup DenseMatVec + @{ + */ + + /*! \file + * \brief This file implements a dense vector with a dynamic size. + */ + + template< class K, class Allocator > class DynamicVector; + template< class K, class Allocator > + struct DenseMatVecTraits< DynamicVector< K, Allocator > > { - typedef DynamicVector derived_type; - typedef std::vector container_type; + typedef DynamicVector< K, Allocator > derived_type; + typedef std::vector< K, Allocator > container_type; typedef K value_type; typedef typename container_type::size_type size_type; }; - - template< class K > - struct FieldTraits< DynamicVector > + + template< class K, class Allocator > + struct FieldTraits< DynamicVector< K, Allocator > > { - typedef typename FieldTraits::field_type field_type; - typedef typename FieldTraits::real_type real_type; + typedef typename FieldTraits< K >::field_type field_type; + typedef typename FieldTraits< K >::real_type real_type; }; /** \brief Construct a vector with a dynamic size. * * \tparam K is the field type (use float, double, complex, etc) + * \tparam Allocator type of allocator object used to define the storage allocation model, + * default Allocator = std::allocator< K >. */ - template< class K > - class DynamicVector : public DenseVector< DynamicVector > + template< class K, class Allocator = std::allocator< K > > + class DynamicVector : public DenseVector< DynamicVector< K, Allocator > > { - std::vector _data; + std::vector< K, Allocator > _data; - typedef DenseVector< DynamicVector > Base; + typedef DenseVector< DynamicVector< K, Allocator > > Base; public: typedef typename Base::size_type size_type; typedef typename Base::value_type value_type; - - //! Constructor making uninitialized vector - DynamicVector() {} - - //! Constructor making vector with identical coordinates - explicit DynamicVector (size_type n, value_type c = value_type() ) : - _data(n,c) + + typedef Allocator allocator_type; + + //! Constructor making uninitialized vector + explicit DynamicVector(const allocator_type &a = allocator_type() ) : + _data( a ) + {} + + explicit DynamicVector(size_type n, const allocator_type &a = allocator_type() ) : + _data( n, value_type(), a ) + {} + + //! Constructor making vector with identical coordinates + DynamicVector( size_type n, value_type c, const allocator_type &a = allocator_type() ) : + _data( n, c, a ) + {} + + /** \brief Construct from a std::initializer_list */ + DynamicVector (std::initializer_list const &l) : + _data(l) + {} + + //! Constructor making vector with identical coordinates + DynamicVector(const DynamicVector & x) : + Base(), _data(x._data) + {} + + //! Move constructor + DynamicVector(DynamicVector && x) : + _data(std::move(x._data)) + {} + + template< class T > + DynamicVector(const DynamicVector< T, Allocator > & x) : + _data(x.begin(), x.end(), x.get_allocator()) {} - //! Constructor making vector with identical coordinates - DynamicVector (const DynamicVector & x) : - _data(x._data) - {} + //! Copy constructor from another DenseVector + template< class X > + DynamicVector(const DenseVector< X > & x, const allocator_type &a = allocator_type() ) : + _data(a) + { + const size_type n = x.size(); + _data.reserve(n); + for( size_type i =0; i + template< class K, class Allocator > inline std::istream &operator>> ( std::istream &in, - DynamicVector &v ) + DynamicVector< K, Allocator > &v ) { - DynamicVector w(v); - for( typename DynamicVector::size_type i = 0; i < w.size(); ++i ) + DynamicVector< K, Allocator > w(v); + for( typename DynamicVector< K, Allocator >::size_type i = 0; i < w.size(); ++i ) in >> w[ i ]; if(in) - v = w; + v = std::move(w); return in; } diff -Nru dune-common-2.2.1/dune/common/enumset.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/enumset.hh --- dune-common-2.2.1/dune/common/enumset.hh 2010-08-25 16:17:10.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/enumset.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,11 +1,14 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_ENUMSET_HH #define DUNE_ENUMSET_HH -#include +#include +#include namespace Dune { - /** + /** * @file * @brief Classes for building sets out of enumeration values. * @author Markus Blatt @@ -33,7 +36,7 @@ }; /** - * @brief An set containing everything. + * @brief A set containing everything. */ template class AllSet @@ -53,14 +56,14 @@ * @brief A set consisting only of one item. */ template - class EnumItem + class EnumItem { public: /** * @brief The type the set holds. */ typedef TA Type; - + /** * @brief Tests whether an item is in the set. * @return True if item==Type. @@ -92,32 +95,34 @@ { public: typedef typename S::Type Type; - + static bool contains(const Type& item) { return !S::contains(item); } }; - + /** * @brief A set combining two other sets. */ template - class Combine + class Combine { public: static bool contains(const TA& item); }; - + template inline bool EmptySet::contains(const Type& attribute) { + DUNE_UNUSED_PARAMETER(attribute); return false; } template inline bool AllSet::contains(const Type& attribute) { + DUNE_UNUSED_PARAMETER(attribute); return true; } @@ -138,25 +143,25 @@ { return from<=item && item<=to; } - + template inline std::ostream& operator<<(std::ostream& os, const EnumRange&) { return os<<"["< inline bool Combine::contains(const TA& item) { return TI1::contains(item) || - TI2::contains(item); + TI2::contains(item); } - + template inline Combine combine(const TI1& set1, const TI2& set2) { return Combine(); - } + } template inline std::ostream& operator<<(std::ostream& os, const Combine&) diff -Nru dune-common-2.2.1/dune/common/exceptions.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/exceptions.cc --- dune-common-2.2.1/dune/common/exceptions.cc 2010-08-25 17:20:21.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/exceptions.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,6 +1,40 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #include namespace Dune { - // static member of Dune::Exception - ExceptionHook * Exception::_hook = 0; + /* + static member of Dune::Exception + */ + ExceptionHook * Exception::_hook = 0; + + /* + Implementation of Dune::Exception + */ + Exception::Exception () + { + // call the hook if necessary + if (_hook != 0) _hook->operator()(); + } + + void Exception::registerHook (ExceptionHook * hook) + { + _hook = hook; + } + + void Exception::clearHook () + { + _hook = 0; + } + + void Exception::message(const std::string & msg) + { + _message = msg; + } + + const char* Exception::what() const noexcept + { + return _message.data(); + } + } diff -Nru dune-common-2.2.1/dune/common/exceptions.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/exceptions.hh --- dune-common-2.2.1/dune/common/exceptions.hh 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/exceptions.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,316 +1,288 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: -// $Id: exceptions.hh 7077 2013-01-19 10:06:29Z mblatt $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_EXCEPTIONS_HH #define DUNE_EXCEPTIONS_HH +#include #include #include namespace Dune { -/*! \defgroup Exceptions Exception handling - \ingroup Common - \{ - - The Dune-exceptions are designed to allow a simple derivation of subclasses - and to accept a text written in the '<<' syntax. - - Example of usage: - -\code -#include - -... - -class FileNotFoundError : public Dune::IOError {}; - -... - -void fileopen (std::string name) { - std::ifstream file; - - file.open(name.c_str()); + /*! \defgroup Exceptions Exception handling + \ingroup Common + \{ + + The Dune-exceptions are designed to allow a simple derivation of subclasses + and to accept a text written in the '<<' syntax. + + Example of usage: + + \code + #include + + ... + + class FileNotFoundError : public Dune::IOError {}; + + ... + + void fileopen (std::string name) { + std::ifstream file; + + file.open(name.c_str()); + + if (file == 0) + DUNE_THROW(FileNotFoundError, "File " << name << " not found!"); + + ... + + file.close(); + } + + ... + + int main () { + try { + ... + } catch (Dune::IOError &e) { + std::cerr << "I/O error: " << e << std::endl; + return 1; + } catch (Dune::Exception &e) { + std::cerr << "Generic Dune error: " << e << std::endl; + return 2; + } + } + \endcode + + \see exceptions.hh for detailed info + + */ + + /*! \file + \brief A few common exception classes + + This file defines a common framework for generating exception + subclasses and to throw them in a simple manner + + */ + + /* forward declarations */ + class Exception; + struct ExceptionHook; + + /*! \class Exception + \brief Base class for Dune-Exceptions + + all Dune exceptions are derived from this class via trivial subclassing: + + \code + class MyException : public Dune::Exception {}; + \endcode + + You should not \c throw a Dune::Exception directly but use the macro + DUNE_THROW() instead which fills the message-buffer of the exception + in a standard way and features a way to pass the result in the + operator<<-style + + \see DUNE_THROW, IOError, MathError + + */ + class Exception + : public std::exception + { + public: + Exception (); + void message(const std::string &msg); //!< store string in internal message buffer + virtual const char* what() const noexcept; //!< output internal message buffer + static void registerHook (ExceptionHook * hook); //!< add a functor which is called before a Dune::Exception is emitted (see Dune::ExceptionHook) \see Dune::ExceptionHook + static void clearHook (); //!< remove all hooks + private: + std::string _message; + static ExceptionHook * _hook; + }; + + /*! \brief Base class to add a hook to the Dune::Exception + + The user can add a functor which should be called before a Dune::Exception is emitted. + + + Example: attach a debugger to the process, if an exception is thrown + \code + struct ExceptionHookDebugger : public Dune::ExceptionHook + { + char * process_; + char * debugger_; + ExceptionHookDebugger (int argc, char ** argv, std::string debugger) + { + process_ = strdup(argv[0]); + debugger_ = strdup(debugger.c_str()); + } + virtual void operator () () + { + pid_t pid = getpid(); + pid_t cpid; + cpid = fork(); + if (cpid == 0) // child + { + char * argv[4]; + argv[0] = debugger_; + argv[1] = process_; + argv[2] = new char[12]; + snprintf(argv[2], 12, "%i", int(pid)); + argv[3] = 0; + // execute debugger + std::cout << process_ << "\n"; + std::cout << argv[0] << " " + << argv[1] << " " + << argv[2] << std::endl; + execv(argv[0], argv); + } + else // parent + { + // send application to sleep + kill(pid, SIGSTOP); + } + } + }; + \endcode + + This hook is registered via a static method of Dune::Exception: + \code + int main(int argc, char** argv) { + Dune::MPIHelper & mpihelper = Dune::MPIHelper::instance(argc,argv); + ExceptionHookDebugger debugger(argc, argv, "/usr/bin/ddd"); + Dune::Exception::registerHook(& debugger); + try + { + ... + } + catch (std::string & s) { + std::cout << mpihelper.rank() << ": ERROR: " << s << std::endl; + } + catch (Dune::Exception & e) { + std::cout << mpihelper.rank() << ": DUNE ERROR: " << e.what() << std::endl; + } + } + \endcode + + */ + struct ExceptionHook + { + virtual ~ExceptionHook() {} + virtual void operator () () = 0; + }; + + inline std::ostream& operator<<(std::ostream &stream, const Exception &e) + { + return stream << e.what(); + } - if (file == 0) - DUNE_THROW(FileNotFoundError, "File " << name << " not found!"); +#ifndef DOXYGEN + // the "format" the exception-type gets printed. __FILE__ and + // __LINE__ are standard C-defines, the GNU cpp-infofile claims that + // C99 defines __func__ as well. __FUNCTION__ is a GNU-extension +#define THROWSPEC(E) # E << " [" << __func__ << ":" << __FILE__ << ":" << __LINE__ << "]: " +#endif // DOXYGEN - ... + /*! Macro to throw an exception - file.close(); -} + \code + #include + \endcode -... + \param E exception class derived from Dune::Exception + \param m reason for this exception in ostream-notation -int main () { - try { - ... - } catch (Dune::IOError &e) { - std::cerr << "I/O error: " << e << std::endl; - return 1; - } catch (Dune::Exception &e) { - std::cerr << "Generic Dune error: " << e << std::endl; - return 2; - } -} -\endcode + Example: - \see exceptions.hh for detailed info + \code + if (filehandle == 0) + DUNE_THROW(FileError, "Could not open " << filename << " for reading!"); + \endcode -*/ + DUNE_THROW automatically adds information about the exception thrown + to the text. -/*! \file - \brief A few common exception classes - -This file defines a common framework for generating exception -subclasses and to throw them in a simple manner - -*/ - -/* forward declarations */ -class Exception; -struct ExceptionHook; - -/*! \class Exception - \brief Base class for Dune-Exceptions - - all Dune exceptions are derived from this class via trivial subclassing: - -\code - class MyException : public Dune::Exception {}; -\endcode - - You should not \c throw a Dune::Exception directly but use the macro - DUNE_THROW() instead which fills the message-buffer of the exception - in a standard way and features a way to pass the result in the - operator<<-style - - \see DUNE_THROW, IOError, MathError - -*/ -class Exception { -public: - Exception (); - void message(const std::string &msg); //!< store string in internal message buffer - const std::string& what() const; //!< output internal message buffer - static void registerHook (ExceptionHook * hook); //!< add a functor which is called before a Dune::Exception is emitted (see Dune::ExceptionHook) \see Dune::ExceptionHook - static void clearHook (); //!< remove all hooks -private: - std::string _message; - static ExceptionHook * _hook; -}; - -/*! \brief Base class to add a hook to the Dune::Exception - - The user can add a functor which should be called before a Dune::Exception is emitted. - - - Example: attach a debugger to the process, if an exception is thrown -\code -struct ExceptionHookDebugger : public Dune::ExceptionHook -{ - char * process_; - char * debugger_; - ExceptionHookDebugger (int argc, char ** argv, std::string debugger) - { - process_ = strdup(argv[0]); - debugger_ = strdup(debugger.c_str()); - } - virtual void operator () () - { - pid_t pid = getpid(); - pid_t cpid; - cpid = fork(); - if (cpid == 0) // child - { - char * argv[4]; - argv[0] = debugger_; - argv[1] = process_; - argv[2] = new char[12]; - snprintf(argv[2], 12, "%i", int(pid)); - argv[3] = 0; - // execute debugger - std::cout << process_ << "\n"; - std::cout << argv[0] << " " - << argv[1] << " " - << argv[2] << std::endl; - execv(argv[0], argv); - } - else // parent - { - // send application to sleep - kill(pid, SIGSTOP); - } - } -}; -\endcode - - This hook is registered via a static method of Dune::Exception: -\code -int main(int argc, char** argv) { - Dune::MPIHelper & mpihelper = Dune::MPIHelper::instance(argc,argv); - ExceptionHookDebugger debugger(argc, argv, "/usr/bin/ddd"); - Dune::Exception::registerHook(& debugger); - try - { - ... - } - catch (std::string & s) { - std::cout << mpihelper.rank() << ": ERROR: " << s << std::endl; - } - catch (Dune::Exception & e) { - std::cout << mpihelper.rank() << ": DUNE ERROR: " << e.what() << std::endl; - } -} -\endcode - - */ -struct ExceptionHook -{ - virtual ~ExceptionHook() {} - virtual void operator () () = 0; -}; - -/* - Implementation of Dune::Exception - */ - -inline Exception::Exception () -{ - // call the hook if necessary - if (_hook != 0) _hook->operator()(); -} - -inline void Exception::registerHook (ExceptionHook * hook) -{ - _hook = hook; -} - -inline void Exception::clearHook () -{ - _hook = 0; -} - -inline void Exception::message(const std::string & msg) -{ - _message = msg; -} - -inline const std::string& Exception::what() const -{ - return _message; -} - -inline std::ostream& operator<<(std::ostream &stream, const Exception &e) -{ - return stream << e.what(); -} + \note + you can add a hook to be called before a Dune::Exception is emitted, + e.g. to add additional information to the exception, + or to invoke a debugger during parallel debugging. (see Dune::ExceptionHook) -#ifndef DOXYGEN -// the "format" the exception-type gets printed. __FILE__ and -// __LINE__ are standard C-defines, the GNU cpp-infofile claims that -// C99 defines __func__ as well. __FUNCTION__ is a GNU-extension -#define THROWSPEC(E) #E << " [" << __func__ << ":" << __FILE__ << ":" << __LINE__ << "]: " -#endif // DOXYGEN + */ + // this is the magic: use the usual do { ... } while (0) trick, create + // the full message via a string stream and throw the created object +#define DUNE_THROW(E, m) do { E th__ex; std::ostringstream th__out; \ + th__out << THROWSPEC(E) << m; th__ex.message(th__out.str()); throw th__ex; \ +} while (0) -/*! Macro to throw an exception + /*! \brief Default exception class for I/O errors - \code -#include - \endcode - - \param E exception class derived from Dune::Exception - \param m reason for this exception in ostream-notation - - Example: - - \code - if (filehandle == 0) - DUNE_THROW(FileError, "Could not open " << filename << " for reading!"); - \endcode - - DUNE_THROW automatically adds information about the exception thrown - to the text. - - \note - you can add a hook to be called before a Dune::Exception is emitted, - e.g. to add additional information to the exception, - or to invoke a debugger during parallel debugging. (see Dune::ExceptionHook) - - */ -// this is the magic: use the usual do { ... } while (0) trick, create -// the full message via a string stream and throw the created object -#define DUNE_THROW(E, m) do { E th__ex; std::ostringstream th__out; \ - th__out << THROWSPEC(E) << m; th__ex.message(th__out.str()); throw th__ex; \ - } while (0) + This is a superclass for any errors dealing with file/socket I/O problems + like -/*! \brief Default exception class for I/O errors + - file not found + - could not write file + - could not connect to remote socket + */ + class IOError : public Exception {}; - This is a superclass for any errors dealing with file/socket I/O problems - like + /*! \brief Default exception class for mathematical errors - - file not found - - could not write file - - could not connect to remote socket - */ -class IOError : public Exception {}; + This is the superclass for all errors which are caused by + mathematical problems like -/*! \brief Default exception class for mathematical errors + - matrix not invertible + - not convergent + */ + class MathError : public Exception {}; - This is the superclass for all errors which are caused by - mathematical problems like + /*! \brief Default exception class for range errors - - matrix not invertible - - not convergent - */ -class MathError : public Exception {}; + This is the superclass for all errors which are caused because + the user tries to access data that was not allocated before. + These can be problems like -/*! \brief Default exception class for range errors + - accessing array entries behind the last entry + - adding the fourth non zero entry in a sparse matrix + with only three non zero entries per row - This is the superclass for all errors which are caused because - the user tries to access data that was not allocated before. - These can be problems like + */ + class RangeError : public Exception {}; - - accessing array entries behind the last entry - - adding the fourth non zero entry in a sparse matrix - with only three non zero entries per row - - */ -class RangeError : public Exception {}; + /*! \brief Default exception for dummy implementations -/*! \brief Default exception for dummy implementations + This exception can be used for functions/methods - This exception can be used for functions/methods + - that have to be implemented but should never be called + - that are missing + */ + class NotImplemented : public Exception {}; - - that have to be implemented but should never be called - - that are missing - */ -class NotImplemented : public Exception {}; + /*! \brief Default exception class for OS errors -/*! \brief Default exception class for OS errors + This class is thrown when a system-call is used and returns an + error. - This class is thrown when a system-call is used and returns an - error. - - */ -class SystemError : public Exception {}; + */ + class SystemError : public Exception {}; -/*! \brief Default exception if memory allocation fails + /*! \brief Default exception if memory allocation fails - */ -class OutOfMemoryError : public SystemError {}; + */ + class OutOfMemoryError : public SystemError {}; -/*! \brief Default exception if a function was called while - the object is not in a valid state for that function. - */ -class InvalidStateException : public Exception {}; + /*! \brief Default exception if a function was called while + the object is not in a valid state for that function. + */ + class InvalidStateException : public Exception {}; -/*! \brief Default exception if an error in the parallel - communication of the programm occured - \ingroup ParallelCommunication - */ -class ParallelError : public Exception {}; + /*! \brief Default exception if an error in the parallel + communication of the programm occurred + \ingroup ParallelCommunication + */ + class ParallelError : public Exception {}; } // end namespace diff -Nru dune-common-2.2.1/dune/common/fassign.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/fassign.hh --- dune-common-2.2.1/dune/common/fassign.hh 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/fassign.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,296 +0,0 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set ts=8 sw=4 et sts=4: -#ifndef DUNE_ASSIGN_HH -#define DUNE_ASSIGN_HH - -#include -#include - -namespace Dune { - - /** - * @file - * @brief Classes for implementing an assignment to FieldVector from a comma-separated list - */ - /** @addtogroup Common - * - * @{ - */ - -/** - * Emtpy namespace make this class and the object local to one object file - */ -namespace { - - /** - * @brief Initializer class for - * - * overload operator <<= for FieldVector assignment from Dune::Zero - */ - struct Zero { - explicit Zero (int) {}; - /** \brief Conversion operator to double */ - operator double () { return 0.0; } - /** \brief Conversion operator to int */ - operator int () { return 0; } - } zero(0); - - /** - * @brief Marker class for next row - * - * overload operator <<= for FieldMatrix assignment - */ - struct NextRow { - explicit NextRow (int) {}; - } nextRow(0); -} // end empty namespace - -/** - * @brief fvector assignment operator - * - * overload operator <<= for fvector assignment from Dune::Zero - * - * after including fassing.hh you can easily assign data to a FieldVector - * using - * - * @code - * FieldVector x; x <<= 1.0, 4.0, 10.0, 11.0; - * @endcode - * - * The operator checks that the whole vector is initalized. - * In case you know that all following entries will be zero padded, you can use - * - * @code - * FieldVector x; x <<= 1.0, 4.0, 10.0, 11.0, zero; - * @endcode - * - */ -template -class fvector_assigner -{ -private: - FieldVector & v; - int c; - bool temporary; - fvector_assigner(); -public: - /*! @brief Copy Constructor */ - fvector_assigner(fvector_assigner & a) : v(a.v), c(a.c), temporary(false) - { - } - /*! @brief Constructor from vector and temporary flag - \param _v vector which should be initialized - \param t bool indicating, that this is a temporary object (see ~fvector_assigner) - */ - fvector_assigner(FieldVector & _v, bool t) : v(_v), c(0), temporary(t) - { - }; - /*! @brief Destructor - checks for complete initialization of the vector. - The check is skipped, if this object is marked temporary. - */ - ~fvector_assigner() - { - if (!temporary && c!=s) - DUNE_THROW(MathError, "Trying to assign " << c << - " entries to a FieldVector of size " << s); - } - /*! @brief append data to this vector */ - fvector_assigner & append (const T & t) - { - v[c++] = t; - return *this; - } - /*! @brief append zeros to this vector - */ - fvector_assigner & append (Zero z) - { - while (c!=s) v[c++] = 0; - return *this; - } - /*! @brief append data to this vector - the overloaded comma operator is used to assign a comma seperated list - of values to the vector - */ - fvector_assigner & operator , (const T & t) - { - return append(t); - } - /*! @brief append zeros to this vector - the overloaded comma operator is used to stop the assign of values - to the vector, all remaining entries are assigned 0. - */ - fvector_assigner & operator , (Zero z) - { - return append(z); - } -}; - -/** - * @brief fvector assignment operator - * - * overload operator <<= for fvector assignment - * from comma seperated list of values - */ -template -fvector_assigner operator <<= (FieldVector & v, const K & t) -{ - return fvector_assigner(v,true).append(t); -} - -/** - * @brief fvector assignment operator - * - * overload operator <<= for fvector assignment from Dune::Zero - */ -template -fvector_assigner operator <<= (FieldVector & v, Zero z) -{ - return fvector_assigner(v,true).append(z); -} - -/** - * @brief fmatrix assignment operator - * - * overload operator <<= for fmatrix assignment from Dune::Zero - * - * after including fassing.hh you can easily assign data to a FieldMatrix - * using - * - * @code - * FieldMatrix x; x <<= 1.0, 4.0, nextRow, 10.0, 11.0; - * @endcode - * - * The operator checks that the whole matrix is initalized. - * In case you know that all following entries of a row will be zero padded, you can use - * - * @code - * FieldMatrix x; x <<= 1.0, zero, nextRow, 10.0, 11.0; - * @endcode - * - */ -template -class fmatrix_assigner -{ -private: - FieldMatrix & A; - int c; - int r; - bool temporary; - bool thrown; - - void end_row() - { - if (!temporary && c!=m && !thrown){ - thrown=true; - DUNE_THROW(MathError, "Trying to assign " << c << - " entries to a FieldMatrix row of size " << m); - } - c=0; - } -public: - /*! @brief Copy Constructor */ - fmatrix_assigner(fmatrix_assigner & a) : A(a.A), c(a.c), r(a.r), temporary(false), thrown(a.thrown) - { - } - /*! @brief Constructor from matrix and temporary flag - \param _A matrix which should be initialized - \param t bool indicating, that this is a temporary object (see ~fmatrix_assigner) - */ - fmatrix_assigner(FieldMatrix & _A, bool t) : A(_A), c(0), r(0), temporary(t), - thrown(false) - { - }; - /*! @brief Destructor - checks for complete initialization of the matrix. - The check is skipped, if this object is marked temporary. - */ - ~fmatrix_assigner() - { - end_row(); - if (!temporary && r!=n-1 && !thrown){ - thrown=true; - DUNE_THROW(MathError, "Trying to assign " << r << - " rows to a FieldMatrix of size " << n << " x " << m); - } - } - /*! @brief append data to this matrix */ - fmatrix_assigner & append (const T & t) - { - // Check whether we have passed the last row - if(r>=m){ - thrown=true; - DUNE_THROW(MathError, "Trying to assign more than " << m << - " rows to a FieldMatrix of size " << n << " x " << m); - } - A[r][c++] = t; - return *this; - } - /*! @brief append zeros to this matrix - */ - fmatrix_assigner & append (Zero z) - { - while (c!=m) A[r][c++] = 0; - return *this; - } - /*! @brief move to next row of the matrix - */ - fmatrix_assigner & append (NextRow nr) - { - end_row(); - r++; - return *this; - } - /*! @brief append data to this matrix - the overloaded comma operator is used to assign a comma seperated list - of values to the matrix - */ - fmatrix_assigner & operator , (const T & t) - { - return append(t); - } - /*! @brief append zeros to this matrix - the overloaded comma operator is used to stop the assign of values - to the matrix, all remaining entries are assigned 0. - */ - fmatrix_assigner & operator , (Zero z) - { - return append(z); - } - /*! @brief append zeros to this matrix - the overloaded comma operator is used to stop the assign of values - to the current row, it will be checked whether all entries have been - assigned values. - */ - fmatrix_assigner & operator , (NextRow nr) - { - return append(nr); - } -}; - -/** - * @brief FieldMatrix assignment operator - * - * overload operator <<= for FieldMatrix assignment - * from comma seperated list of values - */ -template -fmatrix_assigner operator <<= (FieldMatrix & v, const K & t) -{ - return fmatrix_assigner(v,true).append(t); -} - -/** - * @brief FieldMatrix assignment operator - * - * overload operator <<= for FieldMatrix row assignment from Dune::Zero - */ -template -fmatrix_assigner operator <<= (FieldMatrix & v, Zero z) -{ - return fmatrix_assigner(v,true).append(z); -} - -} // end namespace Dune - -#endif // DUNE_ASSIGN_HH diff -Nru dune-common-2.2.1/dune/common/finitestack.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/finitestack.hh --- dune-common-2.2.1/dune/common/finitestack.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/finitestack.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -#ifndef DUNE_FINITE_STACK_HH -#define DUNE_FINITE_STACK_HH - -/** \file - * \brief Stack class of fixed maximum size (deprecated) - */ - -#warning This file is deprecated and will be removed after the release of dune-common-2.2. \ - Please use std::stack instead of FiniteStack. - -#include - -#include -#include - -namespace Dune { - - /*! \addtogroup Common - @{ - */ - - /*! \file - - This file implements a stack classes FiniteStack. It is - mainly used by the grid iterators where exact knowledge of the stack - implementation is needed to guarantee efficient execution. - */ - - /** \brief A stack with static memory allocation - * - This class implements a very efficient stack where the maximum - depth is known in advance. Note that no error checking is - performed! - - \param n Maximum number of stack entries - */ - template - class FiniteStack - : public std::stack > - { - public : - - //! Returns true if the stack is full - bool full () const - { - return this->size()>=n; - } - - /** Removes and returns the uppermost object from the stack - \warning This differs from the semantics of std::stack, where pop() returns void - */ - T pop () - { -#ifndef NDEBUG - if (this->empty()) - DUNE_THROW(Dune::RangeError, "trying to call pop() on an empty FiniteStack"); -#endif - T tmp = this->top(); - this->std::stack >::pop(); - return tmp; - } - - }; - -} - -//! }@ - -#endif diff -Nru dune-common-2.2.1/dune/common/float_cmp.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/float_cmp.cc --- dune-common-2.2.1/dune/common/float_cmp.cc 2009-06-22 12:22:13.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/float_cmp.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #include "float_cmp.hh" #include @@ -17,7 +19,7 @@ * @tparam T The value type */ template struct EpsilonType { - //! The epsilon type corresponding to value type T + //! The epsilon type corresponding to value type T typedef T Type; }; //! Specialization of EpsilonType for std::vector @@ -116,64 +118,88 @@ bool eq(const T &first, const T &second, typename EpsilonType::Type epsilon) - { return Detail::eq_t::eq(first, second, epsilon); } + { + return Detail::eq_t::eq(first, second, epsilon); + } template bool ne(const T &first, const T &second, typename EpsilonType::Type epsilon) - { return !eq(first, second, epsilon); } + { + return !eq(first, second, epsilon); + } template bool gt(const T &first, const T &second, typename EpsilonType::Type epsilon) - { return first > second && ne(first, second, epsilon); } + { + return first > second && ne(first, second, epsilon); + } template bool lt(const T &first, const T &second, typename EpsilonType::Type epsilon) - { return first < second && ne(first, second, epsilon); } + { + return first < second && ne(first, second, epsilon); + } template bool ge(const T &first, const T &second, typename EpsilonType::Type epsilon) - { return first > second || eq(first, second, epsilon); } + { + return first > second || eq(first, second, epsilon); + } template bool le(const T &first, const T &second, typename EpsilonType::Type epsilon) - { return first < second || eq(first, second, epsilon); } + { + return first < second || eq(first, second, epsilon); + } // default template arguments template bool eq(const T &first, const T &second, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return eq(first, second, epsilon); } + { + return eq(first, second, epsilon); + } template bool ne(const T &first, const T &second, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return ne(first, second, epsilon); } + { + return ne(first, second, epsilon); + } template bool gt(const T &first, const T &second, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return gt(first, second, epsilon); } + { + return gt(first, second, epsilon); + } template bool lt(const T &first, const T &second, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return lt(first, second, epsilon); } + { + return lt(first, second, epsilon); + } template bool ge(const T &first, const T &second, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return ge(first, second, epsilon); } + { + return ge(first, second, epsilon); + } template bool le(const T &first, const T &second, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return le(first, second, epsilon); } + { + return le(first, second, epsilon); + } // rounding operations namespace Detail { @@ -216,7 +242,7 @@ static I round(const T &val, typename EpsilonType::Type epsilon = (DefaultEpsilon::value())) { - if(val > T(0)) + if(val > T(0)) return round_t::round(val, epsilon); else return round_t::round(val, epsilon); } @@ -226,7 +252,7 @@ static I round(const T &val, typename EpsilonType::Type epsilon = (DefaultEpsilon::value())) { - if(val > T(0)) + if(val > T(0)) return round_t::round(val, epsilon); else return round_t::round(val, epsilon); } @@ -257,16 +283,24 @@ } // namespace Detail template I round(const T &val, typename EpsilonType::Type epsilon /*= DefaultEpsilon::value()*/) - { return Detail::round_t::round(val, epsilon); } + { + return Detail::round_t::round(val, epsilon); + } template I round(const T &val, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return round(val, epsilon); } + { + return round(val, epsilon); + } template I round(const T &val, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return round(val, epsilon); } + { + return round(val, epsilon); + } template I round(const T &val, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return round(val, epsilon); } + { + return round(val, epsilon); + } // truncation namespace Detail { @@ -277,7 +311,7 @@ static I trunc(const T &val, typename EpsilonType::Type epsilon = (DefaultEpsilon::value())) { - // this sould be optimized away unless needed + // this should be optimized away unless needed if(!std::numeric_limits::is_signed) // make sure this works for all useful cases even if I is an unsigned type if(eq(val, T(0), epsilon)) return I(0); @@ -345,16 +379,24 @@ } // namespace Detail template I trunc(const T &val, typename EpsilonType::Type epsilon /*= DefaultEpsilon::value()*/) - { return Detail::trunc_t::trunc(val, epsilon); } + { + return Detail::trunc_t::trunc(val, epsilon); + } template I trunc(const T &val, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return trunc(val, epsilon); } + { + return trunc(val, epsilon); + } template I trunc(const T &val, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return trunc(val, epsilon); } + { + return trunc(val, epsilon); + } template I trunc(const T &val, typename EpsilonType::Type epsilon = DefaultEpsilon::value()) - { return trunc(val, epsilon); } + { + return trunc(val, epsilon); + } } //namespace Dune // oo interface @@ -366,55 +408,75 @@ template typename FloatCmpOps::EpsilonType FloatCmpOps::epsilon() const - { return epsilon_; } + { + return epsilon_; + } template void FloatCmpOps::epsilon(EpsilonType epsilon__) - { epsilon_ = epsilon__; } + { + epsilon_ = epsilon__; + } template bool FloatCmpOps:: eq(const ValueType &first, const ValueType &second) const - { return Dune::FloatCmp::eq(first, second, epsilon_); } + { + return Dune::FloatCmp::eq(first, second, epsilon_); + } template bool FloatCmpOps:: ne(const ValueType &first, const ValueType &second) const - { return Dune::FloatCmp::ne(first, second, epsilon_); } + { + return Dune::FloatCmp::ne(first, second, epsilon_); + } template bool FloatCmpOps:: gt(const ValueType &first, const ValueType &second) const - { return Dune::FloatCmp::gt(first, second, epsilon_); } + { + return Dune::FloatCmp::gt(first, second, epsilon_); + } template bool FloatCmpOps:: lt(const ValueType &first, const ValueType &second) const - { return Dune::FloatCmp::lt(first, second, epsilon_); } + { + return Dune::FloatCmp::lt(first, second, epsilon_); + } template bool FloatCmpOps:: ge(const ValueType &first, const ValueType &second) const - { return Dune::FloatCmp::ge(first, second, epsilon_); } + { + return Dune::FloatCmp::ge(first, second, epsilon_); + } template bool FloatCmpOps:: le(const ValueType &first, const ValueType &second) const - { return Dune::FloatCmp::le(first, second, epsilon_); } + { + return Dune::FloatCmp::le(first, second, epsilon_); + } template template I FloatCmpOps:: round(const ValueType &val) const - { return Dune::FloatCmp::round(val, epsilon_); } + { + return Dune::FloatCmp::round(val, epsilon_); + } template template I FloatCmpOps:: trunc(const ValueType &val) const - { return Dune::FloatCmp::trunc(val, epsilon_); } + { + return Dune::FloatCmp::trunc(val, epsilon_); + } } //namespace Dune diff -Nru dune-common-2.2.1/dune/common/float_cmp.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/float_cmp.hh --- dune-common-2.2.1/dune/common/float_cmp.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/float_cmp.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_FLOAT_CMP_HH #define DUNE_COMMON_FLOAT_CMP_HH @@ -6,88 +8,87 @@ */ /** - @addtogroup FloatCmp FloatCmp - @ingroup Common + @addtogroup FloatCmp - @section How_to_compare How to compare floats + @section How_to_compare How to compare floats - When comparing floating point numbers for equality, one often faces the - problem that floating point operations are not always exact. For example on - i386 the expression - @code + When comparing floating point numbers for equality, one often faces the + problem that floating point operations are not always exact. For example on + i386 the expression + @code 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 == 2.0 - @endcode - evaluates to - @code + @endcode + evaluates to + @code 1.99999999999999977796 == 2.00000000000000000000 - @endcode - which is false. One solution is to compare approximately, using an epsilon - which says how much deviation to accept. - - The most straightforward way of comparing is using an @em absolute epsilon. - This means comparison for equality is replaced by - @code + @endcode + which is false. One solution is to compare approximately, using an epsilon + which says how much deviation to accept. + + The most straightforward way of comparing is using an @em absolute epsilon. + This means comparison for equality is replaced by + @code abs(first-second) <= epsilon - @endcode - This has a severe disadvantage: if you have an epsilon like 1e-10 but first - and second are of the magnitude 1e-15 everything will compare equal which is - certainly not what you want. This can be overcome by selecting an - appropriate epsilon. Nevertheless this method of comparing is not - recommended in general, and we will present a more robus method in the - next paragraph. - - There is another way of comparing approximately, using a @em relative - epsilon which is then scaled with first: - @code + @endcode + This has a severe disadvantage: if you have an epsilon like 1e-10 but first + and second are of the magnitude 1e-15 everything will compare equal which is + certainly not what you want. This can be overcome by selecting an + appropriate epsilon. Nevertheless this method of comparing is not + recommended in general, and we will present a more robus method in the + next paragraph. + + There is another way of comparing approximately, using a @em relative + epsilon which is then scaled with first: + @code abs(first-second) <= epsilon * abs(first) - @endcode - Of cource the comparison should be symmetric in first and second so we - cannot arbitrarily select either first or second to scale epsilon. The are - two symmetric variants, @em relative_weak - @code + @endcode + Of cource the comparison should be symmetric in first and second so we + cannot arbitrarily select either first or second to scale epsilon. The are + two symmetric variants, @em relative_weak + @code abs(first-second) <= epsilon * max(abs(first), abs(second)) - @endcode - and @em relative_strong - @code + @endcode + and @em relative_strong + @code abs(first-second) <= epsilon * min(abs(first), abs(second)) - @endcode - Both variants are good, but in practice the relative_weak variant is - preferred. This is also the default variant. + @endcode + Both variants are good, but in practice the relative_weak variant is + preferred. This is also the default variant. - \note Although using a relative epsilon is better than using an absolute + \note Although using a relative epsilon is better than using an absolute epsilon, using a relative epsilon leads to problems if either first or second equals 0. In principle the relative method can be combined with an absolute method using an epsilon near the minimum representable positive value, but this is not implemented here. - There is a completely different way of comparing floats. Instead of giving - an epsilon, the programmer states how many representable value are allowed - between first and second. See the "Comparing using integers" section in - http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm - for more about that. - - @section Interface Interface - - To do the comparison, you can use the free functions @link - Dune::FloatCmp::eq eq()@endlink, @link Dune::FloatCmp::ne ne()@endlink, - @link Dune::FloatCmp::gt gt()@endlink, @link Dune::FloatCmp::lt - lt()@endlink, @link Dune::FloatCmp::ge ge()@endlink and @link - Dune::FloatCmp::le le()@endlink from the namespace Dune::FloatCmp. They - take the values to compare and optionally an epsilon, which defaults to 8 - times the machine epsilon (the difference between 1.0 and the smallest - representable value > 1.0) for relative comparisons, or simply 1e-6 for - absolute comparisons. The compare style can be given as an optional second - template parameter and defaults to relative_weak. - - You can also use the class Dune::FloatCmpOps which has @link - Dune::FloatCmpOps::eq eq()@endlink, @link Dune::FloatCmpOps::ne - ne()@endlink, @link Dune::FloatCmpOps::gt gt()@endlink, @link - Dune::FloatCmpOps::lt lt()@endlink, @link Dune::FloatCmpOps::ge ge()@endlink - and @link Dune::FloatCmpOps::le le()@endlink as member functions. In this - case the class encapsulates the epsilon and the comparison style (again the - defaults from the previous paragraph apply). This may be more convenient if - you write your own class utilizing floating point comparisons, and you want - the user of you class to specify epsilon and compare style. + There is a completely different way of comparing floats. Instead of giving + an epsilon, the programmer states how many representable value are allowed + between first and second. See the "Comparing using integers" section in + http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm + for more about that. + + @section Interface Interface + + To do the comparison, you can use the free functions @link + Dune::FloatCmp::eq eq()@endlink, @link Dune::FloatCmp::ne ne()@endlink, + @link Dune::FloatCmp::gt gt()@endlink, @link Dune::FloatCmp::lt + lt()@endlink, @link Dune::FloatCmp::ge ge()@endlink and @link + Dune::FloatCmp::le le()@endlink from the namespace Dune::FloatCmp. They + take the values to compare and optionally an epsilon, which defaults to 8 + times the machine epsilon (the difference between 1.0 and the smallest + representable value > 1.0) for relative comparisons, or simply 1e-6 for + absolute comparisons. The compare style can be given as an optional second + template parameter and defaults to relative_weak. + + You can also use the class Dune::FloatCmpOps which has @link + Dune::FloatCmpOps::eq eq()@endlink, @link Dune::FloatCmpOps::ne + ne()@endlink, @link Dune::FloatCmpOps::gt gt()@endlink, @link + Dune::FloatCmpOps::lt lt()@endlink, @link Dune::FloatCmpOps::ge ge()@endlink + and @link Dune::FloatCmpOps::le le()@endlink as member functions. In this + case the class encapsulates the epsilon and the comparison style (again the + defaults from the previous paragraph apply). This may be more convenient if + you write your own class utilizing floating point comparisons, and you want + the user of you class to specify epsilon and compare style. */ //! Dune namespace @@ -98,7 +99,7 @@ // basic constants //! How to compare //! @ingroup FloatCmp - enum CmpStyle { + enum CmpStyle { //! |a-b|/|a| <= epsilon || |a-b|/|b| <= epsilon relativeWeak, //! |a-b|/|a| <= epsilon && |a-b|/|b| <= epsilon @@ -222,9 +223,9 @@ * @param first left operand of less-or-equals operation * @param second right operand of less-or-equals operation * @param epsilon The epsilon to use in the comparison - * @return eq(first, second) || first > second + * @return eq(first, second) || first < second * - * this is like first > second, but the region that compares equal with an + * this is like first < second, but the region that compares equal with an * epsilon is also included */ template @@ -281,7 +282,7 @@ * @tparam rstyle_ How to round */ template + FloatCmp::RoundingStyle rstyle_ = FloatCmp::defaultRoundingStyle> class FloatCmpOps { typedef FloatCmp::CmpStyle CmpStyle; typedef FloatCmp::RoundingStyle RoundingStyle; @@ -374,7 +375,7 @@ */ template I trunc(const ValueType &val) const; - + }; } //namespace Dune diff -Nru dune-common-2.2.1/dune/common/fmatrixev.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/fmatrixev.cc --- dune-common-2.2.1/dune/common/fmatrixev.cc 2011-03-24 20:34:06.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/fmatrixev.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,7 @@ -#ifndef DUNE_FMATRIXEIGENVALUES_CC -#define DUNE_FMATRIXEIGENVALUES_CC +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_FMATRIXEIGENVALUES_CC +#define DUNE_FMATRIXEIGENVALUES_CC #ifdef HAVE_CONFIG_H #include "config.h" @@ -13,90 +15,210 @@ #if HAVE_LAPACK -// symetric matrices +// symmetric matrices #define DSYEV_FORTRAN FC_FUNC (dsyev, DSYEV) -// nonsymetric matrices +// nonsymmetric matrices #define DGEEV_FORTRAN FC_FUNC (dgeev, DGEEV) // dsyev declaration (in liblapack) extern "C" { -/* - * - ** purpose - ** ======= - ** - ** xsyev computes all eigenvalues and, optionally, eigenvectors of a - ** BASE DATA TYPE symmetric matrix a. - ** - ** arguments - ** ========= - ** - ** jobz (input) char - ** = 'n': compute eigenvalues only; - ** = 'v': compute eigenvalues and eigenvectors. - ** - ** uplo (input) char - ** = 'u': upper triangle of a is stored; - ** = 'l': lower triangle of a is stored. - ** - ** n (input) long int - ** the order of the matrix a. n >= 0. - ** - ** a (input/output) BASE DATA TYPE array, dimension (lda, n) - ** on entry, the symmetric matrix a. if uplo = 'u', the - ** leading n-by-n upper triangular part of a contains the - ** upper triangular part of the matrix a. if uplo = 'l', - ** the leading n-by-n lower triangular part of a contains - ** the lower triangular part of the matrix a. - ** on exit, if jobz = 'v', then if info = 0, a contains the - ** orthonormal eigenvectors of the matrix a. - ** if jobz = 'n', then on exit the lower triangle (if uplo='l') - ** or the upper triangle (if uplo='u') of a, including the - ** diagonal, is destroyed. - ** - ** lda (input) long int - ** the leading dimension of the array a. lda >= max(1,n). - ** - ** w (output) BASE DATA TYPE array, dimension (n) - ** if info = 0, the eigenvalues in ascending order. - ** - ** - ** - ** info (output) long int - ** = 0: successful exit - ** < 0: if info = -i, the i-th argument had an illegal value - ** > 0: if info = i, the algorithm failed to converge; i - ** off-diagonal elements of an intermediate tridiagonal - ** form did not converge to zero. - ** -**/ -extern void DSYEV_FORTRAN(const char* jobz, const char* uplo, const long - int* n, double* a, const long int* lda, double* w, - double* work, const long int* lwork, long int* info); - -} // end extern C + /* + * + ** purpose + ** ======= + ** + ** xsyev computes all eigenvalues and, optionally, eigenvectors of a + ** BASE DATA TYPE symmetric matrix a. + ** + ** arguments + ** ========= + ** + ** jobz (input) char + ** = 'n': compute eigenvalues only; + ** = 'v': compute eigenvalues and eigenvectors. + ** + ** uplo (input) char + ** = 'u': upper triangle of a is stored; + ** = 'l': lower triangle of a is stored. + ** + ** n (input) long int + ** the order of the matrix a. n >= 0. + ** + ** a (input/output) BASE DATA TYPE array, dimension (lda, n) + ** on entry, the symmetric matrix a. if uplo = 'u', the + ** leading n-by-n upper triangular part of a contains the + ** upper triangular part of the matrix a. if uplo = 'l', + ** the leading n-by-n lower triangular part of a contains + ** the lower triangular part of the matrix a. + ** on exit, if jobz = 'v', then if info = 0, a contains the + ** orthonormal eigenvectors of the matrix a. + ** if jobz = 'n', then on exit the lower triangle (if uplo='l') + ** or the upper triangle (if uplo='u') of a, including the + ** diagonal, is destroyed. + ** + ** lda (input) long int + ** the leading dimension of the array a. lda >= max(1,n). + ** + ** w (output) BASE DATA TYPE array, dimension (n) + ** if info = 0, the eigenvalues in ascending order. + ** + ** + ** + ** info (output) long int + ** = 0: successful exit + ** < 0: if info = -i, the i-th argument had an illegal value + ** > 0: if info = i, the algorithm failed to converge; i + ** off-diagonal elements of an intermediate tridiagonal + ** form did not converge to zero. + ** + **/ + extern void DSYEV_FORTRAN(const char* jobz, const char* uplo, const long + int* n, double* a, const long int* lda, double* w, + double* work, const long int* lwork, long int* info); + + /* + * + ** purpose + ** ======= + ** + ** xgeev computes for an N-by-N BASE DATA TYPE nonsymmetric matrix A, the + ** eigenvalues and, optionally, the left and/or right eigenvectors. + ** + ** The right eigenvector v(j) of A satisfies + ** A * v(j) = lambda(j) * v(j) + ** where lambda(j) is its eigenvalue. + ** The left eigenvector u(j) of A satisfies + ** u(j)**T * A = lambda(j) * u(j)**T + ** where u(j)**T denotes the transpose of u(j). + ** + ** The computed eigenvectors are normalized to have Euclidean norm + ** equal to 1 and largest component real. + ** + ** arguments + ** ========= + ** + ** jobvl (input) char + ** = 'n': left eigenvectors of a are not computed; + ** = 'v': left eigenvectors of a are computed. + ** + ** jobvr (input) char + ** = 'n': right eigenvectors of a are not computed; + ** = 'v': right eigenvectors of a are computed. + ** + ** n (input) long int + ** the order of the matrix v. v >= 0. + ** + ** a (input/output) BASE DATA TYPE array, dimension (lda,n) + ** on entry, the n-by-n matrix a. + ** on exit, a has been overwritten. + ** + ** lda (input) long int + ** the leading dimension of the array a. lda >= max(1,n). + ** + ** wr (output) BASE DATA TYPE array, dimension (n) + ** wi (output) BASE DATA TYPE array, dimension (n) + ** wr and wi contain the real and imaginary parts, + ** respectively, of the computed eigenvalues. complex + ** conjugate pairs of eigenvalues appear consecutively + ** with the eigenvalue having the positive imaginary part + ** first. + ** + ** vl (output) COMPLEX DATA TYPE array, dimension (ldvl,n) + ** if jobvl = 'v', the left eigenvectors u(j) are stored one + ** after another in the columns of vl, in the same order + ** as their eigenvalues. + ** if jobvl = 'n', vl is not referenced. + ** if the j-th eigenvalue is real, then u(j) = vl(:,j), + ** the j-th column of vl. + ** if the j-th and (j+1)-st eigenvalues form a complex + ** conjugate pair, then u(j) = vl(:,j) + i*vl(:,j+1) and + ** u(j+1) = vl(:,j) - i*vl(:,j+1). + ** + ** ldvl (input) long int + ** the leading dimension of the array vl. ldvl >= 1; if + ** jobvl = 'v', ldvl >= n. + ** + ** vr (output) COMPLEX DATA TYPE array, dimension (ldvr,n) + ** if jobvr = 'v', the right eigenvectors v(j) are stored one + ** after another in the columns of vr, in the same order + ** as their eigenvalues. + ** if jobvr = 'n', vr is not referenced. + ** if the j-th eigenvalue is real, then v(j) = vr(:,j), + ** the j-th column of vr. + ** if the j-th and (j+1)-st eigenvalues form a complex + ** conjugate pair, then v(j) = vr(:,j) + i*vr(:,j+1) and + ** v(j+1) = vr(:,j) - i*vr(:,j+1). + ** + ** ldvr (input) long int + ** the leading dimension of the array vr. ldvr >= 1; if + ** jobvr = 'v', ldvr >= n. + ** + ** work (workspace/output) BASE DATA TYPE array, dimension (max(1,lwork)) + ** on exit, if info = 0, work(1) returns the optimal lwork. + ** + ** lwork (input) long int + ** the dimension of the array work. lwork >= max(1,3*n), and + ** if jobvl = 'v' or jobvr = 'v', lwork >= 4*n. for good + ** performance, lwork must generally be larger. + ** + ** if lwork = -1, then a workspace query is assumed; the routine + ** only calculates the optimal size of the work array, returns + ** this value as the first entry of the work array, and no error + ** message related to lwork is issued by xerbla. + ** + ** info (output) long int + ** = 0: successful exit + ** < 0: if info = -i, the i-th argument had an illegal value. + ** > 0: if info = i, the qr algorithm failed to compute all the + ** eigenvalues, and no eigenvectors have been computed; + ** elements i+1:n of wr and wi contain eigenvalues which + ** have converged. + ** + **/ + + extern void DGEEV_FORTRAN(const char* jobvl, const char* jobvr, const long + int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, + const long int* ldvl, double* vr, const long int* ldvr, double* work, + const long int* lwork, const long int* info); + +} // end extern C #endif namespace Dune { -namespace FMatrixHelp { + namespace FMatrixHelp { -void eigenValuesLapackCall( + void eigenValuesLapackCall( const char* jobz, const char* uplo, const long int* n, double* a, const long int* lda, double* w, double* work, const long int* lwork, long int* info) -{ -#if HAVE_LAPACK - // call LAPACK dsyev - DSYEV_FORTRAN(jobz, uplo, n, a, lda, w, work, lwork, info); -#else - DUNE_THROW(NotImplemented,"eigenValuesLapackCall: LAPACK not found!"); + { +#if HAVE_LAPACK + // call LAPACK dsyev + DSYEV_FORTRAN(jobz, uplo, n, a, lda, w, work, lwork, info); +#else + DUNE_THROW(NotImplemented,"eigenValuesLapackCall: LAPACK not found!"); +#endif + } + + void eigenValuesNonsymLapackCall( + const char* jobvl, const char* jobvr, const long + int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, + const long int* ldvl, double* vr, const long int* ldvr, double* work, + const long int* lwork, const long int* info) + { +#if HAVE_LAPACK + // call LAPACK dgeev + DGEEV_FORTRAN(jobvl, jobvr, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, + work, lwork, info); +#else + DUNE_THROW(NotImplemented,"eigenValuesNonsymLapackCall: LAPACK not found!"); #endif -} + } -} // end namespace FMatrixHelp + } // end namespace FMatrixHelp -} // end namespace Dune +} // end namespace Dune #endif diff -Nru dune-common-2.2.1/dune/common/fmatrixev.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/fmatrixev.hh --- dune-common-2.2.1/dune/common/fmatrixev.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/fmatrixev.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,7 @@ -#ifndef DUNE_FMATRIXEIGENVALUES_HH -#define DUNE_FMATRIXEIGENVALUES_HH +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_FMATRIXEIGENVALUES_HH +#define DUNE_FMATRIXEIGENVALUES_HH /** \file * \brief Eigenvalue computations for the FieldMatrix class @@ -15,114 +17,232 @@ namespace Dune { -/** -@addtogroup DenseMatVec -@{ - */ - -namespace FMatrixHelp { + /** + @addtogroup DenseMatVec + @{ + */ + + namespace FMatrixHelp { + + // defined in fmatrixev.cc + extern void eigenValuesLapackCall( + const char* jobz, const char* uplo, const long + int* n, double* a, const long int* lda, double* w, + double* work, const long int* lwork, long int* info); + + extern void eigenValuesNonsymLapackCall( + const char* jobvl, const char* jobvr, const long + int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, + const long int* ldvl, double* vr, const long int* ldvr, double* work, + const long int* lwork, const long int* info); + + /** \brief calculates the eigenvalues of a symmetric field matrix + \param[in] matrix matrix eigenvalues are calculated for + \param[out] eigenvalues FieldVector that contains eigenvalues in + ascending order + */ + template + static void eigenValues(const FieldMatrix& matrix, + FieldVector& eigenvalues) + { + eigenvalues[0] = matrix[0][0]; + } -// defined in fmatrixev.cc -extern void eigenValuesLapackCall( - const char* jobz, const char* uplo, const long - int* n, double* a, const long int* lda, double* w, - double* work, const long int* lwork, long int* info); - -/** \brief calculates the eigenvalues of a symetric field matrix - \param[in] matrix matrix eigenvalues are calculated for - \param[out] eigenvalues FieldVector that contains eigenvalues in - ascending order -*/ -template -static void eigenValues(const FieldMatrix& matrix, - FieldVector& eigenvalues) -{ - eigenvalues[0] = matrix[0][0]; -} - -/** \brief calculates the eigenvalues of a symetric field matrix - \param[in] matrix matrix eigenvalues are calculated for - \param[out] eigenvalues FieldVector that contains eigenvalues in - ascending order -*/ -template -static void eigenValues(const FieldMatrix& matrix, - FieldVector& eigenvalues) -{ - const K detM = matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]; - const K p = 0.5 * (matrix[0][0] + matrix [1][1]); - K q = p * p - detM; - if( q < 0 && q > -1e-14 ) q = 0; - if (p < 0 || q < 0) - { - std::cout << p << " p | q " << q << "\n"; - std::cout << matrix << std::endl; - std::cout << "something went wrong in Eigenvalues for matrix!" << std::endl; - assert(false); - abort(); - } - - // get square root - q = std :: sqrt(q); - - // store eigenvalues in ascending order - eigenvalues[0] = p - q; - eigenvalues[1] = p + q; -} - -/** \brief calculates the eigenvalues of a symetric field matrix - \param[in] matrix matrix eigenvalues are calculated for - \param[out] eigenvalues FieldVector that contains eigenvalues in - ascending order - - \note LAPACK::dsyev is used to calculate the eigen values -*/ -template -static void eigenValues(const FieldMatrix& matrix, - FieldVector& eigenvalues) -{ - { - const long int N = dim ; - const char jobz = 'n'; // only calculate eigenvalues - const char uplo = 'u'; // use upper triangular matrix - - // length of matrix vector - const long int w = N * N ; - - // matrix to put into dsyev - double matrixVector[dim * dim]; - - // copy matrix - int row = 0; - for(int i=0; i + static void eigenValues(const FieldMatrix& matrix, + FieldVector& eigenvalues) { - for(int j=0; j -1e-14 ) q = 0; + if (q < 0) { - matrixVector[ row ] = matrix[ i ][ j ]; + std::cout << matrix << std::endl; + // Complex eigenvalues are either caused by non-symmetric matrices or by round-off errors + DUNE_THROW(MathError, "Complex eigenvalue detected (which this implementation cannot handle)."); } - } - // working memory - double workSpace[dim * dim]; + // get square root + q = std :: sqrt(q); - // return value information - long int info = 0; + // store eigenvalues in ascending order + eigenvalues[0] = p - q; + eigenvalues[1] = p + q; + } + + /** \brief Calculates the eigenvalues of a symmetric 3x3 field matrix + \param[in] matrix matrix eigenvalues are calculated for + \param[out] eigenvalues Eigenvalues in ascending order + + \note If the input matrix is not symmetric the behavior of this method is undefined. + + This implementation was adapted from the pseudo-code (Python?) implementation found on + http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August 2014). + Wikipedia claims to have taken it from + Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix., + Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316 + */ + template + static void eigenValues(const FieldMatrix& matrix, + FieldVector& eigenvalues) + { + K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1][2]*matrix[1][2]; - // call LAPACK routine (see fmatrixev.cc) - eigenValuesLapackCall(&jobz, &uplo, &N, &matrixVector[0], &N, - &eigenvalues[0], &workSpace[0], &w, &info); + if (p1 <= 1e-8) + { + // A is diagonal. + eigenvalues[0] = matrix[0][0]; + eigenvalues[1] = matrix[1][1]; + eigenvalues[2] = matrix[2][2]; + } + else + { + // q = trace(A)/3 + K q = 0; + for (int i=0; i<3; i++) + q += matrix[i][i]/3.0; + + K p2 = (matrix[0][0] - q)*(matrix[0][0] - q) + (matrix[1][1] - q)*(matrix[1][1] - q) + (matrix[2][2] - q)*(matrix[2][2] - q) + 2 * p1; + K p = std::sqrt(p2 / 6); + // B = (1 / p) * (A - q * I); // I is the identity matrix + FieldMatrix B; + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + B[i][j] = (1/p) * (matrix[i][j] - q*(i==j)); + + K r = B.determinant() / 2.0; + + // In exact arithmetic for a symmetric matrix -1 <= r <= 1 + // but computation error can leave it slightly outside this range. + K phi; + if (r <= -1) + phi = M_PI / 3.0; + else if (r >= 1) + phi = 0; + else + phi = std::acos(r) / 3; + + // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0] + eigenvalues[2] = q + 2 * p * cos(phi); + eigenvalues[0] = q + 2 * p * cos(phi + (2*M_PI/3)); + eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace(matrix) = eig1 + eig2 + eig3 + } + } - if( info != 0 ) + /** \brief calculates the eigenvalues of a symmetric field matrix + \param[in] matrix matrix eigenvalues are calculated for + \param[out] eigenvalues FieldVector that contains eigenvalues in + ascending order + + \note LAPACK::dsyev is used to calculate the eigenvalues + */ + template + static void eigenValues(const FieldMatrix& matrix, + FieldVector& eigenvalues) + { + { + const long int N = dim ; + const char jobz = 'n'; // only calculate eigenvalues + const char uplo = 'u'; // use upper triangular matrix + + // length of matrix vector + const long int w = N * N ; + + // matrix to put into dsyev + double matrixVector[dim * dim]; + + // copy matrix + int row = 0; + for(int i=0; i + static void eigenValuesNonSym(const FieldMatrix& matrix, + FieldVector& eigenValues) { - std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl; - DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!"); + { + const long int N = dim ; + const char jobvl = 'n'; + const char jobvr = 'n'; + + // matrix to put into dgeev + double matrixVector[dim * dim]; + + // copy matrix + int row = 0; + for(int i=0; i #include #include +#include +#include -#include +#include #include #include #include #include -#include +#include namespace Dune { - -/** - @addtogroup DenseMatVec - @{ -*/ - -/*! \file - -\brief Implements a matrix constructed from a given type - representing a field and compile-time given number of rows and columns. -*/ + + /** + @addtogroup DenseMatVec + @{ + */ + + /*! \file + + \brief Implements a matrix constructed from a given type + representing a field and compile-time given number of rows and columns. + */ template< class K, int ROWS, int COLS > class FieldMatrix; @@ -42,11 +43,11 @@ typedef row_type &row_reference; typedef const row_type &const_row_reference; - typedef Dune::array container_type; + typedef std::array container_type; typedef K value_type; typedef typename container_type::size_type size_type; }; - + template< class K, int ROWS, int COLS > struct FieldTraits< FieldMatrix > { @@ -54,32 +55,32 @@ typedef typename FieldTraits::real_type real_type; }; - /** + /** @brief A dense n x m matrix. - Matrices represent linear maps from a vector space V to a vector space W. + Matrices represent linear maps from a vector space V to a vector space W. This class represents such a linear map by storing a two-dimensional %array of numbers of a given field type K. The number of rows and columns is given at compile time. - */ + */ template class FieldMatrix : public DenseMatrix< FieldMatrix > { - Dune::array< FieldVector, ROWS > _data; + std::array< FieldVector, ROWS > _data; typedef DenseMatrix< FieldMatrix > Base; public: //! export size enum { //! The number of rows. - rows = ROWS, + rows = ROWS, //! The number of columns. cols = COLS }; typedef typename Base::size_type size_type; typedef typename Base::row_type row_type; - + typedef typename Base::row_reference row_reference; typedef typename Base::const_row_reference const_row_reference; @@ -88,46 +89,40 @@ */ FieldMatrix () {} - /** \brief Constructor initializing the whole matrix with a scalar + /** \brief Constructor initializing the matrix from a list of vector */ - explicit FieldMatrix (const K& k) - { - for (size_type i=0; i > const &l) { + assert(l.size() == rows); // Actually, this is not needed any more! + std::copy_n(l.begin(), std::min(static_cast(ROWS), + l.size()), + _data.begin()); } - template - explicit FieldMatrix (const T& t) + template ::value>> + FieldMatrix(T const& rhs) { - DenseMatrixAssigner::exists>::assign(*this, t); + *this = rhs; } - - //===== assignment + using Base::operator=; - // To be removed! -#if 0 - //! Multiplies M from the left to this matrix - FieldMatrix& leftmultiply (const FieldMatrix& M) - { - FieldMatrix C(*this); - - for (size_type i=0; i + FieldMatrix& operator=(FieldMatrix const &rhs) + { + static_assert(rows == ROWS, "Size mismatch in matrix assignment (rows)"); + static_assert(cols == COLS, "Size mismatch in matrix assignment (columns)"); + _data = rhs._data; return *this; } -#endif - + //! Multiplies M from the left to this matrix, this matrix is not modified template FieldMatrix leftmultiplyany (const FieldMatrix& M) const { FieldMatrix C; - + for (size_type i=0; i& M) + template + FieldMatrix& rightmultiply (const FieldMatrix& M) { + static_assert(r == c, "Cannot rightmultiply with non-square matrix"); + static_assert(r == cols, "Size mismatch"); FieldMatrix C(*this); - + for (size_type i=0; i rightmultiplyany (const FieldMatrix& M) const { FieldMatrix C; - + for (size_type i=0; i > Base; public: // standard constructor and everything is sufficient ... - + //===== type definitions and constants - + //! The type used for index access and size operations typedef typename Base::size_type size_type; - + //! We are at the leaf of the block recursion enum { //! The number of block levels we contain. @@ -209,7 +209,7 @@ }; typedef typename Base::row_type row_type; - + typedef typename Base::row_reference row_reference; typedef typename Base::const_row_reference const_row_reference; @@ -227,19 +227,23 @@ /** \brief Default constructor */ FieldMatrix () {} - - /** \brief Constructor initializing the whole matrix with a scalar + + /** \brief Constructor initializing the matrix from a list of vector */ - FieldMatrix (const K& k) + FieldMatrix(std::initializer_list> const &l) { - _data[0] = k; + std::copy_n(l.begin(), std::min(static_cast< std::size_t >( 1 ), l.size()), &_data); } - template - FieldMatrix(const T& t) + + template ::value>> + FieldMatrix(T const& rhs) { - DenseMatrixAssigner::exists>::assign(*this, t); + *this = rhs; } - + + using Base::operator=; + //===== solve //! Multiplies M from the left to this matrix, this matrix is not modified @@ -264,25 +268,27 @@ FieldMatrix rightmultiplyany (const FieldMatrix& M) const { FieldMatrix C; - + for (size_type j=0; j -static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) -{ - inverse[0][0] = 1.0/matrix[0][0]; - return matrix[0][0]; -} - -//! invert scalar without changing the original matrix -template -static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) -{ - return invertMatrix(matrix,inverse); -} + //! invert scalar without changing the original matrix + template + static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) + { + inverse[0][0] = 1.0/matrix[0][0]; + return matrix[0][0]; + } + + //! invert scalar without changing the original matrix + template + static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) + { + return invertMatrix(matrix,inverse); + } + + + //! invert 2x2 Matrix without changing the original matrix + template + static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) + { + // code generated by maple + K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]); + K det_1 = 1.0/det; + inverse[0][0] = matrix[1][1] * det_1; + inverse[0][1] = - matrix[0][1] * det_1; + inverse[1][0] = - matrix[1][0] * det_1; + inverse[1][1] = matrix[0][0] * det_1; + return det; + } + + //! invert 2x2 Matrix without changing the original matrix + //! return transposed matrix + template + static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) + { + // code generated by maple + K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]); + K det_1 = 1.0/det; + inverse[0][0] = matrix[1][1] * det_1; + inverse[1][0] = - matrix[0][1] * det_1; + inverse[0][1] = - matrix[1][0] * det_1; + inverse[1][1] = matrix[0][0] * det_1; + return det; + } + + //! invert 3x3 Matrix without changing the original matrix + template + static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) + { + // code generated by maple + K t4 = matrix[0][0] * matrix[1][1]; + K t6 = matrix[0][0] * matrix[1][2]; + K t8 = matrix[0][1] * matrix[1][0]; + K t10 = matrix[0][2] * matrix[1][0]; + K t12 = matrix[0][1] * matrix[2][0]; + K t14 = matrix[0][2] * matrix[2][0]; + + K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+ + t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]); + K t17 = 1.0/det; + + inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17; + inverse[0][1] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17; + inverse[0][2] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17; + inverse[1][0] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17; + inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17; + inverse[1][2] = -(t6-t10) * t17; + inverse[2][0] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17; + inverse[2][1] = -(matrix[0][0] * matrix[2][1] - t12) * t17; + inverse[2][2] = (t4-t8) * t17; + + return det; + } + + //! invert 3x3 Matrix without changing the original matrix + template + static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) + { + // code generated by maple + K t4 = matrix[0][0] * matrix[1][1]; + K t6 = matrix[0][0] * matrix[1][2]; + K t8 = matrix[0][1] * matrix[1][0]; + K t10 = matrix[0][2] * matrix[1][0]; + K t12 = matrix[0][1] * matrix[2][0]; + K t14 = matrix[0][2] * matrix[2][0]; + + K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+ + t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]); + K t17 = 1.0/det; + + inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17; + inverse[1][0] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17; + inverse[2][0] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17; + inverse[0][1] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17; + inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17; + inverse[2][1] = -(t6-t10) * t17; + inverse[0][2] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17; + inverse[1][2] = -(matrix[0][0] * matrix[2][1] - t12) * t17; + inverse[2][2] = (t4-t8) * t17; + + return det; + } + + //! calculates ret = A * B + template< class K, int m, int n, int p > + static inline void multMatrix ( const FieldMatrix< K, m, n > &A, + const FieldMatrix< K, n, p > &B, + FieldMatrix< K, m, p > &ret ) + { + typedef typename FieldMatrix< K, m, p > :: size_type size_type; + + for( size_type i = 0; i < m; ++i ) + { + for( size_type j = 0; j < p; ++j ) + { + ret[ i ][ j ] = K( 0 ); + for( size_type k = 0; k < n; ++k ) + ret[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ]; + } + } + } + //! calculates ret= A_t*A + template + static inline void multTransposedMatrix(const FieldMatrix &matrix, FieldMatrix& ret) + { + typedef typename FieldMatrix::size_type size_type; + + for(size_type i=0; i -static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) -{ - // code generated by maple - K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]); - K det_1 = 1.0/det; - inverse[0][0] = matrix[1][1] * det_1; - inverse[0][1] = - matrix[0][1] * det_1; - inverse[1][0] = - matrix[1][0] * det_1; - inverse[1][1] = matrix[0][0] * det_1; - return det; -} - -//! invert 2x2 Matrix without changing the original matrix -//! return transposed matrix -template -static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) -{ - // code generated by maple - K det = (matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]); - K det_1 = 1.0/det; - inverse[0][0] = matrix[1][1] * det_1; - inverse[1][0] = - matrix[0][1] * det_1; - inverse[0][1] = - matrix[1][0] * det_1; - inverse[1][1] = matrix[0][0] * det_1; - return det; -} - -//! invert 3x3 Matrix without changing the original matrix -template -static inline K invertMatrix (const FieldMatrix &matrix, FieldMatrix &inverse) -{ - // code generated by maple - K t4 = matrix[0][0] * matrix[1][1]; - K t6 = matrix[0][0] * matrix[1][2]; - K t8 = matrix[0][1] * matrix[1][0]; - K t10 = matrix[0][2] * matrix[1][0]; - K t12 = matrix[0][1] * matrix[2][0]; - K t14 = matrix[0][2] * matrix[2][0]; - - K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+ - t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]); - K t17 = 1.0/det; - - inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17; - inverse[0][1] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17; - inverse[0][2] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17; - inverse[1][0] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17; - inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17; - inverse[1][2] = -(t6-t10) * t17; - inverse[2][0] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17; - inverse[2][1] = -(matrix[0][0] * matrix[2][1] - t12) * t17; - inverse[2][2] = (t4-t8) * t17; - - return det; -} - -//! invert 3x3 Matrix without changing the original matrix -template -static inline K invertMatrix_retTransposed (const FieldMatrix &matrix, FieldMatrix &inverse) -{ - // code generated by maple - K t4 = matrix[0][0] * matrix[1][1]; - K t6 = matrix[0][0] * matrix[1][2]; - K t8 = matrix[0][1] * matrix[1][0]; - K t10 = matrix[0][2] * matrix[1][0]; - K t12 = matrix[0][1] * matrix[2][0]; - K t14 = matrix[0][2] * matrix[2][0]; - - K det = (t4*matrix[2][2]-t6*matrix[2][1]-t8*matrix[2][2]+ - t10*matrix[2][1]+t12*matrix[1][2]-t14*matrix[1][1]); - K t17 = 1.0/det; - - inverse[0][0] = (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])*t17; - inverse[1][0] = -(matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1])*t17; - inverse[2][0] = (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])*t17; - inverse[0][1] = -(matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0])*t17; - inverse[1][1] = (matrix[0][0] * matrix[2][2] - t14) * t17; - inverse[2][1] = -(t6-t10) * t17; - inverse[0][2] = (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * t17; - inverse[1][2] = -(matrix[0][0] * matrix[2][1] - t12) * t17; - inverse[2][2] = (t4-t8) * t17; - - return det; -} - -//! calculates ret = A * B -template< class K, int m, int n, int p > -static inline void multMatrix ( const FieldMatrix< K, m, n > &A, - const FieldMatrix< K, n, p > &B, - FieldMatrix< K, m, p > &ret ) -{ - typedef typename FieldMatrix< K, m, p > :: size_type size_type; + using Dune::DenseMatrixHelp::multAssign; - for( size_type i = 0; i < m; ++i ) - { - for( size_type j = 0; j < p; ++j ) - { - ret[ i ][ j ] = K( 0 ); - for( size_type k = 0; k < n; ++k ) - ret[ i ][ j ] += A[ i ][ k ] * B[ k ][ j ]; + //! calculates ret = matrix^T * x + template + static inline void multAssignTransposed( const FieldMatrix &matrix, const FieldVector & x, FieldVector & ret) + { + typedef typename FieldMatrix::size_type size_type; + + for(size_type i=0; i -static inline void multTransposedMatrix(const FieldMatrix &matrix, FieldMatrix& ret) -{ - typedef typename FieldMatrix::size_type size_type; - - for(size_type i=0; i -static inline void multAssign(const FieldMatrix &matrix, const FieldVector & x, FieldVector & ret) -{ - typedef typename FieldMatrix::size_type size_type; - - for(size_type i=0; i + static inline FieldVector mult(const FieldMatrix &matrix, const FieldVector & x) { - ret[i] += matrix[i][j]*x[j]; + FieldVector ret; + multAssign(matrix,x,ret); + return ret; } - } -} -#else -using Dune::DenseMatrixHelp::multAssign; -#endif - -//! calculates ret = matrix^T * x -template -static inline void multAssignTransposed( const FieldMatrix &matrix, const FieldVector & x, FieldVector & ret) -{ - typedef typename FieldMatrix::size_type size_type; - - for(size_type i=0; i -static inline FieldVector mult(const FieldMatrix &matrix, const FieldVector & x) -{ - FieldVector ret; - multAssign(matrix,x,ret); - return ret; -} - -//! calculates ret = matrix^T * x -template -static inline FieldVector multTransposed(const FieldMatrix &matrix, const FieldVector & x) -{ - FieldVector ret; - multAssignTransposed( matrix, x, ret ); - return ret; -} + //! calculates ret = matrix^T * x + template + static inline FieldVector multTransposed(const FieldMatrix &matrix, const FieldVector & x) + { + FieldVector ret; + multAssignTransposed( matrix, x, ret ); + return ret; + } -} // end namespace FMatrixHelp + } // end namespace FMatrixHelp -/** @} end documentation */ + /** @} end documentation */ } // end namespace diff -Nru dune-common-2.2.1/dune/common/forloop.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/forloop.hh --- dune-common-2.2.1/dune/common/forloop.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/forloop.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,227 +1,78 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_FORLOOP_HH #define DUNE_COMMON_FORLOOP_HH +#include + +#include +#include + /** \file * \brief A static for loop for template meta-programming */ -#include - namespace Dune { - // GenericForLoop - // -------------- - - template< template< class, class > class Operation, template< int > class Value, int first, int last > - class GenericForLoop - : public Operation< Value< first >, GenericForLoop< Operation, Value, first+1, last > > - { - dune_static_assert( (first <= last), "GenericForLoop: first > last" ); - }; - - template< template< class, class > class Operation, template< int > class Value, int last > - class GenericForLoop< Operation, Value, last, last > - : public Value< last > - {}; - - - - // ForLoopHelper - // ------------- - - namespace ForLoopHelper - { - - template< class A, class B > - struct Apply - { - static void apply () - { - A::apply(); - B::apply(); - } - - template< class T1 > - static void apply ( T1 &p1 ) - { - A::apply( p1 ); - B::apply( p1 ); - } - - template< class T1, class T2 > - static void apply ( T1 &p1, T2 &p2 ) - { - A::apply( p1, p2 ); - B::apply( p1, p2 ); - } - - template< class T1, class T2, class T3 > - static void apply ( T1 &p1, T2 &p2, T3 &p3 ) - { - A::apply( p1, p2, p3 ); - B::apply( p1, p2, p3 ); - } - - template< class T1, class T2, class T3, class T4 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4 ) - { - A::apply( p1, p2, p3, p4 ); - B::apply( p1, p2, p3, p4 ); - } - - template< class T1, class T2, class T3, class T4, class T5 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5 ) - { - A::apply( p1, p2, p3, p4, p5 ); - B::apply( p1, p2, p3, p4, p5 ); - } - - template< class T1, class T2, class T3, class T4, class T5, class T6 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6 ) - { - A::apply( p1, p2, p3, p4, p5, p6 ); - B::apply( p1, p2, p3, p4, p5, p6 ); - } - - template< class T1, class T2, class T3, class T4, class T5, class T6, - class T7 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, - T7 &p7 ) - { - A::apply( p1, p2, p3, p4, p5, p6, p7 ); - B::apply( p1, p2, p3, p4, p5, p6, p7 ); - } - - template< class T1, class T2, class T3, class T4, class T5, class T6, - class T7, class T8 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, - T7 &p7, T8 &p8 ) - { - A::apply( p1, p2, p3, p4, p5, p6, p7, p8 ); - B::apply( p1, p2, p3, p4, p5, p6, p7, p8 ); - } - - template< class T1, class T2, class T3, class T4, class T5, class T6, - class T7, class T8, class T9 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, - T7 &p7, T8 &p8, T9 &p9 ) - { - A::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9 ); - B::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9 ); - } - - template< class T1, class T2, class T3, class T4, class T5, class T6, - class T7, class T8, class T9, class T10 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, - T7 &p7, T8 &p8, T9 &p9, T10 &p10 ) - { - A::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 ); - B::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 ); - } - - template< class T1, class T2, class T3, class T4, class T5, class T6, - class T7, class T8, class T9, class T10, class T11 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, - T7 &p7, T8 &p8, T9 &p9, T10 &p10, T11 &p11 ) - { - A::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 ); - B::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 ); - } - - template< class T1, class T2, class T3, class T4, class T5, class T6, - class T7, class T8, class T9, class T10, class T11, class T12 > - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, - T7 &p7, T8 &p8, T9 &p9, T10 &p10, T11 &p11, - T12 &p12 ) - { - A::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12 ); - B::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12 ); - } - - template< class T1, class T2, class T3, class T4, class T5, class T6, - class T7, class T8, class T9, class T10, class T11, class T12, - class T13> - static void apply ( T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5, T6 &p6, - T7 &p7, T8 &p8, T9 &p9, T10 &p10, T11 &p11, - T12 &p12, T13 &p13 ) - { - A::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 ); - B::apply( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 ); - } - }; - - } - - - /** \class ForLoop * @brief A static loop using TMP * - * The ForLoop takes a + * The ForLoop takes a * \code template class Operation \endcode * template argument with a static apply method * which is called for i=first...last (first<=last are int template arguments). * A specialization for class template class Operation for i=first * or i=last is not required. The class Operation must provide a - * static void function apply(...). Arguments (as references) - * can be passed through the ForLoop to this function - * (up to 5 at the moment). + * static void function apply(...). Arguments are perfectly forwarded + * through the ForLoop to this function. * - * It is possible to pass a subclass to the ForLoop + * It is possible to pass a subclass to the ForLoop * (since no specialization is needed). * * Example of usage: * \code -template -struct PrintTupleTypes -{ - template - struct Operation - { - template - static void apply(Stream &stream, const std::string &prefix) - { - stream << prefix << i << ": " - << className::type>() - << std::endl; - } - }; - template - static void print(Stream &stream, const std::string &prefix) - { - // cannot attach on-the-fly in the argument to ForLoop<..>::apply() since - // that would yield an rvalue - std::string extended_prefix = prefix+" "; - - stream << prefix << "tuple<" << std::endl; - ForLoop::value-1>:: - apply(stream, extended_prefix); - stream << prefix << ">" << std::endl; - } -}; + * template + * struct PrintTupleTypes + * { + * template + * struct Operation + * { + * template + * static void apply(Stream &stream, const std::string &prefix) + * { + * stream << prefix << i << ": " + * << className::type>() + * << std::endl; + * } + * }; + * template + * static void print(Stream &stream, const std::string &prefix) + * { + * // cannot attach on-the-fly in the argument to ForLoop<..>::apply() since + * // that would yield an rvalue + * std::string extended_prefix = prefix+" "; + * + * stream << prefix << "tuple<" << std::endl; + * ForLoop::value-1>:: + * apply(stream, extended_prefix); + * stream << prefix << ">" << std::endl; + * } + * }; * \endcode - * - * \note Don't use any rvalues as the arguments to apply(). - * - * Rvalues will bind to const-references, but not to references that are - * non-const. Since we do want to support modifiable arguments to apply(), - * we have to use non-const references as arguments. Supporting const - * references as well would lead to an insane number of overloads which all - * have to be written more-or-less by hand. - * - * Examples of rvalues are: literals (1.0, 0, "huhu"), the results of - * functions returning an object (std::make_pair(0, 1.0)) and temporary - * object constructions (std::string("hello")); */ template< template< int > class Operation, int first, int last > - class ForLoop - : public GenericForLoop< ForLoopHelper::Apply, Operation, first, last > + struct ForLoop { - dune_static_assert( (first <= last), "ForLoop: first > last" ); + static_assert( (first <= last), "ForLoop: first > last" ); + + template + static void apply(Args&&... args) + { + Hybrid::forEach(Std::make_index_sequence{}, + [&](auto i){Operation::apply(args...);}); + } }; } diff -Nru dune-common-2.2.1/dune/common/ftraits.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/ftraits.hh --- dune-common-2.2.1/dune/common/ftraits.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/ftraits.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,4 +1,5 @@ -// $Id: fvector.hh 5262 2008-09-07 09:03:38Z christi $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_FTRAITS_HH #define DUNE_FTRAITS_HH @@ -7,38 +8,53 @@ */ #include +#include namespace Dune { -/** - @addtogroup DenseMatVec - \brief Type traits to retrieve the field and the real type of classes - - Type traits to retrieve the field and the real type of classes - e.g. that of FieldVector or FieldMatrix -*/ -template -struct FieldTraits -{ - //! export the type representing the field - typedef T field_type; - //! export the type representing the real type of the field - typedef T real_type; -}; - -template -struct FieldTraits -{ + /** + @addtogroup DenseMatVec + \brief Type traits to retrieve the field and the real type of classes + + Type traits to retrieve the field and the real type of classes + e.g. that of FieldVector or FieldMatrix + */ + template + struct FieldTraits + { + //! export the type representing the field + typedef T field_type; + //! export the type representing the real type of the field + typedef T real_type; + }; + + template + struct FieldTraits + { typedef typename FieldTraits::field_type field_type; typedef typename FieldTraits::real_type real_type; -}; + }; -template -struct FieldTraits< std::complex > -{ + template + struct FieldTraits< std::complex > + { typedef std::complex field_type; typedef T real_type; -}; + }; + + template + struct FieldTraits< T[N] > + { + typedef typename FieldTraits::field_type field_type; + typedef typename FieldTraits::real_type real_type; + }; + + template + struct FieldTraits< std::vector > + { + typedef typename FieldTraits::field_type field_type; + typedef typename FieldTraits::real_type real_type; + }; } // end namespace Dune diff -Nru dune-common-2.2.1/dune/common/function.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/function.hh --- dune-common-2.2.1/dune/common/function.hh 2010-01-23 15:07:19.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/function.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_FUNCTION_HH #define DUNE_FUNCTION_HH @@ -8,13 +8,13 @@ namespace Dune { -/** @addtogroup Common - @{ -*/ - -/*! \file - \brief Simple base class templates for functions. -*/ + /** @addtogroup Common + @{ + */ + + /*! \file + \brief Simple base class templates for functions. + */ /** * \brief Base class template for function classes @@ -26,31 +26,31 @@ template class Function { - typedef typename ConstantVolatileTraits::ReferredType >::UnqualifiedType RawDomainType; - typedef typename ConstantVolatileTraits::ReferredType >::UnqualifiedType RawRangeType; + typedef typename std::remove_cv::type >::type RawDomainType; + typedef typename std::remove_cv::type >::type RawRangeType; - public: + public: - //! Raw type of input variable with removed reference and constness - typedef RawRangeType RangeType; + //! Raw type of input variable with removed reference and constness + typedef RawRangeType RangeType; - //! Raw type of output variable with removed reference and constness + //! Raw type of output variable with removed reference and constness + typedef RawDomainType DomainType; + + //! Traits class containing raw types + struct Traits + { typedef RawDomainType DomainType; + typedef RawRangeType RangeType; + }; - //! Traits class containing raw types - struct Traits - { - typedef RawDomainType DomainType; - typedef RawRangeType RangeType; - }; - - /** - * \brief Function evaluation. - * - * \param x Argument for function evaluation. - * \param y Result of function evaluation. - */ - void evaluate(Domain x, Range y) const; + /** + * \brief Function evaluation. + * + * \param x Argument for function evaluation. + * \param y Result of function evaluation. + */ + void evaluate(const typename Traits::DomainType& x, typename Traits::RangeType& y) const; }; // end of Function class @@ -64,20 +64,22 @@ */ template class VirtualFunction : - public Function + public Function { - public: + public: + typedef typename Function::Traits Traits; + virtual ~VirtualFunction() {} - /** - * \brief Function evaluation. - * - * \param x Argument for function evaluation. - * \param y Result of function evaluation. - */ - virtual void evaluate(const DomainType& x, RangeType& y) const = 0; + /** + * \brief Function evaluation. + * + * \param x Argument for function evaluation. + * \param y Result of function evaluation. + */ + virtual void evaluate(const typename Traits::DomainType& x, typename Traits::RangeType& y) const = 0; }; // end of VirtualFunction class -/** @} end documentation */ + /** @} end documentation */ } // end namespace diff -Nru dune-common-2.2.1/dune/common/fvector.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/fvector.hh --- dune-common-2.2.1/dune/common/fvector.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/fvector.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,51 +1,47 @@ // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: -// $Id: fvector.hh 6785 2012-05-31 22:07:47Z sander $ #ifndef DUNE_FVECTOR_HH #define DUNE_FVECTOR_HH -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "typetraits.hh" #include "exceptions.hh" -#include "array.hh" -#include "densevector.hh" -#include "static_assert.hh" - -#if ! DUNE_COMMON_FIELDVECTOR_SIZE_IS_METHOD -#warning The FieldVector class exports its size by the enum member 'size'. \ - This behavior is deprecated. In the future, 'size' will be a method, \ - which puts it in compliance with the stl conventions. To enable the new behavior \ - (and get rid of this warning), build your Dune with --enable-fieldvector-size-is-method. \ - If you do need the vector size as an enum, use 'dimension'. -#endif +#include "ftraits.hh" +#include "densevector.hh" +#include "unused.hh" +#include "boundschecking.hh" namespace Dune { -/** @addtogroup DenseMatVec - @{ -*/ - -/*! \file - * \brief Implements a vector constructed from a given type -representing a field and a compile-time given size. -*/ + /** @addtogroup DenseMatVec + @{ + */ + + /*! \file + * \brief Implements a vector constructed from a given type + representing a field and a compile-time given size. + */ template< class K, int SIZE > class FieldVector; template< class K, int SIZE > struct DenseMatVecTraits< FieldVector > { typedef FieldVector derived_type; - typedef Dune::array container_type; + typedef std::array container_type; typedef K value_type; typedef typename container_type::size_type size_type; }; - + template< class K, int SIZE > struct FieldTraits< FieldVector > { @@ -56,7 +52,7 @@ /** * @brief TMP to check the size of a DenseVectors statically, if possible. * - * If the implementation type of C is a FieldVector, we statically check + * If the implementation type of C is a FieldVector, we statically check * whether its dimension is SIZE. * @tparam C The implementation of the other DenseVector * @tparam SIZE The size we need assume. @@ -64,27 +60,28 @@ template struct IsFieldVectorSizeCorrect { - enum{ + enum { /** - *@param True if C is not of type FieldVector or its dimension + *@param True if C is not of type FieldVector or its dimension * is not equal SIZE. */ - value = true}; + value = true + }; }; - + template struct IsFieldVectorSizeCorrect,SIZE> { - enum{value = true}; + enum {value = true}; }; - + template struct IsFieldVectorSizeCorrect,SIZE> { - enum{value = false}; + enum {value = false}; }; - - + + /** \brief vector space out of a tensor product of fields. * * \tparam K the field type (use float, double, complex, etc) @@ -94,37 +91,49 @@ class FieldVector : public DenseVector< FieldVector > { - Dune::array _data; + std::array _data; typedef DenseVector< FieldVector > Base; public: - //! export size - enum { - //! The size of this vector. + //! export size + enum { + //! The size of this vector. dimension = SIZE -#if ! DUNE_COMMON_FIELDVECTOR_SIZE_IS_METHOD - , - //! The size of this vector. - size = SIZE -#endif - }; + }; typedef typename Base::size_type size_type; typedef typename Base::value_type value_type; - //! Constructor making uninitialized vector - FieldVector() {} + /** \brief The type used for references to the vector entry */ + typedef value_type& reference; + + /** \brief The type used for const references to the vector entry */ + typedef const value_type& const_reference; + + //! Constructor making default-initialized vector + constexpr FieldVector() + : _data{{}} + {} + + //! Constructor making vector with identical coordinates + explicit FieldVector (const K& t) + { + std::fill(_data.begin(),_data.end(),t); + } + + //! Copy constructor + FieldVector (const FieldVector & x) : Base(), _data(x._data) + {} - //! Constructor making vector with identical coordinates - explicit FieldVector (const K& t) - { - fill(t); - } - - //! Constructor making vector with identical coordinates - FieldVector (const FieldVector & x) : _data(x._data) - {} + /** \brief Construct from a std::initializer_list */ + FieldVector (std::initializer_list const &l) + { + assert(l.size() == dimension);// Actually, this is not needed any more! + std::copy_n(l.begin(), std::min(static_cast(dimension), + l.size()), + _data.begin()); + } - /** + /** * \brief Copy constructor from a second vector of possibly different type * * If the DenseVector type of the this constructor's argument @@ -136,32 +145,34 @@ * \param[in] dummy A void* dummy argument needed by SFINAE. */ template - FieldVector (const DenseVector & x, typename Dune::enable_if::value>::type* dummy=0 ) - { + FieldVector (const DenseVector & x, typename std::enable_if::value>::type* dummy=0 ) + { + DUNE_UNUSED_PARAMETER(dummy); // do a run-time size check, for the case that x is not a FieldVector - assert(x.size() == SIZE); - for (size_type i = 0; i(SIZE),x.size()), _data.begin()); } //! Constructor making vector with identical coordinates template - explicit FieldVector (const FieldVector & x) - { - dune_static_assert(SIZE1 == SIZE, "FieldVector in constructor has wrong size"); + explicit FieldVector (const FieldVector & x) + { + static_assert(SIZE1 == SIZE, "FieldVector in constructor has wrong size"); for (size_type i = 0; i inline std::istream &operator>> ( std::istream &in, - FieldVector &v ) + FieldVector &v ) { FieldVector w; for( typename FieldVector::size_type i = 0; i < SIZE; ++i ) @@ -207,98 +218,158 @@ K _data; typedef DenseVector< FieldVector > Base; public: - //! export size - enum { - //! The size of this vector. + //! export size + enum { + //! The size of this vector. dimension = 1 -#if ! DUNE_COMMON_FIELDVECTOR_SIZE_IS_METHOD - , - //! The size of this vector. - size = 1 -#endif - }; + }; typedef typename Base::size_type size_type; - - //===== construction + + /** \brief The type used for references to the vector entry */ + typedef K& reference; + + /** \brief The type used for const references to the vector entry */ + typedef const K& const_reference; + + //===== construction /** \brief Default constructor */ - FieldVector () {} + constexpr FieldVector () + : _data() + {} /** \brief Constructor with a given scalar */ - FieldVector (const K& k) : _data(k) {} + template::value && + ! std::is_same::field_type> + >::value + >::type + > + FieldVector (const T& k) : _data(k) {} - //! Constructor making vector with identical coordinates + //! Constructor from static vector of different type template - FieldVector (const DenseVector & x) - { - dune_static_assert(((bool)IsFieldVectorSizeCorrect::value), "FieldVectors do not match in dimension!"); + FieldVector (const DenseVector & x) + { + static_assert(((bool)IsFieldVectorSizeCorrect::value), "FieldVectors do not match in dimension!"); assert(x.size() == 1); _data = x[0]; } + //! copy constructor + FieldVector ( const FieldVector &other ) + : Base(), _data( other._data ) + {} + + /** \brief Construct from a std::initializer_list */ + FieldVector (std::initializer_list const &l) + { + assert(l.size() == 1); + _data = *l.begin(); + } + //! Assignment operator for scalar - inline FieldVector& operator= (const K& k) + template::value && + ! std::is_same::field_type> + >::value + >::type + > + inline FieldVector& operator= (const T& k) { _data = k; return *this; } - + //===== forward methods to container - size_type vec_size() const { return 1; } - K & vec_access(size_type i) + static constexpr size_type size () { return 1; } + + K & operator[](size_type i) { - assert(i == 0); + DUNE_UNUSED_PARAMETER(i); + DUNE_ASSERT_BOUNDS(i == 0); return _data; } - const K & vec_access(size_type i) const + const K & operator[](size_type i) const { - assert(i == 0); + DUNE_UNUSED_PARAMETER(i); + DUNE_ASSERT_BOUNDS(i == 0); return _data; } - - //===== conversion operator + + //===== conversion operator /** \brief Conversion operator */ - operator K () { return _data; } + operator K& () { return _data; } /** \brief Const conversion operator */ - operator K () const { return _data; } + operator const K& () const { return _data; } }; /* ----- FV / FV ----- */ - /* not necessary as these operations are already covered via the cast operator */ + /* mostly not necessary as these operations are already covered via the cast operator */ + + //! Binary compare, when using FieldVector like K + template + inline bool operator> (const FieldVector& a, const FieldVector& b) + { + return a[0]>b[0]; + } + + //! Binary compare, when using FieldVector like K + template + inline bool operator>= (const FieldVector& a, const FieldVector& b) + { + return a[0]>=b[0]; + } + + //! Binary compare, when using FieldVector like K + template + inline bool operator< (const FieldVector& a, const FieldVector& b) + { + return a[0] like K + template + inline bool operator<= (const FieldVector& a, const FieldVector& b) + { + return a[0]<=b[0]; + } /* ----- FV / scalar ----- */ - + //! Binary addition, when using FieldVector like K template inline FieldVector operator+ (const FieldVector& a, const K b) { return a[0]+b; } - + //! Binary subtraction, when using FieldVector like K template inline FieldVector operator- (const FieldVector& a, const K b) { return a[0]-b; } - + //! Binary multiplication, when using FieldVector like K template inline FieldVector operator* (const FieldVector& a, const K b) { return a[0]*b; } - + //! Binary division, when using FieldVector like K template inline FieldVector operator/ (const FieldVector& a, const K b) { return a[0]/b; } - + //! Binary compare, when using FieldVector like K template inline bool operator> (const FieldVector& a, const K b) @@ -342,14 +413,14 @@ } /* ----- scalar / FV ------ */ - + //! Binary addition, when using FieldVector like K template inline FieldVector operator+ (const K a, const FieldVector& b) { return a+b[0]; } - + //! Binary subtraction, when using FieldVector like K template inline FieldVector operator- (const K a, const FieldVector& b) @@ -363,7 +434,7 @@ { return a*b[0]; } - + //! Binary division, when using FieldVector like K template inline FieldVector operator/ (const K a, const FieldVector& b) diff -Nru dune-common-2.2.1/dune/common/gcd.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/gcd.hh --- dune-common-2.2.1/dune/common/gcd.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/gcd.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,11 +1,12 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_GCD_HH #define DUNE_GCD_HH -#include"static_assert.hh" namespace Dune { - /** - * @addtogroup Common + /** + * @addtogroup Common * @{ */ /** @@ -20,8 +21,8 @@ template struct GcdHelper {}; - - + + template struct GcdHelper { @@ -30,17 +31,17 @@ */ static void conceptCheck() { - dune_static_assert(b::gcd; + const static long gcd = GcdHelper::gcd; }; - + template struct GcdHelper { @@ -54,9 +55,9 @@ { const static long gcd=a; }; - + #endif - + /** * @brief Calculator of the greatest common divisor. */ @@ -67,7 +68,7 @@ * @brief The greatest common divisior of a and b. */ const static long value = GcdHelperb)>::gcd; }; - + /** * @} */ diff -Nru dune-common-2.2.1/dune/common/genericiterator.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/genericiterator.hh --- dune-common-2.2.1/dune/common/genericiterator.hh 2013-02-26 12:26:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/genericiterator.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,4 +1,5 @@ -// $Id: genericiterator.hh 7391 2013-02-26 12:26:33Z mblatt $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_GENERICITERATOR_HH #define DUNE_GENERICITERATOR_HH @@ -8,24 +9,24 @@ namespace Dune { /*! \defgroup GenericIterator GenericIterator - \ingroup IteratorFacades + \ingroup IteratorFacades - \brief Generic Iterator class for writing stl conformant iterators - for any container class with operator[] - - Using this template class you can create an iterator and a const_iterator - for any container class. - - Imagine you have SimpleContainer and would like to have an iterator. - All you have to do is provide operator[], begin() and end() - (for const and for non-const). - - \code - template - class SimpleContainer{ - public: + \brief Generic Iterator class for writing stl conformant iterators + for any container class with operator[] + + Using this template class you can create an iterator and a const_iterator + for any container class. + + Imagine you have SimpleContainer and would like to have an iterator. + All you have to do is provide operator[], begin() and end() + (for const and for non-const). + + \code + template + class SimpleContainer{ + public: typedef GenericIterator,T> iterator; - + typedef GenericIterator,const T> const_iterator; SimpleContainer(){ @@ -37,7 +38,7 @@ return iterator(*this, 0); } - const_iterator begin() const{ + const_iterator begin() const{ return const_iterator(*this, 0); } @@ -45,34 +46,34 @@ return iterator(*this, 100); } - const_iterator end() const{ + const_iterator end() const{ return const_iterator(*this, 100); } - + T& operator[](int i){ return values_[i]; } - + const T& operator[](int i) const{ return values_[i]; } - private: + private: T values_[100]; - }; - \endcode + }; + \endcode - See dune/common/test/iteratorfacestest.hh for details or - Dune::QuadratureDefault in dune/quadrature/quadrature.hh - for a real example. - */ - -/** - * @file - * @brief Implements a generic iterator class for writing stl conformant iterators. - * - * Using this generic iterator writing iterators for containers - * that implement operator[] is only a matter of seconds. - */ + See dune/common/test/iteratorfacestest.hh for details or + Dune::QuadratureDefault in dune/quadrature/quadrature.hh + for a real example. + */ + + /** + * @file + * @brief Implements a generic iterator class for writing stl conformant iterators. + * + * Using this generic iterator writing iterators for containers + * that implement operator[] is only a matter of seconds. + */ /** \brief Get the 'const' version of a reference to a mutable object @@ -84,25 +85,25 @@ { typedef const R type; }; - + template struct const_reference { typedef const R type; }; - + template struct const_reference { typedef const R& type; }; - + template struct const_reference { typedef const R& type; }; - + /** \brief get the 'mutable' version of a reference to a const object @@ -113,25 +114,25 @@ { typedef R type; }; - + template struct mutable_reference { typedef R type; }; - + template struct mutable_reference { typedef R& type; }; - + template struct mutable_reference { typedef R& type; }; - + /** @addtogroup GenericIterator * * @{ @@ -140,138 +141,138 @@ /** * @brief Generic class for stl-conforming iterators for container classes with operator[]. * - * If template parameter C has a const qualifier we are a const iterator, otherwise we + * If template parameter C has a const qualifier we are a const iterator, otherwise we * are a mutable iterator. */ template class IteratorFacade=RandomAccessIteratorFacade> -class GenericIterator : + template class IteratorFacade=RandomAccessIteratorFacade> + class GenericIterator : public IteratorFacade,T,R,D> -{ - friend class GenericIterator::type, typename remove_const::type, typename mutable_reference::type, D, IteratorFacade>; - friend class GenericIterator::type, const typename remove_const::type, typename const_reference::type, D, IteratorFacade>; - - typedef GenericIterator::type, typename remove_const::type, typename mutable_reference::type, D, IteratorFacade> MutableIterator; - typedef GenericIterator::type, const typename remove_const::type, typename const_reference::type, D, IteratorFacade> ConstIterator; - -public: - - /** - * @brief The type of container we are an iterator for. - * - * The container type must provide an operator[] method. - * - * If C has a const qualifier we are a const iterator, otherwise we - * are a mutable iterator. - */ - typedef C Container; - - /** - * @brief The value type of the iterator. - * - * This is the return type when dereferencing the iterator. - */ - typedef T Value; - - /** - * @brief The type of the difference between two positions. - */ - typedef D DifferenceType; - - /** - * @brief The type of the reference to the values accessed. - */ - typedef R Reference; - - // Constructors needed by the base iterators - GenericIterator(): container_(0), position_(0) - {} - - /** - * @brief Constructor - * @param cont Reference to the container we are an iterator for - * @param pos The postion the iterator will be positioned to - * (e.g. 0 for an iterator returned by Container::begin() or - * the sizeof the container for an iterator returned by Container::end() - */ - GenericIterator(Container& cont, DifferenceType pos) - : container_(&cont), position_(pos) - {} - - /** - * @brief Copy constructor - * - * This is somehow hard to understand, therefore play with the cases: - * 1. if we are mutable this is the only valid copy constructor, as the argument is a mutable iterator - * 2. if we are a const iterator the argument is a mutable iterator => This is the needed conversion to initialize a const iterator from a mutable one. - */ - GenericIterator(const MutableIterator& other): container_(other.container_), position_(other.position_) - {} - - /** - * @brief Copy constructor - * - * @warning Calling this method results in a compiler error, if this is a mutable iterator. - * - * This is somehow hard to understand, therefore play with the cases: - * 1. if we are mutable the arguments is a const iterator and therefore calling this method is mistake in the user's code and results in a (probably not understandable) compiler error - * 2. If we are a const iterator this is the default copy constructor as the argument is a const iterator too. - */ - GenericIterator(const ConstIterator& other): container_(other.container_), position_(other.position_) - {} - - // Methods needed by the forward iterator - bool equals(const MutableIterator & other) const { - return position_ == other.position_ && container_ == other.container_; - } - - bool equals(const ConstIterator & other) const - { - return position_ == other.position_ && container_ == other.container_; - } - - Reference dereference() const{ - return container_->operator[](position_); - } - - void increment(){ - ++position_; - } - - // Additional function needed by BidirectionalIterator - void decrement(){ - --position_; - } - - // Additional function needed by RandomAccessIterator - Reference elementAt(DifferenceType i)const{ - return container_->operator[](position_+i); - } - - void advance(DifferenceType n){ - position_=position_+n; - } + friend class GenericIterator::type, typename std::remove_const::type, typename mutable_reference::type, D, IteratorFacade>; + friend class GenericIterator::type, const typename std::remove_const::type, typename const_reference::type, D, IteratorFacade>; - DifferenceType distanceTo(const MutableIterator& other)const - { - assert(other.container_==container_); - return other.position_ - position_; - } + typedef GenericIterator::type, typename std::remove_const::type, typename mutable_reference::type, D, IteratorFacade> MutableIterator; + typedef GenericIterator::type, const typename std::remove_const::type, typename const_reference::type, D, IteratorFacade> ConstIterator; - DifferenceType distanceTo(const ConstIterator& other)const - { - assert(other.container_==container_); - return other.position_ - position_; - } - -private: - Container *container_; - DifferenceType position_; -}; + public: + + /** + * @brief The type of container we are an iterator for. + * + * The container type must provide an operator[] method. + * + * If C has a const qualifier we are a const iterator, otherwise we + * are a mutable iterator. + */ + typedef C Container; + + /** + * @brief The value type of the iterator. + * + * This is the return type when dereferencing the iterator. + */ + typedef T Value; + + /** + * @brief The type of the difference between two positions. + */ + typedef D DifferenceType; + + /** + * @brief The type of the reference to the values accessed. + */ + typedef R Reference; + + // Constructors needed by the base iterators + GenericIterator() : container_(0), position_(0) + {} + + /** + * @brief Constructor + * @param cont Reference to the container we are an iterator for + * @param pos The position the iterator will be positioned to + * (e.g. 0 for an iterator returned by Container::begin() or + * the size of the container for an iterator returned by Container::end() + */ + GenericIterator(Container& cont, DifferenceType pos) + : container_(&cont), position_(pos) + {} + + /** + * @brief Copy constructor + * + * This is somehow hard to understand, therefore play with the cases: + * 1. if we are mutable this is the only valid copy constructor, as the argument is a mutable iterator + * 2. if we are a const iterator the argument is a mutable iterator => This is the needed conversion to initialize a const iterator from a mutable one. + */ + GenericIterator(const MutableIterator& other) : container_(other.container_), position_(other.position_) + {} + + /** + * @brief Copy constructor + * + * @warning Calling this method results in a compiler error, if this is a mutable iterator. + * + * This is somehow hard to understand, therefore play with the cases: + * 1. if we are mutable the arguments is a const iterator and therefore calling this method is mistake in the user's code and results in a (probably not understandable) compiler error + * 2. If we are a const iterator this is the default copy constructor as the argument is a const iterator too. + */ + GenericIterator(const ConstIterator& other) : container_(other.container_), position_(other.position_) + {} + + // Methods needed by the forward iterator + bool equals(const MutableIterator & other) const + { + return position_ == other.position_ && container_ == other.container_; + } + + bool equals(const ConstIterator & other) const + { + return position_ == other.position_ && container_ == other.container_; + } + + Reference dereference() const { + return container_->operator[](position_); + } + + void increment(){ + ++position_; + } + + // Additional function needed by BidirectionalIterator + void decrement(){ + --position_; + } + + // Additional function needed by RandomAccessIterator + Reference elementAt(DifferenceType i) const { + return container_->operator[](position_+i); + } + + void advance(DifferenceType n){ + position_=position_+n; + } + + DifferenceType distanceTo(const MutableIterator& other) const + { + assert(other.container_==container_); + return other.position_ - position_; + } + + DifferenceType distanceTo(const ConstIterator& other) const + { + assert(other.container_==container_); + return other.position_ - position_; + } + + private: + Container *container_; + DifferenceType position_; + }; /** @} */ - + } // end namespace Dune #endif diff -Nru dune-common-2.2.1/dune/common/geometrytype.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/geometrytype.hh --- dune-common-2.2.1/dune/common/geometrytype.hh 2013-02-26 12:26:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/geometrytype.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,395 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: - -#ifndef DISABLE_GEOMETRYTYPE_DEPRECATION_WARNING -#warning #include is deprecated. Use -#warning #include instead. You may need the new -#warning Dune-Geometry core module. -#endif // DISABLE_GEOMETRYTYPE_DEPRECATION_WARNING - -#ifndef DUNE_COMMON_GEOMETRYTYPE_HH -#define DUNE_COMMON_GEOMETRYTYPE_HH - -#include - -/** \file - \brief A unique label for each type of element that can occur in a grid - - \deprecated This header has been moved to \, - you may need the new Dune-Geometry core module. -*/ - -#include - -#include - -namespace Dune { - - /** \brief Unique label for each type of entities that can occur in DUNE grids - - This class has to be extended if a grid implementation with new entity types - is added to DUNE. - - \deprecated The location of this class has been moved to \, - you may need the new Dune-Geometry core module. - - \ingroup COGeometryType - */ - class GeometryType - { - public: - /** \brief Each entity can be tagged by one of these basic types - plus its space dimension */ - enum BasicType { - simplex, //!< Simplicial element in any nonnegative dimension - cube, //!< Cube element in any nonnegative dimension - pyramid, //!< Four sided pyramid in three dimensions - prism, //!< Prism element in three dimensions - extended, //!< Other, more general geometry, representable as topologyId - none //!< Generic element in any nonnegative dimension - }; - - /** \brief A few binary constants */ - enum Binary { - b0001 = 1, - b0011 = 3, - b0101 = 5, - b0111 = 7 - }; - private: - - /** \brief Topology Id element */ - unsigned int topologyId_; - - /** \brief Dimension of the element */ - unsigned char dim_ : 7; - - /** \brief bool if this is none-type */ - bool none_ : 1; - - public: - /** \brief Default constructor, not initializing anything */ - GeometryType () - : topologyId_(0), dim_(0), none_(true) - {} - - /** \brief Constructor */ - GeometryType(BasicType basicType, unsigned int dim) - : topologyId_(0), dim_(dim), none_(false) - { - if (dim < 2) - return; - switch( basicType ) - { - case GeometryType::simplex: - makeSimplex(dim); - break; - case GeometryType::cube: - makeCube(dim); - break; - case GeometryType::pyramid: - if (dim == 3) - makePyramid(); - break; - case GeometryType::prism: - if (dim == 3) - makePrism(); - break; - case GeometryType::none: - makeNone(dim); - break; - default: - DUNE_THROW( RangeError, - "Invalid basic geometry type: " << basicType << " for dimension " << dim << "." ); - } - } - - /** \brief Constructor */ - GeometryType(unsigned int topologyId, unsigned int dim) - : topologyId_(topologyId), dim_(dim), none_(false) - {} - - /** \brief Constructor from static TopologyType class - * - * Constructs the GeometryType object from a static topology representation. - * - * \tparam TopologyType A class providing public static unsigned int members - * TopologyType::dimension and TopologyType::id. - * You can e.g. use the Point, Prism and Pyramid structs from - * topologytypes.hh in dune-grid. - * \param t Any object of type TopologyType. The object t itself is ignored. - */ - template - explicit GeometryType(TopologyType t) - : topologyId_(TopologyType::id), dim_(TopologyType::dimension), none_(false) - {} - - /** \brief Constructor for vertices and segments */ - explicit GeometryType(unsigned int dim) - : topologyId_(0), dim_(dim), none_(false) - { - assert(dim < 2); - } - - /** \brief Constructor for vertices and segments */ - // We need this constructor for "int" and "unsigned int", - // because otherwise GeometryType(int) would try to call the - // generic GeometryType(TopologyType) constructor - explicit GeometryType(int dim) - : topologyId_(0), dim_(dim), none_(false) - { - assert(dim < 2); - } - - /** @name Setup Methods */ - /*@{*/ - - /** \brief Make a vertex */ - void makeVertex() { - none_ = false; - dim_ = 0; - topologyId_ = 0; - } - - /** \brief Make a line segment */ - void makeLine() { - none_ = false; - dim_ = 1; - topologyId_ = 0; - } - - /** \brief Make a triangle */ - void makeTriangle() { - makeSimplex(2); - } - - /** \brief Make a quadrilateral */ - void makeQuadrilateral() { - makeCube(2); - } - - /** \brief Make a tetrahedron */ - void makeTetrahedron() { - makeSimplex(3); - } - - /** \brief Make a pyramid */ - void makePyramid() { - none_ = false; - dim_ = 3; - topologyId_ = b0011; - } - - /** \brief Make a prism */ - void makePrism() { - none_ = false; - dim_ = 3; - topologyId_ = b0101; // (1 << (dim_-1)) - 1; - } - - /** \brief Make a hexahedron */ - void makeHexahedron() { - makeCube(3); - } - - /** \brief Make a simplex of given dimension */ - void makeSimplex(unsigned int dim) { - none_ = false; - dim_ = dim; - topologyId_ = 0; - } - - /** \brief Make a hypercube of given dimension */ - void makeCube(unsigned int dim) { - none_ = false; - dim_ = dim; - topologyId_ = ((dim>1) ? ((1 << dim) - 1) : 0); - } - - /** \brief Make a singular of given dimension */ - void makeNone(unsigned int dim) { - none_ = true; - dim_ = dim; - topologyId_ = 0; - } - - /*@}*/ - - - /** @name Query Methods */ - /*@{*/ - /** \brief Return true if entity is a vertex */ - bool isVertex() const { - return dim_==0; - } - - /** \brief Return true if entity is a line segment */ - bool isLine() const { - return dim_==1; - } - - /** \brief Return true if entity is a triangle */ - bool isTriangle() const { - return ! none_ && dim_==2 && (topologyId_ | 1) == b0001; - } - - /** \brief Return true if entity is a quadrilateral */ - bool isQuadrilateral() const { - return ! none_ && dim_==2 && (topologyId_ | 1) == b0011; - } - - /** \brief Return true if entity is a tetrahedron */ - bool isTetrahedron() const { - return ! none_ && dim_==3 && (topologyId_ | 1) == b0001; - } - - /** \brief Return true if entity is a pyramid */ - bool isPyramid() const { - return ! none_ && dim_==3 && (topologyId_ | 1) == b0011; - } - - /** \brief Return true if entity is a prism */ - bool isPrism() const { - return ! none_ && dim_==3 && (topologyId_ | 1) == b0101; - } - - /** \brief Return true if entity is a hexahedron */ - bool isHexahedron() const { - return ! none_ && dim_==3 && (topologyId_ | 1) == b0111; - } - - /** \brief Return true if entity is a simplex of any dimension */ - bool isSimplex() const { - return ! none_ && (topologyId_ | 1) == 1; - } - - /** \brief Return true if entity is a cube of any dimension */ - bool isCube() const { - return ! none_ && ((topologyId_ ^ ((1 << dim_)-1)) >> 1 == 0); - } - - /** \brief Return true if entity is a singular of any dimension */ - bool isNone() const { - return none_; - } - - /** \brief Return dimension of the type */ - unsigned int dim() const { - return dim_; - } - - /** \brief Return the basic type of the type */ - BasicType basicType() const DUNE_DEPRECATED { - if (isSimplex()) - return GeometryType::simplex; - if (isCube()) - return GeometryType::cube; - if (isPyramid()) - return GeometryType::pyramid; - if (isPrism()) - return GeometryType::prism; - if (isNone()) - return GeometryType::none; - return GeometryType::extended; - } - - /** \brief Return the topology id the type */ - unsigned int id() const { - return topologyId_; - } - - /*@}*/ - - /** \brief Check for equality. This method knows that in dimension 0 and 1 - all BasicTypes are equal. - */ - bool operator==(const GeometryType& other) const { - return ( ( none_ == other.none_ ) - && ( ( none_ == true ) - || ( ( dim_ == other.dim_ ) - && ( (topologyId_ >> 1) == (other.topologyId_ >> 1) ) - ) - ) - ); - } - - /** \brief Check for inequality */ - bool operator!=(const GeometryType& other) const { - return ! ((*this)==other); - } - - /** \brief less-than operation for use with maps */ - bool operator < (const GeometryType& other) const { - return ( ( none_ < other.none_ ) - || ( !( other.none_ < none_ ) - && ( ( dim_ < other.dim_ ) - || ( (other.dim_ == dim_) - && ((topologyId_ >> 1) < (other.topologyId_ >> 1) ) - ) - ) - ) - ); - } - }; - - /** \brief Prints the type to an output stream */ - inline std::ostream& operator<< (std::ostream& s, const GeometryType& a) - { - if (a.isSimplex()) - { - s << "(simplex, " << a.dim() << ")"; - return s; - } - if (a.isCube()) - { - s << "(cube, " << a.dim() << ")"; - return s; - } - if (a.isPyramid()) - { - s << "(pyramid, 3)"; - return s; - } - if (a.isPrism()) - { - s << "(prism, 3)"; - return s; - } - if (a.isNone()) - { - s << "(none, " << a.dim() << ")"; - return s; - } - s << "(other [" << a.id() << "], " << a.dim() << ")"; - return s; - } - - /** \brief Prints a GeometryType::BasicType to an output stream */ - inline std::ostream& operator<< (std::ostream& s, GeometryType::BasicType type) - { - switch (type) { - case GeometryType::simplex: - s << "simplex"; - break; - case GeometryType::cube: - s << "cube"; - break; - case GeometryType::pyramid: - s << "pyramid"; - break; - case GeometryType::prism: - s << "prism"; - break; - case GeometryType::extended: - s << "other"; - case GeometryType::none: - s << "none"; - break; - default: - DUNE_THROW(Exception, "invalid GeometryType::BasicType"); - } - return s; - } -} - -#endif // DUNE_COMMON_GEOMETRYTYPE_HH diff -Nru dune-common-2.2.1/dune/common/geometrytypeindex.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/geometrytypeindex.hh --- dune-common-2.2.1/dune/common/geometrytypeindex.hh 2011-11-09 10:53:43.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/geometrytypeindex.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: - -#ifndef DISABLE_GEOMETRYTYPEINDEX_DEPRECATION_WARNING -#warning #include is deprecated. Use -#warning #include instead. You may need the new -#warning Dune-Geometry core module. -#warning NOTE: was never part of a release, -#warning so this compatibility mechanism should be removed before the 2.2 -#warning release. -#endif // DISABLE_GEOMETRYTYPEINDEX_DEPRECATION_WARNING - -#ifndef DUNE_COMMON_GEOMETRYTYPEINDEX_HH -#define DUNE_COMMON_GEOMETRYTYPEINDEX_HH - -/** \file - * \brief Helper classes to provide indices for geometrytypes for use in a - * vector - */ - -#include - -#define DISABLE_GEOMETRYTYPE_DEPRECATION_WARNING -#include -#undef DISABLE_GEOMETRYTYPE_DEPRECATION_WARNING - -namespace Dune { - - //! Compute per-dimension indices for geometry types - class LocalGeometryTypeIndex { - //! compute the number of regular geometry types for the given dimension - /** - * Regular geometry type are those which have a topologyId, i.e. "None" is - * not a regular geometry type. - */ - inline static std::size_t regular_size(std::size_t dim) { - // The following expression is derived from the expression for - // GlobalGeometryTypeIndex::regular_base(). Substracting - // regular_base(dim+1)-regular_base(dim) we get: - // - // ((1 << dim+1) >> 1) - ((1 << dim) >> 1) - // - // We always have - // - // dim >= 0, - // - // so - // - // (1 << dim+1) >= 2 and (1 << dim+2) % 2 == 0. - // - // So if we apply a single right-shift to that, we will never lose any - // set bits, thus - // - // ((1 << dim+1) >> 1) == (1 << dim) - return (1 << dim) - ((1 << dim) >> 1); - } - - public: - //! compute total number of geometry types for the given dimension - /** - * This includes irregular geometry types such as "None". - */ - inline static std::size_t size(std::size_t dim) { - // one for "none" - return regular_size(dim) + 1; - } - - //! compute the index for the given geometry type within its dimension - /** - * Geometry types from different dimensions my get the same index. If - * that is not what you want, maybe you should look at - * GlobalGeometryTypeIndex. - */ - inline static std::size_t index(const GeometryType >) { - if(gt.isNone()) - return regular_size(gt.dim()); - else - return gt.id() >> 1; - } - }; - - //! Compute indices for geometry types, taking the dimension into account - class GlobalGeometryTypeIndex { - //! \brief Compute the starting index for a given dimension ignoring - //! irregular geometry types - /** - * This ignores irregular geometry types so it is not useful in itself. - * Have a look at base() which does include the irregular geometry types. - */ - inline static std::size_t regular_base(std::size_t dim) { - // The number of regular geometry types in a given dimension is - // 2^(dim-1). For dim==0 this would yield 1/2 geometry types (which is - // obviously bogus, dim==0 has one regular geometry type, the point). - // The following expression relies on 1 >> 1 == 0 to treat dim==0 - // specially. - return (1 << dim) >> 1; - } - - //! \brief Compute the starting index for a given dimension including - //! irregular geometry types - inline static std::size_t base(std::size_t dim) { - // dim times "none" - return regular_base(dim) + dim; - } - - public: - //! \brief Compute total number of geometry types up to and including the - //! given dimension - /** - * This includes irregular geometry types such as "None". - */ - inline static std::size_t size(std::size_t maxdim) - { return base(maxdim+1); } - - //! compute the index for the given geometry type over all dimensions - /** - * Geometry types from different dimensions will get different indices, - * and lower dimensions will always have lower indices than higher - * dimensions. If that is not what you want, maybe you should look at - * LocalGeometryTypeIndex. - */ - inline static std::size_t index(const GeometryType >) { - return base(gt.dim()) + LocalGeometryTypeIndex::index(gt); - } - }; - -} // namespace Dune - -#endif // DUNE_COMMON_GEOMETRYTYPEINDEX_HH diff -Nru dune-common-2.2.1/dune/common/gmpfield.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/gmpfield.hh --- dune-common-2.2.1/dune/common/gmpfield.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/gmpfield.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_GMPFIELD_HH #define DUNE_GMPFIELD_HH @@ -6,37 +8,56 @@ */ #include +#include -#if HAVE_GMP +#if HAVE_GMP || DOXYGEN #include +#include + namespace Dune { + /** + * \ingroup Numbers + * \brief Number class for high precision floating point number using the GMP library mpf_class implementation + */ template< unsigned int precision > class GMPField - : public mpf_class + : public mpf_class { typedef mpf_class Base; public: + /** default constructor, initialize to zero */ GMPField () - : Base(0,precision) + : Base(0,precision) {} - template< class T > - GMPField ( const T &v ) - : Base( v,precision ) + /** \brief initialize from a string + \note this is the only reliable way to initialize with higher precision values + */ + GMPField ( const char* str ) + : Base(str,precision) {} - /* - GMPField &operator=(const GMPField &other) - { - Base(*this) = Base(other); - return *this; - } - */ + /** \brief initialize from a string + \note this is the only reliable way to initialize with higher precision values + */ + GMPField ( const std::string& str ) + : Base(str,precision) + {} + + /** \brief initialize from a compatible scalar type + */ + template< class T, + typename EnableIf = typename std::enable_if< + std::is_convertible::value>::type + > + GMPField ( const T &v ) + : Base( v,precision ) + {} // type conversion operators operator double () const @@ -44,87 +65,12 @@ return this->get_d(); } - operator float () const - { - return this->get_d(); - } - - operator mpf_class () const - { - return static_cast(*this); - } }; - - - template< unsigned int precision > - inline GMPField< precision > - operator+ ( const GMPField< precision > &a, const GMPField< precision > &b ) - { - typedef mpf_class F; - return ((const F &)a + (const F &)b); - } - - template< unsigned int precision > - inline GMPField< precision > - operator- ( const GMPField< precision > &a, const GMPField< precision > &b ) - { - typedef mpf_class F; - return ((const F &)a - (const F &)b); - } - - template< unsigned int precision > - inline GMPField< precision > - operator- ( const GMPField< precision > &a ) - { - typedef mpf_class F; - return -((const F &)a); - } - - template< unsigned int precision > - inline GMPField< precision > - operator* ( const GMPField< precision > &a, const GMPField< precision > &b ) - { - typedef mpf_class F; - return ((const F &)a * (const F &)b); - } - - template< unsigned int precision > - inline GMPField< precision > - operator/ ( const GMPField< precision > &a, const GMPField< precision > &b ) - { - typedef mpf_class F; - return ((const F &)a / (const F &)b); - } - - - - template< unsigned int precision > - inline std::ostream & - operator<< ( std::ostream &out, const GMPField< precision > &value ) - { - return out << static_cast(value); - } - -} - -namespace std -{ - - template< unsigned int precision > - inline Dune::GMPField< precision > - sqrt ( const Dune::GMPField< precision > &a ) - { - return Dune::GMPField< precision >(sqrt(static_cast(a))); - } - - template< unsigned int precision > - inline Dune::GMPField< precision > - abs ( const Dune::GMPField< precision > &a ) - { - return Dune::GMPField< precision >( abs( static_cast< const mpf_class & >( a ) ) ); - } - + template + struct IsNumber> + : public std::integral_constant { + }; } #endif // HAVE_GMP diff -Nru dune-common-2.2.1/dune/common/hash.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/hash.hh --- dune-common-2.2.1/dune/common/hash.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/hash.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,336 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_HASH_HH +#define DUNE_COMMON_HASH_HH + +#include + +#include + +/** + * \file + * \brief Support for calculating hash values of objects. + * + * This file provides the functor Dune::hash to calculate hash values and + * some infrastructure to simplify extending Dune::hash for user-defined types, + * independent of the actual underlying implementation. + * + */ + + + +// ******************************************************************************** +// Doxygen documentation +// ******************************************************************************** + +#ifdef DOXYGEN + +namespace Dune { + + //! Functor for hashing objects of type T. + /** + * The interface outlined below is compatible with std::hash, std::tr1::hash and + * boost::hash, so it is possible to use Dune::hash in associative containers from + * those libraries. + */ + template + struct hash + { + + //! Calculates the hash of t. + std::size_t operator()(const T& t) const + { + return hash(t); + } + + }; + +} + +//! Defines the required struct specialization to make type hashable via `Dune::hash`. +/** + * In order to calculate the hash, operator() of the generated specialization will + * return the result of an unqualified call to the global function `hash_value(const type&)`. + * As the call is not qualified, the function will be found using argument-dependent lookup, + * allowing implementors to conveniently place it inside the class body. + * + * Consider the following type: + * + * \code + * namespace ns { + * template + * class Foo + * { + * ... + * }; + * } + * \endcode + * + * In order to add support for `Dune::hash`, you need to extend the definition like this: + * + * \code + * namespace ns { + * template + * class Foo + * { + * ... + * // The keyword "friend" turns this into a global function that is a friend of Foo. + * inline friend std::size_t hash_value(const Foo& arg) + * { + * return ...; + * } + * }; + * } + * + * // Define hash struct specialization + * DUNE_DEFINE_HASH(DUNE_HASH_TEMPLATE_ARGS(typename A, int i),DUNE_HASH_TYPE(Foo)) + * \endcode + * + * \warning + * As the specialization has to be placed in the original namespace of the + * `hash` struct (e.g. `std`), this macro *must* be called from the global namespace! + * + * \param template_args The template arguments required by the hash struct specialization, + * wrapped in a call to DUNE_HASH_TEMPLATE_ARGS. If this is a complete + * specialization, call DUNE_HASH_TEMPLATE_ARGS without arguments. + * \param type The exact type of the specialization, wrapped in a call to DUNE_HASH_TYPE. + */ +#define DUNE_DEFINE_HASH(template_args,type) + + +//! Wrapper macro for the template arguments in DUNE_DEFINE_HASH. +/** + * This macro should always be used as a wrapper for the template arguments when calling DUNE_DEFINE_HASH. + * It works around some preprocessor limitations when the template arguments contain commas or the list + * is completely empty. + */ +#define DUNE_HASH_TEMPLATE_ARGS(...) + +//! Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH. +/** + * This macro should always be used as a wrapper for the type of the specialization when calling + * DUNE_DEFINE_HASH. + * It works around some preprocessor limitations when the type contains commas. + */ +#define DUNE_HASH_TYPE(...) + +#else // DOXYGEN - hide all the ugly implementation + + + +// ******************************************************************************** +// C++11 support +// ******************************************************************************** + +// import std::hash into Dune namespace +namespace Dune { + + using std::hash; + +} + +// Macro for defining a std::hash specialization for type. +// This should not be called directly. Call DUNE_DEFINE_HASH +// instead. +#define DUNE_DEFINE_STD_HASH(template_args,type) \ + namespace std { \ + \ + template \ + struct hash \ + { \ + \ + typedef type argument_type; \ + typedef std::size_t result_type; \ + \ + std::size_t operator()(const type& arg) const \ + { \ + return hash_value(arg); \ + } \ + }; \ + \ + } \ + +// Wrapper macro for template arguments. +// This is required because the template arguments can contain commas, +// which will create a macro argument list of unknown length. That in itself +// would not be a problem, but DUNE_DEFINE_HASH has to be called with two argument +// lists of unknown length. So this macro wraps its arguments with parentheses, +// turning it into a single argument. The result is used as the parameter list of +// an expansion macro in the calls to the implementation-specific macros +// for C++11 and TR1. Noto that technically, this trick is only legal for C++11, +// but pretty much every compiler supports variadic macros in C++03 mode, as they +// are part of C99. +#define DUNE_HASH_TEMPLATE_ARGS(...) (__VA_ARGS__) + +// Wrapper macro for type to be hashed. +// See above for rationale. +#define DUNE_HASH_TYPE(...) (__VA_ARGS__) + +// Expansion macro for the parenthesed argument lists created by +// DUNE_HASH_TEMPLATE_ARGS and DUNE_HASH_TYPE. +#define DUNE_HASH_EXPAND_VA_ARGS(...) __VA_ARGS__ + +// Define specializations for all discovered hash implementations. +#define DUNE_DEFINE_HASH(template_args,type) \ + DUNE_DEFINE_STD_HASH(DUNE_HASH_EXPAND_VA_ARGS template_args, DUNE_HASH_EXPAND_VA_ARGS type) \ + + +#endif // DOXYGEN + + + +// ******************************************************************************** +// Some utility functions for combining hashes of member variables. +// ******************************************************************************** + +namespace Dune { + + // The following functions are an implementation of the proposed hash extensions for + // the C++ standard by Peter Dimov + // (cf. http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf, issue 6.18). + // They are also contained in the boost::functional::hash library by Daniel James, but + // that implementation uses boost::hash internally, while we want to use Dune::hash. They + // are also considered for inclusion in TR2 (then based on std::hash, of course). + +#ifndef DOXYGEN + + // helper struct for providing different hash combining algorithms dependent on + // the size of size_t. + // hash_combiner has to be specialized for the size (in bytes) of std::size_t. + // Specialized versions should provide a method + // + // template + // void operator()(typeof_size_t& seed, const T& arg) const; + // + // that will be called by the interface function hash_combine() described further below. + // The redundant template parameter typeof_size_t is needed to avoid warnings for the + // unused 64-bit specialization on 32-bit systems. + // + // There is no default implementation! + template + struct hash_combiner; + + + // hash combining for 64-bit platforms. + template<> + struct hash_combiner<8> + { + + template + void operator()(typeof_size_t& seed, const T& arg) const + { + static_assert(sizeof(typeof_size_t)==8, "hash_combiner::operator() instantiated with nonmatching type and size"); + + // The following algorithm for combining two 64-bit hash values is inspired by a similar + // function in CityHash (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.h), + // which is in turn based on ideas from the MurmurHash library. The basic idea is easy to + // grasp, though: New information is XORed into the existing hash multiple times at different + // places (using shift operations), and the resulting pattern is spread over the complete + // range of available bits via multiplication with a "magic" constant. The constants used + // below (47 and 0x9ddfea08eb382d69ULL) are taken from the CityHash implementation. + // + // We opted not to use the mixing algorithm proposed in the C++ working group defect list at + // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf, p. 57f. because it + // has very bad hash distribution properties if you apply it to lists of very small numbers, + // an application that is frequent in PDELab's ordering framework. + + Dune::hash hasher; + const typeof_size_t kMul = 0x9ddfea08eb382d69ULL; + typeof_size_t h = hasher(arg); + typeof_size_t a = (seed ^ h) * kMul; + a ^= (a >> 47); + typeof_size_t b = (h ^ a) * kMul; + b ^= (b >> 47); + b *= kMul; + seed = b; + } + + }; + + + // hash combining for 32-bit platforms. + template<> + struct hash_combiner<4> + { + + template + void operator()(typeof_size_t& seed, const T& arg) const + { + static_assert(sizeof(typeof_size_t)==4, "hash_combiner::operator() instantiated with nonmatching type and size"); + + // The default algorithm above requires a 64-bit std::size_t. The following algorithm is a + // 32-bit compatible fallback, again inspired by CityHash and MurmurHash + // (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.cc). + // It uses 32-bit constants and relies on rotation instead of multiplication to spread the + // mixed bits as that is apparently more efficient on IA-32. The constants used below are again + // taken from CityHash, in particular from the file referenced above. + + Dune::hash hasher; + const typeof_size_t c1 = 0xcc9e2d51; + const typeof_size_t c2 = 0x1b873593; + const typeof_size_t c3 = 0xe6546b64; + typeof_size_t h = hasher(arg); + typeof_size_t a = seed * c1; + a = (a >> 17) | (a << (32 - 17)); + a *= c2; + h ^= a; + h = (h >> 19) | (h << (32 - 19)); + seed = h * 5 + c3; + } + + }; + +#endif // DOXYGEN + + //! Calculates the hash value of arg and combines it in-place with seed. + /** + * + * \param seed The hash value that will be combined with the hash of arg. + * \param arg The object for which to calculate a hash value and combine it with seed. + */ + template + inline void hash_combine(std::size_t& seed, const T& arg) + { + hash_combiner()(seed,arg); + } + + //! Hashes all elements in the range [first,last) and returns the combined hash. + /** + * + * \param first Iterator pointing to the first object to hash. + * \param last Iterator pointing one past the last object to hash. + + * \returns The result of hashing all objects in the range and combining them + * using hash_combine() in sequential fashion, starting with seed 0. + */ + template + inline std::size_t hash_range(It first, It last) + { + std::size_t seed = 0; + for (; first != last; ++first) + { + hash_combine(seed,*first); + } + return seed; + } + + //! Hashes all elements in the range [first,last) and combines the hashes in-place with seed. + /** + * + * \param seed Start value that will be combined with the hash values of all objects in + * the range using hash_combine() in sequential fashion. + * \param first Iterator pointing to the first ojbect to hash. + * \param last Iterator pointing one past the last object to hash. + */ + template + inline void hash_range(std::size_t& seed, It first, It last) + { + for (; first != last; ++first) + { + hash_combine(seed,*first); + } + } + +} // end namespace Dune + +#endif // DUNE_COMMON_HASH_HH diff -Nru dune-common-2.2.1/dune/common/hybridutilities.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/hybridutilities.hh --- dune-common-2.2.1/dune/common/hybridutilities.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/hybridutilities.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,536 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_HYBRIDUTILITIES_HH +#define DUNE_COMMON_HYBRIDUTILITIES_HH + +#include +#include + +#include +#include +#include + + + +namespace Dune { +namespace Hybrid { + +namespace Impl { + + // Try if tuple_size is implemented for class + template + constexpr auto size(const Dune::FieldVector*, const PriorityTag<5>&) + -> decltype(std::integral_constant()) + { + return {}; + } + + // Try if we have an instance of std::integer_sequence + template + constexpr auto size(std::integer_sequence, PriorityTag<4>) + { + using sizeAsType = std::tuple_size; + return std::integral_constant(); + } + + // Try if tuple_size is implemented for class + template + constexpr auto size(const T*, const PriorityTag<3>&) + -> decltype(std::integral_constant::value>()) + { + return {}; + } + + // Try if there's a static constexpr size() + template + constexpr auto size(const T*, const PriorityTag<1>&) + -> decltype(std::integral_constant()) + { + return {}; + } + + // As a last resort try if there's a static constexpr size() + template + constexpr auto size(const T* t, const PriorityTag<0>&) + { + return t->size(); + } + +} // namespace Impl + + + +/** + * \brief Size query + * + * \ingroup HybridUtilities + * + * \tparam T Type of container whose size is queried + * + * \param t Container whose size is queried + * + * \return Size of t + * + * If the size of t is known at compile type the size is + * returned as std::integral_constant. + * Otherwise the result of t.size() is returned. + * + * Supported types for deriving the size at compile time are: + * * instances of std::integer_sequence + * * all types std::tuple_size is implemented for + * * all typed that have a static method ::size() + * * instances of Dune::FieldVector + */ +template +constexpr auto size(const T& t) +{ + return Impl::size(&t, PriorityTag<42>()); +} + + + +namespace Impl { + + template>::value, int> = 0> + constexpr decltype(auto) elementAt(Container&& c, Index&&, PriorityTag<2>) + { + return std::get::value>(c); + } + + template + constexpr decltype(auto) elementAt(std::integer_sequence c, Index&&, PriorityTag<1>) + { + return std::get::value>(std::make_tuple(std::integral_constant()...)); + } + + template + constexpr decltype(auto) elementAt(Container&& c, Index&& i, PriorityTag<0>) + { + return c[i]; + } + +} // namespace Impl + + + +/** + * \brief Get element at given position from container + * + * \ingroup HybridUtilities + * + * \tparam Container Type of given container + * \tparam Index Type of index + * + * \param c Given container + * \param i Index of element to obtain + * + * \return The element at position i, i.e. c[i] + * + * If this returns the i-th entry of c. It supports the following + * containers + * * Containers providing dynamic access via operator[] + * * Heterogenous containers providing access via operator[](integral_constant<...>) + * * std::tuple<...> + * * std::integer_sequence + */ +template +constexpr decltype(auto) elementAt(Container&& c, Index&& i) +{ + return Impl::elementAt(std::forward(c), std::forward(i), PriorityTag<42>()); +} + + + +namespace Impl { + + template + class StaticIntegralRange + { + public: + + template + constexpr auto operator[](Dune::index_constant) const + { + return std::integral_constant(); + } + + static constexpr auto size() + { + return std::integral_constant(); + } + }; + + template + class DynamicIntegralRange + { + public: + constexpr DynamicIntegralRange(const T& begin, const T& end): + begin_(begin), + end_(end) + {} + + constexpr auto size() const + { + return end_ - begin_; + } + + constexpr T operator[](const T&i) const + { return begin_+i; } + + private: + T begin_; + T end_; + }; + + template::value and IsIntegralConstant::value, int> = 0> + constexpr auto integralRange(const Begin& begin, const End& end, const PriorityTag<1>&) + { + static_assert(Begin::value <= End::value, "You cannot create an integralRange where end(); + } + + // This should be constexpr but gcc-4.9 does not support + // the relaxed constexpr requirements. Hence for beeing + // constexpr the function body can only contain a return + // statement and no assertion before this. + template + auto integralRange(const Begin& begin, const End& end, const PriorityTag<0>&) + { + assert(begin <= end); + return Impl::DynamicIntegralRange(begin, end); + } + +} // namespace Impl + + + +/** + * \brief Create an integral range + * + * \ingroup HybridUtilities + * + * \tparam Begin Type of begin entry of the range + * \tparam End Type of end entry of the range + * + * \param begin First entry of the range + * \param end One past the last entry of the range + * + * \returns An object encoding the given range + * + * If Begin and End are both instances of type + * std::integral_constant, the returned range + * encodes begin and end statically. + */ +template +constexpr auto integralRange(const Begin& begin, const End& end) +{ + return Impl::integralRange(begin, end, PriorityTag<42>()); +} + +/** + * \brief Create an integral range starting from 0 + * + * \ingroup HybridUtilities + * + * \tparam End Type of end entry of the range + * + * \param end One past the last entry of the range + * + * \returns An object encoding the given range + * + * This is a short cut for integralRange(_0, end). + */ +template +constexpr auto integralRange(const End& end) +{ + return Impl::integralRange(Dune::Indices::_0, end, PriorityTag<42>()); +} + + + +namespace Impl { + + template + void evaluateFoldExpression(std::initializer_list&&) + {} + + template + constexpr void forEachIndex(Range&& range, F&& f, std::integer_sequence) + { + evaluateFoldExpression({(f(Hybrid::elementAt(range, std::integral_constant())), 0)...}); + } + + template + constexpr void forEach(std::integer_sequence range, F&& f, PriorityTag<2>) + { + evaluateFoldExpression({(f(std::integral_constant()), 0)...}); + } + + + template()))>::value, int> = 0> + constexpr void forEach(Range&& range, F&& f, PriorityTag<1>) + { + auto size = Hybrid::size(range); + auto indices = std::make_index_sequence(); + forEachIndex(std::forward(range), std::forward(f), indices); + } + + template + constexpr void forEach(Range&& range, F&& f, PriorityTag<0>) + { + for(std::size_t i=0; i +constexpr void forEach(Range&& range, F&& f) +{ + Impl::forEach(std::forward(range), std::forward(f), PriorityTag<42>()); +} + + + +/** + * \brief Accumulate values + * + * \ingroup HybridUtilities + * + * \tparam Range Type of given range + * \tparam T Type of accumulated value + * \tparam F Type of binary accumulation operator + * + * \param range The range of values to accumulate + * \param value Initial value for accumulation + * \param f Binary operator for accumulation + * + * This supports looping over the same ranges as Hybrid::forEach + */ +template +T accumulate(Range&& range, T value, F&& f) +{ + forEach(std::forward(range), [&](auto&& entry) { + value = f(value, entry); + }); + return value; +} + + + +namespace Impl { + + template + constexpr decltype(auto) ifElse(std::true_type, IfFunc&& ifFunc, ElseFunc&& elseFunc) + { + return ifFunc([](auto&& x) -> decltype(auto) { return std::forward(x);}); + } + + template + constexpr decltype(auto) ifElse(std::false_type, IfFunc&& ifFunc, ElseFunc&& elseFunc) + { + return elseFunc([](auto&& x) -> decltype(auto) { return std::forward(x);}); + } + + template + decltype(auto) ifElse(const bool& condition, IfFunc&& ifFunc, ElseFunc&& elseFunc) + { + if (condition) + return ifFunc([](auto&& x) -> decltype(auto) { return std::forward(x);}); + else + return elseFunc([](auto&& x) -> decltype(auto) { return std::forward(x);}); + } + +} // namespace Impl + + + +/** + * \brief A conditional expression + * + * \ingroup HybridUtilities + * + * This will call either ifFunc or elseFunc depending + * on the condition. In any case a single argument + * will be passed to the called function. This will always + * be the indentity function. Passing an expression through + * this function will lead to lazy evaluation. This way both + * 'branches' can contain expressions that are only valid + * within this branch if the condition is a std::integral_constant. + * + * In order to do this, the passed functors must have a single + * argument of type auto. + * + * Due to the lazy evaluation mechanism and support for + * std::integral_constant this allows to emulate + * a static if statement. + */ +template +decltype(auto) ifElse(const Condition& condition, IfFunc&& ifFunc, ElseFunc&& elseFunc) +{ + return Impl::ifElse(condition, std::forward(ifFunc), std::forward(elseFunc)); +} + +/** + * \brief A conditional expression + * + * \ingroup HybridUtilities + * + * This provides an ifElse conditional with empty else clause. + */ +template +void ifElse(const Condition& condition, IfFunc&& ifFunc) +{ + ifElse(condition, std::forward(ifFunc), [](auto&& i) {}); +} + + + +namespace Impl { + + template + constexpr auto equals(const T1& t1, const T2& t2, PriorityTag<1>) -> decltype(T1::value, T2::value, std::integral_constant()) + { return {}; } + + template + constexpr auto equals(const T1& t1, const T2& t2, PriorityTag<0>) + { + return t1==t2; + } + +} // namespace Impl + + + +/** + * \brief Equality comparison + * + * \ingroup HybridUtilities + * + * If both types have a static member value, the result of comparing + * these is returned as std::integral_constant. Otherwise + * the result of a runtime comparison of t1 and t2 is directly returned. + */ +template +constexpr auto equals(T1&& t1, T2&& t2) +{ + return Impl::equals(std::forward(t1), std::forward(t2), PriorityTag<1>()); +} + + + +namespace Impl { + + template + constexpr Result switchCases(std::integer_sequence, const Value& value, Branches&& branches, ElseBranch&& elseBranch) + { + return elseBranch(); + } + + template + constexpr Result switchCases(std::integer_sequence, const Value& value, Branches&& branches, ElseBranch&& elseBranch) + { + return ifElse( + Hybrid::equals(std::integral_constant(), value), + [&](auto id) -> decltype(auto) { + return id(branches)(std::integral_constant()); + }, [&](auto id) -> decltype(auto) { + return Impl::switchCases(id(std::integer_sequence()), value, branches, elseBranch); + }); + } + +} // namespace Impl + + + +/** + * \brief Switch statement + * + * \ingroup HybridUtilities + * + * \tparam Cases Type of case range + * \tparam Value Type of value to check against the cases + * \tparam Branches Type of branch function + * \tparam ElseBranch Type of branch function + * + * \param cases A range of cases to check for + * \param value The value to check against the cases + * \param branches A callback that will be executed with matching entry from case list + * \param elseBranch A callback that will be executed if no other entry matches + * + * Value is checked against all entries of the given range. + * If one matches, then branches is executed with the matching + * value as single argument. If the range is an std::integer_sequence, + * the value is passed as std::integral_constant. + * If non of the entries matches, then elseBranch is executed + * without any argument. + * + * Notice that this short circuits, e.g., if one case matches, + * the others are no longer evaluated. + * + * The return value will be deduced from the else branch. + */ +template +constexpr decltype(auto) switchCases(const Cases& cases, const Value& value, Branches&& branches, ElseBranch&& elseBranch) +{ + return Impl::switchCases(cases, value, std::forward(branches), std::forward(elseBranch)); +} + +/** + * \brief Switch statement + * + * \ingroup HybridUtilities + * + * \tparam Cases Type of case range + * \tparam Value Type of value to check against the cases + * \tparam Branches Type of branch function + * + * \param cases A range of cases to check for + * \param value The value to check against the cases + * \param branches A callback that will be executed with matching entry from case list + * + * Value is checked against all entries of the given range. + * If one matches, then branches is executed with the matching + * value as single argument. If the range is an std::integer_sequence, + * the value is passed as std::integral_constant. + * If non of the entries matches, then elseBranch is executed + * without any argument. + */ +template +constexpr void switchCases(const Cases& cases, const Value& value, Branches&& branches) +{ + return Impl::switchCases(cases, value, std::forward(branches), []() {}); +} + + +} // namespace Hybrid +} // namespace Dune + + +#endif // #ifndef DUNE_COMMON_HYBRIDUTILITIES_HH diff -Nru dune-common-2.2.1/dune/common/identitymatrix.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/identitymatrix.hh --- dune-common-2.2.1/dune/common/identitymatrix.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/identitymatrix.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,166 @@ +#ifndef DUNE_COMMON_IDENTITYMATRIX_HH +#define DUNE_COMMON_IDENTITYMATRIX_HH + +#warning Deprecated since dune-common 2.5: If you really do need an identity matrix, use DiagonalMatrix or ScalarIdentityMatrix (from dune-istl) instead! + +#include +#include +#include +#include + +/** + * \file + * \ingroup DenseMatVec + * \brief Implementation of an identity matrix that does not store + * any data. + * \author Christoph Gersbacher + */ + +namespace Dune +{ + + // IdentityMatrix + // -------------- + + /** \class IdentityMatrix + * + * \ingroup DenseMatVec + * + * \brief Read-only identity matrix. + * + * Implementation of an identity matrix that does not store any data. + * + * \tparam K field type + * \tparam N dimension + */ + template< class K, int N > + struct IdentityMatrix + { + /** \brief field type */ + typedef K field_type; + /** \brief size type */ + typedef std::size_t size_type; + + /** \brief return number of rows */ + constexpr size_type rows () const { return N; } + /** \brief return number of columns */ + constexpr size_type cols () const { return N; } + + /** \copydoc Dune::DenseMatrix::mv */ + template< class X, class Y > + void mv ( const X &x, Y &y ) const + { + y = x; + } + + /** \copydoc Dune::DenseMatrix::mtv */ + template< class X, class Y > + void mtv ( const X &x, Y &y ) const + { + y = x; + } + + /** \copydoc Dune::DenseMatrix::umv */ + template< class X, class Y > + void umv ( const X &x, Y &y ) const + { + y += x; + } + + /** \copydoc Dune::DenseMatrix::umtv */ + template< class X, class Y > + void umtv ( const X &x, Y &y ) const + { + y += x; + } + + /** \copydoc Dune::DenseMatrix::umhv */ + template< class X, class Y > + void umhv ( const X &x, Y &y ) const + { + y += x; + } + + /** \copydoc Dune::DenseMatrix::mmv */ + template< class X, class Y > + void mmv ( const X &x, Y &y ) const + { + y -= x; + } + + /** \copydoc Dune::DenseMatrix::mmtv */ + template< class X, class Y > + void mmtv ( const X &x, Y &y ) const + { + y -= x; + } + + /** \copydoc Dune::DenseMatrix::mmhv */ + template< class X, class Y > + void mmhv ( const X &x, Y &y ) const + { + y -= x; + } + + /** \copydoc Dune::DenseMatrix::usmv */ + template< class X, class Y > + void usmv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const + { + y.axpy( alpha, x ); + } + + /** \copydoc Dune::DenseMatrix::usmtv */ + template< class X, class Y > + void usmtv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const + { + y.axpy( alpha, x ); + } + + /** \copydoc Dune::DenseMatrix::usmhv */ + template< class X, class Y > + void usmhv (const typename FieldTraits::field_type & alpha, + const X& x, Y& y) const + { + y.axpy( alpha, x ); + } + + /** \copydoc Dune::DenseMatrix::frobenius_norm */ + typename FieldTraits< field_type >::real_type frobenius_norm () const + { + return std::sqrt( frobenius_norm2() ); + } + + /** \copydoc Dune::DenseMatrix::frobenius_norm2 */ + typename FieldTraits< field_type >::real_type frobenius_norm2 () const + { + return FieldTraits< field_type >::real_type( N ); + } + + /** \copydoc Dune::DenseMatrix::infinity_norm */ + typename FieldTraits< field_type >::real_type infinity_norm () const + { + return FieldTraits< field_type >::real_type( 1 ); + } + + /** \copydoc Dune::DenseMatrix::infinity_norm_real */ + typename FieldTraits< field_type >::real_type infinity_norm_real () const + { + return FieldTraits< field_type >::real_type( 1 ); + } + }; + + template + struct DenseMatrixAssigner> { + static void apply(DenseMatrix &denseMatrix, IdentityMatrix const &rhs) { + DUNE_ASSERT_BOUNDS(denseMatrix.M() == N); + DUNE_ASSERT_BOUNDS(denseMatrix.N() == N); + denseMatrix = field(0); + for (int i = 0; i < N; ++i) + denseMatrix[i][i] = field(1); + } + }; +} // namespace Dune + +#endif // #ifndef DUNE_COMMON_IDENTITYMATRIX_HH diff -Nru dune-common-2.2.1/dune/common/indent.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/indent.hh --- dune-common-2.2.1/dune/common/indent.hh 2010-06-14 11:06:19.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/indent.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,12 +1,12 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_INDENT_HH #define DUNE_COMMON_INDENT_HH #include #include -namespace Dune{ +namespace Dune { /** @addtogroup Common * * @{ diff -Nru dune-common-2.2.1/dune/common/indices.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/indices.hh --- dune-common-2.2.1/dune/common/indices.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/indices.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,112 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#ifndef DUNE_COMMON_INDICES_HH +#define DUNE_COMMON_INDICES_HH + +#include +#include + + +namespace Dune +{ + /** \addtogroup Common + * \{ + */ + + /** \brief An index constant with value i + * + * An index constant is a simple type alias for an integral_constant. + * Its main advantages are clarity (it is easier to see that code uses it + * as an index) and the fact that the integral type is fixed, reducing verbosity + * and avoiding the problem of maybe trying to overload / specialize using a different + * integral type. + */ + template + using index_constant = std::integral_constant; + + + + /** \brief Namespace with predefined compile time indices for the range [0,19] + * + * The predefined index objects in this namespace are `constexpr`, which allows them to + * be used in situations where a compile time constant is needed, e.g. for a template + * parameter. Apart from that, `constexpr` implies internal linkage, which helps to avoid + * ODR problems. + * + * The constants implicitly convert to their contained value, so you can for example write + * + * \code{.cc} + * std::array a; + * // the above line is equivalent to + * std::array b; + * \endcode + * + */ + namespace Indices + { + //! Compile time index with value 0. + constexpr index_constant< 0> _0 = {}; + + //! Compile time index with value 1. + constexpr index_constant< 1> _1 = {}; + + //! Compile time index with value 2. + constexpr index_constant< 2> _2 = {}; + + //! Compile time index with value 3. + constexpr index_constant< 3> _3 = {}; + + //! Compile time index with value 4. + constexpr index_constant< 4> _4 = {}; + + //! Compile time index with value 5. + constexpr index_constant< 5> _5 = {}; + + //! Compile time index with value 6. + constexpr index_constant< 6> _6 = {}; + + //! Compile time index with value 7. + constexpr index_constant< 7> _7 = {}; + + //! Compile time index with value 8. + constexpr index_constant< 8> _8 = {}; + + //! Compile time index with value 9. + constexpr index_constant< 9> _9 = {}; + + //! Compile time index with value 10. + constexpr index_constant<10> _10 = {}; + + //! Compile time index with value 11. + constexpr index_constant<11> _11 = {}; + + //! Compile time index with value 12. + constexpr index_constant<12> _12 = {}; + + //! Compile time index with value 13. + constexpr index_constant<13> _13 = {}; + + //! Compile time index with value 14. + constexpr index_constant<14> _14 = {}; + + //! Compile time index with value 15. + constexpr index_constant<15> _15 = {}; + + //! Compile time index with value 16. + constexpr index_constant<16> _16 = {}; + + //! Compile time index with value 17. + constexpr index_constant<17> _17 = {}; + + //! Compile time index with value 18. + constexpr index_constant<18> _18 = {}; + + //! Compile time index with value 19. + constexpr index_constant<19> _19 = {}; + + } // namespace Indices + +} //namespace Dune + +#endif // DUNE_COMMON_INDICES_HH diff -Nru dune-common-2.2.1/dune/common/interfaces.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/interfaces.hh --- dune-common-2.2.1/dune/common/interfaces.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/interfaces.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,12 +1,12 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_INTERFACES_HH #define DUNE_INTERFACES_HH /** @file - @author Robert Kloefkorn - @brief Provides interfaces for detection of specific behavior -*/ + @author Robert Kloefkorn + @brief Provides interfaces for detection of specific behavior + */ namespace Dune { @@ -14,8 +14,8 @@ struct Cloneable { /** \brief Clones the object - * clone needs to be redefined by an implementation class, with the - * return type covariantly adapted. Remember to + * clone needs to be redefined by an implementation class, with the + * return type covariantly adapted. Remember to * delete the resulting pointer. */ virtual Cloneable* clone() const = 0; @@ -23,7 +23,7 @@ /** \brief Destructor */ virtual ~Cloneable() {} - + }; } // end namespace Dune diff -Nru dune-common-2.2.1/dune/common/ios_state.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/ios_state.cc --- dune-common-2.2.1/dune/common/ios_state.cc 2010-05-31 12:17:02.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/ios_state.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #include -namespace Dune{ +namespace Dune { ////////////////////////////////////////////////////////////////////// // diff -Nru dune-common-2.2.1/dune/common/ios_state.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/ios_state.hh --- dune-common-2.2.1/dune/common/ios_state.hh 2010-05-31 12:17:02.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/ios_state.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,11 +1,11 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_IOS_STATE_HH #define DUNE_COMMON_IOS_STATE_HH -#include +#include -namespace Dune{ +namespace Dune { /** @addtogroup Common * * @{ diff -Nru dune-common-2.2.1/dune/common/iteratorfacades.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/iteratorfacades.hh --- dune-common-2.2.1/dune/common/iteratorfacades.hh 2010-10-05 23:11:05.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/iteratorfacades.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,127 +1,131 @@ -// $Id: iteratorfacades.hh 6155 2010-10-05 23:11:05Z joe $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_ITERATORFACADES_HH #define DUNE_ITERATORFACADES_HH -#include -#include"typetraits.hh" + +#include +#include + +#include "typetraits.hh" namespace Dune { - /*! \defgroup IteratorFacades Iterator facades - \ingroup Common - - \brief Iterator facades for writing stl conformant iterators. - - With using these facades writing iterators for arbitrary containers becomes much less - cumbersome as only few functions have to be implemented. All other functions needed by - the stl are provided by the facades using the Barton-Nackman trick (also known as - curiously recurring template pattern). - - The following example illustrates how a random access iterator might be written: - - \code - #include - - ... - - template - class TestIterator : public Dune::BidirectionalIteratorFacade,T, T&, int> - { - friend class TestIterator::type, typename remove_const::type >; - friend class TestIterator::type, const typename remove_const::type >; - - public: - + /*! \defgroup IteratorFacades Iterator facades + \ingroup Common + + \brief Iterator facades for writing stl conformant iterators. + + With using these facades writing iterators for arbitrary containers becomes much less + cumbersome as only few functions have to be implemented. All other functions needed by + the stl are provided by the facades using the Barton-Nackman trick (also known as + curiously recurring template pattern). + + The following example illustrates how a random access iterator might be written: + + \code + #include + + ... + + template + class TestIterator : public Dune::BidirectionalIteratorFacade,T, T&, int> + { + friend class TestIterator::type, typename std::remove_const::type >; + friend class TestIterator::type, const typename std::remove_const::type >; + + public: + // Constructors needed by the facade iterators. TestIterator(): container_(0), position_(0) { } - + TestIterator(C& cont, int pos) : container_(&cont), position_(pos) {} - TestIterator(const TestIterator::type, typename remove_const::type >& other) + TestIterator(const TestIterator::type, typename std::remove_const::type >& other) : container_(other.container_), position_(other.position_) {} - - - TestIterator(const TestIterator::type, const typename remove_const::type >& other) + + + TestIterator(const TestIterator::type, const typename std::remove_const::type >& other) : container_(other.container_), position_(other.position_) {} - + // Methods needed by the forward iterator - bool equals(const TestIterator::type,typename remove_const::type>& other) const + bool equals(const TestIterator::type,typename std::remove_const::type>& other) const { return position_ == other.position_ && container_ == other.container_; } - - - bool equals(const TestIterator::type,const typename remove_const::type>& other) const + + + bool equals(const TestIterator::type,const typename std::remove_const::type>& other) const { return position_ == other.position_ && container_ == other.container_; } - + T& dereference() const { return container_->values_[position_]; } - + void increment() { - ++position_; + ++position_; } - + // Additional function needed by BidirectionalIterator void decrement() { --position_; } - + // Additional function needed by RandomAccessIterator T& elementAt(int i)const { return container_->operator[](position_+i); } - + void advance(int n) { position_=position_+n; } - std::ptrdiff_t distanceTo(TestIterator::type,const typename remove_const::type> other) const + std::ptrdiff_t distanceTo(TestIterator::type,const typename std::remove_const::type> other) const { assert(other.container_==container_); return other.position_ - position_; } - - std::ptrdiff_t distanceTo(TestIterator::type, typename remove_const::type> other) const + + std::ptrdiff_t distanceTo(TestIterator::type, typename std::remove_const::type> other) const { assert(other.container_==container_); return other.position_ - position_; } - private: + private: C *container_; size_t position_; - }; + }; + + \endcode + See dune/common/test/iteratorbase.hh for details. + */ - \endcode - See dune/common/test/iteratorbase.hh for details. - */ - - -/** - * @file - * @brief This file implements iterator facade classes for writing stl conformant iterators. - * - * With using these facades writing iterators for arbitrary containers becomes much less - * cumbersome as only few functions have to be implemented. All other functions needed by - * the stl are provided by the facades using the Barton-Nackman trick (also known as - * curiously recurring template pattern. - */ - /** @addtogroup IteratorFacades - * - * @{ - */ + /** + * @file + * @brief This file implements iterator facade classes for writing stl conformant iterators. + * + * With using these facades writing iterators for arbitrary containers becomes much less + * cumbersome as only few functions have to be implemented. All other functions needed by + * the stl are provided by the facades using the Barton-Nackman trick (also known as + * curiously recurring template pattern. + */ + + /** @addtogroup IteratorFacades + * + * @{ + */ /** * @brief Base class for stl conformant forward iterators. * @@ -132,18 +136,18 @@ */ template class ForwardIteratorFacade : - public std::iterator< std::forward_iterator_tag, - typename remove_const::type, // std::iterator needs mutable value type - D, - V*, - R> + public std::iterator< std::forward_iterator_tag, + typename std::remove_const::type, // std::iterator needs mutable value type + D, + V*, + R> { public: /** * @brief The type of derived iterator. * - * The iterator has to define following + * The iterator has to define following * functions have to be present: * * \code @@ -152,10 +156,13 @@ * Reference dereference() const; * * // Compare for equality with iterator j - * equals(i); + * bool equals(j); * * // position the iterator at the next element. * void increment() + * + * // check for equality with other iterator + * bool equals(other) * \endcode * * For an elaborate explanation see the @@ -177,12 +184,12 @@ * @brief The type of the difference between two positions. */ typedef D DifferenceType; - + /** * @brief The type of the reference to the values accessed. */ typedef R Reference; - + /** @brief Dereferencing operator. */ Reference operator*() const { @@ -221,12 +228,12 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator==(const ForwardIteratorFacade& lhs, - const ForwardIteratorFacade& rhs) + const ForwardIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return static_cast(lhs).equals(static_cast(rhs)); else return static_cast(rhs).equals(static_cast(lhs)); @@ -243,12 +250,12 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator!=(const ForwardIteratorFacade& lhs, - const ForwardIteratorFacade& rhs) + const ForwardIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return !static_cast(lhs).equals(static_cast(rhs)); else return !static_cast(rhs).equals(static_cast(lhs)); @@ -260,18 +267,18 @@ */ template class BidirectionalIteratorFacade : - public std::iterator< std::bidirectional_iterator_tag, - typename remove_const::type, // std::iterator needs mutable value type - D, - V*, - R> + public std::iterator< std::bidirectional_iterator_tag, + typename std::remove_const::type, // std::iterator needs mutable value type + D, + V*, + R> { public: /** * @brief The type of derived iterator. * - * The iterator has to define following + * The iterator has to define following * functions have to be present: * * \code @@ -284,7 +291,7 @@ * * // position the iterator at the next element. * void increment() - * + * * // position the iterator at the previous element. * void decrement() * @@ -309,12 +316,12 @@ * @brief The type of the difference between two positions. */ typedef D DifferenceType; - + /** * @brief The type of the reference to the values accessed. */ typedef R Reference; - + /** @brief Dereferencing operator. */ Reference operator*() const { @@ -341,7 +348,7 @@ return tmp; } - + /** @brief Preincrement operator. */ DerivedType& operator--() { @@ -366,10 +373,10 @@ * yield an invalid type expression. */ template - inline typename enable_if::exists,bool>::type + class T2, class V2, class R2> + inline typename std::enable_if::value,bool>::type operator==(const BidirectionalIteratorFacade& lhs, - const BidirectionalIteratorFacade& rhs) + const BidirectionalIteratorFacade& rhs) { return static_cast(lhs).equals(static_cast(rhs)); } @@ -383,10 +390,10 @@ * type expression. */ template + class T2, class V2, class R2> inline - typename enable_if::exists && !Conversion::exists, - bool>::type + typename std::enable_if::value && !std::is_convertible::value, + bool>::type operator==(const BidirectionalIteratorFacade& lhs, const BidirectionalIteratorFacade& rhs) { @@ -404,10 +411,10 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator!=(const BidirectionalIteratorFacade& lhs, - const BidirectionalIteratorFacade& rhs) + const BidirectionalIteratorFacade& rhs) { return !(lhs == rhs); } @@ -418,18 +425,18 @@ */ template class RandomAccessIteratorFacade : - public std::iterator< std::random_access_iterator_tag, - typename remove_const::type, // std::iterator needs mutable value type - D, - V*, - R> + public std::iterator< std::random_access_iterator_tag, + typename std::remove_const::type, // std::iterator needs mutable value type + D, + V*, + R> { public: /** * @brief The type of derived iterator. * - * The iterator has to define following + * The iterator has to define following * functions have to be present: * * \code @@ -440,7 +447,7 @@ * Reference elementAt(n) const; * * // Compare for equality with j - * equals(i); + * bool equals(j); * * // position the iterator at the next element. * void increment() @@ -451,7 +458,7 @@ * // advance the iterator by a number of positions- * void advance(DifferenceType n); * // calculate the distance to another iterator. - * // One should incorporate an assertion wether + * // One should incorporate an assertion whether * // the same containers are referenced * DifferenceType distanceTo(j) const; * \endcode @@ -475,12 +482,12 @@ * @brief The type of the difference between two positions. */ typedef D DifferenceType; - + /** * @brief The type of the reference to the values accessed. */ typedef R Reference; - + /** @brief Dereferencing operator. */ Reference operator*() const { @@ -522,7 +529,7 @@ static_cast(this)->advance(n); return *static_cast(this); } - + DerivedType operator+(DifferenceType n) const { DerivedType tmp(static_cast(*this)); @@ -551,7 +558,7 @@ static_cast(this)->advance(-n); return *static_cast(this); } - + DerivedType operator-(DifferenceType n) const { DerivedType tmp(static_cast(*this)); @@ -559,7 +566,7 @@ return tmp; } - + }; /** @@ -573,12 +580,12 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator==(const RandomAccessIteratorFacade& lhs, - const RandomAccessIteratorFacade& rhs) + const RandomAccessIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return static_cast(lhs).equals(static_cast(rhs)); else return static_cast(rhs).equals(static_cast(lhs)); @@ -595,12 +602,12 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator!=(const RandomAccessIteratorFacade& lhs, - const RandomAccessIteratorFacade& rhs) + const RandomAccessIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return !static_cast(lhs).equals(static_cast(rhs)); else return !static_cast(rhs).equals(static_cast(lhs)); @@ -617,18 +624,18 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator<(const RandomAccessIteratorFacade& lhs, - const RandomAccessIteratorFacade& rhs) + const RandomAccessIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return static_cast(lhs).distanceTo(static_cast(rhs))>0; else return static_cast(rhs).distanceTo(static_cast(lhs))<0; } - + /** * @brief Comparison operator. * @@ -640,12 +647,12 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator<=(const RandomAccessIteratorFacade& lhs, - const RandomAccessIteratorFacade& rhs) + const RandomAccessIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return static_cast(lhs).distanceTo(static_cast(rhs))>=0; else return static_cast(rhs).distanceTo(static_cast(lhs))<=0; @@ -663,12 +670,12 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator>(const RandomAccessIteratorFacade& lhs, - const RandomAccessIteratorFacade& rhs) + const RandomAccessIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return static_cast(lhs).distanceTo(static_cast(rhs))<0; else return static_cast(rhs).distanceTo(static_cast(lhs))>0; @@ -685,12 +692,12 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator>=(const RandomAccessIteratorFacade& lhs, - const RandomAccessIteratorFacade& rhs) + const RandomAccessIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return static_cast(lhs).distanceTo(static_cast(rhs))<=0; else return static_cast(rhs).distanceTo(static_cast(lhs))>=0; @@ -707,17 +714,17 @@ * */ template + class T2, class V2, class R2> inline typename EnableIfInterOperable::type operator-(const RandomAccessIteratorFacade& lhs, - const RandomAccessIteratorFacade& rhs) + const RandomAccessIteratorFacade& rhs) { - if(Conversion::exists) + if(std::is_convertible::value) return -static_cast(lhs).distanceTo(static_cast(rhs)); else return static_cast(rhs).distanceTo(static_cast(lhs)); } /** @} */ -} -#endif +} +#endif diff -Nru dune-common-2.2.1/dune/common/iteratorrange.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/iteratorrange.hh --- dune-common-2.2.1/dune/common/iteratorrange.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/iteratorrange.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,63 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_ITERATORRANGE_HH +#define DUNE_COMMON_ITERATORRANGE_HH + +namespace Dune { + + //! Simple range between a begin and an end iterator. + /** + * IteratorRange is mainly useful as a lightweight adaptor + * class when adding support for range-based for loops to + * existing containers that lack a standard begin(), end() + * pair of member functions. + * + * \tparam Iterator The type of iterator + */ + template + class IteratorRange + { + + public: + + //! The iterator belonging to this range. + typedef Iterator iterator; + + //! The iterator belonging to this range. + /** + * This typedef is here mainly for compatibility reasons. + */ + typedef Iterator const_iterator; + + //! Constructs an iterator range on [begin,end). + IteratorRange(const Iterator& begin, const Iterator& end) + : _begin(begin) + , _end(end) + {} + + //! Default constructor, relies on iterators being default-constructible. + IteratorRange() + {} + + //! Returns an iterator pointing to the begin of the range. + iterator begin() const + { + return _begin; + } + + //! Returns an iterator pointing past the end of the range. + iterator end() const + { + return _end; + } + + private: + + Iterator _begin; + Iterator _end; + + }; + +} + +#endif // DUNE_COMMON_ITERATORRANGE_HH diff -Nru dune-common-2.2.1/dune/common/lcm.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/lcm.hh --- dune-common-2.2.1/dune/common/lcm.hh 2011-03-28 12:34:55.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/lcm.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_LCM_HH #define DUNE_LCM_HH @@ -5,19 +7,18 @@ * \brief Statically compute the least common multiple of two integers */ -#include -#include +#include namespace Dune { - - /** - * @addtogroup Common + + /** + * @addtogroup Common * @{ */ /** * @file - * This file provides template constructs for calculation the + * This file provides template constructs for calculation the * least common multiple. */ @@ -29,8 +30,8 @@ { static void conceptCheck() { - dune_static_assert(0 #include +#include + /** @file @author Christian Engwer @brief LRU Cache Container, using an STL like interface -*/ + */ namespace Dune { -namespace { + namespace { -/* - hide the default traits in an empty namespace - */ -template > -struct _lru_default_traits -{ - typedef _Key key_type; - typedef _Alloc allocator; - typedef std::list< std::pair<_Key, _Tp> > list_type; - typedef typename list_type::iterator iterator; - typedef typename std::less cmp; - typedef std::map< key_type, iterator, cmp, - typename allocator::template rebind >::other > map_type; -}; - -} // end empty namespace - -/** - @brief LRU Cache Container - - Implementatation of an LRU (least recently used) cache - container. This implementation follows the approach presented in - http://aim.adc.rmit.edu.au/phd/sgreuter/papers/graphite2003.pdf - */ -template > -class lru -{ - typedef typename _Traits::list_type list_type; - typedef typename _Traits::map_type map_type; - typedef typename _Traits::allocator allocator; - typedef typename map_type::iterator map_iterator; + /* + hide the default traits in an empty namespace + */ + template > + struct _lru_default_traits + { + typedef _Key key_type; + typedef _Alloc allocator; + typedef std::list< std::pair<_Key, _Tp> > list_type; + typedef typename list_type::iterator iterator; + typedef typename std::less cmp; + typedef std::map< key_type, iterator, cmp, + typename allocator::template rebind >::other > map_type; + }; + + } // end empty namespace + + /** + @brief LRU Cache Container + + Implementation of an LRU (least recently used) cache + container. This implementation follows the approach presented in + http://aim.adc.rmit.edu.au/phd/sgreuter/papers/graphite2003.pdf + */ + template > + class lru + { + typedef typename _Traits::list_type list_type; + typedef typename _Traits::map_type map_type; + typedef typename _Traits::allocator allocator; + typedef typename map_type::iterator map_iterator; typedef typename map_type::const_iterator const_map_iterator; - -public: - typedef typename _Traits::key_type key_type; - typedef typename allocator::value_type value_type; - typedef typename allocator::pointer pointer; - typedef typename allocator::const_pointer const_pointer; + + public: + typedef typename _Traits::key_type key_type; + typedef typename allocator::value_type value_type; + typedef typename allocator::pointer pointer; + typedef typename allocator::const_pointer const_pointer; typedef typename allocator::const_reference const_reference; - typedef typename allocator::reference reference; - typedef typename allocator::size_type size_type; - typedef typename list_type::iterator iterator; - typedef typename list_type::const_iterator const_iterator; - + typedef typename allocator::reference reference; + typedef typename allocator::size_type size_type; + typedef typename list_type::iterator iterator; + typedef typename list_type::const_iterator const_iterator; + /** * Returns a read/write reference to the data of the most * recently used entry. */ reference front() { - return _data.front().second; + return _data.front().second; } /** @@ -75,7 +79,7 @@ */ const_reference front() const { - return _data.front().second; + return _data.front().second; } /** @@ -84,7 +88,7 @@ */ reference back() { - return _data.back().second; + return _data.back().second; } /** @@ -93,27 +97,27 @@ */ const_reference back (int i) const { - return _data.back().second; + return _data.back().second; } /** * @brief Removes the first element. */ - const void pop_front() + void pop_front() { - key_type k = _data.front().first; - _data.pop_front(); - _index.erase(k); + key_type k = _data.front().first; + _data.pop_front(); + _index.erase(k); } /** * @brief Removes the last element. */ - const void pop_back() + void pop_back() { - key_type k = _data.back().first; - _data.pop_back(); - _index.erase(k); + key_type k = _data.back().first; + _data.pop_back(); + _index.erase(k); } /** @@ -123,11 +127,11 @@ */ iterator find (const key_type & key) { - const map_iterator it = _index.find(key); - if (it == _index.end()) return _data.end(); - return it->second; + const map_iterator it = _index.find(key); + if (it == _index.end()) return _data.end(); + return it->second; } - + /** * @brief Finds the element whose key is k. * @@ -135,15 +139,16 @@ */ const_iterator find (const key_type & key) const { - const map_iterator it = _index.find(key); - if (it == _index.end()) return _data.end(); - return it->second; + const map_iterator it = _index.find(key); + if (it == _index.end()) return _data.end(); + return it->second; } /** * @brief Insert a value into the container * - * Stores value under key and marks it as most recent. + * Stores value under key and marks it as most recent. If this key + * is already present, the associated data is replaced. * * @param key associated with data * @param data to store @@ -152,13 +157,13 @@ */ reference insert (const key_type & key, const_reference data) { - std::pair x(key, data); - /* insert item as mru */ - iterator it = _data.insert(_data.begin(), x); - /* store index */ - _index.insert(std::make_pair(key,it)); + std::pair x(key, data); + /* insert item as mru */ + iterator it = _data.insert(_data.begin(), x); + /* store index */ + _index.insert(std::make_pair(key,it)); - return it->second; + return it->second; } /** @@ -166,58 +171,64 @@ */ reference insert (const key_type & key) { - return touch (key); + return touch (key); } /** - * @brief mark data associateed with key as most recent + * @brief mark data associated with key as most recent * * @return reference of stored data */ reference touch (const key_type & key) { - /* query _index for iterator */ - iterator it = _index[key]; - /* update _data - move it to the front - */ - _data.splice(_data.begin(), _data, it); - return it->second; + /* query _index for iterator */ + map_iterator it = _index.find(key); + if (it == _index.end()) + DUNE_THROW(Dune::RangeError, + "Failed to touch key " << key << ", it is not in the lru container"); + /* update _data + move it to the front + */ + _data.splice(_data.begin(), _data, it->second); + return it->second->second; } /** - * + * @brief Retrieve number of entries in the container */ size_type size() const { - return _data.size(); - } - + return _data.size(); + } + /** + * @brief ensure a maximum size of the container * + * If new_size is smaller than size the oldest elements are + * dropped. Otherwise nothing happens. */ void resize(size_type new_size) { - assert(new_size <= size()); + assert(new_size <= size()); - while (new_size < size()) - pop_back(); + while (new_size < size()) + pop_back(); } - + /** * */ void clear() { - _data.clear(); - _index.clear(); - } - -private: + _data.clear(); + _index.clear(); + } + + private: list_type _data; - map_type _index; - -}; + map_type _index; + + }; } // namespace Dune diff -Nru dune-common-2.2.1/dune/common/Makefile.am dune-common-2.5.2~20170808ga5c076ca/dune/common/Makefile.am --- dune-common-2.2.1/dune/common/Makefile.am 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -# $Id: Makefile.am 7077 2013-01-19 10:06:29Z mblatt $ - -SUBDIRS = . test parallel - -# the standard debug streams are put into the libdune -noinst_LTLIBRARIES = libcommon.la - -libcommon_la_SOURCES = \ - fmatrixev.cc \ - ios_state.cc \ - parametertree.cc \ - parametertreeparser.cc \ - path.cc \ - exceptions.cc \ - stdstreams.cc -libcommon_la_LIBADD = $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) - -commonincludedir = $(includedir)/dune/common -commoninclude_HEADERS = \ - alignment.hh \ - array.hh \ - arraylist.hh \ - bartonnackmanifcheck.hh \ - bigunsignedint.hh \ - binaryfunctions.hh \ - bitsetvector.hh \ - classname.hh \ - collectivecommunication.hh \ - debugstream.hh \ - deprecated.hh \ - densematrix.hh \ - densevector.hh \ - documentation.hh \ - dynmatrix.hh \ - dynvector.hh \ - enumset.hh \ - exceptions.hh \ - fassign.hh \ - finitestack.hh \ - float_cmp.cc \ - float_cmp.hh \ - fmatrix.hh \ - fmatrixev.hh \ - forloop.hh \ - ftraits.hh \ - function.hh \ - fvector.hh \ - gcd.hh \ - genericiterator.hh \ - geometrytype.hh \ - geometrytypeindex.hh \ - gmpfield.hh \ - indent.hh \ - interfaces.hh \ - ios_state.hh \ - iteratorfacades.hh \ - lcm.hh \ - lru.hh \ - math.hh \ - matvectraits.hh \ - misc.hh \ - mpicollectivecommunication.hh \ - mpiguard.hh \ - mpihelper.hh \ - mpitraits.hh \ - nullptr.hh \ - parametertree.hh \ - parametertreeparser.hh \ - path.hh \ - poolallocator.hh \ - precision.hh \ - propertymap.hh \ - reservedvector.hh \ - shared_ptr.hh \ - singleton.hh \ - sllist.hh \ - static_assert.hh \ - stdstreams.hh \ - timer.hh \ - tuples.hh \ - tupleutility.hh \ - typetraits.hh \ - unused.hh \ - version.hh - -include $(top_srcdir)/am/global-rules diff -Nru dune-common-2.2.1/dune/common/mallocallocator.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/mallocallocator.hh --- dune-common-2.2.1/dune/common/mallocallocator.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/mallocallocator.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,101 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_MALLOC_ALLOCATOR_HH +#define DUNE_MALLOC_ALLOCATOR_HH + +#include +#include +#include +#include +#include + +/** + * @file + * @brief Allocators that use malloc/free. + */ +namespace Dune +{ + /** + @ingroup Allocators + @brief Allocators implementation which simply calls malloc/free + */ + template + class MallocAllocator { + public: + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T value_type; + template struct rebind { + typedef MallocAllocator other; + }; + + //! create a new MallocAllocator + MallocAllocator() throw() {} + //! copy construct from an other MallocAllocator, possibly for a different result type + template + MallocAllocator(const MallocAllocator&) throw() {} + //! cleanup this allocator + ~MallocAllocator() throw() {} + + pointer address(reference x) const + { + return &x; + } + const_pointer address(const_reference x) const + { + return &x; + } + + //! allocate n objects of type T + pointer allocate(size_type n, + const void* hint = 0) + { + DUNE_UNUSED_PARAMETER(hint); + if (n > this->max_size()) + throw std::bad_alloc(); + + pointer ret = static_cast(std::malloc(n * sizeof(T))); + if (!ret) + throw std::bad_alloc(); + return ret; + } + + //! deallocate n objects of type T at address p + void deallocate(pointer p, size_type n) + { + DUNE_UNUSED_PARAMETER(n); + std::free(p); + } + + //! max size for allocate + size_type max_size() const throw() + { + return size_type(-1) / sizeof(T); + } + + //! copy-construct an object of type T (i.e. make a placement new on p) + void construct(pointer p, const T& val) + { + ::new((void*)p)T(val); + } + + //! construct an object of type T from variadic parameters + template + void construct(pointer p, _Args&&... __args) + { + ::new((void *)p)T(std::forward<_Args>(__args) ...); + } + + //! destroy an object of type T (i.e. call the destructor) + void destroy(pointer p) + { + p->~T(); + } + }; +} + +#endif // DUNE_MALLOC_ALLOCATOR_HH diff -Nru dune-common-2.2.1/dune/common/math.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/math.hh --- dune-common-2.2.1/dune/common/math.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/math.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=4 sts=2: +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_MATH_HH #define DUNE_MATH_HH @@ -8,13 +8,14 @@ */ #include +#include namespace Dune { /** \brief Provides commonly used mathematical constants. - + a struct that is specialized for types repesenting real or complex numbers. I provides commonly used mathematical constants with the required accuary for the specified type. @@ -28,10 +29,10 @@ This implementation will work with all built-in floating point types. It provides - * e as std::exp(1.0) - * pi as std::acos(-1.0) - - */ + * e as std::exp(1.0) + * pi as std::acos(-1.0) + + */ template< class T > struct StandardMathematicalConstants { @@ -55,7 +56,7 @@ template<> struct MathematicalConstants< float > - : public StandardMathematicalConstants< float > + : public StandardMathematicalConstants< float > {}; @@ -65,7 +66,7 @@ template<> struct MathematicalConstants< double > - : public StandardMathematicalConstants< double > + : public StandardMathematicalConstants< double > {}; @@ -75,10 +76,51 @@ template<> struct MathematicalConstants< long double > - : public StandardMathematicalConstants< long double > + : public StandardMathematicalConstants< long double > {}; #endif // DOXYGEN + + //! Calculates the factorial of m at compile time + template + struct Factorial + { + //! factorial stores m! + enum { factorial = m * Factorial::factorial }; + }; + + //! end of recursion of factorial via specialization + template <> + struct Factorial<0> + { + // 0! = 1 + enum { factorial = 1 }; + }; + + //! compute conjugate complex of x + // conjugate complex does nothing for non-complex types + template + inline K conjugateComplex (const K& x) + { + return x; + } + +#ifndef DOXYGEN + // specialization for complex + template + inline std::complex conjugateComplex (const std::complex& c) + { + return std::complex(c.real(),-c.imag()); + } +#endif + + //! Return the sign of the value + template + int sign(const T& val) + { + return (val < 0 ? -1 : 1); + } + } #endif // #ifndef DUNE_MATH_HH diff -Nru dune-common-2.2.1/dune/common/matvectraits.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/matvectraits.hh --- dune-common-2.2.1/dune/common/matvectraits.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/matvectraits.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,4 +1,5 @@ -// $Id: fvector.hh 5262 2008-09-07 09:03:38Z christi $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_MATVECTRAITS_HH #define DUNE_MATVECTRAITS_HH @@ -8,24 +9,24 @@ namespace Dune { -/** - @addtogroup DenseMatVec - \brief Type Traits to retrieve types associated with an implementation of Dune::DenseVector or Dune::DenseMatrix - - you have to specialize this class for every implementation of DenseVector or DenseMatrix. - - \code - //! export the type of the derived class (e.g. FieldVector) - typedef ... derived_type; - //! export the type of the stored values - typedef ... value_type; - //! export the type representing the size information - typedef ... size_type; - \endcode - -*/ -template -struct DenseMatVecTraits {}; + /** + @addtogroup DenseMatVec + \brief Type Traits to retrieve types associated with an implementation of Dune::DenseVector or Dune::DenseMatrix + + you have to specialize this class for every implementation of DenseVector or DenseMatrix. + + \code + //! export the type of the derived class (e.g. FieldVector) + typedef ... derived_type; + //! export the type of the stored values + typedef ... value_type; + //! export the type representing the size information + typedef ... size_type; + \endcode + + */ + template + struct DenseMatVecTraits {}; } // end namespace Dune diff -Nru dune-common-2.2.1/dune/common/misc.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/misc.hh --- dune-common-2.2.1/dune/common/misc.hh 2011-08-30 08:56:22.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/misc.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: -#ifndef MISC_HH -#define MISC_HH - -/** \file - \brief Miscellaneous helper stuff -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "exceptions.hh" -#include - -namespace Dune { - - -/** @addtogroup Common - - @{ - */ - -//! compute conjugate complex of x -// conjugate complex does nothing for non-complex types -template -inline K conjugateComplex (const K& x) -{ - return x; -} - -#ifndef DOXYGEN -// specialization for complex -template -inline std::complex conjugateComplex (const std::complex& c) -{ - return std::complex(c.real(),-c.imag()); -} -#endif - -//! Return the sign of the value -template -int sign(const T& val) -{ - return (val < 0 ? -1 : 1); -} - -/** \brief Compute the square of T */ -/** - * \code -#include - * \endcode - */ -template -T SQR (T t) -{ - return t*t; -} - -//! Calculates m^p at compile time -template -struct Power_m_p -{ - // power stores m^p - enum { power = (m * Power_m_p::power ) }; -}; - -//! end of recursion via specialization -template -struct Power_m_p< m , 0> -{ - // m^0 = 1 - enum { power = 1 }; -}; - -//! Calculates the factorial of m at compile time -template -struct Factorial -{ - //! factorial stores m! - enum { factorial = m * Factorial::factorial }; -}; - -//! end of recursion of factorial via specialization -template <> -struct Factorial<0> -{ - // 0! = 1 - enum { factorial = 1 }; -}; - -//******************************************************************** -// -// generate filenames with timestep number in it -// -//******************************************************************** - - /** \brief Generate filenames with timestep number in it */ -inline std::string genFilename(const std::string& path, - const std::string& fn, - int ntime, - int precision = 6) -{ - std::ostringstream name; - - if(path.size() > 0) - { - name << path; - name << "/"; - } - name << fn << std::setw(precision) << std::setfill('0') << ntime; - - // Return the string corresponding to the stringstream - return name.str(); -} - - -//******************************************************************** -// -// check whether a given container has a prefix/suffix -// -//******************************************************************** - -//! check whether a character container has a given prefix -/** - * The container must support the the begin() and size() methods. - */ -template -bool hasPrefix(const C& c, const char* prefix) { - std::size_t len = std::strlen(prefix); - return c.size() >= len && - std::equal(prefix, prefix+len, c.begin()); -} - -//! check whether a character container has a given suffix -/** - * The container must support the the begin() and size() methods and the - * const_iterator member type. - * - * \note This is slow for containers which don't have random access iterators. - * In the case of containers with bidirectional iterators, this - * slow-ness is unnecessary. - */ -template -bool hasSuffix(const C& c, const char* suffix) { - std::size_t len = std::strlen(suffix); - if(c.size() < len) return false; - typename C::const_iterator it = c.begin(); - std::advance(it, c.size() - len); - return std::equal(suffix, suffix+len, it); -} -/** @} */ - -} - - -#endif diff -Nru dune-common-2.2.1/dune/common/modules dune-common-2.5.2~20170808ga5c076ca/dune/common/modules --- dune-common-2.2.1/dune/common/modules 2007-01-25 19:09:38.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/modules 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/* This file determines the order how things appear in the doxygen - documentation within the dune-common module. It works like this: - - @defgroup commands appear only in this file here which is - parsed before the other files (because it is mentioned first - in the Doxyfile). - - Only @addtogroup is used in the code documentation. -*/ - - /** - @defgroup COGeometryType GeometryType - @ingroup Common - */ diff -Nru dune-common-2.2.1/dune/common/modules.txt dune-common-2.5.2~20170808ga5c076ca/dune/common/modules.txt --- dune-common-2.2.1/dune/common/modules.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/modules.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,9 @@ +/* This file determines the order how things appear in the doxygen + documentation within the dune-common module. It works like this: + + @defgroup commands appear only in this file here which is + parsed before the other files (because it is mentioned first + in the Doxyfile). + + Only @addtogroup is used in the code documentation. +*/ diff -Nru dune-common-2.2.1/dune/common/mpicollectivecommunication.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/mpicollectivecommunication.hh --- dune-common-2.2.1/dune/common/mpicollectivecommunication.hh 2012-05-02 09:53:42.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/mpicollectivecommunication.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,306 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -#ifndef DUNE_MPICOLLECTIVECOMMUNICATION_HH -#define DUNE_MPICOLLECTIVECOMMUNICATION_HH - -/*! - \file - \ingroup ParallelCommunication - */ - -#include -#include -#include -#include - -#include"exceptions.hh" -#include"collectivecommunication.hh" -#include"binaryfunctions.hh" -#include"shared_ptr.hh" -#include"mpitraits.hh" - -#if HAVE_MPI -// MPI header -#include - -namespace Dune -{ - - //======================================================= - // use singleton pattern and template specialization to - // generate MPI operations - //======================================================= - - template - class Generic_MPI_Op - { - - public: - static MPI_Op get () - { - if (!op) - { - op = shared_ptr(new MPI_Op); - MPI_Op_create((void (*)(void*, void*, int*, MPI_Datatype*))&operation,true,op.get()); - } - return *op; - } - private: - static void operation (Type *in, Type *inout, int *len, MPI_Datatype *dptr) - { - BinaryFunction func; - - for (int i=0; i< *len; ++i, ++in, ++inout){ - Type temp; - temp = func(*in, *inout); - *inout = temp; - } - } - Generic_MPI_Op () {} - Generic_MPI_Op (const Generic_MPI_Op& ) {} - static shared_ptr op; - }; - - - template - shared_ptr Generic_MPI_Op::op = shared_ptr(static_cast(0)); - -#define ComposeMPIOp(type,func,op) \ - template<> \ - class Generic_MPI_Op >{ \ - public:\ - static MPI_Op get(){ \ - return op; \ - } \ - private:\ - Generic_MPI_Op () {}\ - Generic_MPI_Op (const Generic_MPI_Op& ) {}\ - } - - - ComposeMPIOp(char, std::plus, MPI_SUM); - ComposeMPIOp(unsigned char, std::plus, MPI_SUM); - ComposeMPIOp(short, std::plus, MPI_SUM); - ComposeMPIOp(unsigned short, std::plus, MPI_SUM); - ComposeMPIOp(int, std::plus, MPI_SUM); - ComposeMPIOp(unsigned int, std::plus, MPI_SUM); - ComposeMPIOp(long, std::plus, MPI_SUM); - ComposeMPIOp(unsigned long, std::plus, MPI_SUM); - ComposeMPIOp(float, std::plus, MPI_SUM); - ComposeMPIOp(double, std::plus, MPI_SUM); - ComposeMPIOp(long double, std::plus, MPI_SUM); - - ComposeMPIOp(char, std::multiplies, MPI_PROD); - ComposeMPIOp(unsigned char, std::multiplies, MPI_PROD); - ComposeMPIOp(short, std::multiplies, MPI_PROD); - ComposeMPIOp(unsigned short, std::multiplies, MPI_PROD); - ComposeMPIOp(int, std::multiplies, MPI_PROD); - ComposeMPIOp(unsigned int, std::multiplies, MPI_PROD); - ComposeMPIOp(long, std::multiplies, MPI_PROD); - ComposeMPIOp(unsigned long, std::multiplies, MPI_PROD); - ComposeMPIOp(float, std::multiplies, MPI_PROD); - ComposeMPIOp(double, std::multiplies, MPI_PROD); - ComposeMPIOp(long double, std::multiplies, MPI_PROD); - - ComposeMPIOp(char, Min, MPI_MIN); - ComposeMPIOp(unsigned char, Min, MPI_MIN); - ComposeMPIOp(short, Min, MPI_MIN); - ComposeMPIOp(unsigned short, Min, MPI_MIN); - ComposeMPIOp(int, Min, MPI_MIN); - ComposeMPIOp(unsigned int, Min, MPI_MIN); - ComposeMPIOp(long, Min, MPI_MIN); - ComposeMPIOp(unsigned long, Min, MPI_MIN); - ComposeMPIOp(float, Min, MPI_MIN); - ComposeMPIOp(double, Min, MPI_MIN); - ComposeMPIOp(long double, Min, MPI_MIN); - - ComposeMPIOp(char, Max, MPI_MAX); - ComposeMPIOp(unsigned char, Max, MPI_MAX); - ComposeMPIOp(short, Max, MPI_MAX); - ComposeMPIOp(unsigned short, Max, MPI_MAX); - ComposeMPIOp(int, Max, MPI_MAX); - ComposeMPIOp(unsigned int, Max, MPI_MAX); - ComposeMPIOp(long, Max, MPI_MAX); - ComposeMPIOp(unsigned long, Max, MPI_MAX); - ComposeMPIOp(float, Max, MPI_MAX); - ComposeMPIOp(double, Max, MPI_MAX); - ComposeMPIOp(long double, Max, MPI_MAX); - -#undef ComposeMPIOp - - - //======================================================= - // use singleton pattern and template specialization to - // generate MPI operations - //======================================================= - - /*! \brief Specialization of CollectiveCommunication for MPI - \ingroup ParallelCommunication - */ - template<> - class CollectiveCommunication - { - public: - //! Instantiation using a MPI communicator - CollectiveCommunication (const MPI_Comm& c) - : communicator(c) - { - if(communicator!=MPI_COMM_NULL){ - MPI_Comm_rank(communicator,&me); - MPI_Comm_size(communicator,&procs); - }else{ - procs=0; - me=-1; - } - } - - //! @copydoc CollectiveCommunication::rank - int rank () const - { - return me; - } - - //! @copydoc CollectiveCommunication::size - int size () const - { - return procs; - } - - //! @copydoc CollectiveCommunication::sum - template - T sum (T& in) const // MPI does not know about const :-( - { - T out; - allreduce >(&in,&out,1); - return out; - } - - //! @copydoc CollectiveCommunication::sum - template - int sum (T* inout, int len) const - { - return allreduce >(inout,len); - } - - //! @copydoc CollectiveCommunication::prod - template - T prod (T& in) const // MPI does not know about const :-( - { - T out; - allreduce >(&in,&out,1); - return out; - } - - //! @copydoc CollectiveCommunication::prod - template - int prod (T* inout, int len) const - { - return allreduce >(inout,len); - } - - //! @copydoc CollectiveCommunication::min - template - T min (T& in) const // MPI does not know about const :-( - { - T out; - allreduce >(&in,&out,1); - return out; - } - - //! @copydoc CollectiveCommunication::min - template - int min (T* inout, int len) const - { - return allreduce >(inout,len); - } - - - //! @copydoc CollectiveCommunication::max - template - T max (T& in) const // MPI does not know about const :-( - { - T out; - allreduce >(&in,&out,1); - return out; - } - - //! @copydoc CollectiveCommunication::max - template - int max (T* inout, int len) const - { - return allreduce >(inout,len); - } - - //! @copydoc CollectiveCommunication::barrier - int barrier () const - { - return MPI_Barrier(communicator); - } - - //! @copydoc CollectiveCommunication::broadcast - template - int broadcast (T* inout, int len, int root) const - { - return MPI_Bcast(inout,len,MPITraits::getType(),root,communicator); - } - - //! @copydoc CollectiveCommunication::gather() - template - int gather (T* in, T* out, int len, int root) const // note out must have space for P*len elements - { - return MPI_Gather(in,len,MPITraits::getType(), - out,len,MPITraits::getType(), - root,communicator); - } - - //! @copydoc CollectiveCommunication::scatter() - template - int scatter (T* send, T* recv, int len, int root) const // note out must have space for P*len elements - { - return MPI_Scatter(send,len,MPITraits::getType(), - recv,len,MPITraits::getType(), - root,communicator); - } - - operator MPI_Comm () const - { - return communicator; - } - - //! @copydoc CollectiveCommunication::allgather() - template - int allgather(T* sbuf, int count, T1* rbuf) const - { - return MPI_Allgather(sbuf, count, MPITraits::getType(), - rbuf, count, MPITraits::getType(), - communicator); - } - - //! @copydoc CollectiveCommunication::allreduce(Type* inout,int len) const - template - int allreduce(Type* inout, int len) const - { - Type* out = new Type[len]; - int ret = allreduce(inout,out,len); - std::copy(out, out+len, inout); - delete[] out; - return ret; - } - - //! @copydoc CollectiveCommunication::allreduce(Type* in,Type* out,int len) const - template - int allreduce(Type* in, Type* out, int len) const - { - return MPI_Allreduce(in, out, len, MPITraits::getType(), - (Generic_MPI_Op::get()),communicator); - } - - private: - MPI_Comm communicator; - int me; - int procs; - }; -} // namespace dune - -#endif -#endif diff -Nru dune-common-2.2.1/dune/common/mpiguard.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/mpiguard.hh --- dune-common-2.2.1/dune/common/mpiguard.hh 2010-08-25 16:43:06.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/mpiguard.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=8 sw=4 sts=4: - -/** - * @file - * @brief Implements a MPIGuard which detects an error on a remote process - * @author Christian Engwer - * @ingroup ParallelCommunication - */ - -#ifndef DUNE_COMMON_MPIGUARD_HH -#define DUNE_COMMON_MPIGUARD_HH - -#include -#include -#include -#include - -namespace Dune -{ - -#ifndef DOXYGEN - - /* - Interface class for the communication needed by MPIGuard - */ - struct GuardCommunicator - { - // cleanup - virtual ~GuardCommunicator() {}; - // all the communication methods we need - virtual int rank() = 0; - virtual int size() = 0; - virtual int sum(int i) = 0; - // create a new GuardCommunicator pointer - template - static GuardCommunicator * create(const C & c); - }; - - namespace { - /* - templated implementation of different communication classes - */ - // the default class will always fail, due to the missing implementation of "sum" - template - struct GenericGuardCommunicator - : public GuardCommunicator - {}; - // specialization for CollectiveCommunication - template - struct GenericGuardCommunicator< CollectiveCommunication > - : public GuardCommunicator - { - const CollectiveCommunication comm; - GenericGuardCommunicator(const CollectiveCommunication & c) : - comm(c) {} - virtual int rank() { return comm.rank(); }; - virtual int size() { return comm.size(); }; - virtual int sum(int i) { return comm.sum(i); } - }; - -#if HAVE_MPI - // specialization for MPI_Comm - template <> - struct GenericGuardCommunicator - : public GenericGuardCommunicator< CollectiveCommunication > - { - GenericGuardCommunicator(const MPI_Comm & c) : - GenericGuardCommunicator< CollectiveCommunication >( - CollectiveCommunication(c)) {} - }; -#endif - } // anonymous namespace - - template - GuardCommunicator * GuardCommunicator::create(const C & comm) - { - return new GenericGuardCommunicator(comm); - } -#endif - - /*! @brief This exception is thrown if the MPIGuard detects an error on a remote process - @ingroup ParallelCommunication - */ - class MPIGuardError : public ParallelError {}; - - /*! @brief detects a thrown exception and communicates to all other processes - @ingroup ParallelCommunication - - @code - { - MPIGuard guard(...); - - do_something(); - - // tell the guard that you successfully passed a critical operation - guard.finalize(); - // reactivate the guard for the next critical operation - guard.reactivate(); - - int result = do_something_else(); - - // tell the guard the result of your operation - guard.finalize(result == success); - } - @endcode - - You create a MPIGuard object. If an exception is risen on a - process the MPIGuard detects the exception, because the finalize - method was not called. when reaching the finalize call all - other processes are informed that an error occured and the - MPIGuard throws an exception of type MPIGuardError. - - @note You can initialize the MPIGuard from different types of communication objects: - - MPIHelper - - CollectiveCommunication - - MPI_Comm - */ - class MPIGuard - { - GuardCommunicator * comm_; - bool active_; - - // we don't want to copy this class - MPIGuard (const MPIGuard &); - - public: - /*! @brief create an MPIGuard operating on the Communicator of the global Dune::MPIHelper - - @param active should the MPIGuard be active upon creation? - */ - MPIGuard (bool active=true) : - comm_(GuardCommunicator::create( - MPIHelper::getCollectiveCommunication())), - active_(active) - {} - - /*! @brief create an MPIGuard operating on the Communicator of a special Dune::MPIHelper m - - @param m a reference to an MPIHelper - @param active should the MPIGuard be active upon creation? - */ - MPIGuard (MPIHelper & m, bool active=true) : - comm_(GuardCommunicator::create( - m.getCollectiveCommunication())), - active_(active) - {} - - /*! @brief create an MPIGuard operating on an arbitrary communicator. - - Supported types for the communication object are: - - MPIHelper - - CollectiveCommunication - - MPI_Comm - - @param comm reference to a communication object - @param active should the MPIGuard be active upon creation? - */ - template - MPIGuard (const C & comm, bool active=true) : - comm_(GuardCommunicator::create(comm)), - active_(active) - {} - - /*! @brief destroy the guard and check for undetected exceptions - */ - ~MPIGuard() - { - if (active_) - { - active_ = false; - finalize(false); - } - delete comm_; - } - - /*! @brief reactivate the guard. - - If the guard is still active finalize(true) is called first. - */ - void reactivate() { - if (active_ == true) - finalize(); - active_ = true; - } - - /*! @brief stop the guard. - - If no success parameter is passed, the guard assumes that - everything worked as planned. All errors are communicated - and an exception of type MPIGuardError is thrown if an error - (or exception) occured on any of the processors in the - communicator. - - @param success inform the guard about possible errors - */ - void finalize(bool success = true) - { - int result = success?0:1; - bool was_active = active_; - active_ = false; - result = comm_->sum(result); - if (result>0 && was_active) - { - DUNE_THROW(MPIGuardError, "Terminating process " - << comm_->rank() << " due to " - << result << " remote error(s)"); - } - } - }; - -} - -#endif // DUNE_COMMON_MPIGUARD_HH diff -Nru dune-common-2.2.1/dune/common/mpihelper.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/mpihelper.hh --- dune-common-2.2.1/dune/common/mpihelper.hh 2011-03-28 12:34:55.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/mpihelper.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,288 +0,0 @@ -// $Id: $ -#ifndef DUNE_MPIHELPER -#define DUNE_MPIHELPER - -#include -#include"collectivecommunication.hh" -#if HAVE_MPI -#include"mpi.h" -#include"mpicollectivecommunication.hh" -#endif - -#include "stdstreams.hh" - -namespace Dune -{ - /** - * @file - * @brief Helpers for dealing with MPI. - * - * @ingroup ParallelCommunication - * - * Basically there are two helpers available: - *
- *
FakeMPIHelper
- *
A class adhering to the interface of MPIHelper - * that does not need MPI at all. This can be used - * to create a sequential program even if MPI is - * used to compile it. - *
- *
MPIHelper
- *
A real MPI helper. When the singleton - * gets instantiated MPI_Init will be - * called and before the program exits - * MPI_Finalize will be called. - *
- *
- * - * Example of who to use these classes: - * - * A program that is parallel if compiled with MPI - * and sequential otherwise: - * \code - * int main(int argc, char** argv){ - * typedef Dune::MPIHelper MPIHelper; - * MPIHelper::instance(argc, argv); - * typename MPIHelper::MPICommunicator world = - * MPIHelper::getCommunicator(); - * ... - * \endcode - * - * If one wants to have sequential program even if the code is - * compiled with mpi then one simply has to exchange the typedef - * with \code typedef Dune::MPIHelper FakeMPIHelper; \endcode. - * - * For checking whether we really use MPI or just fake please use - * MPIHelper::isFake (this is also possible at compile time!) - */ - /** - * @brief A fake mpi helper. - * - * This helper can be used if no MPI is available - * or one wants to run sequentially even if MPI is - * available and used. - */ - class FakeMPIHelper - { - public: - enum{ - /** - * @brief Are we fake (i.e. pretend to have MPI support but are compiled - * without.) - */ - isFake = true - }; - - /** - * @brief The type of the mpi communicator. - */ - typedef No_Comm MPICommunicator; - - /** \brief get the default communicator - * - * Return a communicator to exchange data with all processes - * - * \returns a fake communicator - */ - static MPICommunicator getCommunicator () - { - static MPICommunicator comm; - return comm; - } - - /** \brief get a local communicator - * - * Returns a communicator to communicate with the local process only - * - * \returns a fake communicator - */ - static MPICommunicator getLocalCommunicator () - { - return getCommunicator(); - } - - - - static CollectiveCommunication - getCollectiveCommunication() - { - return CollectiveCommunication(getCommunicator()); - } - - /** - * @brief Get the singleton instance of the helper. - * - * This method has to be called with the same arguments - * that the main method of the program was called: - * \code - * int main(int argc, char** argv){ - * MPIHelper::instance(argc, argv); - * // program code comes here - * ... - * } - * \endcode - * @param argc The number of arguments provided to main. - * @param argv The arguments provided to main. - */ - static FakeMPIHelper& instance(int argc, char** argv) - { - // create singleton instance - static FakeMPIHelper singleton; - return singleton; - } - - /** - * @brief return rank of process, i.e. zero - */ - int rank () const { return 0; } - /** - * @brief return rank of process, i.e. one - */ - int size () const { return 1; } - - private: - FakeMPIHelper() {} - FakeMPIHelper(const FakeMPIHelper&); - FakeMPIHelper& operator=(const FakeMPIHelper); - }; - -#if HAVE_MPI - /** - * @brief A real mpi helper. - * @ingroup ParallelCommunication - * - * This helper should be used for parallel programs. - */ - class MPIHelper - { - public: - enum{ - /** - * @brief Are we fake (i. e. pretend to have MPI support but are compiled - * without. - */ - isFake = false - }; - - /** - * @brief The type of the mpi communicator. - */ - typedef MPI_Comm MPICommunicator; - - /** \brief get the default communicator - * - * Return a communicator to exchange data with all processes - * - * \returns MPI_COMM_WORLD - */ - static MPICommunicator getCommunicator () - { - return MPI_COMM_WORLD; - } - - /** \brief get a local communicator - * - * Returns a communicator to exchange data with the local process only - * - * \returns MPI_COMM_SELF - */ - static MPICommunicator getLocalCommunicator () - { - return MPI_COMM_SELF; - } - - static CollectiveCommunication - getCollectiveCommunication() - { - return CollectiveCommunication(getCommunicator()); - } - /** - * @brief Get the singleton instance of the helper. - * - * This method has to be called with the same arguments - * that the main method of the program was called: - * \code - * int main(int argc, char** argv){ - * MPIHelper::instance(argc, argv); - * // program code comes here - * ... - * } - * \endcode - * @param argc The number of arguments provided to main. - * @param argv The arguments provided to main. - */ - static MPIHelper& instance(int& argc, char**& argv) - { - // create singleton instance - static MPIHelper singleton (argc, argv); - return singleton; - } - - /** - * @brief return rank of process - */ - int rank () const { return rank_; } - /** - * @brief return number of processes - */ - int size () const { return size_; } - - private: - int rank_; - int size_; - void prevent_warning(int){} - - //! \brief calls MPI_Init with argc and argv as parameters - MPIHelper(int& argc, char**& argv) - { -#if MPI_2 - int wasInitialized = -1; - MPI_Initialized( &wasInitialized ); - if(!wasInitialized) -#endif - { - rank_ = -1; - size_ = -1; - static int is_initialized = MPI_Init(&argc, &argv); - prevent_warning(is_initialized); - } - - MPI_Comm_rank(MPI_COMM_WORLD,&rank_); - MPI_Comm_size(MPI_COMM_WORLD,&size_); - - assert( rank_ >= 0 ); - assert( size_ >= 1 ); - - dverb << "Called MPI_Init on p=" << rank_ << "!" << std::endl; - } - //! \brief calls MPI_Finalize - ~MPIHelper() - { -#ifdef MPI_2 - int wasFinalized = -1; - MPI_Finalized( &wasFinalized ); - if(!wasFinalized){ -#endif - MPI_Finalize(); - dverb << "Called MPI_Finalize on p=" << rank_ << "!" < - -namespace Dune -{ - /** @addtogroup ParallelCommunication - * - * @{ - */ - /** - * @file - * @brief Traits classes for mapping types onto MPI_Datatype. - * @author Markus Blatt - */ - -#if HAVE_MPI - /** - * @brief A traits class describing the mapping of types onto MPI_Datatypes. - * - * Specializations exist for the default types. - * Specializations should provide a static method - * \code - * static MPI_Datatype getType(); - * \endcode - */ - template - struct MPITraits - { - private: - MPITraits(){} - MPITraits(const MPITraits&){} - static MPI_Datatype datatype; - static MPI_Datatype vectortype; - public: - static inline MPI_Datatype getType() - { - if(datatype==MPI_DATATYPE_NULL){ - MPI_Type_contiguous(sizeof(T),MPI_BYTE,&datatype); - MPI_Type_commit(&datatype); - } - return datatype; - } - - }; - template - MPI_Datatype MPITraits::datatype = MPI_DATATYPE_NULL; - -#ifndef DOXYGEN -#if HAVE_MPI - - // A Macro for defining traits for the primitive data types -#define ComposeMPITraits(p,m) \ - template<> \ - struct MPITraits

{ \ - static inline MPI_Datatype getType(){ \ - return m; \ - } \ - } - - ComposeMPITraits(char, MPI_CHAR); - ComposeMPITraits(unsigned char,MPI_UNSIGNED_CHAR); - ComposeMPITraits(short,MPI_SHORT); - ComposeMPITraits(unsigned short,MPI_UNSIGNED_SHORT); - ComposeMPITraits(int,MPI_INT); - ComposeMPITraits(unsigned int,MPI_UNSIGNED); - ComposeMPITraits(long,MPI_LONG); - ComposeMPITraits(unsigned long,MPI_UNSIGNED_LONG); - ComposeMPITraits(float,MPI_FLOAT); - ComposeMPITraits(double,MPI_DOUBLE); - ComposeMPITraits(long double,MPI_LONG_DOUBLE); - - -#undef ComposeMPITraits - - template class FieldVector; - - template - struct MPITraits > - { - static MPI_Datatype datatype; - static MPI_Datatype vectortype; - - static inline MPI_Datatype getType() - { - if(datatype==MPI_DATATYPE_NULL){ - MPI_Type_contiguous(n, MPITraits::getType(), &vectortype); - MPI_Type_commit(&vectortype); - FieldVector fvector; - MPI_Aint base; - MPI_Aint displ; - MPI_Address(&fvector, &base); - MPI_Address(&(fvector[0]), &displ); - displ -= base; - int length[1]={1}; - - MPI_Type_struct(1, length, &displ, &vectortype, &datatype); - MPI_Type_commit(&datatype); - } - return datatype; - } - - }; - - template - MPI_Datatype MPITraits >::datatype = MPI_DATATYPE_NULL; - template - MPI_Datatype MPITraits >::vectortype = {MPI_DATATYPE_NULL}; - - - template - class bigunsignedint; - - template - struct MPITraits > - { - static MPI_Datatype datatype; - static MPI_Datatype vectortype; - - static inline MPI_Datatype getType() - { - if(datatype==MPI_DATATYPE_NULL){ - MPI_Type_contiguous(bigunsignedint::n, MPITraits::getType(), - &vectortype); - //MPI_Type_commit(&vectortype); - bigunsignedint data; - MPI_Aint base; - MPI_Aint displ; - MPI_Address(&data, &base); - MPI_Address(&(data.digit), &displ); - displ -= base; - int length[1]={1}; - MPI_Type_struct(1, length, &displ, &vectortype, &datatype); - MPI_Type_commit(&datatype); - } - return datatype; - } - }; -} - -namespace Dune -{ - template - MPI_Datatype MPITraits >::datatype = MPI_DATATYPE_NULL; - template - MPI_Datatype MPITraits >::vectortype = MPI_DATATYPE_NULL; - - template - struct MPITraits > - { - public: - inline static MPI_Datatype getType(); - private: - static MPI_Datatype type; - }; - template - MPI_Datatype MPITraits >::getType() - { - if(type==MPI_DATATYPE_NULL){ - int length[4]; - MPI_Aint disp[4]; - MPI_Datatype types[4] = {MPI_LB, MPITraits::getType(), - MPITraits::getType(), MPI_UB}; - std::pair rep[2]; - length[0]=length[1]=length[2]=length[3]=1; - MPI_Address(rep, disp); // lower bound of the datatype - MPI_Address(&(rep[0].first), disp+1); - MPI_Address(&(rep[0].second), disp+2); - MPI_Address(rep+1, disp+3); // upper bound of the datatype - for(int i=3; i >= 0; --i) - disp[i] -= disp[0]; - MPI_Type_struct(4, length, disp, types, &type); - MPI_Type_commit(&type); - } - return type; - } - - template - MPI_Datatype MPITraits >::type=MPI_DATATYPE_NULL; -#endif -#endif -#endif - /** @} */ -} - -#endif diff -Nru dune-common-2.2.1/dune/common/nullptr.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/nullptr.hh --- dune-common-2.2.1/dune/common/nullptr.hh 2011-09-06 17:04:07.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/nullptr.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,55 +1,14 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_NULLPTR_HH #define DUNE_NULLPTR_HH -/** \file - * \brief Fallback implementation of the nullptr object in C++0x - */ - -#if ! HAVE_NULLPTR - -/** - \brief Fallback implementation of nullptr - - see C++ proposal - http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf - */ -const // this is a const object... -class dune_nullptr_t { // of type nullptr_t -public: - template // convertible to any type - operator T*() const // of null non-member - { return 0; } // pointer... - template // or any type of null - operator T C::*() const // member pointer... - { return 0; } -private: - void operator&() const; // whose address can't be taken -} nullptr = {}; // and whose name is nullptr - -namespace Dune { - typedef dune_nullptr_t nullptr_t; -} - -template -bool operator == (T* t, dune_nullptr_t) -{ - return (t == static_cast(nullptr)); -} - -template -bool operator == (dune_nullptr_t, T* t) -{ - return (t == static_cast(nullptr)); -} - -#else - #include namespace Dune { - using std::nullptr_t; + using std::nullptr_t; } -#endif // HAVE_NULLPTR +#warning The header dune/common/nullptr.hh is deprecated. Just remove the include. #endif // DUNE_NULLPTR_HH diff -Nru dune-common-2.2.1/dune/common/overloadset.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/overloadset.hh --- dune-common-2.2.1/dune/common/overloadset.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/overloadset.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,174 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_OVERLOADSET_HH +#define DUNE_COMMON_OVERLOADSET_HH + +#include +#include + +#include + + + +namespace Dune { + +namespace Impl { + + // This overload set derives from + // all passed functions. Since we + // cannot do argument pack expansion + // on using statements this is done recursively. + template + class OverloadSet: public OverloadSet, F0 + { + using Base = OverloadSet; + public: + + template + OverloadSet(FF0&& f0, FF&&... ff) : + Base(std::forward(ff)...), + F0(std::forward(f0)) + {} + + // pull in operator() of F0 and of all F... via the base class + using F0::operator(); + using Base::operator(); + }; + + template + class OverloadSet: public F0 + { + public: + + template + OverloadSet(FF0&& f0) : + F0(std::forward(f0)) + {} + + // pull in operator() of F0 + using F0::operator(); + }; + +} // end namespace Impl + + + +/** + * \brief Create an overload set + * + * \tparam F List of function object types + * \param f List of function objects + * + * This returns an object that contains all + * operator() implementations of the passed + * functions. All those are available when + * calling operator() of the returned object. + * + * The returned object derives from + * those implementations such that it contains + * all operator() implementations in its + * overload set. When calling operator() + * this will select the best overload. + * If multiple overload are equally good this + * will lead to ambiguity. + * + * Notice that the passed function objects are + * stored by value and must be copy-constructible. + */ +template +auto overload(F&&... f) +{ + return Impl::OverloadSet...>(std::forward(f)...); +} + + + +namespace Impl { + + template + class OrderedOverloadSet: public OrderedOverloadSet, F0 + { + using Base = OrderedOverloadSet; + public: + + template + OrderedOverloadSet(FF0&& f0, FF&&... ff) : + Base(std::forward(ff)...), + F0(std::forward(f0)) + {} + + // Forward to operator() of F0 if it can be called with the given arguments. + template::value, int> = 0> + decltype(auto) operator()(Args&&... args) + { + return F0::operator()(std::forward(args)...); + } + + // Forward to operator() of base class if F0 cannot be called with the given + // arguments. In this case the base class will successively try operator() + // of all F... . + template::value, int> = 0> + decltype(auto) operator()(Args&&... args) + { + return Base::operator()(std::forward(args)...); + } + + }; + + template + class OrderedOverloadSet: public F0 + { + public: + + template + OrderedOverloadSet(FF0&& f0) : + F0(std::forward(f0)) + {} + + // Forward to operator() of F0. If it cannot be called with + // the given arguments a static assertion will fail. + template + decltype(auto) operator()(Args&&... args) + { + static_assert(Std::is_callable::value, "No matching overload found in OrderedOverloadSet"); + return F0::operator()(std::forward(args)...); + } + }; + +} // end namespace Impl + + + +/** + * \brief Create an ordered overload set + * + * \tparam F List of function object types + * \param f List of function objects + * + * This returns an object that contains all + * operator() implementations of the passed + * functions. All those are available when + * calling operator() of the returned object. + * + * In contrast to overload() these overloads + * are ordered in the sense that the first + * matching overload for the given arguments + * is selected and later ones are ignored. + * Hence such a call is never ambiguous. + * + * Notice that the passed function objects are + * stored by value and must be copy-constructible. + */ +template +auto orderedOverload(F&&... f) +{ + return Impl::OrderedOverloadSet...>(std::forward(f)...); +} + + + +} // end namespace Dune + +#endif // DUNE_COMMON_OVERLOADSET_HH diff -Nru dune-common-2.2.1/dune/common/parallel/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/CMakeLists.txt --- dune-common-2.2.1/dune/common/parallel/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,20 @@ +add_subdirectory(test) + +#install headers +install(FILES + collectivecommunication.hh + communicator.hh + indexset.hh + indicessyncer.hh + interface.hh + localindex.hh + mpicollectivecommunication.hh + mpiguard.hh + mpihelper.hh + mpitraits.hh + plocalindex.hh + remoteindices.hh + selection.hh + variablesizecommunicator.hh + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common/parallel) + diff -Nru dune-common-2.2.1/dune/common/parallel/collectivecommunication.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/collectivecommunication.hh --- dune-common-2.2.1/dune/common/parallel/collectivecommunication.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/collectivecommunication.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,381 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COLLECTIVECOMMUNICATION_HH +#define DUNE_COLLECTIVECOMMUNICATION_HH +/*! + \file + \brief Implements an utility class that provides + collective communication methods for sequential programs. + + \ingroup ParallelCommunication + */ +#include +#include +#include + +#include +#include + +/*! \defgroup ParallelCommunication Parallel Communication + \ingroup Common + + \brief Abstractions for paralle computing + + Dune offers an abstraction to the basic methods of parallel + communication. It allows one to switch parallel features on and off, + without changing the code. This is done using either CollectiveCommunication + or MPICollectiveCommunication. + + */ + +/*! + \file + \brief An abstraction to the basic methods of parallel communication, + following the message-passing paradigm. + \ingroup ParallelCommunication + */ + +namespace Dune +{ + + /* define some type that definitely differs from MPI_Comm */ + struct No_Comm {}; + + + /*! @brief Collective communication interface and sequential default implementation + + CollectiveCommunication offers an abstraction to the basic methods + of parallel communication, following the message-passing + paradigm. It allows one to switch parallel features on and off, without + changing the code. Currently only MPI and sequential code are + supported. + + A CollectiveCommunication object is returned by all grids (also + the sequential ones) in order to allow code to be written in + a transparent way for sequential and parallel grids. + + This class provides a default implementation for sequential grids. + The number of processes involved is 1, any sum, maximum, etc. returns + just its input argument and so on. + + In specializations one can implement the real thing using appropriate + communication functions, e.g. there exists an implementation using + the Message Passing %Interface (MPI), see Dune::CollectiveCommunication. + + Moreover, the communication subsystem used by an implementation + is not visible in the interface, i.e. Dune grid implementations + are not restricted to MPI. + + \tparam Communicator The communicator type used by your message-passing implementation. + For MPI this will be MPI_Comm. For sequential codes there is the dummy communicator No_Comm. + It is assumed that if you want to specialize the CollectiveCommunication class for a + message-passing system other than MPI, that message-passing system will have something + equivalent to MPI communicators. + + \ingroup ParallelCommunication + */ + template + class CollectiveCommunication + { + public: + //! Construct default object + CollectiveCommunication() + {} + + /** \brief Constructor with a given communicator + * + * As this is implementation for the sequential setting, the communicator is a dummy and simply discarded. + */ + CollectiveCommunication (const Communicator&) + {} + + //! Return rank, is between 0 and size()-1 + int rank () const + { + return 0; + } + + //! Number of processes in set, is greater than 0 + int size () const + { + return 1; + } + + /** @brief Compute the sum of the argument over all processes and + return the result in every process. Assumes that T has an operator+ + */ + template + T sum (T& in) const // MPI does not know about const :-( + { + return in; + } + + /** @brief Compute the sum over all processes for each component of an array and return the result + in every process. Assumes that T has an operator+ + + @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + int sum (T* inout, int len) const + { + return 0; + } + + /** @brief Compute the product of the argument over all processes and + return the result in every process. Assumes that T has an operator* + */ + template + T prod (T& in) const // MPI does not know about const :-( + { + return in; + } + + /** @brief Compute the product over all processes + for each component of an array and return the result + in every process. Assumes that T has an operator* + @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + int prod (T* inout, int len) const + { + return 0; + } + + /** @brief Compute the minimum of the argument over all processes and + return the result in every process. Assumes that T has an operator< + */ + template + T min (T& in) const // MPI does not know about const :-( + { + return in; + } + + /** @brief Compute the minimum over all processes + for each component of an array and return the result + in every process. Assumes that T has an operator< + @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + int min (T* inout, int len) const + { + return 0; + } + + /** @brief Compute the maximum of the argument over all processes and + return the result in every process. Assumes that T has an operator< + */ + template + T max (T& in) const // MPI does not know about const :-( + { + return in; + } + + /** @brief Compute the maximum over all processes + for each component of an array and return the result + in every process. Assumes that T has an operator< + @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + int max (T* inout, int len) const + { + return 0; + } + + /** @brief Wait until all processes have arrived at this point in the program. + @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + int barrier () const + { + return 0; + } + + /** @brief Distribute an array from the process with rank root to all other processes + @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + int broadcast (T* inout, int len, int root) const + { + return 0; + } + + /** @brief Gather arrays on root task. + * + * Each process sends its in array of length len to the root process + * (including the root itself). In the root process these arrays are stored in rank + * order in the out array which must have size len * number of processes. + * @param[in] in The send buffer with the data to send. + * @param[out] out The buffer to store the received data in. Might have length zero on non-root + * tasks. + * @param[in] len The number of elements to send on each task. + * @param[in] root The root task that gathers the data. + * @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + int gather (T* in, T* out, int len, int root) const // note out must have same size as in + { + for (int i=0; i + int gatherv (T* in, int sendlen, T* out, int* recvlen, int* displ, int root) const + { + for (int i=*displ; i + int scatter (T* send, T* recv, int len, int root) const // note out must have same size as in + { + for (int i=0; i + int scatterv (T* send, int* sendlen, int* displ, T* recv, int recvlen, int root) const + { + for (int i=*displ; i<*sendlen; i++) + recv[i] = send[i]; + return 0; + } + + /** + * @brief Gathers data from all tasks and distribute it to all. + * + * The block of data sent from the jth process is received by every + * process and placed in the jth block of the buffer recvbuf. + * + * @param[in] sbuf The buffer with the data to send. Has to be the same for + * each task. + * @param[in] count The number of elements to send by any process. + * @param[out] rbuf The receive buffer for the data. Has to be of size + * notasks*count, with notasks being the number of tasks in the communicator. + * @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + int allgather(T* sbuf, int count, T* rbuf) const + { + for(T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf) + *rbuf=*sbuf; + return 0; + } + + /** + * @brief Gathers data of variable length from all tasks and distribute it to all. + * + * The block of data sent from the jth process is received by every + * process and placed in the jth block of the buffer out. + * + * @param[in] in The send buffer with the data to send. + * @param[in] sendlen The number of elements to send on each task. + * @param[out] out The buffer to store the received data in. + * @param[in] recvlen An array with size equal to the number of processes containing the number + * of elements to recieve from process i at position i, i.e. the number that + * is passed as sendlen argument to this function in process i. + * @param[in] displ An array with size equal to the number of processes. Data recieved from + * process i will be written starting at out+displ[i]. + * @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + int allgatherv (T* in, int sendlen, T* out, int* recvlen, int* displ) const + { + for (int i=*displ; i + int allreduce(Type* inout, int len) const + { + return 0; + } + + /** + * @brief Compute something over all processes + * for each component of an array and return the result + * in every process. + * + * The template parameter BinaryFunction is the type of + * the binary function to use for the computation + * + * @param in The array to compute on. + * @param out The array to store the results in. + * @param len The number of components in the array + * @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise + */ + template + void allreduce(Type* in, Type* out, int len) const + { + std::copy(in, in+len, out); + return; + } + + }; +} + +#endif diff -Nru dune-common-2.2.1/dune/common/parallel/communicator.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/communicator.hh --- dune-common-2.2.1/dune/common/parallel/communicator.hh 2012-04-17 15:16:58.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/communicator.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,4 +1,5 @@ -// $Id$ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMUNICATOR #define DUNE_COMMUNICATOR @@ -14,14 +15,14 @@ namespace Dune { - /** @defgroup Common_Parallel Communication for distributed computing - * @ingroup Common - * @brief Provides classes for syncing distributed indexed + /** @defgroup Common_Parallel Parallel Computing based on Indexsets + * @ingroup ParallelCommunication + * @brief Provides classes for syncing distributed indexed * data structures. * * In a parallel representation a container \f$x\f$, * e.g. a plain C-array, cannot be stored with all entries on each process - * because of limited memory and efficiency reasons. Therefore + * because of limited memory and efficiency reasons. Therefore * it is represented by individual * pieces \f$x_p\f$, \f$p=0, \ldots, P-1\f$, where \f$x_p\f$ is the piece stored on * process \f$p\f$ of the \f$P\f$ processes participating in the calculation. @@ -29,8 +30,8 @@ * available on any process, a process \f$p\f$ needs to know how the entries * of it's local piece \f$x_p\f$ correspond to the entries of the global * container \f$x\f$, which would be used in a sequential program. In this - * module we present classes describing the mapping of the local pieces - * to the global + * module we present classes describing the mapping of the local pieces + * to the global * view and the communication interfaces. * * @section IndexSet Parallel Index Sets @@ -42,13 +43,13 @@ * \f$x_p\f$ of the container \f$x\f$ stored on process \f$p\f$ is a mapping \f$x_p:I_p * \rightarrow K\f$, where \f$I_p \subset I\f$. Due to efficiency the entries * of \f$x_p\f$ should be stored in consecutive memory. - * + * * This means that for the local computation the data must be addressable * by a consecutive index starting from \f$0\f$. When using adaptive * discretisation methods there might be the need to reorder the indices * after adding and/or deleting some of the discretisation * points. Therefore this index does not have to be persistent. Further - *on we will call this index local index. + * on we will call this index local index. * * For the communication phases of our algorithms these locally stored * entries must also be addressable by a global identifier to be able to @@ -66,16 +67,20 @@ * * To setup communication between the processes every process needs to * know what indices are also known to other processes and what - * attributes are attached to them on the remote side. This information is + * attributes are attached to them on the remote side. This information is * calculated and encapsulated in class RemoteIndices. * * @section comm Communication * * Based on the information about the distributed index sets, data - * independent interfaces between different sets of the index sets - * can be setup using the class Interface. For the actual communication it - * data dependant communicators can be setup using BufferedCommunicator or - * DatatypeCommunicator. + * independent interfaces between different sets of the index sets + * can be setup using the class Interface. For the actual communication + * data dependent communicators can be setup using BufferedCommunicator, + * DatatypeCommunicator VariableSizeCommunicator based on the interface + * information. In contrast to the former + * the latter is independent of the class Interface can work on a map + * from process number to a pair of index lists describing which local indices + * are send and received from that processs, respectively. */ /** @addtogroup Common_Parallel * @@ -83,19 +88,19 @@ */ /** * @file - * @brief Provides utility classes for syncing distributed data via + * @brief Provides utility classes for syncing distributed data via * MPI communication. * @author Markus Blatt - */ + */ /** - * @brief Flag for marking indexed data structures where data at + * @brief Flag for marking indexed data structures where data at * each index is of the same size. - * @see VariableSize + * @see VariableSize */ struct SizeOne {}; - + /** * @brief Flag for marking indexed data structures where the data at each index may * be a variable multiple of another type. @@ -103,7 +108,7 @@ */ struct VariableSize {}; - + /** * @brief Default policy used for communicating an indexed type. @@ -113,26 +118,26 @@ template struct CommPolicy { - /** + /** * @brief The type the policy is for. * * It has to provide the mode * \code Type::IndexedType operator[](int i);\endcode * for - * the access of the value at index i and a typedef IndexedType. - * It is assumed + * the access of the value at index i and a typedef IndexedType. + * It is assumed * that only one entry is at each index (as in scalar * vector. - */ + */ typedef V Type; - + /** * @brief The type we get at each index with operator[]. * * The default is the value_type typedef of the container. */ typedef typename V::value_type IndexedType; - + /** * @brief Whether the indexed type has variable size or there * is always one value at each index. @@ -148,7 +153,7 @@ * @param index The index of the entry. */ static const void* getAddress(const V& v, int index); - + /** * @brief Get the number of primitve elements at that index. * @@ -158,23 +163,23 @@ }; template class FieldVector; - + template class VariableBlockVector; - + template struct CommPolicy, A> > { typedef VariableBlockVector, A> Type; - + typedef typename Type::B IndexedType; - + typedef VariableSize IndexedTypeFlag; static const void* getAddress(const Type& v, int i); - + static int getSize(const Type& v, int i); }; - + /** * @brief Error thrown if there was a problem with the communication. */ @@ -188,11 +193,11 @@ struct CopyGatherScatter { typedef typename CommPolicy::IndexedType IndexedType; - + static const IndexedType& gather(const T& vec, std::size_t i); - + static void scatter(T& vec, const IndexedType& v, std::size_t i); - + }; /** @@ -200,16 +205,16 @@ * * This communicator creates special MPI datatypes that address the non contiguous elements * to be send and received. The idea was to prevent the copying to an additional buffer and - * the mpi implementation decide whether to allocate buffers or use buffers offered by the + * the mpi implementation decide whether to allocate buffers or use buffers offered by the * interconnection network. * - * Unfortunately the implementation of MPI datatypes seems to be poor. Therefore for most MPI + * Unfortunately the implementation of MPI datatypes seems to be poor. Therefore for most MPI * implementations using a BufferedCommunicator will be more efficient. */ template class DatatypeCommunicator : public InterfaceBuilder { - public: + public: /** * @brief Type of the index set. @@ -225,7 +230,7 @@ * @brief The type of the global index. */ typedef typename RemoteIndices::GlobalIndex GlobalIndex; - + /** * @brief The type of the attribute. */ @@ -235,12 +240,12 @@ * @brief The type of the local index. */ typedef typename RemoteIndices::LocalIndex LocalIndex; - + /** * @brief Creates a new DatatypeCommunicator. */ DatatypeCommunicator(); - + /** * @brief Destructor. */ @@ -252,15 +257,15 @@ * Has to be called before the actual communication by forward or backward * can be called. Nonpublic indices will be ignored! * - * - * The types T1 and T2 are classes representing a set of - * enumeration values of type DatatypeCommunicator::Attribute. + * + * The types T1 and T2 are classes representing a set of + * enumeration values of type DatatypeCommunicator::Attribute. * They have to provide * a (static) method * \code * bool contains(Attribute flag) const; * \endcode - * for checking whether the set contains a specfic flag. + * for checking whether the set contains a specific flag. * This functionality is for example provided the classes * EnumItem, EnumRange and Combine. * @@ -274,42 +279,42 @@ */ template void build(const RemoteIndices& remoteIndices, const T1& sourceFlags, V& sendData, const T2& destFlags, V& receiveData); - + /** * @brief Sends the primitive values from the source to the destination. */ void forward(); - + /** * @brief Sends the primitive values from the destination to the source. */ void backward(); - + /** * @brief Deallocates the MPI requests and data types. */ - void free(); + void free(); private: - enum { + enum { /** * @brief Tag for the MPI communication. */ commTag_ = 234 }; - + /** * @brief The indices also known at other processes. */ const RemoteIndices* remoteIndices_; - - typedef std::map > + + typedef std::map > MessageTypeMap; - + /** * @brief The datatypes built according to the communication interface. */ MessageTypeMap messageTypes; - + /** * @brief The pointer to the data whose entries we communicate. */ @@ -321,13 +326,13 @@ * @brief True if the request and data types were created. */ bool created_; - + /** * @brief Creates the MPI_Requests for the forward communication. */ template void createRequests(V& sendData, V& receiveData); - + /** * @brief Creates the data types needed for the unbuffered receive. */ @@ -338,7 +343,7 @@ * @brief Initiates the sending and receive. */ void sendRecv(MPI_Request* req); - + /** * @brief Information used for setting up the MPI Datatypes. */ @@ -351,24 +356,24 @@ */ void build(int i) { - length = new int[i]; - displ = new MPI_Aint[i]; - size = i; + length = new int[i]; + displ = new MPI_Aint[i]; + size = i; } - + /** * @brief Free the allocated space. */ void free() { - delete[] length; - delete[] displ; + delete[] length; + delete[] displ; } /** @brief The number of values at each index. */ int* length; /** @brief The displacement at each index. */ MPI_Aint* displ; - /** + /** * @brief The number of elements we send. * In case of variable sizes this will differ from * size. @@ -379,7 +384,7 @@ */ int size; }; - + /** * @brief Functor for the InterfaceBuilder. * @@ -392,9 +397,9 @@ * @brief Constructor. * @param data The data we construct an MPI data type for. */ - MPIDatatypeInformation(const V& data): data_(data) + MPIDatatypeInformation(const V& data) : data_(data) {} - + /** * @brief Reserver space for the information about the datatype. * @param proc The rank of the process this information is for. @@ -402,7 +407,7 @@ */ void reserve(int proc, int size) { - information_[proc].build(size); + information_[proc].build(size); } /** * @brief Add a new index to the datatype. @@ -412,15 +417,15 @@ */ void add(int proc, int local) { - IndexedTypeInformation& info=information_[proc]; - assert(info.elements(CommPolicy::getAddress(data_, local)), - info.displ+info.elements); - info.length[info.elements]=CommPolicy::getSize(data_, local); - info.elements++; + IndexedTypeInformation& info=information_[proc]; + assert((info.elements)(CommPolicy::getAddress(data_, local)), + info.displ+info.elements); + info.length[info.elements]=CommPolicy::getSize(data_, local); + info.elements++; } - - /** + + /** * @brief The information about the datatypes to send to or * receive from each process. */ @@ -429,37 +434,37 @@ * @brief A representative of the indexed data we send. */ const V& data_; - + }; - + }; /** * @brief A communicator that uses buffers to gather and scatter * the data to be send or received. * - * Before the data is sent it it copied to a consecutive buffer and + * Before the data is sent it is copied to a consecutive buffer and * then that buffer is sent. * The data is received in another buffer and then copied to the actual * position. */ class BufferedCommunicator { - + public: /** * @brief Constructor. */ BufferedCommunicator(); - + /** * @brief Build the buffers and information for the communication process. * - * + * * @param interface The interface that defines what indices are to be communicated. */ template - typename enable_if::IndexedTypeFlag>::value, void>::type + typename std::enable_if::IndexedTypeFlag>::value, void>::type build(const Interface& interface); /** @@ -471,7 +476,7 @@ */ template void build(const Data& source, const Data& target, const Interface& interface); - + /** * @brief Send from source to target. * @@ -486,7 +491,7 @@ * \endcode * in the case where CommPolicy::IndexedTypeFlag is SizeOne * and - * + * * \code * static const typename CommPolicy::IndexedType> gather(Data& data, int index, int subindex); * @@ -497,12 +502,12 @@ * subindex of the block at index. * @warning The source and target data have to have the same layout as the ones given * to the build function in case of variable size values at the indices. - * @param source The values will be copied from here to the send buffers. + * @param source The values will be copied from here to the send buffers. * @param dest The received values will be copied to here. */ template void forward(const Data& source, Data& dest); - + /** * @brief Communicate in the reverse direction, i.e. send from target to source. * @@ -517,7 +522,7 @@ * \endcode * in the case where CommPolicy::IndexedTypeFlag is SizeOne * and - * + * * \code * static onst typename CommPolicy::IndexedType> gather(Data& data, int index, int subindex); * @@ -528,7 +533,7 @@ * subindex of the block at index. * @warning The source and target data have to have the same layout as the ones given * to the build function in case of variable size values at the indices. - * @param dest The values will be copied from here to the send buffers. + * @param dest The values will be copied from here to the send buffers. * @param source The received values will be copied to here. */ template @@ -548,7 +553,7 @@ * \endcode * in the case where CommPolicy::IndexedTypeFlag is SizeOne * and - * + * * \code * static onst typename CommPolicy::IndexedType> gather(Data& data, int index, int subindex); * @@ -561,7 +566,7 @@ */ template void forward(Data& data); - + /** * @brief Backward send where target and source are the same. * @@ -576,7 +581,7 @@ * \endcode * in the case where CommPolicy::IndexedTypeFlag is SizeOne * and - * + * * \code * static onst typename CommPolicy::IndexedType> gather(Data& data, int index, int subindex); * @@ -589,20 +594,20 @@ */ template void backward(Data& data); - + /** * @brief Free the allocated memory (i.e. buffers and message information. */ void free(); - + /** * @brief Destructor. */ ~BufferedCommunicator(); - + private: - - /** + + /** * @brief The type of the map that maps interface information to processors. */ typedef std::map > @@ -615,7 +620,7 @@ template struct MessageSizeCalculator {}; - + /** * @brief Functor for message size caculation for datatypes * where at each index is only one value. @@ -658,14 +663,14 @@ */ inline int operator()(const Data& data, const InterfaceInformation& info) const; }; - + /** * @brief Functors for message data gathering. */ template struct MessageGatherer {}; - + /** * @brief Functor for message data gathering for datatypes * where at each index is only one value. @@ -675,22 +680,22 @@ { /** @brief The type of the values we send. */ typedef typename CommPolicy::IndexedType Type; - - /** + + /** * @brief The type of the functor that does the actual copying * during the data Scattering. */ typedef GatherScatter Gatherer; - - enum{ - /** - * @brief The communication mode - * - *True if this was a forward commuication. - */ - forward=send + + enum { + /** + * @brief The communication mode + * + * True if this was a forward communication. + */ + forward=send }; - + /** * @brief Copies the values to send into the buffer. * @param interface The interface used in the send. @@ -700,7 +705,7 @@ */ inline void operator()(const InterfaceMap& interface, const Data& data, Type* buffer, size_t bufferSize) const; }; - + /** * @brief Functor for message data scattering for datatypes * where at each index can be a variable size of values @@ -710,22 +715,22 @@ { /** @brief The type of the values we send. */ typedef typename CommPolicy::IndexedType Type; - - /** + + /** * @brief The type of the functor that does the actual copying * during the data Scattering. */ typedef GatherScatter Gatherer; - - enum{ - /** - * @brief The communication mode - * - *True if this was a forward commuication. - */ - forward=send + + enum { + /** + * @brief The communication mode + * + * True if this was a forward communication. + */ + forward=send }; - + /** * @brief Copies the values to send into the buffer. * @param interface The interface used in the send. @@ -752,22 +757,22 @@ { /** @brief The type of the values we send. */ typedef typename CommPolicy::IndexedType Type; - - /** + + /** * @brief The type of the functor that does the actual copying * during the data Scattering. */ typedef GatherScatter Scatterer; - - enum{ - /** - * @brief The communication mode - * - *True if this was a forward commuication. - */ - forward=send + + enum { + /** + * @brief The communication mode + * + * True if this was a forward communication. + */ + forward=send }; - + /** * @brief Copy the message data from the receive buffer to the data. * @param interface The interface used in the send. @@ -786,22 +791,22 @@ { /** @brief The type of the values we send. */ typedef typename CommPolicy::IndexedType Type; - - /** + + /** * @brief The type of the functor that does the actual copying * during the data Scattering. */ typedef GatherScatter Scatterer; - - enum{ - /** - * @brief The communication mode - * - *True if this was a forward commuication. - */ - forward=send + + enum { + /** + * @brief The communication mode + * + * True if this was a forward communication. + */ + forward=send }; - + /** * @brief Copy the message data from the receive buffer to the data. * @param interface The interface used in the send. @@ -819,18 +824,18 @@ { /** @brief Constructor. */ MessageInformation() - : start_(0), size_(0) + : start_(0), size_(0) {} - - /** - * @brief Constructor. + + /** + * @brief Constructor. * @param start The start of the message in the global buffer. * Not in bytes but in number of values from the beginning of * the buffer * @param size The size of the message in bytes. - */ + */ MessageInformation(size_t start, size_t size) - :start_(start), size_(size) + : start_(start), size_(size) {} /** * @brief Start of the message in the buffer counted in number of value. @@ -845,7 +850,7 @@ /** * @brief Type of the map of information about the messages to send. * - * The key is the process number to communicate with and the key is + * The key is the process number to communicate with and the value is * the pair of information about sending and receiving messages. */ typedef std::map > @@ -862,14 +867,14 @@ * @brief The size of the communication buffers */ size_t bufferSize_[2]; - - enum{ + + enum { /** - * @brief The tag we use for communication. + * @brief The tag we use for communication. */ commTag_ }; - + /** * @brief The interface we currently work with. */ @@ -882,9 +887,9 @@ */ template void sendRecv(const Data& source, Data& target); - + }; - + #ifndef DOXYGEN template @@ -892,10 +897,12 @@ { return &(v[index]); } - + template inline int CommPolicy::getSize(const V& v, int index) { + DUNE_UNUSED_PARAMETER(v); + DUNE_UNUSED_PARAMETER(index); return 1; } @@ -912,7 +919,7 @@ } template - inline const typename CopyGatherScatter::IndexedType& CopyGatherScatter::gather(const T& vec, std::size_t i) + inline const typename CopyGatherScatter::IndexedType& CopyGatherScatter::gather(const T & vec, std::size_t i) { return vec[i]; } @@ -930,20 +937,20 @@ requests_[0]=0; requests_[1]=0; } - - + + template DatatypeCommunicator::~DatatypeCommunicator() { free(); } - + template template inline void DatatypeCommunicator::build(const RemoteIndices& remoteIndices, - const T1& source, V& sendData, - const T2& destination, V& receiveData) + const T1& source, V& sendData, + const T2& destination, V& receiveData) { remoteIndices_ = &remoteIndices; free(); @@ -957,32 +964,30 @@ template void DatatypeCommunicator::free() { - if(created_){ + if(created_) { delete[] requests_[0]; delete[] requests_[1]; typedef MessageTypeMap::iterator iterator; typedef MessageTypeMap::const_iterator const_iterator; - + const const_iterator end=messageTypes.end(); - - for(iterator process = messageTypes.begin(); process != end; ++process){ - MPI_Datatype *type = &(process->second.first); - int finalized=0; -#if MPI_2 - MPI_Finalized(&finalized); -#endif - if(*type!=MPI_DATATYPE_NULL && !finalized) - MPI_Type_free(type); - type = &(process->second.second); - if(*type!=MPI_DATATYPE_NULL && !finalized) - MPI_Type_free(type); + + for(iterator process = messageTypes.begin(); process != end; ++process) { + MPI_Datatype *type = &(process->second.first); + int finalized=0; + MPI_Finalized(&finalized); + if(*type!=MPI_DATATYPE_NULL && !finalized) + MPI_Type_free(type); + type = &(process->second.second); + if(*type!=MPI_DATATYPE_NULL && !finalized) + MPI_Type_free(type); } messageTypes.clear(); created_=false; } - + } - + template template void DatatypeCommunicator::createDataTypes(const T1& sourceFlags, const T2& destFlags, V& data) @@ -993,67 +998,66 @@ typedef typename RemoteIndices::RemoteIndexMap::const_iterator const_iterator; const const_iterator end=this->remoteIndices_->end(); - + // Allocate MPI_Datatypes and deallocate memory for the type construction. - for(const_iterator process=this->remoteIndices_->begin(); process != end; ++process){ + for(const_iterator process=this->remoteIndices_->begin(); process != end; ++process) { IndexedTypeInformation& info=dataInfo.information_[process->first]; // Shift the displacement MPI_Aint base; - MPI_Address(const_cast(CommPolicy::getAddress(data, 0)), &base); - - for(int i=0; i< info.elements; i++){ - info.displ[i]-=base; + MPI_Get_address(const_cast(CommPolicy::getAddress(data, 0)), &base); + + for(int i=0; i< info.elements; i++) { + info.displ[i]-=base; } - + // Create data type MPI_Datatype* type = &( send ? messageTypes[process->first].first : messageTypes[process->first].second); - MPI_Type_hindexed(info.elements, info.length, info.displ, - MPITraits::IndexedType>::getType(), - type); + MPI_Type_create_hindexed(info.elements, info.length, info.displ, + MPITraits::IndexedType>::getType(), type); MPI_Type_commit(type); // Deallocate memory info.free(); } } - + template template void DatatypeCommunicator::createRequests(V& sendData, V& receiveData) { typedef std::map >::const_iterator MapIterator; int rank; - static int index = createForward?1:0; + static int index = createForward ? 1 : 0; int noMessages = messageTypes.size(); // allocate request handles requests_[index] = new MPI_Request[2*noMessages]; const MapIterator end = messageTypes.end(); int request=0; MPI_Comm_rank(MPI_COMM_WORLD, &rank); - + // Set up the requests for receiving first - for(MapIterator process = messageTypes.begin(); process != end; - ++process, ++request){ + for(MapIterator process = messageTypes.begin(); process != end; + ++process, ++request) { MPI_Datatype type = createForward ? process->second.second : process->second.first; void* address = const_cast(CommPolicy::getAddress(receiveData,0)); MPI_Recv_init(address, 1, type, process->first, commTag_, this->remoteIndices_->communicator(), requests_[index]+request); } - + // And now the send requests - for(MapIterator process = messageTypes.begin(); process != end; - ++process, ++request){ + for(MapIterator process = messageTypes.begin(); process != end; + ++process, ++request) { MPI_Datatype type = createForward ? process->second.first : process->second.second; void* address = const_cast(CommPolicy::getAddress(sendData, 0)); MPI_Ssend_init(address, 1, type, process->first, commTag_, this->remoteIndices_->communicator(), requests_[index]+request); } - } - + } + template void DatatypeCommunicator::forward() { sendRecv(requests_[1]); } - + template void DatatypeCommunicator::backward() { @@ -1068,62 +1072,62 @@ MPI_Startall(noMessages, requests); // Now the send calls MPI_Startall(noMessages, requests+noMessages); - + // Wait for completion of the communication send first then receive MPI_Status* status=new MPI_Status[2*noMessages]; for(int i=0; i<2*noMessages; i++) status[i].MPI_ERROR=MPI_SUCCESS; - + int send = MPI_Waitall(noMessages, requests+noMessages, status+noMessages); int receive = MPI_Waitall(noMessages, requests, status); - + // Error checks int success=1, globalSuccess=0; - if(send==MPI_ERR_IN_STATUS){ + if(send==MPI_ERR_IN_STATUS) { int rank; MPI_Comm_rank(this->remoteIndices_->communicator(), &rank); std::cerr<remoteIndices_->communicator(), &rank); std::cerr<remoteIndices_->communicator()); - + delete[] status; if(!globalSuccess) DUNE_THROW(CommunicationError, "A communication error occurred!"); - + } - + inline BufferedCommunicator::BufferedCommunicator() { buffers_[0]=0; @@ -1133,30 +1137,31 @@ } template - typename enable_if::IndexedTypeFlag>::value, void>::type + typename std::enable_if::IndexedTypeFlag>::value, void>::type BufferedCommunicator::build(const Interface& interface) { interfaces_=interface.interfaces(); communicator_=interface.communicator(); typedef typename std::map > - ::const_iterator const_iterator; + ::const_iterator const_iterator; typedef typename CommPolicy::IndexedTypeFlag Flag; const const_iterator end = interfaces_.end(); int lrank; MPI_Comm_rank(communicator_, &lrank); - + bufferSize_[0]=0; bufferSize_[1]=0; for(const_iterator interfacePair = interfaces_.begin(); - interfacePair != end; ++interfacePair){ - int noSend = MessageSizeCalculator()(interfacePair->second.first); - int noRecv = MessageSizeCalculator()(interfacePair->second.second); - messageInformation_.insert(std::make_pair(interfacePair->first, - std::make_pair(MessageInformation(bufferSize_[0], - noSend*sizeof(typename CommPolicy::IndexedType)), - MessageInformation(bufferSize_[1], - noRecv*sizeof(typename CommPolicy::IndexedType))))); + interfacePair != end; ++interfacePair) { + int noSend = MessageSizeCalculator() (interfacePair->second.first); + int noRecv = MessageSizeCalculator() (interfacePair->second.second); + if (noSend + noRecv > 0) + messageInformation_.insert(std::make_pair(interfacePair->first, + std::make_pair(MessageInformation(bufferSize_[0], + noSend*sizeof(typename CommPolicy::IndexedType)), + MessageInformation(bufferSize_[1], + noRecv*sizeof(typename CommPolicy::IndexedType))))); bufferSize_[0] += noSend; bufferSize_[1] += noRecv; } @@ -1164,35 +1169,35 @@ // allocate the buffers bufferSize_[0] *= sizeof(typename CommPolicy::IndexedType); bufferSize_[1] *= sizeof(typename CommPolicy::IndexedType); - + buffers_[0] = new char[bufferSize_[0]]; - buffers_[1] = new char[bufferSize_[1]]; - } - + buffers_[1] = new char[bufferSize_[1]]; + } + template void BufferedCommunicator::build(const Data& source, const Data& dest, const Interface& interface) { - + interfaces_=interface.interfaces(); communicator_=interface.communicator(); typedef typename std::map > - ::const_iterator const_iterator; + ::const_iterator const_iterator; typedef typename CommPolicy::IndexedTypeFlag Flag; const const_iterator end = interfaces_.end(); - + bufferSize_[0]=0; bufferSize_[1]=0; for(const_iterator interfacePair = interfaces_.begin(); - interfacePair != end; ++interfacePair){ - int noSend = MessageSizeCalculator()(source, interfacePair->second.first); - int noRecv = MessageSizeCalculator()(dest, interfacePair->second.second); - - messageInformation_.insert(std::make_pair(interfacePair->first, - std::make_pair(MessageInformation(bufferSize_[0], - noSend*sizeof(typename CommPolicy::IndexedType)), - MessageInformation(bufferSize_[1], - noRecv*sizeof(typename CommPolicy::IndexedType))))); + interfacePair != end; ++interfacePair) { + int noSend = MessageSizeCalculator() (source, interfacePair->second.first); + int noRecv = MessageSizeCalculator() (dest, interfacePair->second.second); + if (noSend + noRecv > 0) + messageInformation_.insert(std::make_pair(interfacePair->first, + std::make_pair(MessageInformation(bufferSize_[0], + noSend*sizeof(typename CommPolicy::IndexedType)), + MessageInformation(bufferSize_[1], + noRecv*sizeof(typename CommPolicy::IndexedType))))); bufferSize_[0] += noSend; bufferSize_[1] += noRecv; } @@ -1203,23 +1208,23 @@ buffers_[0] = new char[bufferSize_[0]]; buffers_[1] = new char[bufferSize_[1]]; } - + inline void BufferedCommunicator::free() { - messageInformation_.clear(); - if(buffers_[0]) - delete[] buffers_[0]; - - if(buffers_[1]) - delete[] buffers_[1]; - buffers_[0]=buffers_[1]=0; + messageInformation_.clear(); + if(buffers_[0]) + delete[] buffers_[0]; + + if(buffers_[1]) + delete[] buffers_[1]; + buffers_[0]=buffers_[1]=0; } inline BufferedCommunicator::~BufferedCommunicator() { free(); } - + template inline int BufferedCommunicator::MessageSizeCalculator::operator() (const InterfaceInformation& info) const @@ -1227,15 +1232,15 @@ return info.size(); } - + template inline int BufferedCommunicator::MessageSizeCalculator::operator() - (const Data& data, const InterfaceInformation& info) const + (const Data&, const InterfaceInformation& info) const { return operator()(info); } - + template inline int BufferedCommunicator::MessageSizeCalculator::operator() (const Data& data, const InterfaceInformation& info) const @@ -1247,150 +1252,152 @@ return entries; } - - + + template inline void BufferedCommunicator::MessageGatherer::operator()(const InterfaceMap& interfaces,const Data& data, Type* buffer, size_t bufferSize) const { + DUNE_UNUSED_PARAMETER(bufferSize); typedef typename InterfaceMap::const_iterator - const_iterator; + const_iterator; int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); const const_iterator end = interfaces.end(); size_t index=0; - + for(const_iterator interfacePair = interfaces.begin(); - interfacePair != end; ++interfacePair){ + interfacePair != end; ++interfacePair) { int size = forward ? interfacePair->second.first.size() : - interfacePair->second.second.size(); - - for(int i=0; i < size; i++){ - int local = forward ? interfacePair->second.first[i] : - interfacePair->second.second[i]; - for(std::size_t j=0; j < CommPolicy::getSize(data, local);j++, index++){ + interfacePair->second.second.size(); + + for(int i=0; i < size; i++) { + int local = forward ? interfacePair->second.first[i] : + interfacePair->second.second[i]; + for(std::size_t j=0; j < CommPolicy::getSize(data, local); j++, index++) { #ifdef DUNE_ISTL_WITH_CHECKING - assert(bufferSize>=(index+1)*sizeof(typename CommPolicy::IndexedType)); + assert(bufferSize>=(index+1)*sizeof(typename CommPolicy::IndexedType)); #endif - buffer[index]=GatherScatter::gather(data, local, j); - } - + buffer[index]=GatherScatter::gather(data, local, j); + } + } } - + } - + template - inline void BufferedCommunicator::MessageGatherer::operator()(const InterfaceMap& interfaces, const Data& data, Type* buffer, size_t bufferSize)const + inline void BufferedCommunicator::MessageGatherer::operator()(const InterfaceMap& interfaces, const Data& data, Type* buffer, size_t bufferSize) const { + DUNE_UNUSED_PARAMETER(bufferSize); typedef typename InterfaceMap::const_iterator - const_iterator; + const_iterator; const const_iterator end = interfaces.end(); size_t index = 0; - + int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); for(const_iterator interfacePair = interfaces.begin(); - interfacePair != end; ++interfacePair){ + interfacePair != end; ++interfacePair) { size_t size = FORWARD ? interfacePair->second.first.size() : - interfacePair->second.second.size(); - - for(size_t i=0; i < size; i++){ + interfacePair->second.second.size(); + + for(size_t i=0; i < size; i++) { #ifdef DUNE_ISTL_WITH_CHECKING - assert(bufferSize>=(index+1)*sizeof(typename CommPolicy::IndexedType)); + assert(bufferSize>=(index+1)*sizeof(typename CommPolicy::IndexedType)); #endif - buffer[index++] = GatherScatter::gather(data, FORWARD ? interfacePair->second.first[i] : - interfacePair->second.second[i]); + buffer[index++] = GatherScatter::gather(data, FORWARD ? interfacePair->second.first[i] : + interfacePair->second.second[i]); } } - + } - - + + template - inline void BufferedCommunicator::MessageScatterer::operator()(const InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc)const + inline void BufferedCommunicator::MessageScatterer::operator()(const InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const { typedef typename InterfaceMap::value_type::second_type::first_type Information; const typename InterfaceMap::const_iterator infoPair = interfaces.find(proc); assert(infoPair!=interfaces.end()); - + const Information& info = FORWARD ? infoPair->second.second : - infoPair->second.first; + infoPair->second.first; - for(size_t i=0, index=0; i < info.size(); i++){ - for(size_t j=0; j < CommPolicy::getSize(data, info[i]); j++) - GatherScatter::scatter(data, buffer[index++], info[i], j); + for(size_t i=0, index=0; i < info.size(); i++) { + for(size_t j=0; j < CommPolicy::getSize(data, info[i]); j++) + GatherScatter::scatter(data, buffer[index++], info[i], j); } } - + template - inline void BufferedCommunicator::MessageScatterer::operator()(const InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc)const + inline void BufferedCommunicator::MessageScatterer::operator()(const InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const { typedef typename InterfaceMap::value_type::second_type::first_type Information; const typename InterfaceMap::const_iterator infoPair = interfaces.find(proc); assert(infoPair!=interfaces.end()); - + const Information& info = FORWARD ? infoPair->second.second : - infoPair->second.first; - - for(size_t i=0; i < info.size(); i++){ + infoPair->second.first; + + for(size_t i=0; i < info.size(); i++) { GatherScatter::scatter(data, buffer[i], info[i]); } } - - + + template void BufferedCommunicator::forward(Data& data) { this->template sendRecv(data, data); } - - + + template void BufferedCommunicator::backward(Data& data) { this->template sendRecv(data, data); } - + template void BufferedCommunicator::forward(const Data& source, Data& dest) { this->template sendRecv(source, dest); } - - + + template void BufferedCommunicator::backward(Data& source, const Data& dest) { this->template sendRecv(dest, source); } - + template - void BufferedCommunicator::sendRecv(const Data& source, Data& dest) + void BufferedCommunicator::sendRecv(const Data& source, Data& dest) { int rank, lrank; - + MPI_Comm_rank(MPI_COMM_WORLD,&rank); MPI_Comm_rank(MPI_COMM_WORLD,&lrank); - + typedef typename CommPolicy::IndexedType Type; Type *sendBuffer, *recvBuffer; size_t sendBufferSize; #ifndef NDEBUG size_t recvBufferSize; #endif - - if(FORWARD){ + + if(FORWARD) { sendBuffer = reinterpret_cast(buffers_[0]); sendBufferSize = bufferSize_[0]; recvBuffer = reinterpret_cast(buffers_[1]); @@ -1407,95 +1414,117 @@ } typedef typename CommPolicy::IndexedTypeFlag Flag; - MessageGatherer()(interfaces_, source, sendBuffer, sendBufferSize); - + MessageGatherer() (interfaces_, source, sendBuffer, sendBufferSize); + MPI_Request* sendRequests = new MPI_Request[messageInformation_.size()]; MPI_Request* recvRequests = new MPI_Request[messageInformation_.size()]; - + /* Number of recvRequests that are not MPI_REQUEST_NULL */ + size_t numberOfRealRecvRequests = 0; + // Setup receive first typedef typename InformationMap::const_iterator const_iterator; const const_iterator end = messageInformation_.end(); size_t i=0; int* processMap = new int[messageInformation_.size()]; - - for(const_iterator info = messageInformation_.begin(); info != end; ++info, ++i){ - processMap[i]=info->first; - if(FORWARD){ - assert(info->second.second.start_*sizeof(typename CommPolicy::IndexedType)+info->second.second.size_ <= recvBufferSize ); - Dune::dvverb<second.second.size_<<" from "<first<second.second.start_, info->second.second.size_, - MPI_BYTE, info->first, commTag_, communicator_, - recvRequests+i); - }else{ - assert(info->second.first.start_*sizeof(typename CommPolicy::IndexedType)+info->second.first.size_ <= recvBufferSize ); - Dune::dvverb<second.first.size_<<" to "<first<second.first.start_, info->second.first.size_, - MPI_BYTE, info->first, commTag_, communicator_, - recvRequests+i); - } + + for(const_iterator info = messageInformation_.begin(); info != end; ++info, ++i) { + processMap[i]=info->first; + if(FORWARD) { + assert(info->second.second.start_*sizeof(typename CommPolicy::IndexedType)+info->second.second.size_ <= recvBufferSize ); + Dune::dvverb<second.second.size_<<" from "<first<second.second.size_) { + MPI_Irecv(recvBuffer+info->second.second.start_, info->second.second.size_, + MPI_BYTE, info->first, commTag_, communicator_, + recvRequests+i); + numberOfRealRecvRequests += 1; + } else { + // Nothing to receive -> set request to inactive + recvRequests[i]=MPI_REQUEST_NULL; + } + }else{ + assert(info->second.first.start_*sizeof(typename CommPolicy::IndexedType)+info->second.first.size_ <= recvBufferSize ); + Dune::dvverb<second.first.size_<<" to "<first<second.first.size_) { + MPI_Irecv(recvBuffer+info->second.first.start_, info->second.first.size_, + MPI_BYTE, info->first, commTag_, communicator_, + recvRequests+i); + numberOfRealRecvRequests += 1; + } else { + // Nothing to receive -> set request to inactive + recvRequests[i]=MPI_REQUEST_NULL; + } + } } - + // now the send requests i=0; for(const_iterator info = messageInformation_.begin(); info != end; ++info, ++i) - if(FORWARD){ + if(FORWARD) { assert(info->second.second.start_*sizeof(typename CommPolicy::IndexedType)+info->second.second.size_ <= recvBufferSize ); - Dune::dvverb<second.first.size_<<" to "<first<second.first.start_*sizeof(typename CommPolicy::IndexedType)+info->second.first.size_ <= sendBufferSize ); - MPI_Issend(sendBuffer+info->second.first.start_, info->second.first.size_, - MPI_BYTE, info->first, commTag_, communicator_, - sendRequests+i); + Dune::dvverb<second.first.size_<<" to "<first<second.first.start_*sizeof(typename CommPolicy::IndexedType)+info->second.first.size_ <= sendBufferSize ); + if(info->second.first.size_) + MPI_Issend(sendBuffer+info->second.first.start_, info->second.first.size_, + MPI_BYTE, info->first, commTag_, communicator_, + sendRequests+i); + else + // Nothing to send -> set request to inactive + sendRequests[i]=MPI_REQUEST_NULL; }else{ - assert(info->second.second.start_*sizeof(typename CommPolicy::IndexedType)+info->second.second.size_ <= sendBufferSize ); + assert(info->second.second.start_*sizeof(typename CommPolicy::IndexedType)+info->second.second.size_ <= sendBufferSize ); Dune::dvverb<second.second.size_<<" to "<first<second.second.start_, info->second.second.size_, - MPI_BYTE, info->first, commTag_, communicator_, - sendRequests+i); + if(info->second.second.size_) + MPI_Issend(sendBuffer+info->second.second.start_, info->second.second.size_, + MPI_BYTE, info->first, commTag_, communicator_, + sendRequests+i); + else + // Nothing to send -> set request to inactive + sendRequests[i]=MPI_REQUEST_NULL; } - + // Wait for completion of receive and immediately start scatter i=0; //int success = 1; int finished = MPI_UNDEFINED; - MPI_Status status;//[messageInformation_.size()]; + MPI_Status status; //[messageInformation_.size()]; //MPI_Waitall(messageInformation_.size(), recvRequests, status); - - for(i=0;i< messageInformation_.size();i++){ + + for(i=0; i< numberOfRealRecvRequests; i++) { status.MPI_ERROR=MPI_SUCCESS; MPI_Waitany(messageInformation_.size(), recvRequests, &finished, &status); assert(finished != MPI_UNDEFINED); - - if(status.MPI_ERROR==MPI_SUCCESS){ - int& proc = processMap[finished]; - typename InformationMap::const_iterator infoIter = messageInformation_.find(proc); - assert(infoIter != messageInformation_.end()); - MessageInformation info = (FORWARD)? infoIter->second.second : infoIter->second.first; - assert(info.start_+info.size_ <= recvBufferSize); + if(status.MPI_ERROR==MPI_SUCCESS) { + int& proc = processMap[finished]; + typename InformationMap::const_iterator infoIter = messageInformation_.find(proc); + assert(infoIter != messageInformation_.end()); + + MessageInformation info = (FORWARD) ? infoIter->second.second : infoIter->second.first; + assert(info.start_+info.size_ <= recvBufferSize); - MessageScatterer()(interfaces_, dest, recvBuffer+info.start_, proc); + MessageScatterer() (interfaces_, dest, recvBuffer+info.start_, proc); }else{ - std::cerr<communicator()); + int globalSuccess; + MPI_Allreduce(&success, &globalSuccess, 1, MPI_INT, MPI_MIN, interface_->communicator()); - if(!globalSuccess) - DUNE_THROW(CommunicationError, "A communication error occurred!"); - */ + if(!globalSuccess) + DUNE_THROW(CommunicationError, "A communication error occurred!"); + */ delete[] processMap; delete[] sendRequests; delete[] recvRequests; @@ -1503,7 +1532,7 @@ } #endif // DOXYGEN - + /** @} */ } diff -Nru dune-common-2.2.1/dune/common/parallel/indexset.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/indexset.hh --- dune-common-2.2.1/dune/common/parallel/indexset.hh 2013-02-26 11:14:37.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/indexset.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,19 +1,21 @@ -// $Id$ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_INDEXSET_HH #define DUNE_INDEXSET_HH -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include"localindex.hh" +#include "localindex.hh" #include // for uint32_t namespace Dune { -/** @addtogroup Common_Parallel + /** @addtogroup Common_Parallel * * @{ */ @@ -26,7 +28,7 @@ template class IndexPair; - + /** * @brief Print an index pair. * @param os The outputstream to print to. @@ -40,7 +42,7 @@ template bool operator!=(const IndexPair&, const IndexPair&); - + template bool operator<(const IndexPair&, const IndexPair&); @@ -58,7 +60,7 @@ template bool operator!=(const IndexPair&, const TG&); - + template bool operator<(const IndexPair&, const TG&); @@ -70,10 +72,10 @@ template bool operator >=(const IndexPair&, const TG&); - + template - class MPITraits; - + struct MPITraits; + /** * @brief A pair consisting of a global and local index. */ @@ -87,14 +89,14 @@ friend bool operator><>(const IndexPair&, const IndexPair&); friend bool operator<=<>(const IndexPair&, const IndexPair&); friend bool operator>=<>(const IndexPair&, const IndexPair&); - friend bool operator==<>(const IndexPair&, const TG&); - friend bool operator!=<>(const IndexPair&, const TG&); - friend bool operator< <>(const IndexPair&, const TG&); - friend bool operator> <>(const IndexPair&, const TG&); - friend bool operator<=<>(const IndexPair&, const TG&); - friend bool operator>=<>(const IndexPair&, const TG&); - friend class MPITraits >; - + friend bool operator==<>(const IndexPair&, const TG &); + friend bool operator!=<>(const IndexPair&, const TG &); + friend bool operator< <>(const IndexPair&, const TG &); + friend bool operator> <>(const IndexPair&, const TG &); + friend bool operator<=<>(const IndexPair&, const TG &); + friend bool operator>=<>(const IndexPair&, const TG &); + friend struct MPITraits >; + public: /** * @brief the type of the global index. @@ -102,10 +104,10 @@ * This type has to provide at least a operator< for sorting. */ typedef TG GlobalIndex; - + /** * @brief the type of the local index. - * + * * This class to provide the following functions: * \code * LocalIndex operator=(int); @@ -142,7 +144,7 @@ * @return The global index. */ inline const GlobalIndex& global() const; - + /** * @brief Get the local index. * @@ -155,7 +157,7 @@ * * @return The local index. */ - inline const LocalIndex& local()const; + inline const LocalIndex& local() const; /** * @brief Set the local index. @@ -174,13 +176,13 @@ * @brief The states the index set can be in. * @see ParallelIndexSet::state_ */ - enum ParallelIndexSetState - { - /** - * @brief The default mode. + enum ParallelIndexSetState + { + /** + * @brief The default mode. * Indicates that the index set is ready to be used. */ - GROUND, + GROUND, /** * @brief Indicates that the index set is currently being resized. */ @@ -188,22 +190,22 @@ /** * @brief Indicates that all previously deleted indices are now deleted. * - CLEAN, - ** + CLEAN, + ** * @brief Indicates that the index set is currently being reordered. * - REORDER - */ + REORDER + */ }; /** * @brief Exception indicating that the index set is not in the expected state. */ - class InvalidIndexSetState: public Exception{}; - + class InvalidIndexSetState : public InvalidStateException {}; + // Forward declaration template class GlobalLookupIndexSet; - + /** * @brief Manager class for the mapping between local indices and globally unique indices. * @@ -214,17 +216,17 @@ class ParallelIndexSet { friend class GlobalLookupIndexSet >; - - public: + + public: /** * @brief the type of the global index. * This type has to provide at least a operator< for sorting. */ typedef TG GlobalIndex; - + /** * @brief The type of the local index, e.g. ParallelLocalIndex. - * + * * This class to provide the following functions: * \code * LocalIndex operator=(int); @@ -239,19 +241,19 @@ * @brief The type of the pair stored. */ typedef Dune::IndexPair IndexPair; - - enum{ + + enum { /** * @brief The size of the individual arrays in the underlying ArrayList. * * The default value is 100. * @see ArrayList::size */ - arraySize= (N>0)?N:1 - }; + arraySize= (N>0) ? N : 1 + }; /** @brief The iterator over the pairs. */ - class iterator : + class iterator : public ArrayList::iterator { typedef typename ArrayList::iterator @@ -259,66 +261,66 @@ friend class ParallelIndexSet; public: iterator(ParallelIndexSet& indexSet, const Father& father) - : Father(father), indexSet_(&indexSet) + : Father(father), indexSet_(&indexSet) {} iterator(const iterator& other) - : Father(other), indexSet_(other.indexSet_) + : Father(other), indexSet_(other.indexSet_) {} iterator& operator==(const iterator& other) { - Father::operator==(other); - indexSet_ = other.indexSet_; + Father::operator==(other); + indexSet_ = other.indexSet_; } - - private: + + private: /** * @brief Mark the index as deleted. - * + * * The deleted flag will be set in the local index. - * The index will be removed in the endResize method of the + * The index will be removed in the endResize method of the * index set. */ inline void markAsDeleted() const throw(InvalidIndexSetState) { #ifndef NDEBUG - if(indexSet_->state_ != RESIZE) - DUNE_THROW(InvalidIndexSetState, "Indices can only be removed " - <<"while in RESIZE state!"); + if(indexSet_->state_ != RESIZE) + DUNE_THROW(InvalidIndexSetState, "Indices can only be removed " + <<"while in RESIZE state!"); #endif - Father::operator*().local().setState(DELETED); + Father::operator*().local().setState(DELETED); } /** @brief The index set we are an iterator of. */ ParallelIndexSet* indexSet_; - + }; - - + + /** @brief The constant iterator over the pairs. */ - typedef typename - ArrayList::const_iterator + typedef typename + ArrayList::const_iterator const_iterator; /** * @brief Constructor. */ ParallelIndexSet(); - + /** * @brief Get the state the index set is in. * @return The state of the index set. */ inline const ParallelIndexSetState& state() - { - return state_; - } - + { + return state_; + } + /** * @brief Indicate that the index set is to be resized. - * @exception InvalidState If index set was not in + * @exception InvalidState If index set was not in * ParallelIndexSetState::GROUND mode. */ void beginResize() throw(InvalidIndexSetState); @@ -328,7 +330,7 @@ * * The local index is created by the default constructor. * @param global The globally unique id of the index. - * @exception InvalidState If index set is not in + * @exception InvalidState If index set is not in * ParallelIndexSetState::RESIZE mode. */ inline void add(const GlobalIndex& global) throw(InvalidIndexSetState); @@ -338,11 +340,11 @@ * * @param global The globally unique id of the index. * @param local The local index. - * @exception InvalidState If index set is not in + * @exception InvalidState If index set is not in * ParallelIndexSetState::RESIZE mode. */ inline void add(const GlobalIndex& global, const LocalIndex& local) - throw(InvalidIndexSetState); + throw(InvalidIndexSetState); /** * @brief Mark an index as deleted. @@ -351,19 +353,19 @@ * @param position An iterator at the position we want to delete. * @exception InvalidState If index set is not in ParallelIndexSetState::RESIZE mode. */ - inline void markAsDeleted(const iterator& position) - throw(InvalidIndexSetState); + inline void markAsDeleted(const iterator& position) + throw(InvalidIndexSetState); /** * @brief Indicate that the resizing finishes. * - * @warning Invalidates all pointers stored to the elements of this index set. + * @warning Invalidates all pointers stored to the elements of this index set. * The local indices will be ordered * according to the global indices: - * Let \f$(g_i,l_i)_{i=0}^N \f$ be the set of all indices then \f$l_i < l_j\f$ + * Let \f$(g_i,l_i)_{i=0}^N \f$ be the set of all indices then \f$l_i < l_j\f$ * if and * only if \f$g_i < g_j\f$ for arbitrary \f$i \neq j\f$. - * @exception InvalidState If index set was not in + * @exception InvalidState If index set was not in * ParallelIndexSetState::RESIZE mode. */ void endResize() throw(InvalidIndexSetState); @@ -371,51 +373,51 @@ /** * @brief Find the index pair with a specific global id. * - * This starts a binary search for the entry and therefor has complexity - * N log(N). + * This starts a binary search for the entry and therefore has complexity + * log(N). * @param global The globally unique id of the pair. * @return The pair of indices for the id. - * @warning If the global index is not in the set a wrong or even a + * @warning If the global index is not in the set a wrong or even a * null reference might be returned. To be save use the throwing alternative at. */ - inline IndexPair& + inline IndexPair& operator[](const GlobalIndex& global); /** * @brief Find the index pair with a specific global id. * - * This starts a binary search for the entry and therefor has complexity - * N log(N). + * This starts a binary search for the entry and therefore has complexity + * log(N). * @param global The globally unique id of the pair. * @return The pair of indices for the id. * @exception RangeError Thrown if the global id is not known. */ - inline IndexPair& + inline IndexPair& at(const GlobalIndex& global); /** * @brief Find the index pair with a specific global id. * - * This starts a binary search for the entry and therefor has complexity - * N log(N). + * This starts a binary search for the entry and therefore has complexity + * log(N). * @param global The globally unique id of the pair. * @return The pair of indices for the id. - * @warning If the global index is not in the set a wrong or even a + * @warning If the global index is not in the set a wrong or even a * null reference might be returned. To be save use the throwing alternative at. */ - inline const IndexPair& + inline const IndexPair& operator[](const GlobalIndex& global) const; /** * @brief Find the index pair with a specific global id. * - * This starts a binary search for the entry and therefor has complexity - * N log(N). + * This starts a binary search for the entry and therefore has complexity + * log(N). * @param global The globally unique id of the pair. * @return The pair of indices for the id. * @exception RangeError Thrown if the global id is not known. */ - inline const IndexPair& + inline const IndexPair& at(const GlobalIndex& global) const; /** @@ -445,9 +447,9 @@ /** * @brief Renumbers the local index numbers. * - * After this function returns the indices are + * After this function returns the indices are * consecutively numbered beginning from 0. Let - * $(g_i,l_i)$, $(g_j,l_j)$ be two arbituary index + * $(g_i,l_i)$, $(g_j,l_j)$ be two arbitrary index * pairs with $g_i std::ostream& operator<<(std::ostream& os, const ParallelIndexSet& indexSet); - + /** * @brief Decorates an index set with the possibility to find a global index * that is mapped to a specific local. @@ -507,12 +509,12 @@ * @brief The type of the index set. */ typedef I ParallelIndexSet; - + /** * @brief The type of the local index. */ typedef typename ParallelIndexSet::LocalIndex LocalIndex; - + /** * @brief The type of the global index. */ @@ -522,9 +524,9 @@ * @brief The iterator over the index pairs. */ typedef typename ParallelIndexSet::const_iterator const_iterator; - + typedef Dune::IndexPair IndexPair; - + /** * @brief Constructor. * @param indexset The index set we want to be able to lookup the corresponding @@ -532,29 +534,29 @@ * @param size The number of indices present, i.e. one more than the maximum local index. */ GlobalLookupIndexSet(const ParallelIndexSet& indexset, std::size_t size); - + /** * @brief Constructor. * @param indexset The index set we want to be able to lookup the corresponding * global index of a local index. */ GlobalLookupIndexSet(const ParallelIndexSet& indexset); - + /** * @brief Destructor. */ ~GlobalLookupIndexSet(); - + /** * @brief Find the index pair with a specific global id. * - * This starts a binary search for the entry and therefor has complexity - * N log(N). This method is forwarded to the underlying index set. + * This starts a binary search for the entry and therefore has complexity + * log(N). This method is forwarded to the underlying index set. * @param global The globally unique id of the pair. * @return The pair of indices for the id. * @exception RangeError Thrown if the global id is not known. */ - inline const IndexPair& + inline const IndexPair& operator[](const GlobalIndex& global) const; /** @@ -562,7 +564,7 @@ */ inline const IndexPair* pair(const std::size_t& local) const; - + /** * @brief Get an iterator over the indices positioned at the first index. * @return Iterator over the local indices. @@ -593,7 +595,7 @@ * @brief The index set we lookup in. */ const ParallelIndexSet& indexSet_; - + /** * @brief The number of indices. */ @@ -603,14 +605,16 @@ * @brief Array with the positions of the corresponding index pair of the index set. */ std::vector indices_; - + }; - - + + template struct LocalIndexComparator { static bool compare(const T& t1, const T& t2){ + DUNE_UNUSED_PARAMETER(t1); + DUNE_UNUSED_PARAMETER(t2); return false; } }; @@ -620,13 +624,13 @@ { bool operator()(const IndexPair& i1, const IndexPair& i2) { - return i1.global()::compare(i1.local(), - i2.local())); + return i1.global()::compare(i1.local(), + i2.local())); } }; - - + + template inline std::ostream& operator<<(std::ostream& os, const IndexPair& pair) @@ -645,9 +649,9 @@ os<<*index<<" "; os<<"}"; return os; - + } - + template inline bool operator==(const IndexPair& a, const IndexPair& b) { @@ -659,7 +663,7 @@ { return a.global_!=b.global_; } - + template inline bool operator<(const IndexPair& a, const IndexPair& b) { @@ -683,7 +687,7 @@ { return a.global_>=b.global_; } - + template inline bool operator==(const IndexPair& a, const TG& b) { @@ -695,7 +699,7 @@ { return a.global_!=b; } - + template inline bool operator<(const IndexPair& a, const TG& b) { @@ -721,7 +725,7 @@ } #ifndef DOXYGEN - + template IndexPair::IndexPair(const TG& global, const TL& local) : global_(global), local_(local){} @@ -735,7 +739,7 @@ : global_(), local_(){} template - inline const TG& IndexPair::global() const{ + inline const TG& IndexPair::global() const { return global_; } @@ -745,7 +749,7 @@ } template - inline const TL& IndexPair::local() const{ + inline const TL& IndexPair::local() const { return local_; } @@ -766,50 +770,50 @@ // Checks in unproductive code #ifndef NDEBUG if(state_!=GROUND) - DUNE_THROW(InvalidIndexSetState, - "IndexSet has to be in GROUND state, when " - << "beginResize() is called!"); + DUNE_THROW(InvalidIndexSetState, + "IndexSet has to be in GROUND state, when " + << "beginResize() is called!"); #endif - + state_ = RESIZE; deletedEntries_ = false; } template - inline void ParallelIndexSet::add(const GlobalIndex& global) - throw(InvalidIndexSetState) + inline void ParallelIndexSet::add(const GlobalIndex& global) + throw(InvalidIndexSetState) { // Checks in unproductive code #ifndef NDEBUG if(state_ != RESIZE) DUNE_THROW(InvalidIndexSetState, "Indices can only be added " - <<"while in RESIZE state!"); + <<"while in RESIZE state!"); #endif newIndices_.push_back(IndexPair(global)); } template - inline void ParallelIndexSet::add(const TG& global, const TL& local) - throw(InvalidIndexSetState) + inline void ParallelIndexSet::add(const TG& global, const TL& local) + throw(InvalidIndexSetState) { // Checks in unproductive code #ifndef NDEBUG if(state_ != RESIZE) DUNE_THROW(InvalidIndexSetState, "Indices can only be added " - <<"while in RESIZE state!"); + <<"while in RESIZE state!"); #endif newIndices_.push_back(IndexPair(global,local)); } template inline void ParallelIndexSet::markAsDeleted(const iterator& global) - throw(InvalidIndexSetState){ - // Checks in unproductive code + throw(InvalidIndexSetState){ + // Checks in unproductive code #ifndef NDEBUG if(state_ != RESIZE) DUNE_THROW(InvalidIndexSetState, "Indices can only be removed " - <<"while in RESIZE state!"); -#endif + <<"while in RESIZE state!"); +#endif deletedEntries_ = true; global.markAsDeleted(); @@ -821,89 +825,89 @@ #ifndef NDEBUG if(state_ != RESIZE) DUNE_THROW(InvalidIndexSetState, "endResize called while not " - <<"in RESIZE state!"); + <<"in RESIZE state!"); #endif - + std::sort(newIndices_.begin(), newIndices_.end(), IndexSetSortFunctor()); merge(); seqNo_++; state_ = GROUND; } - - + + template inline void ParallelIndexSet::merge(){ if(localIndices_.size()==0) + { + localIndices_=newIndices_; + newIndices_.clear(); + } + else if(newIndices_.size()>0 || deletedEntries_) + { + ArrayList tempPairs; + typedef typename ArrayList::iterator iterator; + typedef typename ArrayList::const_iterator const_iterator; + + iterator old=localIndices_.begin(); + iterator added=newIndices_.begin(); + const const_iterator endold=localIndices_.end(); + const const_iterator endadded=newIndices_.end(); + + while(old != endold && added!= endadded) { - localIndices_=newIndices_; - newIndices_.clear(); + if(old->local().state()==DELETED) { + old.eraseToHere(); + } + else + { + if(old->global() < added->global() || + (old->global() == added->global() + && LocalIndexComparator::compare(old->local(),added->local()))) + { + tempPairs.push_back(*old); + old.eraseToHere(); + continue; + }else + { + tempPairs.push_back(*added); + added.eraseToHere(); + } + } } - else if(newIndices_.size()>0 || deletedEntries_) + + while(old != endold) { - ArrayList tempPairs; - typedef typename ArrayList::iterator iterator; - typedef typename ArrayList::const_iterator const_iterator; - - iterator old=localIndices_.begin(); - iterator added=newIndices_.begin(); - const const_iterator endold=localIndices_.end(); - const const_iterator endadded=newIndices_.end(); - - while(old != endold && added!= endadded) - { - if(old->local().state()==DELETED){ - old.eraseToHere(); - } - else - { - if(old->global() < added->global() || - (old->global() == added->global() - && LocalIndexComparator::compare(old->local(),added->local()))) - { - tempPairs.push_back(*old); - old.eraseToHere(); - continue; - }else - { - tempPairs.push_back(*added); - added.eraseToHere(); - } - } - } - - while(old != endold) - { - if(old->local().state()!=DELETED){ - tempPairs.push_back(*old); - } - old.eraseToHere(); - } - - while(added!= endadded) - { - tempPairs.push_back(*added); - added.eraseToHere(); - } - localIndices_ = tempPairs; + if(old->local().state()!=DELETED) { + tempPairs.push_back(*old); + } + old.eraseToHere(); } + + while(added!= endadded) + { + tempPairs.push_back(*added); + added.eraseToHere(); + } + localIndices_ = tempPairs; + } } template - inline const IndexPair& + inline const IndexPair& ParallelIndexSet::at(const TG& global) const { // perform a binary search int low=0, high=localIndices_.size()-1, probe=-1; while(low - inline const IndexPair& + template + inline const IndexPair& ParallelIndexSet::operator[](const TG& global) const { // perform a binary search int low=0, high=localIndices_.size()-1, probe=-1; while(low= global) - high = probe; - else - low = probe+1; - } + { + probe = (high + low) / 2; + if(localIndices_[probe].global() >= global) + high = probe; + else + low = probe+1; + } if(probe==-1) DUNE_THROW(RangeError, "No entries!"); @@ -963,13 +967,13 @@ int low=0, high=localIndices_.size()-1, probe=-1; while(low= global) - high = probe; - else - low = probe+1; - } + { + probe = (high + low) / 2; + if(localIndices_[probe].global() >= global) + high = probe; + else + low = probe+1; + } return localIndices_[low]; } @@ -980,24 +984,24 @@ return iterator(*this, localIndices_.begin()); } - + template - inline typename ParallelIndexSet::iterator + inline typename ParallelIndexSet::iterator ParallelIndexSet::end() { return iterator(*this,localIndices_.end()); } template - inline typename ParallelIndexSet::const_iterator + inline typename ParallelIndexSet::const_iterator ParallelIndexSet::begin() const { return localIndices_.begin(); } - + template - inline typename ParallelIndexSet::const_iterator + inline typename ParallelIndexSet::const_iterator ParallelIndexSet::end() const { return localIndices_.end(); @@ -1008,7 +1012,7 @@ #ifndef NDEBUG if(state_==RESIZE) DUNE_THROW(InvalidIndexSetState, "IndexSet has to be in " - <<"GROUND state for renumberLocal()"); + <<"GROUND state for renumberLocal()"); #endif typedef typename ArrayList::iterator iterator; @@ -1033,28 +1037,28 @@ template GlobalLookupIndexSet::GlobalLookupIndexSet(const I& indexset, - std::size_t size) - : indexSet_(indexset), size_(size), + std::size_t size) + : indexSet_(indexset), size_(size), indices_(size_, static_cast(0)) { const_iterator end_ = indexSet_.end(); - for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair){ + for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) { assert(pair->local()local()] = &(*pair); } } - template + template GlobalLookupIndexSet::GlobalLookupIndexSet(const I& indexset) : indexSet_(indexset), size_(0) { const_iterator end_ = indexSet_.end(); for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) size_=std::max(size_,static_cast(pair->local())); - + indices_.resize(++size_, 0); - + for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) indices_[pair->local()] = &(*pair); } @@ -1062,27 +1066,27 @@ template GlobalLookupIndexSet::~GlobalLookupIndexSet() {} - + template inline const IndexPair* GlobalLookupIndexSet::pair(const std::size_t& local) const { return indices_[local]; } - + template inline const IndexPair& GlobalLookupIndexSet::operator[](const GlobalIndex& global) const { return indexSet_[global]; } - + template typename I::const_iterator GlobalLookupIndexSet::begin() const { return indexSet_.begin(); } - + template typename I::const_iterator GlobalLookupIndexSet::end() const { @@ -1094,7 +1098,7 @@ { return size_; } - + template inline int GlobalLookupIndexSet::seqNo() const { @@ -1102,7 +1106,7 @@ } template - bool operator==(const ParallelIndexSet& idxset, + bool operator==(const ParallelIndexSet& idxset, const ParallelIndexSet& idxset1) { if(idxset.size()!=idxset1.size()) @@ -1110,12 +1114,12 @@ typedef typename ParallelIndexSet::const_iterator Iter; typedef typename ParallelIndexSet::const_iterator Iter1; Iter iter=idxset.begin(); - for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1){ + for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1) { if(iter1->global()!=iter->global()) return false; typedef typename ParallelIndexSet::LocalIndex PI; const PI& pi=iter->local(), pi1=iter1->local(); - + if(pi!=pi1) return false; } @@ -1123,14 +1127,14 @@ } template - bool operator!=(const ParallelIndexSet& idxset, + bool operator!=(const ParallelIndexSet& idxset, const ParallelIndexSet& idxset1) { return !(idxset==idxset1); } - - + + #endif // DOXYGEN } -#endif +#endif diff -Nru dune-common-2.2.1/dune/common/parallel/indicessyncer.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/indicessyncer.hh --- dune-common-2.2.1/dune/common/parallel/indicessyncer.hh 2013-02-26 11:14:37.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/indicessyncer.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,18 +1,20 @@ -// $Id$ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_INDICESSYNCER_HH #define DUNE_INDICESSYNCER_HH -#include"indexset.hh" -#include"remoteindices.hh" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "indexset.hh" +#include "remoteindices.hh" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if HAVE_MPI namespace Dune @@ -21,9 +23,9 @@ * * @{ */ - /** + /** * @file - * @brief Class for adding missing indices of a distributed index set in a local + * @brief Class for adding missing indices of a distributed index set in a local * communication. * @author Markus Blatt */ @@ -43,18 +45,18 @@ /** @brief The type of the index pair */ typedef typename ParallelIndexSet::IndexPair IndexPair; - + /** @brief Type of the global index used in the index set. */ typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; - + /** @brief Type of the attribute used in the index set. */ typedef typename ParallelIndexSet::LocalIndex::Attribute Attribute; /** - * @brief Type of the remote indices. + * @brief Type of the remote indices. */ typedef Dune::RemoteIndices RemoteIndices; - + /** * @brief Constructor. * @@ -64,17 +66,17 @@ * of the locally present indices. * @param remoteIndices The remoteIndices. */ - IndicesSyncer(ParallelIndexSet& indexSet, - RemoteIndices& remoteIndices); - + IndicesSyncer(ParallelIndexSet& indexSet, + RemoteIndices& remoteIndices); + /** * @brief Sync the index set. * * Computes the missing indices in the local and the remote index list and adds them. * No global communication is necessary! - * All indices added to the index will become the local index + * All indices added to the index will become the local index * std::numeric_limits::max() - * + * */ void sync(); @@ -84,40 +86,40 @@ * Computes the missing indices in the local and the remote index list and adds them. * No global communication is necessary! * @param numberer Functor providing the local indices for the added global indices. - * has to provide a function size_t operator()(const TG& global) that provides the + * has to provide a function size_t operator()(const TG& global) that provides the * local index to a global one. It will be called for ascending global indices. - * + * */ template void sync(T1& numberer); - - private: - + + private: + /** @brief The set of locally present indices.*/ ParallelIndexSet& indexSet_; /** @brief The remote indices. */ RemoteIndices& remoteIndices_; - + /** @brief The send buffers for the neighbour processes. */ char** sendBuffers_; /** @brief The receive buffer. */ char* receiveBuffer_; - + /** @brief The size of the send buffers. */ std::size_t* sendBufferSizes_; - + /** @brief The size of the receive buffer in bytes. */ int receiveBufferSize_; // int because of MPI - + /** * @brief Information about the messages to send to a neighbouring process. */ struct MessageInformation { MessageInformation() - : publish(), pairs() + : publish(), pairs() {} /** @brief The number of indices we publish for the other process. */ int publish; @@ -141,39 +143,40 @@ */ std::size_t operator()(const GlobalIndex& global) { - return std::numeric_limits::max(); + DUNE_UNUSED_PARAMETER(global); + return std::numeric_limits::max(); } }; - + /** @brief The mpi datatype for the MessageInformation */ MPI_Datatype datatype_; /** @brief Our rank. */ int rank_; - - /** + + /** * @brief List type for temporarily storing the global indices of the * remote indices. */ typedef SLList, typename RemoteIndices::Allocator> GlobalIndexList; - + /** @brief The modifying iterator for the global index list. */ typedef typename GlobalIndexList::ModifyIterator GlobalIndexModifier; - - /** + + /** * @brief The type of the iterator of GlobalIndexList */ - typedef typename SLList::iterator + typedef typename SLList::iterator GlobalIndexIterator; /** @brief Type of the map of ranks onto GlobalIndexLists. */ typedef std::map GlobalIndicesMap; - - /** + + /** * @brief Map of global index lists onto process ranks. * * As the pointers in the remote index lists become invalid due to - * resorting the index set entries one has store the corresponding + * resorting the index set entries one has store the corresponding * global index for each remote index. Thus the pointers can be adjusted * properly as a last step. */ @@ -191,7 +194,7 @@ /** @brief The type of the modifying iterator for the list of bools. */ typedef typename BoolList::ModifyIterator BoolListModifier; - + /** @brief The type of the map of bool lists. */ typedef std::map BoolMap; @@ -200,19 +203,19 @@ * call of sync. */ BoolMap oldMap_; - + /** @brief Information about the messages we send. */ std::map infoSend_; - + /** @brief The type of the remote index list. */ typedef typename RemoteIndices::RemoteIndexList RemoteIndexList; /** @brief The tyoe of the modifying iterator of the remote index list. */ typedef typename RemoteIndexList::ModifyIterator RemoteIndexModifier; - + /** @brief The type of the remote inde. */ typedef Dune::RemoteIndex RemoteIndex; - + /** @brief The iterator of the remote index list. */ typedef typename RemoteIndexList::iterator RemoteIndexIterator; @@ -220,14 +223,14 @@ typedef typename RemoteIndexList::const_iterator ConstRemoteIndexIterator; /** @brief Type of the tuple of iterators needed for the adding of indices. */ - typedef Dune::tuple IteratorTuple; + typedef std::tuple IteratorTuple; /** * @brief A tuple of iterators. * * Insertion into a single linked list is only possible at the position after the one of the iterator. - * Therefore for each linked list two iterators are needed: One position before the actual entry + * Therefore for each linked list two iterators are needed: One position before the actual entry * (for insertion) and one positioned at the actual position (for searching). */ class Iterators @@ -236,7 +239,7 @@ public: /** * @brief Constructor. - * + * * Initializes all iterator to first entry and the one before the first entry, respectively. * @param remoteIndices The list of the remote indices. * @param globalIndices The list of the coresponding global indices. This is needed because the @@ -244,32 +247,32 @@ * @param booleans Whether the remote index was there before the sync process started. */ Iterators(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices, - BoolList& booleans); - + BoolList& booleans); + /** * @brief Default constructor. */ Iterators(); - - /** + + /** * @brief Increment all iteraors. */ Iterators& operator++(); - + /** * @brief Insert a new remote index to the underlying remote index list. * @param index The remote index. * @param global The global index corresponding to the remote index. */ - void insert(const RemoteIndex& index, + void insert(const RemoteIndex& index, const std::pair& global); - + /** * @brief Get the remote index at current position. * @return The current remote index. */ RemoteIndex& remoteIndex() const; - + /** * @brief Get the global index of the remote index at current position. * @return The current global index. @@ -277,14 +280,14 @@ std::pair& globalIndexPair() const; Attribute& attribute() const; - + /** * @brief Was this entry already in the remote index list before the sync process? - * @return True if the current index wasalready in the remote index list + * @return True if the current index wasalready in the remote index list * before the sync process. */ bool isOld() const; - + /** * @brief Reset all the underlying iterators. * @@ -295,7 +298,7 @@ * @param booleans Whether the remote index was there before the sync process started. */ void reset(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices, - BoolList& booleans); + BoolList& booleans); /** * @brief Are we not at the end of the list? @@ -303,14 +306,14 @@ * and the tail of the list respectively. */ bool isNotAtEnd() const; - + /** * @brief Are we at the end of the list? * @return True if the iterators are positioned at the end of the list * and the tail of the list respectively. */ bool isAtEnd() const; - + private: /** * @brief The iterator tuple. @@ -318,41 +321,41 @@ * The tuple consists of one iterator over a single linked list of remote indices * initially positioned before the first entry, one over a sll of global indices * , one over a all of bool values both postioned at the same entry. The another three - * iterators of the same type positioned at the first entry. Last an iterator over the + * iterators of the same type positioned at the first entry. Last an iterator over the * sll of remote indices positioned at the end. */ IteratorTuple iterators_; }; - + /** @brief Type of the map from ranks to iterator tuples. */ typedef std::map IteratorsMap; - + /** * @brief The iterator tuples mapped on the neighbours. * * The key of the map is the rank of the neighbour. - * The first entry in the tuple is an iterator over the remote indices + * The first entry in the tuple is an iterator over the remote indices * initially positioned before the first entry. The second entry is an - * iterator over the corresponding global indices also initially positioned + * iterator over the corresponding global indices also initially positioned * before the first entry. The third entry an iterator over remote indices * initially positioned at the beginning. The last entry is the iterator over * the remote indices positioned at the end. */ IteratorsMap iteratorsMap_; - + /** @brief Calculates the message sizes to send. */ void calculateMessageSizes(); /** - * @brief Pack and send the message for another process. + * @brief Pack and send the message for another process. * @param destination The rank of the process we send to. * @param buffer The allocated buffer to use. * @param bufferSize The size of the buffer. * @param req The MPI_Request to setup the nonblocking send. */ void packAndSend(int destination, char* buffer, std::size_t bufferSize, MPI_Request& req); - - /** + + /** * @brief Recv and unpack the message from another process and add the indices. * @param numberer Functor providing local indices for added global indices. */ @@ -363,25 +366,25 @@ * @brief Register the MPI datatype for the MessageInformation. */ void registerMessageDatatype(); - + /** * @brief Insert an entry into the remote index list if not yet present. */ - void insertIntoRemoteIndexList(int process, - const std::pair& global, + void insertIntoRemoteIndexList(int process, + const std::pair& global, char attribute); /** * @brief Reset the iterator tuples of all neighbouring processes. */ void resetIteratorsMap(); - + /** * @brief Check whether the iterator tuples of all neighbouring processes * are reset. */ bool checkReset(); - + /** * @brief Check whether the iterator tuple is reset. * @@ -391,34 +394,34 @@ * @param bList The SLList of the bool values. */ bool checkReset(const Iterators& iterators, RemoteIndexList& rlist, GlobalIndexList& gList, - BoolList& bList); + BoolList& bList); }; template bool operator<(const IndexPair >& i1, const std::pair& i2) { - return i1.global() < i2.first || - (i1.global() == i2.first && i1.local().attribute() bool operator<(const std::pair& i1, - const IndexPair >& i2) + const IndexPair >& i2) { - return i1.first < i2.global() || - (i1.first == i2.global() && i1.second - bool operator==(const IndexPair >& i1, + bool operator==(const IndexPair >& i1, const std::pair& i2) { return (i1.global() == i2.first && i1.local().attribute()==i2.second); } - + template - bool operator!=(const IndexPair >& i1, + bool operator!=(const IndexPair >& i1, const std::pair& i2) { return (i1.global() != i2.first || i1.local().attribute()!=i2.second); @@ -430,7 +433,7 @@ { return (i1.global() == i2.first && i1.local().attribute()==i2.second); } - + template bool operator!=(const std::pair& i2, const IndexPair >& i1) @@ -443,11 +446,11 @@ * * Whenever a ParallelIndexSet is resized all RemoteIndices that use it will be invalided * as the pointers to the index set are invalid after calling ParallelIndexSet::Resize() - * One can rebuild them by storing the global indices in a map with this function and later + * One can rebuild them by storing the global indices in a map with this function and later * repairing the pointers by calling repairLocalIndexPointers. - * - * @warning The RemoteIndices class has to be build with the same index set for both the - * sending and receiving side + * + * @warning The RemoteIndices class has to be build with the same index set for both the + * sending and receiving side * @param globalMap Map to store the corresponding global indices in. * @param remoteIndices The remote index information we need to store the corresponding global * indices of. @@ -456,26 +459,25 @@ */ template void storeGlobalIndicesOfRemoteIndices(std::map,A> >& globalMap, - const RemoteIndices& remoteIndices, - const T& indexSet) + const RemoteIndices& remoteIndices) { typedef typename RemoteIndices::const_iterator RemoteIterator; - - for(RemoteIterator remote = remoteIndices.begin(), end =remoteIndices.end(); remote != end; ++remote){ + + for(RemoteIterator remote = remoteIndices.begin(), end =remoteIndices.end(); remote != end; ++remote) { typedef typename RemoteIndices::RemoteIndexList RemoteIndexList; typedef typename RemoteIndexList::const_iterator RemoteIndexIterator; typedef SLList,A> GlobalIndexList; GlobalIndexList& global = globalMap[remote->first]; RemoteIndexList& rList = *(remote->second.first); - + for(RemoteIndexIterator index = rList.begin(), riEnd = rList.end(); - index != riEnd; ++index){ + index != riEnd; ++index) { global.push_back(std::make_pair(index->localIndexPair().global(), index->localIndexPair().local().attribute())); } } } - + /** * @brief Repair the pointers to the local indices in the remote indices. * @@ -486,10 +488,10 @@ */ template inline void repairLocalIndexPointers(std::map,A> >& globalMap, - RemoteIndices& remoteIndices, - const T& indexSet) + SLList,A> >& globalMap, + RemoteIndices& remoteIndices, + const T& indexSet) { typedef typename RemoteIndices::RemoteIndexMap::iterator RemoteIterator; typedef typename RemoteIndices::RemoteIndexList::iterator RemoteIndexIterator; @@ -503,49 +505,49 @@ // Repair pointers to index set in remote indices. typename std::map::iterator global = globalMap.begin(); RemoteIterator end = remoteIndices.remoteIndices_.end(); - - for(RemoteIterator remote = remoteIndices.remoteIndices_.begin(); remote != end; ++remote, ++global){ + + for(RemoteIterator remote = remoteIndices.remoteIndices_.begin(); remote != end; ++remote, ++global) { typedef typename T::const_iterator IndexIterator; assert(remote->first==global->first); assert(remote->second.first->size() == global->second.size()); - + RemoteIndexIterator riEnd = remote->second.first->end(); RemoteIndexIterator rIndex = remote->second.first->begin(); GlobalIndexIterator gIndex = global->second.begin(); - IndexIterator index = indexSet.begin(); + IndexIterator index = indexSet.begin(); assert(rIndex==riEnd || gIndex != global->second.end()); - while(rIndex != riEnd){ - // Search for the index in the set. - assert(gIndex != global->second.end()); - - while(!(index->global() == gIndex->first - && index->local().attribute() == gIndex->second)){ - ++index; - // this is only needed for ALU, where there may exist - // more entries with the same global index in the remote index set - // than in the index set - if (index->global() > gIndex->first){ - index=indexSet.begin(); - } - } - - assert(index != indexSet.end() && *index == *gIndex); - - rIndex->localIndex_ = &(*index); - ++index; - ++rIndex; - ++gIndex; + while(rIndex != riEnd) { + // Search for the index in the set. + assert(gIndex != global->second.end()); + + while(!(index->global() == gIndex->first + && index->local().attribute() == gIndex->second)) { + ++index; + // this is only needed for ALU, where there may exist + // more entries with the same global index in the remote index set + // than in the index set + if (index->global() > gIndex->first) { + index=indexSet.begin(); + } + } + + assert(index != indexSet.end() && *index == *gIndex); + + rIndex->localIndex_ = &(*index); + ++index; + ++rIndex; + ++gIndex; } } remoteIndices.sourceSeqNo_ = remoteIndices.source_->seqNo(); remoteIndices.destSeqNo_ = remoteIndices.target_->seqNo(); } - + template - IndicesSyncer::IndicesSyncer(ParallelIndexSet& indexSet, - RemoteIndices& remoteIndices) + IndicesSyncer::IndicesSyncer(ParallelIndexSet& indexSet, + RemoteIndices& remoteIndices) : indexSet_(indexSet), remoteIndices_(remoteIndices) { // index sets must match. @@ -553,78 +555,78 @@ assert(remoteIndices.source_ == &indexSet); MPI_Comm_rank(remoteIndices_.communicator(), &rank_); } - + template - IndicesSyncer::Iterators::Iterators(RemoteIndexList& remoteIndices, - GlobalIndexList& globalIndices, - BoolList& booleans) + IndicesSyncer::Iterators::Iterators(RemoteIndexList& remoteIndices, + GlobalIndexList& globalIndices, + BoolList& booleans) : iterators_(remoteIndices.beginModify(), globalIndices.beginModify(), - booleans.beginModify(), remoteIndices.end()) + booleans.beginModify(), remoteIndices.end()) { } template IndicesSyncer::Iterators::Iterators() : iterators_() {} - + template inline typename IndicesSyncer::Iterators& IndicesSyncer::Iterators::operator++() { - ++(get<0>(iterators_)); - ++(get<1>(iterators_)); - ++(get<2>(iterators_)); - return *this; + ++(std::get<0>(iterators_)); + ++(std::get<1>(iterators_)); + ++(std::get<2>(iterators_)); + return *this; } template - inline void IndicesSyncer::Iterators::insert(const RemoteIndex& index, - const std::pair& global) + inline void IndicesSyncer::Iterators::insert(const RemoteIndex & index, + const std::pair& global) { - get<0>(iterators_).insert(index); - get<1>(iterators_).insert(global); - get<2>(iterators_).insert(false); + std::get<0>(iterators_).insert(index); + std::get<1>(iterators_).insert(global); + std::get<2>(iterators_).insert(false); } - + template - inline typename IndicesSyncer::RemoteIndex& + inline typename IndicesSyncer::RemoteIndex& IndicesSyncer::Iterators::remoteIndex() const { - return *(get<0>(iterators_)); + return *(std::get<0>(iterators_)); } - + template - inline std::pair::GlobalIndex,typename IndicesSyncer::Attribute>& - IndicesSyncer::Iterators::globalIndexPair() const + inline std::pair::GlobalIndex,typename IndicesSyncer::Attribute>& + IndicesSyncer::Iterators::globalIndexPair() const { - return *(get<1>(iterators_)); + return *(std::get<1>(iterators_)); } - + template inline bool IndicesSyncer::Iterators::isOld() const { - return *(get<2>(iterators_)); + return *(std::get<2>(iterators_)); } - + template - inline void IndicesSyncer::Iterators::reset(RemoteIndexList& remoteIndices, - GlobalIndexList& globalIndices, - BoolList& booleans) + inline void IndicesSyncer::Iterators::reset(RemoteIndexList& remoteIndices, + GlobalIndexList& globalIndices, + BoolList& booleans) { - get<0>(iterators_) = remoteIndices.beginModify(); - get<1>(iterators_) = globalIndices.beginModify(); - get<2>(iterators_) = booleans.beginModify(); + std::get<0>(iterators_) = remoteIndices.beginModify(); + std::get<1>(iterators_) = globalIndices.beginModify(); + std::get<2>(iterators_) = booleans.beginModify(); } - + template inline bool IndicesSyncer::Iterators::isNotAtEnd() const { - return get<0>(iterators_)!=get<3>(iterators_); + return std::get<0>(iterators_) != std::get<3>(iterators_); } - + template inline bool IndicesSyncer::Iterators::isAtEnd() const { - return get<0>(iterators_)==get<3>(iterators_); + return std::get<0>(iterators_) == std::get<3>(iterators_); } template @@ -634,87 +636,87 @@ int blocklength[2] = {1,1}; MPI_Aint displacement[2]; MPI_Aint base; - + // Compute displacement MessageInformation message; - - MPI_Address( &(message.publish), displacement); - MPI_Address( &(message.pairs), displacement+1); - + + MPI_Get_address( &(message.publish), displacement); + MPI_Get_address( &(message.pairs), displacement+1); + // Make the displacement relative - MPI_Address(&message, &base); + MPI_Get_address(&message, &base); displacement[0] -= base; displacement[1] -= base; - - MPI_Type_struct( 2, blocklength, displacement, type, &datatype_); + + MPI_Type_create_struct( 2, blocklength, displacement, type, &datatype_); MPI_Type_commit(&datatype_); } - + template void IndicesSyncer::calculateMessageSizes() - { + { typedef typename ParallelIndexSet::const_iterator IndexIterator; typedef CollectiveIterator CollectiveIterator; - + IndexIterator iEnd = indexSet_.end(); CollectiveIterator collIter = remoteIndices_.template iterator(); - - for(IndexIterator index = indexSet_.begin(); index != iEnd; ++index){ + + for(IndexIterator index = indexSet_.begin(); index != iEnd; ++index) { collIter.advance(index->global(), index->local().attribute()); if(collIter.empty()) - break; + break; int knownRemote=0; typedef typename CollectiveIterator::iterator ValidIterator; ValidIterator end = collIter.end(); // Count the remote indices we know. - for(ValidIterator valid = collIter.begin(); valid != end; ++valid){ + for(ValidIterator valid = collIter.begin(); valid != end; ++valid) { ++knownRemote; } - - if(knownRemote>0){ - Dune::dverb<global()<< " for processes "; - - // Update MessageInformation - for(ValidIterator valid = collIter.begin(); valid != end; ++valid){ - ++(infoSend_[valid.process()].publish); - (infoSend_[valid.process()].pairs) += knownRemote; - Dune::dverb<0) { + Dune::dverb<global()<< " for processes "; + + // Update MessageInformation + for(ValidIterator valid = collIter.begin(); valid != end; ++valid) { + ++(infoSend_[valid.process()].publish); + (infoSend_[valid.process()].pairs) += knownRemote; + Dune::dverb<::const_iterator - MessageIterator; - + + typedef typename std::map::const_iterator + MessageIterator; + const MessageIterator end = infoSend_.end(); // registerMessageDatatype(); - + // Now determine the buffersizes needed for each neighbour using MPI_Pack_size MessageInformation dummy; - + MessageIterator messageIter= infoSend_.begin(); typedef typename RemoteIndices::RemoteIndexMap::const_iterator RemoteIterator; const RemoteIterator rend = remoteIndices_.end(); int neighbour=0; - - for(RemoteIterator remote = remoteIndices_.begin(); remote != rend; ++remote, ++neighbour){ + + for(RemoteIterator remote = remoteIndices_.begin(); remote != rend; ++remote, ++neighbour) { MessageInformation* message; MessageInformation recv; - - if(messageIter != end && messageIter->first==remote->first){ - // We want to send message information to that process - message = const_cast(&(messageIter->second)); - ++messageIter; + + if(messageIter != end && messageIter->first==remote->first) { + // We want to send message information to that process + message = const_cast(&(messageIter->second)); + ++messageIter; }else - // We do not want to send information but the other process might. - message = &dummy; + // We do not want to send information but the other process might. + message = &dummy; sendBufferSizes_[neighbour]=0; int tsize; @@ -722,249 +724,249 @@ MPI_Pack_size(1, MPI_INT,remoteIndices_.communicator(), &tsize); sendBufferSizes_[neighbour] += tsize; - for(int i=0; i < message->publish; ++i){ - // The global index - MPI_Pack_size(1, MPITraits::getType(), remoteIndices_.communicator(), &tsize); - sendBufferSizes_[neighbour] += tsize; - // The attribute in the local index - MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize); - sendBufferSizes_[neighbour] += tsize; - // The number of corresponding remote indices - MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize); - sendBufferSizes_[neighbour] += tsize; + for(int i=0; i < message->publish; ++i) { + // The global index + MPI_Pack_size(1, MPITraits::getType(), remoteIndices_.communicator(), &tsize); + sendBufferSizes_[neighbour] += tsize; + // The attribute in the local index + MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize); + sendBufferSizes_[neighbour] += tsize; + // The number of corresponding remote indices + MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize); + sendBufferSizes_[neighbour] += tsize; } - for(int i=0; i < message->pairs; ++i){ - // The process of the remote index - MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize); - sendBufferSizes_[neighbour] += tsize; - // The attribute of the remote index - MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize); - sendBufferSizes_[neighbour] += tsize; + for(int i=0; i < message->pairs; ++i) { + // The process of the remote index + MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize); + sendBufferSizes_[neighbour] += tsize; + // The attribute of the remote index + MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize); + sendBufferSizes_[neighbour] += tsize; } - + Dune::dverb< void IndicesSyncer::packAndSend(int destination, char* buffer, std::size_t bufferSize, MPI_Request& request) { typedef typename ParallelIndexSet::const_iterator IndexIterator; - - IndexIterator iEnd = indexSet_.end(); - int bpos = 0; - int published = 0; - int pairs = 0; - + + IndexIterator iEnd = indexSet_.end(); + int bpos = 0; + int published = 0; + int pairs = 0; + assert(checkReset()); - + // Pack the number of indices we publish - MPI_Pack(&(infoSend_[destination].publish), 1, MPI_INT, buffer, bufferSize, &bpos, - remoteIndices_.communicator()); + MPI_Pack(&(infoSend_[destination].publish), 1, MPI_INT, buffer, bufferSize, &bpos, + remoteIndices_.communicator()); - for(IndexIterator index = indexSet_.begin(); index != iEnd; ++index){ + for(IndexIterator index = indexSet_.begin(); index != iEnd; ++index) { // Search for corresponding remote indices in all iterator tuples typedef typename IteratorsMap::iterator Iterator; Iterator iteratorsEnd = iteratorsMap_.end(); // advance all iterators to a position with global index >= index->global() - for(Iterator iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators){ - while(iterators->second.isNotAtEnd() && + for(Iterator iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators) { + while(iterators->second.isNotAtEnd() && iterators->second.globalIndexPair().first < index->global()) - ++(iterators->second); + ++(iterators->second); assert(!iterators->second.isNotAtEnd() || iterators->second.globalIndexPair().first >= index->global()); } - + // Add all remote indices positioned at global which were already present before calling sync // to the message. // Count how many remote indices we will send int indices = 0; bool knownRemote = false; // Is the remote process supposed to know this index? - + for(Iterator iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators) + { + std::pair p; + if (iterators->second.isNotAtEnd()) { - std::pair p; - if (iterators->second.isNotAtEnd()) - { - p = iterators->second.globalIndexPair(); - } - - if(iterators->second.isNotAtEnd() && iterators->second.isOld() - && iterators->second.globalIndexPair().first == index->global()){ - indices++; - if(destination == iterators->first) - knownRemote = true; - } + p = iterators->second.globalIndexPair(); } - + + if(iterators->second.isNotAtEnd() && iterators->second.isOld() + && iterators->second.globalIndexPair().first == index->global()) { + indices++; + if(destination == iterators->first) + knownRemote = true; + } + } + if(!knownRemote) - // We do not need to send any indices - continue; - + // We do not need to send any indices + continue; + Dune::dverb<global()<<" to "<(&(index->global())), 1, MPITraits::getType(), buffer, bufferSize, &bpos, - remoteIndices_.communicator()); - + MPI_Pack(const_cast(&(index->global())), 1, MPITraits::getType(), buffer, bufferSize, &bpos, + remoteIndices_.communicator()); + char attr = index->local().attribute(); - MPI_Pack(&attr, 1, MPI_CHAR, buffer, bufferSize, &bpos, - remoteIndices_.communicator()); + MPI_Pack(&attr, 1, MPI_CHAR, buffer, bufferSize, &bpos, + remoteIndices_.communicator()); // Pack the number of remote indices we send. - MPI_Pack(&indices, 1, MPI_INT, buffer, bufferSize, &bpos, - remoteIndices_.communicator()); - + MPI_Pack(&indices, 1, MPI_INT, buffer, bufferSize, &bpos, + remoteIndices_.communicator()); + // Pack the information about the remote indices for(Iterator iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators) - if(iterators->second.isNotAtEnd() && iterators->second.isOld() - && iterators->second.globalIndexPair().first == index->global()){ - int process = iterators->first; + if(iterators->second.isNotAtEnd() && iterators->second.isOld() + && iterators->second.globalIndexPair().first == index->global()) { + int process = iterators->first; ++pairs; assert(pairs <= infoSend_[destination].pairs); - MPI_Pack(&process, 1, MPI_INT, buffer, bufferSize, &bpos, - remoteIndices_.communicator()); - char attr = iterators->second.remoteIndex().attribute(); - - MPI_Pack(&attr, 1, MPI_CHAR, buffer, bufferSize, &bpos, - remoteIndices_.communicator()); + MPI_Pack(&process, 1, MPI_INT, buffer, bufferSize, &bpos, + remoteIndices_.communicator()); + char attr2 = iterators->second.remoteIndex().attribute(); + + MPI_Pack(&attr2, 1, MPI_CHAR, buffer, bufferSize, &bpos, + remoteIndices_.communicator()); --indices; - } + } assert(indices==0); ++published; Dune::dvverb<<" (publish="< - inline void IndicesSyncer::insertIntoRemoteIndexList(int process, - const std::pair& globalPair, - char attribute) + inline void IndicesSyncer::insertIntoRemoteIndexList(int process, + const std::pair& globalPair, + char attribute) { Dune::dverb<<"Inserting from "<second; - + // Search for the remote index - while(iterators.isNotAtEnd() && iterators.globalIndexPair() < globalPair){ + while(iterators.isNotAtEnd() && iterators.globalIndexPair() < globalPair) { // Increment all iterators ++iterators; - + } - - if(iterators.isAtEnd() || iterators.globalIndexPair() != globalPair){ + + if(iterators.isAtEnd() || iterators.globalIndexPair() != globalPair) { // The entry is not yet known - // Insert in the the list and do not change the first iterator. + // Insert in the list and do not change the first iterator. iterators.insert(RemoteIndex(Attribute(attribute)),globalPair); return; } - + // Global indices match bool indexIsThere=false; - for(Iterators tmpIterators = iterators; + for(Iterators tmpIterators = iterators; !tmpIterators.isAtEnd() && tmpIterators.globalIndexPair() == globalPair; ++tmpIterators) //entry already exists with the same attribute - if(tmpIterators.globalIndexPair().second == attribute){ + if(tmpIterators.globalIndexPair().second == attribute) { indexIsThere=true; break; } - + if(!indexIsThere) // The entry is not yet known - // Insert in the the list and do not change the first iterator. + // Insert in the list and do not change the first iterator. iterators.insert(RemoteIndex(Attribute(attribute)),globalPair); } - + template template void IndicesSyncer::recvAndUnpack(T1& numberer) { typedef typename ParallelIndexSet::const_iterator IndexIterator; - IndexIterator iEnd = indexSet_.end(); - IndexIterator index = indexSet_.begin(); - int bpos = 0; - int publish; - + IndexIterator iEnd = indexSet_.end(); + IndexIterator index = indexSet_.begin(); + int bpos = 0; + int publish; + assert(checkReset()); MPI_Status status; // We have to determine the message size and source before the receive MPI_Probe(MPI_ANY_SOURCE, 345, remoteIndices_.communicator(), &status); - + int source=status.MPI_SOURCE; int count; MPI_Get_count(&status, MPI_PACKED, &count); Dune::dvverb<receiveBufferSize_){ + if(count>receiveBufferSize_) { receiveBufferSize_=count; delete[] receiveBuffer_; receiveBuffer_ = new char[receiveBufferSize_]; } MPI_Recv(receiveBuffer_, count, MPI_PACKED, source, 345, remoteIndices_.communicator(), &status); - + // How many global entries were published? MPI_Unpack(receiveBuffer_, count, &bpos, &publish, 1, MPI_INT, remoteIndices_.communicator()); - + // Now unpack the remote indices and add them. - while(publish>0){ - + while(publish>0) { + // Unpack information about the local index on the source process - GlobalIndex global; // global index of the current entry + GlobalIndex global; // global index of the current entry char sourceAttribute; // Attribute on the source process int pairs; - - MPI_Unpack(receiveBuffer_, count, &bpos, &global, 1, MPITraits::getType(), - remoteIndices_.communicator()); - MPI_Unpack(receiveBuffer_, count, &bpos, &sourceAttribute, 1, MPI_CHAR, - remoteIndices_.communicator()); - MPI_Unpack(receiveBuffer_, count, &bpos, &pairs, 1, MPI_INT, - remoteIndices_.communicator()); - + + MPI_Unpack(receiveBuffer_, count, &bpos, &global, 1, MPITraits::getType(), + remoteIndices_.communicator()); + MPI_Unpack(receiveBuffer_, count, &bpos, &sourceAttribute, 1, MPI_CHAR, + remoteIndices_.communicator()); + MPI_Unpack(receiveBuffer_, count, &bpos, &pairs, 1, MPI_INT, + remoteIndices_.communicator()); + // Insert the entry on the remote process to our // remote index list SLList > sourceAttributeList; @@ -1093,29 +1095,29 @@ bool foundSelf = false; #endif Attribute myAttribute=Attribute(); - + // Unpack the remote indices - for(;pairs>0;--pairs){ - // Unpack the process id that knows the index - int process; - char attribute; - MPI_Unpack(receiveBuffer_, count, &bpos, &process, 1, MPI_INT, - remoteIndices_.communicator()); - // Unpack the attribute - MPI_Unpack(receiveBuffer_, count, &bpos, &attribute, 1, MPI_CHAR, - remoteIndices_.communicator()); + for(; pairs>0; --pairs) { + // Unpack the process id that knows the index + int process; + char attribute; + MPI_Unpack(receiveBuffer_, count, &bpos, &process, 1, MPI_INT, + remoteIndices_.communicator()); + // Unpack the attribute + MPI_Unpack(receiveBuffer_, count, &bpos, &attribute, 1, MPI_CHAR, + remoteIndices_.communicator()); - if(process==rank_){ + if(process==rank_) { #ifndef NDEBUG foundSelf=true; #endif myAttribute=Attribute(attribute); - // Now we know the local attribute of the global index + // Now we know the local attribute of the global index //Only add the index if it is unknown. // Do we know that global index already? IndexIterator pos = std::lower_bound(index, iEnd, IndexPair(global)); - if(pos == iEnd || pos->global() != global){ + if(pos == iEnd || pos->global() != global) { // no entry with this global index indexSet_.add(global, ParallelLocalIndex(numberer(global), @@ -1123,28 +1125,28 @@ Dune::dvverb << "Adding "<global()==global;++pos) - if(pos->local().attribute() == myAttribute){ + for(; pos->global()==global; ++pos) + if(pos->local().attribute() == myAttribute) { Dune::dvverb<<"found "<(numberer(global), - myAttribute, true)); + myAttribute, true)); Dune::dvverb << "Adding "<second); --publish; } - + resetIteratorsMap(); } - + template void IndicesSyncer::resetIteratorsMap(){ - + // Reset iterators in all tuples. typedef typename IteratorsMap::iterator Iterator; - typedef typename RemoteIndices::RemoteIndexMap::iterator - RemoteIterator; + typedef typename RemoteIndices::RemoteIndexMap::iterator + RemoteIterator; typedef typename GlobalIndicesMap::iterator GlobalIterator; typedef typename BoolMap::iterator BoolIterator; - + const RemoteIterator remoteEnd = remoteIndices_.remoteIndices_.end(); Iterator iterators = iteratorsMap_.begin(); GlobalIterator global = globalMap_.begin(); BoolIterator added = oldMap_.begin(); - + for(RemoteIterator remote = remoteIndices_.remoteIndices_.begin(); - remote != remoteEnd; ++remote, ++global, ++added, ++iterators){ + remote != remoteEnd; ++remote, ++global, ++added, ++iterators) { iterators->second.reset(*(remote->second.first), global->second, added->second); } } - + template bool IndicesSyncer::checkReset(const Iterators& iterators, RemoteIndexList& rList, GlobalIndexList& gList, - BoolList& bList){ - - if(get<0>(iterators.iterators_)!=rList.begin()) + BoolList& bList){ + + if(std::get<0>(iterators.iterators_) != rList.begin()) return false; - if(get<1>(iterators.iterators_)!=gList.begin()) + if(std::get<1>(iterators.iterators_) != gList.begin()) return false; - if(get<2>(iterators.iterators_)!=bList.begin()) + if(std::get<2>(iterators.iterators_) != bList.begin()) return false; return true; } - + template bool IndicesSyncer::checkReset(){ - + // Reset iterators in all tuples. typedef typename IteratorsMap::iterator Iterator; - typedef typename RemoteIndices::RemoteIndexMap::iterator - RemoteIterator; + typedef typename RemoteIndices::RemoteIndexMap::iterator + RemoteIterator; typedef typename GlobalIndicesMap::iterator GlobalIterator; typedef typename BoolMap::iterator BoolIterator; - + const RemoteIterator remoteEnd = remoteIndices_.remoteIndices_.end(); Iterator iterators = iteratorsMap_.begin(); GlobalIterator global = globalMap_.begin(); BoolIterator added = oldMap_.begin(); bool ret = true; - + for(RemoteIterator remote = remoteIndices_.remoteIndices_.begin(); - remote != remoteEnd; ++remote, ++global, ++added, ++iterators){ + remote != remoteEnd; ++remote, ++global, ++added, ++iterators) { if(!checkReset(iterators->second, *(remote->second.first), global->second, - added->second)) - ret=false; + added->second)) + ret=false; } return ret; - } + } } #endif diff -Nru dune-common-2.2.1/dune/common/parallel/interface.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/interface.hh --- dune-common-2.2.1/dune/common/parallel/interface.hh 2013-02-26 11:14:37.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/interface.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,15 +1,16 @@ -// $Id$ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_INTERFACE_HH #define DUNE_INTERFACE_HH #if HAVE_MPI -#include"remoteindices.hh" -#include +#include "remoteindices.hh" +#include namespace Dune { - /** @addtogroup Common_Parallel + /** @addtogroup Common_Parallel * * @{ */ @@ -30,10 +31,10 @@ */ class InterfaceBuilder { - public: - class RemotexIndicesStateError : public Exception + public: + class RemoteIndicesStateError : public InvalidStateException {}; - + virtual ~InterfaceBuilder() {} @@ -43,18 +44,18 @@ */ InterfaceBuilder() {} - + /** * @brief Builds the interface between remote processes. * - * - * The types T1 and T2 are classes representing a set of + * + * The types T1 and T2 are classes representing a set of * enumeration values of type InterfaceBuilder::Attribute. They have to provide * a (static) method * \code * bool contains(Attribute flag) const; * \endcode - * for checking whether the set contains a specfic flag. + * for checking whether the set contains a specific flag. * This functionality is for example provided the classes * EnumItem, EnumRange and Combine. * @@ -75,18 +76,18 @@ * // Reserve memory for the interface to processor proc. The interface * // has to hold size entries * void reserve(int proc, int size); - * + * * // Add an entry to the interface * // We will send/receive size entries at index local to process proc * void add(int proc, int local); * \endcode */ template - void buildInterface (const R& remoteIndices, - const T1& sourceFlags, const T2& destFlags, - Op& functor) const; + void buildInterface (const R& remoteIndices, + const T1& sourceFlags, const T2& destFlags, + Op& functor) const; }; - + /** * @brief Information describing an interface. * @@ -96,9 +97,9 @@ */ class InterfaceInformation { - + public: - + /** * @brief Get the number of entries in the interface. */ @@ -132,7 +133,7 @@ { indices_ = new std::size_t[size]; maxSize_ = size; - + } /** * brief Frees allocated memory. @@ -140,7 +141,7 @@ void free() { if(indices_) - delete[] indices_; + delete[] indices_; maxSize_ = 0; size_=0; indices_=0; @@ -153,30 +154,29 @@ assert(size_ > InformationMap; + public: + /** + * @brief The type of the map form process number to InterfaceInformation for + * sending and receiving to and from it. + */ + typedef std::map > InformationMap; /** * @brief Builds the interface. * - * The types T1 and T2 are classes representing a set of + * The types T1 and T2 are classes representing a set of * enumeration values of type Interface::Attribute. They have to provide * a (static) method * \code * bool contains(Attribute flag) const; * \endcode - * for checking whether the set contains a specfic flag. + * for checking whether the set contains a specific flag. * This functionality is for example provided the classes * EnumItem, EnumRange and Combine. * @param remoteIndices The indices known to remote processes. @@ -228,8 +230,8 @@ * @param destFlags The set of flags marking indices we receive for. */ template - void build(const R& remoteIndices, const T1& sourceFlags, - const T2& destFlags); + void build(const R& remoteIndices, const T1& sourceFlags, + const T2& destFlags); /** * @brief Frees memory allocated during the build. @@ -248,17 +250,17 @@ * The key of the map is the process number and the value * is the information pair (first the send and then the receive * information). - */ + */ const InformationMap& interfaces() const; - + Interface(MPI_Comm comm) : communicator_(comm), interfaces_() {} - + Interface() : communicator_(MPI_COMM_NULL), interfaces_() {} - + /** * @brief Print the interface to std::out for debugging. */ @@ -268,28 +270,28 @@ { return ! operator==(o); } - + bool operator==(const Interface& o) const { if(communicator_!=o.communicator_) - return false; + return false; if(interfaces_.size()!=o.interfaces_.size()) - return false; + return false; typedef InformationMap::const_iterator MIter; - + for(MIter m=interfaces_.begin(), om=o.interfaces_.begin(); - m!=interfaces_.end(); ++m, ++om) - { - if(om->first!=m->first) - return false; - if(om->second.first!=om->second.first) - return false; - if(om->second.second!=om->second.second) - return false; - } + m!=interfaces_.end(); ++m, ++om) + { + if(om->first!=m->first) + return false; + if(om->second.first!=om->second.first) + return false; + if(om->second.second!=om->second.second) + return false; + } return true; } - + /** * @brief Destructor. */ @@ -297,7 +299,7 @@ void strip(); protected: - + /** * @brief Get information about the interfaces. * @@ -305,12 +307,12 @@ * The key of the map is the process number and the value * is the information pair (first the send and then the receive * information). - */ + */ InformationMap& interfaces(); /** @brief The MPI communicator we use. */ MPI_Comm communicator_; - + private: /** * @brief Information about the interfaces. @@ -320,103 +322,103 @@ * information). */ InformationMap interfaces_; - + template class InformationBuilder { public: InformationBuilder(InformationMap& interfaces) - : interfaces_(interfaces) + : interfaces_(interfaces) {} - + void reserve(int proc, int size) { - if(send) - interfaces_[proc].first.reserve(size); - else - interfaces_[proc].second.reserve(size); + if(send) + interfaces_[proc].first.reserve(size); + else + interfaces_[proc].second.reserve(size); } void add(int proc, std::size_t local) { - if(send){ - interfaces_[proc].first.add(local); - }else{ - interfaces_[proc].second.add(local); - } + if(send) { + interfaces_[proc].first.add(local); + }else{ + interfaces_[proc].second.add(local); + } } - + private: InformationMap& interfaces_; }; }; - + template void InterfaceBuilder::buildInterface(const R& remoteIndices, const T1& sourceFlags, const T2& destFlags, Op& interfaceInformation) const { if(!remoteIndices.isSynced()) - DUNE_THROW(RemotexIndicesStateError,"RemoteIndices is not in sync with the index set. Call RemoteIndices::rebuild first!"); + DUNE_THROW(RemoteIndicesStateError,"RemoteIndices is not in sync with the index set. Call RemoteIndices::rebuild first!"); // Allocate the memory for the data type construction. typedef R RemoteIndices; typedef typename RemoteIndices::RemoteIndexMap::const_iterator const_iterator; const const_iterator end=remoteIndices.end(); - + int rank; - + MPI_Comm_rank(remoteIndices.communicator(), &rank); - + // Allocate memory for the type construction. - for(const_iterator process=remoteIndices.begin(); process != end; ++process){ + for(const_iterator process=remoteIndices.begin(); process != end; ++process) { // Messure the number of indices send to the remote process first int size=0; typedef typename RemoteIndices::RemoteIndexList::const_iterator RemoteIterator; - const RemoteIterator remoteEnd = send ? process->second.first->end() : - process->second.second->end(); + const RemoteIterator remoteEnd = send ? process->second.first->end() : + process->second.second->end(); RemoteIterator remote = send ? process->second.first->begin() : process->second.second->begin(); - - while(remote!=remoteEnd){ - if( send ? destFlags.contains(remote->attribute()) : - sourceFlags.contains(remote->attribute())){ - - // do we send the index? - if( send ? sourceFlags.contains(remote->localIndexPair().local().attribute()) : - destFlags.contains(remote->localIndexPair().local().attribute())) - ++size; - } - ++remote; + + while(remote!=remoteEnd) { + if( send ? destFlags.contains(remote->attribute()) : + sourceFlags.contains(remote->attribute())) { + + // do we send the index? + if( send ? sourceFlags.contains(remote->localIndexPair().local().attribute()) : + destFlags.contains(remote->localIndexPair().local().attribute())) + ++size; + } + ++remote; } interfaceInformation.reserve(process->first, size); } // compare the local and remote indices and set up the types - - for(const_iterator process=remoteIndices.begin(); process != end; ++process){ + + for(const_iterator process=remoteIndices.begin(); process != end; ++process) { typedef typename RemoteIndices::RemoteIndexList::const_iterator RemoteIterator; - const RemoteIterator remoteEnd = send ? process->second.first->end() : - process->second.second->end(); + const RemoteIterator remoteEnd = send ? process->second.first->end() : + process->second.second->end(); RemoteIterator remote = send ? process->second.first->begin() : process->second.second->begin(); - - while(remote!=remoteEnd){ - if( send ? destFlags.contains(remote->attribute()) : - sourceFlags.contains(remote->attribute())){ - // do we send the index? - if( send ? sourceFlags.contains(remote->localIndexPair().local().attribute()) : - destFlags.contains(remote->localIndexPair().local().attribute())) - interfaceInformation.add(process->first,remote->localIndexPair().local().local()); - } - ++remote; + + while(remote!=remoteEnd) { + if( send ? destFlags.contains(remote->attribute()) : + sourceFlags.contains(remote->attribute())) { + // do we send the index? + if( send ? sourceFlags.contains(remote->localIndexPair().local().attribute()) : + destFlags.contains(remote->localIndexPair().local().attribute())) + interfaceInformation.add(process->first,remote->localIndexPair().local().local()); + } + ++remote; } } } - + inline MPI_Comm Interface::communicator() const { return communicator_; - + } - - + + inline const std::map >& Interface::interfaces() const { return interfaces_; @@ -433,64 +435,64 @@ const const_iterator end=interfaces_.end(); int rank; MPI_Comm_rank(communicator(), &rank); - - for(const_iterator infoPair=interfaces_.begin(); infoPair!=end; ++infoPair){ + + for(const_iterator infoPair=interfaces_.begin(); infoPair!=end; ++infoPair) { { - std::cout<first<<": "; - const InterfaceInformation& info(infoPair->second.first); - for(size_t i=0; i < info.size(); i++) - std::cout<first<<": "; - const InterfaceInformation& info(infoPair->second.second); - for(size_t i=0; i < info.size(); i++) - std::cout<first<<": "; + const InterfaceInformation& info(infoPair->second.first); + for(size_t i=0; i < info.size(); i++) + std::cout<first<<": "; + const InterfaceInformation& info(infoPair->second.second); + for(size_t i=0; i < info.size(); i++) + std::cout< - inline void Interface::build(const R& remoteIndices, const T1& sourceFlags, - const T2& destFlags) + inline void Interface::build(const R& remoteIndices, const T1& sourceFlags, + const T2& destFlags) { communicator_=remoteIndices.communicator(); - + assert(interfaces_.empty()); // Build the send interface InformationBuilder sendInformation(interfaces_); - this->template buildInterface,true>(remoteIndices, sourceFlags, - destFlags, sendInformation); - + this->template buildInterface,true>(remoteIndices, sourceFlags, + destFlags, sendInformation); + // Build the receive interface InformationBuilder recvInformation(interfaces_); - this->template buildInterface,false>(remoteIndices,sourceFlags, - destFlags, recvInformation); + this->template buildInterface,false>(remoteIndices,sourceFlags, + destFlags, recvInformation); strip(); } inline void Interface::strip() { typedef InformationMap::iterator const_iterator; for(const_iterator interfacePair = interfaces_.begin(); interfacePair != interfaces_.end();) - if(interfacePair->second.first.size()==0 && interfacePair->second.second.size()==0){ - interfacePair->second.first.free(); - interfacePair->second.second.free(); - const_iterator toerase=interfacePair++; - interfaces_.erase(toerase); + if(interfacePair->second.first.size()==0 && interfacePair->second.second.size()==0) { + interfacePair->second.first.free(); + interfacePair->second.second.free(); + const_iterator toerase=interfacePair++; + interfaces_.erase(toerase); }else - ++interfacePair; + ++interfacePair; } - + inline void Interface::free() { typedef InformationMap::iterator iterator; typedef InformationMap::const_iterator const_iterator; const const_iterator end = interfaces_.end(); - for(iterator interfacePair = interfaces_.begin(); interfacePair != end; ++interfacePair){ + for(iterator interfacePair = interfaces_.begin(); interfacePair != end; ++interfacePair) { interfacePair->second.first.free(); interfacePair->second.second.free(); } @@ -511,19 +513,19 @@ typedef Dune::Interface::InformationMap InfoMap; typedef InfoMap::const_iterator Iter; for(Iter i=interface.interfaces().begin(), end = interface.interfaces().end(); - i!=end; ++i) - { - os<first<<": [ source=["; - for(std::size_t j=0; j < i->second.first.size(); ++j) - os<second.first[j]<<" "; - os<<"] size="<second.first.size()<<", target=["; - for(std::size_t j=0; j < i->second.second.size(); ++j) - os<second.second[j]<<" "; - os<<"] size="<second.second.size()<<"\n"; - } + i!=end; ++i) + { + os<first<<": [ source=["; + for(std::size_t j=0; j < i->second.first.size(); ++j) + os<second.first[j]<<" "; + os<<"] size="<second.first.size()<<", target=["; + for(std::size_t j=0; j < i->second.second.size(); ++j) + os<second.second[j]<<" "; + os<<"] size="<second.second.size()<<"\n"; + } return os; } -}// end namespace std +} // end namespace std #endif // HAVE_MPI #endif diff -Nru dune-common-2.2.1/dune/common/parallel/localindex.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/localindex.hh --- dune-common-2.2.1/dune/common/parallel/localindex.hh 2010-11-24 17:37:07.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/localindex.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,15 +1,16 @@ -// $Id$ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_LOCALINDEX_HH #define DUNE_COMMON_LOCALINDEX_HH -#include +#include namespace Dune { -/** @addtogroup Common_Parallel + /** @addtogroup Common_Parallel * * @{ */ @@ -23,14 +24,14 @@ * @see LocalIndex::state() */ enum LocalIndexState {VALID, DELETED}; - - + + /** * @brief An index present on the local process. */ class LocalIndex { - public: + public: /** * @brief Constructor. * known to other processes. @@ -38,7 +39,7 @@ LocalIndex() : localIndex_(0), state_(VALID){} - + /** * @brief Constructor. * @param index The value of the index. @@ -78,24 +79,24 @@ private: /** @brief The local index. */ std::size_t localIndex_; - - /** + + /** * @brief The state of the index. * * Has to be one of LocalIndexState! * @see LocalIndexState. */ char state_; - + }; - - inline const std::size_t& LocalIndex::local() const{ + + inline const std::size_t& LocalIndex::local() const { return localIndex_; } - inline LocalIndex::operator std::size_t() const{ + inline LocalIndex::operator std::size_t() const { return localIndex_; } @@ -103,9 +104,9 @@ localIndex_ = index; return *this; } - - inline LocalIndexState LocalIndex::state() const{ - return static_cast(state_); + + inline LocalIndexState LocalIndex::state() const { + return static_cast(state_); } inline void LocalIndex::setState(LocalIndexState state){ diff -Nru dune-common-2.2.1/dune/common/parallel/Makefile.am dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/Makefile.am --- dune-common-2.2.1/dune/common/parallel/Makefile.am 2010-11-24 17:37:08.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -# $Id$ - -SUBDIRS = test - -parallelincludedir = $(includedir)/dune/common/parallel -parallelinclude_HEADERS = communicator.hh \ - indexset.hh \ - indicessyncer.hh \ - interface.hh \ - localindex.hh \ - plocalindex.hh \ - remoteindices.hh \ - selection.hh - - -include $(top_srcdir)/am/global-rules diff -Nru dune-common-2.2.1/dune/common/parallel/mpicollectivecommunication.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/mpicollectivecommunication.hh --- dune-common-2.2.1/dune/common/parallel/mpicollectivecommunication.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/mpicollectivecommunication.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,344 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_MPICOLLECTIVECOMMUNICATION_HH +#define DUNE_MPICOLLECTIVECOMMUNICATION_HH + +/*! + \file + \brief Implements an utility class that provides + MPI's collective communication methods. + + \ingroup ParallelCommunication + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include "collectivecommunication.hh" +#include "mpitraits.hh" + +#if HAVE_MPI +// MPI header +#include + +namespace Dune +{ + + //======================================================= + // use singleton pattern and template specialization to + // generate MPI operations + //======================================================= + + template + class Generic_MPI_Op + { + + public: + static MPI_Op get () + { + if (!op) + { + op = std::shared_ptr(new MPI_Op); + MPI_Op_create((void (*)(void*, void*, int*, MPI_Datatype*))&operation,true,op.get()); + } + return *op; + } + private: + static void operation (Type *in, Type *inout, int *len, MPI_Datatype*) + { + BinaryFunction func; + + for (int i=0; i< *len; ++i, ++in, ++inout) { + Type temp; + temp = func(*in, *inout); + *inout = temp; + } + } + Generic_MPI_Op () {} + Generic_MPI_Op (const Generic_MPI_Op& ) {} + static std::shared_ptr op; + }; + + + template + std::shared_ptr Generic_MPI_Op::op = std::shared_ptr(static_cast(0)); + +#define ComposeMPIOp(type,func,op) \ + template<> \ + class Generic_MPI_Op >{ \ + public:\ + static MPI_Op get(){ \ + return op; \ + } \ + private:\ + Generic_MPI_Op () {}\ + Generic_MPI_Op (const Generic_MPI_Op & ) {}\ + } + + + ComposeMPIOp(char, std::plus, MPI_SUM); + ComposeMPIOp(unsigned char, std::plus, MPI_SUM); + ComposeMPIOp(short, std::plus, MPI_SUM); + ComposeMPIOp(unsigned short, std::plus, MPI_SUM); + ComposeMPIOp(int, std::plus, MPI_SUM); + ComposeMPIOp(unsigned int, std::plus, MPI_SUM); + ComposeMPIOp(long, std::plus, MPI_SUM); + ComposeMPIOp(unsigned long, std::plus, MPI_SUM); + ComposeMPIOp(float, std::plus, MPI_SUM); + ComposeMPIOp(double, std::plus, MPI_SUM); + ComposeMPIOp(long double, std::plus, MPI_SUM); + + ComposeMPIOp(char, std::multiplies, MPI_PROD); + ComposeMPIOp(unsigned char, std::multiplies, MPI_PROD); + ComposeMPIOp(short, std::multiplies, MPI_PROD); + ComposeMPIOp(unsigned short, std::multiplies, MPI_PROD); + ComposeMPIOp(int, std::multiplies, MPI_PROD); + ComposeMPIOp(unsigned int, std::multiplies, MPI_PROD); + ComposeMPIOp(long, std::multiplies, MPI_PROD); + ComposeMPIOp(unsigned long, std::multiplies, MPI_PROD); + ComposeMPIOp(float, std::multiplies, MPI_PROD); + ComposeMPIOp(double, std::multiplies, MPI_PROD); + ComposeMPIOp(long double, std::multiplies, MPI_PROD); + + ComposeMPIOp(char, Min, MPI_MIN); + ComposeMPIOp(unsigned char, Min, MPI_MIN); + ComposeMPIOp(short, Min, MPI_MIN); + ComposeMPIOp(unsigned short, Min, MPI_MIN); + ComposeMPIOp(int, Min, MPI_MIN); + ComposeMPIOp(unsigned int, Min, MPI_MIN); + ComposeMPIOp(long, Min, MPI_MIN); + ComposeMPIOp(unsigned long, Min, MPI_MIN); + ComposeMPIOp(float, Min, MPI_MIN); + ComposeMPIOp(double, Min, MPI_MIN); + ComposeMPIOp(long double, Min, MPI_MIN); + + ComposeMPIOp(char, Max, MPI_MAX); + ComposeMPIOp(unsigned char, Max, MPI_MAX); + ComposeMPIOp(short, Max, MPI_MAX); + ComposeMPIOp(unsigned short, Max, MPI_MAX); + ComposeMPIOp(int, Max, MPI_MAX); + ComposeMPIOp(unsigned int, Max, MPI_MAX); + ComposeMPIOp(long, Max, MPI_MAX); + ComposeMPIOp(unsigned long, Max, MPI_MAX); + ComposeMPIOp(float, Max, MPI_MAX); + ComposeMPIOp(double, Max, MPI_MAX); + ComposeMPIOp(long double, Max, MPI_MAX); + +#undef ComposeMPIOp + + + //======================================================= + // use singleton pattern and template specialization to + // generate MPI operations + //======================================================= + + /*! \brief Specialization of CollectiveCommunication for MPI + \ingroup ParallelCommunication + */ + template<> + class CollectiveCommunication + { + public: + //! Instantiation using a MPI communicator + CollectiveCommunication (const MPI_Comm& c = MPI_COMM_WORLD) + : communicator(c) + { + if(communicator!=MPI_COMM_NULL) { + int initialized = 0; + MPI_Initialized(&initialized); + if (!initialized) + DUNE_THROW(ParallelError,"You must call MPIHelper::instance(argc,argv) in your main() function before using the MPI CollectiveCommunication!"); + MPI_Comm_rank(communicator,&me); + MPI_Comm_size(communicator,&procs); + }else{ + procs=0; + me=-1; + } + } + + //! @copydoc CollectiveCommunication::rank + int rank () const + { + return me; + } + + //! @copydoc CollectiveCommunication::size + int size () const + { + return procs; + } + + //! @copydoc CollectiveCommunication::sum + template + T sum (T& in) const // MPI does not know about const :-( + { + T out; + allreduce >(&in,&out,1); + return out; + } + + //! @copydoc CollectiveCommunication::sum + template + int sum (T* inout, int len) const + { + return allreduce >(inout,len); + } + + //! @copydoc CollectiveCommunication::prod + template + T prod (T& in) const // MPI does not know about const :-( + { + T out; + allreduce >(&in,&out,1); + return out; + } + + //! @copydoc CollectiveCommunication::prod + template + int prod (T* inout, int len) const + { + return allreduce >(inout,len); + } + + //! @copydoc CollectiveCommunication::min + template + T min (T& in) const // MPI does not know about const :-( + { + T out; + allreduce >(&in,&out,1); + return out; + } + + //! @copydoc CollectiveCommunication::min + template + int min (T* inout, int len) const + { + return allreduce >(inout,len); + } + + + //! @copydoc CollectiveCommunication::max + template + T max (T& in) const // MPI does not know about const :-( + { + T out; + allreduce >(&in,&out,1); + return out; + } + + //! @copydoc CollectiveCommunication::max + template + int max (T* inout, int len) const + { + return allreduce >(inout,len); + } + + //! @copydoc CollectiveCommunication::barrier + int barrier () const + { + return MPI_Barrier(communicator); + } + + //! @copydoc CollectiveCommunication::broadcast + template + int broadcast (T* inout, int len, int root) const + { + return MPI_Bcast(inout,len,MPITraits::getType(),root,communicator); + } + + //! @copydoc CollectiveCommunication::gather() + //! @note out must have space for P*len elements + template + int gather (T* in, T* out, int len, int root) const + { + return MPI_Gather(in,len,MPITraits::getType(), + out,len,MPITraits::getType(), + root,communicator); + } + + //! @copydoc CollectiveCommunication::gatherv() + template + int gatherv (T* in, int sendlen, T* out, int* recvlen, int* displ, int root) const + { + return MPI_Gatherv(in,sendlen,MPITraits::getType(), + out,recvlen,displ,MPITraits::getType(), + root,communicator); + } + + //! @copydoc CollectiveCommunication::scatter() + //! @note out must have space for P*len elements + template + int scatter (T* send, T* recv, int len, int root) const + { + return MPI_Scatter(send,len,MPITraits::getType(), + recv,len,MPITraits::getType(), + root,communicator); + } + + //! @copydoc CollectiveCommunication::scatterv() + template + int scatterv (T* send, int* sendlen, int* displ, T* recv, int recvlen, int root) const + { + return MPI_Scatterv(send,sendlen,displ,MPITraits::getType(), + recv,recvlen,MPITraits::getType(), + root,communicator); + } + + + operator MPI_Comm () const + { + return communicator; + } + + //! @copydoc CollectiveCommunication::allgather() + template + int allgather(T* sbuf, int count, T1* rbuf) const + { + return MPI_Allgather(sbuf, count, MPITraits::getType(), + rbuf, count, MPITraits::getType(), + communicator); + } + + //! @copydoc CollectiveCommunication::allgatherv() + template + int allgatherv (T* in, int sendlen, T* out, int* recvlen, int* displ) const + { + return MPI_Allgatherv(in,sendlen,MPITraits::getType(), + out,recvlen,displ,MPITraits::getType(), + communicator); + } + + //! @copydoc CollectiveCommunication::allreduce(Type* inout,int len) const + template + int allreduce(Type* inout, int len) const + { + Type* out = new Type[len]; + int ret = allreduce(inout,out,len); + std::copy(out, out+len, inout); + delete[] out; + return ret; + } + + //! @copydoc CollectiveCommunication::allreduce(Type* in,Type* out,int len) const + template + int allreduce(Type* in, Type* out, int len) const + { + return MPI_Allreduce(in, out, len, MPITraits::getType(), + (Generic_MPI_Op::get()),communicator); + } + + private: + MPI_Comm communicator; + int me; + int procs; + }; +} // namespace dune + +#endif +#endif diff -Nru dune-common-2.2.1/dune/common/parallel/mpiguard.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/mpiguard.hh --- dune-common-2.2.1/dune/common/parallel/mpiguard.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/mpiguard.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,214 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +/** + * @file + * @brief Implements a MPIGuard which detects an error on a remote process + * @author Christian Engwer + * @ingroup ParallelCommunication + */ + +#ifndef DUNE_COMMON_MPIGUARD_HH +#define DUNE_COMMON_MPIGUARD_HH + +#include "mpihelper.hh" +#include "collectivecommunication.hh" +#include "mpicollectivecommunication.hh" +#include + +namespace Dune +{ + +#ifndef DOXYGEN + + /* + Interface class for the communication needed by MPIGuard + */ + struct GuardCommunicator + { + // cleanup + virtual ~GuardCommunicator() {}; + // all the communication methods we need + virtual int rank() = 0; + virtual int size() = 0; + virtual int sum(int i) = 0; + // create a new GuardCommunicator pointer + template + static GuardCommunicator * create(const C & c); + }; + + namespace { + /* + templated implementation of different communication classes + */ + // the default class will always fail, due to the missing implementation of "sum" + template + struct GenericGuardCommunicator + : public GuardCommunicator + {}; + // specialization for CollectiveCommunication + template + struct GenericGuardCommunicator< CollectiveCommunication > + : public GuardCommunicator + { + const CollectiveCommunication comm; + GenericGuardCommunicator(const CollectiveCommunication & c) : + comm(c) {} + virtual int rank() { return comm.rank(); }; + virtual int size() { return comm.size(); }; + virtual int sum(int i) { return comm.sum(i); } + }; + +#if HAVE_MPI + // specialization for MPI_Comm + template <> + struct GenericGuardCommunicator + : public GenericGuardCommunicator< CollectiveCommunication > + { + GenericGuardCommunicator(const MPI_Comm & c) : + GenericGuardCommunicator< CollectiveCommunication >( + CollectiveCommunication(c)) {} + }; +#endif + } // anonymous namespace + + template + GuardCommunicator * GuardCommunicator::create(const C & comm) + { + return new GenericGuardCommunicator(comm); + } +#endif + + /*! @brief This exception is thrown if the MPIGuard detects an error on a remote process + @ingroup ParallelCommunication + */ + class MPIGuardError : public ParallelError {}; + + /*! @brief detects a thrown exception and communicates to all other processes + @ingroup ParallelCommunication + + @code + { + MPIGuard guard(...); + + do_something(); + + // tell the guard that you successfully passed a critical operation + guard.finalize(); + // reactivate the guard for the next critical operation + guard.reactivate(); + + int result = do_something_else(); + + // tell the guard the result of your operation + guard.finalize(result == success); + } + @endcode + + You create a MPIGuard object. If an exception is risen on a + process the MPIGuard detects the exception, because the finalize + method was not called. when reaching the finalize call all + other processes are informed that an error occurred and the + MPIGuard throws an exception of type MPIGuardError. + + @note You can initialize the MPIGuard from different types of communication objects: + - MPIHelper + - CollectiveCommunication + - MPI_Comm + */ + class MPIGuard + { + GuardCommunicator * comm_; + bool active_; + + // we don't want to copy this class + MPIGuard (const MPIGuard &); + + public: + /*! @brief create an MPIGuard operating on the Communicator of the global Dune::MPIHelper + + @param active should the MPIGuard be active upon creation? + */ + MPIGuard (bool active=true) : + comm_(GuardCommunicator::create( + MPIHelper::getCollectiveCommunication())), + active_(active) + {} + + /*! @brief create an MPIGuard operating on the Communicator of a special Dune::MPIHelper m + + @param m a reference to an MPIHelper + @param active should the MPIGuard be active upon creation? + */ + MPIGuard (MPIHelper & m, bool active=true) : + comm_(GuardCommunicator::create( + m.getCollectiveCommunication())), + active_(active) + {} + + /*! @brief create an MPIGuard operating on an arbitrary communicator. + + Supported types for the communication object are: + - MPIHelper + - CollectiveCommunication + - MPI_Comm + + @param comm reference to a communication object + @param active should the MPIGuard be active upon creation? + */ + template + MPIGuard (const C & comm, bool active=true) : + comm_(GuardCommunicator::create(comm)), + active_(active) + {} + + /*! @brief destroy the guard and check for undetected exceptions + */ + ~MPIGuard() + { + if (active_) + { + active_ = false; + finalize(false); + } + delete comm_; + } + + /*! @brief reactivate the guard. + + If the guard is still active finalize(true) is called first. + */ + void reactivate() { + if (active_ == true) + finalize(); + active_ = true; + } + + /*! @brief stop the guard. + + If no success parameter is passed, the guard assumes that + everything worked as planned. All errors are communicated + and an exception of type MPIGuardError is thrown if an error + (or exception) occurred on any of the processors in the + communicator. + + @param success inform the guard about possible errors + */ + void finalize(bool success = true) + { + int result = success ? 0 : 1; + bool was_active = active_; + active_ = false; + result = comm_->sum(result); + if (result>0 && was_active) + { + DUNE_THROW(MPIGuardError, "Terminating process " + << comm_->rank() << " due to " + << result << " remote error(s)"); + } + } + }; + +} + +#endif // DUNE_COMMON_MPIGUARD_HH diff -Nru dune-common-2.2.1/dune/common/parallel/mpihelper.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/mpihelper.hh --- dune-common-2.2.1/dune/common/parallel/mpihelper.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/mpihelper.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,289 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_MPIHELPER +#define DUNE_MPIHELPER + +#include +#include "collectivecommunication.hh" +#if HAVE_MPI +#include "mpi.h" +#include "mpicollectivecommunication.hh" +#endif + +#include +#include + +namespace Dune +{ + /** + * @file + * @brief Helpers for dealing with MPI. + * + * @ingroup ParallelCommunication + * + * Basically there are two helpers available: + *

+ *
FakeMPIHelper
+ *
A class adhering to the interface of MPIHelper + * that does not need MPI at all. This can be used + * to create a sequential program even if MPI is + * used to compile it. + *
+ *
MPIHelper
+ *
A real MPI helper. When the singleton + * gets instantiated MPI_Init will be + * called and before the program exits + * MPI_Finalize will be called. + *
+ *
+ * + * Example of who to use these classes: + * + * A program that is parallel if compiled with MPI + * and sequential otherwise: + * \code + * int main(int argc, char** argv){ + * typedef Dune::MPIHelper MPIHelper; + * MPIHelper::instance(argc, argv); + * typename MPIHelper::MPICommunicator world = + * MPIHelper::getCommunicator(); + * ... + * \endcode + * + * If one wants to have sequential program even if the code is + * compiled with mpi then one simply has to exchange the typedef + * with \code typedef Dune::MPIHelper FakeMPIHelper; \endcode. + * + * For checking whether we really use MPI or just fake please use + * MPIHelper::isFake (this is also possible at compile time!) + */ + /** + * @brief A fake mpi helper. + * + * This helper can be used if no MPI is available + * or one wants to run sequentially even if MPI is + * available and used. + */ + class FakeMPIHelper + { + public: + enum { + /** + * @brief Are we fake (i.e. pretend to have MPI support but are compiled + * without.) + */ + isFake = true + }; + + /** + * @brief The type of the mpi communicator. + */ + typedef No_Comm MPICommunicator; + + /** \brief get the default communicator + * + * Return a communicator to exchange data with all processes + * + * \returns a fake communicator + */ + DUNE_EXPORT static MPICommunicator getCommunicator () + { + static MPICommunicator comm; + return comm; + } + + /** \brief get a local communicator + * + * Returns a communicator to communicate with the local process only + * + * \returns a fake communicator + */ + static MPICommunicator getLocalCommunicator () + { + return getCommunicator(); + } + + + + static CollectiveCommunication + getCollectiveCommunication() + { + return CollectiveCommunication(getCommunicator()); + } + + /** + * @brief Get the singleton instance of the helper. + * + * This method has to be called with the same arguments + * that the main method of the program was called: + * \code + * int main(int argc, char** argv){ + * MPIHelper::instance(argc, argv); + * // program code comes here + * ... + * } + * \endcode + * @param argc The number of arguments provided to main. + * @param argv The arguments provided to main. + */ + DUNE_EXPORT static FakeMPIHelper& instance(int argc, char** argv) + { + (void)argc; (void)argv; + // create singleton instance + static FakeMPIHelper singleton; + return singleton; + } + + /** + * @brief return rank of process, i.e. zero + */ + int rank () const { return 0; } + /** + * @brief return rank of process, i.e. one + */ + int size () const { return 1; } + + private: + FakeMPIHelper() {} + FakeMPIHelper(const FakeMPIHelper&); + FakeMPIHelper& operator=(const FakeMPIHelper); + }; + +#if HAVE_MPI + /** + * @brief A real mpi helper. + * @ingroup ParallelCommunication + * + * This helper should be used for parallel programs. + */ + class MPIHelper + { + public: + enum { + /** + * @brief Are we fake (i. e. pretend to have MPI support but are compiled + * without. + */ + isFake = false + }; + + /** + * @brief The type of the mpi communicator. + */ + typedef MPI_Comm MPICommunicator; + + /** \brief get the default communicator + * + * Return a communicator to exchange data with all processes + * + * \returns MPI_COMM_WORLD + */ + static MPICommunicator getCommunicator () + { + return MPI_COMM_WORLD; + } + + /** \brief get a local communicator + * + * Returns a communicator to exchange data with the local process only + * + * \returns MPI_COMM_SELF + */ + static MPICommunicator getLocalCommunicator () + { + return MPI_COMM_SELF; + } + + static CollectiveCommunication + getCollectiveCommunication() + { + return CollectiveCommunication(getCommunicator()); + } + /** + * @brief Get the singleton instance of the helper. + * + * This method has to be called with the same arguments + * that the main method of the program was called: + * \code + * int main(int argc, char** argv){ + * MPIHelper::instance(argc, argv); + * // program code comes here + * ... + * } + * \endcode + * @param argc The number of arguments provided to main. + * @param argv The arguments provided to main. + */ + DUNE_EXPORT static MPIHelper& instance(int& argc, char**& argv) + { + // create singleton instance + static MPIHelper singleton (argc, argv); + return singleton; + } + + /** + * @brief return rank of process + */ + int rank () const { return rank_; } + /** + * @brief return number of processes + */ + int size () const { return size_; } + + private: + int rank_; + int size_; + bool initializedHere_; + void prevent_warning(int){} + + //! \brief calls MPI_Init with argc and argv as parameters + MPIHelper(int& argc, char**& argv) + : initializedHere_(false) + { + int wasInitialized = -1; + MPI_Initialized( &wasInitialized ); + if(!wasInitialized) + { + rank_ = -1; + size_ = -1; + static int is_initialized = MPI_Init(&argc, &argv); + prevent_warning(is_initialized); + initializedHere_ = true; + } + + MPI_Comm_rank(MPI_COMM_WORLD,&rank_); + MPI_Comm_size(MPI_COMM_WORLD,&size_); + + assert( rank_ >= 0 ); + assert( size_ >= 1 ); + + dverb << "Called MPI_Init on p=" << rank_ << "!" << std::endl; + } + //! \brief calls MPI_Finalize + ~MPIHelper() + { + int wasFinalized = -1; + MPI_Finalized( &wasFinalized ); + if(!wasFinalized && initializedHere_) + { + MPI_Finalize(); + dverb << "Called MPI_Finalize on p=" << rank_ << "!" < +#endif + +#include +#include +#include +#include + +namespace Dune +{ + /** @addtogroup ParallelCommunication + * + * @{ + */ + /** + * @file + * @brief Traits classes for mapping types onto MPI_Datatype. + * @author Markus Blatt + */ + +#if HAVE_MPI + /** + * @brief A traits class describing the mapping of types onto MPI_Datatypes. + * + * Specializations exist for the default types. + * Specializations should provide a static method + * \code + * static MPI_Datatype getType(); + * \endcode + */ + template + struct MPITraits + { + private: + MPITraits(){} + MPITraits(const MPITraits&){} + static MPI_Datatype datatype; + static MPI_Datatype vectortype; + public: + static inline MPI_Datatype getType() + { + if(datatype==MPI_DATATYPE_NULL) { + MPI_Type_contiguous(sizeof(T),MPI_BYTE,&datatype); + MPI_Type_commit(&datatype); + } + return datatype; + } + + }; + template + MPI_Datatype MPITraits::datatype = MPI_DATATYPE_NULL; + +#ifndef DOXYGEN +#if HAVE_MPI + + // A Macro for defining traits for the primitive data types +#define ComposeMPITraits(p,m) \ + template<> \ + struct MPITraits

{ \ + static inline MPI_Datatype getType(){ \ + return m; \ + } \ + } + + ComposeMPITraits(char, MPI_CHAR); + ComposeMPITraits(unsigned char,MPI_UNSIGNED_CHAR); + ComposeMPITraits(short,MPI_SHORT); + ComposeMPITraits(unsigned short,MPI_UNSIGNED_SHORT); + ComposeMPITraits(int,MPI_INT); + ComposeMPITraits(unsigned int,MPI_UNSIGNED); + ComposeMPITraits(long,MPI_LONG); + ComposeMPITraits(unsigned long,MPI_UNSIGNED_LONG); + ComposeMPITraits(float,MPI_FLOAT); + ComposeMPITraits(double,MPI_DOUBLE); + ComposeMPITraits(long double,MPI_LONG_DOUBLE); + + +#undef ComposeMPITraits + + template class FieldVector; + + template + struct MPITraits > + { + static MPI_Datatype datatype; + static MPI_Datatype vectortype; + + static inline MPI_Datatype getType() + { + if(datatype==MPI_DATATYPE_NULL) { + MPI_Type_contiguous(n, MPITraits::getType(), &vectortype); + MPI_Type_commit(&vectortype); + FieldVector fvector; + MPI_Aint base; + MPI_Aint displ; + MPI_Get_address(&fvector, &base); + MPI_Get_address(&(fvector[0]), &displ); + displ -= base; + int length[1]={1}; + + MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype); + MPI_Type_commit(&datatype); + } + return datatype; + } + + }; + + template + MPI_Datatype MPITraits >::datatype = MPI_DATATYPE_NULL; + template + MPI_Datatype MPITraits >::vectortype = {MPI_DATATYPE_NULL}; + + + template + class bigunsignedint; + + template + struct MPITraits > + { + static MPI_Datatype datatype; + static MPI_Datatype vectortype; + + static inline MPI_Datatype getType() + { + if(datatype==MPI_DATATYPE_NULL) { + MPI_Type_contiguous(bigunsignedint::n, MPITraits::getType(), + &vectortype); + //MPI_Type_commit(&vectortype); + bigunsignedint data; + MPI_Aint base; + MPI_Aint displ; + MPI_Get_address(&data, &base); + MPI_Get_address(&(data.digit), &displ); + displ -= base; + int length[1]={1}; + MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype); + MPI_Type_commit(&datatype); + } + return datatype; + } + }; +} + +namespace Dune +{ + template + MPI_Datatype MPITraits >::datatype = MPI_DATATYPE_NULL; + template + MPI_Datatype MPITraits >::vectortype = MPI_DATATYPE_NULL; + + template + struct MPITraits > + { + public: + inline static MPI_Datatype getType(); + private: + static MPI_Datatype type; + }; + template + MPI_Datatype MPITraits >::getType() + { + if(type==MPI_DATATYPE_NULL) { + int length[2] = {1, 1}; + MPI_Aint disp[2]; + MPI_Datatype types[2] = {MPITraits::getType(), + MPITraits::getType()}; + + using Pair = std::pair; + static_assert(std::is_standard_layout::value, "offsetof() is only defined for standard layout types"); + disp[0] = offsetof(Pair, first); + disp[1] = offsetof(Pair, second); + + MPI_Datatype tmp; + MPI_Type_create_struct(2, length, disp, types, &tmp); + + MPI_Type_create_resized(tmp, 0, sizeof(Pair), &type); + MPI_Type_commit(&type); + + MPI_Type_free(&tmp); + } + return type; + } + + template + MPI_Datatype MPITraits >::type=MPI_DATATYPE_NULL; +#endif +#endif +#endif + /** @} */ +} + +#endif diff -Nru dune-common-2.2.1/dune/common/parallel/plocalindex.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/plocalindex.hh --- dune-common-2.2.1/dune/common/parallel/plocalindex.hh 2013-02-07 12:44:27.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/plocalindex.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,19 +1,20 @@ -// $Id$ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_PLOCALINDEX_HH #define DUNE_PLOCALINDEX_HH #include "localindex.hh" #include "indexset.hh" -#include +#include "mpitraits.hh" -#include +#include namespace Dune { -/** @addtogroup Common_Parallel + /** @addtogroup Common_Parallel * * @{ */ @@ -34,7 +35,7 @@ std::ostream& operator<<(std::ostream& os, const ParallelLocalIndex& index) { os<<"{local="< >; + friend struct MPITraits >; #endif friend std::ostream& operator<<<>(std::ostream& os, const ParallelLocalIndex& index); - public: + public: /** * @brief The type of the attributes. * Normally this will be an enumeration like @@ -62,9 +63,9 @@ /** * @brief Constructor. * - * The local index will be initialized to 0. + * The local index will be initialized to 0. * @param attribute The attribute of the index. - * @param isPublic True if the index might also be + * @param isPublic True if the index might also be * known to other processes. */ ParallelLocalIndex(const Attribute& attribute, bool isPublic); @@ -74,7 +75,7 @@ * * @param localIndex The local index. * @param attribute The attribute of the index. - * @param isPublic True if the index might also be + * @param isPublic True if the index might also be * known to other processes. */ ParallelLocalIndex(size_t localIndex, const Attribute& attribute, bool isPublic=true); @@ -91,10 +92,10 @@ * @param globalIndex The global index. * @param attribute The attribute of the index. * @param local The local index. - * @param isPublic True if the index might also be + * @param isPublic True if the index might also be * known to other processes. * - */ + */ ParallelLocalIndex(const Attribute& attribute, size_t local, bool isPublic); #endif @@ -128,7 +129,7 @@ */ inline ParallelLocalIndex& operator=(size_t index); - /** + /** * @brief Check whether the index might also be known other processes. * @return True if the index might be known to other processors. */ @@ -149,21 +150,21 @@ private: /** @brief The local index. */ size_t localIndex_; - + /** @brief An attribute for the index. */ char attribute_; /** @brief True if the index is also known to other processors. */ char public_; - /** + /** * @brief The state of the index. * * Has to be one of LocalIndexState! * @see LocalIndexState. */ char state_; - + }; template @@ -184,12 +185,12 @@ { return !(p1==p2); } - - + + template struct LocalIndexComparator > { - static bool compare(const ParallelLocalIndex& t1, + static bool compare(const ParallelLocalIndex& t1, const ParallelLocalIndex& t2){ return t1.attribute() - ParallelLocalIndex::ParallelLocalIndex(const Attribute& attribute, bool isPublic) - : localIndex_(0), attribute_(static_cast(attribute)), + ParallelLocalIndex::ParallelLocalIndex(const T& attribute, bool isPublic) + : localIndex_(0), attribute_(static_cast(attribute)), public_(static_cast(isPublic)), state_(static_cast(VALID)) {} template - ParallelLocalIndex::ParallelLocalIndex(size_t local, const Attribute& attribute, bool isPublic) - : localIndex_(local), attribute_(static_cast(attribute)), + ParallelLocalIndex::ParallelLocalIndex(size_t local, const T& attribute, bool isPublic) + : localIndex_(local), attribute_(static_cast(attribute)), public_(static_cast(isPublic)), state_(static_cast(VALID)) {} template - ParallelLocalIndex::ParallelLocalIndex() - : localIndex_(0), attribute_(), public_(static_cast(false)), + ParallelLocalIndex::ParallelLocalIndex() + : localIndex_(0), attribute_(), public_(static_cast(false)), state_(static_cast(VALID)) {} @@ -237,7 +238,7 @@ } template - inline void + inline void ParallelLocalIndex::setAttribute(const Attribute& attribute) { attribute_ = attribute; @@ -254,9 +255,9 @@ { return localIndex_; } - + template - inline ParallelLocalIndex& + inline ParallelLocalIndex& ParallelLocalIndex::operator=(size_t index) { localIndex_=index; @@ -286,24 +287,27 @@ template MPI_Datatype MPITraits >::getType() { - - if(type==MPI_DATATYPE_NULL){ - int length[3]; - MPI_Aint disp[3]; - MPI_Datatype types[3] = {MPI_LB, MPITraits::getType(), MPI_UB}; - ParallelLocalIndex rep[2]; - length[0]=length[1]=length[2]=1; - MPI_Address(rep, disp); // lower bound of the datatype - MPI_Address(&(rep[0].attribute_), disp+1); - MPI_Address(rep+1, disp+2); // upper bound of the datatype - for(int i=2; i >= 0; --i) - disp[i] -= disp[0]; - MPI_Type_struct(3, length, disp, types, &type); + + if(type==MPI_DATATYPE_NULL) { + int length = 1; + MPI_Aint base, disp; + MPI_Datatype types[1] = {MPITraits::getType()}; + ParallelLocalIndex rep; + MPI_Get_address(&rep, &base); + MPI_Get_address(&(rep.attribute_), &disp); + disp -= base; + + MPI_Datatype tmp; + MPI_Type_create_struct(1, &length, &disp, types, &tmp); + + MPI_Type_create_resized(tmp, 0, sizeof(ParallelLocalIndex), &type); MPI_Type_commit(&type); + + MPI_Type_free(&tmp); } return type; } - + template MPI_Datatype MPITraits >::type = MPI_DATATYPE_NULL; diff -Nru dune-common-2.2.1/dune/common/parallel/remoteindices.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/remoteindices.hh --- dune-common-2.2.1/dune/common/parallel/remoteindices.hh 2013-02-26 11:14:37.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/remoteindices.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,30 +1,30 @@ -// $Id$ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_REMOTEINDICES_HH #define DUNE_REMOTEINDICES_HH -#include"indexset.hh" +#include "indexset.hh" +#include "plocalindex.hh" #include -#include"plocalindex.hh" -#include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #if HAVE_MPI -#include -#include"mpi.h" +#include "mpitraits.hh" +#include -namespace Dune{ +namespace Dune { /** @addtogroup Common_Parallel * * @{ */ - /** + /** * @file * @brief Classes describing a distributed indexset * @author Markus Blatt @@ -39,25 +39,25 @@ private: static MPI_Datatype type; }; - - + + template class RemoteIndices; - + template class RemoteIndex; - + template class IndicesSyncer; - + template std::ostream& operator<<(std::ostream& os, const RemoteIndex& index); - + template class RemoteIndexListModifier; - + /** * @brief Information about an index residing on another processor. */ @@ -68,14 +68,14 @@ friend class IndicesSyncer; template - friend void repairLocalIndexPointers(std::map,A> >&, + friend void repairLocalIndexPointers(std::map,A> >&, RemoteIndices&, const T&); template friend class RemoteIndexListModifier; - public: + public: /** * @brief the type of the global index. * This type has to provide at least a operator< for sorting. @@ -96,7 +96,7 @@ */ typedef IndexPair > PairType; - + /** * @brief Get the attribute of the index on the remote process. * @return The remote attribute. @@ -114,18 +114,18 @@ * @brief Parameterless Constructor. */ RemoteIndex(); - - - /** + + + /** * @brief Constructor. * @param attribute The attribute of the index on the remote processor. * @param local The corresponding local index. */ - RemoteIndex(const T2& attribute, - const PairType* local); + RemoteIndex(const T2& attribute, + const PairType* local); + - - /** + /** * @brief Constructor. * Private as it should only be called from within Indexset. * @param attribute The attribute of the index on the remote processor. @@ -133,7 +133,7 @@ RemoteIndex(const T2& attribute); bool operator==(const RemoteIndex& ri) const; - + bool operator!=(const RemoteIndex& ri) const; private: /** @brief The corresponding local index for this process. */ @@ -142,72 +142,72 @@ /** @brief The attribute of the index on the other process. */ char attribute_; }; - + template std::ostream& operator<<(std::ostream& os, const RemoteIndices& indices); - + class InterfaceBuilder; template class CollectiveIterator; template - class IndicesSyncer; - + class IndicesSyncer; + // forward declaration needed for friend declaration. template class OwnerOverlapCopyCommunication; - + /** * @brief The indices present on remote processes. * - * To set up communication between the set of processes active in + * To set up communication between the set of processes active in * the communication every process needs to know which - * indices are also known to other processes and which attributes + * indices are also known to other processes and which attributes * are attached to them on the remote side. * * This information is managed by this class. The information can either * be computed automatically calling rebuild (which requires information - * to be sent in a ring) or set up by hand using the + * to be sent in a ring) or set up by hand using the * RemoteIndexListModifiers returned by function getModifier(int). * * @tparam T The type of the underlying index set. * @tparam A The type of the allocator to use. */ template > > + typename T::LocalIndex::Attribute> > > class RemoteIndices { friend class InterfaceBuilder; friend class IndicesSyncer; template - friend void repairLocalIndexPointers(std::map,A2> >&, + friend void repairLocalIndexPointers(std::map,A2> >&, RemoteIndices&, const T1&); - + template friend void fillIndexSetHoles(const G& graph, Dune::OwnerOverlapCopyCommunication& oocomm); friend std::ostream& operator<<<>(std::ostream&, const RemoteIndices&); - + public: - + /** * @brief Type of the index set we use, e.g. ParallelLocalIndexSet. */ typedef T ParallelIndexSet; - + /** * @brief The type of the collective iterator over all remote indices. */ typedef CollectiveIterator CollectiveIteratorT; - - /** + + /** * @brief The type of the global index. */ typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; - - - /** + + + /** * @brief The type of the local index. */ typedef typename ParallelIndexSet::LocalIndex LocalIndex; @@ -216,13 +216,13 @@ * @brief The type of the attribute. */ typedef typename LocalIndex::Attribute Attribute; - + /** * @brief Type of the remote indices we manage. */ typedef Dune::RemoteIndex RemoteIndex; - + /** * @brief The type of the allocator for the remote index list. */ @@ -231,87 +231,87 @@ /** @brief The type of the remote index list. */ typedef Dune::SLList RemoteIndexList; - + /** @brief The type of the map from rank to remote index list. */ typedef std::map > - RemoteIndexMap; - + RemoteIndexMap; + typedef typename RemoteIndexMap::const_iterator const_iterator; - + /** * @brief Constructor. * @param comm The communicator to use. - * @param source The indexset which represents the global to - * local mapping at the source of the communication - * @param destination The indexset to which the communication - * which represents the global to + * @param source The indexset which represents the global to + * local mapping at the source of the communication + * @param destination The indexset to which the communication + * which represents the global to * local mapping at the destination of the communication. * May be the same as the source indexset. * @param neighbours Optional: The neighbours the process shares indices with. - * If this parameter is omitted a ring communication with all indices will take + * If this parameter is omitted a ring communication with all indices will take * place to calculate this information which is O(P). - * @param includeSelf If true, sending from indices of the processor to other - * indices on the same processor is enabled even if the same indexset is used + * @param includeSelf If true, sending from indices of the processor to other + * indices on the same processor is enabled even if the same indexset is used * on both the * sending and receiving side. */ - inline RemoteIndices(const ParallelIndexSet& source, const ParallelIndexSet& destination, - const MPI_Comm& comm, const std::vector& neighbours=std::vector(), bool includeSelf=false); + inline RemoteIndices(const ParallelIndexSet& source, const ParallelIndexSet& destination, + const MPI_Comm& comm, const std::vector& neighbours=std::vector(), bool includeSelf=false); RemoteIndices(); - + /** - * @brief Tell whether sending from indices of the processor to other - * indices on the same processor is enabled even if the same indexset is + * @brief Tell whether sending from indices of the processor to other + * indices on the same processor is enabled even if the same indexset is * used on both the sending and receiving side. * * @param includeSelf If true it is enabled. */ void setIncludeSelf(bool includeSelf); - + /** * @brief Set the index sets and communicator we work with. * * @warning All remote indices already setup will be deleted! * * @param comm The communicator to use. - * @param source The indexset which represents the global to - * local mapping at the source of the communication - * @param destination The indexset to which the communication - * which represents the global to + * @param source The indexset which represents the global to + * local mapping at the source of the communication + * @param destination The indexset to which the communication + * which represents the global to * local mapping at the destination of the communication. * May be the same as the source indexset. * @param neighbours Optional: The neighbours the process shares indices with. - * If this parameter is omitted a ring communication with all indices will take + * If this parameter is omitted a ring communication with all indices will take * place to calculate this information which is O(P). */ - void setIndexSets(const ParallelIndexSet& source, const ParallelIndexSet& destination, - const MPI_Comm& comm, const std::vector& neighbours=std::vector()); + void setIndexSets(const ParallelIndexSet& source, const ParallelIndexSet& destination, + const MPI_Comm& comm, const std::vector& neighbours=std::vector()); template void setNeighbours(const C& neighbours) { neighbourIds.clear(); neighbourIds.insert(neighbours.begin(), neighbours.end()); - + } - + const std::set& getNeighbours() const { return neighbourIds; } - + /** * @brief Destructor. */ ~RemoteIndices(); - + /** * @brief Rebuilds the set of remote indices. - * + * * This has to be called whenever the underlying index sets * change. - * + * * If the template parameter ignorePublic is true all indices will be treated * as public. */ @@ -319,11 +319,11 @@ void rebuild(); bool operator==(const RemoteIndices& ri); - + /** * @brief Checks whether the remote indices are synced with * the indexsets. - * + * * If they are not synced the remote indices need to be rebuild. * @return True if they are synced. */ @@ -343,10 +343,10 @@ * @warning Use with care. If the remote index list is inconsistent * after the modification the communication might result in a dead lock! * - * @tparam mode If true the index set corresponding to the remote indices might get modified. + * @tparam mode If true the index set corresponding to the remote indices might get modified. * Therefore the internal pointers to the indices need to be repaired. * @tparam send If true the remote index information at the sending side will - * be modified, if false the receiving side. + * be modified, if false the receiving side. */ template inline RemoteIndexListModifier getModifier(int process); @@ -354,7 +354,7 @@ /** * @brief Find an iterator over the remote index lists of a specific process. * @param proc The identifier of the process. - * @return The iterator the remote index lists postioned at the process. + * @return The iterator the remote index lists postioned at the process. * If theres is no list for this process, the end iterator is returned. */ inline const_iterator find(int proc) const; @@ -364,13 +364,13 @@ * @return The iterator over all remote index lists postioned at the first process. */ inline const_iterator begin() const; - + /** * @brief Get an iterator over all remote index lists. * @return The iterator over all remote index lists postioned at the end. */ inline const_iterator end() const; - + /** * @brief Get an iterator for colletively iterating over the remote indices of all remote processes. */ @@ -381,7 +381,7 @@ * @brief Free the index lists. */ inline void free(); - + /** * @brief Get the number of processors we share indices with. * @return The number of neighbours. @@ -390,14 +390,14 @@ /** @brief Get the index set at the source. */ inline const ParallelIndexSet& sourceIndexSet() const; - + /** @brief Get the index set at destination. */ inline const ParallelIndexSet& destinationIndexSet() const; private: /** copying is forbidden. */ RemoteIndices(const RemoteIndices&) - {} + {} /** @brief Index set used at the source of the communication. */ const ParallelIndexSet* source_; @@ -411,17 +411,17 @@ /** @brief The neighbours we share indices with. * If not empty this will speedup rebuild. */ std::set neighbourIds; - + /** @brief The communicator tag to use. */ const static int commTag_=333; - - /** + + /** * @brief The sequence number of the source index set when the remote indices * where build. */ int sourceSeqNo_; - - /** + + /** * @brief The sequence number of the destination index set when the remote indices * where build. */ @@ -436,19 +436,19 @@ * @brief Whether the next build will be the first build ever. */ bool firstBuild; - + /* - * @brief If true, sending from indices of the processor to other - * indices on the same processor is enabled even if the same indexset is used + * @brief If true, sending from indices of the processor to other + * indices on the same processor is enabled even if the same indexset is used * on both the * sending and receiving side. */ bool includeSelf; - + /** @brief The index pair type. */ - typedef IndexPair + typedef IndexPair PairType; - + /** * @brief The remote indices. * @@ -456,14 +456,14 @@ * index lists, the first for receiving, the second for sending. */ RemoteIndexMap remoteIndices_; - - /** - * @brief Build the remote mapping. - * + + /** + * @brief Build the remote mapping. + * * If the template parameter ignorePublic is true all indices will be treated * as public. - * @param includeSelf If true, sending from indices of the processor to other - * indices on the same processor is enabled even if the same indexset is used + * @param includeSelf If true, sending from indices of the processor to other + * indices on the same processor is enabled even if the same indexset is used * on both the * sending and receiving side. */ @@ -476,8 +476,8 @@ * @return the number of indices marked as public. */ inline int noPublic(const ParallelIndexSet& indexSet); - - /** + + /** * @brief Pack the indices to send if source_ and target_ are the same. * * If the template parameter ignorePublic is true all indices will be treated @@ -490,48 +490,48 @@ */ template inline void packEntries(PairType** myPairs, const ParallelIndexSet& indexSet, - char* p_out, MPI_Datatype type, int bufferSize, - int* position, int n); - + char* p_out, MPI_Datatype type, int bufferSize, + int* position, int n); + /** * @brief unpacks the received indices and builds the remote index list. * * @param remote The list to add the indices to. * @param remoteEntries The number of remote entries to unpack. - * @param local The local indices to check wether we know the remote + * @param local The local indices to check whether we know the remote * indices. * @param localEntries The number of local indices. * @param type The mpi data type for unpacking. * @param p_in The input buffer to unpack from. - * @param postion The position in the buffer to start unpacking from. + * @param position The position in the buffer to start unpacking from. * @param bufferSize The size of the input buffer. */ inline void unpackIndices(RemoteIndexList& remote, int remoteEntries, - PairType** local, int localEntries, char* p_in, - MPI_Datatype type, int* positon, int bufferSize, + PairType** local, int localEntries, char* p_in, + MPI_Datatype type, int* position, int bufferSize, bool fromOurself); inline void unpackIndices(RemoteIndexList& send, RemoteIndexList& receive, - int remoteEntries, PairType** localSource, - int localSourceEntries, PairType** localDest, - int localDestEntries, char* p_in, - MPI_Datatype type, int* position, int bufferSize); - - void unpackCreateRemote(char* p_in, PairType** sourcePairs, PairType** DestPairs, - int remoteProc, int sourcePublish, int destPublish, - int bufferSize, bool sendTwo, bool fromOurSelf=false); + int remoteEntries, PairType** localSource, + int localSourceEntries, PairType** localDest, + int localDestEntries, char* p_in, + MPI_Datatype type, int* position, int bufferSize); + + void unpackCreateRemote(char* p_in, PairType** sourcePairs, PairType** DestPairs, + int remoteProc, int sourcePublish, int destPublish, + int bufferSize, bool sendTwo, bool fromOurSelf=false); }; - + /** @} */ /** * @brief Modifier for adding and/or deleting remote indices from * the remote index list. * - * In some cases all the information about the indices also present + * In some cases all the information about the indices also present * on remote process might already be known. In this case this * information can be provided to the RemoteIndices via this modifier. - * This prevents the global communication needed by a call to + * This prevents the global communication needed by a call to * RemoteIndices::rebuild. * * In some cases it might advisable to run IndicesSyncer::sync afterwards. @@ -545,7 +545,7 @@ template friend class RemoteIndices; - + public: class InvalidPosition : public RangeError {}; @@ -561,7 +561,7 @@ */ MODIFYINDEXSET=mode }; - + /** * @brief Type of the index set we use. */ @@ -576,17 +576,17 @@ * @brief The type of the local index. */ typedef typename ParallelIndexSet::LocalIndex LocalIndex; - + /** * @brief The type of the attribute. */ typedef typename LocalIndex::Attribute Attribute; - + /** * @brief Type of the remote indices we manage. */ typedef Dune::RemoteIndex RemoteIndex; - + /** * @brief The type of the allocator for the remote index list. */ @@ -600,12 +600,12 @@ * @brief The type of the modifying iterator of the remote index list. */ typedef SLListModifyIterator ModifyIterator; - + /** * @brief The type of the remote index list iterator. */ typedef typename RemoteIndexList::const_iterator ConstIterator; - + /** * @brief Insert an index to the list. * @@ -620,8 +620,8 @@ * the one before has bigger global index than the one to be inserted. */ void insert(const RemoteIndex& index) throw(InvalidPosition); - - + + /** * @brief Insert an index to the list. * @@ -663,45 +663,37 @@ RemoteIndexListModifier(const RemoteIndexListModifier&); - - /** + + /** * @brief Default constructor. * @warning Object is not usable! */ RemoteIndexListModifier() : glist_() {} - - /** @brief Constructor */ - ~RemoteIndexListModifier() - { - if(glist_) - delete glist_; - } - + private: - + /** * @brief Create a modifier for a remote index list. * @param indexSet The set of indices the process knows. * @param rList The list of remote indices to modify. */ RemoteIndexListModifier(const ParallelIndexSet& indexSet, - RemoteIndexList& rList); + RemoteIndexList& rList); typedef SLList GlobalList; typedef typename GlobalList::ModifyIterator GlobalModifyIterator; - RemoteIndices* remoteIndices_; RemoteIndexList* rList_; const ParallelIndexSet* indexSet_; - GlobalList* glist_; + GlobalList glist_; ModifyIterator iter_; GlobalModifyIterator giter_; ConstIterator end_; bool first_; GlobalIndex last_; }; - + /** * @brief A collective iterator for moving over the remote indices for * all processes collectively. @@ -709,7 +701,7 @@ template class CollectiveIterator { - + /** * @brief Type of the index set we use. */ @@ -724,7 +716,7 @@ * @brief The type of the local index. */ typedef typename ParallelIndexSet::LocalIndex LocalIndex; - + /** * @brief The type of the attribute. */ @@ -732,34 +724,34 @@ /** @brief The remote index type */ typedef Dune::RemoteIndex RemoteIndex; - + /** @brief The allocator of the remote indices. */ typedef typename A::template rebind::other Allocator; /** @brief The type of the remote index list. */ - typedef Dune::SLList RemoteIndexList; + typedef Dune::SLList RemoteIndexList; /** @brief The of map for storing the iterators. */ typedef std::map > + const typename RemoteIndexList::const_iterator> > Map; public: - + /** @brief The type of the map from rank to remote index list. */ typedef std::map > RemoteIndexMap; - - /** + + /** * @brief Constructor. * @param map_ The map of the remote indices. * @param send True if we want iterate over the remote indices used for sending. */ inline CollectiveIterator(const RemoteIndexMap& map_, bool send); - + /** * @brief Advances all underlying iterators. - * + * * All iterators are advanced until they point to a remote index whose * global id is bigger or equal to global. * Iterators pointing to their end are removed. @@ -769,7 +761,7 @@ /** * @brief Advances all underlying iterators. - * + * * All iterators are advanced until they point to a remote index whose * global id is bigger or equal to global. * Iterators pointing to their end are removed. @@ -779,12 +771,12 @@ inline void advance(const GlobalIndex& global, const Attribute& attribute); CollectiveIterator& operator++(); - + /** * @brief Checks whether there are still iterators in the map. */ inline bool empty(); - + /** * @brief Iterator over the valid underlying iterators. * @@ -796,117 +788,122 @@ public: typedef typename Map::iterator RealIterator; typedef typename Map::iterator ConstRealIterator; - - + + //! \todo Please doc me! iterator(const RealIterator& iter, const ConstRealIterator& end, GlobalIndex& index) - : iter_(iter), end_(end), index_(index), hasAttribute(false) + : iter_(iter), end_(end), index_(index), hasAttribute(false) { - // Move to the first valid entry - while(iter_!=end_ && iter_->second.first->localIndexPair().global()!=index_) - ++iter_; + // Move to the first valid entry + while(iter_!=end_ && iter_->second.first->localIndexPair().global()!=index_) + ++iter_; } - + iterator(const RealIterator& iter, const ConstRealIterator& end, GlobalIndex index, Attribute attribute) - : iter_(iter), end_(end), index_(index), attribute_(attribute), hasAttribute(true) + : iter_(iter), end_(end), index_(index), attribute_(attribute), hasAttribute(true) { // Move to the first valid entry or the end - while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_ + while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_ || iter_->second.first->localIndexPair().local().attribute()!=attribute)) - ++iter_; + ++iter_; } //! \todo Please doc me! iterator(const iterator& other) - : iter_(other.iter_), end_(other.end_), index_(other.index_) + : iter_(other.iter_), end_(other.end_), index_(other.index_) { } - - //! \todo Please doc me! + + //! \todo Please doc me! iterator& operator++() - { - ++iter_; - // If entry is not valid move on - while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_ || - (hasAttribute && - iter_->second.first->localIndexPair().local().attribute()!=attribute_))) - ++iter_; - assert(iter_==end_ || + { + ++iter_; + // If entry is not valid move on + while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_ || + (hasAttribute && + iter_->second.first->localIndexPair().local().attribute()!=attribute_))) + ++iter_; + assert(iter_==end_ || (iter_->second.first->localIndexPair().global()==index_)); assert(iter_==end_ || !hasAttribute || (iter_->second.first->localIndexPair().local().attribute()==attribute_)); - return *this; + return *this; } - + //! \todo Please doc me! - const RemoteIndex& operator*()const + const RemoteIndex& operator*() const { - return *(iter_->second.first); + return *(iter_->second.first); } - + //! \todo Please doc me! int process() const { - return iter_->first; + return iter_->first; } - + //! \todo Please doc me! - const RemoteIndex* operator->()const + const RemoteIndex* operator->() const { - return iter_->second.first.operator->(); + return iter_->second.first.operator->(); } - + //! \todo Please doc me! bool operator==(const iterator& other) { - return other.iter_==iter_; + return other.iter_==iter_; } //! \todo Please doc me! bool operator!=(const iterator& other) { - return other.iter_!=iter_; + return other.iter_!=iter_; } private: iterator(); - + RealIterator iter_; RealIterator end_; GlobalIndex index_; Attribute attribute_; bool hasAttribute; }; - + iterator begin(); - + iterator end(); - + private: - + Map map_; GlobalIndex index_; Attribute attribute_; bool noattribute; }; - + template MPI_Datatype MPITraits > >::getType() { - if(type==MPI_DATATYPE_NULL){ - int length[4]; - MPI_Aint disp[4]; - MPI_Datatype types[4] = {MPI_LB, MPITraits::getType(), - MPITraits >::getType(), MPI_UB}; - IndexPair > rep[2]; - length[0]=length[1]=length[2]=length[3]=1; - MPI_Address(rep, disp); // lower bound of the datatype - MPI_Address(&(rep[0].global_), disp+1); - MPI_Address(&(rep[0].local_), disp+2); - MPI_Address(rep+1, disp+3); // upper bound of the datatype - for(int i=3; i >= 0; --i) - disp[i] -= disp[0]; - MPI_Type_struct(4, length, disp, types, &type); + if(type==MPI_DATATYPE_NULL) { + int length[2] = {1, 1}; + MPI_Aint base; + MPI_Aint disp[2]; + MPI_Datatype types[2] = {MPITraits::getType(), + MPITraits >::getType()}; + IndexPair > rep; + MPI_Get_address(&rep, &base); // lower bound of the datatype + MPI_Get_address(&(rep.global_), &disp[0]); + MPI_Get_address(&(rep.local_), &disp[1]); + for (MPI_Aint& d : disp) + d -= base; + + MPI_Datatype tmp; + MPI_Type_create_struct(2, length, disp, types, &tmp); + + MPI_Type_create_resized(tmp, 0, sizeof(IndexPair >), &type); MPI_Type_commit(&type); + + MPI_Type_free(&tmp); } return type; } @@ -933,13 +930,13 @@ { return localIndex_==ri.localIndex_ && attribute_==ri.attribute; } - + template inline bool RemoteIndex::operator!=(const RemoteIndex& ri) const { return localIndex_!=ri.localIndex_ || attribute_!=ri.attribute_; } - + template inline const T2 RemoteIndex::attribute() const { @@ -951,11 +948,11 @@ { return *localIndex_; } - + template inline RemoteIndices::RemoteIndices(const ParallelIndexSet& source, - const ParallelIndexSet& destination, - const MPI_Comm& comm, + const ParallelIndexSet& destination, + const MPI_Comm& comm, const std::vector& neighbours, bool includeSelf_) : source_(&source), target_(&destination), comm_(comm), @@ -970,18 +967,19 @@ { includeSelf=b; } - + template RemoteIndices::RemoteIndices() - :source_(0), target_(0), sourceSeqNo_(-1), - destSeqNo_(-1), publicIgnored(false), firstBuild(true) + : source_(0), target_(0), sourceSeqNo_(-1), + destSeqNo_(-1), publicIgnored(false), firstBuild(true), + includeSelf(false) {} - + template void RemoteIndices::setIndexSets(const ParallelIndexSet& source, - const ParallelIndexSet& destination, - const MPI_Comm& comm, - const std::vector& neighbours) + const ParallelIndexSet& destination, + const MPI_Comm& comm, + const std::vector& neighbours) { free(); source_ = &source; @@ -992,21 +990,21 @@ } template - const typename RemoteIndices::ParallelIndexSet& + const typename RemoteIndices::ParallelIndexSet& RemoteIndices::sourceIndexSet() const { return *source_; } - - + + template - const typename RemoteIndices::ParallelIndexSet& + const typename RemoteIndices::ParallelIndexSet& RemoteIndices::destinationIndexSet() const { return *target_; } - - + + template RemoteIndices::~RemoteIndices() { @@ -1016,11 +1014,12 @@ template template inline void RemoteIndices::packEntries(IndexPair** pairs, - const ParallelIndexSet& indexSet, - char* p_out, MPI_Datatype type, - int bufferSize, - int *position, int n) + const ParallelIndexSet& indexSet, + char* p_out, MPI_Datatype type, + int bufferSize, + int *position, int n) { + DUNE_UNUSED_PARAMETER(n); // fill with own indices typedef typename ParallelIndexSet::const_iterator const_iterator; typedef IndexPair PairType; @@ -1029,130 +1028,130 @@ //Now pack the source indices int i=0; for(const_iterator index = indexSet.begin(); index != end; ++index) - if(ignorePublic || index->local().isPublic()){ - - MPI_Pack(const_cast(&(*index)), 1, - type, - p_out, bufferSize, position, comm_); - pairs[i++] = const_cast(&(*index)); - + if(ignorePublic || index->local().isPublic()) { + + MPI_Pack(const_cast(&(*index)), 1, + type, + p_out, bufferSize, position, comm_); + pairs[i++] = const_cast(&(*index)); + } assert(i==n); } - + template inline int RemoteIndices::noPublic(const ParallelIndexSet& indexSet) { typedef typename ParallelIndexSet::const_iterator const_iterator; - + int noPublic=0; - + const const_iterator end=indexSet.end(); for(const_iterator index=indexSet.begin(); index!=end; ++index) if(index->local().isPublic()) - noPublic++; - + noPublic++; + return noPublic; - + } - + template inline void RemoteIndices::unpackCreateRemote(char* p_in, PairType** sourcePairs, - PairType** destPairs, int remoteProc, + PairType** destPairs, int remoteProc, int sourcePublish, int destPublish, int bufferSize, bool sendTwo, bool fromOurSelf) { - - // unpack the number of indices we received - int noRemoteSource=-1, noRemoteDest=-1; - char twoIndexSets=0; - int position=0; - // Did we receive two index sets? - MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, comm_); - // The number of source indices received - MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, comm_); - // The number of destination indices received - MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, comm_); - - - // Indices for which we receive - RemoteIndexList* receive= new RemoteIndexList(); - // Indices for which we send - RemoteIndexList* send=0; - - MPI_Datatype type= MPITraits::getType(); - - if(!twoIndexSets){ - if(sendTwo){ - send = new RemoteIndexList(); - // Create both remote index sets simultaneously - unpackIndices(*send, *receive, noRemoteSource, sourcePairs, sourcePublish, - destPairs, destPublish, p_in, type, &position, bufferSize); - }else{ - // we only need one list - unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish, - p_in, type, &position, bufferSize, fromOurSelf); - send=receive; - } + + // unpack the number of indices we received + int noRemoteSource=-1, noRemoteDest=-1; + char twoIndexSets=0; + int position=0; + // Did we receive two index sets? + MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, comm_); + // The number of source indices received + MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, comm_); + // The number of destination indices received + MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, comm_); + + + // Indices for which we receive + RemoteIndexList* receive= new RemoteIndexList(); + // Indices for which we send + RemoteIndexList* send=0; + + MPI_Datatype type= MPITraits::getType(); + + if(!twoIndexSets) { + if(sendTwo) { + send = new RemoteIndexList(); + // Create both remote index sets simultaneously + unpackIndices(*send, *receive, noRemoteSource, sourcePairs, sourcePublish, + destPairs, destPublish, p_in, type, &position, bufferSize); }else{ - - int oldPos=position; - // Two index sets received - unpackIndices(*receive, noRemoteSource, destPairs, destPublish, - p_in, type, &position, bufferSize, fromOurSelf); - if(!sendTwo) - //unpack source entries again as destination entries - position=oldPos; - - send = new RemoteIndexList(); - unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish, - p_in, type, &position, bufferSize, fromOurSelf); - } - - if(receive->empty() && send->empty()){ - if(send==receive){ - delete send; - }else{ - delete send; - delete receive; - } + // we only need one list + unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish, + p_in, type, &position, bufferSize, fromOurSelf); + send=receive; + } + }else{ + + int oldPos=position; + // Two index sets received + unpackIndices(*receive, noRemoteSource, destPairs, destPublish, + p_in, type, &position, bufferSize, fromOurSelf); + if(!sendTwo) + //unpack source entries again as destination entries + position=oldPos; + + send = new RemoteIndexList(); + unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish, + p_in, type, &position, bufferSize, fromOurSelf); + } + + if(receive->empty() && send->empty()) { + if(send==receive) { + delete send; }else{ - remoteIndices_.insert(std::make_pair(remoteProc, - std::make_pair(send,receive))); + delete send; + delete receive; } + }else{ + remoteIndices_.insert(std::make_pair(remoteProc, + std::make_pair(send,receive))); + } } - + template template - inline void RemoteIndices::buildRemote(bool includeSelf) + inline void RemoteIndices::buildRemote(bool includeSelf_) { // Processor configuration int rank, procs; MPI_Comm_rank(comm_, &rank); MPI_Comm_size(comm_, &procs); - + // number of local indices to publish // The indices of the destination will be send. int sourcePublish, destPublish; - + // Do we need to send two index sets? char sendTwo = (source_ != target_); - - if(procs==1 && !(sendTwo || includeSelf)) + + if(procs==1 && !(sendTwo || includeSelf_)) // Nothing to communicate - return; + return; + + sourcePublish = (ignorePublic) ? source_->size() : noPublic(*source_); - sourcePublish = (ignorePublic)? source_->size() : noPublic(*source_); - if(sendTwo) - destPublish = (ignorePublic)? target_->size() : noPublic(*target_); - else + destPublish = (ignorePublic) ? target_->size() : noPublic(*target_); + else // we only need to send one set of indices destPublish = 0; - + int maxPublish, publish=sourcePublish+destPublish; // Calucate maximum number of indices send @@ -1160,157 +1159,157 @@ // allocate buffers typedef IndexPair PairType; - + PairType** destPairs; - PairType** sourcePairs = new PairType*[sourcePublish>0?sourcePublish:1]; - + PairType** sourcePairs = new PairType*[sourcePublish>0 ? sourcePublish : 1]; + if(sendTwo) - destPairs = new PairType*[destPublish>0?destPublish:1]; + destPairs = new PairType*[destPublish>0 ? destPublish : 1]; else destPairs=sourcePairs; - + char** buffer = new char*[2]; - int bufferSize; + int bufferSize; int position=0; int intSize; int charSize; // calculate buffer size MPI_Datatype type = MPITraits::getType(); - + MPI_Pack_size(maxPublish, type, comm_, - &bufferSize); + &bufferSize); MPI_Pack_size(1, MPI_INT, comm_, - &intSize); + &intSize); MPI_Pack_size(1, MPI_CHAR, comm_, - &charSize); + &charSize); // Our message will contain the following: - // a bool wether two index sets where sent - // the size of the source and the dest indexset, + // a bool whether two index sets where sent + // the size of the source and the dest indexset, // then the source and destination indices bufferSize += 2 * intSize + charSize; - + if(bufferSize<=0) bufferSize=1; - + buffer[0] = new char[bufferSize]; buffer[1] = new char[bufferSize]; - - + + // pack entries into buffer[0], p_out below! MPI_Pack(&sendTwo, 1, MPI_CHAR, buffer[0], bufferSize, &position, - comm_); - + comm_); + // The number of indices we send for each index set - MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position, - comm_); + MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position, + comm_); MPI_Pack(&destPublish, 1, MPI_INT, buffer[0], bufferSize, &position, - comm_); - + comm_); + // Now pack the source indices and setup the destination pairs - packEntries(sourcePairs, *source_, buffer[0], type, - bufferSize, &position, sourcePublish); + packEntries(sourcePairs, *source_, buffer[0], type, + bufferSize, &position, sourcePublish); // If necessary send the dest indices and setup the source pairs if(sendTwo) packEntries(destPairs, *target_, buffer[0], type, - bufferSize, &position, destPublish); + bufferSize, &position, destPublish); // Update remote indices for ourself - if(sendTwo|| includeSelf) - unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, sourcePublish, - destPublish, bufferSize, sendTwo, includeSelf); + if(sendTwo|| includeSelf_) + unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, sourcePublish, + destPublish, bufferSize, sendTwo, includeSelf_); neighbourIds.erase(rank); if(neighbourIds.size()==0) - { - Dune::dvverb<::size_type size_type; + size_type noNeighbours=neighbourIds.size(); + + // setup sends + for(std::set::iterator neighbour=neighbourIds.begin(); + neighbour!= neighbourIds.end(); ++neighbour) { + // Only send the information to the neighbouring processors + MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, req++); + } + + //Test for received messages + + for(size_type received=0; received ::size_type size_type; - size_type noNeighbours=neighbourIds.size(); - - // setup sends - for(std::set::iterator neighbour=neighbourIds.begin(); - neighbour!= neighbourIds.end(); ++neighbour){ - // Only send the information to the neighbouring processors - MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, req++); - } - - //Test for received messages - - for(size_type received=0; received inline void RemoteIndices::unpackIndices(RemoteIndexList& remote, int remoteEntries, @@ -1324,120 +1323,120 @@ { if(remoteEntries==0) return; - - PairType index(-1); - MPI_Unpack(p_in, bufferSize, position, &index, 1, - type, comm_); + + PairType index(1); + MPI_Unpack(p_in, bufferSize, position, &index, 1, + type, comm_); GlobalIndex oldGlobal=index.global(); int n_in=0, localIndex=0; - + //Check if we know the global index - while(localIndexglobal()==index.global()){ - int oldLocalIndex=localIndex; - - while(localIndexglobal()==index.global()){ - if(!fromOurSelf || index.local().attribute() != - local[localIndex]->local().attribute()) - // if index is from us it has to have a different attribute - remote.push_back(RemoteIndex(index.local().attribute(), - local[localIndex])); - localIndex++; - } - - // unpack next remote index - if((++n_in) < remoteEntries){ - MPI_Unpack(p_in, bufferSize, position, &index, 1, - type, comm_); + while(localIndexglobal()==index.global()) { + int oldLocalIndex=localIndex; + + while(localIndexglobal()==index.global()) { + if(!fromOurSelf || index.local().attribute() != + local[localIndex]->local().attribute()) + // if index is from us it has to have a different attribute + remote.push_back(RemoteIndex(index.local().attribute(), + local[localIndex])); + localIndex++; + } + + // unpack next remote index + if((++n_in) < remoteEntries) { + MPI_Unpack(p_in, bufferSize, position, &index, 1, + type, comm_); if(index.global()==oldGlobal) // Restart comparison for the same global indices localIndex=oldLocalIndex; else oldGlobal=index.global(); }else{ - // No more received indices - break; - } - continue; - } - - if (local[localIndex]->global()global() inline void RemoteIndices::unpackIndices(RemoteIndexList& send, - RemoteIndexList& receive, - int remoteEntries, - PairType** localSource, - int localSourceEntries, - PairType** localDest, - int localDestEntries, - char* p_in, - MPI_Datatype type, - int* position, - int bufferSize) - { + RemoteIndexList& receive, + int remoteEntries, + PairType** localSource, + int localSourceEntries, + PairType** localDest, + int localDestEntries, + char* p_in, + MPI_Datatype type, + int* position, + int bufferSize) + { int n_in=0, sourceIndex=0, destIndex=0; - + //Check if we know the global index - while(n_in= than the one in the unpacked index while(sourceIndexglobal()global()global()==index.global()) - send.push_back(RemoteIndex(index.local().attribute(), - localSource[sourceIndex])); + send.push_back(RemoteIndex(index.local().attribute(), + localSource[sourceIndex])); if(destIndex < localDestEntries && localDest[destIndex]->global() == index.global()) - receive.push_back(RemoteIndex(index.local().attribute(), - localDest[sourceIndex])); + receive.push_back(RemoteIndex(index.local().attribute(), + localDest[sourceIndex])); } - + } - + template inline void RemoteIndices::free() { typedef typename RemoteIndexMap::iterator Iterator; Iterator lend = remoteIndices_.end(); - for(Iterator lists=remoteIndices_.begin(); lists != lend; ++lists){ - if(lists->second.first==lists->second.second){ - // there is only one remote index list. - delete lists->second.first; + for(Iterator lists=remoteIndices_.begin(); lists != lend; ++lists) { + if(lists->second.first==lists->second.second) { + // there is only one remote index list. + delete lists->second.first; }else{ - delete lists->second.first; - delete lists->second.second; + delete lists->second.first; + delete lists->second.second; } } remoteIndices_.clear(); @@ -1449,17 +1448,17 @@ { return remoteIndices_.size(); } - + template template inline void RemoteIndices::rebuild() { - // Test wether a rebuild is Needed. - if(firstBuild || + // Test whether a rebuild is Needed. + if(firstBuild || ignorePublic!=publicIgnored || ! - isSynced()){ + isSynced()) { free(); - + buildRemote(includeSelf); sourceSeqNo_ = source_->seqNo(); @@ -1467,10 +1466,10 @@ firstBuild=false; publicIgnored=ignorePublic; } - - + + } - + template inline bool RemoteIndices::isSynced() const { @@ -1489,24 +1488,23 @@ destSeqNo_ = target_->seqNo(); typename RemoteIndexMap::iterator found = remoteIndices_.find(process); - + if(found == remoteIndices_.end()) { if(source_ != target_) - remoteIndices_.insert(std::make_pair(process, - std::make_pair(new RemoteIndexList(), - new RemoteIndexList()))); + found = remoteIndices_.insert(found, std::make_pair(process, + std::make_pair(new RemoteIndexList(), + new RemoteIndexList()))); else{ - RemoteIndexList* rlist = new RemoteIndexList(); - remoteIndices_.insert(std::make_pair(process, - std::make_pair(rlist, rlist))); - - found = remoteIndices_.find(process); + RemoteIndexList* rlist = new RemoteIndexList(); + found = remoteIndices_.insert(found, + std::make_pair(process, + std::make_pair(rlist, rlist))); } } - + firstBuild = false; - + if(send) return RemoteIndexListModifier(*source_, *(found->second.first)); else @@ -1526,7 +1524,7 @@ { return remoteIndices_.begin(); } - + template inline typename RemoteIndices::const_iterator RemoteIndices::end() const @@ -1540,124 +1538,124 @@ { if(neighbours()!=ri.neighbours()) return false; - + typedef RemoteIndexList RList; typedef typename std::map >::const_iterator const_iterator; - + const const_iterator rend = remoteIndices_.end(); - for(const_iterator rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin(); rindex!=rend; ++rindex, ++rindex1){ + for(const_iterator rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin(); rindex!=rend; ++rindex, ++rindex1) { if(rindex->first != rindex1->first) - return false; + return false; if(*(rindex->second.first) != *(rindex1->second.first)) - return false; + return false; if(*(rindex->second.second) != *(rindex1->second.second)) - return false; + return false; } return true; } - + template RemoteIndexListModifier::RemoteIndexListModifier(const ParallelIndexSet& indexSet, - RemoteIndexList& rList) - : rList_(&rList), indexSet_(&indexSet), glist_(new GlobalList()), iter_(rList.beginModify()), end_(rList.end()), first_(true) + RemoteIndexList& rList) + : rList_(&rList), indexSet_(&indexSet), iter_(rList.beginModify()), end_(rList.end()), first_(true) { - if(MODIFYINDEXSET){ + if(MODIFYINDEXSET) { assert(indexSet_); for(ConstIterator iter=iter_; iter != end_; ++iter) - glist_->push_back(iter->localIndexPair().global()); - giter_ = glist_->beginModify(); + glist_.push_back(iter->localIndexPair().global()); + giter_ = glist_.beginModify(); } } template RemoteIndexListModifier::RemoteIndexListModifier(const RemoteIndexListModifier& other) - : rList_(other.rList_), indexSet_(other.indexSet_), - glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_(other.end_), + : rList_(other.rList_), indexSet_(other.indexSet_), + glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_(other.end_), first_(other.first_), last_(other.last_) {} - + template inline void RemoteIndexListModifier::repairLocalIndexPointers() throw(InvalidIndexSetState) - { - if(MODIFYINDEXSET){ + { + if(MODIFYINDEXSET) { // repair pointers to local index set. #ifdef DUNE_ISTL_WITH_CHECKING if(indexSet_->state()!=GROUND) - DUNE_THROW(InvalidIndexSetState, "Index has to be in ground mode for repairing pointers to indices"); + DUNE_THROW(InvalidIndexSetState, "Index has to be in ground mode for repairing pointers to indices"); #endif typedef typename ParallelIndexSet::const_iterator IndexIterator; typedef typename GlobalList::const_iterator GlobalIterator; typedef typename RemoteIndexList::iterator Iterator; - GlobalIterator giter = glist_->begin(); + GlobalIterator giter = glist_.begin(); IndexIterator index = indexSet_->begin(); - - for(Iterator iter=rList_->begin(); iter != end_; ++iter){ - while(index->global()<*giter){ - ++index; + + for(Iterator iter=rList_->begin(); iter != end_; ++iter) { + while(index->global()<*giter) { + ++index; #ifdef DUNE_ISTL_WITH_CHECKING - if(index == indexSet_.end()) - DUNE_THROW(InvalidPosition, "No such global index in set!"); + if(index == indexSet_->end()) + DUNE_THROW(InvalidPosition, "No such global index in set!"); #endif - } + } #ifdef DUNE_ISTL_WITH_CHECKING - if(index->global() != *giter) - DUNE_THROW(InvalidPosition, "No such global index in set!"); + if(index->global() != *giter) + DUNE_THROW(InvalidPosition, "No such global index in set!"); #endif - iter->localIndex_ = &(*index); + iter->localIndex_ = &(*index); } } } - + template inline void RemoteIndexListModifier::insert(const RemoteIndex& index) throw(InvalidPosition) { - dune_static_assert(!mode,"Not allowed if the mode indicates that new indices" - "might be added to the underlying index set. Use " - "insert(const RemoteIndex&, const GlobalIndex&) instead"); - + static_assert(!mode,"Not allowed if the mode indicates that new indices" + "might be added to the underlying index set. Use " + "insert(const RemoteIndex&, const GlobalIndex&) instead"); + #ifdef DUNE_ISTL_WITH_CHECKING if(!first_ && index.localIndexPair().global()localIndexPair().global() < index.localIndexPair().global()){ + while(iter_ != end_ && iter_->localIndexPair().global() < index.localIndexPair().global()) { ++iter_; } - + // No duplicate entries allowed assert(iter_==end_ || iter_->localIndexPair().global() != index.localIndexPair().global()); iter_.insert(index); last_ = index.localIndexPair().global(); first_ = false; } - + template inline void RemoteIndexListModifier::insert(const RemoteIndex& index, const GlobalIndex& global) throw(InvalidPosition) { - dune_static_assert(mode,"Not allowed if the mode indicates that no new indices" - "might be added to the underlying index set. Use " - "insert(const RemoteIndex&) instead"); + static_assert(mode,"Not allowed if the mode indicates that no new indices" + "might be added to the underlying index set. Use " + "insert(const RemoteIndex&) instead"); #ifdef DUNE_ISTL_WITH_CHECKING if(!first_ && globallocalIndexPair().global() != global); iter_.insert(index); giter_.insert(global); - + last_ = global; first_ = false; } - + template bool RemoteIndexListModifier::remove(const GlobalIndex& global) throw(InvalidPosition) { @@ -1667,28 +1665,28 @@ #endif bool found= false; - - if(MODIFYINDEXSET){ - // Move to the correct position - while(iter_!=end_ && *giter_< global){ - ++giter_; - ++iter_; - } - if(*giter_ == global){ - giter_.remove(); - iter_.remove(); - found=true; + + if(MODIFYINDEXSET) { + // Move to the correct position + while(iter_!=end_ && *giter_< global) { + ++giter_; + ++iter_; + } + if(*giter_ == global) { + giter_.remove(); + iter_.remove(); + found=true; } }else{ while(iter_!=end_ && iter_->localIndexPair().global() < global) - ++iter_; - - if(iter_->localIndexPair().global()==global){ - iter_.remove(); - found = true; + ++iter_; + + if(iter_->localIndexPair().global()==global) { + iter_.remove(); + found = true; } } - + last_ = global; first_ = false; return found; @@ -1705,20 +1703,20 @@ inline MPI_Comm RemoteIndices::communicator() const { return comm_; - + } - + template CollectiveIterator::CollectiveIterator(const RemoteIndexMap& pmap, bool send) { typedef typename RemoteIndexMap::const_iterator const_iterator; - + const const_iterator end=pmap.end(); - for(const_iterator process=pmap.begin(); process != end; ++process){ - const RemoteIndexList* list = send? process->second.first : process->second.second; + for(const_iterator process=pmap.begin(); process != end; ++process) { + const RemoteIndexList* list = send ? process->second.first : process->second.second; typedef typename RemoteIndexList::const_iterator iterator; - map_.insert(std::make_pair(process->first, - std::pair(list->begin(), list->end()))); + map_.insert(std::make_pair(process->first, + std::pair(list->begin(), list->end()))); } } @@ -1728,23 +1726,23 @@ typedef typename Map::iterator iterator; typedef typename Map::const_iterator const_iterator; const const_iterator end = map_.end(); - - for(iterator iter = map_.begin(); iter != end;){ + + for(iterator iter = map_.begin(); iter != end;) { // Step the iterator until we are >= index typename RemoteIndexList::const_iterator current = iter->second.first; typename RemoteIndexList::const_iterator rend = iter->second.second; RemoteIndex remoteIndex; if(current != rend) - remoteIndex = *current; - + remoteIndex = *current; + while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()second.first); - + ++(iter->second.first); + // erase from the map if there are no more entries. if(iter->second.first == iter->second.second) - map_.erase(iter++); + map_.erase(iter++); else{ - ++iter; + ++iter; } } index_=index; @@ -1758,30 +1756,30 @@ typedef typename Map::iterator iterator; typedef typename Map::const_iterator const_iterator; const const_iterator end = map_.end(); - - for(iterator iter = map_.begin(); iter != end;){ + + for(iterator iter = map_.begin(); iter != end;) { // Step the iterator until we are >= index typename RemoteIndexList::const_iterator current = iter->second.first; typename RemoteIndexList::const_iterator rend = iter->second.second; RemoteIndex remoteIndex; if(current != rend) - remoteIndex = *current; + remoteIndex = *current; // Move to global index or bigger while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()second.first); - + ++(iter->second.first); + // move to attribute or bigger - while(iter->second.first!=iter->second.second + while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()==index && iter->second.first->localIndexPair().local().attribute()second.first); + ++(iter->second.first); // erase from the map if there are no more entries. if(iter->second.first == iter->second.second) - map_.erase(iter++); + map_.erase(iter++); else{ - ++iter; + ++iter; } } index_=index; @@ -1790,13 +1788,13 @@ } template - inline CollectiveIterator& CollectiveIterator::operator++() + inline CollectiveIterator& CollectiveIterator::operator++() { typedef typename Map::iterator iterator; typedef typename Map::const_iterator const_iterator; const const_iterator end = map_.end(); - - for(iterator iter = map_.begin(); iter != end;){ + + for(iterator iter = map_.begin(); iter != end;) { // Step the iterator until we are >= index typename RemoteIndexList::const_iterator current = iter->second.first; typename RemoteIndexList::const_iterator rend = iter->second.second; @@ -1804,13 +1802,13 @@ // move all iterators pointing to the current global index to next value if(iter->second.first->localIndexPair().global()==index_ && (noattribute || iter->second.first->localIndexPair().local().attribute() == attribute_)) - ++(iter->second.first); - + ++(iter->second.first); + // erase from the map if there are no more entries. if(iter->second.first == iter->second.second) - map_.erase(iter++); + map_.erase(iter++); else{ - ++iter; + ++iter; } } return *this; @@ -1821,7 +1819,7 @@ { return map_.empty(); } - + template inline typename CollectiveIterator::iterator CollectiveIterator::begin() @@ -1832,21 +1830,21 @@ return iterator(map_.begin(), map_.end(), index_, attribute_); } - + template inline typename CollectiveIterator::iterator CollectiveIterator::end() { return iterator(map_.end(), map_.end(), index_); } - + template inline std::ostream& operator<<(std::ostream& os, const RemoteIndex& index) { os<<"[global="< inline std::ostream& operator<<(std::ostream& os, const RemoteIndices& indices) { @@ -1858,27 +1856,24 @@ const const_iterator rend = indices.remoteIndices_.end(); - for(const_iterator rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex){ + for(const_iterator rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex) { os<first<<":"; - - if(!rindex->second.first->empty()){ - os<<" send:"; - - const typename RList::const_iterator send= rindex->second.first->end(); - - for(typename RList::const_iterator index = rindex->second.first->begin(); - index != send; ++index) - os<<*index<<" "; - os<second.second->empty()){ - os<first<<": "<<"receive: "; - - const typename RList::const_iterator rend= rindex->second.second->end(); - - for(typename RList::const_iterator index = rindex->second.second->begin(); - index != rend; ++index) - os<<*index<<" "; + + if(!rindex->second.first->empty()) { + os<<" send:"; + + const typename RList::const_iterator send= rindex->second.first->end(); + + for(typename RList::const_iterator index = rindex->second.first->begin(); + index != send; ++index) + os<<*index<<" "; + os<second.second->empty()) { + os<first<<": "<<"receive: "; + + for(const auto& index : *(rindex->second.second)) + os << index << " "; } os< +#include "indexset.hh" +#include namespace Dune { @@ -14,10 +15,10 @@ /** * @file * @brief Provides classes for selecting - * indices base on attribute flags. + * indices based on attribute flags. * @author Markus Blatt */ - + /** * @brief A const iterator over an uncached selection. */ @@ -34,12 +35,12 @@ * Such types are EnumItem, EnumRange, Combine. */ typedef TS AttributeSet; - + /** * @brief The type of the underlying index set. */ typedef Dune::ParallelIndexSet ParallelIndexSet; - + //typedef typename ParallelIndexSet::const_iterator ParallelIndexSetIterator; typedef ConstArrayListIterator, N, std::allocator > > ParallelIndexSetIterator; @@ -53,39 +54,39 @@ { // Step to the first valid entry while(iter_!=end_ && !AttributeSet::contains(iter_->local().attribute())) - ++iter_; + ++iter_; } - + void operator++() { assert(iter_!=end_); - for(++iter_;iter_!=end_; ++iter_) - if(AttributeSet::contains(iter_->local().attribute())) - break; + for(++iter_; iter_!=end_; ++iter_) + if(AttributeSet::contains(iter_->local().attribute())) + break; } - - + + uint32_t operator*() const { return iter_->local().local(); } - + bool operator==(const SelectionIterator& other) const { return iter_ == other.iter_; } - + bool operator!=(const SelectionIterator& other) const { return iter_ != other.iter_; } - + private: ParallelIndexSetIterator iter_; const ParallelIndexSetIterator end_; }; - - + + /** * @brief An uncached selection of indices. */ @@ -102,12 +103,12 @@ * Such types are EnumItem, EnumRange, Combine. */ typedef TS AttributeSet; - + /** * @brief The type of the global index of the underlying index set. */ typedef TG GlobalIndex; - + /** * @brief The type of the local index of the underlying index set. * @@ -120,21 +121,21 @@ * @brief The type of the underlying index set. */ typedef Dune::ParallelIndexSet ParallelIndexSet; - + /** * @brief The type of the iterator of the selected indices. */ typedef SelectionIterator iterator; - + /** * @brief The type of the iterator of the selected indices. */ typedef iterator const_iterator; - + UncachedSelection() : indexSet_() {} - + UncachedSelection(const ParallelIndexSet& indexset) : indexSet_(&indexset) {} @@ -143,39 +144,39 @@ * @param indexset The index set to use. */ void setIndexSet(const ParallelIndexSet& indexset); - + /** * @brief Get the index set we are a selection for. */ //const ParallelIndexSet& indexSet() const; - + /** * @brief Get an iterator over the selected indices. * @return An iterator positioned at the first selected index. */ const_iterator begin() const; - - /** + + /** * @brief Get an iterator over the selected indices. * @return An iterator positioned at the first selected index. */ const_iterator end() const; - - + + private: const ParallelIndexSet* indexSet_; - + }; - + /** - * @brief An cached selection of indices. + * @brief A cached selection of indices. */ template class Selection { public: /** - * @brief The type of the Set of attributes. + * @brief The type of the set of attributes. * * It has to provide a static method * \code bool contains(AttributeType a); \endcode @@ -183,12 +184,12 @@ * Such types are EnumItem, EnumRange, Combine. */ typedef TS AttributeSet; - + /** * @brief The type of the global index of the underlying index set. */ typedef TG GlobalIndex; - + /** * @brief The type of the local index of the underlying index set. * @@ -196,34 +197,34 @@ * \code AttributeType attribute(); \endcode */ typedef TL LocalIndex; - + /** * @brief The type of the underlying index set. */ typedef Dune::ParallelIndexSet ParallelIndexSet; - + /** * @brief The type of the iterator of the selected indices. */ typedef uint32_t* iterator; - + /** * @brief The type of the iterator of the selected indices. */ typedef uint32_t* const_iterator; - + Selection() : selected_() {} - + Selection(const ParallelIndexSet& indexset) : selected_(), size_(0), built_(false) { setIndexSet(indexset); } - + ~Selection(); - + /** * @brief Set the index set of the selection. * @param indexset The index set to use. @@ -234,30 +235,30 @@ * @brief Free allocated memory. */ void free(); - + /** * @brief Get the index set we are a selection for. */ //IndexSet indexSet() const; - + /** * @brief Get an iterator over the selected indices. * @return An iterator positioned at the first selected index. */ const_iterator begin() const; - - /** + + /** * @brief Get an iterator over the selected indices. * @return An iterator positioned at the first selected index. */ const_iterator end() const; - - + + private: uint32_t* selected_; size_t size_; bool built_; - + }; template @@ -265,28 +266,28 @@ { if(built_) free(); - + // Count the number of entries the selection has to hold typedef typename ParallelIndexSet::const_iterator const_iterator; const const_iterator end = indexset.end(); int entries = 0; - + for(const_iterator index = indexset.begin(); index != end; ++index) if(AttributeSet::contains(index->local().attribute())) - ++entries; + ++entries; selected_ = new uint32_t[entries]; built_ = true; - + entries = 0; for(const_iterator index = indexset.begin(); index != end; ++index) if(AttributeSet::contains(index->local().attribute())) - selected_[entries++]= index->local().local(); - + selected_[entries++]= index->local().local(); + size_=entries; built_=true; } - + template uint32_t* Selection::begin() const { @@ -298,7 +299,7 @@ { return selected_+size_; } - + template inline void Selection::free() { @@ -313,28 +314,28 @@ if(built_) free(); } - + template SelectionIterator UncachedSelection::begin() const { return SelectionIterator(indexSet_->begin(), - indexSet_->end()); + indexSet_->end()); } - + template SelectionIterator UncachedSelection::end() const { return SelectionIterator(indexSet_->end(), - indexSet_->end()); + indexSet_->end()); } template void UncachedSelection::setIndexSet(const ParallelIndexSet& indexset) { indexSet_ = &indexset; } - + /** @} */ - + } #endif diff -Nru dune-common-2.2.1/dune/common/parallel/test/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/test/CMakeLists.txt --- dune-common-2.2.1/dune/common/parallel/test/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/test/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,13 @@ +dune_add_test(SOURCES indexsettest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES remoteindicestest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES selectiontest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES syncertest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES variablesizecommunicatortest.cc) diff -Nru dune-common-2.2.1/dune/common/parallel/test/indexsettest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/test/indexsettest.cc --- dune-common-2.2.1/dune/common/parallel/test/indexsettest.cc 2010-11-28 01:39:13.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parallel/test/indexsettest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #if HAVE_CONFIG_H #include "config.h" @@ -19,65 +19,65 @@ indexSet.beginResize(); indexSet1.beginResize(); - - for(int i=0; i< 10; i++){ + + for(int i=0; i< 10; i++) { indexSet.add(i, Dune::LocalIndex (i)); indexSet1.add(i, Dune::LocalIndex (i)); } - + indexSet.endResize(); indexSet1.endResize(); - + typedef Dune::ParallelIndexSet::iterator - Iterator; - + Iterator; + Iterator entry = indexSet.begin(); indexSet.beginResize(); - + for(int i=0; i < 5; i++) ++entry; - + indexSet.markAsDeleted(entry); - + indexSet.endResize(); - + std::cout<<"Unchanged: "<global()==5){ + if(entry->global()==5) { std::cerr<<"Entry was not deleted!"<9){ + + if(i>9) { std::cerr<<"Number of entries not correct!"<::iterator iter=indexSet1.begin(); - + // Test whether the local indices changed - for(entry = indexSet.begin(); entry != end; ++entry){ + for(entry = indexSet.begin(); entry != end; ++entry) { while(iter->global() < entry->global()) iter++; - if(iter->global() != entry->global()){ + if(iter->global() != entry->global()) { std::cerr <<" Global indices do not match!"<local() != entry->local()){ + if(iter->local() != entry->local()) { std::cerr <<" Local indices do not match!"< -#include -#include -#include -#include -#include - -#if HAVE_MPI -#include"mpi.h" - -enum GridFlags{ - owner, overlap, border -}; - -class Array; - -std::ostream& operator<<(std::ostream& os, const Array& a); - -class Array -{ - friend std::ostream& operator<<(std::ostream& os, const Array& a); -public: - typedef double value_type; - Array() : vals_(0), size_(0) - {} - - Array(int size) :size_(size) - { - vals_ = new double[size]; - } - - void build(int size) - { - vals_ = new double[size]; - size_ = size; - } - - Array& operator+=(double d) - { - for(int i=0; i < size_; i++) - vals_[i]+=d; - return *this; - } - - ~Array() - { - if(vals_!=0) - delete[] vals_; - } - - const double& operator[](int i) const - { - return vals_[i]; - } - - double& operator[](int i) - { - return vals_[i]; - } -private: - Array(const Array&) - {} - double *vals_; - int size_; -}; - -struct ArrayGatherScatter -{ - static double gather(const Array& a, int i); - - static void scatter(Array& a, double v, int i); - -}; - - -inline double ArrayGatherScatter::gather(const Array& a, int i) -{ - return a[i]; -} - -inline void ArrayGatherScatter::scatter(Array& a, double v, int i) -{ - a[i]=v; - -} - -std::ostream& operator<<(std::ostream& os, const Array& a) -{ - if(a.size_>0) - os<< "{ "< LocalIndexType; - - typedef Dune::ParallelIndexSet,45> ParallelIndexSet; - - ParallelIndexSet distIndexSet; - // global indexset - ParallelIndexSet globalIndexSet; - - // Set up the indexsets. - int start = std::max(rank*nx-1,0); - int end = std::min((rank + 1) * nx+1, Nx); - - distIndexSet.beginResize(); - - int localIndex=0; - int size = Ny*(end-start); - Array distArray(size); - Array* globalArray; - int index=0; - - std::cout< -void setupDistributed(Array& distArray, Dune::ParallelIndexSet >& distIndexSet, - int rank, int procs) -{ - // The local grid - int nx = NX/procs; - int mod = NX%procs; - - // Set up the indexsets. - int start, end; - int ostart, oend; - - if(rank0) - ostart = start - 1; - else - ostart = start; - - if(rank=end-1); - GridFlags flag = owner; - if((i=end)){ - distArray[localIndex]=-(i+j*NX+rank*NX*NY); - flag = overlap; - }else - distArray[localIndex]=i+j*NX+rank*NX*NY; - - distIndexSet.add(i+j*NX, Dune::ParallelLocalIndex (localIndex++,flag,isPublic)); - } - - distIndexSet.endResize(); - - -} - -template -void setupGlobal(Array& globalArray, Dune::ParallelIndexSet >& globalIndexSet) -{ - // build global indexset on first process - globalIndexSet.beginResize(); - globalArray.build(NX*NY); - int k=0; - for(int j=0; j (i+j*NX,owner,false)); - globalArray[i+j*NX]=-(i+j*NX); - k++; - - } - - globalIndexSet.endResize(); -} - -void testIndicesBuffered(MPI_Comm comm) -{ - //using namespace Dune; - - // The global grid size - const int Nx = 8; - const int Ny = 1; - - // Process configuration - int procs, rank, master=0; - MPI_Comm_size(comm, &procs); - MPI_Comm_rank(comm, &rank); - - typedef Dune::ParallelIndexSet > ParallelIndexSet; - - ParallelIndexSet distIndexSet; - // global indexset - ParallelIndexSet globalIndexSet; - - Array distArray; - Array globalArray; - - setupDistributed(distArray, distIndexSet, rank, procs); - - - if(rank==master){ - setupGlobal(globalArray, globalIndexSet); - } - - typedef Dune::RemoteIndices RemoteIndices; - - RemoteIndices accuIndices(distIndexSet, globalIndexSet, comm); - - accuIndices.rebuild(); - std::cout<<"dist "<(); - - Dune::Interface accuInterface; - Dune::Interface overlapInterface; - Dune::EnumItem sourceFlags; - Dune::Combine,Dune::EnumItem,GridFlags> destFlags; - // Dune::Bool2Type flag; - - accuInterface.build(accuIndices, sourceFlags, destFlags); - overlapInterface.build(overlapIndices, Dune::EnumItem(), - Dune::EnumItem()); - overlapInterface.print(); - accuInterface.print(); - - //accuInterface.print(); - - Dune::BufferedCommunicator accumulator, overlapExchanger; - - accumulator.build(accuInterface); - - overlapExchanger.build(overlapInterface); - - std::cout<< rank<<": before forward distArray="<< distArray<(distArray, distArray); - - std::cout<(distArray); - - std::cout< > ParallelIndexSet; - ParallelIndexSet sendIndexSet; - // global indexset - ParallelIndexSet receiveIndexSet; - - Array array, redistributedArray; - - // Set up the indexsets. - { - - int start = std::max(rank*nx-1,0); - int end = std::min((rank + 1) * nx+1, Nx); - - sendIndexSet.beginResize(); - - - array.build(Ny*(end-start)); - - for(int j=0, localIndex=0; j=end-2); - GridFlags flag = owner; - - if((i==start && i!=0)||(i==end-1 && i!=Nx-1)) - flag = overlap; - - sendIndexSet.add(i+j*Nx, ParallelLocalIndex (localIndex,flag,isPublic)); - array[localIndex]=i+j*Nx+rank*Nx*Ny; - } - - sendIndexSet.endResize(); - } - { - int newrank = (rank + 1) % procs; - - int start = std::max(newrank*nx-1,0); - int end = std::min((newrank + 1) * nx+1, Nx); - - std::cout<=end-2); - GridFlags flag = owner; - - if((i==start && i!=0)||(i==end-1 && i!=Nx-1)) - flag = overlap; - - receiveIndexSet.add(i+j*Nx, ParallelLocalIndex (localIndex,flag,isPublic)); - redistributedArray[localIndex]=-1; - } - - receiveIndexSet.endResize(); - } - - - std::cout<< rank<<": distributed and global index set!"< RemoteIndices; - - RemoteIndices redistributeIndices(sendIndexSet, - receiveIndexSet, comm); - RemoteIndices overlapIndices(receiveIndexSet, receiveIndexSet, comm); - - redistributeIndices.rebuild(); - overlapIndices.rebuild(); - - DatatypeCommunicator redistribute, overlapComm; - EnumItem fowner; - EnumItem foverlap; - - redistribute.build(redistributeIndices, fowner, array, fowner, redistributedArray); - - overlapComm.build(overlapIndices, fowner, redistributedArray, foverlap, redistributedArray); - std::cout< > ParallelIndexSet; - ParallelIndexSet sendIndexSet; - // global indexset - ParallelIndexSet receiveIndexSet; - - Array array, redistributedArray; - - std::vector neighbours; - - // Set up the indexsets. - { - - int start = std::max(rank*nx-1,0); - int end = std::min((rank + 1) * nx+1, Nx); - - neighbours.reserve(2); - - if(rank>0) neighbours.push_back(rank-1); - if(rank=end-2); - GridFlags flag = owner; - - if((i==start && i!=0)||(i==end-1 && i!=Nx-1)) - flag = overlap; - - sendIndexSet.add(i+j*Nx, ParallelLocalIndex (localIndex,flag,isPublic)); - array[localIndex]=i+j*Nx;//+rank*Nx*Ny; - if(flag==overlap) - array[localIndex]=-array[localIndex]; - } - - sendIndexSet.endResize(); - } - { - int newrank = (rank + 1) % procs; - - int start = std::max(newrank*nx-1,0); - int end = std::min((newrank + 1) * nx+1, Nx); - - std::cout<=end-2); - GridFlags flag = owner; - - if((i==start && i!=0)||(i==end-1 && i!=Nx-1)) - flag = overlap; - - receiveIndexSet.add(i+j*Nx, ParallelLocalIndex (localIndex,flag,isPublic)); - redistributedArray[localIndex]=-1; - } - - receiveIndexSet.endResize(); - } - - - std::cout<< rank<<": distributed and global index set!"< RemoteIndices; - RemoteIndices redistributeIndices(sendIndexSet, - receiveIndexSet, comm); - RemoteIndices overlapIndices(receiveIndexSet, receiveIndexSet, comm); - RemoteIndices sendIndices(sendIndexSet, - sendIndexSet, comm, neighbours); - RemoteIndices sendIndices1(sendIndexSet, - sendIndexSet, comm); - overlapIndices.rebuild(); - redistributeIndices.rebuild(); - sendIndices.rebuild(); - sendIndices1.rebuild(); - - if(rank==0) - std::cout< fowner; - EnumItem foverlap; - - redistributeInterface.build(redistributeIndices, fowner, fowner); - overlapInterface.build(overlapIndices, fowner, foverlap); - - BufferedCommunicator redistribute; - BufferedCommunicator overlapComm; - - redistribute.build(array, redistributedArray, redistributeInterface); - overlapComm.build(overlapInterface); - - std::cout<(array, redistributedArray); - - std::cout<(redistributedArray); - - std::cout<(array, redistributedArray); - - std::cout<(array, redistributedArray); - - std::cout<firstRank){ - if(rank==0) - key = firstRank; - if(rank==firstRank) - key=0; - } - - MPI_Comm_split(MPI_COMM_WORLD, 0, key, &comm); - -#ifdef DEBUG - bool wait=1; - while(size>1 && wait); -#endif - - // testIndices(comm); - testIndicesBuffered(comm); - - if(rank==0) - std::cout< +#include +#include +#include +#include +#include + +#if HAVE_MPI +#include "mpi.h" + +enum GridFlags { + owner, overlap, border +}; + +class Array; + +std::ostream& operator<<(std::ostream& os, const Array& a); + +class Array +{ + friend std::ostream& operator<<(std::ostream& os, const Array& a); +public: + typedef double value_type; + Array() : vals_(0), size_(0) + {} + + Array(int size) : size_(size) + { + vals_ = new double[size]; + } + + void build(int size) + { + vals_ = new double[size]; + size_ = size; + } + + Array& operator+=(double d) + { + for(int i=0; i < size_; i++) + vals_[i]+=d; + return *this; + } + + ~Array() + { + if(vals_!=0) + delete[] vals_; + } + + const double& operator[](int i) const + { + return vals_[i]; + } + + double& operator[](int i) + { + return vals_[i]; + } +private: + Array(const Array&) + {} + double *vals_; + int size_; +}; + +struct ArrayGatherScatter +{ + static double gather(const Array& a, int i); + + static void scatter(Array& a, double v, int i); + +}; + + +inline double ArrayGatherScatter::gather(const Array& a, int i) +{ + return a[i]; +} + +inline void ArrayGatherScatter::scatter(Array& a, double v, int i) +{ + a[i]=v; + +} + +std::ostream& operator<<(std::ostream& os, const Array& a) +{ + if(a.size_>0) + os<< "{ "< LocalIndexType; + + typedef Dune::ParallelIndexSet,45> ParallelIndexSet; + + ParallelIndexSet distIndexSet; + // global indexset + ParallelIndexSet globalIndexSet; + + // Set up the indexsets. + int start = std::max(rank*nx-1,0); + int end = std::min((rank + 1) * nx+1, Nx); + + distIndexSet.beginResize(); + + int localIndex=0; + int size = Ny*(end-start); + Array distArray(size); + Array* globalArray; + int index=0; + + std::cout< +void setupDistributed(Array& distArray, Dune::ParallelIndexSet >& distIndexSet, + int rank, int procs) +{ + // The local grid + int nx = NX/procs; + int mod = NX%procs; + + // Set up the indexsets. + int start, end; + int ostart, oend; + + if(rank0) + ostart = start - 1; + else + ostart = start; + + if(rank=end-1); + GridFlags flag = owner; + if((i=end)) { + distArray[localIndex]=-(i+j*NX+rank*NX*NY); + flag = overlap; + }else + distArray[localIndex]=i+j*NX+rank*NX*NY; + + distIndexSet.add(i+j*NX, Dune::ParallelLocalIndex (localIndex++,flag,isPublic)); + } + + distIndexSet.endResize(); + + +} + +template +void setupGlobal(Array& globalArray, Dune::ParallelIndexSet >& globalIndexSet) +{ + // build global indexset on first process + globalIndexSet.beginResize(); + globalArray.build(NX*NY); + int k=0; + for(int j=0; j (i+j*NX,owner,false)); + globalArray[i+j*NX]=-(i+j*NX); + k++; + + } + + globalIndexSet.endResize(); +} + +void testIndicesBuffered(MPI_Comm comm) +{ + //using namespace Dune; + + // The global grid size + const int Nx = 8; + const int Ny = 1; + + // Process configuration + int procs, rank, master=0; + MPI_Comm_size(comm, &procs); + MPI_Comm_rank(comm, &rank); + + typedef Dune::ParallelIndexSet > ParallelIndexSet; + + ParallelIndexSet distIndexSet; + // global indexset + ParallelIndexSet globalIndexSet; + + Array distArray; + Array globalArray; + + setupDistributed(distArray, distIndexSet, rank, procs); + + + if(rank==master) { + setupGlobal(globalArray, globalIndexSet); + } + + typedef Dune::RemoteIndices RemoteIndices; + + RemoteIndices accuIndices(distIndexSet, globalIndexSet, comm); + + accuIndices.rebuild(); + std::cout<<"dist "<(); + + Dune::Interface accuInterface; + Dune::Interface overlapInterface; + Dune::EnumItem sourceFlags; + Dune::Combine,Dune::EnumItem,GridFlags> destFlags; + // Dune::Bool2Type flag; + + accuInterface.build(accuIndices, sourceFlags, destFlags); + overlapInterface.build(overlapIndices, Dune::EnumItem(), + Dune::EnumItem()); + overlapInterface.print(); + accuInterface.print(); + + //accuInterface.print(); + + Dune::BufferedCommunicator accumulator, overlapExchanger; + + accumulator.build(accuInterface); + + overlapExchanger.build(overlapInterface); + + std::cout<< rank<<": before forward distArray="<< distArray<(distArray, distArray); + + std::cout<(distArray); + + std::cout< > ParallelIndexSet; + ParallelIndexSet sendIndexSet; + // global indexset + ParallelIndexSet receiveIndexSet; + + Array array, redistributedArray; + + // Set up the indexsets. + { + + int start = std::max(rank*nx-1,0); + int end = std::min((rank + 1) * nx+1, Nx); + + sendIndexSet.beginResize(); + + + array.build(Ny*(end-start)); + + for(int j=0, localIndex=0; j=end-2); + GridFlags flag = owner; + + if((i==start && i!=0)||(i==end-1 && i!=Nx-1)) + flag = overlap; + + sendIndexSet.add(i+j*Nx, ParallelLocalIndex (localIndex,flag,isPublic)); + array[localIndex]=i+j*Nx+rank*Nx*Ny; + } + + sendIndexSet.endResize(); + } + { + int newrank = (rank + 1) % procs; + + int start = std::max(newrank*nx-1,0); + int end = std::min((newrank + 1) * nx+1, Nx); + + std::cout<=end-2); + GridFlags flag = owner; + + if((i==start && i!=0)||(i==end-1 && i!=Nx-1)) + flag = overlap; + + receiveIndexSet.add(i+j*Nx, ParallelLocalIndex (localIndex,flag,isPublic)); + redistributedArray[localIndex]=-1; + } + + receiveIndexSet.endResize(); + } + + + std::cout<< rank<<": distributed and global index set!"< RemoteIndices; + + RemoteIndices redistributeIndices(sendIndexSet, + receiveIndexSet, comm); + RemoteIndices overlapIndices(receiveIndexSet, receiveIndexSet, comm); + + redistributeIndices.rebuild(); + overlapIndices.rebuild(); + + DatatypeCommunicator redistribute, overlapComm; + EnumItem fowner; + EnumItem foverlap; + + redistribute.build(redistributeIndices, fowner, array, fowner, redistributedArray); + + overlapComm.build(overlapIndices, fowner, redistributedArray, foverlap, redistributedArray); + std::cout< > ParallelIndexSet; + ParallelIndexSet sendIndexSet; + // global indexset + ParallelIndexSet receiveIndexSet; + + Array array, redistributedArray; + + std::vector neighbours; + + // Set up the indexsets. + { + + int start = std::max(rank*nx-1,0); + int end = std::min((rank + 1) * nx+1, Nx); + + neighbours.reserve(2); + + if(rank>0) neighbours.push_back(rank-1); + if(rank=end-2); + GridFlags flag = owner; + + if((i==start && i!=0)||(i==end-1 && i!=Nx-1)) + flag = overlap; + + sendIndexSet.add(i+j*Nx, ParallelLocalIndex (localIndex,flag,isPublic)); + array[localIndex]=i+j*Nx; //+rank*Nx*Ny; + if(flag==overlap) + array[localIndex]=-array[localIndex]; + } + + sendIndexSet.endResize(); + } + { + int newrank = (rank + 1) % procs; + + int start = std::max(newrank*nx-1,0); + int end = std::min((newrank + 1) * nx+1, Nx); + + std::cout<=end-2); + GridFlags flag = owner; + + if((i==start && i!=0)||(i==end-1 && i!=Nx-1)) + flag = overlap; + + receiveIndexSet.add(i+j*Nx, ParallelLocalIndex (localIndex,flag,isPublic)); + redistributedArray[localIndex]=-1; + } + + receiveIndexSet.endResize(); + } + + + std::cout<< rank<<": distributed and global index set!"< RemoteIndices; + RemoteIndices redistributeIndices(sendIndexSet, + receiveIndexSet, comm); + RemoteIndices overlapIndices(receiveIndexSet, receiveIndexSet, comm); + RemoteIndices sendIndices(sendIndexSet, + sendIndexSet, comm, neighbours); + RemoteIndices sendIndices1(sendIndexSet, + sendIndexSet, comm); + overlapIndices.rebuild(); + redistributeIndices.rebuild(); + sendIndices.rebuild(); + sendIndices1.rebuild(); + + if(rank==0) + std::cout< fowner; + EnumItem foverlap; + + redistributeInterface.build(redistributeIndices, fowner, fowner); + overlapInterface.build(overlapIndices, fowner, foverlap); + + BufferedCommunicator redistribute; + BufferedCommunicator overlapComm; + + redistribute.build(array, redistributedArray, redistributeInterface); + overlapComm.build(overlapInterface); + + std::cout<(array, redistributedArray); + + std::cout<(redistributedArray); + + std::cout<(array, redistributedArray); + + std::cout<(array, redistributedArray); + + std::cout<firstRank) { + if(rank==0) + key = firstRank; + if(rank==firstRank) + key=0; + } + + MPI_Comm_split(MPI_COMM_WORLD, 0, key, &comm); + +#ifdef DEBUG + bool wait=1; + while(size>1 && wait) ; +#endif + + // testIndices(comm); + testIndicesBuffered(comm); + + if(rank==0) + std::cout< -#include -#include -#include -#include +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#include "config.h" +#include +#include +#include +#include +#include -enum GridFlags{ - owner, overlap, border +enum GridFlags { + owner, overlap, border }; template int meassure(const T& selection) { /* - return meassure<1>(selection); -} + return meassure<1>(selection); + } -template -int meassure(const T& selection) -{*/ + template + int meassure(const T& selection) + {*/ typedef typename T::const_iterator iterator; - + const iterator end = selection.end(); int count=0; @@ -31,7 +33,7 @@ count+=*iter; std::cout<<" took "<< timer.elapsed()<<" seconds"<,ALSIZE> distIndexSet; distIndexSet.beginResize(); - + for(int y=0, i=0; y < Ny; y++) - for(int x=0; x < Nx; x++, i++){ + for(int x=0; x < Nx; x++, i++) { GridFlags flag = owner; if(x==0 || x == Nx-1 || y ==0 || y==Ny-1) - flag = overlap; - + flag = overlap; + distIndexSet.add(i, Dune::ParallelLocalIndex (i, flag, true)); } - + distIndexSet.endResize(); - + Dune::UncachedSelection,int,Dune::ParallelLocalIndex,ALSIZE> - ownerUncached(distIndexSet); - + ownerUncached(distIndexSet); + Dune::Selection,int,Dune::ParallelLocalIndex,ALSIZE> - ownerCached(distIndexSet); + ownerCached(distIndexSet); Dune::UncachedSelection,int,Dune::ParallelLocalIndex,ALSIZE> - overlapUncached(distIndexSet); - + overlapUncached(distIndexSet); + Dune::Selection,int,Dune::ParallelLocalIndex,ALSIZE> - overlapCached(distIndexSet); + overlapCached(distIndexSet); int count=0; - + std::cout<<" Owner selection uncached:"; count+=meassure(ownerUncached); std::cout<<" Owner selection cached:"; @@ -81,7 +83,7 @@ count+=meassure(overlapUncached); std::cout<<" Overlap selection cached:"; count+=meassure(overlapCached); -std::cout< -#include -#include -#include +#include +#include +#include +#include +#include -enum GridFlags{ - owner, overlap, border +enum GridFlags { + owner, overlap, border }; template -void deleteOverlapEntries(T& indices, - Dune::RemoteIndices& remoteIndices) +void deleteOverlapEntries(T& indices, + Dune::RemoteIndices& remoteIndices) { typedef typename T::iterator IndexIterator; typedef typename T::GlobalIndex GlobalIndex; @@ -23,89 +26,89 @@ typedef typename RemoteIndices::RemoteIndexList::const_iterator RemoteIterator; typedef Dune::SLList, typename RemoteIndices::RemoteIndexList::Allocator> GlobalList; typedef typename GlobalList::ModifyIterator GlobalModifier; - typedef Dune::tuple IteratorTuple; + typedef std::tuple IteratorTuple; typedef std::map IteratorMap; typedef typename RemoteIndices::const_iterator RemoteMapIterator; - + int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); - + std::map globalLists; - + IteratorMap iterators; RemoteMapIterator rmEnd = remoteIndices.end(); - + for(RemoteMapIterator remote = remoteIndices.begin(); - remote != rmEnd; ++remote){ + remote != rmEnd; ++remote) { // Initialize global indices GlobalList& gList=globalLists[remote->first]; const RemoteIterator rend = remote->second.first->end(); - + for(RemoteIterator index= remote->second.first->begin(); - index != rend; ++index) + index != rend; ++index) gList.push_back(std::make_pair(index->localIndexPair().global(), index->localIndexPair().local().attribute())); assert(gList.size()==remote->second.first->size()); std::cout << "Size of remote indices is "<first, - IteratorTuple(remote->second.first->beginModify(), - gList.beginModify(), - rend, - gList.end(), - &gList, - remote->second.first))); + + iterators.insert(std::make_pair(remote->first, + IteratorTuple(remote->second.first->beginModify(), + gList.beginModify(), + rend, + gList.end(), + &gList, + remote->second.first))); } - + indices.beginResize(); - + const IndexIterator endIndex = indices.end(); - for(IndexIterator index = indices.begin(); index != endIndex; ++index){ - if(index->local().attribute()==overlap){ + for(IndexIterator index = indices.begin(); index != endIndex; ++index) { + if(index->local().attribute()==overlap) { std::cout << rank<<": Deleting "<<*index<(remote->second) != Dune::get<2>(remote->second) - && *(Dune::get<1>(remote->second)) < *index){ - // increment all iterators - ++(Dune::get<0>(remote->second)); - ++(Dune::get<1>(remote->second)); - if(Dune::get<0>(remote->second)!=Dune::get<2>(remote->second)) - assert(Dune::get<1>(remote->second)!=Dune::get<3>(remote->second)); - } - - // Delete the entry if present - if(Dune::get<0>(remote->second) != Dune::get<2>(remote->second)){ - assert(Dune::get<1>(remote->second) != Dune::get<3>(remote->second)); - - if(*(Dune::get<1>(remote->second)) == *index){ - - std::cout<(remote->second)->first<<", "<< - Dune::get<1>(remote->second)->second<<" of process " - << remote->first<(remote->second).remove(); - Dune::get<1>(remote->second).remove(); - assert(Dune::get<4>(remote->second)->size()==Dune::get<5>(remote->second)->size()); - } - } + for(iterator remote = iterators.begin(); remote != end; ++remote) { + + // Search for the index + while(std::get<0>(remote->second) != std::get<2>(remote->second) + && *(std::get<1>(remote->second)) < *index) { + // increment all iterators + ++(std::get<0>(remote->second)); + ++(std::get<1>(remote->second)); + if(std::get<0>(remote->second)!=std::get<2>(remote->second)) + assert(std::get<1>(remote->second)!=std::get<3>(remote->second)); + } + + // Delete the entry if present + if(std::get<0>(remote->second) != std::get<2>(remote->second)) { + assert(std::get<1>(remote->second) != std::get<3>(remote->second)); + + if(*(std::get<1>(remote->second)) == *index) { + + std::cout<(remote->second)->first<<", "<< + std::get<1>(remote->second)->second<<" of process " + << remote->first<(remote->second).remove(); + std::get<1>(remote->second).remove(); + assert(std::get<4>(remote->second)->size()==std::get<5>(remote->second)->size()); + } + } } } } - - indices.endResize(); + + indices.endResize(); // Update the pointers to the local index pairs Dune::repairLocalIndexPointers(globalLists, remoteIndices, indices); @@ -115,9 +118,9 @@ template bool areEqual(T& indices, - Dune::RemoteIndices& remoteIndices, - T& oIndices, - Dune::RemoteIndices& oRemoteIndices){ + Dune::RemoteIndices& remoteIndices, + T& oIndices, + Dune::RemoteIndices& oRemoteIndices){ typedef typename T::iterator IndexIterator; typedef Dune::RemoteIndices RemoteIndices; @@ -127,158 +130,158 @@ bool ret=true; int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); - + // Test the index sets - if(indices.size() != oIndices.size()){ + if(indices.size() != oIndices.size()) { std::cerr<< rank<<": Size of index set is unequal!"<global() != oIndex->global()){ + index != iEnd; ++index, ++oIndex) { + if( index->global() != oIndex->global()) { std::cerr<global() <<" is missing!"<local().attribute() !=oIndex->local().attribute()){ + else if(index->local().attribute() !=oIndex->local().attribute()) { std::cerr<global() <<" has wrong attribute: "<< - index->local().attribute()<< "!= "<local().attribute()<local().attribute()<< "!= "<local().attribute()<second.first->size() != remote->second.first->size()){ + oRemote = oRemoteIndices.begin(); + remote != rmEnd; ++remote, ++oRemote) { + if(oRemote->second.first->size() != remote->second.first->size()) { std::cerr <first - <<" does not match!"<second.first->end(); for(RemoteIterator rIndex= remote->second.first->begin(), - oRIndex = oRemote->second.first->begin(); oRIndex != rEnd; - ++rIndex, ++oRIndex){ + oRIndex = oRemote->second.first->begin(); oRIndex != rEnd; + ++rIndex, ++oRIndex) { - if(rIndex->localIndexPair().global() != oRIndex->localIndexPair().global()){ + if(rIndex->localIndexPair().global() != oRIndex->localIndexPair().global()) { - std::cerr<localIndexPair().global() - <<" is missing for process "<first<localIndexPair().global() + <<" is missing for process "<first<attribute() != oRIndex->attribute()){ - std::cerr<localIndexPair().global() - <<" for process "<< remote->first<<" is wrong: " - <attribute()<<" != "<attribute()<attribute() != oRIndex->attribute()) { + std::cerr<localIndexPair().global() + <<" for process "<< remote->first<<" is wrong: " + <attribute()<<" != "<attribute()< void addFakeRemoteIndices(T& indices, - T& oIndices, - Dune::RemoteIndices& remoteIndices, - Dune::RemoteIndices& oRemoteIndices){ + T& oIndices, + Dune::RemoteIndices& remoteIndices, + Dune::RemoteIndices& oRemoteIndices){ typedef typename T::iterator IndexIterator; typedef typename T::GlobalIndex GlobalIndex; typedef typename T::LocalIndex::Attribute Attribute; typedef typename Dune::RemoteIndices::RemoteIndexList RemoteIndexList; assert(remoteIndices.neighbours()==0 && oRemoteIndices.neighbours()==0); - + RemoteIndexList* rlist = new RemoteIndexList(); RemoteIndexList* orlist = new RemoteIndexList(); int added=0; IndexIterator iEnd = indices.end(); for(IndexIterator index = indices.begin(), oIndex = oIndices.begin(); - index != iEnd; ++index, ++oIndex){ + index != iEnd; ++index, ++oIndex) { assert(*index == *oIndex); - if(index->local().attribute()==overlap){ + if(index->local().attribute()==overlap) { added++; rlist->push_back(Dune::RemoteIndex(owner,&(*index))); orlist->push_back(Dune::RemoteIndex(owner,&(*oIndex))); } } - - + + remoteIndices.remoteIndices_.insert(std::make_pair(1,std::make_pair(rlist,rlist))); oRemoteIndices.remoteIndices_.insert(std::make_pair(1,std::make_pair(orlist,orlist))); - + std::cout<<"Added "< LocalIndexType; - + typedef Dune::ParallelIndexSet > ParallelIndexSet; ParallelIndexSet indexSet, changedIndexSet; - + // Set up the indexsets. int start,end, ostart, oend; - if(rank0 &&start syncer(changedIndexSet, changedRemoteIndices); // return 0; - + std::cout<<"Syncing!"< +#if HAVE_MPI +#include +#endif + +#include + +struct MyDataHandle +{ + MyDataHandle(int r) + : rank(r) + { + } + int rank; + + typedef double DataType; + + bool fixedsize() + { + return true; + } + template + void gather(B& buffer, int i) + { + std::cout< + void scatter(B& buffer, int i, int size) + { + std::cout<0;--size) + { + double index; + buffer.read(index); + std::cout< + void gather(B& buffer, int i) + { + std::size_t s=i%5; + std::cout<(i+j)); + } + template + void scatter(B& buffer, int i, int size) + { + std::cout<0;--size) + { + double index; + buffer.read(index); + std::cout< + +int main(int argc, char** argv) +{ +#if HAVE_MPI + MPI_Init(&argc, &argv); + int procs, rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &procs); + if(procs==1) + { + typedef Dune::VariableSizeCommunicator<>::InterfaceMap Interface; + Dune::InterfaceInformation send, recv; + send.reserve(6); + for(std::size_t i=0; i<=10; i+=2) + send.add(i); + + recv.reserve(6); + for(std::size_t i=10; i<=10; i-=2) + recv.add(i); + Interface inf; + inf[0]=std::make_pair(send, recv); + Dune::VariableSizeCommunicator<> comm(MPI_COMM_SELF, inf, 6); + MyDataHandle handle(0); + comm.forward(handle); + std::cout<<"===================== backward ========================="<2) + --procs; + int N=100000; + int num_per_proc=N/procs; + int start, end; + if(rank::InterfaceMap Interface; + Interface inf; + if(rank && rank comm(MPI_COMM_WORLD, inf, 6); + MyDataHandle handle(rank); + comm.forward(handle); + MPI_Barrier(MPI_COMM_WORLD); + if(rank==0) + std::cout<<"===================== backward ========================="< +#include +#include +#include +#include +#include "interface.hh" +#include "mpitraits.hh" + +/** + * @addtogroup Common_Parallel + * + * @{ + */ +/** + * @file + * @brief A communicator that only needs to know the number of elements per + * index at the sender side. + * @author Markus Blatt + * @} + */ +namespace Dune +{ + +namespace +{ +/** + * @brief A message buffer. + * @tparam T The type of data that the buffer will hold. + */ +template > +class MessageBuffer +{ +public: + /** + * @brief Constructs a message. + * @param size The number of elements that buffer should hold, + */ + explicit MessageBuffer(int size) + : buffer_(new T[size]), size_(size), position_(0) + {} + /** + * @brief Copy constructor. + * @param o The instance to copy. + */ + explicit MessageBuffer(const MessageBuffer& o) + : buffer_(new T[o.size_]), size_(o.size_), position_(o.position_) + { + } + /** @brief Destructor. */ + ~MessageBuffer() + { + delete[] buffer_; + } + /** + * @brief Write an item to the buffer. + * @param data The data item to write. + */ + void write(const T& data) + { + buffer_[position_++]=data; + } + + /** + * @brief Reads a data item from the buffer + * @param[out] data Reference to where to store the read data. + */ + void read(T& data) + { + data=buffer_[position_++]; + } + + /** + * @brief Reset the buffer. + * + * On return the buffer will be positioned at the start again. + */ + void reset() + { + position_=0; + } + + /** + * @brief Test whether the whole buffer was read. + * @return True if we read or wrot until the end of the buffer. + */ + bool finished() + { + return position_==size_; + } + + /** + * @brief Tests whether the buffer has enough space left to read/write data. + * @param notItems The number of items to read or write. + * @return True if there is enough space for noItems items. + */ + bool hasSpaceForItems(int noItems) + { + return position_+noItems<=size_; + } + /** + * @brief Get the size of the buffer. + * @return The number of elements the buffer can hold. + */ + std::size_t size() const + { + return size_; + } + /** + * @brief Converts the buffer to a C array. + * @return The underlying C array. + */ + operator T*() + { + return buffer_; + } + +private: + /** + * @brief Pointer to the current insertion point of the buffer. + */ + T* buffer_; + /** + * @brief The size of the buffer + */ + std::size_t size_; + /** + * @brief The current position in the buffer. + */ + std::size_t position_; +}; + +/** + * @brief A tracker for the current position in a communication interface. + */ +class InterfaceTracker +{ +public: + /** + * @brief Constructor. + * @param rank The other rank that the interface communicates with. + * @param info A list of local indices belonging to this interface. + */ + InterfaceTracker(int rank, InterfaceInformation info, std::size_t fixedsize=0, + bool allocateSizes=false) + : fixedSize(fixedsize),rank_(rank), index_(), interface_(info), sizes_(), + sizesAllocated_(allocateSizes) + { + if(allocateSizes) + { + sizes_.resize(info.size()); + } + } + + /** + * @brief Moves to the next index in the interface. + */ + void moveToNextIndex() + { + index_++; + assert(index_<=interface_.size()); + skipZeroIndices(); + } + /** + * @brief Increment index various times. + * @param i The number of times to increment. + */ + void increment(std::size_t i) + { + index_+=i; + assert(index_<=interface_.size()); + } + /** + * @brief Checks whether all indices have been visited. + * @return True if all indices have been visited. + */ + bool finished() const + { + return index_==interface_.size(); + } + + void skipZeroIndices() + { + // skip indices with size zero! + while(sizes_.size() && index_!=interface_.size() &&!size()) + ++index_; + } + + /** + * @brief Get the current local index of the interface. + * @return The current local index of the interface. + */ + std::size_t index() const + { + return interface_[index_]; + } + /** + * @brief Get the size at the current index. + */ + std::size_t size() const + { + assert(sizes_.size()); + return sizes_[index_]; + } + /** + * @brief Get a pointer to the array with the sizes. + */ + std::size_t* getSizesPointer() + { + return &sizes_[0]; + } + /** + * @brief Returns whether the interface is empty. + * @return True if there are no entries in the interface. + */ + bool empty() const + { + return !interface_.size(); + } + + /** + * @brief Checks whether there are still indices waiting to be processed. + * @return True if there are still indices waiting to be processed. + */ + std::size_t indicesLeft() const + { + return interface_.size()-index_; + } + /** + * @brief The number of data items per index if it is fixed, 0 otherwise. + */ + std::size_t fixedSize; + /** + * @brief Get the process rank that this communication interface is with. + */ + int rank() const + { + return rank_; + } + /** + * @brief Get the offset to the first index. + */ + std::size_t offset() const + { + return index_; + } +private: + /** @brief The process rank that this communication interface is with. */ + int rank_; + /** @brief The other rank that this interface communcates with. */ + std::size_t index_; + /** @brief The list of local indices of this interface. */ + InterfaceInformation interface_; + std::vector sizes_; + bool sizesAllocated_; +}; + + +} // end unnamed namespace + +/** + * @addtogroup Common_Parallel + * + * @{ + */ +/** + * @brief A buffered communicator where the amount of data sent does not have to be known a priori. + * + * In contrast to BufferedCommunicator the amount of data is determined by the container + * whose entries are sent and not known at the receiving side a priori. + */ +template > > +class VariableSizeCommunicator +{ +public: + /** + * @brief The type of the map form process number to InterfaceInformation for + * sending and receiving to and from it. + */ + typedef std::map, + std::less, + typename Allocator::template rebind > >::other> InterfaceMap; + +#ifndef DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE + /** + * @brief Creates a communicator with the default maximum buffer size. + * + * The default size ist either what the macro DUNE_MAX_COMMUNICATION_BUFFER_SIZE + * is set to or 32768 if is not set. + */ + VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap& inf) + : maxBufferSize_(32768), interface_(&inf) + { + MPI_Comm_dup(comm, &communicator_); + } + /** + * @brief Creates a communicator with the default maximum buffer size. + * @param inf The communication interface. + */ + VariableSizeCommunicator(const Interface& inf) + : maxBufferSize_(32768), interface_(&inf.interfaces()) + { + MPI_Comm_dup(inf.communicator(), &communicator_); + } +#else + /** + * @brief Creates a communicator with the default maximum buffer size. + * + * The default size ist either what the macro DUNE_MAX_COMMUNICATION_BUFFER_SIZE + * is set to or 32768 if is not set. + */ + VariableSizeCommunicator(MPI_Comm comm, InterfaceMap& inf) + : maxBufferSize_(DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE), + interface_(&inf) + { + MPI_Comm_dup(comm, &communicator_); + } + /** + * @brief Creates a communicator with the default maximum buffer size. + * @param inf The communication interface. + */ + VariableSizeCommunicator(const Interface& inf) + : maxBufferSize_(DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE), + interface_(&inf.interfaces()) + { + MPI_Comm_dup(inf.communicator(), &communicator_); + } +#endif + /** + * @brief Creates a communicator with a specific maximum buffer size. + * @param comm The MPI communicator to use. + * @param inf The communication interface. + * @param max_buffer_size The maximum buffer size allowed. + */ + VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap& inf, std::size_t max_buffer_size) + : maxBufferSize_(max_buffer_size), interface_(&inf) + { + MPI_Comm_dup(comm, &communicator_); + } + + /** + * @brief Creates a communicator with a specific maximum buffer size. + * @param inf The communication interface. + * @param max_buffer_size The maximum buffer size allowed. + */ + VariableSizeCommunicator(const Interface& inf, std::size_t max_buffer_size) + : maxBufferSize_(max_buffer_size), interface_(&inf.interfaces()) + { + MPI_Comm_dup(inf.communicator(), &communicator_); + } + + ~VariableSizeCommunicator() + { + MPI_Comm_free(&communicator_); + } + + + /** + * @brief Communicate forward. + * + * @tparam DataHandle The type of the handle describing the data. This type has to adhere + * to the following interface: + * \code{.cpp} + * // returns whether the number of data items per entry is fixed + * bool fixedsize(); + * // get the number of data items for an entry with index i + * std::size_t size(std::size_t i); + * // gather the data at index i + * template + * void gather(MessageBuffer& buf, std::size_t i); + * // scatter the n data items to index i + * template + * void scatter(MessageBuffer& buf, std::size_t i, std::size_t n); + * \endcode + * @param handle A handle responsible for describing the data, gathering, and scattering it. + */ + template + void forward(DataHandle& handle) + { + communicate(handle); + } + + /** + * @brief Communicate backwards. + * + * @tparam DataHandle The type of the handle describing the data. This type has to adhere + * to the following interface: + * \code{.cpp} + * // returns whether the number of data items per entry is fixed + * bool fixedsize(); + * // get the number of data items for an entry with index i + * std::size_t size(std::size_t i); + * // gather the data at index i + * template + * void gather(MessageBuffer& buf, std::size_t i); + * // scatter the n data items to index i + * template + * void scatter(MessageBuffer& buf, std::size_t i, std::size_t n); + * \endcode + * @param handle A handle responsible for describing the data, gathering, and scattering it. + */ + template + void backward(DataHandle& handle) + { + communicate(handle); + } + +private: + template + void communicateSizes(DataHandle& handle, + std::vector& recv_trackers); + + /** + * @brief Communicates data according to the interface. + * @tparam forward If true sends data forwards, otherwise backwards along the interface. + * @tparame DataHandle The type of the data handle @see forward for a description of the interface. + * @param handle The handle describing the data and responsible for gather and scatter operations. + */ + template + void communicate(DataHandle& handle); + /** + * @brief Initialize the trackers along the interface for the communication. + * @tparam FORWARD If true we send in the forward direction. + * @tparam DataHandle DataHandle The type of the data handle. + * @param handle The handle describing the data and responsible for gather + * and scatter operations. + * @param[out] send_trackers The trackers for the sending side. + * @param[out] recv_trackers The trackers for the receiving side. + */ + template + void setupInterfaceTrackers(DataHandle& handle, + std::vector& send_trackers, + std::vector& recv_trackers); + /** + * @brief Communicate data with a fixed amount of data per entry. + * @tparam FORWARD If true we send in the forward direction. + * @tparam DataHandle DataHandle The type of the data handle. + * @param handle The handle describing the data and responsible for gather + * and scatter operations. + */ + template + void communicateFixedSize(DataHandle& handle); + /** + * @brief Communicate data with a variable amount of data per entry. + * @tparam FORWARD If true we send in the forward direction. + * @tparam DataHandle DataHandle The type of the data handle. + * @param handle The handle describing the data and responsible for gather + * and scatter operations. + */ + template + void communicateVariableSize(DataHandle& handle); + /** + * @brief The maximum size if the buffers used for gather and scatter. + * + * @note If this process has n neighbours, then a maximum of 2n buffers of this size + * is allocate. Memory needed will be n*sizeof(std::size_t)+n*sizeof(Datahandle::DataType) + */ + std::size_t maxBufferSize_; + /** + * @brief description of the interface. + * + * This is a map of the neighboring process number to a pair of local index lists. + * The first is a list of indices to gather data for sending from and the second is a list of + * indices to scatter received data to during forward. + */ + const InterfaceMap* interface_; + /** + * @brief The communicator. + * + * This is a cloned communicator to ensure there are no interferences. + */ + MPI_Comm communicator_; +}; + +/** @} */ +namespace +{ +/** + * @brief A data handle for comunicating the sizes of variable sized data. + */ +template +class SizeDataHandle +{ +public: + typedef std::size_t DataType; + + SizeDataHandle(DataHandle& data, + std::vector& trackers) + : data_(data), trackers_(trackers), index_() + {} + bool fixedsize() + { + return true; + } + std::size_t size(std::size_t i) + { + DUNE_UNUSED_PARAMETER(i); + return 1; + } + template + void gather(B& buf, int i) + { + buf.write(data_.size(i)); + } + void setReceivingIndex(std::size_t i) + { + index_=i; + } + std::size_t* getSizesPointer() + { + return trackers_[index_].getSizesPointer(); + } + +private: + DataHandle& data_; + std::vector& trackers_; + int index_; +}; + +template +void setReceivingIndex(T&, int) +{} + +template +void setReceivingIndex(SizeDataHandle& t, int i) +{ + t.setReceivingIndex(i); +} + + +/** + * @brief Template meta program for choosing then send or receive interface + * information based on the direction. + * @tparam FORWARD If true the communication happens in the forward direction. + */ +template +struct InterfaceInformationChooser +{ + /** + * @brief Get the interface information for the sending side. + */ + static const InterfaceInformation& + getSend(const std::pair& info) + { + return info.first; + } + + /** + * @brief Get the interface information for the receiving side. + */ + static const InterfaceInformation& + getReceive(const std::pair& info) + { + return info.second; + } +}; + +template<> +struct InterfaceInformationChooser +{ + static const InterfaceInformation& + getSend(const std::pair& info) + { + return info.second; + } + + static const InterfaceInformation& + getReceive(const std::pair& info) + { + return info.first; + } +}; + +/** + * @brief A functor that packs entries into the message buffer. + * @tparam DataHandle The type of the data handle that describes + * the communicated data. + */ +template +struct PackEntries +{ + + int operator()(DataHandle& handle, InterfaceTracker& tracker, + MessageBuffer& buffer, + int i) const + { + return operator()(handle,tracker,buffer); + } + + /** + * @brief packs data. + * @param handle The handle describing the data and the gather and scatter operations. + * @param tracker The tracker of the interface to tell us where we are. + * @param buffer The buffer to use for packing. + * @return The number data entries that we packed. + */ + int operator()(DataHandle& handle, InterfaceTracker& tracker, + MessageBuffer& buffer) const + { + if(tracker.fixedSize) // fixed size if variable is >0! + { + + std::size_t noIndices=std::min(buffer.size()/tracker.fixedSize, tracker.indicesLeft()); + for(std::size_t i=0; i< noIndices; ++i) + { + handle.gather(buffer, tracker.index()); + tracker.moveToNextIndex(); + } + return noIndices*tracker.fixedSize; + } + else + { + int packed=0; + tracker.skipZeroIndices(); + while(!tracker.finished()) + if(buffer.hasSpaceForItems(handle.size(tracker.index()))) + { + handle.gather(buffer, tracker.index()); + packed+=handle.size(tracker.index()); + tracker.moveToNextIndex(); + } + else + break; + assert(packed); + return packed; + } + } +}; + +/** + * @brief A functor that unpacks entries from the message buffer. + * @tparam DataHandle The type of the data handle that describes + * the communicated data. + */ +template +struct UnpackEntries{ + + /** + * @brief packs data. + * @param handle The handle describing the data and the gather and scatter operations. + * @param tracker The tracker of the interface to tell us where we are. + * @param buffer The buffer to use for packing. + * @return The number data entries that we packed. + */ + bool operator()(DataHandle& handle, InterfaceTracker& tracker, + MessageBuffer& buffer, + int count=0) + { + if(tracker.fixedSize) // fixed size if variable is >0! + { + std::size_t noIndices=std::min(buffer.size()/tracker.fixedSize, tracker.indicesLeft()); + + for(std::size_t i=0; i< noIndices; ++i) + { + handle.scatter(buffer, tracker.index(), tracker.fixedSize); + tracker.moveToNextIndex(); + } + return tracker.finished(); + } + else + { + assert(count); + for(int unpacked=0;unpacked +struct UnpackSizeEntries{ + + /** + * @brief packs data. + * @param handle The handle describing the data and the gather and scatter operations. + * @param tracker The tracker of the interface to tell us where we are. + * @param buffer The buffer to use for packing. + * @return The number data entries that we packed. + */ + bool operator()(SizeDataHandle& handle, InterfaceTracker& tracker, + MessageBuffer::DataType>& buffer) const + { + std::size_t noIndices=std::min(buffer.size(), tracker.indicesLeft()); + std::copy(static_cast(buffer), static_cast(buffer)+noIndices, + handle.getSizesPointer()+tracker.offset()); + tracker.increment(noIndices); + return noIndices; + } + bool operator()(SizeDataHandle& handle, InterfaceTracker& tracker, + MessageBuffer::DataType>& buffer, int) const + { + return operator()(handle,tracker,buffer); + } +}; + +/** + * @brief Sends the size in case of communicating a fixed amount of data per entry. + * @param[in] send_trackers The trackers for the sending side. + * @param[out] send_requests The request for the asynchronous send operations. + * @param[in] recv_trackers The trackers for the receiving side. + * @param[out] recv_requests The request for the asynchronous receive operations. + */ +void sendFixedSize(std::vector& send_trackers, + std::vector& send_requests, + std::vector& recv_trackers, + std::vector& recv_requests, + MPI_Comm communicator) +{ + typedef std::vector::iterator TIter; + std::vector::iterator mIter=recv_requests.begin(); + + for(TIter iter=recv_trackers.begin(), end=recv_trackers.end(); iter!=end; + ++iter, ++mIter) + { + MPI_Irecv(&(iter->fixedSize), 1, MPITraits::getType(), + iter->rank(), 933881, communicator, &(*mIter)); + } + + // Send our size to all neighbours using non-blocking synchronous communication. + std::vector::iterator mIter1=send_requests.begin(); + for(TIter iter=send_trackers.begin(), end=send_trackers.end(); + iter!=end; + ++iter, ++mIter1) + { + MPI_Issend(&(iter->fixedSize), 1, MPITraits::getType(), + iter->rank(), 933881, communicator, &(*mIter1)); + } +} + + +/** + * @brief Functor for setting up send requests. + * @tparam DataHandle The type of the data handle for describing the data. + */ +template +struct SetupSendRequest{ + void operator()(DataHandle& handle, + InterfaceTracker& tracker, + MessageBuffer& buffer, + MPI_Request& request, + MPI_Comm comm) const + { + buffer.reset(); + int size=PackEntries()(handle, tracker, buffer); + // Skip indices of zero size. + while(!tracker.finished() && !handle.size(tracker.index())) + tracker.moveToNextIndex(); + if(size) + MPI_Issend(buffer, size, MPITraits::getType(), + tracker.rank(), 933399, comm, &request); + } +}; + + +/** + * @brief Functor for setting up receive requests. + * @tparam DataHandle The type of the data handle for describing the data. + */ +template +struct SetupRecvRequest{ + void operator()(DataHandle& /*handle*/, + InterfaceTracker& tracker, + MessageBuffer& buffer, + MPI_Request& request, + MPI_Comm comm) const + { + buffer.reset(); + if(tracker.indicesLeft()) + MPI_Irecv(buffer, buffer.size(), MPITraits::getType(), + tracker.rank(), 933399, comm, &request); + } +}; + +/** + * @brief A functor that does nothing. + */ +template +struct NullPackUnpackFunctor +{ + int operator()(DataHandle&, InterfaceTracker&, + MessageBuffer&, int) + { + return 0; + } + int operator()(DataHandle&, InterfaceTracker&, + MessageBuffer&) + { + return 0; + } +}; + +/** + * @brief Check whether some of the requests finished and continue send/receive operation. + * @tparam DataHandle The type of the data handle describing the data. + * @tparam BufferFunctor A functor that packs or unpacks data from the buffer. + * E.g. NullPackUnpackFunctor. + * @tparam CommunicationFuntor A functor responsible for continuing the communication. + * @param handle The data handle describing the data. + * @param trackers The trackers indicating the current position in the communication. + * @param requests The requests to test whether they finished. + * @param requests2 The requests to use for setting up the continuing communication. Might + * be the same as requests. + * @param comm The MPI communicator to use. + * @param buffer_func The functor that does the packing or unpacking of the data. + */ +template +std::size_t checkAndContinue(DataHandle& handle, + std::vector& trackers, + std::vector& requests, + std::vector& requests2, + std::vector >& buffers, + MPI_Comm comm, + BufferFunctor buffer_func, + CommunicationFunctor comm_func, + bool valid=true, + bool getCount=false) +{ + std::size_t size=requests.size(); + std::vector statuses(size); + int no_completed; + std::vector indices(size, -1); // the indices for which the communication finished. + + MPI_Testsome(size, &(requests[0]), &no_completed, &(indices[0]), &(statuses[0])); + indices.resize(no_completed); + for(std::vector::iterator index=indices.begin(), end=indices.end(); + index!=end; ++index) + { + InterfaceTracker& tracker=trackers[*index]; + setReceivingIndex(handle, *index); + if(getCount) + { + // Get the number of entries received + int count; + MPI_Get_count(&(statuses[index-indices.begin()]), + MPITraits::getType(), + &count); + // Communication completed, we can reuse the buffers, e.g. unpack or repack + buffer_func(handle, tracker, buffers[*index], count); + }else + buffer_func(handle, tracker, buffers[*index]); + tracker.skipZeroIndices(); + if(!tracker.finished()){ + // Maybe start another communication. + comm_func(handle, tracker, buffers[*index], requests2[*index], comm); + tracker.skipZeroIndices(); + if(valid) + no_completed-=!tracker.finished(); // communication not finished, decrement counter for finished ones. + } + } + return no_completed; + +} + +/** + * @brief Receive the size per data entry and set up requests for receiving the data. + * @tparam DataHandle The type of the data handle. + * @param trackers The trackers indicating the indices where we send and from which rank. + * @param size_requests The requests for receiving the size. + * @param data_requests The requests for sending the data. + * @param buffers The buffers to use for sending. + * @param comm The mpi communicator to use. + */ +template +std::size_t receiveSizeAndSetupReceive(DataHandle& handle, + std::vector& trackers, + std::vector& size_requests, + std::vector& data_requests, + std::vector >& buffers, + MPI_Comm comm) +{ + return checkAndContinue(handle, trackers, size_requests, data_requests, buffers, comm, + NullPackUnpackFunctor(), SetupRecvRequest(), false); +} + +/** + * @brief Check whether send request completed and continue sending if necessary. + * @tparam DataHandle The type of the data handle. + * @param trackers The trackers indicating the indices where we send and from which rank. + * @param requests The requests for the asynchronous communication. + * @param buffers The buffers to use for sending. + * @param comm The mpi communicator to use. + */ +template +std::size_t checkSendAndContinueSending(DataHandle& handle, + std::vector& trackers, + std::vector& requests, + std::vector >& buffers, + MPI_Comm comm) +{ + return checkAndContinue(handle, trackers, requests, requests, buffers, comm, + NullPackUnpackFunctor(), SetupSendRequest()); +} + +/** + * @brief Check whether receive request completed and continue receiving if necessary. + * @tparam DataHandle The type of the data handle. + * @param trackers The trackers indicating the indices where we receive and from which rank. + * @param requests The requests for the asynchronous communication. + * @param buffers The buffers to use for receiving. + * @param comm The mpi communicator to use. + */ +template +std::size_t checkReceiveAndContinueReceiving(DataHandle& handle, + std::vector& trackers, + std::vector& requests, + std::vector >& buffers, + MPI_Comm comm) +{ + return checkAndContinue(handle, trackers, requests, requests, buffers, comm, + UnpackEntries(), SetupRecvRequest(), + true, !handle.fixedsize()); +} + + +bool validRecvRequests(const std::vector reqs) +{ + for(std::vector::const_iterator i=reqs.begin(), end=reqs.end(); + i!=end; ++i) + if(*i!=MPI_REQUEST_NULL) + return true; + return false; +} + +/** + * @brief Sets up all the send requests for the data. + * @tparam DataHandle The type of the data handle. + * @tparam Functor The type of the functor to set up the request. + * @param handle The data handle describing the data. + * @param trackers The trackers for the communication interfaces. + * @param buffers The buffers for the comunication. One for each neighbour. + * @param requests The send requests for each neighbour. + * @param setupFunctor The functor responsible for setting up the request. + */ +template +std::size_t setupRequests(DataHandle& handle, + std::vector& trackers, + std::vector >& buffers, + std::vector& requests, + const Functor& setupFunctor, + MPI_Comm communicator) +{ + typedef typename std::vector::iterator TIter; + typename std::vector >::iterator + biter=buffers.begin(); + typename std::vector::iterator riter=requests.begin(); + std::size_t complete=0; + for(TIter titer=trackers.begin(), end=trackers.end(); titer!=end; ++titer, ++biter, ++riter) + { + setupFunctor(handle, *titer, *biter, *riter, communicator); + complete+=titer->finished(); + } + return complete; +} +} // end unnamed namespace + +template +template +void VariableSizeCommunicator::setupInterfaceTrackers(DataHandle& handle, + std::vector& send_trackers, + std::vector& recv_trackers) +{ + if(interface_->size()==0) + return; + send_trackers.reserve(interface_->size()); + recv_trackers.reserve(interface_->size()); + + int fixedsize=0; + if(handle.fixedsize()) + ++fixedsize; + + + typedef typename InterfaceMap::const_iterator IIter; + for(IIter inf=interface_->begin(), end=interface_->end(); inf!=end; ++inf) + { + + if(handle.fixedsize() && InterfaceInformationChooser::getSend(inf->second).size()) + fixedsize=handle.size(InterfaceInformationChooser::getSend(inf->second)[0]); + assert(!handle.fixedsize()||fixedsize>0); + send_trackers.push_back(InterfaceTracker(inf->first, + InterfaceInformationChooser::getSend(inf->second), fixedsize)); + recv_trackers.push_back(InterfaceTracker(inf->first, + InterfaceInformationChooser::getReceive(inf->second), fixedsize, fixedsize==0)); + } +} + +template +template +void VariableSizeCommunicator::communicateFixedSize(DataHandle& handle) +{ + std::vector size_send_req(interface_->size()); + std::vector size_recv_req(interface_->size()); + + std::vector send_trackers; + std::vector recv_trackers; + setupInterfaceTrackers(handle,send_trackers, recv_trackers); + sendFixedSize(send_trackers, size_send_req, recv_trackers, size_recv_req, communicator_); + + std::vector data_send_req(interface_->size(), MPI_REQUEST_NULL); + std::vector data_recv_req(interface_->size(), MPI_REQUEST_NULL); + typedef typename DataHandle::DataType DataType; + std::vector > send_buffers(interface_->size(), MessageBuffer(maxBufferSize_)), + recv_buffers(interface_->size(), MessageBuffer(maxBufferSize_)); + + + setupRequests(handle, send_trackers, send_buffers, data_send_req, + SetupSendRequest(), communicator_); + + std::size_t no_size_to_recv, no_to_send, no_to_recv, old_size; + no_size_to_recv = no_to_send = no_to_recv = old_size = interface_->size(); + + // Skip empty interfaces. + typedef typename std::vector::const_iterator Iter; + for(Iter i=recv_trackers.begin(), end=recv_trackers.end(); i!=end; ++i) + if(i->empty()) + --no_to_recv; + for(Iter i=send_trackers.begin(), end=send_trackers.end(); i!=end; ++i) + if(i->empty()) + --no_to_send; + + while(no_size_to_recv+no_to_send+no_to_recv) + { + // Receive the fixedsize and setup receives accordingly + if(no_size_to_recv) + no_size_to_recv -= receiveSizeAndSetupReceive(handle,recv_trackers, size_recv_req, + data_recv_req, recv_buffers, + communicator_); + + // Check send completion and initiate other necessary sends + if(no_to_send) + no_to_send -= checkSendAndContinueSending(handle, send_trackers, data_send_req, + send_buffers, communicator_); + if(validRecvRequests(data_recv_req)) + // Receive data and setup new unblocking receives if necessary + no_to_recv -= checkReceiveAndContinueReceiving(handle, recv_trackers, data_recv_req, + recv_buffers, communicator_); + } + + // Wait for completion of sending the size. + //std::vector statuses(interface_->size(), MPI_STATUSES_IGNORE); + MPI_Waitall(size_send_req.size(), &(size_send_req[0]), MPI_STATUSES_IGNORE); + +} + +template +template +void VariableSizeCommunicator::communicateSizes(DataHandle& handle, + std::vector& data_recv_trackers) +{ + std::vector send_trackers; + std::vector recv_trackers; + std::size_t size = interface_->size(); + std::vector send_requests(size); + std::vector recv_requests(size); + std::vector > + send_buffers(size, MessageBuffer(maxBufferSize_)), + recv_buffers(size, MessageBuffer(maxBufferSize_)); + SizeDataHandle size_handle(handle,data_recv_trackers); + setupInterfaceTrackers(size_handle,send_trackers, recv_trackers); + std::size_t size_to_send=size, size_to_recv=size; + + // Skip empty interfaces. + typedef typename std::vector::const_iterator Iter; + for(Iter i=recv_trackers.begin(), end=recv_trackers.end(); i!=end; ++i) + if(i->empty()) + --size_to_recv; + + size_to_send -= setupRequests(size_handle, send_trackers, send_buffers, send_requests, + SetupSendRequest >(), communicator_); + setupRequests(size_handle, recv_trackers, recv_buffers, recv_requests, + SetupRecvRequest >(), communicator_); + + + while(size_to_send+size_to_recv) + { + if(size_to_send) + size_to_send -= + checkSendAndContinueSending(size_handle, send_trackers, send_requests, + send_buffers, communicator_); + if(size_to_recv) + // Could have done this using checkSendAndContinueSending + // But the call below is more efficient as UnpackSizeEntries + // uses std::copy. + size_to_recv -= + checkAndContinue(size_handle, recv_trackers, recv_requests, recv_requests, + recv_buffers, communicator_, UnpackSizeEntries(), + SetupRecvRequest >()); + } +} + +template +template +void VariableSizeCommunicator::communicateVariableSize(DataHandle& handle) +{ + + std::vector send_trackers; + std::vector recv_trackers; + setupInterfaceTrackers(handle, send_trackers, recv_trackers); + + std::vector send_requests(interface_->size(), MPI_REQUEST_NULL); + std::vector recv_requests(interface_->size(), MPI_REQUEST_NULL); + typedef typename DataHandle::DataType DataType; + std::vector > + send_buffers(interface_->size(), MessageBuffer(maxBufferSize_)), + recv_buffers(interface_->size(), MessageBuffer(maxBufferSize_)); + + communicateSizes(handle, recv_trackers); + std::size_t no_to_send, no_to_recv; + no_to_send = no_to_recv = interface_->size(); + // Setup requests for sending and receiving. + no_to_send -= setupRequests(handle, send_trackers, send_buffers, send_requests, + SetupSendRequest(), communicator_); + setupRequests(handle, recv_trackers, recv_buffers, recv_requests, + SetupRecvRequest(), communicator_); + + while(no_to_send+no_to_recv) + { + // Check send completion and initiate other necessary sends + if(no_to_send) + no_to_send -= checkSendAndContinueSending(handle, send_trackers, send_requests, + send_buffers, communicator_); + if(no_to_recv) + // Receive data and setup new unblocking receives if necessary + no_to_recv -= checkReceiveAndContinueReceiving(handle, recv_trackers, recv_requests, + recv_buffers, communicator_); + } +} + +template +template +void VariableSizeCommunicator::communicate(DataHandle& handle) +{ + if( interface_->size() == 0) + // Simply return as otherwise we will index an empty container + // either for MPI_Wait_all or MPI_Test_some. + return; + + if(handle.fixedsize()) + communicateFixedSize(handle); + else + communicateVariableSize(handle); +} +} // end namespace Dune +#endif +#endif diff -Nru dune-common-2.2.1/dune/common/parametertree.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/parametertree.cc --- dune-common-2.2.1/dune/common/parametertree.cc 2011-08-11 14:42:46.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parametertree.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #if HAVE_CONFIG_H #include "config.h" @@ -20,211 +20,222 @@ using namespace Dune; ParameterTree::ParameterTree() -{ -} +{} + +const Dune::ParameterTree Dune::ParameterTree::empty_; void ParameterTree::report(std::ostream& stream, const std::string& prefix) const { - typedef std::map::const_iterator ValueIt; - ValueIt vit = values.begin(); - ValueIt vend = values.end(); - - for(; vit!=vend; ++vit) - stream << vit->first << " = \"" << vit->second << "\"" << std::endl; - - typedef std::map::const_iterator SubIt; - SubIt sit = subs.begin(); - SubIt send = subs.end(); - for(; sit!=send; ++sit) - { - stream << "[ " << prefix + sit->first << " ]" << std::endl; - (sit->second).report(stream, prefix + sit->first + "."); - } + typedef std::map::const_iterator ValueIt; + ValueIt vit = values_.begin(); + ValueIt vend = values_.end(); + + for(; vit!=vend; ++vit) + stream << vit->first << " = \"" << vit->second << "\"" << std::endl; + + typedef std::map::const_iterator SubIt; + SubIt sit = subs_.begin(); + SubIt send = subs_.end(); + for(; sit!=send; ++sit) + { + stream << "[ " << prefix + prefix_ + sit->first << " ]" << std::endl; + (sit->second).report(stream, prefix); + } } bool ParameterTree::hasKey(const std::string& key) const { - std::string::size_type dot = key.find("."); - - if (dot != std::string::npos) - { - std::string prefix = key.substr(0,dot); - if (subs.count(prefix) == 0) - return false; - - const ParameterTree& s = sub(prefix); - return s.hasKey(key.substr(dot+1)); - } - else - return (values.count(key) != 0); + std::string::size_type dot = key.find("."); + + if (dot != std::string::npos) + { + std::string prefix = key.substr(0,dot); + if (subs_.count(prefix) == 0) + return false; + + if (values_.count(prefix) > 0) + DUNE_THROW(RangeError,"key " << prefix << " occurs as value and as subtree"); + + const ParameterTree& s = sub(prefix); + return s.hasKey(key.substr(dot+1)); + } + else + if (values_.count(key) != 0) + { + if (subs_.count(key) > 0) + DUNE_THROW(RangeError,"key " << key << " occurs as value and as subtree"); + return true; + } + else + return false; + } bool ParameterTree::hasSub(const std::string& key) const { - std::string::size_type dot = key.find("."); - - if (dot != std::string::npos) - { - std::string prefix = key.substr(0,dot); - if (subs.count(prefix) == 0) - return false; - - const ParameterTree& s = sub(prefix); - return s.hasSub(key.substr(dot+1)); - } - else - return (subs.count(key) != 0); + std::string::size_type dot = key.find("."); + + if (dot != std::string::npos) + { + std::string prefix = key.substr(0,dot); + if (subs_.count(prefix) == 0) + return false; + + if (values_.count(prefix) > 0) + DUNE_THROW(RangeError,"key " << prefix << " occurs as value and as subtree"); + + const ParameterTree& s = sub(prefix); + return s.hasSub(key.substr(dot+1)); + } + else + if (subs_.count(key) != 0) + { + if (values_.count(key) > 0) + DUNE_THROW(RangeError,"key " << key << " occurs as value and as subtree"); + return true; + } + else + return false; } ParameterTree& ParameterTree::sub(const std::string& key) { - std::string::size_type dot = key.find("."); - - if (dot != std::string::npos) - { - ParameterTree& s = sub(key.substr(0,dot)); - return s.sub(key.substr(dot+1)); - } - else - { - if (subs.count(key) == 0) - subKeys.push_back(key.substr(0,dot)); - return subs[key]; - } -} - -const ParameterTree& ParameterTree::sub(const std::string& key) const -{ - std::string::size_type dot = key.find("."); - - if (dot != std::string::npos) - { - const ParameterTree& s = sub(key.substr(0,dot)); - return s.sub(key.substr(dot+1)); - } - else - { - if (subs.count(key) == 0) - DUNE_THROW(Dune::RangeError, "Key '" << key << "' not found in ParameterTree"); - return subs.find(key)->second; - } + std::string::size_type dot = key.find("."); + + if (dot != std::string::npos) + { + ParameterTree& s = sub(key.substr(0,dot)); + return s.sub(key.substr(dot+1)); + } + else + { + if (values_.count(key) > 0) + DUNE_THROW(RangeError,"key " << key << " occurs as value and as subtree"); + if (subs_.count(key) == 0) + subKeys_.push_back(key.substr(0,dot)); + subs_[key].prefix_ = prefix_ + key + "."; + return subs_[key]; + } +} + +const ParameterTree& ParameterTree::sub(const std::string& key, bool fail_if_missing) const +{ + std::string::size_type dot = key.find("."); + + if (dot != std::string::npos) + { + const ParameterTree& s = sub(key.substr(0,dot)); + return s.sub(key.substr(dot+1)); + } + else + { + if (values_.count(key) > 0) + DUNE_THROW(RangeError,"key " << key << " occurs as value and as subtree"); + if (subs_.count(key) == 0) + { + if (fail_if_missing) + { + DUNE_THROW(Dune::RangeError, "SubTree '" << key + << "' not found in ParameterTree (prefix " + prefix_ + ")"); + } + else + return empty_; + } + return subs_.find(key)->second; + } } std::string& ParameterTree::operator[] (const std::string& key) { - std::string::size_type dot = key.find("."); - - if (dot != std::string::npos) - { - if (not(hasSub(key.substr(0,dot)))) - { - subs[key.substr(0,dot)]; - subKeys.push_back(key.substr(0,dot)); - } - ParameterTree& s = sub(key.substr(0,dot)); - return s[key.substr(dot+1)]; - } - else - { - if (not(hasKey(key))) - valueKeys.push_back(key); - return values[key]; - } + std::string::size_type dot = key.find("."); + + if (dot != std::string::npos) + { + ParameterTree& s = sub(key.substr(0,dot)); + return s[key.substr(dot+1)]; + } + else + { + if (! hasKey(key)) + valueKeys_.push_back(key); + return values_[key]; + } } const std::string& ParameterTree::operator[] (const std::string& key) const { - std::string::size_type dot = key.find("."); - - if (dot != std::string::npos) - { - if (not(hasSub(key.substr(0,dot)))) - DUNE_THROW(Dune::RangeError, "Key '" << key << "' not found in ParameterTree"); - const ParameterTree& s = sub(key.substr(0,dot)); - return s[key.substr(dot+1)]; - } - else - { - if (not(hasKey(key))) - DUNE_THROW(Dune::RangeError, "Key '" << key << "' not found in ParameterTree"); - return values.find(key)->second; - } + std::string::size_type dot = key.find("."); + + if (dot != std::string::npos) + { + const ParameterTree& s = sub(key.substr(0,dot)); + return s[key.substr(dot+1)]; + } + else + { + if (! hasKey(key)) + DUNE_THROW(Dune::RangeError, "Key '" << key + << "' not found in ParameterTree (prefix " + prefix_ + ")"); + return values_.find(key)->second; + } } std::string ParameterTree::get(const std::string& key, const std::string& defaultValue) const { - if (hasKey(key)) - return (*this)[key]; - else - return defaultValue; + if (hasKey(key)) + return (*this)[key]; + else + return defaultValue; } std::string ParameterTree::get(const std::string& key, const char* defaultValue) const { - if (hasKey(key)) - return (*this)[key]; - else - return defaultValue; -} - - -int ParameterTree::get(const std::string& key, int defaultValue) const -{ - std::stringstream stream; - stream << defaultValue; - std::string ret = get(key, stream.str()); - - return atoi(ret.c_str()); -} - -double ParameterTree::get(const std::string& key, double defaultValue) const -{ - if(hasKey(key)) - return atof((*this)[key].c_str()); - else - return defaultValue; + if (hasKey(key)) + return (*this)[key]; + else + return defaultValue; } std::string ParameterTree::ltrim(const std::string& s) { - std::size_t firstNonWS = s.find_first_not_of(" \t\n\r"); + std::size_t firstNonWS = s.find_first_not_of(" \t\n\r"); - if (firstNonWS!=std::string::npos) - return s.substr(firstNonWS); - return std::string(); + if (firstNonWS!=std::string::npos) + return s.substr(firstNonWS); + return std::string(); } std::string ParameterTree::rtrim(const std::string& s) { - std::size_t lastNonWS = s.find_last_not_of(" \t\n\r"); + std::size_t lastNonWS = s.find_last_not_of(" \t\n\r"); - if (lastNonWS!=std::string::npos) - return s.substr(0, lastNonWS+1); - return std::string(); + if (lastNonWS!=std::string::npos) + return s.substr(0, lastNonWS+1); + return std::string(); } std::vector ParameterTree::split(const std::string & s) { - std::vector substrings; - std::size_t front = 0, back = 0, size = 0; - - while (front != std::string::npos) - { - // find beginning of substring - front = s.find_first_not_of(" \t\n\r", back); - back = s.find_first_of(" \t\n\r", front); - size = back - front; - if (size > 0) - substrings.push_back(s.substr(front, size)); - } - return substrings; + std::vector substrings; + std::size_t front = 0, back = 0, size = 0; + + while (front != std::string::npos) + { + // find beginning of substring + front = s.find_first_not_of(" \t\n\r", back); + back = s.find_first_of(" \t\n\r", front); + size = back - front; + if (size > 0) + substrings.push_back(s.substr(front, size)); + } + return substrings; } const ParameterTree::KeyVector& ParameterTree::getValueKeys() const { - return valueKeys; + return valueKeys_; } const ParameterTree::KeyVector& ParameterTree::getSubKeys() const { - return subKeys; + return subKeys_; } diff -Nru dune-common-2.2.1/dune/common/parametertree.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/parametertree.hh --- dune-common-2.2.1/dune/common/parametertree.hh 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parametertree.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_PARAMETERTREE_HH #define DUNE_PARAMETERTREE_HH @@ -7,10 +7,12 @@ * \brief A hierarchical structure of string parameters */ +#include #include #include #include #include +#include #include #include #include @@ -18,8 +20,8 @@ #include #include #include +#include -#include #include #include #include @@ -88,8 +90,8 @@ * \throw Dune::RangeError if key is not found */ const std::string& operator[] (const std::string& key) const; - - + + /** \brief print distinct substructure to stream * * Prints all entries with given prefix. @@ -98,7 +100,7 @@ * \param prefix for key and substructure names */ void report(std::ostream& stream = std::cout, - const std::string& prefix = "") const; + const std::string& prefix = "") const; /** \brief get substructure by name @@ -111,10 +113,11 @@ /** \brief get const substructure by name * - * \param sub substructure name - * \return reference to substructure + * \param sub substructure name + * \param fail_if_missing if true, throw an error if substructure is missing + * \return reference to substructure */ - const ParameterTree& sub(const std::string& sub) const; + const ParameterTree& sub(const std::string& sub, bool fail_if_missing = false) const; /** \brief get value as string @@ -140,28 +143,6 @@ std::string get(const std::string& key, const char* defaultValue) const; - /** \brief get value as int - * - * Returns value for given key interpreted as int. - * - * \param key key name - * \param defaultValue default if key does not exist - * \return value as int - */ - int get(const std::string& key, int defaultValue) const; - - - /** \brief get value as double - * - * Returns value for given key interpreted as double. - * - * \param key key name - * \param defaultValue default if key does not exist - * \return value as double - */ - double get(const std::string& key, double defaultValue) const; - - /** \brief get value converted to a certain type * * Returns value as type T for given key. @@ -190,15 +171,16 @@ template T get(const std::string& key) const { if(not hasKey(key)) - DUNE_THROW(RangeError, "Key '" << key << "' not found in parameter " - "file!"); + DUNE_THROW(Dune::RangeError, "Key '" << key + << "' not found in ParameterTree (prefix " + prefix_ + ")"); try { return Parser::parse((*this)[key]); } - catch(const RangeError&) { - DUNE_THROW(RangeError, "Cannot parse value \"" << - (*this)[key] << "\" for key \"" << key << "\" as a " << - className()); + catch(const RangeError& e) { + // rethrow the error and add more information + DUNE_THROW(RangeError, "Cannot parse value \"" << (*this)[key] + << "\" for key \"" << prefix_ << "." << key << "\"" + << e.what()); } } @@ -222,11 +204,17 @@ const KeyVector& getSubKeys() const; protected: - KeyVector valueKeys; - KeyVector subKeys; - std::map values; - std::map subs; + static const ParameterTree empty_; + + std::string prefix_; + + KeyVector valueKeys_; + KeyVector subKeys_; + + std::map values_; + std::map subs_; + static std::string ltrim(const std::string& s); static std::string rtrim(const std::string& s); static std::vector split(const std::string & s); @@ -242,18 +230,17 @@ for(; it != end; ++it, ++n) { s >> *it; if(!s) - DUNE_THROW(RangeError, "Cannot parse value \"" << str << "\" as a " - "range of items of type " << className() << " " - "(" << n << " items were extracted successfully)"); + DUNE_THROW(RangeError, "as a range of items of type " + << className() + << " (" << n << " items were extracted successfully)"); } Value dummy; s >> dummy; // now extraction should have failed, and eof should be set if(not s.fail() or not s.eof()) - DUNE_THROW(RangeError, "Cannot parse value \"" << str << "\" as a " - "range of " << n << " items of type " - << className() << " (more items than the range " - "can hold)"); + DUNE_THROW(RangeError, "as a range of " + << n << " items of type " + << className() << " (more items than the range can hold)"); } }; @@ -262,16 +249,16 @@ static T parse(const std::string& str) { T val; std::istringstream s(str); + // make sure we are in locale "C" + s.imbue(std::locale::classic()); s >> val; if(!s) - DUNE_THROW(RangeError, "Cannot parse value \"" << str << "\" as a " << - className()); + DUNE_THROW(RangeError, " as a " << className()); T dummy; s >> dummy; // now extraction should have failed, and eof should be set - if(not s.fail() or not s.eof()) - DUNE_THROW(RangeError, "Cannot parse value \"" << str << "\" as a " << - className()); + if ((! s.fail()) || (! s.eof())) + DUNE_THROW(RangeError, " as a " << className()); return val; } }; @@ -292,24 +279,24 @@ template<> struct ParameterTree::Parser< bool > { struct ToLower { - int operator()(int c) + char operator()(char c) { - return std::tolower(c); + return std::tolower(c, std::locale::classic()); } }; static bool parse(const std::string& str) { std::string ret = str; - + std::transform(ret.begin(), ret.end(), ret.begin(), ToLower()); - + if (ret == "yes" || ret == "true") return true; - + if (ret == "no" || ret == "false") return false; - + return (Parser::parse(ret) != 0); } }; @@ -325,14 +312,30 @@ }; template - struct ParameterTree::Parser > { - static array + struct ParameterTree::Parser > { + static std::array parse(const std::string& str) { - array val; + std::array val; parseRange(str, val.begin(), val.end()); return val; } }; + + template + struct ParameterTree::Parser > { + static std::bitset + parse(const std::string& str) { + std::bitset val; + std::vector sub = split(str); + if (sub.size() != n) + DUNE_THROW(RangeError, "as a bitset<" << n << "> " + << "because of unmatching size " << sub.size()); + for (std::size_t i=0; i::parse(sub[i]); + } + return val; + } + }; template struct ParameterTree::Parser > { diff -Nru dune-common-2.2.1/dune/common/parametertreeparser.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/parametertreeparser.cc --- dune-common-2.2.1/dune/common/parametertreeparser.cc 2011-08-11 14:42:46.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/parametertreeparser.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #if HAVE_CONFIG_H #include "config.h" @@ -14,25 +14,27 @@ #include #include #include +#include +#include #include std::string Dune::ParameterTreeParser::ltrim(const std::string& s) { - std::size_t firstNonWS = s.find_first_not_of(" \t\n\r"); + std::size_t firstNonWS = s.find_first_not_of(" \t\n\r"); - if (firstNonWS!=std::string::npos) - return s.substr(firstNonWS); - return std::string(); + if (firstNonWS!=std::string::npos) + return s.substr(firstNonWS); + return std::string(); } std::string Dune::ParameterTreeParser::rtrim(const std::string& s) { - std::size_t lastNonWS = s.find_last_not_of(" \t\n\r"); + std::size_t lastNonWS = s.find_last_not_of(" \t\n\r"); - if (lastNonWS!=std::string::npos) - return s.substr(0, lastNonWS+1); - return std::string(); + if (lastNonWS!=std::string::npos) + return s.substr(0, lastNonWS+1); + return std::string(); } @@ -41,12 +43,12 @@ ParameterTree& pt, bool overwrite) { - std::ifstream in(file.c_str()); + std::ifstream in(file.c_str()); - if (!in) - DUNE_THROW(Dune::IOError, "Could not open configuration file " << file); + if (!in) + DUNE_THROW(Dune::IOError, "Could not open configuration file " << file); - readINITree(in, pt, "file '" + file + "'", overwrite); + readINITree(in, pt, "file '" + file + "'", overwrite); } @@ -54,7 +56,7 @@ ParameterTree& pt, bool overwrite) { - readINITree(in, pt, "stream", overwrite); + readINITree(in, pt, "stream", overwrite); } @@ -63,99 +65,179 @@ const std::string srcname, bool overwrite) { - std::string prefix; - std::set keysInFile; - while(!in.eof()) - { - std::string line; - getline(in, line); - line = ltrim(line); - switch (line[0]) { - case '#': - break; - case '[': - line = rtrim(line); - if (line[line.length()-1] == ']') - { - prefix = rtrim(ltrim(line.substr(1, line.length()-2))); - if (prefix != "") - prefix += "."; - } - break; - default: - std::string::size_type comment = line.find("#"); - line = line.substr(0,comment); - std::string::size_type mid = line.find("="); - if (mid != std::string::npos) - { - std::string key = prefix+rtrim(ltrim(line.substr(0, mid))); - std::string value = ltrim(line.substr(mid+1)); - - if (value.length()>0) - { - // handle quoted strings - if ((value[0]=='\'') or (value[0]=='"')) - { - char quote = value[0]; - value=value.substr(1); - while (*(rtrim(value).rbegin())!=quote) - { - if (not in.eof()) - { - std::string l; - getline(in, l); - value = value+"\n"+l; - } - else - value = value+quote; - } - value = rtrim(value); - value = value.substr(0,value.length()-1); - } - else - value = rtrim(value); - } - - if (keysInFile.count(key) != 0) - DUNE_THROW(Exception, "Key '" << key << - "' appears twice in " << srcname << " !"); - else - { - if(overwrite || ! pt.hasKey(key)) - pt[key] = value; - keysInFile.insert(key); - } - } - break; + std::string prefix; + std::set keysInFile; + while(!in.eof()) + { + std::string line; + getline(in, line); + line = ltrim(line); + if (line.size() == 0) + continue; + switch (line[0]) { + case '#' : + break; + case '[' : + line = rtrim(line); + if (line[line.length()-1] == ']') + { + prefix = rtrim(ltrim(line.substr(1, line.length()-2))); + if (prefix != "") + prefix += "."; + } + break; + default : + std::string::size_type comment = line.find("#"); + line = line.substr(0,comment); + std::string::size_type mid = line.find("="); + if (mid != std::string::npos) + { + std::string key = prefix+rtrim(ltrim(line.substr(0, mid))); + std::string value = ltrim(line.substr(mid+1)); + + if (value.length()>0) + { + // handle quoted strings + if ((value[0]=='\'') || (value[0]=='"')) + { + char quote = value[0]; + value=value.substr(1); + while (*(rtrim(value).rbegin())!=quote) + { + if (! in.eof()) + { + std::string l; + getline(in, l); + value = value+"\n"+l; + } + else + value = value+quote; + } + value = rtrim(value); + value = value.substr(0,value.length()-1); + } + else + value = rtrim(value); } + + if (keysInFile.count(key) != 0) + DUNE_THROW(ParameterTreeParserError, "Key '" << key << + "' appears twice in " << srcname << " !"); + else + { + if(overwrite || ! pt.hasKey(key)) + pt[key] = value; + keysInFile.insert(key); + } + } + break; } + } } - void Dune::ParameterTreeParser::readOptions(int argc, char* argv [], ParameterTree& pt) { - std::string v = ""; - std::string k = ""; - - for(int i=1; i keywords, + unsigned int required, + bool allow_more, + bool overwrite, + std::vector help) +{ + std::string helpstr = generateHelpString(argv[0], keywords, required, help); + std::vector done(keywords.size(),false); + std::size_t current = 0; + + for (std::size_t i=1; i= done.size()) + DUNE_THROW(ParameterTreeParserError, + "superfluous unnamed parameter" << "\n" << helpstr); + // do we overwrite an existing entry? + if (!overwrite && pt[keywords[current]] != "") + DUNE_THROW(ParameterTreeParserError, + "parameter " << keywords[current] << " already specified" << "\n" << helpstr); + pt[keywords[current]] = opt; + done[current] = true; // mark key as stored + } + } + // check that we receive all required keywords + std::string missing = ""; + for (unsigned int i=0; i keywords, unsigned int required, std::vector help) +{ + static const char braces[] = "<>[]"; + std::string helpstr = ""; + helpstr = helpstr + "Usage: " + progname; + for (std::size_t i=0; i #include +#include #include +#include namespace Dune { + /** \brief report parser error while reading ParameterTree */ + class ParameterTreeParserError : public RangeError {}; + /** \brief exception thrown if the user wants to see help string + + this exception is only thrown if the command line parameters + contain an option --help or -h + */ + class HelpRequest : public Exception {}; + /** \brief Parsers to set up a ParameterTree from various input sources * \ingroup Common * */ class ParameterTreeParser { - + static std::string ltrim(const std::string& s); static std::string rtrim(const std::string& s); - public: - - /** @name Parsing methods for the INITree file format - * - * INITree files should look like this - * \verbatim -# this file configures fruit colors in fruitsalad - - -#these are no fruit but could also appear in fruit salad -honeydewmelon = yellow -watermelon = green - -fruit.tropicalfruit.orange = orange -[fruit] -strawberry = red -pomegranate = red - -[fruit.pipfruit] -apple = green/red/yellow -pear = green - -[fruit.stonefruit] -cherry = red -plum = purple + /** @name Parsing methods for the INITree file format + * + * INITree files should look like this + * \verbatim + * # this file configures fruit colors in fruitsalad + * + * + * #these are no fruit but could also appear in fruit salad + * honeydewmelon = yellow + * watermelon = green + * + * fruit.tropicalfruit.orange = orange + * + * [fruit] + * strawberry = red + * pomegranate = red + * + * [fruit.pipfruit] + * apple = green/red/yellow + * pear = green + * + * [fruit.stonefruit] + * cherry = red + * plum = purple + * + * \endverbatim + * + * + * If a '[prefix]' statement appears all following entries use this prefix + * until the next '[prefix]' statement. Fruitsalads for example contain: + * \verbatim + * honeydewmelon = yellow + * fruit.tropicalfruit.orange = orange + * fruit.pipfruit.apple = green/red/yellow + * fruit.stonefruit.cherry = red + * \endverbatim + * + * All keys with a common 'prefix.' belong to the same substructure called + * 'prefix'. Leading and trailing spaces and tabs are removed from the + * values unless you use single or double quotes around them. Using single + * or double quotes you can also have multiline values. + */ + //@{ - \endverbatim - * - * - * If a '[prefix]' statement appears all following entries use this prefix - * until the next '[prefix]' statement. Fruitsalads for example contain: - \verbatim -honeydewmelon = yellow -fruit.tropicalfruit.orange = orange -fruit.pipfruit.apple = green/red/yellow -fruit.stonefruit.cherry = red - \endverbatim - * - * All keys with a common 'prefix.' belong to the same substructure called - * 'prefix'. Leading and trailing spaces and tabs are removed from the - * values unless you use single or double quotes around them. Using single - * or double quotes you can also have multiline values. - */ - //@{ - /** \brief parse C++ stream * * Parses C++ stream and build hierarchical config structure. * * \param in The stream to parse - * \param pt The parameter tree to store the config structure. + * \param[out] pt The parameter tree to store the config structure. * \param overwrite Whether to overwrite already existing values. * If false, values in the stream will be ignored * if the key is already present. * * \note This method is identical to parseStream(std::istream&, * const std::string&, bool) with the exception that that - * method allows to give a custom name for the stream. + * method allows one to give a custom name for the stream. */ static void readINITree(std::istream& in, ParameterTree& pt, - bool overwrite); + bool overwrite); /** \brief parse C++ stream @@ -94,7 +104,7 @@ * Parses C++ stream and build hierarchical config structure. * * \param in The stream to parse - * \param pt The parameter tree to store the config structure. + * \param[out] pt The parameter tree to store the config structure. * \param srcname Name of the configuration source for error * messages, "stdin" or a filename. * \param overwrite Whether to overwrite already existing values. @@ -102,8 +112,8 @@ * if the key is already present. */ static void readINITree(std::istream& in, ParameterTree& pt, - const std::string srcname = "stream", - bool overwrite = true); + const std::string srcname = "stream", + bool overwrite = true); /** \brief parse file @@ -111,7 +121,7 @@ * Parses file with given name and build hierarchical config structure. * * \param file filename - * \param pt The parameter tree to store the config structure. + * \param[out] pt The parameter tree to store the config structure. * \param overwrite Whether to overwrite already existing values. * If false, values in the stream will be ignored * if the key is already present. @@ -129,10 +139,37 @@ * * \param argc arg count * \param argv arg values - * \param pt The parameter tree to store the config structure. + * \param[out] pt The parameter tree to store the config structure. */ static void readOptions(int argc, char* argv [], ParameterTree& pt); + /** + * \brief read [named] command line options and build hierarchical ParameterTree structure + * + * Similar to pythons named options we expect the parameters in the + * ordering induced by keywords, but allow the user to pass named options + * in the form of --key=value. Optionally the user can pass an additional + * vector with help strings. + * + * \param argc arg count + * \param argv arg values + * \param[out] pt The parameter tree to store the config structure. + * \param keywords vector with keywords names + * \param required number of required options (the first n keywords are required, default is all are required) + * \param allow_more allow more options than these listed in keywords (default = true) + * \param overwrite allow to overwrite existing options (default = true) + * \param help vector containing help strings + */ + static void readNamedOptions(int argc, char* argv[], + ParameterTree& pt, + std::vector keywords, + unsigned int required = std::numeric_limits::max(), + bool allow_more = true, + bool overwrite = true, + std::vector help = std::vector()); + + private: + static std::string generateHelpString(std::string progname, std::vector keywords, unsigned int required, std::vector help); }; } // end namespace Dune diff -Nru dune-common-2.2.1/dune/common/path.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/path.cc --- dune-common-2.2.1/dune/common/path.cc 2010-06-08 11:08:49.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/path.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #if HAVE_CONFIG_H #include "config.h" @@ -10,7 +10,7 @@ #include #include -#include +#include #include namespace Dune { @@ -28,11 +28,11 @@ //! concatenate two paths std::string concatPaths(const std::string& base, const std::string& p) { - if(p == "") return base; - if(p[0] == '/') return p; - if(base == "") return p; + if(p == "") return base; + if(p[0] == '/') return p; + if(base == "") return p; if(hasSuffix(base, "/")) return base+p; - else return base+'/'+p; + else return base+'/'+p; } //! sanitize a path for further processing @@ -45,7 +45,7 @@ // each path component now has a trailing '/' - // collapse any occurance of multiple '/' to a single '/' + // collapse any occurrence of multiple '/' to a single '/' dst = src = 0; while(src < result.size()) { result[dst] = result[src]; @@ -59,7 +59,7 @@ // the path is now free of multiple '/' in a row - // collapse any occurance of "/./" to "/" + // collapse any occurrence of "/./" to "/" dst = src = 0; while(src < result.size()) { result[dst] = result[src]; @@ -83,7 +83,7 @@ src = result.find("/../", src); if(src == std::string::npos) break; - for(dst = src; dst > 0 && result[dst-1] != '/'; --dst); + for(dst = src; dst > 0 && result[dst-1] != '/'; --dst) ; if(result.substr(dst, src-dst) == "..") { // don't remove "../../" src += 3; @@ -111,20 +111,20 @@ //! check whether the given path indicates that it is a directory bool pathIndicatesDirectory(const std::string& p) { - if(p == "") return true; - if(p == ".") return true; - if(p == "..") return true; - if(hasSuffix(p, "/")) return true; - if(hasSuffix(p, "/.")) return true; + if(p == "") return true; + if(p == ".") return true; + if(p == "..") return true; + if(hasSuffix(p, "/")) return true; + if(hasSuffix(p, "/.")) return true; if(hasSuffix(p, "/..")) return true; - else return false; + else return false; } //! pretty print path std::string prettyPath(const std::string& p, bool isDirectory) { std::string result = processPath(p); // current directory - if(result == "") return "."; + if(result == "") return "."; // root directory if(result == "/") return result; @@ -180,7 +180,7 @@ // count the number of components in mybase typedef std::iterator_traits::difference_type - count_t; + count_t; count_t count = std::count(mybase.begin(), mybase.end(), '/'); std::string result; diff -Nru dune-common-2.2.1/dune/common/path.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/path.hh --- dune-common-2.2.1/dune/common/path.hh 2010-06-08 11:08:49.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/path.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_PATH_HH #define DUNE_COMMON_PATH_HH @@ -7,15 +7,14 @@ namespace Dune { /** - * @addtogroup Path Filesystem Paths - * @ingroup Common + * @addtogroup Path * @{ */ /** * @file * @author Jö Fahlke - * @brief Utilites for handling filesystem paths + * @brief Utilities for handling filesystem paths */ //! concatenate two paths @@ -24,7 +23,7 @@ * \param p The path to concatenate onto base. * * If p is an absolute path, return p. Otherwise return the - * string-concatenation of base and path, possibly with a '/' inbetween, if + * string-concatenation of base and path, possibly with a '/' in between, if * necessary. * * Some examples: @@ -56,13 +55,13 @@ *

    *
  • The path is a series of components, each followed by a single '/'. *
  • An absolute path starts with an empty component followed by a '/', - * so its first charachter will be '/'. This is the only case where an + * so its first character will be '/'. This is the only case where an * empty component can occur. *
  • The path does not contain any component ".". Any such component in * the input is removed. *
  • A ".." component may only occur in the following case: A relative * path may contain a series of ".." in the beginning. Any other - * occurances of ".." int eh input is collapsed with a preceding + * occurrences of ".." in the input is collapsed with a preceding * component or simply removed if it is at the beginning of an absolute * path. *
@@ -114,7 +113,7 @@ * directory. * * Pretty print the path. This removes any duplicate '/' and any - * superfluous occurances of ".." and ".". The resulting path will have a + * superfluous occurrences of ".." and ".". The resulting path will have a * trailing '/' if it is the root path or if isDirectory is true. It will * however not have a trailing '/' if it is otherwise clear that it is a * directory -- i.e. if its last component is "." or "..". diff -Nru dune-common-2.2.1/dune/common/poolallocator.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/poolallocator.hh --- dune-common-2.2.1/dune/common/poolallocator.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/poolallocator.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,6 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: -// $Id: poolallocator.hh 6785 2012-05-31 22:07:47Z sander $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_POOLALLOCATOR_HH #define DUNE_COMMON_POOLALLOCATOR_HH @@ -8,77 +7,76 @@ * \brief An stl-compliant pool allocator */ -#include"alignment.hh" -#include"static_assert.hh" -#include"lcm.hh" -#include -#include -#include -#include - -//forward declarations. +#include "lcm.hh" +#include +#include +#include +#include +#ifndef DOXYGEN +// forward declarations. // we need to know the test function to declare it friend template struct testPoolMain; +#endif namespace Dune { - -template -class Pool; -template -class PoolAllocator; + template + class Pool; + + template + class PoolAllocator; } namespace std { /* - template - inline ostream& operator<<(ostream& os, Dune::Pool& pool) - { - os<<"pool="<<&pool<<" allocated_="< - inline ostream& operator<<(ostream& os, Dune::PoolAllocator& pool) - { - os< + inline ostream& operator<<(ostream& os, Dune::Pool& pool) + { + os<<"pool="<<&pool<<" allocated_="< + inline ostream& operator<<(ostream& os, Dune::PoolAllocator& pool) + { + os<; - + //friend std::ostream& std::operator<<<>(std::ostream&,Pool&); template< class, std::size_t > friend class PoolAllocator; private: - + /** @brief Reference to next free element. */ struct Reference { @@ -106,27 +104,27 @@ /** @brief The type of object we allocate memory for. */ typedef T MemberType; - enum + enum { /** * @brief The size of a union of Reference and MemberType. */ - unionSize = ((sizeof(MemberType) < sizeof(Reference)) ? - sizeof(Reference) : sizeof(MemberType)), - + unionSize = ((sizeof(MemberType) < sizeof(Reference)) ? + sizeof(Reference) : sizeof(MemberType)), + /** * @brief Size requirement. At least one object has to * stored. */ - size = ((sizeof(MemberType) <= s && sizeof(Reference) <= s)? - s : unionSize), - + size = ((sizeof(MemberType) <= s && sizeof(Reference) <= s) ? + s : unionSize), + /** - * @brief The alignment that suits both the MemberType and + * @brief The alignment that suits both the MemberType and * the Reference (i.e. their least common multiple). */ - alignment = Lcm::value,AlignmentOf::value>::value, - + alignment = Lcm::value, + /** * @brief The aligned size of the type. * @@ -134,26 +132,26 @@ * the alignment requirement. */ alignedSize = ((unionSize % alignment == 0) ? - unionSize : - ((unionSize / alignment + 1) * alignment)), - - /** - * @brief The size of each chunk memory chunk. + unionSize : + ((unionSize / alignment + 1) * alignment)), + + /** + * @brief The size of each chunk memory chunk. * * Will be adapted to be a multiple of the alignment plus * an offset to handle the case that the pointer to the memory * does not satisfy the alignment requirements. */ - chunkSize = ((size % alignment == 0)? - size : ((size / alignment + 1)* alignment)) - + alignment - 1, - + chunkSize = ((size % alignment == 0) ? + size : ((size / alignment + 1)* alignment)) + + alignment - 1, + /** * @brief The number of element each chunk can hold. */ elements = ((chunkSize - alignment + 1)/ alignedSize) }; - + private: /** @brief Chunk of memory managed by the pool. */ struct Chunk @@ -164,16 +162,16 @@ /** @brief The memory we hold. */ char chunk_[chunkSize]; - /** - * @brief Adress the first properly aligned + /** + * @brief Address of the first properly aligned * position in the chunk. */ char* memory_; - + /** @brief The next element */ Chunk *next_; - - /** + + /** * @brief Constructor. */ Chunk() @@ -183,23 +181,23 @@ unsigned long long lmemory = reinterpret_cast(chunk_); if(lmemory % alignment != 0) lmemory = (lmemory / alignment + 1) - * alignment; - + * alignment; + memory_ = reinterpret_cast(lmemory); } }; - + public: /** @brief Constructor. */ inline Pool(); /** @brief Destructor. */ inline ~Pool(); - /** - * @brief Get a new or recycled object + /** + * @brief Get a new or recycled object * @return A pointer to the object memory. - */ + */ inline void* allocate(); - /** + /** * @brief Free an object. * @param o The pointer to memory block of the object. */ @@ -211,7 +209,7 @@ inline void print(std::ostream& os); private: - + // Prevent Copying! Pool(const Pool&); @@ -231,7 +229,7 @@ * @brief An allocator managing a pool of objects for reuse. * * This allocator is specifically useful for small data types - * where new and delete are too expensive. + * where new and delete are too expensive. * * It uses a pool of memory chunks where the objects will be allocated. * This means that assuming that N objects fit into memory only every N-th @@ -248,7 +246,7 @@ class PoolAllocator { //friend std::ostream& std::operator<<<>(std::ostream&,PoolAllocator&); - + public: /** * @brief Type of the values we construct and allocate. @@ -263,7 +261,7 @@ */ size=s*sizeof(value_type) }; - + /** * @brief The pointer type. */ @@ -288,24 +286,37 @@ * @brief The size type. */ typedef std::size_t size_type; - + /** * @brief The difference_type. */ typedef std::ptrdiff_t difference_type; - + /** * @brief Constructor. */ inline PoolAllocator(); /** - * @brief Coopy Constructor. + * @brief Copy Constructor that does not copy the memory pool. */ template inline PoolAllocator(const PoolAllocator&) - {} - + { + // we allow copying but never copy the pool + // to have a clear ownership of allocated pointers. + } + + /// \brief Copy constructor that does not copy the memory pool. + PoolAllocator(const PoolAllocator&) + { + // we allow copying but never copy the pool + // to have a clear ownership of allocated pointers. + // For this behaviour we have to implement + // the copy constructor, because the default + // one would copy the pool and deallocation + // of it would break. + } /** * @brief Allocates objects. * @param n The number of objects to allocate. Has to be one! @@ -313,7 +324,7 @@ * @return A pointer tp the allocated elements. */ inline pointer allocate(std::size_t n, const_pointer hint=0); - + /** * @brief Free objects. * @@ -341,7 +352,7 @@ */ inline pointer address(reference x) const { return &x; } - + /** * @brief Convert a reference to a pointer. */ @@ -351,7 +362,7 @@ * @brief Not correctly implemented, yet! */ inline int max_size() const throw(){ return 1;} - + /** * @brief Rebind the allocator to another type. */ @@ -368,27 +379,22 @@ /** * @brief The underlying memory pool. */ - static PoolType memoryPool_; + PoolType memoryPool_; }; // specialization for void - template - class PoolAllocator + template + class PoolAllocator { public: typedef void* pointer; typedef const void* const_pointer; // reference to void members are impossible. typedef void value_type; - template struct rebind - { - typedef PoolAllocator other; + template struct rebind + { + typedef PoolAllocator other; }; - - template - PoolAllocator(const PoolAllocator&) - {} - }; @@ -397,7 +403,7 @@ { return false; } - + template bool operator!=(const PoolAllocator&, const PoolAllocator&) @@ -406,30 +412,16 @@ } template - bool operator==(const PoolAllocator&, const PoolAllocator&) + bool operator==(const PoolAllocator& p1, const PoolAllocator& p2) { - return Pool::chunkSize == Pool::chunkSize; + return &p1==&p2; } - - template - bool operator!=(const PoolAllocator&, const PoolAllocator&) - { - return Pool::chunkSize != Pool::chunkSize; - } - - - template - bool operator==(const PoolAllocator&, const PoolAllocator&) - { - return false; - } - template - bool operator!=(const PoolAllocator&, const PoolAllocator&) + bool operator!=(const PoolAllocator& p1, const PoolAllocator& p2) { - return true; + return &p1 != &p2; } template @@ -437,53 +429,52 @@ { return false; } - + template bool operator!=(const PoolAllocator&, const PoolAllocator&) { return true; } + template - bool operator==(const PoolAllocator&, const PoolAllocator&) + bool operator==(const PoolAllocator& p1, const PoolAllocator& p2) { - return true; + return &p1==&p2; } template - bool operator!=(const PoolAllocator&, const PoolAllocator&) + bool operator!=(const PoolAllocator& p1, const PoolAllocator& p2) { - return false; + return &p1!=&p2; } template inline Pool::Pool() - :head_(0), chunks_(0)//, allocated_(0) + : head_(0), chunks_(0) //, allocated_(0) { - dune_static_assert(sizeof(T)<=unionSize, "Library Error: type T is too big"); - dune_static_assert(sizeof(Reference)<=unionSize, "Library Error: type of referene is too big"); - dune_static_assert(unionSize<=alignedSize, "Library Error: alignedSize too small"); - dune_static_assert(sizeof(T)<=chunkSize, "Library Error: chunkSize must be able to hold at least one value"); - dune_static_assert(sizeof(Reference)<=chunkSize, "Library Error: chunkSize must be able to hold at least one reference"); - dune_static_assert((chunkSize - (alignment - 1)) % alignment == 0, "Library Error: compiler cannot calculate!"); - dune_static_assert(elements>=1, "Library Error: we need to hold at least one element!"); - dune_static_assert(elements*alignedSize<=chunkSize, "Library Error: aligned elements must fit into chuck!"); - /* std::cout<<"s= "<=1, "Library Error: we need to hold at least one element!"); + static_assert(elements*alignedSize<=chunkSize, "Library Error: aligned elements must fit into chuck!"); } - + template inline Pool::~Pool() { /* - if(allocated_!=0) - std::cerr<<"There are still "< " - <(this)<<"! This is a memory leak and might result in segfaults" - < " + <(this)<<"! This is a memory leak and might result in segfaults" + <::print(std::ostream& os) { Chunk* current=chunks_; - while(current){ + while(current) { os<next_; } os< inline void Pool::grow() { Chunk *newChunk = new Chunk; newChunk->next_ = chunks_; chunks_ = newChunk; - + char* start = chunks_->memory_; char* last = &start[elements*alignedSize]; Reference* ref = new (start) (Reference); - // grow is only called if head==0, + // grow is only called if head==0, assert(!head_); head_ = ref; - - for(char* element=start+alignedSize; elementnext_ = next; ref = next; @@ -530,13 +521,28 @@ template inline void Pool::free(void* b) { - if(b){ - Reference* freed = static_cast(b); - freed->next_ = head_; - head_ = freed; - //--allocated_; - }else + if(b) { +#ifndef NDEBUG + Chunk* current=chunks_; + while(current) { + if(static_cast(current->chunk_)<=b && + static_cast(current->chunk_+chunkSize)>b) + break; + current=current->next_; + } + if(!current) + throw std::bad_alloc(); +#endif + Reference* freed = static_cast(b); + freed->next_ = head_; + head_ = freed; + //--allocated_; + } + else + { std::cerr<< "Tried to free null pointer! "< @@ -544,23 +550,20 @@ { if(!head_) grow(); - + Reference* p = head_; head_ = p->next_; //++allocated_; return p; } - template - typename PoolAllocator::PoolType PoolAllocator::memoryPool_; - - template + template inline PoolAllocator::PoolAllocator() { } template inline typename PoolAllocator::pointer - PoolAllocator::allocate(std::size_t n, const_pointer hint) + PoolAllocator::allocate(std::size_t n, const_pointer) { if(n==1) return static_cast(memoryPool_.allocate()); @@ -574,11 +577,11 @@ for(size_t i=0; i inline void PoolAllocator::construct(pointer p, const_reference value) { - ::new (static_cast(p)) T(value); + ::new (static_cast(p))T(value); } template diff -Nru dune-common-2.2.1/dune/common/power.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/power.hh --- dune-common-2.2.1/dune/common/power.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/power.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,90 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_POWER_HH +#define DUNE_COMMON_POWER_HH + +/** \file + \brief Various implementations of the power function for run-time and static arguments + */ + +namespace Dune { + + /** @addtogroup Common + + @{ + */ + + //! Calculates m^p at compile time + template + struct StaticPower + { + /** \brief power stores m^p */ + enum { power = (m * StaticPower::power ) }; + }; + + //! end of recursion via specialization + template + struct StaticPower< m , 0> + { + /** \brief m^0 = 1 */ + enum { power = 1 }; + }; + + + #ifndef DOXYGEN + template + struct PowerImp {}; +#endif + + /** \brief Compute power for a run-time mantissa and a compile-time integer exponent + * + * Does some magic to create efficient code. Not benchmarked AFAIK. + * + * \tparam p The exponent + */ + template + struct Power + { + template + static T eval(const T & a) + { + return PowerImp

::eval(a); + } + }; + +#ifndef DOXYGEN + template + struct PowerImp + { + template + static T eval(const T & a) + { + T t = Power

    -
  1. dune_static_assert is not in the namespace Dune
  2. -
  3. you must use extra parentheses if your condition contains ','. - This is because dune_static_assert is a preprocessor macro
  4. -
- -*/ - -#if HAVE_STATIC_ASSERT -#define dune_static_assert(COND,MSG) \ - static_assert(COND,MSG) -#else -#define dune_static_assert(COND,MSG) \ - typedef static_assert_test< \ - sizeof(static_assert_failure< (bool)( COND )>)\ - > CPPMAGIC_JOIN(dune_static_assert_typedef_, __LINE__) -#endif - -namespace Dune { - //! template which always yields a false value - /** - * \tparam T Some type. It sould be a type expression involving template - * parameters of the class or function using AlwaysFalse. - * - * Suppose you have a template class. You want to document the required - * members of this class in the non-specialized template, but you know that - * actually instantiating the non-specialized template is an error. You - * can try something like this: - * \code -template -struct Traits { - dune_static_assert(false, - "Instanciating this non-specialized template is an " - "error. You should use one of the specializations " - "instead."); - //! The type used to frobnicate T - typedef void FrobnicateType; -}; - * \endcode - * This will trigger dune_static_assert() as soon as the compiler reads the - * definition for the Traits template, since it knows that "false" can - * never become true, no matter what the template parameters of Traits are. - * As a workaround you can use AlwaysFalse: replace false by - * AlwaysFalse::value, like this: - * \code -template -struct Traits { - dune_static_assert(AlwaysFalse::value, - "Instanciating this non-specialized template is an " - "error. You should use one of the specializations " - "instead."); - //! The type used to frobnicate T - typedef void FrobnicateType; -}; - * \endcode - * Since there might be an specialization of AlwaysFalse for template - * parameter T, the compiler cannot trigger dune_static_assert() until the - * type of T is known, that is, until Traits is instantiated. - */ - template - struct AlwaysFalse { - //! always a false value - static const bool value = false; - }; - - //! template which always yields a true value - /** - * \tparam T Some type. It sould be a type expression involving template - * parameters of the class or function using AlwaysTrue. - * - * \note This class exists mostly for consistency with AlwaysFalse. - */ - template - struct AlwaysTrue { - //! always a true value - static const bool value = true; - }; -} // namespace Dune - -/* @} */ - -#endif diff -Nru dune-common-2.2.1/dune/common/std/apply.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/std/apply.hh --- dune-common-2.2.1/dune/common/std/apply.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/apply.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,65 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_STD_APPLY_HH +#define DUNE_COMMON_STD_APPLY_HH + +#if __cpp_lib_apply + #include +#elif __cpp_lib_experimental_apply + #include +#else + #include + #include + #include +#endif + + + +namespace Dune +{ + + namespace Std + { + +#if __cpp_lib_apply + + using std::apply; + +#elif __cpp_lib_experimental_apply + + using std::experimental::apply; + +#else + + namespace Impl + { + template + decltype(auto) applyHelper(F&& f, ArgTuple&& args, std::index_sequence) + { + return f(std::get(args)...); + } + } // namespace Impl + + + + /** + * \brief Apply function with arguments given as tuple + * + * \param f A callable object + * \param args Tuple of arguments + * + * This will call the function with arguments generated by unpacking the tuple. + */ + template + decltype(auto) apply(F&& f, ArgTuple&& args) + { + auto indices = std::make_index_sequence>::value>(); + return Impl::applyHelper(std::forward(f), std::forward(args), indices); + } + +#endif + + } // namespace Std +} // namespace Dune + +#endif // #ifndef DUNE_COMMON_STD_APPLY_HH diff -Nru dune-common-2.2.1/dune/common/std/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/dune/common/std/CMakeLists.txt --- dune-common-2.2.1/dune/common/std/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,11 @@ +install( + FILES + apply.hh + constexpr.hh + final.hh + noexcept.hh + make_array.hh + memory.hh + type_traits.hh + utility.hh + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common/std) diff -Nru dune-common-2.2.1/dune/common/std/constexpr.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/std/constexpr.hh --- dune-common-2.2.1/dune/common/std/constexpr.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/constexpr.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,8 @@ +#ifndef DUNE_COMMON_STD_CONSTEXPR_HH +#define DUNE_COMMON_STD_CONSTEXPR_HH + +#warning The header dune/common/std/constexpr.hh is deprecated. Remove the include and use "constexpr". + +#define DUNE_CONSTEXPR constexpr + +#endif // #ifndef DUNE_COMMON_STD_CONSTEXPR_HH diff -Nru dune-common-2.2.1/dune/common/std/final.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/std/final.hh --- dune-common-2.2.1/dune/common/std/final.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/final.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,8 @@ +#ifndef DUNE_COMMON_STD_FINAL_HH +#define DUNE_COMMON_STD_FINAL_HH + +#warning The header dune/common/std/final.hh is deprecated. Remove the include and use "final". + +#define DUNE_FINAL final + +#endif // DUNE_COMMON_STD_FINAL_HH diff -Nru dune-common-2.2.1/dune/common/std/make_array.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/std/make_array.hh --- dune-common-2.2.1/dune/common/std/make_array.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/make_array.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,31 @@ +#ifndef DUNE_COMMON_STD_MAKE_ARRAY_HH +#define DUNE_COMMON_STD_MAKE_ARRAY_HH + +#include +#include + +namespace Dune { +namespace Std { + //! Create and initialize an array + /** + * \note This method is a somewhat limited dune-specific version of + * make_array() as proposed for C++17 (see N4391, + * accepted May + * 2015). The differences are that this version should + * never be used with expliclitly given template arguments, or + * with std::reference_wrapper<...> arguments, and we do not + * give a diagnostic when anyone happens to do that. + */ + template + std::array::type, sizeof...(Args)> + make_array(const Args&... args) { + std::array::type, sizeof...(Args)> + result = {{args...}}; + return result; + } +} +} + +#endif diff -Nru dune-common-2.2.1/dune/common/std/memory.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/std/memory.hh --- dune-common-2.2.1/dune/common/std/memory.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/memory.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,88 @@ +// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set ts=8 sw=2 et sts=2: +#ifndef DUNE_COMMON_STD_MEMORY_HH +#define DUNE_COMMON_STD_MEMORY_HH + +#include +#include + +namespace Dune +{ + + namespace Std + { + + // Helper struct to distinguish non-array, unknown bound + // array, and known bound array types using SFINAE + // following proposal N3656 by Stephan T. Lavavej. + + template + struct MakeUniqueHelper + { + typedef std::unique_ptr NonArrayUniquePtr; + }; + + template + struct MakeUniqueHelper + { + typedef std::unique_ptr UnknownBoundArrayUniquePtr; + typedef T RawType; + }; + + template + struct MakeUniqueHelper + { + typedef void KnownBoundArrayUniquePtr; + }; + + + /** \brief Implementation of std::make_unique to be introduced in C++14 + * + * \tparam T Nonarray type of object to be constructed + * \tparam ...Args Parameter types for constructor of T + * + * \param args Arguments to be passed to constructor of T + * + * This fallback implementation using perfect forwarding + * as proposed by Herb Sutter in http://herbsutter.com/gotw/_102/ + */ + template + typename MakeUniqueHelper::NonArrayUniquePtr + make_unique(Args&&... args) + { + return std::unique_ptr(new T(std::forward(args)...)); + } + + /** \brief Implementation of std::make_unique to be introduced in C++14 + * + * \tparam T Array type of unknown bound + * + * \param n Size of array to allocate + */ + template + typename MakeUniqueHelper::UnknownBoundArrayUniquePtr + make_unique(size_t n) + { + return std::unique_ptr(new typename MakeUniqueHelper::RawType[n]()); + } + + /** \brief Implementation of std::make_unique to be introduced in C++14 + * + * \tparam T Array type of known bound + * \tparam Args Dummy arguments + * + * This is deleted, since, according to the standard this should not + * participate in overload resolution + * + * \param args Dummy arguments + */ + template + typename MakeUniqueHelper::KnownBoundArrayUniquePtr + make_unique(Args&&... args) = delete; + + + } // namespace Std + +} // namespace Dune + +#endif // #ifndef DUNE_COMMON_STD_MEMORY_HH diff -Nru dune-common-2.2.1/dune/common/std/noexcept.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/std/noexcept.hh --- dune-common-2.2.1/dune/common/std/noexcept.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/noexcept.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,8 @@ +#ifndef DUNE_COMMON_STD_NOEXCEPT_HH +#define DUNE_COMMON_STD_NOEXCEPT_HH + +#warning The header dune/common/std/noexcept.hh is deprecated. Remove the include and use "noexcept". + +#define DUNE_NOEXCEPT noexcept + +#endif // DUNE_COMMON_STD_NOEXCEPT_HH diff -Nru dune-common-2.2.1/dune/common/std/type_traits.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/std/type_traits.hh --- dune-common-2.2.1/dune/common/std/type_traits.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/type_traits.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,182 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_STD_TYPE_TRAITS_HH +#define DUNE_COMMON_STD_TYPE_TRAITS_HH + +#include +#include +#include + +namespace Dune +{ + +namespace Std +{ + + // to_false_type + // ------------- + + /** \class to_false_type + * + * \brief template mapping a type to std::false_type + * + * \tparam T Some type + * + * Suppose you have a template class. You want to document the required + * members of this class in the non-specialized template, but you know that + * actually instantiating the non-specialized template is an error. You can + * try something like this: + * \code + * template + * struct Traits + * { + * static_assert(false, + * "Instanciating this non-specialized template is an " + * "error. You should use one of the specializations " + * "instead."); + * //! The type used to frobnicate T + * typedef void FrobnicateType; + * }; + * \endcode + * This will trigger static_assert() as soon as the compiler reads the + * definition for the Traits template, since it knows that "false" can never + * become true, no matter what the template parameters of Traits are. As a + * workaround you can use to_false_type: replace false by + * to_false_type::value, like this: + * \code + * template + * struct Traits + * { + * static_assert(Std::to_false_type::value, + * "Instanciating this non-specialized template is an " + * "error. You should use one of the specializations " + * "instead."); + * //! The type used to frobnicate T + * typedef void FrobnicateType; + * }; + * \endcode + * Since there might be an specialization of to_false_type for template + * parameter T, the compiler cannot trigger static_assert() until the type + * of T is known, that is, until Traits is instantiated. + */ + template< typename T > + struct to_false_type : public std::false_type {}; + + + + // to_true_type + // ------------ + + /** \class to_true_type + * + * \brief template mapping a type to std::true_type + * + * \tparam T Some type + * + * \note This class exists mostly for consistency with to_false_type. + */ + template< typename T > + struct to_true_type : public std::true_type {}; + + +#if __cpp_lib_bool_constant + + using std::bool_constant; + +#elif __cpp_lib_experimental_bool_constant + + using std::experimental::bool_constant; + +#else + + /** + * \brief A template alias for std::integral_constant + * + * \tparam value Boolean value to encode as std::integral_constant + */ + template + using bool_constant = std::integral_constant; + +#endif + + + namespace Imp { + + // If R is void we only need to check if F can be called + // with given Args... list. If this is not possible + // result_of_t is not defined and this overload is disabled. + template>, R>::value + , int> = 0> + std::true_type is_callable_helper(PriorityTag<2>) + { return {}; } + + // Check if result of F(Args...) can be converted to R. + // If F cannot even be called with given Args... then + // result_of_t is not defined and this overload is disabled. + template, R>::value + , int> = 0> + std::true_type is_callable_helper(PriorityTag<1>) + { return {}; } + + // If none of the above matches, F can either not be called + // with given Args..., or the result cannot be converted to + // void, or R is not void. + template + std::false_type is_callable_helper(PriorityTag<0>) + { return {}; } + } + + /** + * \brief Traits class to check if function is callable + * + * \tparam D Function descriptor + * \tparam R Return value + * + * If D = F(Args...) this checks if F can be called with an + * argument list of type Args..., and if the return value can + * be converted to R. If R is void, any return type is accepted. + * The result is encoded by deriving from std::integral_constant. + * + * If D is not of the form D = F(Args...) this class is not defined. + * + * This implements std::is_callable as proposed in N4446 for C++17. + */ + template + struct is_callable; + + /** + * \brief Traits class to check if function is callable + * + * \tparam D Function descriptor + * \tparam R Return value + * + * If D = F(Args...) this checks if F can be called with an + * argument list of type Args..., and if the return value can + * be converted to R. If R is void, any return type is accepted. + * The result is encoded by deriving from std::integral_constant. + * + * If D is not of the form D = F(Args...) this class is not defined. + * + * This implements std::is_callable as proposed in N4446 for C++17. + */ + template + struct is_callable< F(Args...), R> : + decltype(Imp::is_callable_helper(PriorityTag<42>())) + {}; + + + + + + + + +} // namespace Std + +} // namespace Dune + +#endif // #ifndef DUNE_COMMON_STD_TYPE_TRAITS_HH diff -Nru dune-common-2.2.1/dune/common/std/utility.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/std/utility.hh --- dune-common-2.2.1/dune/common/std/utility.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/std/utility.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,46 @@ +#ifndef DUNE_COMMON_STD_UTILITY_HH +#define DUNE_COMMON_STD_UTILITY_HH + +#include + +#include +#include + +#include + +namespace Dune +{ + + namespace Std + { + + + using std::integer_sequence; + using std::index_sequence; + using std::make_integer_sequence; + using std::make_index_sequence; + + /** + * \brief Create index_sequence from 0 to sizeof...(T)-1 + * + * This should do the same as std::index_sequence_for. + * But due to a bug in the sizeof... operator this + * may produce wrong results with clang<3.8. + * + * As a workaround we provide our own implementation + * that avoids this bug even if the std:: version + * exists. + * + * This implemenation can be dropped, once we require + * a minimum clang version that has this bug fixed (i.e. >=3.8). + */ + template + using index_sequence_for = make_index_sequence{}>; + + + + } // namespace Std + +} // namespace Dune + +#endif // #ifndef DUNE_COMMON_STD_UTILITY_HH diff -Nru dune-common-2.2.1/dune/common/stdstreams.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/stdstreams.cc --- dune-common-2.2.1/dune/common/stdstreams.cc 2010-11-17 11:12:45.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/stdstreams.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,4 +1,5 @@ -// $Id: stdstreams.cc 6248 2010-11-17 11:12:45Z sander $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" @@ -8,25 +9,25 @@ namespace Dune { -/* + /* -The standard debug streams declared in stdstreams.hh exist in this -file so that they can be compiled into libdune + The standard debug streams declared in stdstreams.hh exist in this + file so that they can be compiled into libdune -*/ + */ /* stream for very verbose output: information on the lowest - level. This is expected to report insane amounts of - information. Use of the activation-flag to only generate output - near the problem is recommended */ + level. This is expected to report insane amounts of + information. Use of the activation-flag to only generate output + near the problem is recommended */ DVVerbType dvverb(std::cout); /* stream for verbose output: information that helps to trace in - more detail what the modules do */ + more detail what the modules do */ DVerbType dverb(std::cout); /* stream for informative output: summary infos on what a module - does, runtimes, etc. */ + does, runtimes, etc. */ DInfoType dinfo(std::cout); /* stream for warnings: messages which may indicate problems */ @@ -36,8 +37,8 @@ DGraveType dgrave(std::cerr); /* stream for error messages: only packages integrating Dune - completely will redirect it. The output of derr is independent of - the debug-level, only the activation-flag is checked */ + completely will redirect it. The output of derr is independent of + the debug-level, only the activation-flag is checked */ DErrType derr(std::cerr); } diff -Nru dune-common-2.2.1/dune/common/stdstreams.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/stdstreams.hh --- dune-common-2.2.1/dune/common/stdstreams.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/stdstreams.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,10 +1,14 @@ -// $Id: stdstreams.hh 6785 2012-05-31 22:07:47Z sander $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: -/* - - Declaration of standard Dune-library streams - -*/ +/** + \file + \brief Standard Dune debug streams + + The standard debug streams are compiled into libdune to exist + globally. This file declares the stream types and the global debug + level. + */ #ifndef DUNE_COMMON_STDSTREAMS_HH #define DUNE_COMMON_STDSTREAMS_HH @@ -13,157 +17,150 @@ namespace Dune { -/*! - \addtogroup DebugOut - @{ - - standard debug streams with level below MINIMAL_DEBUG_LEVEL will - collapse to doing nothing if output is requested. - - MINIMAL_DEBUG_LEVEL is set to DUNE_MINIMAL_DEBUG_LEVEL, wich is - defined in config.h and can be changed by the configure option - @code --with-minimal-debug-level=[grave|warn|info|verb|vverb] @endcode - - For a Dune-Release this should be set to at least 4 so that only - important messages are active. Dune-developers may adapt this - setting to their debugging needs locally - - Keep in mind that libdune has to be recompiled if this value is changed! + /** + \addtogroup DebugOut + @{ + + standard debug streams with level below MINIMAL_DEBUG_LEVEL will + collapse to doing nothing if output is requested. + + MINIMAL_DEBUG_LEVEL is set to DUNE_MINIMAL_DEBUG_LEVEL, which is + defined in config.h and can be changed by the configure option + @code --with-minimal-debug-level=[grave|warn|info|verb|vverb] @endcode + + For a Dune-Release this should be set to at least 4 so that only + important messages are active. Dune-developers may adapt this + setting to their debugging needs locally + + Keep in mind that libdune has to be recompiled if this value is changed! + + The singleton instances of the available debug streams can be found in + the \ref DebugOut "Standard Debug Streams" module - The singleton instances of the available debug streams can be found in - the \ref DebugOut "Standard Debug Streams" module -*/ - - /*! \file - \brief Standard Dune debug streams - - The standard debug streams are compiled into libdune to exist - globally. This file declares the stream types and the global debug - level. - - */ - /*! @} */ - /*! - \defgroup StdStreams Standard Debug Streams - \ingroup DebugOut - @{ - - Dune defines several standard output streams for the library - routines. - - Applications may control the standard streams via the attach/detach, - push/pop interface but should define an independent set of streams (see \ref DebugAppl ) - - */ - - /** - * @brief The default minimum debug level. - * - * If the level of a stream is bigger than this value - * it will be activated. - */ - #ifndef DUNE_MINIMAL_DEBUG_LEVEL - #define DUNE_MINIMAL_DEBUG_LEVEL 4 - #endif + @} + */ + + /** + \defgroup StdStreams Standard Debug Streams + \ingroup DebugOut + @{ + + Dune defines several standard output streams for the library + routines. + + Applications may control the standard streams via the attach/detach, + push/pop interface but should define an independent set of streams (see \ref DebugAppl ) + + */ + + /** + @brief The default minimum debug level. + + If the level of a stream is bigger than this value + it will be activated. + */ +#ifndef DUNE_MINIMAL_DEBUG_LEVEL +#define DUNE_MINIMAL_DEBUG_LEVEL 4 +#endif static const DebugLevel MINIMAL_DEBUG_LEVEL = DUNE_MINIMAL_DEBUG_LEVEL; - /** - * @brief The level of the very verbose debug stream. - * @see dvverb + /** + @brief The level of the very verbose debug stream. + @see dvverb */ static const DebugLevel VERY_VERBOSE_DEBUG_LEVEL = 1; - - /** - @brief Type of very verbose debug stream. + + /** + @brief Type of very verbose debug stream. @see dvverb - */ + */ typedef DebugStream DVVerbType; - /*! - \brief stream for very verbose output. - - \code -#include - \endcode - - Information on the lowest - level. This is expected to report insane amounts of - information. Use of the activation-flag to only generate output - near the problem is recommended. - */ + /** + \brief stream for very verbose output. + + \code + #include + \endcode + + Information on the lowest + level. This is expected to report insane amounts of + information. Use of the activation-flag to only generate output + near the problem is recommended. + */ extern DVVerbType dvverb; - /** - * @brief The level of the verbose debug stream. - * @see dvverb + /** + @brief The level of the verbose debug stream. + @see dvverb */ static const DebugLevel VERBOSE_DEBUG_LEVEL = 2; - /** + /** @brief Type of more verbose debug stream. @see dverb - */ + */ typedef DebugStream DVerbType; /** - * @brief Singleton of verbose debug stream. - * - * \code -#include - * \endcode + @brief Singleton of verbose debug stream. + + \code + #include + \endcode */ extern DVerbType dverb; - /** - * @brief The level of the informative debug stream. - * @see dinfo + /** + @brief The level of the informative debug stream. + @see dinfo */ static const DebugLevel INFO_DEBUG_LEVEL = 3; - /** + /** @brief Type of debug stream with info level. @see dinfo - */ + */ typedef DebugStream DInfoType; - /** + /** @brief Stream for informative output. - + \code -#include + #include \endcode Summary infos on what a module - does, runtimes, etc. - */ + does, runtimes, etc. + */ extern DInfoType dinfo; - /** - * @brief The level of the debug stream for warnings. - * @see dwarn + /** + @brief The level of the debug stream for warnings. + @see dwarn */ static const DebugLevel WARN_DEBUG_LEVEL = 4; - /** + /** @brief Type of debug stream with warn level. @see dwarn - */ + */ typedef DebugStream DWarnType; /** - * @brief Stream for warnings indicating problems. - * - * \code -#include - * \endcode + @brief Stream for warnings indicating problems. + + \code + #include + \endcode */ extern DWarnType dwarn; - /** - * @brief The level of the debug stream for fatal errors. - * @see dgrave + /** + @brief The level of the debug stream for fatal errors. + @see dgrave */ static const DebugLevel GRAVE_DEBUG_LEVEL = 5; @@ -171,31 +168,31 @@ typedef DebugStream DGraveType; /** - * @brief Stream for warnings indicating fatal errors. - * - * \code -#include - * \endcode + @brief Stream for warnings indicating fatal errors. + + \code + #include + \endcode */ extern DGraveType dgrave; /** @brief The type of the stream used for error messages. */ typedef DebugStream<1> DErrType; - /*! - @brief Stream for error messages. + /** + @brief Stream for error messages. \code -#include + #include \endcode Only packages integrating Dune completely will redirect it. The output of derr is independent of the debug-level, only the activation-flag is checked. - */ + */ extern DErrType derr; - //! }@ + /** }@ */ } #endif diff -Nru dune-common-2.2.1/dune/common/stdthread.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/stdthread.cc --- dune-common-2.2.1/dune/common/stdthread.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/stdthread.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,80 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include + +namespace Dune +{ + + namespace { + + void printCallOnceError(const char *file, int line, const char *function, + const char *msg) + { + if(file) + std::cerr << file << ":" << line << ": "; + std::cerr << "error: "; + if(function) + std::cerr << "(in " << function << "()) "; + std::cerr << "std::call_once() is broken.\n" + << "\n" + << msg << std::endl; + } + + void setBool(bool *v) + { + *v = true; + } + + } // anonymous namespace + + void doAssertCallOnce(const char *file, int line, const char *function) + { + std::once_flag once; + bool works = false; + try { + // pass address to works since call_once passes by value + std::call_once(once, setBool, &works); + } + catch(...) { + printCallOnceError(file, line, function, +"std::call_once() throws an exception. This suggests that the program was\n" +"linked without a threading library. Common ways to link to a threading\n" +"library is to specify one of the following during linking: -pthread, \n" +"-lpthread, or -pthreads. The build system should have tried various of\n" +"these options, but unfortunately that is only a guess and we cannot verify\n" +"that we found a working configuration until runtime.\n" +"\n" +"Going to rethrow the exception now to give the system library a chance to\n" +"print more information about it, just in case that helps with debugging.\n" + ); + throw; + } + if(!works) + { + printCallOnceError(file, line, function, +"std::call_once() never calls the function. This suggests that your\n" +"libctdc++ or your gcc built without threading support (--disable-threads,\n" +"see https://gcc.gnu.org/install/configure.html). This is probably a bug in\n" +"__gthread_once() in /usr/include/c++/4.7/x86_64-linux-gnu/bits/gthr-single.h\n" +"(which should not silently return success without doing anything, but\n" +"apparently does so in some versions).\n" +"\n" +"To fix the issue, either recompile gcc with a working threading\n" +"implementation, or file a bug for gthr-single.h, or file a bug at\n" +"https://dune-project.org/flyspray/ and request a workaround at the dune-side." + ); + std::abort(); + } + } + +} // namespace Dune diff -Nru dune-common-2.2.1/dune/common/stdthread.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/stdthread.hh --- dune-common-2.2.1/dune/common/stdthread.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/stdthread.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,54 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#ifndef DUNE_COMMON_STDTHREAD_HH +#define DUNE_COMMON_STDTHREAD_HH + +#include + +namespace Dune +{ + + // used internally by assertCallOnce for the actual check + void doAssertCallOnce(const char *file, int line, const char *function); + + //! \brief Make sure call_once() works and provide a helpful error message + //! otherwise. + /** + * For call_once() to work, certain versions of libstdc++ need to be + * _linked_ with -pthread or similar flags. If that is not the case, + * call_once() will throw an exception. This function checks that + * call_once() can indeed be used, i.e. that it does not throw an exception + * when it should not, and that the code does indeed get executed. If + * call_once() cannot be used, assertCallOnce() aborts the program with a + * helpful error message. + * + * The check is only actually executed the first time assertCallOnce() is + * called. + * + * The arguments \c file and \c line specify the filename and line number + * that should appear in the error message. They are ignored if \c file is + * 0. The argument \c function specifies the name of the function to appear + * in the error message. It is ignored if \c function is 0. + */ + + inline void assertCallOnce(const char *file = nullptr, int line = -1, + const char *function = nullptr) + { + // make sure to call this only the first time this function is invoked + static const bool DUNE_UNUSED works + = (doAssertCallOnce(file, line, function), true); + } + + //! \brief Make sure call_once() works and provide a helpful error message + //! otherwise. + /** + * This calls assertCallOnce() and automatically provides information about + * the caller in the error message. + */ +#define DUNE_ASSERT_CALL_ONCE() \ + ::Dune::assertCallOnce(__FILE__, __LINE__, __func__) + +} // namespace Dune + +#endif // DUNE_COMMON_STDTHREAD_HH diff -Nru dune-common-2.2.1/dune/common/streamoperators.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/streamoperators.hh --- dune-common-2.2.1/dune/common/streamoperators.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/streamoperators.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,67 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#ifndef DUNE_STREAMOPERATORS_HH +#define DUNE_STREAMOPERATORS_HH + +/** \file + \brief Implementation of stream operators for std::array and std::tuple + */ + +#include +#include + +#include +#include + +namespace Dune +{ + /** @addtogroup Common + + @{ + */ + + //! Print a std::tuple + template + inline Stream& operator<<(Stream& stream, const std::tuple& t) + { + stream<<"["; + if(sizeof...(Ts)>0) + { + Hybrid::forEach(Std::make_index_sequence{}, + [&](auto i){stream<(t)<<",";}); + stream<(t); + } + stream<<"]"; + return stream; + } + + //! Read a std::tuple + template + inline Stream& operator>>(Stream& stream, std::tuple& t) + { + Hybrid::forEach(Std::make_index_sequence{}, + [&](auto i){stream>>std::get(t);}); + return stream; + } + + //! Print a std::array + template + inline Stream& operator<<(Stream& stream, const std::array& a) + { + stream<<"["; + if(N>0) + { + for(std::size_t i=0; i +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +namespace Dune { + + /** + * @addtogroup StringUtilities + * + * @{ + */ + + /** \brief Check whether a character container has a given prefix + * + * The container must support the begin() and size() methods. + */ + template + bool hasPrefix(const C& c, const char* prefix) { + std::size_t len = std::strlen(prefix); + return c.size() >= len && + std::equal(prefix, prefix+len, c.begin()); + } + + /** \brief Check whether a character container has a given suffix + * + * The container must support the begin() and size() methods and the + * const_iterator member type. + * + * \note This is slow for containers which don't have random access iterators. + * In the case of containers with bidirectional iterators, this + * slowness is unnecessary. + */ + template + bool hasSuffix(const C& c, const char* suffix) { + std::size_t len = std::strlen(suffix); + if(c.size() < len) return false; + typename C::const_iterator it = c.begin(); + std::advance(it, c.size() - len); + return std::equal(suffix, suffix+len, it); + } + + /** + * \brief Format values according to printf format string + * + * \param s The format string to be used + * \param args The valued to be formatted + * + * This is a wrapper to std::snprintf that provides + * overflow save printf functionality. For up to 1000 + * characters a static buffer is used. If this is not sufficient + * a dynamic buffer of appropriate size is allocated. + */ + template + static std::string formatString(const std::string& s, const T&... args) + { + static const int bufferSize=1000; + char buffer[bufferSize]; + + // try to format with static buffer + int r = std::snprintf(buffer, bufferSize, s.c_str(), args...); + + // negative return values correspond to errors + if (r<0) + DUNE_THROW(Dune::Exception,"Could not convert format string using given arguments."); + + // if buffer was large enough return result as string + if (r dynamicBuffer; + try { + dynamicBuffer = Dune::Std::make_unique(dynamicBufferSize); + } + catch (const std::bad_alloc&) { + DUNE_THROW(Dune::Exception,"Could allocate large enough dynamic buffer in formatString."); + } + + // convert and check for errors again + r = std::snprintf(dynamicBuffer.get(), dynamicBufferSize, s.c_str(), args...); + if (r<0) + DUNE_THROW(Dune::Exception,"Could not convert format string using given arguments."); + + // the new buffer should always be large enough + assert(r -#include -#include -#include -#include +#include +#include +#include +#include +#include -class Double{ +class Double { public: - double val; - Double(): val(0){} - Double(double d): val(d){} - Double& operator=(double d){ - val=d; - return *this; - } + double val; + Double() : val(0){} + Double(double d) : val(d){} + Double& operator=(double d){ + val=d; + return *this; + } }; bool operator<(Double a, Double b){ - return a.val void randomizeList(Dune::ArrayList& alist){ - using namespace Dune; - - srand(300); - - int lowest=0, highest=1000, range=(highest-lowest)+1; - - for(int i=0; i < 250; i++) - alist.push_back(T(static_cast(range*(rand()/(RAND_MAX+1.0))))); + using namespace Dune; + + srand(300); + + int lowest=0, highest=1000, range=(highest-lowest)+1; + + for(int i=0; i < 250; i++) + alist.push_back(T(static_cast(range*(rand()/(RAND_MAX+1.0))))); } int testSorting(){ - using namespace Dune; - ArrayList alist; + using namespace Dune; + ArrayList alist; - randomizeList(alist); - std::sort(alist.begin(), alist.end()); - double last=-1; - - for(ArrayList::iterator iter=alist.begin(), end=alist.end(); - iter != end; ++iter){ - if((*iter)>=last){ - last=*iter; - }else{ - std::cerr << last<<">"<<(*iter)<<" List is not sorted! "<<__FILE__ <<":"<<__LINE__<::iterator iter=alist.begin(), end=alist.end(); + iter != end; ++iter) { + if((*iter)>=last) { + last=*iter; + }else{ + std::cerr << last<<">"<<(*iter)<<" List is not sorted! "<<__FILE__ <<":"<<__LINE__< void initConsecutive(Dune::ArrayList& alist){ - using namespace Dune; + using namespace Dune; - for(int i=0; i < 100; i++) - alist.push_back(i); + for(int i=0; i < 100; i++) + alist.push_back(i); } int testIteratorRemove(){ - using namespace Dune; - ArrayList alist; - initConsecutive(alist); - ArrayList::iterator iter=alist.begin(); - - iter+=8; - - iter.eraseToHere(); - ++iter; - - if((*iter)!=10){ - std::cerr<<"Removing from iterator failed! "<<__FILE__<<":"<<__LINE__< alist; + initConsecutive(alist); + ArrayList::iterator iter=alist.begin(); + + iter+=8; + + iter.eraseToHere(); + ++iter; + + if((*iter)!=10) { + std::cerr<<"Removing from iterator failed! "<<__FILE__<<":"<<__LINE__< alist; + initConsecutive(alist); - iter = alist.begin(); + ArrayList::iterator iter=alist.begin(); - if((*iter)!=9){ - std::cerr<<"Removing from iterator failed! "<<__FILE__<<":"<<__LINE__< alist; - initConsecutive(alist); - - ArrayList::iterator iter=alist.begin(); - - - for(int i=0; i < 100; i++){ - if(iter[i]!=i){ - std::cerr << "Random Access failed: "< alist; - initConsecutive(alist); - - ArrayList::iterator iter=alist.begin(), iter1=alist.begin(); - iter1=iter+5; - iter1=iter-5; - iter1=iter+5; - - - if(!(iter="<<*iter1<<" Operator< seems to be wrong! "<< __FILE__ <<__LINE__<iter)){ - std::cerr<<"operator> seems to be wrong! "<< __FILE__ <<__LINE__<=iter)){ - std::cerr<<"operator>= seems to be wrong! "<< __FILE__ <<__LINE__< alist; + initConsecutive(alist); + + ArrayList::iterator iter=alist.begin(), iter1=alist.begin(); + iter1=iter+5; + iter1=iter-5; + iter1=iter+5; + + + if(!(iter="<<*iter1<<" Operator< seems to be wrong! "<< __FILE__ <<__LINE__<iter)) { + std::cerr<<"operator> seems to be wrong! "<< __FILE__ <<__LINE__<=iter)) { + std::cerr<<"operator>= seems to be wrong! "<< __FILE__ <<__LINE__< alist; - - randomizeList(alist); - - int ret=testIterator(alist); - - if(0!=testComparison()){ - ret++; - cerr<< "Comparison failed!"< alist; + + randomizeList(alist); + + int ret=testIterator(alist); + + if(0!=testComparison()) { + ret++; + cerr<< "Comparison failed!"< +#include #include -#include -#include +#include #include #include +#include template -void f(const Dune::array &a) { - std::cout << "Got a " << Dune::className(a) << " with elements"; - for(std::size_t i = 0; i < n; ++i) - std::cout << " (" << a[i] << ")"; - std::cout << std::endl; +void f(const std::array &a) +{ + using Dune::operator<<; + std::cout << "Got a " << Dune::className(a) << " with elements " << a << std::endl; } int main() { // check that make_array works - f(Dune::make_array(1, 2)); + f(Dune::Std::make_array(1, 2)); + f(Dune::Std::make_array(1, 2, 3)); + f(Dune::Std::make_array(1, 2, 3, 4)); + f(Dune::Std::make_array(1, 2, 3, 4, 5)); + f(Dune::Std::make_array(1, 2, 3, 4, 5, 6)); + f(Dune::Std::make_array(1, 2, 3, 4, 5, 6, 7)); + f(Dune::Std::make_array(1, 2, 3, 4, 5, 6, 7, 8)); + f(Dune::Std::make_array(1, 2, 3, 4, 5, 6, 7, 8, 9)); + f(Dune::Std::make_array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); Dune::FieldVector x(0); - f(Dune::make_array(x, x)); + f(Dune::Std::make_array(x, x)); } diff -Nru dune-common-2.2.1/dune/common/test/bigunsignedinttest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/bigunsignedinttest.cc --- dune-common-2.2.1/dune/common/test/bigunsignedinttest.cc 2009-11-19 10:22:25.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/bigunsignedinttest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,68 +1,92 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include +#include +#include +#include + +#include +#include + +#define CHECK(x) \ + do { \ + if (!(x)) { \ + pass = false; \ + std::cerr << "FAILED: " << #x << std::endl; \ + } \ + } while(false) int main() { - - std::cout<<"unsigned short: max="<::max() - <<" min="<::min() - <<" digits="<::digits< hasher; + CHECK(hasher(BigInteger(100)) == hasher(BigInteger(100))); } + + return pass ? 0 : 1; } diff -Nru dune-common-2.2.1/dune/common/test/bitsetvectortest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/bitsetvectortest.cc --- dune-common-2.2.1/dune/common/test/bitsetvectortest.cc 2012-04-18 21:43:58.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/bitsetvectortest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,187 +1,191 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include #include + #if defined(__GNUC__) && ! defined(__clang__) #include #endif -#include +#include template struct ConstReferenceOp { - typedef typename BBF::value_type bitset; - typedef typename BBF::const_reference const_reference; - - void operator()(const_reference t){ - bitset x = t[0]; - } + typedef typename BBF::value_type bitset; + typedef typename BBF::const_reference const_reference; + + void operator()(const_reference t){ + DUNE_UNUSED bitset x = t; + } }; template void testConstBitSetMethods(const T t) { - t.size(); - t[0]; - t[t.size()-1]; - t << 2; - t >> 2; - ~t; - t.count(); - t.any(); - t.none(); - t.test(0); + t.size(); + t[0]; + t[t.size()-1]; + t << 2; + t >> 2; + ~t; + t.count(); + t.any(); + t.none(); + t.test(0); } template void testContainer(BBF & bbf) { - typedef typename BBF::value_type bitset; - typedef typename BBF::reference reference; - typedef typename BBF::const_reference const_reference; - - const BBF & cbbf = bbf; - - bitset x = bbf[3]; - reference y = bbf[4]; - const_reference z = bbf[4]; - const reference v = bbf[4]; - - // assignement - y = false; - y[2] = true; - y = x; - y = z; - y = v; - x = y; - x = z; - x = v; - y = cbbf[1]; - x = cbbf[1]; - bbf[4] = x; - bbf[4] = v; - bbf[4] = y; - bbf[4] = true; - - // invoke methods - testConstBitSetMethods(x); - testConstBitSetMethods(y); - testConstBitSetMethods(z); - testConstBitSetMethods(v); - testConstBitSetMethods(bbf[1]); - testConstBitSetMethods(cbbf[2]); - - // equality - y == cbbf[2]; - y == bbf[3]; - y == x; - x == y; - x == z; - z == x; - z == y; - y == z; - - // inequality - y != cbbf[2]; - y != bbf[3]; - y != x; - x != y; - x != z; - z != x; - z != y; - y != z; - - // &= - y &= cbbf[2]; - y &= bbf[3]; - y &= x; - x &= y; - x &= z; - y &= z; - - // |= - y |= cbbf[2]; - y |= bbf[3]; - y |= x; - x |= y; - x |= z; - y |= z; - - // ^= - y ^= cbbf[2]; - y ^= bbf[3]; - y ^= x; - x ^= y; - x ^= z; - y ^= z; - - // shift operator - y <<= 1; - y >>= 1; - - // flip - y.flip(); - y.flip(2); - y[3].flip(); + typedef typename BBF::value_type bitset; + typedef typename BBF::reference reference; + typedef typename BBF::const_reference const_reference; + + const BBF & cbbf = bbf; + + bitset x = bbf[3]; + reference y = bbf[4]; + const_reference z = bbf[4]; + const reference v = bbf[4]; + + // assignement + y = false; + y[2] = true; + y = x; + y = z; + y = v; + x = y; + x = z; + x = v; + y = cbbf[1]; + x = cbbf[1]; + bbf[4] = x; + bbf[4] = v; + bbf[4] = y; + bbf[4] = true; + + // invoke methods + testConstBitSetMethods(x); + testConstBitSetMethods(y); + testConstBitSetMethods(z); + testConstBitSetMethods(v); + testConstBitSetMethods(bbf[1]); + testConstBitSetMethods(cbbf[2]); + + // equality + y == cbbf[2]; + y == bbf[3]; + y == x; + x == y; + x == z; + z == x; + z == y; + y == z; + + // inequality + y != cbbf[2]; + y != bbf[3]; + y != x; + x != y; + x != z; + z != x; + z != y; + y != z; + + // &= + y &= cbbf[2]; + y &= bbf[3]; + y &= x; + x &= y; + x &= z; + y &= z; + + // |= + y |= cbbf[2]; + y |= bbf[3]; + y |= x; + x |= y; + x |= z; + y |= z; + + // ^= + y ^= cbbf[2]; + y ^= bbf[3]; + y ^= x; + x ^= y; + x ^= z; + y ^= z; + + // shift operator + y <<= 1; + y >>= 1; + + // flip + y.flip(); + y.flip(2); + y[3].flip(); } template void testConstContainer(const BBF& bbf){ - typedef typename BBF::value_type bitset; - typedef typename BBF::iterator iterator; - typedef typename std::iterator_traits::value_type value_type; - typedef typename BBF::const_reference reference; - - const BBF & cbbf = bbf; - - bitset x = bbf[3]; - value_type z; - reference y = bbf[4]; - - // assignement - x = y; - x = cbbf[1]; - - // equality - y == cbbf[2]; - y == bbf[3]; - y == x; - x == y; - - // inequality - y != cbbf[2]; - y != bbf[3]; - y != x; - x != y; + typedef typename BBF::value_type bitset; + typedef typename BBF::iterator iterator; + typedef typename std::iterator_traits::value_type value_type; + typedef typename BBF::const_reference reference; + + const BBF & cbbf = bbf; + + bitset x = bbf[3]; + value_type z; + reference y = bbf[4]; + + // assignement + x = y; + x = cbbf[1]; + + // equality + y == cbbf[2]; + y == bbf[3]; + y == x; + x == y; + + // inequality + y != cbbf[2]; + y != bbf[3]; + y != x; + x != y; } template void doTest() { - typedef Dune::BitSetVector BBF; + typedef Dune::BitSetVector BBF; + + BBF bbf(10,true); + const BBF & cbbf = bbf; - BBF bbf(10,true); - const BBF & cbbf = bbf; + // test containers and some basic bitset operations + testContainer(bbf); + testConstContainer(bbf); + testConstContainer(cbbf); - // test containers and some basic bitset operations - testContainer(bbf); - testConstContainer(bbf); - testConstContainer(cbbf); - - // iterator interface + // iterator interface #ifndef NDEBUG - ConstReferenceOp cop; - assert(testIterator(bbf, cop) == 0); - assert(testIterator(cbbf, cop) == 0); + ConstReferenceOp cop; + assert(testIterator(bbf, cop) == 0); + assert(testIterator(cbbf, cop) == 0); #endif } int main() { - doTest<4, std::allocator >(); + doTest<4, std::allocator >(); #if defined(__GNUC__) && ! defined(__clang__) - doTest<4, __gnu_cxx::malloc_allocator >(); + doTest<4, __gnu_cxx::malloc_allocator >(); #endif - return 0; + return 0; } diff -Nru dune-common-2.2.1/dune/common/test/boundscheckingmvtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/boundscheckingmvtest.cc --- dune-common-2.2.1/dune/common/test/boundscheckingmvtest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/boundscheckingmvtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,391 @@ +#include +#include +#include +#include + +int main() try { + bool passed = true; + + // Free matrix-vector multiplication (mv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + Dune::DenseMatrixHelp::multAssign(A,x,b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Free matrix-vector multiplication (mv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + Dune::DenseMatrixHelp::multAssign(A,x,b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (mv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.mv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (mv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.mv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (mtv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.mtv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (mtv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.mtv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (umv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.umv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (umv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.umv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (umtv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.umtv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (umtv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.umtv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (umhv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.umhv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (umhv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.umhv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (mmv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.mmv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (mmv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.mmv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (mmtv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.mmtv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (mmtv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.mmtv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (mmhv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.mmhv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (mmhv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.mmhv(x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (usmv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.usmv(2, x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (usmv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.usmv(2, x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (usmtv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.usmtv(2, x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (usmtv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.usmtv(2, x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Matrix-vector multiplication (usmhv): Input size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2, 3}; + Dune::FieldVector b(0); + A.usmhv(2, x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Matrix-vector multiplication (usmhv): Output size incorrect + try { + Dune::FieldMatrix A = {{1, 2, 3}, {10, 20, 30}}; + Dune::FieldVector x = {1, 2}; + Dune::FieldVector b(0); + A.usmhv(2, x, b); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // right multiplication: None-square Matrix argument + try { + Dune::DynamicMatrix A(2, 3, 5); + Dune::DynamicMatrix const B(3, 2, 5); + A.rightmultiply(B); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // right multiplication: Incorrect number of rows + try { + Dune::DynamicMatrix A(2, 2, 5); + Dune::DynamicMatrix const B(3, 3, 5); + A.rightmultiply(B); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // left multiplication: None-square Matrix argument + try { + Dune::FieldMatrix A = {{1, 2}, {10, 20}, {100, 200}}; + Dune::FieldMatrix const B = {{1, 2, 3}, {10, 20, 30}}; + A.leftmultiply(B); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // left multiplication: Incorrect number of rows + try { + Dune::FieldMatrix A = { + {1, 2, 3}, {10, 20, 30}, {100, 200, 300}}; + Dune::FieldMatrix const B = {{1, 2}, {10, 20}, {100, 200}}; + A.leftmultiply(B); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + return passed ? 0 : 1; +} catch (Dune::Exception &e) { + std::cerr << e << std::endl; + return 1; +} catch (std::exception &e) { + std::cerr << e.what() << std::endl; + return 1; +} diff -Nru dune-common-2.2.1/dune/common/test/boundscheckingoptest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/boundscheckingoptest.cc --- dune-common-2.2.1/dune/common/test/boundscheckingoptest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/boundscheckingoptest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,140 @@ +#include +#include +#include + +int main() try { + bool passed = true; + + // Add vectors of different sizes + try { + Dune::FieldVector v1 = {1, 2, 3}; + Dune::FieldVector const v2 = {1, 2}; + v1 += v2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Subtract vectors of different sizes + try { + Dune::FieldVector v1 = {1, 2, 3}; + Dune::FieldVector const v2 = {1, 2}; + v1 -= v2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Check vectors of different sizes for equality + try { + Dune::FieldVector const v1 = {1, 2, 3}; + Dune::FieldVector const v2 = {1, 2}; + v1 == v2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Check vectors of different sizes for inequality + try { + Dune::FieldVector const v1 = {1, 2, 3}; + Dune::FieldVector const v2 = {1, 2}; + v1 != v2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Apply axpy to vectors of different sizes + try { + Dune::FieldVector v1 = {1, 2, 3}; + Dune::FieldVector const v2 = {1, 2}; + v1.axpy(2, v2); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + try { + Dune::FieldMatrix m1 = {{1, 2, 3}}; + Dune::FieldMatrix const m2 = {{1, 2, 3}, {10, 20, 30}}; + m1 += m2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + try { + Dune::FieldMatrix m1 = {{1, 2, 3}}; + Dune::FieldMatrix const m2 = {{1, 2, 3}, {10, 20, 30}}; + m1 -= m2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + try { + Dune::FieldMatrix m1 = {{1, 2, 3}}; + Dune::FieldMatrix const m2 = {{1, 2, 3}, {10, 20, 30}}; + m1 == m2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + try { + Dune::FieldMatrix m1 = {{1, 2, 3}}; + Dune::FieldMatrix const m2 = {{1, 2, 3}, {10, 20, 30}}; + m1 != m2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + try { + Dune::FieldMatrix m1 = {{1, 2, 3}}; + Dune::FieldMatrix const m2 = {{1, 2, 3}, {10, 20, 30}}; + m1.axpy(2, m2); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + return passed ? 0 : 1; +} catch (Dune::Exception &e) { + std::cerr << e << std::endl; + return 1; +} catch (std::exception &e) { + std::cerr << e.what() << std::endl; + return 1; +} diff -Nru dune-common-2.2.1/dune/common/test/boundscheckingtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/boundscheckingtest.cc --- dune-common-2.2.1/dune/common/test/boundscheckingtest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/boundscheckingtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,300 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +int main() try { + bool passed = true; + + // Write beyond end of singleton vector + try { + Dune::FieldVector v = {1}; + v[1] = 10; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Read beyond end of singleton vector + try { + Dune::FieldVector const v = {1}; + DUNE_UNUSED double const x = v[1]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Write beyond end of vector + try { + Dune::FieldVector v = {1, 2, 3}; + v[3] = 10; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + Dune::DynamicVector v = {1, 2, 3}; + v[3] = 10; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Read beyond end of vector + try { + Dune::FieldVector const v = {1, 2, 3}; + DUNE_UNUSED double const x = v[3]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + Dune::DynamicVector const v = {1, 2, 3}; + DUNE_UNUSED double const x = v[3]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + + // Write beyond end of singleton matrix + try { + Dune::FieldMatrix m = {{1}}; + m[1][0] = 100; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Read beyond end of singleton matrix + try { + Dune::FieldMatrix const m = {{1}}; + DUNE_UNUSED double const x = m[1][0]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Write beyond end of matrix + try { + Dune::FieldMatrix m = {{1, 2, 3}, {10, 20, 30}}; + m[2][0] = 100; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + Dune::DynamicMatrix m = {{1, 2, 3}, {10, 20, 30}}; + m[2][0] = 100; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Read beyond end of matrix + try { + Dune::FieldMatrix const m = {{1, 2, 3}, {10, 20, 30}}; + DUNE_UNUSED double const x = m[2][0]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + Dune::DynamicMatrix const m = {{1, 2, 3}, {10, 20, 30}}; + DUNE_UNUSED double const x = m[2][0]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Write beyond end of diagonal matrix (way #1) + try { + Dune::DiagonalMatrix d(5); + d[3][3] = 9; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Write beyond end of diagonal matrix (way #2) + try { + Dune::DiagonalMatrix d(5); + d.diagonal(3) = 9; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Read beyond end of diagonal matrix (way #1) + try { + Dune::DiagonalMatrix const d(5); + DUNE_UNUSED double const x = d[3][3]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + // Read beyond end of diagonal matrix (way #2) + try { + Dune::DiagonalMatrix const d(5); + DUNE_UNUSED double const x = d.diagonal(3); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Write outside of diagonal matrix pattern + try { + Dune::DiagonalMatrix d(5); + d[1][2] = 9; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Read outside of diagonal matrix pattern + try { + Dune::DiagonalMatrix const d(5); + DUNE_UNUSED double const x = d[1][2]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Check for entry beyond diagonal matrix size + try { + Dune::DiagonalMatrix const d(5); + d.exists(3, 3); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Check for entry beyond matrix size + try { + Dune::FieldMatrix const m = {{1, 2, 3}, {10, 20, 30}}; + m.exists(2, 2); + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Read beyond end of bitsetvector + try { + Dune::BitSetVector<3> const b(10); + DUNE_UNUSED auto const x = b[10]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Write beyond end of bitsetvector + try { + Dune::BitSetVector<3> b(10); + b[10] = true; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Read beyond end of bitsetvectorreference + try { + Dune::BitSetVector<3> const b(10); + DUNE_UNUSED auto const x = b[10][3]; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + // Write beyond end of bitsetvectorreference + try { + Dune::BitSetVector<3> b(10); + b[10][3] = true; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + return passed ? 0 : 1; +} catch (Dune::Exception &e) { + std::cerr << e << std::endl; + return 1; +} catch (std::exception &e) { + std::cerr << e.what() << std::endl; + return 1; +} diff -Nru dune-common-2.2.1/dune/common/test/calloncetest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/calloncetest.cc --- dune-common-2.2.1/dune/common/test/calloncetest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/calloncetest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,12 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +int main() { + DUNE_ASSERT_CALL_ONCE(); +} diff -Nru dune-common-2.2.1/dune/common/test/check_fvector_size.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/check_fvector_size.cc --- dune-common-2.2.1/dune/common/test/check_fvector_size.cc 2011-09-08 18:38:30.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/check_fvector_size.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,13 +1,15 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #include #include -int main(int argc, char * argv[]) +int main(int, char **) { Dune::DynamicVector one(1); Dune::DynamicVector two(2); two = one; - + return 0; } diff -Nru dune-common-2.2.1/dune/common/test/check_fvector_size_fail.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/check_fvector_size_fail.cc --- dune-common-2.2.1/dune/common/test/check_fvector_size_fail.cc 2011-09-08 18:38:30.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/check_fvector_size_fail.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #include #include diff -Nru dune-common-2.2.1/dune/common/test/checkmatrixinterface.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/test/checkmatrixinterface.hh --- dune-common-2.2.1/dune/common/test/checkmatrixinterface.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/checkmatrixinterface.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,435 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_CHECK_MATRIX_INTERFACE_HH +#define DUNE_COMMON_CHECK_MATRIX_INTERFACE_HH + +#include +#include + +#include +#include +#include +#include + + +/* + * @file + * @brief This file provides an interface check for dense matrices. + * @author Christoph Gersbacher + */ + + +namespace Dune +{ + + // External forward declarations for namespace Dune + // ------------------------------------------------ + + template< class, int, int > class FieldMatrix; + template< class, int > class DiagonalMatrix; + +} // namespace Dune + + + +namespace CheckMatrixInterface +{ + + namespace Capabilities + { + + // hasStaticSizes + // -------------- + + template< class Matrix > + struct hasStaticSizes + { + static const bool v = false; + static const int rows = ~0; + static const int cols = ~0; + }; + + template< class Matrix > + struct hasStaticSizes< const Matrix > + { + static const bool v = hasStaticSizes< Matrix >::v; + static const int rows = hasStaticSizes< Matrix >::rows; + static const int cols = hasStaticSizes< Matrix >::cols; + }; + + + + // isSquare + // -------- + + template< class Matrix > + struct isSquare + { + static const bool v = false; + }; + + template< class Matrix > + struct isSquare< const Matrix > + { + static const bool v = isSquare< Matrix >::v; + }; + + + + // Template specializations for Dune::FieldMatrix + // ---------------------------------------------- + + template< class K, int r, int c > + struct hasStaticSizes< Dune::FieldMatrix< K, r, c > > + { + static const bool v = true; + static const int rows = r; + static const int cols = c; + }; + + template< class K, int rows, int cols > + struct isSquare< Dune::FieldMatrix< K, rows, cols > > + { + static const bool v = ( rows == cols ); + }; + + + + // Template specializations for Dune::DiagonalMatrix + // ------------------------------------------------- + + template< class K, int n > + struct hasStaticSizes< Dune::DiagonalMatrix > + { + static const bool v = true; + static const int rows = n; + static const int cols = n; + }; + + template< class K, int n > + struct isSquare< Dune::DiagonalMatrix > + { + static const bool v = true; + }; + + } // namespace Capabilities + + + + // UseDynamicVector + // ---------------- + + template< class Matrix > + struct UseDynamicVector + { + typedef typename Matrix::value_type value_type; + + typedef Dune::DynamicVector< value_type > domain_type; + typedef domain_type range_type; + + static domain_type domain ( const Matrix &matrix, value_type v = value_type() ) + { + return domain_type( matrix.M(), v ); + } + + static range_type range ( const Matrix &matrix, value_type v = value_type() ) + { + return range_type( matrix.N(), v ); + } + }; + + + + // UseFieldVector + // -------------- + + template< class K, int rows, int cols > + struct UseFieldVector + { + typedef K value_type; + + typedef Dune::FieldVector< K, cols > domain_type; + typedef Dune::FieldVector< K, rows > range_type; + + template< class Matrix > + static domain_type domain ( const Matrix &, value_type v = value_type() ) + { + return domain_type( v ); + } + + template< class Matrix > + static range_type range ( const Matrix &, value_type v = value_type() ) + { + return range_type( v ); + } + }; + + + + // MatrixSizeHelper + // ---------------- + + template< class Matrix, bool hasStaticSizes = Capabilities::hasStaticSizes< Matrix >::v > + struct MatrixSizeHelper; + + template< class Matrix > + struct MatrixSizeHelper< Matrix, false > + { + typedef typename Matrix::size_type size_type; + static const size_type rows ( const Matrix &matrix ) { return matrix.rows(); } + static const size_type cols ( const Matrix &matrix ) { return matrix.cols(); } + }; + + template< class Matrix > + struct MatrixSizeHelper< Matrix, true > + { + typedef typename Matrix::size_type size_type; + static const size_type rows ( const Matrix & ) { return Matrix::rows; } + static const size_type cols ( const Matrix & ) { return Matrix::cols; } + }; + + + + // CheckIfSquareMatrix + // ------------------- + + template< class Matrix, class Traits, bool isSquare = Capabilities::isSquare< Matrix >::v > + struct CheckIfSquareMatrix; + + template< class Matrix, class Traits > + struct CheckIfSquareMatrix< Matrix, Traits, false > + { + static void apply ( const Matrix &) {} + + static void apply ( Matrix &) {} + }; + + template< class Matrix, class Traits > + struct CheckIfSquareMatrix< Matrix, Traits, true > + { + typedef typename Matrix::value_type value_type; + + static value_type tolerance () + { + return value_type( 16 ) * std::numeric_limits< value_type >::epsilon(); + } + + static void apply ( const Matrix &matrix ) + { + const value_type determinant = matrix.determinant(); + if( determinant > tolerance() ) + { + typename Traits::domain_type x = Traits::domain( matrix ); + const typename Traits::range_type b = Traits::range( matrix ); + matrix.solve( x, b ); + } + } + + static void apply ( Matrix &matrix ) + { + apply( const_cast< const Matrix & >( matrix ) ); + if( matrix.determinant() > tolerance() ) + matrix.invert(); + } + }; + + + + // CheckConstMatrix + // ---------------- + + template< class Matrix, class Traits > + struct CheckConstMatrix + { + // required type definitions + typedef typename Matrix::size_type size_type; + + typedef typename Matrix::value_type value_type; + typedef typename Matrix::field_type field_type; + typedef typename Matrix::block_type block_type; + + typedef typename Matrix::const_row_reference const_row_reference; + + typedef typename Matrix::ConstIterator ConstIterator; + + static void apply ( const Matrix &matrix ) + { + checkDataAccess ( matrix ); + checkIterators ( matrix ); + checkLinearAlgebra ( matrix ); + checkNorms ( matrix ); + checkSizes ( matrix ); + CheckIfSquareMatrix< Matrix, Traits >::apply( matrix ); + + // TODO: check comparison + // bool operator == ( const Matrix &other ); + // bool operator != ( const Matrix &other ); + } + + // check size methods + static void checkSizes ( const Matrix &matrix ) + { + DUNE_UNUSED const size_type size = matrix.size(); + const size_type rows = MatrixSizeHelper< Matrix >::rows( matrix ); + const size_type cols = MatrixSizeHelper< Matrix >::cols( matrix ); + const size_type N = matrix.N(); + const size_type M = matrix.M(); + + if( N != rows || M != cols ) + DUNE_THROW( Dune::RangeError, "Returned inconsistent sizes." ); + } + + // check read-only access to data + static void checkDataAccess ( const Matrix &matrix ) + { + const size_type size = matrix.size(); + for( size_type i = size_type( 0 ); i < size; ++i ) + DUNE_UNUSED const_row_reference row = matrix[ i ]; + + const size_type rows = MatrixSizeHelper< Matrix >::rows( matrix ); + const size_type cols = MatrixSizeHelper< Matrix >::cols( matrix ); + for( size_type i = size_type( 0 ); i < rows; ++i ) + { + for( size_type j = size_type( 0 ); j < cols; ++j ) + { + DUNE_UNUSED bool exists = matrix.exists( i, j ); + DUNE_UNUSED const value_type &value = matrix[ i ][ j ]; + } + } + } + + // check norms + static void checkNorms ( const Matrix &matrix ) + { + typedef typename Dune::FieldTraits< value_type >::real_type real_type; + real_type frobenius_norm = matrix.frobenius_norm(); + real_type frobenius_norm2 = matrix.frobenius_norm2(); + real_type infinity_norm = matrix.infinity_norm() ; + real_type infinity_norm_real = matrix.infinity_norm_real(); + + if( std::min( std::min( frobenius_norm, frobenius_norm2 ), + std::min( infinity_norm, infinity_norm_real ) ) < real_type( 0 ) ) + DUNE_THROW( Dune::InvalidStateException, "Norms must return non-negative value." ); + } + + // check basic linear algebra methods + static void checkLinearAlgebra ( const Matrix &matrix ) + { + typename Traits::domain_type domain = Traits::domain( matrix ); + typename Traits::range_type range = Traits::range( matrix ); + typename Traits::value_type alpha( 1 ); + + matrix.mv( domain, range ); + matrix.mtv( range, domain ); + matrix.umv( domain, range ); + matrix.umtv( range, domain ); + matrix.umhv( range, domain ); + matrix.mmv( domain, range ); + matrix.mmtv( range, domain ); + matrix.mmhv( range, domain ); + matrix.usmv( alpha, domain, range ); + matrix.usmtv( alpha, range, domain ); + matrix.usmhv( alpha, range, domain ); + } + + // check iterator methods + static void checkIterators ( const Matrix &matrix ) + { + const ConstIterator end = matrix.end(); + for( ConstIterator it = matrix.begin(); it != end; ++it ) + DUNE_UNUSED const_row_reference row = *it; + } + }; + + + + // CheckNonConstMatrix + // ------------------- + + template< class Matrix, class Traits > + struct CheckNonConstMatrix + { + // required type definitions + typedef typename Matrix::size_type size_type; + typedef typename Matrix::value_type value_type; + typedef typename Matrix::row_reference row_reference; + typedef typename Matrix::row_type row_type; + typedef typename Matrix::Iterator Iterator; + + static void apply ( Matrix &matrix ) + { + checkIterators( matrix ); + checkAssignment( matrix ); + + CheckIfSquareMatrix< Matrix, Traits >::apply( matrix ); + + // TODO: check scalar/matrix and matrix/matrix operations + // Matrix &operator+= ( const Matrix &other ); + // Matrix &operator-= ( const Matrix &other ); + // Matrix &operator*= ( const value_type &v ); + // Matrix &operator/= ( const value_type &v ); + // Matrix &axpy += ( const value_type &v, const Matrix &other ); + // Matrix &axpy += ( const value_type &v, const Matrix &other ); + // Matrix &leftmultiply ( const Matrix &other ); + // Matrix &rightmultiply ( const Matrix &other ); + } + + // check assignment + static void checkAssignment ( Matrix &matrix ) + { + matrix = value_type( 1 ); + + const size_type size = matrix.size(); + for( size_type i = size_type( 0 ); i < size; ++i ) + { + row_reference row = matrix[ i ]; + row = row_type( value_type( 0 ) ); + } + + const size_type rows = MatrixSizeHelper< Matrix >::rows( matrix ); + const size_type cols = MatrixSizeHelper< Matrix >::cols( matrix ); + for( size_type i = size_type( 0 ); i < rows; ++i ) + { + for( size_type j = size_type( 0 ); j < cols; ++j ) + matrix[ i ][ j ] = ( i == j ? value_type( 1 ) : value_type( 0 ) ); + } + } + + // check iterator methods + static void checkIterators ( Matrix &matrix ) + { + const Iterator end = matrix.end(); + for( Iterator it = matrix.begin(); it != end; ++it ) + { + row_reference row = *it; + row = row_type( value_type( 0 ) ); + } + } + }; + +} // namespace CheckMatrixInterface + + + +namespace Dune +{ + + // checkMatrixInterface + // -------------------- + + template< class Matrix, class Traits = CheckMatrixInterface::UseDynamicVector< Matrix > > + void checkMatrixInterface ( const Matrix &matrix ) + { + CheckMatrixInterface::CheckConstMatrix< Matrix, Traits >::apply( matrix ); + } + + template< class Matrix, class Traits = CheckMatrixInterface::UseDynamicVector< Matrix > > + void checkMatrixInterface ( Matrix &matrix ) + { + checkMatrixInterface( const_cast< const Matrix & >( matrix ) ); + CheckMatrixInterface::CheckNonConstMatrix< Matrix, Traits >::apply( matrix ); + } + +} // namespace Dune + +#endif // #ifndef DUNE_COMMON_CHECK_MATRIX_INTERFACE_HH diff -Nru dune-common-2.2.1/dune/common/test/classnametest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/classnametest.cc --- dune-common-2.2.1/dune/common/test/classnametest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/classnametest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,60 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include +#include +#include + + +using Dune::FieldVector; +using std::complex; + +int main() +{ + try { + std::cout << "First three simple class names extracted from variables:" << std::endl; + FieldVector xi; + std::cout << className(xi) << std::endl; + FieldVector xd; + std::cout << className(xd) << std::endl; + FieldVector, 10> xcd; + std::cout << className(xcd) << std::endl; + std::cout << std::endl; + + std::cout << "Adding const:" << std::endl; + const FieldVector cxi; + std::cout << className(cxi) << std::endl; + std::cout << std::endl; + + std::cout << "If a variable is a reference can not be extracted (needs decltype as used below): " << std::endl; + FieldVector &rxd = xd; + std::cout << className(rxd) << std::endl; + std::cout << std::endl; + + std::cout << "Extracting the class name using a type directly - " + << "also extractes references correctly: " << std::endl; + std::cout << Dune::className() << std::endl; + const FieldVector &rcxd = xd; + std::cout << Dune::className() << std::endl; + const FieldVector &rcxi = cxi; + std::cout << Dune::className() << std::endl; + std::cout << std::endl; + + std::cout << "Test some further types:" << std::endl; + std::cout << Dune::className< volatile FieldVector, 10>& >() << std::endl; + std::cout << Dune::className< FieldVector, 10>&& >() << std::endl; + std::cout << std::endl; + + } catch (Dune::Exception& e) { + throw; + } catch (...) { + std::cerr << "Generic exception!" << std::endl; + return 2; + } +} diff -Nru dune-common-2.2.1/dune/common/test/CMakeLists.txt dune-common-2.5.2~20170808ga5c076ca/dune/common/test/CMakeLists.txt --- dune-common-2.2.1/dune/common/test/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/CMakeLists.txt 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,218 @@ +dune_add_test(SOURCES arraylisttest.cc) + +dune_add_test(SOURCES arraytest.cc) + +dune_add_test(SOURCES bigunsignedinttest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES bitsetvectortest.cc) + +dune_add_test(SOURCES boundscheckingtest.cc + COMPILE_DEFINITIONS DUNE_CHECK_BOUNDS=1 + LINK_LIBRARIES dunecommon) +dune_add_test(SOURCES boundscheckingmvtest.cc + COMPILE_DEFINITIONS DUNE_CHECK_BOUNDS=1 + LINK_LIBRARIES dunecommon) +dune_add_test(SOURCES boundscheckingoptest.cc + COMPILE_DEFINITIONS DUNE_CHECK_BOUNDS=1 + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES calloncetest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES check_fvector_size.cc) + +dune_add_test(NAME check_fvector_size_fail1 + SOURCES check_fvector_size_fail.cc + COMPILE_DEFINITIONS DIM=1 + EXPECT_COMPILE_FAIL) + +dune_add_test(NAME check_fvector_size_fail2 + SOURCES check_fvector_size_fail.cc + COMPILE_DEFINITIONS DIM=3 + EXPECT_COMPILE_FAIL) + +dune_add_test(SOURCES classnametest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES concept.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES densematrixassignmenttest.cc + LINK_LIBRARIES dunecommon) +dune_add_test(NAME densematrixassignmenttest_fail0 + SOURCES densematrixassignmenttest.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE0" + EXPECT_COMPILE_FAIL) +dune_add_test(NAME densematrixassignmenttest_fail1 + SOURCES densematrixassignmenttest.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE1" + EXPECT_COMPILE_FAIL) +dune_add_test(NAME densematrixassignmenttest_fail2 + SOURCES densematrixassignmenttest.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE2" + EXPECT_COMPILE_FAIL) +dune_add_test(NAME densematrixassignmenttest_fail3 + SOURCES densematrixassignmenttest.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE3" + EXPECT_COMPILE_FAIL) +dune_add_test(NAME densematrixassignmenttest_fail4 + SOURCES densematrixassignmenttest.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE4" + EXPECT_COMPILE_FAIL) +dune_add_test(NAME densematrixassignmenttest_fail5 + SOURCES densematrixassignmenttest.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE5" + EXPECT_COMPILE_FAIL) +dune_add_test(NAME densematrixassignmenttest_fail6 + SOURCES densematrixassignmenttest.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE6" + EXPECT_COMPILE_FAIL) + +dune_add_test(SOURCES diagonalmatrixtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES dynmatrixtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES dynvectortest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES densevectortest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES enumsettest.cc) + +dune_add_test(NAME fmatrixtest + SOURCES fmatrixtest.cc dummy.f + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES fvectortest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES genericiterator_compile_fail.cc + EXPECT_COMPILE_FAIL) + +dune_add_test(SOURCES gcdlcmtest.cc) + +dune_add_test(SOURCES hybridutilitiestest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES indicestest.cc) + +dune_add_test(SOURCES integersequence.cc) + +dune_add_test(SOURCES iteratorfacadetest2.cc) + +dune_add_test(SOURCES iteratorfacadetest.cc) + +dune_add_test(SOURCES lrutest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES mpicollectivecommunication.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES mpiguardtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES mpihelpertest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(NAME mpihelpertest2 + SOURCES mpihelpertest.cc + COMPILE_DEFINITIONS MPIHELPER_PREINITIALIZE + LINK_LIBRARIES dunecommon + ) + +dune_add_test(SOURCES overloadsettest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES parametertreelocaletest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES parametertreetest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES pathtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES poolallocatortest.cc) + +dune_add_test(SOURCES rangeutilitiestest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES shared_ptrtest.cc) + +dune_add_test(SOURCES singletontest.cc) + +dune_add_test(SOURCES sllisttest.cc) + +dune_add_test(SOURCES stdapplytest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES stdtypetraitstest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES streamoperatorstest.cc) + +dune_add_test(SOURCES streamtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES stringutilitytest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(NAME testdebugallocator_fail1 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE1;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS" + EXPECT_FAIL) + +dune_add_test(NAME testdebugallocator_fail2 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE2;EXPECTED_SIGNAL=SIGABRT" + EXPECT_FAIL) + +dune_add_test(NAME testdebugallocator_fail3 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE3;EXPECTED_SIGNAL=SIGABRT" + EXPECT_FAIL) + +dune_add_test(NAME testdebugallocator_fail4 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE4;DEBUG_ALLOCATOR_KEEP=1;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS" + EXPECT_FAIL) + +dune_add_test(NAME testdebugallocator_fail5 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE5;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS" + EXPECT_FAIL) + +dune_add_test(SOURCES testfloatcmp.cc) + +dune_add_test(SOURCES tupleutilitytest.cc) + +dune_add_test(SOURCES utilitytest.cc) + +dune_add_test(SOURCES eigenvaluestest.cc + LINK_LIBRARIES dunecommon + CMAKE_GUARD LAPACK_FOUND) + +install( + FILES + testsuite.hh + collectorstream.hh + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common/test) diff -Nru dune-common-2.2.1/dune/common/test/collectorstream.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/test/collectorstream.hh --- dune-common-2.2.1/dune/common/test/collectorstream.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/collectorstream.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,81 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_TEST_COLLECTORSTREAM_HH +#define DUNE_COMMON_TEST_COLLECTORSTREAM_HH + +#include +#include +#include + + +#include + + +namespace Dune { + + + +/** + * \brief Data collector stream + * + * A class derived from std::ostringstream that allows to + * collect data via a temporary returned object. To facilitate + * this it stores a callback that is used to pass the collected + * data to its creator on destruction. + * + * In order to avoid passing the same data twice, copy construction + * is forbidden and only move construction is allowed. + */ +class CollectorStream : public std::ostringstream +{ +public: + + /** + * \brief Create from callback + * + * \tparam CallBack Type of callback. Must be convertible to std::function + * \param callBack A copy of this function will be stored and called on destruction. + */ + template = 0> + CollectorStream(CallBack&& callBack) : + callBack_(callBack) + {} + + CollectorStream(const CollectorStream& other) = delete; + + /** + * \brief Move constructor + * + * This will take over the data and callback from the + * moved from CollectorStream and disable the callback + * in the latter. + */ + CollectorStream(CollectorStream&& other) : + callBack_(other.callBack_) + { + (*this) << other.str(); + other.callBack_ = [](std::string){}; + } + + /** + * \brief Destructor + * + * This calls the callback function given on creation + * passing all collected data as a single string argument. + */ + ~CollectorStream() + { + callBack_(this->str()); + } + +private: + std::function callBack_; +}; + + + +} // namespace Dune + + +#endif // DUNE_COMMON_TEST_COLLECTORSTREAM_HH diff -Nru dune-common-2.2.1/dune/common/test/concept.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/concept.cc --- dune-common-2.2.1/dune/common/test/concept.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/concept.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,200 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#include + +#include + +#include +#include + +#include +#include + + + +struct HasFoo +{ + template + auto require(const T& t) -> decltype( + t.foo() + ); +}; + +struct HasBar +{ + template + auto require(const T& t) -> decltype( + t.bar() + ); +}; + +struct HasFooAndBar1 : Dune::Concept::Refines +{ + template + auto require(const T& t) -> decltype( + t.bar() + ); +}; + +struct HasFooAndBar2 : Dune::Concept::Refines +{ + template + auto require(const T& t) -> decltype( + t.foo() + ); +}; + +struct HasFooAndBar3 +{ + template + auto require(const T& t) -> decltype( + t.foo(), + t.bar() + ); +}; + +struct HasFooAndBar4 : Dune::Concept::Refines +{ + template + auto require(const T& t) -> decltype( + 0 + ); +}; + +struct HasFooAndBar5 +{ + template + auto require(const T& t) -> decltype( + 0 + ); + using BaseConceptList = Dune::TypeList; +}; + + + + +template +struct Foo +{ + T foo() const + { return T(); } +}; + +template +struct Bar +{ + T bar() const + { return T(); } +}; + +template +struct FooBar +{ + T foo() const + { return T(); } + + T bar() const + { return T(); } +}; + + + + +int main ( int argc, char **argv ) +try +{ + using namespace Dune; + + MPIHelper::instance(argc, argv); + + TestSuite test; + + test.check(models>()) + << "models>() gives wrong result"; + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(models>()) + << "models>() gives wrong result"; + + + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(models>()) + << "models>() gives wrong result"; + + test.check(models>()) + << "models>() gives wrong result"; + + + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(models>()) + << "models>() gives wrong result"; + + + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(models>()) + << "models>() gives wrong result"; + + + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(models>()) + << "models>() gives wrong result"; + + + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(models>()) + << "models>() gives wrong result"; + + + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(not models>()) + << "models>() gives wrong result"; + + test.check(models>()) + << "models>() gives wrong result"; + + + + return test.exit(); +} +catch( Dune::Exception &e ) +{ + std::cerr << "Dune reported error: " << e << std::endl; + return 1; +} +catch(...) +{ + std::cerr << "Unknown exception thrown!" << std::endl; + return 1; +} diff -Nru dune-common-2.2.1/dune/common/test/conversiontest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/conversiontest.cc --- dune-common-2.2.1/dune/common/test/conversiontest.cc 2008-10-20 08:49:07.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/conversiontest.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -#include -#include - -int main () -{ - std :: cout << "Conversion from int to double exists? " - << Dune::Conversion< int, double > :: exists << std :: endl; - - return 0; -} diff -Nru dune-common-2.2.1/dune/common/test/densematrixassignmenttest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/densematrixassignmenttest.cc --- dune-common-2.2.1/dune/common/test/densematrixassignmenttest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/densematrixassignmenttest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,381 @@ +#include "config.h" + +#define DUNE_CHECK_BOUNDS + +#include + +#include +#include +#include +#include +#include +#include + +template +void populateMatrix(M &A, int rows, int cols) { + for (int i = 0; i < rows; ++i) + for (int j = 0; j < cols; ++j) + A[i][j] = i + 10 * j; +} + + +template< class K, int rows, int cols > +struct Foo +{ + constexpr static int M () noexcept { return cols; } + constexpr static int N () noexcept { return rows; } + + operator Dune::FieldMatrix< K, rows, cols > () const + { + Dune::FieldMatrix< K, rows, cols > A; + populateMatrix( A, rows, cols ); + return A; + } +}; + + +template +bool identicalContents(A const &a, B const &b) { + typedef typename A::size_type Size; + + if (a.N() != b.N() or a.M() != b.M()) + return false; + + for (Size i = 0; i < a.N(); ++i) + for (Size j = 0; j < b.N(); ++j) + if (a[i][j] != b[i][j]) + return false; + return true; +} + +template +bool run() { + ft const constant = 47.11; + std::cout << "Testing with type: " << Dune::className(constant) << std::endl; + + Dune::FieldMatrix fieldM; + Dune::FieldMatrix fieldMWrong11; + Dune::FieldMatrix fieldMWrong22; + Dune::FieldMatrix fieldMWrong33; + populateMatrix(fieldM, 2, 3); + populateMatrix(fieldMWrong11, 1, 1); + populateMatrix(fieldMWrong22, 2, 2); + populateMatrix(fieldMWrong33, 3, 3); + + Foo< ft, 2, 3 > fooM; + fieldM = static_cast< Dune::FieldMatrix< ft, 2, 3 > >( fooM ); + + Dune::DynamicMatrix dynM(2, 3); + Dune::DynamicMatrix dynMWrong11(1, 1); + Dune::DynamicMatrix dynMWrong22(2, 2); + Dune::DynamicMatrix dynMWrong33(3, 3); + populateMatrix(dynM, 2, 3); + populateMatrix(dynMWrong11, 1, 1); + populateMatrix(dynMWrong22, 2, 2); + populateMatrix(dynMWrong33, 3, 3); + + Dune::DiagonalMatrix const diagMWrong1 = {1}; + Dune::DiagonalMatrix const diagMWrong2 = {1, 2}; + Dune::DiagonalMatrix const diagMWrong3 = {1, 2, 3}; + + bool passed = true; + + // class: FieldMatrix + { + using M = Dune::FieldMatrix; + + // Assignment + { + M fieldT; + fieldT = fieldM; + if (!identicalContents(fieldT, fieldM)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + } + { + M fieldT; + fieldT = dynM; + if (!identicalContents(fieldT, dynM)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + } + { + M fieldT; + fieldT = constant; + } + + // Copy construction + { + M const fieldT = fieldM; + if (!identicalContents(fieldT, fieldM)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + } + { + M const fieldT = dynM; + if (!identicalContents(fieldT, dynM)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + } + { + DUNE_UNUSED M const fieldT = constant; + } + } + + // class: DynamicMatrix + { + using M = Dune::DynamicMatrix; + + // Assignment + { + M dynT; + dynT = fieldM; + if (!identicalContents(dynT, fieldM)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + dynT = fieldMWrong11; + if (!identicalContents(dynT, fieldMWrong11)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + } + { + M dynT; + dynT = dynM; + if (!identicalContents(dynT, dynM)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + } + { + M dynT; + dynT = constant; + } + + // Copy construction + { + M const dynT = fieldM; + if (!identicalContents(dynT, fieldM)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + } + { + M const dynT = dynM; + if (!identicalContents(dynT, dynM)) { + std::cout << "FAIL: Content mismatch on line: " << __LINE__ + << std::endl; + passed = false; + } + } + } + + // Assignment from other classes + { + using M = Dune::FieldMatrix; + Dune::DiagonalMatrix diagM({1, 2, 3}); + { DUNE_UNUSED M const fieldT = diagM; } + { + M fieldT; + fieldT = diagM; + } + } + { + using M = Dune::DynamicMatrix; + Dune::DiagonalMatrix diagM({1, 2, 3}); + { DUNE_UNUSED M const dynT = diagM; } + { + M dynT; + dynT = diagM; + } + } + + // Invalid assignments + { + using M = Dune::FieldMatrix; +#ifdef FAILURE0 + { + // Should fail at compile-time + M fieldT; + fieldT = fieldMWrong11; + } +#endif +#ifdef FAILURE1 + { + // Should fail at compile-time + M fieldT; + fieldT = fieldMWrong22; + } +#endif +#ifdef FAILURE2 + { + // Should fail at compile-time + M fieldT; + fieldT = fieldMWrong33; + } +#endif + try { + // Should fail at run-time with RangeError + M fieldT; + fieldT = dynMWrong11; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + // Should fail at run-time with RangeError + M fieldT; + fieldT = dynMWrong22; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + // Should fail at run-time with RangeError + M fieldT; + fieldT = dynMWrong33; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + + try { + // Should fail at run-time with RangeError + // Note: this could be made to fail at compile-time already if + // we further specialised DenseMatrixAssigner to (FieldMatrix, + // DiagonalMatrix) + M fieldT; + fieldT = diagMWrong1; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + // Should fail at run-time with RangeError + // Note: this could be made to fail at compile-time already if + // we further specialised DenseMatrixAssigner to (FieldMatrix, + // DiagonalMatrix) + M fieldT; + fieldT = diagMWrong2; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + // Should fail at run-time with RangeError + // Note: this could be made to fail at compile-time already if + // we further specialised DenseMatrixAssigner to (FieldMatrix, + // DiagonalMatrix) + M fieldT; + fieldT = diagMWrong3; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + } + + // Invalid copy construction + { + using M = Dune::FieldMatrix; +#ifdef FAILURE3 + { + // Should fail at compile-time + DUNE_UNUSED M const fieldT = fieldMWrong11; + } +#endif +#ifdef FAILURE4 + { + // Should fail at compile-time + DUNE_UNUSED M const fieldT = fieldMWrong22; + } +#endif +#ifdef FAILURE5 + { + // Should fail at compile-time + DUNE_UNUSED M const fieldT = fieldMWrong33; + } +#endif + try { + // Should fail at run-time with RangeError + DUNE_UNUSED M const fieldT = dynMWrong11; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + // Should fail at run-time with RangeError + DUNE_UNUSED M const fieldT = dynMWrong22; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + try { + // Should fail at run-time with RangeError + DUNE_UNUSED M const fieldT = dynMWrong33; + std::cout << "(line " << __LINE__ << ") Error: No exception thrown." + << std::endl; + passed = false; + } catch (Dune::RangeError) { + std::cout << "(line " << __LINE__ + << ") All good: Exception thrown as expected." << std::endl; + } + } + { +#ifdef FAILURE6 + using M = Dune::DynamicMatrix; + { + // Should fail at compile-time + DUNE_UNUSED M const dynT = constant; + } +#endif + } + std::cout << std::endl; + return passed; +} + +int main() { + bool passed = true; + passed = passed && run(); + passed = passed && run>(); +#ifdef HAVE_GMP + passed = passed && run>(); +#endif + return passed ? 0 : 1; +} diff -Nru dune-common-2.2.1/dune/common/test/densevectortest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/densevectortest.cc --- dune-common-2.2.1/dune/common/test/densevectortest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/densevectortest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,59 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include +#include +#include + +class MyVector; + +namespace Dune +{ + template< > + struct DenseMatVecTraits< MyVector > + { + typedef MyVector derived_type; + typedef double value_type; + typedef unsigned int size_type; + }; +} + +class MyVector : public Dune::DenseVector< MyVector > +{ +public: + MyVector ( unsigned int size, double v = 0 ) + : data_( size, v ) {} + + unsigned int size () const { return data_.size(); } + + double& operator[] ( unsigned int i ) { return data_[ i ]; } + const double& operator[] ( unsigned int i ) const { return data_[ i ]; } +protected: + std::vector< double > data_; +}; + + +int main() +{ + try + { + unsigned int n = 15; + MyVector v( n, 1 ); + if( ( v.end() - v.begin() ) < 0 ) + DUNE_THROW(Dune::Exception, "Negative value reported for end() - begin()" ); + + return 0; + } catch (Dune::Exception& e) { + std::cerr << e << std::endl; + return 1; + } catch (...) { + std::cerr << "Generic exception!" << std::endl; + return 2; + } +} diff -Nru dune-common-2.2.1/dune/common/test/diagonalmatrixtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/diagonalmatrixtest.cc --- dune-common-2.2.1/dune/common/test/diagonalmatrixtest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/diagonalmatrixtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,96 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef DUNE_FMatrix_WITH_CHECKING +#define DUNE_FMatrix_WITH_CHECKING +#endif + +#include +#include + +#include +#include +#include +#include + +#include "checkmatrixinterface.hh" + +using namespace Dune; + +template +void test_matrix() +{ + typedef typename DiagonalMatrix::size_type size_type DUNE_UNUSED; + + DiagonalMatrix A(1); + FieldVector f; + FieldVector v; + + // assign matrix + A=2; + + // assign vector + f = 1; + v = 2; + + // matrix vector product + A.umv(v,f); + + + // test norms + A.frobenius_norm(); + A.frobenius_norm2(); + A.infinity_norm(); + A.infinity_norm_real(); + + std::sort(v.begin(), v.end()); + + // print matrix + std::cout << A << std::endl; + // print vector + std::cout << f << std::endl; + + // assign to FieldMatrix + DUNE_UNUSED FieldMatrix AFM = FieldMatrix(A); + DUNE_UNUSED FieldMatrix AFM2 = A; + DUNE_UNUSED FieldMatrix AFM3; + AFM3 = A; +} + +template +void test_interface() +{ + typedef CheckMatrixInterface::UseFieldVector Traits; + typedef Dune::DiagonalMatrix DiagonalMatrix; + + const DiagonalMatrix A(1); + checkMatrixInterface< DiagonalMatrix >( A ); + checkMatrixInterface< DiagonalMatrix, Traits >( A ); +} + +void test_initialisation() +{ + DUNE_UNUSED Dune::DiagonalMatrix const b = { 1, 2 }; + + assert(b.diagonal(0) == 1); + assert(b.diagonal(1) == 2); +} + +int main() +{ + try { + test_matrix(); + test_interface(); + test_matrix(); + test_interface(); + test_matrix(); + test_interface(); + } + catch (Dune::Exception & e) + { + std::cerr << "Exception: " << e << std::endl; + } +} diff -Nru dune-common-2.2.1/dune/common/test/dummyiterator.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/test/dummyiterator.hh --- dune-common-2.2.1/dune/common/test/dummyiterator.hh 2009-10-27 22:47:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/dummyiterator.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,19 +1,19 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_COMMON_DUMMYITERATOR_HH #define DUNE_COMMON_DUMMYITERATOR_HH #include +#include #include -#include template class dummyiterator : public Dune::BidirectionalIteratorFacade, T, T&, - std::ptrdiff_t> + std::ptrdiff_t> { - friend class dummyiterator::type>; + friend class dummyiterator::type>; T *value; @@ -24,8 +24,8 @@ template dummyiterator - ( const dummyiterator& o, - typename Dune::enable_if::exists>::type* = 0) + ( const dummyiterator& o, + typename std::enable_if::value>::type* = 0) : value(o.value) {} diff -Nru dune-common-2.2.1/dune/common/test/dynmatrixtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/dynmatrixtest.cc --- dune-common-2.2.1/dune/common/test/dynmatrixtest.cc 2012-04-05 12:19:01.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/dynmatrixtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,9 +1,12 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#define DUNE_ISTL_WITH_CHECKING +// Activate checking +#ifndef DUNE_FMatrix_WITH_CHECKING +#define DUNE_FMatrix_WITH_CHECKING +#endif #include #include #include @@ -11,58 +14,53 @@ #include #include +#include "checkmatrixinterface.hh" + using namespace Dune; template -int test_invert_solve(T A_data[n*n], T inv_data[n*n], - T x_data[n], T b_data[n]) +int test_invert_solve(Dune::DynamicMatrix &A, + Dune::DynamicMatrix &inv, + Dune::FieldVector &x, + Dune::FieldVector &b) { int ret=0; std::cout <<"Checking inversion of:"< A(n,n), inv(n,n), calced_inv(n,n); - FieldVector x, b, calced_x; - - for(size_t i =0; i < n; ++i){ - x[i]=x_data[i]; - b[i]=b_data[i]; - for(size_t j=0; j calced_inv(n,n); + FieldVector calced_x; + std::cout< prod = A; prod.rightmultiply(inv); for (size_t i=0; i 1e-6) { - std::cerr<<"Given inverse wrong"< copy(A); A.invert(); - + calced_inv = A; A-=inv; - + double singthres = FMatrixPrecision<>::singular_limit()*10; for(size_t i =0; i < n; ++i) for(size_t j=0; j singthres){ - std::cerr<<"calculated inverse wrong at ("<singthres) { + std::cerr<<"calculated inverse wrong at ("< xcopy(calced_x); @@ -91,12 +89,12 @@ equal=true; for(size_t i =0; i < n; ++i) - if(std::abs(xcopy[i])>singthres){ - std::cerr<<"calculated isolution wrong at ("<singthres) { + std::cerr<<"calculated isolution wrong at ("<(A_data, inv_data, x, b); - - double A_data0[9] = {-0.5, 0, -0.25, 0.5, 0, -0.25, 0, 0.5, 0}; - double inv_data0[9] = {-1, 1, 0, 0, 0, 2, -2, -2, 0}; - double b0[3] = {32,75,201}; - double x0[3] = {43, 402, -214}; - - ret += test_invert_solve(A_data0, inv_data0, x0, b0); - - double A_data1[9] = {0, 1, 0, 1, 0, 0, 0, 0, 1}; - double b1[3] = {0,1,2}; - double x1[3] = {1,0,2}; - - ret += test_invert_solve(A_data1, A_data1, x1, b1); - - double A_data2[9] ={3, 1, 6, 2, 1, 3, 1, 1, 1}; - double inv_data2[9] ={-2, 5, -3, 1, -3, 3, 1, -2, 1}; - double b2[3] = {2, 7, 4}; - double x2[3] = {19,-7,-8}; - - return ret + test_invert_solve(A_data2, inv_data2, x2, b2); + int ret = 0; + + using DM = Dune::DynamicMatrix; + using FV = Dune::FieldVector; + + DM A = {{1, 5, 7}, {2, 14, 15}, {4, 40, 39}}; + DM inv = {{-9.0 / 4, 85.0 / 24, -23.0 / 24}, + {-3.0 / 4, 11.0 / 24, -1.0 / 24}, + {1, -5.0 / 6, 1.0 / 6}}; + FV b = {32, 75, 201}; + FV x = {1, 2, 3}; + + ret += test_invert_solve(A, inv, x, b); + + DM A0 = {{-0.5, 0, -0.25}, {0.5, 0, -0.25}, {0, 0.5, 0}}; + DM inv0 = {{-1, 1, 0}, {0, 0, 2}, {-2, -2, 0}}; + FV b0 = {32, 75, 201}; + FV x0 = {43, 402, -214}; + + ret += test_invert_solve(A0, inv0, x0, b0); + + DM A1 = {{0, 1, 0}, {1, 0, 0}, {0, 0, 1}}; + FV b1 = {0, 1, 2}; + FV x1 = {1, 0, 2}; + + ret += test_invert_solve(A1, A1, x1, b1); + + DM A2 = {{3, 1, 6}, {2, 1, 3}, {1, 1, 1}}; + DM inv2 = {{-2, 5, -3}, {1, -3, 3}, {1, -2, 1}}; + FV b2 = {2, 7, 4}; + FV x2 = {19, -7, -8}; + + return ret + test_invert_solve(A2, inv2, x2, b2); } template -void test_mult(DynamicMatrix& A, +void test_mult(DynamicMatrix& A, X& v, Y& f) { // test the various matrix-vector products @@ -155,17 +158,17 @@ A.mmv(v,f); A.mmtv(f,v); A.mmhv(f,v); - A.usmv(0.5,v,f); - A.usmtv(0.5,f,v); - A.usmhv(0.5,f,v); + A.usmv((K)0.5,v,f); + A.usmtv((K)0.5,f,v); + A.usmhv((K)0.5,f,v); } - - + + template void test_matrix() { typedef typename DynamicMatrix::size_type size_type; - + DynamicMatrix A(n,m); DynamicVector f(n); DynamicVector v(m); @@ -188,10 +191,10 @@ (*cit) *= 2; } } - + // assign vector f = 1; - + // random access vector for (size_type i=0; i res2(n,0); DynamicVector res1(n); DynamicVector b(m,1); - A.mv(b, res1); + A.mv(b, res1); A.umv(b, res2); - if( (res1 - res2).two_norm() > 1e-12 ) + if( (res1 - res2).two_norm() > 1e-12 ) { DUNE_THROW(FMatrixError,"mv and umv are not doing the same!"); } @@ -244,21 +247,21 @@ test_mult(A, v0, f ); } - { - std::vector v1( m ) ; - std::vector f1( n, 1 ) ; - // random access vector - for (size_type i=0; i v1( m ) ; + // std::vector f1( n, 1 ) ; + // // random access vector + // for (size_type i=0; i= 0 ); @@ -267,7 +270,7 @@ assert( A.infinity_norm_real() >= 0); std::sort(v.begin(), v.end()); - + // print matrix std::cout << A << std::endl; // print vector @@ -295,11 +298,11 @@ DUNE_THROW(FMatrixError,"Axpy test failed!"); } { - DynamicMatrix A(n,n+1); - for(size_type i=0; i& Aref DUNE_UNUSED = A; + DynamicMatrix A2(n,n+1); + for(size_type i=0; i& Aref DUNE_UNUSED = A2; DynamicMatrix B(n+1,n+1); @@ -354,43 +357,46 @@ int test_determinant() { - int ret = 0; + int ret = 0; - DynamicMatrix B(4,4); - B[0][0] = 3.0; B[0][1] = 0.0; B[0][2] = 1.0; B[0][3] = 0.0; - B[1][0] = -1.0; B[1][1] = 3.0; B[1][2] = 0.0; B[1][3] = 0.0; - B[2][0] = -3.0; B[2][1] = 0.0; B[2][2] = -1.0; B[2][3] = 2.0; - B[3][0] = 0.0; B[3][1] = -1.0; B[3][2] = 0.0; B[3][3] = 1.0; - if (std::abs(B.determinant() + 2.0) > 1e-12) - { - std::cerr << "Determinant 1 test failed" << std::endl; - ++ret; - } + DynamicMatrix B(4,4); + B[0][0] = 3.0; B[0][1] = 0.0; B[0][2] = 1.0; B[0][3] = 0.0; + B[1][0] = -1.0; B[1][1] = 3.0; B[1][2] = 0.0; B[1][3] = 0.0; + B[2][0] = -3.0; B[2][1] = 0.0; B[2][2] = -1.0; B[2][3] = 2.0; + B[3][0] = 0.0; B[3][1] = -1.0; B[3][2] = 0.0; B[3][3] = 1.0; + if (std::abs(B.determinant() + 2.0) > 1e-12) + { + std::cerr << "Determinant 1 test failed" << std::endl; + ++ret; + } - B[0][0] = 3.0; B[0][1] = 0.0; B[0][2] = 1.0; B[0][3] = 0.0; - B[1][0] = -1.0; B[1][1] = 3.0; B[1][2] = 0.0; B[1][3] = 0.0; - B[2][0] = -3.0; B[2][1] = 0.0; B[2][2] = -1.0; B[2][3] = 2.0; - B[3][0] = -1.0; B[3][1] = 3.0; B[3][2] = 0.0; B[3][3] = 2.0; - if (B.determinant() != 0.0) - { - std::cerr << "Determinant 2 test failed" << std::endl; - ++ret; - } + B[0][0] = 3.0; B[0][1] = 0.0; B[0][2] = 1.0; B[0][3] = 0.0; + B[1][0] = -1.0; B[1][1] = 3.0; B[1][2] = 0.0; B[1][3] = 0.0; + B[2][0] = -3.0; B[2][1] = 0.0; B[2][2] = -1.0; B[2][3] = 2.0; + B[3][0] = -1.0; B[3][1] = 3.0; B[3][2] = 0.0; B[3][3] = 2.0; + if (B.determinant() != 0.0) + { + std::cerr << "Determinant 2 test failed" << std::endl; + ++ret; + } - return 0; + return 0; } int main() { try { + Dune::DynamicMatrix A( 5, 5 ); + checkMatrixInterface( A ); + test_matrix(); test_matrix(); test_matrix(); test_matrix(); test_determinant(); - Dune::DynamicMatrix A(34, 34, 1e-15); - for (int i=0; i<34; i++) A[i][i] = 1; - A.invert(); + Dune::DynamicMatrix B(34, 34, 1e-15); + for (int i=0; i<34; i++) B[i][i] = 1; + B.invert(); return test_invert_solve(); } catch (Dune::Exception & e) diff -Nru dune-common-2.2.1/dune/common/test/dynvectortest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/dynvectortest.cc --- dune-common-2.2.1/dune/common/test/dynvectortest.cc 2012-04-05 12:19:01.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/dynvectortest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,9 +1,14 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif + +#include + #include #include -#include +#include using Dune::DynamicVector; @@ -14,7 +19,7 @@ DynamicVector w(d,2); DynamicVector z(d,2); bool b DUNE_UNUSED; - + // Test whether the norm methods compile (w+v).two_norm(); (w+v).two_norm2(); @@ -39,7 +44,7 @@ // test scalar product, axpy a = v * w; z = v.axpy(a,w); - + // test comparison b = (w != v); b = (w == v); @@ -54,7 +59,7 @@ } s >> w; assert(v == w); - + } int main() diff -Nru dune-common-2.2.1/dune/common/test/eigenvaluestest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/eigenvaluestest.cc --- dune-common-2.2.1/dune/common/test/eigenvaluestest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/eigenvaluestest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,138 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include +#include + +using namespace Dune; + +#if HAVE_LAPACK +/** \brief Test the eigenvalue code with the Rosser test matrix + + This matrix was a challenge for many matrix eigenvalue + algorithms. But the Francis QR algorithm, as perfected by + Wilkinson and implemented in EISPACK, has no trouble with it. The + matrix is 8-by-8 with integer elements. It has: + + * A double eigenvalue + * Three nearly equal eigenvalues + * Dominant eigenvalues of opposite sign + * A zero eigenvalue + * A small, nonzero eigenvalue + +*/ +template +void testRosserMatrix() +{ + DynamicMatrix A = { + { 611, 196, -192, 407, -8, -52, -49, 29 }, + { 196, 899, 113, -192, -71, -43, -8, -44 }, + { -192, 113, 899, 196, 61, 49, 8, 52 }, + { 407, -192, 196, 611, 8, 44, 59, -23 }, + { -8, -71, 61, 8, 411, -599, 208, 208 }, + { -52, -43, 49, 44, -599, 411, 208, 208 }, + { -49, -8, 8, 59, 208, 208, 99, -911 }, + { 29, -44, 52, -23, 208, 208, -911, 99} + }; + + // compute eigenvalues + DynamicVector > eigenComplex; + DynamicMatrixHelp::eigenValuesNonSym(A, eigenComplex); + + // test results + /* + reference solution computed with octave 3.2 + + > format long e + > eig(rosser()) + + */ + std::vector reference = { + -1.02004901843000e+03, + -4.14362871168386e-14, + 9.80486407214362e-02, + 1.00000000000000e+03, + 1.00000000000000e+03, + 1.01990195135928e+03, + 1.02000000000000e+03, + 1.02004901843000e+03 + }; + + std::vector eigenRealParts(8); + for (int i=0; i<8; i++) + eigenRealParts[i] = std::real(eigenComplex[i]); + + std::sort(eigenRealParts.begin(), eigenRealParts.end()); + + for (int i=0; i<8; i++) + { + if (std::fabs(std::imag(eigenComplex[i])) > 1e-10) + DUNE_THROW(MathError, "Symmetric matrix has complex eigenvalue"); + + if( std::fabs(reference[i] - eigenRealParts[i]) > 1e-10 ) + DUNE_THROW(MathError,"error computing eigenvalues"); + } + + std::cout << "Eigenvalues of Rosser matrix: " << eigenComplex << std::endl; +} +#endif // HAVE_LAPACK + +template +void testSymmetricFieldMatrix() +{ + int numberOfTestMatrices = 10; + + for (int i=0; i testMatrix; + for (int j=0; j eigenValues; + FMatrixHelp::eigenValues(testMatrix, eigenValues); + + // Make sure the compute numbers really are the eigenvalues + for (int j=0; j copy = testMatrix; + for (int k=0; k 1e-8) + DUNE_THROW(MathError, "Value computed by FMatrixHelp::eigenValues is not an eigenvalue"); + } + + // Make sure the eigenvalues are in ascending order + for (int j=0; j eigenValues[j+1] + 1e-10) + DUNE_THROW(MathError, "Values computed by FMatrixHelp::eigenValues are not in ascending order"); + } +} + +int main() try +{ +#if HAVE_LAPACK + testRosserMatrix(); +#else + std::cout << "WARNING: eigenvaluetest needs LAPACK, test disabled" << std::endl; +#endif // HAVE_LAPACK + + testSymmetricFieldMatrix(); + testSymmetricFieldMatrix(); + + return 0; +} catch (Exception exception) +{ + std::cerr << exception << std::endl; + return 1; +} diff -Nru dune-common-2.2.1/dune/common/test/enumsettest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/enumsettest.cc --- dune-common-2.2.1/dune/common/test/enumsettest.cc 2010-09-08 14:51:38.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/enumsettest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,14 +1,16 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include +#include +#include int main() { using namespace Dune; std::cout<,EnumItem,int>::contains(1)<< - " "<,EnumItem,int>::contains(2)<< - " "<,EnumItem,int>,EnumItem,int>::contains(3)<< - " "<::contains(3)<,EnumItem,int>::contains(2)<< + " "<,EnumItem,int>,EnumItem,int>::contains(3)<< + " "<::contains(3)< exrpressionentry - - FlatColIterator does not work if Matrix is mutable - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -//#include -//#include -#include - -Indent INDENT; - -void test_fvector() -{ - typedef Dune::FieldVector VB; - VB v1(1); - VB v2(2); - - typedef Dune::ExprTmpl::ConstRef RVB; - VB v = 0.5 * (v1 + v2 * 2) + 3 * v1 - v2; - std::cout << " 0.5 * ( " << v1 << " + " << v2 << " * 2) + 3 * " << v1 << " - " << v2 << std::endl; -} - -void test_blockvector() -{ - Dune::FieldVector v(10); - typedef Dune::FieldVector VB; - typedef Dune::BlockVector BV; - - const int sz = 3; - BV bv1(sz), bv2(sz); - bv1 = 1; - bv2 = 0; - bv2[1][0]=1; - bv2[1][1]=2; - - BV bv(sz); - bv = -17; - printvector (std::cout, bv, "bv", "r"); -// bv.emptyClone(bv1); - std::cout << "Assingn from ConstRef\n"; - bv = 2 * (bv1 + bv2); - bv -= 1; - - printvector (std::cout, bv1, "bv1", "r"); - printvector (std::cout, bv2, "bv2", "r"); - printvector (std::cout, bv, "bv", "r"); - -} - -void test_blockblockvector() -{ - const int bs = 2; - const int sz = 3; - typedef Dune::FieldVector VB; - typedef Dune::BlockVector BV; - typedef Dune::BlockVector BBV; - typedef Dune::ExprTmpl::ConstRef RBV; - BV bv1(sz), bv2(sz); - bv1 = 1; - bv2 = 0; - bv2[1][0]=1; - bv2[1][1]=2; - - Dune::ExprTmpl::ConstRef rbv1(bv1); - Dune::ExprTmpl::ConstRef rbv2(bv2); - - BBV bbv(2); - bbv[0].resize(bv1.N()); - bbv[0] = Dune::ExprTmpl::Expression(rbv1); - bbv[1].resize(bv2.N()); - bbv[1] = Dune::ExprTmpl::Expression(rbv2); - - Dune::Timer stopwatch; - stopwatch.reset(); - for (int i=0; i<10; i++) bbv *= 2; - std::cout << "Time bbv*2: " << stopwatch.elapsed() << std::endl; -#ifndef NOPRINT -// Dune::FlatIterator fit(bbv.begin()); -// Dune::FlatIterator fend(bbv.end()); -// int index = 0; -// for(;fit!=fend;++fit) -// { -// BBV::field_type x; -// x = *fit; -// std::cout << index << "\t" << x << std::endl; -// index++; -// } - printvector (std::cout, bv1, "bv1", "r"); - printvector (std::cout, bv2, "bv1", "r"); - printvector (std::cout, bbv, "bbv", "r"); -#endif - std::cout << "infinity_norm(bbv)=" << infinity_norm(bbv) << std::endl; - std::cout << "two_norm(bbv)=" << two_norm(bbv) << std::endl; - std::cout << "bbv.two_norm()=" << bbv.two_norm() << std::endl; - std::cout << "two_norm2(bbv)=" << two_norm2(bbv) << std::endl; - std::cout << "one_norm(bbv)=" << one_norm(bbv) << std::endl; -} - -// namespace Dune { - -// namespace ExprTmpl { - -// template -// class MatrixMulVector< FieldMatrix, -// BCRSMatrix< FieldMatrix >, -// BlockVector< FieldVector > > -// { -// public: -// typedef BCRSMatrix< FieldMatrix > Mat; -// typedef BlockVector< FieldVector > Vec; -// typedef typename -// BlockTypeN, -// MyDepth,Mat>::value-1>::type -// ParentBlockType; -// /* constructor */ -// MatrixMulVector(const Mat & _A, const Vec & _v, int* _DUNE_TEST_M, -// const ParentBlockType & _parent) : -// parent(_parent), M(_DUNE_TEST_M), A(_A), v(_v ) -// { -// int parent_i = M[0]; -// typename Mat::ConstColIterator it = A[parent_i].begin(); -// typename Mat::ConstColIterator end = A[parent_i].end(); -// tmp = 0; -// for (; it!=end; ++it) -// { -// it->umv(tmp,v[it.index()]); -// } -// }; -// K operator[] (int i) const { -// return tmp[i]; -// } -// int N() const { iN; }; -// const ParentBlockType & parent; -// private: -// FieldVector tmp; -// mutable int* M; -// const Mat & A; -// const Vec & v; -// }; - -// } // NS ExpreTmpl - -// } // NS Dune - -//template -template -void test_matrix() -{ - std::cout << "test_matrix<" << BN << ", " << BM << ", " - << N << ", " << M << ">\n"; - - typedef double matvec_t; - typedef Dune::FieldVector LVB; - typedef Dune::FieldVector VB; - typedef Dune::FieldMatrix MB; - typedef Dune::BlockVector LeftVector; - typedef Dune::BlockVector Vector; - typedef Dune::BCRSMatrix Matrix; - - LVB a(0); - VB b(2); - MB _DUNE_TEST_M(1); - _DUNE_TEST_M[1][1] = 3; - - // a += M * b - _DUNE_TEST_M.umv(b,a); - -#ifndef NOPRINT - printmatrix (std::cout, _DUNE_TEST_M, "Matrix", "r"); - printvector (std::cout, a, "Vector", "r"); -#endif - - // a = M * b -#if 0 - a = _DUNE_TEST_M*b; -#endif - -#ifndef NOPRINT - printvector (std::cout, a, "Vector", "r"); -#endif - - Matrix A(N,M,Matrix::row_wise); - typename Matrix::CreateIterator i=A.createbegin(); - typename Matrix::CreateIterator end=A.createend(); - std::cout << "Building matrix structure\n"; - // build up the matrix structure - int c=0; - for (; i!=end; ++i) - { - // insert a non zero entry for myself - i.insert(c); - // insert index M-1 - i.insert(M-1); - c++; - } - std::cout << "...done\n"; - -#ifndef NOPRINT - std::cout << "Matrix coldim=" << A.coldim() << std::endl; - std::cout << "Matrix rowdim=" << A.rowdim() << std::endl; - std::cout << "Matrix N=" << A.M() << std::endl; - std::cout << "Matrix M=" << A.N() << std::endl; - - std::cout << "Assembling matrix\n"; - typename Matrix::Iterator rit=A.begin(); - typename Matrix::Iterator rend=A.end(); - for (;rit!=rend; ++rit) - { - typename Matrix::ColIterator cit=rit->begin(); - typename Matrix::ColIterator cend=rit->end(); - for (;cit!=cend;++cit) - { -// *rit = rit.index(); - *cit = 10*cit.index()+rit.index(); - } - } - std::cout << "...done\n"; - - printmatrix (std::cout, A, "Matrix", "r"); -#endif - - LeftVector v(N); - LeftVector v2(N); - v = 0; - Vector x(M); - x = 1; - Dune::FlatIterator fit = x.begin(); - Dune::FlatIterator fend = x.end(); - c = 0; - for (;fit!=fend; ++fit) - *fit=c++; - - Dune::Timer stopwatch; - stopwatch.reset(); - A.umv(x,v); - std::cout << "Time umv: " << stopwatch.elapsed() << std::endl; - - using namespace Dune; -#ifndef NOPRINT - printvector (std::cout, x, "Vector X", "r"); - printvector (std::cout, v, "Vector", "r"); -#endif - - v2 = 0; - stopwatch.reset(); - v2 += A * x; - std::cout << "Time v2+=A*x: " << stopwatch.elapsed() << std::endl; -#ifndef NOPRINT - printvector (std::cout, v2, "Vector2", "r"); -#endif - -#ifndef NOPRINT -// int rowIndex[]={1}; -// FlatColIterator it(A[2].begin(),rowIndex); -// for (int i=0; i<5; i++) -// { -// std::cout << *it << " "; -// ++it; -// } -// std::cout << std::endl; -#endif - std::cout << std::endl; -} - -void test_norm() -{ - Dune::FieldVector a,b; - double c; - c = (a-b).two_norm(); - c = two_norm(a-b); -} - -void test_sproduct() -{ - Dune::FieldVector v(10); - typedef Dune::FieldVector VB; - typedef Dune::BlockVector BV; - - const int sz = 3; - BV bv1(sz), bv2(sz); - bv1 = 1; - bv2 = 0; - bv2[1][0]=1; - bv2[1][1]=2; - - double x; - x = bv1[0] * bv2[0]; - x = bv1 * bv2; -} - -int main() -{ - // Dune::dvverb.attach(std::cout); - try - { -// test_fvector(); -// test_blockvector(); - test_norm(); - test_sproduct(); - test_blockblockvector(); - test_matrix<2,3,3,4>(); -#ifdef NOPRINT - test_matrix<3,6,400000,500000>(); - test_matrix<6,3,400000,500000>(); - test_matrix<30,60,4000,5000>(); - test_matrix<150,150,500,4000>(); - test_matrix<150,150,1000,2000>(); -#endif -// test_matrix<150,150,2000,1000>(); // fails in fmeta_something -// test_matrix<150,150,4000,500>(); // fails in fmeta_something - } - catch (Dune::Exception & e) - { - std::cout << e << std::endl; - } - return (0); -} diff -Nru dune-common-2.2.1/dune/common/test/fassigntest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/fassigntest.cc --- dune-common-2.2.1/dune/common/test/fassigntest.cc 2010-03-12 07:40:59.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/fassigntest.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -#include - -#include -#include -#include - -using namespace Dune; - -int main(int argc, char** argv) try -{ -Dune::FieldVector pos; - -pos <<= 1, 0, 0; - -} catch (Exception e) { - -std::cout << e << std::endl; - -} diff -Nru dune-common-2.2.1/dune/common/test/fmatrixtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/fmatrixtest.cc --- dune-common-2.2.1/dune/common/test/fmatrixtest.cc 2013-02-26 12:26:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/fmatrixtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,68 +1,67 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#define DUNE_ISTL_WITH_CHECKING +// Activate checking. +#ifndef DUNE_FMatrix_WITH_CHECKING +#define DUNE_FMatrix_WITH_CHECKING +#endif #include -#include #include #include #include #include +#include +#include + +#include "checkmatrixinterface.hh" using namespace Dune; template -int test_invert_solve(T A_data[n*n], T inv_data[n*n], - T x_data[n], T b_data[n]) +int test_invert_solve(Dune::FieldMatrix &A, + Dune::FieldMatrix &inv, + Dune::FieldVector &x, + Dune::FieldVector &b) { int ret=0; std::cout <<"Checking inversion of:"< A, inv, calced_inv; - FieldVector x, b, calced_x; - - for(size_t i =0; i < n; ++i){ - x[i]=x_data[i]; - b[i]=b_data[i]; - for(size_t j=0; j calced_inv; + FieldVector calced_x; + std::cout< prod = A; prod.rightmultiply(inv); for (size_t i=0; i 1e-6) { - std::cerr<<"Given inverse wrong"< copy(A); A.invert(); - + calced_inv = A; A-=inv; - + double singthres = FMatrixPrecision<>::singular_limit()*10; for(size_t i =0; i < n; ++i) for(size_t j=0; j singthres){ - std::cerr<<"calculated inverse wrong at ("<singthres) { + std::cerr<<"calculated inverse wrong at ("< xcopy(calced_x); @@ -91,12 +90,12 @@ equal=true; for(size_t i =0; i < n; ++i) - if(std::abs(xcopy[i])>singthres){ - std::cerr<<"calculated isolution wrong at ("<singthres) { + std::cerr<<"calculated isolution wrong at ("<(A_data, inv_data, x, b); - - double A_data0[9] = {-0.5, 0, -0.25, 0.5, 0, -0.25, 0, 0.5, 0}; - double inv_data0[9] = {-1, 1, 0, 0, 0, 2, -2, -2, 0}; - double b0[3] = {32,75,201}; - double x0[3] = {43, 402, -214}; - - ret += test_invert_solve(A_data0, inv_data0, x0, b0); - - double A_data1[9] = {0, 1, 0, 1, 0, 0, 0, 0, 1}; - double b1[3] = {0,1,2}; - double x1[3] = {1,0,2}; - - ret += test_invert_solve(A_data1, A_data1, x1, b1); - - double A_data2[9] ={3, 1, 6, 2, 1, 3, 1, 1, 1}; - double inv_data2[9] ={-2, 5, -3, 1, -3, 3, 1, -2, 1}; - double b2[3] = {2, 7, 4}; - double x2[3] = {19,-7,-8}; - - return ret + test_invert_solve(A_data2, inv_data2, x2, b2); -} - -template -void test_mult(FieldMatrix& A, - X& v, Y& f) + int ret = 0; + + using FM = Dune::FieldMatrix; + using FV = Dune::FieldVector; + + FM A_data = {{1, 5, 7}, {2, 14, 15}, {4, 40, 39}}; + FM inv_data = {{-9.0 / 4, 85.0 / 24, -23.0 / 24}, + {-3.0 / 4, 11.0 / 24, -1.0 / 24}, + {1, -5.0 / 6, 1.0 / 6}}; + FV b = {32, 75, 201}; + FV x = {1, 2, 3}; + ret += test_invert_solve(A_data, inv_data, x, b); + + FM A_data0 = {{-0.5, 0, -0.25}, {0.5, 0, -0.25}, {0, 0.5, 0}}; + FM inv_data0 = {{-1, 1, 0}, {0, 0, 2}, {-2, -2, 0}}; + FV b0 = {32, 75, 201}; + FV x0 = {43, 402, -214}; + ret += test_invert_solve(A_data0, inv_data0, x0, b0); + + FM A_data1 = {{0, 1, 0}, {1, 0, 0}, {0, 0, 1}}; + FV b1 = {0, 1, 2}; + FV x1 = {1, 0, 2}; + ret += test_invert_solve(A_data1, A_data1, x1, b1); + + FM A_data2 = {{3, 1, 6}, {2, 1, 3}, {1, 1, 1}}; + FM inv_data2 = {{-2, 5, -3}, {1, -3, 3}, {1, -2, 1}}; + FV b2 = {2, 7, 4}; + FV x2 = {19, -7, -8}; + return ret + test_invert_solve(A_data2, inv_data2, x2, b2); +} + +template +void test_mult(FieldMatrix& A, + X& v, Y& f, XT& vT, YT& fT) { // test the various matrix-vector products A.mv(v,f); - A.mtv(f,v); + A.mtv(fT,vT); A.umv(v,f); - A.umtv(f,v); - A.umhv(f,v); + A.umtv(fT,vT); + A.umhv(fT,vT); A.mmv(v,f); - A.mmtv(f,v); - A.mmhv(f,v); - A.usmv(0.5,v,f); - A.usmtv(0.5,f,v); - A.usmhv(0.5,f,v); -} - - -template + A.mmtv(fT,vT); + A.mmhv(fT,vT); + using S = typename FieldTraits::field_type; + using S2 = typename FieldTraits::field_type; + S scalar = (S)(0.5); + S2 scalar2 = (S2)(0.5); + A.usmv(scalar,v,f); + A.usmtv(scalar2,fT,vT); + A.usmhv(scalar2,fT,vT); +} + +template void test_matrix() { typedef typename FieldMatrix::size_type size_type; - + FieldMatrix A; - FieldVector f; - FieldVector v; + FieldVector v; + FieldVector f; // assign matrix A=K(); @@ -177,27 +180,27 @@ for (size_type j=0; j::RowIterator rit = A.begin(); + auto rit = A.begin(); for (; rit!=A.end(); ++rit) { rit.index(); - typename FieldMatrix::ColIterator cit = rit->begin(); + auto cit = rit->begin(); for (; cit!=rit->end(); ++cit) { cit.index(); (*cit) *= 2; } } - + // assign vector f = 1; - + // random access vector for (size_type i=0; i::iterator it = v.begin(); - typename FieldVector::ConstIterator end = v.end(); + auto it = v.begin(); + auto end = v.end(); for (; it!=end; ++it) { it.index(); @@ -214,45 +217,48 @@ it = v.find(i); (*it) += 1; } - + // matrix vector product A.umv(v,f); // check that mv and umv are doing the same thing - { - FieldVector res2(0); - FieldVector res1; + { + FieldVector res2(0); + FieldVector res1; - FieldVector b(1); + FieldVector b(1); - A.mv(b, res1); + A.mv(b, res1); A.umv(b, res2); - if( (res1 - res2).two_norm() > 1e-12 ) + if( (res1 - res2).two_norm() > 1e-12 ) { DUNE_THROW(FMatrixError,"mv and umv are not doing the same!"); } } { - FieldVector v0 ( v ); - test_mult(A, v0, f ); - } - - { - std::vector v1( m ) ; - std::vector f1( n, 1 ) ; - // random access vector - for (size_type i=0; i v0 (v); + FieldVector f0 (f); + FieldVector vT (0); + FieldVector fT (0); + test_mult(A, v0, f0, vT, fT); + } + + // { + // std::vector v1( m ) ; + // std::vector f1( n, 1 ) ; + // // random access vector + // for (size_type i=0; i= 0 ); @@ -287,11 +293,11 @@ DUNE_THROW(FMatrixError,"Axpy test failed!"); } { - FieldMatrix A; - for(size_type i=0; i& Aref = A; + FieldMatrix A2; + for(size_type i=0; i& Aref = A2; FieldMatrix B; @@ -312,15 +318,15 @@ if (std::abs(AB[i][j] - K(i*n*(n+1)/2)) > 1e-10) DUNE_THROW(FMatrixError,"Rightmultiplyany test failed!"); - FieldMatrix AB2 = A; + FieldMatrix AB2 = A2; AB2.rightmultiply(B); AB2 -= AB; if (std::abs(AB2.infinity_norm()) > 1e-10) DUNE_THROW(FMatrixError,"Rightmultiply test failed!"); - FieldMatrix AB3 = Bref.leftmultiplyany(A); + FieldMatrix AB3 = Bref.leftmultiplyany(A2); AB3 -= AB; - if (std::abs(AB3.infinity_norm() > 1e-10)) + if (std::abs(AB3.infinity_norm()) > 1e-10) DUNE_THROW(FMatrixError,"Leftmultiplyany test failed!"); FieldMatrix CA = Aref.leftmultiplyany(C); @@ -329,13 +335,13 @@ if (std::abs(CA[i][j] - K(i*n*(n-1)/2)) > 1e-10) DUNE_THROW(FMatrixError,"Leftmultiplyany test failed!"); - FieldMatrix CA2 = A; + FieldMatrix CA2 = A2; CA2.leftmultiply(C); CA2 -= CA; if (std::abs(CA2.infinity_norm()) > 1e-10) DUNE_THROW(FMatrixError,"Leftmultiply test failed!"); - FieldMatrix CA3 = Cref.rightmultiplyany(A); + FieldMatrix CA3 = Cref.rightmultiplyany(A2); CA3 -= CA; if (std::abs(CA3.infinity_norm()) > 1e-10) DUNE_THROW(FMatrixError,"Rightmultiplyany test failed!"); @@ -344,30 +350,30 @@ int test_determinant() { - int ret = 0; + int ret = 0; - FieldMatrix B; - B[0][0] = 3.0; B[0][1] = 0.0; B[0][2] = 1.0; B[0][3] = 0.0; - B[1][0] = -1.0; B[1][1] = 3.0; B[1][2] = 0.0; B[1][3] = 0.0; - B[2][0] = -3.0; B[2][1] = 0.0; B[2][2] = -1.0; B[2][3] = 2.0; - B[3][0] = 0.0; B[3][1] = -1.0; B[3][2] = 0.0; B[3][3] = 1.0; - if (std::abs(B.determinant() + 2.0) > 1e-12) - { - std::cerr << "Determinant 1 test failed" << std::endl; - ++ret; - } + FieldMatrix B; + B[0][0] = 3.0; B[0][1] = 0.0; B[0][2] = 1.0; B[0][3] = 0.0; + B[1][0] = -1.0; B[1][1] = 3.0; B[1][2] = 0.0; B[1][3] = 0.0; + B[2][0] = -3.0; B[2][1] = 0.0; B[2][2] = -1.0; B[2][3] = 2.0; + B[3][0] = 0.0; B[3][1] = -1.0; B[3][2] = 0.0; B[3][3] = 1.0; + if (std::abs(B.determinant() + 2.0) > 1e-12) + { + std::cerr << "Determinant 1 test failed" << std::endl; + ++ret; + } - B[0][0] = 3.0; B[0][1] = 0.0; B[0][2] = 1.0; B[0][3] = 0.0; - B[1][0] = -1.0; B[1][1] = 3.0; B[1][2] = 0.0; B[1][3] = 0.0; - B[2][0] = -3.0; B[2][1] = 0.0; B[2][2] = -1.0; B[2][3] = 2.0; - B[3][0] = -1.0; B[3][1] = 3.0; B[3][2] = 0.0; B[3][3] = 2.0; - if (B.determinant() != 0.0) - { - std::cerr << "Determinant 2 test failed" << std::endl; - ++ret; - } + B[0][0] = 3.0; B[0][1] = 0.0; B[0][2] = 1.0; B[0][3] = 0.0; + B[1][0] = -1.0; B[1][1] = 3.0; B[1][2] = 0.0; B[1][3] = 0.0; + B[2][0] = -3.0; B[2][1] = 0.0; B[2][2] = -1.0; B[2][3] = 2.0; + B[3][0] = -1.0; B[3][1] = 3.0; B[3][2] = 0.0; B[3][3] = 2.0; + if (B.determinant() != 0.0) + { + std::cerr << "Determinant 2 test failed" << std::endl; + ++ret; + } - return 0; + return 0; } template @@ -387,7 +393,7 @@ a = a + c; a = a / c; a = a - c; - + v = a; v = w = v; a = v; @@ -401,7 +407,7 @@ v = v - a; v = v * a; v = v / a; - + a = a + v; a = a - v; a = a * v; @@ -433,28 +439,28 @@ // rosser test matrix /* - This matrix was a challenge for many matrix eigenvalue - algorithms. But the Francis QR algorithm, as perfected by - Wilkinson and implemented in EISPACK, has no trouble with it. The - matrix is 8-by-8 with integer elements. It has: - - * A double eigenvalue - * Three nearly equal eigenvalues - * Dominant eigenvalues of opposite sign - * A zero eigenvalue - * A small, nonzero eigenvalue - + This matrix was a challenge for many matrix eigenvalue + algorithms. But the Francis QR algorithm, as perfected by + Wilkinson and implemented in EISPACK, has no trouble with it. The + matrix is 8-by-8 with integer elements. It has: + + * A double eigenvalue + * Three nearly equal eigenvalues + * Dominant eigenvalues of opposite sign + * A zero eigenvalue + * A small, nonzero eigenvalue + */ - Dune::FieldMatrix A; - A <<= - 611, 196, -192, 407, -8, -52, -49, 29, Dune::nextRow, - 196, 899, 113, -192, -71, -43, -8, -44, Dune::nextRow, - -192, 113, 899, 196, 61, 49, 8, 52, Dune::nextRow, - 407, -192, 196, 611, 8, 44, 59, -23, Dune::nextRow, - -8, -71, 61, 8, 411, -599, 208, 208, Dune::nextRow, - -52, -43, 49, 44, -599, 411, 208, 208, Dune::nextRow, - -49, -8, 8, 59, 208, 208, 99, -911, Dune::nextRow, - 29, -44, 52, -23, 208, 208, -911, 99; + Dune::FieldMatrix A = { + { 611, 196, -192, 407, -8, -52, -49, 29 }, + { 196, 899, 113, -192, -71, -43, -8, -44 }, + { -192, 113, 899, 196, 61, 49, 8, 52 }, + { 407, -192, 196, 611, 8, 44, 59, -23 }, + { -8, -71, 61, 8, 411, -599, 208, 208 }, + { -52, -43, 49, 44, -599, 411, 208, 208 }, + { -49, -8, 8, 59, 208, 208, 99, -911 }, + { 29, -44, 52, -23, 208, 208, -911, 99} + }; // compute eigenvalues Dune::FieldVector eig; @@ -463,23 +469,22 @@ // test results Dune::FieldVector ref; /* - reference solution computed with octave 3.2 - - > format long e - > eig(rosser()) + reference solution computed with octave 3.2 + + > format long e + > eig(rosser()) */ - ref <<= - -1.02004901843000e+03, - -4.14362871168386e-14, - 9.80486407214362e-02, - 1.00000000000000e+03, - 1.00000000000000e+03, - 1.01990195135928e+03, - 1.02000000000000e+03, - 1.02004901843000e+03; + ref = { -1.02004901843000e+03, + -4.14362871168386e-14, + 9.80486407214362e-02, + 1.00000000000000e+03, + 1.00000000000000e+03, + 1.01990195135928e+03, + 1.02000000000000e+03, + 1.02004901843000e+03 }; - if( (ref - eig).two_norm() > 1e-10 ) + if( (ref - eig).two_norm() > 1e-10 ) { DUNE_THROW(FMatrixError,"error computing eigenvalues"); } @@ -496,20 +501,140 @@ A.invert(); } +template +void checkNormNAN(M const &v, int line) { + if (!std::isnan(v.frobenius_norm())) { + std::cerr << "error: norm not NaN: frobenius_norm() on line " + << line << " (type: " << Dune::className(v[0]) << ")" + << std::endl; + std::exit(-1); + } + if (!std::isnan(v.infinity_norm())) { + std::cerr << "error: norm not NaN: infinity_norm() on line " + << line << " (type: " << Dune::className(v[0]) << ")" + << std::endl; + std::exit(-1); + } +} + +// Make sure that matrices with NaN entries have norm NaN. +// See also bug flyspray/FS#1147 +template +void +test_nan(T const &mynan) +{ + T const n(0); + { + Dune::FieldMatrix m = { + { mynan, mynan }, + { mynan, mynan } + }; + checkNormNAN(m, __LINE__); + } + { + Dune::FieldMatrix m = { + { mynan, n }, + { n, n } + }; + checkNormNAN(m, __LINE__); + } + { + Dune::FieldMatrix m = { + { n, mynan }, + { n, n } + }; + checkNormNAN(m, __LINE__); + } + { + Dune::FieldMatrix m = { + { n, n }, + { mynan, n } + }; + checkNormNAN(m, __LINE__); + } + { + Dune::FieldMatrix m = { + { n, n }, + { n, mynan } + }; + checkNormNAN(m, __LINE__); + } +} + +// The computation of infinity_norm_real() was flawed from r6819 on +// until r6915. +void +test_infinity_norms() +{ + std::complex threefour(3.0, -4.0); + std::complex eightsix(8.0, -6.0); + + Dune::FieldMatrix, 2, 2> m; + m[0] = threefour; + m[1] = eightsix; + assert(std::abs(m.infinity_norm() -20.0) < 1e-10); // max(5+5, 10+10) + assert(std::abs(m.infinity_norm_real()-28.0) < 1e-10); // max(7+7, 14+14) +} + + +template< class K, class K2, int rows, int cols > +void test_interface() +{ + typedef CheckMatrixInterface::UseFieldVector< K2, rows, cols > Traits; + typedef Dune::FieldMatrix< K, rows, cols > FMatrix; + + FMatrix m( 1 ); + checkMatrixInterface< FMatrix >( m ); + checkMatrixInterface< FMatrix, Traits >( m ); +} + +void test_initialisation() +{ + DUNE_UNUSED Dune::FieldMatrix const A = { + { 1, 2 }, + { 3, 4 } + }; + + assert(A[0][0] == 1); + assert(A[0][1] == 2); + assert(A[1][0] == 3); + assert(A[1][1] == 4); +} + int main() { try { + { + double nan = std::nan(""); + test_nan(nan); + } + { + std::complex nan( std::nan(""), 17 ); + test_nan(nan); + } + test_infinity_norms(); + test_initialisation(); + // test 1 x 1 matrices - test_matrix(); + test_interface(); + test_matrix(); ScalarOperatorTest(); - test_matrix(); + test_matrix(); ScalarOperatorTest(); // test n x m matrices - test_matrix(); - test_matrix(); + test_interface(); + test_matrix(); + test_matrix(); + test_interface(); + // mixed precision + test_interface(); + test_matrix(); // test complex matrices - test_matrix, 1, 1>(); - test_matrix, 5, 10>(); + test_matrix, std::complex, std::complex, 1, 1>(); + test_matrix, std::complex, std::complex, 5, 10>(); + // test complex/real matrices mixed case + test_matrix, std::complex, 1, 1>(); + test_matrix, float, std::complex, 1, 1>(); #if HAVE_LAPACK // test eigemvalue computation test_ev(); @@ -518,6 +643,7 @@ test_determinant(); test_invert< float, 34 >(); test_invert< double, 34 >(); + test_invert< std::complex< long double >, 2 >(); return test_invert_solve(); } catch (Dune::Exception & e) diff -Nru dune-common-2.2.1/dune/common/test/fvectortest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/fvectortest.cc --- dune-common-2.2.1/dune/common/test/fvectortest.cc 2012-04-05 12:19:01.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/fvectortest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,50 +1,61 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include -#include #include +#include #include #include #include +#include using Dune::FieldVector; using std::complex; +// Tests that can be run without the construction of complex template -struct FieldVectorMainTest +struct FieldVectorMainTestCommons { - FieldVectorMainTest() { + FieldVectorMainTestCommons() { ft a = 1; FieldVector v(1); FieldVector w(2); FieldVector z(2); const FieldVector x(z); - a = x[0]; + if (x.size()>0) + a = x[0]; bool b DUNE_UNUSED; rt n DUNE_UNUSED; std::cout << __func__ << "\t ( " << className(v) << " )" << std::endl; + // test exported types + static_assert( + std::is_same::value_type>::value, + "FieldVector::value_type is not the correct type" + ); + // test traits - dune_static_assert( - ( Dune::is_same< typename Dune::FieldTraits< - FieldVector >::field_type, ft >::value ), + static_assert( + ( std::is_same< typename Dune::FieldTraits< + FieldVector >::field_type, ft >::value ), "FieldTraits yields wrong field_type" ); - dune_static_assert( - ( Dune::is_same< typename Dune::FieldTraits::real_type, rt >::value ), + static_assert( + ( std::is_same< typename Dune::FieldTraits::real_type, rt >::value ), "FieldTraits yields wrong real_type" ); - dune_static_assert( - ( Dune::is_same< typename Dune::FieldTraits< - FieldVector >::real_type, rt >::value ), + static_assert( + ( std::is_same< typename Dune::FieldTraits< + FieldVector >::real_type, rt >::value ), "FieldTraits yields wrong real_type" ); - + // Test whether the norm methods compile n = (w+v).two_norm(); n = (w+v).two_norm2(); @@ -68,17 +79,13 @@ // test scalar product, axpy a = v * w; + a = v.dot(w); z = v.axpy(a,w); - + // test comparison b = (w != v); b = (w == v); - // assignment to vector of complex - FieldVector< std::complex ,d> cv = v; - cv = a; - const FieldVector< std::complex ,d> ccv DUNE_UNUSED = x; - // test istream operator std::stringstream s; for (int i=0; i> w; assert(v == w); - + // test container methods - typename FieldVector::size_type size DUNE_UNUSED = FieldVector::dimension; -#if DUNE_COMMON_FIELDVECTOR_SIZE_IS_METHOD - size = w.size(); -#endif + typename FieldVector::size_type size = FieldVector::dimension; + assert(size == w.size()); } }; +// Additional tests for floating point types, for which complex will work +template::value> +struct FieldVectorMainTest + : FieldVectorMainTestCommons +{ + FieldVectorMainTest() + : FieldVectorMainTestCommons() + { + ft a = 1; + FieldVector v(1); + FieldVector z(2); + const FieldVector x(z); -template + // assignment to vector of complex + FieldVector< std::complex ,d> cv = v; + cv = a; + const FieldVector< std::complex ,d> ccv DUNE_UNUSED = x; + } +}; + +template +struct FieldVectorMainTest + : FieldVectorMainTestCommons +{ + FieldVectorMainTest() + : FieldVectorMainTestCommons() + {} +}; + +template struct ScalarOperatorTest { ScalarOperatorTest() { - ft a = 1; - ft c = 2; + // testft has to initializable with an int + testft a = 1; + testft c = 2; FieldVector v(2); FieldVector w(2); bool b DUNE_UNUSED; @@ -115,7 +150,7 @@ a = a + c; a = a / c; a = a - c; - + v = a; v = w = v; a = v; @@ -123,25 +158,25 @@ a = v + a; a = v - a; a = v * a; - a += (ft)1;// make sure a!=0 + a += 1; // make sure a!=0 a = v / a; v = v + a; v = v - a; v = v * a; - a += (ft)1;// make sure a!=0 + a += 1; // make sure a!=0 v = v / a; - + a = a + v; a = a - v; a = a * v; - v += (ft)1;// make sure v!=0 + v += 1; // make sure v!=0 a = a / v; v = a + v; v = a - v; v = a * v; - v += (ft)1;// make sure v!=0 + v += 1; // make sure v!=0 v = a / v; v -= v; @@ -149,7 +184,7 @@ v += v; v += a; v *= a; - a += (ft)1;// make sure a!=0 + a += 1; // make sure a!=0 v /= a; b = (v == a); @@ -178,7 +213,7 @@ b = (a <= c); b = (a >= c); b = (a > c); - + b = (v == a); b = (v != a); b = (a == v); @@ -201,7 +236,124 @@ } }; -template +template +struct Epsilon +{ + static T value() { return T(1e-6); } +}; + +template<> +struct Epsilon +{ + static int value() { return 0; } +}; + +// scalar ordering doesn't work for complex numbers +template ::value> +struct DotProductTest +{ + DotProductTest() { + typedef std::complex ct; + DUNE_UNUSED const rt myEps = Epsilon::value(); + + static_assert( + ( std::is_same< typename Dune::FieldTraits::real_type, rt>::value ), + "DotProductTest requires real data type as template parameter!" + ); + + const ct I(0.,1.); // imaginary unit + const FieldVector one(1.); // vector filled with 1 + const FieldVector iVec(ct(0.,1.)); // vector filled with I + + std::cout << __func__ << "\t \t ( " << Dune::className(one) << " and " << Dune::className(iVec) << ")" << std::endl; + + const bool isRealOne = std::is_same::field_type,typename Dune::FieldTraits::real_type>::value; + const bool isRealIVec = std::is_same::field_type,typename Dune::FieldTraits::real_type> ::value; + static_assert(isRealOne,"1-vector expected to be real"); + static_assert(!isRealIVec,"i-vector expected to be complex"); + + ct result = ct(); + ct length = ct(d); + + + // one^H*one should equal d + result = dot(one,one); + assert(std::abs(result-length)<= myEps); + result = one.dot(one); + assert(std::abs(result-length)<= myEps); + + + // iVec^H*iVec should equal d + result = dot(iVec,iVec); + assert(std::abs(result-length)<= myEps); + result = iVec.dot(iVec); + assert(std::abs(result-length)<= myEps); + + + // test that we do conjugate first argument + result = dot(one,iVec); + assert(std::abs(result-length*I)<= myEps); + result = dot(one,iVec); + assert(std::abs(result-length*I)<= myEps); + + + // test that we do not conjugate second argument + result = dot(iVec,one); + assert(std::abs(result+length*I)<= myEps); + result = iVec.dot(one); + assert(std::abs(result+length*I)<= myEps); + + + // test that dotT does not conjugate at all + result = dotT(one,one) + one*one; + assert(std::abs(result-ct(2)*length)<= myEps); + result = dotT(iVec,iVec) + iVec*iVec; + assert(std::abs(result+ct(2)*length)<= myEps); + result = dotT(one,iVec) + one*iVec; + assert(std::abs(result-ct(2)*length*I)<= myEps); + result = dotT(iVec,one) + iVec*one; + assert(std::abs(result-ct(2)*length*I)<= myEps); + + } +}; + +// scalar ordering doesn't work for complex numbers +template +struct DotProductTest +{ + DotProductTest() { + DUNE_UNUSED const rt myEps = Epsilon::value(); + + static_assert( + ( std::is_same< typename Dune::FieldTraits::real_type, rt>::value ), + "DotProductTest requires real data type as template parameter!" + ); + + const FieldVector one(1.); // vector filled with 1 + + std::cout << __func__ << "\t \t ( " << Dune::className(one) << " only)" << std::endl; + + const bool isRealOne = std::is_same::field_type,typename Dune::FieldTraits::real_type>::value; + static_assert(isRealOne,"1-vector expected to be real"); + + rt result = rt(); + rt length = rt(d); + + // one^H*one should equal d + result = dot(one,one); + assert(abs(result-length)<= myEps); + result = one.dot(one); + assert(abs(result-length)<= myEps); + + // test that dotT does not conjugate at all + result = dotT(one,one) + one*one; + assert(abs(result-rt(2)*length)<= myEps); + } +}; + +template::value> struct FieldVectorTest { FieldVectorTest() @@ -209,14 +361,29 @@ // --- test complex and real valued vectors FieldVectorMainTest(); FieldVectorMainTest,ft,d>(); + DotProductTest(); + // --- test next lower dimension + FieldVectorTest(); + } +}; + +// specialisation for non-floating-point vectors +template +struct FieldVectorTest +{ + FieldVectorTest() + { + // --- test real valued vectors + FieldVectorMainTest(); + DotProductTest(); // --- test next lower dimension FieldVectorTest(); } }; -// specialization for 1d vector +// specialization for 1d floating point vector template -class FieldVectorTest +class FieldVectorTest { public: FieldVectorTest() @@ -225,22 +392,132 @@ FieldVectorMainTest(); ScalarOperatorTest(); ScalarOrderingTest(); + DotProductTest(); // --- complex valued FieldVectorMainTest,ft,1>(); ScalarOperatorTest< complex >(); // ordering doesn't work for complex numbers + // --- test with an integer + ScalarOperatorTest< ft, int >(); // --- test next lower dimension FieldVectorMainTest(); } }; +// specialization for other 1d vectors +template +class FieldVectorTest +{ +public: + FieldVectorTest() + { + // --- real valued + FieldVectorMainTest(); + ScalarOperatorTest(); + ScalarOrderingTest(); + DotProductTest(); + + // --- test with an integer + ScalarOperatorTest< ft, int >(); + // --- test next lower dimension + FieldVectorMainTest(); + } +}; + +template +void checkNormNAN(V const &v, int line) { + if (!std::isnan(v.one_norm())) { + std::cerr << "error: norm not NaN: one_norm() on line " + << line << " (type: " << Dune::className(v[0]) << ")" + << std::endl; + std::exit(-1); + } + if (!std::isnan(v.two_norm())) { + std::cerr << "error: norm not NaN: two_norm() on line " + << line << " (type: " << Dune::className(v[0]) << ")" + << std::endl; + std::exit(-1); + } + if (!std::isnan(v.infinity_norm())) { + std::cerr << "error: norm not NaN: infinity_norm() on line " + << line << " (type: " << Dune::className(v[0]) << ")" + << std::endl; + std::exit(-1); + } +} + +// Make sure that vectors with NaN entries have norm NaN. +// See also bug flyspray/FS#1147 +template +void +test_nan(T const &mynan) +{ + { + Dune::FieldVector v = { mynan, mynan }; + checkNormNAN(v, __LINE__); + } + { + Dune::FieldVector v = { mynan, 0 }; + checkNormNAN(v, __LINE__); + } + { + Dune::FieldVector v = { 0, mynan }; + checkNormNAN(v, __LINE__); + } +} + +void +test_infinity_norms() +{ + std::complex threefour(3.0, -4.0); + std::complex eightsix(8.0, -6.0); + + Dune::FieldVector, 2> v; + v[0] = threefour; + v[1] = eightsix; + assert(std::abs(v.infinity_norm() -10.0) < 1e-10); // max(5,10) + assert(std::abs(v.infinity_norm_real()-14.0) < 1e-10); // max(7,14) +} + +void +test_initialisation() +{ + DUNE_UNUSED Dune::FieldVector const b = { 1, 2 }; + + assert(b[0] == 1); + assert(b[1] == 2); +} + int main() { try { FieldVectorTest(); FieldVectorTest(); FieldVectorTest(); + FieldVectorTest(); +#if HAVE_GMP + // we skip the complex test and the int test, as these will be very hard to implement with GMPField + typedef Dune::GMPField<128u> ft; + FieldVectorMainTest(); + FieldVectorMainTest(); + FieldVectorMainTest(); + FieldVectorMainTest(); + ScalarOperatorTest(); + ScalarOrderingTest(); + DotProductTest(); +#endif // HAVE_GMP + + { + double nan = std::nan(""); + test_nan(nan); + } + { + std::complex nan( std::nan(""), 17 ); + test_nan(nan); + } + test_infinity_norms(); + test_initialisation(); } catch (Dune::Exception& e) { std::cerr << e << std::endl; return 1; diff -Nru dune-common-2.2.1/dune/common/test/gcdlcmtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/gcdlcmtest.cc --- dune-common-2.2.1/dune/common/test/gcdlcmtest.cc 2008-11-15 17:55:56.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/gcdlcmtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,28 +1,33 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include -#include -#include -#include +#include +#include void test() { - dune_static_assert((Dune::Gcd<2*2*2*5*5*5*11, 2*2*5*13>::value == 2*2*5), "gcd not working properly"); - dune_static_assert((Dune::Lcm<11,3>::value == 33), "lcm not working properly"); - dune_static_assert((Dune::Lcm<18,15>::value == 18*15/3), "lcm not working properly"); - dune_static_assert((Dune::Lcm<10800,Dune::Lcm<36000,7680>::value>::value==1728000), "lcm not working properly"); + static_assert((Dune::Gcd<2*2*2*5*5*5*11, 2*2*5*13>::value == 2*2*5), + "gcd not working properly"); + static_assert((Dune::Lcm<11,3>::value == 33), + "lcm not working properly"); + static_assert((Dune::Lcm<18,15>::value == 18*15/3), + "lcm not working properly"); + static_assert((Dune::Lcm<10800,Dune::Lcm<36000,7680>::value>::value==1728000), + "lcm not working properly"); } int main() { std::cout<<" gcd(2,5)="<::value<<" gcd(3, 18)=" - <::value<<" gcd("<<2*2*2*5*5*5*11<<", " - << 2*2*5*13<<")="<::value - <::value<<" gcd("<<2*2*2*5*5*5*11<<", " + << 2*2*5*13<<")="<::value + < -#include +#include +#include int main(){ // Test the TestIterator; diff -Nru dune-common-2.2.1/dune/common/test/hybridutilitiestest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/hybridutilitiestest.cc --- dune-common-2.2.1/dune/common/test/hybridutilitiestest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/hybridutilitiestest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,81 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include +#include +#include + + + +template +auto incrementAll(C&& c) +{ + using namespace Dune::Hybrid; + forEach(c, [](auto&& ci) { + ++ci; + }); +} + +template +auto addIndex(C&& c) +{ + using namespace Dune::Hybrid; + forEach(integralRange(Dune::Hybrid::size(c)), [&](auto&& i) { + c[i] += i; + }); +} + +template +auto incAndAppendToFirst(C&& c) +{ + using namespace Dune::Hybrid; + using namespace Dune::Indices; + forEach(integralRange(Dune::Hybrid::size(c)), [&](auto&& i) { + ifElse(equals(i, _0), [&](auto id) { + id(c[i]).append("+1"); + }, [&](auto id) { + ++id(c[i]); + }); + }); +} + + + +int main() +{ + auto vector = std::vector{1, 2, 3}; + auto numberTuple = Dune::makeTupleVector(0.1, 2, 3); + + Dune::TestSuite test; + + incrementAll(vector); + test.check(vector == std::vector{2, 3, 4}) + << "Incrementing vector entries with Hybrid::forEach failed."; + + incrementAll(numberTuple); + test.check(numberTuple == Dune::makeTupleVector(1.1, 3, 4)) + << "Incrementing tuple entries with Hybrid::forEach failed."; + + addIndex(vector); + test.check(vector == std::vector{2, 4, 6}) + << "Adding indices to vector entries with Hybrid::forEach failed."; + + addIndex(numberTuple); + test.check(numberTuple == Dune::makeTupleVector(1.1, 4, 6)) + << "Adding indices to vector entries with Hybrid::forEach failed."; + + + auto mixedTuple = Dune::makeTupleVector(std::string("1"), 2, 3); + incAndAppendToFirst(mixedTuple); + test.check(mixedTuple == Dune::makeTupleVector(std::string("1+1"), 3, 4)) + << "Adding indices to vector entries with Hybrid::forEach failed."; + + return test.exit(); +} diff -Nru dune-common-2.2.1/dune/common/test/indicestest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/indicestest.cc --- dune-common-2.2.1/dune/common/test/indicestest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/indicestest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,32 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +using namespace Dune; + + + +int main() +{ + using namespace Dune::Indices; + + // Test whether indices can be used to index a data structure + Dune::TupleVector v; + v[_0] = 42; + v[_1] = 3.14; + v[_2] = 2.7; + + // Test whether the indices can be used as numbers + std::get<_0>(v) = 43; + std::get<_1>(v) = 4.14; + std::get<_2>(v) = 3.7; + + return 0; +} diff -Nru dune-common-2.2.1/dune/common/test/integersequence.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/integersequence.cc --- dune-common-2.2.1/dune/common/test/integersequence.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/integersequence.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,34 @@ +#include + +#include +#include +#include + +#include +#include +#include + +template< class T, std::size_t... Ints > +std::tuple< typename std::tuple_element< Ints, std::array< T, sizeof...( Ints ) > >::type... > +array_to_tuple_impl ( const std::array< T, sizeof...( Ints ) > &array, Dune::Std::index_sequence< Ints... > ) +{ + auto tuple = std::make_tuple( array[ Ints ]... ); + return std::move( tuple ); +} + +template< class T, std::size_t N > +auto array_to_tuple ( const std::array< T, N > &array ) + -> decltype( array_to_tuple_impl( array, Dune::Std::make_index_sequence< N >{} ) ) +{ + return array_to_tuple_impl( array, Dune::Std::make_index_sequence< N >{} ); +} + +int main ( int, char** ) +{ + using Dune::operator<<; + std::array< int, 4 > array{{ 1, 2, 3, 4 }}; + + auto tuple = array_to_tuple_impl( array, Dune::Std::make_index_sequence< 4 >{} ); + std::cout << Dune::className( tuple ) << std::endl; + std::cout << tuple << std::endl; +} diff -Nru dune-common-2.2.1/dune/common/test/iteratorfacadetest2.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/iteratorfacadetest2.cc --- dune-common-2.2.1/dune/common/test/iteratorfacadetest2.cc 2009-10-27 22:47:33.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/iteratorfacadetest2.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" diff -Nru dune-common-2.2.1/dune/common/test/iteratorfacadetest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/iteratorfacadetest.cc --- dune-common-2.2.1/dune/common/test/iteratorfacadetest.cc 2009-12-04 11:52:49.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/iteratorfacadetest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,18 +1,20 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include -#include - +#include +#include +#include +#include + template void randomize(Container& cont){ srand(300); double size=1000; - for(int i=0; i < 100; i++){ + for(int i=0; i < 100; i++) { cont[i] = (size*(rand()/(RAND_MAX+1.0))); } @@ -32,7 +34,7 @@ // print(container); //std::sort(container.begin(), container.end()); //print(container); - + const Container ccontainer(container); int ret=0; Printer print; @@ -53,6 +55,6 @@ ret += containerTest(forwardcontainer); ret += containerTest(bidicontainer); ret += containerTest(randomcontainer); - + return (ret); } diff -Nru dune-common-2.2.1/dune/common/test/iteratorfacadetest.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/test/iteratorfacadetest.hh --- dune-common-2.2.1/dune/common/test/iteratorfacadetest.hh 2008-11-09 18:07:02.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/iteratorfacadetest.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,15 +1,17 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_ITERATORFACADETEST_HH #define DUNE_ITERATORFACADETEST_HH -#include -#include -#include +#include +#include +#include template class IteratorFacade=Dune::RandomAccessIteratorFacade> -class TestContainer{ + template class IteratorFacade=Dune::RandomAccessIteratorFacade> +class TestContainer { public: typedef Dune::GenericIterator,T,T&,std::ptrdiff_t,IteratorFacade> iterator; - + typedef Dune::GenericIterator,const T,const T&,std::ptrdiff_t,IteratorFacade> const_iterator; TestContainer(){ @@ -21,7 +23,7 @@ return iterator(*this, 0); } - const_iterator begin() const{ + const_iterator begin() const { return const_iterator(*this, 0); } @@ -29,16 +31,16 @@ return iterator(*this, 100); } - const_iterator end() const{ + const_iterator end() const { return const_iterator(*this, 100); } - + T& operator[](int i){ return values_[i]; } - - const T& operator[](int i) const{ + + const T& operator[](int i) const { return values_[i]; } private: diff -Nru dune-common-2.2.1/dune/common/test/iteratortest.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/test/iteratortest.hh --- dune-common-2.2.1/dune/common/test/iteratortest.hh 2012-04-12 12:09:52.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/iteratortest.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,39 +1,85 @@ -// $Id: iteratortest.hh 6617 2012-04-12 12:09:52Z christi $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_ITERATORTEST_HH #define DUNE_ITERATORTEST_HH -#include -#include -#include -#include +#include +#include +#include +#include /** - * @brief Tests the capabilities of a forward iterator. - * @param begin Iterator positioned at the start. - * @param end Iterator positioned at the end. - * @param opt Functor for doing whatever one wants. + * @brief Test whether the class Iter implements the interface of an STL forward iterator + * + * @param begin Iterator positioned at the start + * @param end Iterator positioned at the end + * @param opt Functor for doing whatever one wants + * + * \todo Test whether begin-> works. (I don't know how) */ template int testForwardIterator(Iter begin, Iter end, Opt& opt) { - //std::cout<< "forward: "; - Iter tmp=begin, tmp1(begin); + // Return status int ret=0; - if(tmp!=begin || tmp1!=begin || tmp!=tmp1){ + + // Test whether iterator is default-constructible + // This object will go out of scope at the end of this method, and hence + // it will also test whether the object is destructible. + Iter defaultConstructedIterator; + + // Test whether iterator is copy-constructible + Iter tmp1(begin); + + // Test whether iterator is copy-assignable + Iter tmp=begin; + + // Test for inequality + if (tmp!=begin || tmp1!=begin || tmp!=tmp1) { + std::cerr<<" Copying iterator failed "<<__FILE__<<":"<<__LINE__< construction allows one to test whether the type A exists at all, + // without assuming anything further about A. + static_assert(std::is_same::difference_type, typename std::iterator_traits::difference_type>::value, + "std::iterator_traits::difference_type is not defined!"); + static_assert(std::is_same::value_type, typename std::iterator_traits::value_type>::value, + "std::iterator_traits::value_type is not defined!"); + static_assert(std::is_same::pointer, typename std::iterator_traits::pointer>::value, + "std::iterator_traits::pointer is not defined!"); + static_assert(std::is_same::reference, typename std::iterator_traits::reference>::value, + "std::iterator_traits::reference is not defined!"); + + // Make sure the iterator_category is properly set + static_assert(std::is_same::iterator_category, std::forward_iterator_tag>::value + or std::is_same::iterator_category, std::bidirectional_iterator_tag>::value + or std::is_same::iterator_category, std::random_access_iterator_tag>::value, + "std::iterator_traits::iterator_category is not properly defined!"); + return ret; } /** * @brief Tests the capabilities of a bidirectional iterator. * - * Namely it test wether random positions can be reached from + * Namely it test whether random positions can be reached from * each directions. * * @param begin Iterator positioned at the stsrt. @@ -44,29 +90,41 @@ int testBidirectionalIterator(Iter begin, Iter end, Opt opt) { testForwardIterator(begin, end, opt); - Iter tbegin=--begin; - Iter tend=--end; - for(;tbegin!=tend; --tend) - opt(*tend); + for(Iter pre = end, post = end; pre != begin; ) + { + if(pre != post--) + { + std::cerr << "Postdecrement did not return the old iterator" + << std::endl; + return 1; + } + if(--pre != post) + { + std::cerr << "Predecrement did not return the new iterator" + << std::endl; + return 1; + } + opt(*pre); + } typename Iter::difference_type size = std::distance(begin, end); srand(300); - int no= (size>10)?10:size; + int no= (size>10) ? 10 : size; for(int i=0; i < no; i++) { int index = static_cast(size*(rand()/(RAND_MAX+1.0))); int backwards=size-index; - tbegin=begin; - tend=end; + Iter tbegin = begin; + Iter tend = end; for(int j=0; j < index; j++) ++tbegin; for(int j=0; j < backwards; j++) --tend; if(tbegin != tend) { std::cerr<<"Did not reach same index by starting forward from " - <<"begin and backwards from end."<10)?10:size; + int no= (size>10) ? 10 : size; for(int i=0; i < no; i++) { @@ -96,15 +154,15 @@ ret++; } - if(begin != end){ - if(begin-end >= 0){ - std::cerr<<"begin!=end, but begin-end >= 0!"<= 0) { + std::cerr<<"begin!=end, but begin-end >= 0!"<(size*(rand()/(RAND_MAX+1.0))); Iter rand(begin), test(begin), res; rand+=index; - + if((res=begin+index) != rand) { std::cerr << " i+n should have the result i+=n, where i is the " - <<"iterator and n is the difference type!" <(size*(rand()/(RAND_MAX+1.0))); Iter iter2 = begin+static_cast(size*(rand()/(RAND_MAX+1.0))); typename Iter::difference_type diff = iter2 -iter1; - if((iter1+diff)!=iter2){ + if((iter1+diff)!=iter2) { std::cerr<< "i+(j-i) = j should hold, where i,j are iterators!"< - static void testSorting(Container& c, IteratorTag tag) - { - } + static void testSorting(Container&, IteratorTag) + {} template static void testSorting(Container& c, std::random_access_iterator_tag) { @@ -214,16 +273,14 @@ struct TestSorting { template - static void testSorting(Container& c, std::random_access_iterator_tag) - { - } + static void testSorting(Container&, std::random_access_iterator_tag) + {} template - static void testSorting(Container& c, IteratorTag tag) - { - } + static void testSorting(Container&, IteratorTag) + {} }; - + template int testIterator(Container& c, Opt& opt) { @@ -234,7 +291,7 @@ int ret = 0; TestSorting::testSorting(c, typename std::iterator_traits::iterator_category()); - + if(end!=cend || cend!=end) { std::cerr<<"constant and mutable iterators should be equal!"< -void testAssignment(Iter begin, Iter end, Opt& opt) +void testAssignment(Iter begin, Iter end, Opt&) { //std::cout << "Assignment: "; - for(;begin!=end;begin++) + for(; begin!=end; begin++) *begin=typename std::iterator_traits::value_type(); //std::cout<<" Done."<< std::endl; } @@ -271,16 +328,16 @@ template -class Printer{ - typename Dune::remove_const::type res; +class Printer { + typename std::remove_const::type res; public: - Printer():res(0){} + Printer() : res(0){} void operator()(const T& t){ res+=t; // std::cout << t <<" "; } }; - + template int testIterator(const Container& c, Opt& opt) { @@ -292,8 +349,8 @@ template int testIterator(Container& c) { - Printer::value_type> print; - return testIterator(c,print); + Printer::value_type> print; + return testIterator(c,print); } #endif diff -Nru dune-common-2.2.1/dune/common/test/lrutest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/lrutest.cc --- dune-common-2.2.1/dune/common/test/lrutest.cc 2011-04-15 08:44:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/lrutest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,43 +1,45 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #include #include #include -#include +#include void lru_test() { - std::cout << "testing Dune::lru\n"; - - Dune::lru lru; - lru.insert(10, 1.0); - assert(lru.front() == lru.back()); - lru.insert(11, 2.0); - assert(lru.front() == 2.0 && lru.back() == 1.0); - lru.insert(12, 99); - lru.insert(13, 1.3); - lru.insert(14, 12345); - lru.insert(15, -17); - assert(lru.front() == -17 && lru.back() == 1.0); - // update - lru.insert(10); - assert(lru.front() == 1.0 && lru.back() == 2.0); - // update - lru.touch(13); - assert(lru.front() == 1.3 && lru.back() == 2.0); - // remove item - lru.pop_front(); - assert(lru.front() == 1.0 && lru.back() == 2.0); - // remove item - lru.pop_back(); - assert(lru.front() == 1.0 && lru.back() == 99); + std::cout << "testing Dune::lru\n"; - std::cout << "... passed\n"; + Dune::lru lru; + lru.insert(10, 1.0); + assert(lru.front() == lru.back()); + lru.insert(11, 2.0); + assert(lru.front() == 2.0 && lru.back() == 1.0); + lru.insert(12, 99); + lru.insert(13, 1.3); + lru.insert(14, 12345); + lru.insert(15, -17); + assert(lru.front() == -17 && lru.back() == 1.0); + // update + lru.insert(10); + assert(lru.front() == 1.0 && lru.back() == 2.0); + // update + lru.touch(13); + assert(lru.front() == 1.3 && lru.back() == 2.0); + // remove item + lru.pop_front(); + assert(lru.front() == 1.0 && lru.back() == 2.0); + // remove item + lru.pop_back(); + assert(lru.front() == 1.0 && lru.back() == 99); + + std::cout << "... passed\n"; } int main (int argc, char** argv) { - Dune::MPIHelper::instance(argc,argv); - - lru_test(); + Dune::MPIHelper::instance(argc,argv); + + lru_test(); - return 0; + return 0; } diff -Nru dune-common-2.2.1/dune/common/test/Makefile.am dune-common-2.5.2~20170808ga5c076ca/dune/common/test/Makefile.am --- dune-common-2.2.1/dune/common/test/Makefile.am 2012-04-25 17:18:11.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,243 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil -*- -# $Id: Makefile.am 6658 2012-04-25 17:18:11Z sander $ - -TESTPROGS = \ - arraylisttest \ - arraytest \ - bigunsignedinttest \ - bitsetvectortest \ - check_fvector_size \ - conversiontest \ - dynmatrixtest \ - dynvectortest \ - enumsettest \ - fassigntest \ - fmatrixtest \ - fvectortest \ - gcdlcmtest \ - iteratorfacadetest \ - iteratorfacadetest2 \ - lrutest \ - mpicollectivecommunication \ - mpiguardtest \ - mpihelpertest \ - mpihelpertest2 \ - nullptr-test \ - pathtest \ - parametertreetest \ - poolallocatortest \ - shared_ptrtest_config \ - shared_ptrtest_dune \ - singletontest \ - static_assert_test \ - streamtest \ - test-stack \ - testfassign1 \ - testfassign2 \ - testfassign3 \ - testfassign4 \ - testfassign_fail1 \ - testfassign_fail2 \ - testfassign_fail3 \ - testfassign_fail4 \ - testfassign_fail5 \ - testfassign_fail6 \ - testfconstruct \ - testfloatcmp \ - tuplestest_dune \ - tuplestest_std \ - tuplestest_tr1 \ - tupleutilitytest \ - utilitytest - -# which tests to run -COMPILE_XFAIL=$(DUNE_COMMON_BIN)/xfail-compile-tests - -COMPILE_XFAIL_TESTS = \ - check_fvector_size_fail1 \ - check_fvector_size_fail2 \ - genericiterator_compile_fail \ - nullptr-test-fail \ - static_assert_test_fail \ - testfconstruct_fail1 \ - testfconstruct_fail2 - -compile_XFAIL: - for i in $(COMPILE_XFAIL_TESTS); do \ - if $(MAKE) $$i; then \ - echo "ERROR: target $$i did compile, although it is listed in the COMPILE_XFAIL_TESTS"; \ - exit 1; \ - else true; \ - fi; \ - done - -EXTRA_PROGRAMS = $(COMPILE_XFAIL_TESTS) sllisttest - -TESTS = $(TESTPROGS) $(COMPILE_XFAIL) - -XFAIL_TESTS = \ - testfassign_fail1 \ - testfassign_fail2 \ - testfassign_fail3 \ - testfassign_fail4 \ - testfassign_fail5 \ - testfassign_fail6 - -# programs just to build when "make check" is used -check_PROGRAMS = $(TESTPROGS) - -noinst_HEADERS = dummyiterator.hh - -# Install some test headers, because they get used by tests in other modules -testincludedir = $(includedir)/dune/common/test -testinclude_HEADERS = iteratortest.hh - -# define the programs -pathtest_SOURCES = pathtest.cc - -parametertreetest_SOURCES = parametertreetest.cc - -bitsetvectortest_SOURCES = bitsetvectortest.cc - -nullptr_test_SOURCES = nullptr-test.cc nullptr-test2.cc -nullptr_test_fail_SOURCES = nullptr-test.cc -nullptr_test_fail_CPPFLAGS = $(AM_CPPFLAGS) -DFAIL - -static_assert_test_SOURCES = static_assert_test.cc -static_assert_test_fail_SOURCES = static_assert_test_fail.cc - -fassigntest_SOURCES = fassigntest.cc - -bigunsignedinttest_SOURCES=bigunsignedinttest.cc - -lrutest_SOURCES = lrutest.cc - -sllisttest_SOURCES = sllisttest.cc - -test_stack_SOURCES = test-stack.cc - -arraylisttest_SOURCES = arraylisttest.cc - -arraytest_SOURCES = arraytest.cc - -shared_ptrtest_config_SOURCES = shared_ptrtest.cc - -shared_ptrtest_dune_SOURCES = shared_ptrtest.cc -shared_ptrtest_dune_CPPFLAGS = $(AM_CPPFLAGS) \ - -DDISABLE_CONFIGURED_SHARED_PTR - -tuplestest_dune_SOURCES = tuplestest.cc -tuplestest_dune_CPPFLAGS = $(AM_CPPFLAGS) \ - -DDISABLE_TR1_TUPLE -DDISABLE_STD_TUPLE - -tuplestest_std_SOURCES = tuplestest.cc - -tuplestest_tr1_SOURCES = tuplestest.cc -tuplestest_tr1_CPPFLAGS = $(AM_CPPFLAGS) \ - -DDISABLE_STD_TUPLE - -tupleutilitytest_SOURCES = tupleutilitytest.cc - -streamtest_SOURCES = streamtest.cc - -# mention headers so that they are distributed too -iteratorfacadetest_SOURCES = iteratorfacadetest.cc iteratorfacadetest.hh \ - iteratortest.hh - -iteratorfacadetest2_SOURCES = iteratorfacadetest2.cc - -dynmatrixtest_SOURCES = dynmatrixtest.cc - -dynvectortest_SOURCES = dynvectortest.cc - -fmatrixtest_SOURCES = fmatrixtest.cc -fmatrixtest_LDADD = $(LAPACK_LIBS) $(LDADD) $(BLAS_LIBS) $(LIBS) $(FLIBS) - -fvectortest_SOURCES = fvectortest.cc - -check_fvector_size_fail1_SOURCES = check_fvector_size_fail.cc -check_fvector_size_fail1_CPPFLAGS = $(AM_CPPFLAGS) -DDIM=1 - -check_fvector_size_fail2_SOURCES = check_fvector_size_fail.cc -check_fvector_size_fail2_CPPFLAGS = $(AM_CPPFLAGS) -DDIM=3 - -check_fvector_size_SOURCES = check_fvector_size.cc - -poolallocatortest_SOURCES = poolallocatortest.cc - -enumsettest_SOURCES=enumsettest.cc - -gcdlcmtest_SOURCES = gcdlcmtest.cc - -mpihelpertest_SOURCES = mpihelpertest.cc -mpihelpertest_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS) -mpihelpertest_LDADD = $(DUNEMPILIBS) $(LDADD) -mpihelpertest_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS) - -mpihelpertest2_SOURCES = mpihelpertest.cc -mpihelpertest2_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS) -DMPIHELPER_PREINITIALIZE -mpihelpertest2_LDADD = $(DUNEMPILIBS) $(LDADD) -mpihelpertest2_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS) - -mpicollectivecommunication_SOURCES = mpicollectivecommunication.cc -mpicollectivecommunication_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS) -mpicollectivecommunication_LDADD = $(DUNEMPILIBS) $(LDADD) -mpicollectivecommunication_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS) - -mpiguardtest_SOURCES = mpiguardtest.cc -mpiguardtest_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS) -mpiguardtest_LDADD = $(DUNEMPILIBS) $(LDADD) -mpiguardtest_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS) - -singletontest_SOURCES = singletontest.cc - -utilitytest_SOURCES = utilitytest.cc - -testfassign1_SOURCES = testfassign.cc testfassign2.cc -testfassign1_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=3 -D_VALUES="1,2,3" - -testfassign2_SOURCES = testfassign.cc -testfassign2_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=3 -D_VALUES="1,zero" - -testfassign3_SOURCES = testfassign.cc -testfassign3_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=3 -D_VALUES="zero" - -testfassign4_SOURCES = testfassign.cc -testfassign4_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=2 -D_DUNE_TEST_M=3 -D_VALUES="1, zero, nextRow, 2, 3, 4" - -testfassign_fail1_SOURCES = testfassign.cc -testfassign_fail1_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=3 -D_VALUES="1,2" - -testfassign_fail2_SOURCES = testfassign.cc -testfassign_fail2_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=3 -D_VALUES="1,2,3,4" - -testfassign_fail3_SOURCES = testfassign.cc -testfassign_fail3_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=2 -D_DUNE_TEST_M=2 -D_VALUES="1, nextRow, 2, 3" - -testfassign_fail4_SOURCES = testfassign.cc -testfassign_fail4_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=2 -D_DUNE_TEST_M=2 -D_VALUES="1, 2, 3, nextRow, 2, 3" - -testfassign_fail5_SOURCES = testfassign.cc -testfassign_fail5_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=2 -D_DUNE_TEST_M=2 -D_VALUES="1, 2" - -testfassign_fail6_SOURCES = testfassign.cc -testfassign_fail6_CPPFLAGS = $(AM_CPPFLAGS) -D_DUNE_TEST_N=2 -D_DUNE_TEST_M=2 -D_VALUES="1, 2, nextRow, 2, 3, nextRow, 4, 5" - -testfconstruct_SOURCES = testfconstruct.cc -testfconstruct_CPPFLAGS = $(AM_CPPFLAGS) -DFVSIZE=3 - -testfconstruct_fail1_SOURCES = testfconstruct.cc -testfconstruct_fail1_CPPFLAGS = $(AM_CPPFLAGS) -DFVSIZE=2 - -testfconstruct_fail2_SOURCES = testfconstruct.cc -testfconstruct_fail2_CPPFLAGS = $(AM_CPPFLAGS) -DFVSIZE=5 - -conversiontest_SOURCES = conversiontest.cc - -sourcescheck_NOSOURCES = exprtmpl.cc timing.cc - -testfloatcmp_SOURCES = testfloatcmp.cc - -genericiterator_compile_fail_SOURCES = genericiterator_compile_fail.cc - -include $(top_srcdir)/am/global-rules diff -Nru dune-common-2.2.1/dune/common/test/mpicollectivecommunication.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/mpicollectivecommunication.cc --- dune-common-2.2.1/dune/common/test/mpicollectivecommunication.cc 2012-04-17 15:16:58.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/mpicollectivecommunication.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,54 +1,56 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include -#if HAVE_MPI -#include +#if HAVE_MPI +#include #endif -#include +#include int main(int argc, char** argv) { typedef Dune::MPIHelper Helper; Helper& mpi = Helper::instance(argc, argv); - -#if HAVE_MPI + +#if HAVE_MPI { typedef Helper::MPICommunicator MPIComm; Dune::CollectiveCommunication comm(mpi.getCommunicator()); enum { length = 5 }; - double values[5]; - for(int i=0; i disabled because MPI not available! " << std::endl; return 77; #endif diff -Nru dune-common-2.2.1/dune/common/test/mpiguardtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/mpiguardtest.cc --- dune-common-2.2.1/dune/common/test/mpiguardtest.cc 2010-06-07 11:53:30.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/mpiguardtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,91 +1,93 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #include -#include -#include +#include +#include int main(int argc, char** argv) { - Dune::MPIHelper & mpihelper = Dune::MPIHelper::instance(argc, argv); + Dune::MPIHelper & mpihelper = Dune::MPIHelper::instance(argc, argv); - if (mpihelper.rank() == 0) - std::cout << "---- default constructor" << std::endl; - try - { - // at the end of this block the guard is destroyed and possible exceptions are communicated - { - Dune::MPIGuard guard; - if (mpihelper.rank() > 0) - DUNE_THROW(Dune::Exception, "Fakeproblem on process " << mpihelper.rank()); - guard.finalize(); - } - } - catch (Dune::Exception & e) + if (mpihelper.rank() == 0) + std::cout << "---- default constructor" << std::endl; + try + { + // at the end of this block the guard is destroyed and possible exceptions are communicated + { + Dune::MPIGuard guard; + if (mpihelper.rank() > 0) + DUNE_THROW(Dune::Exception, "Fakeproblem on process " << mpihelper.rank()); + guard.finalize(); + } + } + catch (Dune::Exception & e) + { + std::cout << "Error (rank " << mpihelper.rank() << "): " + << e.what() << std::endl; + } + + mpihelper.getCollectiveCommunication().barrier(); + if (mpihelper.rank() == 0) + std::cout << "---- guard(MPI_COMM_WORLD)" << std::endl; + try + { +#if HAVE_MPI + // at the end of this block the guard is destroyed and possible exceptions are communicated { - std::cout << "Error (rank " << mpihelper.rank() << "): " - << e.what() << std::endl; + Dune::MPIGuard guard(MPI_COMM_WORLD); + if (mpihelper.rank() > 0) + DUNE_THROW(Dune::Exception, "Fakeproblem on process " << mpihelper.rank()); + guard.finalize(); } - - mpihelper.getCollectiveCommunication().barrier(); - if (mpihelper.rank() == 0) - std::cout << "---- guard(MPI_COMM_WORLD)" << std::endl; - try - { -#if HAVE_MPI - // at the end of this block the guard is destroyed and possible exceptions are communicated - { - Dune::MPIGuard guard(MPI_COMM_WORLD); - if (mpihelper.rank() > 0) - DUNE_THROW(Dune::Exception, "Fakeproblem on process " << mpihelper.rank()); - guard.finalize(); - } #else - std::cout << "Info: no mpi used\n"; + std::cout << "Info: no mpi used\n"; #endif - } - catch (Dune::Exception & e) - { - std::cout << "Error (rank " << mpihelper.rank() << "): " - << e.what() << std::endl; - } - - mpihelper.getCollectiveCommunication().barrier(); - if (mpihelper.rank() == 0) - std::cout << "---- guard(MPIHelper)" << std::endl; - try - { - // at the end of this block the guard is destroyed and possible exceptions are communicated - { - Dune::MPIGuard guard(mpihelper); - if (mpihelper.rank() > 0) - DUNE_THROW(Dune::Exception, "Fakeproblem on process " << mpihelper.rank()); - guard.finalize(); - } - } - catch (Dune::Exception & e) - { - std::cout << "Error (rank " << mpihelper.rank() << "): " - << e.what() << std::endl; - } - - - mpihelper.getCollectiveCommunication().barrier(); - if (mpihelper.rank() == 0) - std::cout << "---- manual error" << std::endl; - try - { - // at the end of this block the guard is destroyed and possible exceptions are communicated - { - Dune::MPIGuard guard; - guard.finalize(mpihelper.rank() > 0); - } - } - catch (Dune::Exception & e) - { - std::cout << "Error (rank " << mpihelper.rank() << "): " - << e.what() << std::endl; - } - - mpihelper.getCollectiveCommunication().barrier(); - if (mpihelper.rank() == 0) - std::cout << "---- done" << std::endl; + } + catch (Dune::Exception & e) + { + std::cout << "Error (rank " << mpihelper.rank() << "): " + << e.what() << std::endl; + } + + mpihelper.getCollectiveCommunication().barrier(); + if (mpihelper.rank() == 0) + std::cout << "---- guard(MPIHelper)" << std::endl; + try + { + // at the end of this block the guard is destroyed and possible exceptions are communicated + { + Dune::MPIGuard guard(mpihelper); + if (mpihelper.rank() > 0) + DUNE_THROW(Dune::Exception, "Fakeproblem on process " << mpihelper.rank()); + guard.finalize(); + } + } + catch (Dune::Exception & e) + { + std::cout << "Error (rank " << mpihelper.rank() << "): " + << e.what() << std::endl; + } + + + mpihelper.getCollectiveCommunication().barrier(); + if (mpihelper.rank() == 0) + std::cout << "---- manual error" << std::endl; + try + { + // at the end of this block the guard is destroyed and possible exceptions are communicated + { + Dune::MPIGuard guard; + guard.finalize(mpihelper.rank() > 0); + } + } + catch (Dune::Exception & e) + { + std::cout << "Error (rank " << mpihelper.rank() << "): " + << e.what() << std::endl; + } + + mpihelper.getCollectiveCommunication().barrier(); + if (mpihelper.rank() == 0) + std::cout << "---- done" << std::endl; } diff -Nru dune-common-2.2.1/dune/common/test/mpihelpertest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/mpihelpertest.cc --- dune-common-2.2.1/dune/common/test/mpihelpertest.cc 2011-03-04 09:42:58.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/mpihelpertest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,32 +1,36 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include +#include + +#include +#include int main(int argc, char** argv) { -#ifdef MPIHELPER_PREINITIALIZE +#ifdef MPIHELPER_PREINITIALIZE #if HAVE_MPI MPI_Init(&argc, &argv); #endif #endif typedef Dune::MPIHelper Helper; - + { Helper& mpi = Helper::instance(argc, argv); - - Helper::MPICommunicator comm = mpi.getCommunicator(); + + Helper::MPICommunicator comm DUNE_UNUSED = mpi.getCommunicator(); comm= mpi.getCommunicator(); } - + { Helper& mpi = Helper::instance(argc, argv); - Helper::MPICommunicator comm= mpi.getCommunicator(); + Helper::MPICommunicator comm DUNE_UNUSED = mpi.getCommunicator(); comm= mpi.getCommunicator(); #ifdef MPIHELPER_PREINITIALIZE @@ -36,5 +40,5 @@ #endif } std::cout << "We are at the end!"< diff -Nru dune-common-2.2.1/dune/common/test/nullptr-test.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/nullptr-test.cc --- dune-common-2.2.1/dune/common/test/nullptr-test.cc 2011-09-06 17:04:07.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/nullptr-test.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -void basic_tests() -{ - typedef Dune::nullptr_t NULLPTR_T; - char* ch = nullptr; // ch has the null pointer value - char* ch2 = 0; // ch2 has the null pointer value -#ifdef FAIL - int n = nullptr; // error - ++n; -#endif - int n2 = 0; // n2 is zero - if( ch == 0 ); // evaluates to true - if( ch == nullptr ); // evaluates to true - if( nullptr == ch ); // evaluates to true - if( ch ); // evaluates to false - if( n2 == 0 ); // evaluates to true - ch = ch2; -#ifdef FAIL - if( n2 == nullptr ); // error - if( nullptr ); // error, no conversion to bool - if( nullptr == 0 ); // error - // arithmetic - nullptr = 0; // error, nullptr is not an lvalue - nullptr + 2; // error -#endif -} - -int main() -{ - basic_tests(); - return 0; -} diff -Nru dune-common-2.2.1/dune/common/test/overloadsettest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/overloadsettest.cc --- dune-common-2.2.1/dune/common/test/overloadsettest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/overloadsettest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,97 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + + +#include + +#include +#include + +#include + + +int main() +{ + Dune::TestSuite test; + + { + auto foo = Dune::overload( + [](double i) { return 0; }, + [](int i) { return 1; }, + [](long i) { return 2; }); + + test.check(foo(3.14) == 0) + << "incorrect overload selected from OverloadSet"; + test.check(foo(int(42)) == 1) + << "incorrect overload selected from OverloadSet"; + test.check(foo(long(42)) == 2) + << "incorrect overload selected from OverloadSet"; + } + + { + auto foo = Dune::orderedOverload( + [](double i) { return 0; }, + [](int i) { return 1; }, + [](long i) { return 2; }); + + test.check(foo(3.14) == 0) + << "incorrect overload selected from OverloadSet"; + test.check(foo(int(42)) == 0) + << "incorrect overload selected from OverloadSet"; + test.check(foo(long(42)) == 0) + << "incorrect overload selected from OverloadSet"; + } + + { + auto foo = Dune::overload( + [](const int& i) { return 0; }, + [](int&& i) { return 1; }); + + int i = 0; + test.check(foo(long(42)) == 1) + << "incorrect overload selected from OverloadSet"; + test.check(foo(int(42)) == 1) + << "incorrect overload selected from OverloadSet"; + test.check(foo(i) == 0) + << "incorrect overload selected from OverloadSet"; + } + + { + auto foo = Dune::orderedOverload( + [](const int& i) { return 0; }, + [](int&& i) { return 1; }); + + int i = 0; + test.check(foo(long(42)) == 0) + << "incorrect overload selected from OverloadSet"; + test.check(foo(int(42)) == 0) + << "incorrect overload selected from OverloadSet"; + test.check(foo(i) == 0) + << "incorrect overload selected from OverloadSet"; + } + + { + auto t = std::make_tuple(42, "foo", 3.14); + + auto typeToName = Dune::overload( + [](int) { return "int"; }, + [](long) { return "long"; }, + [](std::string) { return "string"; }, + [](float) { return "float"; }, + [](double) { return "double"; }); + + std::string tupleTypes; + Dune::Hybrid::forEach(t, [&](auto&& ti) { + tupleTypes += typeToName(ti); + }); + + test.check(tupleTypes == "intstringdouble") + << "traversal of tuple called incorrect overloads"; + } + + + return test.exit(); +} diff -Nru dune-common-2.2.1/dune/common/test/parametertreelocaletest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/parametertreelocaletest.cc --- dune-common-2.2.1/dune/common/test/parametertreelocaletest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/parametertreelocaletest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,97 @@ +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include + +// This assert macro does not depend on the value of NDEBUG +#define check_assert(expr) \ + do \ + { \ + if(!(expr)) \ + { \ + std::cerr << __FILE__ << ":" << __LINE__ << ": check_assert(" \ + << #expr << ") failed" << std::endl; \ + std::abort(); \ + } \ + } while(false) + +// Check that the given expression throws the given exception +#define check_throw(expr, except) \ + do { \ + try { \ + expr; \ + std::cerr << __FILE__ << ":" << __LINE__ << ": " << #expr \ + << " should throw " << #except << std::endl; \ + std::abort(); \ + } \ + catch(except) {} \ + catch(...) { \ + std::cerr << __FILE__ << ":" << __LINE__ << ": " << #expr \ + << " should throw " << #except << std::endl; \ + std::abort(); \ + } \ + } while(false) + +// globally set a locale that uses "," as the decimal seperator. +// return false if no such locale is installed on the system +bool setCommaLocale() +{ + static char const* const commaLocales[] = { + "de", "de@euro", "de.UTF-8", + "de_AT", "de_AT@euro", "de_AT.UTF-8", + "de_BE", "de_BE@euro", "de_BE.UTF-8", + "de_CH", "de_CH@euro", "de_CH.UTF-8", + "de_DE", "de_DE@euro", "de_DE.UTF-8", + "de_LI", "de_LI@euro", "de_LI.UTF-8", + "de_LU", "de_LU@euro", "de_LU.UTF-8", + NULL + }; + for(char const* const* loc = commaLocales; *loc; ++loc) + { + try { + std::locale::global(std::locale(*loc)); + std::cout << "Using comma-locale " << std::locale().name() << std::endl; + return true; + } + catch(std::runtime_error) { } + } + + std::cout << "No comma-using locale found on system, tried the following:"; + std::string sep = " "; + for(char const* const* loc = commaLocales; *loc; ++loc) + { + std::cout << sep << *loc; + sep = ", "; + } + std::cout << std::endl; + return false; +} + +int main() +{ + if(!setCommaLocale()) + { + std::cerr << "No locale using comma as decimal seperator found on system" + << std::endl; + return 77; + } + { // Try with comma + Dune::ParameterTree ptree; + check_throw(ptree["setting"] = "42,42"; ptree.get("setting"), + Dune::RangeError); + } + { // Try with point + Dune::ParameterTree ptree; + check_assert((ptree["setting"] = "42.42", + ptree.get("setting") == 42.42)); + } +} diff -Nru dune-common-2.2.1/dune/common/test/parametertreetest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/parametertreetest.cc --- dune-common-2.2.1/dune/common/test/parametertreetest.cc 2012-04-18 21:43:58.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/parametertreetest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,136 +1,327 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include +#include #include +#include #include + +#include #include #include +// This assert macro does not depend on the value of NDEBUG +#define check_assert(expr) \ + do \ + { \ + if(!(expr)) \ + { \ + std::cerr << __FILE__ << ":" << __LINE__ << ": check_assert(" \ + << #expr << ") failed" << std::endl; \ + std::abort(); \ + } \ + } while(false) + +// Check that the given expression throws the given exception +#define check_throw(expr, except) \ + do { \ + try { \ + expr; \ + std::cerr << __FILE__ << ":" << __LINE__ << ": " << #expr \ + << " should throw " << #except << std::endl; \ + std::abort(); \ + } \ + catch(except) {} \ + catch(...) { \ + std::cerr << __FILE__ << ":" << __LINE__ << ": " << #expr \ + << " should throw " << #except << std::endl; \ + std::abort(); \ + } \ + } while(false) + template void testparam(const P & p) { - // try accessing key - std::cout << p.template get("x1") << std::endl; - std::cout << p.template get("x1") << std::endl; - std::cout << p.template get("x2") << std::endl; - std::cout << p.template get("x3") << std::endl; - // try reading array like structures - std::vector - array1 = p.template get< std::vector >("array"); -#ifndef NDEBUG - Dune::array - array2 = p.template get< Dune::array >("array"); - Dune::FieldVector - array3 = p.template get< Dune::FieldVector >("array"); -#endif - assert(array1.size() == 8); - std::cout << "array ="; - for (unsigned int i=0; i<8; i++) - { - assert(array1[i] == i+1); - assert(array2[i] == i+1); - assert(array3[i] == i+1); - std::cout << "\t" << array1[i]; - } - std::cout << std::endl; - // try accessing subtree - p.sub("Foo"); - p.sub("Foo").template get("peng"); - // check hasSub and hasKey - assert(p.hasSub("Foo")); - assert(!p.hasSub("x1")); - assert(p.hasKey("x1")); - assert(!p.hasKey("Foo")); - // try accessing inexistent key - try { - p.template get("bar"); - DUNE_THROW(Dune::Exception, "failed to detect missing key"); - } - catch (Dune::RangeError & r) {} - // try accessing inexistent subtree - try { - p.sub("bar"); - DUNE_THROW(Dune::Exception, "failed to detect missing subtree"); - } - catch (Dune::RangeError & r) {} - // try accessing key as subtree - try { - p.sub("x1"); - DUNE_THROW(Dune::Exception, "succeeded to access key as subtree"); - } - catch (Dune::RangeError & r) {} - // try accessing subtree as key - try { - p.template get("Foo"); - DUNE_THROW(Dune::Exception, "succeeded to access subtree as key"); - } - catch (Dune::RangeError & r) {} + // try accessing key + check_assert(p.template get("x1") == 1); + check_assert(p.template get("x1") == 1.0); + check_assert(p.template get("x2") == "hallo"); + check_assert(p.template get("x3") == false); + // try reading array like structures + std::vector + array1 = p.template get< std::vector >("array"); + std::array + array2 = p.template get< std::array >("array"); + Dune::FieldVector + array3 = p.template get< Dune::FieldVector >("array"); + check_assert(array1.size() == 8); + for (unsigned int i=0; i<8; i++) + { + check_assert(array1[i] == i+1); + check_assert(array2[i] == i+1); + check_assert(array3[i] == i+1); + } + // try accessing subtree + p.sub("Foo"); + p.sub("Foo").template get("peng"); + // check hasSub and hasKey + check_assert(p.hasSub("Foo")); + check_assert(!p.hasSub("x1")); + check_assert(p.hasKey("x1")); + check_assert(!p.hasKey("Foo")); + // try accessing inexistent key + try { + p.template get("bar"); + DUNE_THROW(Dune::Exception, "failed to detect missing key"); + } + catch (Dune::RangeError & r) {} + // try accessing inexistent subtree in throwing mode + try { + p.sub("bar",true); + DUNE_THROW(Dune::Exception, "failed to detect missing subtree"); + } + catch (Dune::RangeError & r) {} + // try accessing inexistent subtree in non-throwing mode + p.sub("bar"); + // try accessing inexistent subtree that shadows a value key + try { + p.sub("x1.bar"); + DUNE_THROW(Dune::Exception, "succeeded to access non-existent subtree that shadows a value key"); + } + catch (Dune::RangeError & r) {} + // try accessing key as subtree + try { + p.sub("x1"); + DUNE_THROW(Dune::Exception, "succeeded to access key as subtree"); + } + catch (Dune::RangeError & r) {} + // try accessing subtree as key + try { + p.template get("Foo"); + DUNE_THROW(Dune::Exception, "succeeded to access subtree as key"); + } + catch (Dune::RangeError & r) {} } template void testmodify(P parameterSet) { - parameterSet["testDouble"] = "3.14"; - parameterSet["testInt"] = "42"; - parameterSet["testString"] = "Hallo Welt!"; - parameterSet["testVector"] = "2 3 5 7 11"; - parameterSet.sub("Foo")["bar"] = "2"; - - double testDouble = parameterSet.template get("testDouble"); - int testInt = parameterSet.template get("testInt"); - ++testDouble; - ++testInt; - std::string testString = parameterSet.template get("testString"); - typedef Dune::FieldVector FVector; - FVector testFVector = parameterSet.template get("testVector"); - typedef std::vector SVector; - SVector testSVector = parameterSet.template get("testVector"); - if(testSVector.size() != 5) - DUNE_THROW(Dune::Exception, "Testing std::vector: expected " - "size()==5, got size()==" << testSVector.size()); - for(unsigned i = 0; i < 5; ++i) - if(testFVector[i] != testSVector[i]) - DUNE_THROW(Dune::Exception, - "testFVector[" << i << "]==" << testFVector[i] << " but " - "testSVector[" << i << "]==" << testSVector[i]); - if (parameterSet.template get("Foo.bar") != "2") - DUNE_THROW(Dune::Exception, "Failed to write subtree entry"); - if (parameterSet.sub("Foo").template get("bar") != "2") - DUNE_THROW(Dune::Exception, "Failed to write subtree entry"); + parameterSet["testDouble"] = "3.14"; + parameterSet["testInt"] = "42"; + parameterSet["testString"] = "Hallo Welt!"; + parameterSet["testVector"] = "2 3 5 7 11"; + parameterSet.sub("Foo")["bar"] = "2"; + + double testDouble = parameterSet.template get("testDouble"); + int testInt = parameterSet.template get("testInt"); + ++testDouble; + ++testInt; + std::string testString = parameterSet.template get("testString"); + typedef Dune::FieldVector FVector; + FVector testFVector = parameterSet.template get("testVector"); + typedef std::vector SVector; + SVector testSVector = parameterSet.template get("testVector"); + if(testSVector.size() != 5) + DUNE_THROW(Dune::Exception, "Testing std::vector: expected " + "size()==5, got size()==" << testSVector.size()); + for(unsigned i = 0; i < 5; ++i) + if(testFVector[i] != testSVector[i]) + DUNE_THROW(Dune::Exception, + "testFVector[" << i << "]==" << testFVector[i] << " but " + "testSVector[" << i << "]==" << testSVector[i]); + if (parameterSet.template get("Foo.bar") != "2") + DUNE_THROW(Dune::Exception, "Failed to write subtree entry"); + if (parameterSet.sub("Foo").template get("bar") != "2") + DUNE_THROW(Dune::Exception, "Failed to write subtree entry"); +} + +void testOptionsParserResults(std::vector args, + const std::vector & keywords, + unsigned int required, + bool allow_more, + bool overwrite, + std::string foo, std::string bar, + const std::string referr = "") +{ + Dune::ParameterTree pt; + try { + char * argv[10]; + for (std::size_t i = 0; i < args.size(); ++i) + argv[i] = &args[i][0]; + Dune::ParameterTreeParser::readNamedOptions(args.size(), argv, pt, keywords, required, allow_more, overwrite); + check_assert(referr == ""); + } + catch (const Dune::ParameterTreeParserError & e) + { + std::string err = e.what(); + std::size_t offset = err.find("]: "); + err = err.substr(offset + 3, err.find('\n') - offset - 3); + check_assert(referr == err); + } + if (foo != "" && foo != pt.get("foo")) + DUNE_THROW(Dune::Exception, "Options parser failed... foo = " + << pt.get("foo") << " != " << foo); + if (bar != "" && bar != pt.get("bar")) + DUNE_THROW(Dune::Exception, "Options parser failed... bar = " + << pt.get("bar") << " != " << bar); +} + +void testOptionsParser() +{ + std::vector keywords = { "foo", "bar" }; + // check normal behaviour + { + std::vector args = { "progname", "--bar=ligapokal", "peng", "--bar=ligapokal", "--argh=other"}; + testOptionsParserResults(args,keywords,keywords.size(),true,true,"peng","ligapokal", + "" /* no error */ ); + } + // bail out on overwrite + { + std::vector args = { "progname", "--bar=ligapokal", "peng", "--bar=ligapokal", "--argh=other"}; + testOptionsParserResults(args,keywords,keywords.size(),true,false,"peng","ligapokal", + "parameter bar already specified"); + } + // bail out on unknown options + { + std::vector args = { "progname", "--bar=ligapokal", "peng", "--bar=ligapokal", "--argh=other"}; + testOptionsParserResults(args,keywords,keywords.size(),false,true,"peng","ligapokal", + "unknown parameter argh"); + } + // bail out on missing parameter + { + std::vector args = { "progname", "--bar=ligapokal"}; + testOptionsParserResults(args,keywords,keywords.size(),true,true,"","ligapokal", + "missing parameter(s) ... foo"); + } + // check optional parameter + { + std::vector args = { "progname", "--foo=peng"}; + testOptionsParserResults(args,keywords,1,true,true,"peng","", + "" /* no error */); + } + // check optional parameter, but bail out on missing parameter + { + std::vector args = { "progname", "--bar=ligapokal"}; + testOptionsParserResults(args,keywords,1,true,true,"","ligapokal", + "missing parameter(s) ... foo"); + } + // bail out on too many parameters + { + std::vector args = { "progname", "peng", "ligapokal", "hurz"}; + testOptionsParserResults(args,keywords,keywords.size(),true,true,"peng","ligapokal", + "superfluous unnamed parameter"); + } + // bail out on missing value + { + std::vector args = { "progname", "--foo=peng", "--bar=ligapokal", "--hurz"}; + testOptionsParserResults(args,keywords,keywords.size(),true,true,"peng","ligapokal", + "value missing for parameter --hurz"); + } +} + +void testFS1527() +{ + { // Check that junk at the end is not accepted (int) + Dune::ParameterTree ptree; + check_throw(ptree["setting"] = "0.5"; ptree.get("setting", 0), + Dune::RangeError); + } + { // Check that junk at the end is not accepted (double) + Dune::ParameterTree ptree; + check_throw(ptree["setting"] = "0.5 junk"; ptree.get("setting", 0.0), + Dune::RangeError); + } +} + +// check that negative values can be given on the command line +void testFS1523() +{ + static char arg0[] = "progname"; + static char arg1[] = "-setting"; + static char arg2[] = "-1"; + static char *argv[] = { arg0, arg1, arg2, NULL }; + int argc = sizeof argv / sizeof (char *) - 1; + + Dune::ParameterTree ptree; + Dune::ParameterTreeParser::readOptions(argc, argv, ptree); + + check_assert(ptree.get("setting") == -1); +} + +void check_recursiveTreeCompare(const Dune::ParameterTree & p1, + const Dune::ParameterTree & p2) +{ + check_assert(p1.getValueKeys() == p2.getValueKeys()); + check_assert(p1.getSubKeys() == p2.getSubKeys()); + typedef Dune::ParameterTree::KeyVector::const_iterator Iterator; + for (Iterator it = p1.getValueKeys().begin(); + it != p1.getValueKeys().end(); ++it) + check_assert(p1[*it] == p2[*it]); + for (Iterator it = p1.getSubKeys().begin(); + it != p1.getSubKeys().end(); ++it) + check_recursiveTreeCompare(p1.sub(*it), p2.sub(*it)); +} + +// test report method and read back in +void testReport() +{ + std::stringstream s; + s << "foo.i = 1 \n foo.bar.peng = hurz"; + Dune::ParameterTree ptree; + Dune::ParameterTreeParser::readINITree(s, ptree); + + std::stringstream s2; + ptree.report(s2); + Dune::ParameterTree ptree2; + Dune::ParameterTreeParser::readINITree(s2, ptree2); + check_recursiveTreeCompare(ptree, ptree2); } int main() { - try { - // read config - std::stringstream s; - s << "x1 = 1 # comment\n" - << "x2 = hallo\n" - << "x3 = no\n" - << "array = 1 2 3 4 5\t6 7 8\n" - << "\n" - << "[Foo]\n" - << "peng = ligapokal\n"; - - Dune::ParameterTree c; - Dune::ParameterTreeParser::readINITree(s, c); - - // test modifying and reading - testmodify(c); - try { - c.get("testInt"); - DUNE_THROW(Dune::Exception, "unexpected shallow copy of ParameterTree"); - } - catch (Dune::RangeError & r) {} + try { + // read config + std::stringstream s; + s << "x1 = 1 # comment\n" + << "x2 = hallo\n" + << "x3 = no\n" + << "array = 1 2 3 4 5\t6 7 8\n" + << "\n" + << "[Foo]\n" + << "peng = ligapokal\n"; - // more const tests - testparam(c); - } - catch (Dune::Exception & e) - { - std::cout << e << std::endl; - return 1; + Dune::ParameterTree c; + Dune::ParameterTreeParser::readINITree(s, c); + + // test modifying and reading + testmodify(c); + try { + c.get("testInt"); + DUNE_THROW(Dune::Exception, "unexpected shallow copy of ParameterTree"); } - return (0); + catch (Dune::RangeError & r) {} + + // more const tests + testparam(c); + + // check the command line parser + testOptionsParser(); + + // check report + testReport(); + + // check for specific bugs + testFS1527(); + testFS1523(); + } + catch (Dune::Exception & e) + { + std::cout << e << std::endl; + return 1; + } + return 0; } diff -Nru dune-common-2.2.1/dune/common/test/pathtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/pathtest.cc --- dune-common-2.2.1/dune/common/test/pathtest.cc 2010-06-08 11:08:56.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/pathtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,5 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #if HAVE_CONFIG_H #include "config.h" #endif @@ -16,8 +16,8 @@ if(!status) code = 1; else - if(code == 77) - code = 0; + if(code == 77) + code = 0; } void concatPathsTests(int& code) { @@ -203,7 +203,3 @@ throw; } } - - - - diff -Nru dune-common-2.2.1/dune/common/test/poolallocatortest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/poolallocatortest.cc --- dune-common-2.2.1/dune/common/test/poolallocatortest.cc 2012-04-05 12:19:01.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/poolallocatortest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,12 +1,11 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include +#include +#include using namespace Dune; @@ -18,14 +17,14 @@ }; - + template struct testPoolMain { static int test() { int ret=0; - + Pool pool; int elements = Pool::elements; @@ -34,20 +33,20 @@ //int alignedSize = Pool::alignedSize; unsigned long* oelements = new unsigned long[10*elements]; - + typedef typename Pool::Chunk Chunk; - + //Fill 10 chunks - for(int chunk=0; chunk < 10; ++chunk){ + for(int chunk=0; chunk < 10; ++chunk) { //std::cout<< std::endl<<"Chunk "<(pool.allocate()); //void* celement = reinterpret_cast(element); //std::cout << element<<" "<< celement<<", "<(currentChunk->memory_)); - unsigned long end = reinterpret_cast(currentChunk->chunk_)+Pool::chunkSize; + unsigned long end = reinterpret_cast(currentChunk->chunk_)+Pool::chunkSize; if(element< reinterpret_cast(currentChunk->chunk_)) { @@ -55,45 +54,45 @@ <<">"<(pool.allocate()); //celement = reinterpret_cast(element); //std::cout << element<<" "<(currentChunk->chunk_)){ + if(element< reinterpret_cast(currentChunk->chunk_)) { std::cerr <<" buffer underflow during first alloc: "<(currentChunk->chunk_) <<">"<element){ + if(oelements[chunk*elements+i-1]+sizeof(T)>element) { std::cerr<<"allocated elements overlap!"<(oelements+i)); + pool.free(reinterpret_cast(oelements[i])); delete[] oelements; return ret; @@ -103,38 +102,63 @@ template int testPool() { - const std::size_t size = sizeof(T)>=2?sizeof(T)-2:0; - + const std::size_t size = sizeof(T)>=2 ? sizeof(T)-2 : 0; + int ret=0; - + std::cout<<"Checking "<(); - + ret+= testPool(); ret+= testPool(); - + ret += testPool >(); + ret+=testPoolAllocator(); - std::cout<::value<<" "<(); - + return ret; } diff -Nru dune-common-2.2.1/dune/common/test/rangeutilitiestest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/rangeutilitiestest.cc --- dune-common-2.2.1/dune/common/test/rangeutilitiestest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/rangeutilitiestest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,81 @@ +#include "config.h" + +#include + +#include +#include +#include +#include + + +int main() +{ + // Check is_range<> for https://gitlab.dune-project.org/core/dune-common/issues/58 + static_assert(Dune::is_range< std::array >::value, "std::array must be a range"); + static_assert(Dune::is_range< Dune::IteratorRange >::value, "IteratorRange must be a range"); + static_assert(!Dune::is_range< int >::value, "int must not be a range"); + + Dune::TestSuite suite; + + // max_value, min_value + { + const int value = 12; + suite.check(Dune::max_value(value) == value); + suite.check(Dune::min_value(value) == value); + + std::array values{-42, 0, 42}; + suite.check(Dune::max_value(values) == 42) + << "maximum of values is 42, but got " << Dune::max_value(values); + suite.check(Dune::min_value(values) == -42) + << "minimum of values is -42, but got " << Dune::min_value(values); + + std::array positiveValues{1, 2, 3}; + suite.check(Dune::max_value(positiveValues) == 3) + << "maximum of positiveValues is 3, but got " << Dune::max_value(positiveValues); + suite.check(Dune::min_value(positiveValues) == 1) + << "minimum of positiveValues is 1, but got " << Dune::min_value(positiveValues); + + std::array negativeValues{-1, -3, -1}; + suite.check(Dune::max_value(negativeValues) == -1) + << "maximum of negativeValues is -1, but got " << Dune::max_value(negativeValues); + suite.check(Dune::min_value(negativeValues) == -3) + << "minimum of negativeValues is -3, but got " << Dune::min_value(negativeValues); + } + + // any_true, all_true + { + const std::array allTrue{true, true, true}; + const std::array allFalse{false, false, false}; + const std::array someTrue{false, true, false}; + + suite.check(Dune::any_true(allTrue)) + << "any_true(allTrue) must be true"; + suite.check(!Dune::any_true(allFalse)) + << "any_true(allFalse) must be false"; + suite.check(Dune::any_true(someTrue)) + << "any_true(someTrue) must be true"; + + suite.check(Dune::all_true(allTrue)) + << "all_true(allTrue) must be true"; + suite.check(!Dune::all_true(allFalse)) + << "all_true(allFalse) must be false"; + suite.check(!Dune::all_true(someTrue)) + << "all_true(someTrue) must be false"; + + const bool t = true; + const bool f = false; + + suite.check(Dune::any_true(t)) + << "any_true(true) must be true"; + suite.check(!Dune::any_true(f)) + << "any_true(false) must be false"; + + suite.check(Dune::all_true(t)) + << "all_true(true) must be true"; + suite.check(!Dune::all_true(f)) + << "all_true(false) must be false"; + } + + return suite.exit(); + +} diff -Nru dune-common-2.2.1/dune/common/test/shared_ptrtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/shared_ptrtest.cc --- dune-common-2.2.1/dune/common/test/shared_ptrtest.cc 2013-01-25 21:35:58.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/shared_ptrtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,7 +1,5 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set ts=8 sw=4 et sts=4: - -// $Id: shared_ptrtest.cc 7090 2013-01-25 21:35:58Z mblatt $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: // make sure assert works even when not compiling for debugging #ifdef NDEBUG @@ -12,36 +10,31 @@ #include "config.h" #endif -#if defined(DISABLE_CONFIGURED_SHARED_PTR) && defined(SHARED_PTR_NAMESPACE) -#undef SHARED_PTR_NAMESPACE -#undef HAVE_MAKE_SHARED -#endif - -#include -#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include template class Deleter { public: - Deleter(bool& deleted) : - deleted_(deleted) - {} - - void operator() (T* p) const - { - delete p; - deleted_ = true; - } + Deleter(bool& deleted) : + deleted_(deleted) + {} + + void operator() (T* p) const + { + delete p; + deleted_ = true; + } private: - bool& deleted_; + bool& deleted_; }; class A {}; @@ -51,202 +44,202 @@ Dune::shared_ptr test_make_shared() { - return Dune::make_shared(); + return Dune::make_shared(); } int main(){ - using namespace Dune; - int ret=0; + using namespace Dune; + int ret=0; + { + // test default constructor + shared_ptr foo; + + // test conversion in make_shared + shared_ptr a=test_make_shared(); + + { + shared_ptr b(new B); + a=b; + + if(b.use_count()!=2) { + std::cout << "Reference count is wrong! "<<__LINE__<<":"<< + __FILE__< bar(foo); + shared_ptr baz; + baz = foo; + } + + // test cast-to-bool + if (foo) { + std::cout << "Default constructor doesn't create a NULL pointer!" << std::endl; + ret=1; + } + + // test custom deleter + bool deleted = false; + { + shared_ptr bar(new int(1), Deleter(deleted)); + + //test if deleter is called + deleted = false; + bar.reset(new int(2)); // this should call the deleter in the constructor + if (not (deleted)) + { + std::cout << "Custom deleter not called!" << std::endl; + ret=1; + } + + //test if old deleter is not called + deleted = false; + bar.reset(); // this should call no deleter + if (deleted) + { + std::cout << "Old deleter was called!" << std::endl; + ret=1; + } + + //test if old deleter is not called + deleted = false; + bar.reset(new int(3), Deleter(deleted)); // this should call no deleter + if (deleted) + { + std::cout << "Old deleter was called!" << std::endl; + ret=1; + } + // going out of scope should call the deleter + } + if (not (deleted)) + { + std::cout << "Custom deleter not called!" << std::endl; + ret=1; + } + { + shared_ptr bar(new int(1), Deleter(deleted)); + + bar.reset(new int(4)); // this should call the deleter... + + deleted = false; + // ... but going out of scope should call no deleter + } + if (deleted) { - // test default constructor - shared_ptr foo; - - // test conversion in make_shared - shared_ptr a=test_make_shared(); - - { - shared_ptr b(new B); - a=b; - - if(b.use_count()!=2){ - std::cout << "Reference count is wrong! "<<__LINE__<<":"<< - __FILE__< bar(foo); - shared_ptr baz; - baz = foo; - } - - // test cast-to-bool - if (foo) { - std::cout << "Default constructor doesn't create a NULL pointer!" << std::endl; - ret=1; - } - - // test custom deleter - bool deleted = false; - { - shared_ptr foo(new int(1), Deleter(deleted)); - - //test if deleter is called - deleted = false; - foo.reset(new int(2)); // this should call the deleter in the constructor - if (not(deleted)) - { - std::cout << "Custom deleter not called!" << std::endl; - ret=1; - } - - //test if old deleter is not called - deleted = false; - foo.reset(); // this should call no deleter - if (deleted) - { - std::cout << "Old deleter was called!" << std::endl; - ret=1; - } - - //test if old deleter is not called - deleted = false; - foo.reset(new int(3), Deleter(deleted)); // this should call no deleter - if (deleted) - { - std::cout << "Old deleter was called!" << std::endl; - ret=1; - } - // going out of scope should call the deleter - } - if (not(deleted)) - { - std::cout << "Custom deleter not called!" << std::endl; - ret=1; - } - { - shared_ptr foo(new int(1), Deleter(deleted)); - - foo.reset(new int(4)); // this should call the deleter... - - deleted = false; - // ... but going out of scope should call no deleter - } - if (deleted) - { - std::cout << "1Old deleter was called!" << std::endl; - ret=1; - } - - // test constructor from a given pointer - shared_ptr bar(new double(43.0)); - assert(bar); - - // test constructor from nullptr -#if defined(SHARED_PTR_HEADER) && !defined(HAVE_NULLPTR) - #warning Construction of shared_ptr from a nullptr will not work as compiler + std::cout << "1Old deleter was called!" << std::endl; + ret=1; + } + + // test constructor from a given pointer + shared_ptr bar(new double(43.0)); + assert(bar); + + // test constructor from nullptr +#ifndef HAVE_NULLPTR + #warning Construction of shared_ptr from a nullptr will not work as compiler #warning does not support the latter. - shared_ptr bar_null=shared_ptr(); + shared_ptr bar_null=shared_ptr(); #else - shared_ptr bar_null(nullptr); + shared_ptr bar_null(nullptr); #endif - assert(!bar_null); - assert(!bar_null.get()); + assert(!bar_null); + assert(!bar_null.get()); + + // test reset() + bar.reset(); + assert(!bar); + + // test get() for empty shared_ptr + assert(!bar.get()); + + // test reset(T*) + double* p = new double(44.0); + bar.reset(p); + assert(bar); + assert(bar.use_count()==1); + + // test get() + double* barPtr = bar.get(); + assert(barPtr==p); + + // test constructor from a given pointer + shared_ptr b(new double(42.0)); + { + shared_ptr d(b); + *b = 7; + } + + if(b.use_count()!=1) { + std::cout << "Reference count is wrong! "<<__LINE__<<":"<< + __FILE__< c(b); - // test reset() - bar.reset(); - assert(!bar); - - // test get() for empty shared_ptr - assert(!bar.get()); - - // test reset(T*) - double* p = new double(44.0); - bar.reset(p); - assert(bar); - assert(bar.use_count()==1); - - // test get() - double* barPtr = bar.get(); - assert(barPtr==p); - - // test constructor from a given pointer - shared_ptr b(new double(42.0)); - { - shared_ptr d(b); - *b = 7; - } - - if(b.use_count()!=1){ - std::cout << "Reference count is wrong! "<<__LINE__<<":"<< - __FILE__< c(b); - - if(*b!=*c){ - std::cerr<<"References do not match! "<<__LINE__<<":"<< - __FILE__< foo = shared_ptr(new int(42)); - shared_ptr bar; //null ptr - - foo = bar; // should release memory held by foo - } - - // test shared_ptr for stack allocation - { - int i = 10; - shared_ptr pi = stackobject_to_shared_ptr(i); - } - - // test shared_ptr for stack allocation with down cast - { - B b; - shared_ptr pa = stackobject_to_shared_ptr(b); + if(*b!=*c) { + std::cerr<<"References do not match! "<<__LINE__<<":"<< + __FILE__< foobar = shared_ptr(new int(42)); + shared_ptr foobaz; //null ptr + + foobar = foobaz; // should release memory held by foo + } + + // test shared_ptr for stack allocation + { + int i = 10; + shared_ptr pi = stackobject_to_shared_ptr(i); + } + + // test shared_ptr for stack allocation with down cast + { + B b2; + shared_ptr pa = stackobject_to_shared_ptr(b2); #ifdef SHARED_PTR_COMPILE_FAIL - C c; - pa = stackobject_to_shared_ptr(c); // A is an inaccessible base of C + C c; + pa = stackobject_to_shared_ptr(c); // A is an inaccessible base of C #endif - } } - return (ret); + } + return (ret); } diff -Nru dune-common-2.2.1/dune/common/test/singletontest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/singletontest.cc --- dune-common-2.2.1/dune/common/test/singletontest.cc 2008-11-15 17:55:56.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/singletontest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,9 +1,11 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include +#include +#include class Foo : public Dune::Singleton { public: @@ -11,7 +13,7 @@ { bytes = new char[1000]; } - + ~Foo() { delete[] bytes; @@ -27,7 +29,7 @@ { bytes = new char[1000]; } - + ~Foo1() { delete[] bytes; @@ -55,7 +57,7 @@ int testFoo() { - if(globalFoo != &Foo::instance()){ + if(globalFoo != &Foo::instance()) { std::cerr<<" Foo is not a real singleton!"< -#include -#include -#include +#include +#include +#include +#include class DoubleWrapper { public: - DoubleWrapper(double b) + DoubleWrapper(double b) : d(b) { std::cout<<"Constructed "<::const_iterator Iterator; Iterator tail=alist.begin(); - + for(int i = alist.size() - 1; i > 0; --i) ++tail; return *tail; } - + template int check(const Dune::SLList& alist, const T* vals) { typedef typename Dune::SLList::const_iterator iterator; int i=0; - for(iterator iter = alist.begin(); iter != alist.end(); ++iter, i++){ - if( vals[i] != *iter ){ + for(iterator iter = alist.begin(); iter != alist.end(); ++iter, i++) { + if( vals[i] != *iter ) { std::cerr<<" List missmatch! "<<__FILE__<<":"<<__LINE__< void randomizeListBack(Dune::SLList& alist){ - using namespace Dune; - - srand(300); - - int lowest=0, highest=1000, range=(highest-lowest)+1; - - T vals[10]; - - for(int i=0; i < 10; i++){ - T d = T(range*(rand()/(RAND_MAX+1.0))); - alist.push_back(d); - vals[i]=d; - } - - check(alist, vals); + using namespace Dune; + + srand(300); + + int lowest=0, highest=1000, range=(highest-lowest)+1; + + T vals[10]; + + for(int i=0; i < 10; i++) { + T d = T(range*(rand()/(RAND_MAX+1.0))); + alist.push_back(d); + vals[i]=d; + } + + check(alist, vals); } template void randomizeListFront(Dune::SLList& alist){ - using namespace Dune; - - srand(300); - T vals[10]; - - int lowest=0, highest=1000, range=(highest-lowest)+1; - - for(int i=0; i < 10; i++){ - T d = T(range*(rand()/(RAND_MAX+1.0))); - alist.push_front(d); - vals[9-i]=d; - } - - check(alist, vals); + using namespace Dune; + + srand(300); + T vals[10]; + + int lowest=0, highest=1000, range=(highest-lowest)+1; + + for(int i=0; i < 10; i++) { + T d = T(range*(rand()/(RAND_MAX+1.0))); + alist.push_front(d); + vals[9-i]=d; + } + + check(alist, vals); } int testAssign() { typedef Dune::SLList List; List alist, blist; - + alist.push_back(3); alist.push_back(4); alist.push_back(5); - + blist.push_back(-1); - + blist=alist; List::iterator biter=blist.begin(), aiter=alist.begin(); for(; aiter!=alist.end(); ++aiter, ++biter) - if(*aiter!=*biter){ + if(*aiter!=*biter) { std::cerr<<"Asignment failed "<<__FILE__<<":"<<__LINE__< List; List alist; - + alist.push_back(3); alist.push_back(4); alist.push_back(5); - + List::ModifyIterator iter = alist.beginModify(); iter.remove(); - if(*(alist.begin())!=4){ + if(*(alist.begin())!=4) { std::cerr<<"delete next on position before head failed! "<<__FILE__<<":"<<__LINE__< List; int ret = 0; - + List alist; - if(!alist.empty()){ + if(!alist.empty()) { std::cerr<<"Newly created list not empty! "<<__FILE__<<":"<<__LINE__<0; --elements) alist.pop_front(); - - if(!alist.empty()){ + + if(!alist.empty()) { std::cerr<<"Emptied list not empty! "<<__FILE__<<":"<<__LINE__< alist; - //std::cout<<"PushPop 1:"< alist; + //std::cout<<"PushPop 1:"< list; Dune::SLList list, list1; Dune::SLList list2; @@ -377,7 +377,7 @@ randomizeListFront(list); Dune::SLList copied(list); - if(copied.size()!=list.size()){ + if(copied.size()!=list.size()) { std::cerr << "Size of copied list does not match!"<::const_iterator Iterator; Iterator iend = list.end(); for(Iterator iter1=list.begin(), iter2=copied.begin(); iter1 != iend; ++iter1, ++iter2) - if(*iter1!=*iter2){ - std::cerr << "Entries of copied are not the same!"<::ModifyIterator>::value_type> print; - + Dune::SLList::ModifyIterator lbegin = list.beginModify(), lend = list.endModify(); - + double& d = lbegin.dereference(); - + d=2.0; double& d1 = lbegin.dereference(); d1=3.0; - + lbegin.dereference()=5.0; lbegin.operator*()=5.0; *lbegin=5.0; - + std::cout << "Testing ConstIterator "< - -int main() -{ - dune_static_assert(true, "OK"); - return 0; -} diff -Nru dune-common-2.2.1/dune/common/test/static_assert_test_fail.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/static_assert_test_fail.cc --- dune-common-2.2.1/dune/common/test/static_assert_test_fail.cc 2009-12-04 11:52:49.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/static_assert_test_fail.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include - -int main() -{ - dune_static_assert(false, "FAIL"); - return 0; -} diff -Nru dune-common-2.2.1/dune/common/test/stdapplytest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/stdapplytest.cc --- dune-common-2.2.1/dune/common/test/stdapplytest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/stdapplytest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,51 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include + +#include + + +template +void nop(std::initializer_list&&) +{} + + +int main() +{ + auto args = std::make_tuple(true, 2, 3, "abc"); + + Dune::TestSuite test; + + auto concat = [](auto&&... args) { + bool first = true; + std::stringstream stream; + nop({(stream << (first ? "":",") << args, first = false)...}); + return stream.str(); + }; + + test.check(Dune::Std::apply(concat, args) == "1,2,3,abc") << "Dune::Std::apply failed with concat lambda"; + + auto makeTuple = [](auto&&... args) { + return std::make_tuple(args...); + }; + + test.check(Dune::Std::apply(makeTuple, args) == args) << "Dune::Std::apply failed with makeTuple lambda"; + + auto intTuple = std::make_tuple(1,2,3); + auto&& intTuple0 = Dune::Std::apply([](auto&& arg0, auto&&... args) -> decltype(auto) { return arg0; }, intTuple); + intTuple0 = 42; + + test.check(std::get<0>(intTuple) == intTuple0) << "Dune::Std::apply does not properly return references"; + + + return test.exit(); +} diff -Nru dune-common-2.2.1/dune/common/test/stdtypetraitstest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/stdtypetraitstest.cc --- dune-common-2.2.1/dune/common/test/stdtypetraitstest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/stdtypetraitstest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,75 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + + +#include + +#include + + +int main() +{ + Dune::TestSuite test; + + { + auto f = [](int i) { return 0; }; + using F = decltype(f); + + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept copy from r-value"; + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept copy from l-value reference"; + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept copy from r-value reference"; + + test.check(Dune::Std::is_callable() == false) + << "Dune::Std::is_callable accepts invalid argument type"; + test.check(Dune::Std::is_callable() == false) + << "Dune::Std::is_callable accepts invalid argument count"; + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept valid return type"; + test.check(Dune::Std::is_callable() == false) + << "Dune::Std::is_callable accepts invalid return type"; + } + + { + auto f = [](const int& i) {}; + using F = decltype(f); + + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept const& temporary from r-value"; + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept const& temporary from l-value reference"; + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept const& temporary from r-value reference"; + } + + { + auto f = [](int& i) {}; + using F = decltype(f); + + test.check(Dune::Std::is_callable() == false) + << "Dune::Std::is_callable accepts l-value reference from r-value"; + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept l-value reference from l-value reference"; + test.check(Dune::Std::is_callable() == false) + << "Dune::Std::is_callable accepts l-value reference from r-value reference"; + } + + { + auto f = [](int&& i) {}; + using F = decltype(f); + + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept r-value reference from r-value"; + test.check(Dune::Std::is_callable() == false) + << "Dune::Std::is_callable accepts r-value reference from l-value reference"; + test.check(Dune::Std::is_callable() == true) + << "Dune::Std::is_callable does not accept r-value reference from r-value reference"; + } + + return test.exit(); +} diff -Nru dune-common-2.2.1/dune/common/test/streamoperatorstest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/streamoperatorstest.cc --- dune-common-2.2.1/dune/common/test/streamoperatorstest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/streamoperatorstest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,46 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include + +using Dune::operator>>; +using Dune::operator<<; + +int main() +{ + typedef std::tuple Tuple; + + { + const Tuple t{1, 2, 3}; + const std::string expected = "[1,2,3]"; + + std::ostringstream out; + out << t; + + if( out.str() != expected ) + return 1; + } + + { + const std::string data = "1 2 3"; + const Tuple expected{1, 2, 3}; + + std::istringstream in(data); + Tuple t; + in >> t; + + if( t != expected ) + return 1; + } + + return 0; +} diff -Nru dune-common-2.2.1/dune/common/test/streamtest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/streamtest.cc --- dune-common-2.2.1/dune/common/test/streamtest.cc 2008-11-15 17:55:56.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/streamtest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,11 +1,12 @@ -// $Id: streamtest.cc 5371 2008-11-15 17:55:56Z christi $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: /* - Test to check if the standard streams in libdune can be properly - linked with this program and if they work + Test to check if the standard streams in libdune can be properly + linked with this program and if they work -*/ + */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -20,7 +21,7 @@ int main () { try { // let output happen but vanish - std::ofstream dummy("/dev/null"); + std::ofstream dummy("/dev/null"); Dune::derr.attach(dummy); Dune::derr.push(true); @@ -32,7 +33,7 @@ Dune::dinfo << VALUE << std::endl; Dune::dwarn << VALUE << std::endl; Dune::dgrave << VALUE << std::endl; - + // instantiate private stream and connect global stream { Dune::DebugStream<> mystream(dummy); @@ -42,7 +43,7 @@ Dune::derr.untie(); } - Dune::derr << "Still working" << std::endl; + Dune::derr << "Still working" << std::endl; } catch (Dune::Exception &e) { std::cerr << e << std::endl; return 2; diff -Nru dune-common-2.2.1/dune/common/test/stringutilitytest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/stringutilitytest.cc --- dune-common-2.2.1/dune/common/test/stringutilitytest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/stringutilitytest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,58 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include + +namespace { +const std::string hello_world("hello world"); +} /* namespace */ + +bool test_hasPrefix() +{ + bool pass = true; + + using Dune::hasPrefix; + pass &= hasPrefix(hello_world, "hello"); + pass &= !hasPrefix(hello_world, "world"); + + return pass; +} + +bool test_hasSuffix() +{ + bool pass = true; + + using Dune::hasSuffix; + pass &= hasSuffix(hello_world, "world"); + pass &= !hasSuffix(hello_world, "hello"); + + return pass; +} + +bool test_formatString() +{ + bool pass = true; + const int one = 1; + const static std::string format("hello %i"); + const static std::string expected("hello 1"); + + using Dune::formatString; + const std::string s = formatString(format, one); + pass &= (s == expected); + + return pass; +} + +int main() +{ + bool pass = true; + + pass &= test_hasPrefix(); + pass &= test_hasSuffix(); + pass &= test_formatString(); + + return pass ? 0 : 1; +} diff -Nru dune-common-2.2.1/dune/common/test/testdebugallocator.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testdebugallocator.cc --- dune-common-2.2.1/dune/common/test/testdebugallocator.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testdebugallocator.cc 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,108 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +// #define DEBUG_ALLOCATOR_KEEP 1 +#define DEBUG_NEW_DELETE 3 + +#include + +#include +#include +#include +#include + +class A +{ +public: + A() { std::cout << "INIT A\n"; } + int x; + void foo() {}; +}; + +void basic_tests () +{ + using Dune::DebugMemory::alloc_man; + + size_t s = 256; + double * x = alloc_man.allocate(s); + x[s-1] = 10; + + // access out of bounds +#ifdef FAILURE1 + x[s+1] = 1; +#endif + + // lost allocation, free and double-free +#ifndef FAILURE2 + alloc_man.deallocate(x); +#endif +#ifdef FAILURE3 + alloc_man.deallocate(x); +#endif + + // access after free +#ifdef FAILURE4 + x[s-1] = 10; +#endif +} + +void allocator_tests() +{ + std::vector > v; + v.push_back(10); + v.push_back(12); + v.size(); + std::cout << v[0] << "\n"; + std::cout << v[1] << "\n"; +#ifdef FAILURE5 + std::cout << v[v.capacity()] << "\n"; +#endif +} + +void new_delete_tests() +{ + std::cout << "alloc double[3]\n"; + double * y = new double[3]; + delete[] y; + + std::cout << "alloc A[2]\n"; + A * z = new A[2]; + z->foo(); + delete[] z; + z = 0; + + std::cout << "alloc (buf) A[3]\n"; + char * buf = (char*)malloc(128); + A * z2 = new (buf) A[3]; + z2->foo(); + free(buf); + z2 = 0; + + std::cout << "alloc A[4]\n"; + A * z4 = ::new A[4]; + z4->foo(); + ::delete[] z4; + z4 = 0; +} + +int main(int, char**) +{ +#if EXPECTED_SIGNAL + std::signal(EXPECTED_SIGNAL, std::_Exit); +#endif +#if EXPECTED_ALT_SIGNAL + std::signal(EXPECTED_ALT_SIGNAL, std::_Exit); +#endif + + basic_tests(); + allocator_tests(); + new_delete_tests(); +#ifdef EXPECTED_SIGNAL + return 1; +#else + return 0; +#endif +} diff -Nru dune-common-2.2.1/dune/common/test/testfassign2.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testfassign2.cc --- dune-common-2.2.1/dune/common/test/testfassign2.cc 2008-11-15 17:55:56.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testfassign2.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include diff -Nru dune-common-2.2.1/dune/common/test/testfassign.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testfassign.cc --- dune-common-2.2.1/dune/common/test/testfassign.cc 2011-10-19 10:23:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testfassign.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -using Dune::zero; -using Dune::nextRow; - -template struct Print {}; - -template -struct Print< Dune::FieldVector > -{ - static void print(Dune::FieldVector & v) - { - for (int i=0; i -struct Print< Dune::FieldMatrix > -{ - static void print(Dune::FieldMatrix & A) - { - for (int i=0; i -void print(T & t) { Print::print(t); } - -int main () -{ - try - { -#ifdef _DUNE_TEST_M - Dune::FieldMatrix x; -#else - Dune::FieldVector x; -#endif - - x <<= _VALUES; - print(x); - - return 0; - } - catch (Dune::MathError &e) - { - std::cerr << "Dune reported MathError: " << e << std::endl; - return 1; - } - catch (Dune::Exception &e) - { - std::cerr << "Dune reported error: " << e << std::endl; - return 1; - } - catch (...) - { - std::cerr << "Unknown exception thrown!" << std::endl; - return 1; - } -} diff -Nru dune-common-2.2.1/dune/common/test/testfconstruct.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testfconstruct.cc --- dune-common-2.2.1/dune/common/test/testfconstruct.cc 2011-03-03 14:41:25.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testfconstruct.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -#include - -#include -#include -#include - -using namespace Dune; - -int main(int argc, char** argv) { - Dune::FieldVector pos; - - pos <<= 1, 0, 0; - - Dune::FieldVector pos2(pos); -} diff -Nru dune-common-2.2.1/dune/common/test/testfloatcmp.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testfloatcmp.cc --- dune-common-2.2.1/dune/common/test/testfloatcmp.cc 2012-04-17 11:38:46.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testfloatcmp.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: // Test the new (Dune) interface of float_cmp #ifdef HAVE_CONFIG_H @@ -23,7 +25,7 @@ FloatCmp::eq(0.0, 0.0); } } // namespace Dune -// check that we can access the functions as FloatCmp::function with using namespace Dune + // check that we can access the functions as FloatCmp::function with using namespace Dune void checkUsingAccess() { using namespace Dune; FloatCmp::eq(0.0, 0.0); @@ -32,7 +34,7 @@ // run time checks const char* repr(bool b) { if(b) return "true "; - else return "false"; + else return "false"; } int passed = 0; @@ -152,5 +154,5 @@ int total = passed + failed; cout << passed << "/" << total << " tests passed; " << failed << "/" << total << " tests failed" << endl; if(failed > 0) return 1; - else return 0; + else return 0; } diff -Nru dune-common-2.2.1/dune/common/test/test-stack.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/test-stack.cc --- dune-common-2.2.1/dune/common/test/test-stack.cc 2012-02-06 10:34:13.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/test-stack.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -// $Id: test-stack.cc 6560 2012-02-06 10:34:13Z robertk $ - -#ifdef NDEBUG -#warning "Disabling NDEBUG for this test, otherwise it will fail!" -#undef NDEBUG -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include - -// stack depth to test -static const int MAX = 100; - -template -void exercise_stack (SType &S) { - assert(S.empty()); - - // fill stack to maximum - for (int i = 0; i < MAX; ++i) { - assert(! S.full()); - S.push(i); - assert(! S.empty()); - }; - - for (int i = MAX - 1; i >= 0; --i) { - int x = S.top(); - int y = S.pop(); - assert(x == i); - assert(y == i); - }; - - assert(S.empty()); -} - -int main () { - // initialize stack, push stuff and check if it comes out again - Dune::FiniteStack fixedstack; - exercise_stack(fixedstack); - - // check error handling of Stack - try { - Dune::FiniteStack stack1; - - assert(stack1.empty()); - stack1.pop(); - - // exception has to happen - // make sure you compile this test without NDEBUG - std::cerr << "Expected exception Dune::RangeError, but nothing caught\n"; - return 1; - } catch (Dune::RangeError &e) { - // exception was correctly reported - std::cerr << "Caught expected Dune::RangeError: " << e.what() << std::endl; - return 0; - } catch (Dune::Exception &e) { - // exception was correctly reported - std::cerr << "Dune::Exception: " << e.what() << std::endl; - return 1; - } catch (std::exception &e) { - // exception was correctly reported - std::cerr << "std::exception: " << e.what() << std::endl; - return 1; - } catch (...) { - // wrong type of exception - std::cerr << "unknown exception\n"; - return 1; - } - -} diff -Nru dune-common-2.2.1/dune/common/test/testsuite.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testsuite.hh --- dune-common-2.2.1/dune/common/test/testsuite.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/testsuite.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,206 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_TEST_TESTSUITE_HH +#define DUNE_COMMON_TEST_TESTSUITE_HH + +#include +#include +#include + +#include +#include + + + +namespace Dune { + + + + /** + * \brief A Simple helper class to organize your test suite + * + * Usage: Construct a TestSuite and call check() or require() + * with the condition to check and probably a name for this check. + * These methods return a stream such that you can pipe in an + * explanantion accompanied by respective data to give a reason + * for a test failure. + */ + class TestSuite + { + public: + enum ThrowPolicy + { + AlwaysThrow, + ThrowOnRequired + }; + + /** + * \brief Create TestSuite + * + * \param name A name to identify this TestSuite. Defaults to "". + * \param policy If AlwaysThrow any failing check will throw, otherwise only required checks will do. + */ + TestSuite(ThrowPolicy policy, std::string name="") : + name_(name), + checks_(0), + failedChecks_(0), + throwPolicy_(policy==AlwaysThrow) + {} + + /** + * \brief Create TestSuite + * + * \param name A name to identify this TestSuite. Defaults to "". + * \param policy If AlwaysThrow any failing check will throw, otherwise only required checks will do. Defaults to ThrowOnRequired + */ + TestSuite(std::string name="", ThrowPolicy policy=ThrowOnRequired) : + name_(name), + checks_(0), + failedChecks_(0), + throwPolicy_(policy==AlwaysThrow) + {} + + /** + * \brief Check condition + * + * This will throw an exception if the check fails and if the AlwaysThrow policy was used on creation. + * + * \param conditon Checks if this is true and increases the failure counter if not. + * \param name A name to identify this check. Defaults to "" + * \returns A CollectorStream that can be used to create a diagnostic message to be printed on failure. + */ + CollectorStream check(bool condition, std::string name="") + { + ++checks_; + if (not condition) + ++failedChecks_; + + return CollectorStream([=](std::string reason) { + if (not condition) + this->announceCheckResult(throwPolicy_, "CHECK ", name, reason); + }); + } + + /** + * \brief Check a required condition + * + * This will always throw an exception if the check fails. + * + * \param conditon Checks if this is true and increases the failure counter if not. + * \param name A name to identify this check. Defaults to "" + * \returns A CollectorStream that can be used to create a diagnostic message to be printed on failure. + */ + CollectorStream require(bool condition, std::string name="") + { + ++checks_; + if (not condition) + ++failedChecks_; + + return CollectorStream([=](std::string reason) { + if (not condition) + this->announceCheckResult(true, "REQUIRED CHECK", name, reason); + }); + } + + /** + * \brief Collect data from a sub-TestSuite + * + * This will incorporate the accumulated results of the sub-TestSuite + * into this one. If the sub-TestSuite failed, i.e., contained failed + * checks, a summary will be printed. + */ + void subTest(const TestSuite& subTest) + { + checks_ += subTest.checks_; + failedChecks_ += subTest.failedChecks_; + + if (not subTest) + announceCheckResult(throwPolicy_, "SUBTEST", subTest.name(), std::to_string(subTest.failedChecks_)+"/"+std::to_string(subTest.checks_) + " checks failed in this subtest."); + } + + /** + * \brief Check if this TestSuite failed + * + * \returns False if any of the executed tests failed, otherwise true. + */ + operator const bool () const + { + return (failedChecks_==0); + } + + /** + * \brief Query name + * + * \returns Name of this TestSuite + */ + std::string name() const + { + return name_; + } + + /** + * \brief Print a summary of this TestSuite + * + * \returns False if any of the executed tests failed, otherwise true. + */ + bool report() const + { + if (failedChecks_>0) + std::cout << composeMessage("TEST ", name(), std::to_string(failedChecks_)+"/"+std::to_string(checks_) + " checks failed in this test.") << std::endl; + return (failedChecks_==0); + } + + /** + * \brief Exit the test. + * + * This wil print a summary of the test and return an integer + * to be used on program exit. + * + * \returns 1 if any of the executed tests failed, otherwise 0. + */ + int exit() const + { + return (report() ? 0: 1); + } + + protected: + + // Compose a diagnostic message + static std::string composeMessage(std::string type, std::string name, std::string reason) + { + std::ostringstream s; + s << type << " FAILED"; + if (name!="") + s << "(" << name << ")"; + s << ": "; + if (reason!="") + s << reason; + return s.str(); + } + + // Announce check results. To be called on failed checks + static void announceCheckResult(bool throwException, std::string type, std::string name, std::string reason) + { + std::string message = composeMessage(type, name, reason); + std::cout << message << std::endl; + if (throwException) + { + Dune::Exception ex; + ex.message(message); + throw ex; + } + } + + std::string name_; + std::size_t checks_; + std::size_t failedChecks_; + bool throwPolicy_; + }; + + + +} // namespace Dune + + + +#endif // DUNE_COMMON_TEST_TESTSUITE_HH diff -Nru dune-common-2.2.1/dune/common/test/timing.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/timing.cc --- dune-common-2.2.1/dune/common/test/timing.cc 2008-11-15 17:55:56.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/timing.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -35,7 +37,7 @@ /* bbv2 = bbv2; */ bbv2[0] = bv3; bbv2[1] = bv4; -// bbv2 = 0; + // bbv2 = 0; Dune::Timer stopwatch; stopwatch.reset(); @@ -93,7 +95,7 @@ v = 0; Vector x(M); x = 1; - + Dune::Timer stopwatch; stopwatch.reset(); #ifdef DUNE_EXPRESSIONTEMPLATES @@ -126,13 +128,13 @@ timing_vector<100,10000>(); timing_vector<400,2500>(); -// timing_matrix<150,150,500,4000>(); -// timing_matrix<150,150,1000,2000>(); -// timing_matrix<1,18,400000,500000>(); -// timing_matrix<6,3,400000,500000>(); -// timing_matrix<3,6,400000,500000>(); -// timing_matrix<18,1,400000,500000>(); -// timing_matrix<50,50,9000,10000>(); - + // timing_matrix<150,150,500,4000>(); + // timing_matrix<150,150,1000,2000>(); + // timing_matrix<1,18,400000,500000>(); + // timing_matrix<6,3,400000,500000>(); + // timing_matrix<3,6,400000,500000>(); + // timing_matrix<18,1,400000,500000>(); + // timing_matrix<50,50,9000,10000>(); + std::cout << std::endl; } diff -Nru dune-common-2.2.1/dune/common/test/tuplestest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/tuplestest.cc --- dune-common-2.2.1/dune/common/test/tuplestest.cc 2012-04-25 17:02:18.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/tuplestest.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,274 +0,0 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: - -// $Id: tuplestest.cc 6657 2012-04-25 17:02:18Z sander $ - -// make sure assert works even when not compiling for debugging -#ifdef NDEBUG -#undef NDEBUG -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#if defined(DISABLE_TR1_TUPLE) && defined(HAVE_TR1_TUPLE) -#undef HAVE_TR1_TUPLE -#endif - -#if defined(DISABLE_STD_TUPLE) && defined(HAVE_TUPLE) -#undef HAVE_TUPLE -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace Dune; - -template -void test(T& tuple) -{ - float f DUNE_UNUSED; - f = get<0>(tuple); - int i DUNE_UNUSED; - i = get<1>(tuple); - double d DUNE_UNUSED; - d = get<2>(tuple); - char c DUNE_UNUSED; - c = get<3>(tuple); - std::string s; - s = get<4>(tuple); - typename tuple_element<4,typename remove_const::type>::type s2 = get<4>(tuple); -} - -int iteratorTupleTest() -{ - std::vector v; - - v.push_back(0); - v.push_back(1); - v.push_back(2); - - typedef std::vector::iterator iterator; - typedef std::vector::const_iterator const_iterator; - typedef tuple Tuple; - - - Tuple tuple_(v.begin(), v.begin(), v.end()); - dune_static_assert(tuple_size::value==3, "The tuple size should be 3!");; - - int ret=0; - - if(get<0>(tuple_)!= v.begin()){ - std::cerr<<"Iterator tuple construction failed!"<(tuple_) == v.begin()); - assert(get<1>(tuple_) == get<0>(tuple_)); - if(get<2>(tuple_)!= v.end()){ - std::cerr<<"Iterator tuple construction failed!"<(tuple_) == v.end()); - assert(get<0>(tuple_) != v.end()); - assert(get<1>(tuple_) != get<2>(tuple_)); - return ret; -} - -int lessTest() -{ - tuple t1(1,2.0,3.0); - tuple t2(1,2,1); - - int ret=0; - - if ((t1 t(n); - get<0>(t) = 777; - assert(n == 777); - } - - int k=5; - int& kr(k); - kr=20; - int i=50; - double d=-3.3; - long j=-666; - tuple t1(100, 5.0, 10); - tuple t2(1,5,9); - std::cout << "i="<& >(tuple_)); - test(static_cast&>(tuple_)); - return (copyTest()+iteratorTupleTest()+referenceTest()+lessTest() - +pointerTest()+constPointerTest()+tuple_tr1_test()); - -} diff -Nru dune-common-2.2.1/dune/common/test/tupleutilitytest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/tupleutilitytest.cc --- dune-common-2.2.1/dune/common/test/tupleutilitytest.cc 2010-12-03 23:06:53.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/tupleutilitytest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,30 +1,28 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #if HAVE_CONFIG_H #include "config.h" #endif +#include #include +#include +#include -#include -#include #include ////////////////////////////////////////////////////////////////////// // // check FirstTypeIndex // -typedef Dune::tuple MyTuple; -dune_static_assert((Dune::FirstTypeIndex::value == 0), - "FirstTypeIndex finds the wrong index for double in " - "MyTuple!"); -dune_static_assert((Dune::FirstTypeIndex::value == 1), - "FirstTypeIndex finds the wrong index for double in " - "MyTuple!"); -dune_static_assert((Dune::FirstTypeIndex::value == 2), - "FirstTypeIndex finds the wrong index for double in " - "MyTuple!"); +typedef std::tuple MyTuple; +static_assert((Dune::FirstTypeIndex::value == 0), + "FirstTypeIndex finds the wrong index for double in MyTuple!"); +static_assert((Dune::FirstTypeIndex::value == 1), + "FirstTypeIndex finds the wrong index for double in MyTuple!"); +static_assert((Dune::FirstTypeIndex::value == 2), + "FirstTypeIndex finds the wrong index for double in MyTuple!"); @@ -32,9 +30,9 @@ // // check PushBackTuple typedef Dune::PushBackTuple::type MyTupleAppended1; -typedef Dune::tuple MyTupleAppended2; -dune_static_assert((Dune::is_same::value), - "PushBackTuple failed!"); +typedef std::tuple MyTupleAppended2; +static_assert((std::is_same::value), + "PushBackTuple failed!"); @@ -42,9 +40,9 @@ // // check PushFrontTuple typedef Dune::PushFrontTuple::type MyTuplePrepended1; -typedef Dune::tuple MyTuplePrepended2; -dune_static_assert((Dune::is_same::value), - "PushFrontTuple failed!"); +typedef std::tuple MyTuplePrepended2; +static_assert((std::is_same::value), + "PushFrontTuple failed!"); @@ -52,21 +50,21 @@ // // check JoinTuples typedef Dune::JoinTuples::type MyTupleMyTuple1; -typedef Dune::tuple MyTupleMyTuple2; -dune_static_assert((Dune::is_same::value), - "JoinTuples failed!"); +typedef std::tuple MyTupleMyTuple2; +static_assert((std::is_same::value), + "JoinTuples failed!"); ////////////////////////////////////////////////////////////////////// // // check FlattenTuple -typedef Dune::tuple MyTuple2; -typedef Dune::tuple MyTupleTuple; +typedef std::tuple MyTuple2; +typedef std::tuple MyTupleTuple; typedef Dune::FlattenTuple::type MyTupleTupleFlat1; -typedef Dune::tuple MyTupleTupleFlat2; -dune_static_assert((Dune::is_same::value), - "FlattenTuples failed!"); +typedef std::tuple MyTupleTupleFlat2; +static_assert((std::is_same::value), + "FlattenTuples failed!"); @@ -78,74 +76,97 @@ template struct Range { - typedef typename Dune::PushBackTuple< - typename Range::type, - typename Dune::integral_constant - >::type type; + typedef typename Dune::PushBackTuple< + typename Range::type, + typename std::integral_constant + >::type type; }; template struct Range { - typedef Dune::tuple<> type; + typedef std::tuple<> type; }; // An accumulator to build up a list of divisors of an integer using reduce template struct DivisorAccumulator { - enum {value = Data::first_type::value}; - enum {isDivisor = (PotentialDivisor::value*(value / PotentialDivisor::value)==value)}; + enum {value = Data::first_type::value}; + enum {isDivisor = (PotentialDivisor::value*(value / PotentialDivisor::value)==value)}; - typedef typename Data::second_type OldTuple; - typedef typename Dune::PushBackTuple::type ExtendedTuple; - typedef typename Dune::SelectType::Type NewTuple; + typedef typename Data::second_type OldTuple; + typedef typename Dune::PushBackTuple::type ExtendedTuple; + typedef typename std::conditional::type NewTuple; - typedef typename std::pair type; + typedef typename std::pair type; }; // Construct list of divisors using reduce template struct Divisors { - typedef typename Dune::ReduceTuple< - DivisorAccumulator, - typename Range<1,X+1>::type, - typename std::pair, typename Dune::tuple<> > - >::type::second_type type; + typedef typename Dune::ReduceTuple< + DivisorAccumulator, + typename Range<1,X+1>::type, + typename std::pair, typename std::tuple<> > + >::type::second_type type; - enum {value = Dune::tuple_size::value}; + enum {value = std::tuple_size::value}; }; // An accumulator to build up a list of primes up to a fixed integer template struct PrimeAccumulator { - enum {isPrime = (Divisors::value==2)}; + enum {isPrime = (Divisors::value==2)}; - typedef typename Dune::SelectType::type, Data>::Type type; + typedef typename std::conditional::type, Data>::type type; }; // Construct list primes template struct Primes { - typedef typename Dune::ReduceTuple< - PrimeAccumulator, - typename Range<1,X+1>::type, - typename Dune::tuple<> - >::type type; + typedef typename Dune::ReduceTuple< + PrimeAccumulator, + typename Range<1,X+1>::type, + typename std::tuple<> + >::type type; }; typedef Primes<9>::type Primes1; -typedef Dune::tuple< - Dune::integral_constant, - Dune::integral_constant, - Dune::integral_constant, - Dune::integral_constant > Primes2; -dune_static_assert((Dune::is_same::value), - "ReduceTuple failed in primes-tmp!"); - - -int main() { +typedef std::tuple< + std::integral_constant, + std::integral_constant, + std::integral_constant, + std::integral_constant > Primes2; +static_assert((std::is_same::value), + "ReduceTuple failed in primes-tmp!"); + +struct Reciprocal +{ + template + struct TypeEvaluator + { + typedef double Type; + }; + template + typename TypeEvaluator::Type operator()(const T& val) const { + return 1./val; + }; +}; + +int main() +{ + const std::tuple t1(1, 2.); + auto t2 = Dune::genericTransformTuple(t1, Reciprocal()); + static_assert(std::is_same>::value, + "Type after genericTransformTuple does not match!"); + if(fabs(std::get<0>(t2)-1.) > 1e-8 || + fabs(std::get<1>(t2)-.5) > 1e-8) + { + std::cout << "genericTransformTuple gives wrong result!\n"; + std::abort(); + } } diff -Nru dune-common-2.2.1/dune/common/test/utilitytest.cc dune-common-2.5.2~20170808ga5c076ca/dune/common/test/utilitytest.cc --- dune-common-2.2.1/dune/common/test/utilitytest.cc 2012-04-05 12:19:01.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/test/utilitytest.cc 2017-08-08 08:39:46.000000000 +0000 @@ -1,15 +1,15 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #if HAVE_CONFIG_H #include "config.h" #endif -#include -#include +#include +#include + #include -#include -#include +#include template struct Eval @@ -19,66 +19,72 @@ struct Counter { Counter() : result_(0) {} - + template - void visit(T1 elem) { ++result_; } - + void visit(T1) { ++result_; } + template - void visit(T1 elem, T2 elem1) { ++(++result_); } + void visit(T1, T2) { ++(++result_); } int result_; }; - -int main(int argc, char** argv) +int main(int, char**) { + typedef std::tuple PointerTuple; + PointerTuple pointers = Dune::NullPointerInitialiser::apply(); - typedef Dune::tuple PointerTuple; - - Dune::tuple pointers = Dune::NullPointerInitialiser::apply(); int ret=0; - - if(Dune::get<0>(pointers)!=0){ + + if(std::get<0>(pointers)!=nullptr) { std::cerr<<"First pointer not null"<(pointers)!=0){ + if(std::get<1>(pointers)!=nullptr) { std::cerr<<"Second pointer not null"<(pointers)!=0){ + + if(std::get<2>(pointers)!=nullptr) { std::cerr<<"Third pointer not null"<(pointers)!=0){ + if(std::get<3>(pointers)!=nullptr) { std::cerr<<"Fourth pointer not null"< RefTuple1; - typedef Dune::tuple PointerTuple1; - dune_static_assert((Dune::is_same::Type>::value), + + typedef std::tuple Tuple1; + typedef std::tuple RefTuple1; + typedef std::tuple PointerTuple1; + static_assert((std::is_same::Type>::value), "RefTuple1 with added pointers should be the same as " "PointerTuple1, but it isn't!"); + Tuple1 t1(i,c,l,c); RefTuple1 refs(i, c, l, c); - PointerTuple1 pointers1 - (Dune::transformTuple(refs)); - if(&i != Dune::get<0>(pointers1) || &c != Dune::get<1>(pointers1) || - &l != Dune::get<2>(pointers1) || &c != Dune::get<3>(pointers1)) { + +#if 0 + // Broken with Debian 8 and gcc. See issue #53 on the bug tracker. + DUNE_UNUSED RefTuple1 refs2(Dune::transformTuple(t1)); + PointerTuple1 pointers1(Dune::transformTuple(refs)); + if(&i != std::get<0>(pointers1) || &c != std::get<1>(pointers1) || + &l != std::get<2>(pointers1) || &c != std::get<3>(pointers1)) { std::cerr << "utilitytest: error: incorrect pointers in pointers1" << std::endl; ret = 1; } - - if(static_cast(Dune::tuple_size::value) != static_cast(Dune::tuple_size::value)){ +#endif + + PointerTuple1 pointers1 = Dune::NullPointerInitialiser::apply(); + + if(static_cast(std::tuple_size::value) != static_cast(std::tuple_size::value)) { std::cerr<<"Length and size do not match!"< foreach1(pointers, pointers1); foreach1.apply(count); - - if(Dune::At<2>::get(pointers)!=Dune::get<1>(pointers)){ + + if(Dune::At<2>::get(pointers)!=std::get<1>(pointers)) { ret+=10; std::cerr<<"at inconsistent!"<::Type ConvertedType; + + typedef Dune::ForEachType::Type ConvertedType DUNE_UNUSED; Dune::PointerPairDeletor::apply(p); + if(p != PointerTuple1(nullptr,nullptr,nullptr,nullptr)){ + ret+=20; + std::cerr<<"PointerPairDeletor not working!"< -#endif - +// headers for std::chrono +#include +#else +// headers for std::clock #include +#endif // headers for stderror(3) #include @@ -20,13 +21,13 @@ namespace Dune { -/** @addtogroup Common - @{ -*/ - -/*! \file - \brief A simple timing class. -*/ + /** @addtogroup Common + @{ + */ + + /*! \file + \brief A simple timing class. + */ /** \brief %Exception thrown by the Timer class */ class TimerError : public SystemError {} ; @@ -34,126 +35,127 @@ /** \brief A simple stop watch - This class reports the elapsed user-time, i.e. time spent computing, - after the last call to Timer::reset(). The results are seconds and - fractional seconds. Note that the resolution of the timing depends - on your OS kernel which should be somewhere in the milisecond range. + This class reports the elapsed user-time, i.e. time spent computing, + after the last call to Timer::reset(). The results are seconds and + fractional seconds. Note that the resolution of the timing depends + on your OS kernel which should be somewhere in the milisecond range. + + The class is basically a wrapper for the libc-function getrusage() + + \warning In a multi-threading situation, this class does NOT return wall-time! + Instead, the run time for all threads will be added up. + For example, if you have four threads running in parallel taking one second each, + then the Timer class will return an elapsed time of four seconds. - The class is basically a wrapper for the libc-function getrusage() - - */ + */ class Timer { - public: + public: - /** \brief A new timer, create and reset - * - * \param startImmediately If true (default) the timer starts counting immediately - */ - Timer (bool startImmediately=true) throw(TimerError) + /** \brief A new timer, create and reset + * + * \param startImmediately If true (default) the timer starts counting immediately + */ + Timer (bool startImmediately=true) throw(TimerError) + { + isRunning_ = startImmediately; + reset(); + } + + //! Reset timer while keeping the running/stopped state + void reset() throw (TimerError) + { + sumElapsed_ = 0.0; + storedLastElapsed_ = 0.0; + rawReset(); + } + + + //! Start the timer and continue measurement if it is not running. Otherwise do nothing. + void start() throw (TimerError) + { + if (not (isRunning_)) { - isRunning_ = startImmediately; - reset(); - } - - //! Reset timer while keeping the running/stopped state - void reset() throw (TimerError) - { - sumElapsed_ = 0.0; - storedLastElapsed_ = 0.0; rawReset(); + isRunning_ = true; } + } - //! Start the timer and continue measurement if it is not running. Otherwise do nothing. - void start() throw (TimerError) - { - if (not(isRunning_)) - { - rawReset(); - isRunning_ = true; - } - } - - - //! Get elapsed user-time from last reset until now/last stop in seconds. - double elapsed () const throw (TimerError) - { - // if timer is running add the time elapsed since last start to sum - if (isRunning_) - return sumElapsed_ + lastElapsed(); + //! Get elapsed user-time from last reset until now/last stop in seconds. + double elapsed () const throw (TimerError) + { + // if timer is running add the time elapsed since last start to sum + if (isRunning_) + return sumElapsed_ + lastElapsed(); - return sumElapsed_; - } + return sumElapsed_; + } - //! Get elapsed user-time from last start until now/last stop in seconds. - double lastElapsed () const throw (TimerError) - { - // if timer is running return the current value - if (isRunning_) - return rawElapsed(); + //! Get elapsed user-time from last start until now/last stop in seconds. + double lastElapsed () const throw (TimerError) + { + // if timer is running return the current value + if (isRunning_) + return rawElapsed(); - // if timer is not running return stored value from last run - return storedLastElapsed_; - } + // if timer is not running return stored value from last run + return storedLastElapsed_; + } - //! Stop the timer and return elapsed(). - double stop() throw (TimerError) + //! Stop the timer and return elapsed(). + double stop() throw (TimerError) + { + if (isRunning_) { - if (isRunning_) - { - // update storedLastElapsed_ and sumElapsed_ and stop timer - storedLastElapsed_ = lastElapsed(); - sumElapsed_ += storedLastElapsed_; - isRunning_ = false; - } - return elapsed(); + // update storedLastElapsed_ and sumElapsed_ and stop timer + storedLastElapsed_ = lastElapsed(); + sumElapsed_ += storedLastElapsed_; + isRunning_ = false; } + return elapsed(); + } - private: + private: - bool isRunning_; - double sumElapsed_; - double storedLastElapsed_; + bool isRunning_; + double sumElapsed_; + double storedLastElapsed_; #ifdef TIMER_USE_STD_CLOCK - void rawReset() throw (TimerError) - { - cstart = std::clock(); - } + void rawReset() throw (TimerError) + { + cstart = std::clock(); + } + + double rawElapsed () const throw (TimerError) + { + return (std::clock()-cstart) / static_cast(CLOCKS_PER_SEC); + } - double rawElapsed () const throw (TimerError) - { - return (std::clock()-cstart) / static_cast(CLOCKS_PER_SEC); - } - - std::clock_t cstart; + std::clock_t cstart; #else - void rawReset() throw (TimerError) - { - rusage ru; - if (getrusage(RUSAGE_SELF, &ru)) - DUNE_THROW(TimerError, strerror(errno)); - cstart = ru.ru_utime; - } - - double rawElapsed () const throw (TimerError) - { - rusage ru; - if (getrusage(RUSAGE_SELF, &ru)) - DUNE_THROW(TimerError, strerror(errno)); - return 1.0 * (ru.ru_utime.tv_sec - cstart.tv_sec) + (ru.ru_utime.tv_usec - cstart.tv_usec) / (1000.0 * 1000.0); - } + void rawReset() throw (TimerError) + { + cstart = std::chrono::high_resolution_clock::now(); + } + + double rawElapsed () const throw (TimerError) + { + std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now(); + std::chrono::duration time_span = std::chrono::duration_cast >(now - cstart); + return time_span.count(); + } - struct timeval cstart; + std::chrono::high_resolution_clock::time_point cstart; #endif }; // end class Timer -/** @} end documentation */ + /** @} end documentation */ } // end namespace diff -Nru dune-common-2.2.1/dune/common/tuples.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/tuples.hh --- dune-common-2.2.1/dune/common/tuples.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/tuples.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,1197 +1,18 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +#warning The header dune/common/tuples.hh is deprecated. Use directly "std::tuple" and include dune/common/streamoperators.hh for stream operators. #ifndef DUNE_TUPLES_HH #define DUNE_TUPLES_HH -#include - -#include"typetraits.hh" -#include"static_assert.hh" - -#ifdef HAVE_TUPLE #include -#elif defined HAVE_TR1_TUPLE -#include -#endif - -namespace Dune{ - /** @addtogroup Common - * - * @{ - */ - /** - * @file - * @brief Fallback implementation of the std::tuple class - * - * This a refined implementation of the approach defined in - * in the article "Tuples and multiple return values - * in C++" of Jaakko Järvi (Turku Centre of Computer - * Science, TUCS Technical Report No 249, March 1999, - * ISBN 952-12-0401-X, ISSN 1239-1891) available from the - * TUCS publications archive - * @author Markus Blatt - */ - - - template - struct TupleAccessTraits - { - typedef typename ConstantVolatileTraits::ConstType& ConstType; - typedef T& NonConstType; - typedef const typename ConstantVolatileTraits::UnqualifiedType& ParameterType; - }; - - template - struct TupleAccessTraits - { - typedef typename ConstantVolatileTraits::ConstType* ConstType; - typedef T* NonConstType; - typedef T* ParameterType; - }; - - template - struct TupleAccessTraits - { - typedef T& ConstType; - typedef T& NonConstType; - typedef T& ParameterType; - }; +#include +#include -#ifdef HAVE_TUPLE +namespace Dune { using std::tuple; -#elif defined HAVE_TR1_TUPLE - using std::tr1::tuple; -#else - /** - * @brief An empty class. - */ - struct Nil - {}; - - namespace - { - inline const Nil nullType() - { - return Nil(); - } - } - - /** - * @brief A tuple consisting of two objects. - * - * This is similar to std::pair - */ - template - struct Pair - { - /** - * @brief The type of the first field. - */ - typedef T1 Type1; - - /** - * @brief The type of the second field. - */ - typedef TT Type2; -// enum{ -// /** -// * @brief The number of values we hold. -// */ -// values = 2; -// }; - - /** - * @brief Constructor - * - * @param t1 The value of the first field. - * @param t2 The value of the second field. - * @param t3 The value of the third field. - * @param t4 The value of the 4th field. - * @param t5 The value of the 5th field. - * @param t6 The value of the 6th field. - * @param t7 The value of the 7th field. - * @param t8 The value of the 8th field. - * @param t9 The value of the 9th field. - */ - template - Pair(typename TupleAccessTraits::ParameterType t1, T2& t2, T3& t3, T4& t4, T5& t5, - T6& t6, T7& t7, T8& t8, T9& t9); - - /** - * @brief Constructor - * - * @param t1 The value of the first field. - * @param t2 The value of the second field. - */ - Pair(typename TupleAccessTraits::ParameterType t1, TT& t2); - - Pair(); - - /** - * @brief Copy Constructor for implicit type conversion - * @param other The tuple to copy. - */ - template - Pair(const Pair& other); - - /** - * @brief Assignment operator for implicit type conversion - * @param other The tuple to assign. - */ - template - Pair& operator=(const Pair& other); - - Pair& operator=(const Pair& other); - - /** - * @brief Get the first value - * @return The first value - */ - typename TupleAccessTraits::NonConstType first(); - - /** - * @brief Get the first value - * @return The first value - */ - typename TupleAccessTraits::ConstType - first() const; - - /** - * @brief Get the second value - * @return The second value - */ - typename TupleAccessTraits::NonConstType - second(); - - /** - * @brief Get the second value - * @return The second value - */ - typename TupleAccessTraits::ConstType - second() const; - - /** @brief The value of the first field. */ - Type1 first_; - /** @brief The value of the second field. */ - Type2 second_; - - }; - - /** - * @brief A tuple consisting of one object. - * Specialization of Pair that really is a single value. - */ - template - struct Pair - { - /** - * @brief The type of the first field. - */ - typedef T1 Type1; - - /** - * @brief The type of the (non-existent) second field is Nil. - * This typedef is useful in template metaprogramming, since it allows - * you to specialise for Nil instead of Pair - */ - typedef Nil Type2; - - /** - * @brief Constructor. - * @param first The values for the first field. - */ - Pair(typename TupleAccessTraits::ParameterType first, const Nil&, const Nil&, const Nil&, const Nil&, - const Nil&, const Nil&, const Nil&, const Nil&); - - /** - * @brief Constructor. - * @param first The values for the first field. - */ - Pair(typename TupleAccessTraits::ParameterType first, - const Nil&); - - Pair(); - - /** - * @brief Copy constructor for type conversion. - */ - template - Pair(const Pair& other); - - /** - * @brief Assignment operator for type conversion. - */ - template - Pair& operator=(const Pair& other); - - /** - * @brief Assignment operator. - */ - Pair& operator=(const Pair& other); - - /** - * @brief Get the first value - * @return The first value - */ - typename TupleAccessTraits::NonConstType - first(); - - /** - * @brief Get the first value - * @return The first value - */ - typename TupleAccessTraits::ConstType - first() const; - - /** @brief The value of the first field.*/ - Type1 first_; - }; - - - /** - * @brief Converts the Tuple to a list of pairs. - */ - template - struct TupleToPairs - { - typedef Pair::Type > Type; - }; - - /** - * @brief Specialization for a tuple consisting only of one type. - */ - template - struct TupleToPairs - { - typedef Pair Type; - }; - - /** - * @brief A Tuple of objects. - * - * A maximum of 9 objects is supported. - * - * Use the following construction to access the individual elements. - \code - tuple my_tuple; - - std:string& s = get<0>(my_tuple); - float* p = get<1>(my_tuple); - - // Access the third element in a generic way - typedef tuple_element<2, tuple >::type Type; - Type& i = get<2>(my_tuple); - \endcode - */ - template - class tuple : public TupleToPairs::Type - { - public: - //! Type of the first Pair defining the Tuple - typedef typename TupleToPairs::Type FirstPair; - - tuple() - {} - - tuple(typename TupleAccessTraits::ParameterType t1) - : FirstPair(t1, nullType(), nullType(), nullType(), - nullType(), nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits::ParameterType t1, - typename TupleAccessTraits::ParameterType t2) - : FirstPair(t1, t2, nullType(), nullType(), - nullType(), nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits::ParameterType t1, - typename TupleAccessTraits::ParameterType t2, - typename TupleAccessTraits::ParameterType t3) - : FirstPair(t1, t2, t3, nullType(), - nullType(), nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits::ParameterType t1, - typename TupleAccessTraits::ParameterType t2, - typename TupleAccessTraits::ParameterType t3, - typename TupleAccessTraits::ParameterType t4) - : FirstPair(t1, t2, t3, t4, - nullType(), nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits::ParameterType t1, - typename TupleAccessTraits::ParameterType t2, - typename TupleAccessTraits::ParameterType t3, - typename TupleAccessTraits::ParameterType t4, - typename TupleAccessTraits::ParameterType t5) - : FirstPair(t1, t2, t3, t4, - t5, nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits::ParameterType t1, - typename TupleAccessTraits::ParameterType t2, - typename TupleAccessTraits::ParameterType t3, - typename TupleAccessTraits::ParameterType t4, - typename TupleAccessTraits::ParameterType t5, - typename TupleAccessTraits::ParameterType t6) - : FirstPair(t1, t2, t3, t4, - t5, t6, nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits::ParameterType t1, - typename TupleAccessTraits::ParameterType t2, - typename TupleAccessTraits::ParameterType t3, - typename TupleAccessTraits::ParameterType t4, - typename TupleAccessTraits::ParameterType t5, - typename TupleAccessTraits::ParameterType t6, - typename TupleAccessTraits::ParameterType t7) - : FirstPair(t1, t2, t3, t4, - t5, t6, t7, nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits::ParameterType t1, - typename TupleAccessTraits::ParameterType t2, - typename TupleAccessTraits::ParameterType t3, - typename TupleAccessTraits::ParameterType t4, - typename TupleAccessTraits::ParameterType t5, - typename TupleAccessTraits::ParameterType t6, - typename TupleAccessTraits::ParameterType t7, - typename TupleAccessTraits::ParameterType t8) - : FirstPair(t1, t2, t3, t4, - t5, t6, t7, t8, - nullType()) - {} - - tuple(typename TupleAccessTraits::ParameterType t1, - typename TupleAccessTraits::ParameterType t2, - typename TupleAccessTraits::ParameterType t3, - typename TupleAccessTraits::ParameterType t4, - typename TupleAccessTraits::ParameterType t5, - typename TupleAccessTraits::ParameterType t6, - typename TupleAccessTraits::ParameterType t7, - typename TupleAccessTraits::ParameterType t8, - typename TupleAccessTraits::ParameterType t9) - : FirstPair(t1, t2, t3, t4, t5, t6, t7, t8, t9) - {} - - template - tuple& operator=(const Pair& other) - { - FirstPair::operator=(other); - return *this; - } - }; - -#endif - -#ifdef HAVE_TUPLE using std::tuple_element; -#elif defined HAVE_TR1_TUPLE - using std::tr1::tuple_element; -#else - /** - * @brief Get the type of the N-th element of the tuple. - */ - template - struct tuple_element - { - /** - * @brief The type of the N-th element of the tuple. - */ - typedef typename tuple_element::type type; - typedef typename tuple_element::type Type; - }; - - template - struct tuple_element > - { - /** - * @brief The type of the N-th element of the tuple. - */ - typedef typename tuple_element::Type type; - typedef typename tuple_element::Type Type; - }; - - /** - * @brief Get the type of the first element of the tuple. - */ - template - struct tuple_element<0, Pair > - { - /** - * @brief The type of the first element of the tuple. - */ - typedef T1 type; - typedef T1 Type; - }; - -#endif - -#if defined HAVE_TUPLE || defined HAVE_TR1_TUPLE -#ifdef HAVE_TUPLE using std::get; -#elif defined HAVE_TR1_TUPLE - using std::tr1::get; -#endif - -#else - /** - * @brief Get the N-th element of a tuple. - * - * \warning This is an internal class. Do no use it directly! - */ - template - struct Element - { - /** - * @brief Get the N-th element of the tuple. - * @param tuple The tuple whose N-th element we want. - * @return The N-th element of the tuple. - */ - template - static typename TupleAccessTraits< - typename tuple_element >::type - >::NonConstType - get(Pair& tuple) - { - return Element::get(tuple.second()); - } - - /** - * @brief Get the N-th element of the tuple. - * @param tuple The tuple whose N-th element we want. - * @return The N-th element of the tuple. - */ - template - static typename TupleAccessTraits< - typename tuple_element >::type - >::ConstType - get(const Pair& tuple) - { - return Element::get(tuple.second()); - } - }; - - /** - * @brief Get the first element of a tuple. - */ - template<> - struct Element<0> - { - /** - * @brief Get the first element of the tuple. - * @param tuple The tuple whose first element we want. - * @return The first element of the tuple. - */ - template - static typename TupleAccessTraits::NonConstType get(Pair& tuple) - { - return tuple.first(); - } - - /** - * @brief Get the first element of the tuple. - * @param tuple The tuple whose first element we want. - * @return The first element of the tuple. - */ - template - static typename TupleAccessTraits::ConstType get(const Pair& tuple) - { - return tuple.first(); - } - }; - - template - typename TupleAccessTraits >::type> - ::NonConstType - get(tuple& t) - { - return Element::get(t); - } - - template - typename TupleAccessTraits >::type> - ::ConstType - get(const tuple& t) - { - return Element::get(t); - } - -#endif - -#ifdef HAVE_TUPLE using std::tuple_size; -#elif defined HAVE_TR1_TUPLE - using std::tr1::tuple_size; -#else - /** - * @brief Template meta_programm to query the size of a tuple - * - */ - template - struct tuple_size - { - enum{ - // @brief The number of Elements in the tuple. - value=tuple_size::value - }; - - - }; - - template - struct tuple_size > - { - enum{ value=1+tuple_size::value}; - }; - - - template - struct tuple_size > - { - enum{ value=1}; - }; - - template<> - struct tuple_size > - { - enum{ value=0}; - }; -#endif - - -#ifdef HAVE_TUPLE using std::tie; using std::make_tuple; -#elif defined HAVE_TR1_TUPLE - using std::tr1::tie; - using std::tr1::make_tuple; -#endif - - - template - struct tuple_writer - { - template - static std::ostream& put(std::ostream& os, const T& t, const char* delim=", ") - { - return tuple_writer::put(os,t,delim)<(t); - } - - template< class T > - static std::istream &get ( std::istream &is, T &t, const char *delim = "," ) - { - tuple_writer< i-1 >::get( is, t, delim ); - for( const char *it = delim; is && (*it != 0); ++it ) - { - char c = 0; - is >> c; - if( c != *it ) - is.setstate( std::ios::failbit ); - } - return is >> Dune::get< i-1 >( t ); - } - }; - - template<> - struct tuple_writer<1> - { - template - static std::ostream& put(std::ostream& os, const T& t, const char* delim=", ") - { - return os<(t); - } - - template< class T > - static std::istream &get ( std::istream &is, T &t, const char *delim = ", " ) - { - return is >> Dune::get< 0 >( t ); - } - }; - - template<> - struct tuple_writer<0> - { - template - static std::ostream& put(std::ostream& os, const T& t, const char* delim=", ") - { - return os; - } - - template< class T > - static std::istream &get ( std::istream &is, T &t, const char *delim = ", " ) - { - return is; - } - }; - -#if defined HAVE_TUPLE || defined HAVE_TR1_TUPLE - /** - * \brief Print a tuple. - */ - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - template - inline std::ostream& operator<<( std::ostream& os, const tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::put(os, t); - } - - /** - * \brief Read a tuple. - */ - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } - - template - inline std::istream& operator>>( std::istream& is, tuple & t) - { - typedef tuple TupleT; - return tuple_writer::value>::get(is, t); - } -#else - /** - * @brief Equality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template - inline bool operator==(const Pair& tuple1, const Pair& tuple2) - { - return (tuple1.first()==tuple2.first() && tuple1.second()==tuple2.second()); - } - - /** - * @brief Inequality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template - inline bool operator!=(const Pair& tuple1, const Pair& tuple2) - { - return (tuple1.first()!=tuple2.first() || tuple1.second()!=tuple2.second()); - } - - /** - * @brief Less operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template - inline bool operator<(const Pair& tuple1, const Pair& tuple2) - { - return tuple1.first() < tuple2.first() - || (tuple1.first() == tuple2.first() && tuple1.second() < tuple2.second()); - } - - /** - * @brief Equality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template - inline bool operator==(const Pair& tuple1, const Pair& tuple2) - { - return (tuple1.first()==tuple2.first()); - } - - /** - * @brief Inequality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template - inline bool operator!=(const Pair& tuple1, const Pair& tuple2) - { - dune_static_assert( (IsInteroperable::value), - "T1 and U1 have to be interoperable, i.e., either " - "conversion from one to the other must exist." ); - return (tuple1.first()!=tuple2.first()); - } - - /** - * @brief Less operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template - inline bool operator<(const Pair& tuple1, const Pair& tuple2) - { - return (tuple1.first() - inline bool operator==(const Pair& tuple1, const Pair& tuple2) - { - return false; - } - - /** - * @brief Inequality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple. - * @return True as the type of the compared objects are different. - */ - template - inline bool operator!=(const Pair& tuple1, const Pair& tuple2) - { - return true; - } - - - /** - * @brief Equality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple. - * @return False as the type of the compared objects are different. - */ - template - inline bool operator==(const Pair& tuple1, const Pair& tuple2) - { - return false; - } - - /** - * @brief Inequality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple. - * @return True as the type of the compared objects are different. - */ - template - inline bool operator!=(const Pair& tuple1, const Pair& tuple2) - { - return true; - } - - /** - * @brief Create a tuple and initialize it. - * @param first The value of the first field. - * @param second The value of the second field. - */ - template - inline Pair makePair(const T1& first, const T2& second) - { - return Pair(first, second); - } - - /** - * @brief Print a pair or tuple. - */ - template - inline std::ostream& operator<<(std::ostream& os, const Pair& pair) - { - os< - inline std::ostream& operator<<(std::ostream& os, const Pair& pair) - { - os< - inline std::istream& operator>>(std::istream& is, Pair& pair) - { - return is >> pair.first() >> pair.second(); - } - - template - inline std::istream& operator>>(std::istream& is, Pair& pair) - { - return is >> pair.first(); - } - - template - inline tuple tie(T1& t1) { - return tuple (t1); - } - - template - inline tuple tie(T1& t1, T2& t2) { - return tuple (t1, t2); - } - - template - inline tuple tie(T1& t1, T2& t2, T3& t3) { - return tuple (t1, t2, t3); - } - - template - inline tuple tie(T1& t1, T2& t2, T3& t3, T4& t4) { - return tuple (t1, t2, t3, t4); - } - - template - inline tuple - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5) { - return tuple (t1, t2, t3, t4, t5); - } - - template - inline tuple - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6) { - return tuple (t1, t2, t3, t4, t5, t6); - } - - template - inline tuple - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7) { - return tuple (t1, t2, t3, t4, t5, t6, t7); - } - - template - inline tuple - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8) { - return tuple - (t1, t2, t3, t4, t5, t6, t7, t8); - } - - template - inline tuple - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8, T9& t9) { - return tuple - (t1, t2, t3, t4, t5, t6, t7, t8, t9); - } - - template - inline tuple make_tuple(const T1& t1) { - return tuple (t1); - } - - template - inline tuple make_tuple(const T1& t1, const T2& t2) { - return tuple (t1, t2); - } - - template - inline tuple make_tuple(const T1& t1, const T2& t2, const T3& t3) { - return tuple (t1, t2, t3); - } - - template - inline tuple make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4) { - return tuple (t1, t2, t3, t4); - } - - template - inline tuple - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) { - return tuple (t1, t2, t3, t4, t5); - } - - template - inline tuple - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) { - return tuple (t1, t2, t3, t4, t5, t6); - } - - template - inline tuple - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, - const T7& t7) { - return tuple (t1, t2, t3, t4, t5, t6, t7); - } - - template - inline tuple - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, - const T7& t7, const T8& t8) { - return tuple - (t1, t2, t3, t4, t5, t6, t7, t8); - } - - template - inline tuple - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, - const T7& t7, const T8& t8, const T9& t9) { - return tuple - (t1, t2, t3, t4, t5, t6, t7, t8, t9); - } - - template - template - inline Pair::Pair(typename TupleAccessTraits::ParameterType first, - T2& t2, T3& t3, T4& t4, T5& t5, - T6& t6, T7& t7, T8& t8, T9& t9) - : first_(first), second_(t2,t3,t4,t5,t6,t7,t8,t9, nullType()) - {} - - template - inline Pair::Pair(typename TupleAccessTraits::ParameterType first, TT& second) - : first_(first), second_(second) - {} - - template - inline Pair::Pair() - : first_(), second_() - {} - - template - template - inline Pair::Pair(const Pair& other) - : first_(other.first_), second_(other.second_) - {} - - template - template - inline Pair& Pair::operator=(const Pair& other) - { - first_=other.first_; - second_=other.second_; - return *this; - } - - template - inline Pair& Pair::operator=(const Pair& other) - { - first_=other.first_; - second_=other.second_; - return *this; - } - - template - inline typename TupleAccessTraits::NonConstType - Pair::first() - { - return first_; - } - - template - inline typename TupleAccessTraits::ConstType - Pair::first() const - { - return first_; - } - - - template - inline typename TupleAccessTraits::NonConstType - Pair::second() - { - return second_; - } - - template - inline typename TupleAccessTraits::ConstType - Pair::second() const - { - return second_; - } - - template - inline Pair::Pair(typename TupleAccessTraits::ParameterType first, - const Nil&, const Nil&, const Nil&, const Nil&, - const Nil&, const Nil&, const Nil&, const Nil&) - : first_(first) - {} - - template - inline Pair::Pair(typename TupleAccessTraits::ParameterType first, - const Nil&) - : first_(first) - {} - - template - inline Pair::Pair() - : first_() - {} - - template - template - inline Pair::Pair(const Pair& other) - : first_(other.first_) - {} - - template - template - Pair& Pair::operator=(const Pair& other) - { - first_ = other.first_; - return *this; - } - - - template - Pair& Pair::operator=(const Pair& other) - { - first_ = other.first_; - return *this; - } - - template - inline typename TupleAccessTraits::NonConstType - Pair::first() - { - return first_; - } - - template - inline typename TupleAccessTraits::ConstType - Pair::first() const - { - return first_; - } - - /** }@ */ -#endif } #endif diff -Nru dune-common-2.2.1/dune/common/tupleutility.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/tupleutility.hh --- dune-common-2.2.1/dune/common/tupleutility.hh 2012-05-02 09:53:42.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/tupleutility.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,661 +1,174 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set ts=8 sw=2 et sts=2: +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_TUPLE_UTILITY_HH #define DUNE_TUPLE_UTILITY_HH #include +#include +#include -#include -#include - -#include "tuples.hh" +#include +#include +#include namespace Dune { - /** @ addtogroup Common + /** @addtogroup TupleUtilities * * @{ */ /** * @file - * @brief Contains utility classes which can be used with tuples. + * @brief Contains utility classes which can be used with std::tuple. */ - /** - * @brief A helper template that initializes a tuple consisting of pointers - * to NULL. - * - * A tuple of NULL pointers may be useful when you use a tuple of pointers - * in a class which you can only initialise in a later stage. - */ - template - class NullPointerInitialiser { - dune_static_assert(AlwaysFalse::value, "Attempt to use the " - "unspecialized version of NullPointerInitialiser. " - "NullPointerInitialiser needs to be specialized for " - "each possible tuple size. Naturally the number of " - "pre-defined specializations is limited arbitrarily. " - "Maybe you need to raise this limit by defining some " - "more specializations? Also check that the tuple this " - "is applied to really is a tuple of pointers only."); - public: - //! export the type of the tuples - typedef Tuple ResultType; - //! generate a zero-initialized tuple - static ResultType apply(); - }; - -#ifndef DOXYGEN - template - struct NullPointerInitialiser - : public NullPointerInitialiser + template + struct TupleAccessTraits { - typedef const Tuple ResultType; + typedef typename std::add_const::type& ConstType; + typedef T& NonConstType; + typedef const typename std::remove_const::type& ParameterType; }; - template<> - struct NullPointerInitialiser > { - typedef tuple<> ResultType; - static ResultType apply() { - return ResultType(); - } - }; - - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0)); - } - }; - - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0), static_cast(0)); - } - }; - - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0), static_cast(0), - static_cast(0)); - } - }; - - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0), static_cast(0), - static_cast(0), static_cast(0)); - } - }; - - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0)); - } - }; - - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0), static_cast(0)); - } + template + struct TupleAccessTraits + { + typedef typename std::add_const::type* ConstType; + typedef T* NonConstType; + typedef T* ParameterType; }; - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0)); - } + template + struct TupleAccessTraits + { + typedef T& ConstType; + typedef T& NonConstType; + typedef T& ParameterType; }; - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0), static_cast(0)); - } - }; + /** + * @brief A helper template that initializes a std::tuple consisting of pointers + * to nullptr. + * + * A std::tuple of nullptr may be useful when you use a std::tuple of pointers + * in a class which you can only initialise in a later stage. + */ + template + struct NullPointerInitialiser; - template - struct NullPointerInitialiser > { - typedef tuple ResultType; - static ResultType apply() { - return ResultType(static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0), static_cast(0), - static_cast(0)); + template + struct NullPointerInitialiser > + { + typedef std::tuple ResultType; + static ResultType apply() + { + return ResultType(static_cast(nullptr)...); } }; - // template - // struct NullPointerInitialiser > { - // typedef tuple ResultType; - // static ResultType apply() { - // return ResultType(static_cast(0), static_cast(0), - // static_cast(0), static_cast(0), - // static_cast(0), static_cast(0), - // static_cast(0), static_cast(0), - // static_cast(0), static_cast(0)); - // } - // }; -#endif // !defined(DOXYGEN) - /** - * @brief Helper template to clone the type definition of a tuple with the + * @brief Helper template to clone the type definition of a std::tuple with the * storage types replaced by a user-defined rule. - * - * Suppose all storage types A_i in a tuple define a type A_i::B. You can + * + * Suppose all storage types A_i in a std::tuple define a type A_i::B. You can * build up a pair consisting of the types defined by A_i::B in the following * way: - \code - template - struct MyEvaluator { - typedef typename A::B Type; - }; - - typedef ForEachType::Type BTuple; - \endcode + * + * \code + * template + * struct MyEvaluator + * { + * typedef typename A::B Type; + * }; + * + * typedef ForEachType::Type BTuple; + * \endcode + * * Here, MyEvaluator is a helper struct that extracts the correct type from * the storage types of the tuple defined by the tuple ATuple. * * \sa AddRefTypeEvaluator, AddPtrTypeEvaluator, genericTransformTuple(), * and transformTuple(). */ - template

::eval(a); + return t*t; + } + }; + + template + struct PowerImp + { + template + static T eval(const T & a) + { + return a*Power::eval(a);; + } + }; + + template <> + struct PowerImp<1,true> + { + template + static T eval(const T & a) + { + return a; + } + }; +#endif + +} + +#endif diff -Nru dune-common-2.2.1/dune/common/precision.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/precision.hh --- dune-common-2.2.1/dune/common/precision.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/precision.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,3 +1,5 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_PRECISION_HH #define DUNE_PRECISION_HH @@ -8,11 +10,11 @@ #include namespace Dune { - - /** - @addtogroup DenseMatVec - @{ - */ + + /** + @addtogroup DenseMatVec + @{ + */ /** * @brief Precisions for calculations with FieldMatrix and FieldVector. @@ -20,47 +22,47 @@ template class FMatrixPrecision { public: - //! return threshold to do pivoting - static ctype pivoting_limit () - { - return _pivoting; - } - - //! set pivoting threshold - static void set_pivoting_limit (ctype pivthres) - { - _pivoting = pivthres; - } - - //! return threshold to declare matrix singular - static ctype singular_limit () - { - return _singular; - } - - //! set singular threshold - static void set_singular_limit (ctype singthres) - { - _singular = singthres; - } - - //! return threshold to declare matrix singular - static ctype absolute_limit () - { - return _absolute; - } - - //! set singular threshold - static void set_absolute_limit (ctype absthres) - { - _absolute = absthres; - } + //! return threshold to do pivoting + static ctype pivoting_limit () + { + return _pivoting; + } + + //! set pivoting threshold + static void set_pivoting_limit (ctype pivthres) + { + _pivoting = pivthres; + } + + //! return threshold to declare matrix singular + static ctype singular_limit () + { + return _singular; + } + + //! set singular threshold + static void set_singular_limit (ctype singthres) + { + _singular = singthres; + } + + //! return threshold to declare matrix singular + static ctype absolute_limit () + { + return _absolute; + } + + //! set singular threshold + static void set_absolute_limit (ctype absthres) + { + _absolute = absthres; + } private: - // just to demonstrate some state information - static ctype _pivoting; - static ctype _singular; - static ctype _absolute; + // just to demonstrate some state information + static ctype _pivoting; + static ctype _singular; + static ctype _absolute; }; template @@ -69,7 +71,7 @@ ctype FMatrixPrecision::_singular = 1E-14; template ctype FMatrixPrecision::_absolute = 1E-80; - + /** @} end documentation */ } // end namespace diff -Nru dune-common-2.2.1/dune/common/promotiontraits.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/promotiontraits.hh --- dune-common-2.2.1/dune/common/promotiontraits.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/promotiontraits.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,39 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_PROMOTIONTRAITS_HH +#define DUNE_PROMOTIONTRAITS_HH + +#include + +namespace Dune { + /** + * @file + * @brief Compute type of the result of an arithmetic operation involving two different number types. + * + * @author Matthias Wohlmuth + */ + + /** @addtogroup Common + * + * @{ + */ + + /** \brief Compute type of the result of an arithmetic operation involving two different number types. + */ + template + struct PromotionTraits + { + typedef decltype(std::declval()+std::declval()) PromotedType; + }; + + // Specialization for the case of two equal types + // One should think that the generic template should handle this case as well. + // However, the fvectortest.cc unit test fails without it if ENABLE_GMP is set. + template + struct PromotionTraits { typedef T1 PromotedType; }; + + /** @} */ +} // end namespace + + +#endif // DUNE_PROMOTIONTRAITS_HH diff -Nru dune-common-2.2.1/dune/common/propertymap.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/propertymap.hh --- dune-common-2.2.1/dune/common/propertymap.hh 2010-05-14 09:12:39.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/propertymap.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,12 +1,11 @@ -// $Id: propertymap.hh 6003 2010-05-14 09:12:39Z sander $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_PROPERTYMAP_HH #define DUNE_PROPERTYMAP_HH #include #include - -#include"static_assert.hh" -#include"typetraits.hh" +#include namespace Dune { @@ -31,18 +30,18 @@ */ typedef typename PM::Category Category; }; - + /** @brief Tag for the category of readable property maps. */ struct ReadablePropertyMapTag {}; - + /** @brief Tag for the category of writable property maps. */ struct WritablePropertyMapTag {}; - /** + /** * @brief Tag for the category of readable and writable property - * maps. + * maps. */ struct ReadWritePropertyMapTag : public ReadablePropertyMapTag, public WritablePropertyMapTag @@ -63,8 +62,8 @@ typedef std::ptrdiff_t KeyType; typedef LvaluePropertyMapTag Category; }; - - + + template struct PropertyMapTraits { @@ -77,90 +76,90 @@ template struct RAPropertyMapHelper {}; - + template - inline Reference + inline Reference get(const RAPropertyMapHelper& pmap, const Key& key) { return static_cast(pmap)[key]; } - + template inline void put(const RAPropertyMapHelper& pmap, const Key& key, const Value& value) { - dune_static_assert((Conversion - ::exists), "WritablePropertyMapTag required!"); + static_assert(std::is_convertible::value, + "WritablePropertyMapTag required!"); static_cast(pmap)[key] = value; } - + /** * @brief Adapter to turn a random access iterator into a property map. */ - template::value_type, - class R = typename std::iterator_traits::reference> + template::value_type, + class R = typename std::iterator_traits::reference> class IteratorPropertyMap : public RAPropertyMapHelper > { public: - /** - * @brief The type of the random access iterator. + /** + * @brief The type of the random access iterator. */ typedef RAI RandomAccessIterator; - - /** + + /** * @brief The type of the index map. * * This will convert the KeyType to std::ptrdiff_t via operator[](). */ typedef IM IndexMap; - + /** * @brief The key type of the property map. */ typedef typename IndexMap::KeyType KeyType; - + /** * @brief The value type of the property map. */ typedef T ValueType; - + /** * @brief The reference type of the property map. */ typedef R Reference; - + /** * @brief The category of this property map. */ typedef LvaluePropertyMapTag Category; - + /** * @brief Constructor. - * @param iter The random access iterator that + * @param iter The random access iterator that * provides the mapping. - * @param im The index map that maps the KeyType + * @param im The index map that maps the KeyType * to the difference_type of the iterator. */ inline IteratorPropertyMap(RandomAccessIterator iter, - const IndexMap& im=IndexMap()) - :iter_(iter), indexMap_(im) + const IndexMap& im=IndexMap()) + : iter_(iter), indexMap_(im) {} - + /** @brief Constructor. */ inline IteratorPropertyMap() : iter_(), indexMap_() {} - + /** @brief Access the a value by reference. */ inline Reference operator[](KeyType key) const { return *(iter_ + get(indexMap_, key)); } - + private: /** @brief The underlying iterator. */ RandomAccessIterator iter_; @@ -175,57 +174,57 @@ template class AssociativePropertyMap : RAPropertyMapHelper > + AssociativePropertyMap > { /** * @brief The type of the unique associative container. */ typedef T UniqueAssociativeContainer; - + /** * @brief The key type of the property map. */ typedef typename UniqueAssociativeContainer::value_type::first_type KeyType; - + /** * @brief The value type of the property map. */ typedef typename UniqueAssociativeContainer::value_type::second_type ValueType; - + /** * @brief The reference type of the property map. */ typedef ValueType& Reference; - + /** * @brief The category of the property map. */ typedef LvaluePropertyMapTag Category; - + /** @brief Constructor */ inline AssociativePropertyMap() : map_(0) {} - + /** @brief Constructor. */ inline AssociativePropertyMap(UniqueAssociativeContainer& map) : map_(&map) {} - + /** * @brief Access a property. * @param key The key of the property. */ - inline Reference operator[](KeyType key)const + inline Reference operator[](KeyType key) const { return map_->find(key)->second; } private: UniqueAssociativeContainer* map_; }; - + /** * @brief An adaptor to turn an unique associative container * into a property map. @@ -233,50 +232,50 @@ template class ConstAssociativePropertyMap : RAPropertyMapHelper > + ConstAssociativePropertyMap > { /** * @brief The type of the unique associative container. */ typedef T UniqueAssociativeContainer; - + /** * @brief The key type of the property map. */ typedef typename UniqueAssociativeContainer::value_type::first_type KeyType; - + /** * @brief The value type of the property map. */ typedef typename UniqueAssociativeContainer::value_type::second_type ValueType; - + /** * @brief The reference type of the property map. */ typedef const ValueType& Reference; - + /** * @brief The category of the property map. */ typedef LvaluePropertyMapTag Category; - + /** @brief Constructor */ inline ConstAssociativePropertyMap() : map_(0) {} - + /** @brief Constructor. */ inline ConstAssociativePropertyMap(const UniqueAssociativeContainer& map) : map_(&map) {} - + /** * @brief Access a property. * @param key The key of the property. */ - inline Reference operator[](KeyType key)const + inline Reference operator[](KeyType key) const { return map_->find(key)->second; } @@ -301,7 +300,7 @@ /** @brief The category of the map. */ typedef ReadablePropertyMapTag Category; - + inline ValueType operator[](const KeyType& key) const { return key; @@ -309,25 +308,25 @@ }; + /** + * @brief Selector for the property map type. + * + * If present the type of the property map is accessible via the typedef Type. + */ + template + struct PropertyMapTypeSelector + { /** - * @brief Selector for the property map type. - * - * If present the type of the property map is accessible via the typedef Type. + * @brief the tag identifying the property. */ - template - struct PropertyMapTypeSelector - { - /** - * @brief the tag identifying the property. - */ - typedef T Tag; - /** - * @brief The container type to whose entries the properties - * are attached. - */ - typedef C Container; - }; - + typedef T Tag; + /** + * @brief The container type to whose entries the properties + * are attached. + */ + typedef C Container; + }; + } #endif diff -Nru dune-common-2.2.1/dune/common/proxymemberaccess.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/proxymemberaccess.hh --- dune-common-2.2.1/dune/common/proxymemberaccess.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/proxymemberaccess.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,118 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_PROXYMEMBERACCESS_HH +#define DUNE_COMMON_PROXYMEMBERACCESS_HH + +/** + * \file + * \brief infrastructure for supporting operator->() on both references and proxies + */ + +#include +#include + +namespace Dune { + + namespace { + + // helper struct to store a temporary / proxy + // for the duration of the member access + template + struct member_access_proxy_holder + { + + // only support moving the temporary into the holder object + member_access_proxy_holder(T&& t) + : _t(std::move(t)) + {} + + // The object is fundamentally a temporary, i.e. an rvalue, + // + const T* operator->() const + { + return &_t; + } + + T _t; + + }; + + } // anonymous namespace + + +#ifdef DOXYGEN + + //! Transparent support for providing member access to both lvalues and rvalues (temporary proxies). + /** + * If an iterator facade (like entity iterators) wants to allow the embedded implementation to + * return either an (internally stored) reference or a temporary object and expose these two + * behaviors to enable performance optimizations, operator->() needs special handling: If the + * implementation returns a reference, operator->() in the facade can simply return the address + * of the referenced object, but if the returned object is a temporary, we need to capture and + * store it in a helper object to make sure it outlives the member access. This function transparently + * supports both variants. It should be used like this: + * + * \code + * class iterator + * { + * ... + * + * decltype(handle_proxy_member_access(implementation.dereference())) + * operator->() const + * { + * return handle_proxy_member_access(implementation.dereference()); + * } + * + * ... + * }; + * \endcode + * + * \note This function exploits the special type deduction rules for unqualified rvalue references + * to distinguish between lvalues and rvalues and thus needs to be passed the object returned + * by the implementation. + */ + template + pointer_or_proxy_holder + handle_proxy_member_access(T&& t); + +#else // DOXYGEN + + + // This version matches lvalues (the C++ type deduction rules state that + // the T&& signature deduces to a reference iff the argument is an lvalue). + // As the argument is an lvalue, we do not have to worry about its lifetime + // and can just return its address. + template + inline typename std::enable_if< + std::is_lvalue_reference::value, + typename std::add_pointer< + typename std::remove_reference< + T + >::type + >::type + >::type + handle_proxy_member_access(T&& target) + { + return ⌖ + } + + // This version matches rvalues (the C++ type deduction rules state that + // the T&& signature deduces to a non-reference iff the argument is an rvalue). + // In this case, we have to capture the rvalue in a new object to make sure it + // is kept alive for the duration of the member access. For this purpose, we move + // it into a member_access_proxy_holder instance. + template + inline typename std::enable_if< + !std::is_lvalue_reference::value, + member_access_proxy_holder + >::type + handle_proxy_member_access(T&& target) + { + return {std::forward(target)}; + } + +#endif // DOXYGEN + +} // namespace Dune + +#endif // DUNE_COMMON_PROXYMEMBERACCESS_HH diff -Nru dune-common-2.2.1/dune/common/rangeutilities.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/rangeutilities.hh --- dune-common-2.2.1/dune/common/rangeutilities.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/rangeutilities.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,109 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_RANGE_UTILITIES_HH +#define DUNE_COMMON_RANGE_UTILITIES_HH + +#include +#include +#include +#include +#include + +/** + * \file + * \brief Utilities for reduction like operations on ranges + * \author Christian Engwer + */ + +/** + * @addtogroup RangeUtilities + * @{ + */ + +namespace Dune +{ + /** + \brief compute the maximum value over a range + + overloads for scalar values, and ranges exist + */ + template ::value, int>::type = 0> + typename T::value_type + max_value(const T & v) { + using std::max_element; + return *max_element(v.begin(), v.end()); + } + + template ::value, int>::type = 0> + const T & max_value(const T & v) { return v; } + + /** + \brief compute the minimum value over a range + + overloads for scalar values, and ranges exist + */ + template ::value, int>::type = 0> + typename T::value_type + min_value(const T & v) { + using std::min_element; + return *min_element(v.begin(), v.end()); + } + + template ::value, int>::type = 0> + const T & min_value(const T & v) { return v; } + + /** + \brief similar to std::bitset::any() return true, if any entries is true + + overloads for scalar values, ranges, and std::bitset exist + */ + template ::value, int>::type = 0> + bool any_true(const T & v) { + bool b = false; + for (const auto & e : v) + b = b or bool(e); + return b; + } + + template ::value, int>::type = 0> + bool any_true(const T & v) { return v; } + + template + bool any_true(const std::bitset & b) + { + return b.any(); + } + + /** + \brief similar to std::bitset::all() return true, if any entries is true + + overloads for scalar values, ranges, and std::bitset exist + */ + template ::value, int>::type = 0> + bool all_true(const T & v) { + bool b = true; + for (const auto & e : v) + b = b and bool(e); + return b; + } + + template ::value, int>::type = 0> + bool all_true(const T & v) { return v; } + + template + bool all_true(const std::bitset & b) + { + return b.all(); + } + +} + +#endif // DUNE_COMMON_RANGE_UTILITIES_HH diff -Nru dune-common-2.2.1/dune/common/reservedvector.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/reservedvector.hh --- dune-common-2.2.1/dune/common/reservedvector.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/reservedvector.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,12 +1,17 @@ -#ifndef RESERVEDVECTOR_HH -#define RESERVEDVECTOR_HH +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_COMMON_RESERVEDVECTOR_HH +#define DUNE_COMMON_RESERVEDVECTOR_HH /** \file * \brief An stl-compliant random-access container which stores everything on the stack -*/ + */ +#include #include +#include #include +#include #ifdef CHECK_RESERVEDVECTOR #define CHECKSIZE(X) assert(X) @@ -16,188 +21,195 @@ namespace Dune { - /** - \brief A Vector class with statically reserved memory. + /** + \brief A Vector class with statically reserved memory. + + ReservedVector is something between Dune::array and std::vector. + You have vector which can be extended and shrunk using methods like + push_back and pop_back, but reserved memory is predefined. + + This implies that the vector can not grow bigger than the predefined + maximum size. + + \tparam T The data type ReservedVector stores. + \tparam n The maximum number of objects the ReservedVector can store. + + */ + template + class ReservedVector + { + public: + + /** @{ Typedefs */ + + //! The type of object, T, stored in the vector. + typedef T value_type; + //! Pointer to T. + typedef T* pointer; + //! Reference to T + typedef T& reference; + //! Const reference to T + typedef const T& const_reference; + //! An unsigned integral type. + typedef size_t size_type; + //! A signed integral type. + typedef std::ptrdiff_t difference_type; + //! Iterator used to iterate through a vector. + typedef Dune::GenericIterator iterator; + //! Const iterator used to iterate through a vector. + typedef Dune::GenericIterator const_iterator; + + /** @} */ + + /** @{ Constructors */ + + //! Constructor + ReservedVector() : sz(0) {} + + ReservedVector(std::initializer_list const &l) + { + assert(l.size() <= n);// Actually, this is not needed any more! + sz = l.size(); + std::copy_n(l.begin(), sz, data); + } + + /** @} */ + + /** @{ Data access operations */ + + //! Erases all elements. + void clear() + { + sz = 0; + } + + //! Specifies a new size for the vector. + void resize(size_t s) + { + CHECKSIZE(s<=n); + sz = s; + } + + //! Appends an element to the end of a vector, up to the maximum size n, O(1) time. + void push_back(const T& t) + { + CHECKSIZE(szi); + return data[i]; + } + + //! Returns a const reference to the i'th element. + const_reference operator[] (size_type i) const + { + CHECKSIZE(sz>i); + return data[i]; + } + + //! Returns reference to first element of vector. + reference front() + { + CHECKSIZE(sz>0); + return data[0]; + } + + //! Returns const reference to first element of vector. + const_reference front() const + { + CHECKSIZE(sz>0); + return data[0]; + } + + //! Returns reference to last element of vector. + reference back() + { + CHECKSIZE(sz>0); + return data[sz-1]; + } + + //! Returns const reference to last element of vector. + const_reference back() const + { + CHECKSIZE(sz>0); + return data[sz-1]; + } + + /** @} */ + + /** @{ Informative Methods */ + + //! Returns number of elements in the vector. + size_type size () const + { + return sz; + } + + //! Returns true if vector has no elements. + bool empty() const + { + return sz==0; + } + + //! Returns current capacity (allocated memory) of the vector. + static constexpr size_type capacity() + { + return n; + } + + //! Returns the maximum length of the vector. + static constexpr size_type max_size() + { + return n; + } + + /** @} */ + + //! Send ReservedVector to an output stream + friend std::ostream& operator<< (std::ostream& s, const ReservedVector& v) + { + for (size_t i=0; i - class ReservedVector - { - public: - - /** @{ Typedefs */ - - //! The type of object, T, stored in the vector. - typedef T value_type; - //! Pointer to T. - typedef T* pointer; - //! Reference to T - typedef T& reference; - //! Const reference to T - typedef const T& const_reference; - //! An unsigned integral type. - typedef size_t size_type; - //! A signed integral type. - typedef std::ptrdiff_t difference_type; - //! Iterator used to iterate through a vector. - typedef Dune::GenericIterator iterator; - //! Const iterator used to iterate through a vector. - typedef Dune::GenericIterator const_iterator; - - /** @} */ - - /** @{ Constructors */ - - //! Constructor - ReservedVector() : sz(0) {} - - /** @} */ - - /** @{ Data access operations */ - - //! Erases all elements. - void clear() - { - sz = 0; - } - - //! Specifies a new size for the vector. - void resize(size_t s) - { - CHECKSIZE(s<=n); - sz = s; - } - - //! Appends an element to the end of a vector, up to the maximum size n, O(1) time. - void push_back(const T& t) - { - CHECKSIZE(szi); - return data[i]; - } - - //! Returns a const reference to the i'th element. - const_reference operator[] (size_type i) const - { - CHECKSIZE(sz>i); - return data[i]; - } - - //! Returns reference to first element of vector. - reference front() - { - CHECKSIZE(sz>0); - return data[0]; - } - - //! Returns const reference to first element of vector. - const_reference front() const - { - CHECKSIZE(sz>0); - return data[0]; - } - - //! Returns reference to last element of vector. - reference back() - { - CHECKSIZE(sz>0); - return data[sz-1]; - } - - //! Returns const reference to last element of vector. - const_reference back() const - { - CHECKSIZE(sz>0); - return data[sz-1]; - } - - /** @} */ - - /** @{ Informative Methods */ - - //! Returns number of elements in the vector. - size_type size () const - { - return sz; - } - - //! Returns true if vector has no elements. - bool empty() const - { - return sz==0; - } - - //! Returns current capacity (allocated memory) of the vector. - static size_type capacity() - { - return n; - } - - //! Returns the maximum length of the vector. - static size_type max_size() - { - return n; - } - - /** @} */ - - //! Send ReservedVector to an output stream - friend std::ostream& operator<< (std::ostream& s, const ReservedVector& v) - { - for (size_t i=0; i -#endif -#endif +#include -#include -#include +#include /** * @file * @brief This file implements the class shared_ptr (a reference counting @@ -24,504 +15,143 @@ */ namespace Dune { - // A shared_ptr implementation has been found if SHARED_PTR_NAMESPACE is set at all -#ifdef SHARED_PTR_NAMESPACE - using SHARED_PTR_NAMESPACE :: shared_ptr; -#else - - /** @addtogroup Common - * - * @{ - */ - - /** @brief The object we reference. */ - class SharedCount - { - template - friend class shared_ptr; - protected: - /** @brief The number of references. */ - int count_; - /** @brief Constructor from existing Pointer. */ - SharedCount() : count_(1) {} - /** @brief Copy constructor with type conversion. */ - SharedCount(const SharedCount& rep) - : count_(rep.count_) {} - - /** @brief Destructor, deletes element_type* rep_. */ - virtual ~SharedCount() {}; - - }; - /** - * @brief A reference counting smart pointer. - * - * It is designed such that it is usable within a std::vector. - * The contained object is destroyed only if there are no more - * references to it. - */ - template - class shared_ptr - { - template friend class shared_ptr; - - public: - /** - * @brief The data type we are a pointer for. - * - * This has to have a parameterless constructor. - */ - typedef T element_type; - - /** - * @brief Constructs a new smart pointer and allocates the referenced Object. - */ - inline shared_ptr(); - - inline shared_ptr(nullptr_t null); - - /** - * @brief Constructs a new smart pointer from a preallocated Object. - * - * \param pointer Raw pointer to the shared data - * - * note: the object must be allocated on the heap and after handing the pointer to - * shared_ptr the ownership of the pointer is also handed to the shared_ptr. - */ - template - inline shared_ptr(T1 * pointer); - - - /** - * @brief Constructs a new smart pointer from a preallocated Object. - * - * \tparam Deleter This class must by copyconstructable, the copy constructor must not throw an exception - * and it must implement void operator() (T*) const - * - * \param pointer Raw pointer to the shared data - * \param deleter A copy of this deleter is stored - * - * note: the object must be allocated on the heap and after handing the pointer to - * shared_ptr the ownership of the pointer is also handed to the shared_ptr. - */ - template - inline shared_ptr(T1 * pointer, Deleter deleter); - - /** - * @brief Copy constructor. - * @param pointer The object to copy. - */ - template - inline shared_ptr(const shared_ptr& pointer); - - /** - * @brief Copy constructor. - * @param pointer The object to copy. - */ - inline shared_ptr(const shared_ptr& pointer); - - /** - * @brief Destructor. - */ - inline ~shared_ptr(); - - /** \brief Assignment operator */ - template - inline shared_ptr& operator=(const shared_ptr& pointer); - - /** \brief Assignment operator */ - inline shared_ptr& operator=(const shared_ptr& pointer); - - /** \brief Dereference as object */ - inline element_type& operator*(); - - /** \brief Dereference as pointer */ - inline element_type* operator->(); - - /** \brief Dereference as const object */ - inline const element_type& operator*() const; - - /** \brief Dereference as const pointer */ - inline const element_type* operator->() const; - - /** \brief Access to the raw pointer, if you really want it */ - element_type* get() const { - return rep_; - } - - /** \brief Checks if shared_ptr manages an object, i.e. whether get() != 0. */ - operator bool() const { - return count_ != 0 && rep_ != 0; - } - - /** \brief Swap content of this shared_ptr and another */ - inline void swap(shared_ptr& other); - - /** \brief Decrease the reference count by one and free the memory if the - reference count has reached 0 - */ - inline void reset(); - - /** \brief Detach shared pointer and set it anew for the given pointer */ - template - inline void reset(T1* pointer); - - //** \brief Same as shared_ptr(pointer,deleter).swap(*this) - template - inline void reset(T1* pointer, Deleter deleter); - - /** \brief The number of shared_ptrs pointing to the object we point to */ - int use_count() const; - - private: - /** \brief Assignment operator */ - template - inline shared_ptr& assign(const shared_ptr& pointer); - /** @brief Adds call to deleter to SharedCount. */ - template - class SharedCountImpl : - public SharedCount - { - template - friend class shared_ptr; - /** @brief Constructor from existing Pointer with custom deleter. */ - SharedCountImpl(T* elem,const Deleter& deleter) : - SharedCount(), - rep_(elem), - deleter_(deleter) - {} - /** @brief Copy constructor with type conversion. */ - SharedCountImpl(const SharedCountImpl& rep) - : SharedCount(rep), deleter_(rep.deleter_) {} - /** @brief Destructor, deletes element_type* rep_ using deleter. */ - ~SharedCountImpl() - { deleter_(rep_); } - - // store a copy of the deleter - Deleter deleter_; - T* rep_; - }; - - /** \brief A default deleter that just calls delete */ - struct DefaultDeleter - { - void operator() (element_type* p) const - { delete p; } - }; - - - SharedCount *count_; - T *rep_; - - // Needed for the implicit conversion to "bool" - typedef T* *__unspecified_bool_type; - - public: - /** \brief Implicit conversion to "bool" */ - operator __unspecified_bool_type() const // never throws - { - return rep_ == 0 ? 0 : &shared_ptr::rep_; - } - - }; - - template - template - inline shared_ptr::shared_ptr(T1 * p) - { - rep_ = p; - count_ = new SharedCountImpl(p, DefaultDeleter()); - } - - template - inline shared_ptr::shared_ptr(nullptr_t n) - { - rep_ = 0; - count_ = 0; - } - - template - template - inline shared_ptr::shared_ptr(T1 * p, Deleter deleter) - { - rep_ = p; - count_ = new SharedCountImpl(p, deleter); - } - - template - inline shared_ptr::shared_ptr() - { - rep_ = 0; - count_=0; - } - - template - template - inline shared_ptr::shared_ptr(const shared_ptr& other) - : rep_(other.rep_), count_(other.count_) - { - if (rep_) - ++(count_->count_); - } - - template - inline shared_ptr::shared_ptr(const shared_ptr& other) - : rep_(other.rep_), count_(other.count_) - { - if (rep_) - ++(count_->count_); - } - - template - template - inline shared_ptr& shared_ptr::operator=(const shared_ptr& other) - { - return assign(other); - } - - template - inline shared_ptr& shared_ptr::operator=(const shared_ptr& other) - { - return assign(other); - } - - template - template - inline shared_ptr& shared_ptr::assign(const shared_ptr& other) - { - if (other.count_) - (other.count_->count_)++; - - if(rep_!=0 && --(count_->count_)<=0){ - delete count_; - } - - rep_ = other.rep_; - count_ = other.count_; - return *this; - } - - template - inline shared_ptr::~shared_ptr() - { - if(rep_!=0 && --(count_->count_)==0){ - delete count_; - rep_=0; - } - } - - template - inline T& shared_ptr::operator*() - { - return *(rep_); - } - - template - inline T *shared_ptr::operator->() - { - return rep_; - } - - template - inline const T& shared_ptr::operator*() const - { - return *(rep_); - } - - template - inline const T *shared_ptr::operator->() const - { - return rep_; - } - - template - inline int shared_ptr::use_count() const - { - return count_->count_; - } - - template - inline void shared_ptr::swap(shared_ptr& other) - { - SharedCount* dummy = count_; - count_=other.count_; - other.count_ = dummy; - T* tdummy=rep_; - rep_ = other.rep_; - other.rep_ = tdummy; - } - - template - inline void shared_ptr::reset() - { - shared_ptr().swap(*this); - } - - template - template - inline void shared_ptr::reset(T1* pointer) - { - shared_ptr(pointer).swap(*this); - } - - template - template - inline void shared_ptr::reset(T1* pointer, Deleter deleter) - { - shared_ptr(pointer, deleter).swap(*this); - } - - /** @} */ -#endif // #ifdef SHARED_PTR_NAMESPACE - - -// C++0x and Boost have a make_shared implementation, TR1 does not. -// Unfortunately, TR1 gets picked over Boost if present. -// Moreover, boost::make_shared() only exists for (remotely) recent versions of Boost. -#if HAVE_MAKE_SHARED -#ifdef SHARED_PTR_NAMESPACE - using SHARED_PTR_NAMESPACE :: make_shared; -#endif -#else - - template - shared_ptr make_shared() - { - return shared_ptr(new T()); - } - - template - shared_ptr make_shared(const Arg1& arg1) - { - return shared_ptr(new T(arg1)); - } - - template - shared_ptr make_shared(const Arg1& arg1, const Arg2& arg2) - { - return shared_ptr(new T(arg1,arg2)); - } - - template - shared_ptr make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3) - { - return shared_ptr(new T(arg1,arg2,arg3)); - } - - template - shared_ptr make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) - { - return shared_ptr(new T(arg1,arg2,arg3,arg4)); - } - - template - shared_ptr make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5) - { - return shared_ptr(new T(arg1,arg2,arg3,arg4,arg5)); - } - - template - shared_ptr make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6) - { - return shared_ptr(new T(arg1,arg2,arg3,arg4,arg5,arg6)); - } - - template - shared_ptr make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6, const Arg7& arg7) - { - return shared_ptr(new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7)); - } - - template - shared_ptr make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6, const Arg7& arg7, const Arg8& arg8) - { - return shared_ptr(new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)); - } - - template - shared_ptr make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6, const Arg7& arg7, const Arg8& arg8, - const Arg9& arg9) - { - return shared_ptr(new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)); - } - -#endif // custom make_shared - - /** - @brief implements the Deleter concept of shared_ptr without deleting anything - @relates shared_ptr - - If you allocate an object on the stack, but want to pass it to a class or function as a shared_ptr, - you can use this deleter to avoid accidental deletion of the stack-allocated object. - - For convenience we provide two free functions to create a shared_ptr from a stack-allocated object - (\see stackobject_to_shared_ptr): - - 1) Convert a stack-allocated object to a shared_ptr: - @code - int i = 10; - shared_ptr pi = stackobject_to_shared_ptr(i); - @endcode - 2) Convert a stack-allocated object to a shared_ptr of a base class - @code - class A {}; - class B : public A {}; - - ... - - B b; - shared_ptr pa = stackobject_to_shared_ptr(b); - @endcode - - @tparam T type of the stack-allocated object - */ - template - struct null_deleter - { - void operator() (T* p) const {} - }; - - /** - @brief Convert a stack-allocated object to a shared_ptr: - @relates shared_ptr - @code - int i = 10; - shared_ptr pi = stackobject_to_shared_ptr(i); - @endcode - */ - template - inline shared_ptr stackobject_to_shared_ptr(T & t) - { - return shared_ptr(&t, null_deleter()); - } - - /** - @brief Convert a stack object to a shared_ptr of a base class - @relates shared_ptr - @code - class A {}; - class B : public A {}; - - ... - - B b; - shared_ptr pa = stackobject_to_shared_ptr(b); - @endcode - */ - template - inline shared_ptr stackobject_to_shared_ptr(T & t) - { - return shared_ptr(dynamic_cast(&t), null_deleter()); - } + // pull in default implementations + using std::shared_ptr; + using std::make_shared; + + /** + @brief implements the Deleter concept of shared_ptr without deleting anything + @relates shared_ptr + + If you allocate an object on the stack, but want to pass it to a class or function as a shared_ptr, + you can use this deleter to avoid accidental deletion of the stack-allocated object. + + For convenience we provide two free functions to create a shared_ptr from a stack-allocated object + (\see stackobject_to_shared_ptr): + + 1) Convert a stack-allocated object to a shared_ptr: + @code + int i = 10; + shared_ptr pi = stackobject_to_shared_ptr(i); + @endcode + 2) Convert a stack-allocated object to a shared_ptr of a base class + @code + class A {}; + class B : public A {}; + + ... + + B b; + shared_ptr pa = stackobject_to_shared_ptr(b); + @endcode + + @tparam T type of the stack-allocated object + */ + template + struct null_deleter + { + void operator() (T*) const {} + }; + + /** + @brief Create a shared_ptr for a stack-allocated object + @relatesalso null_deleter + @code + #include + @endcode + + Usage: + @code + int i = 10; + shared_ptr pi = stackobject_to_shared_ptr(i); + @endcode + The @c shared_ptr points to the object on the stack, but its deleter is + set to an instance of @c null_deleter so that nothing happens when the @c + shared_ptr is destroyed. + + @sa shared_ptr, null_deleter + */ + template + inline shared_ptr stackobject_to_shared_ptr(T & t) + { + return shared_ptr(&t, null_deleter()); + } + + /** + @brief Create a shared_ptr to a base class for a stack-allocated object + @relatesalso null_deleter + @code + #include + @endcode + + Usage: + @code + class A {}; + class B : public A {}; + + ... + + B b; + shared_ptr pa = stackobject_to_shared_ptr(b); + @endcode + The @c shared_ptr points to the object on the stack, but its deleter is + set to an instance of @c null_deleter so that nothing happens when the @c + shared_ptr is destroyed. + + @sa shared_ptr, null_deleter + */ + template + inline shared_ptr stackobject_to_shared_ptr(T & t) + { + return shared_ptr(dynamic_cast(&t), null_deleter()); + } + + + /** + * \brief Capture R-value reference to shared_ptr + * + * This will store a copy of the passed object in + * a shared_ptr. + * + * The two overloads of wrap_or_move are intended + * to capture references and temporaries in a unique + * way without creating copies and only moving if + * necessary. + * + * Be careful: Only use this function if you are + * aware of it's implications. You can e.g. easily + * end up storing a reference to a temporary if + * you use this inside of another function without + * perfect forwarding. + */ + template + auto wrap_or_move(T&& t) + { + return std::make_shared>(std::forward(t)); + } + + /** + * \brief Capture L-value reference to shared_ptr + * + * This will store a pointer for the passed reference + * in a non-owning shared_ptr. + * + * The two overloads of wrap_or_move are intended + * to capture references and temporaries in a unique + * way without creating copies and only moving if + * necessary. + * + * Be careful: Only use this function if you are + * aware of it's implications. You can e.g. easily + * end up storing a reference to a temporary if + * you use this inside of another function without + * perfect forwarding. + */ + template + auto wrap_or_move(T& t) + { + return stackobject_to_shared_ptr(t); + } } #endif diff -Nru dune-common-2.2.1/dune/common/simd.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/simd.hh --- dune-common-2.2.1/dune/common/simd.hh 1970-01-01 00:00:00.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/simd.hh 2017-08-08 08:39:46.000000000 +0000 @@ -0,0 +1,133 @@ +#ifndef DUNE_COMMON_SIMD_HH +#define DUNE_COMMON_SIMD_HH + +/** + \file Abstractions for support of dedicated SIMD data types + + Libraries like Vc (https://github.com/VcDevel/Vc) add high-level + data types for SIMD (or vectorization) support in C++. Most of + these operations mimic the behavior of a numerical data type. Some + boolean operations can not be implemented in a compatible way to + trivial data types. + + This header contains additional abstractions to help writing code + that works with trivial numericaldata types (like double) and Vc + vectorization data types. + + See also the conditional.hh and range_utils.hh headers. + */ + +#include +#include +#if HAVE_VC +#include +#endif + +namespace Dune +{ + + template + struct SimdScalarTypeTraits + { + using type = T; + }; + + template + using SimdScalar = typename SimdScalarTypeTraits::type; + +#if HAVE_VC + /* + Add Vc specializations for the SimdScalarTypeTraits trais class + */ + template + struct SimdScalarTypeTraits< Vc::Vector > + { + using type = T; + }; + + template + struct SimdScalarTypeTraits< Vc::SimdArray > + { + using type = T; + }; +#endif // HAVE_VC + +#if HAVE_VC + /* + Add Vc specializations for cond(), see conditional.hh + */ + template + Vc::Vector cond(const Vc::Mask & b, + const Vc::Vector & v1, + const Vc::Vector & v2) + { + return std::move(Vc::iif(b, v1, v2)); + } + + template + Vc::SimdArray cond(const typename Vc::SimdArray::mask_type & b, + const Vc::SimdArray & v1, + const Vc::SimdArray & v2) + { + return std::move(Vc::iif(b, v1, v2)); + } +#endif // HAVE_VC + +#if HAVE_VC + /* + Add Vc specializations for several boolean operations, see rangeutitlities.hh: + + max_value, min_value, any_true, all_true + */ + template + T max_value(const Vc::Vector & v) + { + return v.max(); + } + + template + double max_value(const Vc::SimdArray & v) + { + return v.max(); + } + + template + T min_value(const Vc::Vector & v) + { + return v.min(); + } + + template + double min_value(const Vc::SimdArray & v) + { + return v.min(); + } + + template + bool any_true(const Vc::Mask & v) + { + return Vc::any_of(v); + } + + template + bool any_true(const Vc::SimdMaskArray & v) + { + return Vc::any_of(v); + } + + template + bool all_true(const Vc::Mask & v) + { + return Vc::all_of(v); + } + + template + bool all_true(const Vc::SimdMaskArray & v) + { + return Vc::all_of(v); + } +#endif // HAVE_VC + +} // end namespace Dune + +#endif // DUNE_COMMON_SIMD_HH diff -Nru dune-common-2.2.1/dune/common/singleton.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/singleton.hh --- dune-common-2.2.1/dune/common/singleton.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/singleton.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,7 +1,9 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_SINGLETON_HH #define DUNE_SINGLETON_HH -#include +#include /** * @file @@ -17,7 +19,7 @@ * * The class represented by the template parameter T must * have a parameterless constructor. - * + * * Class T can be publicly derived from Singleton: * * \code @@ -29,7 +31,7 @@ * { * bytes = new char[1000]; * } - * + * * ~Foo() * { * delete[] bytes; @@ -50,8 +52,6 @@ template class Singleton { - /** @brief Smartpointer to the instance. */ - static std::auto_ptr instance_; protected: /* @brief Private constructor. */ Singleton(){} @@ -59,23 +59,19 @@ Singleton(const Singleton&){} /** @brief Private assignment operator. */ Singleton& operator=(const Singleton&){} - + public: /** * @brief Get the instance of the singleton. * @return The instance of the singleton. */ - static T& instance() + DUNE_EXPORT static T& instance() { - if(instance_.get() == 0) - instance_ = std::auto_ptr(new T()); - return *instance_; + static T instance_; + return instance_; } - }; + }; - template - typename std::auto_ptr Singleton::instance_; - } // namespace Dune #endif diff -Nru dune-common-2.2.1/dune/common/sllist.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/sllist.hh --- dune-common-2.2.1/dune/common/sllist.hh 2013-01-19 10:06:29.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/sllist.hh 2017-08-08 08:39:46.000000000 +0000 @@ -1,39 +1,40 @@ -// $Id: sllist.hh 7077 2013-01-19 10:06:29Z mblatt $ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_SLLIST_HH #define DUNE_SLLIST_HH -#include +#include #include -#include"iteratorfacades.hh" -#include +#include "iteratorfacades.hh" +#include namespace Dune -{ - /** +{ + /** * @addtogroup Common * * @{ */ /** - * @file + * @file * \brief Implements a singly linked list together with * the necessary iterators. * @author Markus Blatt */ template class SLListIterator; - + template class SLListConstIterator; - + template class SLListModifyIterator; - + /** * @brief A single linked list. * * The list is capable of insertions at the front and at - * the end and of removing elements at the front. Those + * the end and of removing elements at the front. Those * operations require constant time. */ template > @@ -44,17 +45,17 @@ friend class SLListConstIterator; public: - + /** * @brief The size type. */ typedef typename A::size_type size_type; - + /** * @brief The type we store. */ typedef T MemberType; - + /** * @brief The allocator to use. */ @@ -64,7 +65,7 @@ * @brief The mutable iterator of the list. */ typedef SLListIterator iterator; - + /** * @brief The constant iterator of the list. */ @@ -74,7 +75,7 @@ * @brief Constructor. */ SLList(); - + /** * @brief Copy constructor with type conversion. */ @@ -92,20 +93,20 @@ * Deallocates all elements in the list. */ ~SLList(); - + /** * @brief The type of the iterator capable of deletion * and insertion. */ typedef SLListModifyIterator ModifyIterator; - + /** * @brief Assignment operator. */ SLList& operator=(const SLList& other); - - - /** + + + /** * @brief Add a new entry to the end of the list. * @param item The item to add. */ @@ -116,29 +117,29 @@ * @param item The item to add. */ inline void push_front(const MemberType& item); - + /** * @brief Remove the first item in the list. */ inline void pop_front(); - - /** @brief Remove all elements from the list. */ + + /** @brief Remove all elements from the list. */ inline void clear(); /** - * @brief Get an iterator pointing to the first + * @brief Get an iterator pointing to the first * element in the list. * - * @return An iterator pointing to the first + * @return An iterator pointing to the first * element or the end if the list is empty. */ inline iterator begin(); - + /** - * @brief Get an iterator pointing to the first + * @brief Get an iterator pointing to the first * element in the list. * - * @return An iterator pointing to the first + * @return An iterator pointing to the first * element or the end if the list is empty. */ inline const_iterator begin() const; @@ -151,7 +152,7 @@ * of the list. */ inline ModifyIterator beginModify(); - + /** * @brief Get an iterator capable of deleting and * inserting elements. @@ -189,12 +190,12 @@ * contains. */ inline int size() const; - + bool operator==(const SLList& sl) const; - - + + bool operator!=(const SLList& sl) const; - + private: /** \todo Please doc me! */ struct Element @@ -209,9 +210,9 @@ MemberType item_; Element(const MemberType& item, Element* next_=0); - + Element(); - + ~Element(); }; @@ -220,13 +221,13 @@ * @param current Element whose next element should be deleted. */ void deleteNext(Element* current); - + /** * @brief Copy the elements from another list. * @param other The other list. */ void copyElements(const SLList& other); - + /** * @brief Delete the next element in the list. * @@ -245,17 +246,17 @@ /** @brief Pseudo element before the first entry. */ Element beforeHead_; - - /** - * @brief Pointer to he last element in the list. + + /** + * @brief Pointer to he last element in the list. * * If list is empty this will point to beforeHead_ */ Element* tail_; - + /** @brief The allocator we use. */ Allocator allocator_; - + /** brief The number of elements the list holds. */ int size_; }; @@ -269,10 +270,10 @@ friend class SLListConstIterator; friend class SLListModifyIterator; friend class SLList; - + public: inline SLListIterator(typename SLList::Element* item, - SLList* sllist) + SLList* sllist) : current_(item), list_(sllist) {} @@ -292,7 +293,7 @@ { return current_->item_; } - + /** * @brief Equality test for the iterator facade. * @param other The other iterator to check. @@ -302,7 +303,7 @@ { return current_==other.current_; } - + /** * @brief Equality test for the iterator facade. * @param other The other iterator to check. @@ -312,7 +313,7 @@ { return current_==other.current_; } - + /** * @brief Equality test for the iterator facade. * @param other The other iterator to check. @@ -322,7 +323,7 @@ { return current_==other.iterator_.current_; } - + /** * @brief Increment function for the iterator facade. */ @@ -336,8 +337,8 @@ * the current position. * @param v The value to insert. */ - inline void insertAfter(const T& v)const - { + inline void insertAfter(const T& v) const + { assert(list_ ); list_->insertAfter(current_, v); } @@ -352,14 +353,14 @@ assert(list_); list_->deleteNext(current_); } - + private: /** @brief The current element. */ typename SLList::Element* current_; /** @brief The list we iterate over. */ SLList* list_; }; - + /** * @brief A constant iterator for the SLList. */ @@ -381,7 +382,7 @@ inline SLListConstIterator(const SLListIterator& other) : current_(other.current_) {} - + inline SLListConstIterator(const SLListConstIterator& other) : current_(other.current_) {} @@ -389,7 +390,7 @@ inline SLListConstIterator(const SLListModifyIterator& other) : current_(other.iterator_.current_) {} - + /** * @brief Dereferencing function for the facade. * @return A reference to the element at the current position. @@ -398,7 +399,7 @@ { return current_->item_; } - + /** * @brief Equality test for the iterator facade. * @param other The other iterator to check. @@ -408,7 +409,7 @@ { return current_==other.current_; } - + /** * @brief Increment function for the iterator facade. */ @@ -416,12 +417,12 @@ { current_ = current_->next_; } - + private: /** @brief The current element. */ typename SLList::Element* current_; }; - + /** * @brief A mutable iterator for the SLList. */ @@ -432,18 +433,18 @@ friend class SLListIterator; public: inline SLListModifyIterator(SLListIterator beforeIterator, - SLListIterator _iterator) + SLListIterator _iterator) : beforeIterator_(beforeIterator), iterator_(_iterator) {} - inline SLListModifyIterator(const SLListModifyIterator& other) + inline SLListModifyIterator(const SLListModifyIterator& other) : beforeIterator_(other.beforeIterator_), iterator_(other.iterator_) {} - + inline SLListModifyIterator() : beforeIterator_(), iterator_() {} - + /** * @brief Dereferencing function for the iterator facade. * @return A reference to the element at the current position. @@ -452,39 +453,39 @@ { return *iterator_; } - + /** * @brief Test whether another iterator is equal. * @return true if the other iterator is at the same position as * this one. */ - inline bool equals(const SLListConstIterator& other) const + inline bool equals(const SLListConstIterator& other) const { return iterator_== other; } - + /** * @brief Test whether another iterator is equal. * @return true if the other iterator is at the same position as * this one. */ - inline bool equals(const SLListIterator& other) const + inline bool equals(const SLListIterator& other) const { return iterator_== other; } - + /** * @brief Test whether another iterator is equal. * @return true if the other iterator is at the same position as * this one. */ - inline bool equals(const SLListModifyIterator& other) const + inline bool equals(const SLListModifyIterator& other) const { return iterator_== other.iterator_; } - + /** * @brief Increment function for the iterator facade. */ @@ -496,12 +497,12 @@ /** * @brief Insert an element at the current position. - * + * * Starting from the element at the current position all * elements will be shifted by one position to the back. - * The iterator will point to the same element as before + * The iterator will point to the same element as before * after the insertion, i.e the number of increments to - * reach the same position from a begin iterator increases + * reach the same position from a begin iterator increases * by one. * This means the inserted element is the one before the one * the iterator points to. @@ -516,7 +517,7 @@ /** * @brief Delete the entry at the current position. * - * The iterator will be positioned at the next postion after the + * The iterator will be positioned at the next position after the * deletion * @warning This will invalidate all iterators positioned at the delete position! Use with care! */ @@ -525,18 +526,18 @@ ++iterator_; beforeIterator_.deleteNext(); } - + private: /** @brief Iterator positioned at the position before the current. */ SLListIterator beforeIterator_; /** @brief Iterator positioned at the current position. */ SLListIterator iterator_; }; -}// namespace Dune +} // namespace Dune namespace std { - + template ostream& operator<<(ostream& os, const Dune::SLList sllist) { @@ -545,22 +546,22 @@ Iterator current= sllist.begin(); os << "{ "; - - if(current!=end){ + + if(current!=end) { os<<*current<<" ("<(&(*current))<<")"; ++current; - + for(; current != end; ++current) - os<<", "<<*current<<" ("<(&(*current))<<")"; + os<<", "<<*current<<" ("<(&(*current))<<")"; } os<<"} "; return os; } -}//namespace std +} //namespace std namespace Dune { - + template SLList::Element::Element(const MemberType& item, Element* next) : next_(next), item_(item) @@ -570,13 +571,13 @@ SLList::Element::Element() : next_(0), item_() {} - + template SLList::Element::~Element() { next_=0; } - + template SLList::SLList() : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0) @@ -592,7 +593,7 @@ { copyElements(other); } - + template template SLList::SLList(const SLList& other) @@ -610,10 +611,10 @@ Iterator iend = other.end(); for(Iterator element=other.begin(); element != iend; ++element) push_back(*element); - + assert(other.size()==size()); } - + template SLList::~SLList() { @@ -626,20 +627,20 @@ if(size()!=other.size()) return false; for(const_iterator iter=begin(), oiter=other.begin(); - iter != end(); ++iter, ++oiter) + iter != end(); ++iter, ++oiter) if(*iter!=*oiter) - return false; + return false; return true; } - + template bool SLList::operator!=(const SLList& other) const { - if(size()==other.size()){ + if(size()==other.size()) { for(const_iterator iter=begin(), oiter=other.begin(); - iter != end(); ++iter, ++oiter) - if(*iter!=*oiter) - return true; + iter != end(); ++iter, ++oiter) + if(*iter!=*oiter) + return true; return false; }else return true; @@ -651,16 +652,16 @@ copyElements(other); return *this; } - + template inline void SLList::push_back(const MemberType& item) { assert(size_>0 || tail_==&beforeHead_); - tail_->next_ = allocator_.allocate(1, 0); + tail_->next_ = allocator_.allocate(1, 0); assert(size_>0 || tail_==&beforeHead_); - tail_ = tail_->next_; - ::new (static_cast(&(tail_->item_))) T(item); - tail_->next_=0; + tail_ = tail_->next_; + ::new (static_cast(&(tail_->item_)))T(item); + tail_->next_=0; assert(tail_->next_==0); ++size_; } @@ -684,10 +685,10 @@ // Use copy constructor to initialize memory allocator_.construct(current->next_, Element(item,tmp)); - + //::new(static_cast(&(current->next_->item_))) T(item); - if(!current->next_->next_){ + if(!current->next_->next_) { // Update tail assert(changeTail); tail_ = current->next_; @@ -695,18 +696,18 @@ ++size_; assert(!tail_->next_); } - + template inline void SLList::push_front(const MemberType& item) { - if(tail_ == &beforeHead_){ + if(tail_ == &beforeHead_) { // list was empty beforeHead_.next_ = tail_ = allocator_.allocate(1, 0); - ::new(static_cast(&beforeHead_.next_->item_)) T(item); + ::new(static_cast(&beforeHead_.next_->item_))T(item); beforeHead_.next_->next_=0; }else{ Element* added = allocator_.allocate(1, 0); - ::new(static_cast(&added->item_)) T(item); + ::new(static_cast(&added->item_))T(item); added->next_=beforeHead_.next_; beforeHead_.next_=added; } @@ -714,43 +715,43 @@ ++size_; } - + template inline void SLList::deleteNext(Element* current) { this->template deleteNext(current); } - + template template inline void SLList::deleteNext(Element* current) { assert(current->next_); Element* next = current->next_; - + if(watchForTail) - if(next == tail_){ - // deleting last element changes tail! - tail_ = current; - } - + if(next == tail_) { + // deleting last element changes tail! + tail_ = current; + } + current->next_ = next->next_; allocator_.destroy(next); allocator_.deallocate(next, 1); --size_; assert(!watchForTail || &beforeHead_ != tail_ || size_==0); } - + template inline void SLList::pop_front() { deleteNext(&beforeHead_); } - + template inline void SLList::clear() - { - while(beforeHead_.next_ ){ + { + while(beforeHead_.next_ ) { this->template deleteNext(&beforeHead_); } @@ -770,19 +771,19 @@ { return size_; } - + template inline SLListIterator SLList::begin() { return iterator(beforeHead_.next_, this); } - + template inline SLListConstIterator SLList::begin() const { return const_iterator(beforeHead_.next_); - } - + } + template inline SLListIterator SLList::end() { @@ -799,8 +800,8 @@ template inline SLListModifyIterator SLList::beginModify() { - return SLListModifyIterator(iterator(&beforeHead_, this), - iterator(beforeHead_.next_, this)); + return SLListModifyIterator(iterator(&beforeHead_, this), + iterator(beforeHead_.next_, this)); } template diff -Nru dune-common-2.2.1/dune/common/static_assert.hh dune-common-2.5.2~20170808ga5c076ca/dune/common/static_assert.hh --- dune-common-2.2.1/dune/common/static_assert.hh 2012-05-31 22:07:47.000000000 +0000 +++ dune-common-2.5.2~20170808ga5c076ca/dune/common/static_assert.hh 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=8 sw=2 sts=2: -#ifndef DUNE_STATIC_ASSERT_HH -#define DUNE_STATIC_ASSERT_HH - -/** \file - * \brief Fallback implementation of the C++0x static_assert feature - */ - -/** - * @addtogroup Common - * - * @{ - */ - -#if not HAVE_STATIC_ASSERT -// Taken from BOOST -// -// Helper macro CPPMAGIC_JOIN: -// The following piece of macro magic joins the two -// arguments together, even when one of the arguments is -// itself a macro (see 16.3.1 in C++ standard). The key -// is that macro expansion of macro arguments does not -// occur in CPPMAGIC_DO_JOIN2 but does in CPPMAGIC_DO_JOIN. -// -#define CPPMAGIC_JOIN( X, Y ) CPPMAGIC_DO_JOIN( X, Y ) -#define CPPMAGIC_DO_JOIN( X, Y ) CPPMAGIC_DO_JOIN2(X,Y) -#define CPPMAGIC_DO_JOIN2( X, Y ) X##Y - -template struct static_assert_failure; - -template <> struct static_assert_failure { }; - -template struct static_assert_test{}; -#endif - -/** - \brief Helper template so that compilation fails if condition is not true. - - \code - #include - dune_static_assert(CONDITION, ERRORMSG); - \endcode - - If CONDITION is not true, dune_static_assert fails. - - If the C++0x language feature static_assert is available, dune_static_assert - forwards everything to static_assert. Otherwise dune_static_assert implements a - test that triggers a compile time error if the condition is false. - - Example: - - \code - dune_static_assert(1<=2, "error"); - dune_static_assert((is_same::value), "error msg"); - dune_static_assert((is_same::value), "error msg"); // false, will trigger a compile time error - \endcode - - \note - \code -dune_static_assert(false, "error"); - \endcode - will usually not do what was intended, see Dune::AlwaysFalse for a way to - achieve the desired result. - - Be aware that... -