10 #include "Teko_PCDStrategy.hpp"
12 #include "Teuchos_TimeMonitor.hpp"
18 using Teuchos::TimeMonitor;
20 Teuchos::RCP<Teuchos::Time> PCDStrategy::initTimer_;
21 Teuchos::RCP<Teuchos::Time> PCDStrategy::invSTimer_;
22 Teuchos::RCP<Teuchos::Time> PCDStrategy::invFTimer_;
23 Teuchos::RCP<Teuchos::Time> PCDStrategy::opsTimer_;
26 if (initTimer_ == Teuchos::null)
27 initTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec");
29 if (invSTimer_ == Teuchos::null)
30 invSTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec invS");
32 if (invFTimer_ == Teuchos::null)
33 invFTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec invF");
35 if (opsTimer_ == Teuchos::null)
36 opsTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec buildOps");
40 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
41 lapParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
43 lapParams_->set(
"Name", getPressureLaplaceString());
51 const Teuchos::RCP<InverseFactory>& invS)
52 : invFactoryF_(invFA),
54 massInverseType_(Diagonal),
55 schurCompOrdering_(false) {
56 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
57 lapParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
59 lapParams_->set(
"Name", getPressureLaplaceString());
92 Teko_DEBUG_SCOPE(
"PCDStrategy::initializeState", 10);
95 std::string pcdStr = getPCDString();
96 std::string presLapStr = getPressureLaplaceString();
97 std::string presMassStr = getPressureMassString();
102 Teuchos::TimeMonitor timer(*initTimer_,
true);
105 LinearOp F = Teko::getBlock(0, 0, A);
106 LinearOp Bt = Teko::getBlock(0, 1, A);
107 LinearOp B = Teko::getBlock(1, 0, A);
108 LinearOp C = Teko::getBlock(1, 1, A);
111 TEUCHOS_ASSERT(Qp != Teuchos::null);
116 if (massInverseType_ == NotDiag) {
118 Teko_DEBUG_SCOPE(
"Building inv(Mass)", 10);
120 if (invMass == Teuchos::null)
128 "Building inverse mass of type \"" << Teko::getDiagonalName(massInverseType_) <<
"\"", 10);
129 iQp = getInvDiagonalOp(Qp, massInverseType_);
136 Teuchos::TimeMonitor timerInvS(*invSTimer_,
true);
140 TEUCHOS_ASSERT(laplace != Teuchos::null);
141 if (invLaplace == Teuchos::null)
150 Teko_DEBUG_SCOPE(
"Building S", 10);
151 Teuchos::TimeMonitor timerS(*opsTimer_,
true);
156 TEUCHOS_ASSERT(pcd != Teuchos::null);
157 LinearOp invL = invLaplace;
160 if (schurCompOrdering_ ==
false)
161 invS = multiply(iQp, pcd, invL);
163 invS = multiply(invL, pcd, iQp);
171 Teko_DEBUG_SCOPE(
"Building inv(F)", 10);
172 Teuchos::TimeMonitor timerInvF(*invFTimer_,
true);
175 if (invF == Teuchos::null)
197 const InverseLibrary& invLib) {
198 Teko_DEBUG_SCOPE(
"PCDStrategy::initializeFromParameterList", 10);
200 std::string invStr =
"", invFStr =
"", invSStr =
"";
201 #if defined(Teko_ENABLE_Amesos)
203 #elif defined(Teko_ENABLE_Amesos2)
207 massInverseType_ = Diagonal;
210 if (pl.isParameter(
"Inverse Type")) invStr = pl.get<std::string>(
"Inverse Type");
211 if (pl.isParameter(
"Inverse F Type")) invFStr = pl.get<std::string>(
"Inverse F Type");
212 if (pl.isParameter(
"Inverse Laplace Type")) invSStr = pl.get<std::string>(
"Inverse Laplace Type");
213 if (pl.isParameter(
"Inverse Mass Type")) {
214 std::string massInverseStr = pl.get<std::string>(
"Inverse Mass Type");
217 massInverseType_ = getDiagonalType(massInverseStr);
219 if (pl.isParameter(
"Flip Schur Complement Ordering"))
220 schurCompOrdering_ = pl.get<
bool>(
"Flip Schur Complement Ordering");
223 if (invFStr ==
"") invFStr = invStr;
224 if (invSStr ==
"") invSStr = invStr;
227 if (pl.isSublist(
"Pressure Laplace Parameters"))
229 Teuchos::rcp(
new Teuchos::ParameterList(pl.sublist(
"Pressure Laplace Parameters")));
231 lapParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
234 if (pl.isSublist(
"Pressure Convection Diffusion Parameters"))
236 new Teuchos::ParameterList(pl.sublist(
"Pressure Convection Diffusion Parameters")));
238 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
241 TEUCHOS_TEST_FOR_EXCEPTION(
242 lapParams_->isParameter(
"Name"), std::logic_error,
243 "Teko: Parameter \"Name\" is not allowed in the sublist \"" +
lapParams_->name() +
"\"");
244 TEUCHOS_TEST_FOR_EXCEPTION(
245 lapParams_->isParameter(
"Tag"), std::logic_error,
246 "Teko: Parameter \"Tag\" is not allowed in the sublist \"" +
lapParams_->name() +
"\"");
247 TEUCHOS_TEST_FOR_EXCEPTION(
248 pcdParams_->isParameter(
"Name"), std::logic_error,
249 "Teko: Parameter \"Name\" is not allowed in the sublist \"" +
pcdParams_->name() +
"\"");
250 TEUCHOS_TEST_FOR_EXCEPTION(
251 pcdParams_->isParameter(
"Tag"), std::logic_error,
252 "Teko: Parameter \"Tag\" is not allowed in the sublist \"" +
pcdParams_->name() +
"\"");
254 Teko_DEBUG_MSG_BEGIN(5) DEBUG_STREAM <<
"PCD Strategy Parameters: " << std::endl;
255 DEBUG_STREAM <<
" inv type = \"" << invStr <<
"\"" << std::endl;
256 DEBUG_STREAM <<
" inv F type = \"" << invFStr <<
"\"" << std::endl;
257 DEBUG_STREAM <<
" inv Laplace type = \"" << invSStr <<
"\"" << std::endl;
258 DEBUG_STREAM <<
" inv Mass type = \"" << Teko::getDiagonalName(massInverseType_) <<
"\""
260 DEBUG_STREAM <<
"PCD Strategy Parameter list: " << std::endl;
261 pl.print(DEBUG_STREAM);
265 invFactoryF_ = invLib.getInverseFactory(invFStr);
267 if (invFStr == invSStr)
268 invFactoryS_ = invFactoryF_;
270 invFactoryS_ = invLib.getInverseFactory(invSStr);
272 lapParams_->set(
"Name", getPressureLaplaceString());
285 TEUCHOS_ASSERT(
false);
287 return Teuchos::null;
292 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.