47 #include "Teko_LSCSIMPLECStrategy.hpp"
49 #include "Thyra_DefaultDiagonalLinearOp.hpp"
50 #include "Thyra_VectorStdOps.hpp"
52 #include "Teuchos_Time.hpp"
53 #include "Teuchos_TimeMonitor.hpp"
57 #include "Teko_LSCPreconditionerFactory.hpp"
60 using Teuchos::rcp_const_cast;
61 using Teuchos::rcp_dynamic_cast;
72 LSCSIMPLECStrategy::LSCSIMPLECStrategy()
73 : invFactoryF_(Teuchos::null),
74 invFactoryS_(Teuchos::null),
76 scaleType_(Diagonal) {}
81 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::buildState", 10);
84 TEUCHOS_ASSERT(lscState != 0);
88 Teko_DEBUG_EXPR(Teuchos::Time timer(
""));
92 Teko_DEBUG_SCOPE(
"LSC-SIMPLEC::buildState constructing operators", 1);
93 Teko_DEBUG_EXPR(timer.start(
true));
97 Teko_DEBUG_EXPR(timer.stop());
98 Teko_DEBUG_MSG(
"LSC-SIMPLEC::buildState BuildOpsTime = " << timer.totalElapsedTime(), 1);
103 Teko_DEBUG_SCOPE(
"LSC-SIMPLEC::buildState calculating inverses", 1);
104 Teko_DEBUG_EXPR(timer.start(
true));
108 Teko_DEBUG_EXPR(timer.stop());
109 Teko_DEBUG_MSG(
"LSC-SIMPLEC::buildState BuildInvTime = " << timer.totalElapsedTime(), 1);
122 return state.
getInverse(
"invBQBtmC").getConst();
133 TEUCHOS_ASSERT(lscState != 0);
136 const LinearOp C = getBlock(1, 1, A);
137 return scale(-1.0, C);
143 TEUCHOS_ASSERT(lscState != 0);
156 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::initializeState", 10);
158 const LinearOp F = getBlock(0, 0, A);
159 const LinearOp Bt = getBlock(0, 1, A);
160 const LinearOp B = getBlock(1, 0, A);
161 const LinearOp C = getBlock(1, 1, A);
163 bool isStabilized = (not isZeroOp(C));
165 state->
invMass_ = getInvDiagonalOp(F, scaleType_);
171 Teko::ModifiableLinearOp BQBtmC = state->
getInverse(
"BQBtmC");
172 BQBtmC = explicitAdd(state->
BQBt_, scale(-1.0, C), BQBtmC);
175 Teko_DEBUG_MSG(
"Computed BQBt", 10);
186 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::computeInverses", 10);
187 Teko_DEBUG_EXPR(Teuchos::Time invTimer(
""));
189 const LinearOp F = getBlock(0, 0, A);
194 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses Building inv(F)", 1);
195 Teko_DEBUG_EXPR(invTimer.start(
true));
196 InverseLinearOp invF = state->
getInverse(
"invF");
197 if (invF == Teuchos::null) {
203 Teko_DEBUG_EXPR(invTimer.stop());
204 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses GetInvF = " << invTimer.totalElapsedTime(), 1);
209 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses Building inv(BQBtmC)", 1);
210 Teko_DEBUG_EXPR(invTimer.start(
true));
211 const LinearOp BQBt = state->
getInverse(
"BQBtmC");
212 InverseLinearOp invBQBt = state->
getInverse(
"invBQBtmC");
213 if (invBQBt == Teuchos::null) {
219 Teko_DEBUG_EXPR(invTimer.stop());
220 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses GetInvBQBt = " << invTimer.totalElapsedTime(), 1);
225 const InverseLibrary& invLib) {
227 std::string invStr =
"", invVStr =
"", invPStr =
"";
229 scaleType_ = Diagonal;
232 if (pl.isParameter(
"Inverse Type")) invStr = pl.get<std::string>(
"Inverse Type");
233 if (pl.isParameter(
"Inverse Velocity Type"))
234 invVStr = pl.get<std::string>(
"Inverse Velocity Type");
235 if (pl.isParameter(
"Inverse Pressure Type"))
236 invPStr = pl.get<std::string>(
"Inverse Pressure Type");
237 if (pl.isParameter(
"Use LDU")) useLDU = pl.get<
bool>(
"Use LDU");
238 if (pl.isParameter(
"Scaling Type")) {
239 scaleType_ = getDiagonalType(pl.get<std::string>(
"Scaling Type"));
240 TEUCHOS_TEST_FOR_EXCEPT(scaleType_ == NotDiag);
243 Teko_DEBUG_MSG_BEGIN(0) DEBUG_STREAM <<
"LSC Inverse Strategy Parameters: " << std::endl;
244 DEBUG_STREAM <<
" inv type = \"" << invStr <<
"\"" << std::endl;
245 DEBUG_STREAM <<
" inv v type = \"" << invVStr <<
"\"" << std::endl;
246 DEBUG_STREAM <<
" inv p type = \"" << invPStr <<
"\"" << std::endl;
247 DEBUG_STREAM <<
" use ldu = " << useLDU << std::endl;
248 DEBUG_STREAM <<
" scale type = " << getDiagonalName(scaleType_) << std::endl;
249 DEBUG_STREAM <<
"LSC Inverse Strategy Parameter list: " << std::endl;
250 pl.print(DEBUG_STREAM);
254 #if defined(Teko_ENABLE_Amesos)
255 if (invStr ==
"") invStr =
"Amesos";
256 #elif defined(Teko_ENABLE_Amesos2)
257 if (invStr ==
"") invStr =
"Amesos2";
259 if (invVStr ==
"") invVStr = invStr;
260 if (invPStr ==
"") invPStr = invStr;
263 invFactoryF_ = invLib.getInverseFactory(invVStr);
264 invFactoryS_ = invFactoryF_;
265 if (invVStr != invPStr)
266 invFactoryS_ = invLib.getInverseFactory(invPStr);
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
virtual Teko::InverseLinearOp getInverse(const std::string &name) const
Get a named inverse from the state object.
void computeInverses(const BlockedLinearOp &A, LSCPrecondState *state) const
virtual LinearOp getInvMass(const BlockedLinearOp &A, BlockPreconditionerState &state) const
An implementation of a state object for block preconditioners.
virtual bool isInitialized() const
virtual void setUseFullLDU(bool val)
Set to true to use the Full LDU decomposition, false otherwise.
virtual void addInverse(const std::string &name, const Teko::InverseLinearOp &ilo)
Add a named inverse to the state object.
virtual void initializeState(const BlockedLinearOp &A, LSCPrecondState *state) const
Initialize the state object using this blocked linear operator.
virtual LinearOp getHScaling(const BlockedLinearOp &A, BlockPreconditionerState &state) const
LinearOp invMass_
Inverse mass operator ( )
Preconditioner state for the LSC factory.
virtual void initializeFromParameterList(const Teuchos::ParameterList &pl, const InverseLibrary &invLib)
Initialize from a parameter list.
virtual LinearOp getInnerStabilization(const 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 LinearOp getInvF(const BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual LinearOp getInvBHBt(const BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual LinearOp getInvBQBt(const BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual void buildState(BlockedLinearOp &A, BlockPreconditionerState &state) const
Functions inherited from LSCStrategy.
virtual void setInitialized(bool init=true)