From 4800ba783c8322dbb71b799273d9a2d7b4f8ca24 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Mon, 18 Jun 2012 13:58:20 +0000 Subject: [PATCH] Fixed serialization. --- AMDiS/src/parallel/DofComm.cc | 31 ++++++ AMDiS/src/parallel/DofComm.h | 16 +-- AMDiS/src/parallel/ElementObjectDatabase.cc | 4 +- AMDiS/src/parallel/MeshDistributor.cc | 110 +++++++++----------- 4 files changed, 91 insertions(+), 70 deletions(-) diff --git a/AMDiS/src/parallel/DofComm.cc b/AMDiS/src/parallel/DofComm.cc index 6b125e01..c5baa1e1 100644 --- a/AMDiS/src/parallel/DofComm.cc +++ b/AMDiS/src/parallel/DofComm.cc @@ -89,6 +89,37 @@ namespace AMDiS { } + void DofComm::serialize(ostream &out) + { + FUNCNAME("DofComm:serialize()"); + + MSG("MUSS DAS WIRKLICH SEIN????\n"); + } + + + void DofComm::deserialize(istream &in, + map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > dofIndexMap) + { + FUNCNAME("DofComm::deserialize()"); + + MSG("MUSS DAS WIRKLICH SEIN????\n"); + } + + + void DofComm::serialize(LevelDataType &data, ostream &out) + { + FUNCNAME("DofComm:serialize()"); + } + + + void DofComm::deserialize(LevelDataType &data, + istream &in, + map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > dofIndexMap) + { + FUNCNAME("DofComm::deserialize()"); + } + + int DofComm::getNumberDofs(LevelDataType &data, int level, const FiniteElemSpace *feSpace, diff --git a/AMDiS/src/parallel/DofComm.h b/AMDiS/src/parallel/DofComm.h index 40b98333..eacea516 100644 --- a/AMDiS/src/parallel/DofComm.h +++ b/AMDiS/src/parallel/DofComm.h @@ -73,17 +73,11 @@ namespace AMDiS { } // Writes all data of this object to an output stream. - void serialize(ostream &out) - { - ERROR_EXIT("MUST BE IMPLEMENTED!\n"); - } + void serialize(ostream &out); // Reads the object data from an input stream. void deserialize(istream &in, - map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > dofIndexMap) - { - ERROR_EXIT("MUST BE IMPLEMENTED!\n"); - } + map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > dofIndexMap); int getNumberDofs(LevelDataType &data, int level, @@ -93,6 +87,12 @@ namespace AMDiS { protected: void createContainer(RankToBoundMap &boundary, LevelDataType &data); + void serialize(LevelDataType &data, ostream &out); + + void deserialize(LevelDataType &data, + istream &in, + map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > dofIndexMap); + protected: /// This map contains for each rank the list of DOFs the current rank must /// end to exchange solution DOFs at the interior boundaries. diff --git a/AMDiS/src/parallel/ElementObjectDatabase.cc b/AMDiS/src/parallel/ElementObjectDatabase.cc index bd1e4480..fea60559 100644 --- a/AMDiS/src/parallel/ElementObjectDatabase.cc +++ b/AMDiS/src/parallel/ElementObjectDatabase.cc @@ -739,8 +739,6 @@ namespace AMDiS { } - ERROR_EXIT("REWRITE SERIALIZATION!\n"); - nSize = vertexInRank.size(); SerUtil::serialize(out, nSize); for (map<DegreeOfFreedom, map<int, ElementObjectData> >::iterator it = vertexInRank.begin(); @@ -874,7 +872,7 @@ namespace AMDiS { faceLocalMap[data] = face; } - ERROR_EXIT("REWRITE DESERIALIZATION!\n"); + SerUtil::deserialize(in, nSize); vertexInRank.clear(); diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc index 175c4cd5..108be0e9 100644 --- a/AMDiS/src/parallel/MeshDistributor.cc +++ b/AMDiS/src/parallel/MeshDistributor.cc @@ -166,6 +166,8 @@ namespace AMDiS { // isRankDofs to all matrices and rhs vector and to remove periodic // boundary conditions (if there are some). if (deserialized) { + createMeshLevelStructure(); + updateMacroElementInfo(); setRankDofs(); @@ -174,7 +176,8 @@ namespace AMDiS { elObjDb.createMacroElementInfo(allMacroElements); - createBoundaryDofs(); + // createBoundaryDofs(); + updateLocalGlobalNumbering(); #if (DEBUG != 0) ParallelDebug::writeDebugFile(feSpaces[feSpaces.size() - 1], dofMap, @@ -920,57 +923,62 @@ namespace AMDiS { // === At least one rank mesh has been changed, so the boundaries must be === // === adapted to the new mesh structure. === - if (skip == 0) - do { - bool meshChanged = false; - - // To check the interior boundaries, the ownership of the boundaries is not - // important. Therefore, we add all boundaries to one boundary container. - RankToBoundMap allBound; - - for (InteriorBoundary::iterator it(intBoundary.getOwn()); !it.end(); ++it) + if (skip == 0) { + int iterationCounter = 0; + do { + bool meshChanged = false; + + // To check the interior boundaries, the ownership of the boundaries is not + // important. Therefore, we add all boundaries to one boundary container. + RankToBoundMap allBound; + + for (InteriorBoundary::iterator it(intBoundary.getOwn()); !it.end(); ++it) if ((mesh->getDim() == 2 && it->rankObj.subObj == EDGE) || (mesh->getDim() == 3 && it->rankObj.subObj == FACE)) allBound[it.getRank()].push_back(*it); - - for (InteriorBoundary::iterator it(intBoundary.getOther()); - !it.end(); ++it) - if ((mesh->getDim() == 2 && it->rankObj.subObj == EDGE) || - (mesh->getDim() == 3 && it->rankObj.subObj == FACE)) - allBound[it.getRank()].push_back(*it); - - for (InteriorBoundary::iterator it(intBoundary.getPeriodic()); - !it.end(); ++it) { - if (it.getRank() == mpiRank) { - if ((mesh->getDim() == 2 && it->rankObj.subObj == EDGE) || - (mesh->getDim() == 3 && it->rankObj.subObj == FACE)) { - MeshStructure elCode; - elCode.init(it->rankObj); - - MeshManipulation mm(mesh); - meshChanged |= mm.fitElementToMeshCode(elCode, it->neighObj); - } - } else { + + for (InteriorBoundary::iterator it(intBoundary.getOther()); + !it.end(); ++it) if ((mesh->getDim() == 2 && it->rankObj.subObj == EDGE) || (mesh->getDim() == 3 && it->rankObj.subObj == FACE)) - allBound[it.getRank()].push_back(*it); + allBound[it.getRank()].push_back(*it); + + for (InteriorBoundary::iterator it(intBoundary.getPeriodic()); + !it.end(); ++it) { + if (it.getRank() == mpiRank) { + if ((mesh->getDim() == 2 && it->rankObj.subObj == EDGE) || + (mesh->getDim() == 3 && it->rankObj.subObj == FACE)) { + MeshStructure elCode; + elCode.init(it->rankObj); + + MeshManipulation mm(mesh); + meshChanged |= mm.fitElementToMeshCode(elCode, it->neighObj); + } + } else { + if ((mesh->getDim() == 2 && it->rankObj.subObj == EDGE) || + (mesh->getDim() == 3 && it->rankObj.subObj == FACE)) + allBound[it.getRank()].push_back(*it); + } } - } - - - // === Check the boundaries and adapt mesh if necessary. === - MSG_DBG("Run checkAndAdaptBoundary ...\n"); - - meshChanged |= checkAndAdaptBoundary(allBound); - // === Check on all ranks if at least one rank's mesh has changed. === - int sendValue = static_cast<int>(meshChanged); - recvAllValues = 0; - mpiComm.Allreduce(&sendValue, &recvAllValues, 1, MPI_INT, MPI_SUM); + // === Check the boundaries and adapt mesh if necessary. === + MSG_DBG("Run checkAndAdaptBoundary ...\n"); + + meshChanged |= checkAndAdaptBoundary(allBound); + + // === Check on all ranks if at least one rank's mesh has changed. === + + int sendValue = static_cast<int>(meshChanged); + recvAllValues = 0; + mpiComm.Allreduce(&sendValue, &recvAllValues, 1, MPI_INT, MPI_SUM); + + MSG("Mesh changed on %d ranks!\n", recvAllValues); + iterationCounter++; + } while (recvAllValues != 0); - MSG("Mesh changed on %d ranks!\n", recvAllValues); - } while (recvAllValues != 0); + MSG("Number of iteration to adapt mesh: %d\n", iterationCounter); + } #if (DEBUG != 0) debug::writeMesh(feSpaces[0], -1, debugOutputDir + "mesh"); @@ -1972,14 +1980,8 @@ namespace AMDiS { intBoundary.serialize(out); - dofComm.serialize(out); - // === Serialieze FE space dependent data === - dofMap.serialize(out); - - periodicMap.serialize(out, feSpaces); - SerUtil::serialize(out, macroElementNeighbours); int nSize = allMacroElements.size(); @@ -1989,8 +1991,6 @@ namespace AMDiS { SerUtil::serialize(out, nMeshChangesAfterLastRepartitioning); SerUtil::serialize(out, repartitioningCounter); - - levelData.serialize(out); } @@ -2023,14 +2023,8 @@ namespace AMDiS { intBoundary.deserialize(in, mesh); - dofComm.deserialize(in, dofIndexMap); - // === Deerialieze FE space dependent data === - dofMap.deserialize(in); - - periodicMap.deserialize(in, feSpaces); - SerUtil::deserialize(in, macroElementNeighbours); int nSize = 0; @@ -2048,8 +2042,6 @@ namespace AMDiS { SerUtil::deserialize(in, nMeshChangesAfterLastRepartitioning); SerUtil::deserialize(in, repartitioningCounter); - levelData.deserialize(in); - deserialized = true; } -- GitLab