File: m3.c

package info (click to toggle)
z88 13.0.0%2Bdfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 107,800 kB
  • ctags: 3,296
  • sloc: ansic: 45,530; sh: 71; makefile: 14
file content (386 lines) | stat: -rw-r--r-- 11,089 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/***********************************************************************
* 
*               *****   ***    ***
*                  *   *   *  *   *
*                 *     ***    ***
*                *     *   *  *   *
*               *****   ***    ***
*
* A FREE Finite Elements Analysis Program in ANSI C for the UNIX OS.
*
* Composed and edited and copyright by 
* Professor Dr.-Ing. Frank Rieg, University of Bayreuth, Germany
*
* eMail: 
* frank.rieg@uni-bayreuth.de
* dr.frank.rieg@t-online.de
* 
* V12.0  February 14, 2005
*
* Z88 should compile and run under any UNIX OS and Motif 2.0.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING.  If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
***********************************************************************/ 
/***********************************************************************
* Compiler-Unit m3.c enthaelt:
*        sest88.for : stab in der ebene
*        ssta88.for : stab im raum
*        swel88.for : welle im raum
*        sbal88.for : balken im raum
*        seba88.for : ebener balken
* Diese Compiler-Unit enthaelt Programmteile, die gedanklich an FORTRAN-
* Quellen von H.R. Schwarz, ETH Zuerich, Schweiz, angelehnt sind.
*
* 18.1.2008 Rieg
***********************************************************************/

/***********************************************************************
* Fuer UNIX
***********************************************************************/
#ifdef FR_UNIX
#include <z88d.h>
#include <stdio.h>    /* FILE,fprintf */
#endif

/***********************************************************************
* Fuer Windows 95
***********************************************************************/
#ifdef FR_WIN95
#include <z88d.h>
#include <stdio.h>    /* FILE,fprintf */
#endif

/***********************************************************************
* Formate
***********************************************************************/
#define NL "\n"

#ifdef FR_XINT
#define P5D "%5d"
#endif

#ifdef FR_XLONG
#define P5D "%5ld"
#endif

#ifdef FR_XLOLO
#define P5D "%5lld"
#endif

#ifdef FR_XDOUB
#define P11E "%+#11.3lE"
#define P11EB "%+#11.3lE "
#endif

#ifdef FR_XQUAD
#define P11E "%+#11.3LE"
#define P11EB "%+#11.3LE "
#endif

/***********************************************************************
*  hier beginnt Function sest88
***********************************************************************/
int sest88(FR_INT4 k)
{
extern FILE *fo3;

extern FR_DOUBLEAY gmw;

extern FR_DOUBLE ul[];
extern FR_DOUBLE xk[],yk[];

extern FR_DOUBLE emode;

extern FR_INT4 LANG,kc;

FR_DOUBLE zug,dlunv,dlv,xv,yv,xu,yu;

/***********************************************************************
* gedehnte Laenge berechnen
***********************************************************************/
xv= xk[1]+ul[1] - xk[2]-ul[3];
yv= yk[1]+ul[2] - yk[2]-ul[4];

dlv= FR_SQRT( xv * xv + yv * yv );

/***********************************************************************
* unverformte Laenge bestimmen
***********************************************************************/
xu= xk[1]-xk[2];
yu= yk[1]-yk[2];

dlunv= FR_SQRT( xu * xu + yu * yu );

/***********************************************************************
* Spannung berechnen
***********************************************************************/
zug= emode * (dlv/dlunv - 1.);

if(LANG == 1) fprintf(fo3,"\n\nElement # = " P5D "     Typ = Stab in Ebene\
     SIG = " P11E,k,zug);
if(LANG == 2) fprintf(fo3,"\n\nelement # = " P5D "     type = truss in plane\
     SIG = " P11E,k,zug);

gmw[kc]= zug;

return(0);
}

