Commit 4888fda1 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

output changed from macros to variadic functions

parent ee990734
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(dune-amdis CXX) project(dune-amdis CXX)
set(ALBERTA_ROOT /opt/software/alberta) #set(ALBERTA_ROOT /opt/software/alberta)
set(ALBERTA_INCLUDE_DIR /opt/software/alberta/include) #set(ALBERTA_INCLUDE_DIR /opt/software/alberta/include)
# set(CMAKE_PREFIX_PATH /opt/software/dune/lib/cmake) # set(CMAKE_PREFIX_PATH /opt/software/dune/lib/cmake)
# set(UG_DIR /opt/software/dune/lib/cmake/ug) # set(UG_DIR /opt/software/dune/lib/cmake/ug)
# set(Vc_DIR /opt/software/dune/lib/cmake/Vc) # set(Vc_DIR /opt/software/dune/lib/cmake/Vc)
set(MTL_DIR ${CMAKE_SOURCE_DIR}/install/MTL/share/mtl) #set(MTL_DIR ${CMAKE_SOURCE_DIR}/install/MTL/share/mtl)
if(NOT (dune-common_DIR OR dune-common_ROOT OR if(NOT (dune-common_DIR OR dune-common_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*")) "${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
...@@ -30,6 +30,7 @@ add_subdirectory("src") ...@@ -30,6 +30,7 @@ add_subdirectory("src")
add_subdirectory("dune") add_subdirectory("dune")
add_subdirectory("doc") add_subdirectory("doc")
add_subdirectory("cmake/modules") add_subdirectory("cmake/modules")
add_subdirectory("projects")
# finalize the dune project, e.g. generating config.h etc. # finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE) finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
// AMDiS includes // AMDiS includes
#include "Initfile.hpp" #include <dune/amdis/Initfile.hpp>
#include "Log.hpp" #include <dune/amdis/Output.hpp>
namespace AMDiS namespace AMDiS
{ {
...@@ -17,7 +17,7 @@ namespace AMDiS ...@@ -17,7 +17,7 @@ namespace AMDiS
{ {
// Maybe initialize MPI // Maybe initialize MPI
Dune::MPIHelper& mpiHelper = Dune::MPIHelper::instance(argc, argv); Dune::MPIHelper& mpiHelper = Dune::MPIHelper::instance(argc, argv);
Parameters::clearData(); Parameters::clearData();
// read commandline arguments // read commandline arguments
...@@ -63,9 +63,7 @@ namespace AMDiS ...@@ -63,9 +63,7 @@ namespace AMDiS
if (vm.count("init-file")) if (vm.count("init-file"))
Parameters::init(vm["init-file"].as<std::string>()); Parameters::init(vm["init-file"].as<std::string>());
else else
{ error_exit("No init file specified!\n");
AMDIS_ERROR_EXIT("No init file specified!\n");
}
} }
else else
{ {
...@@ -78,7 +76,7 @@ namespace AMDiS ...@@ -78,7 +76,7 @@ namespace AMDiS
// if (vm.count("parameters") && !ignoreCommandline) // if (vm.count("parameters") && !ignoreCommandline)
// Parameters::readArgv(vm["parameters"].as<std::string>(),0); // Parameters::readArgv(vm["parameters"].as<std::string>(),0);
// TODO: add command-line arguments again. // TODO: add command-line arguments again.
return mpiHelper; return mpiHelper;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "Initfile.hpp" #include <dune/amdis/Initfile.hpp>
namespace AMDiS namespace AMDiS
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <vector> #include <vector>
// AMDiS includes // AMDiS includes
#include <dune/amdis/Log.hpp> #include <dune/amdis/Output.hpp>
#include <dune/amdis/Math.hpp> #include <dune/amdis/Math.hpp>
namespace AMDiS namespace AMDiS
...@@ -304,8 +304,8 @@ namespace AMDiS ...@@ -304,8 +304,8 @@ namespace AMDiS
double getEstSum(int index) const double getEstSum(int index) const
{ {
AMDIS_FUNCNAME_DBG("AdaptInfo::getEstSum()"); AMDIS_FUNCNAME_DBG("AdaptInfo::getEstSum()");
AMDIS_TEST_EXIT_DBG(static_cast<size_t>(index) < scalContents.size(), test_exit_dbg(static_cast<size_t>(index) < scalContents.size(),
"Wrong index for adaptInfo!\n"); "Wrong index for adaptInfo!\n");
return scalContents[index]->est_sum; return scalContents[index]->est_sum;
} }
...@@ -320,8 +320,8 @@ namespace AMDiS ...@@ -320,8 +320,8 @@ namespace AMDiS
double getEstMax(int index) const double getEstMax(int index) const
{ {
AMDIS_FUNCNAME_DBG("AdaptInfo::getEstSum()"); AMDIS_FUNCNAME_DBG("AdaptInfo::getEstSum()");
AMDIS_TEST_EXIT_DBG(static_cast<size_t>(index) < scalContents.size(), test_exit_dbg(static_cast<size_t>(index) < scalContents.size(),
"Wrong index for adaptInfo!\n"); "Wrong index for adaptInfo!\n");
return scalContents[index]->est_max; return scalContents[index]->est_max;
} }
......
#include "AdaptInstationary.hpp" #include "AdaptInstationary.hpp"
// AMDiS includes // AMDiS includes
#include "AdaptInfo.hpp" #include <dune/amdis/AdaptInfo.hpp>
#include "Flag.hpp" #include <dune/amdis/Flag.hpp>
#include "Initfile.hpp" #include <dune/amdis/Initfile.hpp>
#include "Log.hpp" #include <dune/amdis/Output.hpp>
#include "ProblemIterationInterface.hpp" #include <dune/amdis/ProblemIterationInterface.hpp>
#include "ProblemTimeInterface.hpp" #include <dune/amdis/ProblemTimeInterface.hpp>
namespace AMDiS namespace AMDiS
{ {
...@@ -46,8 +46,7 @@ namespace AMDiS ...@@ -46,8 +46,7 @@ namespace AMDiS
problemTime->setTime(adaptInfo); problemTime->setTime(adaptInfo);
AMDIS_MSG("time = " << adaptInfo.getTime() << ", timestep = " msg("time = ", adaptInfo.getTime(), ", timestep = ", adaptInfo.getTimestep());
<< adaptInfo.getTimestep());
adaptInfo.setSpaceIteration(0); adaptInfo.setSpaceIteration(0);
...@@ -68,8 +67,7 @@ namespace AMDiS ...@@ -68,8 +67,7 @@ namespace AMDiS
adaptInfo.setTime(adaptInfo.getTime() + adaptInfo.getTimestep()); adaptInfo.setTime(adaptInfo.getTime() + adaptInfo.getTimestep());
problemTime->setTime(adaptInfo); problemTime->setTime(adaptInfo);
AMDIS_MSG("time = " << adaptInfo.getTime() << ", timestep = " msg("time = ", adaptInfo.getTime(), ", timestep = ", adaptInfo.getTimestep());
<< adaptInfo.getTimestep());
problemIteration->oneIteration(adaptInfo, NO_ADAPTION); problemIteration->oneIteration(adaptInfo, NO_ADAPTION);
...@@ -160,8 +158,7 @@ namespace AMDiS ...@@ -160,8 +158,7 @@ namespace AMDiS
adaptInfo.setTime(adaptInfo.getTime() + adaptInfo.getTimestep()); adaptInfo.setTime(adaptInfo.getTime() + adaptInfo.getTimestep());
problemTime->setTime(adaptInfo); problemTime->setTime(adaptInfo);
AMDIS_MSG("time = " << adaptInfo.getTime() << ", timestep = " msg("time = ", adaptInfo.getTime(), ", timestep = ", adaptInfo.getTimestep());
<< adaptInfo.getTimestep());
problemIteration->oneIteration(adaptInfo, FULL_ITERATION); problemIteration->oneIteration(adaptInfo, FULL_ITERATION);
...@@ -197,7 +194,7 @@ namespace AMDiS ...@@ -197,7 +194,7 @@ namespace AMDiS
simpleAdaptiveTimeStrategy(); simpleAdaptiveTimeStrategy();
break; break;
default: default:
AMDIS_ERROR_EXIT("Unknown strategy = " << strategy); error_exit("Unknown strategy = ", strategy);
} }
adaptInfo.incTimestepNumber(); adaptInfo.incTimestepNumber();
...@@ -209,12 +206,12 @@ namespace AMDiS ...@@ -209,12 +206,12 @@ namespace AMDiS
AMDIS_FUNCNAME("AdaptInstationary::adapt()"); AMDIS_FUNCNAME("AdaptInstationary::adapt()");
int errorCode = 0; int errorCode = 0;
AMDIS_TEST_EXIT(adaptInfo.getTimestep() >= adaptInfo.getMinTimestep(), test_exit(adaptInfo.getTimestep() >= adaptInfo.getMinTimestep(),
"timestep < min timestep"); "timestep < min timestep");
AMDIS_TEST_EXIT(adaptInfo.getTimestep() <= adaptInfo.getMaxTimestep(), test_exit(adaptInfo.getTimestep() <= adaptInfo.getMaxTimestep(),
"timestep > max timestep"); "timestep > max timestep");
AMDIS_TEST_EXIT(adaptInfo.getTimestep() > 0, "timestep <= 0!"); test_exit(adaptInfo.getTimestep() > 0, "timestep <= 0!");
if (adaptInfo.getTimestepNumber() == 0) if (adaptInfo.getTimestepNumber() == 0)
{ {
......
...@@ -24,7 +24,6 @@ set(BOOST_LIBS_REQUIRED system program_options) ...@@ -24,7 +24,6 @@ set(BOOST_LIBS_REQUIRED system program_options)
if (NOT BUILD_SHARED_LIBS) if (NOT BUILD_SHARED_LIBS)
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS ON)
endif (NOT BUILD_SHARED_LIBS) endif (NOT BUILD_SHARED_LIBS)
set(Boost_NO_SYSTEM_PATHS ON)
find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED}) find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED})
if (Boost_FOUND) if (Boost_FOUND)
add_library(boost INTERFACE) add_library(boost INTERFACE)
...@@ -49,14 +48,14 @@ if (MTL_FOUND) ...@@ -49,14 +48,14 @@ if (MTL_FOUND)
foreach (feature ${CXX_ELEVEN_FEATURE_LIST}) foreach (feature ${CXX_ELEVEN_FEATURE_LIST})
target_compile_definitions("duneamdis" PUBLIC MTL_WITH_${feature}) target_compile_definitions("duneamdis" PUBLIC MTL_WITH_${feature})
endforeach () endforeach ()
if (HAVE_UMFPACK OR ENABLE_SUITESPARSE OR SuiteSparse_FOUND) if (HAVE_UMFPACK OR ENABLE_SUITESPARSE OR SuiteSparse_FOUND)
target_compile_definitions("duneamdis" PUBLIC MTL_HAS_UMFPACK) target_compile_definitions("duneamdis" PUBLIC MTL_HAS_UMFPACK)
endif () endif ()
endif (MTL_FOUND) endif (MTL_FOUND)
install(FILES install(FILES
AdaptBase.hpp AdaptBase.hpp
AdaptInfo.hpp AdaptInfo.hpp
AdaptInstationary.hpp AdaptInstationary.hpp
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <string> #include <string>
#include <dune/amdis/common/Utility.hpp> #include <dune/amdis/common/Utility.hpp>
#include <dune/amdis/Log.hpp> #include <dune/amdis/Output.hpp>
namespace AMDiS namespace AMDiS
{ {
...@@ -31,7 +31,7 @@ namespace AMDiS ...@@ -31,7 +31,7 @@ namespace AMDiS
* Must be implemented by sub classes of CreatorInterface. * Must be implemented by sub classes of CreatorInterface.
* Creates a new instance of the sub class of BaseClass. * Creates a new instance of the sub class of BaseClass.
*/ */
virtual shared_ptr<BaseClass> create() = 0; virtual shared_ptr<BaseClass> create() = 0;
}; };
/** /**
...@@ -44,28 +44,28 @@ namespace AMDiS ...@@ -44,28 +44,28 @@ namespace AMDiS
class CreatorInterfaceName : public CreatorInterface<BaseClass> class CreatorInterfaceName : public CreatorInterface<BaseClass>
{ {
public: public:
virtual shared_ptr<BaseClass> create() override virtual shared_ptr<BaseClass> create() override
{ {
AMDIS_ERROR_EXIT("Should not be called. Call create(string) instead!"); error_exit("Should not be called. Call create(string) instead!");
return {}; return {};
}; };
/** \brief /** \brief
* Must be implemented by sub classes of CreatorInterfaceName. * Must be implemented by sub classes of CreatorInterfaceName.
* Creates a new instance of the sub class of BaseClass by passing a * Creates a new instance of the sub class of BaseClass by passing a
* string to the constructor. * string to the constructor.
*/ */
virtual shared_ptr<BaseClass> create(std::string) = 0; virtual shared_ptr<BaseClass> create(std::string) = 0;
}; };
/// cast a ptr of CreatorInterface to CreatorInterfaceName /// cast a ptr of CreatorInterface to CreatorInterfaceName
template <class BaseClass> template <class BaseClass>
inline CreatorInterfaceName<BaseClass>* named(CreatorInterface<BaseClass>* ptr) inline CreatorInterfaceName<BaseClass>* named(CreatorInterface<BaseClass>* ptr)
{ {
auto result = dynamic_cast<CreatorInterfaceName<BaseClass>*>(ptr); auto result = dynamic_cast<CreatorInterfaceName<BaseClass>*>(ptr);
AMDIS_TEST_EXIT_DBG(result, "Can not cast CreatorInterface to CreatorInterfaceName!"); test_exit_dbg(result, "Can not cast CreatorInterface to CreatorInterfaceName!");
return result; return result;
} }
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
#include <dune/amdis/CreatorInterface.hpp> #include <dune/amdis/CreatorInterface.hpp>
namespace AMDiS namespace AMDiS
{ {
// forward declaration. // forward declaration.
// All classes that need creators must specialize this class and implement // All classes that need creators must specialize this class and implement
// a static void init() method. // a static void init() method.
template <class BaseClass> template <class BaseClass>
struct DefaultCreators; struct DefaultCreators;
/** \ingroup Common /** \ingroup Common
* \brief * \brief
* A CreatorMap is used to construct objects, which types depends on key words * A CreatorMap is used to construct objects, which types depends on key words
...@@ -26,7 +26,7 @@ namespace AMDiS ...@@ -26,7 +26,7 @@ namespace AMDiS
*/ */
template <class BaseClass> template <class BaseClass>
class CreatorMap class CreatorMap
{ {
public: public:
using CreatorMapType = std::map< std::string, CreatorInterface<BaseClass>* >; using CreatorMapType = std::map< std::string, CreatorInterface<BaseClass>* >;
...@@ -35,8 +35,8 @@ namespace AMDiS ...@@ -35,8 +35,8 @@ namespace AMDiS
static void addCreator(std::string key, CreatorInterface<BaseClass>* creator) static void addCreator(std::string key, CreatorInterface<BaseClass>* creator)
{ {
init(); init();
AMDIS_TEST_EXIT( !creatorMap[key], test_exit(!creatorMap[key],
"There is already a creator for key " << key); "There is already a creator for key ", key);
creatorMap[key] = creator; creatorMap[key] = creator;
} }
...@@ -44,14 +44,14 @@ namespace AMDiS ...@@ -44,14 +44,14 @@ namespace AMDiS
static CreatorInterface<BaseClass>* getCreator(std::string key, std::string initFileStr) static CreatorInterface<BaseClass>* getCreator(std::string key, std::string initFileStr)
{ {
init(); init();
auto it = creatorMap.find(key); auto it = creatorMap.find(key);
if (it == creatorMap.end()) if (it == creatorMap.end())
key = "default"; key = "default";
auto creator = creatorMap[key]; auto creator = creatorMap[key];
AMDIS_TEST_EXIT(creator, test_exit(creator,
"No creator for key \"" << key << "\" defined in init file for parameter \"" << initFileStr << "\""); "No creator for key \"", key, "\" defined in init file for parameter \"", initFileStr, "\"");
return creator; return creator;
} }
......
...@@ -6,22 +6,22 @@ ...@@ -6,22 +6,22 @@
#include <dune/amdis/common/ConceptsBase.hpp> #include <dune/amdis/common/ConceptsBase.hpp>
#include "Log.hpp" #include <dune/amdis/Output.hpp>
namespace AMDiS namespace AMDiS
{ {
/// Implements a boundary condition of Dirichlet-type. /// Implements a boundary condition of Dirichlet-type.
/** /**
* By calling the methods \ref init() and \ref finish before and after * By calling the methods \ref init() and \ref finish before and after
* assembling the system-matrix, respectively, dirichlet boundary conditions * assembling the system-matrix, respectively, dirichlet boundary conditions
* can be applied to the matrix and system vector. Therefore a predicate * can be applied to the matrix and system vector. Therefore a predicate
* functions indicates the DOFs where values should be enforced and a second * functions indicates the DOFs where values should be enforced and a second
* functor provided in the constructor is responsible for determining the * functor provided in the constructor is responsible for determining the
* values to be set at the DOFs. * values to be set at the DOFs.
* *
* In the \ref finish method the matrix is called with \ref applyDirichletBC * In the \ref finish method the matrix is called with \ref applyDirichletBC
* to erase the corresponding rows and columns for the DOF indices. This * to erase the corresponding rows and columns for the DOF indices. This
* application of boundary conditions can be symmetric if the matrix does * application of boundary conditions can be symmetric if the matrix does
* support this symmetric modification. As a result, this method returns a list * support this symmetric modification. As a result, this method returns a list
* of columns values, that should be subtracted from the rhs. * of columns values, that should be subtracted from the rhs.
**/ **/
...@@ -36,25 +36,25 @@ namespace AMDiS ...@@ -36,25 +36,25 @@ namespace AMDiS
: predicate(std::forward<Predicate>(predicate)) : predicate(std::forward<Predicate>(predicate))
, values(std::forward<Values>(values)) , values(std::forward<Values>(values))
{} {}
template <class Matrix, class VectorX, class VectorB> template <class Matrix, class VectorX, class VectorB>
void init(bool apply, void init(bool apply,
Matrix& matrix, Matrix& matrix,
VectorX& rhs, VectorX& rhs,
VectorB& solution); VectorB& solution);
template <class Matrix, class VectorX, class VectorB> template <class Matrix, class VectorX, class VectorB>
void finish(bool apply, void finish(bool apply,
Matrix& matrix, Matrix& matrix,
VectorX& rhs, VectorX& rhs,
VectorB& solution); VectorB& solution);
private: private:
std::function<bool(WorldVector)> predicate; std::function<bool(WorldVector)> predicate;
std::function<double(WorldVector)> values; std::function<double(WorldVector)> values;
bool initialized = false; bool initialized = false;
std::vector<char> dirichletNodes; std::vector<char> dirichletNodes;
}; };
......
...@@ -8,29 +8,29 @@ namespace AMDiS ...@@ -8,29 +8,29 @@ namespace AMDiS
template <class WorldVector> template <class WorldVector>
template <class Matrix, class VectorX, class VectorB> template <class Matrix, class VectorX, class VectorB>
void DirichletBC<WorldVector>::init(bool apply, void DirichletBC<WorldVector>::init(bool apply,
Matrix& matrix, Matrix& matrix,
VectorX& solution, VectorX& solution,
VectorB& rhs) VectorB& rhs)
{ {
using Dune::Functions::interpolate; using Dune::Functions::interpolate;
if (!initialized) { if (!initialized) {
interpolate(matrix.getRowFeSpace(), dirichletNodes, predicate); interpolate(matrix.getRowFeSpace(), dirichletNodes, predicate);
initialized = true; initialized = true;
} }
} }
template <class WorldVector> template <class WorldVector>
template <class Matrix, class VectorX, class VectorB> template <class Matrix, class VectorX, class VectorB>
void DirichletBC<WorldVector>::finish(bool apply, void DirichletBC<WorldVector>::finish(bool apply,
Matrix& matrix, Matrix& matrix,
VectorX& solution, VectorX& solution,
VectorB& rhs) VectorB& rhs)
{ {
using Dune::Functions::interpolate; using Dune::Functions::interpolate;
AMDIS_TEST_EXIT( initialized, "Boundary condition not initialized!" ); test_exit(initialized, "Boundary condition not initialized!");
matrix.clearDirichletRows(dirichletNodes, apply); matrix.clearDirichletRows(dirichletNodes, apply);
if (apply) { if (apply) {
...@@ -38,6 +38,6 @@ namespace AMDiS ...@@ -38,6 +38,6 @@ namespace AMDiS
interpolate(matrix.getColFeSpace(), wrapper(solution.getVector()), values, dirichletNodes); interpolate(matrix.getColFeSpace(), wrapper(solution.getVector()), values, dirichletNodes);
} }
} }
} // end namespace AMDiS } // end namespace AMDiS
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
// a parser for arithmetic expressions // a parser for arithmetic expressions
// #include <muParser.h> // #include <muParser.h>
#include "Log.hpp" #include <dune/amdis/Output.hpp>
namespace AMDiS