加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

FLAC3D2Tecplot501.dat

(2015-08-26 22:47:07)
标签:

flac3d

500

flac3d500

flac3d2tecplot501.da

分类: flac3d
 下面的fish语言可以提取单元的应力位移等共tecplot后处理使用。
使用前先读入*.f3sav,然后call下面的代码文档。
 FISH Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
;;=================================================================
;;Oct/10/2011 All the data of this file are lined in Block type
;;FLAC3D Mesh to Tecplot
;;Tecplot Version --  Version 
2011
;;Revised by Eric, ZhengZhou
;;Tecplot Version --  Version 
2016 for FLAC3D 5.0
;;=================================================================
;rest XXX.f3sav
;==================================================================
;;Initialization Global Parametres
set fish autocreate on
;set fish sa off
set echo off
set log off 
def ini_Flac2tec
    global IO_READ  
0;
    global IO_WRITE 
1;To overwrite the exist file
    global IO_ASCII 
1;To write the file in ASCII format
    global N_RECORD 
10;MODIFY to set the figure count of each line
    global i=
0;To control the loop
    global j=
0;To mark the new indices of Nodes
    array my_Point(
8)
    array buf(
1)
    global ScaleFactor 
0;MODIFY to scale the transform
    global tec_file 
'FLAC3DMesh_deformation.dat';To define the write file name
    command;create an output range with the name writeRange
        ;MODIFY the group to define the range to deal with,Default the whole file,DON
'T USE group XX not
        ran name writeRange ;group v_fgc any group v_jy any group v_rtjc any
    endcommand
end;End of ini_Flac2tec
@ini_Flac2tec
;;
;;Write Tecplot File Head
def write_FileHead
    local p_gp=gp_head
    i=
0
    loop 
while p_gp null
        
if in_range('writeRange',p_gp) 1  then
            i=i+
1
        endif
        p_gp gp_next(p_gp);next grid point
    endloop
    local p_z=zone_head
    j=
0
    loop 
while p_z null
        
if in_range('writeRange',p_z) 1  then
        
if z_model(p_z) 'null' then
            j=j+
