48template <
class T,
unsigned Dim,
class Mesh >
58template <
class T,
unsigned Dim,
class Mesh >
68template <
class T,
unsigned Dim,
class Mesh >
78template <
class T,
unsigned Dim,
class Mesh >
87template <
class T,
unsigned Dim,
class Mesh >
104template <
class T,
unsigned Dim,
class Mesh >
115template <
class T,
unsigned Dim,
class Mesh >
127template <
class T,
unsigned Dim,
class Mesh >
137 bool periodicBC[2*
Dim];
138 unsigned numPeriodicBC = 0;
140 for (
unsigned d=0; d<2*
Dim; ++d) {
141 periodicBC[d] = (pBConds[d] == periodicBCond);
142 if (periodicBC[d]) ++numPeriodicBC;
144 if (numPeriodicBC>0) {
168template <
class T,
unsigned Dim,
class Mesh >
180 for (j=0; j < N; ++j)
190 for (localVN = this->
RLayout.begin_iv(); localVN != endLocalVN; ++localVN) {
194 for (d=0; d <
Dim; ++d) {
195 chkDom[d] =
PRegion<T>(chkDom[d].first() - interRad,
196 chkDom[d].last() + interRad);
202 this->
RLayout.touch_range_rdv(chkDom);
204 for ( ; tVN != touchingVN.second; ++tVN) {
207 unsigned vn = ((*tVN).second)->getNode();
228template <
class T,
unsigned Dim,
class Mesh >
230 const bool periodicBC[2*
Dim])
242 for (j=0; j < N; ++j)
255 bool flipBit, activeBit[
Dim], refBit[
Dim];
265 for (localVN = this->
RLayout.begin_iv(); localVN != endLocalVN; ++localVN) {
268 chkDom = (*localVN).second->getDomain();
269 for (d=0; d<
Dim; ++d) {
270 chkDom[d] =
PRegion<T>(chkDom[d].first() - interRad,
271 chkDom[d].last() + interRad);
276 touchingVN = this->
RLayout.touch_range_rdv(chkDom);
277 for (tVN = touchingVN.first; tVN != touchingVN.second; ++tVN) {
280 unsigned vn = ((*tVN).second)->getNode();
289 for (d=0; d<
Dim; ++d) {
290 if (periodicBC[2*d] && chkDom[d].first()<globalDom[d].first()) {
292 offset[d] = globalDom[d].length();
294 numRef = 2 * numRef + 1;
296 else if (periodicBC[2*d+1] && chkDom[d].last()>globalDom[d].last()) {
298 offset[d] = -globalDom[d].length();
300 numRef = 2 * numRef + 1;
304 activeBit[d] =
false;
310 for (j=0; j<numRef; ++j) {
316 while (d<
Dim && !flipBit) {
335 for (d=0; d<
Dim; ++d) {
336 if (refBit[d]) refDom[d] = refDom[d] + offset[d];
341 touchingVN = this->
RLayout.touch_range_rdv(refDom);
342 for (tVN = touchingVN.first; tVN != touchingVN.second; ++tVN) {
345 unsigned vn = ((*tVN).second)->getNode();
354 bool interact =
false;
355 localVN2 = this->
RLayout.begin_iv();
356 while (localVN2 != endLocalVN && !interact) {
357 interact = refDom.
touches((*localVN2).second->getDomain());
382template <
class T,
unsigned Dim,
class Mesh >
389 unsigned LocalNum = PData.getLocalNum();
390 unsigned DestroyNum = PData.getDestroyNum();
398 PData.performDestroy();
399 LocalNum -= DestroyNum;
403 if ( ! this->
RLayout.initialized())
408 this->
apply_bconds(LocalNum, PData.R, this->getBConds(), this->RLayout.getDomain());
424 TotalNum = this->
NodeCount[myN] = LocalNum;
454 int notrecvd = N - 1;
456 while (notrecvd > 0) {
460 int remNodeCount = 0;
462 msg->
get(remNodeCount);
468 TotalNum += remNodeCount;
470 if (remMaxRad > maxrad)
484 PData.setTotalNum(TotalNum);
485 PData.setLocalNum(LocalNum);
494 bool periodicBC[2*
Dim];
495 unsigned numPeriodicBC = 0;
497 for (
unsigned d=0; d<2*
Dim; ++d) {
498 periodicBC[d] = (pBConds[d] == periodicBCond);
499 if (periodicBC[d]) ++numPeriodicBC;
501 if (numPeriodicBC>0) {
525template <
class T,
unsigned Dim,
class Mesh >
541 PData.ghostDestroy(PData.getGhostNum(), 0);
545 unsigned sendnum = 0;
546 for (i=0; i < N; i++)
552 if (sendnum == 0 || LocalNum == 0) {
568 for (i=0; i < N; i++)
656template <
class T,
unsigned Dim,
class Mesh >
660 const bool periodicBC[2*
Dim])
675 PData.ghostDestroy(PData.getGhostNum(), 0);
680 unsigned sendnum = 0;
681 for (i=0; i < N; i++)
686 if (sendnum == 0 || LocalNum == 0)
702 bool flipBit, activeBit[
Dim], refBit[
Dim];
716 for (i=0; i < N; i++)
724 for (i=0; i < LocalNum; ++i) {
731 for (j=0; j <
Dim; ++j)
732 pLoc[j] =
PRegion<T>(PData.R[i][j] - interRad,
733 PData.R[i][j] + interRad);
737 touchingVN = this->
RLayout.touch_range_rdv(pLoc);
738 for (tVNit = touchingVN.first; tVNit != touchingVN.second; ++tVNit) {
740 unsigned node = tVN->
getNode();
745 ERRORMSG(
"ParticleCashedLayout: Cannot send ghost " << i);
746 ERRORMSG(
" to node " << node <<
" ... skipping." <<
endl);
749 PData.ghostPutMessage(*(this->
SwapMsgList[node]), 1, i);
757 for (d=0; d<
Dim; ++d) {
758 if (periodicBC[2*d] && pLoc[d].first()<globalDom[d].first()) {
760 offset[d] = globalDom[d].length();
762 numRef = 2 * numRef + 1;
764 else if (periodicBC[2*d+1] && pLoc[d].last()>globalDom[d].last()) {
766 offset[d] = -globalDom[d].length();
768 numRef = 2 * numRef + 1;
772 activeBit[d] =
false;
777 if (numRef>0) savePos = PData.R[i];
780 for (j=0; j<numRef; ++j) {
783 PData.R[i] = savePos;
787 while (d<
Dim && !flipBit) {
806 for (d=0; d<
Dim; ++d) {
808 refLoc[d] = refLoc[d] + offset[d];
809 PData.R[i][d] = PData.R[i][d] + offset[d];
817 touchingVN = this->
RLayout.touch_range_rdv(refLoc);
818 for (tVNit = touchingVN.first; tVNit != touchingVN.second; ++tVNit) {
820 unsigned node = tVN->
getNode();
825 ERRORMSG(
"ParticleCashedLayout: Cannot send ghost " << i);
826 ERRORMSG(
" to node " << node <<
" ... skipping." <<
endl);
829 PData.ghostPutMessage(*(this->
SwapMsgList[node]), 1, i);
838 bool interact =
false;
839 localVN = this->
RLayout.begin_iv();
840 while (localVN != endLocalVN && !interact) {
841 interact = refLoc.
touches((*localVN).second->getDomain());
845 PData.ghostPutMessage(*(this->
SwapMsgList[pe]), 1, i);
849 if (numRef>0) PData.R[i] = savePos;
855 for (i=0; i < N; ++i) {
858 PData.ghostPutMessage(*(this->
SwapMsgList[i]), (
unsigned)0, (
unsigned)0);
866 while (sendnum-- > 0) {
870 while (PData.ghostGetMessage(*recmsg, node) > 0);
880template <
class T,
unsigned Dim,
class Mesh >
883 out <<
"ParticleCashedLayout, with particle distribution:\n ";
886 out <<
"\nInteractLayout decomposition = " << L.
getLayout();
895template <
class T,
unsigned Dim,
class Mesh >
#define P_SPATIAL_GHOST_TAG
#define P_SPATIAL_RETURN_TAG
#define P_SPATIAL_LAYOUT_TAG
T ParticlePeriodicBCond(const T t, const T minval, const T maxval)
std::ostream & operator<<(std::ostream &out, const ParticleCashedLayout< T, Dim, Mesh > &L)
Inform & endl(Inform &inf)
Message & put(const T &val)
Message & get(const T &cval)
int getNodeCount(unsigned i) const
void rebuild_layout(size_t haveLocal, PB &PData)
RegionLayout< T, Dim, Mesh > & getLayout()
RegionLayout< T, Dim, Mesh > RLayout
size_t swap_particles(size_t LocalNum, PB &PData)
ParticleSpatialLayout(FieldLayout< Dim > &)
T(* ParticleBCond)(const T, const T, const T)
unsigned InteractionNodes
void getCashedParticles(IpplParticleBase< ParticleCashedLayout< T, Dim, Mesh > > &)
T getMaxInteractionRadius()
void swap_ghost_particles(unsigned, IpplParticleBase< ParticleCashedLayout< T, Dim, Mesh > > &)
void update(IpplParticleBase< ParticleCashedLayout< T, Dim, Mesh > > &p, const ParticleAttrib< char > *canSwap=0)
ParticleCashedLayout(FieldLayout< Dim > &)
virtual void Repartition(UserList *)
ParticleLayout< T, Dim >::SingleParticlePos_t SingleParticlePos_t
T getMaxLocalInteractionRadius()
void setMaxInteractionRadius(T maxval)
void rebuild_interaction_data()
void apply_bconds(unsigned n, PPT &R, const ParticleBConds< T, Dim > &bcs, const NDI &nr)
ParticleBConds< T, Dim > & getBConds()
bool getUpdateFlag(UpdateFlags f) const
bool touches(const NDRegion< T, Dim > &nr) const
ac_id_vnodes::iterator iterator_iv
ac_domain_vnodes::touch_iterator touch_iterator_dv
std::pair< touch_iterator_dv, touch_iterator_dv > touch_range_dv
static Communicate * Comm
ID_t getUserListID() const