本文整理汇总了C++中Particles::setVerletList方法的典型用法代码示例。如果您正苦于以下问题:C++ Particles::setVerletList方法的具体用法?C++ Particles::setVerletList怎么用?C++ Particles::setVerletList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Particles
的用法示例。
在下文中一共展示了Particles::setVerletList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateVerletList
void updateVerletList(const string &verletStringId,
Particles & particles,
Grid & grid,
double radius)
{
double radiusSquared = radius*radius;
int verletId = particles.getVerletId(verletStringId);
const unordered_map<int, GridPoint*> &gridpoints = grid.gridpoints();
const mat & R = particles.r();
const vector<int> &mygridPoints = grid.myGridPoints();
particles.clearVerletList(verletId);
#ifdef USE_OPENMP
#pragma omp parallel for
#endif
for(int i=0; i<mygridPoints.size(); i++)
{
double dx, dy, dz;
int gridId = mygridPoints.at(i);
const GridPoint & gridPoint = *gridpoints.at(gridId);
for(const pair<int, int> & idCol_i:gridPoint.particles())
{
int id_i = idCol_i.first;
vector<int> verletList;
const vec & r_i = R.col(idCol_i.second);
for(const pair<int, int> & idCol_j:gridPoint.particles())
{
int id_j = idCol_j.first;
if(id_i == id_j)
continue;
const vec & r_j = R.col(idCol_j.second);
dx = r_i(0) - r_j(0);
dy = r_i(1) - r_j(1);
dz = r_i(2) - r_j(2);
double drSquared = dx*dx + dy*dy + dz*dz;
if(drSquared < radiusSquared)
{
verletList.push_back(id_j);
}
}
// Neighbouring cells
const vector<GridPoint*> & neighbours = gridPoint.neighbours();
for(const GridPoint *neighbour:neighbours)
{
for(const pair<int, int> & idCol_j:neighbour->particles())
{
const vec & r_j = R.col(idCol_j.second);
dx = r_i(0) - r_j(0);
dy = r_i(1) - r_j(1);
dz = r_i(2) - r_j(2);
double drSquared = dx*dx + dy*dy + dz*dz;
if(drSquared < radiusSquared)
{
verletList.push_back(idCol_j.first);
}
}
}
#ifdef USE_OPENMP
#pragma omp critical
{
particles.setVerletList(id_i, verletList, verletId);
}
#else
particles.setVerletList(id_i, verletList, verletId);
#endif
}
}
}