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 1503 by gezelter, Sat Oct 2 19:54:41 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 >  }
66 >
67 >  void ForceManager::calcForces() {
68      
69      if (!info_->isFortranInitialized()) {
70        info_->update();
# Line 69 | Line 74 | namespace OpenMD {
74      
75      calcShortRangeInteraction();
76  
77 <    calcLongRangeInteraction(needPotential, needStress);
77 >    calcLongRangeInteraction();
78  
79 <    postCalculation(needStress);
79 >    postCalculation();
80      
81    }
82    
# Line 145 | Line 150 | namespace OpenMD {
150          RealType angle;
151          bend->calcForce(angle);
152          RealType currBendPot = bend->getPotential();          
153 +        
154          bendPotential += bend->getPotential();
155          std::map<Bend*, BendDataSet>::iterator i = bendDataSets.find(bend);
156          if (i == bendDataSets.end()) {
# Line 222 | Line 228 | namespace OpenMD {
228      
229    }
230    
231 <  void ForceManager::calcLongRangeInteraction(bool needPotential,
226 <                                              bool needStress) {
231 >  void ForceManager::calcLongRangeInteraction() {
232      Snapshot* curSnapshot;
233      DataStorage* config;
234      RealType* frc;
# Line 275 | Line 280 | namespace OpenMD {
280      //initialize data before passing to fortran
281      RealType longRangePotential[LR_POT_TYPES];
282      RealType lrPot = 0.0;
278    Vector3d totalDipole;
279    short int passedCalcPot = needPotential;
280    short int passedCalcStress = needStress;
283      int isError = 0;
284  
285      for (int i=0; i<LR_POT_TYPES;i++){
# Line 293 | Line 295 | namespace OpenMD {
295                  tau.getArrayPointer(),
296                  longRangePotential,
297                  particlePot,
296                &passedCalcPot,
297                &passedCalcStress,
298                  &isError );
299      
300      if( isError ){
# Line 306 | Line 306 | namespace OpenMD {
306      for (int i=0; i<LR_POT_TYPES;i++){
307        lrPot += longRangePotential[i]; //Quick hack
308      }
309 <    
310 <    // grab the simulation box dipole moment if specified
311 <    if (info_->getCalcBoxDipole()){
312 <      getAccumulatedBoxDipole(totalDipole.getArrayPointer());
313 <      
314 <      curSnapshot->statData[Stats::BOX_DIPOLE_X] = totalDipole(0);
315 <      curSnapshot->statData[Stats::BOX_DIPOLE_Y] = totalDipole(1);
316 <      curSnapshot->statData[Stats::BOX_DIPOLE_Z] = totalDipole(2);
317 <    }
318 <    
309 >        
310      //store the tau and long range potential    
311      curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot;
312      curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VDW_POT];
# Line 323 | Line 314 | namespace OpenMD {
314    }
315  
316    
317 <  void ForceManager::postCalculation(bool needStress) {
317 >  void ForceManager::postCalculation() {
318      SimInfo::MoleculeIterator mi;
319      Molecule* mol;
320      Molecule::RigidBodyIterator rbIter;
# Line 336 | Line 327 | namespace OpenMD {
327           mol = info_->nextMolecule(mi)) {
328        for (rb = mol->beginRigidBody(rbIter); rb != NULL;
329             rb = mol->nextRigidBody(rbIter)) {
330 <        if (needStress) {          
331 <          Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial();
341 <          tau += rbTau;
342 <        } else{
343 <          rb->calcForcesAndTorques();
344 <        }
330 >        Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial();
331 >        tau += rbTau;
332        }
333      }
334 <
348 <    if (needStress) {
334 >    
335   #ifdef IS_MPI
336 <      Mat3x3d tmpTau(tau);
337 <      MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(),
338 <                    9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
336 >    Mat3x3d tmpTau(tau);
337 >    MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(),
338 >                  9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
339   #endif
340 <      curSnapshot->statData.setTau(tau);
355 <    }
340 >    curSnapshot->statData.setTau(tau);
341    }
342  
343   } //end namespace OpenMD

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines