48 #include "Teko_DiagonallyScaledPreconditionerFactory.hpp"
50 #include "Teko_PreconditionerInverseFactory.hpp"
56 : invFactory_(Teuchos::null), scalingType_(ROW_SCALING), diagonalType_(AbsRowSum)
63 ScalingType scalingType,DiagonalType diagonalType)
64 : invFactory_(invFactory), scalingType_(scalingType), diagonalType_(diagonalType)
78 using Teuchos::rcp_dynamic_cast;
79 Teko_DEBUG_SCOPE(
"DiagonallyScaledPreconditionerFactory::buildPreconditionerOperator",10);
81 TEUCHOS_TEST_FOR_EXCEPTION(invFactory_==Teuchos::null,std::runtime_error,
82 "ERROR: Teko::DiagonallyScaledPreconditionerFactory::buildPreconditionerOperator requires that an "
83 <<
"inverse factory has been set. Currently it is null!");
86 LinearOp invD = getInvDiagonalOp(lo,diagonalType_);
90 if(scalingType_==COLUMN_SCALING)
91 M = explicitMultiply(lo,invD,M);
93 M = explicitMultiply(invD,lo,M);
97 if(invM==Teuchos::null)
103 if(scalingType_==COLUMN_SCALING)
104 return multiply(invD,invM.getConst());
106 return multiply(invM.getConst(),invD);
114 TEUCHOS_TEST_FOR_EXCEPTION(not settings.isParameter(
"Inverse Factory"),std::runtime_error,
115 "Parameter \"Inverse Factory\" is required by a Teko::DiagonallyScaledPreconditionerFactory");
118 std::string invName = settings.get<std::string>(
"Inverse Factory");
122 invFactory_ = il->getInverseFactory(invName);
123 TEUCHOS_TEST_FOR_EXCEPTION(invFactory_==Teuchos::null,std::runtime_error,
124 "ERROR: \"Inverse Factory\" = " << invName
125 <<
" could not be found");
128 const std::string defaultScaleType =
"Row";
129 const std::string scalingTypeString =
"Scaling Type";
130 std::string scaleType = defaultScaleType;
131 if(settings.isParameter(scalingTypeString))
132 scaleType = settings.get<std::string>(scalingTypeString);
134 if(defaultScaleType==scaleType)
135 scalingType_ = ROW_SCALING;
137 scalingType_ = COLUMN_SCALING;
139 if(settings.isParameter(
"Diagonal Type"))
140 diagonalType_ = Teko::getDiagonalType(settings.get<std::string>(
"Diagonal Type"));
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
virtual LinearOp buildPreconditionerOperator(LinearOp &lo, PreconditionerState &state) const
Function that is called to build the preconditioner for the linear operator that is passed in...
virtual void initializeFromParameterList(const Teuchos::ParameterList &settings)
This function builds the internals of the preconditioner factory from a parameter list...
virtual ~DiagonallyScaledPreconditionerFactory()
default destructor: prints out diagnostic string
DiagonallyScaledPreconditionerFactory()
Default constructor, for use with the AutoClone class.
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 Teko::ModifiableLinearOp & getModifiableOp(const std::string &name)
Add a named operator to the state object.