1
        endif
        endif
        p_z z_next(p_z);next zone
    endloop
    buf(
1         'TITLE     "FLAC3D Mesh to Tecplot by Eric!" \n'
    buf(
1buf(1'VARIABLES "X" "Y" "Z" "DISP" "XDISP" "YDISP" "ZDISP" "SXX" "SYY" "SZZ" "Sig1" "Sig2" "Sig3"\n'
    buf(
1buf(1'ZONE T="FLAC3D Data" \n'
    buf(
1buf(1'N='+string(i)+','+'E='+string(j)+','+'ZONETYPE=FEBrick '
    buf(
1buf(1'DATAPACKING=block\n'+'VARLOCATION=([8-13]=CELLCENTERED)\n'
    buf(
1buf(1'DT=(SINGLE SINGLE SINGLE SINGLE SINGLE SINGLE SINGLE SINGLE SINGLE SINGLE SINGLE SINGLE SINGLE)'
    status write(buf,
1)
ii=out(
'File Head has been written!')
end;End of write_FileHead
;;
;;Write Nodes
Coordinates Z
def write_node
    ;Write position  
    p_gp gp_head
    loop 
while p_gp null
        buf(
1)=''
        n=
1
        loop 
while <= N_RECORD
            
if p_gp null then
                
if in_range('writeRange',p_gp) 1  then
                    buf(
1buf(1)+string(gp_xpos(p_gp)+gp_xdisp(p_gp)*ScaleFactor)+  '
                    n=n+
1
                endif
                p_gp gp_next(p_gp)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    ;
    ;Write position  
    p_gp gp_head
    loop 
while p_gp null
        buf(
1)=''
        n=
1
        loop 
while <= N_RECORD
            
if p_gp null then
                
if in_range('writeRange',p_gp) 1  then
                    buf(
1buf(1)+string(gp_ypos(p_gp)+gp_ydisp(p_gp)*ScaleFactor)+  '
                    n=n+
1
                endif
                p_gp gp_next(p_gp)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    
    ;Write position  
    p_gp gp_head
    loop 
while p_gp null
        buf(
1)=''
        n=
1
        loop 
while <= N_RECORD
            
if p_gp null then
                
if in_range('writeRange',p_gp) 1  then
                    buf(
1buf(1)+string(gp_zpos(p_gp)+gp_zdisp(p_gp)*ScaleFactor)+  '
                    n=n+
1
                endif
                p_gp gp_next(p_gp)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
ii=out(
'Node coordinations have been written!')
end;End of write_node
;;
;;Write the data on Node
def write_nodeData
    ;Write total displacement
    p_gp gp_head
    loop 
while p_gp null
        buf(
1)=''
        n=
1
        loop 
while <= N_RECORD
            
if p_gp null then
                
if in_range('writeRange',p_gp) 1 then
                    buf(
1buf(1)+string(sqrt(gp_xdisp(p_gp)^2+gp_ydisp(p_gp)^2+gp_zdisp(p_gp)^2)*100.)+  '
                    n=n+
1
                endif
                p_gp gp_next(p_gp)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    ;Write x-displacement
    p_gp gp_head
    loop 
while p_gp null
        buf(
1)=''
        n=
1
        loop 
while <= N_RECORD
            
if p_gp null then
                
if in_range('writeRange',p_gp) 1 then
                    buf(
1buf(1)+string(gp_xdisp(p_gp)*100.)+  '
                    n=n+
1
                endif
                p_gp gp_next(p_gp)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    ;
    ;Write y-displcaement 
    p_gp gp_head
    loop 
while p_gp null
        buf(
1)=''
        n=
1
        loop 
while <= N_RECORD
            
if p_gp null then
                
if in_range('writeRange',p_gp) 1  then
                    buf(
1buf(1)+string(gp_ydisp(p_gp)*100.)+  '
                    n=n+
1
                endif
                p_gp gp_next(p_gp)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
     
    ;write z-displacement
    p_gp gp_head
    loop 
while p_gp null
        buf(
1)=''
        n=
1
        loop 
while <= N_RECORD
            
if p_gp null then
                
if in_range('writeRange',p_gp) 1  then
                    buf(
1buf(1)+string(gp_zdisp(p_gp)*100.)+  '
                    n=n+
1
                endif
                p_gp gp_next(p_gp)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
ii=out(
'Displacement data have been written!')
end;End of write_nodeData
;;
;;Write the data in Elements
def write_zoneData
    ;Write SXX
    p_z zone_head
    loop 
while p_z null
        buf(
1)=''
        n=
1
        loop 
while n<=N_RECORD
            
if p_z null then
                
if in_range('writeRange',p_z) 1 then
                
if z_model(p_z) 'null' then
                    buf(
1buf(1)+string(z_sxx(p_z)/(-1.e6))+  '
                    n=n+
1
                endif
                endif
                p_z z_next(p_z)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    ;Write SYY
    p_z zone_head
    loop 
while p_z null
        buf(
1)=''
        n=
1
        loop 
while n<=N_RECORD
            
if p_z null then
                
if in_range('writeRange',p_z) 1 then
                
if z_model(p_z) 'null' then
                    buf(
1buf(1)+string(z_syy(p_z)/(-1.e6))+  '
                    n=n+
1
                endif
                endif
                p_z z_next(p_z)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    ;Write SZZ
    p_z zone_head
    loop 
while p_z null
        buf(
1)=''
        n=
1
        loop 
while n<=N_RECORD
            
if p_z null then
                
if in_range('writeRange',p_z) 1 then
                
if z_model(p_z) 'null' then
                    buf(
1buf(1)+string(z_szz(p_z)/(-1.e6))+  '
                    n=n+
1
                endif
                endif
                p_z z_next(p_z)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    ;Write Sig1 Max Princinple
    p_z zone_head
    loop 
while p_z null
        buf(
1)=''
        n=
1
        loop 
while n<=N_RECORD
            
if p_z null then
                
if in_range('writeRange',p_z) 1 then
                
if z_model(p_z) 'null' then
                    buf(
1buf(1)+string(z_sig1(p_z)/(-1.e6))+  '
                    n=n+
1
                endif
                endif
                p_z z_next(p_z)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    ;Write Sig2 Mid Princinple
    p_z zone_head
    loop 
while p_z null
        buf(
1)=''
        n=
1
        loop 
while n<=N_RECORD
            
if p_z null then
                
if in_range('writeRange',p_z) 1 then
                
if z_model(p_z) 'null' then
                    buf(
1buf(1)+string(z_sig2(p_z)/(-1.e6))+  '
                    n=n+
1
                endif
                endif
                p_z z_next(p_z)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
    ;Write Sig3 Min Princinple
    p_z zone_head
    loop 
while p_z null
        buf(
1)=''
        n=
1
        loop 
while n<=N_RECORD
            
if p_z null then
                
if in_range('writeRange',p_z) 1 then
                
if z_model(p_z) 'null' then
                    buf(
1buf(1)+string(z_sig3(p_z)/(-1.e6))+  '
                    n=n+
1
                endif
                endif
                p_z z_next(p_z)
            
else
                n=N_RECORD+
1
            endif
        endloop
        status write(buf,
1)
    endloop
ii=out(
'Element stress data have been written!')
end;End of write_zoneData
;;
;;Zone Connectivity List
;Calculate the maximum index of the array my_Grid()
def my_array
    p_gp=gp_head
    loop 
while p_gp null
        ski=gp_id(p_gp)
        p_gp=gp_next(p_gp)
    endloop
end;End of my_array
@my_array
;
def write_zone
    ;create an array to store the grid point data
    array my_Grid(ski) 
    ;initialize the grid point array
    p_gp=gp_head
    i=
1
    loop 
while p_gp null
        
if in_range('writeRange',p_gp) 1  then
            my_Grid(gp_id(p_gp))=i
            i=i+
1
        endif
        p_gp=gp_next(p_gp)
    endloop
    ;Write Zone Connectivity List
    p_z zone_head
    loop 
while p_z null
    
if in_range('writeRange',p_z) 1  then
    
if z_model(p_z) 'null' then
        
if z_numgp(p_z) 8 then;A
        ;
1 2 5 3 4 7 8 6
            my_Point(
1)=string(my_Grid(gp_id(z_gp(p_z, 1))))
            my_Point(
2)=string(my_Grid(gp_id(z_gp(p_z, 2))))
            my_Point(
3)=string(my_Grid(gp_id(z_gp(p_z, 3))))
            my_Point(
4)=string(my_Grid(gp_id(z_gp(p_z, 4))))
            my_Point(
5)=string(my_Grid(gp_id(z_gp(p_z, 5))))
            my_Point(
6)=string(my_Grid(gp_id(z_gp(p_z, 6))))
            my_Point(
7)=string(my_Grid(gp_id(z_gp(p_z, 7))))
            my_Point(
8)=string(my_Grid(gp_id(z_gp(p_z, 8))))
            ;
            buf(
1my_Point(1 ' my_Point(2)+  ' my_Point(5)+  ' my_Point(3)
            buf(
1buf(1)+  ' +my_Point(4 ' my_Point(7)+  ' my_Point(8)+  ' my_Point(6)
        
else 
        
if z_numgp(p_z) 4 then;B
        ;
1 2 3 3 4 4 4 4
            my_Point(
1)=string(my_Grid(gp_id(z_gp(p_z, 1))))
            my_Point(
2)=string(my_Grid(gp_id(z_gp(p_z, 2))))
            my_Point(
3)=string(my_Grid(gp_id(z_gp(p_z, 3))))
            my_Point(
4)=string(my_Grid(gp_id(z_gp(p_z, 4))))
            ;
                buf(
1my_Point(1 ' my_Point(2)+  ' my_Point(3)+  ' my_Point(3)
                buf(
1buf(1)+  ' +my_Point(4 ' my_Point(4)+  ' my_Point(4)+  ' my_Point(4)
        
else  
        
if z_numgp(p_z) 6 then;C
        ;
1 2 5 3 4 4 6 6 or 1 2 4 4 3 5 6 6
            my_Point(
1)=string(my_Grid(gp_id(z_gp(p_z, 1))))
            my_Point(
2)=string(my_Grid(gp_id(z_gp(p_z, 2))))
            my_Point(
3)=string(my_Grid(gp_id(z_gp(p_z, 3))))
            my_Point(
4)=string(my_Grid(gp_id(z_gp(p_z, 4))))
            my_Point(
5)=string(my_Grid(gp_id(z_gp(p_z, 5))))
            my_Point(
6)=string(my_Grid(gp_id(z_gp(p_z, 6))))
            ;
                buf(
1my_Point(1 ' my_Point(2)+  ' my_Point(4)+  ' my_Point(4)
                buf(
1buf(1)+  ' +my_Point(3 ' my_Point(5)+  ' my_Point(6)+  ' my_Point(6   
        
else
        
if z_numgp(p_z) 5 then;D
        ;
1 2 5 3 4 4 4 4
            my_Point(
1)=string(my_Grid(gp_id(z_gp(p_z, 1))))
            my_Point(
2)=string(my_Grid(gp_id(z_gp(p_z, 2))))
            my_Point(
3)=string(my_Grid(gp_id(z_gp(p_z, 3))))
            my_Point(
4)=string(my_Grid(gp_id(z_gp(p_z, 4))))
            my_Point(
5)=string(my_Grid(gp_id(z_gp(p_z, 5))))
            ;
                buf(
1my_Point(1 ' my_Point(2)+  ' my_Point(5)+  ' my_Point(3)
                buf(
1buf(1)+  ' +my_Point(4 ' my_Point(4)+  ' my_Point(4)+  ' my_Point(4 
        endif;A
        endif;B
        endif;C
        endif;D
            status write(buf,
1)
    endif
    endif;
if inrange('writeRange',p_z) 1 then
        p_z z_next(p_z);next zone
    endloop;loop 
while p_z null
ii=out(
'Zone Connectivity List has been written!')
end;End of write_zone
;;
;;Main Function
def Flac2tec    
    status close
    status open(tec_file,IO_WRITE,IO_ASCII)
    
if status 0 then
        write_FileHead
        write_node
        write_nodeData
        write_zoneData
        write_zone
        status close
        ii out(
'Data File for Tecplot has been created!  ' tec_file)
    
else
        ii out(
'Open File Error! Status ' string(status))         
    endif
end;End of Flac2tec 
@Flac2tec
system(
"preplot FLAC3DMesh_deformation.dat")
set echo on
ret
;EoF

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有