diff --git a/AMDiS/src/DOFMatrix.cc b/AMDiS/src/DOFMatrix.cc index 6b32912b01c5102ae5f362edb1a61365d18856cc..7f6d9754336db6bd0a4901f2069cd532227d17f4 100644 --- a/AMDiS/src/DOFMatrix.cc +++ b/AMDiS/src/DOFMatrix.cc @@ -238,7 +238,7 @@ namespace AMDiS { if (condition->applyBoundaryCondition()) { #ifdef HAVE_PARALLEL_DOMAIN_AMDIS - if (dofMap->isRankDof(rowIndices[i], 0)) + if (dofMap->isRankDof(rowIndices[i])) applyDBCs.insert(static_cast<int>(row)); #else applyDBCs.insert(static_cast<int>(row)); diff --git a/AMDiS/src/DOFVector.h b/AMDiS/src/DOFVector.h index 4db016c5f822d10d8cf894fbaa960def78552f19..41afc730400dd5447dff825fc3b5a2d7aeccbfc0 100644 --- a/AMDiS/src/DOFVector.h +++ b/AMDiS/src/DOFVector.h @@ -248,7 +248,7 @@ namespace AMDiS { { TEST_EXIT_DBG(dofMap)("No rank dofs set!\n"); - return dofMap->isRankDof(dof, 0); + return dofMap->isRankDof(dof); } #endif diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc index f7700e1f29f9dcbd7b60321214ef746c0eb51601..3d19c081b7a70fa26dcdf675239d4298f4d9672a 100644 --- a/AMDiS/src/parallel/MeshDistributor.cc +++ b/AMDiS/src/parallel/MeshDistributor.cc @@ -1246,7 +1246,7 @@ namespace AMDiS { // === Run mesh partitioner to calculate a new mesh partitioning. === - partitioner->setLocalGlobalDofMap(&(dofMap[feSpaces[0]].getMap(0))); + partitioner->setLocalGlobalDofMap(&(dofMap[feSpaces[0]].getMap())); bool partitioningSucceed = partitioner->partition(elemWeights, ADAPTIVE_REPART); @@ -1654,23 +1654,19 @@ namespace AMDiS { MSG("| number of levels: %d\n", nLevels); MSG("| number of FE spaces: %d\n", feSpaces.size()); - for (int level = 0; level < nLevels; level++) { - for (unsigned int i = 0; i < feSpaces.size(); i++) { - MSG("| level = %d FE space = %d:\n", level, i); - MSG("| nRankDofs = %d\n", dofMap[feSpaces[i]].nRankDofs[level]); - MSG("| nOverallDofs = %d\n", dofMap[feSpaces[i]].nOverallDofs[level]); - MSG("| rStartDofs = %d\n", dofMap[feSpaces[i]].rStartDofs[level]); - } + for (unsigned int i = 0; i < feSpaces.size(); i++) { + MSG("| FE space = %d:\n", i); + MSG("| nRankDofs = %d\n", dofMap[feSpaces[i]].nRankDofs); + MSG("| nOverallDofs = %d\n", dofMap[feSpaces[i]].nOverallDofs); + MSG("| rStartDofs = %d\n", dofMap[feSpaces[i]].rStartDofs); } if (nLevels > 1) { - for (int level = 0; level < nLevels; level++) { - for (unsigned int i = 0; i < feSpaces.size(); i++) { - MSG("| level = %d FE space = %d:\n", level, i); - MSG("| nRankDofs = %d\n", dofMapSd[feSpaces[i]].nRankDofs[level]); - MSG("| nOverallDofs = %d\n", dofMapSd[feSpaces[i]].nOverallDofs[level]); - MSG("| rStartDofs = %d\n", dofMapSd[feSpaces[i]].rStartDofs[level]); - } + for (unsigned int i = 0; i < feSpaces.size(); i++) { + MSG("| FE space = %d:\n", i); + MSG("| nRankDofs = %d\n", dofMapSd[feSpaces[i]].nRankDofs); + MSG("| nOverallDofs = %d\n", dofMapSd[feSpaces[i]].nOverallDofs); + MSG("| rStartDofs = %d\n", dofMapSd[feSpaces[i]].rStartDofs); } } @@ -1704,23 +1700,19 @@ namespace AMDiS { sort(rankDofs.begin(), rankDofs.end(), cmpDofsByValue); // === Traverse interior boundaries and get all DOFs on them. === - - int nLevels = levelData.getLevelNumber(); - for (int level = 0; level < nLevels; level++) { - DofContainerSet nonRankDofs; - for (DofComm::Iterator it(dcom.getRecvDofs(), level, feSpace); - !it.end(); it.nextRank()) - for (; !it.endDofIter(); it.nextDof()) - nonRankDofs.insert(it.getDof()); - - for (unsigned int i = 0; i < rankDofs.size(); i++) - if (nonRankDofs.count(rankDofs[i]) == 0) - dmap[feSpace].insertRankDof(level, *(rankDofs[i])); - - for (DofContainerSet::iterator it = nonRankDofs.begin(); - it != nonRankDofs.end(); ++it) - dmap[feSpace].insertNonRankDof(level, **it); - } + DofContainerSet nonRankDofs; + for (DofComm::Iterator it(dcom.getRecvDofs(), 0, feSpace); + !it.end(); it.nextRank()) + for (; !it.endDofIter(); it.nextDof()) + nonRankDofs.insert(it.getDof()); + + for (unsigned int i = 0; i < rankDofs.size(); i++) + if (nonRankDofs.count(rankDofs[i]) == 0) + dmap[feSpace].insertRankDof(*(rankDofs[i])); + + for (DofContainerSet::iterator it = nonRankDofs.begin(); + it != nonRankDofs.end(); ++it) + dmap[feSpace].insertNonRankDof(**it); } @@ -1782,8 +1774,8 @@ namespace AMDiS { BoundaryType type = bound.type; for (unsigned int j = 0; j < dofs0.size(); j++) { - DegreeOfFreedom globalDof0 = dofMap[feSpace][0][*(dofs0[j])].global; - DegreeOfFreedom globalDof1 = dofMap[feSpace][0][*(dofs1[j])].global; + DegreeOfFreedom globalDof0 = dofMap[feSpace][*(dofs0[j])].global; + DegreeOfFreedom globalDof1 = dofMap[feSpace][*(dofs1[j])].global; if (!periodicMap.isPeriodicOnBound(feSpace, type, globalDof0)) periodicMap.add(feSpace, type, globalDof0, globalDof1); @@ -1808,7 +1800,7 @@ namespace AMDiS { // Send the global indices to the rank on the other side. stdMpi.getSendData(it->first).reserve(dofs.size()); for (unsigned int i = 0; i < dofs.size(); i++) - stdMpi.getSendData(it->first).push_back(dofMap[feSpace][0][*(dofs[i])].global); + stdMpi.getSendData(it->first).push_back(dofMap[feSpace][*(dofs[i])].global); // Receive from this rank the same number of dofs. stdMpi.recv(it->first, dofs.size()); @@ -1834,7 +1826,7 @@ namespace AMDiS { // Added the received DOFs to the mapping. for (unsigned int i = 0; i < dofs.size(); i++) { - int globalDofIndex = dofMap[feSpace][0][*(dofs[i])].global; + int globalDofIndex = dofMap[feSpace][*(dofs[i])].global; int mapGlobalDofIndex = stdMpi.getRecvData(it->first)[i]; BoundaryType type = types[i]; @@ -1867,7 +1859,7 @@ namespace AMDiS { boundIt->rankObj.el->getAllDofs(feSpace, boundIt->rankObj, dofs); for (unsigned int i = 0; i < dofs.size(); i++) { - DegreeOfFreedom globalDof = dofMap[feSpace][0][*dofs[i]].global; + DegreeOfFreedom globalDof = dofMap[feSpace][*dofs[i]].global; std::set<BoundaryType>& assoc = periodicMap.getAssociations(feSpace, globalDof); diff --git a/AMDiS/src/parallel/MeshDistributor.h b/AMDiS/src/parallel/MeshDistributor.h index 9d49c7600824c179f9e503af814f665f87b5c29f..402b66b96c2dd6fb085fe0a898085c493de51b1d 100644 --- a/AMDiS/src/parallel/MeshDistributor.h +++ b/AMDiS/src/parallel/MeshDistributor.h @@ -151,6 +151,11 @@ namespace AMDiS { return dofMap; } + inline ParallelDofMapping& getDofMapSd() + { + return dofMapSd; + } + /// Returns the periodic mapping handler, \ref periodicMap. inline PeriodicMap& getPeriodicMap() { diff --git a/AMDiS/src/parallel/ParallelDebug.cc b/AMDiS/src/parallel/ParallelDebug.cc index c8844a1d3a64fce1e3cd7396f0af452b90fb80d3..bdbb55373911c14f8d9abbd0d28875a5d183a900 100644 --- a/AMDiS/src/parallel/ParallelDebug.cc +++ b/AMDiS/src/parallel/ParallelDebug.cc @@ -480,7 +480,7 @@ namespace AMDiS { DOFIterator<WorldVector<double> > it(&coords, USED_DOFS); for (it.reset(); !it.end(); ++it) { - coordsToIndex[(*it)] = pdb.dofMap[feSpace][0][it.getDOFIndex()].global; + coordsToIndex[(*it)] = pdb.dofMap[feSpace][it.getDOFIndex()].global; // MSG(" CHECK FOR DOF %d AT COORDS %f %f %f\n", // coordsToIndex[(*it)], (*it)[0], (*it)[1], (*it)[2]); } @@ -794,8 +794,8 @@ namespace AMDiS { DOFIterator<WorldVector<double> > it(&coords, USED_DOFS); for (it.reset(); !it.end(); ++it) { file << it.getDOFIndex() << " " - << pdb.dofMap[feSpace][0][it.getDOFIndex()].global << " " - << pdb.dofMap[feSpace].isRankDof(it.getDOFIndex(), 0); + << pdb.dofMap[feSpace][it.getDOFIndex()].global << " " + << pdb.dofMap[feSpace].isRankDof(it.getDOFIndex()); for (int i = 0; i < pdb.mesh->getDim(); i++) file << " " << (*it)[i]; file << "\n"; diff --git a/AMDiS/src/parallel/ParallelDofMapping.cc b/AMDiS/src/parallel/ParallelDofMapping.cc index 872b4a70d5c9d9f13e2f2994a6876df889e3be4e..05f6c476511984a478f957e8f87801a89fba2fe5 100644 --- a/AMDiS/src/parallel/ParallelDofMapping.cc +++ b/AMDiS/src/parallel/ParallelDofMapping.cc @@ -19,22 +19,14 @@ namespace AMDiS { void FeSpaceDofMap::clear() { - int nLevel = levelData->getLevelNumber(); dofMap.clear(); - dofMap.resize(nLevel); nonRankDofs.clear(); - nonRankDofs.resize(nLevel); - nRankDofs.clear(); - nLocalDofs.clear(); - nOverallDofs.clear(); - rStartDofs.clear(); - - nRankDofs.resize(nLevel, 0); - nLocalDofs.resize(nLevel, 0); - nOverallDofs.resize(nLevel, 0); - rStartDofs.resize(nLevel, 0); + nRankDofs = 0; + nLocalDofs = 0; + nOverallDofs = 0; + rStartDofs = 0; } @@ -42,48 +34,44 @@ namespace AMDiS { { FUNCNAME("FeSpaceDofMap::update()"); - int nLevel = levelData->getLevelNumber(); - for (int i = 0; i < nLevel; i++) { - - // === Compute local indices for all rank owned DOFs. === - - for (DofMap::iterator it = dofMap[i].begin(); it != dofMap[i].end(); ++it) - if (it->second.local == -1 && nonRankDofs[i].count(it->first) == 0) - it->second.local = nRankDofs[i]++; - - // === Compute number of local and global DOFs in the mapping. === - - nOverallDofs[i] = 0; - rStartDofs[i] = 0; - mpi::getDofNumbering(mpiComm, - nRankDofs[i], rStartDofs[i], nOverallDofs[i]); - - // === If required, compute also the global indices. === + // === Compute local indices for all rank owned DOFs. === + + for (DofMap::iterator it = dofMap.begin(); it != dofMap.end(); ++it) + if (it->second.local == -1 && nonRankDofs.count(it->first) == 0) + it->second.local = nRankDofs++; + + // === Compute number of local and global DOFs in the mapping. === + + nOverallDofs = 0; + rStartDofs = 0; + mpi::getDofNumbering(mpiComm, nRankDofs, rStartDofs, nOverallDofs); + + // === If required, compute also the global indices. === + + if (needGlobalMapping) { + computeGlobalMapping(); - if (needGlobalMapping) { - computeGlobalMapping(i); - - if (hasNonLocalDofs) - computeNonLocalIndices(i); - } + if (hasNonLocalDofs) + computeNonLocalIndices(); } } - void FeSpaceDofMap::computeGlobalMapping(int level) + void FeSpaceDofMap::computeGlobalMapping() { FUNCNAME("FeSpaceDofMap::computeGlobalMapping()"); - for (DofMap::iterator it = dofMap[level].begin(); - it != dofMap[level].end(); ++it) - it->second.global = it->second.local + rStartDofs[level]; + for (DofMap::iterator it = dofMap.begin(); it != dofMap.end(); ++it) + it->second.global = it->second.local + rStartDofs; } - void FeSpaceDofMap::computeNonLocalIndices(int level) + void FeSpaceDofMap::computeNonLocalIndices() { FUNCNAME("FeSpaceDofMap::computeNonLocalIndices()"); + TEST_EXIT_DBG(dofComm)("No DOF communicator defined!\n"); + typedef map<int, map<const FiniteElemSpace*, DofContainer> >::iterator it_type; // === Send all global indices of DOFs that are owned by the rank to all === @@ -91,17 +79,17 @@ namespace AMDiS { StdMpi<vector<int> > stdMpi(mpiComm); - for (DofComm::Iterator it(dofComm->getSendDofs(), level, feSpace); + for (DofComm::Iterator it(dofComm->getSendDofs(), 0, feSpace); !it.end(); it.nextRank()) { int rank = it.getRank(); if (meshLevel > 0) rank = levelData->mapRank(rank, 0, meshLevel); for (; !it.endDofIter(); it.nextDof()) - if (dofMap[level].count(it.getDofIndex()) && - !nonRankDofs[level].count(it.getDofIndex())) + if (dofMap.count(it.getDofIndex()) && + !nonRankDofs.count(it.getDofIndex())) stdMpi.getSendData(rank). - push_back(dofMap[level][it.getDofIndex()].global); + push_back(dofMap[it.getDofIndex()].global); } stdMpi.updateSendDataSize(); @@ -109,11 +97,11 @@ namespace AMDiS { // === Check from which ranks this rank must receive some data. === - for (DofComm::Iterator it(dofComm->getRecvDofs(), level, feSpace); + for (DofComm::Iterator it(dofComm->getRecvDofs(), 0, feSpace); !it.end(); it.nextRank()) { bool recvFromRank = false; for (; !it.endDofIter(); it.nextDof()) { - if (nonRankDofs[level].count(it.getDofIndex())) { + if (nonRankDofs.count(it.getDofIndex())) { recvFromRank = true; break; } @@ -136,7 +124,7 @@ namespace AMDiS { // === And set the global indices for all DOFs that are not owned by rank. === - for (DofComm::Iterator it(dofComm->getRecvDofs(), level, feSpace); + for (DofComm::Iterator it(dofComm->getRecvDofs(), 0, feSpace); !it.end(); it.nextRank()) { int rank = it.getRank(); if (meshLevel > 0) @@ -144,8 +132,8 @@ namespace AMDiS { int i = 0; for (; !it.endDofIter(); it.nextDof()) - if (nonRankDofs[level].count(it.getDofIndex())) - dofMap[level][it.getDofIndex()].global = stdMpi.getRecvData(rank)[i++]; + if (nonRankDofs.count(it.getDofIndex())) + dofMap[it.getDofIndex()].global = stdMpi.getRecvData(rank)[i++]; } } @@ -185,20 +173,11 @@ namespace AMDiS { it != feSpacesUnique.end(); ++it) data[*it].clear(); - int nLevel = levelData->getLevelNumber(); - nRankDofs.resize(nLevel); - nLocalDofs.resize(nLevel); - nOverallDofs.resize(nLevel); - rStartDofs.resize(nLevel); - dofToMatIndex.resize(nLevel); - - for (int i = 0; i < nLevel; i++) { - nRankDofs[i] = -1; - nLocalDofs[i] = -1; - nOverallDofs[i] = -1; - rStartDofs[i] = -1; - dofToMatIndex[i].clear(); - } + nRankDofs = -1; + nLocalDofs = -1; + nOverallDofs = -1; + rStartDofs = -1; + dofToMatIndex.clear(); } @@ -239,56 +218,56 @@ namespace AMDiS { } - int ParallelDofMapping::computeRankDofs(int level) + int ParallelDofMapping::computeRankDofs() { FUNCNAME("ParallelDofMapping::computeRankDofs()"); int result = 0; for (unsigned int i = 0; i < feSpaces.size(); i++) { TEST_EXIT_DBG(data.count(feSpaces[i]))("Should not happen!\n"); - result += data[feSpaces[i]].nRankDofs[level]; + result += data[feSpaces[i]].nRankDofs; } return result; } - int ParallelDofMapping::computeLocalDofs(int level) + int ParallelDofMapping::computeLocalDofs() { FUNCNAME("ParallelDofMapping::computeLocalDofs()"); int result = 0; for (unsigned int i = 0; i < feSpaces.size(); i++) { TEST_EXIT_DBG(data.count(feSpaces[i]))("Should not happen!\n"); - result += data[feSpaces[i]].nLocalDofs[level]; + result += data[feSpaces[i]].nLocalDofs; } return result; } - int ParallelDofMapping::computeOverallDofs(int level) + int ParallelDofMapping::computeOverallDofs() { FUNCNAME("ParallelDofMapping::computeOverallDofs()"); int result = 0; for (unsigned int i = 0; i < feSpaces.size(); i++) { TEST_EXIT_DBG(data.count(feSpaces[i]))("Should not happen!\n"); - result += data.find(feSpaces[i])->second.nOverallDofs[level]; + result += data.find(feSpaces[i])->second.nOverallDofs; } return result; } - int ParallelDofMapping::computeStartDofs(int level) + int ParallelDofMapping::computeStartDofs() { FUNCNAME("ParallelDofMapping::computeStartDofs()"); int result = 0; for (unsigned int i = 0; i < feSpaces.size(); i++) { TEST_EXIT_DBG(data.count(feSpaces[i]))("Should not happen!\n"); - result += data.find(feSpaces[i])->second.rStartDofs[level]; + result += data.find(feSpaces[i])->second.rStartDofs; } return result; @@ -304,19 +283,15 @@ namespace AMDiS { it != feSpacesUnique.end(); ++it) data[*it].update(); - int nLevel = levelData->getLevelNumber(); - for (int i = 0; i < nLevel; i++) { - // Compute all numbers from this mappings. - - nRankDofs[i] = computeRankDofs(i); - nLocalDofs[i] = computeLocalDofs(i); - nOverallDofs[i] = computeOverallDofs(i); - rStartDofs[i] = computeStartDofs(i); - - // And finally, compute the matrix indices. - if (needMatIndex) - computeMatIndex(needMatIndexFromGlobal, i); - } + // Compute all numbers from this mappings. + nRankDofs = computeRankDofs(); + nLocalDofs = computeLocalDofs(); + nOverallDofs = computeOverallDofs(); + rStartDofs = computeStartDofs(); + + // And finally, compute the matrix indices. + if (needMatIndex) + computeMatIndex(needMatIndexFromGlobal); } @@ -335,16 +310,16 @@ namespace AMDiS { } - void ParallelDofMapping::computeMatIndex(bool globalIndex, int level) + void ParallelDofMapping::computeMatIndex(bool globalIndex) { FUNCNAME("ParallelDofMapping::computeMatIndex()"); - dofToMatIndex[level].clear(); + dofToMatIndex.clear(); // The offset is always added to the local matrix index. The offset for the // DOFs in the first FE spaces is the smalled global index of a DOF that is // owned by the rank. - int offset = rStartDofs[level]; + int offset = rStartDofs; // === Create the matrix indices for all component FE spaces. === @@ -353,20 +328,20 @@ namespace AMDiS { // Traverse all DOFs of the FE space and create for all rank owned DOFs // a matrix index. - DofMap& dofMap = data[feSpaces[i]].getMap(level); + DofMap& dofMap = data[feSpaces[i]].getMap(); for (DofMap::iterator it = dofMap.begin(); it != dofMap.end(); ++it) { - if (data[feSpaces[i]].isRankDof(it->first, level)) { + if (data[feSpaces[i]].isRankDof(it->first)) { int globalMatIndex = it->second.local + offset; if (globalIndex) - dofToMatIndex[level].add(i, it->second.global, globalMatIndex); + dofToMatIndex.add(i, it->second.global, globalMatIndex); else - dofToMatIndex[level].add(i, it->first, globalMatIndex); + dofToMatIndex.add(i, it->first, globalMatIndex); } } // Increase the offset for the next FE space by the number of DOFs owned // by the rank in the current FE space. - offset += data[feSpaces[i]].nRankDofs[level]; + offset += data[feSpaces[i]].nRankDofs; // If there are no non local DOFs, continue with the next FE space. if (!hasNonLocalDofs) @@ -378,16 +353,16 @@ namespace AMDiS { // === interior boundaries. === StdMpi<vector<DegreeOfFreedom> > stdMpi(mpiComm); - for (DofComm::Iterator it(dofComm->getSendDofs(), level, feSpaces[i]); + for (DofComm::Iterator it(dofComm->getSendDofs(), 0, feSpaces[i]); !it.end(); it.nextRank()) { vector<DegreeOfFreedom> sendGlobalDofs; for (; !it.endDofIter(); it.nextDof()) if (dofMap.count(it.getDofIndex())) if (globalIndex) - sendGlobalDofs.push_back(dofToMatIndex[level].get(i, dofMap[it.getDofIndex()].global)); + sendGlobalDofs.push_back(dofToMatIndex.get(i, dofMap[it.getDofIndex()].global)); else - sendGlobalDofs.push_back(dofToMatIndex[level].get(i, it.getDofIndex())); + sendGlobalDofs.push_back(dofToMatIndex.get(i, it.getDofIndex())); int rank = it.getRank(); if (meshLevel > 0) @@ -396,7 +371,7 @@ namespace AMDiS { stdMpi.send(rank, sendGlobalDofs); } - for (DofComm::Iterator it(dofComm->getRecvDofs(), level, feSpaces[i]); + for (DofComm::Iterator it(dofComm->getRecvDofs(), 0, feSpaces[i]); !it.end(); it.nextRank()) { int rank = it.getRank(); if (meshLevel > 0) @@ -408,7 +383,7 @@ namespace AMDiS { stdMpi.startCommunication(); { - for (DofComm::Iterator it(dofComm->getRecvDofs(), level, feSpaces[i]); + for (DofComm::Iterator it(dofComm->getRecvDofs(), 0, feSpaces[i]); !it.end(); it.nextRank()) { int rank = it.getRank(); if (meshLevel > 0) @@ -419,9 +394,9 @@ namespace AMDiS { if (dofMap.count(it.getDofIndex())) { DegreeOfFreedom d = stdMpi.getRecvData(rank)[counter++]; if (globalIndex) - dofToMatIndex[level].add(i, dofMap[it.getDofIndex()].global, d); + dofToMatIndex.add(i, dofMap[it.getDofIndex()].global, d); else - dofToMatIndex[level].add(i, it.getDofIndex(), d); + dofToMatIndex.add(i, it.getDofIndex(), d); } } } diff --git a/AMDiS/src/parallel/ParallelDofMapping.h b/AMDiS/src/parallel/ParallelDofMapping.h index 3f14568434fee213e0dafc1c05e31fcebc1ddcf8..700520ef8afe38f1a0e0152aa14b3255e3ce8972 100644 --- a/AMDiS/src/parallel/ParallelDofMapping.h +++ b/AMDiS/src/parallel/ParallelDofMapping.h @@ -107,7 +107,6 @@ namespace AMDiS { : levelData(ld), dofComm(NULL), feSpace(NULL), - dofMap(1), needGlobalMapping(false), hasNonLocalDofs(false) { @@ -117,75 +116,66 @@ namespace AMDiS { /// Clears all data of the mapping. void clear(); -#if 0 /// Maps a DOF index to both, the local and global index of the mapping. The /// global index must not be set. MultiIndex& operator[](DegreeOfFreedom d) { - TEST_EXIT_DBG(dofMap[0].count(d))("Should not happen!\n"); + TEST_EXIT_DBG(dofMap.count(d))("Should not happen!\n"); - return dofMap[0][d]; + return dofMap[d]; } -#else - DofMap& operator[](int level) - { - TEST_EXIT_DBG(level < static_cast<int>(dofMap.size()))("Should not happen!\n"); - - return dofMap[level]; - } -#endif /// Inserts a new DOF to rank's mapping. The DOF is assumed to be owend by /// the rank. - void insertRankDof(int level, DegreeOfFreedom dof0, DegreeOfFreedom dof1 = -1) + void insertRankDof(DegreeOfFreedom dof0, DegreeOfFreedom dof1 = -1) { FUNCNAME("FeSpaceDofMap::insertRankDof()"); - TEST_EXIT_DBG(dofMap[level].count(dof0) == 0)("Should not happen!\n"); + TEST_EXIT_DBG(dofMap.count(dof0) == 0)("Should not happen!\n"); - dofMap[level][dof0].local = dof1; - nLocalDofs[level]++; + dofMap[dof0].local = dof1; + nLocalDofs++; if (dof1 != -1) - nRankDofs[level]++; + nRankDofs++; } /// Inserts a new DOF to rank's mapping. The DOF exists in rank's subdomain /// but is owned by a different rank, thus it is part of an interior boundary. - void insertNonRankDof(int level, DegreeOfFreedom dof0, DegreeOfFreedom dof1 = -1) + void insertNonRankDof(DegreeOfFreedom dof0, DegreeOfFreedom dof1 = -1) { FUNCNAME("FeSpaceDofMap::insertNonRankDof()"); - TEST_EXIT_DBG(dofMap[level].count(dof0) == 0)("Should not happen!\n"); + TEST_EXIT_DBG(dofMap.count(dof0) == 0)("Should not happen!\n"); - dofMap[level][dof0].local = dof1; - nLocalDofs[level]++; - nonRankDofs[level].insert(dof0); + dofMap[dof0].local = dof1; + nLocalDofs++; + nonRankDofs.insert(dof0); } /// Checks if a given DOF is in the DOF mapping. - bool isSet(DegreeOfFreedom dof, int level) + bool isSet(DegreeOfFreedom dof) { - return static_cast<bool>(dofMap[level].count(dof)); + return static_cast<bool>(dofMap.count(dof)); } /// Checks if a given DOF is a rank owned DOF of the DOF mapping. The DOF must /// a DOF of the mapping (this is not checked here), otherwise the result is /// meaningsless. - bool isRankDof(DegreeOfFreedom dof, int level) + bool isRankDof(DegreeOfFreedom dof) { - return !(static_cast<bool>(nonRankDofs[level].count(dof))); + return !(static_cast<bool>(nonRankDofs.count(dof))); } /// Returns number of DOFs in the mapping. - unsigned int size(int level) + unsigned int size() { - return dofMap[level].size(); + return dofMap.size(); } /// Returns the raw data of the mapping. - DofMap& getMap(int level) + DofMap& getMap() { - return dofMap[level]; + return dofMap; } /// Recomputes the mapping. @@ -224,11 +214,11 @@ namespace AMDiS { private: /// Computes a global mapping from the local one. - void computeGlobalMapping(int level); + void computeGlobalMapping(); /// Computes the global indices of all DOFs in the mapping that are not owned /// by the rank. - void computeNonLocalIndices(int level); + void computeNonLocalIndices(); private: MeshLevelData *levelData; @@ -245,10 +235,10 @@ namespace AMDiS { const FiniteElemSpace *feSpace; /// Mapping data from DOF indices to local and global indices. - vector<DofMap> dofMap; + DofMap dofMap; /// Set of all DOFs that are in mapping but are not owned by the rank. - vector<std::set<DegreeOfFreedom> > nonRankDofs; + std::set<DegreeOfFreedom> nonRankDofs; /// If true, a global index mapping will be computed for all DOFs. bool needGlobalMapping; @@ -260,7 +250,7 @@ namespace AMDiS { public: /// - vector<int> nRankDofs, nLocalDofs, nOverallDofs, rStartDofs; + int nRankDofs, nLocalDofs, nOverallDofs, rStartDofs; }; @@ -283,10 +273,10 @@ namespace AMDiS { nOverallDofs(1), rStartDofs(1) { - nRankDofs[0] = -1; - nLocalDofs[0] = -1; - nOverallDofs[0] = -1; - rStartDofs[0] = -1; + nRankDofs = -1; + nLocalDofs = -1; + nOverallDofs = -1; + rStartDofs = -1; } /** \brief Initialize the parallel DOF mapping. @@ -335,36 +325,36 @@ namespace AMDiS { } /// Returns \ref nRankDofs, thus the number of DOFs owned by the rank. - inline int getRankDofs(int level) + inline int getRankDofs() { - TEST_EXIT_DBG(nRankDofs[level] >= 0)("Should not happen!\n"); + TEST_EXIT_DBG(nRankDofs >= 0)("Should not happen!\n"); - return nRankDofs[level]; + return nRankDofs; } /// Returns \ref nLocalDofs, thus the number of DOFs in ranks subdomain. - inline int getLocalDofs(int level) + inline int getLocalDofs() { - TEST_EXIT_DBG(nLocalDofs[level] >= 0)("Should not happen!\n"); + TEST_EXIT_DBG(nLocalDofs >= 0)("Should not happen!\n"); - return nLocalDofs[level]; + return nLocalDofs; } /// Returns \ref nOverallDofs, thus the number of all DOFs in this mapping. - inline int getOverallDofs(int level) + inline int getOverallDofs() { - TEST_EXIT_DBG(nOverallDofs[level] >= 0)("Should not happen!\n"); + TEST_EXIT_DBG(nOverallDofs >= 0)("Should not happen!\n"); - return nOverallDofs[level]; + return nOverallDofs; } /// Returns \ref rStartDofs, thus the smallest global index of a DOF that is /// owned by the rank. - inline int getStartDofs(int level) + inline int getStartDofs() { - TEST_EXIT_DBG(rStartDofs[level] >= 0)("Should not happen!\n"); + TEST_EXIT_DBG(rStartDofs >= 0)("Should not happen!\n"); - return rStartDofs[level]; + return rStartDofs; } /// Update the mapping. @@ -375,21 +365,21 @@ namespace AMDiS { /// Returns the global matrix index of a given DOF for a given /// component number. - inline int getMatIndex(int level, int ithComponent, DegreeOfFreedom d) + inline int getMatIndex(int ithComponent, DegreeOfFreedom d) { - return dofToMatIndex[level].get(ithComponent, d); + return dofToMatIndex.get(ithComponent, d); } /// Returns the local matrix index of a given DOF for a given /// component number. - inline int getLocalMatIndex(int level, int ithComponent, DegreeOfFreedom d) + inline int getLocalMatIndex(int ithComponent, DegreeOfFreedom d) { FUNCNAME("ParallelDofMapping::getLocalMatIndex()"); - TEST_EXIT_DBG(data[feSpaces[ithComponent]].isRankDof(d, level)) + TEST_EXIT_DBG(data[feSpaces[ithComponent]].isRankDof(d)) ("Should not happen!\n"); - return dofToMatIndex[level].get(ithComponent, d) - rStartDofs[level]; + return dofToMatIndex.get(ithComponent, d) - rStartDofs; } // Writes all data of this object to an output stream. @@ -405,23 +395,23 @@ namespace AMDiS { } /// Compute local and global matrix indices. - void computeMatIndex(bool globalIndex, int level); + void computeMatIndex(bool globalIndex); protected: /// Insert a new FE space DOF mapping for a given FE space. void addFeSpace(const FiniteElemSpace* feSpace); /// Compute \ref nRankDofs. - int computeRankDofs(int level); + int computeRankDofs(); /// Compute \ref nLocalDofs. - int computeLocalDofs(int level); + int computeLocalDofs(); /// Compute \ref nOverallDofs. - int computeOverallDofs(int level); + int computeOverallDofs(); /// Compute \ref rStartDofs. - int computeStartDofs(int level); + int computeStartDofs(); private: MPI::Intracomm mpiComm; @@ -459,20 +449,20 @@ namespace AMDiS { vector<const FiniteElemSpace*> feSpacesUnique; /// Number of DOFs owned by rank. - vector<int> nRankDofs; + int nRankDofs; /// Number of DOFs in rank's subdomain. - vector<int> nLocalDofs; + int nLocalDofs; /// Number of global DOFs (this value is thus the same on all ranks). - vector<int> nOverallDofs; + int nOverallDofs; /// Smallest global index of a DOF owned by the rank. - vector<int> rStartDofs; + int rStartDofs; /// Mapping from global DOF indices to global matrix indices under /// consideration of possibly multiple components. - vector<DofToMatIndex> dofToMatIndex; + DofToMatIndex dofToMatIndex; }; } diff --git a/AMDiS/src/parallel/PetscSolverFeti.cc b/AMDiS/src/parallel/PetscSolverFeti.cc index 7a3b02f6bc3330f7f4255317de97fc16490a06a0..e81eb2157a6d42effbf98858dc6e1029724768dc 100644 --- a/AMDiS/src/parallel/PetscSolverFeti.cc +++ b/AMDiS/src/parallel/PetscSolverFeti.cc @@ -257,13 +257,23 @@ namespace AMDiS { feSpaces, meshDistributor->getFeSpaces(), true, true); lagrangeMap.setComputeMatIndex(true); - - localDofMap.init(levelData, - feSpaces, meshDistributor->getFeSpaces(), - false, false); - localDofMap.setComputeMatIndex(true); + + if (meshLevel == 0) { + localDofMap.init(levelData, + feSpaces, meshDistributor->getFeSpaces(), + false, false); + localDofMap.setComputeMatIndex(true); + } else { + localDofMap.init(levelData, + feSpaces, meshDistributor->getFeSpaces(), + true, true); + localDofMap.setComputeMatIndex(true); + } if (fetiPreconditioner == FETI_DIRICHLET) { + TEST_EXIT(meshLevel == 0) + ("Dirichlet preconditioner not yet implemented for multilevel FETI-DP\n"); + interiorDofMap.init(levelData, feSpaces, meshDistributor->getFeSpaces(), false, false); @@ -280,6 +290,8 @@ namespace AMDiS { TEST_EXIT(meshDistributor->getFeSpaces().size() > 0) ("No FE space defined in mesh distributor!\n"); + MeshLevelData& levelData = meshDistributor->getMeshLevelData(); + primalDofMap.clear(); dualDofMap.clear(); lagrangeMap.clear(); @@ -290,6 +302,14 @@ namespace AMDiS { primalDofMap.setDofComm(meshDistributor->getDofComm()); lagrangeMap.setDofComm(meshDistributor->getDofComm()); + primalDofMap.setMpiComm(levelData.getMpiComm(0), 0); + dualDofMap.setMpiComm(levelData.getMpiComm(0), 0); + lagrangeMap.setMpiComm(levelData.getMpiComm(0), 0); + localDofMap.setMpiComm(levelData.getMpiComm(meshLevel), meshLevel); + + if (meshLevel > 0) + localDofMap.setDofComm(meshDistributor->getDofCommSd()); + for (unsigned int i = 0; i < meshDistributor->getFeSpaces().size(); i++) { const FiniteElemSpace *feSpace = meshDistributor->getFeSpace(i); @@ -319,18 +339,18 @@ namespace AMDiS { MSG("FETI-DP data for %d-ith FE space:\n", i); MSG(" nRankPrimals = %d nOverallPrimals = %d\n", - primalDofMap[feSpace].nRankDofs[meshLevel], - primalDofMap[feSpace].nOverallDofs[meshLevel]); + primalDofMap[feSpace].nRankDofs, + primalDofMap[feSpace].nOverallDofs); MSG(" nRankDuals = %d nOverallDuals = %d\n", - dualDofMap[feSpace].nRankDofs[meshLevel], - dualDofMap[feSpace].nOverallDofs[meshLevel]); + dualDofMap[feSpace].nRankDofs, + dualDofMap[feSpace].nOverallDofs); MSG(" nRankLagrange = %d nOverallLagrange = %d\n", - lagrangeMap[feSpace].nRankDofs[meshLevel], - lagrangeMap[feSpace].nOverallDofs[meshLevel]); + lagrangeMap[feSpace].nRankDofs, + lagrangeMap[feSpace].nOverallDofs); - TEST_EXIT_DBG(localDofMap[feSpace].size(meshLevel) + primalDofMap[feSpace].size(meshLevel) == + TEST_EXIT_DBG(localDofMap[feSpace].size() + primalDofMap[feSpace].size() == static_cast<unsigned int>(feSpace->getAdmin()->getUsedDofs())) ("Should not happen!\n"); } @@ -363,10 +383,10 @@ namespace AMDiS { // === create local indices of the primals starting at zero. === for (DofIndexSet::iterator it = primals.begin(); it != primals.end(); ++it) - if (meshDistributor->getDofMap()[feSpace].isRankDof(*it, 0)) - primalDofMap[feSpace].insertRankDof(meshLevel, *it); + if (meshDistributor->getDofMap()[feSpace].isRankDof(*it)) + primalDofMap[feSpace].insertRankDof(*it); else - primalDofMap[feSpace].insertNonRankDof(meshLevel, *it); + primalDofMap[feSpace].insertNonRankDof(*it); } @@ -382,7 +402,7 @@ namespace AMDiS { for (DofContainer::iterator it = allBoundaryDofs.begin(); it != allBoundaryDofs.end(); ++it) if (!isPrimal(feSpace, **it)) - dualDofMap[feSpace].insertRankDof(meshLevel, **it); + dualDofMap[feSpace].insertRankDof(**it); } @@ -392,7 +412,7 @@ namespace AMDiS { boundaryDofRanks[feSpace].clear(); - if (dualDofMap[feSpace].nLocalDofs[meshLevel] == 0) + if (dualDofMap[feSpace].nLocalDofs == 0) return; // === Create for each dual node that is owned by the rank, the set === @@ -450,18 +470,18 @@ namespace AMDiS { // === appropriate number of Lagrange constraints. === int nRankLagrange = 0; - DofMap& dualMap = dualDofMap[feSpace].getMap(meshLevel); + DofMap& dualMap = dualDofMap[feSpace].getMap(); for (DofMap::iterator it = dualMap.begin(); it != dualMap.end(); ++it) { - if (meshDistributor->getDofMap()[feSpace].isRankDof(it->first, 0)) { - lagrangeMap[feSpace].insertRankDof(meshLevel, it->first, nRankLagrange); + if (meshDistributor->getDofMap()[feSpace].isRankDof(it->first)) { + lagrangeMap[feSpace].insertRankDof(it->first, nRankLagrange); int degree = boundaryDofRanks[feSpace][it->first].size(); nRankLagrange += (degree * (degree - 1)) / 2; } else { - lagrangeMap[feSpace].insertNonRankDof(meshLevel, it->first); + lagrangeMap[feSpace].insertNonRankDof(it->first); } } - lagrangeMap[feSpace].nRankDofs[meshLevel] = nRankLagrange; + lagrangeMap[feSpace].nRankDofs = nRankLagrange; } @@ -480,20 +500,34 @@ namespace AMDiS { if (admin->isDofFree(i) == false && isPrimal(feSpace, i) == false && isDual(feSpace, i) == false) { - localDofMap[feSpace].insertRankDof(meshLevel, i, nLocalInterior); - - if (fetiPreconditioner != FETI_NONE) - interiorDofMap[feSpace].insertRankDof(meshLevel, i, nLocalInterior); + if (meshLevel == 0) { + localDofMap[feSpace].insertRankDof(i, nLocalInterior); - nLocalInterior++; + if (fetiPreconditioner != FETI_NONE) + interiorDofMap[feSpace].insertRankDof(i, nLocalInterior); + + nLocalInterior++; + } else { + if (meshDistributor->getDofMapSd()[feSpace].isRankDof(i)) + localDofMap[feSpace].insertRankDof(i); + else + localDofMap[feSpace].insertNonRankDof(i); + } } } // === And finally, add the global indicies of all dual nodes. === - for (DofMap::iterator it = dualDofMap[feSpace].getMap(meshLevel).begin(); - it != dualDofMap[feSpace].getMap(meshLevel).end(); ++it) - localDofMap[feSpace].insertRankDof(meshLevel, it->first); + for (DofMap::iterator it = dualDofMap[feSpace].getMap().begin(); + it != dualDofMap[feSpace].getMap().end(); ++it) + if (meshLevel == 0) + localDofMap[feSpace].insertRankDof(it->first); + else { + if (meshDistributor->getDofMapSd()[feSpace].isRankDof(it->first)) + localDofMap[feSpace].insertRankDof(it->first); + else + localDofMap[feSpace].insertNonRankDof(it->first); + } } @@ -504,10 +538,10 @@ namespace AMDiS { // === Create distributed matrix for Lagrange constraints. === MatCreateMPIAIJ(mpiComm, - lagrangeMap.getRankDofs(meshLevel), - localDofMap.getRankDofs(meshLevel), - lagrangeMap.getOverallDofs(meshLevel), - localDofMap.getOverallDofs(meshLevel), + lagrangeMap.getRankDofs(), + localDofMap.getRankDofs(), + lagrangeMap.getOverallDofs(), + localDofMap.getOverallDofs(), 2, PETSC_NULL, 2, PETSC_NULL, &mat_lagrange); @@ -519,14 +553,14 @@ namespace AMDiS { // === constraint. === for (unsigned int k = 0; k < feSpaces.size(); k++) { - DofMap &dualMap = dualDofMap[feSpaces[k]].getMap(meshLevel); + DofMap &dualMap = dualDofMap[feSpaces[k]].getMap(); for (DofMap::iterator it = dualMap.begin(); it != dualMap.end(); ++it) { TEST_EXIT_DBG(boundaryDofRanks[feSpaces[k]].count(it->first)) ("Should not happen!\n"); // Global index of the first Lagrange constriant for this node. - int index = lagrangeMap.getMatIndex(meshLevel, k, it->first); + int index = lagrangeMap.getMatIndex(k, it->first); // Copy set of all ranks that contain this dual node. vector<int> W(boundaryDofRanks[feSpaces[k]][it->first].begin(), @@ -537,7 +571,7 @@ namespace AMDiS { for (int i = 0; i < degree; i++) { for (int j = i + 1; j < degree; j++) { if (W[i] == mpiRank || W[j] == mpiRank) { - int colIndex = localDofMap.getMatIndex(meshLevel, k, it->first); + int colIndex = localDofMap.getMatIndex(k, it->first); double value = (W[i] == mpiRank ? 1.0 : -1.0); MatSetValue(mat_lagrange, index, colIndex, value, INSERT_VALUES); } @@ -562,19 +596,19 @@ namespace AMDiS { schurPrimalData.subSolver = subDomainSolver; VecCreateMPI(mpiComm, - localDofMap.getRankDofs(meshLevel), - localDofMap.getOverallDofs(meshLevel), + localDofMap.getRankDofs(), + localDofMap.getOverallDofs(), &(schurPrimalData.tmp_vec_b)); VecCreateMPI(mpiComm, - primalDofMap.getRankDofs(meshLevel), - primalDofMap.getOverallDofs(meshLevel), + primalDofMap.getRankDofs(), + primalDofMap.getOverallDofs(), &(schurPrimalData.tmp_vec_primal)); MatCreateShell(mpiComm, - primalDofMap.getRankDofs(meshLevel), - primalDofMap.getRankDofs(meshLevel), - primalDofMap.getOverallDofs(meshLevel), - primalDofMap.getOverallDofs(meshLevel), + primalDofMap.getRankDofs(), + primalDofMap.getRankDofs(), + primalDofMap.getOverallDofs(), + primalDofMap.getOverallDofs(), &schurPrimalData, &mat_schur_primal); MatShellSetOperation(mat_schur_primal, MATOP_MULT, @@ -590,10 +624,10 @@ namespace AMDiS { double wtime = MPI::Wtime(); - int nRowsRankPrimal = primalDofMap.getRankDofs(meshLevel); - int nRowsOverallPrimal = primalDofMap.getOverallDofs(meshLevel); - int nRowsRankB = localDofMap.getRankDofs(meshLevel); - int nRowsOverallB = localDofMap.getOverallDofs(meshLevel); + int nRowsRankPrimal = primalDofMap.getRankDofs(); + int nRowsOverallPrimal = primalDofMap.getOverallDofs(); + int nRowsRankB = localDofMap.getRankDofs(); + int nRowsOverallB = localDofMap.getOverallDofs(); Mat matBPi; MatCreateMPIAIJ(mpiComm, @@ -609,7 +643,7 @@ namespace AMDiS { map<int, vector<pair<int, double> > > mat_b_primal_cols; for (int i = 0; i < nRowsRankB; i++) { - PetscInt row = localDofMap.getStartDofs(meshLevel) + i; + PetscInt row = localDofMap.getStartDofs() + i; MatGetRow(subDomainSolver->getMatIntCoarse(), row, &nCols, &cols, &values); for (int j = 0; j < nCols; j++) @@ -620,7 +654,7 @@ namespace AMDiS { } TEST_EXIT(static_cast<int>(mat_b_primal_cols.size()) == - primalDofMap.getLocalDofs(meshLevel)) + primalDofMap.getLocalDofs()) ("Should not happen!\n"); for (map<int, vector<pair<int, double> > >::iterator it = mat_b_primal_cols.begin(); @@ -641,7 +675,7 @@ namespace AMDiS { VecGetArray(tmpVec, &tmpValues); for (int i = 0; i < nRowsRankB; i++) MatSetValue(matBPi, - localDofMap.getStartDofs(meshLevel) + i, + localDofMap.getStartDofs() + i, it->first, tmpValues[i], ADD_VALUES); @@ -708,23 +742,23 @@ namespace AMDiS { fetiData.ksp_schur_primal = &ksp_schur_primal; VecCreateMPI(mpiComm, - localDofMap.getRankDofs(meshLevel), - localDofMap.getOverallDofs(meshLevel), + localDofMap.getRankDofs(), + localDofMap.getOverallDofs(), &(fetiData.tmp_vec_b)); VecCreateMPI(mpiComm, - lagrangeMap.getRankDofs(meshLevel), - lagrangeMap.getOverallDofs(meshLevel), + lagrangeMap.getRankDofs(), + lagrangeMap.getOverallDofs(), &(fetiData.tmp_vec_lagrange)); VecCreateMPI(mpiComm, - primalDofMap.getRankDofs(meshLevel), - primalDofMap.getOverallDofs(meshLevel), + primalDofMap.getRankDofs(), + primalDofMap.getOverallDofs(), &(fetiData.tmp_vec_primal)); MatCreateShell(mpiComm, - lagrangeMap.getRankDofs(meshLevel), - lagrangeMap.getRankDofs(meshLevel), - lagrangeMap.getOverallDofs(meshLevel), - lagrangeMap.getOverallDofs(meshLevel), + lagrangeMap.getRankDofs(), + lagrangeMap.getRankDofs(), + lagrangeMap.getOverallDofs(), + lagrangeMap.getOverallDofs(), &fetiData, &mat_feti); MatShellSetOperation(mat_feti, MATOP_MULT, (void(*)(void))petscMultMatFeti); @@ -765,8 +799,8 @@ namespace AMDiS { fetiDirichletPreconData.ksp_interior = &ksp_interior; VecCreateMPI(mpiComm, - localDofMap.getRankDofs(meshLevel), - localDofMap.getOverallDofs(meshLevel), + localDofMap.getRankDofs(), + localDofMap.getOverallDofs(), &(fetiDirichletPreconData.tmp_vec_b)); MatGetVecs(mat_duals_duals, PETSC_NULL, &(fetiDirichletPreconData.tmp_vec_duals0)); @@ -776,11 +810,11 @@ namespace AMDiS { &(fetiDirichletPreconData.tmp_vec_interior)); for (unsigned int i = 0; i < feSpaces.size(); i++) { - DofMap &dualMap = dualDofMap[feSpaces[i]].getMap(meshLevel); + DofMap &dualMap = dualDofMap[feSpaces[i]].getMap(); for (DofMap::iterator it = dualMap.begin(); it != dualMap.end(); ++it) { DegreeOfFreedom d = it->first; - int matIndexLocal = localDofMap.getLocalMatIndex(meshLevel, i, d); - int matIndexDual = dualDofMap.getLocalMatIndex(meshLevel, i, d); + int matIndexLocal = localDofMap.getLocalMatIndex(i, d); + int matIndexDual = dualDofMap.getLocalMatIndex(i, d); fetiDirichletPreconData.localToDualMap[matIndexLocal] = matIndexDual; } } @@ -797,18 +831,18 @@ namespace AMDiS { fetiLumpedPreconData.mat_duals_duals = &mat_duals_duals; for (unsigned int i = 0; i < feSpaces.size(); i++) { - DofMap &dualMap = dualDofMap[feSpaces[i]].getMap(meshLevel); + DofMap &dualMap = dualDofMap[feSpaces[i]].getMap(); for (DofMap::iterator it = dualMap.begin(); it != dualMap.end(); ++it) { DegreeOfFreedom d = it->first; - int matIndexLocal = localDofMap.getLocalMatIndex(meshLevel, i, d); - int matIndexDual = dualDofMap.getLocalMatIndex(meshLevel, i, d); + int matIndexLocal = localDofMap.getLocalMatIndex(i, d); + int matIndexDual = dualDofMap.getLocalMatIndex(i, d); fetiLumpedPreconData.localToDualMap[matIndexLocal] = matIndexDual; } } VecCreateMPI(mpiComm, - localDofMap.getRankDofs(meshLevel), - localDofMap.getOverallDofs(meshLevel), + localDofMap.getRankDofs(), + localDofMap.getOverallDofs(), &(fetiLumpedPreconData.tmp_vec_b)); MatGetVecs(mat_duals_duals, PETSC_NULL, &(fetiLumpedPreconData.tmp_vec_duals0)); @@ -896,20 +930,20 @@ namespace AMDiS { vector<const FiniteElemSpace*> feSpaces = getFeSpaces(&vec); vector<PetscInt> globalIsIndex, localIsIndex; - globalIsIndex.reserve(primalDofMap.getLocalDofs(meshLevel)); - localIsIndex.reserve(primalDofMap.getLocalDofs(meshLevel)); + globalIsIndex.reserve(primalDofMap.getLocalDofs()); + localIsIndex.reserve(primalDofMap.getLocalDofs()); { int cnt = 0; for (unsigned int i = 0; i < feSpaces.size(); i++) { - DofMap& dofMap = primalDofMap[feSpaces[i]].getMap(meshLevel); + DofMap& dofMap = primalDofMap[feSpaces[i]].getMap(); for (DofMap::iterator it = dofMap.begin();it != dofMap.end(); ++it) { - globalIsIndex.push_back(primalDofMap.getMatIndex(meshLevel, i, it->first)); + globalIsIndex.push_back(primalDofMap.getMatIndex(i, it->first)); localIsIndex.push_back(cnt++); } } - TEST_EXIT_DBG(cnt == primalDofMap.getLocalDofs(meshLevel)) + TEST_EXIT_DBG(cnt == primalDofMap.getLocalDofs()) ("Should not happen!\n"); } @@ -949,14 +983,14 @@ namespace AMDiS { for (int i = 0; i < vec.getSize(); i++) { DOFVector<double>& dofVec = *(vec.getDOFVector(i)); - for (DofMap::iterator it = localDofMap[feSpaces[i]].getMap(meshLevel).begin(); - it != localDofMap[feSpaces[i]].getMap(meshLevel).end(); ++it) { - int petscIndex = localDofMap.getLocalMatIndex(meshLevel, i, it->first); + for (DofMap::iterator it = localDofMap[feSpaces[i]].getMap().begin(); + it != localDofMap[feSpaces[i]].getMap().end(); ++it) { + int petscIndex = localDofMap.getLocalMatIndex(i, it->first); dofVec[it->first] = localSolB[petscIndex]; } - for (DofMap::iterator it = primalDofMap[feSpaces[i]].getMap(meshLevel).begin(); - it != primalDofMap[feSpaces[i]].getMap(meshLevel).end(); ++it) + for (DofMap::iterator it = primalDofMap[feSpaces[i]].getMap().begin(); + it != primalDofMap[feSpaces[i]].getMap().end(); ++it) dofVec[it->first] = localSolPrimal[cnt++]; } @@ -986,14 +1020,14 @@ namespace AMDiS { // === Create matrices for FETI-DP preconditioner. === if (fetiPreconditioner != FETI_NONE) { - int nRowsDual = dualDofMap.getRankDofs(meshLevel); + int nRowsDual = dualDofMap.getRankDofs(); MatCreateSeqAIJ(PETSC_COMM_SELF, nRowsDual, nRowsDual, 60, PETSC_NULL, &mat_duals_duals); if (fetiPreconditioner == FETI_DIRICHLET) { - int nRowsInterior = interiorDofMap.getRankDofs(meshLevel); + int nRowsInterior = interiorDofMap.getRankDofs(); MatCreateSeqAIJ(PETSC_COMM_SELF, nRowsInterior, nRowsInterior, 60, PETSC_NULL, @@ -1058,21 +1092,21 @@ namespace AMDiS { if (!rowPrimal && !colPrimal) { if (!isDual(feSpaces[i], *cursor)) { if (!isDual(feSpaces[j], col(*icursor))) { - int colIndex = interiorDofMap.getLocalMatIndex(meshLevel, j, col(*icursor)); + int colIndex = interiorDofMap.getLocalMatIndex(j, col(*icursor)); colsLocal.push_back(colIndex); valuesLocal.push_back(value(*icursor)); } else { - int colIndex = dualDofMap.getLocalMatIndex(meshLevel, j, col(*icursor)); + int colIndex = dualDofMap.getLocalMatIndex(j, col(*icursor)); colsLocalOther.push_back(colIndex); valuesLocalOther.push_back(value(*icursor)); } } else { if (!isDual(feSpaces[j], col(*icursor))) { - int colIndex = interiorDofMap.getLocalMatIndex(meshLevel, j, col(*icursor)); + int colIndex = interiorDofMap.getLocalMatIndex(j, col(*icursor)); colsLocalOther.push_back(colIndex); valuesLocalOther.push_back(value(*icursor)); } else { - int colIndex = dualDofMap.getLocalMatIndex(meshLevel, j, col(*icursor)); + int colIndex = dualDofMap.getLocalMatIndex(j, col(*icursor)); colsLocal.push_back(colIndex); valuesLocal.push_back(value(*icursor)); } @@ -1087,14 +1121,14 @@ namespace AMDiS { switch (fetiPreconditioner) { case FETI_DIRICHLET: if (!isDual(feSpaces[i], *cursor)) { - int rowIndex = interiorDofMap.getLocalMatIndex(meshLevel, i, *cursor); + int rowIndex = interiorDofMap.getLocalMatIndex(i, *cursor); MatSetValues(mat_interior_interior, 1, &rowIndex, colsLocal.size(), &(colsLocal[0]), &(valuesLocal[0]), INSERT_VALUES); if (colsLocalOther.size()) MatSetValues(mat_interior_duals, 1, &rowIndex, colsLocalOther.size(), &(colsLocalOther[0]), &(valuesLocalOther[0]), INSERT_VALUES); } else { - int rowIndex = dualDofMap.getLocalMatIndex(meshLevel, i, *cursor); + int rowIndex = dualDofMap.getLocalMatIndex(i, *cursor); MatSetValues(mat_duals_duals, 1, &rowIndex, colsLocal.size(), &(colsLocal[0]), &(valuesLocal[0]), INSERT_VALUES); if (colsLocalOther.size()) @@ -1105,7 +1139,7 @@ namespace AMDiS { case FETI_LUMPED: if (isDual(feSpaces[i], *cursor)) { - int rowIndex = dualDofMap.getLocalMatIndex(meshLevel, i, *cursor); + int rowIndex = dualDofMap.getLocalMatIndex(i, *cursor); MatSetValues(mat_duals_duals, 1, &rowIndex, colsLocal.size(), &(colsLocal[0]), &(valuesLocal[0]), INSERT_VALUES); } @@ -1182,17 +1216,17 @@ namespace AMDiS { Vec tmp_b0, tmp_b1, tmp_lagrange0, tmp_primal0, tmp_primal1; VecCreateMPI(mpiComm, - localDofMap.getRankDofs(meshLevel), - localDofMap.getOverallDofs(meshLevel), &tmp_b0); + localDofMap.getRankDofs(), + localDofMap.getOverallDofs(), &tmp_b0); VecCreateMPI(mpiComm, - localDofMap.getRankDofs(meshLevel), - localDofMap.getOverallDofs(meshLevel), &tmp_b1); + localDofMap.getRankDofs(), + localDofMap.getOverallDofs(), &tmp_b1); VecCreateMPI(mpiComm, - primalDofMap.getRankDofs(meshLevel), - primalDofMap.getOverallDofs(meshLevel), &tmp_primal0); + primalDofMap.getRankDofs(), + primalDofMap.getOverallDofs(), &tmp_primal0); VecCreateMPI(mpiComm, - primalDofMap.getRankDofs(meshLevel), - primalDofMap.getOverallDofs(meshLevel), &tmp_primal1); + primalDofMap.getRankDofs(), + primalDofMap.getOverallDofs(), &tmp_primal1); MatGetVecs(mat_lagrange, PETSC_NULL, &tmp_lagrange0); MatGetVecs(mat_lagrange, PETSC_NULL, &vec_rhs); diff --git a/AMDiS/src/parallel/PetscSolverFeti.h b/AMDiS/src/parallel/PetscSolverFeti.h index a33ac6f9a5f65052569ff3f742e14203f812db04..e980e553c9f9b28c46ea8778d57ac1f9f296f4ca 100644 --- a/AMDiS/src/parallel/PetscSolverFeti.h +++ b/AMDiS/src/parallel/PetscSolverFeti.h @@ -80,22 +80,22 @@ namespace AMDiS { int getNumberOfPrimals() { - return primalDofMap.getOverallDofs(meshLevel); + return primalDofMap.getOverallDofs(); } int getNumberOfRankPrimals() { - return primalDofMap.getRankDofs(meshLevel); + return primalDofMap.getRankDofs(); } int getNumberOfDuals() { - return dualDofMap.getOverallDofs(meshLevel); + return dualDofMap.getOverallDofs(); } int getNumberOfRankDuals() { - return dualDofMap.getRankDofs(meshLevel); + return dualDofMap.getRankDofs(); } protected: @@ -174,14 +174,14 @@ namespace AMDiS { inline bool isPrimal(const FiniteElemSpace *feSpace, DegreeOfFreedom dof) { - return primalDofMap[feSpace].isSet(dof, meshLevel); + return primalDofMap[feSpace].isSet(dof); } /// Checks whether a given DOF in a give FE space is a dual DOF. inline bool isDual(const FiniteElemSpace *feSpace, DegreeOfFreedom dof) { - return dualDofMap[feSpace].isSet(dof, meshLevel); + return dualDofMap[feSpace].isSet(dof); } protected: diff --git a/AMDiS/src/parallel/PetscSolverGlobalBlockMatrix.cc b/AMDiS/src/parallel/PetscSolverGlobalBlockMatrix.cc index 5a74eaae43d972d2f5cc4d9d1a1f58ac13c46618..70a1b89da3e59b5eafe4a51ddc1b5e7fc8485aa6 100644 --- a/AMDiS/src/parallel/PetscSolverGlobalBlockMatrix.cc +++ b/AMDiS/src/parallel/PetscSolverGlobalBlockMatrix.cc @@ -27,8 +27,8 @@ namespace AMDiS { double wtime = MPI::Wtime(); const FiniteElemSpace *feSpace = meshDistributor->getFeSpace(0); nComponents = mat->getNumRows(); - int nRankRows = (*dofMap)[feSpace].nRankDofs[0]; - int nOverallRows = (*dofMap)[feSpace].nOverallDofs[0]; + int nRankRows = (*dofMap)[feSpace].nRankDofs; + int nOverallRows = (*dofMap)[feSpace].nOverallDofs; #if (DEBUG != 0) MSG("Fill petsc matrix 1 needed %.5f seconds\n", MPI::Wtime() - wtime); @@ -108,8 +108,8 @@ namespace AMDiS { nComponents = vec->getSize(); const FiniteElemSpace *feSpace = meshDistributor->getFeSpace(0); - int nRankRows = (*dofMap)[feSpace].nRankDofs[0]; - int nOverallRows = (*dofMap)[feSpace].nOverallDofs[0]; + int nRankRows = (*dofMap)[feSpace].nRankDofs; + int nOverallRows = (*dofMap)[feSpace].nOverallDofs; nestVec.resize(nComponents); @@ -151,11 +151,11 @@ namespace AMDiS { Vec tmp; VecNestGetSubVec(petscSolVec, i, &tmp); - int nRankDofs = (*dofMap)[feSpace].nRankDofs[0]; + int nRankDofs = (*dofMap)[feSpace].nRankDofs; PetscScalar *vecPointer; VecGetArray(tmp, &vecPointer); - DofMap& d = (*dofMap)[feSpace].getMap(0); + DofMap& d = (*dofMap)[feSpace].getMap(); for (DofMap::iterator it = d.begin(); it != d.end(); ++it) if (it->second.local != -1) dofvec[it->first] = vecPointer[it->second.local]; @@ -217,8 +217,8 @@ namespace AMDiS { typedef traits::range_generator<row, Matrix>::type cursor_type; typedef traits::range_generator<nz, cursor_type>::type icursor_type; - int dispRowIndex = (*dofMap)[feSpace].nRankDofs[0] * dispRowBlock; - int dispColIndex = (*dofMap)[feSpace].nRankDofs[0] * dispColBlock; + int dispRowIndex = (*dofMap)[feSpace].nRankDofs * dispRowBlock; + int dispColIndex = (*dofMap)[feSpace].nRankDofs * dispColBlock; vector<int> cols; vector<double> values; @@ -232,7 +232,7 @@ namespace AMDiS { cend = end<row>(mat->getBaseMatrix()); cursor != cend; ++cursor) { // Global index of the current row DOF. - int rowIndex = (*dofMap)[feSpace][0][*cursor].global + dispRowIndex; + int rowIndex = (*dofMap)[feSpace][*cursor].global + dispRowIndex; cols.clear(); values.clear(); @@ -240,7 +240,7 @@ namespace AMDiS { for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor) { // Global index of the current column index. - int colIndex = (*dofMap)[feSpace][0][col(*icursor)].global + dispColIndex; + int colIndex = (*dofMap)[feSpace][col(*icursor)].global + dispColIndex; // Ignore all zero entries, expect it is a diagonal entry. if (value(*icursor) == 0.0 && rowIndex != colIndex) @@ -267,7 +267,7 @@ namespace AMDiS { // Traverse all used DOFs in the dof vector. DOFVector<double>::Iterator dofIt(vec, USED_DOFS); for (dofIt.reset(); !dofIt.end(); ++dofIt) { - int index = (*dofMap)[feSpace][0][dofIt.getDOFIndex()].global; + int index = (*dofMap)[feSpace][dofIt.getDOFIndex()].global; double value = *dofIt; VecSetValues(petscVec, 1, &index, &value, ADD_VALUES); diff --git a/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc b/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc index 7dfd12283c0a43fff8ff930a73eadf967237ce3d..0c978e55f30dd372a7642c9b5891bb35e5642b75 100644 --- a/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc +++ b/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc @@ -55,8 +55,8 @@ namespace AMDiS { // === Create PETSc vector (solution and a temporary vector). === - int nRankRows = dofMap->getRankDofs(0); - int nOverallRows = dofMap->getOverallDofs(0); + int nRankRows = dofMap->getRankDofs(); + int nOverallRows = dofMap->getOverallDofs(); VecCreateMPI(mpiComm, nRankRows, nOverallRows, &petscSolVec); VecCreateMPI(mpiComm, nRankRows, nOverallRows, &petscTmpVec); @@ -87,8 +87,8 @@ namespace AMDiS { #if (DEBUG != 0) int a, b; MatGetOwnershipRange(petscMatrix, &a, &b); - TEST_EXIT(a == dofMap->getStartDofs(0))("Wrong matrix ownership range!\n"); - TEST_EXIT(b == dofMap->getStartDofs(0) + nRankRows) + TEST_EXIT(a == dofMap->getStartDofs())("Wrong matrix ownership range!\n"); + TEST_EXIT(b == dofMap->getStartDofs() + nRankRows) ("Wrong matrix ownership range!\n"); #endif @@ -133,8 +133,8 @@ namespace AMDiS { TEST_EXIT_DBG(vec)("No DOF vector defined!\n"); TEST_EXIT_DBG(dofMap)("No parallel DOF map defined!\n"); - int nRankRows = dofMap->getRankDofs(0); - int nOverallRows = dofMap->getOverallDofs(0); + int nRankRows = dofMap->getRankDofs(); + int nOverallRows = dofMap->getOverallDofs(); VecCreateMPI(mpiComm, nRankRows, nOverallRows, &petscRhsVec); @@ -193,7 +193,7 @@ namespace AMDiS { int c = 0; for (int i = 0; i < nComponents; i++) { DOFVector<double> &dv = *(vec.getDOFVector(i)); - DofMap& d = (*dofMap)[dv.getFeSpace()].getMap(0); + DofMap& d = (*dofMap)[dv.getFeSpace()].getMap(); for (DofMap::iterator it = d.begin(); it != d.end(); ++it) if (it->second.local != -1) dv[it->first] = vecPointer[c++]; @@ -268,7 +268,7 @@ namespace AMDiS { const FiniteElemSpace *colFe = mat->getColFeSpace(); // Global index of the current row DOF. - int globalRowDof = (*dofMap)[rowFe][0][*cursor].global; + int globalRowDof = (*dofMap)[rowFe][*cursor].global; // Test if the current row DOF is a periodic DOF. bool periodicRow = perMap.isPeriodic(rowFe, globalRowDof); @@ -277,7 +277,7 @@ namespace AMDiS { // === Row DOF index is not periodic. === // Get PETSc's mat row index. - int rowIndex = dofMap->getMatIndex(0, nRowMat, globalRowDof); + int rowIndex = dofMap->getMatIndex(nRowMat, globalRowDof); cols.clear(); values.clear(); @@ -286,11 +286,11 @@ namespace AMDiS { icursor != icend; ++icursor) { // Global index of the current column index. - int globalColDof = (*dofMap)[colFe][0][col(*icursor)].global; + int globalColDof = (*dofMap)[colFe][col(*icursor)].global; // Test if the current col dof is a periodic dof. bool periodicCol = perMap.isPeriodic(colFe, globalColDof); // Get PETSc's mat col index. - int colIndex = dofMap->getMatIndex(0, nColMat, globalColDof); + int colIndex = dofMap->getMatIndex(nColMat, globalColDof); // Ignore all zero entries, expect it is a diagonal entry. if (value(*icursor) == 0.0 && rowIndex != colIndex) @@ -339,7 +339,7 @@ namespace AMDiS { } for (unsigned int i = 0; i < newCols.size(); i++) { - cols.push_back(dofMap->getMatIndex(0, nColMat, newCols[i])); + cols.push_back(dofMap->getMatIndex(nColMat, newCols[i])); values.push_back(scaledValue); } } @@ -361,7 +361,7 @@ namespace AMDiS { for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor) { // Global index of the current column index. - int globalColDof = (*dofMap)[colFe][0][col(*icursor)].global; + int globalColDof = (*dofMap)[colFe][col(*icursor)].global; // Ignore all zero entries, expect it is a diagonal entry. if (value(*icursor) == 0.0 && globalRowDof != globalColDof) @@ -426,8 +426,8 @@ namespace AMDiS { // === Translate the matrix entries to PETSc's matrix. for (unsigned int i = 0; i < entry.size(); i++) { - int rowIdx = dofMap->getMatIndex(0, nRowMat, entry[i].first); - int colIdx = dofMap->getMatIndex(0, nColMat, entry[i].second); + int rowIdx = dofMap->getMatIndex(nRowMat, entry[i].first); + int colIdx = dofMap->getMatIndex(nColMat, entry[i].second); colsMap[rowIdx].push_back(colIdx); valsMap[rowIdx].push_back(scaledValue); @@ -465,14 +465,14 @@ namespace AMDiS { // Traverse all used DOFs in the dof vector. DOFVector<double>::Iterator dofIt(vec, USED_DOFS); for (dofIt.reset(); !dofIt.end(); ++dofIt) { - if (rankOnly && !(*dofMap)[feSpace].isRankDof(dofIt.getDOFIndex(), 0)) + if (rankOnly && !(*dofMap)[feSpace].isRankDof(dofIt.getDOFIndex())) continue; // Calculate global row index of the DOF. DegreeOfFreedom globalRowDof = - (*dofMap)[feSpace][0][dofIt.getDOFIndex()].global; + (*dofMap)[feSpace][dofIt.getDOFIndex()].global; // Get PETSc's mat index of the row DOF. - int index = dofMap->getMatIndex(0, nRowVec, globalRowDof); + int index = dofMap->getMatIndex(nRowVec, globalRowDof); if (perMap.isPeriodic(feSpace, globalRowDof)) { std::set<int>& perAsc = perMap.getAssociations(feSpace, globalRowDof); @@ -482,7 +482,7 @@ namespace AMDiS { for (std::set<int>::iterator perIt = perAsc.begin(); perIt != perAsc.end(); ++perIt) { int mappedDof = perMap.map(feSpace, *perIt, globalRowDof); - int mappedIndex = dofMap->getMatIndex(0, nRowVec, mappedDof); + int mappedIndex = dofMap->getMatIndex(nRowVec, mappedDof); VecSetValues(petscVec, 1, &mappedIndex, &value, ADD_VALUES); } } else { @@ -502,8 +502,8 @@ namespace AMDiS { TEST_EXIT_DBG(!o_nnz)("There is something wrong!\n"); vector<const FiniteElemSpace*> feSpaces = getFeSpaces(mat); - int nRankRows = dofMap->getRankDofs(0); - int rankStartIndex = dofMap->getStartDofs(0); + int nRankRows = dofMap->getRankDofs(); + int rankStartIndex = dofMap->getStartDofs(); d_nnz = new int[nRankRows]; o_nnz = new int[nRankRows]; @@ -572,11 +572,11 @@ namespace AMDiS { for (cursor_type cursor = begin<row>(bmat), cend = end<row>(bmat); cursor != cend; ++cursor) { - int globalRowDof = (*dofMap)[feSpaces[i]][0][*cursor].global; + int globalRowDof = (*dofMap)[feSpaces[i]][*cursor].global; // The corresponding global matrix row index of the current row DOF. - int petscRowIdx = dofMap->getMatIndex(0, i, globalRowDof); - if ((*dofMap)[feSpaces[i]].isRankDof(*cursor, 0)) { + int petscRowIdx = dofMap->getMatIndex(i, globalRowDof); + if ((*dofMap)[feSpaces[i]].isRankDof(*cursor)) { // === The current row DOF is a rank DOF, so create the === // === corresponding nnz values directly on rank's nnz data. === @@ -587,7 +587,7 @@ namespace AMDiS { TEST_EXIT_DBG(localPetscRowIdx >= 0 && localPetscRowIdx < nRankRows) ("Should not happen! \n Debug info: localRowIdx = %d globalRowIndx = %d petscRowIdx = %d localPetscRowIdx = %d rStart = %d nCompontens = %d nRankRows = %d\n", *cursor, - (*dofMap)[feSpaces[i]][0][*cursor].global, + (*dofMap)[feSpaces[i]][*cursor].global, petscRowIdx, localPetscRowIdx, rankStartIndex, @@ -598,8 +598,8 @@ namespace AMDiS { // Traverse all non zero entries in this row. for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor) { - int globalColDof = (*dofMap)[feSpaces[j]][0][col(*icursor)].global; - int petscColIdx = dofMap->getMatIndex(0, j, globalColDof); + int globalColDof = (*dofMap)[feSpaces[j]][col(*icursor)].global; + int petscColIdx = dofMap->getMatIndex(j, globalColDof); if (value(*icursor) != 0.0 || petscRowIdx == petscColIdx) { // The row DOF is a rank DOF, if also the column is a rank DOF, @@ -626,8 +626,8 @@ namespace AMDiS { icend = end<nz>(cursor); icursor != icend; ++icursor) { if (value(*icursor) != 0.0) { int globalColDof = - (*dofMap)[feSpaces[j]][0][col(*icursor)].global; - int petscColIdx = dofMap->getMatIndex(0, j, globalColDof); + (*dofMap)[feSpaces[j]][col(*icursor)].global; + int petscColIdx = dofMap->getMatIndex(j, globalColDof); sendMatrixEntry[sendToRank]. push_back(make_pair(petscRowIdx, petscColIdx)); diff --git a/AMDiS/src/parallel/PetscSolverSchur.cc b/AMDiS/src/parallel/PetscSolverSchur.cc index cbf962b8c213283ec44e64e1a54506ad51d6e393..ecccc62ad78c5e27f14b7588e342f9f7734641dc 100644 --- a/AMDiS/src/parallel/PetscSolverSchur.cc +++ b/AMDiS/src/parallel/PetscSolverSchur.cc @@ -35,7 +35,7 @@ namespace AMDiS { !it.end(); it.nextRank()) for (; !it.endDofIter(); it.nextDof()) { boundaryLocalDofs.insert(it.getDofIndex()); - boundaryDofs.insert((*dofMap)[feSpace][0][it.getDofIndex()].global); + boundaryDofs.insert((*dofMap)[feSpace][it.getDofIndex()].global); } @@ -72,14 +72,14 @@ namespace AMDiS { int counter = rStartEdgeDofs; for (DofContainerSet::iterator it = edgeDofs.begin(); it != edgeDofs.end(); ++it) - mapGlobalBoundaryDof[(*dofMap)[feSpace][0][**it].global] = + mapGlobalBoundaryDof[(*dofMap)[feSpace][**it].global] = counter++; } { int counter = nOverallEdgeDofs + rStartVertexDofs; for (DofContainerSet::iterator it = vertexDofs.begin(); it != vertexDofs.end(); ++it) - mapGlobalBoundaryDof[(*dofMap)[feSpace][0][**it].global] = + mapGlobalBoundaryDof[(*dofMap)[feSpace][**it].global] = counter++; } #else @@ -135,7 +135,7 @@ namespace AMDiS { stdMpi.getSendData(it.getRank()).reserve(it.getDofs().size()); for (; !it.endDofIter(); it.nextDof()) { - int globalSendDof = (*dofMap)[feSpace][0][it.getDofIndex()].global; + int globalSendDof = (*dofMap)[feSpace][it.getDofIndex()].global; TEST_EXIT_DBG(mapGlobalBoundaryDof.count(globalSendDof)) ("No mapping for boundary DOF %d!\n", globalSendDof); @@ -155,7 +155,7 @@ namespace AMDiS { for (DofComm::Iterator it(meshDistributor->getDofComm().getRecvDofs(), feSpace); !it.end(); it.nextRank()) for (; !it.endDofIter(); it.nextDof()) { - int globalRecvDof = (*dofMap)[feSpace][0][it.getDofIndex()].global; + int globalRecvDof = (*dofMap)[feSpace][it.getDofIndex()].global; mapGlobalBoundaryDof[globalRecvDof] = stdMpi.getRecvData(it.getRank())[it.getDofCounter()]; boundaryDofs.insert(globalRecvDof); @@ -244,8 +244,8 @@ namespace AMDiS { MatAssemblyEnd(petscMatrix, MAT_FINAL_ASSEMBLY); - int nRankRows = (*dofMap)[feSpace].nRankDofs[0] * nComponents; - int nOverallRows = (*dofMap)[feSpace].nOverallDofs[0] * nComponents; + int nRankRows = (*dofMap)[feSpace].nRankDofs * nComponents; + int nOverallRows = (*dofMap)[feSpace].nOverallDofs * nComponents; VecCreateMPI(mpiComm, nRankRows, nOverallRows, &petscSolVec); VecCreateMPI(mpiComm, nRankRows, nOverallRows, &petscTmpVec); @@ -258,8 +258,8 @@ namespace AMDiS { const FiniteElemSpace *feSpace = meshDistributor->getFeSpace(0); int nComponents = vec->getSize(); - int nRankRows = (*dofMap)[feSpace].nRankDofs[0] * nComponents; - int nOverallRows = (*dofMap)[feSpace].nOverallDofs[0] * nComponents; + int nRankRows = (*dofMap)[feSpace].nRankDofs * nComponents; + int nOverallRows = (*dofMap)[feSpace].nOverallDofs * nComponents; VecCreateMPI(mpiComm, nRankRows, nOverallRows, &petscRhsVec); @@ -302,7 +302,7 @@ namespace AMDiS { for (int i = 0; i < nComponents; i++) { DOFVector<double>::Iterator dofIt(vec.getDOFVector(i), USED_DOFS); for (dofIt.reset(); !dofIt.end(); ++dofIt) { - DegreeOfFreedom globalRowDof = (*dofMap)[feSpace][0][dofIt.getDOFIndex()].global; + DegreeOfFreedom globalRowDof = (*dofMap)[feSpace][dofIt.getDOFIndex()].global; if (boundaryDofs.count(globalRowDof)) { int index = (mapGlobalBoundaryDof[globalRowDof] - rStartBoundaryDofs + nInteriorDofs) * (i + 1); @@ -373,7 +373,7 @@ namespace AMDiS { cend = end<row>(mat->getBaseMatrix()); cursor != cend; ++cursor) { // Global index of the current row DOF. - int globalRowDof = (*dofMap)[feSpace][0][*cursor].global; + int globalRowDof = (*dofMap)[feSpace][*cursor].global; colsBoundary.clear(); colsInterior.clear(); @@ -382,7 +382,7 @@ namespace AMDiS { for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor) { - int globalColDof = (*dofMap)[feSpace][0][col(*icursor)].global; + int globalColDof = (*dofMap)[feSpace][col(*icursor)].global; if (boundaryDofs.count(globalColDof)) { TEST_EXIT_DBG(mapGlobalBoundaryDof.count(globalColDof)) @@ -441,12 +441,12 @@ namespace AMDiS { DOFVector<double>::Iterator dofIt(vec, USED_DOFS); for (dofIt.reset(); !dofIt.end(); ++dofIt) { - if (rankOnly && !(*dofMap)[feSpace].isRankDof(dofIt.getDOFIndex(), 0)) + if (rankOnly && !(*dofMap)[feSpace].isRankDof(dofIt.getDOFIndex())) continue; // Calculate global row index of the DOF. DegreeOfFreedom globalRowDof = - (*dofMap)[feSpace][0][dofIt.getDOFIndex()].global; + (*dofMap)[feSpace][dofIt.getDOFIndex()].global; double value = *dofIt; if (boundaryDofs.count(globalRowDof)) { diff --git a/AMDiS/src/parallel/SubDomainSolver.cc b/AMDiS/src/parallel/SubDomainSolver.cc index 366ccb4ba0163e19c34550d2e3ef711d86106716..5a08a47708cb7681683b54f1eb1696b690bfdf93 100644 --- a/AMDiS/src/parallel/SubDomainSolver.cc +++ b/AMDiS/src/parallel/SubDomainSolver.cc @@ -24,10 +24,10 @@ namespace AMDiS { vector<const FiniteElemSpace*> feSpaces = getFeSpaces(mat); - int nRowsRankInterior = interiorMap->getRankDofs(level); - int nRowsOverallInterior = interiorMap->getOverallDofs(level); - int nRowsRankCoarse = coarseSpaceMap->getRankDofs(level); - int nRowsOverallCoarse = coarseSpaceMap->getOverallDofs(level); + int nRowsRankInterior = interiorMap->getRankDofs(); + int nRowsOverallInterior = interiorMap->getOverallDofs(); + int nRowsRankCoarse = coarseSpaceMap->getRankDofs(); + int nRowsOverallCoarse = coarseSpaceMap->getOverallDofs(); MSG("FILL MATRIX IN MPI COMM WITH SIZES %d %d\n", mpiCommInterior.Get_size(), @@ -126,33 +126,33 @@ namespace AMDiS { // === Set matrix values. === if (rowPrimal) { - int rowIndex = coarseSpaceMap->getMatIndex(level, i, *cursor); + int rowIndex = coarseSpaceMap->getMatIndex(i, *cursor); for (unsigned int k = 0; k < cols.size(); k++) - cols[k] = coarseSpaceMap->getMatIndex(level, j, cols[k]); + cols[k] = coarseSpaceMap->getMatIndex(j, cols[k]); MatSetValues(matCoarseCoarse, 1, &rowIndex, cols.size(), &(cols[0]), &(values[0]), ADD_VALUES); if (colsOther.size()) { for (unsigned int k = 0; k < colsOther.size(); k++) - colsOther[k] = interiorMap->getMatIndex(level, j, colsOther[k]); + colsOther[k] = interiorMap->getMatIndex(j, colsOther[k]); MatSetValues(matCoarseInt, 1, &rowIndex, colsOther.size(), &(colsOther[0]), &(valuesOther[0]), ADD_VALUES); } } else { - int localRowIndex = interiorMap->getLocalMatIndex(level, i, *cursor); + int localRowIndex = interiorMap->getLocalMatIndex(i, *cursor); for (unsigned int k = 0; k < cols.size(); k++) - cols[k] = interiorMap->getLocalMatIndex(level, j, cols[k]); + cols[k] = interiorMap->getLocalMatIndex(j, cols[k]); MatSetValues(matIntInt, 1, &localRowIndex, cols.size(), &(cols[0]), &(values[0]), ADD_VALUES); if (colsOther.size()) { - int globalRowIndex = interiorMap->getMatIndex(level, i, *cursor); + int globalRowIndex = interiorMap->getMatIndex(i, *cursor); for (unsigned int k = 0; k < colsOther.size(); k++) - colsOther[k] = coarseSpaceMap->getMatIndex(level, j, colsOther[k]); + colsOther[k] = coarseSpaceMap->getMatIndex(j, colsOther[k]); MatSetValues(matIntCoarse, 1, &globalRowIndex, colsOther.size(), &(colsOther[0]), &(valuesOther[0]), ADD_VALUES); @@ -196,13 +196,13 @@ namespace AMDiS { FUNCNAME("SubDomainSolver::fillPetscRhs()"); VecCreateMPI(mpiCommCoarseSpace, - coarseSpaceMap->getRankDofs(level), - coarseSpaceMap->getOverallDofs(level), + coarseSpaceMap->getRankDofs(), + coarseSpaceMap->getOverallDofs(), &rhsCoarseSpace); VecCreateMPI(mpiCommCoarseSpace, - interiorMap->getRankDofs(level), - interiorMap->getOverallDofs(level), + interiorMap->getRankDofs(), + interiorMap->getOverallDofs(), &rhsInterior); for (int i = 0; i < vec->getSize(); i++) { @@ -211,10 +211,10 @@ namespace AMDiS { for (dofIt.reset(); !dofIt.end(); ++dofIt) { int index = dofIt.getDOFIndex(); if (isCoarseSpace(feSpace, index)) { - index = coarseSpaceMap->getMatIndex(level, i, index); + index = coarseSpaceMap->getMatIndex(i, index); VecSetValue(rhsCoarseSpace, index, *dofIt, ADD_VALUES); } else { - index = interiorMap->getMatIndex(level, i, index); + index = interiorMap->getMatIndex(i, index); VecSetValue(rhsInterior, index, *dofIt, INSERT_VALUES); } } @@ -273,13 +273,13 @@ namespace AMDiS { ERROR_EXIT("BLUB!\n"); Vec tmp; - VecCreateSeq(PETSC_COMM_SELF, interiorMap->getRankDofs(level), &tmp); + VecCreateSeq(PETSC_COMM_SELF, interiorMap->getRankDofs(), &tmp); PetscScalar *tmpValues, *rhsValues; VecGetArray(tmp, &tmpValues); VecGetArray(rhs, &rhsValues); - for (int i = 0; i < interiorMap->getRankDofs(level); i++) + for (int i = 0; i < interiorMap->getRankDofs(); i++) tmpValues[i] = rhsValues[i]; VecRestoreArray(rhs, &rhsValues); @@ -290,7 +290,7 @@ namespace AMDiS { VecGetArray(tmp, &tmpValues); VecGetArray(sol, &rhsValues); - for (int i = 0; i < interiorMap->getRankDofs(level); i++) + for (int i = 0; i < interiorMap->getRankDofs(); i++) rhsValues[i] = tmpValues[i]; VecRestoreArray(sol, &rhsValues); diff --git a/AMDiS/src/parallel/SubDomainSolver.h b/AMDiS/src/parallel/SubDomainSolver.h index 3e9eb8258ff7a10b8d01a381484e74f7c356307b..23855daa81eceb279454d417061927186c074162 100644 --- a/AMDiS/src/parallel/SubDomainSolver.h +++ b/AMDiS/src/parallel/SubDomainSolver.h @@ -76,7 +76,7 @@ namespace AMDiS { inline bool isCoarseSpace(const FiniteElemSpace *feSpace, DegreeOfFreedom dof) { - return (*coarseSpaceMap)[feSpace].isSet(dof, level); + return (*coarseSpaceMap)[feSpace].isSet(dof); } inline Vec& getRhsCoarseSpace() diff --git a/test/mpi/src/test0002.cc b/test/mpi/src/test0002.cc index a2f54a1fa0ef06d0ca8219b46687b3193a6f1a00..d62eb88563348bd1aeab11242914f40f38092aef 100644 --- a/test/mpi/src/test0002.cc +++ b/test/mpi/src/test0002.cc @@ -48,9 +48,9 @@ BOOST_AUTO_TEST_CASE(amdis_mpi_feti) vector<double> testData; testData.push_back(feti.getNumberOfRankPrimals()); testData.push_back(feti.getNumberOfRankDuals()); - testData.push_back(dofMap[feSpace].nRankDofs[0]); - testData.push_back(dofMap[feSpace].rStartDofs[0]); - testData.push_back(dofMap[feSpace].nOverallDofs[0]); + testData.push_back(dofMap[feSpace].nRankDofs); + testData.push_back(dofMap[feSpace].rStartDofs); + testData.push_back(dofMap[feSpace].nOverallDofs); BOOST_REQUIRE(data.size() - 1 == testData.size()); for (int i = 0; i < 5; i++) { @@ -70,9 +70,9 @@ BOOST_AUTO_TEST_CASE(amdis_mpi_feti) testData.clear(); testData.push_back(feti.getNumberOfRankPrimals()); testData.push_back(feti.getNumberOfRankDuals()); - testData.push_back(dofMap[feSpace].nRankDofs[0]); - testData.push_back(dofMap[feSpace].rStartDofs[0]); - testData.push_back(dofMap[feSpace].nOverallDofs[0]); + testData.push_back(dofMap[feSpace].nRankDofs); + testData.push_back(dofMap[feSpace].rStartDofs); + testData.push_back(dofMap[feSpace].nOverallDofs); BOOST_REQUIRE(data.size() - 1 == testData.size()); for (int i = 0; i < 5; i++) {