57 |
|
#include "primitives/Bend.hpp" |
58 |
|
#include "primitives/Torsion.hpp" |
59 |
|
#include "primitives/Inversion.hpp" |
60 |
– |
namespace OpenMD { |
60 |
|
|
61 |
< |
void ForceManager::calcForces(bool needPotential, bool needStress) { |
61 |
> |
namespace OpenMD { |
62 |
> |
|
63 |
> |
ForceManager::ForceManager(SimInfo * info) : info_(info), |
64 |
> |
NBforcesInitialized_(false) { |
65 |
> |
std::cerr << __PRETTY_FUNCTION__ << "\n"; |
66 |
> |
lj_ = new LJ(info_->getForceField()); |
67 |
> |
} |
68 |
> |
|
69 |
> |
void ForceManager::calcForces() { |
70 |
|
|
71 |
+ |
std::cerr << __PRETTY_FUNCTION__ << "\n"; |
72 |
|
if (!info_->isFortranInitialized()) { |
73 |
|
info_->update(); |
74 |
|
} |
75 |
|
|
76 |
+ |
if (!NBforcesInitialized_) { |
77 |
+ |
lj_->initialize(); |
78 |
+ |
} |
79 |
+ |
|
80 |
|
preCalculation(); |
81 |
|
|
82 |
|
calcShortRangeInteraction(); |
83 |
|
|
84 |
< |
calcLongRangeInteraction(needPotential, needStress); |
84 |
> |
calcLongRangeInteraction(); |
85 |
|
|
86 |
< |
postCalculation(needStress); |
86 |
> |
postCalculation(); |
87 |
|
|
88 |
|
} |
89 |
|
|
235 |
|
|
236 |
|
} |
237 |
|
|
238 |
< |
void ForceManager::calcLongRangeInteraction(bool needPotential, |
227 |
< |
bool needStress) { |
238 |
> |
void ForceManager::calcLongRangeInteraction() { |
239 |
|
Snapshot* curSnapshot; |
240 |
|
DataStorage* config; |
241 |
|
RealType* frc; |
288 |
|
RealType longRangePotential[LR_POT_TYPES]; |
289 |
|
RealType lrPot = 0.0; |
290 |
|
Vector3d totalDipole; |
280 |
– |
short int passedCalcPot = needPotential; |
281 |
– |
short int passedCalcStress = needStress; |
291 |
|
int isError = 0; |
292 |
|
|
293 |
|
for (int i=0; i<LR_POT_TYPES;i++){ |
303 |
|
tau.getArrayPointer(), |
304 |
|
longRangePotential, |
305 |
|
particlePot, |
297 |
– |
&passedCalcPot, |
298 |
– |
&passedCalcStress, |
306 |
|
&isError ); |
307 |
|
|
308 |
|
if( isError ){ |
331 |
|
} |
332 |
|
|
333 |
|
|
334 |
< |
void ForceManager::postCalculation(bool needStress) { |
334 |
> |
void ForceManager::postCalculation() { |
335 |
|
SimInfo::MoleculeIterator mi; |
336 |
|
Molecule* mol; |
337 |
|
Molecule::RigidBodyIterator rbIter; |
344 |
|
mol = info_->nextMolecule(mi)) { |
345 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
346 |
|
rb = mol->nextRigidBody(rbIter)) { |
347 |
< |
if (needStress) { |
348 |
< |
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
342 |
< |
tau += rbTau; |
343 |
< |
} else{ |
344 |
< |
rb->calcForcesAndTorques(); |
345 |
< |
} |
347 |
> |
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
348 |
> |
tau += rbTau; |
349 |
|
} |
350 |
|
} |
351 |
< |
|
349 |
< |
if (needStress) { |
351 |
> |
|
352 |
|
#ifdef IS_MPI |
353 |
< |
Mat3x3d tmpTau(tau); |
354 |
< |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
355 |
< |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
353 |
> |
Mat3x3d tmpTau(tau); |
354 |
> |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
355 |
> |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
356 |
|
#endif |
357 |
< |
curSnapshot->statData.setTau(tau); |
356 |
< |
} |
357 |
> |
curSnapshot->statData.setTau(tau); |
358 |
|
} |
359 |
|
|
360 |
|
} //end namespace OpenMD |