Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rippleBal.C

Go to the documentation of this file.
00001 
00002 #include "mpi.h"
00003 #include "petsc.h"
00004 #include "sys.h"
00005 #include "parUtils.h"
00006 #include "octUtils.h"
00007 #include "TreeNode.h"
00008 #include <cstdlib>
00009 #include <cstring>
00010 #include "externVars.h"
00011 #include "dendro.h"
00012 
00013 //Don't want time to be synchronized. Need to check load imbalance.
00014 #ifdef MPI_WTIME_IS_GLOBAL
00015 #undef MPI_WTIME_IS_GLOBAL
00016 #endif
00017 
00018 int main(int argc, char ** argv ) {     
00019   int size, rank;
00020   bool incCorner = 1; 
00021   bool rePart = 1;
00022   bool checkBailOut = 1; 
00023   unsigned int writeBOut = 0;
00024   unsigned int rippleType = 2;
00025   char Kstr[20];
00026   char inpFileName[50],n2oOut[50],balOut[50];
00027 
00028   PetscInitialize(&argc,&argv,"options",NULL);
00029   ot::RegisterEvents();
00030 
00031 #ifdef PETSC_USE_LOG
00032   int stages[1];
00033   PetscLogStageRegister(&stages[0],"Bal");
00034 #endif
00035 
00036   MPI_Comm_size(MPI_COMM_WORLD,&size);
00037   MPI_Comm_rank(MPI_COMM_WORLD,&rank);
00038   if(argc < 2) {
00039     std::cerr << "Usage: " << argv[0] << " inpfile writeBOut[0]"<<
00040       " incCorner[1] checkBailOut[1] rePart[1] rippleType[2] "  << std::endl;
00041     return -1;
00042   }
00043   if(argc > 2) {
00044     writeBOut = atoi(argv[2]);
00045   }
00046   if(argc > 3) { incCorner = (bool)(atoi(argv[3]));}
00047   if(argc > 4) { checkBailOut = (bool)(atoi(argv[4]));}
00048   if(argc > 5) { rePart = (bool)(atoi(argv[5]));}
00049   if(argc > 6) { rippleType = atoi(argv[6]);}
00050 
00051   strcpy(inpFileName, argv[1]);
00052   strcpy(balOut,inpFileName);
00053   ot::int2str(rank,Kstr);
00054   strcat(balOut,Kstr);
00055   strcat(balOut,"_\0");
00056   ot::int2str(size,Kstr);
00057   strcat(balOut,Kstr);
00058   strcpy(n2oOut,balOut);
00059   strcat(balOut,"_Bal.ot\0");
00060   strcat(n2oOut,".ot\0");
00061   std::vector<ot::TreeNode> nodes;
00062   std::vector<ot::TreeNode> linOct;
00063 
00064   ot::readNodesFromFile(n2oOut,nodes);
00065   unsigned int dim = nodes[0].getDim();
00066   unsigned int maxDepth = nodes[0].getMaxDepth();
00067   MPI_Barrier(MPI_COMM_WORLD);  
00068 #ifdef PETSC_USE_LOG
00069   PetscLogStagePush(stages[0]);
00070 #endif
00071   ot::completeOctree(nodes,linOct,dim,maxDepth,false, false, false, MPI_COMM_WORLD);
00072   if(rippleType == 1) {
00073     if(!rank) {
00074       std::cout<<"Type 1 ripple."<<std::endl;
00075     }
00076     ot::parallelRippleType1(linOct,incCorner,checkBailOut,rePart,dim, maxDepth, MPI_COMM_WORLD);
00077   }else if(rippleType == 2) {
00078     if(!rank) {
00079       std::cout<<"Type 2 ripple."<<std::endl;
00080     }
00081     ot::parallelRippleType2(linOct,incCorner,checkBailOut,rePart,dim, maxDepth, MPI_COMM_WORLD);
00082   }else {
00083     if(!rank) {
00084       std::cout<<"Type 3 ripple."<<std::endl;
00085     }
00086     ot::parallelRippleType3(linOct,incCorner,checkBailOut,rePart,dim, maxDepth, MPI_COMM_WORLD);
00087   }
00088 #ifdef PETSC_USE_LOG
00089   PetscLogStagePop();
00090 #endif
00091 
00092   DendroIntL locOutSize = linOct.size();
00093   DendroIntL globOutSize;
00094 
00095   par::Mpi_Reduce<DendroIntL>(&locOutSize, &globOutSize, 1, MPI_SUM, 0, MPI_COMM_WORLD);
00096 
00097   if(!rank) {
00098           std::cout<<"Final Balanced Octree Size: "<<globOutSize<<std::endl;
00099   }
00100 
00101 
00102   if(writeBOut) { 
00103     ot::writeNodesToFile(balOut,linOct);
00104   }
00105 
00106   PetscFinalize();
00107 
00108 }
00109 

Generated on Tue Mar 24 16:13:59 2009 for DENDRO by  doxygen 1.3.9.1