48 #include "Teko_IterativePreconditionerFactory.hpp"
50 #include "Teko_PreconditionerInverseFactory.hpp"
56 : correctionNum_(0), precFactory_(Teuchos::null) {}
62 unsigned int correctionNum,
const Teuchos::RCP<Teko::InverseFactory>& precFactory)
63 : correctionNum_(correctionNum), precFactory_(precFactory) {}
69 unsigned int correctionNum,
const Teuchos::RCP<Teko::PreconditionerFactory>& precFactory)
70 : correctionNum_(correctionNum) {
71 precFactory_ = Teuchos::rcp(
72 new Teko::PreconditionerInverseFactory(precFactory, precFactory->getRequestHandler()));
80 TEUCHOS_TEST_FOR_EXCEPTION(
81 precFactory_ == Teuchos::null, std::runtime_error,
82 "ERROR: Teko::IterativePreconditionerFactory::buildPreconditionerOperator requires that a "
83 <<
"preconditioner factory has been set. Currently it is null!");
87 if (invP == Teuchos::null)
96 LinearOp I = Thyra::identity(lo->range(),
"I");
97 LinearOp AiP = multiply(lo, invP.getConst(),
"AiP");
98 LinearOp correction = add(I, scale(-1.0, AiP));
101 for (
unsigned int i = 0; i < correctionNum_; i++)
102 resMap = add(I, multiply(resMap, correction));
105 return multiply(invP.getConst(), resMap);
112 const Teuchos::ParameterList& settings) {
114 if (settings.isParameter(
"Iteration Count"))
115 correctionNum_ = settings.get<
int>(
"Iteration Count");
117 TEUCHOS_TEST_FOR_EXCEPTION(
118 not settings.isParameter(
"Preconditioner Type"), std::runtime_error,
119 "Parameter \"Preconditioner Type\" is required by a Teko::IterativePreconditionerFactory");
123 std::string precName = settings.get<std::string>(
"Preconditioner Type");
126 precFactory_ = il->getInverseFactory(precName);
127 TEUCHOS_TEST_FOR_EXCEPTION(
128 precFactory_ == Teuchos::null, std::runtime_error,
129 "ERROR: \"Preconditioner Type\" = " << precName <<
" could not be found");
137 TEUCHOS_TEST_FOR_EXCEPTION(
138 precFactory_ == Teuchos::null, std::runtime_error,
139 "ERROR: Teko::IterativePreconditionerFactory::getRequestedParameters requires that a "
140 <<
"preconditioner factory has been set. Currently it is null!");
142 return precFactory_->getRequestedParameters();
148 TEUCHOS_TEST_FOR_EXCEPTION(
149 precFactory_ == Teuchos::null, std::runtime_error,
150 "ERROR: Teko::IterativePreconditionerFactory::updateRequestedParameters requires that a "
151 <<
"preconditioner factory has been set. Currently it is null!");
153 return precFactory_->updateRequestedParameters(pl);
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
IterativePreconditionerFactory()
Default constructor, for use with the AutoClone class.
virtual Teuchos::RCP< Teuchos::ParameterList > getRequestedParameters() const
Request the additional parameters this preconditioner factory needs.
virtual void initializeFromParameterList(const Teuchos::ParameterList &settings)
This function builds the internals of the preconditioner factory from a parameter list...
virtual LinearOp buildPreconditionerOperator(LinearOp &lo, PreconditionerState &state) const
Function that is called to build the preconditioner for the linear operator that is passed in...
InverseLinearOp buildInverse(const InverseFactory &factory, const LinearOp &A)
Build an inverse operator using a factory and a linear operator.
Teuchos::RCP< const InverseLibrary > getInverseLibrary() const
Get the inverse library used by this preconditioner factory.
An implementation of a state object preconditioners.
virtual bool updateRequestedParameters(const Teuchos::ParameterList &pl)
Update this object with the fields from a parameter list.
virtual Teko::ModifiableLinearOp & getModifiableOp(const std::string &name)
Add a named operator to the state object.