/***********************************************************************
* hier beginnt Function ssta88
***********************************************************************/
int ssta88(FR_INT4 k)
{
extern FILE *fo3;

extern FR_DOUBLEAY gmw;

extern FR_DOUBLE ul[];
extern FR_DOUBLE xk[],yk[],zk[];

extern FR_DOUBLE emode;

extern FR_INT4 LANG,kc;

FR_DOUBLE zug,dlunv,dlv,xv,yv,zv,xu,yu,zu;
        
/***********************************************************************
* gedehnte Laenge berechnen
***********************************************************************/
xv= xk[1]+ul[1] - xk[2]-ul[4];
yv= yk[1]+ul[2] - yk[2]-ul[5];
zv= zk[1]+ul[3] - zk[2]-ul[6];

dlv= FR_SQRT( xv * xv + yv * yv + zv * zv);

/***********************************************************************
* unverformte Laenge bestimmen
***********************************************************************/
xu= xk[1]-xk[2];
yu= yk[1]-yk[2];
zu= zk[1]-zk[2];

dlunv= FR_SQRT( xu * xu + yu * yu + zu * zu);

/***********************************************************************
* Spannung berechnen
***********************************************************************/
zug= emode * (dlv/dlunv - 1.);

if(LANG == 1) fprintf(fo3,"\n\nElement # = " P5D "     Typ = Stab im Raum\
     SIG = " P11E,k,zug);
if(LANG == 2) fprintf(fo3,"\n\nelement # = " P5D "     type = truss in space\
     SIG = " P11E,k,zug);

gmw[kc]= zug;

return(0);
}

/***********************************************************************
* hier beginnt Function swel88
***********************************************************************/
int swel88(void)
{
extern FILE *fo3;

extern FR_DOUBLE ul[];
extern FR_DOUBLE xk[];

extern FR_DOUBLE emode,rnuee,qparae;

FR_DOUBLE rlu,rlv,fac,qrlu;
FR_DOUBLE sigxx,tauxx,sigxy1,sigxy2,sigxz1,sigxz2;

/***********************************************************************
* gedehnte Laenge & unverformte Laenge berechnen
***********************************************************************/
rlv= xk[2]+ul[7] - xk[1]-ul[1];
rlu= xk[2]-xk[1];

/***********************************************************************
* Spannungen berechnen
***********************************************************************/
sigxx= emode * (rlv/rlu - 1.);
tauxx= (ul[10] - ul[4])/rlu * emode /(4.*(1.+rnuee))*qparae;

fac= emode * 0.5 * qparae;
qrlu= rlu * rlu;

sigxy1= fac* 2. * (3. * (ul[8] - ul[2]) - 
        rlu * (2. * ul[6] + ul[12]))/qrlu;
sigxy2= sigxy1 + fac * 6. * (2. * (ul[2] - ul[8]) + 
        rlu * (ul[12] + ul[6]))/qrlu;

sigxz1= fac * 2. * (3. *(ul[9] - ul[3]) -
        rlu * (2. * ul[5] + ul[11]))/qrlu;
sigxz2= sigxz1 + fac * 6. * (2. * (ul[3] - ul[9]) +
        rlu * (ul[11] + ul[5]))/qrlu;

fprintf(fo3,NL P11EB P11EB P11EB P11EB P11EB P11E,
sigxx,tauxx,sigxy1,sigxz1,sigxy2,sigxz2);

return(0);
}

