10 #include "Teko_LSCSIMPLECStrategy.hpp"
12 #include "Thyra_DefaultDiagonalLinearOp.hpp"
13 #include "Thyra_VectorStdOps.hpp"
15 #include "Teuchos_Time.hpp"
16 #include "Teuchos_TimeMonitor.hpp"
20 #include "Teko_LSCPreconditionerFactory.hpp"
23 using Teuchos::rcp_const_cast;
24 using Teuchos::rcp_dynamic_cast;
35 LSCSIMPLECStrategy::LSCSIMPLECStrategy()
36 : invFactoryF_(Teuchos::null),
37 invFactoryS_(Teuchos::null),
39 scaleType_(Diagonal) {}
44 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::buildState", 10);
47 TEUCHOS_ASSERT(lscState != 0);
51 Teko_DEBUG_EXPR(Teuchos::Time timer(
""));
55 Teko_DEBUG_SCOPE(
"LSC-SIMPLEC::buildState constructing operators", 1);
56 Teko_DEBUG_EXPR(timer.start(
true));
60 Teko_DEBUG_EXPR(timer.stop());
61 Teko_DEBUG_MSG(
"LSC-SIMPLEC::buildState BuildOpsTime = " << timer.totalElapsedTime(), 1);
66 Teko_DEBUG_SCOPE(
"LSC-SIMPLEC::buildState calculating inverses", 1);
67 Teko_DEBUG_EXPR(timer.start(
true));
71 Teko_DEBUG_EXPR(timer.stop());
72 Teko_DEBUG_MSG(
"LSC-SIMPLEC::buildState BuildInvTime = " << timer.totalElapsedTime(), 1);
85 return state.
getInverse(
"invBQBtmC").getConst();
96 TEUCHOS_ASSERT(lscState != 0);
99 const LinearOp C = getBlock(1, 1, A);
100 return scale(-1.0, C);
106 TEUCHOS_ASSERT(lscState != 0);
119 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::initializeState", 10);
121 const LinearOp F = getBlock(0, 0, A);
122 const LinearOp Bt = getBlock(0, 1, A);
123 const LinearOp B = getBlock(1, 0, A);
124 const LinearOp C = getBlock(1, 1, A);
126 bool isStabilized = (not isZeroOp(C));
128 state->
invMass_ = getInvDiagonalOp(F, scaleType_);
134 Teko::ModifiableLinearOp BQBtmC = state->
getInverse(
"BQBtmC");
135 BQBtmC = explicitAdd(state->
BQBt_, scale(-1.0, C), BQBtmC);
138 Teko_DEBUG_MSG(
"Computed BQBt", 10);
149 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::computeInverses", 10);
150 Teko_DEBUG_EXPR(Teuchos::Time invTimer(
""));
152 const LinearOp F = getBlock(0, 0, A);
157 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses Building inv(F)", 1);
158 Teko_DEBUG_EXPR(invTimer.start(
true));
159 InverseLinearOp invF = state->
getInverse(
"invF");
160 if (invF == Teuchos::null) {
166 Teko_DEBUG_EXPR(invTimer.stop());
167 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses GetInvF = " << invTimer.totalElapsedTime(), 1);
172 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses Building inv(BQBtmC)", 1);
173 Teko_DEBUG_EXPR(invTimer.start(
true));
174 const LinearOp BQBt = state->
getInverse(
"BQBtmC");
175 InverseLinearOp invBQBt = state->
getInverse(
"invBQBtmC");
176 if (invBQBt == Teuchos::null) {
182 Teko_DEBUG_EXPR(invTimer.stop());
183 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses GetInvBQBt = " << invTimer.totalElapsedTime(), 1);
188 const InverseLibrary& invLib) {
190 std::string invStr =
"", invVStr =
"", invPStr =
"";
192 scaleType_ = Diagonal;
195 if (pl.isParameter(
"Inverse Type")) invStr = pl.get<std::string>(
"Inverse Type");
196 if (pl.isParameter(
"Inverse Velocity Type"))
197 invVStr = pl.get<std::string>(
"Inverse Velocity Type");
198 if (pl.isParameter(
"Inverse Pressure Type"))
199 invPStr = pl.get<std::string>(
"Inverse Pressure Type");
200 if (pl.isParameter(
"Use LDU")) useLDU = pl.get<
bool>(
"Use LDU");
201 if (pl.isParameter(
"Scaling Type")) {
202 scaleType_ = getDiagonalType(pl.get<std::string>(
"Scaling Type"));
203 TEUCHOS_TEST_FOR_EXCEPT(scaleType_ == NotDiag);
206 Teko_DEBUG_MSG_BEGIN(0) DEBUG_STREAM <<
"LSC Inverse Strategy Parameters: " << std::endl;
207 DEBUG_STREAM <<
" inv type = \"" << invStr <<
"\"" << std::endl;
208 DEBUG_STREAM <<
" inv v type = \"" << invVStr <<
"\"" << std::endl;
209 DEBUG_STREAM <<
" inv p type = \"" << invPStr <<
"\"" << std::endl;
210 DEBUG_STREAM <<
" use ldu = " << useLDU << std::endl;
211 DEBUG_STREAM <<
" scale type = " << getDiagonalName(scaleType_) << std::endl;
212 DEBUG_STREAM <<
"LSC Inverse Strategy Parameter list: " << std::endl;
213 pl.print(DEBUG_STREAM);
217 #if defined(Teko_ENABLE_Amesos)
218 if (invStr ==
"") invStr =
"Amesos";
219 #elif defined(Teko_ENABLE_Amesos2)
220 if (invStr ==
"") invStr =
"Amesos2";
222 if (invVStr ==
"") invVStr = invStr;
223 if (invPStr ==
"") invPStr = invStr;
226 invFactoryF_ = invLib.getInverseFactory(invVStr);
227 invFactoryS_ = invFactoryF_;
228 if (invVStr != invPStr)
229 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)