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_;
64 if(initTimer_==Teuchos::null)
65 initTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec");
67 if(invSTimer_==Teuchos::null)
68 invSTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec invS");
70 if(invFTimer_==Teuchos::null)
71 invFTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec invF");
73 if(opsTimer_==Teuchos::null)
74 opsTimer_ = TimeMonitor::getNewTimer(
"PCDStrategy::initializePrec buildOps");
79 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
80 lapParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
82 lapParams_->set(
"Name",getPressureLaplaceString());
90 const Teuchos::RCP<InverseFactory> & invS)
91 : invFactoryF_(invFA), invFactoryS_(invS), massInverseType_(Diagonal), schurCompOrdering_(false)
93 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
94 lapParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
96 lapParams_->set(
"Name",getPressureLaplaceString());
131 Teko_DEBUG_SCOPE(
"PCDStrategy::initializeState",10);
134 std::string pcdStr = getPCDString();
135 std::string presLapStr = getPressureLaplaceString();
136 std::string presMassStr = getPressureMassString();
142 Teuchos::TimeMonitor timer(*initTimer_,
true);
145 LinearOp F = Teko::getBlock(0,0,A);
146 LinearOp Bt = Teko::getBlock(0,1,A);
147 LinearOp B = Teko::getBlock(1,0,A);
148 LinearOp C = Teko::getBlock(1,1,A);
151 TEUCHOS_ASSERT(Qp!=Teuchos::null);
156 if(massInverseType_==NotDiag) {
158 Teko_DEBUG_SCOPE(
"Building inv(Mass)",10);
160 if(invMass==Teuchos::null)
168 Teko_DEBUG_MSG(
"Building inverse mass of type \"" << Teko::getDiagonalName(massInverseType_) <<
"\"",10);
169 iQp = getInvDiagonalOp(Qp,massInverseType_);
176 Teuchos::TimeMonitor timer(*invSTimer_,
true);
180 TEUCHOS_ASSERT(laplace!=Teuchos::null);
181 if(invLaplace==Teuchos::null)
190 Teko_DEBUG_SCOPE(
"Building S",10);
191 Teuchos::TimeMonitor timer(*opsTimer_,
true);
196 TEUCHOS_ASSERT(pcd!=Teuchos::null);
197 LinearOp invL = invLaplace;
200 if(schurCompOrdering_==
false)
201 invS = multiply(iQp,pcd,invL);
203 invS = multiply(invL,pcd,iQp);
211 Teko_DEBUG_SCOPE(
"Building inv(F)",10);
212 Teuchos::TimeMonitor timer(*invFTimer_,
true);
215 if(invF==Teuchos::null)
237 const InverseLibrary & invLib)
239 Teko_DEBUG_SCOPE(
"PCDStrategy::initializeFromParameterList",10);
241 std::string invStr=
"Amesos", invFStr=
"", invSStr=
"";
242 massInverseType_ = Diagonal;
245 if(pl.isParameter(
"Inverse Type"))
246 invStr = pl.get<std::string>(
"Inverse Type");
247 if(pl.isParameter(
"Inverse F Type"))
248 invFStr = pl.get<std::string>(
"Inverse F Type");
249 if(pl.isParameter(
"Inverse Laplace Type"))
250 invSStr = pl.get<std::string>(
"Inverse Laplace Type");
251 if(pl.isParameter(
"Inverse Mass Type")) {
252 std::string massInverseStr = pl.get<std::string>(
"Inverse Mass Type");
255 massInverseType_ = getDiagonalType(massInverseStr);
257 if(pl.isParameter(
"Flip Schur Complement Ordering"))
258 schurCompOrdering_ = pl.get<
bool>(
"Flip Schur Complement Ordering");
261 if(invFStr==
"") invFStr = invStr;
262 if(invSStr==
"") invSStr = invStr;
265 if(pl.isSublist(
"Pressure Laplace Parameters"))
266 lapParams_ = 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"))
272 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList(pl.sublist(
"Pressure Convection Diffusion Parameters")));
274 pcdParams_ = Teuchos::rcp(
new Teuchos::ParameterList);
277 TEUCHOS_TEST_FOR_EXCEPTION(
lapParams_->isParameter(
"Name"),std::logic_error,
278 "Teko: Parameter \"Name\" is not allowed in the sublist \""+
lapParams_->name()+
"\"");
279 TEUCHOS_TEST_FOR_EXCEPTION(
lapParams_->isParameter(
"Tag"),std::logic_error,
280 "Teko: Parameter \"Tag\" is not allowed in the sublist \""+
lapParams_->name()+
"\"");
281 TEUCHOS_TEST_FOR_EXCEPTION(
pcdParams_->isParameter(
"Name"),std::logic_error,
282 "Teko: Parameter \"Name\" is not allowed in the sublist \""+
pcdParams_->name()+
"\"");
283 TEUCHOS_TEST_FOR_EXCEPTION(
pcdParams_->isParameter(
"Tag"),std::logic_error,
284 "Teko: Parameter \"Tag\" is not allowed in the sublist \""+
pcdParams_->name()+
"\"");
286 Teko_DEBUG_MSG_BEGIN(5)
287 DEBUG_STREAM <<
"PCD Strategy Parameters: " << std::endl;
288 DEBUG_STREAM <<
" inv type = \"" << invStr <<
"\"" << std::endl;
289 DEBUG_STREAM <<
" inv F type = \"" << invFStr <<
"\"" << std::endl;
290 DEBUG_STREAM <<
" inv Laplace type = \"" << invSStr <<
"\"" << std::endl;
291 DEBUG_STREAM <<
" inv Mass type = \"" << Teko::getDiagonalName(massInverseType_) <<
"\"" << std::endl;
292 DEBUG_STREAM <<
"PCD Strategy Parameter list: " << std::endl;
293 pl.print(DEBUG_STREAM);
297 invFactoryF_ = invLib.getInverseFactory(invFStr);
300 invFactoryS_ = invFactoryF_;
302 invFactoryS_ = invLib.getInverseFactory(invSStr);
304 lapParams_->set(
"Name",getPressureLaplaceString());
318 TEUCHOS_ASSERT(
false);
320 return Teuchos::null;
326 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.