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

correction of MeshManipulation

parent 0e305139
...@@ -180,7 +180,7 @@ namespace AMDiS { ...@@ -180,7 +180,7 @@ namespace AMDiS {
#define ABSTRACT_FUNCTION_MACRO(z, n, _) \ #define ABSTRACT_FUNCTION_MACRO(z, n, _) \
template< typename ReturnType, \ template< typename ReturnType, \
BOOST_PP_ENUM_PARAMS_Z(z, n, typename T) \ BOOST_PP_ENUM_PARAMS_Z(z, n, typename T) \
> class AbstractFunction ## n { \ > struct AbstractFunction ## n { \
AbstractFunction ## n (int degree = 0) : \ AbstractFunction ## n (int degree = 0) : \
degree_(degree) \ degree_(degree) \
{} \ {} \
......
...@@ -551,7 +551,7 @@ namespace AMDiS { ...@@ -551,7 +551,7 @@ namespace AMDiS {
TOut tmp; nullify(tmp); TOut tmp; nullify(tmp);
for (int iq = 0; iq < fastQuad->getNumPoints(); iq++) { for (int iq = 0; iq < fastQuad->getNumPoints(); iq++) {
elInfo->coordToWorld(fastQuad->getLambda(iq), coords); elInfo->coordToWorld(fastQuad->getLambda(iq), coords);
tmp += fastQuad->getWeight(iq) * (*fct)(coords); tmp += (*fct)(coords) * fastQuad->getWeight(iq);
} }
value += tmp * elInfo->getDet(); value += tmp * elInfo->getDet();
......
...@@ -468,6 +468,9 @@ namespace AMDiS { ...@@ -468,6 +468,9 @@ namespace AMDiS {
TEST_EXIT_DBG(initType == DEFAULT_VALUE)("wrong initType or wrong initializer\n"); TEST_EXIT_DBG(initType == DEFAULT_VALUE)("wrong initType or wrong initializer\n");
this->set(ini); this->set(ini);
} }
// import assignment operator from base class
using Matrix<T>::operator=;
/// Returns true if the matrix is a diagonal matrix, returns false otherwise. /// Returns true if the matrix is a diagonal matrix, returns false otherwise.
bool isDiagMatrix() const; bool isDiagMatrix() const;
......
...@@ -197,8 +197,13 @@ namespace AMDiS { ...@@ -197,8 +197,13 @@ namespace AMDiS {
template<typename T> inline void nullify(WorldVector<T> &a) template<typename T> inline void nullify(WorldVector<T> &a)
{ {
T null; T null; nullify(null);
nullify(null); a = null;
}
template<typename T> inline void nullify(WorldMatrix<T> &a)
{
T null; nullify(null);
a = null; a = null;
} }
......
...@@ -296,6 +296,18 @@ namespace AMDiS { ...@@ -296,6 +296,18 @@ namespace AMDiS {
return this->valArray + cols * i; return this->valArray + cols * i;
} }
/// Access to i-th matrix row.
inline T& operator()(int i, int j)
{
return this->operator[](i)[j];
}
/// Access to i-th matrix row for constant matrices.
inline const T& operator()(int i, int j) const
{
return this->operator[](i)[j];
}
/// Returns \ref rows. /// Returns \ref rows.
inline int getNumRows() const inline int getNumRows() const
{ {
......
...@@ -122,6 +122,10 @@ namespace AMDiS { ...@@ -122,6 +122,10 @@ namespace AMDiS {
return &invTau; return &invTau;
} }
virtual void serialize(std::ostream &out) {}
virtual void deserialize(std::istream &in) {}
protected: protected:
/// Name of the problem. /// Name of the problem.
std::string name; std::string name;
...@@ -195,10 +199,6 @@ namespace AMDiS { ...@@ -195,10 +199,6 @@ namespace AMDiS {
/// Used by \ref problemInitial /// Used by \ref problemInitial
virtual void transferInitialSolution(AdaptInfo *adaptInfo); virtual void transferInitialSolution(AdaptInfo *adaptInfo);
virtual void serialize(std::ostream &out) {}
virtual void deserialize(std::istream &in) {}
protected: protected:
/// Space problem solved in each timestep. /// Space problem solved in each timestep.
ProblemStatSeq* problemStat; ProblemStatSeq* problemStat;
......
...@@ -22,29 +22,34 @@ ...@@ -22,29 +22,34 @@
#include <mpi.h> #include <mpi.h>
#endif #endif
using namespace boost::posix_time;
namespace AMDiS { namespace AMDiS {
Timer::Timer():
first_seq(clock()) Timer::Timer() :
first_seq(microsec_clock::local_time())
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
,first_mpi(MPI::Wtime()) ,first_mpi(MPI::Wtime())
#endif #endif
{} {}
void Timer::reset() void Timer::reset()
{ {
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
first_mpi = MPI::Wtime(); first_mpi = MPI::Wtime();
#else #else
first_seq = clock(); first_seq = microsec_clock::local_time();
#endif #endif
} }
double Timer::elapsed() double Timer::elapsed()
{ {
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
return MPI::Wtime() - first_mpi; return MPI::Wtime() - first_mpi;
#else #else
return ((double)(clock() - first_seq))/((double)CLOCKS_PER_SEC); time_duration td = microsec_clock::local_time()-first_seq;
return static_cast<double>(td.total_milliseconds())*1.e-3;
#endif #endif
} }
}
} // end namespace AMDiS
...@@ -20,26 +20,30 @@ ...@@ -20,26 +20,30 @@
#ifndef AMDIS_TIMER_H #ifndef AMDIS_TIMER_H
#define AMDIS_TIMER_H #define AMDIS_TIMER_H
#include <time.h> #include "boost/date_time/posix_time/posix_time.hpp"
namespace AMDiS {
/// Helper class to destinct between different time measurement methods
class Timer {
/// begin value for sequentiell measurement
clock_t first_seq;
/// begin value for parallel measurement namespace AMDiS {
double first_mpi;
/// Helper class to distinguish between different time measurement methods
class Timer
{
private:
/// begin value for sequentiell measurement
boost::posix_time::ptime first_seq;
public: /// begin value for parallel measurement
double first_mpi;
///initializes the timer with current time public:
Timer(); /// initializes the timer with current time
Timer();
/// resets the timer to current time /// resets the timer to current time
void reset(); void reset();
/// returns the elapsed time (from construction or last reset) to now in seconds /// returns the elapsed time (from construction or last reset) to now in seconds
double elapsed(); double elapsed();
}; };
} }
#endif
#endif // AMDIS_TIMER_H
...@@ -318,10 +318,14 @@ namespace AMDiS { namespace Parallel { ...@@ -318,10 +318,14 @@ namespace AMDiS { namespace Parallel {
#if (DEBUG != 0) #if (DEBUG != 0)
ElInfo *elInfo = ElInfo *elInfo =
stack.traverseFirstOneMacro(mesh, boundEl.elIndex, -1, traverseFlag); stack.traverseFirstOneMacro(mesh, boundEl.elIndex, -1, traverseFlag);
TEST_EXIT(elInfo->getElement() == boundEl.el)
("This should not happen!\n");
#else
// stack must be initialized before passed to fitElementToMeshCode()
stack.traverseFirstOneMacro(mesh, boundEl.elIndex, -1, traverseFlag);
#endif #endif
TEST_EXIT_DBG(elInfo->getElement() == boundEl.el)
("This should not happen!\n");
pcode = &code; pcode = &code;
pstack = &stack; pstack = &stack;
......
...@@ -68,9 +68,10 @@ namespace AMDiS { namespace Parallel { ...@@ -68,9 +68,10 @@ namespace AMDiS { namespace Parallel {
arhMetaFile); arhMetaFile);
bool partitioningArhBased = (arhMetaFile != ""); bool partitioningArhBased = (arhMetaFile != "");
if (partitioningArhBased) { if (partitioningArhBased) {
MSG("Read Meta-Arh partitioning file: %s\n", arhMetaFile.c_str());
int nProc = ArhReader::readMetaData(arhMetaFile, mapElInRank, arhElCodeSize); int nProc = ArhReader::readMetaData(arhMetaFile, mapElInRank, arhElCodeSize);
if (nProc != mpiSize) if (nProc != mpiSize)
partitioningArhBased = false; useInitialPartitioning = false;
else else
useInitialPartitioning = true; useInitialPartitioning = true;
} }
......
...@@ -39,7 +39,7 @@ namespace AMDiS { namespace Parallel { ...@@ -39,7 +39,7 @@ namespace AMDiS { namespace Parallel {
{ {
globalAdd(MPI::COMM_WORLD, value); globalAdd(MPI::COMM_WORLD, value);
} }
void globalAdd(MPI::Intracomm &mpiComm, int &value); void globalAdd(MPI::Intracomm &mpiComm, int &value);
inline void globalAdd(int &value) inline void globalAdd(int &value)
...@@ -53,6 +53,14 @@ namespace AMDiS { namespace Parallel { ...@@ -53,6 +53,14 @@ namespace AMDiS { namespace Parallel {
WARNING("Unknown type for globalAdd. Can not sum up the values of all processors!\n"); WARNING("Unknown type for globalAdd. Can not sum up the values of all processors!\n");
} }
template<typename VectorType>
inline typename boost::enable_if< mtl::traits::is_vector<VectorType>, void >
globalAdd(VectorType &value)
{
for (size_t i = 0; i < num_rows(value); i++)
globalAdd(value[i]);
}
void globalMin(double &value); void globalMin(double &value);
void globalMin(int &value); void globalMin(int &value);
......
...@@ -179,6 +179,7 @@ namespace AMDiS { namespace Parallel { ...@@ -179,6 +179,7 @@ namespace AMDiS { namespace Parallel {
creator = new PetscSolverNavierStokes::Creator; creator = new PetscSolverNavierStokes::Creator;
CreatorMap< LinearSolver >::addCreator("p_petsc_petsc-navierstokes", creator); CreatorMap< LinearSolver >::addCreator("p_petsc_petsc-navierstokes", creator);
CreatorMap< LinearSolver >::addCreator("petsc-navierstokes", creator);
#elif defined HAVE_BDDC_ML #elif defined HAVE_BDDC_ML
creator = new BddcMlSolver::Creator; creator = new BddcMlSolver::Creator;
......
...@@ -156,7 +156,7 @@ namespace AMDiS { ...@@ -156,7 +156,7 @@ namespace AMDiS {
bool initMatrix = false; bool initMatrix = false;
if (mat == PETSC_NULL) { if (mat == PETSC_NULL) {
std::vector<PetscInt> nnz(rhs.getSize()); std::vector<PetscInt> nnz(rhs.getSize());
for (size_t k = 0; k < rhs.getSize(); k++) for (size_t k = 0; k < static_cast<size_t>(rhs.getSize()); k++)
nnz[k] = rhs.getBaseMatrix().nnz_local(k); nnz[k] = rhs.getBaseMatrix().nnz_local(k);
MatCreateSeqAIJ(PETSC_COMM_SELF, rhs.getSize(), rhs.getSize(), 0, &(nnz[0]), &mat); MatCreateSeqAIJ(PETSC_COMM_SELF, rhs.getSize(), rhs.getSize(), 0, &(nnz[0]), &mat);
...@@ -184,13 +184,12 @@ namespace AMDiS { ...@@ -184,13 +184,12 @@ namespace AMDiS {
inline void operator<<(PetscMatrix& mat, const SolverMatrix<Matrix<DOFMatrix*> >& Asolver) inline void operator<<(PetscMatrix& mat, const SolverMatrix<Matrix<DOFMatrix*> >& Asolver)
{ {
const Matrix< DOFMatrix* >& A = *(Asolver.getOriginalMat()); const Matrix< DOFMatrix* >& A = *(Asolver.getOriginalMat());
int ns = A.getSize();
std::vector<PetscInt> nnz; std::vector<PetscInt> nnz;
mat.nestMat.resize(A.getNumRows() * A.getNumCols()); mat.nestMat.resize(A.getNumRows() * A.getNumCols());
for (size_t i = 0; i < A.getNumRows(); i++) { for (size_t i = 0; i < static_cast<size_t>(A.getNumRows()); i++) {
for (size_t j = 0; j < A.getNumCols(); j++) { for (size_t j = 0; j < static_cast<size_t>(A.getNumCols()); j++) {
size_t idx = i * A.getNumCols() + j; size_t idx = i * A.getNumCols() + j;
if (A[i][j] == NULL if (A[i][j] == NULL
...@@ -244,14 +243,14 @@ namespace AMDiS { ...@@ -244,14 +243,14 @@ namespace AMDiS {
VecGetType(petscVec, &vecType); VecGetType(petscVec, &vecType);
if (strcmp(vecType, VECNEST) == 0) { if (strcmp(vecType, VECNEST) == 0) {
for (size_t i = 0; i < vec.getSize(); i++) { for (size_t i = 0; i < static_cast<size_t>(vec.getSize()); i++) {
Vec v; Vec v;
VecNestGetSubVec(petscVec, i, &v); VecNestGetSubVec(petscVec, i, &v);
v << *(vec.getDOFVector(i)); v << *(vec.getDOFVector(i));
} }
} else { } else {
PetscInt index = 0; PetscInt index = 0;
for (size_t i = 0; i < vec.getSize(); i++) { for (size_t i = 0; i < static_cast<size_t>(vec.getSize()); i++) {
DOFVector<double>::Iterator dofIt(vec.getDOFVector(i), USED_DOFS); DOFVector<double>::Iterator dofIt(vec.getDOFVector(i), USED_DOFS);
for (dofIt.reset(); !dofIt.end(); ++dofIt, ++index) { for (dofIt.reset(); !dofIt.end(); ++dofIt, ++index) {
double value = *dofIt; double value = *dofIt;
...@@ -269,14 +268,14 @@ namespace AMDiS { ...@@ -269,14 +268,14 @@ namespace AMDiS {
VecGetType(petscVec, &vecType); VecGetType(petscVec, &vecType);
if (strcmp(vecType, VECNEST) == 0) { if (strcmp(vecType, VECNEST) == 0) {
for (size_t i = 0; i < vec.getSize(); i++) { for (size_t i = 0; i < static_cast<size_t>(vec.getSize()); i++) {
Vec v; Vec v;
VecNestGetSubVec(petscVec, i, &v); VecNestGetSubVec(petscVec, i, &v);
v >> *(vec.getDOFVector(i)); v >> *(vec.getDOFVector(i));
} }
} else { } else {
int n = 0, ni; PetscInt n = 0;
for (size_t i = 0; i < vec.getSize(); i++) for (size_t i = 0; i < static_cast<size_t>(vec.getSize()); i++)
n += vec.getDOFVector(i)->getUsedSize(); n += vec.getDOFVector(i)->getUsedSize();
PetscInt N = 0; PetscInt N = 0;
...@@ -284,7 +283,7 @@ namespace AMDiS { ...@@ -284,7 +283,7 @@ namespace AMDiS {
assert(n == N); assert(n == N);
PetscInt index = 0; PetscInt index = 0;
for (size_t i = 0; i < vec.getSize(); i++) { for (size_t i = 0; i < static_cast<size_t>(vec.getSize()); i++) {
DOFVector<double>::Iterator dofIt(vec.getDOFVector(i), USED_DOFS); DOFVector<double>::Iterator dofIt(vec.getDOFVector(i), USED_DOFS);
for (dofIt.reset(); !dofIt.end(); ++dofIt, ++index) { for (dofIt.reset(); !dofIt.end(); ++dofIt, ++index) {
double value = 0.0; double value = 0.0;
...@@ -317,7 +316,7 @@ namespace AMDiS { ...@@ -317,7 +316,7 @@ namespace AMDiS {
// create nested vector from vector of block vectors // create nested vector from vector of block vectors
VecCreateNest(PETSC_COMM_SELF, nComponents, PETSC_NULL, &(petscVec.nestVec[0]), &(petscVec.vector)); VecCreateNest(PETSC_COMM_SELF, nComponents, PETSC_NULL, &(petscVec.nestVec[0]), &(petscVec.vector));
} else { } else {
int n = 0, ni; PetscInt n = 0;
for (size_t i = 0; i < nComponents; i++) for (size_t i = 0; i < nComponents; i++)
n += rhs.getDOFVector(i)->getUsedSize(); n += rhs.getDOFVector(i)->getUsedSize();
......
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