24#ifndef REFINEMENT_LOAD_BALANCER_H
25#define REFINEMENT_LOAD_BALANCER_H
40template<
typename T,
unsigned D>
43 std::map<int,int> _coarseLoc;
53 std::vector<int> rankBuffer(fineGeometry.
size(), 0);
54 std::vector<int> locBuffer(fineGeometry.
size(), 0);
55 std::map<int,int> nLoc;
56 for (
unsigned iC=0; iC < fineGeometry.
size(); ++iC) {
57 const auto& fineCuboid = fineGeometry.
get(iC);
58 if (
auto latticeR = coarseGeometry.
getLatticeR(fineCuboid.getOrigin())) {
59 const int coarseC = (*latticeR)[0];
60 if (coarseBalancer.
isLocal(coarseC)) {
61 rankBuffer[iC] = coarseBalancer.
rank(coarseC);
62 locBuffer[iC] = nLoc[rankBuffer[iC]]++;
64 clout <<
"Matching fineC=" << iC <<
" to coarseC=" << coarseC <<
" on rank=" << rankBuffer[iC] << std::endl;
65 _coarseLoc[locBuffer[iC]] = coarseBalancer.
loc(coarseC);
70 #ifdef PARALLEL_MODE_MPI
71 std::vector<int> globalRankBuffer(fineGeometry.
size(), 0);
72 std::vector<int> globalLocBuffer(fineGeometry.
size(), 0);
77 auto& globalRankBuffer = rankBuffer;
78 auto& globalLocBuffer = locBuffer;
82 for (
unsigned iC=0; iC < fineGeometry.
size(); ++iC) {
83 this->
_rank[iC] = globalRankBuffer[iC];
84 this->
_loc[iC] = globalLocBuffer[iC];
86 this->
_glob.resize(std::max(
static_cast<int>(this->
_glob.size()), this->_loc[iC]+1));
95 int cloc(
int fineLoc)
const {
96 return _coarseLoc.at(fineLoc);
Decomposition of a physical volume into a set of disjoint cuboids.
int size() const
Returns number of cuboids in decomposition.
const Cuboid< T, D > & get(int iC) const
Read access to a single cuboid.
std::optional< LatticeR< D+1 > > getLatticeR(Vector< T, D > physR) const
Returns lattice position for given physical position if it exists.
Base class for all LoadBalancer.
bool isLocal(const int &glob) const
returns whether glob is on this process
virtual Platform platform(int loc) const
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
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
class for marking output with some text
void setMultiOutput(bool b)
enable message output for all MPI processes, disabled by default
Load balancer for refined lattice hierarchies.
int cloc(int fineLoc) const
Returns coarse loc for given fine loc.
RefinedLoadBalancer(CuboidDecomposition< T, D > &coarseGeometry, LoadBalancer< T > &coarseBalancer, CuboidDecomposition< T, D > &fineGeometry)
void allreduce(const T *in, T *out, int count, MPI_Op op, MPI_Comm comm=MPI_COMM_WORLD)
Top level namespace for all of OpenLB.