Commit f0f8d33c authored by Thomas Witkowski's avatar Thomas Witkowski

* 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 {
/** \brief
* 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
* realisation of OEMSolver::init
......
......@@ -35,7 +35,7 @@ namespace AMDiS {
template<typename VectorType>
int BiCGSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b)
VectorType *x, VectorType *b, bool reuseMatrix)
{
FUNCNAME("BiCGSolver::solveSystem");
VectorType *t = h;
......
......@@ -80,7 +80,7 @@ namespace AMDiS
* realisation of OEMSolver::solveSystem
*/
int solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b);
VectorType *x, VectorType *b, bool reuseMatrix);
/** \brief
* realisation of OEMSolver::init
......
......@@ -42,7 +42,7 @@ namespace AMDiS
template<typename VectorType>
int BiCGStab<VectorType>::solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b)
VectorType *x, VectorType *b, bool reuseMatrix)
{
FUNCNAME("BiCGStab::solveSystem");
......
......@@ -79,7 +79,7 @@ namespace AMDiS
* realisation of OEMSolver::solveSystem
*/
int solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b);
VectorType *x, VectorType *b, bool reuseMatrix);
/** \brief
* realisation of OEMSolver::init
......
......@@ -42,7 +42,7 @@ namespace AMDiS
template<typename VectorType>
int BiCGStab2<VectorType>::solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b)
VectorType *x, VectorType *b, bool reuseMatrix)
{
FUNCNAME("BiCGStab2::solveSystem()");
......
......@@ -84,7 +84,7 @@ namespace AMDiS {
/** \brief
* 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:
// Pointers to memory needed for solveSystem
......
......@@ -34,7 +34,7 @@ namespace AMDiS {
template<typename VectorType>
int BiCGStab_M<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b)
VectorType *x, VectorType *b, bool reuseMatrix)
{
FUNCNAME("BiCGStab_M::solveSystem");
double old_res = -1.0;
......
......@@ -102,7 +102,7 @@ namespace AMDiS {
/** \brief
* 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:
VectorType *p, *r, *v, *z;
......
......@@ -16,7 +16,7 @@ namespace AMDiS {
template<typename VectorType>
int CGSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b)
VectorType *x, VectorType *b, bool reuseMatrix)
{
FUNCNAME("CGSolver::solve()");
......
......@@ -41,36 +41,36 @@ namespace AMDiS {
/** \brief
* Constructs a unset Flag
*/
inline Flag() : flags(0) {};
inline Flag() : flags(0) {}
/** \brief
* Constructs a Flag initialized by f
*/
inline Flag(const unsigned long f) : flags(f) {};
inline Flag(const unsigned long f) : flags(f) {}
/** \brief
* Copy constructor
*/
inline Flag(const Flag& f) : flags(f.flags) {};
inline Flag(const Flag& f) : flags(f.flags) {}
/** \brief
* Destructor
*/
inline ~Flag() {};
inline ~Flag() {}
/** \brief
* Compares two Flags
*/
inline bool operator==(const Flag& f) const {
return (flags == f.flags);
};
}
/** \brief
* Compares two Flags
*/
inline bool operator!=(const Flag& f) const {
return !(f == *this);
};
}
/** \brief
* Assignment operator
......@@ -79,60 +79,60 @@ namespace AMDiS {
if (this != &f)
flags = f.flags;
return *this;
};
}
/** \brief
* Typecast
*/
inline operator bool() const {
return isAnySet();
};
}
/** \brief
* Set \ref flags
*/
inline void setFlags(const unsigned long f) {
flags = f;
};
}
/** \brief
* Set \ref flags
*/
inline void setFlags(const Flag& f) {
flags = f.flags;
};
}
/** \brief
* Sets \ref flags to \ref flags | f
*/
inline void setFlag(const unsigned long f) {
flags |= f;
};
}
/** \brief
* Sets \ref flags to \ref flags | f.flags
*/
inline void setFlag(const Flag& f) {
flags |= f.flags;
};
}
/** \brief
* Sets \ref flags to \ref flags & ~f
*/
inline void unsetFlag(const unsigned long f) {
flags &= ~f;
};
}
/** \brief
* Sets \ref flags to \ref flags & ~f.flags
*/
inline void unsetFlag(const Flag& f) {
flags &= ~f.flags;
};
}
inline const unsigned long getFlags() const {
return flags;
};
}
/** \brief
* Returns \ref flags | f.flags
......@@ -141,7 +141,7 @@ namespace AMDiS {
Flag r(flags);
r.setFlag(f);
return r;
};
}
/** \brief
* Returns \ref flags & ~f.flags
......@@ -150,7 +150,7 @@ namespace AMDiS {
Flag r(flags);
r.unsetFlag(f);
return r;
};
}
/** \brief
* Returns \ref flags | f.flags
......@@ -159,7 +159,7 @@ namespace AMDiS {
Flag r(flags);
r.setFlag(f);
return r;
};
}
/** \brief
* Returns \ref flags & f.flags
......@@ -168,7 +168,7 @@ namespace AMDiS {
Flag r(flags);
r.flags &= f.flags;
return r;
};
}
/** \brief
* Sets \ref flags to \ref flags &= f.flags
......@@ -176,7 +176,7 @@ namespace AMDiS {
inline Flag operator&=(const Flag& f) {
flags &= f.flags;
return *this;
};
}
/** \brief
* Returns \ref flags ^ f.flags
......@@ -185,7 +185,7 @@ namespace AMDiS {
Flag r(flags);
r.flags ^=f.flags;
return r;
};
}
/** \brief
* Sets \ref flags to \ref flags & f.flags
......@@ -195,7 +195,7 @@ namespace AMDiS {
flags |= f.flags;
};
return *this;
};
}
/** \brief
* Returns ~\ref flags
......@@ -204,28 +204,28 @@ namespace AMDiS {
Flag r;
r.flags = ~flags;
return r;
};
}
/** \brief
* Checks whether all set bits of f.flags are set in \ref flags too.
*/
inline bool isSet(const Flag& f) const {
return ((flags&f.flags) == f.flags);
};
}
/** \brief
* Returns !\ref isSet(f)
*/
inline bool isUnset(const Flag& f) const {
return !isSet(f);
};
}
/** \brief
* Returns true if \ref flags != 0
*/
inline bool isAnySet() const {
return (flags != 0);
};
}
protected:
/** \brief
......
......@@ -86,7 +86,8 @@ namespace AMDiS {
/** \brief
* 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
* realisation of OEMSolver::init
......
......@@ -157,8 +157,7 @@ namespace AMDiS {
template<typename VectorType>
int GMResSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x,
VectorType *b)
VectorType *x, VectorType *b, bool reuseMatrix)
{
FUNCNAME("GMResSolver::solveSystem()");
......
......@@ -85,7 +85,8 @@ namespace AMDiS {
/** \brief
* 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
* realisation of OEMSolver::init
......
......@@ -157,8 +157,8 @@ namespace AMDiS {
template<typename VectorType>
int GMResSolver2<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x,
VectorType *b)
VectorType *x, VectorType *b,
bool reuseMatrix)
{
FUNCNAME("GMResSolver2::solveSystem()");
......
......@@ -73,11 +73,12 @@ namespace AMDiS {
int solveSystem(MatVecMultiplier<DOFVector<double> > *mv,
DOFVector<double> *x,
DOFVector<double> *b)
DOFVector<double> *b,
bool reuseMatrix)
{
DOFMatrix *matrix =
dynamic_cast<StandardMatVec<DOFMatrix, DOFVector<double> >*>(mv)->getMatrix();
return mgSolver_->solve(*matrix, *x, *b);
return mgSolver_->solve(*matrix, *x, *b, reuseMatrix);
};
protected:
......@@ -128,11 +129,12 @@ namespace AMDiS {
int solveSystem(MatVecMultiplier<SystemVector> *mv,
SystemVector *x,
SystemVector *b)
SystemVector *b,
bool reuseMatrix)
{
Matrix<DOFMatrix*> *matrix =
dynamic_cast<StandardMatVec<Matrix<DOFMatrix*>, SystemVector>*>(mv)->getMatrix();
return mgSolver_->solve(*matrix, *x, *b);
return mgSolver_->solve(*matrix, *x, *b, reuseMatrix);
};
protected:
......
......@@ -76,7 +76,8 @@ namespace AMDiS {
/** \brief
* 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
* realisation of OEMSolver::init
......
......@@ -35,7 +35,7 @@ namespace AMDiS {
template<typename VectorType>
int ODirSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b)
VectorType *x, VectorType *b, bool reuseMatrix)
{
FUNCNAME("ODirSolver::solveSystem");
......
......@@ -96,7 +96,8 @@ namespace AMDiS {
int solve(MatVecMultiplier<VectorType> *mv,
VectorType *x, VectorType *b,
Preconditioner<VectorType> *lPrecon = NULL,
Preconditioner<VectorType> *rPrecon = NULL)
Preconditioner<VectorType> *rPrecon = NULL,
bool reuseMatrix = false)
{
FUNCNAME("OEMSolver::solve()");
TEST_EXIT(mv)("no matVec\n");
......@@ -113,7 +114,7 @@ namespace AMDiS {
if (rightPrecon)
rightPrecon->init();
int iter = solveSystem(mv, x, b);
int iter = solveSystem(mv, x, b, reuseMatrix);
if (leftPrecon)
leftPrecon->exit();
......@@ -124,7 +125,7 @@ namespace AMDiS {
exit();
return iter;
};
}
// ===== getting-methods ======================================================
......@@ -137,28 +138,28 @@ namespace AMDiS {
*/
inline const std::string& getName() {
return name;
};
}
/** \brief
* Returns \ref tolerance
*/
inline double getTolerance() {
return tolerance;
};
}
/** \brief
* Returns \ref max_iter
*/
inline int getMaxIterations() {
return max_iter;
};
}
/** \brief
* Returns \ref residual
*/
inline double getResidual() {
return residual;
};
}
/** \} */
......@@ -173,37 +174,36 @@ namespace AMDiS {
*/
inline void setTolerance(double tol) {
tolerance = tol;
};
}
/** \brief
* Sets \ref relative
*/
inline void setRelative(bool rel) {
relative = rel;
};
}
/** \brief
* Sets \ref max_iter
*/
inline void setMaxIterations(int i) {
max_iter = i;
};
}
/** \brief
* Sets \ref info
*/
inline void setInfo(int i) {
info = i;
};
}
inline void setVectorCreator(CreatorInterface<VectorType> *creator) {
vectorCreator = creator;
};
}
inline CreatorInterface<VectorType>* getVectorCreator()
{
inline CreatorInterface<VectorType>* getVectorCreator() {
return vectorCreator;
};
}
/** \} */
......@@ -222,8 +222,9 @@ namespace AMDiS {
* To be overloaded by concrete solvers.
*/
virtual int solveSystem(MatVecMultiplier<VectorType> *mv,
VectorType *x,
VectorType *b) = 0;
VectorType *x,
VectorType *b,
bool reuseMatrix) = 0;
/** \brief
......@@ -294,14 +295,14 @@ namespace AMDiS {
class OEMSolverCreator : public CreatorInterface<OEMSolver<T> >
{
public:
virtual ~OEMSolverCreator() {};
virtual ~OEMSolverCreator() {}
/** \brief
* Sets \ref problem
*/
void setName(std::string name_) {
name = name_;
};
}
protected:
/** \brief
......
......@@ -76,7 +76,8 @@ namespace AMDiS {
/** \brief
* 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
* realisation of OEMSolver::init
......
......@@ -39,7 +39,8 @@ namespace AMDiS {
template<typename VectorType>
int OResSolver<VectorType>::solveSystem(MatVecMultiplier<VectorType> *matVec,
VectorType *x, VectorType *b)
VectorType *x, VectorType *b,
bool reuseMatrix)
{
FUNCNAME("OResSolver::solveSystem");
......
......@@ -11,7 +11,8 @@ namespace AMDiS {
template<>
int PardisoSolver<SystemVector>::solveSystem(MatVecMultiplier<SystemVector> *matVec,
SystemVector *x, SystemVector *b)
SystemVector *x, SystemVector *b,
bool reuseMatrix)
{
FUNCNAME("PardisoSolver::solveSystem()");
......
......@@ -102,7 +102,8 @@ namespace AMDiS {
/** \brief
* 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:
/** \brief
......
......@@ -51,7 +51,7 @@ namespace AMDiS {
ProblemStatBase *initialProb)
: name(name_),
initialProblem(initialProb ? initialProb : this)
{};
{}
/** \brief
* Destructor.
......@@ -68,53 +68,53 @@ namespace AMDiS {
/** \brief
*/
virtual void solve(AdaptInfo *adaptInfo) {};
virtual void solve(AdaptInfo *adaptInfo, bool fixedMatrix) {}
/** \brief
*/
virtual void estimate(AdaptInfo *adaptInfo) {};
virtual void estimate(AdaptInfo *adaptInfo) {}
/** \brief
*/
virtual void buildBeforeRefine(AdaptInfo *adaptInfo, Flag) {};
virtual void buildBeforeRefine(AdaptInfo *adaptInfo, Flag) {}
/** \brief
*/
virtual void buildBeforeCoarsen(AdaptInfo *adaptInfo, Flag) {};
virtual void buildBeforeCoarsen(AdaptInfo *adaptInfo, Flag) {}
/** \brief
*/
virtual void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag) {};
virtual void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag, bool, bool) {}
/** \brief
*/
virtual Flag markElements(AdaptInfo *adaptInfo) {
return 0;
};
}
/** \brief
*/
virtual Flag refineMesh(AdaptInfo *adaptInfo) {
return 0;
};
}
/** \brief
*/
virtual Flag coarsenMesh(AdaptInfo *adaptInfo) {
return 0;
};
}
/** \brief
* Implementation of ProblemTimeInterface::closeTimestep().
*/
virtual void closeTimestep() {};
virtual void closeTimestep() {}
/** \brief
* Returns \ref name.
*/
inline const std::string& getName() {
return name;
};
}
/** \brief
* Used by \ref problemInitial
......
......@@ -29,11 +29,13 @@ namespace AMDiS {
class AdaptInfo;
class ProblemStatBase;