1 /*     CalculiX - A 3-dimensional finite element program                 */
2 /*              Copyright (C) 1998 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 <unistd.h>
23 #include <fcntl.h>
24 #include <ctype.h>
25 
26 #include "CalculiX.h"
27 #include "readfrd.h"
28 
utempread(double * t1,ITG * istep,char * jobnamec)29 void utempread (double *t1,ITG *istep,char *jobnamec)
30 {
31 
32     char  datin[MAX_LINE_LENGTH],text[13]="            ";
33     Summen    anz[1];
34     Nodes     *node=NULL;
35     Elements  *elem=NULL;
36     Datasets *lcase=NULL;
37 
38     ITG i,j,read_mode=0,loadcase,istep_global,nodenr;
39 
40     /* reading the global coordinates and the topology from file
41        (if any, else return) */
42 
43     if(strcmp1(&jobnamec[660]," ")==0)return;
44     strcpy1(datin,&jobnamec[660],132);
45     for(i=0;i<MAX_LINE_LENGTH;i++){
46 	if(strcmp1(&datin[i]," ")==0){
47 	    datin[i]='\0';
48 	    break;
49 	}
50     }
51 
52     /* initialization of the size of fields used in readfrd.c */
53 
54     anz->orign=0;
55     anz->n=0;
56     anz->e=0;
57     anz->f=0;
58     anz->g=0;
59     anz->t=0;
60     anz->l=0;
61     anz->olc=0;
62     anz->orignmax=0;
63     anz->nmax=0;
64     anz->nmin=MAX_INTEGER;
65     anz->emax=0;
66     anz->emin=MAX_INTEGER;
67     anz->sets=0;
68     anz->mats=0;
69     anz->amps=0;
70     anz->nnext=0;
71     anz->enext=0;
72 
73     readfrd( datin, anz, &node, &elem, &lcase, read_mode);
74 
75     /* check for the existence of nodes and/or elements */
76 
77     if((anz[0].n==0)||(anz[0].e==0)){
78 	printf(" *ERROR in utempread: there are either no nodes or\n no elements or neither nodes nor elements in the temperature frd-file\n");
79 	FORTRAN(stop,());
80     }
81 
82     /* loading the step data : NDTEMP (1 variable) if present */
83 
84     /* reading the temperatures */
85     /* 1. determining the appropriate temperature loadcase in the step */
86 
87     loadcase=-1;
88     for(i=0;i<anz[0].l;i++){
89 	for(j=0;j<lcase[i].npheader;j++){
90 	    if(strcmp1(&lcase[i].pheader[j][5],"PSTEP")==0){
91 		strcpy1(text,&lcase[i].pheader[j][48],12);
92 		istep_global=atoi(text);
93 		break;
94 	    }
95 	}
96 	if((istep_global==*istep)&&
97 	   (strcmp1(lcase[i].name,"NDTEMP")==0)){
98 	    loadcase=i;
99 	}else if(istep_global>*istep){
100 	    break;
101 	}
102     }
103 
104     /* 2. reading the data */
105 
106     if(loadcase>-1){
107 	if(!read_mode && readfrdblock(loadcase, anz, node, lcase )==-1)
108 	{
109 	    printf("ERROR in utempread: Could not read data for Dataset:%" ITGFORMAT "\n", i+1);
110 	    FORTRAN(stop,());
111 	}
112 
113     /* 3. storing the data */
114 
115 	for(i=0;i<anz[0].n;i++){
116 	    nodenr=node[i].nr;
117 	    t1[nodenr-1]=lcase[loadcase].dat[0][nodenr];
118 	}
119     }else{
120 	printf("INFO in utempread: no temperature data\n was found for step %d in the temperature frd-file\n\n",*istep);
121     }
122 
123     for(j=0;j<anz->l;j++){
124       freeDatasets(lcase,j);
125     }
126     SFREE(lcase);lcase=NULL;
127 
128     return;
129 
130 }
131