LifeV
LumpedOperator.cpp
Go to the documentation of this file.
1 /*
2  * LumpedOperator.cpp
3  *
4  * Created on: Sep 17, 2010
5  * Author: uvilla
6  */
7 
8 #include <lifev/core/linear_algebra/LumpedOperator.hpp>
9 
10 namespace LifeV
11 {
12 namespace Operators
13 {
15  M_name("LumpedOperator"),
16  M_normInf(-1),
17  M_useTranspose(false),
18  M_alpha(1.0)
19 {
20  // Nothing to be done here
21 }
22 
23 void LumpedOperator::setUp(const rowMatrixPtr_Type & _matrix)
24 {
25  ASSERT_PRE( _matrix->OperatorRangeMap().PointSameAs( _matrix->OperatorDomainMap()),
26  "The matrix we want to lump must be square");
27  M_matrix = _matrix;
28 }
29 
31 {
32  M_lumped.reset(new Epetra_Vector( M_matrix->OperatorRangeMap()) );
33  M_matrix->ExtractDiagonalCopy(*M_lumped);
34  lumpedMatrix_Type ones(M_matrix->OperatorDomainMap()), m1(M_matrix->OperatorRangeMap());
35  ones.PutScalar(1.0); m1.PutScalar(0.0);
36  EPETRA_CHK_ERR(M_matrix->Multiply(false, ones, m1));
37  Real totalMass, lumpMass;
38  ones.Dot(m1, &totalMass);
39  ones.Dot(*M_lumped, &lumpMass);
40  M_lumped->Scale(totalMass/lumpMass);
41  M_lumped->NormInf(&M_normInf);
42 
43  return 0;
44 }
45 
46 int LumpedOperator::Apply(const vector_Type& X, vector_Type& Y) const
47  {
48  ASSERT_PRE(X.NumVectors() == Y.NumVectors(), "X and Y must have the same number of vectors");
49  ASSERT_PRE(X.Map().PointSameAs(M_lumped->Map()), "X map should be the same of M_lumped");
50  ASSERT_PRE(Y.Map().PointSameAs(M_lumped->Map()), "Y map should be the same of M_lumped");
51 
52  return Y.Multiply(M_alpha, X, *M_lumped, 0.0);
53  }
54 
56  {
57  ASSERT_PRE(X.NumVectors() == Y.NumVectors(), "X and Y must have the same number of vectors");
58  ASSERT_PRE(X.Map().PointSameAs(M_lumped->Map()), "X map should be the same of M_lumped");
59  ASSERT_PRE(Y.Map().PointSameAs(M_lumped->Map()), "Y map should be the same of M_lumped");
60 
61  return Y.ReciprocalMultiply(1.0/M_alpha, *M_lumped, X, 0.0);
62  }
63 
64 } /* end namespace Operators */
65 } /*end namespace*/
Real M_alpha
the scalar coefficient for scaling the operator
bool M_useTranspose
whenever to use the transpose
void updateInverseJacobian(const UInt &iQuadPt)
void setUp(const rowMatrixPtr_Type &_matrix)
SetUp.
#define ASSERT_PRE(X, A)
Definition: LifeAssert.hpp:96
int ApplyInverse(const vector_Type &X, vector_Type &Y) const
Apply the inverse of the operator.
Real M_normInf
the infinity norm of the operator
int Apply(const vector_Type &X, vector_Type &Y) const
Apply the Operator.
A class for Mass Lumping The lumped mass matrix is such that (1) The total mass is conserved (2) {M}_...
double Real
Generic real data.
Definition: LifeV.hpp:175
boost::shared_ptr< rowMatrix_Type > rowMatrixPtr_Type
int compute()
compute the lumpded operator