# | 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.12 2008-10-21 16:44:00 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 437 | Line 438 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
438 | ||
439 | boolT ismalloc = False; | |
440 | /* Clean up memory from previous convex hull calculations*/ | |
441 | + | |
442 | Triangles_.clear(); | |
443 | surfaceSDs_.clear(); | |
444 | surfaceSDs_.reserve(Ns_); | |
# | Line 445 | Line 447 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
447 | const_cast<char *>(options_.c_str()), NULL, stderr)) { | |
448 | ||
449 | sprintf(painCave.errMsg, "ConvexHull: Qhull failed to compute convex hull"); | |
450 | < | painCave.isFatal = 0; |
450 | > | painCave.isFatal = 1; |
451 | simError(); | |
452 | ||
453 | } //qh_new_qhull | |
# | Line 453 | Line 455 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
455 | ||
456 | #ifdef IS_MPI | |
457 | std::vector<double> localPts; | |
458 | + | std::vector<double> localVel; |
459 | int localPtArraySize; | |
460 | ||
461 | ||
# | Line 464 | Line 467 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
467 | if (!facet->simplicial){ | |
468 | // should never happen with Qt | |
469 | sprintf(painCave.errMsg, "ConvexHull: non-simplicaial facet detected"); | |
470 | < | painCave.isFatal = 0; |
470 | > | painCave.isFatal = 1; |
471 | simError(); | |
472 | } | |
473 | ||
# | Line 516 | Line 519 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
519 | localPts.push_back(ptArray[dim_ * idx]); | |
520 | localPts.push_back(ptArray[dim_ * idx + 1]); | |
521 | localPts.push_back(ptArray[dim_ * idx + 2]); | |
522 | + | |
523 | + | Vector3d vel = bodydoubles[idx]->getVel(); |
524 | + | localVel.push_back(vel.x()); |
525 | + | localVel.push_back(vel.y()); |
526 | + | localVel.push_back(vel.z()); |
527 | + | |
528 | localPtsMap.push_back(idx); | |
529 | } | |
530 | ||
# | Line 534 | Line 543 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
543 | int nglobalPts = int(Nsglobal_/3); | |
544 | ||
545 | ||
546 | < | std::vector<double> globalPts; |
547 | < | globalPts.resize(Nsglobal_); |
546 | > | std::vector<double> globalPts(Nsglobal_); |
547 | > | std::vector<double> globalVel(Nsglobal_); |
548 | ||
549 | isSurfaceID.resize(nglobalPts); | |
550 | ||
# | Line 553 | Line 562 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
562 | /* gather the potential hull */ | |
563 | ||
564 | MPI::COMM_WORLD.Allgatherv(&localPts[0],localPtArraySize,MPI::DOUBLE,&globalPts[0],&NstoProc_[0],&displs_[0],MPI::DOUBLE); | |
565 | + | MPI::COMM_WORLD.Allgatherv(&localVel[0],localPtArraySize,MPI::DOUBLE,&globalVel[0],&NstoProc_[0],&displs_[0],MPI::DOUBLE); |
566 | ||
567 | /* | |
568 | if (myrank_ == 0){ | |
# | Line 599 | Line 609 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
609 | simError(); | |
610 | } //simplicical | |
611 | ||
612 | < | Triangle* face = new Triangle(); |
613 | < | Vector3d V3dNormal(facet->normal[0],facet->normal[1],facet->normal[2]); |
614 | < | face->setNormal(V3dNormal); |
615 | < | //face->setCentroid(V3dCentroid); |
612 | > | Triangle face; |
613 | > | Vector3d V3dNormal(facet->normal[0],facet->normal[1],facet->normal[2]); |
614 | > | face.setNormal(V3dNormal); |
615 | > | |
616 | > | |
617 | > | |
618 | RealType faceArea = 0.5*V3dNormal.length(); | |
619 | < | //face->setArea(faceArea); |
619 | > | face.setArea(faceArea); |
620 | ||
621 | ||
622 | vertices = qh_facet3vertex(facet); | |
623 | + | |
624 | + | coordT *center = qh_getcenter(vertices); |
625 | + | Vector3d V3dCentroid(center[0], center[1], center[2]); |
626 | + | face.setCentroid(V3dCentroid); |
627 | + | Vector3d faceVel = V3Zero; |
628 | FOREACHvertex_(vertices){ | |
629 | id = qh_pointid(vertex->point); | |
630 | int localindex = id; | |
631 | #ifdef IS_MPI | |
632 | < | |
632 | > | Vector3d velVector(globalVel[dim_ * id],globalVel[dim_ * id + 1], globalVel[dim_ * id + 1]); |
633 | > | faceVel = faceVel + velVector; |
634 | if (id >= noffset/3 && id < (noffset + localPtArraySize)/3 ){ | |
635 | localindex = localPtsMap[id-noffset/3]; | |
636 | + | #else |
637 | + | faceVel = faceVel + bodydoubles[localindex]->getVel(); |
638 | #endif | |
639 | < | face->addVertex(bodydoubles[localindex]); |
639 | > | face.addVertex(bodydoubles[localindex]); |
640 | if( !isSurfaceID[id] ){ | |
641 | isSurfaceID[id] = true; | |
642 | #ifdef IS_MPI | |
# | Line 630 | Line 650 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
650 | #ifdef IS_MPI | |
651 | ||
652 | }else{ | |
653 | < | face->addVertex(NULL); |
653 | > | face.addVertex(NULL); |
654 | } | |
655 | #endif | |
656 | } //Foreachvertex | |
657 | < | |
657 | > | /* |
658 | > | if (!SETempty_(facet->coplanarset)){ |
659 | > | FOREACHpoint_(facet->coplanarset){ |
660 | > | id = qh_pointid(point); |
661 | > | surfaceSDs_.push_back(bodydoubles[id]); |
662 | > | } |
663 | > | } |
664 | > | */ |
665 | > | face.setFacetVelocity(faceVel/3.0); |
666 | Triangles_.push_back(face); | |
667 | qh_settempfree(&vertices); | |
668 | < | |
668 | > | |
669 | } //FORALLfacets | |
670 | ||
671 | < | |
671 | > | /* |
672 | > | std::cout << surfaceSDs_.size() << std::endl; |
673 | > | for (SD = surfaceSDs_.begin(); SD != surfaceSDs_.end(); ++SD){ |
674 | > | Vector3d thisatom = (*SD)->getPos(); |
675 | > | std::cout << "Au " << thisatom.x() << " " << thisatom.y() << " " << thisatom.z() << std::endl; |
676 | > | } |
677 | > | */ |
678 | ||
645 | – | Ns_ = surfaceSDs_.size(); |
679 | ||
680 | ||
681 | < | qh_getarea(qh facet_list); |
682 | < | volume_ = qh totvol; |
683 | < | area_ = qh totarea; |
684 | < | |
685 | < | |
686 | < | |
687 | < | qh_freeqhull(!qh_ALL); |
688 | < | qh_memfreeshort(&curlong, &totlong); |
689 | < | if (curlong || totlong) |
690 | < | std::cerr << "qhull internal warning (main): did not free %d bytes of long memory (%d pieces) " |
691 | < | << totlong << curlong << std::endl; |
692 | < | |
693 | < | |
694 | < | |
681 | > | Ns_ = surfaceSDs_.size(); |
682 | > | nTriangles_ = Triangles_.size(); |
683 | > | |
684 | > | qh_getarea(qh facet_list); |
685 | > | volume_ = qh totvol; |
686 | > | area_ = qh totarea; |
687 | > | |
688 | > | |
689 | > | |
690 | > | qh_freeqhull(!qh_ALL); |
691 | > | qh_memfreeshort(&curlong, &totlong); |
692 | > | if (curlong || totlong) |
693 | > | std::cerr << "qhull internal warning (main): did not free %d bytes of long memory (%d pieces) " |
694 | > | << totlong << curlong << std::endl; |
695 | > | |
696 | > | |
697 | > | |
698 | } | |
699 | ||
700 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |