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

Comparing trunk/src/selection/HullFinder.cpp (file contents):
Revision 1442 by gezelter, Mon May 10 17:28:26 2010 UTC vs.
Revision 1953 by gezelter, Thu Dec 5 18:19:26 2013 UTC

# Line 35 | Line 35
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 < * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include "selection/HullFinder.hpp"
# Line 47 | Line 48 | namespace OpenMD {
48  
49    HullFinder::HullFinder(SimInfo* info) : info_(info) {
50  
51 <    nStuntDoubles_ = info_->getNGlobalAtoms() + info_->getNGlobalRigidBodies();
52 <    stuntdoubles_.resize(nStuntDoubles_);
51 >    nObjects_.push_back(info_->getNGlobalAtoms()+info_->getNGlobalRigidBodies());
52 >    nObjects_.push_back(info_->getNGlobalBonds());
53 >    nObjects_.push_back(info_->getNGlobalBends());
54 >    nObjects_.push_back(info_->getNGlobalTorsions());
55 >    nObjects_.push_back(info_->getNGlobalInversions());
56 >
57 >    stuntdoubles_.resize(nObjects_[STUNTDOUBLE]);
58 >    bonds_.resize(nObjects_[BOND]);
59 >    bends_.resize(nObjects_[BEND]);
60 >    torsions_.resize(nObjects_[TORSION]);
61 >    inversions_.resize(nObjects_[INVERSION]);
62      
63      SimInfo::MoleculeIterator mi;
64 <    Molecule* mol;
55 <    StuntDouble* integrableObject;
56 <    Molecule::IntegrableObjectIterator  ioi;
64 >    Molecule::IntegrableObjectIterator ioi;
65      Molecule::AtomIterator ai;
58    Atom* atom;
66      Molecule::RigidBodyIterator rbIter;
67 <    RigidBody* rb;
67 >    Molecule::BondIterator bondIter;
68 >    Molecule::BendIterator bendIter;
69 >    Molecule::TorsionIterator torsionIter;
70 >    Molecule::InversionIterator inversionIter;
71      
72 +    Molecule* mol;
73 +    StuntDouble* sd;
74 +    Atom* atom;
75 +    RigidBody* rb;
76 +    Bond* bond;
77 +    Bend* bend;
78 +    Torsion* torsion;
79 +    Inversion* inversion;    
80 +
81      for (mol = info_->beginMolecule(mi); mol != NULL;
82           mol = info_->nextMolecule(mi)) {
83          
84        // Hull is constructed from all known integrable objects.
85 <      for (integrableObject = mol->beginIntegrableObject(ioi);
86 <           integrableObject != NULL;
87 <           integrableObject = mol->nextIntegrableObject(ioi)) {
88 <        localSites_.push_back(integrableObject);
85 >      for (sd = mol->beginIntegrableObject(ioi);
86 >           sd != NULL;
87 >           sd = mol->nextIntegrableObject(ioi)) {
88 >        localSites_.push_back(sd);
89        }
90        
91        // selection can include atoms (which may be a subset of the IOs)
# Line 80 | Line 99 | namespace OpenMD {
99             rb = mol->nextRigidBody(rbIter)) {
100          stuntdoubles_[rb->getGlobalIndex()] = rb;
101        }
102 <        
102 >
103 >      // These others are going to be inferred from the objects on the hull:
104 >      for (bond = mol->beginBond(bondIter); bond != NULL;
105 >           bond = mol->nextBond(bondIter)) {
106 >        bonds_[bond->getGlobalIndex()] = bond;
107 >      }  
108 >      for (bend = mol->beginBend(bendIter); bend != NULL;
109 >           bend = mol->nextBend(bendIter)) {
110 >        bends_[bend->getGlobalIndex()] = bend;
111 >      }  
112 >      for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
113 >           torsion = mol->nextTorsion(torsionIter)) {
114 >        torsions_[torsion->getGlobalIndex()] = torsion;
115 >      }  
116 >      for (inversion = mol->beginInversion(inversionIter); inversion != NULL;
117 >           inversion = mol->nextInversion(inversionIter)) {
118 >        inversions_[inversion->getGlobalIndex()] = inversion;
119 >      }  
120 >
121      }
122   #ifdef HAVE_QHULL
123      surfaceMesh_ = new ConvexHull();
124   #endif
125    }
126  
127 <  OpenMDBitSet HullFinder::findHull() {
128 <    StuntDouble* sd;
129 <    Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
130 <    OpenMDBitSet bsResult(nStuntDoubles_);
127 >  HullFinder::~HullFinder() {
128 >    delete surfaceMesh_;
129 >  }
130 >
131 >  SelectionSet HullFinder::findHull() {
132 >    SelectionSet ssResult(nObjects_);
133   #ifdef HAVE_QHULL
134      surfaceMesh_->computeHull(localSites_);
135   #else
136      sprintf( painCave.errMsg,
137 <             "HullFinder error: Hull calculation is not possible without libqhull.\n",
138 <             "Please rebuild OpenMD with qhull enabled.");
137 >             "HullFinder : Hull calculation is not possible without libqhull.\n"
138 >             "\tPlease rebuild OpenMD with qhull enabled.");
139 >    painCave.severity = OPENMD_ERROR;
140 >    painCave.isFatal = 1;
141 >    simError();
142 > #endif
143 >    
144 >    std::vector<Triangle> sMesh = surfaceMesh_->getMesh();
145 >    // Loop over the mesh faces
146 >    std::vector<Triangle>::iterator face;
147 >    std::vector<StuntDouble*>::iterator vertex;
148 >
149 >    // This will work in parallel because the triangles returned by the mesh
150 >    // have a NULL stuntDouble if this processor doesn't own the
151 >    
152 >    for (face = sMesh.begin(); face != sMesh.end(); ++face) {
153 >      Triangle thisTriangle = *face;
154 >      std::vector<StuntDouble*> vertexSDs = thisTriangle.getVertices();
155 >      for (vertex = vertexSDs.begin(); vertex != vertexSDs.end(); ++vertex) {
156 >        if ((*vertex) != NULL) {
157 >          ssResult.bitsets_[STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
158 >        }
159 >      }
160 >    }
161 >    return ssResult;
162 >  }
163 >
164 >  SelectionSet HullFinder::findHull(int frame) {
165 >    SelectionSet ssResult(nObjects_);
166 > #ifdef HAVE_QHULL
167 >    surfaceMesh_->computeHull(localSites_);
168 > #else
169 >    sprintf( painCave.errMsg,
170 >             "HullFinder : Hull calculation is not possible without libqhull.\n"
171 >             "\tPlease rebuild OpenMD with qhull enabled.");
172        painCave.severity = OPENMD_ERROR;
173        painCave.isFatal = 1;
174        simError();
175   #endif
176      
177      std::vector<Triangle> sMesh = surfaceMesh_->getMesh();
106    int nTriangles = sMesh.size();
178      // Loop over the mesh faces
179      std::vector<Triangle>::iterator face;
180      std::vector<StuntDouble*>::iterator vertex;
181  
182 +    // This will work in parallel because the triangles returned by the mesh
183 +    // have a NULL stuntDouble if this processor doesn't own the
184 +    
185      for (face = sMesh.begin(); face != sMesh.end(); ++face) {
186        Triangle thisTriangle = *face;
187        std::vector<StuntDouble*> vertexSDs = thisTriangle.getVertices();
188        for (vertex = vertexSDs.begin(); vertex != vertexSDs.end(); ++vertex) {
189          if ((*vertex) != NULL) {
190 <          bsResult.setBitOn((*vertex)->getGlobalIndex());          
190 >          ssResult.bitsets_[STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
191          }
192        }
193      }
194 <    return bsResult;
194 >    surfaceArea_ = surfaceMesh_->getArea();
195 >    return ssResult;
196    }
197  
198   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines