41 const Teuchos::RCP<Tpetra::Operator<ST, LO, GO, NT> >& content,
42 LinearOp pressureMassMatrix,
double gamma,
const std::string& label)
43 : Teko::TpetraHelpers::BlockedTpetraOperator(vars, content, label),
44 pressureMassMatrix_(pressureMassMatrix),
51 const Teuchos::RCP<Tpetra::Operator<ST, LO, GO, NT> >& content,
double gamma,
52 const std::string& label)
53 : Teko::TpetraHelpers::BlockedTpetraOperator(vars, content, label),
54 pressureMassMatrix_(Teuchos::null),
71 const Teuchos::RCP<Thyra::BlockedLinearOpBase<ST> > blkOp =
72 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<ST> >(blockedOperator_,
true);
73 RCP<const Thyra::TpetraLinearOp<ST, LO, GO, NT> > tOp =
74 rcp_dynamic_cast<const Thyra::TpetraLinearOp<ST, LO, GO, NT> >(blkOp->getBlock(i, j),
true);
75 return tOp != Teuchos::null ? tOp->getConstTpetraOperator() : Teuchos::null;
84 TEUCHOS_ASSERT(blockedMapping_ != Teuchos::null);
87 const Teuchos::RCP<const Tpetra::CrsMatrix<ST, LO, GO, NT> > crsContent =
88 Teuchos::rcp_dynamic_cast<const Tpetra::CrsMatrix<ST, LO, GO, NT> >(fullContent_,
true);
90 if (blockedOperator_ == Teuchos::null) {
91 blockedOperator_ = blockedMapping_->buildBlockedThyraOp(crsContent, label_);
93 const Teuchos::RCP<Thyra::BlockedLinearOpBase<ST> > blkOp0 =
94 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<ST> >(blockedOperator_,
true);
95 blockedMapping_->rebuildBlockedThyraOp(crsContent, blkOp0);
99 const Teuchos::RCP<Thyra::BlockedLinearOpBase<ST> > blkOp =
100 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<ST> >(blockedOperator_,
true);
104 Teuchos::RCP<const Thyra::LinearOpBase<ST> > blockedOpBlocks[4][4];
105 for (
int i = 0; i <=
dim_; i++) {
106 for (
int j = 0; j <=
dim_; j++) {
107 blockedOpBlocks[i][j] = blkOp->getBlock(i, j);
114 std::cout <<
"Pressure mass matrix is null. Use identity." << std::endl;
116 invPressureMassMatrix_ = Thyra::identity<ST>(blockedOpBlocks[
dim_][0]->range());
119 Teuchos::RCP<Thyra::DefaultBlockedLinearOp<ST> > alOperator = Thyra::defaultBlockedLinearOp<ST>();
120 alOperator->beginBlockFill(
dim_ + 1,
dim_ + 1);
123 for (
int i = 0; i <
dim_; i++) {
124 for (
int j = 0; j <
dim_; j++) {
125 alOperator->setBlock(
128 blockedOpBlocks[i][j],
129 Thyra::scale(
gamma_, Thyra::multiply(blockedOpBlocks[i][
dim_], invPressureMassMatrix_,
130 blockedOpBlocks[
dim_][j]))));
135 for (
int j = 0; j <=
dim_; j++) {
136 alOperator->setBlock(
dim_, j, blockedOpBlocks[
dim_][j]);
140 for (
int i = 0; i <
dim_; i++) {
141 alOperator->setBlock(
144 blockedOpBlocks[i][
dim_],
145 Thyra::scale(-
gamma_, Thyra::multiply(blockedOpBlocks[i][
dim_], invPressureMassMatrix_,
149 alOperator->endBlockFill();
159 Teuchos::RCP<Thyra::DefaultBlockedLinearOp<ST> > alOpRhs = Thyra::defaultBlockedLinearOp<ST>();
160 alOpRhs->beginBlockFill(
dim_ + 1,
dim_ + 1);
162 for (
int i = 0; i <
dim_; i++) {
163 alOpRhs->setBlock(i, i, Thyra::identity<ST>(blockedOpBlocks[i][i]->range()));
165 alOpRhs->setBlock(
dim_,
dim_, Thyra::identity<ST>(blockedOpBlocks[
dim_][
dim_]->range()));
167 for (
int i = 0; i <
dim_; i++) {
170 Thyra::scale(
gamma_, Thyra::multiply(blockedOpBlocks[i][
dim_], invPressureMassMatrix_)));
173 alOpRhs->endBlockFill();
176 if (reorderManager_ != Teuchos::null)
Reorder(*reorderManager_);
180 Tpetra::MultiVector<ST, LO, GO, NT>& bAugmented) {
181 Teuchos::RCP<const Teko::TpetraHelpers::MappingStrategy> mapping = this->
getMapStrategy();
183 Teuchos::RCP<Thyra::MultiVectorBase<ST> > bThyra =
184 Thyra::createMembers(thyraOp_->range(), b.getNumVectors());
186 Teuchos::RCP<Thyra::MultiVectorBase<ST> > bThyraAugmented =
187 Thyra::createMembers(thyraOp_->range(), b.getNumVectors());
189 mapping->copyTpetraIntoThyra(b, bThyra.ptr());
190 alOperatorRhs_->apply(Thyra::NOTRANS, *bThyra, bThyraAugmented.ptr(), 1.0, 0.0);
191 mapping->copyThyraIntoTpetra(bThyraAugmented, bAugmented);
void augmentRHS(const Tpetra::MultiVector< ST, LO, GO, NT > &b, Tpetra::MultiVector< ST, LO, GO, NT > &bAugmented)
ALOperator(const std::vector< std::vector< GO > > &vars, const Teuchos::RCP< Tpetra::Operator< ST, LO, GO, NT > > &content, LinearOp pressureMassMatrix, double gamma=0.05, const std::string &label="<ANYM>")