source: src/comm/mpi/key.cpp@ 1610dc

Last change on this file since 1610dc was 2112b1, checked in by Julian Iseringhausen <isering@…>, 14 years ago

Did some work on the MPI communication.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1245 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 * @file key.cpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Mon Nov 21 13:27:22 2011
5 *
6 * @brief Class to distinguish the different entities in maps.
7 *
8 */
9
10#ifdef HAVE_CONFIG_H
11#include <config.h>
12#endif
13
14#include "comm/mpi/key.hpp"
15#include "grid/grid.hpp"
16
17using namespace VMG;
18
19VMG::MPI::Key::Key()
20{
21}
22
23VMG::MPI::Key::Key(const Grid& grid)
24{
25 AddKey(grid);
26}
27
28VMG::MPI::Key::Key(const Grid& grid_1, const Grid& grid_2)
29{
30 AddKey(grid_1);
31 AddKey(grid_2);
32}
33
34VMG::MPI::Key::Key(const Index& i1, const Index& i2, const Index& i3)
35{
36 AddKey(i1);
37 AddKey(i2);
38 AddKey(i3);
39}
40
41void VMG::MPI::Key::AddKey(const Grid& grid)
42{
43 for (int i=0; i<3; ++i) {
44 int_keys.push_back(grid.Global().BeginLocal()[i]);
45 int_keys.push_back(grid.Global().EndLocal()[i]);
46 int_keys.push_back(grid.Global().SizeGlobal()[i]);
47 }
48 addr_keys.push_back(reinterpret_cast<const void*>(&grid));
49}
50
51void VMG::MPI::Key::AddKey(const Index& index)
52{
53 for (int i=0; i<3; ++i)
54 int_keys.push_back(index[i]);
55}
56
57void VMG::MPI::Key::AddKey(const int& i)
58{
59 int_keys.push_back(i);
60}
61
62void VMG::MPI::Key::AddKey(const void* addr)
63{
64 addr_keys.push_back(addr);
65}
66
67bool VMG::MPI::Key::operator<(const Key& other) const
68{
69 if (this->int_keys.size() < other.int_keys.size())
70 return true;
71 else if (this->int_keys.size() > other.int_keys.size())
72 return false;
73
74 if (this->addr_keys.size() < other.addr_keys.size())
75 return true;
76 else if (this->addr_keys.size() > other.addr_keys.size())
77 return false;
78
79 for (unsigned int i=0; i<int_keys.size(); ++i)
80 if (this->int_keys[i] < other.int_keys[i])
81 return true;
82 else if (this->int_keys[i] > other.int_keys[i])
83 return false;
84
85 for (unsigned int i=0; i<addr_keys.size(); ++i)
86 if (this->addr_keys[i] < other.addr_keys[i])
87 return true;
88 else if (this->addr_keys[i] > other.addr_keys[i])
89 return false;
90
91 return false;
92}
Note: See TracBrowser for help on using the repository browser.