16 #include "Teko_BlockedEpetraOperator.hpp"
17 #include "Teko_BlockedMappingStrategy.hpp"
18 #include "Teko_ReorderedMappingStrategy.hpp"
20 #include "Teuchos_VerboseObject.hpp"
22 #include "Thyra_LinearOpBase.hpp"
23 #include "Thyra_EpetraLinearOp.hpp"
24 #include "Thyra_EpetraThyraWrappers.hpp"
25 #include "Thyra_DefaultProductMultiVector.hpp"
26 #include "Thyra_DefaultProductVectorSpace.hpp"
27 #include "Thyra_DefaultBlockedLinearOp.hpp"
28 #include "Thyra_get_Epetra_Operator.hpp"
30 #include "EpetraExt_MultiVectorOut.h"
31 #include "EpetraExt_RowMatrixOut.h"
35 #include "Teko_ALOperator.hpp"
42 const Teuchos::RCP<Epetra_Operator>& content, LinearOp pressureMassMatrix,
43 double gamma,
const std::string& label)
44 : Teko::Epetra::BlockedEpetraOperator(vars, content, label),
45 pressureMassMatrix_(pressureMassMatrix),
53 const Teuchos::RCP<Epetra_Operator>& content,
double gamma,
54 const std::string& label)
55 : Teko::Epetra::BlockedEpetraOperator(vars, content, label),
56 pressureMassMatrix_(Teuchos::null),
64 if (pressureMassMatrix != Teuchos::null) {
70 TEUCHOS_ASSERT(gamma > 0.0);
75 const Teuchos::RCP<Thyra::BlockedLinearOpBase<double> > blkOp =
76 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<double> >(blockedOperator_,
true);
78 return Thyra::get_Epetra_Operator(*blkOp->getBlock(i, j));
82 dim_ = vars.size() - 1;
83 TEUCHOS_ASSERT(
dim_ == 2 ||
dim_ == 3);
87 TEUCHOS_ASSERT(blockedMapping_ != Teuchos::null);
90 const Teuchos::RCP<const Epetra_CrsMatrix> crsContent =
91 Teuchos::rcp_dynamic_cast<
const Epetra_CrsMatrix>(fullContent_);
94 if (blockedOperator_ == Teuchos::null) {
95 blockedOperator_ = blockedMapping_->buildBlockedThyraOp(crsContent, label_);
97 const Teuchos::RCP<Thyra::BlockedLinearOpBase<double> > blkOp =
98 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<double> >(blockedOperator_,
true);
99 blockedMapping_->rebuildBlockedThyraOp(crsContent, blkOp);
103 const Teuchos::RCP<Thyra::BlockedLinearOpBase<double> > blkOp =
104 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<double> >(blockedOperator_,
true);
106 Teuchos::RCP<const Thyra::LinearOpBase<double> > blockedOpBlocks[4][4];
107 for (
int i = 0; i <=
dim_; i++) {
108 for (
int j = 0; j <=
dim_; j++) {
109 blockedOpBlocks[i][j] = blkOp->getBlock(i, j);
119 std::cout <<
"Pressure mass matrix is null. Use identity." << std::endl;
125 Teuchos::RCP<Thyra::DefaultBlockedLinearOp<double> > alOperator =
126 Thyra::defaultBlockedLinearOp<double>();
127 alOperator->beginBlockFill(
dim_ + 1,
dim_ + 1);
130 for (
int i = 0; i <
dim_; i++) {
131 for (
int j = 0; j <
dim_; j++) {
133 alOperator->setBlock(
136 blockedOpBlocks[i][j],
138 blockedOpBlocks[dim_][j]))));
143 for (
int j = 0; j <=
dim_; j++) {
144 alOperator->setBlock(dim_, j, blockedOpBlocks[dim_][j]);
148 for (
int i = 0; i <
dim_; i++) {
149 alOperator->setBlock(
152 blockedOpBlocks[i][dim_],
154 blockedOpBlocks[dim_][dim_]))));
157 alOperator->endBlockFill();
160 SetOperator(alOperator,
false);
163 Teuchos::RCP<Thyra::DefaultBlockedLinearOp<double> > alOpRhs_ =
164 Thyra::defaultBlockedLinearOp<double>();
165 alOpRhs_->beginBlockFill(dim_ + 1, dim_ + 1);
168 for (
int i = 0; i <
dim_; i++) {
170 alOpRhs_->setBlock(i, i, Thyra::identity<double>(blockedOpBlocks[0][0]->range()));
172 alOpRhs_->setBlock(dim_, dim_, Thyra::identity<double>(blockedOpBlocks[dim_][dim_]->range()));
175 for (
int i = 0; i <
dim_; i++) {
181 alOpRhs_->endBlockFill();
186 if (reorderManager_ != Teuchos::null)
Reorder(*reorderManager_);
190 Teuchos::RCP<const Teko::Epetra::MappingStrategy> mapping = this->
getMapStrategy();
191 Teuchos::RCP<Thyra::MultiVectorBase<double> > bThyra =
192 Thyra::createMembers(thyraOp_->range(), b.NumVectors());
193 Teuchos::RCP<Thyra::MultiVectorBase<double> > bThyraAugmented =
194 Thyra::createMembers(thyraOp_->range(), b.NumVectors());
197 mapping->copyEpetraIntoThyra(b, bThyra.ptr());
199 alOperatorRhs_->apply(Thyra::NOTRANS, *bThyra, bThyraAugmented.ptr(), 1.0, 0.0);
201 mapping->copyThyraIntoEpetra(bThyraAugmented, bAugmented);
Teuchos::RCP< Thyra::LinearOpBase< double > > alOperatorRhs_
void augmentRHS(const Epetra_MultiVector &b, Epetra_MultiVector &bAugmented)
LinearOp invPressureMassMatrix_
void checkDim(const std::vector< std::vector< int > > &vars)
void Reorder(const BlockReorderManager &brm)
void setPressureMassMatrix(LinearOp pressureMassMatrix)
virtual void SetContent(const std::vector< std::vector< int > > &vars, const Teuchos::RCP< const Epetra_Operator > &content)
const RCP< const MappingStrategy > getMapStrategy() const
Get the mapping strategy for this wrapper (translate between Thyra and Epetra)
LinearOp pressureMassMatrix_
const Teuchos::RCP< const Epetra_Operator > GetBlock(int i, int j) const
ALOperator(const std::vector< std::vector< int > > &vars, const Teuchos::RCP< Epetra_Operator > &content, LinearOp pressureMassMatrix, double gamma=0.05, const std::string &label="<ANYM>")
void setGamma(double gamma)