CalculiX  2.13
A Free Software Three-Dimensional Structural Finite Element Program
near3d_se.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine near3d_se (xo, yo, zo, x, y, z, nx, ny, nz, xp, yp, zp, n, ir, r, nr, radius)
 

Function/Subroutine Documentation

◆ near3d_se()

subroutine near3d_se ( real*8, dimension(n)  xo,
real*8, dimension(n)  yo,
real*8, dimension(n)  zo,
real*8, dimension(n)  x,
real*8, dimension(n)  y,
real*8, dimension(n)  z,
integer, dimension(n)  nx,
integer, dimension(n)  ny,
integer, dimension(n)  nz,
real*8  xp,
real*8  yp,
real*8  zp,
integer  n,
integer, dimension(n+6)  ir,
real*8, dimension(n+6)  r,
integer  nr,
real*8  radius 
)
21 !
22 ! determines the nodes out of n within a radius r of
23 ! the point with coordinates (xp,yp,zp);
24 !
25 !
26 ! INPUT:
27 !
28 ! xo x-coordinates of cloud of nodes
29 ! yo y-coordinates of cloud of nodes
30 ! zo z-coordinates of cloud of nodes
31 ! x xo ordered in increasing order
32 ! (can be done in the calling program
33 ! with dsort)
34 ! y yo ordered in increasing order
35 ! z zo ordered in increasing order
36 ! nx permutations of x-ordering
37 ! ny permutations of y-ordering
38 ! nz permutations of z-ordering
39 ! xp x-coordinate of point of interest
40 ! yp y-coordinate of point of interest
41 ! zp z-coordinate of point of interest
42 ! n number of nodes in cloud
43 ! radius radius
44 !
45 ! OUTPUT:
46 !
47 ! ir numbers of the nodes within the given radius
48 ! r distance square of the nodes within the given
49 ! radius
50 ! nr number of nodes within the given radius
51 !
52  implicit none
53 !
54  integer n,nx(n),ny(n),nz(n),ir(n+6),nr,nrprev,irnew,
55  & i,j,k,m,id,idx,idy,idz,node
56 !
57  real*8 x(n),y(n),z(n),xo(n),yo(n),zo(n),xp,yp,zp,r(n+6),
58  & xr,yr,zr,c(8),dd,xw,xe,ys,yn,zb,zt,radius,
59  & radius2
60 !
61  radius2=radius*radius
62  nrprev=0
63 !
64 ! identify position of xp, yp and zp
65 !
66  call ident(x,xp,n,idx)
67  call ident(y,yp,n,idy)
68  call ident(z,zp,n,idz)
69 !
70 ! initialization of the maximal distance in each direction
71 !
72  xw=0.d0
73  xe=0.d0
74  ys=0.d0
75  yn=0.d0
76  zb=0.d0
77  zt=0.d0
78 !
79  i=1
80 !
81  do
82 !
83  nr=nrprev
84 !
85 ! westp
86 !
87  id=idx+1-i
88  if(id.gt.0) then
89  node=nx(id)
90  xw=xo(node)-xp
91  yr=yo(node)-yp
92  zr=zo(node)-zp
93  dd=xw*xw+yr*yr+zr*zr
94  if(dd.lt.radius2) then
95  nr=nr+1
96  ir(nr)=node
97  endif
98  else
99  xw=1.d30
100  endif
101 !
102 ! east
103 !
104  id=idx+i
105  if(id.le.n) then
106  node=nx(id)
107  xe=xo(node)-xp
108  yr=yo(node)-yp
109  zr=zo(node)-zp
110  dd=xe*xe+yr*yr+zr*zr
111  if(dd.lt.radius2) then
112  nr=nr+1
113  ir(nr)=node
114  endif
115  else
116  xe=1.d30
117  endif
118 !
119 ! south
120 !
121  id=idy+1-i
122  if(id.gt.0) then
123  node=ny(id)
124  xr=xo(node)-xp
125  ys=yo(node)-yp
126  zr=zo(node)-zp
127  dd=xr*xr+ys*ys+zr*zr
128  if(dd.lt.radius2) then
129  nr=nr+1
130  ir(nr)=node
131  endif
132  else
133  ys=1.d30
134  endif
135 !
136 ! north
137 !
138  id=idy+i
139  if(id.le.n) then
140  node=ny(id)
141  xr=xo(node)-xp
142  yn=yo(node)-yp
143  zr=zo(node)-zp
144  dd=xr*xr+yn*yn+zr*zr
145  if(dd.lt.radius2) then
146  nr=nr+1
147  ir(nr)=node
148  endif
149  else
150  yn=1.d30
151  endif
152 !
153 ! bottom
154 !
155  id=idz+1-i
156  if(id.gt.0) then
157  node=nz(id)
158  xr=xo(node)-xp
159  yr=yo(node)-yp
160  zb=zo(node)-zp
161  dd=xr*xr+yr*yr+zb*zb
162  if(dd.lt.radius2) then
163  nr=nr+1
164  ir(nr)=node
165  endif
166  else
167  zb=1.d30
168  endif
169 !
170 ! top
171 !
172  id=idz+i
173  if(id.le.n) then
174  node=nz(id)
175  xr=xo(node)-xp
176  yr=yo(node)-yp
177  zt=zo(node)-zp
178  dd=xr*xr+yr*yr+zt*zt
179  if(dd.lt.radius2) then
180  nr=nr+1
181  ir(nr)=node
182  endif
183  else
184  zt=1.d30
185  endif
186 !
187 ! check for new entries
188 !
189  if(nr.gt.nrprev) then
190  m=nrprev
191  do j=nrprev+1,nr
192  irnew=ir(j)
193  call nident(ir,irnew,m,id)
194  if(id.eq.0) then
195  m=m+1
196  do k=m,2,-1
197  ir(k)=ir(k-1)
198  enddo
199  ir(1)=irnew
200  elseif(ir(id).ne.irnew) then
201  m=m+1
202  do k=m,id+2,-1
203  ir(k)=ir(k-1)
204  enddo
205  ir(id+1)=irnew
206  endif
207  enddo
208  nrprev=m
209  endif
210 !
211  i=i+1
212 !
213 ! check the corners of the box
214 !
215  c(1)=xe*xe+yn*yn+zb*zb
216  if(c(1).lt.radius2) cycle
217  c(2)=xw*xw+yn*yn+zb*zb
218  if(c(2).lt.radius2) cycle
219  c(3)=xw*xw+ys*ys+zb*zb
220  if(c(3).lt.radius2) cycle
221  c(4)=xe*xe+ys*ys+zb*zb
222  if(c(4).lt.radius2) cycle
223  c(5)=xe*xe+yn*yn+zt*zt
224  if(c(5).lt.radius2) cycle
225  c(6)=xw*xw+yn*yn+zt*zt
226  if(c(6).lt.radius2) cycle
227  c(7)=xw*xw+ys*ys+zt*zt
228  if(c(7).lt.radius2) cycle
229  c(8)=xe*xe+ys*ys+zt*zt
230  if(c(8).lt.radius2) cycle
231 !
232 ! no new entries possible: finished
233 !
234  nr=nrprev
235  do j=1,nr
236  node=ir(j)
237  xr=xo(node)-xp
238  yr=yo(node)-yp
239  zr=zo(node)-zp
240  r(j)=xr*xr+yr*yr+zr*zr
241  enddo
242  exit
243 !
244  enddo
245 !
246  return
subroutine ident(x, px, n, id)
Definition: ident.f:26
subroutine nident(x, px, n, id)
Definition: nident.f:26
Hosted by OpenAircraft.com, (Michigan UAV, LLC)