11 #include "Teko_IterativePreconditionerFactory.hpp"
13 #include "Teko_PreconditionerInverseFactory.hpp"
19 : correctionNum_(0), precFactory_(Teuchos::null) {}
25 unsigned int correctionNum,
const Teuchos::RCP<Teko::InverseFactory>& precFactory)
26 : correctionNum_(correctionNum), precFactory_(precFactory) {}
32 unsigned int correctionNum,
const Teuchos::RCP<Teko::PreconditionerFactory>& precFactory)
33 : correctionNum_(correctionNum) {
34 precFactory_ = Teuchos::rcp(
35 new Teko::PreconditionerInverseFactory(precFactory, precFactory->getRequestHandler()));
43 TEUCHOS_TEST_FOR_EXCEPTION(
44 precFactory_ == Teuchos::null, std::runtime_error,
45 "ERROR: Teko::IterativePreconditionerFactory::buildPreconditionerOperator requires that a "
46 <<
"preconditioner factory has been set. Currently it is null!");
50 if (invP == Teuchos::null)
59 LinearOp I = Thyra::identity(lo->range(),
"I");
60 LinearOp AiP = multiply(lo, invP.getConst(),
"AiP");
61 LinearOp correction = add(I, scale(-1.0, AiP));
64 for (
unsigned int i = 0; i < correctionNum_; i++)
65 resMap = add(I, multiply(resMap, correction));
68 return multiply(invP.getConst(), resMap);
75 const Teuchos::ParameterList& settings) {
77 if (settings.isParameter(
"Iteration Count"))
78 correctionNum_ = settings.get<
int>(
"Iteration Count");
80 TEUCHOS_TEST_FOR_EXCEPTION(
81 not settings.isParameter(
"Preconditioner Type"), std::runtime_error,
82 "Parameter \"Preconditioner Type\" is required by a Teko::IterativePreconditionerFactory");
86 std::string precName = settings.get<std::string>(
"Preconditioner Type");
89 precFactory_ = il->getInverseFactory(precName);
90 TEUCHOS_TEST_FOR_EXCEPTION(
91 precFactory_ == Teuchos::null, std::runtime_error,
92 "ERROR: \"Preconditioner Type\" = " << precName <<
" could not be found");
100 TEUCHOS_TEST_FOR_EXCEPTION(
101 precFactory_ == Teuchos::null, std::runtime_error,
102 "ERROR: Teko::IterativePreconditionerFactory::getRequestedParameters requires that a "
103 <<
"preconditioner factory has been set. Currently it is null!");
105 return precFactory_->getRequestedParameters();
111 TEUCHOS_TEST_FOR_EXCEPTION(
112 precFactory_ == Teuchos::null, std::runtime_error,
113 "ERROR: Teko::IterativePreconditionerFactory::updateRequestedParameters requires that a "
114 <<
"preconditioner factory has been set. Currently it is null!");
116 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.