LAMA
|
#include <SimpleAMG.hpp>
Data Structures | |
struct | SimpleAMGRuntime |
Public Member Functions | |
SimpleAMG (const std::string &id) | |
SimpleAMG (const std::string &id, LoggerPtr logger) | |
SimpleAMG (const SimpleAMG &other) | |
virtual | ~SimpleAMG () |
virtual void | initialize (const Matrix &coefficients) |
Used to initialize a solver with a certain matrix A from A*u=f. | |
virtual void | iterate () |
Represents one iteration step of the solver. | |
void | setMaxLevels (unsigned int levels) |
void | setMinVarsCoarseLevel (unsigned int vars) |
unsigned int | getNumLevels () |
const Matrix & | getGalerkin (unsigned int level) |
const Matrix & | getRestriction (unsigned int level) |
const Matrix & | getInterpolation (unsigned int level) |
Vector & | getSolutionVector (unsigned int level) |
Vector & | getRhsVector (unsigned int level) |
Solver & | getSmoother (unsigned int level) |
Solver & | getCoarseLevelSolver () |
void | setSmootherContext (ContextPtr smootherContext) |
void | setHostOnlyLevel (IndexType hostOnlyLevel) |
void | setReplicatedLevel (IndexType replicatedLevel) |
void | setCoarseLevelSolver (SolverPtr solver) |
void | setSmoother (SolverPtr solver) |
Sets the smoother for all level. | |
virtual SimpleAMGRuntime & | getRuntime () |
Returns the complete configuration of the derived class. | |
virtual const SimpleAMGRuntime & | getConstRuntime () const |
Returns the complete const configuration of the derived class. | |
virtual SolverPtr | copy () |
Copies the status independent solver informations to create a new instance of the same type. | |
virtual void | solveImpl () |
Solves the equation system. | |
void | setStoppingCriterion (const CriterionPtr criterion) |
set a new StoppingCriterion to the solver. | |
void | setPreconditioner (SolverPtr const conditioner) |
Sets the preconditioner of this solver. | |
const SolverPtr | getPreconditioner () const |
returns the preconditioner of this solver | |
int | getIterationCount () const |
returns the number of iterations, this solver has done so far. | |
virtual void | solve (Vector &solution, const Vector &rhs) |
Solves the equation system based on the given rhs. | |
virtual void | solveInit (Vector &solution, const Vector &rhs) |
Initializes the solver with rhs and solution. | |
virtual void | solveFinalize () |
Finalizes the solving process. | |
const std::string & | getId () const |
Returns the ID of this solver. | |
const Vector & | getResidual () const |
Contingently calculates the current residual based on the coefficients, rhs and solution currently associated with this. | |
const Matrix & | getCoefficients () const |
Gets the matrix A from A*u=f. | |
void | setLogger (LoggerPtr logger) |
Redefines mLogger. | |
void | setLogLevel (LogLevel::LogLevel level) |
Switches the loglevel of mLogger. | |
virtual void | setContext (ContextPtr context) |
Sets the context where this solver should be executed. | |
Protected Member Functions | |
bool | criteriaAreSatisfied () const |
Checks if all of the stopping criteria are satisfied. | |
void | logStartSolve () |
Logging methods to maintain code-readability. | |
void | logEndSolve () |
void | logIterationEndAndResidual () |
void | logIterationStart () |
virtual void | writeAt (std::ostream &stream) const |
Overrides Printable::writeAt with more useful stuff. | |
Protected Attributes | |
SimpleAMGRuntime | mSimpleAMGRuntime |
unsigned int | mMaxLevels |
unsigned int | mMinVarsCoarseLevel |
SolverPtr | mCoarseLevelSolver |
SolverPtr | mSmoother |
ContextPtr | mSmootherContext |
SolverPtr | mPreconditioner |
The preconditioner of this solver. | |
CriterionPtr | mCriterionRootComponent |
The root stopping criterion evaluated every iteration in the solve method. | |
std::string | mId |
The ID of this solver. | |
LoggerPtr | mLogger |
The solver logger. | |
ContextPtr | mContext |
For forcing the context solver dependent. | |
Private Member Functions | |
void | logSetupSettings () |
void | logSetupInfo () |
void | logSolverInfo () |
void | logSetupDetails () |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
void | cycle () |
lama::SimpleAMG::SimpleAMG | ( | const std::string & | id | ) |
Referenced by copy().
lama::SimpleAMG::SimpleAMG | ( | const std::string & | id, |
LoggerPtr | logger | ||
) |
lama::SimpleAMG::SimpleAMG | ( | const SimpleAMG & | other | ) |
lama::SimpleAMG::~SimpleAMG | ( | ) | [virtual] |
SolverPtr lama::SimpleAMG::copy | ( | ) | [virtual] |
Copies the status independent solver informations to create a new instance of the same type.
Implements lama::IterativeSolver.
References SimpleAMG().
bool lama::IterativeSolver::criteriaAreSatisfied | ( | ) | const [protected, inherited] |
Checks if all of the stopping criteria are satisfied.
return Whether the criteria are satisfied or not
References lama::Solver::getId(), LAMA_THROWEXCEPTION, and lama::IterativeSolver::mCriterionRootComponent.
Referenced by lama::IterativeSolver::solveImpl().
void lama::SimpleAMG::cycle | ( | ) | [private] |
References getRuntime(), LAMA_REGION_N, lama::SimpleAMG::SimpleAMGRuntime::mCurrentLevel, lama::SimpleAMG::SimpleAMGRuntime::mSetup, and lama::Solver::solve().
Referenced by iterate().
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
const Matrix & lama::Solver::getCoefficients | ( | ) | const [inherited] |
Gets the matrix A from A*u=f.
References lama::Solver::getConstRuntime(), LAMA_ASSERT_DEBUG, and lama::Solver::SolverRuntime::mCoefficients.
Referenced by lama::InverseSolver::invert(), and lama::LUSolver::piamax_own().
const SimpleAMG::SimpleAMGRuntime & lama::SimpleAMG::getConstRuntime | ( | ) | const [virtual] |
Returns the complete const configuration of the derived class.
Implements lama::IterativeSolver.
References mSimpleAMGRuntime.
const Matrix & lama::SimpleAMG::getGalerkin | ( | unsigned int | level | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
const std::string & lama::Solver::getId | ( | ) | const [inherited] |
Returns the ID of this solver.
References lama::Solver::mId.
Referenced by lama::IterativeSolver::criteriaAreSatisfied(), lama::IterativeSolver::solveImpl(), and lama::SolverConfigGrammar::SolverConfigGrammar().
const Matrix & lama::SimpleAMG::getInterpolation | ( | unsigned int | level | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
int lama::IterativeSolver::getIterationCount | ( | ) | const [inherited] |
returns the number of iterations, this solver has done so far.
References lama::IterativeSolver::getConstRuntime(), and lama::IterativeSolver::IterativeSolverRuntime::mIterations.
Referenced by lama::IterationCount::isSatisfied(), lama::ResidualThreshold::isSatisfied(), lama::CG::iterate(), and lama::GMRES::iterate().
unsigned int lama::SimpleAMG::getNumLevels | ( | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
const SolverPtr lama::IterativeSolver::getPreconditioner | ( | ) | const [inherited] |
returns the preconditioner of this solver
References lama::IterativeSolver::mPreconditioner.
Referenced by lama::MetaSolver::initializePreconditioner(), and lama::IterativeSolver::IterativeSolver().
const Vector & lama::Solver::getResidual | ( | ) | const [inherited] |
Contingently calculates the current residual based on the coefficients, rhs and solution currently associated with this.
Should be used internally only, because the three vectors mentioned above have to be initialized.
References lama::LogLevel::completeInformation, lama::Vector::create(), lama::SolutionProxy::getConstReference(), lama::Solver::getConstRuntime(), lama::SolutionProxy::isDirty(), LAMA_ASSERT_DEBUG, lama::Solver::SolverRuntime::mCoefficients, lama::Solver::mLogger, lama::Solver::SolverRuntime::mResidual, lama::Solver::SolverRuntime::mRhs, lama::Solver::SolverRuntime::mSolution, and lama::SolutionProxy::setDirty().
Referenced by lama::ResidualStagnation::isSatisfied(), lama::ResidualThreshold::isSatisfied(), lama::CG::iterate(), lama::GMRES::iterate(), and lama::Logger::logResidual().
const Matrix & lama::SimpleAMG::getRestriction | ( | unsigned int | level | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
Vector & lama::SimpleAMG::getRhsVector | ( | unsigned int | level | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
SimpleAMG::SimpleAMGRuntime & lama::SimpleAMG::getRuntime | ( | ) | [virtual] |
Returns the complete configuration of the derived class.
Implements lama::IterativeSolver.
References mSimpleAMGRuntime.
Referenced by cycle(), getCoarseLevelSolver(), getGalerkin(), getInterpolation(), getNumLevels(), getRestriction(), getRhsVector(), getSmoother(), getSolutionVector(), initialize(), logSetupDetails(), logSetupInfo(), logSetupSettings(), logSolverInfo(), setHostOnlyLevel(), and setReplicatedLevel().
Solver & lama::SimpleAMG::getSmoother | ( | unsigned int | level | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
Vector & lama::SimpleAMG::getSolutionVector | ( | unsigned int | level | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
void lama::SimpleAMG::initialize | ( | const Matrix & | coefficients | ) | [virtual] |
Used to initialize a solver with a certain matrix A from A*u=f.
This method initializes a solver with a certain coefficient-matrix. The only thing it does is storing the matrix pointer as a member for derived solver classes to use it. The caller delegates the property of the pointer to the Solver instance.
This method may be overwritten by derived classes which desire more complex initialization.
coefficients | The matrix A from A*u=f. |
Reimplemented from lama::IterativeSolver.
References getRuntime(), LAMA_REGION, loadLibAndGetFunctionHandle(), logSetupDetails(), logSetupInfo(), logSetupSettings(), logSolverInfo(), mCoarseLevelSolver, lama::SimpleAMG::SimpleAMGRuntime::mHostOnlyLevel, lama::SimpleAMG::SimpleAMGRuntime::mLibHandle, mMaxLevels, mMinVarsCoarseLevel, lama::SimpleAMG::SimpleAMGRuntime::mReplicatedLevel, lama::SimpleAMG::SimpleAMGRuntime::mSetup, mSmoother, and mSmootherContext.
void lama::SimpleAMG::iterate | ( | ) | [virtual] |
Represents one iteration step of the solver.
Use this abstract method to implement new iterative solvers (e.g. Jacobi)
This method represents one solver iteration. Idealically a derived iterative solver only overwrites this method. It is only used by the solve() method of this class. Use the member variables m_rhs, mSolution and m_coefficients during the iteration process.
Implements lama::IterativeSolver.
References cycle(), and LAMA_REGION.
lama::SimpleAMG::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
Reimplemented from lama::IterativeSolver.
void lama::IterativeSolver::logEndSolve | ( | ) | [protected, inherited] |
References lama::IterativeSolver::getRuntime(), lama::Solver::mLogger, and lama::LogLevel::solverInformation.
Referenced by lama::IterativeSolver::solveImpl().
void lama::IterativeSolver::logIterationEndAndResidual | ( | ) | [protected, inherited] |
void lama::IterativeSolver::logIterationStart | ( | ) | [protected, inherited] |
References lama::LogLevel::completeInformation, lama::IterativeSolver::getRuntime(), and lama::Solver::mLogger.
Referenced by lama::IterativeSolver::solveImpl().
void lama::SimpleAMG::logSetupDetails | ( | ) | [private] |
References lama::LogLevel::advancedInformation, getRuntime(), lama::Scalar::getTypeSize(), lama::Solver::mLogger, and lama::SimpleAMG::SimpleAMGRuntime::mSetup.
Referenced by initialize().
void lama::SimpleAMG::logSetupInfo | ( | ) | [private] |
References lama::LogLevel::advancedInformation, getRuntime(), lama::Solver::mLogger, lama::SimpleAMG::SimpleAMGRuntime::mSetup, and lama::LogLevel::solverInformation.
Referenced by initialize().
void lama::SimpleAMG::logSetupSettings | ( | ) | [private] |
References getRuntime(), lama::Solver::mLogger, mMaxLevels, mMinVarsCoarseLevel, lama::SimpleAMG::SimpleAMGRuntime::mSetup, and lama::LogLevel::solverInformation.
Referenced by initialize().
void lama::SimpleAMG::logSolverInfo | ( | ) | [private] |
References getRuntime(), lama::Solver::mLogger, lama::SimpleAMG::SimpleAMGRuntime::mSetup, and lama::LogLevel::solverInformation.
Referenced by initialize().
void lama::IterativeSolver::logStartSolve | ( | ) | [protected, inherited] |
Logging methods to maintain code-readability.
References lama::LogLevel::convergenceHistory, lama::l2Norm(), lama::Solver::mLogger, and lama::LogLevel::solverInformation.
Referenced by lama::IterativeSolver::solveImpl().
void lama::SimpleAMG::setCoarseLevelSolver | ( | SolverPtr | solver | ) |
References mCoarseLevelSolver.
void lama::Solver::setContext | ( | ContextPtr | context | ) | [virtual, inherited] |
Sets the context where this solver should be executed.
Sets the context where this solver should be executed. Caution: This overrides the context of the coefficients matrix A from A * u = f used to inializ this solver.
[in] | context | the context where this solver should be executed. |
Reimplemented in lama::InverseSolver.
References lama::Solver::mContext.
Referenced by lama::GMRES::initialize().
void lama::SimpleAMG::setHostOnlyLevel | ( | IndexType | hostOnlyLevel | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mHostOnlyLevel.
void lama::Solver::setLogger | ( | LoggerPtr | logger | ) | [inherited] |
Redefines mLogger.
References lama::Solver::mLogger.
void lama::Solver::setLogLevel | ( | LogLevel::LogLevel | level | ) | [inherited] |
void lama::SimpleAMG::setMaxLevels | ( | unsigned int | levels | ) |
References mMaxLevels.
void lama::SimpleAMG::setMinVarsCoarseLevel | ( | unsigned int | vars | ) |
References mMinVarsCoarseLevel.
void lama::IterativeSolver::setPreconditioner | ( | SolverPtr const | conditioner | ) | [inherited] |
Sets the preconditioner of this solver.
Preconditioner should be set before initializing the this solver, otherwise the preconditioner initialization should be executed manually
conditioner | The preconditioner |
References lama::IterativeSolver::mPreconditioner.
void lama::SimpleAMG::setReplicatedLevel | ( | IndexType | replicatedLevel | ) |
References getRuntime(), and lama::SimpleAMG::SimpleAMGRuntime::mReplicatedLevel.
void lama::SimpleAMG::setSmoother | ( | SolverPtr | solver | ) |
Sets the smoother for all level.
References mSmoother.
void lama::SimpleAMG::setSmootherContext | ( | ContextPtr | smootherContext | ) |
References mSmootherContext.
void lama::IterativeSolver::setStoppingCriterion | ( | const CriterionPtr | criterion | ) | [inherited] |
set a new StoppingCriterion to the solver.
[in] | criterion | the new criterion. |
References LAMA_ASSERT_ERROR, and lama::IterativeSolver::mCriterionRootComponent.
Referenced by lama::SingleGridSetup::initialize().
void lama::Solver::solve | ( | Vector & | solution, |
const Vector & | rhs | ||
) | [virtual, inherited] |
Solves the equation system based on the given rhs.
The solver needs to be initialized first with the matrix from the equation to solve, e.g. A from A*u=f (call solver::initialize(A) for example) This method is abstract. It has to be implemented by a class which inherits from this class.
rhs | The right hand side of A*u=f. |
solution | The solution from A*u=f. Mostly used as starting solution for an IterativeSolver. |
Reimplemented in lama::LUSolver, lama::DefaultJacobi, and lama::SpecializedJacobi.
References lama::Solver::getConstRuntime(), LAMA_REGION, lama::Solver::solveFinalize(), lama::Solver::solveImpl(), and lama::Solver::solveInit().
Referenced by cycle().
void lama::Solver::solveFinalize | ( | ) | [virtual, inherited] |
Finalizes the solving process.
Reimplemented in lama::DefaultJacobi, and lama::SpecializedJacobi.
Referenced by lama::Solver::solve().
void lama::IterativeSolver::solveImpl | ( | ) | [virtual, inherited] |
Solves the equation system.
Rhs and starting solution have to be initialized first! (call solveInit( rhs, solution ) ). The solver needs to be initialized first with the matrix from the equation to solve, e.g. A from A*u=f (call solver::initialize(A) for example)
This method solves the equation system by using the given rhs and solution. For most iterative solvers the solution-vector is used as a starting solution for the solve process. This class does not take responsibility for deleting the vectors after the solver! Make sure you do not delete the vectors during the solver process.
Implements lama::Solver.
References lama::IterativeSolver::criteriaAreSatisfied(), lama::IterativeSolver::getConstRuntime(), lama::Solver::getId(), lama::IterativeSolver::getRuntime(), lama::IterativeSolver::iterate(), LAMA_THROWEXCEPTION, lama::IterativeSolver::logEndSolve(), lama::IterativeSolver::logIterationEndAndResidual(), lama::IterativeSolver::logIterationStart(), lama::IterativeSolver::logStartSolve(), and lama::IterativeSolver::IterativeSolverRuntime::mIterations.
Referenced by lama::SpecializedJacobi::solve(), and lama::DefaultJacobi::solve().
void lama::Solver::solveInit | ( | Vector & | solution, |
const Vector & | rhs | ||
) | [virtual, inherited] |
Initializes the solver with rhs and solution.
[in] | rhs | The right hand side of the system of equations |
[out] | solution | The allocated memory and starting solution for the system |
Reimplemented in lama::DefaultJacobi, and lama::SpecializedJacobi.
References lama::Matrix::getColDistribution(), lama::Distributed::getDistribution(), lama::Matrix::getNumColumns(), lama::Matrix::getNumRows(), lama::Solver::getRuntime(), LAMA_THROWEXCEPTION, lama::Solver::SolverRuntime::mCoefficients, lama::Solver::SolverRuntime::mRhs, lama::Solver::SolverRuntime::mSolution, lama::Solver::SolverRuntime::mSolveInit, and lama::Vector::size().
Referenced by lama::Solver::solve().
void lama::Solver::writeAt | ( | std::ostream & | stream | ) | const [protected, virtual, inherited] |
Overrides Printable::writeAt with more useful stuff.
Reimplemented from Printable.
References lama::Solver::mId.
SolverPtr lama::SimpleAMG::mCoarseLevelSolver [protected] |
Referenced by initialize(), and setCoarseLevelSolver().
ContextPtr lama::Solver::mContext [protected, inherited] |
For forcing the context solver dependent.
If the context for a solver is set, the context of the input matrix will be ignored
Referenced by lama::SpecializedJacobi::iterateTyped(), lama::InverseSolver::setContext(), and lama::Solver::setContext().
CriterionPtr lama::IterativeSolver::mCriterionRootComponent [protected, inherited] |
The root stopping criterion evaluated every iteration in the solve method.
Referenced by lama::IterativeSolver::criteriaAreSatisfied(), lama::IterativeSolver::IterativeSolver(), and lama::IterativeSolver::setStoppingCriterion().
std::string lama::Solver::mId [protected, inherited] |
The ID of this solver.
Referenced by lama::Solver::getId(), lama::InverseSolver::InverseSolver(), lama::Solver::Solver(), lama::Solver::writeAt(), and lama::Solver::~Solver().
LoggerPtr lama::Solver::mLogger [protected, inherited] |
The solver logger.
May be the NullLogger if no logger has been specified.
Referenced by lama::Solver::getResidual(), lama::IterativeSolver::initialize(), lama::Solver::initialize(), lama::InverseSolver::logEndSolve(), lama::IterativeSolver::logEndSolve(), lama::IterativeSolver::logIterationEndAndResidual(), lama::IterativeSolver::logIterationStart(), logSetupDetails(), logSetupInfo(), logSetupSettings(), logSolverInfo(), lama::InverseSolver::logStartSolve(), lama::IterativeSolver::logStartSolve(), lama::MetaSolver::parseConfiguration(), lama::Solver::setLogger(), and lama::Solver::setLogLevel().
unsigned int lama::SimpleAMG::mMaxLevels [protected] |
Referenced by initialize(), logSetupSettings(), and setMaxLevels().
unsigned int lama::SimpleAMG::mMinVarsCoarseLevel [protected] |
Referenced by initialize(), logSetupSettings(), and setMinVarsCoarseLevel().
SolverPtr lama::IterativeSolver::mPreconditioner [protected, inherited] |
The preconditioner of this solver.
Referenced by lama::IterativeSolver::getPreconditioner(), lama::IterativeSolver::initialize(), lama::CG::iterate(), lama::GMRES::iterate(), lama::IterativeSolver::IterativeSolver(), and lama::IterativeSolver::setPreconditioner().
SimpleAMGRuntime lama::SimpleAMG::mSimpleAMGRuntime [protected] |
Referenced by getConstRuntime(), and getRuntime().
SolverPtr lama::SimpleAMG::mSmoother [protected] |
Referenced by initialize(), and setSmoother().
ContextPtr lama::SimpleAMG::mSmootherContext [protected] |
Referenced by initialize(), and setSmootherContext().