Commit fbab6ab5 authored by Radu Popescu's avatar Radu Popescu
Browse files

Removing obsolete LinearEpetraOperator files

parent 5562eb50
//@HEADER
/*
*******************************************************************************
Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
This file is part of LifeV.
LifeV is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LifeV is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with LifeV. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
//@HEADER
/*!
@file
@brief Some linear operators which inherit from Epetra_Operator
@author Umberto Villa <uvilla.@emory.edu>
@date 03-09-2010
In this file we define a Lifev::Operators:LinearOperator which inherit from Epetra_Operator.
LinearOperator adds to the interface of Epetra_Operator a method "Apply" and "ApplyInverse"
which work with LifeV::VectorEpetra instead of Epetra_MultiVector.
LinearOperator is an abstract class with virtual public interface.
IdentityOperator and NullOperator are defined in this file and both inherit from LinearOperator.
*/
#ifndef LINEAREPETRAOPERATOR_H
#define LINEAREPETRAOPERATOR_H 1
#include <life/lifecore/LifeV.hpp>
// Tell the compiler to ignore specific kind of warnings:
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wextra"
#include <Epetra_Comm.h>
#include <Epetra_Map.h>
#include <Epetra_Operator.h>
#include <Epetra_MultiVector.h>
// Tell the compiler to ignore specific kind of warnings:
#pragma GCC diagnostic warning "-Wunused-variable"
#pragma GCC diagnostic warning "-Wunused-parameter"
#pragma GCC diagnostic warning "-Wextra"
#include <life/lifearray/VectorEpetra.hpp>
namespace LifeV
{
namespace Operators
{
//! @class LinearOperator
/*! @brief Abstract class which defines the interface of a Linear Operator.
*
* LinearOperator is an abstract which inherits from Epetra_Operator.
* LinearOperator should be the base class for all the LifeV class which implements a linear operator.
*
* LinearOperator ensures perfect compatibility with all the Trilinos solvers,
* plus it supports directly the LifeV::VectorEpetra data.
*
* Two concrete methods are implemented in LinearOperator
* int apply(const VectorEpetra &X, VectorEpetra & Y) const ;
* int applyInverse(const VectorEpetra &X, VectorEpetra &Y) const.
*
*
* Such methods extract a raw Epetra_MultiVector from the VectorEpetra and then call the virtual methods
* Int Apply(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const
* or
* Int ApplyInverse(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const
* respectively.
*
*
*/
class LinearOperator : public Epetra_Operator
{
public:
//! @name Destructor
//@{
//! Destructor
virtual ~LinearOperator() {};
//@}
//! @name Attribute set methods
//@{
//! If set true, transpose of this operator will be applied.
/*! This flag allows the transpose of the given operator to be used implicitly. Setting this flag
affects only the Apply() and ApplyInverse() methods. If the implementation of this interface
does not support transpose use, this method should return a value of -1.
\param In
UseTranspose -If true, multiply by the transpose of operator, otherwise just use operator.
\return Integer error code, set to 0 if successful. Set to -1 if this implementation does not support transpose.
*/
virtual int SetUseTranspose(bool UseTranspose) = 0;
//@}
//! @name Mathematical functions
//@{
//! Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
/*!
\param In
X - A Epetra_MultiVector of dimension NumVectors to multiply with matrix.
\param Out
Y -A Epetra_MultiVector of dimension NumVectors containing result.
\return Integer error code, set to 0 if successful.
*/
virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const = 0;
//! Returns the result of a LinearOperator applied to a VectorEpetra X in Y.
/*!
\param In
X - A VectorEpetra to multiply with matrix.
\param Out
Y -A VectorEpetra containing result.
\return Integer error code, set to 0 if successful.
*/
inline int apply(const VectorEpetra & X, VectorEpetra & Y) const
{
return Apply(X.epetraVector(), Y.epetraVector());
}
//! Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y.
/*!
\param In
X - A Epetra_MultiVector of dimension NumVectors to solve for.
\param Out
Y -A Epetra_MultiVector of dimension NumVectors containing result.
\return Integer error code, set to 0 if successful.
\warning In order to work with AztecOO, any implementation of this method must
support the case where X and Y are the same object.
*/
virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const = 0;
//! Returns the result of a LinearOperator inverse applied to an VectorEpetra X in Y.
/*!
\param In
X - A VectorEpetra to solve for.
\param Out
Y -A VectorEpetra containing result.
\return Integer error code, set to 0 if successful.
\warning In order to work with AztecOO, any implementation of this method must
support the case where X and Y are the same object.
*/
inline int applyInverse(const VectorEpetra & X, VectorEpetra Y)
{
return ApplyInverse(X.epetraVector(), Y.epetraVector());
}
//! Returns the infinity norm of the global matrix.
/* Returns the quantity \f$ \| A \|_\infty\f$ such that
\f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f].
\warning This method must not be called unless HasNormInf() returns true.
*/
virtual double NormInf() const = 0;
//@}
//! @name Attribute access functions
//@{
//! Returns a character string describing the operator
virtual const char * Label() const = 0;
//! Returns the current UseTranspose setting.
virtual bool UseTranspose() const = 0;
//! Returns true if the \e this object can provide an approximate Inf-norm, false otherwise.
virtual bool HasNormInf() const = 0;
//! Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual const Epetra_Comm & Comm() const = 0;
//! Returns the Epetra_Map object associated with the domain of this operator.
virtual const Epetra_Map & OperatorDomainMap() const = 0;
//! Returns the Epetra_Map object associated with the range of this operator.
virtual const Epetra_Map & OperatorRangeMap() const = 0;
//@}
};
//! @class IdentityOperator
/*! @brief Identity operator x = I*x. */
class IdentityOperator : public LinearOperator
{
public:
IdentityOperator():M_name("identity"), M_useTranspose(false) {};
void setUp(const boost::shared_ptr<Epetra_Map> & map) {M_map = map;}
int SetUseTranspose(bool useTranspose) {M_useTranspose = useTranspose; return 0; }
int Apply(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const {Y = X; return 0;}
int ApplyInverse(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const {Y=X; return 0;}
double NormInf() const {return 1.0;}
const char * Label() const {return M_name.c_str();}
bool UseTranspose() const {return M_useTranspose;}
bool HasNormInf() const {return true;}
const Epetra_Comm & Comm() const {return M_map->Comm();}
const Epetra_Map & OperatorDomainMap() const {return *M_map;}
const Epetra_Map & OperatorRangeMap() const {return *M_map;}
private:
std::string M_name;
boost::shared_ptr<Epetra_Map> M_map;
bool M_useTranspose;
};
//! @class NullOperator
/*! @brief Null operator 0 = Z*x. */
class NullOperator : public LinearOperator
{
public:
NullOperator():M_name("Null Operator"), M_useTranspose(false) {};
void setUp(const boost::shared_ptr<Epetra_Map> & domainMap,
const boost::shared_ptr<Epetra_Map> & rangeMap)
{
M_domainMap = domainMap;
M_rangeMap = rangeMap;
}
int SetUseTranspose(bool useTranspose) {M_useTranspose = useTranspose; return 0; }
int Apply(const Epetra_MultiVector & /*X*/, Epetra_MultiVector & Y) const {Y.PutScalar(0.0); return 0;}
int ApplyInverse(const Epetra_MultiVector & /*X*/, Epetra_MultiVector & Y) const
{Y.PutScalar(std::numeric_limits<Real>::quiet_NaN( )); return -1;}
double NormInf() const {return 0.0;}
const char * Label() const {return M_name.c_str();}
bool UseTranspose() const {return M_useTranspose;}
bool HasNormInf() const {return true;}
const Epetra_Comm & Comm() const {return M_rangeMap->Comm();}
const Epetra_Map & OperatorDomainMap() const {return *M_domainMap;}
const Epetra_Map & OperatorRangeMap() const {return *M_rangeMap;}
private:
std::string M_name;
boost::shared_ptr<Epetra_Map> M_domainMap;
boost::shared_ptr<Epetra_Map> M_rangeMap;
bool M_useTranspose;
};
} /*end namespace Operators*/
} /*end namespace */
#endif /* LINEAREPETRAOPERATOR_H */
This diff is collapsed.
//@HEADER
/*
*******************************************************************************
Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
This file is part of LifeV.
LifeV is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LifeV is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with LifeV. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
//@HEADER
/*!
@file
@brief A class to manage block structured operators
@author Umberto Villa <uvilla@emory.edu>
@date 20-09-2010
LifeV::Operators::BlockOperator manages block structured operators in a monolithic approach.
BlockOperator inherit from LifeV::Operators::LinearOperator and assumes that each block is also a
LifeV::Operators::LinearOperator.
*/
#ifndef LINEAREPETRAOPERATORBLOCK_H
#define LINEAREPETRAOPERATORBLOCK_H 1
#include <life/lifealg/LinearEpetraOperator.hpp>
#include <boost/numeric/ublas/matrix.hpp>
// Tell the compiler to ignore specific kind of warnings:
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wextra"
#include <Epetra_Import.h>
// Tell the compiler to ignore specific kind of warnings:
#pragma GCC diagnostic warning "-Wunused-variable"
#pragma GCC diagnostic warning "-Wunused-parameter"
#pragma GCC diagnostic warning "-Wextra"
namespace LifeV
{
namespace Operators
{
//! @class BlockOperator
/*! @brief A abstract class for handling n-by-m block operators
* This class inherits from LifeV::LinearOperator.
*
* The Transpose is not supported yet.
*/
class BlockOperator: public LinearOperator
{
public:
//! @name Public Typedefs
//@{
typedef LinearOperator super;
typedef Epetra_Operator raw_operator;
typedef boost::shared_ptr<raw_operator> operator_ptr;
typedef boost::numeric::ublas::matrix<operator_ptr> BlockOper;
typedef Epetra_MultiVector raw_vector;
typedef boost::shared_ptr<raw_vector> vector_ptr;
typedef std::vector<vector_ptr> vector_container;
enum Structure {Diagonal, LowerTriangular, UpperTriangular, NoStructure, Rectangular};
//@}
//! Empty Constructor
BlockOperator();
//! @name Set Methods
//@{
//! SetUp for a "square operator"
/*!
* @param nBlocks: number of blocks in a square n-by-n matrix
* @param domainMap: the map of a vector in the domain of \e this
* is obtained by concatenating the block maps in
* domainMap.
* rangeMap is assumed to be the same of domainMap.
* @param comm: the communicator.
*/
void setUp(UInt nBlocks,
const std::vector<boost::shared_ptr<Epetra_Map> > domainMap,
const boost::shared_ptr<Epetra_Comm> & comm);
//! SetUp for a "rectangular operator"
/*!
* @param nRowBlocks, nColBlocks: \e this is a nRowBlocks-by-nColBlocks
* block operator
* @param domainMap: the map of a vector in the domain of \e this
* is obtained by concatenating the block maps in
* domainMap.
* @param rangeMap: the map of a vector in the range of \e this
* is obtained by concatenating the block maps in
* rangeMap.
* @param comm: the communicator.
*/
void setUp(UInt nRowBlocks, UInt nColBlocks,
const std::vector<boost::shared_ptr<Epetra_Map> > & domainMap,
const std::vector<boost::shared_ptr<Epetra_Map> > & rangeMap,
const boost::shared_ptr<Epetra_Comm> & comm
);
//! SetUp when the operator is given like a boost::matrix
/*!
* @param blockOper: a dense matrix to describe the block operator
* @param comm: the communicator
*/
void setUp(const BlockOper & blockOper, const boost::shared_ptr<Epetra_Comm> & comm);
//! set a component of the block operator
/*!
* @param iblock, jblock: The position of the block is (iblock, jblock).
* @param operBlock : an operator_ptr representing the block
*/
void setBlock(UInt iblock, UInt jblock, const operator_ptr & operBlock);
//! Complete the block matrix with null operators
void fillComplete();
//! If true the transpose of the operator will be computed.
/*
* Not Supported yet
*/
int SetUseTranspose(bool useTranspose) {M_useTranspose = useTranspose; return -1;}
//! Compute Y = Op*X;
virtual int Apply(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const;
//! Compute Y = Op\X;
/*!
* ApplyInverse is implemented for the matrices with block diagonal, lowerTriangular, upperTriangular form
*/
virtual int ApplyInverse(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const;
//! Compute the Inf norm of the operator
/*!
* Not implemented yet.
*/
double NormInf() const {return -1;}
//! Returns a character string describing the operator
virtual const char * Label() const {return M_name.c_str();}
//! Returns the current UseTranspose setting.
bool UseTranspose() const {return M_useTranspose;}
//! Returns true if the \e this object can provide an approximate Inf-norm, false otherwise.
bool HasNormInf() const {return false;}
//! Returns a pointer to the Epetra_Comm communicator associated with this operator.
const Epetra_Comm & Comm() const {return *M_comm;}
//! Returns the Epetra_Map object associated with the domain of this operator.
const Epetra_Map & OperatorDomainMap() const {return *M_domainMap;}
//! Returns the Epetra_Map object associated with the domain of this operator as a pointer
const boost::shared_ptr<Epetra_Map> & OperatorDomainMap_ptr() const {return M_domainMap;}
//! Returns the Epetra_Map object associated with the range of this operator.
const Epetra_Map & OperatorRangeMap() const {return *M_rangeMap;}
//! Returns the Epetra_Map object associated with the range of this operator as a pointer
const boost::shared_ptr<Epetra_Map> & OperatorRangeMap_ptr() const {return M_rangeMap;}
//! Merge two vectors using the domain map
int merge(const Epetra_MultiVector & vBlock, Epetra_MultiVector & vMono, UInt jblock) const;
//! Extract vectors using the range map
int extract(Epetra_MultiVector & vBlock, const Epetra_MultiVector & vMono, UInt jblock) const;
int split(const Epetra_MultiVector & up,
vector_container & vi) const;
int merge( Epetra_MultiVector & up,
const vector_container & vi) const;
protected:
//! Y = diag(block(i,i)^-1)*X
int blockJacobi(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const;
//! Y = backwardsubstitution(X)
int blockUpperTriangularSolve(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const;
//! Y = forwardsubstitution(X)
int blockLowerTriangularSolve(const Epetra_MultiVector & X, Epetra_MultiVector & Y) const;
//! Change the name of the operator, (avaible for derivate classes).
void setName(const std::string & name) {M_name =name;}
private:
//! Construct the maps and the importers
void buildImporter(UInt nblocks,
std::vector<boost::shared_ptr<Epetra_Map> > & blockMaps,
boost::shared_ptr<Epetra_Map> & fullMap,
std::vector< boost::shared_ptr<Epetra_Import> > & block2mono,
std::vector< boost::shared_ptr<Epetra_Import> > & mono2block );
//! Number of blocks in each row
UInt M_nBlockRows;
//! Number of blocks in each column
UInt M_nBlockCols;
//! Name of the object
std::string M_name;
//! Communicator
boost::shared_ptr<Epetra_Comm> M_comm;
//! @name Maps
//@{
//! Domain Map
boost::shared_ptr<Epetra_Map> M_domainMap;
//! Range Map
boost::shared_ptr<Epetra_Map> M_rangeMap;
//! Domain Map of each block
std::vector< boost::shared_ptr<Epetra_Map> > M_domainBlockMaps;
//! Range Map of each block
std::vector< boost::shared_ptr<Epetra_Map> > M_rangeBlockMaps;
//! Shifted domain Map of each block
std::vector< boost::shared_ptr<Epetra_Map> > M_domainBlockMapsShift;
//! Shifted domain Map of each block
std::vector< boost::shared_ptr<Epetra_Map> > M_rangeBlockMapsShift;
//@}
//! block operator represented like a dense matrix of pointers to Operators
BlockOper M_oper;
//! @name Importers
//@{
//! merge block domain vectors in the monolithic domain vector
std::vector< boost::shared_ptr<Epetra_Import> > M_block2monoDomain;
//! split the monolithic domain vector in the block domain vectors
std::vector< boost::shared_ptr<Epetra_Import> > M_mono2blockDomain;
//! merge block range vectors in the monolithic range vector
std::vector< boost::shared_ptr<Epetra_Import> > M_block2monoRange;
//! split the monolithic domain vector in the block domain vectors
std::vector< boost::shared_ptr<Epetra_Import> > M_mono2blockRange;
//@}
//! whenever transpose should be used
bool M_useTranspose;
//! structure of the block operator (Diagonal, LowerDiagonal, UpperDiagonal, NoStructure)
Structure M_structure;
};
} /*end namespace Operators*/
} /*end namespace */
#endif /* LINEAREPETRAOPERATORBLOCK_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment