--- trunk/src/selection/DistanceFinder.cpp 2013/12/05 18:19:26 1953 +++ trunk/src/selection/DistanceFinder.cpp 2015/01/09 19:06:35 2052 @@ -55,12 +55,14 @@ namespace OpenMD { nObjects_.push_back(info_->getNGlobalBends()); nObjects_.push_back(info_->getNGlobalTorsions()); nObjects_.push_back(info_->getNGlobalInversions()); + nObjects_.push_back(info_->getNGlobalMolecules()); stuntdoubles_.resize(nObjects_[STUNTDOUBLE]); bonds_.resize(nObjects_[BOND]); bends_.resize(nObjects_[BEND]); torsions_.resize(nObjects_[TORSION]); inversions_.resize(nObjects_[INVERSION]); + molecules_.resize(nObjects_[MOLECULE]); SimInfo::MoleculeIterator mi; Molecule::AtomIterator ai; @@ -80,7 +82,9 @@ namespace OpenMD { for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { - + + molecules_[mol->getGlobalIndex()] = mol; + for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { stuntdoubles_[atom->getGlobalIndex()] = atom; @@ -120,7 +124,8 @@ namespace OpenMD { int mol; int proc; RealType data[3]; - int worldRank = MPI::COMM_WORLD.Get_rank(); + int worldRank; + MPI_Comm_rank( MPI_COMM_WORLD, &worldRank); #endif for (unsigned int j = 0; j < stuntdoubles_.size(); ++j) { @@ -151,9 +156,9 @@ namespace OpenMD { data[0] = centerPos.x(); data[1] = centerPos.y(); data[2] = centerPos.z(); - MPI::COMM_WORLD.Bcast(data, 3, MPI::REALTYPE, proc); + MPI_Bcast(data, 3, MPI_REALTYPE, proc, MPI_COMM_WORLD); } else { - MPI::COMM_WORLD.Bcast(data, 3, MPI::REALTYPE, proc); + MPI_Bcast(data, 3, MPI_REALTYPE, proc, MPI_COMM_WORLD); centerPos = Vector3d(data); } #else @@ -161,6 +166,13 @@ namespace OpenMD { centerPos = center->getPos(); #endif + for (unsigned int j = 0; j < molecules_.size(); ++j) { + Vector3d r =centerPos - molecules_[j]->getCom(); + currSnapshot->wrapVector(r); + if (r.length() <= distance) { + bsResult.bitsets_[MOLECULE].setBitOn(j); + } + } for (unsigned int j = 0; j < stuntdoubles_.size(); ++j) { Vector3d r =centerPos - stuntdoubles_[j]->getPos(); currSnapshot->wrapVector(r); @@ -229,7 +241,8 @@ namespace OpenMD { int mol; int proc; RealType data[3]; - int worldRank = MPI::COMM_WORLD.Get_rank(); + int worldRank; + MPI_Comm_rank( MPI_COMM_WORLD, &worldRank); #endif for (unsigned int j = 0; j < stuntdoubles_.size(); ++j) { @@ -260,15 +273,23 @@ namespace OpenMD { data[0] = centerPos.x(); data[1] = centerPos.y(); data[2] = centerPos.z(); - MPI::COMM_WORLD.Bcast(data, 3, MPI::REALTYPE, proc); + MPI_Bcast(data, 3, MPI_REALTYPE, proc, MPI_COMM_WORLD); } else { - MPI::COMM_WORLD.Bcast(data, 3, MPI::REALTYPE, proc); + MPI_Bcast(data, 3, MPI_REALTYPE, proc, MPI_COMM_WORLD); centerPos = Vector3d(data); } #else center = stuntdoubles_[i]; centerPos = center->getPos(frame); #endif + for (unsigned int j = 0; j < molecules_.size(); ++j) { + Vector3d r =centerPos - molecules_[j]->getCom(frame); + currSnapshot->wrapVector(r); + if (r.length() <= distance) { + bsResult.bitsets_[MOLECULE].setBitOn(j); + } + } + for (unsigned int j = 0; j < stuntdoubles_.size(); ++j) { Vector3d r =centerPos - stuntdoubles_[j]->getPos(frame); currSnapshot->wrapVector(r);