[Dune-devel] [PATCH 1/2] Skeleton for the project of a grid backend based on the p4est library

Michaƫl Sghaier sghaier.michael at gmail.com
Tue Mar 8 09:07:48 CET 2016


---
 .gitignore                              | 28 ++++++++++++
 CMakeLists.txt                          | 28 ++++++++++++
 Makefile.am                             | 25 +++++++++++
 README                                  | 79 +++++++++++++++++++++++++++++++++
 cmake/Makefile.am                       |  3 ++
 cmake/modules/CMakeLists.txt            |  3 ++
 cmake/modules/DuneP4estgridMacros.cmake |  1 +
 cmake/modules/Makefile.am               |  6 +++
 configure.ac                            | 33 ++++++++++++++
 doc/CMakeLists.txt                      |  1 +
 doc/Makefile.am                         | 13 ++++++
 doc/doxygen/CMakeLists.txt              |  2 +
 doc/doxygen/Doxylocal                   | 30 +++++++++++++
 doc/doxygen/Makefile.am                 |  7 +++
 dune-p4estgrid.pc.in                    | 15 +++++++
 dune.module                             | 10 +++++
 dune/CMakeLists.txt                     |  1 +
 dune/Makefile.am                        |  5 +++
 dune/p4estgrid/CMakeLists.txt           |  2 +
 dune/p4estgrid/Makefile.am              |  6 +++
 dune/p4estgrid/p4estgrid.hh             |  6 +++
 m4/CMakeLists.txt                       |  1 +
 m4/Makefile.am                          |  8 ++++
 m4/dune-p4estgrid.m4                    | 17 +++++++
 src/CMakeLists.txt                      |  2 +
 src/Makefile.am                         | 39 ++++++++++++++++
 src/dune-p4estgrid.cc                   | 30 +++++++++++++
 stamp-regenerate-config-h               |  0
 stamp-vc                                |  1 +
 29 files changed, 402 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 CMakeLists.txt
 create mode 100644 Makefile.am
 create mode 100644 README
 create mode 100644 cmake/Makefile.am
 create mode 100644 cmake/modules/CMakeLists.txt
 create mode 100644 cmake/modules/DuneP4estgridMacros.cmake
 create mode 100644 cmake/modules/Makefile.am
 create mode 100644 configure.ac
 create mode 100644 doc/CMakeLists.txt
 create mode 100644 doc/Makefile.am
 create mode 100644 doc/doxygen/CMakeLists.txt
 create mode 100644 doc/doxygen/Doxylocal
 create mode 100644 doc/doxygen/Makefile.am
 create mode 100644 dune-p4estgrid.pc.in
 create mode 100644 dune.module
 create mode 100644 dune/CMakeLists.txt
 create mode 100644 dune/Makefile.am
 create mode 100644 dune/p4estgrid/CMakeLists.txt
 create mode 100644 dune/p4estgrid/Makefile.am
 create mode 100644 dune/p4estgrid/p4estgrid.hh
 create mode 100644 m4/CMakeLists.txt
 create mode 100644 m4/Makefile.am
 create mode 100644 m4/dune-p4estgrid.m4
 create mode 100644 src/CMakeLists.txt
 create mode 100644 src/Makefile.am
 create mode 100644 src/dune-p4estgrid.cc
 create mode 100644 stamp-regenerate-config-h
 create mode 100644 stamp-vc

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..50b3626
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,28 @@
+Makefile
+Makefile.in
+config.*
+configure
+dependencies.m4
+aclocal.m4
+autom4te.cache
+depcomp
+install-sh
+missing
+mkinstalldirs
+libtool
+dune-p4estgrid.pc
+semantic.cache
+configure.lineno
+stamp-h1
+dune-p4estgrid-*.tar.gz
+dune-p4estgrid-?.?
+ltmain.sh
+am
+.libs/
+.deps/
+*.la
+*.lo
+*.o
+compile
+test-driver
+build-*/
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..ec84852
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(dune-p4estgrid 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})
+
+#include the dune macros
+include(DuneMacros)
+
+# start a dune project with information from dune.module
+dune_project()
+dune_enable_all_packages()
+add_subdirectory("src")
+add_subdirectory("m4")
+add_subdirectory("dune")
+add_subdirectory("doc")
+add_subdirectory("cmake/modules")
+
+# finalize the dune project, e.g. generating config.h etc.
+finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..f92ab11
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,25 @@
+# we need the module file to be able to build via dunecontrol
+EXTRA_DIST = dune.module \
+  CMakeLists.txt \
+  config.h.cmake
+
+SUBDIRS = src m4 dune doc cmake
+
+if BUILD_DOCS
+# TODO: set up documentation tree automatically
+#SUBDIRS += doc
+endif
+
+# don't follow the full GNU-standard
+# we need automake 1.9 or newer
+AUTOMAKE_OPTIONS = foreign 1.9
+
+# pass most important options when "make distcheck" is used
+DISTCHECK_CONFIGURE_FLAGS = --with-dune-common=$(DUNE_COMMON_ROOT) --with-dune-geometry=$(DUNE_GEOMETRY_ROOT)  CXX="$(CXX)" CC="$(CC)"
+
+include $(top_srcdir)/am/top-rules
+include $(top_srcdir)/am/global-rules
+
+# Generate package configuration files for finding
+# installed modules with CMake
+include $(top_srcdir)/am/cmake-pkg-config
diff --git a/README b/README
new file mode 100644
index 0000000..c82aafe
--- /dev/null
+++ b/README
@@ -0,0 +1,79 @@
+Preparing the Sources
+=========================
+
+Additional to the software mentioned in README you'll need the
+following programs installed on your system:
+
+  cmake >= 2.8.12
+
+or if you use the old autoconf build system:
+
+  automake >= 1.9
+
+  autoconf >= 2.62
+
+  libtool
+
+Getting started
+---------------
+
+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
+directory. Note that if dune is not installed properly you will either
+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 call 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.
+
+The most convenient way is to use options files in this case. The files
+define four variables:
+
+CMAKE_FLAGS      flags passed to cmake
+AUTOGEN_FLAGS    flags passed to autogen
+CONFIGURE_FLAGS  flags passed to 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
+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
+AUTOGEN_FLAGS="--ac=2.50 --am=1.8" #Forces autoconf 2.50 and automake 1.8
+CONFIGURE_FLAGS="CXX=g++-4.9 --prefix=/install/path" #Force g++-4.9 as compiler
+MAKE_FLAGS=install #Per default run make install instead of simply make
+
+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.
+
+
+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!
diff --git a/cmake/Makefile.am b/cmake/Makefile.am
new file mode 100644
index 0000000..26735eb
--- /dev/null
+++ b/cmake/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = modules
+
+include $(top_srcdir)/am/global-rules
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
new file mode 100644
index 0000000..6c78379
--- /dev/null
+++ b/cmake/modules/CMakeLists.txt
@@ -0,0 +1,3 @@
+set(modules "DuneP4estgridMacros.cmake")
+
+install(FILES ${modules} DESTINATION ${DUNE_INSTALL_MODULEDIR})
diff --git a/cmake/modules/DuneP4estgridMacros.cmake b/cmake/modules/DuneP4estgridMacros.cmake
new file mode 100644
index 0000000..613dfb6
--- /dev/null
+++ b/cmake/modules/DuneP4estgridMacros.cmake
@@ -0,0 +1 @@
+# File for module specific CMake tests.
diff --git a/cmake/modules/Makefile.am b/cmake/modules/Makefile.am
new file mode 100644
index 0000000..fb3cdac
--- /dev/null
+++ b/cmake/modules/Makefile.am
@@ -0,0 +1,6 @@
+MODULES = DuneP4estgridMacros.cmake
+modulesdir = $(datadir)/dune/cmake/modules
+dist_modules_DATA = ${MODULES}
+
+include $(top_srcdir)/am/global-rules
+EXTRA_DIST = CMakeLists.txt
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..b6631e7
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,33 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+AC_PREREQ([2.62])
+DUNE_AC_INIT # gets module version from dune.module file
+AC_CONFIG_SRCDIR([src/dune-p4estgrid.cc])
+AC_CONFIG_HEADERS([config.h])
+
+# we need no more than the standard DE-stuff
+# this module depends on dune-common dune-geometry
+# this implies checking for [dune-common], [dune-geometry]
+DUNE_CHECK_ALL
+
+# implicitly set the Dune-flags everywhere
+AC_SUBST(AM_CPPFLAGS, $DUNE_CPPFLAGS)
+AC_SUBST(AM_LDFLAGS, $DUNE_LDFLAGS)
+LIBS="$DUNE_LIBS"
+
+AC_CONFIG_FILES([
+  Makefile
+  src/Makefile
+  cmake/Makefile
+  cmake/modules/Makefile
+  doc/Makefile
+  doc/doxygen/Makefile
+  doc/doxygen/Doxyfile
+  dune/Makefile
+  dune/p4estgrid/Makefile
+  m4/Makefile
+  dune-p4estgrid.pc
+])
+AC_OUTPUT
+# finally print the summary information
+DUNE_SUMMARY_ALL
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 0000000..be52cfc
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory("doxygen")
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..1512a7d
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,13 @@
+SUBDIRS = doxygen
+CURDIR = doc
+BASEDIR = ..
+
+# add list of html files to generate from wml
+PAGES=
+
+docdir=$(datadir)/doc/dune-p4estgrid
+
+EXTRA_DIST = CMakeLists.txt
+
+include $(top_srcdir)/am/webstuff
+include $(top_srcdir)/am/global-rules
diff --git a/doc/doxygen/CMakeLists.txt b/doc/doxygen/CMakeLists.txt
new file mode 100644
index 0000000..f7b8ea5
--- /dev/null
+++ b/doc/doxygen/CMakeLists.txt
@@ -0,0 +1,2 @@
+# shortcut for creating the Doxyfile.in and Doxyfile
+add_doxygen_target()
diff --git a/doc/doxygen/Doxylocal b/doc/doxygen/Doxylocal
new file mode 100644
index 0000000..ac65538
--- /dev/null
+++ b/doc/doxygen/Doxylocal
@@ -0,0 +1,30 @@
+# This file contains local changes to the doxygen configuration
+# please us '+=' to add file/directories to the lists
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT                 += @top_srcdir@/dune/
+# see e.g. dune-grid for the examples of mainpage and modules
+# INPUT                 += @srcdir@/mainpage \
+#                          @srcdir@/modules
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+# EXCLUDE               += @top_srcdir@/dune/p4estgrid/test
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+# EXAMPLE_PATH          += @top_srcdir@/src
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+# IMAGE_PATH            += @top_srcdir@/dune/p4estgrid/pics
diff --git a/doc/doxygen/Makefile.am b/doc/doxygen/Makefile.am
new file mode 100644
index 0000000..399d4ea
--- /dev/null
+++ b/doc/doxygen/Makefile.am
@@ -0,0 +1,7 @@
+BASEDIR=../..
+CURDIR=doc/doxygen
+
+EXTRA_DIST = CMakeLists.txt
+
+include $(top_srcdir)/am/doxygen
+include $(top_srcdir)/am/global-rules
diff --git a/dune-p4estgrid.pc.in b/dune-p4estgrid.pc.in
new file mode 100644
index 0000000..ced934f
--- /dev/null
+++ b/dune-p4estgrid.pc.in
@@ -0,0 +1,15 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+CXX=@CXX@
+CC=@CC@
+DEPENDENCIES=@REQUIRES@
+
+Name: @PACKAGE_NAME@
+Version: @VERSION@
+Description: dune-p4estgrid module
+URL: http://dune-project.org/
+Requires: dune-common dune-geometry
+Libs: -L${libdir}
+Cflags: -I${includedir}
diff --git a/dune.module b/dune.module
new file mode 100644
index 0000000..b417fdc
--- /dev/null
+++ b/dune.module
@@ -0,0 +1,10 @@
+################################
+# Dune module information file #
+################################
+
+#Name of the module
+Module: dune-p4estgrid
+Version: 0.1
+Maintainer: sghaier.michael at gmail.com
+#depending on
+Depends: dune-common dune-geometry
diff --git a/dune/CMakeLists.txt b/dune/CMakeLists.txt
new file mode 100644
index 0000000..6d474da
--- /dev/null
+++ b/dune/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(p4estgrid)
diff --git a/dune/Makefile.am b/dune/Makefile.am
new file mode 100644
index 0000000..9e2bd31
--- /dev/null
+++ b/dune/Makefile.am
@@ -0,0 +1,5 @@
+SUBDIRS = p4estgrid
+
+EXTRA_DIST = CMakeLists.txt
+
+include $(top_srcdir)/am/global-rules
diff --git a/dune/p4estgrid/CMakeLists.txt b/dune/p4estgrid/CMakeLists.txt
new file mode 100644
index 0000000..2bd0a2a
--- /dev/null
+++ b/dune/p4estgrid/CMakeLists.txt
@@ -0,0 +1,2 @@
+#install headers
+install(FILES p4estgrid.hh DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/p4estgrid)
diff --git a/dune/p4estgrid/Makefile.am b/dune/p4estgrid/Makefile.am
new file mode 100644
index 0000000..6e29358
--- /dev/null
+++ b/dune/p4estgrid/Makefile.am
@@ -0,0 +1,6 @@
+p4estgridincludedir = $(includedir)/dune/p4estgrid
+p4estgridinclude_HEADERS = p4estgrid.hh
+
+EXTRA_DIST = CMakeLists.txt
+
+include $(top_srcdir)/am/global-rules
diff --git a/dune/p4estgrid/p4estgrid.hh b/dune/p4estgrid/p4estgrid.hh
new file mode 100644
index 0000000..8aaaaaf
--- /dev/null
+++ b/dune/p4estgrid/p4estgrid.hh
@@ -0,0 +1,6 @@
+#ifndef DUNE_P4ESTGRID_HH
+#define DUNE_P4ESTGRID_HH
+
+// add your classes here
+
+#endif // DUNE_P4ESTGRID_HH
diff --git a/m4/CMakeLists.txt b/m4/CMakeLists.txt
new file mode 100644
index 0000000..febc960
--- /dev/null
+++ b/m4/CMakeLists.txt
@@ -0,0 +1 @@
+install(PROGRAMS dune-p4estgrid.m4 DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dune/aclocal)
diff --git a/m4/Makefile.am b/m4/Makefile.am
new file mode 100644
index 0000000..9a9df05
--- /dev/null
+++ b/m4/Makefile.am
@@ -0,0 +1,8 @@
+M4FILES = dune-p4estgrid.m4
+
+aclocaldir = $(datadir)/dune/aclocal
+aclocal_DATA = $(M4FILES)
+
+EXTRA_DIST = $(M4FILES) CMakeLists.txt
+
+include $(top_srcdir)/am/global-rules
diff --git a/m4/dune-p4estgrid.m4 b/m4/dune-p4estgrid.m4
new file mode 100644
index 0000000..3430a93
--- /dev/null
+++ b/m4/dune-p4estgrid.m4
@@ -0,0 +1,17 @@
+dnl -*- autoconf -*-
+# Macros needed to find dune-p4estgrid 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-p4estgrid
+# This macro should be invoked by every module which depends on dune-p4estgrid, as
+# well as by dune-p4estgrid itself
+AC_DEFUN([DUNE_P4ESTGRID_CHECKS])
+
+# Additional checks needed to find dune-p4estgrid
+# This macro should be invoked by every module which depends on dune-p4estgrid, but
+# not by dune-p4estgrid itself
+AC_DEFUN([DUNE_P4ESTGRID_CHECK_MODULE],
+[
+  DUNE_CHECK_MODULES([dune-p4estgrid],[p4estgrid/p4estgrid.hh])
+])
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..009b900
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable("dune-p4estgrid" dune-p4estgrid.cc)
+target_link_dune_default_libraries("dune-p4estgrid")
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..6f105fd
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,39 @@
+SUBDIRS =
+
+noinst_PROGRAMS = dune-p4estgrid
+
+dune_p4estgrid_SOURCES = dune-p4estgrid.cc
+
+dune_p4estgrid_CPPFLAGS = $(AM_CPPFLAGS) \
+	$(DUNEMPICPPFLAGS) \
+	$(UG_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.
+dune_p4estgrid_LDADD = \
+	$(DUNE_LDFLAGS) $(DUNE_LIBS) \
+	$(ALUGRID_LDFLAGS) $(ALUGRID_LIBS) \
+	$(ALBERTA_LDFLAGS) $(ALBERTA_LIBS) \
+	$(UG_LDFLAGS) $(UG_LIBS) \
+	$(DUNEMPILIBS)	\
+	$(LDADD)
+dune_p4estgrid_LDFLAGS = $(AM_LDFLAGS) \
+	$(DUNEMPILDFLAGS) \
+	$(UG_LDFLAGS) \
+	$(ALBERTA_LDFLAGS) \
+	$(ALUGRID_LDFLAGS) \
+	$(DUNE_LDFLAGS)
+
+# don't follow the full GNU-standard
+# we need automake 1.9
+AUTOMAKE_OPTIONS = foreign 1.9
+
+# pass most important options when "make distcheck" is used
+DISTCHECK_CONFIGURE_FLAGS = --with-dune-common=$(DUNE_COMMON_ROOT) --with-dune-geometry=$(DUNE_GEOMETRY_ROOT)  CXX="$(CXX)" CC="$(CC)"
+
+EXTRA_DIST = CMakeLists.txt
+
+include $(top_srcdir)/am/global-rules
diff --git a/src/dune-p4estgrid.cc b/src/dune-p4estgrid.cc
new file mode 100644
index 0000000..1833def
--- /dev/null
+++ b/src/dune-p4estgrid.cc
@@ -0,0 +1,30 @@
+// -*- 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 <iostream>
+#include <dune/common/parallel/mpihelper.hh> // An initializer of MPI
+#include <dune/common/exceptions.hh> // We use exceptions
+
+int main(int argc, char** argv)
+{
+  try{
+    // Maybe initialize MPI
+    Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
+    std::cout << "Hello World! This is dune-p4estgrid." << std::endl;
+    if(Dune::MPIHelper::isFake)
+      std::cout<< "This is a sequential program." << std::endl;
+    else
+      std::cout<<"I am rank "<<helper.rank()<<" of "<<helper.size()
+        <<" processes!"<<std::endl;
+    return 0;
+  }
+  catch (Dune::Exception &e){
+    std::cerr << "Dune reported error: " << e << std::endl;
+  }
+  catch (...){
+    std::cerr << "Unknown exception thrown!" << std::endl;
+  }
+}
diff --git a/stamp-regenerate-config-h b/stamp-regenerate-config-h
new file mode 100644
index 0000000..e69de29
diff --git a/stamp-vc b/stamp-vc
new file mode 100644
index 0000000..ea2c89e
--- /dev/null
+++ b/stamp-vc
@@ -0,0 +1 @@
+A stamp file to signify that this directory comes from a version control system, not an unpacked tarball
-- 
2.7.2





More information about the Dune-devel mailing list