61 Teko_DEBUG_SCOPE(
"LSCPreconditionerFactory::buildPreconditionerOperator", 10);
62 Teko_DEBUG_EXPR(Teuchos::Time timer(
""));
63 Teko_DEBUG_EXPR(Teuchos::Time totalTimer(
""));
64 Teko_DEBUG_EXPR(totalTimer.start());
67 LinearOp F = blockOp->getBlock(0, 0);
68 LinearOp B = blockOp->getBlock(1, 0);
69 LinearOp Bt = blockOp->getBlock(0, 1);
74 Teko_DEBUG_EXPR(timer.start(
true));
75 invOpsStrategy_->buildState(blockOp, state);
76 Teko_DEBUG_EXPR(timer.stop());
77 Teko_DEBUG_MSG(
"LSCPrecFact::buildPO BuildStateTime = " << timer.totalElapsedTime(), 2);
80 Teko_DEBUG_EXPR(timer.start(
true));
81 LinearOp invF = invOpsStrategy_->getInvF(blockOp, state);
82 LinearOp invBQBtmC = invOpsStrategy_->getInvBQBt(blockOp, state);
83 LinearOp invBHBtmC = invOpsStrategy_->getInvBHBt(blockOp, state);
84 LinearOp outerStab = invOpsStrategy_->getOuterStabilization(blockOp, state);
85 LinearOp innerStab = invOpsStrategy_->getInnerStabilization(blockOp, state);
88 LinearOp invMass = invOpsStrategy_->getInvMass(blockOp, state);
89 LinearOp HScaling = invOpsStrategy_->getHScaling(blockOp, state);
90 if (invMass == Teuchos::null) invMass = identity<double>(F->range());
91 if (HScaling == Teuchos::null) HScaling = identity<double>(F->range());
92 Teko_DEBUG_EXPR(timer.stop());
93 Teko_DEBUG_MSG(
"LSCPrecFact::buildPO GetInvTime = " << timer.totalElapsedTime(), 2);
100 multiply(multiply(B, invMass), F, multiply(HScaling, Bt));
101 if (innerStab != Teuchos::null)
102 M = add(M, innerStab);
106 if (outerStab != Teuchos::null)
107 invPschur = add(multiply(invBQBtmC, M, invBHBtmC), outerStab);
109 invPschur = multiply(invBQBtmC, M, invBHBtmC);
112 if (invOpsStrategy_->useFullLDU()) {
113 Teko_DEBUG_EXPR(totalTimer.stop());
114 Teko_DEBUG_MSG(
"LSCPrecFact::buildPO TotalTime = " << totalTimer.totalElapsedTime(), 2);
117 return createLU2x2InverseOp(blockOp, invF, invPschur,
"LSC-LDU");
120 std::vector<LinearOp> invDiag(2);
122 invDiag[1] = Thyra::scale(-1.0, invPschur);
125 BlockedLinearOp U = getUpperTriBlocks(blockOp);
127 Teko_DEBUG_EXPR(totalTimer.stop());
128 Teko_DEBUG_MSG(
"LSCPrecFact::buildPO TotalTime = " << totalTimer.totalElapsedTime(), 2);
131 return createBlockUpperTriInverseOp(U, invDiag,
"LSC-Upper");
137 Teko_DEBUG_SCOPE(
"LSCPreconditionerFactory::initializeFromParameterList", 10);
141 if (pl.isParameter(
"Is Symmetric")) isSymmetric_ = pl.get<
bool>(
"Is Symmetric");
143 std::string name =
"Basic Inverse";
144 if (pl.isParameter(
"Strategy Name")) name = pl.get<std::string>(
"Strategy Name");
145 const Teuchos::ParameterEntry* pe = pl.getEntryPtr(
"Strategy Settings");
148 if (name !=
"Basic Inverse" && pe == 0) {
149 RCP<Teuchos::FancyOStream> out = getOutputStream();
150 *out <<
"LSC Construction failed: ";
151 *out <<
"Strategy \"" << name <<
"\" requires a \"Strategy Settings\" sublist" << std::endl;
152 throw std::runtime_error(
"LSC Construction failed: Strategy Settings not set");
156 Teuchos::RCP<const Teuchos::ParameterList> stratPL = Teuchos::rcpFromRef(pl);
157 if (pe != 0) stratPL = Teuchos::rcpFromRef(pl.sublist(
"Strategy Settings"));
163 if (strategy == Teuchos::null) {
164 RCP<Teuchos::FancyOStream> out = getOutputStream();
165 *out <<
"LSC Construction failed: ";
166 *out <<
"Strategy \"" << name <<
"\" could not be constructed" << std::endl;
167 throw std::runtime_error(
"LSC Construction failed: Strategy could not be constructed");
170 strategy->setSymmetric(isSymmetric_);
171 invOpsStrategy_ = strategy;
204 const Teuchos::ParameterList& settings,
205 const RCP<const InverseLibrary>& invLib,
206 const RCP<RequestHandler>& rh) {
207 Teko_DEBUG_SCOPE(
"LSCPreconditionerFactory::buildStrategy", 10);
210 if (strategyBuilder_.cloneCount() == 0) initializeStrategyBuilder();
213 Teko_DEBUG_MSG(
"Building LSC strategy \"" << name <<
"\"", 1);
214 RCP<LSCStrategy> strategy = strategyBuilder_.build(name);
216 if (strategy == Teuchos::null)
return Teuchos::null;
220 strategy->setRequestHandler(rh);
221 strategy->initializeFromParameterList(settings, *invLib);