PlayaICCPreconditionerFactory.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 //   
00003 /* @HEADER@ */
00004 
00005 #ifndef PLAYA_ICCPRECONDITIONERFACTORY_HPP
00006 #define PLAYA_ICCPRECONDITIONERFACTORY_HPP
00007 
00008 #include "PlayaDefs.hpp"
00009 #include "PlayaPreconditionerFactoryBase.hpp"
00010 #include "PlayaLinearOperatorDecl.hpp"
00011 #include "Teuchos_ParameterList.hpp"
00012 #include "PlayaICCFactorizableOp.hpp"
00013 #include "PlayaLinearSolverBaseDecl.hpp"
00014 
00015 namespace Playa
00016 {
00017   using namespace Teuchos;
00018 
00019   /**
00020    * 
00021    */
00022   template <class Scalar>
00023   class ICCPreconditionerFactory
00024     : public PreconditionerFactoryBase<Scalar>
00025   {
00026   public:
00027     /** Construct with a parameter list */
00028     //const ParameterList& params inside
00029     ICCPreconditionerFactory():
00030       fillLevels_(1),
00031         overlapFill_(0),
00032         relaxationValue_(0.0),
00033         relativeThreshold_(1.0),
00034         absoluteThreshold_(0.0){;}
00035         
00036     ICCPreconditionerFactory(int fillLevels, int overlapFill, Scalar relaxationValue, Scalar relativeThreshold, Scalar absoluteThreshold)
00037     {
00038       fillLevels_=fillLevels;
00039       overlapFill_=overlapFill;
00040       relaxationValue_=relaxationValue;
00041       relativeThreshold_=relativeThreshold;
00042       absoluteThreshold_=absoluteThreshold;
00043     }
00044     /*{
00045       LinearSolverBase<Scalar>::template setParameter<int>(params, &fillLevels_, 
00046                                                   "Graph Fill");
00047 
00048       LinearSolverBase<Scalar>::template setParameter<int>(params, &overlapFill_, 
00049                                                   "Overlap");
00050 
00051       LinearSolverBase<Scalar>::template setParameter<double>(params, &relaxationValue_, 
00052                                                      "Relaxation");
00053 
00054       LinearSolverBase<Scalar>::template setParameter<double>(params, &absoluteThreshold_, 
00055                                                      "Absolute Threshold");
00056 
00057       LinearSolverBase<Scalar>::template setParameter<double>(params, &relativeThreshold_, 
00058                                                      "Relative Threshold");
00059     }*/
00060 
00061 
00062     /** virtual dtor */
00063     virtual ~ICCPreconditionerFactory(){;}
00064 
00065     
00066     /** */
00067     virtual Preconditioner <Scalar>
00068     createPreconditioner(const LinearOperator<Scalar>& A) const 
00069     {
00070       /* In order for ICC factorization to work, the operator A must
00071        * implement the ICCFactorizableOp interface. We cast A's pointer
00072        * to a ICCFactorizableOp ptr. If the cast fails, throw a spoke. */
00073       
00074       const ICCFactorizableOp<Scalar>* fop 
00075         = dynamic_cast<const ICCFactorizableOp<Scalar>*>(A.ptr().get());
00076 
00077       TEUCHOS_TEST_FOR_EXCEPTION(fop==0, std::runtime_error,
00078                          "ICCPreconditionerFactory attempted to "
00079                          "create an ICC preconditioner for an operator type "
00080                          "that does not implement the ICCFactorizableOp "
00081                          "interface. The op is " << A.description());
00082 
00083       
00084       /* Now we can delegate the construction of the ICC factors to 
00085       * the factorizable op. */
00086       Preconditioner<Scalar> P;
00087       fop->getICCPreconditioner(fillLevels_,
00088                                  overlapFill_,
00089                                  relaxationValue_,
00090                                  relativeThreshold_,
00091                                  absoluteThreshold_,
00092                                  P);
00093       /* Return the preconditioner */
00094       return P;
00095     }
00096 
00097     /* Handleable boilerplate */
00098     GET_RCP(PreconditionerFactoryBase<Scalar>);
00099   private:
00100 
00101     int fillLevels_;
00102     int overlapFill_;
00103     Scalar relaxationValue_;
00104     Scalar relativeThreshold_;
00105     Scalar absoluteThreshold_;
00106   };
00107 
00108 
00109 }
00110 
00111 #endif

Site Contact