--- trunk/src/math/ConvexHull.cpp 2009/10/21 02:49:43 1377 +++ trunk/src/math/ConvexHull.cpp 2009/10/22 19:43:10 1384 @@ -44,7 +44,7 @@ * * Created by Charles F. Vardeman II on 11 Dec 2006. * @author Charles F. Vardeman II - * @version $Id: ConvexHull.cpp,v 1.18 2009-10-21 02:49:43 gezelter Exp $ + * @version $Id: ConvexHull.cpp,v 1.20 2009-10-22 19:43:10 gezelter Exp $ * */ @@ -77,9 +77,6 @@ extern "C" #include } -/* Old options Qt Qu Qg QG0 FA */ -/* More old opts Qc Qi Pp*/ - ConvexHull::ConvexHull() : Hull(), dim_(3), options_("qhull Qt Pp") { } @@ -94,8 +91,7 @@ void ConvexHull::computeHull(std::vector setT *vertices; int curlong, totlong; - std::vector ptArray(numpoints*3); - std::vector isSurfaceID(numpoints); + std::vector ptArray(numpoints*dim_); // Copy the positon vector into a points vector for qhull. std::vector::iterator SD; @@ -127,20 +123,24 @@ void ConvexHull::computeHull(std::vector int nproc = MPI::COMM_WORLD.Get_size(); int myrank = MPI::COMM_WORLD.Get_rank(); int localHullSites = 0; - int* hullSitesOnProc = new int[nproc]; - int* coordsOnProc = new int[nproc]; - int* displacements = new int[nproc]; - int* vectorDisplacements = new int[nproc]; + std::vector hullSitesOnProc(nproc, 0); + std::vector coordsOnProc(nproc, 0); + std::vector displacements(nproc, 0); + std::vector vectorDisplacements(nproc, 0); + std::vector coords; std::vector vels; - std::vector objectIDs; + std::vector indexMap; std::vector masses; FORALLvertices{ localHullSites++; int idx = qh_pointid(vertex->point); + + indexMap.push_back(idx); + coords.push_back(ptArray[dim_ * idx]); coords.push_back(ptArray[dim_ * idx + 1]); coords.push_back(ptArray[dim_ * idx + 2]); @@ -155,8 +155,6 @@ void ConvexHull::computeHull(std::vector masses.push_back(sd->getMass()); } - - MPI::COMM_WORLD.Allgather(&localHullSites, 1, MPI::INT, &hullSitesOnProc[0], 1, MPI::INT); @@ -252,7 +250,7 @@ void ConvexHull::computeHull(std::vector int localID = id - displacements[myrank]; if (localID >= 0 && localID < hullSitesOnProc[myrank]) - face.addVertexSD(bodydoubles[localID]); + face.addVertexSD(bodydoubles[indexMap[localID]]); #else vel = bodydoubles[id]->getVel(); @@ -277,13 +275,6 @@ void ConvexHull::computeHull(std::vector volume_ = qh totvol; area_ = qh totarea; -#ifdef IS_MPI - delete [] hullSitesOnProc; - delete [] coordsOnProc; - delete [] displacements; - delete [] vectorDisplacements; -#endif - qh_freeqhull(!qh_ALL); qh_memfreeshort(&curlong, &totlong); if (curlong || totlong) @@ -292,6 +283,10 @@ void ConvexHull::printHull(const std::string& geomFile } void ConvexHull::printHull(const std::string& geomFileName) { + +#ifdef IS_MPI + if (worldRank == 0) { +#endif FILE *newGeomFile; //create new .md file based on old .md file @@ -301,5 +296,8 @@ void ConvexHull::printHull(const std::string& geomFile qh_printfacets(newGeomFile, qh PRINTout[i], qh facet_list, NULL, !qh_ALL); fclose(newGeomFile); +#ifdef IS_MPI + } +#endif } #endif //QHULL