Commit b0d3cf31 authored by Peter Gottschling's avatar Peter Gottschling
Browse files

Matrixausschriften als Kommentare; Iterationszahlen und Fehlercode können abgefragt werden.

parent e4f84157
...@@ -74,7 +74,9 @@ namespace AMDiS { ...@@ -74,7 +74,9 @@ namespace AMDiS {
if (one_norm(x) > 1e100) if (one_norm(x) > 1e100)
x= 0.0; x= 0.0;
#endif #endif
return ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter); error= ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter);
iterations= iter.iterations();
return error;
} }
...@@ -124,7 +126,9 @@ namespace AMDiS { ...@@ -124,7 +126,9 @@ namespace AMDiS {
{ {
itl::cyclic_iteration<value_type> iter(b, this->max_iter, this->relative, itl::cyclic_iteration<value_type> iter(b, this->max_iter, this->relative,
this->tolerance, this->print_cycle); this->tolerance, this->print_cycle);
return ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter, ell); error= ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter, ell);
iterations= iter.iterations();
return error;
} }
class Creator : public OEMSolverCreator class Creator : public OEMSolverCreator
......
...@@ -64,6 +64,8 @@ namespace AMDiS { ...@@ -64,6 +64,8 @@ namespace AMDiS {
info(0), info(0),
residual(0), residual(0),
print_cycle(100), print_cycle(100),
iterations(-1),
error(-1),
leftPrecon(NULL), leftPrecon(NULL),
rightPrecon(NULL) rightPrecon(NULL)
{} {}
...@@ -132,6 +134,7 @@ namespace AMDiS { ...@@ -132,6 +134,7 @@ namespace AMDiS {
counter++; counter++;
} }
// std::cout << "Iterative Solver: A = \n" << A.getMatrix();
int r = solveSystem(A.getMatrix(), xx, bb); int r = solveSystem(A.getMatrix(), xx, bb);
// Copy solution vector to DOFVector // Copy solution vector to DOFVector
...@@ -164,6 +167,7 @@ namespace AMDiS { ...@@ -164,6 +167,7 @@ namespace AMDiS {
} }
// Solver on DOFVector for single system // Solver on DOFVector for single system
std::cout << "Iterative Solver (System): A = \n" << A.getMatrix();
int r= solveSystem(A.getMatrix(), xx, bb); int r= solveSystem(A.getMatrix(), xx, bb);
for (int i = 0, counter = 0; i < ns; i++) { for (int i = 0, counter = 0; i < ns; i++) {
...@@ -227,6 +231,18 @@ namespace AMDiS { ...@@ -227,6 +231,18 @@ namespace AMDiS {
max_iter = i; max_iter = i;
} }
/// Returns number of iterations in last run of an iterative solver
inline int getIterations()
{
return iterations;
}
/// Returns error code in last run of an iterative solver
inline int getErrorCode()
{
return error;
}
/// Sets \ref info /// Sets \ref info
inline void setInfo(int i) inline void setInfo(int i)
{ {
...@@ -257,8 +273,16 @@ namespace AMDiS { ...@@ -257,8 +273,16 @@ namespace AMDiS {
/// Print cycle, after how many iterations the residuum norm is logged. /// Print cycle, after how many iterations the residuum norm is logged.
int print_cycle; int print_cycle;
/// How many iterations were performed in last solver (not set by UmfPack)
int iterations;
/// Error code in last solver (not set by UmfPack)
int error;
/// Left preconditioner (ignored by some iterative solvers and by UmfPack)
ITL_BasePreconditioner *leftPrecon; ITL_BasePreconditioner *leftPrecon;
/// Right preconditioner (ignored by some iterative solvers and by UmfPack)
ITL_BasePreconditioner *rightPrecon; ITL_BasePreconditioner *rightPrecon;
}; };
......
...@@ -87,6 +87,8 @@ namespace AMDiS { ...@@ -87,6 +87,8 @@ namespace AMDiS {
solver->update_numeric(); solver->update_numeric();
else else
solver->update(); solver->update();
// std::cout << "UmfPackSolver: A = \n" << A << "\n";
int code= (*solver)(x, b); int code= (*solver)(x, b);
mtl::dense_vector<value_type> r= b - A * x; mtl::dense_vector<value_type> r= b - A * x;
std::cout << "UmfPackSolver: ||b-Ax|| = " << two_norm(r) << "\n"; std::cout << "UmfPackSolver: ||b-Ax|| = " << two_norm(r) << "\n";
......
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