/******************************************************** % % Written by: % -- % John L. Weatherwax 2006-05-29 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- */ #include #include #include "global_grid.h" #include "sim_consts.h" #include "determineEvictedParticles.h" /* assigns true or false flags to the array "pExportQ" depending on if this particle should be sent to each of the current boxes neighbors, due to its NEW updated position. Neighbors are defined relative to the executing processor and are defined as: NW=0 N=1 NE=2 W=3 I=4 E=5 SW=6 S=7 SE=8 WWX (2006-10-14): This routine was checked (by eye carefully) ... no errors found. */ void assignEvictedParticles(int pi){ double my_lx,my_ly,my_ux,my_uy,px,py; int efN,efE,efS,efW, cn, no; /* unpack local variables from the global procInfo structure */ my_lx = procInfo.my_lx; my_ly = procInfo.my_ly; /* the lower left corner of the home box (my_lx,my_ly) */ my_ux = procInfo.my_ux; my_uy = procInfo.my_uy; /* the upper right corner of the home box (my_ux,my_uy) */ /* unpack particle location */ px = procInfo.px[pi]; py = procInfo.py[pi]; /* unpack this processors face information */ efN = procInfo.isFaceExternal[0]; efE = procInfo.isFaceExternal[1]; efS = procInfo.isFaceExternal[2]; efW = procInfo.isFaceExternal[3]; /* the default values is {\em not} to be evicted */ for( cn=0; cn < 9; cn++ ){ procInfo.pEvictQ[pi][cn] = 0; } /* Should the particle now belong to my NW neighbor? */ no = (px < my_lx) && (my_uy < py); if( no ){ procInfo.pEvictQ[pi][NW] = 1; procInfo.numToEvict[NW]++; /* this result is corrected if either my north or west boundary is external */ if( efN && efW ){ /* both the NORTH and WEST border of this processor is external ... I keep him */ procInfo.pEvictQ[pi][NW] = 0; procInfo.numToEvict[NW]--; }else if( efN ){ /* only the NORTH border of this processor is external ... I evict him WEST */ procInfo.pEvictQ[pi][NW] = 0; procInfo.numToEvict[NW]--; procInfo.pEvictQ[pi][W] = 1; procInfo.numToEvict[W]++; }else if( efW ){ /* only the WEST border of this processor is external ... I evict him NORTH */ procInfo.pEvictQ[pi][NW] = 0; procInfo.numToEvict[NW]--; procInfo.pEvictQ[pi][N] = 1; procInfo.numToEvict[N]++; } return; } /* Should the particle now belong to my N neighbor? */ no = (my_lx < px) && (px < my_ux) && (my_uy < py); if( no ){ procInfo.pEvictQ[pi][N] = 1; procInfo.numToEvict[N]++; /* this result is corrected if my north boundary is external */ if( efN ){ /* the NORTH border of this processor is external ... I keep him */ procInfo.pEvictQ[pi][N] = 0; procInfo.numToEvict[N]--; } return; } /* Should the particle now belong to my NE neighbor? */ no = (my_ux < px) && (my_uy < py); if( no ){ procInfo.pEvictQ[pi][NE] = 1; procInfo.numToEvict[NE]++; /* this result is corrected if either my north or east boundary is external */ if( efN && efE ){ /* both the NORTH and EAST border of this processor is external ... I keep him */ procInfo.pEvictQ[pi][NE] = 0; procInfo.numToEvict[NE]--; }else if( efN ){ /* only the NORTH border of this processor is external ... I evict him EAST */ procInfo.pEvictQ[pi][NE] = 0; procInfo.numToEvict[NE]--; procInfo.pEvictQ[pi][E] = 1; procInfo.numToEvict[E]++; }else if( efE ){ /* only the EAST border of this processor is external ... I evict him NORTH */ procInfo.pEvictQ[pi][NE] = 0; procInfo.numToEvict[NE]--; procInfo.pEvictQ[pi][N] = 1; procInfo.numToEvict[N]++; } return; } /* Should the particle now belong to my W neighbor? */ no = (px < my_lx) && (my_ly < py) && (py < my_uy); if( no ){ procInfo.pEvictQ[pi][W] = 1; procInfo.numToEvict[W]++; /* this result is corrected if my west boundary is external */ if( efW ){ /* the WEST border of this processor is external ... I keep him */ procInfo.pEvictQ[pi][W] = 0; procInfo.numToEvict[W]--; } return; } /* Should the particle stay put? All non evicted particles DO stay put (by default) */ /*no = (my_lx < px < my_lx) && (my_ly < py < my_uy);*/ /* Should the pariticle now belong to my E neighbor? */ no = (my_ux < px) && (my_ly < py) && (py < my_uy); if( no ){ procInfo.pEvictQ[pi][E] = 1; procInfo.numToEvict[E]++; /* this result is corrected if my east boundary is external */ if( efE ){ /* the EAST border of this processor is external ... I keep him */ procInfo.pEvictQ[pi][E] = 0; procInfo.numToEvict[E]--; } return; } /* Should the pariticle now belong to my SW neighbor? */ no = (px < my_lx) && (py < my_ly); if( no ){ procInfo.pEvictQ[pi][SW] = 1; procInfo.numToEvict[SW]++; /* this result is corrected if either my west or south boundary is external */ if( efW && efS ){ /* both the SOUTH and WEST border of this processor is external ... I keep him */ procInfo.pEvictQ[pi][SW] = 0; procInfo.numToEvict[SW]--; }else if( efS ){ /* only the SOUTH border of this processor is external ... I evict him WEST */ procInfo.pEvictQ[pi][SW] = 0; procInfo.numToEvict[SW]--; procInfo.pEvictQ[pi][W] = 1; procInfo.numToEvict[W]++; }else if( efW ){ /* only the WEST border of this processor is external ... I evict him SOUTH */ procInfo.pEvictQ[pi][SW] = 0; procInfo.numToEvict[SW]--; procInfo.pEvictQ[pi][S] = 1; procInfo.numToEvict[S]++; } return; } /* Should the pariticle now belong to my S neighbor? */ no = (my_lx < px) && (px < my_ux) && (py < my_ly); if( no ){ procInfo.pEvictQ[pi][S] = 1; procInfo.numToEvict[S]++; /* this result is corrected if my south boundary is external */ if( efS ){ /* the SOUTH border of this processor is external ... I keep him */ procInfo.pEvictQ[pi][S] = 0; procInfo.numToEvict[S]--; } return; } /* Should the pariticle now belong to my SE neighbor? */ no = (my_ux < px) && (py < my_ly); if( no ){ procInfo.pEvictQ[pi][SE] = 1; procInfo.numToEvict[SE]++; /* this result is corrected if either my east or south boundary is external */ if( efE && efS ){ /* both the EAST and SOUTH border of this processor is external ... I keep him */ procInfo.pEvictQ[pi][SE] = 0; procInfo.numToEvict[SE]--; }else if( efS ){ /* only the SOUTH border of this processor is external ... I evict him EAST */ procInfo.pEvictQ[pi][SE] = 0; procInfo.numToEvict[SE]--; procInfo.pEvictQ[pi][E] = 1; procInfo.numToEvict[E]++; }else if( efE ){ /* only the EAST border of this processor is external ... I evict him SOUTH */ procInfo.pEvictQ[pi][SE] = 0; procInfo.numToEvict[SE]--; procInfo.pEvictQ[pi][S] = 1; procInfo.numToEvict[S]++; } return; } } /* for each particle this processor contains, determine which neighbors it should be exported to ... for the midpoint force calculation */ void determineEvictedParticles(void){ int pi; /* loop over each particle this processor contains */ for( pi=0; pi < procInfo.NbPP; pi++ ){ assignEvictedParticles(pi); } }