LifeV
ApproximatedInvertibleRowMatrix.cpp
Go to the documentation of this file.
1 /*
2  * ApproximatedInvertibleRowMatrix.cpp
3  *
4  * Created on: Oct 13, 2011
5  * Author: uvilla
6  */
7 
9 
10 namespace LifeV
11 {
12 
13 namespace Operators
14 {
15 
19 { }
20 
22 { }
23 
25 {
26  ASSERT_PRE(rowMatrix.get() != 0,
27  "[ApproximatedInvertibleRowMatrix::SetRowMatrix] rowMatrix should be a valid pointer");
28  ASSERT_PRE(rowMatrix->OperatorRangeMap().SameAs(rowMatrix->OperatorDomainMap()),
29  "[ApproximatedInvertibleRowMatrix::SetRowMatrix] should be a square matrix");
30 
31  M_rowMatrix = rowMatrix;
32 }
33 
35 {
36  ASSERT_PRE(pList.isParameter("use preconditioner as approximated inverse"),
37  "[ApproximatedInvertibleRowMatrix::SetParameterList] Not a valid list");
38  ASSERT_PRE(pList.isParameter("preconditioner type"),
39  "[ApproximatedInvertibleRowMatrix::SetParameterList] Not a valid list");
40  ASSERT_PRE(pList.isSublist("solver"),
41  "[ApproximatedInvertibleRowMatrix::SetParameterList] Not a valid list");
42  ASSERT_PRE(pList.isSublist("preconditioner"),
43  "[ApproximatedInvertibleRowMatrix::SetParameterList] Not a valid list");
44 
45  M_pList = pList;
46 
47 }
48 
50 {
51  return -1;
52 }
53 
55 {
56  // Allocate the preconditioner and after allocate the solver
57  std::string precType( M_pList.get<std::string>("preconditioner type") );
58 
59  M_prec.reset( RowMatrixPreconditionerFactory::instance().createObject(precType));
60  M_prec->SetRowMatrix(M_rowMatrix);
61  M_prec->SetParameterList(M_pList.sublist("preconditioner").sublist(precType));
62 
63  EPETRA_CHK_ERR( M_prec->Compute() );
64 
65  std::string solverType(M_pList.sublist("solver").get<std::string>("Linear Solver Type"));
66  M_linSolver.reset( InvertibleOperatorFactory::instance().createObject(solverType));
67  M_linSolver->setOperator(M_rowMatrix);
68  M_linSolver->setPreconditioner(M_prec);
69  M_linSolver->setParameterList(M_pList.sublist("solver").sublist(solverType));
70 
71  usePreconditionerAsApproximatedInverse = M_pList.get<bool>("use preconditioner as approximated inverse");
72 
73  return 0;
74 
75 }
76 
78 {
79  return M_rowMatrix->Apply(X,Y);
80 }
81 
83 {
84  int ierr;
85  if(usePreconditionerAsApproximatedInverse)
86  ierr = M_prec->ApplyInverse(X,Y);
87  else
88  ierr = M_linSolver->ApplyInverse(X,Y);
89 
90  return ierr;
91 }
92 
94 {
95  return M_rowMatrix->NormInf();
96 }
97 
99 {
100  return "ApproximatedInvertibleRowMatrix";
101 }
102 
104 {
105  return -1;
106 }
107 
109 {
110  return M_rowMatrix->HasNormInf();
111 }
112 
114 {
115  return M_rowMatrix->Comm();
116 }
117 
119 {
120  return M_rowMatrix->OperatorDomainMap();
121 }
122 
124 {
125  return M_rowMatrix->OperatorRangeMap();
126 }
127 
128 } // Namespace Operators
129 
130 } // Namespace LifeV
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.
virtual const map_Type & OperatorDomainMap() const
Returns the raw_map object associated with the domain of this operator.
virtual const map_Type & OperatorRangeMap() const
Returns the raw_map object associated with the range of this operator.
#define ASSERT_PRE(X, A)
Definition: LifeAssert.hpp:96
virtual const comm_Type & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual int SetUseTranspose(bool UseTranspose)
not fully supported!
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
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.
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.
Provide the ApplyInverse method for a Epetra_CrsMatrix object.
virtual const char * Label() const
Returns a character string describing the operator.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.