LifeV
VectorBlockMonolithicEpetra.cpp
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 Implementation file for VectorBlockMonolithicEpetra
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @date 01 Jun 2011
33  */
34 
36 
37 namespace LifeV
38 {
39 
40 // ===================================================
41 // Constructors & Destructor
42 // ===================================================
43 
45 VectorBlockMonolithicEpetra ( const map_Type& map, const mapType_type& mapType)
46  : VectorEpetra (map, mapType),
48  M_blockFirstIndex (1, 0)
49 {}
50 
52 VectorBlockMonolithicEpetra ( const mapVector_type& mapVector, const mapType_type& mapType)
53  : VectorEpetra (mapType),
56 {
57  ASSERT ( mapVector.nbMap() > 0 , "Map vector empty, impossible to construct a VectorBlockMonolithicEpetra!");
58 
59  map_Type myMap (mapVector.map (0) );
60 
61  M_blockSize[0] = mapVector.mapSize (0);
62  M_blockFirstIndex[0] = 0;
63 
64  UInt totalSize (M_blockSize[0]);
65 
66  for (UInt i (1); i < mapVector.nbMap(); ++i)
67  {
68  myMap += mapVector.map (i);
69  M_blockSize[i] = mapVector.mapSize (i);
70  M_blockFirstIndex[i] = totalSize;
71 
72  totalSize += M_blockSize[i];
73  }
74 
75  // Set the global map
76  this->setMap (myMap);
77 }
78 
81  : VectorEpetra (vector),
84 {}
85 
91 {}
92 
94 VectorBlockMonolithicEpetra ( const VectorBlockMonolithicEpetra& vector, const mapType_type& mapType, const combine_type& combineMode)
98 {}
99 
100 // ===================================================
101 // Set Methods
102 // ===================================================
103 
104 void
106 setBlockStructure ( const std::vector<UInt>& blockSizes)
107 {
108  M_blockSize = blockSizes;
109 
110  M_blockFirstIndex.resize (M_blockSize.size() );
111 
112  UInt currentSize (0);
113  for (UInt i (0); i < M_blockSize.size(); ++i)
114  {
115  M_blockFirstIndex[i] = currentSize;
116  currentSize += M_blockSize[i];
117  }
118 }
119 
120 void
123 {
124  ASSERT ( mapVector.nbMap() > 0 , "Map vector empty, impossible to set the block structure");
125 
126  M_blockSize.resize (mapVector.nbMap() );
127  M_blockFirstIndex.resize (mapVector.nbMap() );
128 
129  UInt totalSize (0);
130 
131  for (UInt i (0); i < mapVector.nbMap(); ++i)
132  {
133  M_blockSize[i] = mapVector.mapSize (i);
134  M_blockFirstIndex[i] = totalSize;
135 
136  totalSize += M_blockSize[i];
137  }
138 
139  ASSERT ( static_cast<Int>(totalSize) == this->size(), " Incompatible block structure (global size does not match) ");
140 }
141 
142 // ===================================================
143 // Get Methods
144 // ===================================================
145 
146 void
148 blockView ( const UInt& index, block_type& blockView )
149 {
150  ASSERT ( index < M_blockFirstIndex.size(), "Invalid block index");
151  ASSERT ( index < M_blockSize.size(), "Invalid block index");
152 
153  blockView.setup ( M_blockFirstIndex[index], M_blockSize[index], this);
154 }
155 
158 block ( const UInt& index)
159 {
160  ASSERT ( index < M_blockFirstIndex.size(), "Invalid block index");
161  ASSERT ( index < M_blockSize.size(), "Invalid block index");
162 
163  block_ptrType mbv (new block_type);
164 
165  mbv->setup ( M_blockFirstIndex[index], M_blockSize[index], this);
166 
167  return mbv;
168 }
169 
170 
171 } // Namespace LifeV
VectorEpetra - The Epetra Vector format Wrapper.
VectorBlockMonolithicEpetra - class of block vector.
VectorBlockMonolithicEpetra(const mapVector_type &mapVector, const mapType_type &mapType=Unique)
Construction with a vector of map.
VectorBlockMonolithicEpetra(const VectorBlockMonolithicEpetra &vector, const mapType_type &mapType)
Copy constructor with a specified map type (Repeated/Unique)
std::shared_ptr< block_type > block_ptrType
Pointer on the view.
MapEpetraType mapType_type
Type of the map (Unique/Repeated)
void setBlockStructure(const mapVector_type &mapVector)
Reset the block structure using the blocks of a vector of map.
VectorEpetra(const MapEpetra &map, const MapEpetraType &mapType=Unique, const combineMode_Type combineMode=Add)
Constructor - Using Maps.
void updateInverseJacobian(const UInt &iQuadPt)
VectorBlockMonolithicEpetra(const map_Type &map, const mapType_type &mapType=Unique)
Constructor with the monolithic map.
VectorBlockMonolithicEpetra(const VectorBlockMonolithicEpetra &vector, const mapType_type &mapType, const combine_type &combineMode)
Copy constructor with specified map type and combine mode.
void setBlockStructure(const std::vector< UInt > &blockSizes)
VectorBlockMonolithicEpetraView block_type
Type of the view.
VectorEpetra(const MapEpetraType &mapType=Unique, const combineMode_Type combineMode=Add)
Empty Constructor.
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
Epetra_CombineMode combine_type
Combine mode.
VectorBlockMonolithicEpetra(const VectorBlockMonolithicEpetra &vector)
Copy constructor.
block_ptrType block(const UInt &index)
Getter for the block index.
void blockView(const UInt &index, block_type &blockView)
Getter for the block index.
MapVector< map_Type > mapVector_type
Type of the MapVector to be used with this class.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
MapEpetra map_Type
Type of the map to be used.