def sphere_intersect_sphere( c1 , r1 , c2 , r2 ): """ returns the average intersection point if the two spheres centred in *c1* and *c2* and radius *r1*, *r2* are intersecting, else it returns *None* """ d = dist.distance( c1 , c2 ) if r1 + r2 >= d : u = ( c2 - c1 ) / LA.norm( c2 - c1 ) p = ( ( c1 + u*r1 ) + ( c2 - u*r2 ) ) / 2.0 return p else : return None
def search_neighbour( self , cand_queue , res_list , pset , X , r ): """ Search the elements included in the volume centred in *X* with the radius *r* and append the results in the list *res_list*. *res_list* contains the indicies of the particles included in the the sphere. """ while len(cand_queue) : tree = cand_queue.pop() if distance( pset.X[tree.particle,:] , X ) <= r : res_list.append( tree.particle ) if tree.__tree == None : continue for t in tree.__tree: if t.particle != None and box_intersects_sphere( t.min_vertex , t.max_vertex , X , r ) : cand_queue.append( t )
def search_neighbour( self , cand_queue , res_list , pset , X , r ): """ Search the elements included in the volume centred in *X* with the radius *r* and append the results in the list *res_list*. *res_list* contains the indicies of the particles included in the the sphere. """ while len(cand_queue) : tree = cand_queue.pop() if distance( pset.X[tree.particle,:] , X ) <= r : res_list.append( tree.particle ) if tree.__tree == None : continue for t in tree.__tree: if t.particle != None and box_intersects_sphere( t.min_vertex , t.max_vertex , X , r ) : cand_queue.append( t )
def __find_second_particle(x0, x1, x2, i): # if self.__particle_is_in_cell(particle_cell[i,:], (x, y, z)): # Reference particle particle_index.append(i) j = i # Scans particles_set for j in range(i, part_nbr): scnd_part_found = False if (j not in particle_index): # Checks in 9 cells if there are particles if scnd_part_found == False: if self.__particle_is_in_cell(particle_cell[j,:], (x0, x1, x2 )): x = np.array([pset.X[i,0],pset.X[i,1],pset.X[i,2]], dtype=np.float64) y = np.array([pset.X[j,0],pset.X[j,1],pset.X[j,2]], dtype=np.float64) scnd_part_found = True if scnd_part_found == False: if self.__particle_is_in_cell(particle_cell[j,:], (x0+1,x1, x2 )): x = np.array([pset.X[i,0],pset.X[i,1],pset.X[i,2]], dtype=np.float64) y = np.array([pset.X[j,0],pset.X[j,1],pset.X[j,2]], dtype=np.float64) scnd_part_found = True if scnd_part_found == False: if self.__particle_is_in_cell(particle_cell[j,:], (x0+1,x1+1,x2 )): x = np.array([pset.X[i,0],pset.X[i,1],pset.X[i,2]], dtype=np.float64) y = np.array([pset.X[j,0],pset.X[j,1],pset.X[j,2]], dtype=np.float64) scnd_part_found = True if scnd_part_found == False: if self.__particle_is_in_cell(particle_cell[j,:], (x0+1,x1+1,x2+1)): x = np.array([pset.X[i,0],pset.X[i,1],pset.X[i,2]], dtype=np.float64) y = np.array([pset.X[j,0],pset.X[j,1],pset.X[j,2]], dtype=np.float64) scnd_part_found = True if scnd_part_found == False: if self.__particle_is_in_cell(particle_cell[j,:], (x0, x1+1,x2 )): x = np.array([pset.X[i,0],pset.X[i,1],pset.X[i,2]], dtype=np.float64) y = np.array([pset.X[j,0],pset.X[j,1],pset.X[j,2]], dtype=np.float64) scnd_part_found = True if scnd_part_found == False: if self.__particle_is_in_cell(particle_cell[j,:], (x0, x1+1,x2+1)): x = np.array([pset.X[i,0],pset.X[i,1],pset.X[i,2]], dtype=np.float64) y = np.array([pset.X[j,0],pset.X[j,1],pset.X[j,2]], dtype=np.float64) scnd_part_found = True if scnd_part_found == False: if self.__particle_is_in_cell(particle_cell[j,:], (x0, x1, x2+1)): x = np.array([pset.X[i,0],pset.X[i,1],pset.X[i,2]], dtype=np.float64) y = np.array([pset.X[j,0],pset.X[j,1],pset.X[j,2]], dtype=np.float64) scnd_part_found = True if scnd_part_found == False: if self.__particle_is_in_cell(particle_cell[j,:], (x0+1,x1, x2+1)): x = np.array([pset.X[i,0],pset.X[i,1],pset.X[i,2]], dtype=np.float64) y = np.array([pset.X[j,0],pset.X[j,1],pset.X[j,2]], dtype=np.float64) scnd_part_found = True if scnd_part_found: dist = self.__INI_FLOAT dist = distance(x, y) if dist <= h: conn = [self.__INI_INT, self.__INI_INT] conn = [i,j] return conn