void PreconditionerTeko::buildBlockGIDs ( std::vector<std::vector<int> >& gids, const MapEpetra& map, const std::vector<int>& blockSizes ) { int numLocal = map.map ( Unique )->NumMyElements(); int numBlocks = blockSizes.size(); gids.clear(); gids.resize ( blockSizes.size() ); int gid = -1; int cumulBlocksSizes = 0; for ( int i ( 0 ); i < numLocal; ++i ) { gid = map.map ( Unique )->GID ( i ); cumulBlocksSizes = 0; for ( int j ( 0 ); j < numBlocks; ++j ) { cumulBlocksSizes += blockSizes[j]; if ( gid <= cumulBlocksSizes ) { gids[j].push_back ( gid ); break; } } } }
MatrixBlockMonolithicEpetra<DataType>::MatrixBlockMonolithicEpetra (const MapEpetra& map, int numEntries) : MatrixEpetra<DataType> (map, numEntries), M_blockNumRows (std::vector<UInt> (1, map.map (Unique)->NumGlobalElements() ) ), M_blockNumColumns (std::vector<UInt> (1, map.map (Unique)->NumGlobalElements() ) ), M_blockFirstRows (std::vector<UInt> (1, 0) ), M_blockFirstColumns (std::vector<UInt> (1, 0) ) { }
bool MapEpetra::mapsAreSimilar ( MapEpetra const& epetraMap ) const { if ( this == &epetraMap ) { return true; } return ( getUniqueMap()->SameAs ( *epetraMap.getUniqueMap() ) && getRepeatedMap()->SameAs ( *epetraMap.getRepeatedMap() ) ); }
MatrixBlockMonolithicEpetra<DataType>::MatrixBlockMonolithicEpetra ( const MapVector<MapEpetra>& vector, int numEntries) : MatrixEpetra<DataType> (vector.totalMap() ) //MatrixEpetra<DataType>( typename MatrixEpetra<DataType>::matrix_ptrtype()) { ASSERT ( vector.nbMap() > 0 , "Map vector empty, impossible to construct a MatrixBlockMonolithicEpetra!"); MapEpetra myMap (vector.map (0) ); M_blockNumRows.push_back (vector.mapSize (0) ); M_blockNumColumns.push_back (vector.mapSize (0) ); M_blockFirstRows.push_back (0); M_blockFirstColumns.push_back (0); UInt totalRows (vector.mapSize (0) ); UInt totalColumns (vector.mapSize (0) ); for (UInt i (1); i < vector.nbMap(); ++i) { myMap += vector.map (i); M_blockNumRows.push_back (vector.mapSize (i) ); M_blockNumColumns.push_back (vector.mapSize (i) ); M_blockFirstRows.push_back (totalRows); M_blockFirstColumns.push_back (totalColumns); totalRows += vector.mapSize (i); totalColumns += vector.mapSize (i); } this->mapPtr().reset (new MapEpetra (myMap) ); this->matrixPtr().reset ( new typename MatrixEpetra<DataType>::matrix_type ( Copy, *myMap.map ( Unique ), numEntries, false) ); }
MatrixEpetraStructured<DataType>::MatrixEpetraStructured ( const MapVector<MapEpetra>& vector, int numEntries, bool ignoreNonLocalValues ) : MatrixEpetra<DataType> ( typename MatrixEpetra<DataType>::matrix_ptrtype() ), M_blockStructure ( vector ) { ASSERT ( vector.nbMap() > 0 , "Map vector empty, impossible to construct a MatrixBlockMonolithicEpetra!" ); MapEpetra myMap ( vector.totalMap() ); this->mapPtr().reset ( new MapEpetra ( myMap ) ); this->matrixPtr().reset ( new typename MatrixEpetra<DataType>::matrix_type ( Copy, *myMap.map ( Unique ), numEntries, ignoreNonLocalValues ) ); }
void MultiscaleCoupling::createCouplingMap ( MapEpetra& couplingMap ) { #ifdef HAVE_LIFEV_DEBUG debugStream ( 8200 ) << "MultiscaleCoupling::createCouplingMap( couplingMap ) \n"; #endif M_couplingVariablesOffset = couplingMap.map ( Unique )->NumGlobalElements(); couplingMap += localCouplingVariables ( 0 ).map(); }
void MonolithicBlockMatrix::createInterfaceMap( const MapEpetra& interfaceMap , const std::map<ID, ID>& locDofMap, const UInt subdomainMaxId, const boost::shared_ptr<Epetra_Comm> epetraWorldComm ) { //std::map<ID, ID> const& locDofMap = M_dofStructureToHarmonicExtension->locDofMap(); std::map<ID, ID>::const_iterator ITrow; Int numtasks = epetraWorldComm->NumProc(); int* numInterfaceDof(new int[numtasks]); int pid=epetraWorldComm->MyPID(); int numMyElements = interfaceMap.map(Unique)->NumMyElements(); numInterfaceDof[pid]=numMyElements; MapEpetra subMap(*interfaceMap.map(Unique), (UInt)0, subdomainMaxId); M_numerationInterface.reset(new vector_Type(subMap,Unique)); //should be an int vector instead of double // M_numerationInterfaceInt.reset(new Epetra_IntVector(*M_interfaceMap.getMap(Unique))); for (int j=0; j<numtasks; ++j) epetraWorldComm->Broadcast( &numInterfaceDof[j], 1, j); for (int j=numtasks-1; j>0 ; --j) { numInterfaceDof[j] = numInterfaceDof[j-1]; } numInterfaceDof[0]=0; for (int j=1; j<numtasks ; ++j) numInterfaceDof[j] += numInterfaceDof[j-1]; UInt l=0; M_interface = (UInt) interfaceMap.map(Unique)->NumGlobalElements()/nDimensions; //UInt solidDim=M_dFESpace->map().map(Unique)->NumGlobalElements()/nDimensions; for (l=0, ITrow=locDofMap.begin(); ITrow!=locDofMap.end() ; ++ITrow) { if (interfaceMap.map(Unique)->LID(ITrow->second /*+ dim*solidDim*/)>=0) { (*M_numerationInterface)[ITrow->second /*+ dim*solidDim*/ ]=l+ (int)(numInterfaceDof[pid]/nDimensions)/*+ dim*localInterface*/ ; // (*M_numerationInterfaceInt)[ITrow->second /*+ dim*solidDim*/ ]=l+1+ (int)(M_numInterfaceDof[pid]/nDimensions)/*+ dim*localInterface*/ ; if ((int)(*M_numerationInterface)(ITrow->second )!=floor(l+ numInterfaceDof[pid]/nDimensions+0.2 /*+ dim*localInterface*/) ) std::cout<<"ERROR! the numeration of the coupling map is not correct"<<std::endl; ++l; } } std::vector<int> couplingVector; couplingVector.reserve((int)(interfaceMap.map(Unique)->NumMyElements())); for (UInt dim=0; dim<nDimensions; ++dim) { for ( ITrow=locDofMap.begin(); ITrow!=locDofMap.end() ; ++ITrow) { if (interfaceMap.map(Unique)->LID(ITrow->second)>=0) { couplingVector.push_back((*M_numerationInterface)(ITrow->second /*+ dim * solidDim*/)+ dim * M_interface ); //couplingVector.push_back((*M_numerationInterfaceInt)[ITrow->second /*+ dim * solidDim*/]+ dim * M_interface ); } } }// so the map for the coupling part of the matrix is just Unique M_interfaceMap.reset(new MapEpetra(-1, static_cast< Int> ( couplingVector.size() ), &couplingVector[0], epetraWorldComm)); }