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

Comparing branches/development/src/selection/DistanceFinder.cpp (file contents):
Revision 1812 by gezelter, Fri Nov 16 21:18:42 2012 UTC vs.
Revision 1831 by gezelter, Thu Jan 10 14:06:34 2013 UTC

# Line 137 | Line 137 | namespace OpenMD {
137      }
138      return bsResult;
139    }
140 +
141 +
142 + OpenMDBitSet DistanceFinder::find(const OpenMDBitSet& bs, RealType distance, int frame ) {
143 +    StuntDouble * center;
144 +    Vector3d centerPos;
145 +    Snapshot* currSnapshot = info_->getSnapshotManager()->getSnapshot(frame);
146 +    OpenMDBitSet bsResult(nStuntDoubles_);  
147 +    assert(bsResult.size() == bs.size());
148 +
149 + #ifdef IS_MPI
150 +    int mol;
151 +    int proc;
152 +    RealType data[3];
153 +    int worldRank = MPI::COMM_WORLD.Get_rank();
154 + #endif
155 +
156 +    for (unsigned int j = 0; j < stuntdoubles_.size(); ++j) {
157 +      if (stuntdoubles_[j]->isRigidBody()) {
158 +        RigidBody* rb = static_cast<RigidBody*>(stuntdoubles_[j]);
159 +        rb->updateAtoms(frame);
160 +      }
161 +    }
162 +      
163 +    OpenMDBitSet bsTemp(nStuntDoubles_);
164 +    bsTemp = bs;
165 +    bsTemp.parallelReduce();
166 +
167 +    for (int i = bsTemp.firstOnBit(); i != -1; i = bsTemp.nextOnBit(i)) {
168 +
169 +      // Now, if we own stuntdouble i, we can use the position, but in
170 +      // parallel, we'll need to let everyone else know what that
171 +      // position is!
172 +
173 + #ifdef IS_MPI
174 +      mol = info_->getGlobalMolMembership(i);
175 +      proc = info_->getMolToProc(mol);
176 +    
177 +      if (proc == worldRank) {
178 +        center = stuntdoubles_[i];
179 +        centerPos = center->getPos(frame);
180 +        data[0] = centerPos.x();
181 +        data[1] = centerPos.y();
182 +        data[2] = centerPos.z();          
183 +        MPI::COMM_WORLD.Bcast(data, 3, MPI::REALTYPE, proc);
184 +      } else {
185 +        MPI::COMM_WORLD.Bcast(data, 3, MPI::REALTYPE, proc);
186 +        centerPos = Vector3d(data);
187 +      }
188 + #else
189 +      center = stuntdoubles_[i];
190 +      centerPos = center->getPos(frame);
191 + #endif
192 +      
193 +      for (unsigned int j = 0; j < stuntdoubles_.size(); ++j) {
194 +        Vector3d r =centerPos - stuntdoubles_[j]->getPos(frame);
195 +        currSnapshot->wrapVector(r);
196 +        if (r.length() <= distance) {
197 +          bsResult.setBitOn(j);
198 +        }
199 +      }
200 +    }
201 +    return bsResult;
202 +  }
203   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines