16 #include "Teko_ModALPreconditionerFactory.hpp"
18 #include "Thyra_DefaultMultipliedLinearOp.hpp"
19 #include "Thyra_DefaultAddedLinearOp.hpp"
20 #include "Thyra_DefaultIdentityLinearOp.hpp"
21 #include "Thyra_DefaultZeroLinearOp.hpp"
25 #include "Teko_BlockLowerTriInverseOp.hpp"
26 #include "Teko_BlockUpperTriInverseOp.hpp"
27 #include "Teko_StaticLSCStrategy.hpp"
28 #include "Teko_InvLSCStrategy.hpp"
29 #include "Teko_PresLaplaceLSCStrategy.hpp"
31 #include "Teuchos_Time.hpp"
37 ModALPrecondState::ModALPrecondState()
38 : pressureMassMatrix_(Teuchos::null), invPressureMassMatrix_(Teuchos::null) {}
40 ModALPreconditionerFactory::ModALPreconditionerFactory(
const Teuchos::RCP<InverseFactory>& factory)
41 : invOpsStrategy_(Teuchos::rcp(new InvModALStrategy(factory))), isSymmetric_(true) {}
43 ModALPreconditionerFactory::ModALPreconditionerFactory(
44 const Teuchos::RCP<InverseFactory>& invFactoryA,
45 const Teuchos::RCP<InverseFactory>& invFactoryS)
46 : invOpsStrategy_(Teuchos::rcp(new InvModALStrategy(invFactoryA, invFactoryS))),
49 ModALPreconditionerFactory::ModALPreconditionerFactory(
const Teuchos::RCP<InverseFactory>& factory,
50 LinearOp& pressureMassMatrix)
51 : invOpsStrategy_(Teuchos::rcp(new InvModALStrategy(factory, pressureMassMatrix))),
54 ModALPreconditionerFactory::ModALPreconditionerFactory(
55 const Teuchos::RCP<InverseFactory>& invFactoryA,
56 const Teuchos::RCP<InverseFactory>& invFactoryS, LinearOp& pressureMassMatrix)
58 Teuchos::rcp(new InvModALStrategy(invFactoryA, invFactoryS, pressureMassMatrix))),
62 ModALPreconditionerFactory::ModALPreconditionerFactory(
63 const Teuchos::RCP<InvModALStrategy>& strategy)
64 : invOpsStrategy_(strategy), isSymmetric_(true) {}
66 LinearOp ModALPreconditionerFactory::buildPreconditionerOperator(
68 Teko_DEBUG_SCOPE(
"ModALPreconditionerFactory::buildPreconditionerOperator()", 10);
69 Teko_DEBUG_EXPR(Teuchos::Time timer(
""));
70 Teko_DEBUG_EXPR(Teuchos::Time totalTimer(
""));
71 Teko_DEBUG_EXPR(totalTimer.start());
74 int dim = blockRowCount(alOp) - 1;
75 TEUCHOS_ASSERT(dim == 2 || dim == 3);
78 Teko_DEBUG_EXPR(timer.start(
true));
79 invOpsStrategy_->buildState(alOp, state);
80 Teko_DEBUG_EXPR(timer.stop());
81 Teko_DEBUG_MSG(
"ModALPreconditionerFactory::buildPreconditionerOperator():BuildStateTime = "
82 << timer.totalElapsedTime(),
86 Teko_DEBUG_EXPR(timer.start(
true));
87 LinearOp invA11p = invOpsStrategy_->getInvA11p(state);
88 LinearOp invA22p = invOpsStrategy_->getInvA22p(state);
91 invA33p = invOpsStrategy_->getInvA33p(state);
97 TEUCHOS_ASSERT(modALState != NULL);
99 if (modALState->isStabilized_) {
100 invS = invOpsStrategy_->getInvS(state);
102 invS = scale(modALState->gamma_, modALState->invPressureMassMatrix_);
105 Teko_DEBUG_EXPR(timer.stop());
107 "ModALPrecFact::buildPreconditionerOperator(): GetInvTime = " << timer.totalElapsedTime(), 2);
110 std::vector<LinearOp> invDiag;
111 invDiag.resize(dim + 1);
112 invDiag[0] = invA11p;
113 invDiag[1] = invA22p;
115 invDiag[2] = scale(-1.0, invS);
116 }
else if (dim == 3) {
117 invDiag[2] = invA33p;
118 invDiag[3] = scale(-1.0, invS);
122 BlockedLinearOp U = getUpperTriBlocks(alOp);
124 Teko_DEBUG_EXPR(totalTimer.stop());
126 "ModALPrecFact::buildPreconditionerOperator TotalTime = " << totalTimer.totalElapsedTime(),
130 return createBlockUpperTriInverseOp(U, invDiag,
"Modified AL preconditioner-Upper");
An implementation of a state object for block preconditioners.
Class for saving state variables for ModALPreconditionerFactory.