45#include "selection/IndexFinder.hpp"
55 IndexFinder::IndexFinder(SimInfo* info) : info_(info) {
56 nObjects_.push_back(info_->getNGlobalAtoms() +
57 info_->getNGlobalRigidBodies());
58 nObjects_.push_back(info_->getNGlobalBonds());
59 nObjects_.push_back(info_->getNGlobalBends());
60 nObjects_.push_back(info_->getNGlobalTorsions());
61 nObjects_.push_back(info_->getNGlobalInversions());
62 nObjects_.push_back(info_->getNGlobalMolecules());
64 selectionSets_.resize(info_->getNGlobalMolecules());
68 void IndexFinder::init() {
69 SimInfo::MoleculeIterator mi;
70 Molecule::AtomIterator ai;
71 Molecule::RigidBodyIterator rbIter;
72 Molecule::BondIterator bondIter;
73 Molecule::BendIterator bendIter;
74 Molecule::TorsionIterator torsionIter;
75 Molecule::InversionIterator inversionIter;
85 for (mol = info_->beginMolecule(mi); mol != NULL;
86 mol = info_->nextMolecule(mi)) {
87 SelectionSet ss(nObjects_);
89 ss.bitsets_[MOLECULE].setBitOn(mol->getGlobalIndex());
91 for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
92 ss.bitsets_[
STUNTDOUBLE].setBitOn(atom->getGlobalIndex());
94 for (rb = mol->beginRigidBody(rbIter); rb != NULL;
95 rb = mol->nextRigidBody(rbIter)) {
96 ss.bitsets_[
STUNTDOUBLE].setBitOn(rb->getGlobalIndex());
98 for (bond = mol->beginBond(bondIter); bond != NULL;
99 bond = mol->nextBond(bondIter)) {
100 ss.bitsets_[BOND].setBitOn(bond->getGlobalIndex());
102 for (bend = mol->beginBend(bendIter); bend != NULL;
103 bend = mol->nextBend(bendIter)) {
104 ss.bitsets_[BEND].setBitOn(bend->getGlobalIndex());
106 for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
107 torsion = mol->nextTorsion(torsionIter)) {
108 ss.bitsets_[TORSION].setBitOn(torsion->getGlobalIndex());
110 for (inversion = mol->beginInversion(inversionIter); inversion != NULL;
111 inversion = mol->nextInversion(inversionIter)) {
112 ss.bitsets_[INVERSION].setBitOn(inversion->getGlobalIndex());
115 selectionSets_[mol->getGlobalIndex()] = ss;
119 SelectionSet IndexFinder::find(
int molIndex) {
123 MPI_Comm_rank(MPI_COMM_WORLD, &worldRank);
124 proc = info_->getMolToProc(molIndex);
126 if (proc == worldRank) {
128 return selectionSets_[molIndex];
131 return SelectionSet(nObjects_);
136 SelectionSet IndexFinder::find(
int begMolIndex,
int endMolIndex) {
137 SelectionSet ss(nObjects_);
142 MPI_Comm_rank(MPI_COMM_WORLD, &worldRank);
145 for (
int i = begMolIndex; i < endMolIndex; ++i) {
147 proc = info_->getMolToProc(i);
149 if (proc == worldRank) {
151 ss |= selectionSets_[i];
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
@ STUNTDOUBLE
StuntDoubles (Atoms & RigidBodies)