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

small errors corrected

parent 52296030
...@@ -96,6 +96,7 @@ list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/muparser) ...@@ -96,6 +96,7 @@ list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/muparser)
set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@) set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@)
set(AMDIS_OPENMP @ENABLE_OPENMP@) set(AMDIS_OPENMP @ENABLE_OPENMP@)
set(AMDIS_NEED_CXX11 @ENABLE_CXX11@)
set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@) set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@)
set(AMDIS_NEED_HYPRE @ENABLE_HYPRE@) set(AMDIS_NEED_HYPRE @ENABLE_HYPRE@)
set(AMDIS_NEED_SEQ_PETSC @ENABLE_SEQ_PETSC@) set(AMDIS_NEED_SEQ_PETSC @ENABLE_SEQ_PETSC@)
...@@ -114,6 +115,12 @@ if(CMAKE_BUILD_TYPE STREQUAL "") ...@@ -114,6 +115,12 @@ if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")
endif() endif()
if (AMDIS_NEED_CXX11)
list(APPEND AMDIS_COMPILEFLAGS "-DHAS_CXX11=1" "-std=c++11")
else ()
list(APPEND AMDIS_COMPILEFLAGS "-DHAS_CXX11=0")
endif (AMDIS_NEED_CXX11)
#load mpi-compiler for use with parmetis and parallel_domain #load mpi-compiler for use with parmetis and parallel_domain
if(AMDIS_HAS_PARALLEL_DOMAIN) if(AMDIS_HAS_PARALLEL_DOMAIN)
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
......
...@@ -44,6 +44,7 @@ endif() ...@@ -44,6 +44,7 @@ endif()
SET(ENABLE_PARALLEL_DOMAIN "OFF" CACHE STRING "use parallel domain decomposition. please set to one of: PMTL, PETSC, OFF" ) SET(ENABLE_PARALLEL_DOMAIN "OFF" CACHE STRING "use parallel domain decomposition. please set to one of: PMTL, PETSC, OFF" )
option(USE_PETSC_DEV false) option(USE_PETSC_DEV false)
option(ENABLE_ZOLTAN false) option(ENABLE_ZOLTAN false)
option(ENABLE_CXX11 "Enable C++11 compiler features" false)
option(ENABLE_SEQ_PETSC "Use sequential PETSc solvers" false) option(ENABLE_SEQ_PETSC "Use sequential PETSc solvers" false)
option(ENABLE_UMFPACK "Use of UMFPACK solver" false) option(ENABLE_UMFPACK "Use of UMFPACK solver" false)
option(ENABLE_HYPRE "Use HYPRE AMG solver" false) option(ENABLE_HYPRE "Use HYPRE AMG solver" false)
...@@ -201,7 +202,7 @@ SET(AMDIS_SRC ${SOURCE_DIR}/AdaptBase.cc ...@@ -201,7 +202,7 @@ SET(AMDIS_SRC ${SOURCE_DIR}/AdaptBase.cc
${SOURCE_DIR}/time/RosenbrockMethod.cc ${SOURCE_DIR}/time/RosenbrockMethod.cc
${SOURCE_DIR}/time/RosenbrockStationary.cc ${SOURCE_DIR}/time/RosenbrockStationary.cc
) )
if(ENABLE_PARALLEL_DOMAIN) if(ENABLE_PARALLEL_DOMAIN)
### Search for MPI compiler and get compile flags and include paths. ### ### Search for MPI compiler and get compile flags and include paths. ###
...@@ -621,6 +622,18 @@ if(WIN32) ...@@ -621,6 +622,18 @@ if(WIN32)
endif(WIN32) endif(WIN32)
if (ENABLE_CXX11)
list(APPEND COMPILEFLAGS "-DHAS_CXX11=1")
set_property(TARGET "amdis" PROPERTY CXX_STANDARD 11)
set_property(TARGET "compositeFEM" PROPERTY CXX_STANDARD 11)
set_property(TARGET "reinit" PROPERTY CXX_STANDARD 11)
set_property(TARGET "muparser" PROPERTY CXX_STANDARD 11)
else ()
list(APPEND COMPILEFLAGS "-DHAS_CXX11=0")
endif (ENABLE_CXX11)
if(CMAKE_SYSTEM_NAME MATCHES Darwin) if(CMAKE_SYSTEM_NAME MATCHES Darwin)
if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang) if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup")
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include "Element.h" #include "Element.h"
#include "ElementDofIterator.h" #include "ElementDofIterator.h"
#include "Error.h" #include "Error.h"
#include "Expressions.h"
#include "FiniteElemSpace.h" #include "FiniteElemSpace.h"
#include "FirstOrderTerm.h" #include "FirstOrderTerm.h"
#include "FixVec.h" #include "FixVec.h"
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include <list> #include <list>
#include "AMDiS_fwd.h" #include "AMDiS_fwd.h"
#include "ProblemStat.h" #include "ProblemStat.h"
#include "CoarseningManager.h"
#include "RefinementManager.h"
#include "Initfile.h" #include "Initfile.h"
#include "utility/to_string.hpp" #include "utility/to_string.hpp"
...@@ -67,7 +69,6 @@ namespace AMDiS { ...@@ -67,7 +69,6 @@ namespace AMDiS {
virtual void addProblem(ProblemStatType* prob) virtual void addProblem(ProblemStatType* prob)
{ {
problems.push_back(prob); problems.push_back(prob);
nComponents += prob->getNumComponents();
}; };
/// Initialisation of the problem. /// Initialisation of the problem.
......
...@@ -43,6 +43,8 @@ private: ...@@ -43,6 +43,8 @@ private:
T1 val; T1 val;
}; };
typedef Const<double, WorldVector<double> > Constant;
template<typename T=double> template<typename T=double>
struct Factor : public AbstractFunction<T,T> struct Factor : public AbstractFunction<T,T>
{ {
......
...@@ -74,10 +74,10 @@ namespace AMDiS { ...@@ -74,10 +74,10 @@ namespace AMDiS {
FUNCNAME("Msg::change_out()"); FUNCNAME("Msg::change_out()");
if (fp) { if (fp) {
if (out && *out != std::cout && *out != std::cerr) { // if (out && *out != std::cout && *out != std::cerr) {
dynamic_cast< std::ofstream*>(out)->close(); // dynamic_cast< std::ofstream*>(out)->close();
delete out; // delete out;
} // }
out = fp; out = fp;
} else { } else {
...@@ -92,10 +92,10 @@ namespace AMDiS { ...@@ -92,10 +92,10 @@ namespace AMDiS {
FUNCNAME("Msg::change_error_out()"); FUNCNAME("Msg::change_error_out()");
if (fp) { if (fp) {
if (error && *error != std::cout && *error != std::cerr) { // if (error && *error != std::cout && *error != std::cerr) {
dynamic_cast< std::ofstream*>(error)->close(); // dynamic_cast< std::ofstream*>(error)->close();
delete error; // delete error;
} // }
error = fp; error = fp;
} else { } else {
...@@ -111,10 +111,10 @@ namespace AMDiS { ...@@ -111,10 +111,10 @@ namespace AMDiS {
std::ofstream *fp; std::ofstream *fp;
if (filename && (fp = new std::ofstream(filename, type))) { if (filename && (fp = new std::ofstream(filename, type))) {
if (error && *error != std::cout && *error != std::cerr) { // if (error && *error != std::cout && *error != std::cerr) {
dynamic_cast< std::ofstream*>(error)->close(); // dynamic_cast< std::ofstream*>(error)->close();
delete error; // delete error;
} // }
error = fp; error = fp;
} else { } else {
......
...@@ -142,6 +142,12 @@ namespace AMDiS { ...@@ -142,6 +142,12 @@ namespace AMDiS {
void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag flag, void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag flag,
bool assembleMatrix = true, bool assembleMatrix = true,
bool assembleVector = true) override; bool assembleVector = true) override;
/// assemble all operators of matrix and vector side
void assemble(AdaptInfo* adaptInfo)
{
buildAfterCoarsen(adaptInfo, 0, true, true);
}
bool dualMeshTraverseRequired(); bool dualMeshTraverseRequired();
......
...@@ -343,7 +343,7 @@ namespace AMDiS { ...@@ -343,7 +343,7 @@ namespace AMDiS {
int size = x->getNumVectors(); int size = x->getNumVectors();
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
result += x->getDOFVector(i)->squareNrm2(); result += x->getDOFVector(i)->squareNrm2();
return sqrt(result); return std::sqrt(result);
} }
/// L2 norm of system vector. /// L2 norm of system vector.
...@@ -353,7 +353,7 @@ namespace AMDiS { ...@@ -353,7 +353,7 @@ namespace AMDiS {
int size = x->getNumVectors(); int size = x->getNumVectors();
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
result += x->getDOFVector(i)->L2NormSquare(); result += x->getDOFVector(i)->L2NormSquare();
return sqrt(result); return std::sqrt(result);
} }
/// H1 norm of system vector. /// H1 norm of system vector.
...@@ -363,7 +363,7 @@ namespace AMDiS { ...@@ -363,7 +363,7 @@ namespace AMDiS {
int size = x->getNumVectors(); int size = x->getNumVectors();
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
result += x->getDOFVector(i)->H1NormSquare(); result += x->getDOFVector(i)->H1NormSquare();
return sqrt(result); return std::sqrt(result);
} }
inline void mv(const Matrix<DOFMatrix*> &matrix, inline void mv(const Matrix<DOFMatrix*> &matrix,
......
...@@ -48,7 +48,9 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE))); ...@@ -48,7 +48,9 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE)));
// C++11 features // C++11 features
// -------------- // --------------
#if __cplusplus > 199711L #if __cplusplus > 199711L
#define HAS_CXX11 1 #ifndef HAS_CXX11
#define HAS_CXX11 1
#endif
// __has_feature(cxx_rvalue_references) // __has_feature(cxx_rvalue_references)
#if CLANG_VERSION >= 20900 && !defined(HAS_VARIADIC_TEMPLATES) #if CLANG_VERSION >= 20900 && !defined(HAS_VARIADIC_TEMPLATES)
......
...@@ -48,7 +48,9 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE))); ...@@ -48,7 +48,9 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE)));
// C++11 features // C++11 features
// -------------- // --------------
#if __cplusplus > 199711L #if __cplusplus > 199711L
#define HAS_CXX11 1 #ifndef HAS_CXX11
#define HAS_CXX11 1
#endif
#if GCC_VERSION >= 40300 && !defined(HAS_VARIADIC_TEMPLATES) #if GCC_VERSION >= 40300 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1 #define HAS_VARIADIC_TEMPLATES 1
......
...@@ -57,7 +57,9 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t; ...@@ -57,7 +57,9 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
#include <functional> #include <functional>
#if defined(_GLIBCXX_TUPLE) || defined(_GLIBCXX_TYPE_TRAITS) || defined(_GLIBCXX_ARRAY) || (__cplusplus > 199711L) #if defined(_GLIBCXX_TUPLE) || defined(_GLIBCXX_TYPE_TRAITS) || defined(_GLIBCXX_ARRAY) || (__cplusplus > 199711L)
#define HAS_CXX11 1 #ifndef HAS_CXX11
#define HAS_CXX11 1
#endif
#if INTEL_VERSION >= 1201 && !defined(HAS_VARIADIC_TEMPLATES) #if INTEL_VERSION >= 1201 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1 #define HAS_VARIADIC_TEMPLATES 1
......
...@@ -54,7 +54,9 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t; ...@@ -54,7 +54,9 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
// C++11 features // C++11 features
// -------------- // --------------
#if __cplusplus > 199711L #if __cplusplus > 199711L
#define HAS_CXX11 1 #ifndef HAS_CXX11
#define HAS_CXX11 1
#endif
#if MSC_VERSION >= 1800 && !defined(HAS_VARIADIC_TEMPLATES) #if MSC_VERSION >= 1800 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1 #define HAS_VARIADIC_TEMPLATES 1
......
...@@ -77,7 +77,7 @@ namespace AMDiS { namespace io { ...@@ -77,7 +77,7 @@ namespace AMDiS { namespace io {
basis[i][j] = p[i + 1][j] ; basis[i][j] = p[i + 1][j] ;
lengthBasis[i] += basis[i][j] * basis[i][j]; lengthBasis[i] += basis[i][j] * basis[i][j];
} }
lengthBasis[i] = sqrt(lengthBasis[i]); lengthBasis[i] = std::sqrt(lengthBasis[i]);
} }
// norm basis, get steps // norm basis, get steps
...@@ -191,7 +191,7 @@ namespace AMDiS { namespace io { ...@@ -191,7 +191,7 @@ namespace AMDiS { namespace io {
basis[i][j] = p[i + 1][j] ; basis[i][j] = p[i + 1][j] ;
lengthBasis[i] += basis[i][j] * basis[i][j]; lengthBasis[i] += basis[i][j] * basis[i][j];
} }
lengthBasis[i] = sqrt(lengthBasis[i]); lengthBasis[i] = std::sqrt(lengthBasis[i]);
} }
// norm basis, get steps // norm basis, get steps
......
...@@ -26,13 +26,14 @@ ...@@ -26,13 +26,14 @@
namespace AMDiS { namespace AMDiS {
RosenbrockAdaptInstationary::RosenbrockAdaptInstationary(std::string name, RosenbrockAdaptInstationary::RosenbrockAdaptInstationary(std::string name,
RosenbrockStationary *problemStat, ProblemIterationInterface *problemStat,
RosenbrockInterface *rbprob,
AdaptInfo *info, AdaptInfo *info,
ProblemTimeInterface *problemInstat, ProblemTimeInterface *problemInstat,
AdaptInfo *initialInfo, AdaptInfo *initialInfo,
time_t initialTimestamp) time_t initialTimestamp)
: AdaptInstationary(name, problemStat, info, problemInstat, initialInfo, initialTimestamp), : AdaptInstationary(name, problemStat, info, problemInstat, initialInfo, initialTimestamp),
rosenbrockStat(problemStat), rosenbrockStat(rbprob),
firstTimestep(true), firstTimestep(true),
lastTimestepRejected(false), lastTimestepRejected(false),
succRejection(false), succRejection(false),
...@@ -45,19 +46,20 @@ namespace AMDiS { ...@@ -45,19 +46,20 @@ namespace AMDiS {
minusInvTauGamma(-1.0), minusInvTauGamma(-1.0),
dbgTimestepStudy(false) dbgTimestepStudy(false)
{ {
initConstructor(problemStat); initConstructor(rbprob);
rosenbrockStat->setOldTime(adaptInfo->getStartTime()); rosenbrockStat->setOldTime(adaptInfo->getStartTime());
} }
RosenbrockAdaptInstationary::RosenbrockAdaptInstationary(std::string name, RosenbrockAdaptInstationary::RosenbrockAdaptInstationary(std::string name,
RosenbrockStationary &problemStat, ProblemIterationInterface &problemStat,
RosenbrockInterface &rbprob,
AdaptInfo &info, AdaptInfo &info,
ProblemTimeInterface &problemInstat, ProblemTimeInterface &problemInstat,
AdaptInfo &initialInfo, AdaptInfo &initialInfo,
time_t initialTimestamp) time_t initialTimestamp)
: AdaptInstationary(name, problemStat, info, problemInstat, initialInfo, initialTimestamp), : AdaptInstationary(name, problemStat, info, problemInstat, initialInfo, initialTimestamp),
rosenbrockStat(&problemStat), rosenbrockStat(&rbprob),
firstTimestep(true), firstTimestep(true),
lastTimestepRejected(false), lastTimestepRejected(false),
succRejection(false), succRejection(false),
...@@ -70,12 +72,12 @@ namespace AMDiS { ...@@ -70,12 +72,12 @@ namespace AMDiS {
minusInvTauGamma(-1.0), minusInvTauGamma(-1.0),
dbgTimestepStudy(false) dbgTimestepStudy(false)
{ {
initConstructor(&problemStat); initConstructor(&rbprob);
rosenbrockStat->setOldTime(adaptInfo->getStartTime()); rosenbrockStat->setOldTime(adaptInfo->getStartTime());
} }
void RosenbrockAdaptInstationary::initConstructor(RosenbrockStationary *problemStat) void RosenbrockAdaptInstationary::initConstructor(RosenbrockInterface *problemStat)
{ {
FUNCNAME_DBG("RosenbrockAdaptInstationary::initConstructor()"); FUNCNAME_DBG("RosenbrockAdaptInstationary::initConstructor()");
...@@ -283,11 +285,11 @@ namespace AMDiS { ...@@ -283,11 +285,11 @@ namespace AMDiS {
{ {
double errorEst = 0.0; double errorEst = 0.0;
for (int i = 0; i < adaptInfo->getSize(); i++) { for (int i = 0; i < adaptInfo->getSize(); i++) {
double weight = adaptInfo->getTimeTolerance(i) + rosenbrockStat->getSolution(i)->L2Norm() * adaptInfo->getTimeRelativeTolerance(i); double weight = adaptInfo->getTimeTolerance(i) + adaptInfo->getEstSum(i) * adaptInfo->getTimeRelativeTolerance(i);
errorEst += sqr(adaptInfo->getTimeEstCombined(i)) / sqr(weight); errorEst += sqr(adaptInfo->getTimeEstCombined(i)) / sqr(weight);
} }
errorEst = sqrt(errorEst / adaptInfo->getSize()); errorEst = std::sqrt(errorEst / adaptInfo->getSize());
adaptInfo->setTimeEst(errorEst); adaptInfo->setTimeEst(errorEst);
return errorEst; return errorEst;
} }
......
...@@ -42,7 +42,8 @@ namespace AMDiS { ...@@ -42,7 +42,8 @@ namespace AMDiS {
* dependent problem problemInstat. TODO: Make obsolete! * dependent problem problemInstat. TODO: Make obsolete!
*/ */
RosenbrockAdaptInstationary(std::string name, RosenbrockAdaptInstationary(std::string name,
RosenbrockStationary *problemStat, ProblemIterationInterface *problemStat,
RosenbrockInterface *rbprob,
AdaptInfo *info, AdaptInfo *info,
ProblemTimeInterface *problemInstat, ProblemTimeInterface *problemInstat,
AdaptInfo *initialInfo, AdaptInfo *initialInfo,
...@@ -54,7 +55,8 @@ namespace AMDiS { ...@@ -54,7 +55,8 @@ namespace AMDiS {
* dependent problem problemInstat. * dependent problem problemInstat.
*/ */
RosenbrockAdaptInstationary(std::string name, RosenbrockAdaptInstationary(std::string name,
RosenbrockStationary &problemStat, ProblemIterationInterface &problemStat,
RosenbrockInterface &rbprob,
AdaptInfo &info, AdaptInfo &info,
ProblemTimeInterface &problemInstat, ProblemTimeInterface &problemInstat,
AdaptInfo &initialInfo, AdaptInfo &initialInfo,
...@@ -71,7 +73,7 @@ namespace AMDiS { ...@@ -71,7 +73,7 @@ namespace AMDiS {
* removed, remove also this function. * removed, remove also this function.
* TODO: Remove if obsolete constructor will be removed. * TODO: Remove if obsolete constructor will be removed.
*/ */
void initConstructor(RosenbrockStationary *problemStat); void initConstructor(RosenbrockInterface *problemStat);
void reset(); void reset();
...@@ -80,7 +82,7 @@ namespace AMDiS { ...@@ -80,7 +82,7 @@ namespace AMDiS {
RosenbrockMethod *rosenbrockMethod; RosenbrockMethod *rosenbrockMethod;
/// Pointer to the stationary problem; /// Pointer to the stationary problem;
RosenbrockStationary *rosenbrockStat; RosenbrockInterface *rosenbrockStat;
/// Indicates, if this is the very first timestep. /// Indicates, if this is the very first timestep.
bool firstTimestep; bool firstTimestep;
......
...@@ -52,6 +52,88 @@ namespace AMDiS { ...@@ -52,6 +52,88 @@ namespace AMDiS {
int row; int row;
int col; int col;
}; };
class RosenbrockInterface
{
public:
RosenbrockInterface()
: rm(NULL),
oldTime(0.0),
tauPtr(NULL),
tauGamma(NULL),
minusTauGamma(NULL),
invTauGamma(NULL),
minusInvTauGamma(NULL)
{}
virtual ~RosenbrockInterface() {}
/// update solution vector and oldTime value
virtual void acceptTimestep(AdaptInfo* adaptInfo) = 0;
double* getTau()
{
return tauPtr;
}
double* getTauGamma()
{
return tauGamma;
}
double* getMinusTauGamma()
{
return minusTauGamma;
}
double* getInvTauGamma()
{
return invTauGamma;
}
double* getMinusInvTauGamma()
{
return minusInvTauGamma;
}
virtual void setRosenbrockMethod(RosenbrockMethod *method)
{
rm = method;
}
double* getOldTime()
{
return &oldTime;
}
void setTau(double *ptr)
{
tauPtr = ptr;
}
void setTauGamma(double *ptr0, double *ptr1, double *ptr2, double *ptr3)
{
tauGamma = ptr0;
minusTauGamma = ptr1;
invTauGamma = ptr2;
minusInvTauGamma = ptr3;
}
void setOldTime(double t)
{
oldTime = t;
}
protected:
RosenbrockMethod *rm;
double oldTime;
double *tauPtr;
double *tauGamma, *minusTauGamma, *invTauGamma, *minusInvTauGamma;
};
/// Realization of a Rosenbrock time-discretization of M*d_t(X) = F[x] /// Realization of a Rosenbrock time-discretization of M*d_t(X) = F[x]
/** /**
...@@ -65,21 +147,16 @@ namespace AMDiS { ...@@ -65,21 +147,16 @@ namespace AMDiS {
* and new solution * and new solution
* X^{k+1} = X^k + sum_{j=1}^{s} m_j * Y_j^k * X^{k+1} = X^k + sum_{j=1}^{s} m_j * Y_j^k
**/ **/
class RosenbrockStationary : public ProblemStat class RosenbrockStationary : public ProblemStat,
public RosenbrockInterface
{ {