7 #include "Teko_BlockedEpetraOperator.hpp"
8 #include "Teko_BlockedMappingStrategy.hpp"
9 #include "Teko_ReorderedMappingStrategy.hpp"
11 #include "Teuchos_VerboseObject.hpp"
13 #include "Thyra_LinearOpBase.hpp"
14 #include "Thyra_EpetraLinearOp.hpp"
15 #include "Thyra_EpetraThyraWrappers.hpp"
16 #include "Thyra_DefaultProductMultiVector.hpp"
17 #include "Thyra_DefaultProductVectorSpace.hpp"
18 #include "Thyra_DefaultBlockedLinearOp.hpp"
19 #include "Thyra_get_Epetra_Operator.hpp"
21 #include "EpetraExt_MultiVectorOut.h"
22 #include "EpetraExt_RowMatrixOut.h"
26 #include "Teko_ALOperator.hpp"
33 const Teuchos::RCP<Epetra_Operator>& content, LinearOp pressureMassMatrix,
34 double gamma,
const std::string& label)
35 : Teko::Epetra::BlockedEpetraOperator(vars, content, label),
36 pressureMassMatrix_(pressureMassMatrix),
44 const Teuchos::RCP<Epetra_Operator>& content,
double gamma,
45 const std::string& label)
46 : Teko::Epetra::BlockedEpetraOperator(vars, content, label),
47 pressureMassMatrix_(Teuchos::null),
55 if (pressureMassMatrix != Teuchos::null) {
61 TEUCHOS_ASSERT(gamma > 0.0);
66 const Teuchos::RCP<Thyra::BlockedLinearOpBase<double> > blkOp =
67 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<double> >(blockedOperator_,
true);
69 return Thyra::get_Epetra_Operator(*blkOp->getBlock(i, j));
73 dim_ = vars.size() - 1;
74 TEUCHOS_ASSERT(
dim_ == 2 ||
dim_ == 3);
78 TEUCHOS_ASSERT(blockedMapping_ != Teuchos::null);
81 const Teuchos::RCP<const Epetra_CrsMatrix> crsContent =
82 Teuchos::rcp_dynamic_cast<
const Epetra_CrsMatrix>(fullContent_);
85 if (blockedOperator_ == Teuchos::null) {
86 blockedOperator_ = blockedMapping_->buildBlockedThyraOp(crsContent, label_);
88 const Teuchos::RCP<Thyra::BlockedLinearOpBase<double> > blkOp =
89 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<double> >(blockedOperator_,
true);
90 blockedMapping_->rebuildBlockedThyraOp(crsContent, blkOp);
94 const Teuchos::RCP<Thyra::BlockedLinearOpBase<double> > blkOp =
95 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<double> >(blockedOperator_,
true);
97 Teuchos::RCP<const Thyra::LinearOpBase<double> > blockedOpBlocks[4][4];
98 for (
int i = 0; i <=
dim_; i++) {
99 for (
int j = 0; j <=
dim_; j++) {
100 blockedOpBlocks[i][j] = blkOp->getBlock(i, j);
110 std::cout <<
"Pressure mass matrix is null. Use identity." << std::endl;
116 Teuchos::RCP<Thyra::DefaultBlockedLinearOp<double> > alOperator =
117 Thyra::defaultBlockedLinearOp<double>();
118 alOperator->beginBlockFill(
dim_ + 1,
dim_ + 1);
121 for (
int i = 0; i <
dim_; i++) {
122 for (
int j = 0; j <
dim_; j++) {
124 alOperator->setBlock(
127 blockedOpBlocks[i][j],
129 blockedOpBlocks[dim_][j]))));
134 for (
int j = 0; j <=
dim_; j++) {
135 alOperator->setBlock(dim_, j, blockedOpBlocks[dim_][j]);
139 for (
int i = 0; i <
dim_; i++) {
140 alOperator->setBlock(
143 blockedOpBlocks[i][dim_],
145 blockedOpBlocks[dim_][dim_]))));
148 alOperator->endBlockFill();
151 SetOperator(alOperator,
false);
154 Teuchos::RCP<Thyra::DefaultBlockedLinearOp<double> > alOpRhs_ =
155 Thyra::defaultBlockedLinearOp<double>();
156 alOpRhs_->beginBlockFill(dim_ + 1, dim_ + 1);
159 for (
int i = 0; i <
dim_; i++) {
161 alOpRhs_->setBlock(i, i, Thyra::identity<double>(blockedOpBlocks[0][0]->range()));
163 alOpRhs_->setBlock(dim_, dim_, Thyra::identity<double>(blockedOpBlocks[dim_][dim_]->range()));
166 for (
int i = 0; i <
dim_; i++) {
172 alOpRhs_->endBlockFill();
177 if (reorderManager_ != Teuchos::null)
Reorder(*reorderManager_);
181 Teuchos::RCP<const Teko::Epetra::MappingStrategy> mapping = this->
getMapStrategy();
182 Teuchos::RCP<Thyra::MultiVectorBase<double> > bThyra =
183 Thyra::createMembers(thyraOp_->range(), b.NumVectors());
184 Teuchos::RCP<Thyra::MultiVectorBase<double> > bThyraAugmented =
185 Thyra::createMembers(thyraOp_->range(), b.NumVectors());
188 mapping->copyEpetraIntoThyra(b, bThyra.ptr());
190 alOperatorRhs_->apply(Thyra::NOTRANS, *bThyra, bThyraAugmented.ptr(), 1.0, 0.0);
192 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)