| 50 |
|
|
| 51 |
|
ForceMatrixDecomposition::ForceMatrixDecomposition(SimInfo* info, InteractionManager* iMan) : |
| 52 |
|
ForceDecomposition(info, iMan) { |
| 53 |
– |
|
| 53 |
|
// In a parallel computation, row and colum scans must visit all |
| 54 |
|
// surrounding cells (not just the 14 upper triangular blocks that |
| 55 |
|
// are used when the processor can see all pairs) |
| 322 |
|
} |
| 323 |
|
} |
| 324 |
|
} |
| 325 |
+ |
} |
| 326 |
+ |
|
| 327 |
+ |
Globals* simParams_ = info_->getSimParams(); |
| 328 |
+ |
if (simParams_->haveNeighborListReorderFreq()) |
| 329 |
+ |
{ |
| 330 |
+ |
neighborListReorderFreq = simParams_->getNeighborListReorderFreq(); |
| 331 |
+ |
} else |
| 332 |
+ |
{ |
| 333 |
+ |
neighborListReorderFreq = 0; |
| 334 |
|
} |
| 335 |
+ |
reorderFreqCounter = 1; |
| 336 |
|
|
| 337 |
|
createGtypeCutoffMap(); |
| 338 |
|
|
| 805 |
|
pairwisePot += pot_temp[ii]; |
| 806 |
|
#endif |
| 807 |
|
|
| 808 |
< |
cerr << "pairwisePot = " << pairwisePot << "\n"; |
| 808 |
> |
// cerr << "pairwisePot = " << pairwisePot << "\n"; |
| 809 |
|
} |
| 810 |
|
|
| 811 |
|
int ForceMatrixDecomposition::getNAtomsInRow() { |
| 856 |
|
Vector3d d; |
| 857 |
|
|
| 858 |
|
d = snap_->cgData.position[cg2->getLocalIndex()] - snap_->cgData.position[cg1->getLocalIndex()]; |
| 859 |
< |
/* cerr << "cg1_gid = " << cg1->getGlobalIndex() << "\tcg1_lid = " << cg1->getLocalIndex() << "\tcg1p = " |
| 860 |
< |
<< snap_->cgData.position[cg1->getLocalIndex()] << "\n"; |
| 861 |
< |
cerr << "cg2_gid = " << cg2->getGlobalIndex() << "\tcg2_lid = " << cg2->getLocalIndex() << "\tcg2p = " |
| 862 |
< |
<< snap_->cgData.position[cg2->getLocalIndex()] << "\n";*/ |
| 859 |
> |
/* cerr << "cg1_gid = " << cg1->getGlobalIndex() << "\tcg1_lid = " << cg1->getLocalIndex() << "\tcg1p = " |
| 860 |
> |
<< snap_->cgData.position[cg1->getLocalIndex()] << "\n"; |
| 861 |
> |
cerr << "cg2_gid = " << cg2->getGlobalIndex() << "\tcg2_lid = " << cg2->getLocalIndex() << "\tcg2p = " |
| 862 |
> |
<< snap_->cgData.position[cg2->getLocalIndex()] << "\n";*/ |
| 863 |
|
|
| 864 |
|
snap_->wrapVector(d); |
| 865 |
|
return d; |
| 933 |
|
bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2) { |
| 934 |
|
int unique_id_1, unique_id_2; |
| 935 |
|
|
| 936 |
< |
// cerr << "sap with atom1, atom2 =\t" << atom1 << "\t" << atom2 << "\n"; |
| 936 |
> |
// cerr << "sap with atom1, atom2 =\t" << atom1 << "\t" << atom2 << "\n"; |
| 937 |
|
#ifdef IS_MPI |
| 938 |
|
// in MPI, we have to look up the unique IDs for each atom |
| 939 |
|
unique_id_1 = AtomRowToGlobal[atom1]; |
| 1153 |
|
tmp[i] = snap_->cgData.position[i]; |
| 1154 |
|
} |
| 1155 |
|
|
| 1156 |
< |
vector<int> mapPos = vector<int>(nGroups_); |
| 1156 |
> |
vector<int> mapPos = vector<int> (nGroups_); |
| 1157 |
|
for (int i = 0; i < nGroups_; ++i) |
| 1158 |
|
{ |
| 1159 |
|
snap_->cgData.position[i] = tmp[order[i]]; |
| 1173 |
|
} |
| 1174 |
|
} |
| 1175 |
|
|
| 1176 |
< |
/* if (info_->getNCutoffGroups() > 0) |
| 1177 |
< |
{ |
| 1178 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) |
| 1179 |
< |
{ |
| 1180 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) |
| 1181 |
< |
{ |
| 1182 |
< |
printf("gbI:%d locI:%d x:%f y:%f z:%f\n", cg->getGlobalIndex(), cg->getLocalIndex(), |
| 1183 |
< |
cgConfig->position[cg->getLocalIndex()].x(), cgConfig->position[cg->getLocalIndex()].y(), |
| 1184 |
< |
cgConfig->position[cg->getLocalIndex()].z()); |
| 1185 |
< |
} |
| 1186 |
< |
} |
| 1187 |
< |
} else |
| 1188 |
< |
{ |
| 1189 |
< |
// center of mass of the group is the same as position of the atom |
| 1190 |
< |
// if cutoff group does not exist |
| 1191 |
< |
printf("ERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); |
| 1192 |
< |
// cgConfig->position = config->position; |
| 1193 |
< |
}*/ |
| 1176 |
> |
/* if (info_->getNCutoffGroups() > 0) |
| 1177 |
> |
{ |
| 1178 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) |
| 1179 |
> |
{ |
| 1180 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) |
| 1181 |
> |
{ |
| 1182 |
> |
printf("gbI:%d locI:%d x:%f y:%f z:%f\n", cg->getGlobalIndex(), cg->getLocalIndex(), |
| 1183 |
> |
cgConfig->position[cg->getLocalIndex()].x(), cgConfig->position[cg->getLocalIndex()].y(), |
| 1184 |
> |
cgConfig->position[cg->getLocalIndex()].z()); |
| 1185 |
> |
} |
| 1186 |
> |
} |
| 1187 |
> |
} else |
| 1188 |
> |
{ |
| 1189 |
> |
// center of mass of the group is the same as position of the atom |
| 1190 |
> |
// if cutoff group does not exist |
| 1191 |
> |
printf("ERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); |
| 1192 |
> |
// cgConfig->position = config->position; |
| 1193 |
> |
}*/ |
| 1194 |
|
} |
| 1195 |
|
|
| 1196 |
|
void ForceMatrixDecomposition::reorderGroupList(vector<int> &order) { |
| 1209 |
|
|
| 1210 |
|
void ForceMatrixDecomposition::reorderMemory(vector<vector<CutoffGroup *> > &H_c_l) { |
| 1211 |
|
int n = 0; |
| 1212 |
< |
// printf("Reorder memory time:%f!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", |
| 1213 |
< |
// info_->getSnapshotManager()->getCurrentSnapshot()->getTime()); |
| 1212 |
> |
// printf("Reorder memory time:%f!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", |
| 1213 |
> |
// info_->getSnapshotManager()->getCurrentSnapshot()->getTime()); |
| 1214 |
|
|
| 1215 |
|
/* record the reordered atom indices */ |
| 1216 |
|
vector<int> k = vector<int> (nGroups_); |
| 1231 |
|
} |
| 1232 |
|
|
| 1233 |
|
vector<vector<CutoffGroup *> > ForceMatrixDecomposition::buildLayerBasedNeighborList() { |
| 1234 |
< |
// printf("buildLayerBasedNeighborList; nGroups:%d\n", nGroups_); |
| 1234 |
> |
// printf("buildLayerBasedNeighborList; nGroups:%d\n", nGroups_); |
| 1235 |
|
// Na = nGroups_ |
| 1236 |
|
/* cell occupancy counter */ |
| 1237 |
< |
// vector<int> k_c; |
| 1237 |
> |
// vector<int> k_c; |
| 1238 |
|
/* c_i - has cell containing atom i (size Na) */ |
| 1239 |
|
vector<int> c = vector<int> (nGroups_); |
| 1240 |
|
/* l_i - layer containing atom i (size Na) */ |
| 1241 |
< |
// vector<int> l; |
| 1241 |
> |
// vector<int> l; |
| 1242 |
|
|
| 1243 |
|
RealType rList_ = (largestRcut_ + skinThickness_); |
| 1244 |
|
Snapshot* snap_ = sman_->getCurrentSnapshot(); |
| 1257 |
|
int cellIndex; |
| 1258 |
|
int nCtot = nCells_.x() * nCells_.y() * nCells_.z(); |
| 1259 |
|
|
| 1260 |
< |
// k_c = vector<int> (nCtot, 0); |
| 1260 |
> |
// k_c = vector<int> (nCtot, 0); |
| 1261 |
|
|
| 1262 |
|
SimInfo::MoleculeIterator mi; |
| 1263 |
|
Molecule* mol; |
| 1286 |
|
whichCell.y() = nCells_.y() * scaled.y(); |
| 1287 |
|
whichCell.z() = nCells_.z() * scaled.z(); |
| 1288 |
|
|
| 1289 |
< |
// printf("pos x:%f y:%f z:%f cell x:%d y:%d z:%d\n", rs.x(), rs.y(), rs.z(), whichCell.x(), whichCell.y(), |
| 1290 |
< |
// whichCell.z()); |
| 1289 |
> |
// printf("pos x:%f y:%f z:%f cell x:%d y:%d z:%d\n", rs.x(), rs.y(), rs.z(), whichCell.x(), whichCell.y(), |
| 1290 |
> |
// whichCell.z()); |
| 1291 |
|
|
| 1292 |
|
// find single index of this cell: |
| 1293 |
|
cellIndex = Vlinear(whichCell, nCells_); |
| 1296 |
|
} |
| 1297 |
|
} |
| 1298 |
|
|
| 1299 |
< |
// int k_c_curr; |
| 1300 |
< |
// int k_c_max = 0; |
| 1299 |
> |
// int k_c_curr; |
| 1300 |
> |
// int k_c_max = 0; |
| 1301 |
|
/* the cell-layer occupancy matrix */ |
| 1302 |
|
vector<vector<CutoffGroup *> > H_c_l = vector<vector<CutoffGroup *> > (nCtot); |
| 1303 |
|
|
| 1314 |
|
// { |
| 1315 |
|
// k_c_max = k_c_curr; |
| 1316 |
|
// } |
| 1308 |
– |
|
| 1317 |
|
H_c_l[c[cg->getGlobalIndex()]].push_back(/*l[*/cg/*]*/); |
| 1318 |
|
} |
| 1319 |
|
} |
| 1320 |
|
|
| 1321 |
< |
reorderMemory(H_c_l); |
| 1321 |
> |
/* Frequency of reordering the memory */ |
| 1322 |
> |
if (neighborListReorderFreq != 0) |
| 1323 |
> |
{ |
| 1324 |
> |
if (reorderFreqCounter == neighborListReorderFreq) |
| 1325 |
> |
{ |
| 1326 |
> |
//printf("neighborListReorderFreq:%d\n", neighborListReorderFreq); |
| 1327 |
> |
reorderMemory(H_c_l); |
| 1328 |
> |
reorderFreqCounter = 1; |
| 1329 |
> |
} else |
| 1330 |
> |
{ |
| 1331 |
> |
reorderFreqCounter++; |
| 1332 |
> |
} |
| 1333 |
> |
} |
| 1334 |
|
|
| 1335 |
|
int m; |
| 1336 |
|
/* the neighbor matrix */ |