当前位置:文档之家› Flac3D_to_tecplot后处理____转换程序,直接在flac中运行

Flac3D_to_tecplot后处理____转换程序,直接在flac中运行


;; 08/04/2009
;; Modifications:
;; (1) 将应力输出项增加为(SIG1,SIG2,SIG3,SXX,SYY,SZZ,SXY,SYZ,SZX,SHEAR_N,TENSION_N,SHEAR_P,TENSION_P)
;;

;; 01/12/2007
;; Modifications:
;; (1) 将应力输出项增加为(SIG1,SIG2,SIG3,SXX,SYY,SZZ,SXY,SYZ,SZX)
;; (2) 可控制输出的GROUP,若不想输出某个组,请ran name tec_range后面加入组名
;;

;; 18/12/2006
;; Modifications:
;; (1) adapted to all types of zones( brick,pyramid,wedge,tetra )
;; (2) If all the zones are tetra, use the format "ZONETYPE=FETETRAHEDRON"
;;

;; 9/14/2004
;; Modifications:
;; (1) change data packing mode from point to block
;; (2) add zone-related info to be plotted
;;

;; 9/11/2004
;; Modifications:
;; (1) add range tec_range to set plot range
;; (2) add function plot_test to hide null zones
;;

;; 7/11/2004
;; Flac3d Mesh to Tecplot
;; Limits:
;; (1)Zone Type ---- TETRAHEDRON or BRICK
;; (2)Tecplot Version ---- Version 10
;; (3)Only DISPLACEMENTS of Grid Points are outputted
;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Initialization
def ini_mesh2tec
IO_READ = 0
IO_WRITE = 1
IO_FISH = 0
IO_ASCII = 1
N_RECORD = 5 ;;;;;;;;;;;;;;;; 数据每5个存放一行
ZONE_NGP = z_numgp(zone_head)
array buff(1)
tec_file = 'tec10_hole.dat'

;; Edit the tec_range to set plot range
command
;group haitang range group 6 any group 7 any
;model null range group haitang not
ran name tec_range
endcommand
end
ini_mesh2tec


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; If plotit = 1, plot the zone
def plot_test
plotit = 1
if z_model(p_z) = 'NULL' then
plotit = 0
endif
if inrange('tec_range',p_z) = 0 then
plotit = 0
endif
end

;; Get number of zones to plot
def get_nzone
n_zone = 0
numzones = 0
p_z = zone_head
loop while p_z # null
numzones = numzones + 1
plot_test
if plotit = 1 then
n_zone = n_zone + 1
endif
p_z = z_next(p_z)
endloop
end
get_nzone


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Write Tecplot File Head
def write_head
buff(1) = 'TITLE = "FLAC3D to Tecplot 10"\n'
buff(1) = buff(1) + 'VARIABLES = "X(m)" \n"Y(m)" \n"Z(m)" \n'
buff(1) = buff(1) + '"DISP(mm)" \n"XDISP(mm)" \n"YDISP(mm)" \n"ZDISP(mm)" \n'
buff(1) = buff(1) + '"SIG1(MPa)" \n"SIG2(MPa)" \n"SIG3(MPa)" \n'
buff(1) = buff(1) + '"SXX(MPa)" \n"SYY(MPa)" \n"SZZ(MPa)" \n'
buff(1) = buff(1) + '"SXY(MPa)" \n"SYZ(MPa)" \n"SZX(MPa)" \n'
buff(1) = buff(1) + '"SHEAR_N"\n"TENSION_N"\n"SHEAR_P"\n"TENSION_P"\n'
buff(1) = buff(1) + 'ZONE T="GLOBAL" \n'
buff(1) = buff(1) + ' N=' + string(ngp) + ','
buff(1) = buff(1) + ' E=' + string(n_zone) + ','
buff(1) = buff(1) + ' ZONETYPE=FEBrick \n'
buff(1) = buff(1) + ' DATAPACKING=BLOCK \n'

