ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/ForceManager.cpp
(Generate patch)

Comparing:
trunk/src/brains/ForceManager.cpp (file contents), Revision 1442 by gezelter, Mon May 10 17:28:26 2010 UTC vs.
branches/development/src/brains/ForceManager.cpp (file contents), Revision 1469 by gezelter, Mon Jul 19 14:07:59 2010 UTC

# Line 57 | Line 57
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    
# Line 145 | Line 157 | namespace OpenMD {
157          RealType angle;
158          bend->calcForce(angle);
159          RealType currBendPot = bend->getPotential();          
160 +        
161          bendPotential += bend->getPotential();
162          std::map<Bend*, BendDataSet>::iterator i = bendDataSets.find(bend);
163          if (i == bendDataSets.end()) {
# Line 222 | Line 235 | namespace OpenMD {
235      
236    }
237    
238 <  void ForceManager::calcLongRangeInteraction(bool needPotential,
226 <                                              bool needStress) {
238 >  void ForceManager::calcLongRangeInteraction() {
239      Snapshot* curSnapshot;
240      DataStorage* config;
241      RealType* frc;
# Line 276 | Line 288 | namespace OpenMD {
288      RealType longRangePotential[LR_POT_TYPES];
289      RealType lrPot = 0.0;
290      Vector3d totalDipole;
279    short int passedCalcPot = needPotential;
280    short int passedCalcStress = needStress;
291      int isError = 0;
292  
293      for (int i=0; i<LR_POT_TYPES;i++){
# Line 293 | Line 303 | namespace OpenMD {
303                  tau.getArrayPointer(),
304                  longRangePotential,
305                  particlePot,
296                &passedCalcPot,
297                &passedCalcStress,
306                  &isError );
307      
308      if( isError ){
# Line 323 | Line 331 | namespace OpenMD {
331    }
332  
333    
334 <  void ForceManager::postCalculation(bool needStress) {
334 >  void ForceManager::postCalculation() {
335      SimInfo::MoleculeIterator mi;
336      Molecule* mol;
337      Molecule::RigidBodyIterator rbIter;
# Line 336 | Line 344 | namespace OpenMD {
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();
341 <          tau += rbTau;
342 <        } else{
343 <          rb->calcForcesAndTorques();
344 <        }
347 >        Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial();
348 >        tau += rbTau;
349        }
350      }
351 <
348 <    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);
355 <    }
357 >    curSnapshot->statData.setTau(tau);
358    }
359  
360   } //end namespace OpenMD

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines