## root/src/frdvector.c

/* [<][>][^][v][top][bottom][index][help] */

## DEFINITIONS

This source file includes following definitions.
```   1 /*     CalculiX - A 3-dimensional finite element program                 */
2 /*              Copyright (C) 1998-2015 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    */
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 "CalculiX.h"
23
24 void frdvector(double *v,ITG *iset,ITG *ntrans,char * filabl,ITG *nkcoords,
25                ITG *inum,char *m1,ITG *inotr,double *trab,double *co,
26                ITG *istartset,ITG *iendset,ITG *ialset,ITG *mi,ITG *ngraph,
27                FILE *f1,char *output,char *m3){
28
29   ITG i,k,l,m,nksegment;
30
31   int iw;
32
33   float ifl;
34
35   double a[9];
36
37   if(*iset==0){
38     if((*ntrans==0)||(strcmp1(&filabl[5],"G")==0)){
39       for(i=0;i<*nkcoords;i++){
40         if(inum[i]<=0) continue;
41         if(strcmp1(output,"asc")==0){
42           fprintf(f1,"%3s%10" ITGFORMAT "%12.5E%12.5E%12.5E\n",m1,i+1,
43                   (float)v[(mi[1]+1)*i+1],
44                   (float)v[(mi[1]+1)*i+2],(float)v[(mi[1]+1)*i+3]);
45         }else{
46           iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
47           ifl=(float)v[(mi[1]+1)*i+1];fwrite(&ifl,sizeof(float),1,f1);
48           ifl=(float)v[(mi[1]+1)*i+2];fwrite(&ifl,sizeof(float),1,f1);
49           ifl=(float)v[(mi[1]+1)*i+3];fwrite(&ifl,sizeof(float),1,f1);
50         }
51       }
52     }else{
53       for(i=0;i<*nkcoords;i++){
54         if(inum[i]<=0) continue;
55         if(inotr[2*i]==0){
56           if(strcmp1(output,"asc")==0){
57             fprintf(f1,"%3s%10" ITGFORMAT "%12.5E%12.5E%12.5E\n",m1,i+1,
58                     (float)v[(mi[1]+1)*i+1],
59                     (float)v[(mi[1]+1)*i+2],(float)v[(mi[1]+1)*i+3]);
60           }else{
61             iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
62             ifl=(float)v[(mi[1]+1)*i+1];fwrite(&ifl,sizeof(float),1,f1);
63             ifl=(float)v[(mi[1]+1)*i+2];fwrite(&ifl,sizeof(float),1,f1);
64             ifl=(float)v[(mi[1]+1)*i+3];fwrite(&ifl,sizeof(float),1,f1);
65           }
66         }else{
67           FORTRAN(transformatrix,(&trab[7*(inotr[2*i]-1)],&co[3*i],a));
68           if(strcmp1(output,"asc")==0){
69             fprintf(f1,"%3s%10" ITGFORMAT "%12.5E%12.5E%12.5E\n",m1,i+1,
70                     (float)(v[(mi[1]+1)*i+1]*a[0]+v[(mi[1]+1)*i+2]*a[1]+v[(mi[1]+1)*i+3]*a[2]),
71                     (float)(v[(mi[1]+1)*i+1]*a[3]+v[(mi[1]+1)*i+2]*a[4]+v[(mi[1]+1)*i+3]*a[5]),
72                     (float)(v[(mi[1]+1)*i+1]*a[6]+v[(mi[1]+1)*i+2]*a[7]+v[(mi[1]+1)*i+3]*a[8]));
73           }else{
74             iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
75             ifl=(float)v[(mi[1]+1)*i+1]*a[0]+v[(mi[1]+1)*i+2]*a[1]+v[(mi[1]+1)*i+3]*a[2];
76             fwrite(&ifl,sizeof(float),1,f1);
77             ifl=(float)v[(mi[1]+1)*i+1]*a[3]+v[(mi[1]+1)*i+2]*a[4]+v[(mi[1]+1)*i+3]*a[5];
78             fwrite(&ifl,sizeof(float),1,f1);
79             ifl=(float)v[(mi[1]+1)*i+1]*a[6]+v[(mi[1]+1)*i+2]*a[7]+v[(mi[1]+1)*i+3]*a[8];
80             fwrite(&ifl,sizeof(float),1,f1);
81           }
82         }
83       }
84     }
85   }else{
86     nksegment=(*nkcoords)/(*ngraph);
87     for(k=istartset[*iset-1]-1;k<iendset[*iset-1];k++){
88       if(ialset[k]>0){
89         for(l=0;l<*ngraph;l++){
90           i=ialset[k]+l*nksegment-1;
91           if(inum[i]<=0) continue;
92           if((*ntrans==0)||(strcmp1(&filabl[5],"G")==0)||(inotr[2*i]==0)){
93               if(strcmp1(output,"asc")==0){
94                   fprintf(f1,"%3s%10" ITGFORMAT "%12.5E%12.5E%12.5E\n",m1,i+1,(float)v[(mi[1]+1)*i+1],
95                           (float)v[(mi[1]+1)*i+2],(float)v[(mi[1]+1)*i+3]);
96               }else{
97                   iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
98                   ifl=(float)v[(mi[1]+1)*i+1];fwrite(&ifl,sizeof(float),1,f1);
99                   ifl=(float)v[(mi[1]+1)*i+2];fwrite(&ifl,sizeof(float),1,f1);
100                   ifl=(float)v[(mi[1]+1)*i+3];fwrite(&ifl,sizeof(float),1,f1);
101               }
102           }else{
103               FORTRAN(transformatrix,(&trab[7*(inotr[2*i]-1)],&co[3*i],a));
104               if(strcmp1(output,"asc")==0){
105                   fprintf(f1,"%3s%10" ITGFORMAT "%12.5E%12.5E%12.5E\n",m1,i+1,
106                           (float)(v[(mi[1]+1)*i+1]*a[0]+v[(mi[1]+1)*i+2]*a[1]+v[(mi[1]+1)*i+3]*a[2]),
107                           (float)(v[(mi[1]+1)*i+1]*a[3]+v[(mi[1]+1)*i+2]*a[4]+v[(mi[1]+1)*i+3]*a[5]),
108                           (float)(v[(mi[1]+1)*i+1]*a[6]+v[(mi[1]+1)*i+2]*a[7]+v[(mi[1]+1)*i+3]*a[8]));
109               }else{
110                   iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
111                   ifl=(float)v[(mi[1]+1)*i+1]*a[0]+v[(mi[1]+1)*i+2]*a[1]+v[(mi[1]+1)*i+3]*a[2];
112                   fwrite(&ifl,sizeof(float),1,f1);
113                   ifl=(float)v[(mi[1]+1)*i+1]*a[3]+v[(mi[1]+1)*i+2]*a[4]+v[(mi[1]+1)*i+3]*a[5];
114                   fwrite(&ifl,sizeof(float),1,f1);
115                   ifl=(float)v[(mi[1]+1)*i+1]*a[6]+v[(mi[1]+1)*i+2]*a[7]+v[(mi[1]+1)*i+3]*a[8];
116                   fwrite(&ifl,sizeof(float),1,f1);
117               }
118           }
119         }
120       }else{
121         l=ialset[k-2];
122         do{
123           l-=ialset[k];
124           if(l>=ialset[k-1]) break;
125           for(m=0;m<*ngraph;m++){
126             i=l+m*nksegment-1;
127             if(inum[i]<=0) continue;
128             if((*ntrans==0)||(strcmp1(&filabl[5],"G")==0)||(inotr[2*i]==0)){
129                 if(strcmp1(output,"asc")==0){
130                     fprintf(f1,"%3s%10" ITGFORMAT "%12.5E%12.5E%12.5E\n",m1,i+1,(float)v[(mi[1]+1)*i+1],
131                             (float)v[(mi[1]+1)*i+2],(float)v[(mi[1]+1)*i+3]);
132                 }else{
133                     iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
134                     ifl=(float)v[(mi[1]+1)*i+1];fwrite(&ifl,sizeof(float),1,f1);
135                     ifl=(float)v[(mi[1]+1)*i+2];fwrite(&ifl,sizeof(float),1,f1);
136                     ifl=(float)v[(mi[1]+1)*i+3];fwrite(&ifl,sizeof(float),1,f1);
137                 }
138             }else{
139               FORTRAN(transformatrix,(&trab[7*(inotr[2*i]-1)],&co[3*i],a));
140               if(strcmp1(output,"asc")==0){
141                   fprintf(f1,"%3s%10" ITGFORMAT "%12.5E%12.5E%12.5E\n",m1,i+1,
142                           (float)(v[(mi[1]+1)*i+1]*a[0]+v[(mi[1]+1)*i+2]*a[1]+
143                                   v[(mi[1]+1)*i+3]*a[2]),
144                           (float)(v[(mi[1]+1)*i+1]*a[3]+v[(mi[1]+1)*i+2]*a[4]+
145                                   v[(mi[1]+1)*i+3]*a[5]),
146                           (float)(v[(mi[1]+1)*i+1]*a[6]+v[(mi[1]+1)*i+2]*a[7]+
147                                   v[(mi[1]+1)*i+3]*a[8]));
148               }else{
149                   iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
150                   ifl=(float)v[(mi[1]+1)*i+1]*a[0]+v[(mi[1]+1)*i+2]*a[1]+v[(mi[1]+1)*i+3]*a[2];
151                   fwrite(&ifl,sizeof(float),1,f1);
152                   ifl=(float)v[(mi[1]+1)*i+1]*a[3]+v[(mi[1]+1)*i+2]*a[4]+v[(mi[1]+1)*i+3]*a[5];
153                   fwrite(&ifl,sizeof(float),1,f1);
154                   ifl=(float)v[(mi[1]+1)*i+1]*a[6]+v[(mi[1]+1)*i+2]*a[7]+v[(mi[1]+1)*i+3]*a[8];
155                   fwrite(&ifl,sizeof(float),1,f1);
156               }
157             }
158           }
159         }while(1);
160       }
161     }
162   }
163
164   if(strcmp1(output,"asc")==0)fprintf(f1,"%3s\n",m3);
165
166   return;
167
168 }
169
```

/* [<][>][^][v][top][bottom][index][help] */