!ANSYS命令流
! 写单元及节点数据文件
! 作者:陆新征,清华大学土木系
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!选中所有单元
ALLSEL,ALL
! 得到当前模型中的总节点数
*GET,NNode,NODE,,COUNT, , , ,
!输出节点
*CFOPEN,Node,txt
*VWRITE
('coordinates')
*VWRITE,chrval(3),chrval(NNode),chrval(0),chrval(1)
(4A5)
*DO,I,1,NNode
*VWRITE,I,NX(I),NY(I),NZ(I)
(F8.0,3F13.5)
*ENDDO
*CFCLOS

!打开单元文件
*CFOPEN,ELEM,txt
!得到所有单元数
ESEL,S,ENAME,,65
ALLSEL,ALL
*GET,NElem,ELEM,,COUNT, , , ,
*VWRITE,chrval(NElem)
('Number of Element: ', A8)
!对单元集进行循环
*DO,I,1,NElem
!得到当前单元的类型
*GET,ENAME,ELEM,I,ATTR,ENAM
!如果是65号(65号单元)
*IF,ENAME,EQ,65,THEN
!得到该单元的节点编号
*GET,EN1,ELEM,I,NODE,1
*GET,EN2,ELEM,I,NODE,2
*GET,EN3,ELEM,I,NODE,3
*GET,EN4,ELEM,I,NODE,4
*GET,EN5,ELEM,I,NODE,5
*GET,EN6,ELEM,I,NODE,6
*GET,EN7,ELEM,I,NODE,7
*GET,EN8,ELEM,I,NODE,8
*VWRITE,I,EN1,EN2,EN3,EN4,EN5,EN6,EN7,EN8
(F8.0,8F8.0)
*END IF
*ENDDO
*CFCLOS

!Fortran程序,把ansys结果转换为MARC模型文件格式
program main
implicit none;
integer Key;
write(*,*) "Input 1 for node, 2 for element"
read(*,*) Key
if (Key==1) then
call Node_IO()
end if
if (Key==2) then
call Elem_IO()
end if
stop
end program

subroutine Node_IO()
implicit none
integer NNode,I, J
real*8,pointer :: Node(:,:)
real*8 x;
character :: filename*10;
write(*,*) "Please input node filename"
read(*,'(A10)') filename
open(66,file=filename)
read(66,*) NNode
allocate (Node(NNode,3))
do I=1,NNode
read(66,*) x, (Node(I,J), J=1,3)
end do
close (66)
filename=filename//"NEW"
open (66,file=filename)
write(66,'(4I10)') 3, NNode, 0, 1
do I=1, NNode
write(66,'(I10, 3E20.8)') I, (Node(I,J), J=1,3)
end do
close (66)
return
end subroutine Node_IO

subroutine Elem_IO()
implicit none
integer NElem,NumNode,ElemTyp,I, J
integer,pointer :: Elem(:,:)
real*8 x;
real*8,pointer :: y(:)
character :: filename*10, outformat*11,CharEtype;
write(*,*) "Please input node filename"
read(*,'(A10)') filename
write(*,*) "Please input Element type & Number of Nodes per element"
read(*,*) ElemTyp, NumNode
open(66,file=filename)
read(66,*) NElem
allocate (Elem(NElem, NumNode))
allocate (y(NumNode))
do I=1, NElem
read(66,*) x, (y(j),j=1,NumNode)
do J=1, NumNode
Elem(I,J)=int(y(j))
end do
end do
close (66)
filename=filename//"NEW"
write(CharEtype,'(I1)') NumNode
write(outformat,'(A6,A,A4)') "(2I10,", CharEtype, "I10)"
open (66,file=filename)
write(66,'(3I10)') 0, 0, 1
do I=1, NElem
write(66,outformat) I, ElemTyp, (Elem(I,J), J=1,ElemTyp)
end do
close (66)
return
end subroutine Elem_IO

个人信息
研究工作
实际工程
论文工作
教学工作
资料下载
专题
其他

 

 

我们的实验室

抗倒塌专业委员会