LifeV
VectorBlockStructure.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 VectorBlockStructure class
30 
31  @author Gwenol Grandperrin <gwenol.grandperrin@gmail.com>
32  @date 21-08-2012
33  */
34 
35 #ifndef _VECTORBLOCKSTRUCTURE_HPP_
36 #define _VECTORBLOCKSTRUCTURE_HPP_ 1
37 
38 #include <boost/shared_ptr.hpp>
39 #include <lifev/core/LifeV.hpp>
40 #include <lifev/core/array/MapEpetra.hpp>
41 #include <lifev/core/array/MapVector.hpp>
42 
43 namespace LifeV
44 {
45 
46 //! VectorBlockStructure - class representing the structure of a vector
47 /*!
48  @author Gwenol Grandperrin <gwenol.grandperrin@gmail.com>
49 
50  */
51 class VectorBlockStructure
52 {
53 public:
54 
55  //! @name Public Types
56  //@{
57 
58  //! Type of data stored
59  typedef Real data_Type;
60 
61  //! Type of the map to be used
62  typedef MapEpetra map_Type;
63 
64  //! Type of the MapVector to be used with this class
65  typedef MapVector<map_Type> mapVector_Type;
66 
67  //! Type of the map (Unique/Repeated)
68  typedef MapEpetraType mapType_Type;
69 
70  //! Combine mode
71  typedef Epetra_CombineMode combine_Type;
72 
73  //@}
74 
75 
76  //! @name Constructor & Destructor
77  //@{
78 
79  //! Default constructor
80  VectorBlockStructure();
81 
82  //! Constructor with the monolithic map
83  VectorBlockStructure ( const map_Type& map );
84 
85  //! Construction with a map
86  /*!
87  With this constructor, the block structure is automatically deduced from the maps in the
88  vector. The monolithic map and vectors are also built by concatenating the different maps
89  in the vector.
90  */
91  VectorBlockStructure ( const mapVector_Type& mapVector );
92 
93  //! Copy constructor
94  VectorBlockStructure ( const VectorBlockStructure& blockStructure );
95 
96  //! Destructor
97  ~VectorBlockStructure() {}
98 
99  //@}
100 
101 
102  //! @name Set Methods
103  //@{
104 
105  /*! Set the size of the blocks of the vector
106  * @param blockSizes Sizes of the blocks
107  */
108  void setBlockStructure ( const std::vector<UInt>& blockSizes );
109 
110  //! Reset the block structure using the blocks of a vector of map
111  /*
112  The resulting block structure is symmetric (same block structure
113  in the rows and in the columns).
114 
115  This method does not involve big computation overhead. Remark that
116  it is not possible to change the size of the block vector
117  through this method, nor its map.
118  @param The MapVector containing the maps
119  */
120  void setBlockStructure ( const mapVector_Type& mapVector );
121 
122  /*! Set the block structure using a block structure
123  * @param blockStructure Structure of the vector
124  */
125  void setBlockStructure ( const VectorBlockStructure& blockStructure );
126 
127  //@}
128 
129 
130  //! @name Get Methods
131  //@{
132 
133  //! Getter for the size of the block index
134  /*!
135  @param index Index of the block
136  @return size of the index-th block
137  */
138  UInt blockSize ( const UInt& index ) const
139  {
140  ASSERT ( index < M_blockSize.size(), "Invalid block index" );
141  return M_blockSize[index];
142  }
143 
144  /*!
145  @param index Index of the block
146  @return index of the first entry in the index-th block
147  */
148  UInt blockFirstIndex ( const UInt& index ) const
149  {
150  ASSERT ( index < M_blockFirstIndex.size(), "Invalid block index" );
151  return M_blockFirstIndex[index];
152  }
153 
154  /*!
155  @return Number of blocks
156  */
157  UInt numBlocks() const
158  {
159  return M_blockSize.size();
160  }
161 
162  /*!
163  @return Number of blocks
164  */
165  UInt totalSize() const
166  {
167  return M_totalSize;
168  }
169 
170  //@}
171 
172 private:
173 
174  std::vector<UInt> M_blockSize;
175  std::vector<UInt> M_blockFirstIndex;
176  UInt M_totalSize;
177 
178 };
179 
180 } // Namespace LifeV
181 
182 #endif /* _VECTORBLOCKSTRUCTURE_HPP_ */
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