10 #include "Teko_GaussSeidelPreconditionerFactory.hpp"
12 #include "Teko_BlockUpperTriInverseOp.hpp"
13 #include "Teko_BlockLowerTriInverseOp.hpp"
21 const LinearOp& invD0,
22 const LinearOp& invD1)
26 TriSolveType solveType,
const RCP<const BlockInvDiagonalStrategy>& strategy)
27 : invOpsStrategy_(strategy), solveType_(solveType) {}
30 : solveType_(GS_UseLowerTriangle) {}
34 int rows = blockRowCount(blo);
35 int cols = blockColCount(blo);
37 TEUCHOS_ASSERT(rows == cols);
40 std::vector<LinearOp> invDiag;
42 TEUCHOS_ASSERT(rows == (
int)invDiag.size());
44 if (solveType_ == GS_UseUpperTriangle) {
46 BlockedLinearOp U = getUpperTriBlocks(blo);
48 return createBlockUpperTriInverseOp(U, invDiag,
"Gauss Seidel");
49 }
else if (solveType_ == GS_UseLowerTriangle) {
51 BlockedLinearOp L = getLowerTriBlocks(blo);
53 return createBlockLowerTriInverseOp(L, invDiag,
"Gauss Seidel");
56 TEUCHOS_ASSERT(
false);
61 const Teuchos::ParameterList& pl) {
62 Teko_DEBUG_SCOPE(
"GaussSeidelPreconditionerFactory::initializeFromParameterList", 10);
63 Teko_DEBUG_MSG_BEGIN(9);
64 DEBUG_STREAM <<
"Parameter list: " << std::endl;
65 pl.print(DEBUG_STREAM);
68 const std::string inverse_type =
"Inverse Type";
69 const std::string preconditioner_type =
"Preconditioner Type";
70 std::vector<RCP<InverseFactory> > inverses;
71 std::vector<RCP<InverseFactory> > preconditioners;
76 std::string invStr =
"";
77 #if defined(Teko_ENABLE_Amesos)
79 #elif defined(Teko_ENABLE_Amesos2)
82 std::string precStr =
"None";
83 if (pl.isParameter(inverse_type)) invStr = pl.get<std::string>(inverse_type);
84 if (pl.isParameter(preconditioner_type)) precStr = pl.get<std::string>(preconditioner_type);
85 if (pl.isParameter(
"Use Upper Triangle"))
86 solveType_ = pl.get<
bool>(
"Use Upper Triangle") ? GS_UseUpperTriangle : GS_UseLowerTriangle;
88 Teko_DEBUG_MSG(
"GSPrecFact: Building default inverse \"" << invStr <<
"\"", 5);
89 RCP<InverseFactory> defaultInverse = invLib->getInverseFactory(invStr);
90 RCP<InverseFactory> defaultPrec;
91 if (precStr !=
"None") defaultPrec = invLib->getInverseFactory(precStr);
94 Teuchos::ParameterList::ConstIterator itr;
95 for (itr = pl.begin(); itr != pl.end(); ++itr) {
96 std::string fieldName = itr->first;
97 Teko_DEBUG_MSG(
"GSPrecFact: checking fieldName = \"" << fieldName <<
"\"", 9);
100 if (fieldName.compare(0, inverse_type.length(), inverse_type) == 0 &&
101 fieldName != inverse_type) {
103 std::string inverse, type;
106 std::stringstream ss(fieldName);
107 ss >> inverse >> type >> position;
110 Teko_DEBUG_MSG(
"Gauss-Seidel \"Inverse Type\" must be a (strictly) positive integer", 1);
114 std::string invStr2 = pl.get<std::string>(fieldName);
115 Teko_DEBUG_MSG(
"GSPrecFact: Building inverse " << position <<
" \"" << invStr2 <<
"\"", 5);
116 if (position > (
int)inverses.size()) {
117 inverses.resize(position, defaultInverse);
118 inverses[position - 1] = invLib->getInverseFactory(invStr2);
120 inverses[position - 1] = invLib->getInverseFactory(invStr2);
121 }
else if (fieldName.compare(0, preconditioner_type.length(), preconditioner_type) == 0 &&
122 fieldName != preconditioner_type) {
124 std::string preconditioner, type;
127 std::stringstream ss(fieldName);
128 ss >> preconditioner >> type >> position;
131 Teko_DEBUG_MSG(
"Gauss-Seidel \"Preconditioner Type\" must be a (strictly) positive integer",
136 std::string precStr2 = pl.get<std::string>(fieldName);
138 "GSPrecFact: Building preconditioner " << position <<
" \"" << precStr2 <<
"\"", 5);
139 if (position > (
int)preconditioners.size()) {
140 preconditioners.resize(position, defaultPrec);
141 preconditioners[position - 1] = invLib->getInverseFactory(precStr2);
143 preconditioners[position - 1] = invLib->getInverseFactory(precStr2);
148 if (inverses.size() == 0) inverses.push_back(defaultInverse);
An implementation of a state object for block preconditioners.
Teuchos::RCP< const BlockInvDiagonalStrategy > invOpsStrategy_
some members
LinearOp buildPreconditionerOperator(BlockedLinearOp &blo, BlockPreconditionerState &state) const
Create the Gauss-Seidel preconditioner operator.
GaussSeidelPreconditionerFactory()
Teuchos::RCP< const InverseLibrary > getInverseLibrary() const
Get the inverse library used by this preconditioner factory.
virtual void initializeFromParameterList(const Teuchos::ParameterList &pl)
Initialize from a parameter list.