AaronSpark 发表于 2006-8-23 01:53

ansys输入文件转到marc输入数据文件的APDL程序

!最好在ansys前处理器环境下进行转换操作,还要注意下面的命令要采用批处理方式输入,不要复制粘贴.
/COM, ==========================================================
/COM,
/COM,   Beijing University of Technology
/COM,   
/COM,   Beijing, 100022, P.R. China
/COM,   
/COM,   WITH HONEYCOMBS MODEL EXAMPLE
/COM,   Apr. 2006
/COM,   ANSYS 10.0/MARC.2005R2
/COM,
/COM, ==========================================================
/COM,
/COM,   MA LIANHUA               
/COM,   School of Mechanical Engineering,
/COM,   Beijing University of Technology                                          
/COM,   QQ:29128203         
/COM,   Email:mark@emails.bjut.edu.cn         
/COM,
/COM, ==========================================================
!因为MARC的输入文件格式是用行与格来明确定义它所表示的内容,所以它不能有任意的空白行或空白键出现,否则会发生读取资料有误的情况.
!有关指令的描述,我所用的参考书目是"MSC.Marc 2005r2 Volume C",相关指令的详细描述可由本书得到解释说明.
/PREP7
ALLSEL,ALL                !选中所有项目
Swsv=1000000            !定义参数,向量尺寸Swsv(size of work space vector,MAXALL)
MnDOF=24                  !定义参数,最大自由度数MnDOF
*ASK,Lcftes,Library code of the first type of element selected,139
*GET,Nelem,ELEM,0,COUNT   !得到当前模型中的所有总单元数
*GET,El,ELEM,0,NUM,MIN    !所选单元的最小编号
*GET,Nnod,NODE,0,COUNT    !得到当前模型中的所有总节点数
*GET,Nd,NODE,0,NUM,MIN    !所选单元的最小编号
*CFOPEN,ANtoMA,in         !打开ansys-to-marc数据转换文件
*VWRITE
('title   jobname')   ! marc档案名,1-10格为关键词title;11-80格为title名描述
*VWRITE,Swsv,Nelem,Nnod,MnDOF
('sizing',4X,F11.0,TL1,F6.0,TL1,F6.0,TL1,F6.0,TL1,' ')    !向量空间定义,1-10格为关键词sizing;11-20格为向量尺寸,21-25格为最大单元数,26-30为最大节点数,31-35为最大自由度数
*VWRITE,Lcftes
('elements',2X,F6.0,TL1,' ')!单元类型选择,1-10关键字elements,11-15所选第一种单元类型,16-20第二种类型....,以此类推
*VWRITE,11
('version',3X,F6.0,TL1,' ')   !指定MARC输入文件的版本号,1-10关键字version,11-15所用的Marc输入/分析版本号,9-2001,10-2003,11-2005
*VWRITE,1,1,1
('processor',' ',3(F6.0,TL1,' '))
*VWRITE
('$no list')                   !no listing of input data
*VWRITE
('all points')               !状态储存 所有节点均储存
*VWRITE,3
('setname',3x,f6.0,tl1,' ')    !定义 setname最大个数, 最大个数为3
*VWRITE
('end')                        !Parameter Card 结束用语
*VWRITE
('$..............................................')       !分隔符
*VWRITE
('$============ Model Definition Card ===========')       !分隔符
*VWRITE
('optimize','      9')         !Bandwidth 最佳化的方式 采用编号九的方法
*VWRITE
('connectivity')               !指定单元连结性
*VWRITE,Nelem
(F6.0,TL1,' ')               !指定单元连结性
!得到单元编号和各单元的顺序节点编号,并输出
!MULTIPRO,'start',2
!*cset,1,3,Ndpel,'Nodes number - per element(4/8):',4
!*cset,4,6,Rnum,'Number of real constants',2
!*cset,61,62,'输入采用单元','的节点数量和实常数数量:'
!*cset,63,64,'Ndpel','---------Rnum'
!MULTIPRO,'end'
*IF,Ndpel,EQ,4,THEN
*DO,I,1,NELEM,1
En=El                        !单元号 element number         
*VWRITE,En,Lcftes,NELEM(El,1),NELEM(El,2),NELEM(El,3),NELEM(El,4)   !读出单元的4个节点编号
(5(F6.0,TL1),F6.0,TL1,' ')
El=ELNEXT(El)                !读出下一个单元编号
*ENDDO
*ENDIF
*VWRITE
('coordinates')               !指定节点坐标
*VWRITE,0,36,0,1
(3(f6.0,tl1),F6.0,TL1,' ')    !3维,节点数...
*DO,I,1,Nnod,1
Nn=Nd                           !节点号 nodal point number
NX=NX(Nd)                     !节点号,X坐标
NY=Ny(Nd)                     !节点号,Y坐标
NZ=Nz(Nd)                     !节点号,Z坐标
*VWRITE,Nn,NX,NY,NZ
(F6.0,TL1,3F10.4)
Nd=NDNEXT(Nd)                   !读出下一个节点编号
*ENDDO
*VWRITE
('isotropic')                   !指定材料性质      
*VWRITE            
()                              !第二小Card,在这没有相关的描述.
*VWRITE,1,0,0
(F6.0,TL1,'elastic',3X,'isotropic',' ',F6.0,TL1,F6.0,TL1,' ')   !第三小Card,纯弹性,各项同性。将这个材料编号为1,6~25格空白,表示参数的描述为预设值.26~30格在MARC中不使用,预设值为零.31~35格输入0表示不进行水泥破裂(concrete cracking)的运算.
*VWRITE,YOUNG,POISSON
(E10.4,F10.4)                   !第四小Card定义杨氏模量,泊松比,1~10格表示杨氏模量,11~20格表示波松比( poisson ratio),21~30格表示密度,31~40格表示热膨胀系数,41~50格表示Equivalent tensile yield stress,51~60格表示for ORNL yield criteria.
*VWRITE,chrval(Nelem)
('1 TO ',A5)                  !第五小card,输入和这个材料有关的单元
*VWRITE
('geometry')                  !定义几何数据
*VWRITE
()                              !空白行,不描述
*VWRITE,t,0,0,0,0,0,0
(F10.5,6F10.5)                  !第1~10给定材料的厚度,11格以后的参数请参阅Volumn C
ESEL,S,REAL,,1
*GET,ElR1,ELEM,0,NUM,MIN      !所选单元的最小编号
*GET,NelemR1,ELEM,0,COUNT       !得到所选单元的总单元数
ROWR=NelemR1/10               !以每行10个数据计算得到的行数(实数)
ROWI=NINT(ROWR)               !取整后的行数(接近ROWR的整数)
*IF,ROWI,GE,ROWR,THEN
ROW=ROWI
*ELSEIF,ROWI,LT,ROWR
ROW=ROWI+1
*ENDIF
*IF,ROW,EQ,0,THEN
*MSG,NOTE
ERROR......
*ENDIF
*IF,ROW,EQ,1,:10
*DIM,NEro,ARRAY,ROW-1,10
*DO,I,1,ROW-1,1
*DO,J,1,10
NEro(I,J)=ElR1
ElR1=ELNEXT(ElR1)               !读出下一个被选单元编号
*ENDDO                        
*ENDDO
*VWRITE,NEro(1,1),NEro(1,2),NEro(1,3),NEro(1,4),NEro(1,5),NEro(1,6),NEro(1,7),NEro(1,8),NEro(1,9),NEro(1,10)
(9(F6.0,TL1),F6.0,TL1,' C')
:10
NelemR1s=NelemR1-10*(ROW-1)
*DIM,NEros,ARRAY,1,NelemR1s
*DO,I,1,NelemR1s,1
NEros(1,I)=ElR1
ElR1=ELNEXT(ElR1)
*ENDDO
*IF,NelemR1s,EQ,1,THEN
*VWRITE,NEros(1,1)
(F6.0,TL1,' ')
*ELSEIF,NelemR1s,EQ,2
*VWRITE,NEros(1,1),NEros(1,2)
(2(F6.0,TL1),' ')
*ELSEIF,NelemR1s,EQ,3
*VWRITE,NEros(1,1),NEros(1,2),NEros(1,3)
(3(F6.0,TL1),' ')
*ELSEIF,NelemR1s,EQ,4
*VWRITE,NEros(1,1),NEros(1,2),NEros(1,3),NEros(1,4)
(4(F6.0,TL1),' ')
*ELSEIF,NelemR1s,EQ,5
*VWRITE,NEros(1,1),NEros(1,2),NEros(1,3),NEros(1,4),NEros(1,5)
(5(F6.0,TL1),' ')
*ELSEIF,NelemR1s,EQ,6
*VWRITE,NEros(1,1),NEros(1,2),NEros(1,3),NEros(1,4),NEros(1,5),NEros(1,6)
(6(F6.0,TL1),' ')
*ELSEIF,NelemR1s,EQ,7
*VWRITE,NEros(1,1),NEros(1,2),NEros(1,3),NEros(1,4),NEros(1,5),NEros(1,6),NEros(1,7)
(7(F6.0,TL1),' ')
*ELSEIF,NelemR1s,EQ,8
*VWRITE,NEros(1,1),NEros(1,2),NEros(1,3),NEros(1,4),NEros(1,5),NEros(1,6),NEros(1,7),NEros(1,8)
(8(F6.0,TL1),' ')
*ELSEIF,NelemR1s,EQ,9
*VWRITE,NEros(1,1),NEros(1,2),NEros(1,3),NEros(1,4),NEros(1,5),NEros(1,6),NEros(1,7),NEros(1,8),NEros(1,9)
(9(F6.0,TL1),' ')
*ELSEIF,NelemR1s,EQ,10
*VWRITE,NEros(1,1),NEros(1,2),NEros(1,3),NEros(1,4),NEros(1,5),NEros(1,6),NEros(1,7),NEros(1,8),NEros(1,9),NEros(1,10)
(10(F6.0,TL1),' ')
*ELSE
*MSG,note
we are stopped......
*ENDIF
*VWRITE
('geometry')                  !定义几何数据
*VWRITE
()                              !空白行,不描述
*VWRITE,2*t,0,0,0,0,0,0
(F10.5,6F10.5)                  !第1~10给定材料的厚度,11格以后的参数请参阅Volumn C
ESEL,S,REAL,,2
*GET,ElR2,ELEM,0,NUM,MIN      !所选单元的最小编号
*GET,NelemR2,ELEM,0,COUNT       !得到所选单元的总单元数
ROWR2=NelemR2/10                !以每行10个数据计算得到的行数(实数)
ROWI2=NINT(ROWR2)               !取整后的行数(接近ROWR的整数)
*IF,ROWI2,GE,ROWR2,THEN
ROW2=ROWI2
*ELSEIF,ROWI2,LT,ROWR2
ROW2=ROWI2+1
*ENDIF
*IF,ROW2,EQ,0,THEN
*MSG,NOTE
ERROR......
*ENDIF
*IF,ROW2,EQ,1,:20
*DIM,NErt,ARRAY,ROW2-1,10
*DO,I,1,ROW2-1,1
*DO,J,1,10
NErt(I,J)=ElR2
ElR2=ELNEXT(ElR2)               !读出下一个被选单元编号
*ENDDO                        
*ENDDO
*VWRITE,NErt(1,1),NErt(1,2),NErt(1,3),NErt(1,4),NErt(1,5),NErt(1,6),NErt(1,7),NErt(1,8),NErt(1,9),NErt(1,10)
(9(F6.0,TL1),F6.0,TL1,' C')
:20
NelemR2s=NelemR2-10*(ROW2-1)
*DIM,NErts,ARRAY,1,NelemR2s
*DO,I,1,NelemR2s,1
NErts(1,I)=ElR2
ElR2=ELNEXT(ElR2)
*ENDDO
*IF,NelemR2s,EQ,1,THEN
*VWRITE,NErts(1,1)
(F6.0,TL1,' ')
*ELSEIF,NelemR2s,EQ,2
*VWRITE,NErts(1,1),NErts(1,2)
(2(F6.0,TL1),' ')
*ELSEIF,NelemR2s,EQ,3
*VWRITE,NErts(1,1),NErts(1,2),NErts(1,3)
(3(F6.0,TL1),' ')
*ELSEIF,NelemR2s,EQ,4
*VWRITE,NErts(1,1),NErts(1,2),NErts(1,3),NErts(1,4)
(4(F6.0,TL1),' ')
*ELSEIF,NelemR2s,EQ,5
*VWRITE,NErts(1,1),NErts(1,2),NErts(1,3),NErts(1,4),NErts(1,5)
(5(F6.0,TL1),' ')
*ELSEIF,NelemR2s,EQ,6
*VWRITE,NErts(1,1),NErts(1,2),NErts(1,3),NErts(1,4),NErts(1,5),NErts(1,6)
(6(F6.0,TL1),' ')
*ELSEIF,NelemR2s,EQ,7
*VWRITE,NErts(1,1),NErts(1,2),NErts(1,3),NErts(1,4),NErts(1,5),NErts(1,6),NErts(1,7)
(7(F6.0,TL1),' ')
*ELSEIF,NelemR2s,EQ,8
*VWRITE,NErts(1,1),NErts(1,2),NErts(1,3),NErts(1,4),NErts(1,5),NErts(1,6),NErts(1,7),NErts(1,8)
(8(F6.0,TL1),' ')
*ELSEIF,NelemR2s,EQ,9
*VWRITE,NErts(1,1),NErts(1,2),NErts(1,3),NErts(1,4),NErts(1,5),NErts(1,6),NErts(1,7),NErts(1,8),NErts(1,9)
(9(F6.0,TL1),' ')
*ELSEIF,NelemR2s,EQ,10
*VWRITE,NErts(1,1),NErts(1,2),NErts(1,3),NErts(1,4),NErts(1,5),NErts(1,6),NErts(1,7),NErts(1,8),NErts(1,9),NErts(1,10)
(10(F6.0,TL1),' ')
*ELSE
*MSG,note
we are stopped......
*ENDIF
*VWRITE
('FIXED DISP')            !固定的边界条件
*VWRITE
()                        !空白行,不描述
*VWRITE,0
(F10.4)                   !相关自由度位移量
*VWRITE,2
(F6.0,TL1,' ')            !相关自由度标号,1表示第一个自由度,2表示第二个自由度,其余依此类推.至於第一个自由度的位移量有多少,那就得看第三小card中第一组数据的量是多少,在这个例子中第2个自由度的位移量是零.
NSEL,S,LOC,Y,-(shu-1)*(h+l*sin(theta))*2-(h+l*sin(theta))+h/2   !选择你要施加边界条件的节点
!NSEL,A,LOC,..
*GET,Ndbc,NODE,0,NUM,MIN      !所选节点的最小编号
*GET,Nntol,NODE,0,COUNT         !得到所选节点的总节点数
ROWNR=Nntol/10                   !以每行10个数据计算得到的行数(实数)
ROWNI=NINT(ROWNR)                !取整后的行数(接近ROWR的整数)
*IF,ROWNI,GE,ROWNR,THEN
ROWN=ROWNI
*ELSEIF,ROWNI,LT,ROWNR
ROWN=ROWNI+1
*ENDIF
*IF,ROWN,EQ,0,THEN
*MSG,NOTE
ERROR......
*ENDIF
*IF,ROWN,EQ,1,:30
*DO,I,1,ROWN-1,1
Ndbc1=Ndbc
Ndbc2=NDNEXT(Ndbc1)
Ndbc3=NDNEXT(Ndbc2)
Ndbc4=NDNEXT(Ndbc3)
Ndbc5=NDNEXT(Ndbc4)
Ndbc6=NDNEXT(Ndbc5)
Ndbc7=NDNEXT(Ndbc6)
Ndbc8=NDNEXT(Ndbc7)
Ndbc9=NDNEXT(Ndbc8)
Ndbc10=NDNEXT(Ndbc9)
*VWRITE,chrval(Ndbc1),chrval(Ndbc2),chrval(Ndbc3),chrval(Ndbc4),chrval(Ndbc5),chrval(Ndbc6),chrval(Ndbc7),chrval(Ndbc8),chrval(Ndbc9),chrval(Ndbc10)
(10A5,'    C')
Ndbc=NDNEXT(Ndbc10)
*ENDDO
:30
Nntols=Nntol-10*(ROWN-1)
*DIM,Ndts,ARRAY,1,Nntols
*DO,I,1,Nntols,1
Ndts(1,I)=Ndbc
Ndbc=NDNEXT(Ndbc)
*ENDDO
*IF,Nntols,EQ,1,THEN
*VWRITE,chrval(Ndts(1,1))
(A5)
*ELSEIF,Nntols,EQ,2
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2))
(2A5)
*ELSEIF,Nntols,EQ,3
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2)),chrval(Ndts(1,3))
(3A5)
*ELSEIF,Nntols,EQ,4
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2)),chrval(Ndts(1,3)),chrval(Ndts(1,4))
(4A5)
*ELSEIF,Nntols,EQ,5
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2)),chrval(Ndts(1,3)),chrval(Ndts(1,4)),chrval(Ndts(1,5))
(5A5)
*ELSEIF,Nntols,EQ,6
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2)),chrval(Ndts(1,3)),chrval(Ndts(1,4)),chrval(Ndts(1,5)),chrval(Ndts(1,6))
(6A5)
*ELSEIF,Nntols,EQ,7
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2)),chrval(Ndts(1,3)),chrval(Ndts(1,4)),chrval(Ndts(1,5)),chrval(Ndts(1,6)),chrval(Ndts(1,7))
(7A5)
*ELSEIF,Nntols,EQ,8
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2)),chrval(Ndts(1,3)),chrval(Ndts(1,4)),chrval(Ndts(1,5)),chrval(Ndts(1,6)),chrval(Ndts(1,7)),chrval(Ndts(1,8))
(8A5)
*ELSEIF,Nntols,EQ,9
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2)),chrval(Ndts(1,3)),chrval(Ndts(1,4)),chrval(Ndts(1,5)),chrval(Ndts(1,6)),chrval(Ndts(1,7)),chrval(Ndts(1,8)),chrval(Ndts(1,9))
(9A5)
*ELSEIF,Nntols,EQ,10
*VWRITE,chrval(Ndts(1,1)),chrval(Ndts(1,2)),chrval(Ndts(1,3)),chrval(Ndts(1,4)),chrval(Ndts(1,5)),chrval(Ndts(1,6)),chrval(Ndts(1,7)),chrval(Ndts(1,8)),chrval(Ndts(1,9)),chrval(Ndts(1,10))
(10A5)
*ELSE
*MSG,note
we are stopped......
*ENDIF
*VWRITE
('point load')!施力的条件
*VWRITE
()
*VWRITE,0,F,0,0,0,0
(6E10.4)
NSEL,S,LOC,Y,h/2+l*sin(theta)
!NSEL,A,LOC...
*GET,Ndbc,NODE,0,NUM,MIN      !所选节点的最小编号
*GET,Nntol,NODE,0,COUNT         !得到所选节点的总节点数
ROWNR=Nntol/10                   !以每行10个数据计算得到的行数(实数)
ROWNI=NINT(ROWNR)                !取整后的行数(接近ROWR的整数)
*IF,ROWNI,GE,ROWNR,THEN
ROWN=ROWNI
*ELSEIF,ROWNI,LT,ROWNR
ROWN=ROWNI+1
*ENDIF
*IF,ROWN,EQ,0,THEN
*MSG,NOTE
ERROR......
*ENDIF
*IF,ROWN,EQ,1,:40
*DO,I,1,ROWN-1,1
Ndbc1=Ndbc
Ndbc2=NDNEXT(Ndbc1)
Ndbc3=NDNEXT(Ndbc2)
Ndbc4=NDNEXT(Ndbc3)
Ndbc5=NDNEXT(Ndbc4)
Ndbc6=NDNEXT(Ndbc5)
Ndbc7=NDNEXT(Ndbc6)
Ndbc8=NDNEXT(Ndbc7)
Ndbc9=NDNEXT(Ndbc8)
Ndbc10=NDNEXT(Ndbc9)
*VWRITE,chrval(Ndbc1),chrval(Ndbc2),chrval(Ndbc3),chrval(Ndbc4),chrval(Ndbc5),chrval(Ndbc6),chrval(Ndbc7),chrval(Ndbc8),chrval(Ndbc9),chrval(Ndbc10)
(10A5,'    C')
Ndbc=NDNEXT(Ndbc10)
*ENDDO
:40
Nntols=Nntol-10*(ROWN-1)
*DIM,Ndpls,ARRAY,1,Nntols
*DO,I,1,Nntols,1
Ndpls(1,I)=Ndbc
Ndbc=NDNEXT(Ndbc)
*ENDDO
*IF,Nntols,EQ,1,THEN
*VWRITE,chrval(Ndpls(1,1))
(A5)
*ELSEIF,Nntols,EQ,2
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2))
(2A5)
*ELSEIF,Nntols,EQ,3
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2)),chrval(Ndpls(1,3))
(3A5)
*ELSEIF,Nntols,EQ,4
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2)),chrval(Ndpls(1,3)),chrval(Ndpls(1,4))
(4A5)
*ELSEIF,Nntols,EQ,5
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2)),chrval(Ndpls(1,3)),chrval(Ndpls(1,4)),chrval(Ndpls(1,5))
(5A5)
*ELSEIF,Nntols,EQ,6
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2)),chrval(Ndpls(1,3)),chrval(Ndpls(1,4)),chrval(Ndpls(1,5)),chrval(Ndpls(1,6))
(6A5)
*ELSEIF,Nntols,EQ,7
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2)),chrval(Ndpls(1,3)),chrval(Ndpls(1,4)),chrval(Ndpls(1,5)),chrval(Ndpls(1,6)),chrval(Ndpls(1,7))
(7A5)
*ELSEIF,Nntols,EQ,8
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2)),chrval(Ndpls(1,3)),chrval(Ndpls(1,4)),chrval(Ndpls(1,5)),chrval(Ndpls(1,6)),chrval(Ndpls(1,7)),chrval(Ndpls(1,8))
(8A5)
*ELSEIF,Nntols,EQ,9
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2)),chrval(Ndpls(1,3)),chrval(Ndpls(1,4)),chrval(Ndpls(1,5)),chrval(Ndpls(1,6)),chrval(Ndpls(1,7)),chrval(Ndpls(1,8)),chrval(Ndpls(1,9))
(9A5)
*ELSEIF,Nntols,EQ,10
*VWRITE,chrval(Ndpls(1,1)),chrval(Ndpls(1,2)),chrval(Ndpls(1,3)),chrval(Ndpls(1,4)),chrval(Ndpls(1,5)),chrval(Ndpls(1,6)),chrval(Ndpls(1,7)),chrval(Ndpls(1,8)),chrval(Ndpls(1,9)),chrval(Ndpls(1,10))
(10A5)
*ELSE
*MSG,note
we are stopped......
*ENDIF
*VWRITE
('no print')          !列印方式
*VWRITE
('post')            !输出的讯息
*VWRITE,0,16,17,0,0,19,20,0,1,0,0
(11(f6.0,tl1),' ')   
*VWRITE
('end option')      !Model Definition Card 结束用语
*VWRITE
('$..............................................')       !分隔符
*VWRITE
('$============ Model Definition Card over===========')       !分隔符
*CFCLOSE
页: [1]
查看完整版本: ansys输入文件转到marc输入数据文件的APDL程序