ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/selection/HullFinder.cpp
Revision: 1953
Committed: Thu Dec 5 18:19:26 2013 UTC (11 years, 5 months ago) by gezelter
File size: 7403 byte(s)
Log Message:
Rewrote much of selection module, added a bond correlation function

File Contents

# User Rev Content
1 gezelter 1412 /*
2     * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3     *
4     * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
6     * redistribute this software in source and binary code form, provided
7     * that the following conditions are met:
8     *
9     * 1. Redistributions of source code must retain the above copyright
10     * notice, this list of conditions and the following disclaimer.
11     *
12     * 2. Redistributions in binary form must reproduce the above copyright
13     * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the
15     * distribution.
16     *
17     * This software is provided "AS IS," without a warranty of any
18     * kind. All express or implied conditions, representations and
19     * warranties, including any implied warranty of merchantability,
20     * fitness for a particular purpose or non-infringement, are hereby
21     * excluded. The University of Notre Dame and its licensors shall not
22     * be liable for any damages suffered by licensee as a result of
23     * using, modifying or distributing the software or its
24     * derivatives. In no event will the University of Notre Dame or its
25     * licensors be liable for any lost revenue, profit or data, or for
26     * direct, indirect, special, consequential, incidental or punitive
27     * damages, however caused and regardless of the theory of liability,
28     * arising out of the use of or inability to use software, even if the
29     * University of Notre Dame has been advised of the possibility of
30     * such damages.
31     *
32     * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
33     * research, please cite the appropriate papers when you publish your
34     * work. Good starting points are:
35     *
36     * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37     * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38 gezelter 1879 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
39 gezelter 1782 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40     * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 gezelter 1412 */
42    
43     #include "selection/HullFinder.hpp"
44     #include "primitives/Molecule.hpp"
45     #include "math/ConvexHull.hpp"
46    
47     namespace OpenMD {
48    
49     HullFinder::HullFinder(SimInfo* info) : info_(info) {
50    
51 gezelter 1953 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 gezelter 1412
63     SimInfo::MoleculeIterator mi;
64 gezelter 1953 Molecule::IntegrableObjectIterator ioi;
65     Molecule::AtomIterator ai;
66     Molecule::RigidBodyIterator rbIter;
67     Molecule::BondIterator bondIter;
68     Molecule::BendIterator bendIter;
69     Molecule::TorsionIterator torsionIter;
70     Molecule::InversionIterator inversionIter;
71    
72 gezelter 1412 Molecule* mol;
73 gezelter 1782 StuntDouble* sd;
74 gezelter 1412 Atom* atom;
75     RigidBody* rb;
76 gezelter 1953 Bond* bond;
77     Bend* bend;
78     Torsion* torsion;
79     Inversion* inversion;
80    
81 gezelter 1412 for (mol = info_->beginMolecule(mi); mol != NULL;
82     mol = info_->nextMolecule(mi)) {
83    
84     // Hull is constructed from all known integrable objects.
85 gezelter 1782 for (sd = mol->beginIntegrableObject(ioi);
86     sd != NULL;
87     sd = mol->nextIntegrableObject(ioi)) {
88     localSites_.push_back(sd);
89 gezelter 1412 }
90    
91     // selection can include atoms (which may be a subset of the IOs)
92     for(atom = mol->beginAtom(ai); atom != NULL;
93     atom = mol->nextAtom(ai)) {
94     stuntdoubles_[atom->getGlobalIndex()] = atom;
95     }
96    
97     // and rigid bodies
98     for (rb = mol->beginRigidBody(rbIter); rb != NULL;
99     rb = mol->nextRigidBody(rbIter)) {
100     stuntdoubles_[rb->getGlobalIndex()] = rb;
101     }
102 gezelter 1953
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 chuckv 1438 }
122     #ifdef HAVE_QHULL
123     surfaceMesh_ = new ConvexHull();
124 chuckv 1439 #endif
125     }
126    
127 gezelter 1879 HullFinder::~HullFinder() {
128     delete surfaceMesh_;
129     }
130    
131 gezelter 1953 SelectionSet HullFinder::findHull() {
132     SelectionSet ssResult(nObjects_);
133 chuckv 1439 #ifdef HAVE_QHULL
134     surfaceMesh_->computeHull(localSites_);
135 chuckv 1438 #else
136     sprintf( painCave.errMsg,
137 gezelter 1782 "HullFinder : Hull calculation is not possible without libqhull.\n"
138     "\tPlease rebuild OpenMD with qhull enabled.");
139 gezelter 1879 painCave.severity = OPENMD_ERROR;
140     painCave.isFatal = 1;
141     simError();
142 chuckv 1438 #endif
143 chuckv 1439
144 gezelter 1412 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 gezelter 1801 // 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 gezelter 1412 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 gezelter 1953 ssResult.bitsets_[STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
158 gezelter 1412 }
159     }
160     }
161 gezelter 1953 return ssResult;
162 gezelter 1412 }
163    
164 gezelter 1953 SelectionSet HullFinder::findHull(int frame) {
165     SelectionSet ssResult(nObjects_);
166 gezelter 1816 #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();
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 gezelter 1953 ssResult.bitsets_[STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
191 gezelter 1816 }
192     }
193     }
194 gezelter 1903 surfaceArea_ = surfaceMesh_->getArea();
195 gezelter 1953 return ssResult;
196 gezelter 1816 }
197    
198 gezelter 1412 }

Properties

Name Value
svn:executable *
svn:keywords Author Id Revision Date