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 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/brains/ForceManager.cpp (file contents), Revision 1535 by gezelter, Fri Dec 31 18:31:56 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 +
70      if (!info_->isFortranInitialized()) {
71        info_->update();
72 +      nbiMan_->setSimInfo(info_);
73 +      nbiMan_->initialize();    
74 +      info_->setupFortran();
75      }
76      
77      preCalculation();
78      
79      calcShortRangeInteraction();
80  
81 <    calcLongRangeInteraction(needPotential, needStress);
81 >    calcLongRangeInteraction();
82  
83 <    postCalculation(needStress);
83 >    postCalculation();
84      
85    }
86    
# Line 145 | Line 154 | namespace OpenMD {
154          RealType angle;
155          bend->calcForce(angle);
156          RealType currBendPot = bend->getPotential();          
157 +        
158          bendPotential += bend->getPotential();
159          std::map<Bend*, BendDataSet>::iterator i = bendDataSets.find(bend);
160          if (i == bendDataSets.end()) {
# Line 222 | Line 232 | namespace OpenMD {
232      
233    }
234    
235 <  void ForceManager::calcLongRangeInteraction(bool needPotential,
226 <                                              bool needStress) {
235 >  void ForceManager::calcLongRangeInteraction() {
236      Snapshot* curSnapshot;
237      DataStorage* config;
238      RealType* frc;
# Line 275 | Line 284 | namespace OpenMD {
284      //initialize data before passing to fortran
285      RealType longRangePotential[LR_POT_TYPES];
286      RealType lrPot = 0.0;
278    Vector3d totalDipole;
279    short int passedCalcPot = needPotential;
280    short int passedCalcStress = needStress;
287      int isError = 0;
288  
289      for (int i=0; i<LR_POT_TYPES;i++){
# Line 293 | Line 299 | namespace OpenMD {
299                  tau.getArrayPointer(),
300                  longRangePotential,
301                  particlePot,
296                &passedCalcPot,
297                &passedCalcStress,
302                  &isError );
303      
304      if( isError ){
# Line 306 | Line 310 | namespace OpenMD {
310      for (int i=0; i<LR_POT_TYPES;i++){
311        lrPot += longRangePotential[i]; //Quick hack
312      }
313 <    
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 <    
313 >        
314      //store the tau and long range potential    
315      curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot;
316      curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VDW_POT];
# Line 323 | Line 318 | namespace OpenMD {
318    }
319  
320    
321 <  void ForceManager::postCalculation(bool needStress) {
321 >  void ForceManager::postCalculation() {
322      SimInfo::MoleculeIterator mi;
323      Molecule* mol;
324      Molecule::RigidBodyIterator rbIter;
# Line 336 | Line 331 | namespace OpenMD {
331           mol = info_->nextMolecule(mi)) {
332        for (rb = mol->beginRigidBody(rbIter); rb != NULL;
333             rb = mol->nextRigidBody(rbIter)) {
334 <        if (needStress) {          
335 <          Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial();
341 <          tau += rbTau;
342 <        } else{
343 <          rb->calcForcesAndTorques();
344 <        }
334 >        Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial();
335 >        tau += rbTau;
336        }
337      }
338 <
348 <    if (needStress) {
338 >    
339   #ifdef IS_MPI
340 <      Mat3x3d tmpTau(tau);
341 <      MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(),
342 <                    9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
340 >    Mat3x3d tmpTau(tau);
341 >    MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(),
342 >                  9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
343   #endif
344 <      curSnapshot->statData.setTau(tau);
355 <    }
344 >    curSnapshot->statData.setTau(tau);
345    }
346  
347   } //end namespace OpenMD

Comparing:
trunk/src/brains/ForceManager.cpp (property svn:keywords), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/brains/ForceManager.cpp (property svn:keywords), Revision 1535 by gezelter, Fri Dec 31 18:31:56 2010 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines