Commit 5c9749d2 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

merged issue/solver_info

parents 91b1d5ab a99f9670
......@@ -396,16 +396,7 @@ solve(AdaptInfo& adaptInfo, bool createMatrixData, bool storeMatrixData)
}
}
if (solverInfo.doBreak()) {
std::stringstream tol_str;
if (solverInfo.absTolerance() > 0
&& solverInfo.absResidual() > solverInfo.absTolerance())
tol_str << "absTol = " << solverInfo.absTolerance() << " ";
if (solverInfo.relTolerance() > 0
&& solverInfo.relResidual() > solverInfo.relTolerance())
tol_str << "relTol = " << solverInfo.relTolerance() << " ";
error_exit("Tolerance {} could not be reached!", tol_str.str());
}
test_exit(!solverInfo.doBreak() && !solverInfo.error(), "Could not solver the linear system!");
}
......
......@@ -14,16 +14,12 @@ namespace AMDiS
/// The constructor reads needed parameters and sets solver \p prefix.
/**
* Reads parameters for a solver with name 'NAME':
* NAME->absolute tolerance \ref aTol_
* NAME->relative tolerance \ref rTol_
* NAME->info \ref info_
* NAME->break if tolerance not reached \ref breakTolNotReached_
**/
explicit SolverInfo(std::string const& prefix)
: prefix_(prefix)
{
Parameters::get(prefix + "->absolute tolerance", aTol_);
Parameters::get(prefix + "->relative tolerance", rTol_);
Parameters::get(prefix + "->info", info_);
Parameters::get(prefix + "->break if tolerance not reached", breakTolNotReached_);
}
......@@ -32,20 +28,8 @@ namespace AMDiS
* \{
*/
/// Returns \ref aTol_
double absTolerance() const
{
return aTol_;
}
/// Returns \ref rTol_
double relTolerance() const
{
return rTol_;
}
/// Returns error code in last run of an iterative solver
int errorCode() const
int error() const
{
return error_;
}
......@@ -68,12 +52,6 @@ namespace AMDiS
return relResidual_;
}
/// Returns the initfile \ref prefix_
std::string const& prefix() const
{
return prefix_;
}
/// Returns \ref createMatrixData
bool doCreateMatrixData() const
{
......@@ -88,9 +66,7 @@ namespace AMDiS
bool doBreak() const
{
return breakTolNotReached_ && (
(aTol_ > 1.e-30 && absResidual_ > aTol_) ||
(rTol_ > 1.e-30 && relResidual_ > rTol_) );
return breakTolNotReached_;
}
/** \} */
......@@ -100,25 +76,13 @@ namespace AMDiS
* \{
*/
/// Sets \ref aTol_
void setAbsTolerance(double tol)
{
aTol_ = tol;
}
/// Sets \ref rTol_
void setRelTolerance(double tol)
{
rTol_ = tol;
}
/// Sets \ref aTol_
/// Sets \ref absResidual_
void setAbsResidual(double r)
{
absResidual_ = r;
}
/// Sets \ref rTol_
/// Sets \ref relResidual_
void setRelResidual(double r)
{
relResidual_ = r;
......@@ -154,12 +118,6 @@ namespace AMDiS
/// The initfile prefix to read parameters
std::string prefix_;
/// The abolute tolerance
double aTol_ = 0;
/// The relative tolerance
double rTol_ = 1.e-6;
/// Throw an error if tolerance could not be reached
bool breakTolNotReached_ = false;
......
......@@ -51,7 +51,8 @@ namespace AMDiS
/// Implements \ref RunnerInterface::solve()
int solve(M const& A, X& x, Y const& b, SolverInfo& solverInfo) override
{
solver_.setTolerance(solverInfo.relTolerance());
DUNE_UNUSED_PARAMETER(A);
x = solver_.solveWithGuess(b, x);
Y r = b;
......
......@@ -15,6 +15,11 @@ namespace AMDiS
template <class D>
static void init(std::string const& prefix, Eigen::IterativeSolverBase<D>& solver)
{
using RealScalar = typename Eigen::IterativeSolverBase<D>::RealScalar;
auto rtol = Parameters::get<RealScalar>(prefix + "->relative tolerance");
if (rtol)
solver.setTolerance(rtol.value());
int maxIter = 500;
Parameters::get(prefix + "->max iteration", maxIter);
solver.setMaxIterations(maxIter);
......
Supports Markdown
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