- 积分
- 0
- 注册时间
- 2014-2-26
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2016-4-23 08:45:15
|
显示全部楼层
来自 北京
本帖最后由 龙biscuit 于 2016-4-23 08:49 编辑
http://bbs.yantuchina.com/read.php?tid=290809,适用于flac3d5.0提取数据到tecplot,亲试可用,感谢kays大神吧!(ps:高版本的tecplot比如2015版切片功能与2010版不一样了,这个电脑上没有安装,记不清了,反正就是在前面菜单处先切片,然后再在data-里面显示切片。当然,这是题外话,导出的这个东西高低版本的tecplot都是适用的)
- ;;=================================================================
- ;;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(1) = buf(1) + 'VARIABLES = "X" "Y" "Z" "DISP" "XDISP" "YDISP" "ZDISP" "SXX" "SYY" "SZZ" "Sig1" "Sig2" "Sig3"\n'
- buf(1) = buf(1) + 'ZONE T="FLAC3D Data" \n'
- buf(1) = buf(1) + 'N='+string(i)+','+'E='+string(j)+','+'ZONETYPE=FEBrick '
- buf(1) = buf(1) + 'DATAPACKING=block\n'+'VARLOCATION=([8-13]=CELLCENTERED)\n'
- buf(1) = buf(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 X Y Z
- def write_node
- ;Write x position
- p_gp = gp_head
- loop while p_gp # null
- buf(1)=''
- n=1
- loop while n <= N_RECORD
- if p_gp # null then
- if in_range('writeRange',p_gp) = 1 then
- buf(1) = buf(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 y position
- p_gp = gp_head
- loop while p_gp # null
- buf(1)=''
- n=1
- loop while n <= N_RECORD
- if p_gp # null then
- if in_range('writeRange',p_gp) = 1 then
- buf(1) = buf(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 z position
- p_gp = gp_head
- loop while p_gp # null
- buf(1)=''
- n=1
- loop while n <= N_RECORD
- if p_gp # null then
- if in_range('writeRange',p_gp) = 1 then
- buf(1) = buf(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 <= N_RECORD
- if p_gp # null then
- if in_range('writeRange',p_gp) = 1 then
- buf(1) = buf(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 <= N_RECORD
- if p_gp # null then
- if in_range('writeRange',p_gp) = 1 then
- buf(1) = buf(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 <= N_RECORD
- if p_gp # null then
- if in_range('writeRange',p_gp) = 1 then
- buf(1) = buf(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 <= N_RECORD
- if p_gp # null then
- if in_range('writeRange',p_gp) = 1 then
- buf(1) = buf(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(1) = buf(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(1) = buf(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(1) = buf(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(1) = buf(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(1) = buf(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(1) = buf(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(1) = my_Point(1) + ' ' + my_Point(2)+ ' ' + my_Point(5)+ ' ' + my_Point(3)
- buf(1) = buf(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(1) = my_Point(1) + ' ' + my_Point(2)+ ' ' + my_Point(3)+ ' ' + my_Point(3)
- buf(1) = buf(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(1) = my_Point(1) + ' ' + my_Point(2)+ ' ' + my_Point(4)+ ' ' + my_Point(4)
- buf(1) = buf(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(1) = my_Point(1) + ' ' + my_Point(2)+ ' ' + my_Point(5)+ ' ' + my_Point(3)
- buf(1) = buf(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
复制代码 |
|