45#include "selection/HullFinder.hpp"
47#include "math/AlphaHull.hpp"
48#include "math/ConvexHull.hpp"
53 HullFinder::HullFinder(SimInfo* info) : info_(info) {
54 nObjects_.push_back(info_->getNGlobalAtoms() +
55 info_->getNGlobalRigidBodies());
56 nObjects_.push_back(info_->getNGlobalBonds());
57 nObjects_.push_back(info_->getNGlobalBends());
58 nObjects_.push_back(info_->getNGlobalTorsions());
59 nObjects_.push_back(info_->getNGlobalInversions());
60 nObjects_.push_back(info_->getNGlobalMolecules());
62 stuntdoubles_.resize(nObjects_[STUNTDOUBLE]);
63 bonds_.resize(nObjects_[BOND]);
64 bends_.resize(nObjects_[BEND]);
65 torsions_.resize(nObjects_[TORSION]);
66 inversions_.resize(nObjects_[INVERSION]);
67 molecules_.resize(nObjects_[MOLECULE]);
69 SimInfo::MoleculeIterator mi;
70 Molecule::IntegrableObjectIterator ioi;
71 Molecule::AtomIterator ai;
72 Molecule::RigidBodyIterator rbIter;
73 Molecule::BondIterator bondIter;
74 Molecule::BendIterator bendIter;
75 Molecule::TorsionIterator torsionIter;
76 Molecule::InversionIterator inversionIter;
87 for (mol = info_->beginMolecule(mi); mol != NULL;
88 mol = info_->nextMolecule(mi)) {
89 molecules_[mol->getGlobalIndex()] = mol;
92 for (sd = mol->beginIntegrableObject(ioi); sd != NULL;
93 sd = mol->nextIntegrableObject(ioi)) {
94 localSites_.push_back(sd);
98 for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
99 stuntdoubles_[atom->getGlobalIndex()] = atom;
103 for (rb = mol->beginRigidBody(rbIter); rb != NULL;
104 rb = mol->nextRigidBody(rbIter)) {
105 stuntdoubles_[rb->getGlobalIndex()] = rb;
109 for (bond = mol->beginBond(bondIter); bond != NULL;
110 bond = mol->nextBond(bondIter)) {
111 bonds_[bond->getGlobalIndex()] = bond;
113 for (bend = mol->beginBend(bendIter); bend != NULL;
114 bend = mol->nextBend(bendIter)) {
115 bends_[bend->getGlobalIndex()] = bend;
117 for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
118 torsion = mol->nextTorsion(torsionIter)) {
119 torsions_[torsion->getGlobalIndex()] = torsion;
121 for (inversion = mol->beginInversion(inversionIter); inversion != NULL;
122 inversion = mol->nextInversion(inversionIter)) {
123 inversions_[inversion->getGlobalIndex()] = inversion;
127 surfaceMesh_ =
new ConvexHull();
131 AlphaHullFinder::AlphaHullFinder(SimInfo* info) : HullFinder(info) {
134 surfaceMesh_ =
new AlphaHull(0.0);
138 void AlphaHullFinder::setAlpha(RealType alpha) {
141 surfaceMesh_ =
new AlphaHull(alpha);
145 HullFinder::~HullFinder() {
151 SelectionSet HullFinder::findHull() {
152 SelectionSet ssResult(nObjects_);
154 surfaceMesh_->computeHull(localSites_);
156 std::vector<Triangle> sMesh = surfaceMesh_->getMesh();
158 std::vector<Triangle>::iterator face;
159 std::vector<StuntDouble*>::iterator vertex;
164 for (face = sMesh.begin(); face != sMesh.end(); ++face) {
165 Triangle thisTriangle = *face;
166 std::vector<StuntDouble*> vertexSDs = thisTriangle.getVertices();
167 for (vertex = vertexSDs.begin(); vertex != vertexSDs.end(); ++vertex) {
168 if ((*vertex) != NULL) {
169 ssResult.bitsets_[
STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
173 surfaceArea_ = surfaceMesh_->getArea();
175 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
176 "HullFinder : Hull calculation is not possible without libqhull.\n"
177 "\tPlease rebuild OpenMD with qhull enabled.");
178 painCave.severity = OPENMD_ERROR;
179 painCave.isFatal = 1;
186 SelectionSet HullFinder::findHull(
int) {
187 SelectionSet ssResult(nObjects_);
189 surfaceMesh_->computeHull(localSites_);
190 std::vector<Triangle> sMesh = surfaceMesh_->getMesh();
192 std::vector<Triangle>::iterator face;
193 std::vector<StuntDouble*>::iterator vertex;
198 for (face = sMesh.begin(); face != sMesh.end(); ++face) {
199 Triangle thisTriangle = *face;
200 std::vector<StuntDouble*> vertexSDs = thisTriangle.getVertices();
201 for (vertex = vertexSDs.begin(); vertex != vertexSDs.end(); ++vertex) {
202 if ((*vertex) != NULL) {
203 ssResult.bitsets_[
STUNTDOUBLE].setBitOn((*vertex)->getGlobalIndex());
207 surfaceArea_ = surfaceMesh_->getArea();
208 volume_ = surfaceMesh_->getVolume();
211 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
212 "HullFinder : Hull calculation is not possible without libqhull.\n"
213 "\tPlease rebuild OpenMD with qhull enabled.");
214 painCave.severity = OPENMD_ERROR;
215 painCave.isFatal = 1;
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
@ STUNTDOUBLE
StuntDoubles (Atoms & RigidBodies)