| 1 | 
< | 
/* Copyright (c) 2008, 2009, 2010 The University of Notre Dame. All Rights Reserved. | 
| 1 | 
> | 
/* Copyright (c) 2010 The University of Notre Dame. All Rights Reserved. | 
| 2 | 
  | 
 * | 
| 3 | 
  | 
 * The University of Notre Dame grants you ("Licensee") a | 
| 4 | 
  | 
 * non-exclusive, royalty free, license to use, modify and | 
| 35 | 
  | 
 * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).              | 
| 36 | 
  | 
 * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).           | 
| 37 | 
  | 
 * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).           | 
| 38 | 
< | 
 * [4]  Vardeman & Gezelter, in progress (2009).                         | 
| 38 | 
> | 
 * [4] Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 39 | 
> | 
 * [4] , Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). * | 
| 40 | 
  | 
 * | 
| 40 | 
– | 
 * | 
| 41 | 
  | 
 *  ConvexHull.cpp | 
| 42 | 
  | 
 * | 
| 43 | 
  | 
 *  Purpose: To calculate convexhull, hull volume libqhull. | 
| 44 | 
  | 
 * | 
| 45 | 
  | 
 *  Created by Charles F. Vardeman II on 11 Dec 2006. | 
| 46 | 
  | 
 *  @author  Charles F. Vardeman II | 
| 47 | 
< | 
 *  @version $Id: ConvexHull.cpp,v 1.21 2009-11-25 20:02:01 gezelter Exp $ | 
| 47 | 
> | 
 *  @version $Id$ | 
| 48 | 
  | 
 * | 
| 49 | 
  | 
 */ | 
| 50 | 
  | 
 | 
| 67 | 
  | 
#ifdef HAVE_QHULL | 
| 68 | 
  | 
extern "C" | 
| 69 | 
  | 
{ | 
| 70 | 
< | 
#include <qhull/qhull.h> | 
| 70 | 
> | 
#include <qhull/libqhull.h> | 
| 71 | 
  | 
#include <qhull/mem.h> | 
| 72 | 
  | 
#include <qhull/qset.h> | 
| 73 | 
  | 
#include <qhull/geom.h> | 
| 105 | 
  | 
    i++; | 
| 106 | 
  | 
  } | 
| 107 | 
  | 
   | 
| 108 | 
+ | 
  /* Clean up memory from previous convex hull calculations */ | 
| 109 | 
  | 
  boolT ismalloc = False; | 
| 109 | 
– | 
  /* Clean up memory from previous convex hull calculations*/ | 
| 110 | 
  | 
   | 
| 111 | 
+ | 
  /* compute the hull for our local points (or all the points for single | 
| 112 | 
+ | 
     processor versions) */ | 
| 113 | 
  | 
  if (qh_new_qhull(dim_, numpoints, &ptArray[0], ismalloc, | 
| 114 | 
  | 
                   const_cast<char *>(options_.c_str()), NULL, stderr)) { | 
| 115 | 
< | 
 | 
| 115 | 
> | 
     | 
| 116 | 
  | 
    sprintf(painCave.errMsg, "ConvexHull: Qhull failed to compute convex hull"); | 
| 117 | 
  | 
    painCave.isFatal = 1; | 
| 118 | 
  | 
    simError(); | 
| 196 | 
  | 
  // Free previous hull | 
| 197 | 
  | 
  qh_freeqhull(!qh_ALL); | 
| 198 | 
  | 
  qh_memfreeshort(&curlong, &totlong); | 
| 199 | 
< | 
  if (curlong || totlong) | 
| 200 | 
< | 
    std::cerr << "qhull internal warning (main): did not free %d bytes of long memory (%d pieces) " | 
| 201 | 
< | 
              << totlong << curlong << std::endl; | 
| 199 | 
> | 
  if (curlong || totlong) { | 
| 200 | 
> | 
    sprintf(painCave.errMsg, "ConvexHull: qhull internal warning:\n" | 
| 201 | 
> | 
            "\tdid not free %d bytes of long memory (%d pieces)",  | 
| 202 | 
> | 
            totlong, curlong); | 
| 203 | 
> | 
    painCave.isFatal = 1; | 
| 204 | 
> | 
    simError(); | 
| 205 | 
> | 
  } | 
| 206 | 
  | 
   | 
| 207 | 
  | 
  if (qh_new_qhull(dim_, globalHullSites, &globalCoords[0], ismalloc, | 
| 208 | 
  | 
                   const_cast<char *>(options_.c_str()), NULL, stderr)){ | 
| 266 | 
  | 
      vel = bodydoubles[id]->getVel(); | 
| 267 | 
  | 
      mass = bodydoubles[id]->getMass(); | 
| 268 | 
  | 
      face.addVertexSD(bodydoubles[id]);       | 
| 269 | 
< | 
 | 
| 264 | 
< | 
 | 
| 265 | 
< | 
#endif | 
| 266 | 
< | 
         | 
| 269 | 
> | 
#endif   | 
| 270 | 
  | 
      faceVel = faceVel + vel; | 
| 271 | 
  | 
      faceMass = faceMass + mass; | 
| 272 | 
  | 
      ver++;       | 
| 274 | 
  | 
 | 
| 275 | 
  | 
    face.addVertices(p[0], p[1], p[2]); | 
| 276 | 
  | 
    face.setFacetMass(faceMass); | 
| 277 | 
< | 
    face.setFacetVelocity(faceVel/3.0); | 
| 277 | 
> | 
    face.setFacetVelocity(faceVel / RealType(3.0)); | 
| 278 | 
  | 
    /* | 
| 279 | 
  | 
    RealType comparea = face.computeArea(); | 
| 280 | 
  | 
    realT calcarea = qh_facetarea (facet); | 
| 295 | 
  | 
  //  std::cout << "My volume is: " << calcvol << " qhull volume is:" << volume_ << std::endl;  | 
| 296 | 
  | 
  qh_freeqhull(!qh_ALL); | 
| 297 | 
  | 
  qh_memfreeshort(&curlong, &totlong); | 
| 298 | 
< | 
  if (curlong || totlong) | 
| 299 | 
< | 
    std::cerr << "qhull internal warning (main): did not free %d bytes of long memory (%d pieces) " | 
| 300 | 
< | 
              << totlong << curlong << std::endl;     | 
| 298 | 
> | 
  if (curlong || totlong) { | 
| 299 | 
> | 
    sprintf(painCave.errMsg, "ConvexHull: qhull internal warning:\n" | 
| 300 | 
> | 
            "\tdid not free %d bytes of long memory (%d pieces)",  | 
| 301 | 
> | 
            totlong, curlong); | 
| 302 | 
> | 
    painCave.isFatal = 1; | 
| 303 | 
> | 
    simError(); | 
| 304 | 
> | 
  } | 
| 305 | 
  | 
} | 
| 306 | 
  | 
 | 
| 307 | 
  | 
void ConvexHull::printHull(const std::string& geomFileName) { |