# | 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.11 2008-10-20 19:36:32 chuckv Exp $ |
47 | > | * @version $Id: ConvexHull.cpp,v 1.13 2008-11-14 15:44:34 chuckv Exp $ |
48 | * | |
49 | */ | |
50 | ||
# | Line 149 | Line 149 | ConvexHull::ConvexHull() : Hull(){ | |
149 | nproc_ = MPI::COMM_WORLD.Get_size(); | |
150 | myrank_ = MPI::COMM_WORLD.Get_rank(); | |
151 | NstoProc_ = new int[nproc_]; | |
152 | < | displs_ = new int[nproc_]; |
153 | < | |
152 | > | vecdispls_ = new int[nproc_]; |
153 | > | displs_ = new int[nproc_]; |
154 | // Create a surface point type in MPI to send | |
155 | surfacePtType = MPI::DOUBLE.Create_contiguous(3); | |
156 | surfacePtType.Commit(); | |
# | Line 213 | Line 213 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
213 | ||
214 | /* Build a displacements array */ | |
215 | for (int i = 1; i < nproc_; i++){ | |
216 | < | displs_[i] = displs_[i-1] + NstoProc_[i-1]; |
216 | > | vecdispls_[i] = vecdispls_[i-1] + NstoProc_[i-1]; |
217 | } | |
218 | ||
219 | < | int noffset = displs_[myrank_]; |
219 | > | int noffset = vecdispls_[myrank_]; |
220 | /* gather the potential hull */ | |
221 | ||
222 | ||
# | Line 229 | Line 229 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
229 | surfacePtsLocal_.push_back(mpiSurfacePt); | |
230 | } | |
231 | ||
232 | < | MPI::COMM_WORLD.Allgatherv(&surfacePtsLocal_[0],Ns_,surfacePtType,&surfacePtsGlobal_[0],NstoProc_,displs_,surfacePtType); |
232 | > | MPI::COMM_WORLD.Allgatherv(&surfacePtsLocal_[0],Ns_,surfacePtType,&surfacePtsGlobal_[0],NstoProc_,vecdispls_,surfacePtType); |
233 | std::vector<surfacePt_>::iterator spt; | |
234 | std::vector<Enriched_Point_3> gblpoints; | |
235 | ||
# | Line 378 | Line 378 | ConvexHull::ConvexHull() : Hull(), dim_(3), options_(" | |
378 | nproc_ = MPI::COMM_WORLD.Get_size(); | |
379 | myrank_ = MPI::COMM_WORLD.Get_rank(); | |
380 | NstoProc_ = new int[nproc_]; | |
381 | < | displs_ = new int[nproc_]; |
381 | > | vecdispls_ = new int[nproc_]; |
382 | > | vecNstoProc_ = new int[nproc_]; |
383 | > | displs_ = new int[nproc_]; |
384 | ||
385 | // Create a surface point type in MPI to send | |
386 | //surfacePtType = MPI::DOUBLE.Create_contiguous(3); | |
# | Line 438 | Line 440 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
440 | ||
441 | boolT ismalloc = False; | |
442 | /* Clean up memory from previous convex hull calculations*/ | |
443 | + | |
444 | Triangles_.clear(); | |
445 | surfaceSDs_.clear(); | |
446 | surfaceSDs_.reserve(Ns_); | |
# | Line 455 | Line 458 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
458 | #ifdef IS_MPI | |
459 | std::vector<double> localPts; | |
460 | std::vector<double> localVel; | |
461 | + | std::vector<double> localMass; |
462 | int localPtArraySize; | |
463 | ||
464 | ||
# | Line 485 | Line 489 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
489 | ||
490 | ||
491 | ||
488 | – | /* |
489 | – | std::sort(surfaceIDs.begin(),surfaceIDs.end()); |
490 | – | surfaceIDs.erase(std::unique(surfaceIDs.begin(), surfaceIDs.end()), surfaceIDs.end()); |
491 | – | int localPtArraySize = surfaceIDs.size() * 3; |
492 | – | */ |
492 | ||
494 | – | //localPts.resize(localPtArraySize); |
495 | – | //std::fill(localPts.begin(),localPts.end(),0.0); |
496 | – | |
497 | – | |
493 | int idx = 0; | |
494 | int nIsIts = 0; | |
500 | – | /* |
501 | – | // Copy the surface points into an array. |
502 | – | for(std::vector<bool>::iterator list_iter = isSurfaceID.begin(); |
503 | – | list_iter != isSurfaceID.end(); list_iter++) |
504 | – | { |
505 | – | bool isIt = *list_iter; |
506 | – | if (isIt){ |
507 | – | localPts.push_back(ptArray[dim_ * idx]); |
508 | – | localPts.push_back(ptArray[dim_ * idx + 1]); |
509 | – | localPts.push_back(ptArray[dim_ * idx + 2]); |
510 | – | localPtsMap.push_back(idx); |
511 | – | nIsIts++; |
512 | – | } //Isit |
513 | – | idx++; |
514 | – | } //isSurfaceID |
515 | – | */ |
495 | FORALLvertices { | |
496 | idx = qh_pointid(vertex->point); | |
497 | localPts.push_back(ptArray[dim_ * idx]); | |
# | Line 524 | Line 503 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
503 | localVel.push_back(vel.y()); | |
504 | localVel.push_back(vel.z()); | |
505 | ||
506 | + | RealType bdmass = bodydoubles[idx]->getMass(); |
507 | + | localMass.push_back(bdmass); |
508 | + | |
509 | localPtsMap.push_back(idx); | |
510 | + | |
511 | + | |
512 | } | |
513 | ||
514 | ||
531 | – | localPtArraySize = localPts.size(); |
515 | ||
516 | + | localPtArraySize = int(localPts.size()/3.0); |
517 | + | |
518 | ||
519 | MPI::COMM_WORLD.Allgather(&localPtArraySize,1,MPI::INT,&NstoProc_[0],1,MPI::INT); | |
520 | < | |
520 | > | |
521 | Nsglobal_=0; | |
522 | for (int i = 0; i < nproc_; i++){ | |
523 | Nsglobal_ += NstoProc_[i]; | |
524 | + | vecNstoProc_[i] = NstoProc_[i]*3; |
525 | } | |
526 | ||
527 | ||
528 | < | int nglobalPts = int(Nsglobal_/3); |
528 | > | int nglobalPts = Nsglobal_*3; |
529 | ||
530 | ||
531 | < | std::vector<double> globalPts(Nsglobal_); |
532 | < | std::vector<double> globalVel(Nsglobal_); |
531 | > | std::vector<double> globalPts(nglobalPts); |
532 | > | std::vector<double> globalVel(nglobalPts); |
533 | > | std::vector<double> globalMass(Nsglobal_); |
534 | ||
535 | isSurfaceID.resize(nglobalPts); | |
536 | ||
537 | ||
538 | std::fill(globalPts.begin(),globalPts.end(),0.0); | |
539 | ||
540 | < | displs_[0] = 0; |
540 | > | vecdispls_[0] = 0; |
541 | /* Build a displacements array */ | |
542 | for (int i = 1; i < nproc_; i++){ | |
543 | < | displs_[i] = displs_[i-1] + NstoProc_[i-1]; |
543 | > | vecdispls_[i] = vecdispls_[i-1] + vecNstoProc_[i-1]; |
544 | } | |
545 | ||
546 | + | displs_[0] = 0; |
547 | + | for (int i = 1; i < nproc_; i++){ |
548 | + | displs_[i] = displs_[i-1] + NstoProc_[i-1]; |
549 | + | } |
550 | ||
551 | < | int noffset = displs_[myrank_]; |
551 | > | int noffset = vecdispls_[myrank_]; |
552 | /* gather the potential hull */ | |
553 | ||
554 | < | MPI::COMM_WORLD.Allgatherv(&localPts[0],localPtArraySize,MPI::DOUBLE,&globalPts[0],&NstoProc_[0],&displs_[0],MPI::DOUBLE); |
555 | < | MPI::COMM_WORLD.Allgatherv(&localVel[0],localPtArraySize,MPI::DOUBLE,&globalVel[0],&NstoProc_[0],&displs_[0],MPI::DOUBLE); |
556 | < | |
554 | > | MPI::COMM_WORLD.Allgatherv(&localPts[0],localPtArraySize,MPI::DOUBLE,&globalPts[0],&vecNstoProc_[0],&vecdispls_[0],MPI::DOUBLE); |
555 | > | MPI::COMM_WORLD.Allgatherv(&localVel[0],localPtArraySize,MPI::DOUBLE,&globalVel[0],&vecNstoProc_[0],&vecdispls_[0],MPI::DOUBLE); |
556 | > | MPI::COMM_WORLD.Allgatherv(&localMass[0],localPtArraySize,MPI::DOUBLE,&globalMass[0],&NstoProc_[0],&displs_[0],MPI::DOUBLE); |
557 | /* | |
558 | if (myrank_ == 0){ | |
559 | for (i = 0; i < globalPts.size(); i++){ | |
# | Line 608 | Line 599 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
599 | simError(); | |
600 | } //simplicical | |
601 | ||
602 | < | Triangle* face = new Triangle(); |
602 | > | Triangle face; |
603 | Vector3d V3dNormal(facet->normal[0],facet->normal[1],facet->normal[2]); | |
604 | < | face->setNormal(V3dNormal); |
604 | > | face.setNormal(V3dNormal); |
605 | ||
606 | ||
607 | ||
608 | < | RealType faceArea = 0.5*V3dNormal.length(); |
609 | < | face->setArea(faceArea); |
608 | > | //RealType faceArea = 0.5*V3dNormal.length(); |
609 | > | RealType faceArea = qh_facetarea(facet); |
610 | > | face.setArea(faceArea); |
611 | ||
612 | ||
613 | vertices = qh_facet3vertex(facet); | |
614 | ||
615 | coordT *center = qh_getcenter(vertices); | |
616 | Vector3d V3dCentroid(center[0], center[1], center[2]); | |
617 | < | face->setCentroid(V3dCentroid); |
617 | > | face.setCentroid(V3dCentroid); |
618 | Vector3d faceVel = V3Zero; | |
619 | + | Vector3d p[3]; |
620 | + | RealType faceMass = 0.0; |
621 | + | int ver = 0; |
622 | FOREACHvertex_(vertices){ | |
623 | id = qh_pointid(vertex->point); | |
624 | + | p[ver][0] = vertex->point[0]; |
625 | + | p[ver][1] = vertex->point[1]; |
626 | + | p[ver][2] = vertex->point[2]; |
627 | int localindex = id; | |
628 | #ifdef IS_MPI | |
629 | Vector3d velVector(globalVel[dim_ * id],globalVel[dim_ * id + 1], globalVel[dim_ * id + 1]); | |
630 | + | |
631 | faceVel = faceVel + velVector; | |
632 | + | faceMass = faceMass + globalMass[id]; |
633 | if (id >= noffset/3 && id < (noffset + localPtArraySize)/3 ){ | |
634 | localindex = localPtsMap[id-noffset/3]; | |
635 | #else | |
636 | faceVel = faceVel + bodydoubles[localindex]->getVel(); | |
637 | + | faceMass = faceMass + bodydoubles[localindex]->getMass(); |
638 | #endif | |
639 | < | face->addVertex(bodydoubles[localindex]); |
639 | > | face.addVertexSD(bodydoubles[localindex]); |
640 | if( !isSurfaceID[id] ){ | |
641 | isSurfaceID[id] = true; | |
642 | #ifdef IS_MPI | |
# | Line 649 | Line 650 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
650 | #ifdef IS_MPI | |
651 | ||
652 | }else{ | |
653 | < | face->addVertex(NULL); |
653 | > | face.addVertexSD(NULL); |
654 | } | |
655 | #endif | |
656 | + | ver++; |
657 | } //Foreachvertex | |
658 | /* | |
659 | if (!SETempty_(facet->coplanarset)){ | |
# | Line 661 | Line 663 | void ConvexHull::computeHull(std::vector<StuntDouble*> | |
663 | } | |
664 | } | |
665 | */ | |
666 | < | face->setFacetVelocity(faceVel/3.0); |
666 | > | face.addVertices(p[0],p[1],p[2]); |
667 | > | face.setFacetMass(faceMass); |
668 | > | face.setFacetVelocity(faceVel/3.0); |
669 | Triangles_.push_back(face); | |
670 | qh_settempfree(&vertices); | |
671 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |