47 #include "Teko_JacobiPreconditionerFactory.hpp"
58 : invOpsStrategy_(strategy)
68 int rows = blo->productRange()->numBlocks();
69 int cols = blo->productDomain()->numBlocks();
71 TEUCHOS_ASSERT(rows==cols);
74 std::vector<LinearOp> invDiag;
76 TEUCHOS_ASSERT(rows==(
int) invDiag.size());
79 BlockedLinearOp precond = createBlockedOp();
81 ss <<
"Jacobi Preconditioner ( ";
84 beginBlockFill(precond,rows,rows);
87 for(
int i=0;i<rows;i++) {
88 ss <<
" op" << i <<
" = " << invDiag[i]->description() <<
", ";
89 precond->setBlock(i,i,invDiag[i]);
93 endBlockFill(precond);
97 precond->setObjectLabel(
"Jacobi");
106 RCP<const InverseLibrary> invLib = getInverseLibrary();
109 std::string invStr = pl.get<std::string>(
"Inverse Type");
110 if(invStr==
"") invStr =
"Amesos";
117 Teko_DEBUG_SCOPE(
"JacobiPreconditionerFactory::initializeFromParameterList",10);
118 Teko_DEBUG_MSG_BEGIN(9);
119 DEBUG_STREAM <<
"Parameter list: " << std::endl;
120 pl.print(DEBUG_STREAM);
121 Teko_DEBUG_MSG_END();
123 const std::string inverse_type =
"Inverse Type";
124 std::vector<RCP<InverseFactory> > inverses;
126 RCP<const InverseLibrary> invLib = getInverseLibrary();
129 std::string invStr =
"Amesos";
130 if(pl.isParameter(inverse_type))
131 invStr = pl.get<std::string>(inverse_type);
133 Teko_DEBUG_MSG(
"JacobiPrecFact: Building default inverse \"" << invStr <<
"\"",5);
134 RCP<InverseFactory> defaultInverse = invLib->getInverseFactory(invStr);
137 Teuchos::ParameterList::ConstIterator itr;
138 for(itr=pl.begin();itr!=pl.end();++itr) {
139 std::string fieldName = itr->first;
140 Teko_DEBUG_MSG(
"JacobiPrecFact: checking fieldName = \"" << fieldName <<
"\"",9);
143 if(fieldName.compare(0,inverse_type.length(),inverse_type)==0 && fieldName!=inverse_type) {
145 std::string inverse,type;
148 std::stringstream ss(fieldName);
149 ss >> inverse >> type >> position;
152 Teko_DEBUG_MSG(
"Jacobi \"Inverse Type\" must be a (strictly) positive integer",1);
156 std::string invStr = pl.get<std::string>(fieldName);
157 Teko_DEBUG_MSG(
"JacobiPrecFact: Building inverse " << position <<
" \"" << invStr <<
"\"",5);
158 if(position>(
int) inverses.size()) {
159 inverses.resize(position,defaultInverse);
160 inverses[position-1] = invLib->getInverseFactory(invStr);
163 inverses[position-1] = invLib->getInverseFactory(invStr);
168 if(inverses.size()==0)
169 inverses.push_back(defaultInverse);
172 invOpsStrategy_ = rcp(
new InvFactoryDiagStrategy(inverses,defaultInverse));
JacobiPreconditionerFactory()
An implementation of a state object for block preconditioners.
Teuchos::RCP< const BlockInvDiagonalStrategy > invOpsStrategy_
some members
virtual void initializeFromParameterList(const Teuchos::ParameterList &pl)
Initialize from a parameter list.
LinearOp buildPreconditionerOperator(BlockedLinearOp &blo, BlockPreconditionerState &state) const
Create the Jacobi preconditioner operator.