14 template <
typename I=int64_t>
45 visited.push_back(
this);
49 for(
auto& fatherSister : fatherSisters)
50 if(
auto& father=fatherSister.first;
not visited.isContained(father))
51 father->visitAll(visited,fun);
53 for(
auto& childPair : children)
54 for(
auto& child : {childPair.first,childPair.second})
55 if(
not visited.isContained(child))
56 child->visitAll(visited,fun);
72 visitAll(visited,fun);
81 visitAll([&list](PartitioningLevel* pl)
108 for(
auto& fatherSister : fatherSisters)
109 if(
auto& father=fatherSister.first;father->volumeIsSet())
119 const std::string& name) :
137 fatherSisters.push_back({&f,&s});
145 children.push_back({&a,&b});
158 for(
auto& fatherSister : fatherSisters)
160 PartitioningLevel* father=
166 if(fathVol
and fathVol%v!=0)
171 for(
auto& childPair : children)
172 for(
auto& child : {childPair.first,childPair.second})
177 if(childVol
and v%childVol!=0)
189 fatherSisters.begin();
191 while(wentWell
and fatherSister!=fatherSisters.end())
193 PartitioningLevel& father=
194 *fatherSister->first;
196 PartitioningLevel& sister=
197 *fatherSister->second;
201 RUNLOG<<
"Father "<<father.name<<
" has already set volume";
202 if(
not sister.getVol())
204 RUNLOG<<
"Sister "<<sister.name<<
" has no set volume";
208 sister.setVol(father.getVol()/v);
211 RUNLOG<<
"Also sister "<<sister.name<<
" had set volume";
215 RUNLOG<<
"Father "<<father.name<<
" has no set volume";
218 RUNLOG<<
"Sister "<<sister.name<<
" had it, computing father "<<father.name<<
" volume";
222 father.setVol(v*sister.getVol());
225 RUNLOG<<
"Neither sister "<<sister.name<<
" had set volume, cannot fix anything";
231 if(fatherSisters.size()==0)
232 RUNLOG<<name<<
" has no father";
234 if(
auto childPair=children.begin();wentWell)
235 while(wentWell
and childPair!=children.end())
241 *(childPair->second);
247 secondChild.getVol();
249 if(firstVol
and not secondVol)
251 RUNLOG<<
"Second child "<<secondChild.name<<
" has no set volume";
256 secondChild.setVol(v/firstVol);
259 if(secondVol
and not firstVol)
261 RUNLOG<<
"First child "<<firstChild.name<<
" has no set volume";
266 childPair->first->setVol(v/secondVol);
273 RUNLOG<<
"Volume of "<<name<<
" set to "<<v;
276 RUNLOG<<
"Could not set volume of "<<name<<
" to "<<v;
286 template <
typename I=int64_t>
291 c1.addFatherSister(f,c2);
292 c2.addFatherSister(f,c1);
301 rng.seed(trueRandomGenerator);
304 runLog()<<rng.serialize();
309 std::ostringstream os;
310 os<<*
static_cast<_MasterRandomGenerator*>(&mrg);
311 runLog()<<os.str()<<
" "<<_MasterRandomGenerator::word_size;
void visitAll(Vector< PartitioningLevel * > &visited, const F &fun)
Vector< PartitioningLevel * > getAllWithUnfixedVol()
List all elements of the partitioning with unfixed nodes.
Rng(const uint32_t &s=DEFAULT_SEED)
Default constructor.
Vector< PLPP > children
List of children grid partitioning this grid.
bool volumeIsBound() const
const std::string name
Name of the partitioning.
#define RUNLOG
Create the line.
const std::vector< uint64_t > & seeds
Constant access to the seeds.
void divWithMod(Vector< TOut > "ient, Vector< TOut > &remainder, const Vector &divisor) const
Returns the result and remainder of the division.
PartitioningLevel(const int nDim, const std::string &name)
Constructor.
bool volumeIsSet() const
Determines if the volume is set.
decltype(auto) operator+(T1 &&smet1, T2 &&smet2)
Implement smet1+smet2.
Vector< I > sides
Sides of the grid.
#define SCOPE_INDENT(VAR)
Mark the stream to be more indented.
const I & getVol() const
Returns the volume.
void visitAll(const F &fun)
Vector< PLPP > fatherSisters