1#ifndef BOX_PARTICLE_CACHING_POLICY
2#define BOX_PARTICLE_CACHING_POLICY
22template<
class T,
unsigned Dim,
class Mesh>
61 for (
unsigned d=0; d<2*
Dim; ++d)
63 if(pBConds[d] == periodicBCond)
71 for (;localVN!=localVNend;++localVN)
78 for(
unsigned int d = 0;d<
Dim;++d)
85 std::fill(offset.
begin(), offset.
end(), 0);
88 for(
unsigned int d = 0;d<
Dim;++d)
90 if(
periodic[2*d] && (exdom[d].first() < globalDomain[d].first()))
92 offset[d] = globalDomain[d].length();
94 else if(
periodic[2*d+1] && (exdom[d].last() > globalDomain[d].last()))
96 offset[d] = -globalDomain[d].length();
101 std::fill(onoff, onoff+
Dim, 0);
106 for(
unsigned int d = 0;d<
Dim;++d)
119 for(i = touchRange.first; i != touchRange.second; ++i)
121 int node = (*i).second->getNode();
126 for(
unsigned int d = 0;d<
Dim;++d)
128 dom[d] =
PRegion<T>(dom[d].first() - onoff[d]*offset[d],
129 dom[d].last() - onoff[d]*offset[d]);
130 tmpoffset[d] = onoff[d]*offset[d];
133 regions[node].push_back(std::make_pair(dom,tmpoffset));
143 if((onoff[j] = !onoff[j]))
162 typedef typename std::map<unsigned, std::list<std::pair<NDRegion<T,Dim>,
Offset_t> > >
::iterator m_iterator;
165 PData.ghostDestroy(PData.getGhostNum(), 0);
171 std::vector<MPI_Request> requests;
172 std::vector<MsgBuffer*> buffers;
180 std::vector<size_t> sendlist;
181 std::vector<Offset_t> offsetlist;
186 for (
unsigned int i = 0;i < PData.getLocalNum();++i)
189 for (
unsigned int d = 0;d <
Dim;++d)
195 sendlist.push_back(i);
196 offsetlist.push_back((*li).second);
206 requests.push_back(
Ippl::Comm->raw_isend(0, 0, node, tag));
212 PData.writeMsgBufferWithOffsets(msgbuf, sendlist,offsetlist);
215 requests.push_back(request);
216 buffers.push_back(msgbuf);
223 Format *format = PData.getFormat();
232 MsgBuffer recvbuf(format, buffer, bufsize);
233 PData.readGhostMsgBuffer(&recvbuf, node);
238 MPI_Request* requests_ptr = requests.empty()?
static_cast<MPI_Request*
>(0): &(requests[0]);
239 MPI_Waitall(requests.size(), requests_ptr, MPI_STATUSES_IGNORE);
240 for (
unsigned int j = 0; j<buffers.size(); ++j)
242 delete buffers[j]->getFormat();
#define P_SPATIAL_GHOST_TAG
T ParticlePeriodicBCond(const T t, const T minval, const T maxval)
std::string::iterator iterator
virtual MPI_Request raw_isend(void *, int, int, int)
virtual int raw_probe_receive(char *&, int &, int &)
int next_tag(int t, int s=1000)
std::map< unsigned, std::list< std::pair< NDRegion< T, Dim >, Offset_t > > > regions
BoxParticleCachingPolicy()
void updateCacheInformation(ParticleSpatialLayout< T, Dim, Mesh, C > &PLayout)
void updateGhostParticles(IpplParticleBase< ParticleSpatialLayout< T, Dim, Mesh, C > > &PData, ParticleSpatialLayout< T, Dim, Mesh, C > &)
void setCacheDimension(int d, T length)
void setAllCacheDimensions(T length)
~BoxParticleCachingPolicy()
T operator[](int i) const
ParticleBConds< T, Dim > & getBConds()
bool getUpdateFlag(UpdateFlags f) const
bool touches(const NDRegion< T, Dim > &nr) const
touch_range_dv touch_range_rdv(const NDRegion< T, Dim > &domain)
ac_id_vnodes::iterator iterator_iv
const NDRegion< T, Dim > & getDomain() const
std::pair< touch_iterator_dv, touch_iterator_dv > touch_range_dv
static Communicate * Comm