diff --git a/AMDiS/src/ParallelDomainProblem.cc b/AMDiS/src/ParallelDomainProblem.cc index 06c5ac3d0cd104fba428d70a50d19c6058913ac4..cdc6259268d6354799c55f830da938a387d13dd1 100644 --- a/AMDiS/src/ParallelDomainProblem.cc +++ b/AMDiS/src/ParallelDomainProblem.cc @@ -24,7 +24,7 @@ namespace AMDiS { PetscErrorCode myKSPMonitor(KSP ksp, PetscInt iter, PetscReal rnorm, void *) { - if (iter % 1 == 0 && MPI::COMM_WORLD.Get_rank() == 0) + if (iter % 100 == 0 && MPI::COMM_WORLD.Get_rank() == 0) std::cout << " Iteration " << iter << ": " << rnorm << std::endl; return 0; @@ -108,7 +108,6 @@ namespace AMDiS { updateDofAdmins(); - // === Global refinements. === int globalRefinement = 0; @@ -579,15 +578,15 @@ namespace AMDiS { // === Create for all rank owned dofs a new global indexing. === - // Stores for all rank owned dofs a new global index. - DofIndexMap rankOwnedDofsNewGlobalIndex; + // Stores for dofs in rank a new global index. + DofIndexMap rankDofsNewGlobalIndex; // Stores for all rank owned dofs a continues local index. DofIndexMap rankOwnedDofsNewLocalIndex; i = 0; for (DofContainer::iterator dofIt = rankDOFs.begin(); dofIt != rankDOFs.end(); ++dofIt) { - rankOwnedDofsNewGlobalIndex[*dofIt] = i + rstart; + rankDofsNewGlobalIndex[*dofIt] = i + rstart; rankOwnedDofsNewLocalIndex[*dofIt] = i; i++; } @@ -615,10 +614,10 @@ namespace AMDiS { itRanks != partitionDOFs[it->first].end(); ++itRanks) { if (*itRanks != mpiRank) { - TEST_EXIT_DBG(rankOwnedDofsNewGlobalIndex.count(it->first) == 1) + TEST_EXIT_DBG(rankDofsNewGlobalIndex.count(it->first) == 1) ("DOF Key not found!\n"); - sendNewDofs[*itRanks][it->first] = rankOwnedDofsNewGlobalIndex[it->first]; + sendNewDofs[*itRanks][it->first] = rankDofsNewGlobalIndex[it->first]; } } } else { @@ -725,7 +724,7 @@ namespace AMDiS { dofChanged[dofIt->first] = true; recvDofs[recvIt->first].push_back(dofIt->first); - rankOwnedDofsNewGlobalIndex[dofIt->first] = newGlobalDof; + rankDofsNewGlobalIndex[dofIt->first] = newGlobalDof; isRankDof[rankDofsNewLocalIndex[dofIt->first]] = false; found = true; @@ -745,7 +744,7 @@ namespace AMDiS { for (DofIndexMap::iterator dofIt = rankDofsNewLocalIndex.begin(); dofIt != rankDofsNewLocalIndex.end(); ++dofIt) { DegreeOfFreedom localDof = dofIt->second; - DegreeOfFreedom globalDof = rankOwnedDofsNewGlobalIndex[dofIt->first]; + DegreeOfFreedom globalDof = rankDofsNewGlobalIndex[dofIt->first]; *const_cast<DegreeOfFreedom*>(dofIt->first) = localDof; mapLocalGlobalDOFs[localDof] = globalDof; @@ -932,15 +931,13 @@ namespace AMDiS { mpiComm.Allreduce(&nRankDOFs, &nOverallDOFs, 1, MPI_INT, MPI_SUM); - // === - - // Do not change the indices now, but create a new indexing a store it here. DofIndexMap rankDofsNewLocalIndex; isRankDof.clear(); int i = 0; for (DofContainer::iterator dofIt = rankAllDofs.begin(); dofIt != rankAllDofs.end(); ++dofIt) { + rankDofsNewLocalIndex[*dofIt] = i; // First, we set all dofs in ranks partition to be owend by the rank. Later, // the dofs in ranks partition that are owned by other rank are set to false. @@ -949,14 +946,14 @@ namespace AMDiS { } // Stores for all rank owned dofs a new global index. - DofIndexMap rankOwnedDofsNewGlobalIndex; + DofIndexMap rankDofsNewGlobalIndex; // Stores for all rank owned dofs a continues local index. DofIndexMap rankOwnedDofsNewLocalIndex; i = 0; for (DofContainer::iterator dofIt = rankDOFs.begin(); dofIt != rankDOFs.end(); ++dofIt) { - rankOwnedDofsNewGlobalIndex[*dofIt] = i + rstart; + rankDofsNewGlobalIndex[*dofIt] = i + rstart; rankOwnedDofsNewLocalIndex[*dofIt] = i; i++; } @@ -978,7 +975,7 @@ namespace AMDiS { int c = 0; for (DofContainer::iterator dofIt = sendIt->second.begin(); dofIt != sendIt->second.end(); ++dofIt) - sendBuffers[i][c++] = rankOwnedDofsNewGlobalIndex[*dofIt]; + sendBuffers[i][c++] = rankDofsNewGlobalIndex[*dofIt]; request[requestCounter++] = mpiComm.Isend(sendBuffers[i], nSendDofs, MPI_INT, sendIt->first, 0); @@ -1006,14 +1003,15 @@ namespace AMDiS { for (DofContainer::iterator dofIt = recvIt->second.begin(); dofIt != recvIt->second.end(); ++dofIt) { - rankOwnedDofsNewGlobalIndex[*dofIt] = recvBuffers[i][j]; - isRankDof[rankOwnedDofsNewLocalIndex[*dofIt]] = false; + rankDofsNewGlobalIndex[*dofIt] = recvBuffers[i][j]; + isRankDof[rankDofsNewLocalIndex[*dofIt]] = false; j++; } delete [] recvBuffers[i++]; } + // === Update list of dofs that must be communicated for solution exchange. === sendDofs = sendNewDofs; @@ -1023,11 +1021,12 @@ namespace AMDiS { // === Create now the local to global index, and vice verse, mappings. === mapLocalGlobalDOFs.clear(); + mapLocalToDofIndex.clear(); for (DofIndexMap::iterator dofIt = rankDofsNewLocalIndex.begin(); dofIt != rankDofsNewLocalIndex.end(); ++dofIt) { DegreeOfFreedom localDof = dofIt->second; - DegreeOfFreedom globalDof = rankOwnedDofsNewGlobalIndex[dofIt->first]; + DegreeOfFreedom globalDof = rankDofsNewGlobalIndex[dofIt->first]; *const_cast<DegreeOfFreedom*>(dofIt->first) = localDof; mapLocalGlobalDOFs[localDof] = globalDof;