39 #ifdef LIFEV_HAVE_TEKO 44 PreconditionerTeko::PreconditionerTeko (
const std::shared_ptr<Epetra_Comm>& comm ) :
45 PreconditionerBlock ( comm ), M_prec()
50 PreconditionerTeko::PreconditionerTeko ( PreconditionerTeko& P,
const std::shared_ptr<Epetra_Comm>& comm ) :
51 PreconditionerBlock ( P, comm )
56 PreconditionerTeko::~PreconditionerTeko()
61 PreconditionerTeko::operatorPtr_Type
62 PreconditionerTeko::preconditionerPtr()
67 PreconditionerTeko::operator_Type*
68 PreconditionerTeko::preconditioner()
74 PreconditionerTeko::resetPreconditioner()
79 this->M_preconditionerCreated =
false;
83 PreconditionerTeko::isPreconditionerSet()
const 85 return M_prec != 0 ?
true :
false;
89 PreconditionerTeko::SetUseTranspose (
const bool useTranspose )
91 return M_prec->SetUseTranspose ( useTranspose );
95 PreconditionerTeko::UseTranspose()
97 return M_prec->UseTranspose();
100 PreconditionerTeko::ApplyInverse (
const Epetra_MultiVector& X, Epetra_MultiVector& Y )
const 102 return M_prec->ApplyInverse ( X, Y );
106 PreconditionerTeko::Apply (
const Epetra_MultiVector& X, Epetra_MultiVector& Y )
const 108 return M_prec->Apply ( X, Y );
112 PreconditionerTeko::OperatorRangeMap()
const 114 return M_prec->OperatorRangeMap();
118 PreconditionerTeko::OperatorDomainMap()
const 120 return M_prec->OperatorRangeMap();
124 PreconditionerTeko::buildBlockGIDs ( std::vector<std::vector<
int> >& gids,
125 const MapEpetra& map,
126 const std::vector<
int>& blockSizes )
128 int numLocal = map.map ( Unique )->NumMyElements();
129 int numBlocks = blockSizes.size();
132 gids.resize ( blockSizes.size() );
135 int cumulBlocksSizes = 0;
137 for (
int i ( 0 ); i < numLocal; ++i )
139 gid = map.map ( Unique )->GID ( i );
140 cumulBlocksSizes = 0;
141 for (
int j ( 0 ); j < numBlocks; ++j )
143 cumulBlocksSizes += blockSizes[j];
144 if ( gid <= cumulBlocksSizes )
146 gids[j].push_back ( gid );
154 PreconditionerTeko::buildPreconditionerTeko ( RCP<Teko::BlockPreconditionerFactory> precFact,
155 matrixPtr_Type& oper,
156 const std::vector<
int>& blockSizes )
159 Teko::Epetra::EpetraBlockPreconditioner* prec =
new Teko::Epetra::EpetraBlockPreconditioner ( precFact );
161 M_oper = oper->matrixPtr();
163 std::vector<std::vector<
int> > vec;
164 buildBlockGIDs ( vec, oper->rangeMap(), blockSizes );
167 Teuchos::RCP<Teko::Epetra::BlockedEpetraOperator> sA
168 = Teuchos::rcp (
new Teko::Epetra::BlockedEpetraOperator ( vec, Teuchos::rcp ( M_oper.get() ) ) );
170 M_prec.reset ( prec );
173 M_prec->buildPreconditioner ( sA );
178 ERROR_MSG (
"Preconditioner not set, something went wrong in its computation\n" );
181 this->M_preconditionerCreated =
true;