File: mc488n.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 (468 lines) | stat: -rw-r--r-- 15,272 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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
/***********************************************************************
* 
*               *****   ***    ***
*                  *   *   *  *   *
*                 *     ***    ***
*                *     *   *  *   *
*               *****   ***    ***
*
* 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.
***********************************************************************/ 
/***********************************************************************
* mc488n: zweidimensional: Typ 11/12 --> Typ 7/8
* 4.10.2005 Rieg
***********************************************************************/

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

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

/***********************************************************************
* Functions
***********************************************************************/
FR_DOUBLE cphh88(char cmode,FR_INT4 jel);
FR_DOUBLE ihh88(char cmode,FR_DOUBLE xinc,FR_INT4 j,FR_INT4 jmax);
int fc88(FR_DOUBLE r,FR_DOUBLE s);
int wrim88n(FR_INT4,int);
int wlog88n(FR_INT4,int);
 
/***********************************************************************
* hier beginnt Function mc488n
***********************************************************************/
int mc488n(void)
{
extern FILE *fi1,*fwlo;

/*--------------------------------------------------------------------------
* globale Pointer
*-------------------------------------------------------------------------*/
extern FR_DOUBLEAY x;
extern FR_DOUBLEAY y;
extern FR_DOUBLEAY xss;
extern FR_DOUBLEAY yss;
extern FR_DOUBLEAY qparass;
extern FR_DOUBLEAY emodss;
extern FR_DOUBLEAY rnuess;

extern FR_INT4AY koima;
extern FR_INT4AY join; 
extern FR_INT4AY koiss;
extern FR_INT4AY ioffss;
extern FR_INT4AY koffss;
extern FR_INT4AY jel;
extern FR_INT4AY iel;
extern FR_INT4AY ivonss;
extern FR_INT4AY ibisss;
extern FR_INT4AY intoss;
extern FR_INT4AY ivon;
extern FR_INT4AY ibis;

extern FR_CHARAY cjmode;
extern FR_CHARAY cimode;

/*--------------------------------------------------------------------------
* globale Arrays
*-------------------------------------------------------------------------*/
extern FR_DOUBLE h[];

extern FR_INT4 jcssta[];
extern FR_INT4 icssta[];

/*--------------------------------------------------------------------------
* globale Variable
*-------------------------------------------------------------------------*/
extern FR_DOUBLE epsx,epsy;
extern FR_INT4 MAXSE,MAXAN,MAXK,MAXE,MAXNFG,LANG;
extern FR_INT4 ness,negss,ndim,kflag,ibflag,ipflag,iqflag,ifrei,ityp;

/*--------------------------------------------------------------------------
* lokale Arrays
*-------------------------------------------------------------------------*/
FR_INT4 koilo[9];

/*--------------------------------------------------------------------------
* lokale Variable
*-------------------------------------------------------------------------*/
FR_DOUBLE xinc,yinc,r,s,xsp,ysp,x4,y4,xmax,xmin,xist,ymax,ymin,yist;
FR_INT4 index,nkp,ne,nfg,neg,koimax,k,le,je,ie,jmax,imax,iss,isum;
FR_INT4 j,i,m,joffs,icount,macoun,jgerad,igerad,jndex,kk,min,max,n;

/*--------------------------------------------------------------------------
* Start Function
*-------------------------------------------------------------------------*/
wlog88n(0,LOG_SMC488N);
wrim88n(0,TX_BERKOOR);

/*--------------------------------------------------------------------------
* Koordinaten berechnen
*-------------------------------------------------------------------------*/
for(iss = 1;iss <= ness;iss++)
  {        
  wrim88n(iss,TX_SUPERELE);
  
/*----------------------------------------------------------------------
* max. Anzahl Knoten/Elementseite, ioffs & incremente
*---------------------------------------------------------------------*/ 
  jmax= jel[iss]*2+1;
  imax= iel[iss]*2+1;
           
  xinc= cphh88(cjmode[iss],jel[iss]);
  yinc= cphh88(cimode[iss],iel[iss]);

/*----------------------------------------------------------------------
* Offsetvektor berechnen
*---------------------------------------------------------------------*/
  if(iss == 1)
    ioffss[1]= 1;
  else
    ioffss[iss]= ioffss[iss-1] + (jel[iss-1]*2+1)*(iel[iss-1]*2+1);
                    
/*----------------------------------------------------------------------
* Berechnen der Formfunktionen fuer die komplette "Matrix"
* dabei ist a1,1 <=> Knoten 1 des Superelements unten links 
* und a imax,jmax <=> Knoten 3 des Superelements oben rechts
* beginnend bei a1,1 folgt a2,1, a3,1, ..., dann a2,1, a2,2 ..
*---------------------------------------------------------------------*/
  n= 0;
  for(j = 1;j <= jmax;j++)
    {
    r= ihh88(cjmode[iss],xinc,j,jmax);

    for(i = 1;i <= imax;i++)
      {
      n++;
      s= ihh88(cimode[iss],yinc,i,imax);

      /* formfunktionen berechnen */

      fc88(r,s);

      /* echte Koordinaten aus nat. Koordinaten & Formfunktionen */

      xsp= 0.;
      ysp= 0.;

      for(m = 1;m <= 12;m++)
        {
        index= koiss[koffss[iss]+m-1];
        xsp= xsp + h[m] * xss[index];
        ysp= ysp + h[m] * yss[index];
        }

      /* in "Matrix" x und y speichern */

      index= (ioffss[iss]-1) + i+imax*(j-1);

      if(index > MAXSE) 
        {
        wlog88n(0,LOG_TOBIG1);
        fclose(fwlo);
        return(AL_TOBIG1);
        }

      x[index]= xsp;
      y[index]= ysp;
      }
    }
  } 

/***********************************************************************
* Koinzidenzvektor koima fuer die Superelemente aufstellen
***********************************************************************/
wrim88n(0,TX_BERKOIN);
wlog88n(0,LOG_BERKOIN);

icount= 0;
macoun= 0;
for(iss = 1;iss <= ness;iss++)                        /* 890 */
  {
  wrim88n(iss,TX_SUPERELE);
  jmax= jel[iss]*2 + 1;
  imax= iel[iss]*2 + 1;
  joffs= MAXAN*(iss-1);
          
  if(iss == 1) 
    {
/*----------------------------------------------------------------------
*   1.Element braucht Sonderbehandlung
*---------------------------------------------------------------------*/
    for(j = 1;j <= jmax;j++)
      {
      jgerad= j+1-((j+1)/2)*2;
      for(i = 1;i <= imax;i++)
        {
        icount++;
        igerad= i+1-((i+1)/2)*2;
        if(!(jgerad == 1 && igerad == 1)) 
          {
/*======================================================================
*         nur wenn i und j nicht gleichzeitig gerade sind, dann. 
*=====================================================================*/
          macoun++;
          koima[icount]= macoun;
          }
        else
          {
/*======================================================================
*         totes element
*=====================================================================*/
          koima[icount]= 0;
          }  
        }
      }
    }              /* endif Sonderbehandlung 1. Element */
  else
    {
/*-----------------------------------------------------------------------
*   Superelement 2 bis Ende
*---------------------------------------------------------------------*/
    for(j = 1;j <= jmax;j++)                          /* 880 */
      {
      jgerad= j+1 -((j+1)/2)*2;
      for(i = 1;i <= imax;i++)                        /* 870 */
        {
        icount++;
        igerad= i+1 -((i+1)/2)*2;
        if(!(jgerad == 1 && igerad == 1))             /* if */
          {
/*======================================================================
*         nur wenn i und j nicht gleichzeitig gerade sind, dann. 
*=====================================================================*/
          for(kk = 1;kk <= MAXAN;kk++)                /* 860 */
            {
/*......................................................................
*           Schleife ueber die Nachbar-Superelemente
*.....................................................................*/ 
            jndex= join[joffs+kk];
            if(jndex > 0 && jndex < iss)              /* if */
              {
              /* nur wenn Nachbar > 0 und < als aktuelles Superele */     
              min= ioffss[jndex];
              max= ioffss[jndex+1] -1;

              for(index = min;index <= max;index++)   /* 850 */  
                {
                xmax= x[index] + epsx;
                xmin= x[index] - epsx;
                ymax= y[index] + epsy;
                ymin= y[index] - epsy;
                xist= x[icount];
                yist= y[icount];
                if(xist >= xmin && xist <= xmax &&
                   yist >= ymin && yist <= ymax)
                  {                                   /* if */
                  /* alten Knoten gefunden,dessen Index zuweisen */
                  koima[icount]= koima[index];
                  goto L870;
                  }                                   /* end if */
                }                                     /* e 850 */
              }                                       /* end if */
            }                                         /* e 860 */
          /* neuer Knoten; macoun incrementieren */
          macoun++;
          koima[icount]= macoun;
          }                                           /* end if */
        else
          {                                           /* if */
/*======================================================================
*         toter Knoten
*=====================================================================*/
          koima[icount]= 0;
          }                                           /* end if */
        L870:;
        }                                             /* e 870 */
      }                                               /* e 880 */ 
    }                                                 /* end if */
  }                                                   /* e 890 */
/*----------------------------------------------------------------------
* ende if <1.Element> oder <2.bis letztes Element>
*---------------------------------------------------------------------*/

/***********************************************************************
* Beschreiben von Z88I1.TXT
***********************************************************************/
/*----------------------------------------------------------------------
* 1.Zeile
*---------------------------------------------------------------------*/
wrim88n(0,TX_WRII1);
wlog88n(0,LOG_WRII1);

nkp= macoun;

ne= 0;
for(i = 1;i <= ness;i++)
  {
  ne= ne + jel[i]*iel[i];
  }

nfg= 2*nkp;
neg= negss;
        
if(LANG == 1) fprintf(fi1,
" %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld  \
Z88I1.TXT, erzeugt von Z88N V12.0\n",
ndim,nkp,ne,nfg,neg,kflag,ibflag,ipflag,iqflag);
if(LANG == 2) fprintf(fi1,
" %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld  \
Z88I1.TXT, computed by Z88N V12.0\n",
ndim,nkp,ne,nfg,neg,kflag,ibflag,ipflag,iqflag);

/*----------------------------------------------------------------------
* Koordinaten
*---------------------------------------------------------------------*/
koimax= 1;

for(i = 1;i <= icount;i++)
  {
  if(i == 1)
    {
    if(FR_FABS(x[1]) < 1e-21)
      x4= 0.;
    else
      x4= x[1];
    if(FR_FABS(y[1]) < 1e-21)
      y4= 0.;
    else
      y4= y[1];
    if(LANG == 1) fprintf(fi1,
    " %5ld %2ld  %+#13.5lE  %+#13.5lE   Knoten Nr.%ld\n",
    koimax,ifrei,x4,y4,koimax);
    if(LANG == 2) fprintf(fi1,
    " %5ld %2ld  %+#13.5lE  %+#13.5lE   node no.%ld\n",
    koimax,ifrei,x4,y4,koimax);
    }
  else
    {
    if(koima[i] > koimax)
      {
      koimax= koima[i];
      if(FR_FABS(x[i]) < 1e-21)
        x4= 0.;
      else
        x4= x[i];
      if(FR_FABS(y[i]) < 1e-21)
        y4= 0.;
      else
        y4= y[i];
      if(LANG == 1) fprintf(fi1,
      " %5ld %2ld  %+#13.5lE  %+#13.5lE   Knoten Nr.%ld\n",
      koimax,ifrei,x4,y4,koimax);
      if(LANG == 2) fprintf(fi1,
      " %5ld %2ld  %+#13.5lE  %+#13.5lE   node no.%ld\n",
      koimax,ifrei,x4,y4,koimax);
      }
    }
  }
              
/*-----------------------------------------------------------------------
* Elementdaten & Koinzidenzliste
*---------------------------------------------------------------------*/
k= 0;
        
for(iss = 1;iss <= ness;iss++)
  {
  jmax= jel[iss]*2+1;
  imax= iel[iss]*2+1;

  for(je = 1;je <= jel[iss];je++)
    {
    for(ie = 1;ie <= iel[iss];ie++)
      {
      k++;
      for(le = 1;le <= 8;le++)
        {
        j= jcssta[le] + 2*(je-1);
        i= icssta[le] + 2*(ie-1);
        index= (ioffss[iss]-1) + i+imax*(j-1);
        koilo[le]= koima[index];
        }

        if(LANG == 1) fprintf(fi1," %5ld %5ld   Element Nr.%ld\n",k,ityp,k);
        if(LANG == 2) fprintf(fi1," %5ld %5ld   element no.%ld\n",k,ityp,k);
        fprintf(fi1," %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld\n",
        koilo[1],koilo[2],koilo[3],koilo[4],
        koilo[5],koilo[6],koilo[7],koilo[8]);
      }
    }
  }
    
/*-----------------------------------------------------------------------
* Elastizitaetsgesetze 
*---------------------------------------------------------------------*/
for(i = 1;i <= negss;i++)
  {
  if(i == 1)
    {
    ivon[1]= 1;
    isum= 0;
    for(k = ivonss[1]; k <= ibisss[1];k++)
      isum= isum+jel[k]*iel[k];
    ibis[1]= isum;
    }
  else
    {   
    ivon[i]= ibis[i-1]+1;
    isum= 0;
    for(k = ivonss[i]; k <= ibisss[i];k++)
      isum= isum+jel[k]*iel[k];
    ibis[i]= isum + ibis[i-1]; 
    }

  fprintf(fi1," %5ld %5ld %+#13.5lE %+#13.5lE %5ld %+#13.5lE\n",
  ivon[i],ibis[i],emodss[i],rnuess[i],intoss[i],qparass[i]);
  }

/*-----------------------------------------------------------------------
* Testen gegen Grenzen 
*---------------------------------------------------------------------*/
if(nkp > MAXK || ne > MAXE || nfg > MAXNFG)
  {
  wlog88n(0,LOG_FEEXID);
  fclose(fwlo);
  return(AL_FEEXID);
  }

/*-----------------------------------------------------------------------
* normales Ende
*---------------------------------------------------------------------*/
fclose(fwlo);
fclose(fi1);
return(0);
}