CalculiX  2.8
A Free Software Three-Dimensional Structural Finite Element Program
 All Classes Files Functions Variables Macros
readinput.c File Reference
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "CalculiX.h"
Include dependency graph for readinput.c:

Go to the source code of this file.

Functions

void readinput (char *jobnamec, char **inpcp, ITG *nline, ITG *nset, ITG *ipoinp, ITG **inpp, ITG **ipoinpcp, ITG *ithermal)
 

Function Documentation

void readinput ( char *  jobnamec,
char **  inpcp,
ITG nline,
ITG nset,
ITG ipoinp,
ITG **  inpp,
ITG **  ipoinpcp,
ITG ithermal 
)

Definition at line 25 of file readinput.c.

26  {
27 
28  /* reads and stores the input deck in inpcp; determines the
29  number of sets */
30 
31  FILE *f1[10];
32 
33  char buff[1320]="", fninp[132]="", includefn[132]="", *inpc=NULL,
34  textpart[2112]="",*set=NULL;
35 
36  ITG i,j,k,n,in=0,nlinemax=100000,irestartread,irestartstep,
37  icntrl,nload,nforc,nboun,nk,ne,nmpc,nalset,nmat,ntmat,npmat,
38  norien,nam,nprint,mi[3],ntrans,ncs,namtot,ncmat,memmpc,ne1d,
39  ne2d,nflow,*meminset=NULL,*rmeminset=NULL, *inp=NULL,ntie,
40  nener,nstate,nentries=15,ifreeinp,ikey,lincludefn,nslavs,
41  nbody,ncharmax=1000000,*ipoinpc=NULL,ichangefriction=0,nkon,
42  ifile,mcs,initialtemperature=0,nprop,mortar,ifacecount,
43  nintpoint,infree[4],iheading=0;
44 
45  /* initialization */
46 
47  /* nentries is the number of different keyword cards for which
48  the input deck order is important, cf keystart.f */
49 
50  NNEW(inpc,char,ncharmax);
51  NNEW(ipoinpc,ITG,nlinemax+1);
52  NNEW(inp,ITG,3*nlinemax);
53  *nline=0;
54  for(i=0;i<2*nentries;i++){ipoinp[i]=0;}
55  ifreeinp=1;
56  ikey=0;
57 
58  /* opening the input file */
59 
60  strcpy(fninp,jobnamec);
61  strcat(fninp,".inp");
62  if((f1[in]=fopen(fninp,"r"))==NULL){
63  printf("*ERROR in read: cannot open file %s\n",fninp);
64  exit(0);
65  }
66 
67  /* starting to read the input file */
68 
69  do{
70  if(fgets(buff,1320,f1[in])==NULL){
71  fclose(f1[in]);
72  if(in!=0){
73  in--;
74  continue;
75  }
76  else{break;}
77  }
78 
79  /* check for heading lines: should not be changed */
80 
81  if(iheading==1){
82  if((buff[0]=='*')&&(buff[1]!='*')){
83  iheading=0;
84  }
85  }
86 
87  /* storing the significant characters */
88  /* get rid of blanks */
89 
90  k=0;
91  i=-1;
92  if(iheading==0){
93  do{
94  i++;
95  if((buff[i]=='\0')||(buff[i]=='\n')||(buff[i]=='\r')||(k==1320)) break;
96  if((buff[i]==' ')||(buff[i]=='\t')) continue;
97  buff[k]=buff[i];
98  k++;
99  }while(1);
100  }else{
101  do{
102  i++;
103  if((buff[i]=='\0')||(buff[i]=='\n')||(buff[i]=='\r')||(k==1320)) break;
104  buff[k]=buff[i];
105  k++;
106  }while(1);
107  }
108 
109  /* check for blank lines and comments */
110 
111  if(k==0) continue;
112  if(strcmp1(&buff[0],"**")==0) continue;
113 
114  /* changing to uppercase except filenames */
115 
116  if(iheading==0){
117  j=0;
118  ifile=0;
119  do{
120  if(j>=6){
121  if(strcmp1(&buff[j-6],"INPUT=")==0) ifile=1;
122  }
123  if(j>=7){
124  if(strcmp1(&buff[j-7],"OUTPUT=")==0) ifile=1;
125  }
126  if(j>=9){
127  if(strcmp1(&buff[j-9],"FILENAME=")==0) ifile=1;
128  }
129  if(ifile==1){
130  do{
131  if(strcmp1(&buff[j],",")!=0){
132  j++;
133  }else{
134  ifile=0;
135  break;
136  }
137  }while(j<k);
138  }else{
139  buff[j]=toupper(buff[j]);
140  }
141  j++;
142  }while(j<k);
143  }
144 
145  /* check for a *HEADING card */
146 
147  if(strcmp1(&buff[0],"*HEADING")==0){
148  iheading=1;
149  }
150 
151  /* check for include statements */
152 
153  if(strcmp1(&buff[0],"*INCLUDE")==0){
154  lincludefn=k;
155  FORTRAN(includefilename,(buff,includefn,&lincludefn));
156  includefn[lincludefn]='\0';
157  in++;
158  if(in>9){
159  printf("*ERROR in read: include statements can \n not be cascaded over more than 9 levels\n");
160  }
161  if((f1[in]=fopen(includefn,"r"))==NULL){
162  printf("*ERROR in read: cannot open file %s\n",includefn);
163  exit(0);
164  }
165  continue;
166  }
167 
168  /* adding a line */
169 
170  (*nline)++;
171  if(*nline>nlinemax){
172  nlinemax=(ITG)(1.1*nlinemax);
173  RENEW(ipoinpc,ITG,nlinemax+1);
174  RENEW(inp,ITG,3*nlinemax);
175  }
176 
177  /* checking the total number of characters */
178 
179  if(ipoinpc[*nline-1]+k>ncharmax){
180  ncharmax=(ITG)(1.1*ncharmax);
181  RENEW(inpc,char,ncharmax);
182  }
183 
184  /* copying into inpc */
185 
186  for(j=0;j<k;j++){
187  inpc[ipoinpc[*nline-1]+j]=buff[j];
188  }
189  ipoinpc[*nline]=ipoinpc[*nline-1]+k;
190 
191  /* counting sets */
192 
193  if(strcmp1(&buff[0],"*RESTART")==0){
194  irestartread=0;
195  irestartstep=0;
196  strcpy1(&buff[k]," ",1);
197  FORTRAN(splitline,(buff,textpart,&n));
198  for(i=0;i<n;i++){
199  if(strcmp1(&textpart[(long long)132*i],"READ")==0){
200  irestartread=1;
201 // if(irestartstep==0) irestartstep=1;
202  }
203  if(strcmp1(&textpart[(long long)132*i],"STEP")==0){
204  irestartstep=atoi(&textpart[(long long)132*i+5]);
205  }
206  }
207  if(irestartread==1){
208  icntrl=0;
209  FORTRAN(restartshort,(nset,&nload,&nbody,&nforc,&nboun,&nk,
210  &ne,&nmpc,&nalset,&nmat,&ntmat,&npmat,&norien,&nam,
211  &nprint,mi,&ntrans,&ncs,&namtot,&ncmat,&memmpc,
212  &ne1d,&ne2d,&nflow,set,meminset,rmeminset,jobnamec,
213  &irestartstep,&icntrl,ithermal,&nener,&nstate,&ntie,
214  &nslavs,&nkon,&mcs,&nprop,&mortar,&ifacecount,&nintpoint,
215  infree));
216  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"RESTART,READ",
217  nline,&ikey));
218  }
219  else{
220  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"REST",
221  nline,&ikey));
222  }
223 
224  }
225  else if((strcmp1(&buff[0],"*NODE")==0)&&
226  (strcmp1(&buff[0],"*NODEPRINT")!=0)&&
227  (strcmp1(&buff[0],"*NODEOUTPUT")!=0)&&
228  (strcmp1(&buff[0],"*NODEFILE")!=0)){
229  (*nset)++;
230  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"NODE",
231  nline,&ikey));
232  }
233  else if((strcmp1(&buff[0],"*ELEMENT")==0)&&
234  (strcmp1(&buff[0],"*ELEMENTOUTPUT")!=0)){
235  (*nset)++;
236  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"ELEMENT",
237  nline,&ikey));
238  }
239  else if(strcmp1(&buff[0],"*NSET")==0){
240  (*nset)++;
241  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"NSET",
242  nline,&ikey));
243  }
244  else if(strcmp1(&buff[0],"*ELSET")==0){
245  (*nset)++;
246  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"ELSET",
247  nline,&ikey));
248  }
249  else if(strcmp1(&buff[0],"*TRANSFORM")==0){
250  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"TRANSFORM",
251  nline,&ikey));
252  }
253  else if(strcmp1(&buff[0],"*MATERIAL")==0){
254  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
255  nline,&ikey));
256  }
257  else if(strcmp1(&buff[0],"*CREEP")==0){
258  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
259  nline,&ikey));
260  }
261  else if(strcmp1(&buff[0],"*CYCLICHARDENING")==0){
262  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
263  nline,&ikey));
264  }
265  else if(strcmp1(&buff[0],"*DEFORMATIONPLASTICITY")==0){
266  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
267  nline,&ikey));
268  }
269  else if(strcmp1(&buff[0],"*DENSITY")==0){
270  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
271  nline,&ikey));
272  }
273  else if(strcmp1(&buff[0],"*DEPVAR")==0){
274  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
275  nline,&ikey));
276  }
277  else if(strcmp1(&buff[0],"*ELASTIC")==0){
278  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
279  nline,&ikey));
280  }
281  else if(strcmp1(&buff[0],"*EXPANSION")==0){
282  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
283  nline,&ikey));
284  }
285  else if(strcmp1(&buff[0],"*FLUIDCONSTANTS")==0){
286  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
287  nline,&ikey));
288  }
289  else if(strcmp1(&buff[0],"*HYPERELASTIC")==0){
290  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
291  nline,&ikey));
292  }
293  else if(strcmp1(&buff[0],"*HYPERFOAM")==0){
294  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
295  nline,&ikey));
296  }
297  else if(strcmp1(&buff[0],"*PLASTIC")==0){
298  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
299  nline,&ikey));
300  }
301  else if(strcmp1(&buff[0],"*USERMATERIAL")==0){
302  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
303  nline,&ikey));
304  }
305  else if(strcmp1(&buff[0],"*CONDUCTIVITY")==0){
306  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
307  nline,&ikey));
308  }
309  else if(strcmp1(&buff[0],"*SPECIFICGASCONSTANT")==0){
310  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
311  nline,&ikey));
312  }
313  else if(strcmp1(&buff[0],"*SPECIFICHEAT")==0){
314  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
315  nline,&ikey));
316  }
317  else if(strcmp1(&buff[0],"*MAGNETICPERMEABILITY")==0){
318  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
319  nline,&ikey));
320  }
321  else if(strcmp1(&buff[0],"*ELECTRICALCONDUCTIVITY")==0){
322  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"MATERIAL",
323  nline,&ikey));
324  }
325  else if(strcmp1(&buff[0],"*ORIENTATION")==0){
326  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"ORIENTATION",
327  nline,&ikey));
328  }
329  else if(strcmp1(&buff[0],"*SURFACE")==0){
330  (*nset)++;
331  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"SURFACE",
332  nline,&ikey));
333  }
334  else if(strcmp1(&buff[0],"*TIE")==0){
335  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"TIE",
336  nline,&ikey));
337  }
338  else if(strcmp1(&buff[0],"*SURFACEINTERACTION")==0){
339  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"SURFACEINTERACTION",
340  nline,&ikey));
341  }
342  else if(strcmp1(&buff[0],"*SURFACEBEHAVIOR")==0){
343  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"SURFACEINTERACTION",
344  nline,&ikey));
345  }
346  else if(strcmp1(&buff[0],"*GAPCONDUCTANCE")==0){
347  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"SURFACEINTERACTION",
348  nline,&ikey));
349  }
350  else if((strcmp1(&buff[0],"*FRICTION")==0)&&(ichangefriction==0)){
351  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"SURFACEINTERACTION",
352  nline,&ikey));
353  }
354  else if(strcmp1(&buff[0],"*CONTACTDAMPING")==0){
355  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"SURFACEINTERACTION",
356  nline,&ikey));
357  }
358  else if(strcmp1(&buff[0],"*INITIALCONDITIONS")==0){
359  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"INITIALCONDITIONS",
360  nline,&ikey));
361  FORTRAN(splitline,(buff,textpart,&n));
362  for(i=0;i<n;i++){
363  if(strcmp1(&textpart[(long long)132*i],"TYPE=TEMPERATURE")==0){
364 // if(ithermal[1]==0) ithermal[1]=1;
365  initialtemperature=1;
366  }
367  }
368  }
369  else if(strcmp1(&buff[0],"*AMPLITUDE")==0){
370  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"AMPLITUDE",
371  nline,&ikey));
372  }
373  else if(strcmp1(&buff[0],"*CONTACTPAIR")==0){
374  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"CONTACTPAIR",
375  nline,&ikey));
376  }
377  else if(strcmp1(&buff[0],"*CHANGEFRICTION")==0){
378  ichangefriction=1;
379  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"REST",
380  nline,&ikey));
381  }
382  else if(strcmp1(&buff[0],"*SUBMODEL")==0){
383  (*nset)+=2;
384  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"REST",
385  nline,&ikey));
386  }
387  else if(strcmp1(&buff[0],"*")==0){
388  FORTRAN(keystart,(&ifreeinp,ipoinp,inp,"REST",
389  nline,&ikey));
390 
391  /* checking whether the calculation is mechanical,
392  thermal or thermomechanical: needed to know
393  which mpc's to apply to 2-D elements */
394 
395  if((strcmp1(&buff[0],"*STATIC")==0)||
396  (strcmp1(&buff[0],"*VISCO")==0)||
397  (strcmp1(&buff[0],"*DYNAMIC")==0)){
398  if(ithermal[1]==0){
399  if(initialtemperature==1)ithermal[1]=1;
400  }else if(ithermal[1]==2){
401  ithermal[1]=3;
402  }
403  }else if(strcmp1(&buff[0],"*HEATTRANSFER")==0){
404  if(ithermal[1]<2) ithermal[1]=ithermal[1]+2;
405  }else if(strcmp1(&buff[0],"*COUPLEDTEMPERATURE-DISPLACEMENT")==0){
406  ithermal[1]=3;
407  }else if(strcmp1(&buff[0],"*UNCOUPLEDTEMPERATURE-DISPLACEMENT")==0){
408  ithermal[1]=3;
409  }
410  }
411  }while(1);
412 
413  inp[3*ipoinp[2*ikey-1]-2]=*nline;
414  RENEW(inpc,char,(long long)132**nline);
415  RENEW(inp,ITG,3*ipoinp[2*ikey-1]);
416  *inpcp=inpc;
417  *ipoinpcp=ipoinpc;
418  *inpp=inp;
419 
420  // FORTRAN(writeinput,(inpc,ipoinp,inp,nline,&ipoinp[2*ikey-1],ipoinpc));
421 
422  return;
423 
424 }
void FORTRAN(addimdnodecload,(ITG *nodeforc, ITG *i, ITG *imdnode, ITG *nmdnode, double *xforc, ITG *ikmpc, ITG *ilmpc, ITG *ipompc, ITG *nodempc, ITG *nmpc, ITG *imddof, ITG *nmddof, ITG *nactdof, ITG *mi, ITG *imdmpc, ITG *nmdmpc, ITG *imdboun, ITG *nmdboun, ITG *ikboun, ITG *nboun, ITG *ilboun, ITG *ithermal))
ITG strcpy1(char *s1, const char *s2, ITG length)
Definition: strcpy1.c:24
ITG strcmp1(const char *s1, const char *s2)
Definition: strcmp1.c:24
subroutine restartshort(nset, nload, nbody, nforc, nboun, nk, ne, nmpc, nalset, nmat, ntmat, npmat, norien, nam, nprint, mi, ntrans, ncs, namtot, ncmat, memmpc, ne1d, ne2d, nflow, set, meminset, rmeminset, jobnamec, irestartstep, icntrl, ithermal, nener, nstate_, ntie, nslavs, nkon, mcs, nprop, mortar, ifacecount, nintpoint, infree)
Definition: restartshort.f:19
#define RENEW(a, b, c)
Definition: CalculiX.h:40
#define ITG
Definition: CalculiX.h:51
subroutine keystart(ifreeinp, ipoinp, inp, name, iline, ikey)
Definition: keystart.f:19
#define NNEW(a, b, c)
Definition: CalculiX.h:39
subroutine includefilename(text, includefn, lincludefn)
Definition: includefilename.f:19
Hosted by OpenAircraft.com, (Michigan UAV, LLC)