LifeV
MatrixBlockStructure.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 MatrixBlockStructure class
30 
31  @author Gwenol Grandperrin <gwenol.grandperrin@gmail.com>
32  @date 21-08-2012
33  */
34 
35 #ifndef _MATRIXBLOCKSTRUCTURE_HPP_
36 #define _MATRIXBLOCKSTRUCTURE_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 #include <lifev/core/array/VectorBlockStructure.hpp>
43 
44 namespace LifeV
45 {
46 
47 //! MatrixBlockStructure - class representing the structure of a vector
48 /*!
49  @author Gwenol Grandperrin <gwenol.grandperrin@gmail.com>
50 
51  */
52 class MatrixBlockStructure
53 {
54 public:
55 
56  //! @name Public Types
57  //@{
58 
59  //! Type of data stored
60  typedef Real data_Type;
61 
62  //! Type of the map to be used
63  typedef MapEpetra map_Type;
64 
65  //! Type of the MapVector to be used with this class
66  typedef MapVector<map_Type> mapVector_Type;
67 
68  //! Type of the map (Unique/Repeated)
69  typedef MapEpetraType mapType_Type;
70 
71  //@}
72 
73 
74  //! @name Constructor & Destructor
75  //@{
76  //! Default constructor
77  MatrixBlockStructure();
78 
79  //! Constructor with the monolithic maps
80  MatrixBlockStructure ( const map_Type& rowMap,
81  const map_Type& columnMap );
82 
83  //! Constructor with a unique monolithic map
84  MatrixBlockStructure ( const map_Type& map );
85 
86  //! Construction with a map
87  /*!
88  With this constructor, the block structure is automatically deduced from the maps in the
89  vectors. The monolithic map and vectors are also built by concatenating the different maps
90  in the vector.
91  */
92  MatrixBlockStructure ( const mapVector_Type& rowMapVector,
93  const mapVector_Type& columnMapVector );
94 
95  //! Construction with a map
96  /*!
97  With this constructor, the block structure is automatically deduced from the maps in the
98  vector. The monolithic map and vectors are also built by concatenating the different maps
99  in the vector.
100  */
101  MatrixBlockStructure ( const mapVector_Type& mapVector );
102 
103  //! Construction with row and column structure
104  MatrixBlockStructure ( const VectorBlockStructure& rowsBlockStructure,
105  const VectorBlockStructure& columnsBlockStructure );
106 
107  //! Construction with vector structure
108  MatrixBlockStructure ( const VectorBlockStructure& vectorStructure );
109 
110  //! Copy constructor
111  MatrixBlockStructure ( const MatrixBlockStructure& blockStructure );
112 
113  //! Destructor
114  ~MatrixBlockStructure();
115 
116  //@}
117 
118 
119  //! @name Set Methods
120  //@{
121 
122  /*! Set the size of the blocks of the matrix
123  * @param blockNumRows Number of rows in the blocks
124  * @param blockNumColumns Number of columns in the blocks
125  */
126  void setBlockStructure ( const std::vector<UInt>& blockNumRows,
127  const std::vector<UInt>& blockNumColumns );
128 
129  /*! Set the size of the blocks of the matrix
130  * @param blocksSize Number of rows/columns in the blocks
131  */
132  void setBlockStructure ( const std::vector<UInt>& blocksSize );
133 
134  /*!
135  * Set the size of the blocks of the matrix using the maps stored in the vector
136  * of map. The resulting block structure in symmetric (same blocks in the rows
137  * and in the columns).
138  *
139  * This method does not involve large computations. The global size and the map
140  * of the matrix cannot be changed with this method (and the block structure has
141  * to be compatible with the global size).
142  */
143  void setBlockStructure ( const MapVector<MapEpetra>& rowMapVector,
144  const MapVector<MapEpetra>& columnMapVector );
145 
146  /*!
147  * Set the size of the blocks of the matrix using the maps stored in the vector
148  * of map. The resulting block structure in symmetric (same blocks in the rows
149  * and in the columns).
150  *
151  * This method does not involve large computations. The global size and the map
152  * of the matrix cannot be changed with this method (and the block structure has
153  * to be compatible with the global size).
154  */
155  void setBlockStructure ( const MapVector<MapEpetra>& mapVector );
156 
157  //! Set the block structure from a matrix structure object
158  void setBlockStructure ( const MatrixBlockStructure& blockStructure );
159 
160  //! Set the block structure from row and column structures
161  void setBlockStructure ( const VectorBlockStructure& rowsBlockStructure,
162  const VectorBlockStructure& columnsBlockStructure );
163 
164  //! Set the block structure from row and column structures
165  void setBlockStructure ( const VectorBlockStructure& vectorBlockStructure );
166 
167  //@}
168 
169 
170  //! @name Get Methods
171  //@{
172  //! Returns the number of rows of the block
173  /*!
174  * @param rowIndex Row index of the block
175  */
176  UInt blockNumRows ( const UInt& rowIndex ) const;
177 
178  //! Returns the number of columns of the block
179  /*!
180  * @param columnIndex Column index of the block
181  */
182  UInt blockNumColumns ( const UInt& columnIndex ) const;
183 
184  /*!
185  @param index Index of the block
186  @return index of the first entry in the index-th block
187  */
188  UInt rowBlockFirstIndex ( const UInt& index ) const;
189 
190  /*!
191  @param index Index of the block
192  @return index of the first entry in the index-th block
193  */
194  UInt columnBlockFirstIndex ( const UInt& index ) const;
195 
196  //! Number of row blocks
197  UInt numRowBlocks() const;
198 
199  //! Number of column blocks
200  UInt numColumnBlocks() const;
201 
202  //! Number of rows
203  UInt numRows() const;
204 
205  //! Number of rows
206  UInt numColumns() const;
207 
208  //! Get the rows block structure
209  const VectorBlockStructure& rowsBlockStructure() const;
210 
211  //! Get the columns block structure
212  const VectorBlockStructure& columnsBlockStructure() const;
213 
214  //@}
215 
216 private:
217 
218  VectorBlockStructure M_rowsBlockStructure;
219  VectorBlockStructure M_columnsBlockStructure;
220 
221 };
222 
223 } // Namespace LifeV
224 
225 #endif /* _MATRIXBLOCKSTRUCTURE_HPP_ */
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191