--- trunk/src/math/ConvexHull.cpp 2010/01/15 20:46:49 1404 +++ branches/development/src/math/ConvexHull.cpp 2012/01/06 19:03:05 1668 @@ -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$ * */ @@ -67,7 +67,7 @@ extern "C" #ifdef HAVE_QHULL extern "C" { -#include +#include #include #include #include @@ -105,12 +105,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 +196,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)){ @@ -236,7 +242,6 @@ void ConvexHull::computeHull(std::vector p[ver][0] = vertex->point[0]; p[ver][1] = vertex->point[1]; p[ver][2] = vertex->point[2]; - Vector3d vel; RealType mass; @@ -251,15 +256,17 @@ void ConvexHull::computeHull(std::vector int localID = id - displacements[myrank]; - if (localID >= 0 && localID < hullSitesOnProc[myrank]) + + if (localID >= 0 && localID < hullSitesOnProc[myrank]){ face.addVertexSD(bodydoubles[indexMap[localID]]); - + }else{ + face.addVertexSD(NULL); + } #else vel = bodydoubles[id]->getVel(); mass = bodydoubles[id]->getMass(); face.addVertexSD(bodydoubles[id]); -#endif - +#endif faceVel = faceVel + vel; faceMass = faceMass + mass; ver++; @@ -267,7 +274,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); @@ -288,9 +295,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) {