LifeV
BlockEpetra_MultiVector.hpp
Go to the documentation of this file.
1 /*
2  * BlockEpetra_MultiVector.hpp
3  *
4  * Created on: Aug 14, 2011
5  * Author: uvilla
6  */
7 //@ HEADER
8 
9 /*!
10  * \file BlockEpetra_MultiVector.hpp
11  * \author Umberto Villa
12  * \date 2011-08-13
13  * A derived class from \c Epetra_MultiVector specialized to handle parallel block structured Vectors.
14  */
15 
16 
17 
18 #ifndef BLOCKEPETRA_MULTIVECTOR_HPP_
19 #define BLOCKEPETRA_MULTIVECTOR_HPP_
20 
21 #include <Epetra_MultiVector.h>
22 #include <lifev/core/linear_algebra/BlockEpetra_Map.hpp>
23 
24 namespace LifeV
25 {
26 //! @class
27 /*!
28  * @brief A derived class from \c Epetra_MultiVector specialized to handle parallel block structured Vectors.
29  *
30  * \c BlockEpetra_MultiVector provides monolithic or block access to an Epetra_MultiVector.
31  * A \c BlockEpetra_MultiVector object can be constructed or by striding \c Epetra_MultiVector or from a
32  * \c BlockEpetra_Map.
33  *
34  * This class can be also used to overly a block structure to a given Epetra_MultiVector. In this case, to
35  * maximize performances and reduce memory footprint the original object and it's block view will share the same
36  * data in memory. If a \c BlockEpetra_MultiVector object is a view of another Epetra_MultiVector each modification on the
37  * data value of one vector will also affect the other vector and viceversa.
38  */
40 {
41 
42 public:
43 
44  //@name Typedef
45  //@{
47  typedef boost::shared_ptr<vector_Type> vectorPtr_Type;
49  //@}
50 
51  //@name Constructors
52  //@{
53  //! Generate a BlockEpetra_MultiVector from a BlockEpetra_Map
54  BlockEpetra_MultiVector(const BlockEpetra_Map& map, int numVectors, bool zeroOut = true);
55  //! Copy Constructor
57  //! Overlay a block structure to a source.
58  /*!
59  * If the DataAccess type is Copy, then this object will make a deep copy of all the data structure of source
60  * If the DataAccess type is View, then this object will only copy the pointers to the datas in source. (shallow copy).
61  * \warning View access is faster but the user must ensure that \c source will not be deallocated before \c this
62  */
63  BlockEpetra_MultiVector(Epetra_DataAccess CV, const vector_Type & source, const BlockEpetra_Map& map);
64  //@}
65 
66  //@name Getters
67  //@{
68  //! Return a Epetra_MultiVector (view) object for block iblock
69  /*!
70  * \warning The returned object doesn't own the internal data structure. User must ensure correct scoping.
71  */
73  //! const version
74  const Epetra_MultiVector & block(UInt iblock) const;
75 
76  //! retrieve the \c BlockEpetra_Map
77  const BlockEpetra_Map & blockEpetraMap() const;
78  //@}
79 private:
80 
81  void createBlockViews();
82 
87 };
88 
89 //! Generate a BlockEpetra_MultiVector from a list of Epetra_MultiVector.
90 BlockEpetra_MultiVector * stride(std::vector<const BlockEpetra_MultiVector::vector_Type *> vector);
91 //! Generate a BlockEpetra_MultiVector from two Epetra_MultiVectors
94 //! Generate a BlockEpetra_MultiVector from three Epetra_MultiVectors
98 //! Generate a BlockEpetra_MultiVector from three Epetra_MultiVectors
103 /*!
104  * Generate a BlockEpetra_MultiVector from a Epetra_MultiVector and a BlockEpetra_Map
105  * Note the \c BlockEpetra_MultiVector object and the \c source vector will share the same internal data structure.
106  * Each modification in the entry of any of the two vector will affect also the other vector.
107  * \warning The user has the responsibility to keep the scope of the \c BlockEpetra_MultiVector inside the scope of the vector \c source.
108  * If the vector source is distructed, then the internal data structure of the returned object will contain
109  * dangling pointers.
110  */
112 
113 } /* end namespace */
114 
115 
116 #endif /* BLOCKEPETRA_MULTIVECTOR_HPP_ */
This class handles block access to parallel monolithic Vectors with an underling block structure...
BlockEpetra_MultiVector * createBlockView(const BlockEpetra_MultiVector::vector_Type &source, const BlockEpetra_Map &map)
Generate a BlockEpetra_MultiVector from a Epetra_MultiVector and a BlockEpetra_Map.
Epetra_MultiVector & block(UInt iblock)
Return a Epetra_MultiVector (view) object for block iblock.
BlockEpetra_MultiVector(const BlockEpetra_Map &map, int numVectors, bool zeroOut=true)
Generate a BlockEpetra_MultiVector from a BlockEpetra_Map.
const BlockEpetra_Map & blockEpetraMap() const
retrieve the BlockEpetra_Map
BlockEpetra_MultiVector * stride(const BlockEpetra_MultiVector::vector_Type &v1, const BlockEpetra_MultiVector::vector_Type &v2, const BlockEpetra_MultiVector::vector_Type &v3, const BlockEpetra_MultiVector::vector_Type &v4)
Generate a BlockEpetra_MultiVector from three Epetra_MultiVectors.
void updateInverseJacobian(const UInt &iQuadPt)
BlockEpetra_MultiVector(const BlockEpetra_MultiVector &Source)
Copy Constructor.
BlockEpetra_MultiVector(Epetra_DataAccess CV, const vector_Type &source, const BlockEpetra_Map &map)
Overlay a block structure to a source.
A derived class from Epetra_MultiVector specialized to handle parallel block structured Vectors...
BlockEpetra_MultiVector * stride(const BlockEpetra_MultiVector::vector_Type &v1, const BlockEpetra_MultiVector::vector_Type &v2)
Generate a BlockEpetra_MultiVector from two Epetra_MultiVectors.
boost::shared_ptr< vector_Type > vectorPtr_Type
const Epetra_MultiVector & block(UInt iblock) const
const version
std::vector< vectorPtr_Type > vectorPtrContainer_Type
BlockEpetra_MultiVector * stride(const BlockEpetra_MultiVector::vector_Type &v1, const BlockEpetra_MultiVector::vector_Type &v2, const BlockEpetra_MultiVector::vector_Type &v3)
Generate a BlockEpetra_MultiVector from three Epetra_MultiVectors.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
BlockEpetra_MultiVector * stride(std::vector< const BlockEpetra_MultiVector::vector_Type *> vectors)
Generate a BlockEpetra_MultiVector from a list of Epetra_MultiVector.