// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // == http://www.amdis-fem.org == // == == // ============================================================================ // // Software License for AMDiS // // Copyright (c) 2010 Dresden University of Technology // All rights reserved. // Authors: Simon Vey, Thomas Witkowski et al. // // This file is part of AMDiS // // See also license.opensource.txt in the distribution. /** \file MeshLevelData.h */ #ifndef AMDIS_MESH_LEVEL_DATA_H #define AMDIS_MESH_LEVEL_DATA_H #include #include #include #include #include "Global.h" namespace AMDiS { using namespace std; class MeshLevelData { public: MeshLevelData() : nLevel(0) {} void init(std::set &neighbourRanks); void addLevel(std::set &ranksInDomain, int domainId); // Writes all data of this object to an output stream. void serialize(ostream &out); // Reads the object data from an input stream. void deserialize(istream &in); void print(); std::set& getLevelRanks(int level) { TEST_EXIT_DBG(level < nLevel)("Should not happen!\n"); return levelRanks[level]; } std::set& getLevelNeighbours(int level) { TEST_EXIT_DBG(level < nLevel)("Should not happen!\n"); return levelNeighbours[level]; } int getLevelNumber() { return nLevel; } MPI::Intracomm& getMpiComm(int level) { TEST_EXIT_DBG(level < nLevel)("Should not happen!\n"); return mpiComms[level]; } MPI::Group& getMpiGroup(int level) { TEST_EXIT_DBG(level < nLevel)("Should not happen!\n"); return mpiGroups[level]; } int mapRank(int fromRank, int fromLevel, int toLevel) { int toRank = -1; MPI::Group::Translate_ranks(mpiGroups[fromLevel], 1, &fromRank, mpiGroups[toLevel], &toRank); if (toRank == MPI::UNDEFINED) toRank = -1; return toRank; } bool rankInSubdomain(int rank, int level) { TEST_EXIT_DBG(level < nLevel)("Should not happen!\n"); return static_cast(levelRanks[level].count(rank)); } protected: int nLevel; vector > levelRanks; vector > levelNeighbours; vector mpiComms; vector mpiGroups; }; } #endif