00001 00002 #include "mpi.h" 00003 #include "petsc.h" 00004 #include "sys.h" 00005 #include "TreeNode.h" 00006 #include <iostream> 00007 #include <cstdlib> 00008 #include <cstring> 00009 #include "externVars.h" 00010 00011 int main(int argc, char ** argv ) { 00012 bool incCorner = 1; 00013 unsigned int writeBOut = 0; 00014 char n2oOut[256],balOut[256]; 00015 00016 PetscInitialize(&argc,&argv,"options",NULL); 00017 ot::RegisterEvents(); 00018 00019 if(argc < 2) { 00020 std::cerr << "Usage: " << argv[0] << " inpfile writeBOut[0]"<< 00021 " incCorner[1] " << std::endl; 00022 return -1; 00023 } 00024 if(argc > 2) { 00025 writeBOut = atoi(argv[2]); 00026 } 00027 if(argc > 3) { incCorner = (bool)(atoi(argv[3]));} 00028 00029 strcpy(n2oOut, argv[1]); 00030 strcpy(balOut,n2oOut); 00031 strcat(balOut,"_Bal.ot\0"); 00032 strcat(n2oOut,".ot\0"); 00033 std::vector<ot::TreeNode> nodes; 00034 std::vector<ot::TreeNode> linOct; 00035 00036 00037 ot::readNodesFromFile(n2oOut,nodes); 00038 unsigned int dim = nodes[0].getDim(); 00039 unsigned int maxDepth = nodes[0].getMaxDepth(); 00040 00041 ot::TreeNode root(dim,maxDepth); 00042 00043 ot::completeSubtree(root, nodes, linOct, dim, maxDepth, false, false); 00044 00045 std::cout<<"Initial octree size: "<<linOct.size()<<std::endl; 00046 00047 ot::ripple(linOct, incCorner); 00048 00049 std::cout<<"Final octree size: "<<linOct.size()<<std::endl; 00050 00051 if(writeBOut) { 00052 ot::writeNodesToFile(balOut,linOct); 00053 } 00054 00055 PetscFinalize(); 00056 } 00057