00001 /* 00002 00003 ParFUM Collision Interface 00004 00005 Author: Isaac Dooley 11-11-2005 00006 00007 */ 00008 #include "ParFUM.h" 00009 #include "ParFUM_internals.h" 00010 00011 #define NULL 0 00012 00013 ParFUM_collider ParFUM_Collide_Init(int dimension){ 00014 ParFUM_collider c; 00015 c.collide_grid = NULL; // This will be created here if we could reuse the grid 00016 c.dimension = dimension; 00017 return c; 00018 } 00019 00020 00021 int ParFUM_Collide(ParFUM_collider *c, double box_padding){ 00022 // count collidable elements 00023 c->numCollidableElements = 0; 00024 00025 double *boxes = new double[c->numCollidableElements]; 00026 int *priorities = new int[c->numCollidableElements]; 00027 int ncoll; 00028 00029 // scan collidable elements, 00030 // ---build the element to BoxMapping 00031 c->boxToElementMapping = new unsigned int[c->numCollidableElements]; 00032 // ---find bounding boxes and priority for each element 00033 00034 // ---keep track of min/max nodal coordinates 00035 00036 00037 // determine grid sizing based on the nodal coordinate ranges 00038 double gridStart[3], gridSize[3]; 00039 gridStart[0] = gridStart[1] = gridStart[2] = 0.0; 00040 gridSize[0] = gridSize[1] = gridSize[2] = 10.0+box_padding; 00041 00042 // Call COLLIDE_Init() 00043 c->collide_grid=COLLIDE_Init(MPI_COMM_WORLD, gridStart, gridSize); 00044 00045 // Call COLLIDE_Boxes_prio() 00046 00047 // clean up arrays which can now be deallocated 00048 delete [] boxes; 00049 delete [] priorities; 00050 // return number of collisions 00051 return 0; 00052 } 00053 00054 00055 00056 void ParFUM_Collide_GetCollisions(ParFUM_collider *c, void* results){ 00057 00058 00059 // Build list of collisions sorted by remote processor 00060 00061 // Copy local data into results 00062 00063 // iterate through processors, and package data for any processor with which a collision occurs 00064 00065 // If lowest unprocessed one is to a greater VP, send it, otherwise receive it 00066 // Then do the opposite for the same collision 00067 // i.e. send right first then send to the left 00068 00069 // when receiving copy data into results 00070 00071 00072 COLLIDE_Destroy(c->collide_grid); 00073 } 00074 00075 00076 00077 void ParFUM_Collide_Destroy(ParFUM_collider *c){ 00078 // if we setup the collision library in init, then we should clean it up here. 00079 c->collide_grid=NULL; 00080 }