47 #include "Teko_LSCSIMPLECStrategy.hpp" 49 #include "Thyra_DefaultDiagonalLinearOp.hpp" 50 #include "Thyra_EpetraThyraWrappers.hpp" 51 #include "Thyra_get_Epetra_Operator.hpp" 52 #include "Thyra_EpetraLinearOp.hpp" 53 #include "Thyra_VectorStdOps.hpp" 55 #include "Epetra_Vector.h" 56 #include "Epetra_Map.h" 58 #include "EpetraExt_RowMatrixOut.h" 59 #include "EpetraExt_MultiVectorOut.h" 60 #include "EpetraExt_VectorOut.h" 62 #include "Teuchos_Time.hpp" 63 #include "Teuchos_TimeMonitor.hpp" 67 #include "Teko_LSCPreconditionerFactory.hpp" 68 #include "Teko_EpetraHelpers.hpp" 69 #include "Teko_EpetraOperatorWrapper.hpp" 72 using Teuchos::rcp_dynamic_cast;
73 using Teuchos::rcp_const_cast;
84 LSCSIMPLECStrategy::LSCSIMPLECStrategy()
86 , useFullLDU_(false), scaleType_(
Diagonal)
93 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::buildState",10);
96 TEUCHOS_ASSERT(lscState!=0);
100 Teko_DEBUG_EXPR(Teuchos::Time timer(
""));
104 Teko_DEBUG_SCOPE(
"LSC-SIMPLEC::buildState constructing operators",1);
105 Teko_DEBUG_EXPR(timer.start(
true));
107 initializeState(A,lscState);
109 Teko_DEBUG_EXPR(timer.stop());
110 Teko_DEBUG_MSG(
"LSC-SIMPLEC::buildState BuildOpsTime = " << timer.totalElapsedTime(),1);
115 Teko_DEBUG_SCOPE(
"LSC-SIMPLEC::buildState calculating inverses",1);
116 Teko_DEBUG_EXPR(timer.start(
true));
118 computeInverses(A,lscState);
120 Teko_DEBUG_EXPR(timer.stop());
121 Teko_DEBUG_MSG(
"LSC-SIMPLEC::buildState BuildInvTime = " << timer.totalElapsedTime(),1);
134 return state.
getInverse(
"invBQBtmC").getConst();
145 TEUCHOS_ASSERT(lscState!=0);
149 return scale(-1.0,C);
156 TEUCHOS_ASSERT(lscState!=0);
164 return getInvMass(A,state);
170 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::initializeState",10);
173 const LinearOp Bt =
getBlock(0,1,A);
177 bool isStabilized = (not isZeroOp(C));
179 state->
invMass_ = getInvDiagonalOp(F,scaleType_);
185 Teko::ModifiableLinearOp BQBtmC = state->
getInverse(
"BQBtmC");
186 BQBtmC = explicitAdd(state->
BQBt_,
scale(-1.0,C),BQBtmC);
189 Teko_DEBUG_MSG(
"Computed BQBt",10);
201 Teko_DEBUG_SCOPE(
"LSCSIMPLECStrategy::computeInverses",10);
202 Teko_DEBUG_EXPR(Teuchos::Time invTimer(
""));
209 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses Building inv(F)",1);
210 Teko_DEBUG_EXPR(invTimer.start(
true));
211 InverseLinearOp invF = state->
getInverse(
"invF");
212 if(invF==Teuchos::null) {
218 Teko_DEBUG_EXPR(invTimer.stop());
219 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses GetInvF = " << invTimer.totalElapsedTime(),1);
224 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses Building inv(BQBtmC)",1);
225 Teko_DEBUG_EXPR(invTimer.start(
true));
226 const LinearOp BQBt = state->
getInverse(
"BQBtmC");
227 InverseLinearOp invBQBt = state->
getInverse(
"invBQBtmC");
228 if(invBQBt==Teuchos::null) {
234 Teko_DEBUG_EXPR(invTimer.stop());
235 Teko_DEBUG_MSG(
"LSC-SIMPLEC::computeInverses GetInvBQBt = " << invTimer.totalElapsedTime(),1);
242 std::string invStr=
"", invVStr=
"", invPStr=
"";
247 if(pl.isParameter(
"Inverse Type"))
248 invStr = pl.get<std::string>(
"Inverse Type");
249 if(pl.isParameter(
"Inverse Velocity Type"))
250 invVStr = pl.get<std::string>(
"Inverse Velocity Type");
251 if(pl.isParameter(
"Inverse Pressure Type"))
252 invPStr = pl.get<std::string>(
"Inverse Pressure Type");
253 if(pl.isParameter(
"Use LDU"))
254 useLDU = pl.get<
bool>(
"Use LDU");
255 if(pl.isParameter(
"Scaling Type")) {
256 scaleType_ = getDiagonalType(pl.get<std::string>(
"Scaling Type"));
257 TEUCHOS_TEST_FOR_EXCEPT(scaleType_==
NotDiag);
260 Teko_DEBUG_MSG_BEGIN(0)
261 DEBUG_STREAM <<
"LSC Inverse Strategy Parameters: " << std::endl;
262 DEBUG_STREAM <<
" inv type = \"" << invStr <<
"\"" << std::endl;
263 DEBUG_STREAM <<
" inv v type = \"" << invVStr <<
"\"" << std::endl;
264 DEBUG_STREAM <<
" inv p type = \"" << invPStr <<
"\"" << std::endl;
265 DEBUG_STREAM <<
" use ldu = " << useLDU << std::endl;
266 DEBUG_STREAM <<
" scale type = " << getDiagonalName(scaleType_) << std::endl;
267 DEBUG_STREAM <<
"LSC Inverse Strategy Parameter list: " << std::endl;
268 pl.print(DEBUG_STREAM);
272 if(invStr==
"") invStr =
"Amesos";
273 if(invVStr==
"") invVStr = invStr;
274 if(invPStr==
"") invPStr = invStr;
277 invFactoryF_ = invLib.getInverseFactory(invVStr);
278 invFactoryS_ = invFactoryF_;
280 invFactoryS_ = invLib.getInverseFactory(invPStr);
283 setUseFullLDU(useLDU);
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
Specifies that just the diagonal is used.
InverseLinearOp buildInverse(const InverseFactory &factory, const LinearOp &A)
Build an inverse operator using a factory and a linear operator.
void scale(const double alpha, MultiVector &x)
Scale a multivector by a constant.
virtual LinearOp getInvMass(const BlockedLinearOp &A, BlockPreconditionerState &state) const
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
An implementation of a state object for block preconditioners.
virtual bool isInitialized() const
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.
MultiVector getBlock(int i, const BlockedMultiVector &bmv)
Get the ith block from a BlockedMultiVector object.
virtual void initializeFromParameterList(const Teuchos::ParameterList &pl, const InverseLibrary &invLib)
Initialize from a parameter list.
virtual LinearOp getInnerStabilization(const BlockedLinearOp &A, BlockPreconditionerState &state) const
For user convenience, if Teko recieves this value, exceptions will be thrown.
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)