ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/selection/HullFinder.cpp
Revision: 2056
Committed: Fri Feb 20 15:12:07 2015 UTC (10 years, 2 months ago) by gezelter
File size: 7592 byte(s)
Log Message:
Fixes to HullFinder (and by extension to RNEMD) for getSurfaceArea() call.
Adding Multipass Correlation Function (unused right now).

File Contents

# Content
1 /*
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 * [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"
44 #include "primitives/Molecule.hpp"
45 #include "math/ConvexHull.hpp"
46
47 namespace OpenMD {
48
49 HullFinder::HullFinder(SimInfo* info) : info_(info) {
50
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::IntegrableObjectIterator ioi;
67 Molecule::AtomIterator ai;
68 Molecule::RigidBodyIterator rbIter;
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
86 molecules_[mol->getGlobalIndex()] = mol;
87
88 // Hull is constructed from all known integrable objects.
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)
96 for(atom = mol->beginAtom(ai); atom != NULL;
97 atom = mol->nextAtom(ai)) {
98 stuntdoubles_[atom->getGlobalIndex()] = atom;
99 }
100
101 // and rigid bodies
102 for (rb = mol->beginRigidBody(rbIter); rb != NULL;
103 rb = mol->nextRigidBody(rbIter)) {
104 stuntdoubles_[rb->getGlobalIndex()] = rb;
105 }
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 : 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 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();
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 ssResult.bitsets_[STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
196 }
197 }
198 }
199 surfaceArea_ = surfaceMesh_->getArea();
200 return ssResult;
201 }
202
203 }

Properties

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