Commit 931189ba authored by Praetorius, Simon's avatar Praetorius, Simon

Merge branch 'develop' into 'master'

Develop

See merge request !103
parents 4646e930 3efd88e3
Pipeline #1839 passed with stage
in 48 minutes and 21 seconds
---
cache:
paths:
- install/
before_script:
- source ~/toolchain
- export CMAKE_FLAGS="-DCMAKE_C_COMPILER='$CC' -DCMAKE_CXX_COMPILER='$CXX'"
dune:git--gcc:
image: mathiwr/dune:latest
variables:
GIT_SUBMODULE_STRATEGY: recursive
debian:10 gcc-8-17:
image: registry.dune-project.org/docker/ci/dune:2.6-debian-10-gcc-8-17
script:
- dunecontrol --current all
- dunecontrol --current make build_tests
- dunecontrol --current make test
- dunecontrol --current make examples
debian:10 clang-6-libcpp-17:
image: registry.dune-project.org/docker/ci/dune:2.6-debian-10-clang-6-libcpp-17
script:
- duneci-standard-test
- dunecontrol --current make examples
debian:9 gcc-6-14:
image: registry.dune-project.org/docker/ci/dune:2.6-debian-9-gcc-6-14
script:
- dunecontrol --current all
- dunecontrol --current make build_tests
- dunecontrol --current make test
only:
- develop
- dunecontrol --current make examples
ubuntu:18.04 clang-6-17:
image: registry.dune-project.org/docker/ci/dune:2.6-ubuntu-18.04-clang-6-17
script:
- duneci-standard-test
- dunecontrol --current make examples
[submodule "externals/fmt"]
path = externals/fmt
url = https://github.com/fmtlib/fmt.git
......@@ -12,18 +12,22 @@ include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
dune_enable_all_packages(MODULE_LIBRARIES amdis)
dune_enable_all_packages(MODULE_LIBRARIES amdis fmt)
add_subdirectory("bin")
add_subdirectory("cmake/modules")
add_subdirectory("doc")
add_subdirectory("externals")
add_subdirectory("src")
add_subdirectory("test")
add_subdirectory("examples" EXCLUDE_FROM_ALL)
add_subdirectory("doc")
add_subdirectory("cmake/modules")
target_include_directories(amdis PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>)
target_compile_definitions(amdis PUBLIC AMDIS_BACKEND_MTL=1)
target_compile_options(amdis PUBLIC -Wall -pedantic -Wno-unused-parameter) #-ftemplate-backtrace-limit=0
target_link_libraries(amdis fmt)
option(ENABLE_ALL_WARNINGS "enable all meaningful warnings" OFF)
if (ENABLE_ALL_WARNINGS)
target_compile_options(amdis PUBLIC "-Wall" "-Wextra" "-pedantic" "-Wnon-virtual-dtor" "-Wold-style-cast" "-Wcast-align" "-Woverloaded-virtual" "-Wpedantic" "-Wconversion")
endif (ENABLE_ALL_WARNINGS)
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
The MIT License (MIT)
Copyright (c) 2016 Simon Praetorius
Copyright (c) 2016-2018 Simon Praetorius
2018 Felix Müller
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
#pragma once
#include <string>
#include "Flag.hpp"
namespace AMDiS
{
class AdaptInfo;
class ProblemStatBase;
const Flag BUILD = 1; // Assemble vectors and matrices
const Flag BUILD_RHS = 2; // Assemble rhs vectors only
const Flag ADAPT = 4; // Run adaption procedure
const Flag SOLVE = 8; // Solve system
const Flag SOLVE_RHS = 16; // Solve system, where only rhs vectors have changed
const Flag ESTIMATE = 32; // Estimate error
const Flag MARK = 64; // Mark elements
const Flag FULL_ITERATION = BUILD | ADAPT | SOLVE | ESTIMATE | MARK;
const Flag NO_ADAPTION = BUILD | SOLVE | ESTIMATE;
/** \brief
* Interface for master problems needed by the adaption loop. A master problem
* can handle one single or multiple coupled problems. In the latter case,
* the master problem can determine the execution order of the build, solve,
* estimate, and adapt steps of the single problems in \ref oneIteration().
*/
class ProblemIterationInterface
{
public:
virtual ~ProblemIterationInterface() = default;
/// Called before each adaption loop iteration.
virtual void beginIteration(AdaptInfo&) { /* by default, do nothing */ }
/** \brief
* Determines the execution order of the single adaption steps. If adapt is
* true, mesh adaption will be performed. This allows to avoid mesh adaption,
* e.g. in timestep adaption loops of timestep adaptive strategies.
*/
virtual Flag oneIteration(AdaptInfo& adaptInfo, Flag toDo = FULL_ITERATION) = 0;
/// Called after each adaption loop iteration.
virtual void endIteration(AdaptInfo&) { /* by default, do nothing */ }
/// Returns number of managed problems
virtual int numProblems() const = 0;
/** \brief
* Returns the problem with the given number. If only one problem
* is managed by this master problem, the number hasn't to be given.
*/
virtual ProblemStatBase& problem(int number = 0) = 0;
/// Returns the problem with the given name.
virtual ProblemStatBase& problem(std::string const& name) = 0;
/// Returns the name of the problem.
virtual std::string const& name() const = 0;
};
} // end namespace AMDiS
......@@ -18,6 +18,7 @@ The `dunecontrol` script searches for the required
- [dune-geometry](https://gitlab.dune-project.org/core/dune-geometry)
- [dune-grid](https://gitlab.dune-project.org/core/dune-grid)
- [dune-localfunctions](https://gitlab.dune-project.org/core/dune-localfunctions)
- [dune-istl](https://gitlab.dune-project.org/core/dune-istl)
- [dune-typetree](https://gitlab.dune-project.org/staging/dune-typetree)
- [dune-functions](https://gitlab.dune-project.org/staging/dune-functions)
......@@ -26,20 +27,21 @@ can be obtained from https://gitlab.dune-project.org and need to be found in a
subdirectory of `DUNE_CONTROL_PATH`. See also https://dune-project.org/doc/installation
for details about the installation of dune modules.
Additionally we require the following libraries to be found:
Additionally the following optional libraries can be used:
- [MTL4](https://gitlab.math.tu-dresden.de/spraetor/mtl4) (use this fork to get up-to-date changes)
- [SuiteSparse](http://faculty.cse.tamu.edu/davis/suitesparse.html) (optional)
- [Eigen3](http://eigen.tuxfamily.org) >= 3.3
- [SuiteSparse](http://faculty.cse.tamu.edu/davis/suitesparse.html)
- libalberta >= 3.0 (For Alberta-Grids)
And a compiler that supports the C++14 standard, e.g. g++ >= 5.0 and clang >= 3.6, and cmake >= 3.1.
By default, the `dune-istl` linear-algebra backend is used. To choose one of `ISTL`, `MTL`, or `EIGEN`, you can specify the cmake parameter `-DBACKEND=[ISTL,MTL,EIGEN]`.
If your MTL4 installation is not found by default, you have to specify the path,
where the file `MTLConfig.cmake` is found, here called `MTL_ROOT`. Then simply use
`dunecontrol` to configure and `cmake` to build:
```
CMAKE_FLAGS="-DMTL_DIR:PATH=[MTL_ROOT]" dunecontrol --current configure
CMAKE_FLAGS="-DBACKEND=MTL -DMTL_DIR:PATH=[MTL_ROOT]" dunecontrol --current configure
cmake --build build-cmake
```
This compiles the library and all examples in the `src/` directory.
install(PROGRAMS
amdisproject
DESTINATION ${CMAKE_INSTALL_BINDIR})
#!/usr/bin/env bash
#
# TODO:
#
# * Check module names entered as dependencies.
set -e
canonicalname(){
if test $# -ne 1; then
echo Usage: canonicalname path >&2
return 1
fi
file="`eval echo $1`" # expand ~
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")"
}
pkg_config_dependencies(){
if test $# -ne 1; then
echo Usage: pkg_config_dependencies name >&2
return 1
fi
name="$1"
depends="`pkg-config --variable=DEPENDENCIES $name| sed -e 's/,/ /g'`"
for pkg in $depends; do
depends="$depends `pkg_config_dependencies $pkg`"
done
echo $depends
}
modulesexist(){
local status dep found
status=0
for dep in $1; do
found=false
if [[ " $2 " == *" $dep "* ]]; then
found=true
fi
# If module not found in list, try pkg-config
if ! $found && pkg-config $dep &> /dev/null; then
found=true
fi
if ! $found; then
echo "ERROR:">&2
echo "Module with name $dep was not found" >&2
echo "Did you forget to specify its location" >&2
echo "in the DUNE_CONTROL_PATH variable?">&2
echo >&2
status=1
fi
done
return $status
}
make_unique(){
if [ "$#" = "1" ]; then
# take first word
for exclude_word in $1; do
break;
done
make_unique $exclude_word "$1" 0
else
local exclude_word="$1"
local words="$2"
local pos="$3"
local length=0
local i=0
local new_words=""
local cur=0
for word in $words; do
if [ $i -le $pos ]; then
i=$((i+1))
length=$((length+1))
new_words="$new_words $word"
continue
fi
if [ "$word" != "$exclude_word" ]; then
new_words="$new_words $word"
if [ "$((length-1))" = "$pos" ]; then
next_word="$word"
fi
length=$((length+1))
fi
done
if [ "$pos" -lt "$length" ]; then
# process next word
make_unique "$next_word" "$new_words" $((pos+1))
else
export UNIQUE_WORDS="$new_words"
fi
fi
}
echo
echo == AMDiS project/module generator ==
echo
echo amdisproject will assist you in the creation of a new AMDiS application.
echo During this process a new directory with the name of your project will be
echo created. This directory will hold all configuration and Makefiles and a
echo simple example application.
echo
################## FIND AVAILABLE MODULES ##################
DUNE_MODULES_LIB=$(IFS=':' && find $DUNE_CONTROL_PATH -type f -path "*/lib/dunemodules.lib")
. ${DUNE_MODULES_LIB}
export PREFIX_DIR="`canonicalpath "${DUNE_MODULES_LIB}"`/.."
extract_multiarch_pkg_config_path
# search for modules, both installed and src modules
find_modules_in_path
# sort modules to remove duplicates
sort_modules $FOUND_MODULES
FOUND_MODULES=$MODULES
# require module amdis
modulesexist "amdis" "$FOUND_MODULES"
# get the real module names
MODULES=""
for i in $FOUND_MODULES; do
if [ "$i" != "amdis" ]; then
mod=$(eval echo \$NAME_$i)
MODULES="$MODULES$mod "
fi
done
if [ "$MODULES" = "" ]; then
echo "ERROR:">&2
echo " No dune modules were found!">&2
echo " Did you forget to specify the places where ">&2
echo " you installed your modules in the ">&2
echo " DUNE_CONTROL_PATH environment variable">&2
echo " and adjusted the PKG_CONFIG_PATH environment">&2
echo " accordingly?" >&2
exit 1;
fi
################## READ CMDLINE OPTIONS ##########
PROJECT="$1"
DEPENDENCIES="$2"
VERSION="$3"
MAINTAINER="$4"
################## READ OPTIONS ##################
while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do
while [ -z $PROJECT ]; do
read -p "1) Name of your new Project? (e.g.: amdis-ellipt): " PROJECT
if echo "$MODULES" | grep -q ^$PROJECT$; then
read -p " A module named $PROJECT already exists. Continue anyway? [y/N] " CONT
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"
DEPOK=1
while [ "$DEPOK" != 0 ]; do
echo "2) Which additional modules should this project depend on?"
echo " The following modules have been found:"
echo " $MODULES"
# for i in $MODULES; do echo -n " $i"; done
# echo ""
read -p " Enter space-separated list (or nothing): " DEPENDENCIES
if [ -z "$DEPENDENCIES" ]; then
DEPOK=0
fi
set +e
modulesexist "$DEPENDENCIES" "$MODULES"
DEPOK=$?
set -e
if [ "$DEPOK" != 0 ]; then
DEPENDENCIES=""
fi
done
if [ -z "$DEPENDENCIES" ]; then
DEPENDENCIES="amdis"
else
DEPENDENCIES="amdis ${DEPENDENCIES}"
fi
while [ -z $VERSION ]; do
read -p "3) Project/Module version? " VERSION
done
while [ -z "$MAINTAINER" ]; do
read -p "4) Maintainer's email address? " MAINTAINER
done
echo
echo "creating Project \"$PROJECT\", version $VERSION "
echo "which depends on \"$DEPENDENCIES\""
echo "with maintainer \"$MAINTAINER\""
read -p "Are these informations correct? [y/N] " DATACORRECT
# reset data if necessary
if [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; then
PROJECT=""
DEPENDENCIES=""
VERSION=""
MAINTAINER=""
fi
done
echo
echo "A sample code $MODULE.cc is generated in the \"$PROJECT\" directory."
echo "Look at the README.md 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 CMakeLists.txt a bit."
if test -d $PROJECT; then
echo WARNING:
echo "A directory with the name $PROJECT already exists."
echo "Do you want to continue anyway?"
read -p "Type Y to overwrite the old directory, N to abort. [y/N] " DELETE
if test x$DELETE != xy -a x$DELETE != xY; then
echo Abort...
exit 1
fi
rm -rf "$PROJECT"
fi
mkdir "$PROJECT"
################## dune.module ##################
cat > "$PROJECT/dune.module" <<C_DELIM
################################
# Dune module information file #
################################
Module: $MODULE
Version: $VERSION
Maintainer: $MAINTAINER
Depends: $DEPENDENCIES
Suggests: # add additional optional dune modules here
C_DELIM
## Create the parameters passed to DUNE_CHECK_ALL
# save module list of dunemodules.inc
save_MODULES=$MODULES
for name in $DEPENDENCIES; do
mod="`fix_variable_name $name`"
if test "x$(eval echo \$HAVE_$mod)" != "x"; then
# found via dunemodules.inc
sort_modules "$mod"
for mod in $MODULES; do
M_DEPS="$M_DEPS $(eval echo \$NAME_$mod)"
done
MODULES=$save_MODULES
else
# found via pkg-config
M_DEPS="`pkg_config_dependencies $name` $name"
fi
for dep in $M_DEPS; do
CHECK="$CHECK [$dep]"
done
done
set +x
make_unique "$CHECK"
# insert , between modules
j=0
for dep in $UNIQUE_WORDS; do
if [ "$j" = "0" ]; then
CHECK="$dep"
j=1
else
CHECK="$CHECK, $dep"
fi
done
echo "------------------------------------------"
echo "writing initial files:"
# complete module name with _ instead of - to not confuse automake
fix_and_assign CMODULE $MODULE
# module name without prefix "amdis-"
NAME=`echo $PROJECT | sed -e 's/amdis[_-]//'`
# $NAME with _ instead of - to not confuse automake
NAME_=`echo $NAME | tr '-' '_'`
# module name in uppercase with _ instead of -
UNAME=`echo $PROJECT | tr '-' '_' | sed 's/\(.*\)/\U\1/'`
################## README ##################
echo "- $PROJECT/README.md"
cat > "$PROJECT/README.md" <<R_DELIM
Preparing the Sources
=========================
Additional to the software mentioned in README.md you'll need the
following programs installed on your system:
cmake >= 3.1
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.
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 (during configure)
An example options file might look like this:
#use this options to configure and make if no other options are given
CMAKE_FLAGS=" \\
-DCMAKE_CXX_COMPILER=g++-5 \\
-DCMAKE_CXX_FLAGS='-Wall -pedantic' \\
-DCMAKE_INSTALL_PREFIX=/install/path" #Force g++-5 and set compiler flags
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
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!
R_DELIM
################## CMakeLists.txt ##################
echo "- $PROJECT/CMakeLists.txt"
cat> "$PROJECT/CMakeLists.txt" << M_DELIM
# We require version CMake version 3.1 to prevent issues
# with dune_enable_all_packages and older CMake versions.
cmake_minimum_required(VERSION 3.1)
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})
#include the dune macros
include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
dune_enable_all_packages()