10 #include "Teko_LU2x2DiagonalStrategy.hpp"
12 #include "Teuchos_TimeMonitor.hpp"
16 using Teuchos::TimeMonitor;
18 Teuchos::RCP<Teuchos::Time> LU2x2DiagonalStrategy::initTimer_;
19 Teuchos::RCP<Teuchos::Time> LU2x2DiagonalStrategy::invSTimer_;
20 Teuchos::RCP<Teuchos::Time> LU2x2DiagonalStrategy::invA00Timer_;
21 Teuchos::RCP<Teuchos::Time> LU2x2DiagonalStrategy::opsTimer_;
24 if (initTimer_ == Teuchos::null)
25 initTimer_ = TimeMonitor::getNewTimer(
"LU2x2DiagonalStrategy::initializePrec");
27 if (invSTimer_ == Teuchos::null)
28 invSTimer_ = TimeMonitor::getNewTimer(
"LU2x2DiagonalStrategy::initializePrec invS");
30 if (invA00Timer_ == Teuchos::null)
31 invA00Timer_ = TimeMonitor::getNewTimer(
"LU2x2DiagonalStrategy::initializePrec invA00");
33 if (opsTimer_ == Teuchos::null)
34 opsTimer_ = TimeMonitor::getNewTimer(
"LU2x2DiagonalStrategy::initializePrec buildOps");
41 const Teuchos::RCP<InverseFactory>& invS)
42 : invFactoryA00_(invFA), invFactoryS_(invS), a00InverseType_(Diagonal) {
73 Teko_DEBUG_SCOPE(
"LU2x2DiagonalStrategy::initializeState", 10);
78 Teuchos::TimeMonitor timer(*initTimer_,
true);
81 LinearOp A00 = Teko::getBlock(0, 0, A);
82 LinearOp A01 = Teko::getBlock(0, 1, A);
83 LinearOp A10 = Teko::getBlock(1, 0, A);
84 LinearOp A11 = Teko::getBlock(1, 1, A);
90 Teko_DEBUG_SCOPE(
"Building S", 5);
91 Teuchos::TimeMonitor timerS(*opsTimer_,
true);
93 LinearOp diagA00 = getInvDiagonalOp(A00, a00InverseType_);
97 triple = explicitMultiply(A10, diagA00, A01, triple);
98 S = explicitAdd(scale(-1.0, A11), triple, S);
104 Teko_DEBUG_SCOPE(
"Building inverse(S)", 5);
105 Teuchos::TimeMonitor timerInvS(*invSTimer_,
true);
108 if (invS == Teuchos::null)
117 Teko_DEBUG_SCOPE(
"Building inverse(A00)", 5);
118 Teuchos::TimeMonitor timerInvA00(*invA00Timer_,
true);
121 *getOutputStream() <<
"(LU2x2) invA00 pointer = " << invA00 << std::endl;
122 if (invA00 == Teuchos::null)
144 const InverseLibrary& invLib) {
145 Teko_DEBUG_SCOPE(
"LU2x2DiagonalStrategy::initializeFromParameterList", 10);
147 std::string invStr =
"", invA00Str =
"", invSStr =
"";
148 #if defined(Teko_ENABLE_Amesos)
150 #elif defined(Teko_ENABLE_Amesos2)
155 if (pl.isParameter(
"Inverse Type")) invStr = pl.get<std::string>(
"Inverse Type");
156 if (pl.isParameter(
"Inverse A00 Type")) invA00Str = pl.get<std::string>(
"Inverse A00 Type");
157 if (pl.isParameter(
"Inverse Schur Type")) invSStr = pl.get<std::string>(
"Inverse Schur Type");
158 if (pl.isParameter(
"Diagonal Type")) {
159 std::string massInverseStr = pl.get<std::string>(
"Diagonal Type");
162 a00InverseType_ = getDiagonalType(massInverseStr);
166 if (invA00Str ==
"") invA00Str = invStr;
167 if (invSStr ==
"") invSStr = invStr;
169 Teko_DEBUG_MSG_BEGIN(5) DEBUG_STREAM <<
"LU2x2 Diagonal Strategy Parameters: " << std::endl;
170 DEBUG_STREAM <<
" inv type = \"" << invStr <<
"\"" << std::endl;
171 DEBUG_STREAM <<
" inv A00 type = \"" << invA00Str <<
"\"" << std::endl;
172 DEBUG_STREAM <<
" inv S type = \"" << invSStr <<
"\"" << std::endl;
173 DEBUG_STREAM <<
"LU2x2 Diagonal Strategy Parameter list: " << std::endl;
174 pl.print(DEBUG_STREAM);
178 invFactoryA00_ = invLib.getInverseFactory(invA00Str);
180 if (invA00Str == invSStr)
181 invFactoryS_ = invFactoryA00_;
183 invFactoryS_ = invLib.getInverseFactory(invSStr);
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
virtual const Teko::LinearOp getTildeInvA00(const Teko::BlockedLinearOp &A, BlockPreconditionerState &state) const
LU2x2DiagonalStrategy()
default Constructor
An implementation of a state object for block preconditioners.
void initializeState(const Teko::BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual bool isInitialized() const
static void buildTimers()
virtual const Teko::LinearOp getHatInvA00(const Teko::BlockedLinearOp &A, BlockPreconditionerState &state) const
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.
virtual void initializeFromParameterList(const Teuchos::ParameterList &settings, const InverseLibrary &invLib)
This function builds the internals of the state from a parameter list.
virtual void setInitialized(bool init=true)
virtual Teko::ModifiableLinearOp & getModifiableOp(const std::string &name)
Add a named operator to the state object.