找回密码
 注册
Simdroid-非首页
楼主: 609243692

[前后处理] Flac 3d to Tecplot 程序

[复制链接]
 楼主| 发表于 2022-1-17 21:06:43 | 显示全部楼层 来自 甘肃平凉
6.0有一个程序,留个邮箱
回复 不支持

使用道具 举报

 楼主| 发表于 2022-1-17 21:21:14 | 显示全部楼层 来自 甘肃平凉
Simdroid开发平台
;;=================================================================
;;自己保存成(.f3dat)格式FLAC3D 6.0 Mesh to Tecplot
;;Now this dat file was match to flac3d version 6.0
;;Tecplot Version --  Version 2015
;==================================================================
;;Initialization Global Parametres
;model restore '3-2-2.sav'
fish automatic-create on
;set fish sa off
program echo off
program        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
                model range create '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 range.isin('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 range.isin('writeRange',p_z) = 1  then
                if zone.model(p_z) # 'NULL' then
                        j=j+1
                endif
                endif
                p_z = z.next(p_z);next zone
        endloop
    buf(1) =          ' \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 = file.write(buf,1)
    ii=io.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 range.isin('writeRange',p_gp) = 1  then
                                        buf(1) = buf(1)+string(gp.pos.x(p_gp)+gp.disp.x(p_gp)*ScaleFactor)+ '  '
                                        n=n+1
                                endif
                                p_gp = gp.next(p_gp)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_gp) = 1  then
                                        buf(1) = buf(1)+string(gp.pos.y(p_gp)+gp.disp.y(p_gp)*ScaleFactor)+ '  '
                                        n=n+1
                                endif
                                p_gp = gp.next(p_gp)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_gp) = 1  then
                                        buf(1) = buf(1)+string(gp.pos.z(p_gp)+gp.disp.z(p_gp)*ScaleFactor)+ '  '
                                        n=n+1
                                endif
                                p_gp = gp.next(p_gp)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.write(buf,1)
    endloop
ii=io.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 range.isin('writeRange',p_gp) = 1 then
                                        buf(1) = buf(1)+string(math.sqrt(gp.disp.x(p_gp)^2+gp.disp.y(p_gp)^2+gp.disp.z(p_gp)^2))+ '  '
                                        n=n+1
                                endif
                                p_gp = gp.next(p_gp)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_gp) = 1 then
                                        buf(1) = buf(1)+string(gp.disp.x(p_gp))+ '  '
                                        n=n+1
                                endif
                                p_gp = gp.next(p_gp)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_gp) = 1  then
                                        buf(1) = buf(1)+string(gp.disp.y(p_gp))+ '  '
                                        n=n+1
                                endif
                                p_gp = gp.next(p_gp)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_gp) = 1  then
                                        buf(1) = buf(1)+string(gp.disp.z(p_gp))+ '  '
                                        n=n+1
                                endif
                                p_gp = gp.next(p_gp)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.write(buf,1)
    endloop
ii=io.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 range.isin('writeRange',p_z) = 1 then
                                if zone.model(p_z) # 'NULL' then
                                        buf(1) = buf(1)+string(zone.stress.xx(p_z))+ '  '
                                        n=n+1
                                endif
                                endif
                                p_z = zone.next(p_z)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_z) = 1 then
                                if zone.model(p_z) # 'NULL' then
                                        buf(1) = buf(1)+string(zone.stress.yy(p_z))+ '  '
                                        n=n+1
                                endif
                                endif
                                p_z = zone.next(p_z)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_z) = 1 then
                                if zone.model(p_z) # 'NULL' then
                                        buf(1) = buf(1)+string(zone.stress.zz(p_z))+ '  '
                                        n=n+1
                                endif
                                endif
                                p_z = z.next(p_z)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_z) = 1 then
                                if zone.model(p_z) # 'NULL' then
                                        buf(1) = buf(1)+string(zone.stress.min(p_z))+ '  '
                                        n=n+1
                                endif
                                endif
                                p_z = zone.next(p_z)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_z) = 1 then
                                if zone.model(p_z) # 'NULL' then
                                        buf(1) = buf(1)+string(zone.stress.int(p_z))+ '  '
                                        n=n+1
                                endif
                                endif
                                p_z = zone.next(p_z)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.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 range.isin('writeRange',p_z) = 1 then
                                if zone.model(p_z) # 'NULL' then
                                        buf(1) = buf(1)+string(zone.stress.max(p_z))+ '  '
                                        n=n+1
                                endif
                                endif
                                p_z = zone.next(p_z)
                        else
                                n=N_RECORD+1
                        endif
                endloop
                status = file.write(buf,1)
    endloop
ii=io.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 range.isin('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 range.isin('writeRange',p_z) = 1  then
        if zone.model(p_z) # 'NULL' then
                if zone.gp.num(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 zone.gp.num(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 zone.gp.num(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 zone.gp.num(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 = file.write(buf,1)
        endif
        endif;if inrange('writeRange',p_z) = 1 then
                p_z = zone.next(p_z);next zone
        endloop;loop while p_z # null
ii=io.out('Zone Connectivity List has been written!')
end;End of write_zone
;;
;;Main Function
def Flac2tec       
    status = file.close
        status = file.open(tec_file,IO_WRITE,IO_ASCII)
        if status = 0 then
            write_FileHead
            write_node
                write_nodeData
                write_zoneData
            write_zone
            status = file.close
            ii = io.out('Data File for Tecplot has been created!  ' + tec_file)
        else
            ii = io.out('Open File Error! Status = ' + string(status))                       
        endif
end;End of Flac2tec       
@Flac2tec
program system("preplot FLAC3DMesh_deformation.dat")
program echo on
;;If you do not have saved this project before
;; Your output-file would be in C:\Windows\System32

回复 不支持

使用道具 举报

 楼主| 发表于 2022-1-17 21:23:31 | 显示全部楼层 来自 甘肃平凉
上传不了附件了,6.0程序用的,也是给别人要的,方便大家使用吧
回复 不支持

使用道具 举报

发表于 2022-1-19 09:05:05 | 显示全部楼层 来自 浙江
新人学习一下
回复 不支持

使用道具 举报

发表于 2022-2-25 10:17:02 | 显示全部楼层 来自 江苏
609243692 发表于 2013-3-9 10:16
Flac3d运行完成以后,直接Call此程序,会在程序存放的目录下生成一个txt文件,将其导入tecplot即可 ...

请问楼主是不是用的FLAC3.0,我用5.0调用该程序的时候出错
回复 不支持

使用道具 举报

发表于 2022-10-28 23:20:56 | 显示全部楼层 来自 北京
感觉楼主很厉害,我先试试看
回复 不支持

使用道具 举报

发表于 2022-11-2 10:00:39 | 显示全部楼层 来自 中国
还没进行到后处理,先存下
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-6-16 09:03 , Processed in 0.030330 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表