84 for (
int iwtp: wtp ) {
85 std :: unique_ptr< WorkTransferPlugin > plugin;
92 wtpList.push_back(std :: move( plugin ));
129 com.finishExchange();
134 #ifdef LoadBalancer_debug_print 137 fprintf(stderr,
"\n[%d] Nodal Table\n", myrank);
138 for (
int i = 1; i <= nnodes; i++ ) {
147 fprintf(stderr,
"\n");
151 fprintf(stderr,
"\n[%d] Element Table\n", myrank);
152 for (
int i = 1; i <= nelems; i++ ) {
153 fprintf(stderr,
"%5d {", i);
158 fprintf(stderr,
"}\n");
164 for (
auto &wtp: wtpList ) {
169 for (
auto &wtp: wtpList ) {
174 #ifdef LoadBalancer_debug_print 178 fprintf(stderr,
"LB Debug print (after wtp update):\n");
179 fprintf(stderr,
"\n[%d] Nodal Table\n", myrank);
180 for (
int i = 1; i <= nnodes; i++ ) {
189 fprintf(stderr,
"\n");
193 fprintf(stderr,
"\n[%d] Element Table\n", myrank);
194 for (
int i = 1; i <= nelems; i++ ) {
200 fprintf(stderr,
"}\n");
210 int lnode = 0, lelem = 0;
212 for (
int i = 1; i <= nnode; i++ ) {
218 for (
int i = 1; i <= nelem; i++ ) {
224 OOFEM_LOG_RELEVANT(
"[%d] LB Statistics: local elem=%d local node=%d\n", myrank, lelem, lnode);
238 if ( iproc == myrank ) {
246 for (
int idofman = 1; idofman <= ndofman; idofman++ ) {
272 for (
int ielem = 1; ielem <= nelem; ielem++ ) {
288 OOFEM_LOG_RELEVANT(
"[%d] LoadBalancer:: sending %d migrating elements to %d\n", myrank, nsend, iproc);
308 IntArray _partitions, local_partitions;
317 if ( iproc == myrank ) {
326 if ( !pcbuff->
read(_type) ) {
329 if ( _type.size() == 0 ) {
336 pcbuff->
read(_globnum);
366 pcbuff->
read(_globnum);
386 #ifdef __VERBOSE_PARALLEL 387 fprintf(stderr,
"[%d] received Shared new dofman [%d]\n", myrank, _globnum);
398 OOFEM_ERROR(
"unexpected dof manager mode (%d)", _mode);
407 if ( _type.size() == 0 ) {
419 OOFEM_LOG_RELEVANT(
"[%d] LoadBalancer:: receiving %d migrating elements from %d\n", myrank, nrecv, iproc);
440 for (
int i = 1; i <= ndofman; i++ ) {
489 for (
int i = 1; i <= nelem; i++ ) {
509 int lelem = 0, lnode = 0;
515 for (
int i = 1; i <= nnode; i++ ) {
521 for (
int i = 1; i <= nelem; i++ ) {
531 mySolutionWTime, mySolutionUTime, lelem, lnode);
539 int nproc = emodel->giveNumberOfProcesses();
540 int nodeWeightMode = 0;
542 nodeWeights.resize(nproc);
543 for (
int i = 0; i < nproc; i++ ) {
544 nodeWeights(i) = 1.0 / nproc;
548 if ( nodeWeightMode == 0 ) {
549 staticNodeWeightFlag =
false;
550 }
else if ( nodeWeightMode == 1 ) {
551 staticNodeWeightFlag =
true;
552 }
else if ( nodeWeightMode == 2 ) {
554 if ( nodeWeights.giveSize() != nproc ) {
555 OOFEM_ERROR(
"nodeWeights size not equal to number of processors");
558 staticNodeWeightFlag =
true;
560 OOFEM_ERROR(
"unsupported node weight type, using default value");
561 staticNodeWeightFlag =
false;
int addDofManTransaction(DomainTransactionType, int, DofManager *)
contextIOResultType storeYourself(DataStream &stream) const
Stores array to output stream.
DofManMode
Describes the state of dofmanager after load balancing on the local partition.
int addElementTransaction(DomainTransactionType, int, Element *)
#define _IFT_LoadBalancer_wtp
int giveGlobalNumber() const
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
int unpackMigratingData(Domain *, ProcessCommunicator &pc)
int packAllData(T *ptr, int(T::*packFunc)(ProcessCommunicator &))
Pack all problemCommunicators data to their send buffers.
Shared dofman that remains shared.
int giveGlobalNumber() const
int commitTransactions(DomainTransactionManager *tm)
Commits transactions recorded in transaction manager.
void initGlobalDofManMap(bool forceinit=false)
Initializes global dof man map according to domain dofman list.
virtual const char * giveInputRecordName() const =0
const IntArray * givePartitionList()
Returns partition list of receiver.
EngngModel * giveEngngModel()
Returns engineering model to which receiver is associated.
Undefined (undetermined) state, if assigned means internal error.
virtual void initForNewStep()
Initializes receivers state to new time step.
Abstract base class for all finite elements.
DofManager * createDofManager(const char *name, int num, Domain *domain)
Creates new instance of Dof manager corresponding to given keyword.
Base class for dof managers.
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
int giveNumberOfElements() const
Returns number of elements in domain.
The ProcessCommunicator and corresponding buffers (represented by this class) are separated in order ...
int giveRank()
Returns corresponding rank of associated partition.
#define _IFT_LoadBalancerMonitor_initialnodeweights
void migrateLoad(Domain *d)
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
virtual ~WorkTransferPlugin()
virtual int giveNumberOfDofManagers() const
void setParallelMode(dofManagerParallelMode _mode)
Sets parallel mode of receiver.
void initializeWtp(IntArray &wtp)
WorkTransferPlugin(LoadBalancer *_lb)
Local dofman that became remote (became local on remote partition).
#define OOFEM_LOG_RELEVANT(...)
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
void deleteRemoteElements(Domain *)
Class representing domain transaction manager.
DomainTransactionManager * giveTransactionManager()
Returns domain transaction manager.
Element * giveElement(int n)
Service for accessing particular domain fe element.
virtual int write(const int *data, int count)
Writes count integer values from array pointed by data.
#define _IFT_LoadBalancerMonitor_nodeWeightMode
double getWtime(EngngModelTimerType t)
Returns elapsed wall clock time.
Local dofman that remains local.
ProcessCommunicatorBuff * giveProcessCommunicatorBuff()
Returns communication buffer.
std::vector< std::unique_ptr< WorkTransferPlugin > > wtpList
List of work transfer plugins.
Class representing process communicator for engineering model.
contextIOResultType restoreYourself(DataStream &stream)
Restores array from image on stream.
Abstract base class representing general load balancer.
virtual IntArray * giveDofManPartitions(int idofman)=0
Returns the partition list of given dofmanager after load balancing.
(Dynamic) In this case the communication pattern and the amount of data sent between nodes is not kno...
int packMigratingData(Domain *, ProcessCommunicator &pc)
void setPartitionList(const IntArray *_p)
Sets receiver's partition list.
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
elementParallelMode giveParallelMode() const
Return elementParallelMode of receiver.
void deleteRemoteDofManagers(Domain *)
Element is local, there are no contributions from other domains to this element.
IRResultType
Type defining the return values of InputRecord reading operations.
Class representing communicator.
#define CM_DefinitionGlobal
virtual int giveElementPartition(int ielem)=0
Returns the new partition number assigned to local element after LB.
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
ClassFactory & classFactory
virtual int read(int *data, int count)
Reads count integer values into array pointed by data.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
The Communicator and corresponding buffers (represented by this class) are separated in order to allo...
Abstract base class representing the "problem" under consideration.
the oofem namespace is to define a context or scope in which all oofem names are defined.
DofManager * giveDofManager(int i) const
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Element * createElement(const char *name, int num, Domain *domain)
Creates new instance of element corresponding to given keyword.
virtual DofManMode giveDofManState(int idofman)=0
Returns the label of dofmanager after load balancing.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
DofManager is local, there are no contribution from other domains to this DofManager.
double getUtime(EngngModelTimerType t)
Returns total user time elapsed.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
#define CM_UnknownDictState
void setGlobalNumber(int newNumber)
Sets receiver global number.
Class implements Work Transfer Plugin that introduces extension to efficiently handle nonlocal depend...
void initGlobalElementMap(bool forceinit=false)
EngngModelTimer * giveTimer()
Returns reference to receiver timer (EngngModelTimer).
DofManager is shared by neighboring partitions, it is necessary to sum contributions from all contrib...
dofManagerParallelMode giveParallelMode() const
Return dofManagerParallelMode of receiver.
virtual void printStatistics() const
Print receiver statistics.
int findFirstIndexOf(int value) const
Finds index of first occurrence of given value in array.