Commit 59ec2774 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Word-around for a bug in solving Rosenbrock system using UMFPACK.

parent 377e20dc
...@@ -241,6 +241,7 @@ namespace AMDiS { ...@@ -241,6 +241,7 @@ namespace AMDiS {
} else { } else {
for (int j = 0; j < nCol; j++) { for (int j = 0; j < nCol; j++) {
DegreeOfFreedom col = colIndices[j]; DegreeOfFreedom col = colIndices[j];
if (fabs(elMat[i][j]) > 1e-10)
ins[row][col] += elMat[i][j]; ins[row][col] += elMat[i][j];
} }
} }
......
...@@ -437,6 +437,7 @@ namespace AMDiS { ...@@ -437,6 +437,7 @@ namespace AMDiS {
std::ofstream out; std::ofstream out;
out.open(filename.c_str()); out.open(filename.c_str());
out.precision(20);
for (cursor_type cursor = begin<major>(mat.getBaseMatrix()), for (cursor_type cursor = begin<major>(mat.getBaseMatrix()),
cend = end<major>(mat.getBaseMatrix()); cursor != cend; ++cursor) cend = end<major>(mat.getBaseMatrix()); cursor != cend; ++cursor)
......
...@@ -25,11 +25,10 @@ ...@@ -25,11 +25,10 @@
#include <iostream> #include <iostream>
namespace AMDiS { namespace AMDiS {
template< typename MTLMatrix, typename MTLVector, typename Worker > template< typename MTLMatrix, typename MTLVector, typename Worker >
class MTL4Solver : public OEMSolver { class MTL4Solver : public OEMSolver {
protected: protected:
Worker worker; Worker worker;
template< typename Matrix, typename Vector, typename Mapper > template< typename Matrix, typename Vector, typename Mapper >
...@@ -60,10 +59,7 @@ namespace AMDiS { ...@@ -60,10 +59,7 @@ namespace AMDiS {
MTL4Solver(std::string n): MTL4Solver(std::string n):
OEMSolver(n), OEMSolver(n),
worker(this) worker(this)
{ {}
FUNCNAME("MTL4Solver()");
}
virtual int solveSystem(const SolverMatrix<Matrix<DOFMatrix*> >& A, virtual int solveSystem(const SolverMatrix<Matrix<DOFMatrix*> >& A,
SystemVector& x, SystemVector& x,
......
...@@ -73,9 +73,7 @@ namespace AMDiS { ...@@ -73,9 +73,7 @@ namespace AMDiS {
print_cycle(100), print_cycle(100),
iterations(-1), iterations(-1),
error(-1), error(-1),
multipleRhs(false)/*, multipleRhs(false)
leftPrecon(NULL),
rightPrecon(NULL)*/
{} {}
/// ///
...@@ -99,40 +97,6 @@ namespace AMDiS { ...@@ -99,40 +97,6 @@ namespace AMDiS {
SystemVector& x, SystemVector& x,
SystemVector& b, SystemVector& b,
VectorialMapper&) = 0; VectorialMapper&) = 0;
#if 0
{
int ns = x.getSize(), // Number of systems.
size = x.getUsedSize(); // Size of all DOFVectors
// Copy vectors
mtl::dense_vector<value_type> xx(size), bb(size);
xx << x;
bb << b
/* for (int i = 0, counter = 0; i < ns; i++) {
DOFVector<double>::Iterator it_b(b.getDOFVector(i), USED_DOFS);
DOFVector<double>::Iterator it_x(x.getDOFVector(i), USED_DOFS);
for (it_b.reset(), it_x.reset(); !it_b.end(); ++it_b, ++it_x) {
bb[counter] = *it_b;
xx[counter] = *it_x;
counter++;
}
}
*/
// Solver on DOFVector for single system
DOFMatrix::base_matrix_type baseA;
baseA << A;
int r = solveSystem(baseA, xx, bb);
for (int i = 0, counter = 0; i < ns; i++) {
DOFVector<double>::Iterator it(x.getDOFVector(i), USED_DOFS);
for (it.reset(); !it.end(); ++it)
*it = xx[counter++];
}
return r;
}
#endif
inline int solveSystem(const SolverMatrix< Matrix< DOFMatrix* > >& A, inline int solveSystem(const SolverMatrix< Matrix< DOFMatrix* > >& A,
SystemVector& x, SystemVector& x,
...@@ -306,13 +270,6 @@ namespace AMDiS { ...@@ -306,13 +270,6 @@ namespace AMDiS {
* as they can do the factorization of the matrix only once. * as they can do the factorization of the matrix only once.
*/ */
bool multipleRhs; bool multipleRhs;
#if 0
/// Left preconditioner (ignored by some iterative solvers and by UmfPack)
PreconCreator *leftPrecon;
/// Right preconditioner (ignored by some iterative solvers and by UmfPack)
PreconCreator *rightPrecon;
#endif
}; };
/** /**
......
...@@ -634,6 +634,8 @@ namespace AMDiS { ...@@ -634,6 +634,8 @@ namespace AMDiS {
{ {
FUNCNAME("ProblemStat::buildAfterCoarsen()"); FUNCNAME("ProblemStat::buildAfterCoarsen()");
VtkWriter::writeFile(rhs->getDOFVector(0), "test.vtu");
// buildAfterCoarsen_sebastianMode(adaptInfo, flag); // buildAfterCoarsen_sebastianMode(adaptInfo, flag);
// return; // return;
......
...@@ -52,6 +52,8 @@ namespace AMDiS { ...@@ -52,6 +52,8 @@ namespace AMDiS {
store_symbolic(0), store_symbolic(0),
symmetric_strategy(0) symmetric_strategy(0)
{ {
FUNCNAME("Umfpack_runner::Umfpack_runner()");
TEST_EXIT_DBG(oem_ != NULL)("Need real OEMSolver\n"); TEST_EXIT_DBG(oem_ != NULL)("Need real OEMSolver\n");
Parameters::get(oem.getName() + "->store symbolic", store_symbolic); Parameters::get(oem.getName() + "->store symbolic", store_symbolic);
Parameters::get(oem.getName() + "->symmetric strategy", symmetric_strategy); Parameters::get(oem.getName() + "->symmetric strategy", symmetric_strategy);
...@@ -60,7 +62,7 @@ namespace AMDiS { ...@@ -60,7 +62,7 @@ namespace AMDiS {
template< typename Vector> template< typename Vector>
int solve(const Matrix& A, Vector& x, Vector& b) int solve(const Matrix& A, Vector& x, Vector& b)
{ {
FUNCNAME("(UmfPackSolver.h)::solve()"); FUNCNAME("Umfpack_runner::solve()");
if (!solver) { if (!solver) {
if (!symmetric_strategy) if (!symmetric_strategy)
solver = new mtl::matrix::umfpack::solver<matrix_type>(A); solver = new mtl::matrix::umfpack::solver<matrix_type>(A);
...@@ -68,7 +70,6 @@ namespace AMDiS { ...@@ -68,7 +70,6 @@ namespace AMDiS {
solver = new mtl::matrix::umfpack::solver<matrix_type>(A, UMFPACK_STRATEGY_SYMMETRIC); solver = new mtl::matrix::umfpack::solver<matrix_type>(A, UMFPACK_STRATEGY_SYMMETRIC);
} else { } else {
if (!oem.getMultipleRhs()) { if (!oem.getMultipleRhs()) {
if (store_symbolic) if (store_symbolic)
solver->update_numeric(); solver->update_numeric();
else else
...@@ -77,16 +78,14 @@ namespace AMDiS { ...@@ -77,16 +78,14 @@ namespace AMDiS {
} }
int code = (*solver)(x, b); int code = (*solver)(x, b);
if( oem.getInfo() > 0) { if (oem.getInfo() > 0) {
mtl::dense_vector<typename matrix_type::value_type> r(b); mtl::dense_vector<typename matrix_type::value_type> r(b);
r -= A * x; r -= A * x;
double residual = two_norm(r); double residual = two_norm(r);
oem.setResidual(residual); oem.setResidual(residual);
oem.setErrorCode(code); oem.setErrorCode(code);
std::cout << "UmfPackSolver: ||b-Ax|| = " << residual << "\n"; std::cout << "UmfPackSolver: ||b-Ax|| = " << residual << "\n";
if (residual > oem.getTolerance()) { TEST_EXIT(residual <= oem.getTolerance())("Tolerance tol = %e could not be reached!\n Set tolerance by '->solver->tolerance:' \n", oem.getTolerance());
ERROR_EXIT("Tolerance tol=%e could not be reached!\n Set tolerance by '->solver->tolerance:' \n", oem.getTolerance());
}
} }
return code; return code;
...@@ -94,7 +93,7 @@ namespace AMDiS { ...@@ -94,7 +93,7 @@ namespace AMDiS {
~Umfpack_runner() ~Umfpack_runner()
{ {
if(!solver) if (!solver)
delete solver; delete solver;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ProblemStat.h" #include "ProblemStat.h"
#include "SystemVector.h" #include "SystemVector.h"
#include "OEMSolver.h" #include "OEMSolver.h"
#include "Debug.h"
namespace AMDiS { namespace AMDiS {
...@@ -79,7 +80,7 @@ namespace AMDiS { ...@@ -79,7 +80,7 @@ namespace AMDiS {
} }
ProblemStatSeq::buildAfterCoarsen(adaptInfo, flag, (i == 0), asmVector); ProblemStatSeq::buildAfterCoarsen(adaptInfo, flag, (i == 0), asmVector);
solver->setMultipleRhs(i != 0); // solver->setMultipleRhs(i != 0);
ProblemStatSeq::solve(adaptInfo); ProblemStatSeq::solve(adaptInfo);
*(stageSolutions[i]) = *solution; *(stageSolutions[i]) = *solution;
......
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