47 #include "Teko_Config.h"
48 #include "Teko_PreconditionerFactory.hpp"
50 #include "Teko_InverseLibrary.hpp"
51 #include "Teko_Preconditioner.hpp"
54 #include "Teko_JacobiPreconditionerFactory.hpp"
55 #include "Teko_GaussSeidelPreconditionerFactory.hpp"
56 #include "Teko_AddPreconditionerFactory.hpp"
57 #include "Teko_MultPreconditionerFactory.hpp"
58 #include "Teko_LU2x2PreconditionerFactory.hpp"
59 #include "Teko_IterativePreconditionerFactory.hpp"
60 #include "Teko_DiagnosticPreconditionerFactory.hpp"
61 #include "Teko_DiagonallyScaledPreconditionerFactory.hpp"
62 #include "Teko_DiagonalPreconditionerFactory.hpp"
63 #include "Teko_ProbingPreconditionerFactory.hpp"
64 #include "Teko_IdentityPreconditionerFactory.hpp"
65 #include "NS/Teko_LSCPreconditionerFactory.hpp"
66 #include "NS/Teko_SIMPLEPreconditionerFactory.hpp"
67 #include "NS/Teko_TimingsSIMPLEPreconditionerFactory.hpp"
69 #ifdef Teko_ENABLE_ML_SMOOTHERS
70 #include "Teko_SmootherPreconditionerFactory.hpp"
71 #include "Teko_MLPreconditionerFactory.hpp"
75 #include "Thyra_DefaultPreconditioner.hpp"
77 using namespace Thyra;
84 bool PreconditionerFactory::isCompatible(
const Thyra::LinearOpSourceBase<double> &fwdOpSrc)
const
86 RCP<const Thyra::LinearOpBase<double> > A = fwdOpSrc.getOp();
87 return A!=Teuchos::null;
91 RCP<Thyra::PreconditionerBase<double> > PreconditionerFactory::createPrec()
const
95 bp->setStateObject(buildPreconditionerState());
96 bp->getStateObject()->setInitialized(
false);
102 void PreconditionerFactory::initializePrec(
const RCP<
const LinearOpSourceBase<double> > & ASrc,
103 PreconditionerBase<double> * prec,
104 const ESupportSolveUse )
const
107 LinearOp A = Teuchos::rcp_const_cast<Thyra::LinearOpBase<double> >(ASrc->getOp());
110 TEUCHOS_ASSERT(blkPrec!=0);
113 RCP<PreconditionerState> state = blkPrec->getStateObject();
114 state->setInitialized(
false);
117 const RCP<const LinearOpBase<double> > M = buildPreconditionerOperator(A,*state);
120 setOpRequestHandler(*
this,M);
123 DefaultPreconditioner<double> & dPrec = Teuchos::dyn_cast<DefaultPreconditioner<double> >(*prec);
124 dPrec.initializeUnspecified(Teuchos::rcp_const_cast<LinearOpBase<double> >(M));
128 void PreconditionerFactory::initializePrec(
const RCP<
const LinearOpSourceBase<double> > & ASrc,
129 const RCP<
const Thyra::MultiVectorBase<double> > & solnVec,
130 PreconditionerBase<double> * prec,
131 const ESupportSolveUse supportSolveUse)
const
133 Preconditioner * blkPrec =
dynamic_cast<Preconditioner *
>(prec);
134 blkPrec->setSourceVector(Teuchos::rcp_const_cast<Thyra::MultiVectorBase<double> >(solnVec));
136 initializePrec(ASrc,prec,supportSolveUse);
140 void PreconditionerFactory::uninitializePrec(PreconditionerBase<double> * ,
141 RCP<
const LinearOpSourceBase<double> > * ,
142 ESupportSolveUse * )
const
147 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"\"PreconditionerFactory::uninitializePrec not implemented\"");
154 void PreconditionerFactory::setParameterList(
const RCP<Teuchos::ParameterList> & paramList)
156 paramList_ = paramList;
160 RCP< Teuchos::ParameterList > PreconditionerFactory::getNonconstParameterList()
166 RCP< Teuchos::ParameterList > PreconditionerFactory::unsetParameterList()
168 RCP<Teuchos::ParameterList> _paramList = paramList_;
169 paramList_ = Teuchos::null;
174 void PreconditionerFactory::setInverseLibrary(
const RCP<const InverseLibrary> & il)
176 inverseLibrary_ = il;
180 RCP<const InverseLibrary> PreconditionerFactory::getInverseLibrary()
const
183 if(inverseLibrary_==Teuchos::null)
184 return InverseLibrary::buildFromStratimikos();
186 return inverseLibrary_;
196 ModifiableLinearOp mlo = Teuchos::rcp_const_cast<Thyra::LinearOpBase<double> >(op);
200 if(reqHandCont!=Teuchos::null) {
210 CloneFactory<PreconditionerFactory> PreconditionerFactory::precFactoryBuilder_;
226 RCP<PreconditionerFactory>
227 PreconditionerFactory::buildPreconditionerFactory(
const std::string & name,
228 const Teuchos::ParameterList & settings,
229 const RCP<const InverseLibrary> & invLib)
231 Teko_DEBUG_SCOPE(
"PreconditionerFactory::buildPreconditionerFactory",10);
234 if(precFactoryBuilder_.cloneCount()==0) initializePrecFactoryBuilder();
237 RCP<PreconditionerFactory> precFact = precFactoryBuilder_.build(name);
239 Teko_DEBUG_MSG_BEGIN(5);
240 DEBUG_STREAM <<
"Looked up \"" << name <<
"\"" << std::endl;
241 DEBUG_STREAM <<
"Built " << precFact << std::endl;
242 Teko_DEBUG_MSG_END();
244 if(precFact==Teuchos::null)
245 return Teuchos::null;
248 if(invLib!=Teuchos::null) {
249 precFact->setInverseLibrary(invLib);
250 precFact->setRequestHandler(invLib->getRequestHandler());
255 precFact->initializeFromParameterList(settings);
273 void PreconditionerFactory::addPreconditionerFactory(
const std::string & name,
const RCP<Cloneable> & clone)
276 if(precFactoryBuilder_.cloneCount()==0) initializePrecFactoryBuilder();
279 precFactoryBuilder_.addClone(name,clone);
283 void PreconditionerFactory::initializePrecFactoryBuilder()
285 RCP<Cloneable> clone;
289 precFactoryBuilder_.addClone(
"Block LU2x2",clone);
292 precFactoryBuilder_.addClone(
"Block Jacobi",clone);
295 precFactoryBuilder_.addClone(
"Block Gauss-Seidel",clone);
298 precFactoryBuilder_.addClone(
"Block Add",clone);
301 precFactoryBuilder_.addClone(
"Block Multiply",clone);
304 precFactoryBuilder_.addClone(
"NS LSC",clone);
307 precFactoryBuilder_.addClone(
"NS SIMPLE",clone);
310 precFactoryBuilder_.addClone(
"NS SIMPLE-Timed",clone);
313 precFactoryBuilder_.addClone(
"Iterative Preconditioner",clone);
316 precFactoryBuilder_.addClone(
"Explicit Diagonal Preconditioner",clone);
319 precFactoryBuilder_.addClone(
"Diagnostic Inverse",clone);
322 precFactoryBuilder_.addClone(
"Diagonal Scaling",clone);
325 precFactoryBuilder_.addClone(
"Identity",clone);
327 #ifdef Teko_ENABLE_Isorropia
329 precFactoryBuilder_.addClone(
"Probing Preconditioner",clone);
332 #ifdef Teko_ENABLE_ML_SMOOTHERS
334 precFactoryBuilder_.addClone(
"Blocked ML Preconditioner",clone);
338 void PreconditionerFactory::getPreconditionerFactoryNames(std::vector<std::string> & names)
341 if(precFactoryBuilder_.cloneCount()==0) initializePrecFactoryBuilder();
342 precFactoryBuilder_.getCloneNames(names);
virtual void setRequestHandler(const Teuchos::RCP< RequestHandler > &rh)=0
Set the request handler with pointers to the appropriate callbacks.
An extension of the Thyra::DefaultPreconditioner class with some specializations useful for use withi...
virtual Teuchos::RCP< RequestHandler > getRequestHandler() const =0
Get the request handler with pointers to the appropriate callbacks.