/** * @file key.cpp * @author Julian Iseringhausen * @date Mon Nov 21 13:27:22 2011 * * @brief Class to distinguish the different entities in maps. * */ #ifdef HAVE_CONFIG_H #include #endif #include "comm/mpi/key.hpp" #include "grid/grid.hpp" using namespace VMG; VMG::MPI::Key::Key() { } VMG::MPI::Key::Key(const VMG::MPI::Key& other) { this->int_keys.assign(other.int_keys.begin(), other.int_keys.end()); this->addr_keys.assign(other.addr_keys.begin(), other.addr_keys.end()); } VMG::MPI::Key::Key(const Grid& grid) { AddKey(grid); } VMG::MPI::Key::Key(const Grid& grid_1, const Grid& grid_2) { AddKey(grid_1); AddKey(grid_2); } VMG::MPI::Key::Key(const Index& i1, const Index& i2, const Index& i3) { AddKey(i1); AddKey(i2); AddKey(i3); } void VMG::MPI::Key::AddKey(const Grid& grid) { for (int i=0; i<3; ++i) { int_keys.push_back(grid.Global().BeginLocal()[i]); int_keys.push_back(grid.Global().EndLocal()[i]); int_keys.push_back(grid.Global().SizeGlobal()[i]); } addr_keys.push_back(reinterpret_cast(&grid)); } void VMG::MPI::Key::AddKey(const Index& index) { for (int i=0; i<3; ++i) int_keys.push_back(index[i]); } void VMG::MPI::Key::AddKey(const int& i) { int_keys.push_back(i); } void VMG::MPI::Key::AddKey(const void* addr) { addr_keys.push_back(addr); } bool VMG::MPI::Key::operator<(const Key& other) const { if (this->int_keys.size() < other.int_keys.size()) return true; else if (this->int_keys.size() > other.int_keys.size()) return false; if (this->addr_keys.size() < other.addr_keys.size()) return true; else if (this->addr_keys.size() > other.addr_keys.size()) return false; for (unsigned int i=0; iint_keys[i] < other.int_keys[i]) return true; else if (this->int_keys[i] > other.int_keys[i]) return false; for (unsigned int i=0; iaddr_keys[i] < other.addr_keys[i]) return true; else if (this-> addr_keys[i] > other.addr_keys[i]) return false; return false; }