Commits

Rio Yokota committed 3109d24

Unify function call format.

Comments (0)

Files changed (9)

examples/parallel.cxx

     FMM.setLET(cells);
     FMM.commBodies();
     FMM.commCells();
-    FMM.evaluate(cells,cells);
+    FMM.evaluate(cells, cells);
     jbodies = bodies;
     for( int irank=1; irank<FMM.MPISIZE; irank++ ) {
       FMM.getLET(jcells,(FMM.MPIRANK+irank)%FMM.MPISIZE);
 #if 0 // Set to 1 for debugging full LET communication : Step 2 (LET must be set to full tree)
       FMM.shiftBodies(jbodies); // This will overwrite recvBodies. (define recvBodies2 in partition.h to avoid this)
       Cells icells;
-      FMM.buildTree(jbodies,icells);
+      FMM.buildTree(jbodies, icells);
       FMM.upwardPass(icells);
       assert( icells.size() == jcells.size() );
       CellQueue Qi, Qj;
       }
       assert( ic == int(icells.size()) );
 #endif
-      FMM.evaluate(cells,jcells);
+      FMM.evaluate(cells, jcells);
     }
 #else
     jbodies = bodies;
       FMM.shiftBodies(jbodies);
       jcells.clear();
       FMM.setBounds(jbodies);
-      FMM.buildTree(jbodies,jcells);
+      FMM.buildTree(jbodies, jcells);
       FMM.upwardPass(jcells);
-      FMM.evaluate(cells,jcells);
+      FMM.evaluate(cells, jcells);
     }
 #endif
 
     FMM.startTimer("Direct sum");
     for( int i=0; i!=FMM.MPISIZE; ++i ) {
       FMM.shiftBodies(jbodies);
-      FMM.direct(bodies2,jbodies);
+      FMM.direct(bodies2, jbodies);
       if(FMM.printNow) std::cout << "Direct loop          : " << i+1 << "/" << FMM.MPISIZE << std::endl;
     }
     FMM.normalize(bodies2);
     FMM.stopTimer("Direct sum",FMM.printNow);
     FMM.eraseTimer("Direct sum");
     double diff1 = 0, norm1 = 0, diff2 = 0, norm2 = 0, diff3 = 0, norm3 = 0, diff4 = 0, norm4 = 0;
