1 /*     CalculiX - A 3-dimensional finite element program                 */
2 /*              Copyright (C) 1998-2021 Guido Dhondt                          */
3 
4 /*     This program is free software; you can redistribute it and/or     */
5 /*     modify it under the terms of the GNU General Public License as    */
6 /*     published by the Free Software Foundation(version 2);    */
7 /*                                                                       */
8 
9 /*     This program is distributed in the hope that it will be useful,   */
10 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */
11 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
12 /*     GNU General Public License for more details.                      */
13 
14 /*     You should have received a copy of the GNU General Public License */
15 /*     along with this program; if not, write to the Free Software       */
16 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
17 
18 #include <stdlib.h>
19 #include <math.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include "CalculiX.h"
23 
frdheader(ITG * icounter,double * oner,double * time,double * pi,ITG * noddiam,double * cs,ITG * null,ITG * mode,ITG * noutloc,char * description,ITG * kode,ITG * nmethod,FILE * f1,char * output,ITG * istep,ITG * iinc)24 void frdheader(ITG *icounter,double *oner,double *time,double *pi,
25 	       ITG *noddiam,double *cs,ITG *null,ITG *mode,
26 	       ITG *noutloc,char *description,ITG *kode,ITG *nmethod,
27                FILE *f1, char *output,ITG *istep,ITG *iinc){
28 
29   char tmp[132],text[132];
30 
31   ITG i,ncomma;
32 
33   /* icounter counts the number of loadcases in the frd-file
34      kode counts the number of increments in the frd-file */
35 
36   strcpy1(&text[0],"    1PSTEP",10);
37   for(i=10;i<70;i++)text[i]=' ';text[70]='\0';
38   (*icounter)++;
39   sprintf(&text[24],"%12" ITGFORMAT "",*icounter);
40   sprintf(&text[36],"%12" ITGFORMAT "",*iinc);
41   sprintf(&text[48],"%12" ITGFORMAT "",*istep);text[60]=' ';
42   fprintf(f1,"%s\n",text);
43 
44   /* additional headers for frequency calculations */
45 
46   if((*nmethod==2)||(*nmethod==6)||(*nmethod==7)||(*nmethod==13)||
47      ((*nmethod==12)&&(*noddiam>-1))){
48     strcpy1(&text[0],"    1PGM",8);
49     for(i=8;i<70;i++)text[i]=' ';text[70]='\0';
50     sprintf(&text[24],"%12.6E",*oner);text[36]=' ';
51     fprintf(f1,"%s\n",text);
52 
53     strcpy1(&text[0],"    1PGK",8);
54     for(i=8;i<70;i++)text[i]=' ';text[70]='\0';
55     sprintf(&text[24],"%12.6E",(*time*2.**pi)*(*time*2.**pi));text[36]=' ';
56     fprintf(f1,"%s\n",text);
57 
58     strcpy1(&text[0],"    1PHID",9);
59     for(i=9;i<70;i++)text[i]=' ';text[70]='\0';
60     sprintf(&text[24],"%12" ITGFORMAT "",*noddiam);text[36]=' ';
61     fprintf(f1,"%s\n",text);
62 
63     /* additional headers for cyclic symmetry calculations */
64 
65     if((*noddiam>=0)&&(cs!=NULL)){
66       strcpy1(&text[0],"    1PAX",8);
67       for(i=8;i<24;i++)text[i]=' ';
68       sprintf(&text[24],"%12.5E",cs[5]);
69       sprintf(&text[36],"%12.5E",cs[6]);
70       sprintf(&text[48],"%12.5E",cs[7]);
71       sprintf(&text[60],"%12.5E",cs[8]);
72       sprintf(&text[72],"%12.5E",cs[9]);
73       sprintf(&text[84],"%12.5E",cs[10]);
74       fprintf(f1,"%s\n",text);
75     }
76 
77     strcpy1(&text[0],"    1PSUBC",10);
78     for(i=10;i<70;i++)text[i]=' ';text[70]='\0';
79     sprintf(&text[24],"%12" ITGFORMAT "",*null);text[36]=' ';
80     fprintf(f1,"%s\n",text);
81 
82     strcpy1(&text[0],"    1PMODE",10);
83     for(i=10;i<70;i++)text[i]=' ';text[70]='\0';
84     sprintf(&text[24],"%12" ITGFORMAT "",*mode+1);text[36]=' ';
85     fprintf(f1,"%s\n",text);
86   }
87 
88 #ifdef COMPANY
89   writeBasisParameter(f1,istep,iinc);
90 #endif
91 
92   /* 100CL line */
93 
94   for(i=0;i<75;i++)text[i]=' ';
95   if(abs(*nmethod)==1){
96     strcpy1(&text[0],"  100CL       .00000E+00                                 0    1",63);
97   }else if((*nmethod==2)||(*nmethod==13)){
98     strcpy1(&text[0],"  100CL       .00000E+00                                 2    1",63);
99   }else if(*nmethod==3){
100     strcpy1(&text[0],"  100CL       .00000E+00                                 4    1",63);
101   }else if((*nmethod==4)||(*nmethod==5)){
102     strcpy1(&text[0],"  100CL       .00000E+00                                 1    1",63);
103   }else{
104     strcpy1(&text[0],"  100CL       .00000E+00                                 3    1",63);
105   }
106 
107   sprintf(tmp,"%12" ITGFORMAT "",*noutloc);
108   strcpy1(&text[24],tmp,12);
109   strcpy1(&text[36],description,12);
110   if((*nmethod==2)||(*nmethod==13))strcpy1(&text[63],"MODAL",5);
111   if(strcmp1(output,"asc")==0){
112     strcpy1(&text[74],"1",1);
113   }else if(strcmp1(output,"bin")==0){
114     strcpy1(&text[74],"2",1);
115   }else{
116     strcpy1(&text[74],"3",1);
117   }
118   sprintf(tmp,"%5" ITGFORMAT "",100+(*kode));
119   strcpy1(&text[7],tmp,5);
120 //  sprintf(tmp,"%12.5E",*time);
121 
122 // change 21 Oct 2018  if((*time<=0.)||(*nmethod==2)){
123   if(*time<=0.){
124       sprintf(tmp,"%12.5E",*time);
125   }else if((log10(*time)>=0)&&(log10(*time)<10.)){
126       ncomma=10-floor(log10(*time)+1.);
127       if(ncomma==0){
128 	  sprintf(tmp,"%12.0f",*time);
129       }else if(ncomma==1){
130 	  sprintf(tmp,"%12.1f",*time);
131       }else if(ncomma==2){
132 	  sprintf(tmp,"%12.2f",*time);
133       }else if(ncomma==3){
134 	  sprintf(tmp,"%12.3f",*time);
135       }else if(ncomma==4){
136 	  sprintf(tmp,"%12.4f",*time);
137       }else if(ncomma==5){
138 	  sprintf(tmp,"%12.5f",*time);
139       }else if(ncomma==6){
140 	  sprintf(tmp,"%12.6f",*time);
141       }else if(ncomma==7){
142 	  sprintf(tmp,"%12.7f",*time);
143       }else if(ncomma==8){
144 	  sprintf(tmp,"%12.8f",*time);
145       }else{
146 	  sprintf(tmp,"%12.9f",*time);
147       }
148   }else{
149       sprintf(tmp,"%12.5E",*time);
150   }
151 
152   strcpy1(&text[12],tmp,12);
153   sprintf(tmp,"%5" ITGFORMAT "",*kode);
154   strcpy1(&text[58],tmp,5);
155   text[75]='\0';
156   fprintf(f1,"%s\n",text);
157 
158 }
159