!####################################################################### ! SUBROUTINE --- sub_get_neighbor_list.f --- ### !####################################################################### ! ### ! Subroutine for Getting the Neighbor List of i-th Particle ### ! ### ! Input Arguments ### ! trd : Thread Number ### ! xi(3) : Position of SPH Particle ### ! h2i : 2*h ### ! Output Arguments ### ! nbi_tot : Total Number of Neighbor Particles ### ! ### ! nbi_list(NP_NB,trd) : Neighbor List ### ! dis2_nbi_list(NP_NB,trd) : Distance^2 to Neighbor Particles ### ! ### ! 2009/07/29 ### ! 2009/08/27 ### ! 2011/06/27 ### !####################################################################### subroutine sub_get_neighbor_list(trd,xi,h2i,nbi_tot) use mod_parameter use mod_variable implicit none !==== Arguments ======================================================== ! ---- Input Arguments --------------------------------------------- integer(4) :: trd real*8 xi(3) real*8 h2i ! ---- Output Arguments -------------------------------------------- integer nbi_tot !==== Variables Used in This Subroutine ================================ integer nbi integer wait_list_head integer wait_list_tail integer node real*8 dis2 real*8 dis real*8 dis_radius integer node_head integer node_tail integer n_node !======================================================================= nbi_tot=0 nbi=0 wait_list(1,trd)=1 wait_list_head=1 wait_list_tail=1 555 continue ! ---- No Node in Waiting List ------------------------------------- if(wait_list_head .gt. wait_list_tail) go to 999 ! ------------------------------------------------------------------ ! ---- Pickup Last Node in Waiting List ---------------------------- node=wait_list(wait_list_head,trd) ! ------------------------------------------------------------------ ! ---- Distance between i-th Particle and COM of Node -------------- dis2=(center_node(1,node)-xi(1))**2 & +(center_node(2,node)-xi(2))**2 & +(center_node(3,node)-xi(3))**2 dis=dsqrt(dis2) ! ------------------------------------------------------------------ dis_radius=dmax1(h2i,2.0d0*h_max_node(node))+radius_node(node) if(dis .le. dis_radius) then ! ---- Case for one Particle in Node ----------------------------- if(flag_node(node) .ne. -1) then nbi_tot=nbi_tot+1 nbi=nbi+1 nbi_list(nbi,trd)=flag_node(node) dis2_nbi_list(nbi,trd)=dis2 else ! ---- Case for Particles in Node -------------------------------- node_head=head_branch_id(node) node_tail=node_head+num_branch(node)-1 do n_node=node_head,node_tail wait_list_tail=wait_list_tail+1 wait_list(wait_list_tail,trd)=n_node enddo endif endif wait_list_head=wait_list_head+1 go to 555 999 continue return end !####################################################################### ! SUBROUTINE --- sub_get_neighbor_number.f --- ### !####################################################################### ! ### ! Subroutine for Getting the Number of Neighbor Particle ### ! of i-th Particle ### ! ### ! Input Arguments ### ! trd : Thread Number ### ! xi(3) : Position of SPH Particle ### ! h2i : 2*h ### ! Output Arguments ### ! nbi_tot : Total Number of Neighbor Particles ### ! ### ! 2011/08/20 ### !####################################################################### subroutine sub_get_neighbor_number(trd,xi,h2i,nbi_tot) use mod_parameter use mod_variable implicit none !==== Arguments ======================================================== ! ---- Input Arguments --------------------------------------------- integer(4) :: trd real*8 xi(3) real*8 h2i ! ---- Output Arguments -------------------------------------------- integer nbi_tot !==== Variables Used in This Subroutine ================================ integer wait_list_head integer wait_list_tail integer node real*8 dis2 real*8 dis real*8 dis_radius integer node_head integer node_tail integer n_node !======================================================================= nbi_tot=0 wait_list(1,trd)=1 wait_list_head=1 wait_list_tail=1 555 continue ! ---- No Node in Waiting List ------------------------------------- if(wait_list_head .gt. wait_list_tail) go to 999 ! ------------------------------------------------------------------ ! ---- Pickup Last Node in Waiting List ---------------------------- node=wait_list(wait_list_head,trd) ! ------------------------------------------------------------------ ! ---- Distance between i-th Particle and COM of Node -------------- dis2=(center_node(1,node)-xi(1))**2 & +(center_node(2,node)-xi(2))**2 & +(center_node(3,node)-xi(3))**2 dis=dsqrt(dis2) ! ------------------------------------------------------------------ dis_radius=h2i+radius_node(node) if(dis .le. dis_radius) then ! ---- Case for one Particle in Node ----------------------------- if(flag_node(node) .ne. -1) then nbi_tot=nbi_tot+1 else ! ---- Case for Particles in Node -------------------------------- node_head=head_branch_id(node) node_tail=node_head+num_branch(node)-1 do n_node=node_head,node_tail wait_list_tail=wait_list_tail+1 wait_list(wait_list_tail,trd)=n_node enddo endif endif wait_list_head=wait_list_head+1 go to 555 999 continue return end