Commit 4533ce20 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Fixed preconditioner bug in serial computations.

parent e916a98c
......@@ -91,9 +91,7 @@ namespace AMDiS {
/// The constructor reads needed parameters and sets solvers \ref name.
ITL_OEMSolver_para(std::string name)
: MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver, MTLTypes::MTLMatrix, MTLTypes::MTLVector > >(name)
{
}
{}
int solveSystem(const SolverMatrix<Matrix<DOFMatrix*> >& A,
SystemVector& x,
......
......@@ -58,7 +58,7 @@ namespace AMDiS {
BaseITL_runner(oem_),
ell(1)
{
ell=oem.getMaxIterations();
ell = oem.getMaxIterations();
Parameters::get(oem.getName() + "->ell", ell);
}
......@@ -84,6 +84,19 @@ namespace AMDiS {
return error;
}
void exit()
{
if (preconPair.l != NULL) {
delete preconPair.l;
preconPair.l = NULL;
}
if (preconPair.r != NULL) {
delete preconPair.r;
preconPair.r = NULL;
}
}
private:
PreconPair< Vector > preconPair;
ITLSolver solver;
......@@ -92,8 +105,6 @@ namespace AMDiS {
template< typename ITLSolver, typename Matrix, typename Vector >
struct ITL_OEMSolver_runner : BaseITL_runner {
ITL_OEMSolver_runner(OEMSolver* oem):
BaseITL_runner(oem)
{}
......@@ -102,6 +113,7 @@ namespace AMDiS {
{
BaseITL_runner::setPrecon(preconPair, A);
}
int solve(const Matrix& A , Vector& x, Vector& b)
{
FUNCNAME("ITL_OEMSolver_runner::solve()");
......@@ -119,6 +131,19 @@ namespace AMDiS {
return error;
}
void exit()
{
if (preconPair.l != NULL) {
delete preconPair.l;
preconPair.l = NULL;
}
if (preconPair.r != NULL) {
delete preconPair.r;
preconPair.r = NULL;
}
}
private:
ITLSolver solver;
PreconPair< Vector > preconPair;
......
......@@ -34,10 +34,6 @@
namespace AMDiS {
// ============================================================================
// ===== class ITL_Preconditioner ==============================================
// ============================================================================
/**
* \ingroup Solver
......@@ -67,7 +63,6 @@ namespace AMDiS {
solve(const ITL_BasePreconditioner< Vec >& P, const Vec& vin)
{
return itl::pc::solver<ITL_BasePreconditioner< Vec >, Vec, false>(P, vin);
//return P.member_solve(vin);
}
template< typename Vec >
......@@ -76,7 +71,6 @@ namespace AMDiS {
adjoint_solve(const ITL_BasePreconditioner< Vec >& P, const Vec& vin)
{
return itl::pc::solver<ITL_BasePreconditioner< Vec >, Vec, true>(P, vin);
//return P.member_adjoint_solve(vin);
}
/**
......@@ -89,20 +83,6 @@ namespace AMDiS {
{
public:
ITL_Preconditioner(const MTLMatrix& A) : precon(A) {}
#if 0
MTLVector
member_solve(const MTLVector& vin) const
{
return solve(precon, vin);
}
MTLVector
member_adjoint_solve(const MTLVector& vin) const
{
return adjoint_solve(precon, vin);
}
#else
void solve(const MTLVector& vin, MTLVector& vout) const
{
precon.solve(vin, vout);
......@@ -112,7 +92,6 @@ namespace AMDiS {
{
precon.adjoint_solve(vin, vout);
}
#endif
/// Creator class used in the OEMSolverMap.
class Creator : public CreatorInterface< ITL_BasePreconditioner< MTLVector > >
......@@ -133,9 +112,6 @@ namespace AMDiS {
};
// ============================================================================
// ===== class DiagonalPreconditioner =========================================
// ============================================================================
/**
* \ingroup Solver
......@@ -168,19 +144,15 @@ namespace AMDiS {
};
// ============================================================================
// ===== class ILUPreconditioner ==============================================
// ============================================================================
/**
* \ingroup Solver
*
* \brief
* ILU (Incomplete LU factorization) preconditioner.
*
* The preconditioner is used from ITL. It corresponds for instance to "Iterative Methods for
* Sparce Linear Systems", second edition, Yousef Saad. The preconditioner is
* described in chapter 10.3 (algorithm 10.4).
* The preconditioner is used from ITL. It corresponds for instance to
* "Iterative Methods for Sparce Linear Systems", second edition, Yousef Saad.
* The preconditioner is described in chapter 10.3 (algorithm 10.4).
*/
class ILUPreconditioner
: public ITL_Preconditioner< itl::pc::ilu_0<MTLTypes::MTLMatrix>, MTLTypes::MTLVector, MTLTypes::MTLMatrix >
......
......@@ -28,7 +28,7 @@
#include <boost/numeric/mtl/utility/is_distributed.hpp>
#if defined(HAVE_PARALLEL_DOMAIN_AMDIS) && defined(HAVE_PARALLEL_MTL4)
# include <boost/numeric/mtl/par/distribution.hpp>
#include <boost/numeric/mtl/par/distribution.hpp>
#endif
namespace AMDiS {
......@@ -71,7 +71,7 @@ namespace AMDiS {
FUNCNAME("MTL4Solver::solve()");
Timer t;
if(num_rows(matrix) == 0 || !getMultipleRhs() ) {
if (num_rows(matrix) == 0 || !getMultipleRhs()) {
init(mapper, mtl::traits::is_distributed<MTLMatrix>());
set_to_zero(matrix);
......@@ -81,13 +81,13 @@ namespace AMDiS {
}
MTLVector mtl_x;
init(mtl_x,mtl::traits::is_distributed<MTLVector>());
init(mtl_x, mtl::traits::is_distributed<MTLVector>());
set_to_zero(mtl_x);
VecMap< Vector, Mapper > xVecMap(x, mapper);
mtl_x << xVecMap;
MTLVector mtl_b;
init(mtl_b,mtl::traits::is_distributed<MTLVector>());
init(mtl_b, mtl::traits::is_distributed<MTLVector>());
set_to_zero(mtl_b);
VecMap< Vector, Mapper> bVecMap(b, mapper);
mtl_b << bVecMap;
......@@ -104,6 +104,9 @@ namespace AMDiS {
MSG("MTL4Solver: ||b-Ax||= %e\n", residual);
mtl_x >> xVecMap;
worker.exit();
return error;
}
......
......@@ -45,7 +45,6 @@
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/ParallelMapper.h"
#endif
//#include "ITL_Preconditioner.h"
namespace AMDiS {
......@@ -99,7 +98,8 @@ namespace AMDiS {
VectorialMapper&)
{
FUNCNAME("OEMSolver::solveSystem()");
TEST_EXIT(false)("This linear solver is not suitable for sequentiell problems\n");
TEST_EXIT(false)
("This linear solver is not suitable for sequentiell problems\n");
return -1;
}
......@@ -118,7 +118,8 @@ namespace AMDiS {
ParallelMapper&)
{
FUNCNAME("OEMSolver::solveSystem()");
TEST_EXIT(false)("This linear solver is not suitable for domaindecomposition problems\n");
TEST_EXIT(false)
("This linear solver is not suitable for domaindecomposition problems\n");
return -1;
}
#endif
......@@ -269,11 +270,9 @@ namespace AMDiS {
/// Error code in last solver (not set by UmfPack)
int error;
/** \brief
* If true, the solver has to solve multiple right hand sides with the same
* matrix. Some solvers, e.g. direct once, may take advanteges from this knowledge,
* as they can do the factorization of the matrix only once.
*/
/// If true, the solver has to solve multiple right hand sides with the same
/// matrix. Some solvers, e.g. direct once, may take advanteges from this knowledge,
/// as they can do the factorization of the matrix only once.
bool multipleRhs;
};
......@@ -295,10 +294,8 @@ namespace AMDiS {
}
protected:
/** \brief
* Pointer to the problem the solver will belong to. Needed as parameter
* when constructing an OEMSolver
*/
/// Pointer to the problem the solver will belong to. Needed as parameter
/// when constructing an OEMSolver
std::string name;
};
}
......
......@@ -94,9 +94,11 @@ namespace AMDiS {
TEST_EXIT(residual <= oem.getTolerance())("Tolerance tol = %e could not be reached!\n Set tolerance by '->solver->tolerance:' \n", oem.getTolerance());
}
return code;
}
void exit()
{}
~Umfpack_runner()
{
if (solver != NULL)
......@@ -135,8 +137,7 @@ namespace AMDiS {
/// Constructor
UmfPackSolver(std::string name)
: MTL4Solver< MTLMatrix, MTLVector, Umfpack_runner< MTLMatrix > >(name)
{
}
{}
int solveSystem(const SolverMatrix<Matrix<DOFMatrix*> >& A,
SystemVector& x,
......@@ -146,7 +147,6 @@ namespace AMDiS {
return solve(A,x,b,m);
}
private:
};
......
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