00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef __Teko_PreconditionerFactory_hpp__
00048 #define __Teko_PreconditionerFactory_hpp__
00049
00050 #include "Teuchos_ParameterListAcceptor.hpp"
00051
00052
00053 #include "Thyra_SolveSupportTypes.hpp"
00054 #include "Thyra_LinearOpSourceBase.hpp"
00055 #include "Thyra_PreconditionerFactoryBase.hpp"
00056 #include "Thyra_DefaultBlockedLinearOp.hpp"
00057 #include "Thyra_DefaultPreconditioner.hpp"
00058
00059
00060 #include "Teko_Utilities.hpp"
00061 #include "Teko_InverseLibrary.hpp"
00062 #include "Teko_CloneFactory.hpp"
00063 #include "Teko_PreconditionerState.hpp"
00064 #include "Teko_RequestHandler.hpp"
00065 #include "Teko_RequestHandlerContainer.hpp"
00066
00067 namespace Teko {
00068
00069 using Thyra::LinearOpBase;
00070 using Thyra::DefaultPreconditioner;
00071
00082 class PreconditionerFactory
00083 : public virtual Thyra::PreconditionerFactoryBase<double>, public RequestHandlerContainer
00084 {
00085 public:
00086
00100 virtual LinearOp buildPreconditionerOperator(LinearOp & lo,PreconditionerState & state) const = 0;
00101
00114 virtual Teuchos::RCP<PreconditionerState> buildPreconditionerState() const
00115 { return Teuchos::rcp(new PreconditionerState()); }
00116
00118
00119
00132 virtual void initializeFromParameterList(const Teuchos::ParameterList & settings)
00133 { }
00134
00149 virtual Teuchos::RCP<Teuchos::ParameterList> getRequestedParameters() const
00150 { return Teuchos::null; }
00151
00165 virtual bool updateRequestedParameters(const Teuchos::ParameterList & pl)
00166 { return true; }
00167
00169
00171 void setInverseLibrary(const Teuchos::RCP<const InverseLibrary> & il);
00172
00174 Teuchos::RCP<const InverseLibrary> getInverseLibrary() const;
00175
00177
00178
00180 bool isCompatible(const Thyra::LinearOpSourceBase<double> &fwdOpSrc) const;
00181
00183 Teuchos::RCP<Thyra::PreconditionerBase<double> > createPrec() const;
00184
00195 void initializePrec(const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > & fwdOpSrc,
00196 const Teuchos::RCP<const Thyra::MultiVectorBase<double> > & solnVec,
00197 Thyra::PreconditionerBase<double> * precOp,
00198 const Thyra::ESupportSolveUse supportSolveUse) const;
00199
00201 void initializePrec(const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > & fwdOpSrc,
00202 Thyra::PreconditionerBase<double> * precOp,
00203 const Thyra::ESupportSolveUse supportSolveUse) const;
00204
00206 void uninitializePrec(Thyra::PreconditionerBase<double> * prec,
00207 Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > * fwdOpSrc,
00208 Thyra::ESupportSolveUse *supportSolveUse) const;
00210
00212
00213
00215 void setParameterList(const Teuchos::RCP<Teuchos::ParameterList> & paramList);
00216
00218 Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList();
00219
00221 Teuchos::RCP< Teuchos::ParameterList > unsetParameterList();
00223
00225 void setRequestHandler(const Teuchos::RCP<RequestHandler> & rh)
00226 { callbackHandler_ = rh; }
00227
00229 Teuchos::RCP<RequestHandler> getRequestHandler() const
00230 { return callbackHandler_; }
00231
00232 protected:
00234 Teuchos::RCP<Teuchos::ParameterList> paramList_;
00235
00237 Teuchos::RCP<RequestHandler> callbackHandler_;
00238
00239 private:
00241 Teuchos::RCP<const InverseLibrary> inverseLibrary_;
00242
00244 static void setOpRequestHandler(const RequestHandlerContainer & rhc,const LinearOp & op);
00245
00246 public:
00247
00262 static Teuchos::RCP<PreconditionerFactory>
00263 buildPreconditionerFactory(const std::string & name,
00264 const Teuchos::ParameterList & settings,
00265 const Teuchos::RCP<const InverseLibrary> & invLib=Teuchos::null);
00266
00280 static void addPreconditionerFactory(const std::string & name,const Teuchos::RCP<Cloneable> & clone);
00281
00284 static void getPreconditionerFactoryNames(std::vector<std::string> & names);
00285
00286 private:
00287
00289 static CloneFactory<PreconditionerFactory> precFactoryBuilder_;
00290
00292 static void initializePrecFactoryBuilder();
00293 };
00294
00295 }
00296
00297 #endif