资源描述:
《平面桁架静力分析有限元程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、有限单元法平面桁架静力分析有限元程序#defineNODE.NUM300#defineELE_NUM200#include#include#includeintnj,ne,nm,nz,npjJm[ELE_NUM][3],nzc[60],nj2,bw;floatxylNODE_NUMJ[4],EA[5J,plNODE_NUMJ,pj,FlELE_NUMJ;floatek⑸⑸;double**K,*f;intBAND2(intn,intm,double**K,double*f);double**
2、TwoArrayAlloc(int,int);voidTwoArrayFree(double**);FILE*outfile;/**/double**TwoArrayAlloc(intrjntc){double*x,**y;intn;x=(double*)calloc(r*c,sizeof(double));y=(double**)calloc(r,sizeof(double*));for(n=0;n<=r-l;++n)y[n]=&x[c*n];return(y);}/**/voidTwoArrayFree(double**x)free(x[0
3、]);free(x);/**/intBAND2(intn,intm,double**K,double*f)/*解方程函数*/{intdoubles,w;ml=m+l;fbr(i=l;i<=n;i++){if(KLi-l]Lml-lJ<=0)return(O);w=0.0;if(i>ml)tm=i-m;elsetm=l;for(j=tm;j<=i;j++){s=0.0;ij=j-i+ml;for(t=tm;t<=j-l;t++){it=t-i+ml;jt=t-j+ml;}ifO==i)f[i-l]=f[i-l]-w;else}1for(i=n;i
4、>=l;i-){s=0.0;if(i>ml)tm=n;elsetm二i+m;for(j=i+];j<=tm;j++){ji=i-j+ml;s=s+K[j・lHji・l萨}f[i-l]=(f[i-l]-s)/K[i-l][ml-l];}return1;}/**/voidinput()/*输入函数*/intjjj,i,nh,nl;floatdx,dy;FILE*infile;infile=fopen(,,dat.txt,,;,rH);outfile=fopen("out.txt',,"wH);fscanf(infile,M%d%d%d%d%du,&
5、nj,&ne,&nm,&nz,&npj);/*读入控制数据*/fprintf(outfile,"TheNum.OfNodes:%3d",nj);/*输出节点数*/fprintf(outfile,MTheNum.OfMem.:%3d",ne);/*输出单元数*/fprintf(outfile,MTheNum.OfTypeOfSectionCharacteristic:%3d*',nm);/*输出材料类型数*/fprintf(outfile,HTheNum.OfRestriction:%3d",nz);/*输岀荷载数*/fprint
6、f(outfile,nTheNum.OfNodalLoads:%3d",npj);/*输出荷载数*/for(i=l;i<=nj;i++){for(j=l;jv3;j++)fscan^infile/^f^&xyriirj]);/*读入节点坐标*/Ifprintf(outfile,"CoordinatesxandyOfNodes:H);fprintf(outfile,MNodexy");for(i=l;i<=nj;i++){fprintf(outfile;,%10d%10.2f%10.2f°,i,xy[i][l],xy[i][2])
7、;/*输出节点坐标*/}for(i=l;i<=ne;i++){for(j=0;j<3;j++)fscanf(infile,"%d",&jm[i][j]);/*读入单元信息(材料类型、单元左右节点码)*/}fprintf(outfile,nTheNodesNum.OfMem.:M);fprintf(outfile,"Mem.TypeLeftRight");for(i=l;i<=ne;i++){fprintf(outfile,u%10d%10d%10d%10dn,i,jm[i][0],jm[i][l]jm[i][2]);/*输出单元信息
8、*/}for(i=1;i<=nm;i++)fscanf(infile,H%f&EA[i]);/*读入材料刚度*/for(i=l;i<=nm;i++)