1 #include <stdlib.h>
2 
3 #define CGXFLOAT double
4 
5 #include <math.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <unistd.h>
9 #include <fcntl.h>
10 #include <ctype.h>
11 
12 #define     MAX_LINE_LENGTH 256
13 #define     MAX_INTEGER 2147483647
14 #define     MAX_FLOAT   1.e32
15 
16 
17 typedef struct {
18   char  model[MAX_LINE_LENGTH]; /* model-name header*/
19   char  threads;   /* nr of threads to be used */
20   char  **uheader; /* user header */
21   char  **pheader; /* project header (remark: leading dataset-project-headers are stored in the related dataset!) */
22   int   v;         /* number of values */
23   int   u;         /* number of user headers */
24   int   p;         /* number of project headers */
25   int   n;         /* number of nodes */
26   int   e;         /* number of elements  */
27   int   f;         /* number of faces */
28   int   g;         /* number of edges */
29   int   t;         /* number of texts */
30   int   sets;      /* sets (groups) of entities */
31   int   mats;      /* materials   */
32   int   amps;      /* amplitudes  */
33   int   l;         /* number of loadcases (Datasets) */
34   int   b;         /* number of nodeBlocks */
35   int   c;         /* number of 'cuts' over all nodeBlocks (block-to-block interfaces for isaac) */
36   int   etype[100];/* number of elements of a certain type */
37   int   nmax;      /* maximum nodenumber */
38   int   nmin;      /* minimum nodenumber */
39   int   emax;      /* maximum elemnumber */
40   int   emin;      /* minimum elemnumber */
41   int   orignmax;  /* max-node-nr-of-original-nodes (w/o nodes for drawing purposes) */
42   int   orign;     /* nr-of-original-nodes (w/o nodes for drawing purposes) */
43   int   olc;       /* nr-of-original-loadcases (w/o cgx generated datasets (lc)) */
44   int   nnext;     /* next node-nr, eventually defined with asgn */
45   int   enext;     /* next elem-nr, eventually defined with asgn */
46 } Summen;
47 
48 
49 typedef struct {
50   int   nr;              /*   external node-nr (node[node-indx].nr) */
51   int   indx;            /*   node-index (node[ext-node-nr].indx)   */
52   char  pflag;           /*   1 if used for display purposes    */
53                          /*  -1 if the node is deleted          */
54                          /*   0 default                         */
55   double nx;             /*   coordinates  node[ext-node-nr].nx */
56   double ny;
57   double nz;
58   double nv[3];          /* normal vector */
59 } Nodes;
60 
61 
62 typedef struct {
63   int nr;                /* external element-nr */
64   // int indx;              /* -index (elem[external elem-nr].indx)   */
65   int type;              /* element type (1:Hexa8)  */
66   int group;
67   int mat;
68   int attr;              /* -1: unstructured mesh tr3u (-2 for mesh with libGLu tr3g ) */
69                          /*  0: default           */
70                          /*  1: reduced integration he8r he20r */
71                          /*  2: incompatible modes he8i */
72                          /*  3: DASHPOTA be2d */
73                          /*  4: plane strain (CPE) tr3e tr6e qu4e qu8e */
74                          /*  5: plane stress (CPS) tr3s */
75                          /*  6: axisymmetric  (CAX) tr3c */
76                          /*  7: fluid he8f */
77                          /*  8: tet10m */
78                          /*  9: tet10t */
79                          /*  14: reduced integration, plane strain (CPE)  */
80                          /*  15: reduced integration, plane stress (CPS)  */
81                          /*  16: reduced integration, axisymmetric  (CAX) */
82   int nod[27];
83   double **side;         /* side[Nr.][x|y|z]== normal vector */
84 } Elements;
85 
86 
87 typedef struct {
88   char  **pheader;    /* project header */
89   int   npheader;              /* number of headers */
90   char  **compName;
91   char  **icname;
92   char  name[MAX_LINE_LENGTH];
93   char  dataset_name[MAX_LINE_LENGTH];
94   char  dataset_text[MAX_LINE_LENGTH];
95   char  analysis_name[MAX_LINE_LENGTH];
96   double value;
97   char  filename[MAX_LINE_LENGTH];
98   FILE *handle;
99   fpos_t *fileptr;
100   int   loaded;       /* if data are stored:1 else: 0 */
101   int format_flag;
102   int analysis_type;
103   int step_number;
104   int ncomps;         /* components of a result of an entity (node, gauspnt) */
105   int irtype;
106   int *menu;
107   int *ictype;
108   int *icind1;
109   int *icind2;
110   int *iexist;
111   double **dat;        /* node related data */
112   double ***edat;      /* element related data, not propper implemented */
113   double *max;         /* maximum datum */
114   double *min;         /* minimum datum */
115   int *nmax;          /* node with maximum datum */
116   int *nmin;          /* node with minimum datum */
117 } Datasets;
118 
119 int readfrd(char *datin, Summen *anz, Nodes **nptr, Elements **eptr, Datasets **lptr, int read_mode );
120 int readfrdblock( int lc, Summen *anz,   Nodes     *node, Datasets *lcase );
121 double stof(char *string, int a, int b);
122 int stoi(char *string, int a, int b);
123 void stos(char *string, int a, int b, char *puffer);
124 int strsplt( char *rec_str, char breakchar, char ***ptr);
125 int frecord( FILE *handle1,  char *string);
126 int compare (char *str1, char *str2, int length);
127 void freeDatasets(Datasets *lcase, int nr);
128