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 1438 by chuckv, Wed Apr 21 19:05:04 2010 UTC vs.
Revision 2056 by gezelter, Fri Feb 20 15:12:07 2015 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 >    nObjects_.push_back(info_->getNGlobalMolecules());
57 >
58 >    stuntdoubles_.resize(nObjects_[STUNTDOUBLE]);
59 >    bonds_.resize(nObjects_[BOND]);
60 >    bends_.resize(nObjects_[BEND]);
61 >    torsions_.resize(nObjects_[TORSION]);
62 >    inversions_.resize(nObjects_[INVERSION]);
63 >    molecules_.resize(nObjects_[MOLECULE]);
64      
65      SimInfo::MoleculeIterator mi;
66 <    Molecule* mol;
55 <    StuntDouble* integrableObject;
56 <    Molecule::IntegrableObjectIterator  ioi;
66 >    Molecule::IntegrableObjectIterator ioi;
67      Molecule::AtomIterator ai;
58    Atom* atom;
68      Molecule::RigidBodyIterator rbIter;
69 <    RigidBody* rb;
69 >    Molecule::BondIterator bondIter;
70 >    Molecule::BendIterator bendIter;
71 >    Molecule::TorsionIterator torsionIter;
72 >    Molecule::InversionIterator inversionIter;
73      
74 +    Molecule* mol;
75 +    StuntDouble* sd;
76 +    Atom* atom;
77 +    RigidBody* rb;
78 +    Bond* bond;
79 +    Bend* bend;
80 +    Torsion* torsion;
81 +    Inversion* inversion;    
82 +
83      for (mol = info_->beginMolecule(mi); mol != NULL;
84           mol = info_->nextMolecule(mi)) {
85 <        
85 >
86 >      molecules_[mol->getGlobalIndex()] = mol;
87 >      
88        // Hull is constructed from all known integrable objects.
89 <      for (integrableObject = mol->beginIntegrableObject(ioi);
90 <           integrableObject != NULL;
91 <           integrableObject = mol->nextIntegrableObject(ioi)) {
92 <        localSites_.push_back(integrableObject);
89 >      for (sd = mol->beginIntegrableObject(ioi);
90 >           sd != NULL;
91 >           sd = mol->nextIntegrableObject(ioi)) {
92 >        localSites_.push_back(sd);
93        }
94        
95        // selection can include atoms (which may be a subset of the IOs)
# Line 80 | Line 103 | namespace OpenMD {
103             rb = mol->nextRigidBody(rbIter)) {
104          stuntdoubles_[rb->getGlobalIndex()] = rb;
105        }
106 <        
106 >
107 >      // These others are going to be inferred from the objects on the hull:
108 >      for (bond = mol->beginBond(bondIter); bond != NULL;
109 >           bond = mol->nextBond(bondIter)) {
110 >        bonds_[bond->getGlobalIndex()] = bond;
111 >      }  
112 >      for (bend = mol->beginBend(bendIter); bend != NULL;
113 >           bend = mol->nextBend(bendIter)) {
114 >        bends_[bend->getGlobalIndex()] = bend;
115 >      }  
116 >      for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
117 >           torsion = mol->nextTorsion(torsionIter)) {
118 >        torsions_[torsion->getGlobalIndex()] = torsion;
119 >      }  
120 >      for (inversion = mol->beginInversion(inversionIter); inversion != NULL;
121 >           inversion = mol->nextInversion(inversionIter)) {
122 >        inversions_[inversion->getGlobalIndex()] = inversion;
123 >      }  
124 >
125      }
126   #ifdef HAVE_QHULL
127      surfaceMesh_ = new ConvexHull();
128 + #endif
129 +  }
130 +
131 +  HullFinder::~HullFinder() {
132 +    delete surfaceMesh_;
133 +  }
134 +
135 +  SelectionSet HullFinder::findHull() {
136 +    SelectionSet ssResult(nObjects_);
137 + #ifdef HAVE_QHULL
138 +    surfaceMesh_->computeHull(localSites_);
139   #else
140      sprintf( painCave.errMsg,
141 <             "Hullfinder error: Hull calculation not possible without libqhull.\n",
142 <              "Please rebuild with Qhull");
143 <      painCave.severity = OPENMD_ERROR;
144 <      painCave.isFatal = 1;
145 <      simError();
94 <
141 >             "HullFinder : Hull calculation is not possible without libqhull.\n"
142 >             "\tPlease rebuild OpenMD with qhull enabled.");
143 >    painCave.severity = OPENMD_ERROR;
144 >    painCave.isFatal = 1;
145 >    simError();
146   #endif
147 +    
148 +    std::vector<Triangle> sMesh = surfaceMesh_->getMesh();
149 +    // Loop over the mesh faces
150 +    std::vector<Triangle>::iterator face;
151 +    std::vector<StuntDouble*>::iterator vertex;
152 +
153 +    // This will work in parallel because the triangles returned by the mesh
154 +    // have a NULL stuntDouble if this processor doesn't own the
155 +    
156 +    for (face = sMesh.begin(); face != sMesh.end(); ++face) {
157 +      Triangle thisTriangle = *face;
158 +      std::vector<StuntDouble*> vertexSDs = thisTriangle.getVertices();
159 +      for (vertex = vertexSDs.begin(); vertex != vertexSDs.end(); ++vertex) {
160 +        if ((*vertex) != NULL) {
161 +          ssResult.bitsets_[STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
162 +        }
163 +      }
164 +    }
165 +    surfaceArea_ = surfaceMesh_->getArea();
166 +    return ssResult;
167    }
168  
169 <  OpenMDBitSet HullFinder::findHull() {
170 <    StuntDouble* sd;
171 <    Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
101 <    OpenMDBitSet bsResult(nStuntDoubles_);
102 <
169 >  SelectionSet HullFinder::findHull(int frame) {
170 >    SelectionSet ssResult(nObjects_);
171 > #ifdef HAVE_QHULL
172      surfaceMesh_->computeHull(localSites_);
173 + #else
174 +    sprintf( painCave.errMsg,
175 +             "HullFinder : Hull calculation is not possible without libqhull.\n"
176 +             "\tPlease rebuild OpenMD with qhull enabled.");
177 +      painCave.severity = OPENMD_ERROR;
178 +      painCave.isFatal = 1;
179 +      simError();
180 + #endif
181 +    
182      std::vector<Triangle> sMesh = surfaceMesh_->getMesh();
105    int nTriangles = sMesh.size();
183      // Loop over the mesh faces
184      std::vector<Triangle>::iterator face;
185      std::vector<StuntDouble*>::iterator vertex;
186  
187 +    // This will work in parallel because the triangles returned by the mesh
188 +    // have a NULL stuntDouble if this processor doesn't own the
189 +    
190      for (face = sMesh.begin(); face != sMesh.end(); ++face) {
191        Triangle thisTriangle = *face;
192        std::vector<StuntDouble*> vertexSDs = thisTriangle.getVertices();
193        for (vertex = vertexSDs.begin(); vertex != vertexSDs.end(); ++vertex) {
194          if ((*vertex) != NULL) {
195 <          bsResult.setBitOn((*vertex)->getGlobalIndex());          
195 >          ssResult.bitsets_[STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
196          }
197        }
198      }
199 <    return bsResult;
199 >    surfaceArea_ = surfaceMesh_->getArea();
200 >    return ssResult;
201    }
202  
203   }

Comparing trunk/src/selection/HullFinder.cpp (property svn:keywords):
Revision 1438 by chuckv, Wed Apr 21 19:05:04 2010 UTC vs.
Revision 2056 by gezelter, Fri Feb 20 15:12:07 2015 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines