Commit 96cc7b62 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'master' into derivative_term

parents ff8498d1 2ab573aa
Pipeline #191 skipped
......@@ -9,6 +9,8 @@ cache:
#- ./contrib/ci-setup
#- dunecontrol --opts=/duneci/opts.clang --current all
#- dunecontrol --current make test
#only:
#- master
dune:git--gcc:
image: duneci/dune-fufem:git
......@@ -16,3 +18,5 @@ dune:git--gcc:
- ./contrib/ci-setup
- dunecontrol --opts=/duneci/opts.gcc --current all
- dunecontrol --current make test
only:
- master
cmake_minimum_required(VERSION 3.0)
project(dune-amdis CXX)
# set(ALBERTA_ROOT /opt/software/alberta)
# set(ALBERTA_INCLUDE_DIR /opt/software/alberta/include)
set(ALBERTA_ROOT /opt/software/alberta)
set(ALBERTA_INCLUDE_DIR /opt/software/alberta/include)
# set(CMAKE_PREFIX_PATH /opt/software/dune/lib/cmake)
# set(UG_DIR /opt/software/dune/lib/cmake/ug)
# set(Vc_DIR /opt/software/dune/lib/cmake/Vc)
......
Preparing the Sources
=========================
Additional to the software mentioned in README you'll need the
following programs installed on your system:
cmake >= 2.8.12
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)
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
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
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!
Preparing the Sources
=========================
The project *dune-amdis* requires a modern compiler supporting c++14 standard
and an up-to-date cmake >= 3.1 installed on the system.
Installation using dune-docker
------------------------------
The easyest way to compile and run the code is to use the prepared docker images.
Therefore, 1. install *docker*, 2. clone the project *dune-docker*, 3. create the
image `dune:git`, 4. run this docker image with interactive shell.
(See also the `README.md` in the *dune-docker* project for details).
Prepare for installation
------------------------
In order to resolve external dependencies, run the script `contrib/ci-setup`. This
will download the latest MTL4 library (and maybe more).
Compile and link the library and examples
-----------------------------------------
Simply run
```
dunecontrol --opts=/duneci/opts.gcc --current all
```
to build the library and to compile and link the examples from the `src/` directory.
\ No newline at end of file
......@@ -14,10 +14,10 @@ if [ ! -d install/MTL ]; then
cd ${root}
fi
if [ ! -d install/gtest ]; then
mkdir -p install/gtest
cd install/gtest
cmake -DCMAKE_INSTALL_PREFIX=${root}/install/gtest /usr/src/gtest
make
cd ${root}
fi
# if [ ! -d install/gtest ]; then
# mkdir -p install/gtest
# cd install/gtest
# cmake -DCMAKE_INSTALL_PREFIX=${root}/install/gtest /usr/src/gtest
# make
# cd ${root}
# fi
......@@ -30,7 +30,7 @@ if (Boost_FOUND)
add_library(boost INTERFACE)
target_include_directories(boost INTERFACE ${Boost_INCLUDE_DIR})
target_link_libraries(boost INTERFACE ${Boost_LIBRARIES})
target_link_libraries("duneamdis" INTERFACE boost)
target_link_libraries(duneamdis INTERFACE boost)
if (MSVC_SHARED_LIBS)
link_directories(${Boost_LIBRARY_DIRS})
......@@ -49,6 +49,10 @@ if (MTL_FOUND)
foreach (feature ${CXX_ELEVEN_FEATURE_LIST})
target_compile_definitions("duneamdis" PUBLIC MTL_WITH_${feature})
endforeach ()
if (HAVE_UMFPACK OR ENABLE_SUITESPARSE OR SuiteSparse_FOUND)
target_compile_definitions("duneamdis" PUBLIC MTL_HAS_UMFPACK)
endif ()
endif (MTL_FOUND)
......@@ -58,37 +62,73 @@ install(FILES
AdaptInstationary.hpp
AdaptStationary.hpp
AMDiS.hpp
Basic.hpp
CreatorInterface.hpp
CreatorMap.hpp
DirichletBC.hpp
DirichletBC.inc.hpp
FileWriter.hpp
Flag.hpp
IndexSeq.hpp
Initfile.hpp
LinearAlgebra.hpp
Log.hpp
Loop.hpp
Math.hpp
Mesh.hpp
OperatorEvaluation.hpp
Operator.hpp
Operator.inc.hpp
OperatorTermBase.hpp
OperatorTerm.hpp
ProblemInstatBase.hpp
ProblemInstat.hpp
ProblemInstat.inc.hpp
ProblemInterationInterface.hpp
ProblemStatBase.hpp
ProblemStat.hpp
ProblemStat.inc.hpp
ProblemStatBase.hpp
ProblemTimeInterface.hpp
StandardProblemIteration.hpp
Timer.hpp
TermGenerator.hpp
common/ConceptsBase.hpp
common/ClonablePtr.hpp
common/IndexSeq.hpp
common/Literals.hpp
common/Loops.hpp
common/Mpl.hpp
common/ScalarTypes.hpp
common/Timer.hpp
common/Traits.hpp
common/TupleUtility.hpp
common/Utility.hpp
common/ValueCategory.hpp
linear_algebra/LinearAlgebraBse.hpp
linear_algebra/LinearSolverInterface.hpp
linear_algebra/PreconditionerInterface.hpp
linear_algebra/RunnerInterface.hpp
linear_algebra/SolverInfo.hpp
linear_algebra/istl/DOFMatrix.hpp
linear_algebra/istl/DOFVector.hpp
linear_algebra/istl/ISTL_Preconditioner.hpp
linear_algebra/istl/ISTLRunner.hpp
linear_algebra/istl/ISTL_Solver.hpp
linear_algebra/istl/LinearSolver.hpp
linear_algebra/istl/Preconditioner.hpp
linear_algebra/istl/SystemMatrix.hpp
linear_algebra/istl/SystemVector.hpp
linear_algebra/mtl/BITL_Preconditioner.hpp
linear_algebra/mtl/BITL_Solver.hpp
linear_algebra/mtl/BlockMTLMatrix.hpp
linear_algebra/mtl/BlockMTLVector.hpp
linear_algebra/mtl/Copy.hpp
linear_algebra/mtl/DOFMatrix.hpp
linear_algebra/mtl/DOFVector.hpp
linear_algebra/mtl/ITL_Preconditioner.hpp
linear_algebra/mtl/ITL_Solver.hpp
linear_algebra/mtl/KrylovRunner.hpp
linear_algebra/mtl/LinearSolver.hpp
linear_algebra/mtl/Mapper.hpp
linear_algebra/mtl/MTLDenseVector.hpp
linear_algebra/mtl/Preconditioner.hpp
linear_algebra/mtl/SystemMatrix.hpp
linear_algebra/mtl/SystemVector.hpp
linear_algebra/mtl/UmfpackRunner.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/amdis)
#pragma once
#include <memory>
#include <string>
#include <dune/amdis/Log.hpp>
namespace AMDiS
{
......@@ -27,39 +30,9 @@ namespace AMDiS
* Must be implemented by sub classes of CreatorInterface.
* Creates a new instance of the sub class of BaseClass.
*/
virtual BaseClass* create() = 0;
/// Can be implemented by sub classes.
virtual void free(BaseClass*) {}
///
virtual bool isNullCreator()
{
return false;
}
virtual std::shared_ptr<BaseClass> create() = 0;
};
/** \brief
* A Creator which creates no object and returns NULL instead.
* Used together with the key word 'no' in CreatorMap.
*/
template <class BaseClass>
class NullCreator : public CreatorInterface<BaseClass>
{
/// Creates no object.
virtual BaseClass* create() override
{
return NULL;
}
/// Implementation of \ref CreatorInterface::isNullCreator()
virtual bool isNullCreator() override
{
return true;
}
};
/**
* \ingroup Common
*
......@@ -70,14 +43,29 @@ namespace AMDiS
class CreatorInterfaceName : public CreatorInterface<BaseClass>
{
public:
/// Sets \ref name
void setName(std::string str)
{
name = str;
}
protected:
std::string name;
virtual std::shared_ptr<BaseClass> create() override
{
AMDIS_ERROR_EXIT("This create method should not be called. Call create(string) instead!");
return {};
};
/** \brief
* Must be implemented by sub classes of CreatorInterfaceName.
* Creates a new instance of the sub class of BaseClass by passing a
* string to the constructor.
*/
virtual std::shared_ptr<BaseClass> create(std::string) = 0;
};
/// cast a ptr of CreatorInterface to CreatorInterfaceName
template <class BaseClass>
inline CreatorInterfaceName<BaseClass>* named(CreatorInterface<BaseClass>* ptr)
{
auto result = dynamic_cast<CreatorInterfaceName<BaseClass>*>(ptr);
AMDIS_TEST_EXIT_DBG(result, "Can not cast CreatorInterface to CreatorInterfaceName!");
return result;
}
} // end namespace AMDiS
#include "CreatorMap.hpp"
// AMDiS includes
#include "solver/ITL_Preconditioner.hpp"
#include "solver/ITL_Solver.hpp"
#include "solver/KrylovPreconditioner.hpp"
#include "solver/LinearSolverInterface.hpp"
#include "solver/UmfPackSolver.hpp"
namespace AMDiS
{
template<>
void CreatorMap<LinearSolverInterface>::addDefaultCreators()
{
LinearSolverCreator* creator;
// creators for MTL4 krylov solvers
// _________________________________________________________________________
creator = new CGSolver::Creator;
addCreator("mtl_cg", creator);
creator = new CGSSolver::Creator;
addCreator("mtl_cgs", creator);
creator = new BiCGSolver::Creator;
addCreator("mtl_bicg", creator);
creator = new BiCGStabSolver::Creator;
addCreator("mtl_bicgstab", creator);
creator = new BiCGStab2Solver::Creator;
addCreator("mtl_bicgstab2", creator);
creator = new BiCGStabEllSolver::Creator;
addCreator("mtl_bicgstab_ell", creator);
creator = new QMRSolver::Creator;
addCreator("mtl_qmr", creator);
creator = new TFQMRSolver::Creator;
addCreator("mtl_tfqmr", creator);
creator = new GMResSolver::Creator;
addCreator("mtl_gmres", creator);
creator = new GcrSolver::Creator;
addCreator("mtl_gcr", creator);
creator = new FGMResSolver::Creator;
addCreator("mtl_fgmres", creator);
creator = new IDRsSolver::Creator;
addCreator("mtl_idr_s", creator);
creator = new MinResSolver::Creator;
addCreator("mtl_minres", creator);
creator = new PreOnly::Creator;
addCreator("mtl_preonly", creator);
addCreator("mtl_richardson", creator);
#ifdef HAVE_UMFPACK
creator = new UmfPackSolver::Creator;
addCreator("mtl_umfpack", creator);
addCreator("mtl_direct", creator);
#endif
}
template<>
void CreatorMap<ITL_PreconditionerBase<MTLTypes::MTLMatrix, MTLTypes::MTLVector>>::addDefaultCreators()
{
using PreconditionCreator = CreatorInterfaceName<ITL_PreconditionerBase<MTLTypes::MTLMatrix, MTLTypes::MTLVector>>;
PreconditionCreator* creator;
creator = new DiagonalPreconditioner::Creator;
addCreator("diag", creator);
creator = new MassLumpingPreconditioner::Creator;
addCreator("lumping", creator);
addCreator("masslumping", creator);
creator = new ILUPreconditioner::Creator;
addCreator("ilu", creator);
creator = new ICPreconditioner::Creator;
addCreator("ic", creator);
creator = new IdentityPreconditioner::Creator;
addCreator("no", creator);
creator = new KrylovPreconditionerSeq::Creator;
addCreator("krylov", creator);
addCreator("solver", creator);
}
} // end namespace AMDiS
namespace AMDiS
{
template <class BaseClass>
void CreatorMap<BaseClass>::clear()
{
for (auto it = creatorMap.begin(); it != creatorMap.end(); ++it)
delete it->second;
}
} // end namespace AMDiS
......@@ -4,10 +4,17 @@
#include <map>
// AMDiS includes
#include "CreatorInterface.hpp"
#include <dune/amdis/CreatorInterface.hpp>
namespace AMDiS
{
{
// forward declaration.
// All classes that need creators must specialize this class and implement
// a static void init() method.
template <class BaseClass>
struct DefaultCreators;
/** \ingroup Common
* \brief
* A CreatorMap is used to construct objects, which types depends on key words
......@@ -19,58 +26,42 @@ namespace AMDiS
*/
template <class BaseClass>
class CreatorMap
{
{
public:
using CreatorMapType = std::map<std::string, CreatorInterface<BaseClass>*>;
using CreatorMapType = std::map< std::string, CreatorInterface<BaseClass>* >;
public:
/// Adds a new creator together with the given key to the map.
static void addCreator(std::string key, CreatorInterface<BaseClass>* creator)
{
init();
AMDIS_TEST_EXIT(creatorMap[key] == NULL,
AMDIS_TEST_EXIT( !creatorMap[key],
"There is already a creator for key " << key);
creatorMap[key] = creator;
}
static void addCreator(std::string backend,
std::string key,
CreatorInterface<BaseClass>* creator)
{
addCreator(backend + "_" + key, creator);
}
/// Creates a object of the type corresponding to key.
static CreatorInterface<BaseClass>* getCreator(std::string key,
std::string initFileStr)
static CreatorInterface<BaseClass>* getCreator(std::string key, std::string initFileStr)
{
init();
CreatorInterface<BaseClass>* creator = creatorMap[key];
auto it = creatorMap.find(key);
if (it == creatorMap.end())
key = "default";
auto creator = creatorMap[key];
AMDIS_TEST_EXIT(creator,
"No creator for key \"" << key << "\" defined in init file for parameter \"" << initFileStr << "\"");
return creator;
}
static void clear()
{
for (auto entries : creatorMap)
delete it->second;
}
static void addDefaultCreators();
protected:
/// Constructor is protected because derived maps should be singleton.
static void init()
{
if (!initialized)
{
if (!initialized) {
initialized = true;
NullCreator<BaseClass>* nullCreator = new NullCreator<BaseClass>;
addCreator("0", nullCreator);
addDefaultCreators();
DefaultCreators<BaseClass>::init();
}
}
......@@ -88,5 +79,3 @@ namespace AMDiS
bool CreatorMap<BaseClass>::initialized = false;
} // end namespace AMDiS
#include "CreatorMap.hh"
......@@ -4,7 +4,7 @@
#include <type_traits>
#include <vector>
#include <dune/functions/common/functionconcepts.hh>
#include <dune/amdis/common/ConceptsBase.hpp>
#include "Log.hpp"
......@@ -15,8 +15,8 @@ namespace AMDiS
{
public:
template <class Predicate, class Values,
class = std::enable_if_t< Dune::Functions::Concept::isFunction<Predicate, bool(WorldVector)>() &&
Dune::Functions::Concept::isFunction<Values, double(WorldVector)>() > >
class = std::enable_if_t< concepts::Functor<Predicate, bool(WorldVector)> &&
concepts::Functor<Values, double(WorldVector)> > >
DirichletBC(Predicate&& predicate, Values&& values)
: predicate(std::forward<Predicate>(predicate))
, values(std::forward<Values>(values))
......
......@@ -9,8 +9,8 @@
#include <dune/grid/io/file/vtk/vtksequencewriter.hh>
#include <dune/geometry/genericgeometry/referenceelements.hh>
#include "Loops.hpp"
#include "Initfile.hpp"
#include <dune/amdis/Initfile.hpp>
#include <dune/amdis/common/Loops.hpp>
namespace AMDiS
{
......@@ -52,7 +52,7 @@ namespace AMDiS
/// default write method for time-depended data
template <class SystemVectorType>
void write(double time, SystemVectorType&& solutions)
void write(double time, SystemVectorType const& solutions)
{
vtkWriter->clear();
// copy dofvector to vertex data
......@@ -67,7 +67,7 @@ namespace AMDiS
/// default write method for stationary data
template <class SystemVectorType>
void write(SystemVectorType&& solutions)
void write(SystemVectorType const& solutions)
{
vtkWriter->clear();
// copy dofvector to vertex data
......
......@@ -102,7 +102,7 @@ namespace AMDiS
boost::char_separator<char> sep(",; ");
Tokenizer tokens(valStr, sep);
int i = 0;
size_t i = 0;
for (auto token : tokens)
{
AMDIS_TEST_EXIT(i < dim, "Vector data exceeds array dimension!");
......
#pragma once
#include "linear_algebra/LinearSolverInterface.hpp"
#include "linear_algebra/SolverInfo.hpp"
#include <dune/amdis/linear_algebra/LinearSolverInterface.hpp>
#include <dune/amdis/linear_algebra/SolverInfo.hpp>
#if defined(AMDIS_BACKEND_ISTL)
#include "linear_algebra/istl/SystemVector.hpp"
#include "linear_algebra/istl/SystemMatrix.hpp"
#include "linear_algebra/istl/LinearSolver.hpp"
#include <dune/amdis/linear_algebra/istl/SystemVector.hpp>
#include <dune/amdis/linear_algebra/istl/SystemMatrix.hpp>
#include <dune/amdis/linear_algebra/istl/LinearSolver.hpp>
#elif defined(AMDIS_BACKEND_MTL)
#include "linear_algebra/mtl/SystemVector.hpp"
#include "linear_algebra/mtl/SystemMatrix.hpp"
#include "linear_algebra/mtl/LinearSolver.hpp"
#include "linear_algebra/mtl/ITL_Solver.hpp"
#include "linear_algebra/mtl/BITL_Solver.hpp"
#include <dune/amdis/linear_algebra/mtl/SystemVector.hpp>
#include <dune/amdis/linear_algebra/mtl/SystemMatrix.hpp>
#include <dune/amdis/linear_algebra/mtl/LinearSolver.hpp>
#include <dune/amdis/linear_algebra/mtl/ITL_Solver.hpp>
#include <dune/amdis/linear_algebra/mtl/BITL_Solver.hpp>
#elif defined(AMDIS_BACKEND_PETSC)
#include "linear_algebra/petsc/SystemVector.hpp"
#include "linear_algebra/petsc/SystemMatrix.hpp"
#include "linear_algebra/petsc/LinearSolver.hpp"
#include <dune/amdis/linear_algebra/petsc/SystemVector.hpp>
#include <dune/amdis/linear_algebra/petsc/SystemMatrix.hpp>
#include <dune/amdis/linear_algebra/petsc/LinearSolver.hpp>
#else
......
......@@ -29,6 +29,14 @@ namespace AMDiS
return addZOTImpl(toTerm(c));
}
template <class... Args>
static std::shared_ptr<Self> zot(Args&&... args)
{
auto op = std::make_shared<Self>();
op->addZOT(std::forward<Args>(args)...);