33template <
class T,
unsigned Dim,
class Mesh >
43template <
class T,
unsigned Dim,
class Mesh >
53template <
class T,
unsigned Dim,
class Mesh >
63template <
class T,
unsigned Dim,
class Mesh >
72template <
class T,
unsigned Dim,
class Mesh >
90template <
class T,
unsigned Dim,
class Mesh >
96 for (
int i=(
PairList.size() - 1); i >= 0; --i)
103template <
class T,
unsigned Dim,
class Mesh >
124template <
class T,
unsigned Dim,
class Mesh >
133 bool periodicBC[2*
Dim];
134 unsigned numPeriodicBC = 0;
136 for (
unsigned d=0; d<2*
Dim; ++d) {
137 periodicBC[d] = (pBConds[d] == periodicBCond);
138 if (periodicBC[d]) ++numPeriodicBC;
140 if (numPeriodicBC>0) {
167template <
class T,
unsigned Dim,
class Mesh >
178 for (j=0; j < N; ++j)
188 for (localVN = this->
RLayout.begin_iv(); localVN != endLocalVN; ++localVN) {
192 for (d=0; d <
Dim; ++d) {
193 chkDom[d] =
PRegion<T>(chkDom[d].first() - interRad,
194 chkDom[d].last() + interRad);
200 this->
RLayout.touch_range_rdv(chkDom);
202 for ( ; tVN != touchingVN.second; ++tVN) {
205 unsigned vn = ((*tVN).second)->getNode();
226template <
class T,
unsigned Dim,
class Mesh >
228 const bool periodicBC[2*
Dim])
239 for (j=0; j < N; ++j)
252 bool flipBit, activeBit[
Dim], refBit[
Dim];
262 for (localVN = this->
RLayout.begin_iv(); localVN != endLocalVN; ++localVN) {
265 chkDom = (*localVN).second->getDomain();
266 for (d=0; d<
Dim; ++d) {
267 chkDom[d] =
PRegion<T>(chkDom[d].first() - interRad,
268 chkDom[d].last() + interRad);
273 touchingVN = this->
RLayout.touch_range_rdv(chkDom);
274 for (tVN = touchingVN.first; tVN != touchingVN.second; ++tVN) {
277 unsigned vn = ((*tVN).second)->getNode();
286 for (d=0; d<
Dim; ++d) {
287 if (periodicBC[2*d] && chkDom[d].first()<globalDom[d].first()) {
289 offset[d] = globalDom[d].length();
291 numRef = 2 * numRef + 1;
293 else if (periodicBC[2*d+1] && chkDom[d].last()>globalDom[d].last()) {
295 offset[d] = -globalDom[d].length();
297 numRef = 2 * numRef + 1;
301 activeBit[d] =
false;
307 for (j=0; j<numRef; ++j) {
313 while (d<
Dim && !flipBit) {
332 for (d=0; d<
Dim; ++d) {
333 if (refBit[d]) refDom[d] = refDom[d] + offset[d];
338 touchingVN = this->
RLayout.touch_range_rdv(refDom);
339 for (tVN = touchingVN.first; tVN != touchingVN.second; ++tVN) {
342 unsigned vn = ((*tVN).second)->getNode();
351 bool interact =
false;
352 localVN2 = this->
RLayout.begin_iv();
353 while (localVN2 != endLocalVN && !interact) {
354 interact = refDom.
touches((*localVN2).second->getDomain());
379template <
class T,
unsigned Dim,
class Mesh >
386 unsigned LocalNum = PData.getLocalNum();
387 unsigned DestroyNum = PData.getDestroyNum();
393 PData.performDestroy();
394 LocalNum -= DestroyNum;
398 if ( ! this->
RLayout.initialized())
403 apply_bconds(LocalNum, PData.R, this->getBConds(), this->RLayout.getDomain());
419 TotalNum = this->
NodeCount[myN] = LocalNum;
449 int notrecvd = N - 1;
451 while (notrecvd > 0) {
455 int remNodeCount = 0;
457 msg->
get(remNodeCount);
463 TotalNum += remNodeCount;
465 if (remMaxRad > maxrad)
479 PData.setTotalNum(TotalNum);
480 PData.setLocalNum(LocalNum);
489 bool periodicBC[2*
Dim];
490 unsigned numPeriodicBC = 0;
492 for (
unsigned d=0; d<2*
Dim; ++d) {
493 periodicBC[d] = (pBConds[d] == periodicBCond);
494 if (periodicBC[d]) ++numPeriodicBC;
496 if (numPeriodicBC>0) {
519template <
class T,
unsigned Dim,
class Mesh >
535 PData.ghostDestroy(PData.getGhostNum(), 0);
539 unsigned sendnum = 0;
540 for (i=0; i < N; i++)
546 if (sendnum == 0 || LocalNum == 0) {
547 find_pairs(LocalNum, 0, LocalNum,
true, PData);
563 for (i=0; i < N; i++)
625 find_pairs(LocalNum, 0, LocalNum,
true, PData);
654template <
class T,
unsigned Dim,
class Mesh >
658 const bool periodicBC[2*
Dim])
672 PData.ghostDestroy(PData.getGhostNum(), 0);
677 unsigned sendnum = 0;
678 for (i=0; i < N; i++)
684 if (sendnum == 0 || LocalNum == 0) {
685 find_pairs(LocalNum, 0, LocalNum,
true, PData);
699 bool flipBit, activeBit[
Dim], refBit[
Dim];
713 for (i=0; i < N; i++)
721 for (i=0; i < LocalNum; ++i) {
728 for (j=0; j < (
unsigned int)
Dim; ++j)
729 pLoc[j] =
PRegion<T>(PData.R[i][j] - interRad,
730 PData.R[i][j] + interRad);
733 touchingVN = this->
RLayout.touch_range_rdv(pLoc);
734 for (tVNit = touchingVN.first; tVNit != touchingVN.second; ++tVNit) {
736 unsigned node = tVN->
getNode();
741 ERRORMSG(
"ParticleInteractLayout: Cannot send ghost " << i);
742 ERRORMSG(
" to node " << node <<
" ... skipping." <<
endl);
745 PData.ghostPutMessage(*(this->
SwapMsgList[node]), 1, i);
753 for (d=0; d<
Dim; ++d) {
754 if (periodicBC[2*d] && pLoc[d].first()<globalDom[d].first()) {
756 offset[d] = globalDom[d].length();
758 numRef = 2 * numRef + 1;
760 else if (periodicBC[2*d+1] && pLoc[d].last()>globalDom[d].last()) {
762 offset[d] = -globalDom[d].length();
764 numRef = 2 * numRef + 1;
768 activeBit[d] =
false;
773 if (numRef>0) savePos = PData.R[i];
776 for (j=0; j<numRef; ++j) {
779 PData.R[i] = savePos;
783 while (d<
Dim && !flipBit) {
802 for (d=0; d<
Dim; ++d) {
804 refLoc[d] = refLoc[d] + offset[d];
805 PData.R[i][d] = PData.R[i][d] + offset[d];
813 touchingVN = this->
RLayout.touch_range_rdv(refLoc);
814 for (tVNit = touchingVN.first; tVNit != touchingVN.second; ++tVNit) {
816 unsigned node = tVN->
getNode();
821 ERRORMSG(
"ParticleInteractLayout: Cannot send ghost " << i);
822 ERRORMSG(
" to node " << node <<
" ... skipping." <<
endl);
825 PData.ghostPutMessage(*(this->
SwapMsgList[node]), 1, i);
833 bool interact =
false;
834 localVN = this->
RLayout.begin_iv();
835 while (localVN != endLocalVN && !interact) {
836 interact = refLoc.
touches((*localVN).second->getDomain());
840 PData.ghostPutMessage(*(this->
SwapMsgList[pe]), 1, i);
844 if (numRef>0) PData.R[i] = savePos;
850 for (i=0; i < N; ++i) {
853 PData.ghostPutMessage(*(this->
SwapMsgList[i]), (
unsigned)0, (
unsigned)0);
861 find_pairs(LocalNum, 0, LocalNum,
true, PData);
864 while (sendnum-- > 0) {
866 unsigned oldGN = PData.getGhostNum();
869 while (PData.ghostGetMessage(*recmsg, node) > 0);
873 find_pairs(LocalNum, LocalNum + oldGN, LocalNum + PData.getGhostNum(),
882template <
class T,
unsigned Dim,
class Mesh >
884 const unsigned a1,
const unsigned a2,
const bool initLists,
894 for (i=0; i < vlen; ++i)
899 int newamt = LocalNum -
PairList.size();
901 for (
int k=0; k < newamt; ++k)
902 PairList.push_back(
new std::vector<pair_t>);
907 if (a2 <= a1)
return;
910 for (i=0; i < LocalNum; ++i) {
915 j = (a1 > i ? a1 : i + 1);
919 for (; j < LocalNum; ++j) {
927 T sep2 =
dot(rsep, rsep);
931 if (sep2 < intrad2) {
939 for (; j < a2; ++j) {
947 T sep2 =
dot(rsep, rsep);
952 if (sep2 < intrad2) {
962template <
class T,
unsigned Dim,
class Mesh >
965 out <<
"ParticleInteractLayout, with particle distribution:\n ";
968 out <<
"\nInteractLayout decomposition = " << L.
getLayout();
977template <
class T,
unsigned Dim,
class Mesh >
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
#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 ParticleInteractLayout< 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)
ParticleInteractLayout(FieldLayout< Dim > &)
void find_pairs(const unsigned LocalNum, const unsigned a1, const unsigned a2, const bool initLists, IpplParticleBase< ParticleInteractLayout< T, Dim, Mesh > > &PData)
~ParticleInteractLayout()
T getMaxLocalInteractionRadius()
ParticleLayout< T, Dim >::SingleParticlePos_t SingleParticlePos_t
T getMaxInteractionRadius()
std::vector< std::vector< pair_t > * > PairList
unsigned InteractionNodes
void setMaxInteractionRadius(T maxval)
void rebuild_interaction_data()
virtual void Repartition(UserList *)
ParticleInterRadius_t * InterRadiusArray
void update(IpplParticleBase< ParticleInteractLayout< T, Dim, Mesh > > &p, const ParticleAttrib< char > *canSwap=0)
T getInteractionRadius(unsigned i)
void swap_ghost_particles(unsigned, IpplParticleBase< ParticleInteractLayout< T, Dim, Mesh > > &)
std::vector< pair_t >::iterator pair_iterator
void getPairlist(unsigned, pair_iterator &, pair_iterator &, IpplParticleBase< ParticleInteractLayout< T, Dim, Mesh > > &)
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