LifeV
VectorEpetraStructured.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 VectorEpetraStructured class
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @date 01 Jun 2011
33  */
34 
35 #ifndef _VECTOREPETRASTRUCTURED_HPP_
36 #define _VECTOREPETRASTRUCTURED_HPP_ 1
37 
38 #include <lifev/core/LifeV.hpp>
39 
40 #include <lifev/core/array/MapEpetra.hpp>
41 #include <lifev/core/array/VectorEpetra.hpp>
42 #include <lifev/core/array/MapVector.hpp>
43 #include <lifev/core/array/VectorBlockStructure.hpp>
44 #include <lifev/core/array/VectorEpetraStructuredView.hpp>
45 
46 
47 namespace LifeV
48 {
49 
50 //! VectorEpetraStructured - class of block vector
51 /*!
52  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
53 
54  The VectorEpetraStructured class contains data related
55  to block vector. It is an extension to VectorEpetra where data about blocks have
56  been set. For an introduction to the block structures in LifeV, see
57  \ref BlockAlgebraPage "this page".
58 
59  There are mainly two ways to define a VectorEpetraStructured:
60  <ul>
61  <li> Construct it using the same syntax as for LifeV::VectorEpetra and the use
62  a setter for the structure.
63  <li> Construct it directly with the maps of the blocks.
64  </ul>
65  Both ways are equivalent.
66 
67  To access the blocks, one uses then the blockView or block methods.
68 
69  */
70 class VectorEpetraStructured
71  : public VectorEpetra
72 {
73 public:
74 
75  //! @name Public Types
76  //@{
77 
78  //! Type of data stored
79  typedef Real data_type;
80 
81  //! Type of the map to be used
82  typedef MapEpetra map_Type;
83 
84  //! Type of the MapVector to be used with this class
85  typedef MapVector<map_Type> mapVector_type;
86 
87  //! Type of the map (Unique/Repeated)
88  typedef MapEpetraType mapType_type;
89 
90  //! Combine mode
91  typedef Epetra_CombineMode combine_type;
92 
93  //! Type of the view
94  typedef VectorEpetraStructuredView block_type;
95 
96  //! Pointer on the view
97  typedef std::shared_ptr<block_type> block_ptrType;
98 
99  //@}
100 
101 
102  //! @name Constructor & Destructor
103  //@{
104 
105  //! Constructor with the monolithic map
106  explicit VectorEpetraStructured ( const map_Type& map,
107  const mapType_type& mapType = Unique,
108  const combineMode_Type combineMode = Add );
109 
110  //! Construction with a vector of map
111  /*!
112  With this constructor, the block structure is automatically deduced from the maps in the
113  vector. The monolithic map and vectors are also built by concatenating the different maps
114  in the vector.
115  */
116  explicit VectorEpetraStructured ( const mapVector_type& mapVector,
117  const mapType_type& mapType = Unique,
118  const combineMode_Type combineMode = Add );
119 
120  //! Copy constructor
121  VectorEpetraStructured ( const VectorEpetraStructured& vector );
122 
123  //! Copy constructor with a specified map type (Repeated/Unique)
124  VectorEpetraStructured ( const VectorEpetraStructured& vector, const mapType_type& mapType );
125 
126  //! Copy constructor with specified map type and combine mode
127  VectorEpetraStructured ( const VectorEpetraStructured& vector,
128  const mapType_type& mapType,
129  const combine_type& combineMode );
130 
131  //! Destructor
132  ~VectorEpetraStructured() {}
133 
134  //@}
135 
136 
137  //! @name Set Methods
138  //@{
139 
140  /*! Set the size of the blocks of the vector
141  * @param blockSizes Sizes of the blocks
142  */
143  void setBlockStructure ( const std::vector<UInt>& blockSizes );
144 
145  //! Reset the block structure using the blocks of a vector of map
146  /*
147  The resulting block structure is symmetric (same block structure
148  in the rows and in the columns).
149 
150  This method does not involve big computation overhead. Remark that
151  it is not possible to change the size of the block vector
152  through this method, nor its map.
153  @param The MapVector containing the maps
154  */
155  void setBlockStructure ( const mapVector_type& mapVector );
156 
157  /*! Set the block structure of the vector
158  * @param blockStructure Structure of the vector
159  */
160  void setBlockStructure ( const VectorBlockStructure& blockStructure );
161 
162  //@}
163 
164 
165  //! @name Get Methods
166  //@{
167 
168  //! Getter for the size of the block index
169  /*!
170  @param index Index of the block
171  @return size of the index-th block
172  */
173  UInt blockSize ( const UInt& index ) const;
174 
175  //! Getter for the block index
176  /*!
177  @param index Index of the block
178  @param blockView The blockView to be filled
179  */
180  void blockView ( const UInt& index, block_type& blockView );
181 
182  //! Getter for the block index
183  /*!
184  @param index Index of the block
185  @return The index-th block
186  */
187  block_ptrType block ( const UInt& index );
188 
189  /*! Get the block structure of the vector
190  * @param blockStructure Structure of the vector
191  */
192  VectorBlockStructure blockStructure() const;
193 
194  //@}
195 
196 private:
197 
198  VectorBlockStructure M_blockStructure;
199 
200 };
201 
202 } // Namespace LifeV
203 
204 #endif /* _VECTOREPETRASTRUCTURED_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