7 #include "Teko_ModALPreconditionerFactory.hpp"
9 #include "Thyra_DefaultMultipliedLinearOp.hpp"
10 #include "Thyra_DefaultAddedLinearOp.hpp"
11 #include "Thyra_DefaultIdentityLinearOp.hpp"
12 #include "Thyra_DefaultZeroLinearOp.hpp"
13 #include "Thyra_get_Epetra_Operator.hpp"
17 #include "Teko_BlockLowerTriInverseOp.hpp"
18 #include "Teko_BlockUpperTriInverseOp.hpp"
19 #include "Teko_StaticLSCStrategy.hpp"
20 #include "Teko_InvLSCStrategy.hpp"
21 #include "Teko_PresLaplaceLSCStrategy.hpp"
23 #include "EpetraExt_RowMatrixOut.h"
25 #include "Teuchos_Time.hpp"
33 ModALPrecondState::ModALPrecondState():
34 pressureMassMatrix_(Teuchos::null), invPressureMassMatrix_(Teuchos::null)
38 ModALPreconditionerFactory::ModALPreconditionerFactory(
const Teuchos::RCP<InverseFactory> & factory) :
39 invOpsStrategy_(Teuchos::rcp(new InvModALStrategy(factory))),
44 ModALPreconditionerFactory::ModALPreconditionerFactory(
const Teuchos::RCP<InverseFactory> & invFactoryA,
45 const Teuchos::RCP<InverseFactory> & invFactoryS) :
46 invOpsStrategy_(Teuchos::rcp(new InvModALStrategy(invFactoryA, invFactoryS))),
51 ModALPreconditionerFactory::ModALPreconditionerFactory(
const Teuchos::RCP<InverseFactory> & factory,
52 LinearOp & pressureMassMatrix) :
53 invOpsStrategy_(Teuchos::rcp(new InvModALStrategy(factory, pressureMassMatrix))), isSymmetric_(true)
57 ModALPreconditionerFactory::ModALPreconditionerFactory(
const Teuchos::RCP<InverseFactory> & invFactoryA,
58 const Teuchos::RCP<InverseFactory> & invFactoryS,
59 LinearOp & pressureMassMatrix) :
60 invOpsStrategy_(Teuchos::rcp(new InvModALStrategy(invFactoryA, invFactoryS, pressureMassMatrix))),
66 ModALPreconditionerFactory::ModALPreconditionerFactory(
const Teuchos::RCP<InvModALStrategy> & strategy) :
67 invOpsStrategy_(strategy), isSymmetric_(true)
71 LinearOp ModALPreconditionerFactory::buildPreconditionerOperator(BlockedLinearOp & alOp,
74 Teko_DEBUG_SCOPE(
"ModALPreconditionerFactory::buildPreconditionerOperator()", 10);
75 Teko_DEBUG_EXPR(Teuchos::Time timer(
""));
76 Teko_DEBUG_EXPR(Teuchos::Time totalTimer(
""));
77 Teko_DEBUG_EXPR(totalTimer.start());
80 int dim = blockRowCount(alOp) - 1;
81 TEUCHOS_ASSERT(dim == 2 || dim == 3);
84 Teko_DEBUG_EXPR(timer.start(
true));
85 invOpsStrategy_->buildState(alOp, state);
86 Teko_DEBUG_EXPR(timer.stop());
87 Teko_DEBUG_MSG(
"ModALPreconditionerFactory::buildPreconditionerOperator():BuildStateTime = "
88 << timer.totalElapsedTime(), 2);
91 Teko_DEBUG_EXPR(timer.start(
true));
92 LinearOp invA11p = invOpsStrategy_->getInvA11p(state);
93 LinearOp invA22p = invOpsStrategy_->getInvA22p(state);
97 invA33p = invOpsStrategy_->getInvA33p(state);
103 TEUCHOS_ASSERT(modALState != NULL);
105 if(modALState->isStabilized_)
107 invS = invOpsStrategy_->getInvS(state);
111 invS = scale(modALState->gamma_, modALState->invPressureMassMatrix_);
114 Teko_DEBUG_EXPR(timer.stop());
115 Teko_DEBUG_MSG(
"ModALPrecFact::buildPreconditionerOperator(): GetInvTime = "
116 << timer.totalElapsedTime(), 2);
119 std::vector<LinearOp> invDiag;
120 invDiag.resize(dim + 1);
121 invDiag[0] = invA11p;
122 invDiag[1] = invA22p;
125 invDiag[2] = scale(-1.0, invS);
129 invDiag[2] = invA33p;
130 invDiag[3] = scale(-1.0, invS);
134 BlockedLinearOp U = getUpperTriBlocks(alOp);
136 Teko_DEBUG_EXPR(totalTimer.stop());
137 Teko_DEBUG_MSG(
"ModALPrecFact::buildPreconditionerOperator TotalTime = "
138 << totalTimer.totalElapsedTime(), 2);
141 return createBlockUpperTriInverseOp(U, invDiag,
"Modified AL preconditioner-Upper");
An implementation of a state object for block preconditioners.
Class for saving state variables for ModALPreconditionerFactory.