47 #include "Teko_BlockInvDiagonalStrategy.hpp"
51 InvFactoryDiagStrategy::InvFactoryDiagStrategy(
const Teuchos::RCP<InverseFactory> & factory)
54 invDiagFact_.resize(1,factory);
55 defaultInvFact_ = factory;
58 InvFactoryDiagStrategy::InvFactoryDiagStrategy(
const std::vector<Teuchos::RCP<InverseFactory> > & factories,
59 const Teuchos::RCP<InverseFactory> & defaultFact)
61 invDiagFact_ = factories;
63 if(defaultFact==Teuchos::null)
64 defaultInvFact_ = invDiagFact_[0];
66 defaultInvFact_ = defaultFact;
74 Teko_DEBUG_SCOPE(
"InvFactoryDiagStrategy::getInvD",10);
77 int diagCnt = A->productRange()->numBlocks();
78 int invCnt = invDiagFact_.size();
80 Teko_DEBUG_MSG(
"# diags = " << diagCnt <<
", # inverses = " << invCnt,6);
82 const std::string opPrefix =
"JacobiDiagOp";
84 for(
int i=0;i<diagCnt;i++)
85 invDiag.push_back(
buildInverse(*invDiagFact_[i],getBlock(i,i,A),state,opPrefix,i));
88 for(
int i=0;i<invCnt;i++)
89 invDiag.push_back(
buildInverse(*invDiagFact_[i],getBlock(i,i,A),state,opPrefix,i));
91 for(
int i=invCnt;i<diagCnt;i++)
92 invDiag.push_back(
buildInverse(*defaultInvFact_,getBlock(i,i,A),state,opPrefix,i));
98 const std::string & opPrefix,
int i)
const
100 std::stringstream ss;
101 ss << opPrefix <<
"_" << i;
104 if(invOp==Teuchos::null)
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
Abstract class for building an inverse operator.
virtual void getInvD(const BlockedLinearOp &A, BlockPreconditionerState &state, std::vector< LinearOp > &invDiag) const
LinearOp buildInverse(const InverseFactory &invFact, const LinearOp &matrix, BlockPreconditionerState &state, const std::string &opPrefix, int i) const
Conveinence function for building inverse operators.
An implementation of a state object for block preconditioners.
InverseLinearOp buildInverse(const InverseFactory &factory, const LinearOp &A)
Build an inverse operator using a factory and a linear operator.
virtual Teko::ModifiableLinearOp & getModifiableOp(const std::string &name)
Add a named operator to the state object.