34
35
36
37
38
39
40
41
42
43
45
46
47
48#include "implicit_f.inc"
49
50
51
52#include "mvsiz_p.inc"
53#include "vect01_c.inc"
54#include "scr11_c.inc"
55
56
57
58 INTEGER :: IOPT
59 my_real :: x(3,*),xc(mvsiz),yc(mvsiz),zc(mvsiz),bt(mvsiz),vdet,vdet2,alt,tb(mvsiz)
60 TYPE(DETONATOR_CORD_STRUCT_)::DETONATOR_CORD
61 LOGICAL HAS_DETONATOR(MVSIZ)
62
63
64
65 INTEGER :: J, I1,I2, ,K, iTdet, i, NPTS, NSEG,IDIST(MVSIZ),NDETCORD,NNOD
66 my_real :: ddmx, dtos, xlp2, ylp2, xlp1 , zlp2 ,ylp1,
67 . zlp1, xl0 , yl0 , zl0 , xl1 , yl1 ,zl1 , xl2 ,yl2 ,zl2,
68 . ps1 , ps2 , dl1 , dl2 , dl(mvsiz), s1 ,s2 , s3, tdetc, tp1, tp2, th, th1,th2,
69 . tc1,tc2,tc0,tc,p1p2,dh,
alpha,knots(4),zp(3),
70 . zh1(3),dist1,t1,zh2(3),dist2,t2,dist(mvsiz),xx,yy,zz,d,local_pt(4,3),c(3),t,dd,
71 . len,len1,len2
72
73 type spline_path
74 INTEGER :: NUM_POINTS
75 my_real,
ALLOCATABLE,
DIMENSION(:,:) :: control_point
76 my_real,
ALLOCATABLE,
DIMENSION(:) :: length
77 my_real,
ALLOCATABLE,
DIMENSION(:) :: cumulative_length
78 my_real,
ALLOCATABLE,
DIMENSION(:,:) :: knots
79 end type spline_path
80
81 type(SPLINE_PATH),TARGET :: USER_SPLINE_PATH
82
83 my_real,
POINTER,
DIMENSION(:,:) :: ptr
84
85
86
87
88 nnod = detonator_cord%NUMNOD
89 dtos = ep20
90
91 IF(iopt == 2)THEN
92
93 DO j=1,nnod-1
94
95 ii = detonator_cord%NODES(j)
96 xlp1 = x(1,ii)
97 ylp1 = x(2,ii)
98 zlp1 = x(3,ii)
99
100 ii = detonator_cord%NODES(j+1)
101 xlp2 = x(1,ii)
102 ylp2 = x(2,ii)
103 zlp2 = x(3,ii)
104
105 xl0 = (xlp1-xlp2)
106 yl0 = (ylp1-ylp2)
107 zl0 = (zlp1-zlp2)
108
109 DO i=lft,llt
110 xl1 = (xc(i)-xlp1)
111 yl1 = (yc(i)-ylp1)
112 zl1 = (zc(i)-zlp1)
113 xl2 = (xc(i)-xlp2)
114 yl2 = (yc(i)-ylp2)
115 zl2 = (zc(i)-zlp2)
116 ps1 = xl1*xl0+yl1*yl0+zl1*zl0
117 ps2 = xl2*xl0+yl2*yl0+zl2*zl0
118 IF(ps1*ps2 > zero)THEN
119
120 dl1 = sqrt(xl1**2+yl1**2+zl1**2)
121 dl2 = sqrt(xl2**2+yl2**2+zl2**2)
123 ELSE
124
125 s1 = yl1*zl0 - zl1*yl0
126 s2 = zl1*xl0 - xl1*zl0
127 s3 = xl1*yl0 - yl1*xl0
128 dl(i)=sqrt((s1**2+s2**2+s3**2)/(xl0**2+yl0**2+zl0**2))
129 ENDIF
130 bt(i) =alt+dl(i)/vdet
131 IF(bt(i) < abs(tb(i))) tb(i)=-bt(i)
132 END DO
133 END DO
134
135 ELSEIF(iopt == 1)THEN
136
137 DO j=1,nnod-1
138
139 ii = detonator_cord%NODES(j)
140 xlp1 = x(1,ii)
141 ylp1 = x(2,ii)
142 zlp1 = x(3,ii)
143 tp1 = detonator_cord%TDET_PATH(j)
144
145 ii = detonator_cord%NODES(j+1)
146 xlp2 = x(1,ii)
147 ylp2 = x(2,ii)
148 zlp2 = x(3,ii)
149 tp2 = detonator_cord%TDET_PATH(j+1)
150
151 DO i=lft,llt
152 tdetc = zero
153 xl0 = (xlp1-xlp2)
154 yl0 = (ylp1-ylp2)
155 zl0 = (zlp1-zlp2)
156 xl1 = (xc(i)-xlp1)
157 yl1 = (yc(i)-ylp1)
158 zl1 = (zc(i)-zlp1)
159 xl2 = (xc(i)-xlp2)
160 yl2 = (yc(i)-ylp2)
161 zl2 = (zc(i)-zlp2)
162 ps1 = xl1*xl0+yl1*yl0+zl1*zl0
163 ps2 = xl2*xl0+yl2*yl0+zl2*zl0
164 dl1 = sqrt(xl1**2+yl1**2+zl1**2)
165 dl2 = sqrt(xl2**2+yl2**2+zl2**2)
166 tc1 = tp1 + dl1 /vdet
167 tc2 = tp2 + dl2 /vdet
169 IF(ps1*ps2 <= zero)THEN
170 s1 = yl1*zl0 - zl1*yl0
171 s2 = zl1*xl0 - xl1*zl0
172 s3 = xl1*yl0 - yl1*xl0
173
174 p1p2 = (xl0**2+yl0**2+zl0**2)
175 dl2 = (s1**2+s2**2+s3**2)/p1p2
176 dl(i) = sqrt(dl2)
177 p1p2 = sqrt(p1p2)
178 dh = sqrt((xl1**2+yl1**2+zl1**2)-dl2)
179
180 th1 = tp1 + dh/vdet2
181 th2 = tp2 + (p1p2-dh)/vdet2
183 tc0 = th + dl(i)/vdet
185 ENDIF
186 bt(i) = tc
187 IF(bt(i) < abs(tb(i))) tb(i)=-bt(i)
188 END DO
189 END DO
190
191 ELSEIF(iopt == 3)THEN
192
193
194
195
196
198
199 IF(vdet2 == zero)vdet2=vdet
200
201
202 npts = nnod
203 nseg = nnod-1 !number of segment composing
the cord path
204 ALLOCATE(user_spline_path%control_point(0:npts+1,3))
205 ALLOCATE(user_spline_path%length(npts-1))
206 ALLOCATE(user_spline_path%cumulative_length(npts-1))
207 ALLOCATE(user_spline_path%knots(npts-1,4) )
208
209
210
211
212 DO j=1,nnod
213 ii = detonator_cord%NODES(j)
214 xlp1 = x(1,ii)
215 ylp1 = x(2,ii)
216 zlp1 = x(3,ii)
217 user_spline_path%control_point(j,1:3)=(/xlp1, ylp1, zlp1/)
218 ENDDO
219
220
221 ptr=>user_spline_path%control_point(0:npts+1,1:3)
222
223 ptr(1+0,1)=half*(five*ptr(1+1,1)-four
224 ptr(1+0,2)=half*(five*ptr(1+1,2)-four*ptr(1+2,2)+ptr(1+3,2))
225 ptr(1+0,3)=half*(five*ptr(1+1,3)-four*ptr(1+2,3)+ptr(1+3,3))
226
227 ptr(1+npts+1,1)=half*(1.*ptr(1+npts-2,1)-four*ptr(1+npts-1,1)+five*ptr(1+npts,1))
228 ptr(1+npts+1,2)=half*(1.*ptr(1+npts-2,2)-four*ptr(1+npts-1,2)+five*ptr(1+npts,2))
229 ptr(1+npts+1,3)=half*(1.*ptr(1+npts-2,3)-four*ptr(1+npts-1,3)+five*ptr(1+npts,3))
230
231
232 DO j=1,nseg
234 user_spline_path%knots(j,1:4)=knots(1:4)
235 ENDDO
236
237
238
239 DO j=lft,llt
240 dist(j) = 1e20
241 idist(j) = 0
242 DO i=1,npts
243 xx = xc(j)-ptr(1+i,1)
244 yy = yc(j)-ptr(1+i,2)
245 zz = zc(j)-ptr(1+i,3)
246 dd = sqrt(xx*xx+yy*yy+zz*zz)
247 IF(dd < dist(j))THEN
248 dist(j) = dd
249 idist(j) = i
250 ENDIF
251 ENDDO
252 ENDDO
253
254
255 DO i=1,nseg
256 local_pt(1,1:3)=ptr(1+i-1,1:3)
257 local_pt(2,1:3)=ptr(1+i+0,1:3)
258 local_pt(3,1:3)=ptr(1+i+1,1:3)
259 local_pt(4,1:3)=ptr(1+i+2,1:3)
260 t=1.0
262 user_spline_path%length(i) = len
263 IF(i > 1)THEN
264 user_spline_path%cumulative_length(i) = user_spline_path%cumulative_length(i-1) + len
265 ELSE
266 user_spline_path%cumulative_length(1) = len
267 ENDIF
268
269
270 ENDDO
271
272
273 DO j=lft,llt
274
275 i=idist(j)
277 k=i
278 t=half
279 local_pt(1,1:3)=ptr(1+i-1,1:3)
280 local_pt(2,1:3)=ptr(1+i+0,1:3)
281 local_pt(3,1:3)=ptr(1+i+1,1:3)
282 local_pt(4,1:3)=ptr(1+i+2,1:3)
283 zp(1:3) =(/xc(j),yc(j),zc(j)/)
286 c(1:3)=zh1(1:3)
287 t=t1
288 len=len1
289
290 IF(i >= 2)THEN
291 i=i-1
292 local_pt(1,1:3)=ptr(1+i-1,1:3)
293 local_pt(2,1:3)=ptr(1+i+0,1:3)
294 local_pt(3,1:3)=ptr(1+i+1,1:3)
295 local_pt(4,1:3)=ptr(1+i+2,1:3)
298 IF(dist2 < dist1)THEN
299 c(1:3)=zh2(1:3)
300 t=t2
301 k=i
302 len = len2
303 ENDIF
304 ENDIF
305
306
307
308 IF(k > 1)len=len+user_spline_path%cumulative_length(k-1)
309 bt(j) = detonator_cord%TDET_PATH(1) + len/vdet2
310 IF(bt(j) < abs(tb(j))) tb(j)=-bt(j)
311 ENDDO
312
313 ENDIF
314
315 DO i=lft,llt
316 has_detonator(i) = .true.
317 ENDDO
318
319 dto=dtos
320
321
322 RETURN
subroutine cr_spline_knots(pts, knots, alpha)
subroutine cr_spline_length(local_pt, alpha, t, len)
subroutine cr_spline_point_proj(local_pt, z, alpha, zh, h, t)
end diagonal values have been computed in the(sparse) matrix id.SOL