8 #include <lifev/core/linear_algebra/BlockEpetra_Map.hpp> 33 M_blockMap[iblock].reset(
new map_Type(*(map.M_blockMap[iblock])));
34 M_blockShiftedMap[iblock].reset(
new map_Type(*(map.M_blockShiftedMap[iblock])));
35 M_mono2block[iblock].reset(
new import_Type(*(map.M_mono2block[iblock])));
36 M_block2mono[iblock].reset(
new import_Type(*(map.M_block2mono[iblock])));
55 tmpContainer[0] = map1;
56 tmpContainer[1] = map2;
63 tmpContainer[0] = map1;
64 tmpContainer[1] = map2;
65 tmpContainer[2] = map3;
71 M_nBlocks = mapPtrContainer.size();
72 M_blockMap.resize(M_nBlocks);
73 M_myLocalOffsets.resize(M_nBlocks);
74 M_blockShiftedMap.resize(M_nBlocks);
75 M_mono2block.resize(M_nBlocks);
76 M_block2mono.resize(M_nBlocks);
80 M_blockMap[iblock].reset(
new map_Type(*(mapPtrContainer[iblock])));
81 M_blockShiftedMap[iblock].reset(
new map_Type(*(mapPtrContainer[iblock])));
90 tmpContainer[0].reset(blockMap2Map(&map1));
91 tmpContainer[1].reset(blockMap2Map(&map2));
95 void BlockEpetra_Map::
setUp(
const Epetra_BlockMap & map1,
const Epetra_BlockMap & map2,
const Epetra_BlockMap & map3)
98 tmpContainer[0].reset(blockMap2Map(&map1));
99 tmpContainer[1].reset(blockMap2Map(&map2));
100 tmpContainer[2].reset(blockMap2Map(&map3));
120 return M_blockMap[iblock];
125 return M_blockMap[iblock];
130 return M_blockShiftedMap[iblock];
134 return M_blockShiftedMap[iblock];
139 return *M_block2mono[iblock];
144 return *M_mono2block[iblock];
149 std::cout<<
"Number of Blocks = " << M_nBlocks <<
"\n";
150 for(UInt i(0); i < M_nBlocks; ++i)
151 std::cout<<
"MyLocalOffsets[" << i<<
"] = " << M_myLocalOffsets[i] <<
"\n";
158 const comm_Type & comm(M_blockMap[0]->Comm());
165 std::vector<
int> numMyElBlock(M_nBlocks), numGlobalElBlock(M_nBlocks);
166 int numMyElMono(0), numGlobalElMono(0);
170 numMyElBlock[iblock] = M_blockMap[iblock]->NumMyElements();
171 numGlobalElBlock[iblock] = M_blockMap[iblock]->NumGlobalElements();
175 numMyElMono = std::accumulate(numMyElBlock.begin(), numMyElBlock.end(), numMyElMono);
176 numGlobalElMono = std::accumulate(numGlobalElBlock.begin(), numGlobalElBlock.end(), numGlobalElMono);
180 std::vector<
int> shift(M_nBlocks+1);
181 std::vector<
int>::iterator itShift(shift.begin());
183 *itShift = 0; itShift++;
185 std::partial_sum(numGlobalElBlock.begin(), numGlobalElBlock.end(), itShift);
189 std::vector<UInt>::iterator itMyShift(M_myLocalOffsets.begin());
190 *itMyShift = 0; ++itMyShift;
191 std::partial_sum(numMyElBlock.begin(), numMyElBlock.end()-1, itMyShift);
197 std::vector<std::vector<
int> > myGlobalElBlock(M_nBlocks);
198 std::vector<
int> myGlobalElMono(numMyElMono);
201 std::vector<
int>::iterator myGlobalElMonoIt;
202 myGlobalElMonoIt = myGlobalElMono.begin();
205 for(std::vector<std::vector<
int> >::iterator myGlobalElBlockIt = myGlobalElBlock.begin();
206 myGlobalElBlockIt != myGlobalElBlock.end();
210 UInt iblock = (UInt) (myGlobalElBlockIt - myGlobalElBlock.begin());
212 myGlobalElBlockIt->resize(numMyElBlock[iblock]);
213 M_blockShiftedMap[iblock]->MyGlobalElements( &(*myGlobalElBlockIt)[0] );
216 for(std::vector<
int>::iterator it=myGlobalElBlockIt->begin(); it!=myGlobalElBlockIt->end(); ++it)
217 *it += shift[iblock];
220 myGlobalElMonoIt = std::copy(myGlobalElBlockIt->begin(), myGlobalElBlockIt->end(), myGlobalElMonoIt);
223 M_blockShiftedMap[iblock].reset(
new map_Type(numGlobalElBlock[iblock], myGlobalElBlockIt->size(),
224 &(*myGlobalElBlockIt)[0], shift[iblock], comm));
229 M_monolithicMap.reset(
new map_Type(numGlobalElMono, myGlobalElMono.size(), &myGlobalElMono[0], 0, comm));
232 for(UInt iblock=0; iblock<M_nBlocks; ++iblock)
234 M_block2mono[iblock].reset(
new import_Type(*M_monolithicMap, *M_blockShiftedMap[iblock]));
235 M_mono2block[iblock].reset(
new import_Type(*M_blockShiftedMap[iblock], *M_monolithicMap));
242 Epetra_Map * map =
new Epetra_Map
243 (blockMap->NumGlobalElements(),
244 blockMap->NumMyElements(),
245 blockMap->MyGlobalElements(),
246 blockMap->IndexBase(),
const import_Type & mono2blockImporter(UInt iblock) const
return an Trilinos import_Type object from the monolithic map to block iblock map.
This class handles block access to parallel monolithic Vectors with an underling block structure...
mapPtr_Type & blockMap(UInt iblock)
returns the original map of block iblock
mapPtr_Type M_monolithicMap
void setUp(const Epetra_BlockMap &map1, const Epetra_BlockMap &map2, const Epetra_BlockMap &map3)
other set up routines to overcome a design problem in Trilinos (3 blocks)
mapPtr_Type & blockShiftedMap(UInt iblock)
returns the map relative to block iblock in the numbering of the monolithic map
const constMapPtr_Type blockMap(UInt iblock) const
const version
void setUp(const mapPtrContainer_Type &mapPtrContainer)
general setup for arbitrary number of blocks. The maps of the block to stride are collected in a mapP...
BlockEpetra_Map(const mapPtrContainer_Type &mapPtrContainer)
Construct a BlockEpetra_Map from an ordered list of Epetra_BlockMap objects.
importPtrContainer_Type M_mono2block
split the monolithic vector in the block vectors
const constMapPtr_Type monolithicMap() const
const version
void updateInverseJacobian(const UInt &iQuadPt)
mapPtrContainer_Type M_blockMap
const constMapPtr_Type blockShiftedMap(UInt iblock) const
const version
BlockEpetra_Map(const BlockEpetra_Map &map)
Copy constructor.
std::vector< mapPtr_Type > mapPtrContainer_Type
BlockEpetra_Map()
Default Constructor.
importPtrContainer_Type M_block2mono
merge block vectors in the monolithic vector
Epetra_Import import_Type
mapPtrContainer_Type M_blockShiftedMap
const import_Type & block2monoImporter(UInt iblock) const
return an Trilinos import_Type object from block iblock map to the monolithic map ...
void setUp(const Epetra_BlockMap &map1, const Epetra_BlockMap &map2)
other set up routines to overcome a design problem in Trilinos (2 blocks)
mapPtr_Type & monolithicMap()
returns the monolithicMap
void showMe()
Print debug info.
UInt nBlocks() const
get the number of blocks
Epetra_Map * blockMap2Map(const Epetra_BlockMap *blockMap)
uint32_type UInt
generic unsigned integer (used mainly for addressing)