48 #include "Teko_IterativePreconditionerFactory.hpp"
50 #include "Teko_PreconditionerInverseFactory.hpp"
56 : correctionNum_(0), precFactory_(Teuchos::null)
63 const Teuchos::RCP<Teko::InverseFactory> & precFactory)
64 : correctionNum_(correctionNum), precFactory_(precFactory)
71 const Teuchos::RCP<Teko::PreconditionerFactory> & precFactory)
72 : correctionNum_(correctionNum)
74 precFactory_ = Teuchos::rcp(
new Teko::PreconditionerInverseFactory(precFactory,precFactory->getRequestHandler()));
83 TEUCHOS_TEST_FOR_EXCEPTION(precFactory_==Teuchos::null,std::runtime_error,
84 "ERROR: Teko::IterativePreconditionerFactory::buildPreconditionerOperator requires that a "
85 <<
"preconditioner factory has been set. Currently it is null!");
89 if(invP==Teuchos::null)
98 LinearOp I = Thyra::identity(lo->range(),
"I");
99 LinearOp AiP = multiply(lo,invP.getConst(),
"AiP");
100 LinearOp correction = add(I,scale(-1.0,AiP));
103 for(
unsigned int i=0;i<correctionNum_;i++)
104 resMap = add(I,multiply(resMap,correction));
107 return multiply(invP.getConst(),resMap);
117 if(settings.isParameter(
"Iteration Count"))
118 correctionNum_ = settings.get<
int>(
"Iteration Count");
120 TEUCHOS_TEST_FOR_EXCEPTION(not settings.isParameter(
"Preconditioner Type"),std::runtime_error,
121 "Parameter \"Preconditioner Type\" is required by a Teko::IterativePreconditionerFactory");
125 std::string precName = settings.get<std::string>(
"Preconditioner Type");
128 precFactory_ = il->getInverseFactory(precName);
129 TEUCHOS_TEST_FOR_EXCEPTION(precFactory_==Teuchos::null,std::runtime_error,
130 "ERROR: \"Preconditioner Type\" = " << precName
131 <<
" could not be found");
139 TEUCHOS_TEST_FOR_EXCEPTION(precFactory_==Teuchos::null,std::runtime_error,
140 "ERROR: Teko::IterativePreconditionerFactory::getRequestedParameters requires that a "
141 <<
"preconditioner factory has been set. Currently it is null!");
143 return precFactory_->getRequestedParameters();
150 TEUCHOS_TEST_FOR_EXCEPTION(precFactory_==Teuchos::null,std::runtime_error,
151 "ERROR: Teko::IterativePreconditionerFactory::updateRequestedParameters requires that a "
152 <<
"preconditioner factory has been set. Currently it is null!");
154 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.