57 |
|
#include "primitives/Bend.hpp" |
58 |
|
#include "primitives/Torsion.hpp" |
59 |
|
#include "primitives/Inversion.hpp" |
60 |
< |
#include "parallel/ForceDecomposition.hpp" |
61 |
< |
//#include "parallel/SerialDecomposition.hpp" |
60 |
> |
#include "parallel/ForceMatrixDecomposition.hpp" |
61 |
> |
//#include "parallel/ForceSerialDecomposition.hpp" |
62 |
|
|
63 |
|
using namespace std; |
64 |
|
namespace OpenMD { |
66 |
|
ForceManager::ForceManager(SimInfo * info) : info_(info) { |
67 |
|
|
68 |
|
#ifdef IS_MPI |
69 |
< |
decomp_ = new ForceDecomposition(info_); |
69 |
> |
fDecomp_ = new ForceMatrixDecomposition(info_); |
70 |
|
#else |
71 |
< |
// decomp_ = new SerialDecomposition(info); |
71 |
> |
// fDecomp_ = new ForceSerialDecomposition(info); |
72 |
|
#endif |
73 |
|
} |
74 |
|
|
79 |
|
interactionMan_->setSimInfo(info_); |
80 |
|
interactionMan_->initialize(); |
81 |
|
swfun_ = interactionMan_->getSwitchingFunction(); |
82 |
< |
decomp_->distributeInitialData(); |
82 |
> |
fDecomp_->distributeInitialData(); |
83 |
|
info_->setupFortran(); |
84 |
|
} |
85 |
|
|
278 |
|
|
279 |
|
// new stuff starts here: |
280 |
|
|
281 |
< |
decomp_->distributeData(); |
281 |
> |
fDecomp_->distributeData(); |
282 |
|
|
283 |
|
int cg1, cg2, atom1, atom2; |
284 |
|
Vector3d d_grp, dag; |
285 |
|
RealType rgrpsq, rgrp; |
286 |
< |
Vector<RealType, 4> vij; |
286 |
> |
RealType vij; |
287 |
|
Vector3d fij, fg; |
288 |
|
pair<int, int> gtypes; |
289 |
|
RealType rCutSq; |
290 |
|
bool in_switching_region; |
291 |
|
RealType sw, dswdr, swderiv; |
292 |
< |
vector<int> atomListI, atomListJ, atomList; |
292 |
> |
vector<int> atomListColumn, atomListRow, atomListLocal; |
293 |
|
InteractionData idat; |
294 |
|
SelfData sdat; |
295 |
|
RealType mf; |
306 |
|
for (int iLoop = loopStart; iLoop < loopEnd; iLoop++) { |
307 |
|
|
308 |
|
if (iLoop == loopStart) { |
309 |
< |
bool update_nlist = decomp_->checkNeighborList(); |
309 |
> |
bool update_nlist = fDecomp_->checkNeighborList(); |
310 |
|
if (update_nlist) |
311 |
< |
neighborList = decomp_->buildNeighborList(); |
311 |
> |
neighborList = fDecomp_->buildNeighborList(); |
312 |
|
} |
313 |
|
|
314 |
|
for (vector<pair<int, int> >::iterator it = neighborList.begin(); |
317 |
|
cg1 = (*it).first; |
318 |
|
cg2 = (*it).second; |
319 |
|
|
320 |
< |
gtypes = decomp_->getGroupTypes(cg1, cg2); |
321 |
< |
d_grp = decomp_->getIntergroupVector(cg1, cg2); |
320 |
> |
gtypes = fDecomp_->getGroupTypes(cg1, cg2); |
321 |
> |
d_grp = fDecomp_->getIntergroupVector(cg1, cg2); |
322 |
|
curSnapshot->wrapVector(d_grp); |
323 |
|
rgrpsq = d_grp.lengthSquare(); |
324 |
|
rCutSq = groupCutoffMap[gtypes].first; |
331 |
|
} |
332 |
|
|
333 |
|
in_switching_region = swfun_->getSwitch(rgrpsq, idat.sw, dswdr, rgrp); |
334 |
< |
atomListI = decomp_->getAtomsInGroupI(cg1); |
335 |
< |
atomListJ = decomp_->getAtomsInGroupJ(cg2); |
334 |
> |
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
335 |
> |
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
336 |
|
|
337 |
< |
for (vector<int>::iterator ia = atomListI.begin(); |
338 |
< |
ia != atomListI.end(); ++ia) { |
337 |
> |
for (vector<int>::iterator ia = atomListRow.begin(); |
338 |
> |
ia != atomListRow.end(); ++ia) { |
339 |
|
atom1 = (*ia); |
340 |
|
|
341 |
< |
for (vector<int>::iterator jb = atomListJ.begin(); |
342 |
< |
jb != atomListJ.end(); ++jb) { |
341 |
> |
for (vector<int>::iterator jb = atomListColumn.begin(); |
342 |
> |
jb != atomListColumn.end(); ++jb) { |
343 |
|
atom2 = (*jb); |
344 |
|
|
345 |
< |
if (!decomp_->skipAtomPair(atom1, atom2)) { |
345 |
> |
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
346 |
|
|
347 |
< |
idat = decomp_->fillInteractionData(atom1, atom2); |
347 |
> |
idat = fDecomp_->fillInteractionData(atom1, atom2); |
348 |
|
|
349 |
< |
if (atomListI.size() == 1 && atomListJ.size() == 1) { |
349 |
> |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
350 |
|
idat.d = d_grp; |
351 |
|
idat.r2 = rgrpsq; |
352 |
|
} else { |
353 |
< |
idat.d = decomp_->getInteratomicVector(atom1, atom2); |
353 |
> |
idat.d = fDecomp_->getInteratomicVector(atom1, atom2); |
354 |
|
curSnapshot->wrapVector(idat.d); |
355 |
|
idat.r2 = idat.d.lengthSquare(); |
356 |
|
} |
376 |
|
|
377 |
|
fij += fg; |
378 |
|
|
379 |
< |
if (atomListI.size() == 1 && atomListJ.size() == 1) { |
379 |
> |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
380 |
|
tau -= outProduct(idat.d, fg); |
381 |
|
} |
382 |
|
|
383 |
< |
for (vector<int>::iterator ia = atomListI.begin(); |
384 |
< |
ia != atomListI.end(); ++ia) { |
383 |
> |
for (vector<int>::iterator ia = atomListRow.begin(); |
384 |
> |
ia != atomListRow.end(); ++ia) { |
385 |
|
atom1 = (*ia); |
386 |
< |
mf = decomp_->getMfactI(atom1); |
386 |
> |
mf = fDecomp_->getMfactRow(atom1); |
387 |
|
// fg is the force on atom ia due to cutoff group's |
388 |
|
// presence in switching region |
389 |
|
fg = swderiv * d_grp * mf; |
390 |
< |
decomp_->addForceToAtomI(atom1, fg); |
390 |
> |
fDecomp_->addForceToAtomRow(atom1, fg); |
391 |
|
|
392 |
< |
if (atomListI.size() > 1) { |
392 |
> |
if (atomListRow.size() > 1) { |
393 |
|
if (info_->usesAtomicVirial()) { |
394 |
|
// find the distance between the atom |
395 |
|
// and the center of the cutoff group: |
396 |
< |
dag = decomp_->getAtomToGroupVectorI(atom1, cg1); |
396 |
> |
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
397 |
|
tau -= outProduct(dag, fg); |
398 |
|
} |
399 |
|
} |
400 |
|
} |
401 |
< |
for (vector<int>::iterator jb = atomListJ.begin(); |
402 |
< |
jb != atomListJ.end(); ++jb) { |
401 |
> |
for (vector<int>::iterator jb = atomListColumn.begin(); |
402 |
> |
jb != atomListColumn.end(); ++jb) { |
403 |
|
atom2 = (*jb); |
404 |
< |
mf = decomp_->getMfactJ(atom2); |
404 |
> |
mf = fDecomp_->getMfactColumn(atom2); |
405 |
|
// fg is the force on atom jb due to cutoff group's |
406 |
|
// presence in switching region |
407 |
|
fg = -swderiv * d_grp * mf; |
408 |
< |
decomp_->addForceToAtomJ(atom2, fg); |
408 |
> |
fDecomp_->addForceToAtomColumn(atom2, fg); |
409 |
|
|
410 |
< |
if (atomListJ.size() > 1) { |
410 |
> |
if (atomListColumn.size() > 1) { |
411 |
|
if (info_->usesAtomicVirial()) { |
412 |
|
// find the distance between the atom |
413 |
|
// and the center of the cutoff group: |
414 |
< |
dag = decomp_->getAtomToGroupVectorJ(atom2, cg2); |
414 |
> |
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
415 |
|
tau -= outProduct(dag, fg); |
416 |
|
} |
417 |
|
} |
426 |
|
|
427 |
|
if (iLoop == PREPAIR_LOOP) { |
428 |
|
if (info_->requiresPrepair()) { |
429 |
< |
decomp_->collectIntermediateData(); |
430 |
< |
atomList = decomp_->getAtomList(); |
431 |
< |
for (vector<int>::iterator ia = atomList.begin(); |
432 |
< |
ia != atomList.end(); ++ia) { |
429 |
> |
fDecomp_->collectIntermediateData(); |
430 |
> |
atomListLocal = fDecomp_->getAtomList(); |
431 |
> |
for (vector<int>::iterator ia = atomListLocal.begin(); |
432 |
> |
ia != atomListLocal.end(); ++ia) { |
433 |
|
atom1 = (*ia); |
434 |
< |
sdat = decomp_->fillSelfData(atom1); |
434 |
> |
sdat = fDecomp_->fillSelfData(atom1); |
435 |
|
interactionMan_->doPreForce(sdat); |
436 |
|
} |
437 |
< |
decomp_->distributeIntermediateData(); |
437 |
> |
fDecomp_->distributeIntermediateData(); |
438 |
|
} |
439 |
|
} |
440 |
|
|
441 |
|
} |
442 |
|
|
443 |
< |
decomp_->collectData(); |
443 |
> |
fDecomp_->collectData(); |
444 |
|
|
445 |
|
if (info_->requiresSkipCorrection() || info_->requiresSelfCorrection()) { |
446 |
< |
atomList = decomp_->getAtomList(); |
447 |
< |
for (vector<int>::iterator ia = atomList.begin(); |
448 |
< |
ia != atomList.end(); ++ia) { |
446 |
> |
atomListLocal = fDecomp_->getAtomList(); |
447 |
> |
for (vector<int>::iterator ia = atomListLocal.begin(); |
448 |
> |
ia != atomListLocal.end(); ++ia) { |
449 |
|
atom1 = (*ia); |
450 |
|
|
451 |
|
if (info_->requiresSkipCorrection()) { |
452 |
< |
vector<int> skipList = decomp_->getSkipsForAtom(atom1); |
452 |
> |
vector<int> skipList = fDecomp_->getSkipsForAtom(atom1); |
453 |
|
for (vector<int>::iterator jb = skipList.begin(); |
454 |
|
jb != skipList.end(); ++jb) { |
455 |
|
atom2 = (*jb); |
456 |
< |
idat = decomp_->fillSkipData(atom1, atom2); |
456 |
> |
idat = fDecomp_->fillSkipData(atom1, atom2); |
457 |
|
interactionMan_->doSkipCorrection(idat); |
458 |
|
} |
459 |
|
} |
460 |
|
|
461 |
|
if (info_->requiresSelfCorrection()) { |
462 |
< |
sdat = decomp_->fillSelfData(atom1); |
462 |
> |
sdat = fDecomp_->fillSelfData(atom1); |
463 |
|
interactionMan_->doSelfCorrection(sdat); |
464 |
+ |
} |
465 |
|
} |
465 |
– |
|
466 |
– |
|
466 |
|
} |
467 |
|
|
468 |
|
for (int i=0; i<LR_POT_TYPES;i++){ |