LifeV
VectorBlockStructure.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 VectorBlockStructure
30 
31  @author Gwenol Grandperrin <gwenol.grandperrin@gmail.com>
32  @date 21-08-2012
33  */
34 
35 #include <lifev/core/array/VectorBlockStructure.hpp>
36 
37 namespace LifeV
38 {
39 
40 // ===================================================
41 // Constructors & Destructor
42 // ===================================================
43 
46  : M_blockSize(),
48  M_totalSize ( 0 )
49 {}
50 
53  : M_blockSize ( 1, map.map ( Unique )->NumGlobalElements() ),
54  M_blockFirstIndex ( 1, 0 ),
56 {}
57 
60  : M_blockSize ( mapVector.nbMap() ),
62 {
63  ASSERT ( mapVector.nbMap() > 0 , "Map vector empty, impossible to construct a VectorBlockMonolithicEpetra!" );
64 
65  M_blockSize[0] = mapVector.mapSize ( 0 );
66  M_blockFirstIndex[0] = 0;
67 
68  M_totalSize = M_blockSize[0];
69 
70  for ( UInt i ( 1 ); i < mapVector.nbMap(); ++i )
71  {
72  M_blockSize[i] = mapVector.mapSize ( i );
73  M_blockFirstIndex[i] = M_totalSize;
74 
75  M_totalSize += M_blockSize[i];
76  }
77 
78 }
79 
81 VectorBlockStructure ( const VectorBlockStructure& blockStructure )
84  M_totalSize ( blockStructure.M_totalSize )
85 {
86 
87 }
88 
89 // ===================================================
90 // Set Methods
91 // ===================================================
92 
93 void
95 setBlockStructure ( const std::vector<UInt>& blockSizes )
96 {
97  M_blockSize = blockSizes;
98 
99  M_blockFirstIndex.resize ( M_blockSize.size() );
100 
101  M_totalSize = 0;
102 
103  for ( UInt i ( 0 ); i < M_blockSize.size(); ++i )
104  {
105  M_blockFirstIndex[i] = M_totalSize;
106  M_totalSize += M_blockSize[i];
107  }
108 }
109 
110 void
112 setBlockStructure ( const mapVector_Type& mapVector )
113 {
114  ASSERT ( mapVector.nbMap() > 0 , "Map vector empty, impossible to set the block structure" );
115 
116  M_blockSize.resize ( mapVector.nbMap() );
117  M_blockFirstIndex.resize ( mapVector.nbMap() );
118 
119  M_totalSize = 0;
120 
121  for ( UInt i ( 0 ); i < mapVector.nbMap(); ++i )
122  {
123  M_blockSize[i] = mapVector.mapSize ( i );
124  M_blockFirstIndex[i] = M_totalSize;
125  M_totalSize += M_blockSize[i];
126  }
127 }
128 
129 void
131 setBlockStructure ( const VectorBlockStructure& blockStructure )
132 {
133  UInt size ( blockStructure.numBlocks() );
134  M_blockSize.resize ( size );
135  M_blockFirstIndex.resize ( size );
136 
137  M_totalSize = blockStructure.M_totalSize;
138 
139  for ( UInt i ( 0 ); i < size; ++i )
140  {
141  M_blockSize[i] = blockStructure.M_blockSize[i];
142  M_blockFirstIndex[i] = blockStructure.M_blockFirstIndex[i];
143  }
144 }
145 
146 } // Namespace LifeV
VectorBlockStructure(const mapVector_Type &mapVector)
Construction with a map.
VectorBlockStructure(const map_Type &map)
Constructor with the monolithic map.
VectorBlockStructure - class representing the structure of a vector.
MapEpetra map_Type
Type of the map to be used.
void updateInverseJacobian(const UInt &iQuadPt)
void setBlockStructure(const VectorBlockStructure &blockStructure)
void setBlockStructure(const std::vector< UInt > &blockSizes)
VectorBlockStructure(const VectorBlockStructure &blockStructure)
Copy constructor.
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
MapVector< map_Type > mapVector_Type
Type of the MapVector to be used with this class.
void setBlockStructure(const mapVector_Type &mapVector)
Reset the block structure using the blocks of a vector of map.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
VectorBlockStructure()
Default constructor.