PROGRAM p41
!---------------------------------------------
!program 4.1 one dimensional analysis of axially loaded elastic rods
! using 2-node rod elements
!---------------------------------------------
use main; use geom;
implicit none
integer,parameter::iwp=selected_real_kind(15)
integer::fixed_freedoms,i,iel,k,loaded_nodes,ndof=2,nels,neq,nlen,nod=2,&
nodof=1,nn,nprops=1,np_types,nr
real(iwp)::penalty=1.0e20_iwp,zero=0.0iwp;character(len=15)::argv
!----------------dynamic arrays---------------
integer,allocatable::etype(:),g(:),g_g(:,:),kdiag(:),nf(:,:),no(:), &
node(:),num(:)
real(iwp),allocatable::action(:),eld(:),ell(:),km(:,:),kv(:),loads(:), &
prop(:,:),value(:)
!----------------input and initialisation---------------
call getname(argv,nlen)
open(10,file=argv(1:nlen)//'.dat'); open(11,file=argv(1:nlen)//'.res')
read(10,*)nels,np_types;nn=nels+1
allocate(g(ndof),num(nod),nf(nodof,nn),etype(nels),ell(nels),eld(ndof), &
km(ndof,ndof),action(ndof),g_g(ndof,nels),prop(nprops,np_types))
read(10,*)prop; etype=1;if(np_types>1)read(10,*)etype; read(10,*)ell
nf=1; read(10,*)nr,(k,nf(:,k),i=1,nr); call formnf(nf); neq=maxval(nf)
allocate(kdiag(neq),loads(0:neq)); kdiag=0
!----------------loop the elements to find global arrays sizes---------------
elements_1: do iel=1,nels
num=(/iel,iel+1/); call num_to_g(num,nf,g);g_g(:,iel)=g
call fkdiag(kdiag,g)
end do elements_1
do i=2,neq; kdiag(i)=kdiag(i)+kdiag(i-1); end do; allocate(kv(kdiag(neq)))
write(11,'(2(a,i5))')
"There are" ,neq," equations and the skyline storage is",kdiag(neq)
!----------------global stiffness matrix assembly---------------
kv=zero
elements_2:do iel=1,nels
call rod_km(km,prop(1,etype(iel)),ell(iel); g=g_g(:,iel)
call fsparv(kv,km,g,kdiag)
end do elements_2
!----------------read loads and/or displacements---------------
loads=zero; read(10,*) loaded_nodes,(k,loads(nf(:,k)),i=1,loads_nodes)
read(10,*)fixed_freedoms
if(fixed_freedoms/=0)then
allocate(node(fixed_freedoms),no(fixed_freedoms),value(fixed_freedoms))
read(10,*)(node(i),value(i),i=1,fixed_freedoms)
do i=1,fixed_freedoms; no(i)=nf(1,node(i));end do
kv(kdiag(no))=kv(kdiag(no))+penalty; loads(no)=kv(kdiag(no))*value
end if
!----------------equation solution---------------
call sparin(kv,kdiag);call spabac(kv,loads,kdiag);loads(0)=zero
write(11,'(/a)')" node disp"
do k=1,nn; write(11,'(i5,2e12.4)')k,loads(nf(:,k));end do
!----------------retrieve elements end actions---------------
write(11,'(/a)')"element actions "
elements_3: do iel=1,nels
call rod_km(km,prop(1,etype(iel)),ell(iel));g=g_g(:,iel)
eld=loads(g); action=matmul(km,eld);write(11,'(i5,2e12.4)')iel,action
end do elements_3
stop
end program p41
2.75 KB, 下载次数: 1
fcode 发表于 2021-11-17 08:19
这个程序不完整,需要找到 main 和 geom 这两个模块。
注意看 use main; use geom; 这俩语句。 ...
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |