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

output changed from macros to variadic functions

parent ee990734
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)
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
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
......@@ -30,6 +30,7 @@ add_subdirectory("src")
add_subdirectory("dune")
add_subdirectory("doc")
add_subdirectory("cmake/modules")
add_subdirectory("projects")
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
......@@ -6,8 +6,8 @@
#include <boost/program_options.hpp>
// AMDiS includes
#include "Initfile.hpp"
#include "Log.hpp"
#include <dune/amdis/Initfile.hpp>
#include <dune/amdis/Output.hpp>
namespace AMDiS
{
......@@ -17,7 +17,7 @@ namespace AMDiS
{
// Maybe initialize MPI
Dune::MPIHelper& mpiHelper = Dune::MPIHelper::instance(argc, argv);
Parameters::clearData();
// read commandline arguments
......@@ -63,9 +63,7 @@ namespace AMDiS
if (vm.count("init-file"))
Parameters::init(vm["init-file"].as<std::string>());
else
{
AMDIS_ERROR_EXIT("No init file specified!\n");
}
error_exit("No init file specified!\n");
}
else
{
......@@ -78,7 +76,7 @@ namespace AMDiS
// if (vm.count("parameters") && !ignoreCommandline)
// Parameters::readArgv(vm["parameters"].as<std::string>(),0);
// TODO: add command-line arguments again.
return mpiHelper;
}
......
......@@ -4,7 +4,7 @@
#include <string>
#include <iostream>
#include "Initfile.hpp"
#include <dune/amdis/Initfile.hpp>
namespace AMDiS
{
......
......@@ -6,7 +6,7 @@
#include <vector>
// AMDiS includes
#include <dune/amdis/Log.hpp>
#include <dune/amdis/Output.hpp>
#include <dune/amdis/Math.hpp>
namespace AMDiS
......@@ -304,8 +304,8 @@ namespace AMDiS
double getEstSum(int index) const
{
AMDIS_FUNCNAME_DBG("AdaptInfo::getEstSum()");
AMDIS_TEST_EXIT_DBG(static_cast<size_t>(index) < scalContents.size(),
"Wrong index for adaptInfo!\n");
test_exit_dbg(static_cast<size_t>(index) < scalContents.size(),
"Wrong index for adaptInfo!\n");
return scalContents[index]->est_sum;
}
......@@ -320,8 +320,8 @@ namespace AMDiS
double getEstMax(int index) const
{
AMDIS_FUNCNAME_DBG("AdaptInfo::getEstSum()");
AMDIS_TEST_EXIT_DBG(static_cast<size_t>(index) < scalContents.size(),
"Wrong index for adaptInfo!\n");
test_exit_dbg(static_cast<size_t>(index) < scalContents.size(),
"Wrong index for adaptInfo!\n");
return scalContents[index]->est_max;
}
......
#include "AdaptInstationary.hpp"
// AMDiS includes
#include "AdaptInfo.hpp"
#include "Flag.hpp"
#include "Initfile.hpp"
#include "Log.hpp"
#include "ProblemIterationInterface.hpp"
#include "ProblemTimeInterface.hpp"
#include <dune/amdis/AdaptInfo.hpp>
#include <dune/amdis/Flag.hpp>
#include <dune/amdis/Initfile.hpp>
#include <dune/amdis/Output.hpp>
#include <dune/amdis/ProblemIterationInterface.hpp>
#include <dune/amdis/ProblemTimeInterface.hpp>
namespace AMDiS
{
......@@ -46,8 +46,7 @@ namespace AMDiS
problemTime->setTime(adaptInfo);
AMDIS_MSG("time = " << adaptInfo.getTime() << ", timestep = "
<< adaptInfo.getTimestep());
msg("time = ", adaptInfo.getTime(), ", timestep = ", adaptInfo.getTimestep());
adaptInfo.setSpaceIteration(0);
......@@ -68,8 +67,7 @@ namespace AMDiS
adaptInfo.setTime(adaptInfo.getTime() + adaptInfo.getTimestep());
problemTime->setTime(adaptInfo);
AMDIS_MSG("time = " << adaptInfo.getTime() << ", timestep = "
<< adaptInfo.getTimestep());
msg("time = ", adaptInfo.getTime(), ", timestep = ", adaptInfo.getTimestep());
problemIteration->oneIteration(adaptInfo, NO_ADAPTION);
......@@ -160,8 +158,7 @@ namespace AMDiS
adaptInfo.setTime(adaptInfo.getTime() + adaptInfo.getTimestep());
problemTime->setTime(adaptInfo);
AMDIS_MSG("time = " << adaptInfo.getTime() << ", timestep = "
<< adaptInfo.getTimestep());
msg("time = ", adaptInfo.getTime(), ", timestep = ", adaptInfo.getTimestep());
problemIteration->oneIteration(adaptInfo, FULL_ITERATION);
......@@ -197,7 +194,7 @@ namespace AMDiS
simpleAdaptiveTimeStrategy();
break;
default:
AMDIS_ERROR_EXIT("Unknown strategy = " << strategy);
error_exit("Unknown strategy = ", strategy);
}
adaptInfo.incTimestepNumber();
......@@ -209,12 +206,12 @@ namespace AMDiS
AMDIS_FUNCNAME("AdaptInstationary::adapt()");
int errorCode = 0;
AMDIS_TEST_EXIT(adaptInfo.getTimestep() >= adaptInfo.getMinTimestep(),
"timestep < min timestep");
AMDIS_TEST_EXIT(adaptInfo.getTimestep() <= adaptInfo.getMaxTimestep(),
"timestep > max timestep");
test_exit(adaptInfo.getTimestep() >= adaptInfo.getMinTimestep(),
"timestep < min timestep");
test_exit(adaptInfo.getTimestep() <= adaptInfo.getMaxTimestep(),
"timestep > max timestep");
AMDIS_TEST_EXIT(adaptInfo.getTimestep() > 0, "timestep <= 0!");
test_exit(adaptInfo.getTimestep() > 0, "timestep <= 0!");
if (adaptInfo.getTimestepNumber() == 0)
{
......
......@@ -24,7 +24,6 @@ set(BOOST_LIBS_REQUIRED system program_options)
if (NOT BUILD_SHARED_LIBS)
set(Boost_USE_STATIC_LIBS ON)
endif (NOT BUILD_SHARED_LIBS)
set(Boost_NO_SYSTEM_PATHS ON)
find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED})
if (Boost_FOUND)
add_library(boost INTERFACE)
......@@ -49,14 +48,14 @@ 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)
install(FILES
install(FILES
AdaptBase.hpp
AdaptInfo.hpp
AdaptInstationary.hpp
......
......@@ -4,7 +4,7 @@
#include <string>
#include <dune/amdis/common/Utility.hpp>
#include <dune/amdis/Log.hpp>
#include <dune/amdis/Output.hpp>
namespace AMDiS
{
......@@ -31,7 +31,7 @@ namespace AMDiS
* Must be implemented by sub classes of CreatorInterface.
* 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
class CreatorInterfaceName : public CreatorInterface<BaseClass>
{
public:
virtual shared_ptr<BaseClass> create() override
{
AMDIS_ERROR_EXIT("Should not be called. Call create(string) instead!");
return {};
{
error_exit("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
* Creates a new instance of the sub class of BaseClass by passing a
* string to the constructor.
*/
virtual 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!");
test_exit_dbg(result, "Can not cast CreatorInterface to CreatorInterfaceName!");
return result;
}
......
......@@ -7,14 +7,14 @@
#include <dune/amdis/CreatorInterface.hpp>
namespace AMDiS
{
// forward declaration.
{
// 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
......@@ -26,7 +26,7 @@ namespace AMDiS
*/
template <class BaseClass>
class CreatorMap
{
{
public:
using CreatorMapType = std::map< std::string, CreatorInterface<BaseClass>* >;
......@@ -35,8 +35,8 @@ namespace AMDiS
static void addCreator(std::string key, CreatorInterface<BaseClass>* creator)
{
init();
AMDIS_TEST_EXIT( !creatorMap[key],
"There is already a creator for key " << key);
test_exit(!creatorMap[key],
"There is already a creator for key ", key);
creatorMap[key] = creator;
}
......@@ -44,14 +44,14 @@ namespace AMDiS
static CreatorInterface<BaseClass>* getCreator(std::string key, std::string initFileStr)
{
init();
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 << "\"");
test_exit(creator,
"No creator for key \"", key, "\" defined in init file for parameter \"", initFileStr, "\"");
return creator;
}
......
......@@ -6,22 +6,22 @@
#include <dune/amdis/common/ConceptsBase.hpp>
#include "Log.hpp"
#include <dune/amdis/Output.hpp>
namespace AMDiS
{
/// 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
* 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
* 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.
*
* In the \ref finish method the matrix is called with \ref applyDirichletBC
* to erase the corresponding rows and columns for the DOF indices. This
* application of boundary conditions can be symmetric if the matrix does
*
* In the \ref finish method the matrix is called with \ref applyDirichletBC
* to erase the corresponding rows and columns for the DOF indices. This
* application of boundary conditions can be symmetric if the matrix does
* support this symmetric modification. As a result, this method returns a list
* of columns values, that should be subtracted from the rhs.
**/
......@@ -36,25 +36,25 @@ namespace AMDiS
: predicate(std::forward<Predicate>(predicate))
, values(std::forward<Values>(values))
{}
template <class Matrix, class VectorX, class VectorB>
void init(bool apply,
Matrix& matrix,
VectorX& rhs,
void init(bool apply,
Matrix& matrix,
VectorX& rhs,
VectorB& solution);
template <class Matrix, class VectorX, class VectorB>
void finish(bool apply,
Matrix& matrix,
VectorX& rhs,
void finish(bool apply,
Matrix& matrix,
VectorX& rhs,
VectorB& solution);
private:
std::function<bool(WorldVector)> predicate;
std::function<double(WorldVector)> values;
bool initialized = false;
std::vector<char> dirichletNodes;
};
......
......@@ -8,29 +8,29 @@ namespace AMDiS
template <class WorldVector>
template <class Matrix, class VectorX, class VectorB>
void DirichletBC<WorldVector>::init(bool apply,
Matrix& matrix,
VectorX& solution,
Matrix& matrix,
VectorX& solution,
VectorB& rhs)
{
using Dune::Functions::interpolate;
if (!initialized) {
interpolate(matrix.getRowFeSpace(), dirichletNodes, predicate);
initialized = true;
}
}
template <class WorldVector>
template <class Matrix, class VectorX, class VectorB>
void DirichletBC<WorldVector>::finish(bool apply,
Matrix& matrix,
VectorX& solution,
Matrix& matrix,
VectorX& solution,
VectorB& rhs)
{
using Dune::Functions::interpolate;
AMDIS_TEST_EXIT( initialized, "Boundary condition not initialized!" );
test_exit(initialized, "Boundary condition not initialized!");
matrix.clearDirichletRows(dirichletNodes, apply);
if (apply) {
......@@ -38,6 +38,6 @@ namespace AMDiS
interpolate(matrix.getColFeSpace(), wrapper(solution.getVector()), values, dirichletNodes);
}
}
} // end namespace AMDiS
......@@ -14,7 +14,7 @@
// a parser for arithmetic expressions
// #include <muParser.h>
#include "Log.hpp"
#include <dune/amdis/Output.hpp>
namespace AMDiS
{
......@@ -36,28 +36,25 @@ namespace AMDiS
// mu::Parser parser;
// parser.DefineConst(_T("M_PI"), m_pi);
// parser.DefineConst(_T("M_E"), m_e);
//
//
// parser.SetExpr(valStr);
// return parser.Eval();
// }
// }
Initfile* Initfile::singlett = NULL;
/// initialize singleton object an global parameters
void Initfile::init(std::string in)
{
initIntern();
singlett->read(in);
singlett->getInternalParameters();
singlett().read(in);
singlett().getInternalParameters();
}
/// Fill an initfile from a file with filename fn
void Initfile::read(std::string fn, bool /*force*/)
{
AMDIS_TEST_EXIT( file_exists(fn),
"init-file '" << fn << "' cannot be opened for reading");
test_exit(file_exists(fn),
"init-file '", fn, "' cannot be opened for reading");
using namespace boost::property_tree;
json_parser::read_json(fn, pt);
......@@ -87,7 +84,6 @@ namespace AMDiS
/// print all parameters to std::cout
void Initfile::printParameters()
{
initIntern();
// TODO: implement printing of all parameters
}
......
......@@ -15,8 +15,8 @@
#include <dune/common/fvector.hh>
#include "Log.hpp"
#include "Math.hpp"
#include <dune/amdis/Output.hpp>
#include <dune/amdis/Math.hpp>
namespace AMDiS
{
......@@ -52,7 +52,7 @@ namespace AMDiS
// try {
// value = numeric_cast< T >(mu_parser_eval(valStr));
// } catch(...) {
// AMDIS_ERROR("Could not parse '" << valStr << "' to '" << typeid(T).name() << "'\n");
// error_exit("Could not parse '", valStr, "' to '", typeid(T).name(), "'\n");
// }
// }
// };
......@@ -81,8 +81,8 @@ namespace AMDiS
int i = 0;
for (auto token : tokens)
{
AMDIS_TEST_EXIT(i < dim, "Vector data exceeds field-vector dimension!");
test_exit(i < dim, "Vector data exceeds field-vector dimension!");
value_type v;
Convert<value_type>::eval(token, v);
values[i++] = v;
......@@ -105,8 +105,8 @@ namespace AMDiS
size_t i = 0;
for (auto token : tokens)
{
AMDIS_TEST_EXIT(i < dim, "Vector data exceeds array dimension!");
test_exit(i < dim, "Vector data exceeds array dimension!");
value_type v;
Convert<value_type>::eval(token, v);
values[i++] = v;
......@@ -201,14 +201,13 @@ namespace AMDiS
template <class T>
static void get(std::string tag, T& value, int debugInfo = -1)
{
initIntern();
if (debugInfo == -1)
debugInfo = singlett->getMsgInfo();
debugInfo = singlett().getMsgInfo();
else
{
int swap(debugInfo);
debugInfo = singlett->getMsgInfo();
singlett->msgInfo=swap;
debugInfo = singlett().getMsgInfo();
singlett().msgInfo=swap;
}
using path = boost::property_tree::ptree::path_type;
......@@ -218,7 +217,7 @@ namespace AMDiS
// TODO: use boost::optional instead
// TODO: use convert method from above
std::string valueStr = "-";
valueStr = singlett->pt.get(tagPath, valueStr);
valueStr = singlett().pt.get(tagPath, valueStr);
if (valueStr != "-")
detail::Convert<T>::eval(valueStr, value);
......@@ -228,7 +227,7 @@ namespace AMDiS
// std::cout << "Parameter '" << tag << "'"
// << " initialized with: " << value << std::endl;
// }
singlett->msgInfo = debugInfo;
singlett().msgInfo = debugInfo;
}
......@@ -254,17 +253,16 @@ namespace AMDiS
template <class T>
static void set(std::string tag, T& value, int debugInfo= -1)
{
initIntern();
if (debugInfo == -1)
debugInfo = singlett->getMsgInfo();
debugInfo = singlett().getMsgInfo();
using path = boost::property_tree::ptree::path_type;
replaceAll(tag, "->", ">");
auto tagPath = path(tag, '>');
singlett->pt.put(tagPath, value);
singlett().pt.put(tagPath, value);
// update msg parameters msgInfo, msgWait, paramInfo
singlett->getInternalParameters();
singlett().getInternalParameters();
// if (debugInfo == 2)
// std::cout << "Parameter '" << tag << "'"
// << " set to: " << value << std::endl;
......@@ -281,21 +279,7 @@ namespace AMDiS
/// Returns specified info level
static int getMsgInfo()
{
return (singlett != NULL) ? singlett->msgInfo : 0;
}
/// Checks whether parameters are initialized. if not, call init()
static bool initialized()
{
return (singlett != NULL);
}
/// return pointer to singleton
static Initfile* getSingleton()
{
return singlett;
return singlett().msgInfo;
}
......@@ -306,8 +290,7 @@ namespace AMDiS
/// clear data in singleton
static void clearData()
{
initIntern();
// singlett->clear();
// singlett().clear();
}
......@@ -315,22 +298,19 @@ namespace AMDiS
static void save(std::string /*fn*/)
{
using namespace boost::property_tree;
initIntern();
// json_parser::write_jason(fn, singlett->pt);
// json_parser::write_jason(fn, singlett().pt);