buff(1) = buff(1) + ' VARLOCATION=([8-20]=CELLCENTERED) \n'
buff(1) = buff(1) + ' DT=(SINGLE SINGLE SINGLE'
buff(1) = buff(1) + ' SINGLE SINGLE SINGLE SINGLE'
buff(1) = buff(1) + ' SINGLE SINGLE SINGLE'
buff(1) = buff(1) + ' SINGLE SINGLE SINGLE'
buff(1) = buff(1) + ' SINGLE SINGLE SINGLE'
buff(1) = buff(1) + ' SINGLE SINGLE SINGLE SINGLE)'
status = write(buff,1)
end

;; Calculate displacement magnitude
def get_gp_disp
gp_disp = gp_xdisp(p_gp)*gp_xdisp(p_gp)
gp_disp = gp_disp + gp_ydisp(p_gp)*gp_ydisp(p_gp)
gp_disp = gp_disp + gp_zdisp(p_gp)*gp_zdisp(p_gp)
gp_disp = sqrt(gp_disp)
end

;; Write gp-related data,such as Coordinates and Displacements
def write_gp_info
p_gp = gp_head
loop while p_gp # null
buff(1) = ''
loop i(1,N_RECORD)
if p_gp # null then
caseof info_flag
case 0
buff(1) = buff(1) + string(gp_xpos(p_gp)) + ' '
case 1
buff(1) = buff(1) + string(gp_ypos(p_gp)) + ' '
case 2
buff(1) = buff(1) + string(gp_zpos(p_gp)) + ' '
case 4
get_gp_disp
buff(1) = buff(1) + string(gp_disp*1000) + ' '
case 8
buff(1) = buff(1) + string(gp_xdisp(p_gp)*1000) + ' '
case 16
buff(1) = buff(1) + string(gp_ydisp(p_gp)*1000) + ' '
case 32
buff(1) = buff(1) + string(gp_zdisp(p_gp)*1000) + ' '
endcase
p_gp = gp_next(p_gp)
endif
endloop
status = write(buff,1)
endloop
end

;; Write zone-related data,such as Stresses
def write_zone_info_stress
p_z = zone_head
loop while p_z # null
buff(1) = ''
loop i(1,N_RECORD)
if p_z # null then
plot_test
if plotit = 1 then
caseof info_flag
case 0
buff(1) = buff(1) + string(z_sig3(p_z)*0.000001) + ' '
case 1
buff(1) = buff(1) + string(z_sig2(p_z)*0.000001) + ' '
case 2
buff(1) = buff(1) + string(z_sig1(p_z)*0.000001) + ' '
case 4
buff(1) = buff(1) + string(z_sxx(p_z)*0.000001) + ' '
case 8
buff(1) = buff(1) + string(z_syy(p_z)*0.000001) + ' '
case 16
buff(1) = buff(1) + string(z_szz(p_z)*0.000001) + ' '
case 32
buff(1) = buff(1) + string(z_sxy(p_z)*0.000001) + ' '
case 64
buff(1) = buff(1)

+ string(z_syz(p_z)*0.000001) + ' '
case 128
buff(1) = buff(1) + string(z_sxz(p_z)*0.000001) + ' '
endcase
endif
p_z = z_next(p_z)
endif
endloop
status = write(buff,1)
endloop
end

;; Write zone-related data,such as States
def write_zone_info_state
shear_n=1
tension_n=2
shear_p=4
tension_p=8
state=0
p_z = zone_head
loop while p_z # null
buff(1) = ''
loop i(1,N_RECORD)
if p_z # null then
plot_test
if plotit = 1 then
caseof info_flag
case 1
if and(z_state(p_z,0),shear_n)=shear_n then
state=1
else
state=0
endif
buff(1) = buff(1) + string(state) + ' '
case 2
if and(z_state(p_z,0),tension_n)=tension_n then
state=1
else
state=0
endif
buff(1) = buff(1) + string(state) + ' '
case 4
if and(z_state(p_z,0),shear_p)=shear_p then
state=1
else
state=0
endif
buff(1) = buff(1) + string(state) + ' '
case 8
if and(z_state(p_z,0),tension_p)=tension_p then
state=1
else
state=0
endif
buff(1) = buff(1) + string(state) + ' '
endcase
endif
p_z = z_next(p_z)
endif
endloop
status = write(buff,1)
endloop
end

