11 #include "Teko_DiagonallyScaledPreconditionerFactory.hpp"
13 #include "Teko_PreconditionerInverseFactory.hpp"
19 : invFactory_(Teuchos::null), scalingType_(ROW_SCALING), diagonalType_(AbsRowSum) {}
25 const Teuchos::RCP<Teko::InverseFactory>& invFactory, ScalingType scalingType,
26 DiagonalType diagonalType)
27 : invFactory_(invFactory), scalingType_(scalingType), diagonalType_(diagonalType) {}
37 using Teuchos::rcp_dynamic_cast;
38 Teko_DEBUG_SCOPE(
"DiagonallyScaledPreconditionerFactory::buildPreconditionerOperator", 10);
40 TEUCHOS_TEST_FOR_EXCEPTION(
41 invFactory_ == Teuchos::null, std::runtime_error,
42 "ERROR: Teko::DiagonallyScaledPreconditionerFactory::buildPreconditionerOperator requires "
44 <<
"inverse factory has been set. Currently it is null!");
47 LinearOp invD = getInvDiagonalOp(lo, diagonalType_);
51 if (scalingType_ == COLUMN_SCALING)
52 M = explicitMultiply(lo, invD, M);
54 M = explicitMultiply(invD, lo, M);
58 if (invM == Teuchos::null)
64 if (scalingType_ == COLUMN_SCALING)
65 return multiply(invD, invM.getConst());
67 return multiply(invM.getConst(), invD);
74 const Teuchos::ParameterList& settings) {
75 TEUCHOS_TEST_FOR_EXCEPTION(
76 not settings.isParameter(
"Inverse Factory"), std::runtime_error,
77 "Parameter \"Inverse Factory\" is required by a Teko::DiagonallyScaledPreconditionerFactory");
80 std::string invName = settings.get<std::string>(
"Inverse Factory");
84 invFactory_ = il->getInverseFactory(invName);
85 TEUCHOS_TEST_FOR_EXCEPTION(invFactory_ == Teuchos::null, std::runtime_error,
86 "ERROR: \"Inverse Factory\" = " << invName <<
" could not be found");
89 const std::string defaultScaleType =
"Row";
90 const std::string scalingTypeString =
"Scaling Type";
91 std::string scaleType = defaultScaleType;
92 if (settings.isParameter(scalingTypeString))
93 scaleType = settings.get<std::string>(scalingTypeString);
95 if (defaultScaleType == scaleType)
96 scalingType_ = ROW_SCALING;
98 scalingType_ = COLUMN_SCALING;
100 if (settings.isParameter(
"Diagonal Type"))
101 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.