36 namespace fvMeshDistributors
58 multiConstraint_(
dict.lookupOrDefault<
Switch>(
"multiConstraint", true))
74 bool redistributed =
false;
86 const scalar timeStepCpuTime = cpuTime_.cpuTimeIncrement();
94 <<
"No CPU loads have been allocated"
107 procCpuLoads[l++] =
sum(*iter());
117 forAll(maxProcCpuLoads, l)
119 forAll(allProcCpuLoads, proci)
121 sumProcCpuLoads[l] += allProcCpuLoads[proci][l];
124 max(maxProcCpuLoads[l], allProcCpuLoads[proci][l]);
129 const scalar sumMaxProcCpuLoad(
sum(maxProcCpuLoads));
135 const scalar maxBaseCpuTime =
139 const scalar cellBaseCpuTime = maxBaseCpuTime/maxNcells;
142 const scalar baseCpuTime =
mesh.
nCells()*cellBaseCpuTime;
145 const scalar maxProcCpuTime = maxBaseCpuTime + sumMaxProcCpuLoad;
148 const scalar procCpuTime = baseCpuTime +
sum(procCpuLoads);
151 const scalar averageProcessorCpuTime =
154 const scalar imbalance =
155 (maxProcCpuTime - averageProcessorCpuTime)
156 /averageProcessorCpuTime;
163 Info<<
" Imbalance of load " << iter()->name() <<
": "
167 )/averageProcessorCpuTime
172 Info<<
" Imbalance of base load " <<
": "
177 )/averageProcessorCpuTime
180 Info<<
" Total imbalance " << imbalance <<
endl;
182 if (imbalance > maxImbalance_)
184 Info<<
" Redistributing mesh" <<
endl;
188 if (multiConstraint_)
190 const label nWeights = cpuLoads.
size() + 1;
196 weights[nWeights*i] = cellBaseCpuTime;
206 weights[nWeights*i + l] = cpuLoadField[i];
228 distributor_->decompose(
mesh, weights)
233 redistributed =
true;
254 return redistributed;
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Macros for easy insertion into run-time selection tables.
An STL-conforming hash table.
label size() const
Return number of elements in table.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
label timeIndex() const
Return current time index.
virtual label startTimeIndex() const
Return start time index.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Base class for statistical distributions.
Abstract base class for fvMesh movers.
Dynamic mesh redistribution using the distributor specified in decomposeParDict.
Dynamic mesh redistribution using the distributor specified in decomposeParDict.
virtual bool update()
Distribute the.
loadBalancer(fvMesh &mesh, const dictionary &dict)
Construct from fvMesh and dictionary.
virtual ~loadBalancer()
Destructor.
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
label nTotalCells() const
Return total number of cells in decomposed mesh.
const globalMeshData & globalData() const
Return parallel info.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
defineTypeNameAndDebug(none, 0)
addToRunTimeSelectionTable(fvMeshDistributor, none, fvMesh)
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.