SPEED
GET_NEAREST_NODE.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine get_nearest_node (n, xs, ys, zs, xt, yt, zt, nt, dist_min)
 Computes the nearest node with respet to (xt,yt,zt).
 

Function/Subroutine Documentation

◆ get_nearest_node()

subroutine get_nearest_node ( integer*4  n,
real*8, dimension(n)  xs,
real*8, dimension(n)  ys,
real*8, dimension(n)  zs,
real*8  xt,
real*8  yt,
real*8  zt,
integer*4  nt,
real*8  dist_min 
)

Computes the nearest node with respet to (xt,yt,zt).

Author
Ilario Mazzieri
Date
September, 2013
Version
1.0
Parameters
[in]nnumber of local nodes
[in]xsvertex x-coordinate of local nodes
[in]ysvertex y-coordinate of local nodes
[in]zsvertex z-coordinate of local nodes
[in]xtx-coor current vertex
[in]yty-coor current vertex
[in]ztz-coor current vertex
[out]ntindex of the nearest node from (xt,yt,zt)
[out]dist_minminimal distance from (xt,yt,zt)

Definition at line 34 of file GET_NEAREST_NODE.f90.

35
36 implicit none
37
38 integer*4 :: n,nt, i
39 integer*4, dimension(1) :: pos
40
41 !real*8 :: dx,dy,dz,d2,d2min
42 real*8 :: xt,yt,zt
43 real*8 :: dist_min
44
45 real*8, dimension(n) :: xs,ys,zs
46 real*8, dimension(n) :: dist_all
47
48 !d2min = 1.0d30
49
50 !do i = 1,n
51 ! dx = xs(i) - xt
52 ! dy = ys(i) - yt
53 ! dz = zs(i) - zt
54 ! d2 = dx*dx + dy*dy + dz*dz
55 ! if (d2.lt.d2min) then
56 ! d2min = d2
57 ! nt = i
58 !
59 ! endif
60 !enddo
61
62 dist_all = (xs-xt)*(xs-xt) + (ys-yt)*(ys-yt) + (zs-zt)*(zs-zt)
63 dist_min = minval(dist_all)
64 pos = minloc(dist_all); nt = pos(1)
65
66
67 return

Referenced by make_extint_forces(), and make_system_position_lglnodes().

Here is the caller graph for this function: