36 namespace fvMeshDistributors
51 void Foam::fvMeshDistributors::loadBalancer::readDict()
55 const dictionary& distributorDict(
dict());
58 distributorDict.lookupOrDefault<Switch>(
"multiConstraint",
true);
82 const fvMesh& mesh = this->mesh();
84 bool redistributed =
false;
96 const scalar timeStepCpuTime = cpuTime_.cpuTimeIncrement();
101 if (!cpuLoads.
size())
104 <<
"No CPU loads have been allocated"
117 procCpuLoads[l++] =
sum(*iter());
127 forAll(maxProcCpuLoads, l)
129 forAll(allProcCpuLoads, proci)
131 sumProcCpuLoads[l] += allProcCpuLoads[proci][l];
134 max(maxProcCpuLoads[l], allProcCpuLoads[proci][l]);
139 const scalar sumMaxProcCpuLoad(
sum(maxProcCpuLoads));
145 const scalar maxBaseCpuTime =
149 const scalar cellBaseCpuTime = maxBaseCpuTime/maxNcells;
152 const scalar baseCpuTime = mesh.
nCells()*cellBaseCpuTime;
155 const scalar maxProcCpuTime = maxBaseCpuTime + sumMaxProcCpuLoad;
158 const scalar procCpuTime = baseCpuTime +
sum(procCpuLoads);
161 const scalar averageProcessorCpuTime =
164 const scalar imbalance =
165 (maxProcCpuTime - averageProcessorCpuTime)
166 /averageProcessorCpuTime;
173 Info<<
" Imbalance of load " << iter()->name() <<
": "
177 )/averageProcessorCpuTime
182 Info<<
" Imbalance of base load " <<
": "
187 )/averageProcessorCpuTime
190 Info<<
" Total imbalance " << imbalance <<
endl;
192 if (imbalance > maxImbalance_)
194 Info<<
" Redistributing mesh" <<
endl;
198 if (multiConstraint_)
200 const label nWeights = cpuLoads.
size() + 1;
206 weights[nWeights*i] = cellBaseCpuTime;
216 weights[nWeights*i + l] = cpuLoadField[i];
238 distributor_->decompose(mesh, weights)
243 redistributed =
true;
264 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.
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)
Base class for statistical distributions.
Abstract base class for fvMesh movers.
const dictionary & dict() const
Return the dynamicMeshDict/distributor sub-dict.
Dynamic mesh redistribution using the distributor specified in decomposeParDict.
void readDict()
Read the projection parameters from dictionary.
Dynamic mesh redistribution using the distributor specified in decomposeParDict.
loadBalancer(fvMesh &mesh)
Construct from fvMesh.
virtual bool update()
Distribute the.
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.
#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.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
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.