ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/io/ConstraintWriter.cpp
(Generate patch)

Comparing trunk/src/io/ConstraintWriter.cpp (file contents):
Revision 1981 by gezelter, Mon Apr 14 18:32:51 2014 UTC vs.
Revision 1984 by gezelter, Tue Apr 15 21:15:35 2014 UTC

# Line 52 | Line 52 | namespace OpenMD {
52   #include "utils/simError.h"
53  
54   namespace OpenMD {
55 <  ConstraintWriter::ConstraintWriter(SimInfo* info, const std::string& filename) : info_(info) {
55 >  ConstraintWriter::ConstraintWriter(SimInfo* info,
56 >                                     const std::string& filename): info_(info) {
57      //use master - slave mode, only master node writes to disk
58   #ifdef IS_MPI
59      if(worldRank == 0){
60   #endif
61        output_.open(filename.c_str());
62 <
62 >      
63        if(!output_){
64          sprintf( painCave.errMsg,
65 <                 "Could not open %s for Constraint output\n", filename.c_str());
65 >                 "Could not open %s for Constraint output\n",
66 >                 filename.c_str());
67          painCave.isFatal = 1;
68          simError();
69        }
# Line 69 | Line 71 | namespace OpenMD {
71        output_ << "#time(fs)\t"
72                << "Index of atom 1\t"
73                << "Index of atom 2\tconstraint force" << std::endl;
74 <
74 >      
75   #ifdef IS_MPI
76      }
77 < #endif  
76 <
77 > #endif      
78    }
79 <
80 <  ConstraintWriter::~ConstraintWriter() {
80 <    
79 >  
80 >  ConstraintWriter::~ConstraintWriter() {    
81   #ifdef IS_MPI
82      if(worldRank == 0 ){
83   #endif  
# Line 86 | Line 86 | namespace OpenMD {
86      }
87   #endif
88    }
89 <
89 >  
90    void ConstraintWriter::writeConstraintForces(const std::list<ConstraintPair*>& constraints){
91   #ifndef IS_MPI
92      std::list<ConstraintPair*>::const_iterator i;
# Line 100 | Line 100 | namespace OpenMD {
100        }
101      }
102   #else
103 <  
103 >    
104      const int masterNode = 0;
105      int nproc;
106      int myNode;      
# Line 108 | Line 108 | namespace OpenMD {
108      MPI_Comm_rank( MPI_COMM_WORLD, &myNode);
109  
110      std::vector<int> nConstraints(nproc, 0);
111
111      nConstraints[myNode] = constraints.size();
112      
113      //do MPI_ALLREDUCE to exchange the total number of constraints:
114 <    MPI_Allreduce(MPI_IN_PLACE, &nConstraints[0], nproc, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
114 >    MPI_Allreduce(MPI_IN_PLACE, &nConstraints[0], nproc, MPI_INT, MPI_SUM,
115 >                  MPI_COMM_WORLD);
116  
117      MPI_Status ierr;
118      int atom1, atom2, doPrint;
# Line 147 | Line 147 | namespace OpenMD {
147            }
148          }            
149        }
150 <      
151 <      output_ << info_->getSnapshotManager()->getCurrentSnapshot()->getTime() << std::endl;
152 <      output_ << constraintData.size() << std::endl;
153 <      
150 >            
151        std::vector<ConstraintData>::iterator l;
152        for (l = constraintData.begin(); l != constraintData.end(); ++l) {
153          if (l->printForce) {
# Line 171 | Line 168 | namespace OpenMD {
168          
169          MPI_Send(&atom1, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
170          MPI_Send(&atom2, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);
171 <        MPI_Send(&constraintForce, 1, MPI_REALTYPE, masterNode, 0, MPI_COMM_WORLD);
171 >        MPI_Send(&constraintForce, 1, MPI_REALTYPE, masterNode, 0,
172 >                 MPI_COMM_WORLD);
173          MPI_Send(&printForce, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD);            
174        }
175      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines