25#ifndef LOAD_BALANCER_HH
26#define LOAD_BALANCER_HH
39 std::map<int,int>& loc,
40 std::vector<int>& glob,
41 std::map<int,int>& rank)
42 : _size(size), _loc(loc), _glob(glob), _rank(rank)
47 std::map<int,int>& loc,
48 std::vector<int>& glob,
49 std::map<int,int>& rank,
50 std::map<int,Platform>& platform)
51 : _size(size), _loc(loc), _glob(glob), _rank(rank), _platform(platform)
61 std::swap(_size, loadBalancer.
_size);
62 _loc.swap(loadBalancer.
_loc);
63 _glob.swap(loadBalancer.
_glob);
64 _rank.swap(loadBalancer.
_rank);
83 std::map<int,int>::const_iterator iter = _loc.find(glob);
102 std::map<int,int>::const_iterator iter = _rank.find(glob);
121 return _size == rhs.
_size &&
143 + _loc.size() *
sizeof(std::pair<int, int>)
144 + _rank.size() *
sizeof(std::pair<int, int>)
145 + _glob.size() *
sizeof(int);
152 std::size_t currentBlock = 0;
153 size_t sizeBufferIndex = 0;
154 bool* dataPtr =
nullptr;
156 this->registerVar<int> (iBlock, sizeBlock, currentBlock, dataPtr, _size);
157 this->registerMap<int, int> (iBlock, sizeBlock, currentBlock, sizeBufferIndex, dataPtr, _loc, loadingMode);
158 this->registerStdVectorOfVars<int>(iBlock, sizeBlock, currentBlock, sizeBufferIndex, dataPtr, _glob, loadingMode);
159 this->registerMap<int, int> (iBlock, sizeBlock, currentBlock, sizeBufferIndex, dataPtr, _rank, loadingMode);
170 for (
unsigned i = 0; i < this->_glob.size(); i++) {
171 clout <<
"glob[" << i <<
"]=" << this->_glob[i] << std::endl;
173 for (
const auto& [globC, locC] : this->_loc) {
174 clout <<
"loc[" << globC <<
"]=" << locC << std::endl;
176 for (
const auto& [globC, rank] : this->_rank) {
177 clout <<
"rank[" << globC <<
"]=" << rank << std::endl;
Base class for all LoadBalancer.
int rank(const int &glob)
bool operator==(const LoadBalancer< T > &rhs) const
equal operator
bool isLocal(const int &glob)
returns whether glob is on this process
std::size_t getSerializableSize() const override
Binary size for the serializer.
void print(bool multiOutput=false) const
virtual ~LoadBalancer()
Default empty destructor.
std::map< int, Platform > _platform
maps global cuboid number to local platform
std::vector< int > _glob
content is 0,1,2,...,_size
int _size
number of cuboids after shrink -1 in appropriate thread
void swap(LoadBalancer< T > &loadBalancer)
Swap method.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Return a pointer to the memory of the current block and its size for the serializable interface.
std::map< int, int > _rank
maps global cuboid number to the processing thread
std::map< int, int > _loc
maps global cuboid to (local) thread cuboid
LoadBalancer(int size=1)
Default empty constructor.
class for marking output with some text
void setMultiOutput(bool b)
enable message output for all MPI processes, disabled by default
int getRank() const
Returns the process ID.
Top level namespace for all of OpenLB.