-    DATA.evalError(bodies,bodies2,diff1,norm1,diff2,norm2);
-    MPI_Reduce(&diff1,&diff3,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
-    MPI_Reduce(&norm1,&norm3,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
-    MPI_Reduce(&diff2,&diff4,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
-    MPI_Reduce(&norm2,&norm4,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
-    if(FMM.printNow) DATA.printError(diff3,norm3,diff4,norm4);
+    DATA.evalError(bodies, bodies2, diff1, norm1, diff2, norm2);
+    MPI_Reduce(&diff1, &diff3, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
+    MPI_Reduce(&norm1, &norm3, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
+    MPI_Reduce(&diff2, &diff4, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
+    MPI_Reduce(&norm2, &norm4, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
+    if(FMM.printNow) DATA.printError(diff3, norm3, diff4, norm4);
   }
 
 #ifdef VTK
     FMM.startTimer("Direct sum");
     FMM.direct(bodies2, jbodies);
     FMM.normalize(bodies2);
-    FMM.stopTimer("Direct sum",FMM.printNow);
+    FMM.stopTimer("Direct sum", FMM.printNow);
     FMM.eraseTimer("Direct sum");
     double diff1 = 0, norm1 = 0, diff2 = 0, norm2 = 0;
     DATA.evalError(bodies, bodies2, diff1, norm1, diff2, norm2);
     real_t dx = rad+std::abs(X[0]-C->X[0]);                     // Add x distance from center of mass
     real_t dy = rad+std::abs(X[1]-C->X[1]);                     // Add y distance from center of mass
     real_t dz = rad+std::abs(X[2]-C->X[2]);                     // Add z distance from center of mass
-    return std::sqrt( dx*dx + dy*dy + dz*dz );                  // Return scalar distance
+    return std::sqrt(dx * dx + dy * dy + dz * dz);              // Return scalar distance
   }
 
 //! Approximate interaction between two cells
   inline void approximate(C_iter Ci, C_iter Cj, bool mutual) {
 #if AUTO
     if (timeP2P*Ci->NDBODY*Cj->NDBODY > timeM2L) {              // If M2L is faster
-      M2L(Ci,Cj,mutual);                                        //  M2L kernel
+      M2L(Ci, Cj, mutual);                                      //  M2L kernel
       count(NM2L);                                              //  Increment M2L counter
     } else {                                                    // Else if P2P is faster
-      P2P(Ci,Cj,mutual);                                        //  P2P kernel
+      P2P(Ci, Cj, mutual);                                      //  P2P kernel
       count(NP2P);                                              //  Increment P2P counter
     }                                                           // End if for fastest kernel
 #else
 
   void traverse(C_iter CiBegin, C_iter CiEnd, C_iter CjBegin, C_iter CjEnd, bool mutual) {
     if (CiEnd - CiBegin == 1 || CjEnd - CjBegin == 1) {
-      if (CiBegin == CjBegin) {                                 // TODO : unecessary?
+      if (CiBegin == CjBegin) {
         assert(CiEnd == CjEnd);
         traverse(CiBegin, CjBegin, mutual);
       } else {
     if (Cj->NCHILD == 0) {
       assert(Ci->NCHILD > 0);
       for (C_iter ci=Ci0+Ci->CHILD; ci!=Ci0+Ci->CHILD+Ci->NCHILD; ci++ ) {
-        traverse(ci,Cj,mutual);
+        traverse(ci, Cj, mutual);
       }
     } else if (Ci->NCHILD == 0) {
       assert(Cj->NCHILD > 0);
       for (C_iter cj=Cj0+Cj->CHILD; cj!=Cj0+Cj->CHILD+Cj->NCHILD; cj++ ) {
-        traverse(Ci,cj,mutual);
+        traverse(Ci, cj, mutual);
       }
     } else if (Ci->NDBODY + Cj->NDBODY >= NSPAWN || (mutual && Ci == Cj)) {
       traverse(Ci0+Ci->CHILD, Ci0+Ci->CHILD+Ci->NCHILD,
                Cj0+Cj->CHILD, Cj0+Cj->CHILD+Cj->NCHILD, mutual);
     } else if (Ci->RCRIT >= Cj->RCRIT) {
       for (C_iter ci=Ci0+Ci->CHILD; ci!=Ci0+Ci->CHILD+Ci->NCHILD; ci++ ) {
-        traverse(ci,Cj,mutual);
+        traverse(ci, Cj, mutual);
       } 
     } else {
       for (C_iter cj=Cj0+Cj->CHILD; cj!=Cj0+Cj->CHILD+Cj->NCHILD; cj++ ) {
-        traverse(Ci,cj,mutual);
+        traverse(Ci, cj, mutual);
       }
     }
   }
     {                                                           // Dummy bracket
 #else
     if (Ci->RCRIT != Cj->RCRIT) {                               // If cell is not at the same level
-      splitCell(Ci,Cj,mutual);                                  //  Split cell and call function recursively for child
+      splitCell(Ci, Cj, mutual);                                //  Split cell and call function recursively for child
     } else {                                                    // If we don't care if cell is not at the same level
 #endif
       if (R2 > (Ci->RCRIT+Cj->RCRIT)*(Ci->RCRIT+Cj->RCRIT)) {   //  If distance is far enough
-        approximate(Ci,Cj,mutual);                              //   Use approximate kernels
+        approximate(Ci, Cj, mutual);                            //   Use approximate kernels
       } else if (Ci->NCHILD == 0 && Cj->NCHILD == 0) {          //  Else if both cells are bodies
         if (Cj->NCBODY == 0) {                                  //   If the bodies weren't sent from remote node
-          approximate(Ci,Cj,mutual);                            //    Use approximate kernels
+          approximate(Ci, Cj, mutual);                          //    Use approximate kernels
         } else {                                                //   Else if the bodies were sent
           if (Ci == Cj) {                                       //    If source and target are same
             P2P(Ci);                                            //     P2P kernel for single cell
           } else {                                              //    Else if source and target are different
-            P2P(Ci,Cj,mutual);                                  //     P2P kernel for pair of cells
+            P2P(Ci, Cj, mutual);                                //     P2P kernel for pair of cells
           }                                                     //    End if for same source and target
           count(NP2P);                                          //    Increment P2P counter
         }                                                       //   End if for bodies
       } else {                                                  //  Else if cells are close but not bodies
-        splitCell(Ci,Cj,mutual);                                //   Split cell and call function recursively for child
+        splitCell(Ci, Cj, mutual);                              //   Split cell and call function recursively for child
       }                                                         //  End if for multipole acceptance
     }                                                           // End if for same level cells
   }
       Ci->M = 0;                                                //  Reset multipoles of periodic parent
       real_t Rmax = 0;                                          //  Dummy parameter for calling M2M
       setCenter(Ci);                                            //  Set center of mass for periodic parent
-      M2M(Ci,Rmax);                                             //  Evaluate periodic M2M kernels for this sublevel
+      M2M(Ci, Rmax);                                            //  Evaluate periodic M2M kernels for this sublevel
       R *= 3;                                                   //  Increase center cell size three times
       Cj0 = C0;                                                 //  Reset Cj0 back
     }                                                           // End loop over sublevels of tree
     double endTimer = get_time();                               // Get time of day and store in endTimer
     timer[event] += endTimer - beginTimer[event];               // Accumulate event time to timer
     if (print) std::cout << std::setw(stringLength) << std::left// Set format
-                        << event << " : " << timer[event] << std::endl;// Print event and timer to screen
+      << event << " : " << timer[event] << std::endl;           // Print event and timer to screen
     return endTimer - beginTimer[event];                        // Return the event time
   }
 
 //! Print timings of a specific event
   inline void printTime(std::string event) {
     std::cout << std::setw(stringLength) << std::left           // Set format
-              << event << " : " << timer[event] << std::endl;   // Print event and timer
+      << event << " : " << timer[event] << std::endl;           // Print event and timer
   }
 
 //! Print timings of all events
   inline void printAllTime() {
     for (T_iter E=timer.begin(); E!=timer.end(); E++) {         // Loop over all events
       std::cout << std::setw(stringLength) << std::left         //  Set format
-                << E->first << " : " << E->second << std::endl; //  Print event and timer
+        << E->first << " : " << E->second << std::endl;         //  Print event and timer
     }                                                           // End loop over all events
   }
 
   inline void writeTime() {
     for (T_iter E=timer.begin(); E!=timer.end(); E++) {        // Loop over all events
       timerFile << std::setw(stringLength) << std::left         //  Set format
-                << E->first << " " << E->second << std::endl;   //  Print event and timer
+        << E->first << " " << E->second << std::endl;           //  Print event and timer
     }                                                           // End loop over all events
   }
 
     long long values[3] = {0,0,0};                              // Values for each event
     PAPI_stop(PAPIEVENT,values);                                // PAPI stop
     std::cout << "--- PAPI stats -------------------" << std::endl
-    << std::setw(stringLength) << std::left                     // Set format
-    << "L2 Miss"    << " : " << values[0] << std::endl          // Print L2 Misses
-    << std::setw(stringLength) << std::left                     // Set format
-    << "L2 Access"  << " : " << values[1] << std::endl          // Print L2 Access
-    << std::setw(stringLength) << std::left                     // Set format
-    << "TLB Miss"   << " : " << values[2] << std::endl          // Print TLB Misses
-    << "--- PAPI stats -------------------" << std::endl;
+      << std::setw(stringLength) << std::left                   // Set format
+      << "L2 Miss"    << " : " << values[0] << std::endl        // Print L2 Misses
+      << std::setw(stringLength) << std::left                   // Set format
+      << "L2 Access"  << " : " << values[1] << std::endl        // Print L2 Access
+      << std::setw(stringLength) << std::left                   // Set format
+      << "TLB Miss"   << " : " << values[2] << std::endl        // Print TLB Misses
+      << "--- PAPI stats -------------------" << std::endl;
 #endif
   }
 
     sprintf(fname,"trace%4.4d.svg",mpirank);                    // Create file name for trace
     std::ofstream traceFile(fname);                             // Open trace log file
     traceFile << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" // Header statements for trace log file
-        << "<!DOCTYPE svg PUBLIC \"-_W3C_DTD SVG 1.0_EN\" \"http://www.w3.org/TR/SVG/DTD/svg10.dtd\">\n"
-        << "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
-        << "  width=\"200mm\" height=\"40mm\" viewBox=\"0 0 20000 4000\">\n"
-        << "  <g>\n";
+      << "<!DOCTYPE svg PUBLIC \"-_W3C_DTD SVG 1.0_EN\" \"http://www.w3.org/TR/SVG/DTD/svg10.dtd\">\n"
+      << "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
+      << "  width=\"200mm\" height=\"40mm\" viewBox=\"0 0 20000 4000\">\n"
+      << "  <g>\n";
     int num_thread = 0;                                         // Counter for number of threads to trace
     ThreadMap threadMap;                                        // Map pthread ID to thread ID
     double base = traces.front().begin;                         // Base time
       begin -= base;                                            //  Subtract base time from begin time
       end   -= base;                                            //  Subtract base time from end time
       traceFile << "    <rect x=\"" << begin * scale            //  x position of bar plot
-          << "\" y=\"" << (threadMap[thread] - 1) * 100.0       //  y position of bar plot
-          << "\" width=\"" << (end - begin) * scale             //  width of bar
-          << "\" height=\"90.0\" fill=\"#"<< std::setfill('0') << std::setw(6) << std::hex << color// height of bar
-          << "\" stroke=\"#000000\" stroke-width=\"1\"/>\n";    //  stroke color and width
+        << "\" y=\"" << (threadMap[thread] - 1) * 100.0         //  y position of bar plot
+        << "\" width=\"" << (end - begin) * scale               //  width of bar
+        << "\" height=\"90.0\" fill=\"#"<< std::setfill('0') << std::setw(6) << std::hex << color// height of bar
+        << "\" stroke=\"#000000\" stroke-width=\"1\"/>\n";      //  stroke color and width
     }                                                           // End while loop for queue of traces
     traceFile << "  </g>\n" "</svg>\n";                         // Footer for trace log file 
     traceFile.close();                                          // Close trace log file
 #define mympi_h
 #include <mpi.h>
 #include <typeinfo>
-#include "types.h"
 
 //! Custom MPI utilities
 class MyMPI {
     int argc(0);                                                // Dummy argument count
     char **argv;                                                // Dummy argument value
     MPI_Initialized(&EXTERNAL);                                 // Check if MPI_Init has been called
-    if (!EXTERNAL) MPI_Init(&argc,&argv);                       // Initialize MPI communicator
-    MPI_Comm_size(MPI_COMM_WORLD,&MPISIZE);                     // Get number of MPI processes
-    MPI_Comm_rank(MPI_COMM_WORLD,&MPIRANK);                     // Get rank of current MPI process
+    if (!EXTERNAL) MPI_Init(&argc, &argv);                      // Initialize MPI communicator
+    MPI_Comm_size(MPI_COMM_WORLD, &MPISIZE);                    // Get number of MPI processes
+    MPI_Comm_rank(MPI_COMM_WORLD, &MPIRANK);                    // Get rank of current MPI process
   }
 
 //! Destructor

include/parallelfmm.h

       C_iter C = cellQueue.front();                             //  Get front item in traversal queue
       cellQueue.pop();                                          //  Pop item from traversal queue
       for (C_iter CC=Cj0+C->CHILD; CC!=Cj0+C->CHILD+C->NCHILD; CC++) {// Loop over child cells
-        addSendCell(CC,iparent,icell);                          //   Add cells to send
+        addSendCell(CC, iparent, icell);                        //   Add cells to send
         if (CC->NCHILD == 0) {                                  //   If cell is twig
-          addSendBody(CC,ibody,icell);                          //    Add bodies to send
+          addSendBody(CC, ibody, icell);                        //    Add bodies to send
         } else {                                                //   If cell is not twig
           bool divide = false;                                  //    Initialize logical for dividing
           if (IMAGES == 0) {                                    //    If free boundary condition
 
 //! Exchange send count for cells
   void alltoall(Cells) {
-    MPI_Alltoall(sendCellCount,1,MPI_INT,                       // Communicate send count to get receive count
-                 recvCellCount,1,MPI_INT,MPI_COMM_WORLD);
+    MPI_Alltoall(sendCellCount, 1, MPI_INT,                     // Communicate send count to get receive count
+                 recvCellCount, 1, MPI_INT, MPI_COMM_WORLD);
     recvCellDispl[0] = 0;                                       // Initialize receive displacements
     for (int irank=0; irank<MPISIZE-1; irank++) {               // Loop over ranks
       recvCellDispl[irank+1] = recvCellDispl[irank] + recvCellCount[irank];//  Set receive displacement
       recvCellCount[irank] *= word;                             //  Multiply receive count by word size of data
       recvCellDispl[irank] *= word;                             //  Multiply receive displacement by word size of data
     }                                                           // End loop over ranks
-    MPI_Alltoallv(&cells[0],sendCellCount,sendCellDispl,MPI_INT,// Communicate cells
-                  &recvCells[0],recvCellCount,recvCellDispl,MPI_INT,MPI_COMM_WORLD);
+    MPI_Alltoallv(&cells[0], sendCellCount, sendCellDispl, MPI_INT,// Communicate cells
+                  &recvCells[0], recvCellCount, recvCellDispl, MPI_INT, MPI_COMM_WORLD);
     for (int irank=0; irank<MPISIZE; irank++) {                 // Loop over ranks
       sendCellCount[irank] /= word;                             //  Divide send count by word size of data
       sendCellDispl[irank] /= word;                             //  Divide send displacement by word size of data
 private:
 //! Allreduce bounds from all ranks
   void allreduceBounds() {
-    MPI_Allreduce(localXmin,globalXmin,3,MPI_FLOAT,MPI_MIN,MPI_COMM_WORLD);// Reduce domain Xmin
-    MPI_Allreduce(localXmax,globalXmax,3,MPI_FLOAT,MPI_MAX,MPI_COMM_WORLD);// Reduce domain Xmax
+    MPI_Allreduce(localXmin, globalXmin, 3, MPI_FLOAT, MPI_MIN, MPI_COMM_WORLD);// Reduce domain Xmin
+    MPI_Allreduce(localXmax, globalXmax, 3, MPI_FLOAT, MPI_MAX, MPI_COMM_WORLD);// Reduce domain Xmax
     globalRadius = 0;                                           // Initialize global radius
     globalCenter = (globalXmax + globalXmin) / 2;               //  Calculate global center
     for (int d=0; d<3; d++) {                                   // Loop over dimensions
 
 //! Allgather bounds of all partitions
   void allgatherBounds() {
-    MPI_Allgather(localXmin,3,MPI_FLOAT,&rankXmin[0],3,MPI_FLOAT,MPI_COMM_WORLD);// Gather all domain bounds
-    MPI_Allgather(localXmax,3,MPI_FLOAT,&rankXmax[0],3,MPI_FLOAT,MPI_COMM_WORLD);// Gather all domain bounds
+    MPI_Allgather(localXmin, 3, MPI_FLOAT, &rankXmin[0], 3, MPI_FLOAT, MPI_COMM_WORLD);// Gather all domain bounds
+    MPI_Allgather(localXmax, 3, MPI_FLOAT, &rankXmax[0], 3, MPI_FLOAT, MPI_COMM_WORLD);// Gather all domain bounds
   }
 
 //! Set partition of global domain
       sendBodyCount[B->IPROC]++;                                //  Fill send count bucket
       B->IPROC = MPIRANK;                                       //  Tag for sending back to original rank
     }                                                           // End loop over bodies
-    MPI_Alltoall(sendBodyCount,1,MPI_INT,                       // Communicate send count to get receive count
-                 recvBodyCount,1,MPI_INT,MPI_COMM_WORLD);
+    MPI_Alltoall(sendBodyCount, 1, MPI_INT,                     // Communicate send count to get receive count
+                 recvBodyCount, 1, MPI_INT, MPI_COMM_WORLD);
     sendBodyDispl[0] = recvBodyDispl[0] = 0;                    // Initialize send/receive displacements
     for (int irank=0; irank<MPISIZE-1; irank++) {               // Loop over ranks
       sendBodyDispl[irank+1] = sendBodyDispl[irank] + sendBodyCount[irank];//  Set send displacement
       recvBodyCount[irank] *= word;                             //  Multiply receive count by word size of data
       recvBodyDispl[irank] *= word;                             //  Multiply receive displacement by word size of data
     }                                                           // End loop over ranks
-    MPI_Alltoallv(&bodies[0],sendBodyCount,sendBodyDispl,MPI_INT,// Communicate bodies
-                  &recvBodies[0],recvBodyCount,recvBodyDispl,MPI_INT,MPI_COMM_WORLD);
+    MPI_Alltoallv(&bodies[0], sendBodyCount, sendBodyDispl, MPI_INT,// Communicate bodies
+                  &recvBodies[0], recvBodyCount, recvBodyDispl, MPI_INT, MPI_COMM_WORLD);
     for (int irank=0; irank<MPISIZE; irank++) {                 // Loop over ranks
       sendBodyCount[irank] /= word;                             //  Divide send count by word size of data
       sendBodyDispl[irank] /= word;                             //  Divide send displacement by word size of data
     const int irecv = (MPIRANK - 1 + MPISIZE) % MPISIZE;        // Receive from previous rank (wrap around)
     MPI_Request sreq,rreq;                                      // Send, receive request handles
 
-    MPI_Isend(&oldSize,1,MPI_INT,irecv,0,MPI_COMM_WORLD,&sreq); // Send current number of bodies
-    MPI_Irecv(&newSize,1,MPI_INT,isend,0,MPI_COMM_WORLD,&rreq); // Receive new number of bodies
-    MPI_Wait(&sreq,MPI_STATUS_IGNORE);                          // Wait for send to complete
-    MPI_Wait(&rreq,MPI_STATUS_IGNORE);                          // Wait for receive to complete
+    MPI_Isend(&oldSize, 1, MPI_INT, irecv, 0, MPI_COMM_WORLD, &sreq);// Send current number of bodies
+    MPI_Irecv(&newSize, 1, MPI_INT, isend, 0, MPI_COMM_WORLD, &rreq);// Receive new number of bodies
+    MPI_Wait(&sreq, MPI_STATUS_IGNORE);                         // Wait for send to complete
+    MPI_Wait(&rreq, MPI_STATUS_IGNORE);                         // Wait for receive to complete
 
     recvBodies.resize(newSize);                                 // Resize buffer to new number of bodies
-    MPI_Isend(&bodies[0],oldSize*word,MPI_INT,irecv,            // Send bodies to next rank
-              1,MPI_COMM_WORLD,&sreq);
-    MPI_Irecv(&recvBodies[0],newSize*word,MPI_INT,isend,        // Receive bodies from previous rank
-              1,MPI_COMM_WORLD,&rreq);
-    MPI_Wait(&sreq,MPI_STATUS_IGNORE);                          // Wait for send to complete
-    MPI_Wait(&rreq,MPI_STATUS_IGNORE);                          // Wait for receive to complete
+    MPI_Isend(&bodies[0], oldSize*word, MPI_INT, irecv,         // Send bodies to next rank
+              1, MPI_COMM_WORLD, &sreq);
+    MPI_Irecv(&recvBodies[0], newSize*word, MPI_INT, isend,     // Receive bodies from previous rank
+              1, MPI_COMM_WORLD, &rreq);
+    MPI_Wait(&sreq, MPI_STATUS_IGNORE);                         // Wait for send to complete
+    MPI_Wait(&rreq, MPI_STATUS_IGNORE);                         // Wait for receive to complete
     bodies = recvBodies;                                        // Copy bodies from buffer
   }
 
       B->ICELL = B->IPROC;                                      //  Do this to sort accroding to IPROC
     }                                                           // End loop over bodies
     Bodies buffer = bodies;                                     // Resize sort buffer
-    stopTimer("Unpartition",printNow);                          // Stop timer 
-    sortBodies(bodies,buffer);                                  // Sort bodies in ascending order
+    stopTimer("Unpartition", printNow);                         // Stop timer 
+    sortBodies(bodies, buffer);                                 // Sort bodies in ascending order
     startTimer("Unpartition comm");                             // Start timer
     alltoall(bodies);                                           // Alltoall send count
     alltoallv(bodies);                                          // Alltoallv bodies
     bodies = recvBodies;                                        // Copy receive buffer to bodies
-    stopTimer("Unpartition comm",printNow);                     // Stop timer 
+    stopTimer("Unpartition comm", printNow);                    // Stop timer 
     for (B_iter B=bodies.begin(); B!=bodies.end(); B++) {       // Loop over bodies
       B->ICELL = B->IBODY;                                      //  Do this to sort accroding to IPROC
     }                                                           // End loop over bodies
     buffer = bodies;                                            // Resize sort buffer
-    sortBodies(bodies,buffer);                                  // Sort bodies in ascending order
+    sortBodies(bodies, buffer);                                 // Sort bodies in ascending order
   }
 };
 

include/treebuilder.h

       C->NCHILD = 0;                                            //  Number of child cells
       C->NCBODY = octNode->NBODY;                               //  Number of bodies in cell
       assert(C->NCBODY > 0);
-      MAXLEVEL = std::max(MAXLEVEL,level);                      //  Update maximum level of tree
+      MAXLEVEL = std::max(MAXLEVEL, level);                     //  Update maximum level of tree
     } else {                                                    // Else if node has children
       C->NCBODY = 0;                                            //  Set number of bodies in cell to zero
       int nchild = 0;                                           //  Initialize number of child cells
   }
 
   void setPoints(const int Igroup, const vec3 X) {
-    points[Igroup]->SetPoint(I[Igroup],X[0],X[1],X[2]);
+    points[Igroup]->SetPoint(I[Igroup], X[0], X[1], X[2]);
     I[Igroup]++;
   }
 
     int index = bodies[0].ICELL;
     for (B_iter B=bodies.begin(); B!=bodies.end(); B++) {
       if (B->ICELL != index) {
-        setGroup(Ncell,size);
+        setGroup(Ncell, size);
         for (int i=begin; i<begin+size; i++) {
-          setPoints(Ncell,bodies[i].X);
+          setPoints(Ncell, bodies[i].X);
         }
         begin = B-bodies.begin();
         size = 0;
     }
     setGroup(Ncell,size);
     for (int i=begin; i<begin+size; i++) {
-      setPoints(Ncell,bodies[i].X);
+      setPoints(Ncell, bodies[i].X);
     }
     Ncell++;
     assert(Ncell < maxGroups);
     //Associate the mapper to an actor object for points
     vtkActor * pointActor = vtkActor::New();
     pointActor->SetMapper(pointMapper);
-    pointActor->GetProperty()->SetColor(1,0,0);
+    pointActor->GetProperty()->SetColor(1, 0, 0);
 
     //Create a hexahedron for cells
     vtkHexahedron * hex = vtkHexahedron::New();
-    hex->GetPointIds()->SetId(0,0);
-    hex->GetPointIds()->SetId(1,1);
-    hex->GetPointIds()->SetId(2,2);
-    hex->GetPointIds()->SetId(3,3);
-    hex->GetPointIds()->SetId(4,4);
-    hex->GetPointIds()->SetId(5,5);
-    hex->GetPointIds()->SetId(6,6);
-    hex->GetPointIds()->SetId(7,7);
+    hex->GetPointIds()->SetId(0, 0);
+    hex->GetPointIds()->SetId(1, 1);
+    hex->GetPointIds()->SetId(2, 2);
+    hex->GetPointIds()->SetId(3, 3);
+    hex->GetPointIds()->SetId(4, 4);
+    hex->GetPointIds()->SetId(5, 5);
+    hex->GetPointIds()->SetId(6, 6);
+    hex->GetPointIds()->SetId(7, 7);
 
     //Create a grid for cells
     vtkUnstructuredGrid * grid = vtkUnstructuredGrid::New();
-    grid->Allocate(1,1);
-    grid->InsertNextCell(hex->GetCellType(),hex->GetPointIds());
+    grid->Allocate(1, 1);
+    grid->InsertNextCell(hex->GetCellType(), hex->GetPointIds());
     grid->SetPoints(hexPoints);
 
     //Create a mapper object for cells
     vtkRenderer * renderer = vtkRenderer::New();
     renderer->AddActor(pointActor);
     renderer->AddActor(hexActor);
-    renderer->SetBackground(0,0,0);
+    renderer->SetBackground(0, 0, 0);
 
     //Create a render window
     vtkRenderWindow * window = vtkRenderWindow::New();
     window->AddRenderer(renderer);
-    window->SetSize(700,700);
+    window->SetSize(700, 700);
 
     //Create an interactor and associate it to the render window
     vtkRenderWindowInteractor * interactor = vtkRenderWindowInteractor::New();
     representation->SetMinimumValue(0);
     representation->SetMaximumValue(Ngroup-1);
     representation->GetPoint1Coordinate()->SetCoordinateSystemToDisplay();
-    representation->GetPoint1Coordinate()->SetValue(50,50);
+    representation->GetPoint1Coordinate()->SetValue(50, 50);
     representation->GetPoint2Coordinate()->SetCoordinateSystemToDisplay();
-    representation->GetPoint2Coordinate()->SetValue(650,50);
+    representation->GetPoint2Coordinate()->SetValue(650, 50);
 
     //Create a slider widget
     vtkSliderWidget * widget = vtkSliderWidget::New();
     }
     callback->polydata = polydata;
     callback->filter = filter;
-    widget->AddObserver(vtkCommand::InteractionEvent,callback);
+    widget->AddObserver(vtkCommand::InteractionEvent, callback);
 
     //Define the interacting style
     vtkInteractorStyleTrackballCamera * style = vtkInteractorStyleTrackballCamera::New();