--- trunk/src/math/ConvexHull.cpp 2010/02/24 15:22:03 1410 +++ branches/development/src/math/ConvexHull.cpp 2013/01/09 19:27:52 1825 @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2009, 2010 The University of Notre Dame. All Rights Reserved. +/* Copyright (c) 2010 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a * non-exclusive, royalty free, license to use, modify and @@ -35,16 +35,16 @@ * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). - * [4] Vardeman & Gezelter, in progress (2009). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [4] , Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). * * - * * ConvexHull.cpp * * Purpose: To calculate convexhull, hull volume libqhull. * * Created by Charles F. Vardeman II on 11 Dec 2006. * @author Charles F. Vardeman II - * @version $Id: ConvexHull.cpp,v 1.21 2009-11-25 20:02:01 gezelter Exp $ + * @version $Id$ * */ @@ -62,20 +62,10 @@ #include #endif -using namespace OpenMD; +#include "math/qhull.hpp" #ifdef HAVE_QHULL -extern "C" -{ -#include -#include -#include -#include -#include -#include -#include -#include -} +using namespace OpenMD; ConvexHull::ConvexHull() : Hull(), dim_(3), options_("qhull Qt Pp") { } @@ -90,13 +80,14 @@ void ConvexHull::computeHull(std::vector facetT *facet; setT *vertices; int curlong, totlong; - pointT *intPoint; + // pointT *intPoint; std::vector ptArray(numpoints*dim_); // Copy the positon vector into a points vector for qhull. std::vector::iterator SD; int i = 0; + for (SD =bodydoubles.begin(); SD != bodydoubles.end(); ++SD){ Vector3d pos = (*SD)->getPos(); ptArray[dim_ * i] = pos.x(); @@ -105,12 +96,14 @@ void ConvexHull::computeHull(std::vector i++; } + /* Clean up memory from previous convex hull calculations */ boolT ismalloc = False; - /* Clean up memory from previous convex hull calculations*/ + /* compute the hull for our local points (or all the points for single + processor versions) */ if (qh_new_qhull(dim_, numpoints, &ptArray[0], ismalloc, const_cast(options_.c_str()), NULL, stderr)) { - + sprintf(painCave.errMsg, "ConvexHull: Qhull failed to compute convex hull"); painCave.isFatal = 1; simError(); @@ -194,9 +187,13 @@ void ConvexHull::computeHull(std::vector // Free previous hull qh_freeqhull(!qh_ALL); qh_memfreeshort(&curlong, &totlong); - if (curlong || totlong) - std::cerr << "qhull internal warning (main): did not free %d bytes of long memory (%d pieces) " - << totlong << curlong << std::endl; + if (curlong || totlong) { + sprintf(painCave.errMsg, "ConvexHull: qhull internal warning:\n" + "\tdid not free %d bytes of long memory (%d pieces)", + totlong, curlong); + painCave.isFatal = 1; + simError(); + } if (qh_new_qhull(dim_, globalHullSites, &globalCoords[0], ismalloc, const_cast(options_.c_str()), NULL, stderr)){ @@ -208,8 +205,9 @@ void ConvexHull::computeHull(std::vector } //qh_new_qhull #endif - intPoint = qh interior_point; - RealType calcvol = 0.0; + // commented out below, so comment out here also. + // intPoint = qh interior_point; + // RealType calcvol = 0.0; FORALLfacets { Triangle face; //Qhull sets the unit normal in facet->normal @@ -260,10 +258,7 @@ void ConvexHull::computeHull(std::vector vel = bodydoubles[id]->getVel(); mass = bodydoubles[id]->getMass(); face.addVertexSD(bodydoubles[id]); - - -#endif - +#endif faceVel = faceVel + vel; faceMass = faceMass + mass; ver++; @@ -271,7 +266,7 @@ void ConvexHull::computeHull(std::vector face.addVertices(p[0], p[1], p[2]); face.setFacetMass(faceMass); - face.setFacetVelocity(faceVel/3.0); + face.setFacetVelocity(faceVel / RealType(3.0)); /* RealType comparea = face.computeArea(); realT calcarea = qh_facetarea (facet); @@ -292,9 +287,13 @@ void ConvexHull::computeHull(std::vector // std::cout << "My volume is: " << calcvol << " qhull volume is:" << volume_ << std::endl; qh_freeqhull(!qh_ALL); qh_memfreeshort(&curlong, &totlong); - if (curlong || totlong) - std::cerr << "qhull internal warning (main): did not free %d bytes of long memory (%d pieces) " - << totlong << curlong << std::endl; + if (curlong || totlong) { + sprintf(painCave.errMsg, "ConvexHull: qhull internal warning:\n" + "\tdid not free %d bytes of long memory (%d pieces)", + totlong, curlong); + painCave.isFatal = 1; + simError(); + } } void ConvexHull::printHull(const std::string& geomFileName) {