50#define NonlocalMaterialWTP_DEBUG_PRINT 0
57NonlocalMaterialWTP :: giveElementNonlocalDepArry(
IntArray &answer,
Domain *d,
int num)
59 std :: set< int >relems;
60 std :: set< int > :: const_iterator relemsIter;
68 ielem->
ipEvaluator(
this, & NonlocalMaterialWTP :: giveNonlocalDepArryElementPlugin, relems);
72 answer.
resize( relems.size() );
74 for (
int relem: relems ) {
75 answer.
at(_i++) = relem;
84NonlocalMaterialWTP :: giveNonlocalDepArryElementPlugin(
GaussPoint *gp, std :: set< int > &s)
92 auto lir = interface->giveIntegrationDomainList();
94 for (
auto &intdom: *lir ) {
95 remoteElemNum = ( intdom.nearGp )->giveElement()->giveGlobalNumber();
96 s.insert(remoteElemNum);
109NonlocalMaterialWTP :: init(
Domain *domain)
121 for ( ie = 1; ie <= nelem; ie++ ) {
130 com.
packAllData(
this, domain, & NonlocalMaterialWTP :: packMigratingElementDependencies);
132 com.
unpackAllData(
this, domain, & NonlocalMaterialWTP :: unpackMigratingElementDependencies);
143NonlocalMaterialWTP :: migrate()
145 Domain *domain = this->lb->giveDomain();
160 std :: set< int >domainElementDepSet;
162 for ( ie = 1; ie <= nelems; ie++ ) {
168 for ( _i = 1; _i <= _size; _i++ ) {
169 domainElementDepSet.insert( iedep.
at(_i) );
172#if NonlocalMaterialWTP_DEBUG_PRINT
173 fprintf(stderr,
"[%d] element %d dependency:", myrank, _globnum);
174 for ( _i = 1; _i <= _size; _i++ ) {
175 fprintf( stderr,
"%d ", iedep.
at(_i) );
178 fprintf(stderr,
"\n");
183#if NonlocalMaterialWTP_DEBUG_PRINT
184 fprintf(stderr,
"[%d] nonlocal domain dependency:", myrank);
185 for (
int eldep: domainElementDepSet ) {
186 fprintf(stderr,
"%d ", eldep);
189 fprintf(stderr,
"\n");
193 for ( _i = 1; _i <= nelems; _i++ ) {
200#if NonlocalMaterialWTP_DEBUG_PRINT
201 fprintf(stderr,
"[%d] remote elem wish list:", myrank);
202 for (
int eldep: domainElementDepSet ) {
203 fprintf(stderr,
"%d ", eldep);
206 fprintf(stderr,
"\n");
210 _locsize = domainElementDepSet.size() + 1;
211 result = MPI_Allreduce(& _locsize, & _globsize, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
212 if ( result != MPI_SUCCESS ) {
213 OOFEM_ERROR(
"MPI_Allreduce to determine broadcast buffer size failed");
218 std :: set< int >remoteWishSet;
221 for ( i = 0; i < nproc; i++ ) {
226 commBuff.
write(_locsize);
227 for (
int eldep: domainElementDepSet ) {
228 commBuff.
write(eldep);
231 result = commBuff.
bcast(i);
234 remoteWishSet.clear();
235 result = commBuff.
bcast(i);
237 commBuff.
read(_size);
238 for ( _i = 1; _i < _size; _i++ ) {
240 remoteWishSet.insert(_val);
244 for ( _i = 1; _i <= nelems; _i++ ) {
247 if ( remoteWishSet.find( elem->
giveGlobalNumber() ) != remoteWishSet.end() ) {
256#if NonlocalMaterialWTP_DEBUG_PRINT
257 for ( i = 0; i < nproc; i++ ) {
259 fprintf(stderr,
"[%d] elements scheduled for mirroring at [%d]:",
265 fprintf(stderr,
"\n");
274 com.
packAllData(
this, domain, & NonlocalMaterialWTP :: packRemoteElements);
276 com.
unpackAllData(
this, domain, & NonlocalMaterialWTP :: unpackRemoteElements);
281#ifdef __VERBOSE_PARALLEL
288NonlocalMaterialWTP :: update()
306 if ( iproc == myrank ) {
317 for ( ielem = 1; ielem <= nelem; ielem++ ) {
320 ( lb->giveElementPartition(ielem) == iproc ) ) {
324 pcbuff->
write(_globnum);
341 if ( iproc == myrank ) {
350 pcbuff->
read(_globnum);
369 if ( iproc == myrank ) {
379 std :: set< int >nodesToSend;
384 for (
int i = 1; i <= nnodes; i++ ) {
394 for (
int in: nodesToSend ) {
425 if ( iproc == myrank ) {
435 if ( _type.size() == 0 ) {
438 auto dofman =
classFactory.createDofManager(_type.c_str(), 0, d);
445 dofman->giveGlobalNumber(),
453 _partitions.
at(1) = iproc;
456 if ( _type.size() == 0 ) {
460 auto elem =
classFactory.createElement(_type.c_str(), 0, d).release();
463 elem->setPartitionList(_partitions);
465 elem->giveGlobalNumber(), elem);
482NonlocalMaterialWTP :: fastRebuildNonlocalTables()
484 Domain *d = lb->giveDomain();
490 for ( ie = 1; ie <= nelem; ie++ ) {
497 localElementDep.
resize(n);
498 for ( i = 1; i <= n; i++ ) {
502 elem->
ipEvaluator(
this, & NonlocalMaterialWTP :: fastElementIPNonlocTableUpdater, localElementDep);
int givePackSizeOfInt(std::size_t count) override
int unpackAllData(T *ptr, int(T ::*unpackFunc)(ProcessCommunicator &))
int initExchange(int tag)
int packAllData(T *ptr, int(T ::*packFunc)(ProcessCommunicator &))
int giveGlobalNumber() const
const char * giveInputRecordName() const override
bool isShared()
Returns true if receiver is shared.
void saveContext(DataStream &stream, ContextMode mode) override
const IntArray * givePartitionList()
dofManagerParallelMode giveParallelMode() const
int addDofManTransaction(DomainTransactionType, int, DofManager *)
int addElementTransaction(DomainTransactionType, int, Element *)
DomainTransactionManager * giveTransactionManager()
int commitTransactions(DomainTransactionManager *tm)
int dofmanGlobal2Local(int _globnum)
int giveNumberOfElements() const
Returns number of elements in domain.
DofManager * giveDofManager(int n)
Element * giveElement(int n)
EngngModel * giveEngngModel()
int elementGlobal2Local(int _globnum)
int giveGlobalNumber() const
virtual Material * giveMaterial()
void saveContext(DataStream &stream, ContextMode mode) override
elementParallelMode giveParallelMode() const
void ipEvaluator(T *src, void(T ::*f)(GaussPoint *gp))
Integration point evaluator, loops over receiver IP's and calls given function (passed as f parameter...
virtual int giveNumberOfDofManagers() const
DofManager * giveDofManager(int i) const
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1).
virtual Interface * giveInterface(InterfaceType t)
virtual const char * giveInputRecordName() const =0
IntegrationPointStatus * giveMaterialStatus(IntegrationPointStatusIDType key=IPSID_Default)
Element * giveElement()
Returns corresponding element to receiver.
bool contains(int value) const
void rebuildNonlocalPointTable(GaussPoint *gp, IntArray *contributingElems) const
void fastRebuildNonlocalTables()
void giveElementNonlocalDepArry(IntArray &answer, Domain *d, int num)
std ::map< int, IntArray > nonlocElementDependencyMap
std ::vector< std ::list< int > > toSendList
int read(int *data, std::size_t count) override
Reads count integer values into array pointed by data.
int write(const int *data, std::size_t count) override
Writes count integer values from array pointed by data.
ProcessCommunicatorBuff * giveProcessCommunicatorBuff()
Returns communication buffer.
int read(int *dest, std::size_t n) override
Reads count integer values into array pointed by data.
int write(const int *src, std::size_t n) override
Writes count integer values from array pointed by data.
int resize(std::size_t newSize) override
int bcast(int root) override
#define CM_UnknownDictState
#define CM_DefinitionGlobal
@ Element_remote
Element in active domain is only mirror of some remote element.
@ Element_local
Element is local, there are no contributions from other domains to this element.
ClassFactory & classFactory
@ NonlocalMaterialStatusExtensionInterfaceType
@ NonlocalMaterialExtensionInterfaceType
#define MIGRATE_NONLOCALDEP_TAG
#define NonlocalMaterialWTP_END_DATA
#define MIGRATE_REMOTE_ELEMENTS_TAG
#define VERBOSEPARALLEL_PRINT(service, str, rank)