Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

Commit 6b371bfd authored by Naumann, Andreas's avatar Naumann, Andreas
Browse files

removed possible memory error, tested with demos

parent 5603ff15
......@@ -43,13 +43,13 @@ namespace AMDiS {
*/
template <typename ITLSolver>
class ITL_OEMSolver : public MTL4Solver< MTLTypes::MTLMatrix, MTLTypes::MTLVector, ITL_OEMSolver_runner< ITLSolver > > {
class ITL_OEMSolver : public MTL4Solver< MTLTypes::MTLMatrix, MTLTypes::MTLVector, ITL_OEMSolver_runner< ITLSolver, MTLTypes::MTLMatrix, MTLTypes::MTLVector> > {
protected:
public:
/// The constructor reads needed parameters and sets solvers \ref name.
ITL_OEMSolver(std::string name) :
MTL4Solver< MTLTypes::MTLMatrix, MTLTypes::MTLVector, ITL_OEMSolver_runner< ITLSolver > >(name) {}
MTL4Solver< MTLTypes::MTLMatrix, MTLTypes::MTLVector, ITL_OEMSolver_runner< ITLSolver, MTLTypes::MTLMatrix, MTLTypes::MTLVector > >(name) {}
~ITL_OEMSolver() {}
......@@ -77,12 +77,12 @@ namespace AMDiS {
*/
template <typename ITLSolver>
class ITL_OEMSolver_para
: public MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver > > // ITL_OEMSolver<ITLSolver>
: public MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver, MTLTypes::MTLMatrix, MTLTypes::MTLVector > > // ITL_OEMSolver<ITLSolver>
{
public:
/// The constructor reads needed parameters and sets solvers \ref name.
ITL_OEMSolver_para(std::string name)
: MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver > >(name)
: MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver, MTLTypes::MTLMatrix, MTLTypes::MTLVector > >(name)
{
}
......
......@@ -49,7 +49,7 @@ namespace AMDiS {
}
};
template< typename ITLSolver >
template< typename ITLSolver, typename Matrix, typename Vector >
struct ITL_OEMSolver_para_runner : BaseITL_runner {
ITL_OEMSolver_para_runner(OEMSolver* oem_):
BaseITL_runner(oem_),
......@@ -59,27 +59,32 @@ namespace AMDiS {
Parameters::get(oem.getName() + "->ell", ell);
}
template< typename Matrix, typename Vector>
void init(const Matrix& A)
{
BaseITL_runner::setPrecon(preconPair, A);
}
int solve(const Matrix& A, Vector& x, Vector& b)
{
itl::cyclic_iteration<typename Matrix::value_type> iter(b, oem.getMaxIterations(), oem.getRelative(),
FUNCNAME("ITL_OEMSolver_para_runner::solve()");
TEST_EXIT(preconPair.l != NULL)("there is no left preconditioner");
TEST_EXIT(preconPair.r != NULL)("there is no right preconditioner");
itl::cyclic_iteration<typename Vector::value_type> iter(b, oem.getMaxIterations(), oem.getRelative(),
oem.getTolerance(), oem.getPrint_cycle());
static PreconPair< Vector > preconPair;
if (preconPair.l == NULL || preconPair.r == NULL || !oem.getMultipleRhs())
BaseITL_runner::setPrecon(preconPair, A);
int error = ITLSolver()(A, x, b, *(preconPair.l), *(preconPair.r), iter, ell);
int error = solver(A, x, b, *(preconPair.l), *(preconPair.r), iter, ell);
oem.setIterations(iter.iterations());
oem.setResidual(iter.resid());
oem.setErrorCode(error);
return error;
}
private:
PreconPair< Vector > preconPair;
ITLSolver solver;
int ell;
};
template< typename ITLSolver >
template< typename ITLSolver, typename Matrix, typename Vector >
struct ITL_OEMSolver_runner : BaseITL_runner {
......@@ -87,21 +92,26 @@ namespace AMDiS {
BaseITL_runner(oem)
{}
template< typename Matrix, typename Vector>
int solve(const Matrix& A, Vector& x, Vector& b)
void init(const Matrix& A)
{
BaseITL_runner::setPrecon(preconPair, A);
}
int solve(const Matrix& A , Vector& x, Vector& b)
{
FUNCNAME("ITL_OEMSolver_runner::solve()");
TEST_EXIT(preconPair.l != NULL)("there is no left preconditioner");
TEST_EXIT(preconPair.r != NULL)("there is no right preconditioner");
itl::cyclic_iteration<typename Matrix::value_type> iter(b, oem.getMaxIterations(), oem.getRelative(),
oem.getTolerance(), oem.getPrint_cycle());
static PreconPair< Vector > preconPair;
if (preconPair.l == NULL || preconPair.r == NULL || !oem.getMultipleRhs())
BaseITL_runner::setPrecon(preconPair, A);
int error = ITLSolver()(A, x, b, *(preconPair.l), *(preconPair.r), iter);
int error = solver(A, x, b, *(preconPair.l), *(preconPair.r), iter);
oem.setErrorCode(error);
oem.setIterations(iter.iterations());
oem.setResidual(iter.resid());
return error;
}
private:
ITLSolver solver;
PreconPair< Vector > preconPair;
};
}
......@@ -28,16 +28,20 @@ namespace AMDiS {
template< typename MTLMatrix, typename MTLVector, typename Worker >
class MTL4Solver : public OEMSolver {
MTLMatrix matrix;
protected:
Worker worker;
template< typename Matrix, typename Vector, typename Mapper >
int solve(const Matrix& A, Vector& x, Vector& b, Mapper& mapper)
{
MTLMatrix matrix(mapper.nRow(), mapper.nCol());
set_to_zero(matrix);
MatMap< const Matrix, Mapper > matMap(A,mapper);
matrix << matMap;
if(num_rows(matrix) == 0 || !getMultipleRhs() ) {
matrix.change_dim(mapper.nRow(), mapper.nCol());
set_to_zero(matrix);
MatMap< const Matrix, Mapper > matMap(A,mapper);
matrix << matMap;
worker.init(matrix);
}
MTLVector mtl_x(mapper.nRow());
set_to_zero(mtl_x);
......@@ -49,7 +53,7 @@ namespace AMDiS {
VecMap< Vector, Mapper> bVecMap(b, mapper);
mtl_b << bVecMap;
error = worker.solve(matrix, mtl_x, mtl_b);
error = worker.solve(matrix ,mtl_x, mtl_b);
mtl_x >> xVecMap;
return error;
......@@ -58,6 +62,7 @@ namespace AMDiS {
public:
MTL4Solver(std::string n):
OEMSolver(n),
matrix(0,0),
worker(this)
{}
......
......@@ -61,20 +61,27 @@ namespace AMDiS {
Parameters::get(oem.getName() + "->alloc init", alloc_init);
}
void init(const Matrix& A)
{
FUNCNAME("Umfpack_runner::init()")
if(solver != NULL)
delete solver;
solver = new mtl::matrix::umfpack::solver<matrix_type>(A, symmetric_strategy, alloc_init);
}
template< typename Vector>
int solve(const Matrix& A, Vector& x, Vector& b)
{
FUNCNAME("Umfpack_runner::solve()");
if (!solver) {
solver = new mtl::matrix::umfpack::solver<matrix_type>(A, symmetric_strategy, alloc_init);
} else {
if (!oem.getMultipleRhs()) {
if (store_symbolic)
TEST_EXIT(solver != NULL)("The umfpack solver was not initialized\n");
#if 0
if (!oem.getMultipleRhs()) {
if (store_symbolic)
solver->update_numeric();
else
solver->update();
}
}
#endif
int code = (*solver)(x, b);
if (oem.getInfo() > 0) {
......@@ -92,7 +99,7 @@ namespace AMDiS {
~Umfpack_runner()
{
if (!solver)
if (solver != NULL)
delete solver;
}
......
......@@ -32,17 +32,17 @@ namespace AMDiS {
typedef ITL_BasePreconditioner< MTLVector > ParallelPreconditioner;
template< typename ITLSolver >
class PITL_Solver : public AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_runner< ITLSolver > > {
class PITL_Solver : public AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_runner< ITLSolver, MTLMatrix, MTLVector > > {
public:
PITL_Solver(std::string name):
AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_runner< ITLSolver > >(name) {}
AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_runner< ITLSolver, MTLMatrix, MTLVector > >(name) {}
int solveSystem(const SolverMatrix<Matrix<DOFMatrix*> >& A,
SystemVector& x,
SystemVector& b,
ParallelMapper& m)
{
return AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_runner< ITLSolver > >::solve(A,x,b,m);
return AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_runner< ITLSolver, MTLMatrix, MTLVector > >::solve(A,x,b,m);
}
......@@ -61,17 +61,17 @@ namespace AMDiS {
};
template< typename ITLSolver >
class PITL_Solver_para : public AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver > > {
class PITL_Solver_para : public AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver, MTLMatrix, MTLVector > > {
public:
PITL_Solver_para(std::string name):
AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver > >(name) {}
AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver, MTLMatrix, MTLVector > >(name) {}
int solveSystem(const SolverMatrix<Matrix<DOFMatrix*> >& A,
SystemVector& x,
SystemVector& b,
ParallelMapper& m)
{
return AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver > >::solve(A,x,b,m);
return AMDiS::MTL4Solver< MTLMatrix, MTLVector, ITL_OEMSolver_para_runner< ITLSolver, MTLMatrix, MTLVector > >::solve(A,x,b,m);
}
/// Creator class used in the OEMSolverMap.
......
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