LAMA
|
#include <SpecializedJacobi.hpp>
Data Structures | |
struct | SpecializedJacobiRuntime |
Public Member Functions | |
SpecializedJacobi (const std::string &id) | |
SpecializedJacobi (const std::string &id, Scalar omega) | |
SpecializedJacobi (const std::string &id, LoggerPtr logger) | |
SpecializedJacobi (const std::string &id, Scalar omega, LoggerPtr logger) | |
SpecializedJacobi (const SpecializedJacobi &other) | |
virtual | ~SpecializedJacobi () |
virtual void | initialize (const Matrix &coefficients) |
This abstract method is used by derived solvers to initialize a omega solver. | |
virtual void | solve (Vector &rhs, const Vector &solution) |
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. | |
void | iterate () |
This abstract method is used by derived solvers to represent a solver iteration. | |
virtual SpecializedJacobiRuntime & | getRuntime () |
Returns the complete configuration of the derived class. | |
virtual const SpecializedJacobiRuntime & | 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. | |
void | setOmega (const Scalar omega) |
Sets the omega parameter of this. | |
Scalar | getOmega () const |
Returns omega. | |
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. | |
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 | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
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 | |
SpecializedJacobiRuntime | mSpecializedJacobiRuntime |
Scalar | mOmega |
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 | |
template<typename ValueType > | |
void | iterateTyped (const SparseMatrix< ValueType > &) |
lama::SpecializedJacobi::SpecializedJacobi | ( | const std::string & | id | ) |
Referenced by copy().
lama::SpecializedJacobi::SpecializedJacobi | ( | const std::string & | id, |
Scalar | omega | ||
) |
lama::SpecializedJacobi::SpecializedJacobi | ( | const std::string & | id, |
LoggerPtr | logger | ||
) |
lama::SpecializedJacobi::SpecializedJacobi | ( | const std::string & | id, |
Scalar | omega, | ||
LoggerPtr | logger | ||
) |
lama::SpecializedJacobi::SpecializedJacobi | ( | const SpecializedJacobi & | other | ) |
lama::SpecializedJacobi::~SpecializedJacobi | ( | ) | [virtual] |
SolverPtr lama::SpecializedJacobi::copy | ( | ) | [virtual] |
Copies the status independent solver informations to create a new instance of the same type.
Implements lama::OmegaSolver.
References SpecializedJacobi().
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().
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 SpecializedJacobi::SpecializedJacobiRuntime & lama::SpecializedJacobi::getConstRuntime | ( | ) | const [virtual] |
Returns the complete const configuration of the derived class.
Implements lama::OmegaSolver.
References mSpecializedJacobiRuntime.
Referenced by iterate(), iterateTyped(), solve(), solveFinalize(), and solveInit().
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().
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().
Scalar lama::OmegaSolver::getOmega | ( | ) | const [inherited] |
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().
Returns the complete configuration of the derived class.
Implements lama::OmegaSolver.
References mSpecializedJacobiRuntime.
Referenced by initialize(), iterate(), iterateTyped(), solveFinalize(), and solveInit().
void lama::SpecializedJacobi::initialize | ( | const Matrix & | coefficients | ) | [virtual] |
This abstract method is used by derived solvers to initialize a omega solver.
Reimplemented from lama::OmegaSolver.
References lama::Vector::createVector(), getRuntime(), lama::Matrix::hasDiagonalProperty(), LAMA_ASSERT, and LAMA_THROWEXCEPTION.
void lama::SpecializedJacobi::iterate | ( | ) | [virtual] |
This abstract method is used by derived solvers to represent a solver iteration.
Implements lama::OmegaSolver.
References getConstRuntime(), getRuntime(), iterateTyped(), LAMA_REGION, and LAMA_THROWEXCEPTION.
void lama::SpecializedJacobi::iterateTyped | ( | const SparseMatrix< ValueType > & | coefficients | ) | [private] |
References lama::Matrix::ASYNCHRONOUS, lama::Communicator::exchangeByPlan(), lama::LAMAArrayUtils::gather(), lama::Matrix::getColDistribution(), lama::Matrix::getCommunicationKind(), lama::Distribution::getCommunicator(), lama::SolutionProxy::getConstReference(), getConstRuntime(), lama::ContextFactory::getContext(), lama::_MatrixStorage::getContextPtr(), lama::SparseMatrix< T >::getHalo(), lama::Halo::getHaloSize(), lama::SparseMatrix< T >::getHaloStorage(), lama::DenseVector< T >::getHaloValues(), lama::SparseMatrix< T >::getLocalStorage(), lama::DenseVector< T >::getLocalValues(), lama::Matrix::getNumRows(), lama::Halo::getProvidesIndexes(), lama::Halo::getProvidesPlan(), lama::Halo::getRequiredPlan(), getRuntime(), lama::Scalar::getValue(), lama::Context::Host, lama::Halo::isEmpty(), lama::MatrixStorage< T >::jacobiIterate(), lama::MatrixStorage< T >::jacobiIterateAsync(), lama::MatrixStorage< T >::jacobiIterateHalo(), LAMA_REGION, LAMA_THROWEXCEPTION, lama::Solver::mContext, lama::OmegaSolver::mOmega, lama::SpecializedJacobi::SpecializedJacobiRuntime::mProxyOldSolution, lama::SparseMatrix< T >::mTempSendValues, lama::_MatrixStorage::prefetch(), lama::LAMAArray< T >::prefetch(), lama::_LAMAArray::size(), and lama::Matrix::SYNCHRONOUS.
Referenced by iterate().
lama::OmegaSolver::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [protected, inherited] |
Reimplemented from lama::IterativeSolver.
Reimplemented in lama::DefaultJacobi, and lama::SOR.
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::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::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::Solver::setLogger | ( | LoggerPtr | logger | ) | [inherited] |
Redefines mLogger.
References lama::Solver::mLogger.
void lama::Solver::setLogLevel | ( | LogLevel::LogLevel | level | ) | [inherited] |
void lama::OmegaSolver::setOmega | ( | const Scalar | omega | ) | [inherited] |
Sets the omega parameter of this.
[in] | omega | The omega parameter of the omega solver. |
References lama::OmegaSolver::mOmega.
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::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::SpecializedJacobi::solve | ( | Vector & | solution, |
const Vector & | rhs | ||
) | [virtual] |
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 from lama::Solver.
References getConstRuntime(), solveFinalize(), lama::IterativeSolver::solveImpl(), and solveInit().
void lama::SpecializedJacobi::solveFinalize | ( | ) | [virtual] |
Finalizes the solving process.
Reimplemented from lama::Solver.
References getConstRuntime(), getRuntime(), and lama::SpecializedJacobi::SpecializedJacobiRuntime::mProxyOldSolution.
Referenced by 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 solve(), and lama::DefaultJacobi::solve().
void lama::SpecializedJacobi::solveInit | ( | Vector & | solution, |
const Vector & | rhs | ||
) | [virtual] |
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 from lama::Solver.
References lama::Vector::create(), getConstRuntime(), getRuntime(), LAMA_THROWEXCEPTION, lama::SpecializedJacobi::SpecializedJacobiRuntime::mOldSolution, and lama::SpecializedJacobi::SpecializedJacobiRuntime::mProxyOldSolution.
Referenced by 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.
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 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(), lama::SimpleAMG::logSetupDetails(), lama::SimpleAMG::logSetupInfo(), lama::SimpleAMG::logSetupSettings(), lama::SimpleAMG::logSolverInfo(), lama::InverseSolver::logStartSolve(), lama::IterativeSolver::logStartSolve(), lama::MetaSolver::parseConfiguration(), lama::Solver::setLogger(), and lama::Solver::setLogLevel().
Scalar lama::OmegaSolver::mOmega [protected, inherited] |
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().
Referenced by getConstRuntime(), and getRuntime().