25 ASSERT_PRE(fineLevelOper.get() != 0,
"TwoLevelOperator::SetFineLevelOperator Invalid Pointer");
31 ASSERT_PRE(smootherOper.get() != 0,
"TwoLevelOperator::SetFineLevelOperator Invalid Pointer");
38 ASSERT_PRE(coarseLevelOper.get() != 0,
"TwoLevelOperator::SetCoarseLevelOperator Invalid Pointer");
44 ASSERT_PRE(restrictionOper.get() !=0,
"TwoLevelOperator::SetRestrictionOperator Invalid Pointer");
50 ASSERT_PRE(estensionOper.get() !=0,
"TwoLevelOperator::SetEstensionOperator Invalid Pointer");
57 bool verbose( 0 == M_fineLevelOper->Comm().MyPID() );
60 if( &(M_fineLevelOper->Comm()) != &(M_coarseLevelOper->Comm()))
64 std::cout<<
"[TwoLevelOperator::checkConsistency] Comm must be the same for all operators! \n";
71 if(! M_fineLevelOper->OperatorRangeMap().SameAs(M_restrictionOper->OperatorDomainMap()))
74 std::cout<<
"[TwoLevelOperator::checkConsistency] Not compatible maps! \n";
78 if( ! M_restrictionOper->OperatorRangeMap().SameAs(M_coarseLevelOper->OperatorRangeMap()))
81 std::cout<<
"[TwoLevelOperator::checkConsistency] Not compatible maps! \n";
85 if( ! M_coarseLevelOper->OperatorDomainMap().SameAs(M_estensionOper->OperatorDomainMap()))
88 std::cout<<
"[TwoLevelOperator::checkConsistency] Not compatible maps! \n";
92 if( ! M_estensionOper->OperatorRangeMap().SameAs(M_fineLevelOper->OperatorDomainMap()))
95 std::cout<<
"[TwoLevelOperator::checkConsistency] Not compatible maps! \n";
113 return M_fineLevelOper->Apply(X,Y);
121 "[TwoLevelOperator::ApplyInverse] X and Y should have the same number of vectors.");
122 ASSERT_PRE(X.Map().SameAs(M_smootherOper->OperatorRangeMap()),
123 "[TwoLevelOperator::ApplyInverse] The map of X is not compatible with this operator.");
124 ASSERT_PRE(Y.Map().SameAs(M_smootherOper->OperatorDomainMap()),
125 "[TwoLevelOperator::ApplyInverse] The map of X is not compatible with this operator.");
127 UInt nVectors(X.NumVectors());
129 vector_Type Z(Y.Map(), nVectors), Rfine(Y.Map(), nVectors), Yfine(Y.Map(), nVectors);
130 vector_Type Rcoarse(M_coarseLevelOper->OperatorDomainMap(), nVectors);
131 vector_Type Ycoarse(M_coarseLevelOper->OperatorDomainMap(), nVectors);
135 EPETRA_CHK_ERR(M_smootherOper->ApplyInverse(X,Yfine));
136 EPETRA_CHK_ERR(M_fineLevelOper->Apply(Yfine, Z));
137 EPETRA_CHK_ERR(Rfine.Update(1.0, X, -1.0, Z, 0.0));
140 EPETRA_CHK_ERR(M_restrictionOper->Apply(Rfine,Rcoarse));
141 EPETRA_CHK_ERR(M_coarseLevelOper->ApplyInverse(Rcoarse, Ycoarse));
143 EPETRA_CHK_ERR(M_estensionOper->Apply(Ycoarse, Y));
144 EPETRA_CHK_ERR(Yfine.Update(1.0, Y, 1.0));
146 EPETRA_CHK_ERR(M_fineLevelOper->Apply(Y, Z));
147 EPETRA_CHK_ERR(Rfine.Update(-1.0, Z, 1.0));
151 EPETRA_CHK_ERR(M_smootherOper->ApplyInverse(Rfine,Y));
152 EPETRA_CHK_ERR(Y.Update(1.0, Yfine, 1.0));
159 return M_fineLevelOper->NormInf();
165 return "TwoLevelOperator";
175 return M_fineLevelOper->HasNormInf();
180 return M_fineLevelOper->Comm();
185 return M_fineLevelOper->OperatorDomainMap();
190 return M_fineLevelOper->OperatorRangeMap();
virtual int ApplyInverse(const vector_Type &X, vector_Type &Y) const
Returns the result of a raw_operator inverse applied to an raw_vector X in Y.
virtual const map_Type & OperatorRangeMap() const
Returns the raw_map object associated with the range of this operator.
virtual ~TwoLevelOperator()
virtual int Apply(const vector_Type &X, vector_Type &Y) const
Returns the result of a raw_operator applied to a raw_vector X in Y.
void SetSmootherOperator(const operatorPtr_Type &smootherOper)
Set the fine level smoother (smootherOper should have a ApplyInverse method)
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual const char * Label() const
Returns a character string describing the operator.
void SetRestrictionOperator(const operatorPtr_Type &restrictionOper)
Set the restriction operator from the fine to coarse level.
virtual const map_Type & OperatorDomainMap() const
Returns the raw_map object associated with the domain of this operator.
Abstract class which defines the interface of a Linear Operator.
void updateInverseJacobian(const UInt &iQuadPt)
virtual double NormInf() const
Returns the infinity norm of the global matrix.
It defines a two level methods to approximately apply the inverse of a fine level operator...
operatorPtr_Type M_restrictionOper
operatorPtr_Type M_estensionOper
operatorPtr_Type M_coarseLevelOper
int checkConsistency()
Check that the range and domains of all operators are compatible.
operatorPtr_Type M_smootherOper
void SetFineLevelOperator(const operatorPtr_Type &fineLevelOper)
Set the fine level operator.
virtual int SetUseTranspose(bool UseTranspose)
void SetCoarseLevelOperator(const operatorPtr_Type &coarseLevelOper)
Set the coarse level solver (coarseLevelOper should have a ApplyInverse method)
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
operatorPtr_Type M_fineLevelOper
Epetra_MultiVector vector_Type
void SetEstensionOperator(const operatorPtr_Type &estensionOper)
Set the extension operatoe from the coarse to fine level.
virtual const comm_Type & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
std::shared_ptr< operator_Type > operatorPtr_Type