LifeV
VectorBlockMonolithicEpetra.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief File containing the VectorBlockMonolithicEpetra
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @date 01 Jun 2011
33 
34  */
35 
36 #ifndef VECTOR_BLOCK_MONOLITHIC_EPETRA_H
37 #define VECTOR_BLOCK_MONOLITHIC_EPETRA_H 1
38 
39 #include <lifev/core/LifeV.hpp>
40 
41 #include <lifev/core/array/MapEpetra.hpp>
42 #include <lifev/core/array/VectorEpetra.hpp>
43 #include <lifev/core/array/MapVector.hpp>
44 #include <lifev/core/array/VectorBlockMonolithicEpetraView.hpp>
45 
46 #include <boost/shared_ptr.hpp>
47 
48 namespace LifeV
49 {
50 
51 //! VectorBlockMonolithicEpetra - class of block vector
52 /*!
53  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
54 
55  The VectorBlockMonolithicEpetra class contains data related
56  to block vector. It is an extension to VectorEpetra where data about blocks have
57  been set. For an introduction to the block structures in LifeV, see
58  \ref BlockAlgebraPage "this page".
59 
60  There are mainly two ways to define a VectorBlockMonolithicEpetra:
61  <ul>
62  <li> Construct it using the same syntax as for LifeV::VectorEpetra and the use
63  a setter for the structure.
64  <li> Construct it directly with the maps of the blocks.
65  </ul>
66  Both ways are equivalent.
67 
68  To access the blocks, one uses then the blockView or block methods.
69 
70  */
71 class VectorBlockMonolithicEpetra
72  : public VectorEpetra
73 {
74 public:
75 
76  //! @name Public Types
77  //@{
78 
79  //! Type of data stored
80  typedef Real data_type;
81 
82  //! Type of the map to be used
83  typedef MapEpetra map_Type;
84 
85  //! Type of the MapVector to be used with this class
86  typedef MapVector<map_Type> mapVector_type;
87 
88  //! Type of the map (Unique/Repeated)
89  typedef MapEpetraType mapType_type;
90 
91  //! Combine mode
92  typedef Epetra_CombineMode combine_type;
93 
94  //! Type of the view
95  typedef VectorBlockMonolithicEpetraView block_type;
96 
97  //! Pointer on the view
98  typedef std::shared_ptr<block_type> block_ptrType;
99 
100  //@}
101 
102 
103  //! @name Constructor & Destructor
104  //@{
105 
106  //! Constructor with the monolithic map
107  VectorBlockMonolithicEpetra ( const map_Type& map, const mapType_type& mapType = Unique);
108 
109  //! Construction with a vector of map
110  /*!
111  With this constructor, the block structure is automatically deduced from the maps in the
112  vector. The monolithic map and vectors are also built by concanating the different maps
113  in the vector.
114  */
115  VectorBlockMonolithicEpetra ( const mapVector_type& mapVector, const mapType_type& mapType = Unique);
116 
117  //! Copy constructor
118  VectorBlockMonolithicEpetra ( const VectorBlockMonolithicEpetra& vector);
119 
120  //! Copy constructor with a specified map type (Repeated/Unique)
121  VectorBlockMonolithicEpetra ( const VectorBlockMonolithicEpetra& vector, const mapType_type& mapType);
122 
123  //! Copy constructor with specified map type and combine mode
124  VectorBlockMonolithicEpetra ( const VectorBlockMonolithicEpetra& vector, const mapType_type& mapType, const combine_type& combineMode);
125 
126  //! Destructor
127  ~VectorBlockMonolithicEpetra() {}
128 
129  //@}
130 
131 
132  //! @name Set Methods
133  //@{
134 
135  /*! Set the size of the blocks of the vector
136  * @param blockSizes Sizes of the blocks
137  */
138  void setBlockStructure ( const std::vector<UInt>& blockSizes );
139 
140  //! Reset the block structure using the blocks of a vector of map
141  /*
142  The resulting block structure is symmetric (same block structure
143  in the rows and in the columns).
144 
145  This method does not involve big computation overhead. Remark that
146  it is not possible to change the size of the block vector
147  through this method, nor its map.
148  @param The MapVector containing the maps
149  */
150  void setBlockStructure ( const mapVector_type& mapVector);
151 
152  //@}
153 
154 
155  //! @name Get Methods
156  //@{
157 
158  //! Getter for the size of the block index
159  /*!
160  @param index Index of the block
161  @return size of the index-th block
162  */
163  UInt blockSize (const UInt& index) const
164  {
165  ASSERT ( index < M_blockSize.size(), "Invalid block index");
166  return M_blockSize[index];
167  }
168 
169  //! Getter for the block index
170  /*!
171  @param index Index of the block
172  @param blockView The blockView to be filled
173  */
174  void blockView ( const UInt& index, block_type& blockView);
175 
176  //! Getter for the block index
177  /*!
178  @param index Index of the block
179  @return The index-th block
180  */
181  block_ptrType block ( const UInt& index);
182 
183  //@}
184 
185 private:
186 
187  std::vector<UInt> M_blockSize;
188  std::vector<UInt> M_blockFirstIndex;
189 
190 };
191 
192 } // Namespace LifeV
193 
194 #endif /* VECTORBLOCKEPETRA_H */
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191