;; Write Zone Connectivity
def write_zone
p_z = zone_head
tetranum = 0
bricknum = 0
wedgenum = 0
pyramidnum = 0
loop while p_z # null
buff(1) = ' '
Z1_code=z_code(p_z)
if Z1_code = 4 then
tetranum = tetranum + 1
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 1))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 2))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 3))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 3)

)) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
else
if Z1_code = 0 then
bricknum = bricknum + 1
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 1))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 2))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 5))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 3))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 7))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 8))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 6))) + ' '
else
if Z1_code = 1 then
wedgenum = wedgenum + 1
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 1))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 2))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 3))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 5))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 6))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 6))) + ' '
else
if Z1_code = 2 then
pyramidnum = pyramidnum + 1
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 1))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 2))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 5))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 3))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
buff(1) = buff(1) + string(gp_id(z_gp(p_z, 4))) + ' '
endif
endif
endif
endif
plot_test
if plotit = 1 then
status = write(buff,1)
endif
p_z = z_next(p_z)
endloop
end


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main Function
def Wait
status = close
status = open(tec_file,IO_WRITE,IO_ASCII)
if status = 0 then
write_head
;;;;;;;;;;;;;;;; Write gp-related data Coordinates
info_flag = 0
write_gp_info
info_flag = 1
write_gp_info
info_flag = 2
write_gp_info
;;;;;;;;;;;;;;;; Write gp-related data displacement
info_flag = 4
write_gp_info
info_

flag = 8
write_gp_info
info_flag = 16
write_gp_info
info_flag = 32
write_gp_info
;;;;;;;;;;;;;;;; Write zone-related data stress
info_flag = 0
write_zone_info_stress
info_flag = 1
write_zone_info_stress
info_flag = 2
write_zone_info_stress
info_flag = 4
write_zone_info_stress
info_flag = 8
write_zone_info_stress
info_flag = 16
write_zone_info_stress
info_flag = 32
write_zone_info_stress
info_flag = 64
write_zone_info_stress
info_flag = 128
write_zone_info_stress
;;;;;;;;;;;;;;;; Write zone-related data state
info_flag = 1
write_zone_info_state
info_flag = 2
write_zone_info_state
info_flag = 4
write_zone_info_state
info_flag = 8
write_zone_info_state
;;;;;;;;;;;;;;;; Write zone Structure
write_zone
status = close

ii = out('Successfully Write Zone Data Into Tecplot Format File: ' + tec_file)
dipzonenum = numzones - bricknum - tetranum - wedgenum - pyramidnum
ii = out('The numbers of Model Zones: ' + string(numzones) )
ii = out('The numbers of Ouput Zones: ' + string(n_zone) )
ii = out('The numbers of Dipped Zones: ' + string(dipzonenum) )
ii = out('The numbers of Brick Zones: ' + string(bricknum) )
ii = out('The numbers of Tetra Zones: ' + string(tetranum) )
ii = out('The numbers of Wedge Zones: ' + string(wedgenum) )
ii = out('The numbers of Pyramid Zones: ' + string(pyramidnum) )
else
ii=out('Open File Error! Status = ' + string(status))
endif
end
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;* ▆┋ | ╱█◣
;* ◢█◣ | ▆ / ◥ __◢◤ FLAC3D to Tecplot10.0
;* ◤◥╲ | |/__ ╱\ █◣ Version:2007.12.01 修订版 from dynamax
;* ◢█◣▆ / ◢█◣/\◥ Adapted by freebird
;* ◤◥ | ┋ /| ◤◥◢◣ email:freebird5586@https://www.doczj.com/doc/ea9970604.html,
;* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wait ; 单元数多的模型,导出的时间较长,请耐心等候!


相关主题
文本预览
相关文档 最新文档