# | Line 44 | Line 44 | |
---|---|---|
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.9 2008-10-07 17:12:48 chuckv Exp $ |
47 | > | * @version $Id: ConvexHull.cpp,v 1.11 2008-10-20 19:36:32 chuckv Exp $ |
48 | * | |
49 | */ | |
50 | ||
# | Line 369 | Line 369 | void ConvexHull::printHull(const std::string& geomFile | |
369 | #else | |
370 | #ifdef HAVE_QHULL | |
371 | /* Old options Qt Qu Qg QG0 FA */ | |
372 | < | ConvexHull::ConvexHull() : Hull(), dim_(3), options_("qhull Qt Qci Tcv Pp"), Ns_(200) { |
372 | > | /* More old opts Qc Qi Pp*/ |
373 | > | ConvexHull::ConvexHull() : Hull(), dim_(3), options_("qhull Qt Pp"), Ns_(200), nTriangles_(0) { |
374 | //If we are doing the mpi version, set up some vectors for data communication | |
375 | #ifdef IS_MPI | |
376 | ||
# | Line 445 | Line 446 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
446 | const_cast<char *>(options_.c_str()), NULL, stderr)) { | |
447 | ||
448 | sprintf(painCave.errMsg, "ConvexHull: Qhull failed to compute convex hull"); | |
449 | < | painCave.isFatal = 0; |
449 | > | painCave.isFatal = 1; |
450 | simError(); | |
451 | ||
452 | } //qh_new_qhull | |
# | Line 453 | Line 454 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
454 | ||
455 | #ifdef IS_MPI | |
456 | std::vector<double> localPts; | |
457 | + | std::vector<double> localVel; |
458 | int localPtArraySize; | |
459 | ||
460 | ||
# | Line 464 | Line 466 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
466 | if (!facet->simplicial){ | |
467 | // should never happen with Qt | |
468 | sprintf(painCave.errMsg, "ConvexHull: non-simplicaial facet detected"); | |
469 | < | painCave.isFatal = 0; |
469 | > | painCave.isFatal = 1; |
470 | simError(); | |
471 | } | |
472 | ||
# | Line 516 | Line 518 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
518 | localPts.push_back(ptArray[dim_ * idx]); | |
519 | localPts.push_back(ptArray[dim_ * idx + 1]); | |
520 | localPts.push_back(ptArray[dim_ * idx + 2]); | |
521 | + | |
522 | + | Vector3d vel = bodydoubles[idx]->getVel(); |
523 | + | localVel.push_back(vel.x()); |
524 | + | localVel.push_back(vel.y()); |
525 | + | localVel.push_back(vel.z()); |
526 | + | |
527 | localPtsMap.push_back(idx); | |
528 | } | |
529 | ||
# | Line 534 | Line 542 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
542 | int nglobalPts = int(Nsglobal_/3); | |
543 | ||
544 | ||
545 | < | std::vector<double> globalPts; |
546 | < | globalPts.resize(Nsglobal_); |
545 | > | std::vector<double> globalPts(Nsglobal_); |
546 | > | std::vector<double> globalVel(Nsglobal_); |
547 | ||
548 | isSurfaceID.resize(nglobalPts); | |
549 | ||
# | Line 553 | Line 561 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
561 | /* gather the potential hull */ | |
562 | ||
563 | MPI::COMM_WORLD.Allgatherv(&localPts[0],localPtArraySize,MPI::DOUBLE,&globalPts[0],&NstoProc_[0],&displs_[0],MPI::DOUBLE); | |
564 | + | MPI::COMM_WORLD.Allgatherv(&localVel[0],localPtArraySize,MPI::DOUBLE,&globalVel[0],&NstoProc_[0],&displs_[0],MPI::DOUBLE); |
565 | ||
566 | /* | |
567 | if (myrank_ == 0){ | |
# | Line 602 | Line 611 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
611 | Triangle* face = new Triangle(); | |
612 | Vector3d V3dNormal(facet->normal[0],facet->normal[1],facet->normal[2]); | |
613 | face->setNormal(V3dNormal); | |
614 | < | //face->setCentroid(V3dCentroid); |
614 | > | |
615 | > | |
616 | > | |
617 | RealType faceArea = 0.5*V3dNormal.length(); | |
618 | < | //face->setArea(faceArea); |
618 | > | face->setArea(faceArea); |
619 | ||
620 | ||
621 | vertices = qh_facet3vertex(facet); | |
622 | + | |
623 | + | coordT *center = qh_getcenter(vertices); |
624 | + | Vector3d V3dCentroid(center[0], center[1], center[2]); |
625 | + | face->setCentroid(V3dCentroid); |
626 | + | Vector3d faceVel = V3Zero; |
627 | FOREACHvertex_(vertices){ | |
628 | id = qh_pointid(vertex->point); | |
629 | int localindex = id; | |
630 | #ifdef IS_MPI | |
631 | < | |
631 | > | Vector3d velVector(globalVel[dim_ * id],globalVel[dim_ * id + 1], globalVel[dim_ * id + 1]); |
632 | > | faceVel = faceVel + velVector; |
633 | if (id >= noffset/3 && id < (noffset + localPtArraySize)/3 ){ | |
634 | localindex = localPtsMap[id-noffset/3]; | |
635 | + | #else |
636 | + | faceVel = faceVel + bodydoubles[localindex]->getVel(); |
637 | #endif | |
638 | face->addVertex(bodydoubles[localindex]); | |
639 | if( !isSurfaceID[id] ){ | |
# | Line 634 | Line 653 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
653 | } | |
654 | #endif | |
655 | } //Foreachvertex | |
656 | < | |
656 | > | /* |
657 | > | if (!SETempty_(facet->coplanarset)){ |
658 | > | FOREACHpoint_(facet->coplanarset){ |
659 | > | id = qh_pointid(point); |
660 | > | surfaceSDs_.push_back(bodydoubles[id]); |
661 | > | } |
662 | > | } |
663 | > | */ |
664 | > | face->setFacetVelocity(faceVel/3.0); |
665 | Triangles_.push_back(face); | |
666 | qh_settempfree(&vertices); | |
667 | < | |
667 | > | |
668 | } //FORALLfacets | |
669 | ||
670 | < | |
670 | > | /* |
671 | > | std::cout << surfaceSDs_.size() << std::endl; |
672 | > | for (SD = surfaceSDs_.begin(); SD != surfaceSDs_.end(); ++SD){ |
673 | > | Vector3d thisatom = (*SD)->getPos(); |
674 | > | std::cout << "Au " << thisatom.x() << " " << thisatom.y() << " " << thisatom.z() << std::endl; |
675 | > | } |
676 | > | */ |
677 | ||
645 | – | Ns_ = surfaceSDs_.size(); |
678 | ||
679 | ||
680 | < | qh_getarea(qh facet_list); |
681 | < | volume_ = qh totvol; |
682 | < | area_ = qh totarea; |
683 | < | |
684 | < | |
685 | < | |
686 | < | qh_freeqhull(!qh_ALL); |
687 | < | qh_memfreeshort(&curlong, &totlong); |
688 | < | if (curlong || totlong) |
689 | < | std::cerr << "qhull internal warning (main): did not free %d bytes of long memory (%d pieces) " |
690 | < | << totlong << curlong << std::endl; |
691 | < | |
692 | < | |
693 | < | |
680 | > | Ns_ = surfaceSDs_.size(); |
681 | > | nTriangles_ = Triangles_.size(); |
682 | > | |
683 | > | qh_getarea(qh facet_list); |
684 | > | volume_ = qh totvol; |
685 | > | area_ = qh totarea; |
686 | > | |
687 | > | |
688 | > | |
689 | > | qh_freeqhull(!qh_ALL); |
690 | > | qh_memfreeshort(&curlong, &totlong); |
691 | > | if (curlong || totlong) |
692 | > | std::cerr << "qhull internal warning (main): did not free %d bytes of long memory (%d pieces) " |
693 | > | << totlong << curlong << std::endl; |
694 | > | |
695 | > | |
696 | > | |
697 | } | |
698 | ||
699 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |