Commit a4e461ee authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

clean up of some files

parent d079f7e6
...@@ -492,8 +492,7 @@ if(ENABLE_EXTENSIONS) ...@@ -492,8 +492,7 @@ if(ENABLE_EXTENSIONS)
${EXTENSIONS_DIR}/base_problems/NavierStokes_TaylorHood_RB.cc ${EXTENSIONS_DIR}/base_problems/NavierStokes_TaylorHood_RB.cc
${EXTENSIONS_DIR}/base_problems/NavierStokes_TH_MultiPhase.cc ${EXTENSIONS_DIR}/base_problems/NavierStokes_TH_MultiPhase.cc
${EXTENSIONS_DIR}/base_problems/NavierStokes_TH_MultiPhase_RB.cc ${EXTENSIONS_DIR}/base_problems/NavierStokes_TH_MultiPhase_RB.cc
${EXTENSIONS_DIR}/base_problems/PhaseFieldCrystal_Base.cc ${EXTENSIONS_DIR}/base_problems/PhaseFieldCrystal.cc
# ${EXTENSIONS_DIR}/base_problems/PhaseFieldCrystal.cc
${EXTENSIONS_DIR}/base_problems/PhaseFieldCrystal_Phase.cc ${EXTENSIONS_DIR}/base_problems/PhaseFieldCrystal_Phase.cc
${EXTENSIONS_DIR}/base_problems/PhaseFieldCrystal_RB.cc) ${EXTENSIONS_DIR}/base_problems/PhaseFieldCrystal_RB.cc)
list(APPEND COMPILEFLAGS "-DHAVE_BASE_PROBLEMS=1") list(APPEND COMPILEFLAGS "-DHAVE_BASE_PROBLEMS=1")
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#include "Global.h" #include "Global.h"
#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
namespace AMDiS { namespace AMDiS {
/** /**
...@@ -170,6 +174,53 @@ namespace AMDiS { ...@@ -170,6 +174,53 @@ namespace AMDiS {
}; };
///////////////////////////////////////////////////////////////
// test of AbstractFunction with arbitrary number of arguments
#define ABSTRACT_FUNCTION_MACRO(z, n, _) \
template< typename ReturnType, \
BOOST_PP_ENUM_PARAMS_Z(z, n, typename T) \
> class AbstractFunction ## n { \
AbstractFunction ## n (int degree = 0) : \
degree_(degree) \
{} \
virtual ~AbstractFunction ## n () {} \
inline int getDegree() const \
{ \
return degree_; \
} \
virtual ReturnType operator()(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const T, &t)) const = 0; \
\
protected: \
int degree_; \
}; \
// template< typename ReturnType,
// BOOST_PP_ENUM_PARAMS(N, typename T) // expands to typename T0, typename T1, typename T2...
// >
// class CONCAT_STR(AbstractFunction,N)
// {
// public:
// CONCAT_STR(AbstractFunction,N)(int degree = 0) :
// degree_(degree)
// {}
//
// virtual ~CONCAT_STR(AbstractFunction,N)() {}
//
// /// Returns \ref degree_.
// inline int getDegree() const
// {
// return degree_;
// }
//
// /// function evaluation.
// virtual ReturnType operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, const T, &t)) const = 0;
//
// protected:
// int degree_;
// };
BOOST_PP_REPEAT_FROM_TO(1, 11, ABSTRACT_FUNCTION_MACRO, nil)
} }
......
...@@ -192,7 +192,7 @@ namespace AMDiS { ...@@ -192,7 +192,7 @@ namespace AMDiS {
adaptInfo->setSpaceIteration(0); adaptInfo->setSpaceIteration(0);
// === Do only space iterations only if the maximum is higher than 0. === // === Do space iterations only if the maximum is higher than 0. ===
if (adaptInfo->getMaxSpaceIteration() > 0) { if (adaptInfo->getMaxSpaceIteration() > 0) {
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include "boost/tuple/tuple.hpp" #include "boost/tuple/tuple.hpp"
#include "AMDiS_fwd.h" #include "AMDiS_fwd.h"
#include "OpenMP.h" #include "OpenMP.h"
...@@ -148,6 +149,12 @@ namespace AMDiS { ...@@ -148,6 +149,12 @@ namespace AMDiS {
#endif #endif
} }
/// check for inf and nan values
inline bool isNumber(double val)
{
return !boost::math::isnan(val) && !boost::math::isinf(val);
}
/// trim std::string /// trim std::string
inline std::string trim(const std::string& oldStr) inline std::string trim(const std::string& oldStr)
......
...@@ -514,6 +514,7 @@ namespace AMDiS { ...@@ -514,6 +514,7 @@ namespace AMDiS {
{ {
FUNCNAME("ProblemStat::createSolver()"); FUNCNAME("ProblemStat::createSolver()");
// definition of standard-backends
#if defined HAVE_PARALLEL_PETSC #if defined HAVE_PARALLEL_PETSC
string backend("p_petsc"); string backend("p_petsc");
#elif defined HAVE_PARALLEL_MTL #elif defined HAVE_PARALLEL_MTL
...@@ -576,7 +577,7 @@ namespace AMDiS { ...@@ -576,7 +577,7 @@ namespace AMDiS {
for (int j = 0; j < nComponents; j++) for (int j = 0; j < nComponents; j++)
estimator[i]->addSystem((*systemMatrix)[i][j], estimator[i]->addSystem((*systemMatrix)[i][j],
solution->getDOFVector(j), solution->getDOFVector(j),
rhs->getDOFVector(j)); rhs->getDOFVector(j)); // TODO: hier eventuell (i) statt (j) ???
} }
} }
...@@ -625,7 +626,7 @@ namespace AMDiS { ...@@ -625,7 +626,7 @@ namespace AMDiS {
solutionList)); solutionList));
} }
// Create own filewriters for each components of the problem // Create own filewriters for each component of the problem
for (int i = 0; i < nComponents; i++) { for (int i = 0; i < nComponents; i++) {
numberedName = name + "->output[" + boost::lexical_cast<string>(i) + "]"; numberedName = name + "->output[" + boost::lexical_cast<string>(i) + "]";
filename = ""; filename = "";
...@@ -659,13 +660,12 @@ namespace AMDiS { ...@@ -659,13 +660,12 @@ namespace AMDiS {
return; return;
} }
clock_t first = clock(); Timer t;
solver->solveSystem(solverMatrix, *solution, *rhs, solver->solveSystem(solverMatrix, *solution, *rhs,
createMatrixData, storeMatrixData); createMatrixData, storeMatrixData);
INFO(info, 8)("solution of discrete system needed %.5f seconds\n", INFO(info, 8)("solution of discrete system needed %.5f seconds\n",
TIME_USED(first, clock())); t.elapsed());
adaptInfo->setSolverIterations(solver->getIterations()); adaptInfo->setSolverIterations(solver->getIterations());
adaptInfo->setMaxSolverIterations(solver->getMaxIterations()); adaptInfo->setMaxSolverIterations(solver->getMaxIterations());
...@@ -678,11 +678,7 @@ namespace AMDiS { ...@@ -678,11 +678,7 @@ namespace AMDiS {
{ {
FUNCNAME("ProblemStat::estimate()"); FUNCNAME("ProblemStat::estimate()");
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS Timer t;
double first = MPI::Wtime();
#else
clock_t first = clock();
#endif
if (computeExactError) { if (computeExactError) {
computeError(adaptInfo); computeError(adaptInfo);
...@@ -708,12 +704,9 @@ namespace AMDiS { ...@@ -708,12 +704,9 @@ namespace AMDiS {
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
MPI::COMM_WORLD.Barrier(); MPI::COMM_WORLD.Barrier();
INFO(info, 8)("estimation of the error needed %.5f seconds\n",
MPI::Wtime() - first);
#else
INFO(info, 8)("estimation of the error needed %.5f seconds\n",
TIME_USED(first, clock()));
#endif #endif
INFO(info, 8)("estimation of the error needed %.5f seconds\n",
t.elapsed());
} }
...@@ -1506,8 +1499,7 @@ namespace AMDiS { ...@@ -1506,8 +1499,7 @@ namespace AMDiS {
if (matrix) { if (matrix) {
matrix->assemble(1.0, elInfo, bound); matrix->assemble(1.0, elInfo, bound);
// Take the matrix boundary manager from the public matrix, // assemble the boundary conditions on the matrix.
// but assemble the boundary conditions on the thread private matrix.
if (matrix->getBoundaryManager()) if (matrix->getBoundaryManager())
matrix->getBoundaryManager()->fillBoundaryConditions(elInfo, matrix); matrix->getBoundaryManager()->fillBoundaryConditions(elInfo, matrix);
} }
...@@ -1518,9 +1510,6 @@ namespace AMDiS { ...@@ -1518,9 +1510,6 @@ namespace AMDiS {
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
// == Finally, if we have assembled in parallel, we have to add the thread ==
// == private matrix and vector to the global one. ==
if (matrix) { if (matrix) {
matrix->clearDirichletRows(); matrix->clearDirichletRows();
matrix->finishAssembling(); matrix->finishAssembling();
......
...@@ -95,7 +95,7 @@ namespace AMDiS { ...@@ -95,7 +95,7 @@ namespace AMDiS {
print_cycle(100), print_cycle(100),
iterations(-1), iterations(-1),
error(-1), error(-1),
breakTolNotReached(false), breakTolNotReached(true),
calculateResidual(false) calculateResidual(false)
{ {
Parameters::get(name + "->tolerance", tolerance); Parameters::get(name + "->tolerance", tolerance);
...@@ -136,7 +136,7 @@ namespace AMDiS { ...@@ -136,7 +136,7 @@ namespace AMDiS {
MSG("Residual norm: ||b-Ax|| = %e\n", residual); MSG("Residual norm: ||b-Ax|| = %e\n", residual);
TEST_EXIT(residual <= tolerance || !breakTolNotReached) TEST_EXIT((isNumber(residual) && residual <= tolerance) || !breakTolNotReached)
("Tolerance tol = %e could not be reached!\n Set tolerance by '->solver->tolerance:' \n", tolerance); ("Tolerance tol = %e could not be reached!\n Set tolerance by '->solver->tolerance:' \n", tolerance);
} }
return error_code; return error_code;
......
...@@ -67,13 +67,12 @@ namespace AMDiS { ...@@ -67,13 +67,12 @@ namespace AMDiS {
int code = (*solver)(x, b); int code = (*solver)(x, b);
if (oem.getInfo() > 0) {
VectorType r(b); VectorType r(b);
r -= A * x; r -= A * x;
double residual = two_norm(r); double residual = two_norm(r);
oem.setResidual(residual); oem.setResidual(residual);
oem.setErrorCode(code); oem.setErrorCode(code);
}
return code; return code;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment