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);
77 for (
auto [loc, _] : _loc) {
78 if (this->platform(loc) == platform) {
94 std::map<int,int>::const_iterator iter = _loc.find(glob);
107 std::map<int,int>::const_iterator iter = _rank.find(glob);
126 return _size == rhs.
_size &&
128 _glob == rhs.
_glob &&
148 + _loc.size() *
sizeof(std::pair<int, int>)
149 + _rank.size() *
sizeof(std::pair<int, int>)
150 + _glob.size() *
sizeof(int);
157 std::size_t currentBlock = 0;
158 size_t sizeBufferIndex = 0;
159 bool* dataPtr =
nullptr;
161 this->registerVar<int> (iBlock, sizeBlock, currentBlock, dataPtr, _size);
162 this->registerMap<int, int> (iBlock, sizeBlock, currentBlock, sizeBufferIndex, dataPtr, _loc, loadingMode);
163 this->registerStdVectorOfVars<int>(iBlock, sizeBlock, currentBlock, sizeBufferIndex, dataPtr, _glob, loadingMode);
164 this->registerMap<int, int> (iBlock, sizeBlock, currentBlock, sizeBufferIndex, dataPtr, _rank, loadingMode);
175 for (
unsigned i = 0; i < this->_glob.size(); i++) {
176 clout <<
"glob[" << i <<
"]=" << this->_glob[i] << std::endl;
178 for (
const auto& [globC, locC] : this->_loc) {
179 clout <<
"loc[" << globC <<
"]=" << locC << std::endl;
181 for (
const auto& [globC, rank] : this->_rank) {
182 clout <<
"rank[" << globC <<
"]=" << rank << std::endl;
Base class for all LoadBalancer.
bool isLocal(const int &glob) const
returns whether glob is on this process
bool operator==(const LoadBalancer< T > &rhs) const
equal operator
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.
Platform
OpenLB execution targets.