Go to the documentation of this file.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 #ifndef TSFILUKPRECONDITIONERFACTORY_HPP
00030 #define TSFILUKPRECONDITIONERFACTORY_HPP
00031
00032 #include "SundanceDefs.hpp"
00033 #include "TSFPreconditionerFactoryBase.hpp"
00034 #include "TSFLinearOperatorDecl.hpp"
00035 #include "Teuchos_ParameterList.hpp"
00036 #include "TSFILUFactorizableOp.hpp"
00037 #include "TSFLinearSolverBaseDecl.hpp"
00038
00039 namespace TSFExtended
00040 {
00041 using namespace Teuchos;
00042
00043
00044
00045
00046 template <class Scalar>
00047 class ILUKPreconditionerFactory
00048 : public PreconditionerFactoryBase<Scalar>
00049 {
00050 public:
00051
00052 ILUKPreconditionerFactory(const ParameterList& params)
00053 : fillLevels_(1),
00054 overlapFill_(0),
00055 relaxationValue_(0.0),
00056 relativeThreshold_(1.0),
00057 absoluteThreshold_(0.0),
00058 leftOrRight_(Right)
00059 {
00060 LinearSolverBase<Scalar>::template setParameter<int>(params, &fillLevels_,
00061 "Graph Fill");
00062
00063 LinearSolverBase<Scalar>::template setParameter<int>(params, &overlapFill_,
00064 "Overlap");
00065
00066 LinearSolverBase<Scalar>::template setParameter<double>(params, &relaxationValue_,
00067 "Relaxation");
00068
00069 LinearSolverBase<Scalar>::template setParameter<double>(params, &absoluteThreshold_,
00070 "Absolute Threshold");
00071
00072 LinearSolverBase<Scalar>::template setParameter<double>(params, &relativeThreshold_,
00073 "Relative Threshold");
00074
00075 bool isLeft = false;
00076
00077 LinearSolverBase<Scalar>::template setParameter<bool>(params, &isLeft, "Left");
00078
00079 if (isLeft) leftOrRight_ = Left;
00080
00081 }
00082
00083
00084
00085 virtual ~ILUKPreconditionerFactory(){;}
00086
00087
00088
00089 virtual Preconditioner <Scalar>
00090 createPreconditioner(const LinearOperator<Scalar>& A) const
00091 {
00092
00093
00094
00095
00096 const ILUFactorizableOp<Scalar>* fop
00097 = dynamic_cast<const ILUFactorizableOp<Scalar>*>(A.ptr().get());
00098
00099 TEST_FOR_EXCEPTION(fop==0, std::runtime_error,
00100 "ILUKPreconditionerFactory attempted to "
00101 "create an ILU preconditioner for an operator type "
00102 "that does not implement the ILUFactorizableOp "
00103 "interface. The op is " << A.description());
00104
00105
00106
00107
00108 Preconditioner<Scalar> P;
00109 fop->getILUKPreconditioner(fillLevels_,
00110 overlapFill_,
00111 relaxationValue_,
00112 relativeThreshold_,
00113 absoluteThreshold_,
00114 leftOrRight_,
00115 P);
00116
00117 return P;
00118 }
00119
00120
00121 GET_RCP(PreconditionerFactoryBase<Scalar>);
00122 private:
00123
00124 int fillLevels_;
00125 int overlapFill_;
00126 Scalar relaxationValue_;
00127 Scalar relativeThreshold_;
00128 Scalar absoluteThreshold_;
00129 LeftOrRight leftOrRight_;
00130 };
00131
00132
00133 }
00134
00135 #endif