13 #include <Trilinos_version.h> 14 #include <EpetraExt_Transpose_RowMatrix.h> 15 #include <EpetraExt_MatrixMatrix.h> 32 ASSERT_PRE(M_pList.isParameter(
"EstensionMatrix"),
"[TwoLevelPreconditioner::myCompute] pList should contain an EstensionMatrix");
33 ASSERT_PRE(M_pList.isSublist(
"CoarseLevel"),
"[TwoLevelPreconditioner::myCompute] pList should contain a CoarseLevel sublist");
34 ASSERT_PRE(M_pList.isSublist(
"FineLevel"),
"[TwoLevelPreconditioner::myCompute] pList should contain a FineLevel sublist");
35 ASSERT_PRE(M_rowMatrix.get() != 0,
"[TwoLevelPreconditioner::myCompute] You need to SetRowMatrix first");
38 E = M_pList.get<rowMatrixPtr_Type>(
"EstensionMatrix");
40 if(M_pList.isParameter(
"RestrictionMatrix"))
42 R = M_pList.get<rowMatrixPtr_Type>(
"RestrictionMatrix");
46 bool MakeDataContiguous =
true;
47 #if TRILINOS_MAJOR_VERSION < 11
48 EpetraExt::RowMatrix_Transpose transposer ( MakeDataContiguous );
50 EpetraExt::RowMatrix_Transpose transposer ( 0, !MakeDataContiguous );
52 R.reset(
new rowMatrix_Type(
dynamic_cast<rowMatrix_Type &>(transposer(*E))));
53 M_pList.set(
"RestricitionMatrix", R);
58 EPETRA_CHK_ERR(EpetraExt::MatrixMatrix::Multiply(*M_rowMatrix,
false, *E,
false, *AE));
59 EPETRA_CHK_ERR(EpetraExt::MatrixMatrix::Multiply(*R,
false, *AE,
false, *RAE));
61 std::shared_ptr<RowMatrixPreconditioner> S(RowMatrixPreconditionerFactory::instance().createObject(
"Ifpack"));
62 S->SetRowMatrix(M_rowMatrix);
63 S->SetParameterList(M_pList.sublist(
"FineLevel"));
64 EPETRA_CHK_ERR(S->Compute());
66 std::shared_ptr<ApproximatedInvertibleRowMatrix> Ac(
new ApproximatedInvertibleRowMatrix);
67 Ac->SetRowMatrix(RAE);
68 Ac->SetParameterList(M_pList.sublist(
"CoarseLevel"));
69 EPETRA_CHK_ERR(Ac->Compute());
73 prec->SetSmootherOperator(S);
76 prec->SetCoarseLevelOperator(Ac);
void SetRestrictionOperator(const operatorPtr_Type &restrictionOper)
Set the restriction operator from the fine to coarse level.
RowMatrixPreconditioner()
Empty constructor.
void updateInverseJacobian(const UInt &iQuadPt)
It defines a two level methods to approximately apply the inverse of a fine level operator...
std::shared_ptr< rowMatrix_Type > rowMatrixPtr_Type
void SetFineLevelOperator(const operatorPtr_Type &fineLevelOper)
Set the fine level operator.
virtual int myCompute()
Abstract method myCompute implemented by the derived class.
virtual ~TwoLevelPreconditioner()
void SetEstensionOperator(const operatorPtr_Type &estensionOper)
Set the extension operatoe from the coarse to fine level.
An operator that provides a two level approximation of the inverse of a Epetra_CsrMatrix object...
Abstract class to construct preconditioners from a matrix in Epetra_CsrFormat.
rowMatrixPtr_Type M_rowMatrix