/***********************************************************************
* hier beginnt Function sbal88
***********************************************************************/
int sbal88(void)
{      
extern FILE *fo3;

extern FR_DOUBLE ul[];
extern FR_DOUBLE xk[],yk[],zk[];

extern FR_DOUBLE emode,rnuee;
extern FR_DOUBLE eyye,ezze,rite,wte;

FR_DOUBLE c[10];                /* 3 x 3 + 1 */
FR_DOUBLE ulo[13];

FR_DOUBLE rl,rlc,rlv,fac,xu,yu,zu,qrl;
FR_DOUBLE sigxx,tauxx,sigzz1,sigzz2,sigyy1,sigyy2;
        
FR_INT4 j;
        
/***********************************************************************
* die Richtungscosinus bestimmen
***********************************************************************/
xu= xk[2] - xk[1];
yu= yk[2] - yk[1];
zu= zk[2] - zk[1];
rl= FR_SQRT(xu * xu + yu * yu + zu * zu );
qrl = rl * rl;

c[1]= (xk[2]-xk[1])/rl;
c[2]= (yk[2]-yk[1])/rl;
c[3]= (zk[2]-zk[1])/rl;

rlc= FR_SQRT(c[1] * c[1] + c[2] * c[2]);
if(rlc > 1e-12)
  {
  c[4]= -c[2]/rlc;
  c[5]=  c[1]/rlc;
  c[6]=  0.;
  }
else
  {
  c[4]= 0.;
  c[5]= 1.;
  c[6]= 0.;
  }

c[7]= -c[3] * c[5];
c[8]=  c[3] * c[4];
c[9]=  c[1] * c[5] - c[2] * c[4];

/***********************************************************************
* Globale auf lokale Verschiebungen umrechnen
***********************************************************************/
for(j = 1;j <= 3;j++)
  {
  ulo[j]  = c[(j-1)*3+1]*ul[1] +c[(j-1)*3+2]*ul[2] +c[(j-1)*3+3]*ul[3];  
  ulo[j+3]= c[(j-1)*3+1]*ul[4] +c[(j-1)*3+2]*ul[5] +c[(j-1)*3+3]*ul[6]; 
  ulo[j+6]= c[(j-1)*3+1]*ul[7] +c[(j-1)*3+2]*ul[8] +c[(j-1)*3+3]*ul[9];  
  ulo[j+9]= c[(j-1)*3+1]*ul[10]+c[(j-1)*3+2]*ul[11]+c[(j-1)*3+3]*ul[12];  
  }

/***********************************************************************
* Spannungen berechnen
***********************************************************************/
rlv= rl + ulo[7] - ulo[1];

sigxx= emode * (rlv/rl - 1.);
tauxx= (ulo[10] - ulo[4])/rl * emode/(2. * (1. + rnuee)) * rite /wte;

fac= emode * ezze;

sigzz1= fac * 2. * (3. * (ulo[8] - ulo[2]) -
        rl * (2. * ulo[6] + ulo[12]))/qrl;
sigzz2= sigzz1 + fac * 6. * (2. * (ulo[2] - ulo[8]) +
        rl * (ulo[12] + ulo[6]))/qrl;

fac= emode * eyye;

sigyy1= fac * 2. * (3. * (ulo[9] - ulo[3]) +
        rl * (2. * ulo[5] + ulo[11]))/qrl;
sigyy2= sigyy1 + fac * 6. * (2. * (ulo[3] - ulo[9]) -
        rl * (ulo[11] + ulo[5]))/qrl;

fprintf(fo3,NL P11EB P11EB P11EB P11EB P11EB P11E, 
  sigxx,tauxx,sigzz1,sigyy1,sigzz2,sigyy2);

return(0);
}

/***********************************************************************
* hier beginnt Function seba88
***********************************************************************/
int seba88(void)
{
extern FILE *fo3;

extern FR_DOUBLE ul[];
extern FR_DOUBLE xk[],yk[];

extern FR_DOUBLE emode;
extern FR_DOUBLE ezze;

FR_DOUBLE ulo[7];

FR_DOUBLE rl,rlv,fac,ca,sa,xu,yu,qrl;
FR_DOUBLE sigxx,sigzz1,sigzz2;
        
/***********************************************************************
* die Richtungscosinus bestimmen
***********************************************************************/
xu= xk[2] - xk[1];
yu= yk[2] - yk[1];
rl= FR_SQRT(xu * xu + yu * yu );
qrl = rl * rl;

ca= (xk[2]-xk[1])/rl;
sa= (yk[2]-yk[1])/rl;

/***********************************************************************
* Globale auf lokale Verschiebungen umrechnen
***********************************************************************/
ulo[1]=  ca * ul[1] + sa * ul[2];
ulo[2]= -sa * ul[1] + ca * ul[2];
ulo[3]=  ul[3];
ulo[4]=  ca * ul[4] + sa * ul[5];
ulo[5]= -sa * ul[4] + ca * ul[5];
ulo[6]=  ul[6];
        
/***********************************************************************
* Spannungen berechnen
***********************************************************************/     
rlv= rl + ulo[4] - ulo[1];

sigxx= emode * (rlv/rl - 1.);

fac= emode * ezze;

sigzz1= fac * 2. * (3. * (ulo[5] - ulo[2]) -
        rl * (2. * ulo[3] + ulo[6]))/qrl;
sigzz2= sigzz1 + fac * 6. * (2. * (ulo[2] - ulo[5]) +
        rl * (ulo[6] + ulo[3]))/qrl;

fprintf(fo3,NL P11E "                               " P11E\
"       " P11E,sigxx,sigzz1,sigzz2);

return(0);
}