!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"