47 #include "Teko_PCDStrategy.hpp"
49 #include "Teuchos_TimeMonitor.hpp"
55 using Teuchos::TimeMonitor;
57 Teuchos::RCP<Teuchos::Time> PCDStrategy::initTimer_;
58 Teuchos::RCP<Teuchos::Time> PCDStrategy::invSTimer_;
59 Teuchos::RCP<Teuchos::Time> PCDStrategy::invFTimer_;
60 Teuchos::RCP<Teuchos::Time> PCDStrategy::opsTimer_;
63 if (initTimer_ == Teuchos::null)
64 initTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec");
66 if (invSTimer_ == Teuchos::null)
67 invSTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec invS");
69 if (invFTimer_ == Teuchos::null)
70 invFTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec invF");
72 if (opsTimer_ == Teuchos::null)
73 opsTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec buildOps");
77 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
78 lapParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
80 lapParams_->set(
"Name", getPressureLaplaceString());
88 const Teuchos::RCP<InverseFactory>& invS)
89 : invFactoryF_(invFA),
91 massInverseType_(Diagonal),
92 schurCompOrdering_(false) {
93 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
94 lapParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
96 lapParams_->set(
"Name", getPressureLaplaceString());
129 Teko_DEBUG_SCOPE(
"PCDStrategy::initializeState", 10);
132 std::string pcdStr = getPCDString();
133 std::string presLapStr = getPressureLaplaceString();
134 std::string presMassStr = getPressureMassString();
139 Teuchos::TimeMonitor timer(*initTimer_,
true);
142 LinearOp F = Teko::getBlock(0, 0, A);
143 LinearOp Bt = Teko::getBlock(0, 1, A);
144 LinearOp B = Teko::getBlock(1, 0, A);
145 LinearOp C = Teko::getBlock(1, 1, A);
148 TEUCHOS_ASSERT(Qp != Teuchos::null);
153 if (massInverseType_ == NotDiag) {
155 Teko_DEBUG_SCOPE(
"Building inv(Mass)", 10);
157 if (invMass == Teuchos::null)
165 "Building inverse mass of type \"" << Teko::getDiagonalName(massInverseType_) <<
"\"", 10);
166 iQp = getInvDiagonalOp(Qp, massInverseType_);
173 Teuchos::TimeMonitor timerInvS(*invSTimer_,
true);
177 TEUCHOS_ASSERT(laplace != Teuchos::null);
178 if (invLaplace == Teuchos::null)
187 Teko_DEBUG_SCOPE(
"Building S", 10);
188 Teuchos::TimeMonitor timerS(*opsTimer_,
true);
193 TEUCHOS_ASSERT(pcd != Teuchos::null);
194 LinearOp invL = invLaplace;
197 if (schurCompOrdering_ ==
false)
198 invS = multiply(iQp, pcd, invL);
200 invS = multiply(invL, pcd, iQp);
208 Teko_DEBUG_SCOPE(
"Building inv(F)", 10);
209 Teuchos::TimeMonitor timerInvF(*invFTimer_,
true);
212 if (invF == Teuchos::null)
234 const InverseLibrary& invLib) {
235 Teko_DEBUG_SCOPE(
"PCDStrategy::initializeFromParameterList", 10);
237 std::string invStr =
"", invFStr =
"", invSStr =
"";
238 #if defined(Teko_ENABLE_Amesos)
240 #elif defined(Teko_ENABLE_Amesos2)
244 massInverseType_ = Diagonal;
247 if (pl.isParameter(
"Inverse Type")) invStr = pl.get<std::string>(
"Inverse Type");
248 if (pl.isParameter(
"Inverse F Type")) invFStr = pl.get<std::string>(
"Inverse F Type");
249 if (pl.isParameter(
"Inverse Laplace Type")) invSStr = pl.get<std::string>(
"Inverse Laplace Type");
250 if (pl.isParameter(
"Inverse Mass Type")) {
251 std::string massInverseStr = pl.get<std::string>(
"Inverse Mass Type");
254 massInverseType_ = getDiagonalType(massInverseStr);
256 if (pl.isParameter(
"Flip Schur Complement Ordering"))
257 schurCompOrdering_ = pl.get<
bool>(
"Flip Schur Complement Ordering");
260 if (invFStr ==
"") invFStr = invStr;
261 if (invSStr ==
"") invSStr = invStr;
264 if (pl.isSublist(
"Pressure Laplace Parameters"))
266 Teuchos::rcp(
new Teuchos::ParameterList(pl.sublist(
"Pressure Laplace Parameters")));
268 lapParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
271 if (pl.isSublist(
"Pressure Convection Diffusion Parameters"))
273 new Teuchos::ParameterList(pl.sublist(
"Pressure Convection Diffusion Parameters")));
275 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
278 TEUCHOS_TEST_FOR_EXCEPTION(
279 lapParams_->isParameter(
"Name"), std::logic_error,
280 "Teko: Parameter \"Name\" is not allowed in the sublist \"" +
lapParams_->name() +
"\"");
281 TEUCHOS_TEST_FOR_EXCEPTION(
282 lapParams_->isParameter(
"Tag"), std::logic_error,
283 "Teko: Parameter \"Tag\" is not allowed in the sublist \"" +
lapParams_->name() +
"\"");
284 TEUCHOS_TEST_FOR_EXCEPTION(
285 pcdParams_->isParameter(
"Name"), std::logic_error,
286 "Teko: Parameter \"Name\" is not allowed in the sublist \"" +
pcdParams_->name() +
"\"");
287 TEUCHOS_TEST_FOR_EXCEPTION(
288 pcdParams_->isParameter(
"Tag"), std::logic_error,
289 "Teko: Parameter \"Tag\" is not allowed in the sublist \"" +
pcdParams_->name() +
"\"");
291 Teko_DEBUG_MSG_BEGIN(5) DEBUG_STREAM <<
"PCD Strategy Parameters: " << std::endl;
292 DEBUG_STREAM <<
" inv type = \"" << invStr <<
"\"" << std::endl;
293 DEBUG_STREAM <<
" inv F type = \"" << invFStr <<
"\"" << std::endl;
294 DEBUG_STREAM <<
" inv Laplace type = \"" << invSStr <<
"\"" << std::endl;
295 DEBUG_STREAM <<
" inv Mass type = \"" << Teko::getDiagonalName(massInverseType_) <<
"\""
297 DEBUG_STREAM <<
"PCD Strategy Parameter list: " << std::endl;
298 pl.print(DEBUG_STREAM);
302 invFactoryF_ = invLib.getInverseFactory(invFStr);
304 if (invFStr == invSStr)
305 invFactoryS_ = invFactoryF_;
307 invFactoryS_ = invLib.getInverseFactory(invSStr);
309 lapParams_->set(
"Name", getPressureLaplaceString());
322 TEUCHOS_ASSERT(
false);
324 return Teuchos::null;
329 TEUCHOS_ASSERT(
false);
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
virtual void initializeFromParameterList(const Teuchos::ParameterList &settings, const InverseLibrary &invLib)
This function builds the internals of the state from a parameter list.
virtual const Teko::LinearOp getHatInvA00(const Teko::BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual const Teko::LinearOp getTildeInvA00(const Teko::BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual void addLinearOp(const std::string &name, const Teko::LinearOp &lo)
Add a named operator to the state object.
static void buildTimers()
void initializeState(const Teko::BlockedLinearOp &A, BlockPreconditionerState &state) const
An implementation of a state object for block preconditioners.
Teuchos::RCP< RequestHandler > getRequestHandler() const
This method gets the request handler uses by this object.
virtual Teko::LinearOp getLinearOp(const std::string &name)
Add a named operator to the state object.
virtual bool isInitialized() const
PCDStrategy()
default Constructor
virtual bool updateRequestedParameters(const Teuchos::ParameterList &pl)
Update this object with the fields from a parameter list.
Teuchos::RCP< Teuchos::ParameterList > pcdParams_
Passed to application for construction of PCD operator.
virtual const Teko::LinearOp getInvS(const Teko::BlockedLinearOp &A, BlockPreconditionerState &state) const
InverseLinearOp buildInverse(const InverseFactory &factory, const LinearOp &A)
Build an inverse operator using a factory and a linear operator.
Teuchos::RCP< Teuchos::ParameterList > lapParams_
Passed to application for construction of laplace operator.
virtual void setInitialized(bool init=true)
virtual Teko::ModifiableLinearOp & getModifiableOp(const std::string &name)
Add a named operator to the state object.
virtual Teuchos::RCP< Teuchos::ParameterList > getRequestedParameters() const
Request the additional parameters this preconditioner factory needs.