ALGDPP.C
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:5k
- #include "stdio.h"
- #include "conio.h"
- #include "string.h"
- #define MAX 5000
- int start,end,nodenum;
- void save1();
- void save2();
- void main()
- {
- FILE *fp1,*fp2,*fp3;
- float ver[50];
- int t[14],i,j,m;
- int num_node[4];
- int node_number;
- int number=0;
- float val[MAX];
- char ch,ch1,ch2,s1[80],s2[80],s3[80],val_name[80];
- float nodex[MAX],nodey[MAX],nodez[MAX];
- int node2[MAX];
- int *p1;
- float *px,*py,*pz,*pnode;
- int *pnode2;
- px=nodex;py=nodey;pz=nodez;
- pnode=val;
- clrscr();
- printf("Please enter ele_node_data filename:(*.)");
- gets(s1);
- if((fp1=fopen(s1,"r"))==NULL){
- printf("nnaCannot open the file or file not find!n");
- exit(1);
- }
- printf("Please enter Stress_out_data filename:(*.out)");
- gets(s3);
- if((fp3=fopen(s3,"r"))==NULL){
- printf("nnaCannot open the file or file not find!n");
- exit(1);
- }
- if(strstr(s3,".out")==NULL)
- {
- printf("naStress output filename error!Please input again!(*.out)n");
- exit(0);
- }
- printf("Reading datas......n");
- for(i=0;i<=18;i++)
- fscanf(fp1,"%c",&ch);
- fscanf(fp1,"%f%d",&ver[0],&nodenum);
- printf("t****************************n");
- printf("tThe model have %d nodes...n",nodenum);
- printf("t****************************n");
- for(i=0;i<=13;i++)
- fscanf(fp1,"%d",&t[i]);
- fscanf(fp1,"%f",&ver[0]);
- for(i=0;i<=6;i++)
- fscanf(fp1,"%d",&t[i]);
- fscanf(fp1,"%f%f%f",&px[0],&py[0],&pz[0]);
- fscanf(fp1,"%d%f%d%d",&t[0],&ver[0],&t[1],&t[2]);
- for(j=1;j<=nodenum-1;j++)
- {
- for(i=0;i<=6;i++)
- fscanf(fp1,"%d",&t[i]);
- {
- fscanf(fp1,"%f%f%f",&px[j],&py[j],&pz[j]);
- fscanf(fp1,"%d%f",&t[0],&ver[0]);
- }
- }
- for(i=1;i<=64;i++)
- {
- fscanf(fp3,"%c",&ch);
- }
- fscanf(fp3,"%s",val_name);
- rewind(fp3);
- for(i=1;i<=111;i++)
- {
- fscanf(fp3,"%c",&ch);
- if(i>=100&&ch=='1'){break;}
- }
- printf("Screen or File output(S,F)?");
- scanf("%c",&ch);
- if(ch=='s'||ch=='S')
- {
- printf("Continual or Single node output(C,S)?");
- scanf("%s",&ch1);
- if(ch1=='C'||ch1=='c')
- {
- printf("nPlease input Start node:");
- scanf("%d",&start);
- printf("nPlease input End node:");
- scanf("%d",&end);
- pnode2=node2;
- for(j=1;j<=nodenum;j++)
- {
- fscanf(fp3,"%d",&num_node[3]);
- for(i=1;i<=6;i++)
- fscanf(fp3,"%c",&ch);
- fscanf(fp3,"%f",&pnode[j]);
- for(i=start;i<=end;i++)
- {
- if(i==num_node[3])
- {printf("NODEt X_COORt Y_COORt Z_COORt %s VALn",val_name);
- printf("%dt %12.6e %12.6e %12.6e %12.6en",i,px[j-1],py[j-1],pz[j-1],pnode[j]);
- }
- }
- }
- printf("Save above datas(Y,N)?");
- if(getchar()=='Y'||getchar()=='y')
- save1(px,py,pz,pnode,val_name);
- }
- if(ch1=='s'||ch1=='S')
- {
- printf("nPlease input NODE...(0 for END)n");
- for(i=0;;i++)
- {scanf("%d",&node2[i]);
- if(node2[i]==0){m=i;break;}
- }
- pnode2=node2;
- for(j=0;j<=nodenum-1;j++)
- {
- fscanf(fp3,"%d",&num_node[3]);
- for(i=1;i<=6;i++)
- fscanf(fp3,"%c",&ch);
- fscanf(fp3,"%f",&pnode[j]);
- for(i=0;i<m;i++)
- {
- if(pnode2[i]==num_node[3])
- {number++;
- printf("NODEt X_COORt Y_COORt Z_COORt %s VALn",val_name);
- printf("%dt %12.6e %12.6e %12.6e %12.6en",pnode2[i],px[j],py[j],pz[j],pnode[j]);
- }
- }
- }
- printf("Save above datas(Y,N)?");
- if(getchar()=='Y'||getchar()=='y')
- save2(number,pnode2,px,py,pz,pnode,val_name);
-
- }
- }
- if(ch=='f'||ch=='F')
- {printf("Please input savedata filename:");
- scanf("%s",s2);
- if((fp2=fopen(s2,"w"))==NULL){
- printf("tnCannot open the file!n");
- exit(1);
- }
- printf("nSaving datas......n");
- fprintf(fp2,"NODEt X_COORt Y_COORt Z_COORt %s VALn",val_name);
- for(j=0;j<=nodenum-1;j++)
- {
- fscanf(fp3,"%d",&num_node[3]);
- for(i=1;i<=6;i++)
- fscanf(fp3,"%c",&ch);
- fscanf(fp3,"%f",&pnode[j]);
- fprintf(fp2,"%dt",j+1);
- fprintf(fp2,"%12.6e %12.6e %12.6e %12.6en",px[j],py[j],pz[j],pnode[j]);
- }
- fprintf(fp2,"****************************n");
- for(i=0;i<=7;i++)
- fscanf(fp1,"%d",&t[i]);
- for(i=0;i<=33;i++)
- fscanf(fp1,"%f",&ver[i]);
- fprintf(fp2,"NUMtItJtKtLn");
- for(i=0;i<=t[1]-1;i++)
- {
- p1=num_node;
- fscanf(fp1,"%d",&t[4]);
- fprintf(fp2,"%dt",t[4]);
- for(j=0;j<=3;j++)
- {
- fscanf(fp1,"%d",&p1[j]);
- fprintf(fp2,"%dt",p1[j]);
- if(j==3)fprintf(fp2,"n");
- }
- fscanf(fp1,"%d%f%f%d%d%f",&t[2],&ver[0],&ver[1],&t[3],&t[4],&ver[2]);
- if(kbhit())if(getch()==27)break;
- }
- }
- printf("nntProgram is over!n");
- printf("t******************n");
- fclose(fp1);
- fclose(fp2);
- fclose(fp3);
- }
- /********************************************************/
- void save1(float px[],float py[],float pz[],float pnode[],char val_name[])
- {
- FILE *fp;
- int i;
- char s1[80];
- printf("Please input save filename:");
- scanf("%s",s1);
- if((fp=fopen(s1,"w"))==NULL){
- printf("aFile cannot open!n");
- exit(1);
- }
- fprintf(fp,"NODEt X_COORt Y_COORt Z_COORt %s VALn",val_name);
- for(i=start;i<=end;i++)
- {
- fprintf(fp,"%dt%12.6e %12.6e %12.6e %12.6en",i,px[i-1],py[i-1],pz[i-1],pnode[i]);
- if(i>nodenum-1)break;
- }
- fclose(fp);
- }
- /***********************************************************/
- void save2(int number,int pnode2[],float px[],float py[],float pz[],float pnode[],char val_name[])
- {
- FILE *fp;
- int i;
- char s1[80];
- printf("Please input save filename:");
- scanf("%s",s1);
- if((fp=fopen(s1,"w"))==NULL){
- printf("aFile cannot open!n");
- exit(1);
- }
- fprintf(fp,"NODEt X_COORt Y_COORt Z_COORt %s VALn",val_name);
- for(i=0;i<number;i++)
- {
- fprintf(fp,"%dt%12.6e %12.6e %12.6e %12.6en",pnode2[i],px[pnode2[i]-1],py[pnode2[i]-1],pz[pnode2[i]-1],pnode[pnode2[i]-1]);
- }
- fclose(fp);
- }