Commit f0f8d33c authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Several changes to make Rosenbrock method possible to solve systems with...

* Several changes to make Rosenbrock method possible to solve systems with equal matrix but different right hand side vectors

parent ecc316ac
...@@ -77,7 +77,7 @@ namespace AMDiS { ...@@ -77,7 +77,7 @@ namespace AMDiS {
/** \brief /** \brief
* realisation of OEMSolver::solveSystem * realisation of OEMSolver::solveSystem
*/ */
int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b); int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b, bool reuseMatrix);
/** \brief /** \brief
* realisation of OEMSolver::init * realisation of OEMSolver::init
......
...@@ -35,7 +35,7 @@ namespace AMDiS { ...@@ -35,7 +35,7 @@ namespace AMDiS {
template<typename VectorType> template<typename VectorType>
int BiCGSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, int BiCGSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b) VectorType *x, VectorType *b, bool reuseMatrix)
{ {
FUNCNAME("BiCGSolver::solveSystem"); FUNCNAME("BiCGSolver::solveSystem");
VectorType *t = h; VectorType *t = h;
......
...@@ -80,7 +80,7 @@ namespace AMDiS ...@@ -80,7 +80,7 @@ namespace AMDiS
* realisation of OEMSolver::solveSystem * realisation of OEMSolver::solveSystem
*/ */
int solveSystem(MatVecMultiplier<VectorType> *mv, int solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b); VectorType *x, VectorType *b, bool reuseMatrix);
/** \brief /** \brief
* realisation of OEMSolver::init * realisation of OEMSolver::init
......
...@@ -42,7 +42,7 @@ namespace AMDiS ...@@ -42,7 +42,7 @@ namespace AMDiS
template<typename VectorType> template<typename VectorType>
int BiCGStab<VectorType>::solveSystem(MatVecMultiplier<VectorType> *mv, int BiCGStab<VectorType>::solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b) VectorType *x, VectorType *b, bool reuseMatrix)
{ {
FUNCNAME("BiCGStab::solveSystem"); FUNCNAME("BiCGStab::solveSystem");
......
...@@ -79,7 +79,7 @@ namespace AMDiS ...@@ -79,7 +79,7 @@ namespace AMDiS
* realisation of OEMSolver::solveSystem * realisation of OEMSolver::solveSystem
*/ */
int solveSystem(MatVecMultiplier<VectorType> *mv, int solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b); VectorType *x, VectorType *b, bool reuseMatrix);
/** \brief /** \brief
* realisation of OEMSolver::init * realisation of OEMSolver::init
......
...@@ -42,7 +42,7 @@ namespace AMDiS ...@@ -42,7 +42,7 @@ namespace AMDiS
template<typename VectorType> template<typename VectorType>
int BiCGStab2<VectorType>::solveSystem(MatVecMultiplier<VectorType> *mv, int BiCGStab2<VectorType>::solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b) VectorType *x, VectorType *b, bool reuseMatrix)
{ {
FUNCNAME("BiCGStab2::solveSystem()"); FUNCNAME("BiCGStab2::solveSystem()");
......
...@@ -84,7 +84,7 @@ namespace AMDiS { ...@@ -84,7 +84,7 @@ namespace AMDiS {
/** \brief /** \brief
* Implements OEMSolver<VectorType>::solve(). * Implements OEMSolver<VectorType>::solve().
*/ */
int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b); int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b, bool reuseMatrix);
private: private:
// Pointers to memory needed for solveSystem // Pointers to memory needed for solveSystem
......
...@@ -34,7 +34,7 @@ namespace AMDiS { ...@@ -34,7 +34,7 @@ namespace AMDiS {
template<typename VectorType> template<typename VectorType>
int BiCGStab_M<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, int BiCGStab_M<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b) VectorType *x, VectorType *b, bool reuseMatrix)
{ {
FUNCNAME("BiCGStab_M::solveSystem"); FUNCNAME("BiCGStab_M::solveSystem");
double old_res = -1.0; double old_res = -1.0;
......
...@@ -102,7 +102,7 @@ namespace AMDiS { ...@@ -102,7 +102,7 @@ namespace AMDiS {
/** \brief /** \brief
* Implements OEMSolver<VectorType>::solve(). * Implements OEMSolver<VectorType>::solve().
*/ */
int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b); int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b, bool reuseMatrix);
private: private:
VectorType *p, *r, *v, *z; VectorType *p, *r, *v, *z;
......
...@@ -16,7 +16,7 @@ namespace AMDiS { ...@@ -16,7 +16,7 @@ namespace AMDiS {
template<typename VectorType> template<typename VectorType>
int CGSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, int CGSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b) VectorType *x, VectorType *b, bool reuseMatrix)
{ {
FUNCNAME("CGSolver::solve()"); FUNCNAME("CGSolver::solve()");
......
...@@ -41,36 +41,36 @@ namespace AMDiS { ...@@ -41,36 +41,36 @@ namespace AMDiS {
/** \brief /** \brief
* Constructs a unset Flag * Constructs a unset Flag
*/ */
inline Flag() : flags(0) {}; inline Flag() : flags(0) {}
/** \brief /** \brief
* Constructs a Flag initialized by f * Constructs a Flag initialized by f
*/ */
inline Flag(const unsigned long f) : flags(f) {}; inline Flag(const unsigned long f) : flags(f) {}
/** \brief /** \brief
* Copy constructor * Copy constructor
*/ */
inline Flag(const Flag& f) : flags(f.flags) {}; inline Flag(const Flag& f) : flags(f.flags) {}
/** \brief /** \brief
* Destructor * Destructor
*/ */
inline ~Flag() {}; inline ~Flag() {}
/** \brief /** \brief
* Compares two Flags * Compares two Flags
*/ */
inline bool operator==(const Flag& f) const { inline bool operator==(const Flag& f) const {
return (flags == f.flags); return (flags == f.flags);
}; }
/** \brief /** \brief
* Compares two Flags * Compares two Flags
*/ */
inline bool operator!=(const Flag& f) const { inline bool operator!=(const Flag& f) const {
return !(f == *this); return !(f == *this);
}; }
/** \brief /** \brief
* Assignment operator * Assignment operator
...@@ -79,60 +79,60 @@ namespace AMDiS { ...@@ -79,60 +79,60 @@ namespace AMDiS {
if (this != &f) if (this != &f)
flags = f.flags; flags = f.flags;
return *this; return *this;
}; }
/** \brief /** \brief
* Typecast * Typecast
*/ */
inline operator bool() const { inline operator bool() const {
return isAnySet(); return isAnySet();
}; }
/** \brief /** \brief
* Set \ref flags * Set \ref flags
*/ */
inline void setFlags(const unsigned long f) { inline void setFlags(const unsigned long f) {
flags = f; flags = f;
}; }
/** \brief /** \brief
* Set \ref flags * Set \ref flags
*/ */
inline void setFlags(const Flag& f) { inline void setFlags(const Flag& f) {
flags = f.flags; flags = f.flags;
}; }
/** \brief /** \brief
* Sets \ref flags to \ref flags | f * Sets \ref flags to \ref flags | f
*/ */
inline void setFlag(const unsigned long f) { inline void setFlag(const unsigned long f) {
flags |= f; flags |= f;
}; }
/** \brief /** \brief
* Sets \ref flags to \ref flags | f.flags * Sets \ref flags to \ref flags | f.flags
*/ */
inline void setFlag(const Flag& f) { inline void setFlag(const Flag& f) {
flags |= f.flags; flags |= f.flags;
}; }
/** \brief /** \brief
* Sets \ref flags to \ref flags & ~f * Sets \ref flags to \ref flags & ~f
*/ */
inline void unsetFlag(const unsigned long f) { inline void unsetFlag(const unsigned long f) {
flags &= ~f; flags &= ~f;
}; }
/** \brief /** \brief
* Sets \ref flags to \ref flags & ~f.flags * Sets \ref flags to \ref flags & ~f.flags
*/ */
inline void unsetFlag(const Flag& f) { inline void unsetFlag(const Flag& f) {
flags &= ~f.flags; flags &= ~f.flags;
}; }
inline const unsigned long getFlags() const { inline const unsigned long getFlags() const {
return flags; return flags;
}; }
/** \brief /** \brief
* Returns \ref flags | f.flags * Returns \ref flags | f.flags
...@@ -141,7 +141,7 @@ namespace AMDiS { ...@@ -141,7 +141,7 @@ namespace AMDiS {
Flag r(flags); Flag r(flags);
r.setFlag(f); r.setFlag(f);
return r; return r;
}; }
/** \brief /** \brief
* Returns \ref flags & ~f.flags * Returns \ref flags & ~f.flags
...@@ -150,7 +150,7 @@ namespace AMDiS { ...@@ -150,7 +150,7 @@ namespace AMDiS {
Flag r(flags); Flag r(flags);
r.unsetFlag(f); r.unsetFlag(f);
return r; return r;
}; }
/** \brief /** \brief
* Returns \ref flags | f.flags * Returns \ref flags | f.flags
...@@ -159,7 +159,7 @@ namespace AMDiS { ...@@ -159,7 +159,7 @@ namespace AMDiS {
Flag r(flags); Flag r(flags);
r.setFlag(f); r.setFlag(f);
return r; return r;
}; }
/** \brief /** \brief
* Returns \ref flags & f.flags * Returns \ref flags & f.flags
...@@ -168,7 +168,7 @@ namespace AMDiS { ...@@ -168,7 +168,7 @@ namespace AMDiS {
Flag r(flags); Flag r(flags);
r.flags &= f.flags; r.flags &= f.flags;
return r; return r;
}; }
/** \brief /** \brief
* Sets \ref flags to \ref flags &= f.flags * Sets \ref flags to \ref flags &= f.flags
...@@ -176,7 +176,7 @@ namespace AMDiS { ...@@ -176,7 +176,7 @@ namespace AMDiS {
inline Flag operator&=(const Flag& f) { inline Flag operator&=(const Flag& f) {
flags &= f.flags; flags &= f.flags;
return *this; return *this;
}; }
/** \brief /** \brief
* Returns \ref flags ^ f.flags * Returns \ref flags ^ f.flags
...@@ -185,7 +185,7 @@ namespace AMDiS { ...@@ -185,7 +185,7 @@ namespace AMDiS {
Flag r(flags); Flag r(flags);
r.flags ^=f.flags; r.flags ^=f.flags;
return r; return r;
}; }
/** \brief /** \brief
* Sets \ref flags to \ref flags & f.flags * Sets \ref flags to \ref flags & f.flags
...@@ -195,7 +195,7 @@ namespace AMDiS { ...@@ -195,7 +195,7 @@ namespace AMDiS {
flags |= f.flags; flags |= f.flags;
}; };
return *this; return *this;
}; }
/** \brief /** \brief
* Returns ~\ref flags * Returns ~\ref flags
...@@ -204,28 +204,28 @@ namespace AMDiS { ...@@ -204,28 +204,28 @@ namespace AMDiS {
Flag r; Flag r;
r.flags = ~flags; r.flags = ~flags;
return r; return r;
}; }
/** \brief /** \brief
* Checks whether all set bits of f.flags are set in \ref flags too. * Checks whether all set bits of f.flags are set in \ref flags too.
*/ */
inline bool isSet(const Flag& f) const { inline bool isSet(const Flag& f) const {
return ((flags&f.flags) == f.flags); return ((flags&f.flags) == f.flags);
}; }
/** \brief /** \brief
* Returns !\ref isSet(f) * Returns !\ref isSet(f)
*/ */
inline bool isUnset(const Flag& f) const { inline bool isUnset(const Flag& f) const {
return !isSet(f); return !isSet(f);
}; }
/** \brief /** \brief
* Returns true if \ref flags != 0 * Returns true if \ref flags != 0
*/ */
inline bool isAnySet() const { inline bool isAnySet() const {
return (flags != 0); return (flags != 0);
}; }
protected: protected:
/** \brief /** \brief
......
...@@ -86,7 +86,8 @@ namespace AMDiS { ...@@ -86,7 +86,8 @@ namespace AMDiS {
/** \brief /** \brief
* realisation of OEMSolver::solveSystem * realisation of OEMSolver::solveSystem
*/ */
int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b); int solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b, bool reuseMatrix);
/** \brief /** \brief
* realisation of OEMSolver::init * realisation of OEMSolver::init
......
...@@ -157,8 +157,7 @@ namespace AMDiS { ...@@ -157,8 +157,7 @@ namespace AMDiS {
template<typename VectorType> template<typename VectorType>
int GMResSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, int GMResSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *x, VectorType *b, bool reuseMatrix)
VectorType *b)
{ {
FUNCNAME("GMResSolver::solveSystem()"); FUNCNAME("GMResSolver::solveSystem()");
......
...@@ -85,7 +85,8 @@ namespace AMDiS { ...@@ -85,7 +85,8 @@ namespace AMDiS {
/** \brief /** \brief
* realisation of OEMSolver::solveSystem * realisation of OEMSolver::solveSystem
*/ */
int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b); int solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b, bool reuseMatrix);
/** \brief /** \brief
* realisation of OEMSolver::init * realisation of OEMSolver::init
......
...@@ -157,8 +157,8 @@ namespace AMDiS { ...@@ -157,8 +157,8 @@ namespace AMDiS {
template<typename VectorType> template<typename VectorType>
int GMResSolver2<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, int GMResSolver2<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *x, VectorType *b,
VectorType *b) bool reuseMatrix)
{ {
FUNCNAME("GMResSolver2::solveSystem()"); FUNCNAME("GMResSolver2::solveSystem()");
......
...@@ -73,11 +73,12 @@ namespace AMDiS { ...@@ -73,11 +73,12 @@ namespace AMDiS {
int solveSystem(MatVecMultiplier<DOFVector<double> > *mv, int solveSystem(MatVecMultiplier<DOFVector<double> > *mv,
DOFVector<double> *x, DOFVector<double> *x,
DOFVector<double> *b) DOFVector<double> *b,
bool reuseMatrix)
{ {
DOFMatrix *matrix = DOFMatrix *matrix =
dynamic_cast<StandardMatVec<DOFMatrix, DOFVector<double> >*>(mv)->getMatrix(); dynamic_cast<StandardMatVec<DOFMatrix, DOFVector<double> >*>(mv)->getMatrix();
return mgSolver_->solve(*matrix, *x, *b); return mgSolver_->solve(*matrix, *x, *b, reuseMatrix);
}; };
protected: protected:
...@@ -128,11 +129,12 @@ namespace AMDiS { ...@@ -128,11 +129,12 @@ namespace AMDiS {
int solveSystem(MatVecMultiplier<SystemVector> *mv, int solveSystem(MatVecMultiplier<SystemVector> *mv,
SystemVector *x, SystemVector *x,
SystemVector *b) SystemVector *b,
bool reuseMatrix)
{ {
Matrix<DOFMatrix*> *matrix = Matrix<DOFMatrix*> *matrix =
dynamic_cast<StandardMatVec<Matrix<DOFMatrix*>, SystemVector>*>(mv)->getMatrix(); dynamic_cast<StandardMatVec<Matrix<DOFMatrix*>, SystemVector>*>(mv)->getMatrix();
return mgSolver_->solve(*matrix, *x, *b); return mgSolver_->solve(*matrix, *x, *b, reuseMatrix);
}; };
protected: protected:
......
...@@ -76,7 +76,8 @@ namespace AMDiS { ...@@ -76,7 +76,8 @@ namespace AMDiS {
/** \brief /** \brief
* realisation of OEMSolver::solveSystem * realisation of OEMSolver::solveSystem
*/ */
int solveSystem(MatVecMultiplier<VectorType> *mv, VectorType *x, VectorType *b); int solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b, bool reuseMatrix);
/** \brief /** \brief
* realisation of OEMSolver::init * realisation of OEMSolver::init
......
...@@ -35,7 +35,7 @@ namespace AMDiS { ...@@ -35,7 +35,7 @@ namespace AMDiS {
template<typename VectorType> template<typename VectorType>
int ODirSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec, int ODirSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b) VectorType *x, VectorType *b, bool reuseMatrix)
{ {
FUNCNAME("ODirSolver::solveSystem"); FUNCNAME("ODirSolver::solveSystem");
......
...@@ -96,7 +96,8 @@ namespace AMDiS { ...@@ -96,7 +96,8 @@ namespace AMDiS {
int solve(MatVecMultiplier<VectorType> *mv, int solve(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b, VectorType *x, VectorType *b,
Preconditioner<VectorType> *lPrecon = NULL, Preconditioner<VectorType> *lPrecon = NULL,
Preconditioner<VectorType> *rPrecon = NULL) Preconditioner<VectorType> *rPrecon = NULL,
bool reuseMatrix = false)
{ {
FUNCNAME("OEMSolver::solve()"); FUNCNAME("OEMSolver::solve()");
TEST_EXIT(mv)("no matVec\n"); TEST_EXIT(mv)("no matVec\n");
...@@ -113,7 +114,7 @@ namespace AMDiS { ...@@ -113,7 +114,7 @@ namespace AMDiS {
if (rightPrecon) if (rightPrecon)
rightPrecon->init(); rightPrecon->init();
int iter = solveSystem(mv, x, b);