LifeV
InvertibleOperator.cpp
Go to the documentation of this file.
1 #include <lifev/core/linear_algebra/InvertibleOperator.hpp>
2 #include <Teuchos_RCPBoostSharedPtrConversions.hpp>
3 
4 namespace LifeV
5 {
6 
7 namespace Operators
8 {
9 
11  M_name("InvertibleOperator"),
12  M_useTranspose(false)
13 { }
14 
15 int InvertibleOperator::SetUseTranspose(bool useTranspose)
16 {
17  M_useTranspose = useTranspose;
18 
19  int ierr(0);
20  if(M_useTranspose)
21  ierr = -1;
22 
23  return ierr;
24 }
25 
27 {
28  ASSERT_PRE(_oper.get() != this, "Can't self assign");
29  ASSERT_PRE(_oper.get() != 0, "Can't assign a null pointer");
30 
31  // Since Teuchos and boost have different reference counter, we make sure that a copy
32  // of the object is available to this class, using a boost to keep the bost count >0
33  M_operBoost = _oper;
34  M_oper.reset(_oper.get(),false);
36 }
37 
39 {
40  ASSERT_PRE(_prec.get() != this, "Self Assignment is forbidden");
41  ASSERT_PRE(_prec.get() != 0, "Can't assign a null pointer");
42 
43  // Since Teuchos and boost have different reference counter, we make sure that a copy
44  // of the object is available to this class, using a boost to keep the bost count >0
45  M_precBoost = _prec;
46  M_prec.reset(_prec.get(),false);
48 }
49 
50 void InvertibleOperator::setParameterList(const Teuchos::ParameterList& _pList)
51 {
52  M_pList = Teuchos::rcp(new Teuchos::ParameterList(_pList), true);
54 }
55 
57 {
58  ASSERT_PRE(M_oper.assert_valid_ptr().get() != 0, "M_oper must be assigned");
59  ASSERT_PRE(X.Map().SameAs(M_oper->OperatorDomainMap()), "X and domain map do no coincide \n");
60  ASSERT_PRE(Y.Map().SameAs(M_oper->OperatorRangeMap()) , "Y and range map do no coincide \n");
61 
62  return M_oper->Apply(X,Y);
63 }
64 
66 {
67  ASSERT_PRE(M_oper.assert_valid_ptr().get() != 0, "M_oper must be assigned \n");
68  ASSERT_PRE(Y.Map().SameAs(M_oper->OperatorDomainMap()), "Y and domain map do no coincide \n");
69  ASSERT_PRE(X.Map().SameAs(M_oper->OperatorRangeMap()) , "X and range map do no coincide \n");
70 
71  if (M_useTranspose)
72  return -1;
73 
74  return doApplyInverse(X,Y);
75 }
76 
77 } // Namespace Operators
78 
79 } // Namespace LifeV
bool M_useTranspose
Whenever to use the transpose.
void updateInverseJacobian(const UInt &iQuadPt)
virtual int doApplyInverse(const vector_Type &X, vector_Type &Y) const =0
virtual int Apply(const vector_Type &X, vector_Type &Y) const
Returns the result of a Epetra_Operator applied to a vector_Type X in Y.
Abstract class which defines the interface of an Invertible Linear Operator Algebra.
#define ASSERT_PRE(X, A)
Definition: LifeAssert.hpp:96
virtual int ApplyInverse(const vector_Type &X, vector_Type &Y) const
Returns the result of a Epetra_Operator inverse applied to an vector_Type X in Y. ...
void setPreconditioner(const operatorPtr_Type &_prec)
void setOperator(const operatorPtr_Type &_oper)
virtual int SetUseTranspose(bool useTranspose)
If set true, transpose of this operator will be applied.
std::shared_ptr< operator_Type > operatorPtr_Type
void setParameterList(const Teuchos::ParameterList &_pList)